cfg4py package¶
Submodules¶
cfg4py.command_line module¶
-
class
cfg4py.cli.
Command
[source]¶ Bases:
object
-
build
(config_dir: str)[source]¶ Compile configuration files into python script, which is used by IDE’s auto-complete function
- Args:
config_dir: The folder where your configuration files located
Returns:
-
hint
(what: str = None, usage: bool = False)[source]¶ show a cheat sheet for configurations. for example:
cfg4py hint mysql
this will print how to configure PyMySQL :param what :param usage
-
cfg4py.config module¶
cfg4py.core module¶
Main module.
-
class
cfg4py.core.
RedisConfigFetcher
(key: str, host: str = 'localhost', port: int = 6379, db: int = 0, **kwargs)[source]¶
-
cfg4py.core.
config_remote_fetcher
(fetcher: cfg4py.core.RemoteConfigFetcher, interval: int = 300)[source]¶ - config a remote configuration fetcher, which will pull the settings on every
refresh_interval
- Args:
fetcher: sub class of RemoteConfigFetcher interval: how long should cfg4py to pull the configuration from remote
Returns:
-
cfg4py.core.
enable_logging
(level=20, log_file=None, file_size=10, file_count=7)[source]¶ Enable basic log function for the application
if log_file is None, then it’ll provide console logging, otherwise, the console logging is turned off, all events will be logged into the provided file.
- Args:
level: the log level, one of logging.DEBUG, logging.INFO, logging.WARNING, logging.Error log_file: the absolute file path for the log. file_size: file size in MB unit file_count: how many backup files leaved in disk
- Returns:
None
Module contents¶
Top-level package for Cfg4Py.
-
cfg4py.
enable_logging
(level=20, log_file=None, file_size=10, file_count=7)[source]¶ Enable basic log function for the application
if log_file is None, then it’ll provide console logging, otherwise, the console logging is turned off, all events will be logged into the provided file.
- Args:
level: the log level, one of logging.DEBUG, logging.INFO, logging.WARNING, logging.Error log_file: the absolute file path for the log. file_size: file size in MB unit file_count: how many backup files leaved in disk
- Returns:
None
-
cfg4py.
config_remote_fetcher
(fetcher: cfg4py.core.RemoteConfigFetcher, interval: int = 300)[source]¶ - config a remote configuration fetcher, which will pull the settings on every
refresh_interval
- Args:
fetcher: sub class of RemoteConfigFetcher interval: how long should cfg4py to pull the configuration from remote
Returns:
-
cfg4py.
init
(local_cfg_path: str = None, dump_on_change=True, strict=False)[source]¶ create cfg object. Args:
local_cfg_path: the directory name where your configuration files exist dump_on_change: if configuration is updated, whether or not to dump them into
log file
Returns: