Conditions | 3 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | """ |
||
32 | def __init__(self, config_files=None, plugins=None, strict=False): |
||
33 | if config_files is None: |
||
34 | config_files = [] |
||
35 | |||
36 | self.strict = strict |
||
37 | |||
38 | #: logging object for sending log messages. Example:: |
||
39 | #: |
||
40 | #: from groundwork import App |
||
41 | #: my_app = App() |
||
42 | #: my_app.log.debug("Send debug message") |
||
43 | #: my_app.log.error("Send error....") |
||
44 | self.log = logging.getLogger("groundwork") |
||
45 | |||
46 | self._configure_logging() |
||
47 | self.log.info("Initializing groundwork") |
||
48 | self.log.info("Reading configuration") |
||
49 | |||
50 | #: Instance of :class:`~groundwork.configuration.configmanager.ConfigManager`. |
||
51 | #: Used to load different configuration files and create a common configuration object. |
||
52 | self.config = ConfigManager().load(config_files) |
||
53 | |||
54 | self._configure_logging(self.config.get("GROUNDWORK_LOGGING")) |
||
55 | |||
56 | #: Name of the application. Is configurable by parameter "APP_NAME" of a configuration file. |
||
57 | self.name = self.config.get("APP_NAME", None) or "NoName App" |
||
58 | |||
59 | #: Absolute application path. Is configurable by parameter "APP_PATH" of a configuration file. |
||
60 | #: If not given, the current working directory is taken. |
||
61 | #: The path is used to calculate absolute paths for tests, documentation and much more. |
||
62 | self.path = os.path.abspath(self.config.get("APP_PATH", None) or os.getcwd()) |
||
63 | |||
64 | #: Instance of :class:`~groundwork.signals.SignalsApplication`. Provides functions to register and fire |
||
65 | # signals or receivers on application level. |
||
66 | self.signals = SignalsApplication(app=self) |
||
67 | |||
68 | self.signals.register("plugin_activate_pre", self, |
||
69 | "Gets send right before activation routine of a plugins will be executed") |
||
70 | self.signals.register("plugin_activate_post", self, |
||
71 | "Gets send right after activation routine of a plugins was executed") |
||
72 | self.signals.register("plugin_deactivate_pre", self, |
||
73 | "Gets send right before deactivation routine of a plugins will be executed") |
||
74 | self.signals.register("plugin_deactivate_post", self, |
||
75 | "Gets send right after deactivation routine of a plugins was executed") |
||
76 | |||
77 | #: Instance of :class:`~groundwork.pluginmanager.PluginManager`- Provides functions to load, activate and |
||
78 | # deactivate plugins. |
||
79 | self.plugins = PluginManager(app=self) |
||
80 | |||
81 | if plugins is not None: |
||
82 | self.plugins.classes.register(plugins) |
||
83 | |||
114 |