From aa3155ff409a04a8349460fc72c07fca8ba4e92d Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Tue, 13 Nov 2018 20:24:49 +0000 Subject: [PATCH] notes provider --- notes/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 notes/__init__.py diff --git a/notes/__init__.py b/notes/__init__.py new file mode 100644 index 0000000..91ef5bc --- /dev/null +++ b/notes/__init__.py @@ -0,0 +1,26 @@ +from glob import glob +from typing import List + +from porg import Org # typing: ignore + +# TODO move to porg? +class PorgAll: + def __init__(self, paths: List[str]) -> None: + self.paths = paths + + def query_all(self, query): + res = [] + for p in self.paths: + ofiles = glob(p + '/**/*.org', recursive=True) + for of in ofiles: + org = Org.from_file(of) + res.extend(query(org)) + return res + + +def get_notes(): + ORG_PATHS = [ + '***REMOVED***', + '***REMOVED***', + ] + return PorgAll(ORG_PATHS)