diff options
author | Joris | 2023-09-17 12:23:47 +0200 |
---|---|---|
committer | Joris | 2023-09-17 12:23:47 +0200 |
commit | 1ebc55c72a1a17293bbf4ad86e0177a10a794750 (patch) | |
tree | 5fce0ea3a011ccbae85b0d3927f8ac33099585fb /cli/library | |
parent | c236facb4d4c277773c83f1a4ee85b48833d7e67 (diff) |
Make app packageable
Diffstat (limited to 'cli/library')
-rw-r--r-- | cli/library/__init__.py | 0 | ||||
-rw-r--r-- | cli/library/command.py | 21 |
2 files changed, 21 insertions, 0 deletions
diff --git a/cli/library/__init__.py b/cli/library/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/cli/library/__init__.py diff --git a/cli/library/command.py b/cli/library/command.py new file mode 100644 index 0000000..1c4d20c --- /dev/null +++ b/cli/library/command.py @@ -0,0 +1,21 @@ +import glob +import json +import os +import tomllib + +def run(books_library): + print(get(books_library)) + +def get(books_library): + metadatas = [] + + for path in glob.glob(f'{books_library}/**/metadata.toml', recursive=True): + with open(path, 'rb') as f: + directory = os.path.dirname(os.path.realpath(path)) + metadata = tomllib.load(f) + for p in glob.glob(f'{directory}/cover.*'): + metadata['cover'] = p + break + metadatas.append(metadata) + + return json.dumps(metadatas) |