mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-12 21:28:29 +03:00
Get parsing of manifest and combining with config file working
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import ast
|
||||
import os
|
||||
import copy
|
||||
from os.path import join, dirname
|
||||
from typing import List
|
||||
|
||||
@@ -11,15 +13,18 @@ _DEFAULT_MANIFEST = {
|
||||
'external_dependencies': {},
|
||||
'entry_point': '',
|
||||
'version': '1.0',
|
||||
'config': {}
|
||||
}
|
||||
|
||||
def load_manifest(self, module):
|
||||
def load_manifest(module):
|
||||
# load the manifest file
|
||||
manifest = copy.deepcopy(_DEFAULT_MANIFEST)
|
||||
|
||||
with open(join(module, MANIFEST_FILE)) as f:
|
||||
manifest = f.read()
|
||||
manifest.update(ast.literal_eval(f.read()))
|
||||
return manifest
|
||||
|
||||
def available_modules(self, additional_paths: List[str] = []) -> List[dict]:
|
||||
def available_modules(additional_paths: List[str] = [], with_manifest: bool=False) -> List[dict]:
|
||||
# search through all valid 'modules' paths. Default is 'modules' in the current directory
|
||||
|
||||
# see odoo/modules/module.py -> get_modules
|
||||
@@ -32,11 +37,15 @@ def available_modules(self, additional_paths: List[str] = []) -> List[dict]:
|
||||
|
||||
for module_folder in default_path + additional_paths:
|
||||
# walk through each module in module_folder and check if it has a valid manifest
|
||||
for folder in os.listdir(module_folder):
|
||||
possible_module = join(module_folder, folder)
|
||||
if not is_really_module(possible_module):
|
||||
for possible_module in os.listdir(module_folder):
|
||||
possible_module_path = join(module_folder, possible_module)
|
||||
if not is_really_module(possible_module_path):
|
||||
continue
|
||||
# parse manifest and add to list of available modules
|
||||
all_modules.append(possible_module)
|
||||
if with_manifest:
|
||||
manifest = load_manifest(possible_module_path)
|
||||
else:
|
||||
manifest = {}
|
||||
all_modules.append((possible_module, possible_module_path, manifest))
|
||||
|
||||
return all_modules
|
||||
Reference in New Issue
Block a user