diff --git a/doc/ldif2dot-0.1.py b/doc/ldif2dot-0.1.py index 49baaaa1..f492bebf 100644 --- a/doc/ldif2dot-0.1.py +++ b/doc/ldif2dot-0.1.py @@ -43,7 +43,7 @@ class Element: def __repr__(self): """Returns a basic state dump.""" - return 'Element' + str(self.index) + str(self.attributes) + return "Element" + str(self.index) + str(self.attributes) def add(self, line): """Adds a line of input to the object. @@ -57,10 +57,10 @@ class Element: """ def _valid(line): - return line and not line.startswith('#') + return line and not line.startswith("#") def _interesting(line): - return line != 'objectClass: top' + return line != "objectClass: top" if self.is_valid() and not _valid(line): return True @@ -70,11 +70,11 @@ class Element: def is_valid(self): """Indicates whether a valid entry has been read.""" - return len(self.attributes) != 0 and self.attributes[0].startswith('dn: ') + return len(self.attributes) != 0 and self.attributes[0].startswith("dn: ") def dn(self): """Returns the DN for this entry.""" - if self.attributes[0].startswith('dn: '): + if self.attributes[0].startswith("dn: "): return self.attributes[0][4:] else: return None @@ -86,12 +86,12 @@ class Element: Element objects) and returns a string which declares a DOT edge, or an empty string, if no parent was found. """ - dn_components = self.dn().split(',') + dn_components = self.dn().split(",") for i in range(1, len(dn_components) + 1): - parent = ','.join(dn_components[i:]) + parent = ",".join(dn_components[i:]) if parent in dnmap: - return ' n%d->n%d\n' % (dnmap[parent].index, self.index) - return '' + return " n%d->n%d\n" % (dnmap[parent].index, self.index) + return "" def dot(self, dnmap): """Returns a text representation of the node and perhaps its parent edge. @@ -99,6 +99,7 @@ class Element: Args: - dnmap: dictionary mapping dn names to Element objects """ + def _format(attributes): result = [TITLE_ENTRY_TEMPALTE % attributes[0]] @@ -107,7 +108,12 @@ class Element: return result - return TABLE_TEMPLATE % (self.index, '\n '.join(_format(self.attributes)), self.edge(dnmap)) + return TABLE_TEMPLATE % ( + self.index, + "\n ".join(_format(self.attributes)), + self.edge(dnmap), + ) + class Converter: """An LDIF to DOT converter.""" @@ -144,7 +150,11 @@ class Converter: e = Element() if e.is_valid(): self._append(e) - return (BASE_TEMPLATE % (name, ''.join([e.dot(self.dnmap) for e in self.elements]))) + return BASE_TEMPLATE % ( + name, + "".join([e.dot(self.dnmap) for e in self.elements]), + ) + BASE_TEMPLATE = """\ strict digraph "%s" { @@ -191,13 +201,13 @@ ENTRY_TEMPALTE = """\ """ -if __name__ == '__main__': +if __name__ == "__main__": if len(sys.argv) > 2: - raise 'Expected at most one argument.' + raise "Expected at most one argument." elif len(sys.argv) == 2: name = sys.argv[1] - file = open(sys.argv[1], 'r') + file = open(sys.argv[1], "r") else: - name = '' + name = "" file = sys.stdin print(Converter().parse(file, name)) diff --git a/moulinette/actionsmap.py b/moulinette/actionsmap.py index e5e9547b..6d36b252 100644 --- a/moulinette/actionsmap.py +++ b/moulinette/actionsmap.py @@ -107,7 +107,6 @@ class CommentParameter(_ExtraParameter): class AskParameter(_ExtraParameter): - """ Ask for the argument value if possible and needed. @@ -146,7 +145,6 @@ class AskParameter(_ExtraParameter): class PasswordParameter(AskParameter): - """ Ask for the password argument value if possible and needed. @@ -169,7 +167,6 @@ class PasswordParameter(AskParameter): class PatternParameter(_ExtraParameter): - """ Check if the argument value match a pattern. @@ -222,7 +219,6 @@ class PatternParameter(_ExtraParameter): class RequiredParameter(_ExtraParameter): - """ Check if a required argument is defined or not. @@ -262,7 +258,6 @@ extraparameters_list = [ class ExtraArgumentParser: - """ Argument validator and parser for the extra parameters. @@ -374,7 +369,6 @@ class ExtraArgumentParser: class ActionsMap: - """Validate and process actions defined into an actions map The actions map defines the features - and their usage - of an diff --git a/moulinette/authentication.py b/moulinette/authentication.py index bf2f76a3..40fdcbb0 100644 --- a/moulinette/authentication.py +++ b/moulinette/authentication.py @@ -11,7 +11,6 @@ logger = logging.getLogger("moulinette.authenticator") class BaseAuthenticator: - """Authenticator base representation Each authenticators must implement an Authenticator class derived diff --git a/moulinette/core.py b/moulinette/core.py index e83f716b..e5370c2c 100644 --- a/moulinette/core.py +++ b/moulinette/core.py @@ -18,7 +18,6 @@ def during_unittests_run(): class Translator: - """Internationalization class Provide an internationalization mechanism based on JSON files to @@ -173,7 +172,6 @@ class Translator: class Moulinette18n: - """Internationalization service for the moulinette Manage internationalization and access to the proper keys translation @@ -270,7 +268,6 @@ class MoulinetteAuthenticationError(MoulinetteError): class MoulinetteLock: - """Locker for a moulinette instance It provides a lock mechanism for a given moulinette instance. It can diff --git a/moulinette/interfaces/__init__.py b/moulinette/interfaces/__init__.py index 54776552..db814159 100644 --- a/moulinette/interfaces/__init__.py +++ b/moulinette/interfaces/__init__.py @@ -18,7 +18,6 @@ logger = logging.getLogger("moulinette.interface") class BaseActionsMapParser: - """Actions map's base Parser Each interfaces must implement an ActionsMapParser class derived @@ -148,7 +147,6 @@ class BaseActionsMapParser: class _ExtendedSubParsersAction(argparse._SubParsersAction): - """Subparsers with extended properties for argparse It provides the following additional properties at initialization, @@ -448,7 +446,6 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter): class JSONExtendedEncoder(JSONEncoder): - """Extended JSON encoder Extend default JSON encoder to recognize more types and classes. It will diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 34b51143..d5132c9c 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -66,14 +66,12 @@ def filter_csrf(callback): class LogQueues(dict): - """Map of session ids to queue.""" pass class APIQueueHandler(logging.Handler): - """ A handler class which store logging records into a queue, to be used and retrieved from the API. @@ -109,7 +107,6 @@ class APIQueueHandler(logging.Handler): class _HTTPArgumentParser: - """Argument parser for HTTP requests Object for parsing HTTP requests into Python objects. It is based @@ -547,7 +544,6 @@ def format_for_response(content): class ActionsMapParser(BaseActionsMapParser): - """Actions map's Parser for the API Provide actions map parsing methods for a CLI usage. The parser for @@ -691,7 +687,6 @@ class ActionsMapParser(BaseActionsMapParser): class Interface: - """Application Programming Interface for the moulinette Initialize a HTTP server which serves the API connected to a given diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index 84e72185..b4c42ebc 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -208,7 +208,6 @@ def get_locale(): class TTYHandler(logging.StreamHandler): - """TTY log handler A handler class which prints logging records for a tty. The record is @@ -274,7 +273,6 @@ class TTYHandler(logging.StreamHandler): class ActionsMapParser(BaseActionsMapParser): - """Actions map's Parser for the CLI Provide actions map parsing methods for a CLI usage. The parser for @@ -446,7 +444,6 @@ class ActionsMapParser(BaseActionsMapParser): class Interface: - """Command-line Interface for the moulinette Initialize an interface connected to the standard input/output diff --git a/moulinette/utils/log.py b/moulinette/utils/log.py index 02f8a30a..08fec631 100644 --- a/moulinette/utils/log.py +++ b/moulinette/utils/log.py @@ -85,7 +85,6 @@ def getHandlersByClass(classinfo, limit=0): class MoulinetteLogger(Logger): - """Custom logger class Extend base Logger class to provide the SUCCESS custom log level with @@ -173,7 +172,6 @@ def getActionLogger(name=None, logger=None, action_id=None): class ActionFilter: - """Extend log record for an optionnal action Filter a given record and look for an `action_id` key. If it is not found diff --git a/test/src/authenticators/dummy.py b/test/src/authenticators/dummy.py index 1d11a609..cef42c34 100644 --- a/test/src/authenticators/dummy.py +++ b/test/src/authenticators/dummy.py @@ -13,7 +13,6 @@ session_secret = random_ascii() class Authenticator(BaseAuthenticator): - """Dummy authenticator used for tests""" name = "dummy" diff --git a/test/src/authenticators/yoloswag.py b/test/src/authenticators/yoloswag.py index 7dc41fdc..f68122c9 100644 --- a/test/src/authenticators/yoloswag.py +++ b/test/src/authenticators/yoloswag.py @@ -13,7 +13,6 @@ session_secret = random_ascii() class Authenticator(BaseAuthenticator): - """Dummy authenticator used for tests""" name = "yoloswag"