some adjustments to notes provider
This commit is contained in:
parent
aa3155ff40
commit
6679aae475
1 changed files with 27 additions and 7 deletions
|
@ -3,24 +3,44 @@ from typing import List
|
||||||
|
|
||||||
from porg import Org # typing: ignore
|
from porg import Org # typing: ignore
|
||||||
|
|
||||||
|
# TODO enc stuff?
|
||||||
|
def get_org_paths():
|
||||||
|
return [
|
||||||
|
'***REMOVED***',
|
||||||
|
'***REMOVED***',
|
||||||
|
]
|
||||||
|
|
||||||
|
def _get_org_files_in(path, archived: bool=False) -> List[str]:
|
||||||
|
res = []
|
||||||
|
res.extend(glob(path + '/**/*.org', recursive=True))
|
||||||
|
if archived:
|
||||||
|
res.extend(glob(path + '/**/*.org_archive', recursive=True))
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def get_org_files(archived: bool = False) -> List[str]:
|
||||||
|
res = []
|
||||||
|
for p in get_org_paths():
|
||||||
|
res.extend(_get_org_files_in(p, archived=archived))
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
# TODO move to porg?
|
# TODO move to porg?
|
||||||
class PorgAll:
|
class PorgAll:
|
||||||
def __init__(self, paths: List[str]) -> None:
|
def __init__(self, paths: List[str]) -> None:
|
||||||
self.paths = paths
|
self.paths = paths
|
||||||
|
|
||||||
|
def get_all(self):
|
||||||
|
return self.query_all(lambda x: x.xpath_all('//*'))
|
||||||
|
|
||||||
def query_all(self, query):
|
def query_all(self, query):
|
||||||
res = []
|
res = []
|
||||||
for p in self.paths:
|
for p in self.paths:
|
||||||
ofiles = glob(p + '/**/*.org', recursive=True)
|
for of in _get_org_files_in(p):
|
||||||
for of in ofiles:
|
|
||||||
org = Org.from_file(of)
|
org = Org.from_file(of)
|
||||||
res.extend(query(org))
|
res.extend(query(org))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def get_notes():
|
def get_notes():
|
||||||
ORG_PATHS = [
|
return PorgAll(get_org_paths())
|
||||||
'***REMOVED***',
|
|
||||||
'***REMOVED***',
|
|
||||||
]
|
|
||||||
return PorgAll(ORG_PATHS)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue