diff --git a/kodi_addon_checker/addons/Addon.py b/kodi_addon_checker/addons/Addon.py index 1627c23..83de962 100644 --- a/kodi_addon_checker/addons/Addon.py +++ b/kodi_addon_checker/addons/Addon.py @@ -12,6 +12,8 @@ class Addon(): + """Gather all the dependencies of an addon + """ def __init__(self, addon_xml: ET.Element): super().__init__() self.id = addon_xml.get('id') @@ -21,9 +23,19 @@ def __init__(self, addon_xml: ET.Element): self.dependencies.append(AddonDependency(dependency)) def __eq__(self, other): + """Check if the addon and it's version is equivalent or not. + + This compares instances of two addons + """ return self.id == other.id and self.version == other.version def dependsOn(self, addonId): + """Check if addon is dependent on any other addon. + + Arguments: + addonId {str} -- Id of addon whose dependencies + are to be looked + """ for dependency in self.dependencies: if dependency.id == addonId: return True diff --git a/kodi_addon_checker/addons/AddonDependency.py b/kodi_addon_checker/addons/AddonDependency.py index 196d09b..ca3245d 100644 --- a/kodi_addon_checker/addons/AddonDependency.py +++ b/kodi_addon_checker/addons/AddonDependency.py @@ -10,6 +10,8 @@ from ..versions import AddonVersion class AddonDependency(): + """Get the minimum version of the dependency of an addon + """ def __init__(self, import_xml: ET.Element): super().__init__() self.id = import_xml.get('addon') diff --git a/kodi_addon_checker/addons/Repository.py b/kodi_addon_checker/addons/Repository.py index 5ba1813..daf8089 100644 --- a/kodi_addon_checker/addons/Repository.py +++ b/kodi_addon_checker/addons/Repository.py @@ -17,6 +17,8 @@ class Repository(): + """Get information of all the addons + """ def __init__(self, version, path): super().__init__() self.version = version @@ -40,12 +42,23 @@ def __init__(self, version, path): self.addons.append(Addon(addon)) def __contains__(self, addonId): + """Check if addon is present in the list or not + + Arguments: + addonId {str} -- Id of addon that is to be looked for + """ for addon in self.addons: if addon.id == addonId: return True return False def find(self, addonId): + """If the addon exists in the list then return it + + Arguments: + addonId {str} -- Id of addon that is to be looked for + """ + # multiple copies of the same addon might exist on the repository, however # kodi always uses the highest version available addon_instances = [] @@ -61,6 +74,12 @@ def find(self, addonId): return addon_instances[0] def rdepends(self, addonId): + """Check if addon is dependent on any other addon. + + Arguments: + addonId {str} -- Id of addon whose dependencies + are to be looked + """ rdepends = [] for addon in self.addons: if addon.dependsOn(addonId): diff --git a/kodi_addon_checker/check_py3_compatibility.py b/kodi_addon_checker/check_py3_compatibility.py index 6ece348..809b989 100644 --- a/kodi_addon_checker/check_py3_compatibility.py +++ b/kodi_addon_checker/check_py3_compatibility.py @@ -16,6 +16,11 @@ class KodiRefactoringTool(refactor.RefactoringTool): + """Report possible refactoring error detected by lib2to3 + + Extends: + refactor.RefactoringTool + """ def __init__(self, report, log_level, *args, **kwargs): self.report = report diff --git a/kodi_addon_checker/config.py b/kodi_addon_checker/config.py index 50a5a04..02759c4 100644 --- a/kodi_addon_checker/config.py +++ b/kodi_addon_checker/config.py @@ -14,9 +14,10 @@ class Config(): + """Create Config object using .tests-config.json and command line arguments. + """ def __init__(self, repo_path, cmd_args=None): """ - Create Config object using .tests-config.json and command line arguments. :param repo_path: the repo path which contains .tests-config.json. :param cmd_args: argparse object """ @@ -24,6 +25,11 @@ def __init__(self, repo_path, cmd_args=None): self._load_config(repo_path) def _load_config(self, repo_path): + """Load the config file + + Arguments: + repo_path {str} -- the repo path which contains .tests-config.json. + """ if repo_path is None: return config_path = os.path.join(repo_path, '.tests-config.json') @@ -37,6 +43,9 @@ def _load_config(self, repo_path): self.configs = file_config def is_enabled(self, value): + """Check if the certain value in the + config file is enabled or not + """ return self.configs.get(value, False) def __getitem__(self, item): @@ -44,14 +53,20 @@ def __getitem__(self, item): class ConfigManager(): + """Manages Config file + """ configurations = {} @classmethod def register(cls, config, description, default_value, action): + """registers all the config + """ cls.configurations[config] = [description, default_value, action] @classmethod def fill_cmd_args(cls, parser: ArgumentParser): + """Add an argument for the reporter + """ # Add --reporter parser.add_argument("--reporter", action="append", choices=list(ReportManager.reporters.keys()), help="""enable a reporter with the given name. @@ -59,6 +74,8 @@ def fill_cmd_args(cls, parser: ArgumentParser): @classmethod def process_config(cls, config): + """Get the reporters + """ reporters = config["reporter"] if reporters is not None: # To disable all, pass empty array in .tests-config.json diff --git a/kodi_addon_checker/logger.py b/kodi_addon_checker/logger.py index 047774a..a02c8de 100644 --- a/kodi_addon_checker/logger.py +++ b/kodi_addon_checker/logger.py @@ -11,6 +11,8 @@ class Logger: + """Logger class the provokes the create_logger function. + """ @staticmethod def create_logger(debug_filename, logger_name, enabled=False): diff --git a/kodi_addon_checker/plugins/array_reporter.py b/kodi_addon_checker/plugins/array_reporter.py index 5986c6c..0141a6c 100644 --- a/kodi_addon_checker/plugins/array_reporter.py +++ b/kodi_addon_checker/plugins/array_reporter.py @@ -12,6 +12,11 @@ @reporter(name="array", enabled=False) class ArrayReporter(Reporter): + """Setup array report for Reporter class + + Extends: + Reporter + """ def __init__(self): self.reports = [] diff --git a/kodi_addon_checker/plugins/log_reporter.py b/kodi_addon_checker/plugins/log_reporter.py index 37155b0..342c02c 100644 --- a/kodi_addon_checker/plugins/log_reporter.py +++ b/kodi_addon_checker/plugins/log_reporter.py @@ -15,6 +15,11 @@ @reporter(name="log", enabled=False) class LogReporter(Reporter): + """Report logs to the log file + + Extends: + Reporter + """ def __init__(self): self.logger = None diff --git a/kodi_addon_checker/record.py b/kodi_addon_checker/record.py index fb8696c..d826e7f 100644 --- a/kodi_addon_checker/record.py +++ b/kodi_addon_checker/record.py @@ -12,9 +12,10 @@ class Record(): + """Create a record which is the low level entry in Report to represent logs. + """ def __init__(self, log_level, message): """ - Create a record which is the low level entry in Report to represent logs. :param log_level: "ERROR", "WARN" or "INFO" :param message: the actual log message """ diff --git a/kodi_addon_checker/report.py b/kodi_addon_checker/report.py index d3dabcf..2bed373 100644 --- a/kodi_addon_checker/report.py +++ b/kodi_addon_checker/report.py @@ -11,11 +11,9 @@ class Report(): + """Create a new report for the given artifact. The artifact can be a repo, add-on or file. + """ def __init__(self, artifact_name): - """ - Create a new report for the given artifact. The artifact can be a repo, add-on or file. - :param artifact_name: the artifact name - """ self.artifact_name = artifact_name self.problem_count = 0 self.warning_count = 0 diff --git a/kodi_addon_checker/reporter.py b/kodi_addon_checker/reporter.py index dc079a5..76386b5 100644 --- a/kodi_addon_checker/reporter.py +++ b/kodi_addon_checker/reporter.py @@ -17,10 +17,14 @@ def report(self, report): class ReportManager(): + """Manage all the reporters + """ reporters = {} @classmethod def register(cls, reporter_clazz: Reporter, name, enabled): + """Register the reporters + """ cls.reporters[name] = [reporter_clazz(), enabled] @classmethod @@ -35,10 +39,14 @@ def enable(cls, names): @classmethod def getEnabledReporters(cls): + """Get all the reporters that are enabled + """ return [reporter[0] for reporter in cls.reporters.values() if reporter[1]] def reporter(name, enabled=False): + """Report all the enabled reporters to ReportManager + """ def _reporter(clazz): if inspect.isclass(clazz): if not hasattr(clazz, "report") or len(inspect.signature(getattr(clazz, "report")).parameters.items()) != 2: diff --git a/kodi_addon_checker/schema_validation.py b/kodi_addon_checker/schema_validation.py index f8fb392..f0fcbf7 100644 --- a/kodi_addon_checker/schema_validation.py +++ b/kodi_addon_checker/schema_validation.py @@ -126,6 +126,18 @@ def _validate(xml, schemapath): def check_version(branch_name, schema_file): + """Check whether the schema files for the specific + branch exists or not and if not then return the + highest available variant of the schema file or None + + Arguments: + branch_name {str} -- Name of the branch the schema + is being validated of + schema_file {str} -- Schema file to look for. + + Returns: + [str] -- full path to the schema file. + """ all_branches = ValidKodiVersions[::-1] branches = all_branches[all_branches.index(branch_name)::1] for branch in branches: