Applied flake8 in config.
This commit is contained in:
parent
690f8ce792
commit
5510b6d3b9
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import copy
|
||||
from .p3 import configparser
|
||||
|
||||
# constant stuff (DFT = DEFAULT)
|
||||
@ -32,12 +31,15 @@ BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'}
|
||||
# package-shared config that can be accessed using :
|
||||
# from configs import config
|
||||
_config = None
|
||||
def config(section = MAIN_SECTION):
|
||||
|
||||
|
||||
def config(section=MAIN_SECTION):
|
||||
if _config is None:
|
||||
raise ValueError('not config instanciated yet')
|
||||
_config._section = section
|
||||
return _config
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@ -55,11 +57,11 @@ class Config(object):
|
||||
global _config
|
||||
_config = self
|
||||
|
||||
def load(self, path = DFT_CONFIG_PATH):
|
||||
def load(self, path=DFT_CONFIG_PATH):
|
||||
self._cfg.read(path)
|
||||
return self
|
||||
|
||||
def save(self, path = DFT_CONFIG_PATH):
|
||||
def save(self, path=DFT_CONFIG_PATH):
|
||||
with open(path, 'w') as f:
|
||||
self._cfg.write(f)
|
||||
|
||||
@ -77,7 +79,7 @@ class Config(object):
|
||||
value = str2bool(value)
|
||||
return value
|
||||
|
||||
def get(self, name, default = None):
|
||||
def get(self, name, default=None):
|
||||
try:
|
||||
return self.__getattr__(name)
|
||||
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||
@ -89,5 +91,6 @@ class Config(object):
|
||||
value = str2bool(value)
|
||||
yield name, value
|
||||
|
||||
|
||||
def str2bool(s):
|
||||
return str(s).lower() in ('yes', 'true', 't', 'y', '1')
|
||||
|
Loading…
x
Reference in New Issue
Block a user