diff --git a/omg.py b/omg.py index 4ecf296..7c86a5d 100755 --- a/omg.py +++ b/omg.py @@ -15,12 +15,13 @@ class OMG: (Like the Obsidian-plugin "Metadata Extractor" does.) """ - def __init__(self, path: str | os.PathLike) -> None: + def __init__(self, path: str | os.PathLike, include_hidden: bool=False) -> None: """ Generates metadata for markdown files located at the given path. (Like the Obsidian-plugin "Metadata Extractor" does.) :param PathLike path: The path where the markdown files are located + :param bool include_hidden: If True, hidden folders and files (dotfiles) will also get searched. """ self.path = path @@ -28,6 +29,8 @@ class OMG: if not self.path[-1] == "/": self.path += "/" + self.include_hidden = include_hidden + self.md_files = self._parse_all_files(self.path) def _parse_all_files(self, root: str | os.PathLike, path: str | os.PathLike = None) -> list: @@ -40,6 +43,9 @@ class OMG: if filename in [".git", ".obsidian"]: # exclude .git and .obsidian continue + if filename[0] == "." and not self.include_hidden: + continue + filepath = path + filename if os.path.isdir(filepath):