From 0b78a3966f6c7c4837124bff4ad8746a8bc2385b Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Jun 09 2017 14:32:34 +0000 Subject: WIP: Fix PEP-257 warnings --- diff --git a/kiskadee/__init__.py b/kiskadee/__init__.py index 5d94009..2855e6a 100644 --- a/kiskadee/__init__.py +++ b/kiskadee/__init__.py @@ -1,4 +1,4 @@ -""" Continous static analysis package. +"""Continous static analysis package. kiskadee runs different static analyzers on a set of pre-defined software repositories. When the kiskadee package is loaded, we load all the plugin names diff --git a/kiskadee/analyzers.py b/kiskadee/analyzers.py index c021496..2d64149 100644 --- a/kiskadee/analyzers.py +++ b/kiskadee/analyzers.py @@ -2,10 +2,12 @@ import docker def run(analyzer, sources): - """ Runs a static analyzer on a given package. + """Run a static analyzer on a given package. + `analyzer` is the name of the static analyzer container to run. `sources` is the absolute path for the uncompressed package. Returns - a analysis results.""" + a analysis results. + """ volume = {sources: {'bind': '/src', 'mode': 'ro'}} client = docker.from_env() # FIXME: Since we are using only cppcheck for now, we only want stderr diff --git a/kiskadee/converter.py b/kiskadee/converter.py index dbda64c..515d1c9 100644 --- a/kiskadee/converter.py +++ b/kiskadee/converter.py @@ -5,7 +5,7 @@ import os def to_firehose(bytes_input, analyzer): - """ Parser the analyzer report to Firehose format. + """Parser the analyzer report to Firehose format. :bytes_input: The analyzer report, as a byte string :returns: A xml.etree.ElementTree object, representing the firehose report @@ -34,7 +34,7 @@ def to_firehose(bytes_input, analyzer): def import_analyzer_module(analyzer): - """ Import a firehose parser. + """Import a firehose parser. analyzer: The name of the parser that will be imported :returns: Some firehose parser diff --git a/kiskadee/monitor.py b/kiskadee/monitor.py index ff90248..cd91dfc 100644 --- a/kiskadee/monitor.py +++ b/kiskadee/monitor.py @@ -18,7 +18,7 @@ class Monitor: self.logger = kiskadee.logger def initialize(self): - """ Starts all the threads involved with the monitoring process. + """Start all threads related to the monitoring process. This includes all plugins that queue packages in the packages_queue, and the monitor() method, which retrieves packages from packages_queue, @@ -57,7 +57,7 @@ class Monitor: self._save_or_update_pkg(pkg) def dequeue(self): - """ dequeue packages from packages_queue.""" + """Dequeue packages from packages_queue.""" if not kiskadee.queue.packages_queue.empty(): pkg = kiskadee.queue.dequeue_package() kiskadee.queue.package_done() @@ -138,7 +138,7 @@ def _start(module, joinable=False, timeout=None): def daemon(): - """ Entry point to the monitor module.""" + """Entry point to the monitor module.""" # TODO: improve with start/stop system monitor = Monitor() p = Process(target=monitor.initialize()) diff --git a/kiskadee/plugins/__init__.py b/kiskadee/plugins/__init__.py index 834632f..1ef2aa3 100644 --- a/kiskadee/plugins/__init__.py +++ b/kiskadee/plugins/__init__.py @@ -19,7 +19,8 @@ class Plugin(): `source_data` will be a dictionary previously created by the plugin. `source_data` will have at least two obrigatory keys: `name` and - `version` of the package that have to be downloaded.""" + `version` of the package that have to be downloaded. + """ raise NotImplementedError('get_sources must be defined by plugin') @abc.abstractmethod @@ -28,7 +29,8 @@ class Plugin(): This method will be called as a thread, and will run concurrently with the main kiskadee thread. This method must enqueue packages using the - `@kiskadee.queue.package_enqueuer` decorator.""" + `@kiskadee.queue.package_enqueuer` decorator. + """ raise NotImplementedError('watch must be defined by plugin') @abc.abstractmethod @@ -36,7 +38,8 @@ class Plugin(): """Return *true* if `new` is greater then `old`. `new` and `old` will be the versions of packages monitored by your - plugin.""" + plugin. + """ raise NotImplementedError('compare_versions must be defined by plugin') def analyzers(self): diff --git a/kiskadee/plugins/debian.py b/kiskadee/plugins/debian.py index 4390041..f234030 100644 --- a/kiskadee/plugins/debian.py +++ b/kiskadee/plugins/debian.py @@ -24,10 +24,11 @@ RUNNING = True class Plugin(kiskadee.plugins.Plugin): def watch(self): - """ Start the monitoring process for Debian Repositories. + """Start the monitoring process for Debian Repositories. Each package monitored by the plugin will be - queued using the package_enqueuer decorator. """ + queued using the package_enqueuer decorator. + """ self.logger.info("Starting Debian plugin") while RUNNING: url = self._sources_gz_url() @@ -61,7 +62,7 @@ class Plugin(kiskadee.plugins.Plugin): return False def _source_path(self, path): - """ Return the path to the *.orig.tar.gz.""" + """Return the path to the *.orig.tar.gz.""" files = os.listdir(path) prog = re.compile(".orig.") return [x for x in files if prog.search(x)][0] diff --git a/kiskadee/plugins/example.py b/kiskadee/plugins/example.py index ccdb682..ee34920 100644 --- a/kiskadee/plugins/example.py +++ b/kiskadee/plugins/example.py @@ -9,6 +9,7 @@ class Plugin(kiskadee.plugins.Plugin): @kiskadee.queue.package_enqueuer def watch(self): """There is no proper API to inspect new example versions. + It should not matter, since example will not receive updates. """ example = {} @@ -18,8 +19,9 @@ class Plugin(kiskadee.plugins.Plugin): return example def compare_versions(self, new, old): - """Example has only one version. + """Compare package versions. - This method does not matter here, let's just pass + Example has only one version. This method does not matter here, let's + just pass. """ return 0 diff --git a/kiskadee/plugins/juliet.py b/kiskadee/plugins/juliet.py index abc0b8d..9358a85 100644 --- a/kiskadee/plugins/juliet.py +++ b/kiskadee/plugins/juliet.py @@ -20,6 +20,7 @@ class Plugin(kiskadee.plugins.Plugin): @kiskadee.queue.package_enqueuer def watch(self): """SAMATE does not provide a proper API to inspect new Juliet versions. + It should not matter, since Juliet does not receive updates frequently. """ juliet = {} diff --git a/kiskadee/queue.py b/kiskadee/queue.py index 0a46825..bd04307 100644 --- a/kiskadee/queue.py +++ b/kiskadee/queue.py @@ -33,7 +33,7 @@ def package_done(): def source_enqueuer(func): - """ Decorator to queue return values with enqueue_analysis.""" + """Decorate functions to queue return values with enqueue_analysis.""" def wrapper(*args, **kwargs): source = func(*args, **kwargs) enqueue_analysis(source) @@ -41,7 +41,7 @@ def source_enqueuer(func): def package_enqueuer(func): - """ Decorator to queue return values with enqueue_package.""" + """Decorate functions to queue return values with enqueue_package.""" def wrapper(*args, **kwargs): package = func(*args, **kwargs) enqueue_package(package) diff --git a/kiskadee/runner.py b/kiskadee/runner.py index 5d7c74e..13fbdf9 100644 --- a/kiskadee/runner.py +++ b/kiskadee/runner.py @@ -49,9 +49,9 @@ def runner(): def analyze(package): - """ The package dict is in the queue. + """Run each analyzer on a package. - The keys are: + The package dict is in the queue. The keys are: plugin: the plugin module itself name: the package name version: the package version