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
|
||||
|
||||
# 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?
|
||||
class PorgAll:
|
||||
def __init__(self, paths: List[str]) -> None:
|
||||
self.paths = paths
|
||||
|
||||
def get_all(self):
|
||||
return self.query_all(lambda x: x.xpath_all('//*'))
|
||||
|
||||
def query_all(self, query):
|
||||
res = []
|
||||
for p in self.paths:
|
||||
ofiles = glob(p + '/**/*.org', recursive=True)
|
||||
for of in ofiles:
|
||||
for of in _get_org_files_in(p):
|
||||
org = Org.from_file(of)
|
||||
res.extend(query(org))
|
||||
return res
|
||||
|
||||
|
||||
def get_notes():
|
||||
ORG_PATHS = [
|
||||
'***REMOVED***',
|
||||
'***REMOVED***',
|
||||
]
|
||||
return PorgAll(ORG_PATHS)
|
||||
return PorgAll(get_org_paths())
|
||||
|
|
Loading…
Add table
Reference in a new issue