Python configparser.ConfigParser.__init__() Examples
The following are 30
code examples of configparser.ConfigParser.__init__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
configparser.ConfigParser
, or try the search function
.
Example #1
Source File: config.py From pytorch_NER_BiLSTM_CNN_CRF with Apache License 2.0 | 6 votes |
def __init__(self, config_file): # config = ConfigParser() super().__init__() self.test = None self.train = None config = myconf() config.read(config_file) self._config = config self.config_file = config_file print('Loaded config file sucessfully.') for section in config.sections(): for k, v in config.items(section): print(k, ":", v) if not os.path.isdir(self.save_direction): os.mkdir(self.save_direction) config.write(open(config_file, 'w'))
Example #2
Source File: config.py From pytorch_Joint-Word-Segmentation-and-POS-Tagging with Apache License 2.0 | 6 votes |
def __init__(self, config_file): # config = ConfigParser() super().__init__() self.test = None self.train = None config = myconf() config.read(config_file) # if config.has_section(self.add_sec) is False: # config.add_section(self.add_sec) self._config = config self.config_file = config_file print('Loaded config file Successfully.') for section in config.sections(): for k, v in config.items(section): print(k, ":", v) if not os.path.isdir(self.save_direction): os.mkdir(self.save_direction) config.write(open(config_file, 'w'))
Example #3
Source File: CascadingConfigParser.py From redeem with GNU General Public License v3.0 | 6 votes |
def __init__(self, config_files): Parser.__init__(self) # Write options in the case it was read. # self.optionxform = str # Parse to real path self.config_files = [] for config_file in config_files: self.config_files.append(os.path.realpath(config_file)) self.config_location = os.path.dirname(os.path.realpath(config_file)) # Parse all config files in list for config_file in self.config_files: if os.path.isfile(config_file): logging.info("Using config file " + config_file) if PY2: self.readfp(open(config_file)) else: self.read_file(open(config_file)) else: logging.warning("Missing config file " + config_file) # Might also add command line options for overriding stuff
Example #4
Source File: config.py From PyTorch_Biaffine_Dependency_Parsing with Apache License 2.0 | 6 votes |
def __init__(self, config_file): # config = ConfigParser() super().__init__() self.test = None self.train = None config = myconf() config.read(config_file) # if config.has_section(self.add_sec) is False: # config.add_section(self.add_sec) self._config = config self.config_file = config_file print('Loaded config file sucessfully.') for section in config.sections(): for k, v in config.items(section): print(k, ":", v) if not os.path.isdir(self.save_direction): os.makedirs(self.save_direction) config.write(open(config_file, 'w'))
Example #5
Source File: configHandler.py From ironpython3 with Apache License 2.0 | 5 votes |
def __init__(self): self.config_types = ('main', 'extensions', 'highlight', 'keys') self.defaultCfg = {} self.userCfg = {} self.cfg = {} # TODO use to select userCfg vs defaultCfg self.CreateConfigHandlers() self.LoadCfgFiles()
Example #6
Source File: __init__.py From bazarr with GNU General Public License v3.0 | 5 votes |
def __init__(self, defaults=None, *args, **kwargs): configparser.__init__(self, defaults=None, *args, **kwargs) # Improved defaults handling if isinstance(defaults, dict): for section, values in defaults.items(): # Break out original format defaults was passed in if not isinstance(values, dict): break if section not in self.sections(): self.add_section(section) for name, value in values.items(): self.set(section, name, str(value))
Example #7
Source File: configparser.py From BentoML with Apache License 2.0 | 5 votes |
def __init__(self, default_config, *args, **kwargs): ConfigParser.__init__(self, *args, **kwargs) if default_config is not None: self.read_string(default_config)
Example #8
Source File: config.py From pytorch_Joint-Word-Segmentation-and-POS-Tagging with Apache License 2.0 | 5 votes |
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults=defaults) self.add_sec = "Additional"
Example #9
Source File: config.py From python-plexapi with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, path): ConfigParser.__init__(self) self.read(path) self.data = self._asDict()
Example #10
Source File: config.py From PyTorch_Biaffine_Dependency_Parsing with Apache License 2.0 | 5 votes |
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults=defaults) self.add_sec = "Additional"
Example #11
Source File: configHandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def __init__(self, cfgFile, cfgDefaults=None): """ cfgFile - string, fully specified configuration file name """ self.file = cfgFile ConfigParser.__init__(self, defaults=cfgDefaults, strict=False)
Example #12
Source File: configHandler.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.config_types = ('main', 'extensions', 'highlight', 'keys') self.defaultCfg = {} self.userCfg = {} self.cfg = {} # TODO use to select userCfg vs defaultCfg self.CreateConfigHandlers() self.LoadCfgFiles()
Example #13
Source File: edgerc.py From AkamaiOPEN-edgegrid-python with Apache License 2.0 | 5 votes |
def __init__(self, filename): ConfigParser.__init__(self, {'client_token': '', 'client_secret':'', 'host':'', 'access_token':'','max_body': '131072', 'headers_to_sign': 'None'}) logger.debug("loading edgerc from %s", filename) self.read(filename) logger.debug("successfully loaded edgerc")
Example #14
Source File: user_config.py From scfcli with Apache License 2.0 | 5 votes |
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults=None) # super(CliConfigParser, self).__init__(defaults)
Example #15
Source File: user_config.py From scfcli with Apache License 2.0 | 5 votes |
def __init__(self): self.secret_id = "None" self.secret_key = "None" self.region = "None" self.appid = "None" self.using_cos = "False (By default, it isn't deployed by COS.)" self.python2_path = "None" self.python3_path = "None" self.version_time = "None" self.section_map = { UserConfig.USER_QCLOUD_CONFIG: { "secret_id": "None", "secret_key": "None", "region": "None", "appid": "None", "using_cos": "False (By default, it isn't deployed by COS.)" }, UserConfig.GIT_CONFIG: { "git_url": "None", "git_username": "None", "git_password": "None" }, UserConfig.ENV: { "python2_path": "None", "python3_path": "None", }, UserConfig.OTHERS: { "curr_user": "None", "version_time": "None", "no_color": "False", "language": "None", "allow_report": "True", } } self._migrate() self._load_config() self._dumpattr() # 新老配置迁移函数
Example #16
Source File: parser.py From pibooth with MIT License | 5 votes |
def __init__(self, filename, plugin_manager): ConfigParser.__init__(self) self._pm = plugin_manager self.filename = osp.abspath(osp.expanduser(filename)) if osp.isfile(self.filename): self.load()
Example #17
Source File: sma.py From simple-monitor-alert with MIT License | 5 votes |
def __init__(self, file): self.file = file if sys.version_info >= (3, 0): super().__init__() else: # Old Style Class ConfigParser.__init__(self) self.read(self.file)
Example #18
Source File: sma.py From simple-monitor-alert with MIT License | 5 votes |
def __init__(self, monitor_name, monitor_results, sma=None): self.monitor_name = monitor_name self.monitor_results = monitor_results self.sma = sma
Example #19
Source File: sma.py From simple-monitor-alert with MIT License | 5 votes |
def __init__(self, path, create=True, sma=None): super(Results, self).__init__(path, create) self.sma = sma
Example #20
Source File: sma.py From simple-monitor-alert with MIT License | 5 votes |
def __init__(self, monitors_dir=None, alerts_dir=None, config_file=None): # noinspection PyTypeChecker results_file = create_file(os.path.join(get_var_directory(), 'results.json'), { 'version': __version__, 'monitors': {}, }) self.config = Config(config_file) self.results = Results(results_file, sma=self) self.monitors_info = MonitorsInfo(os.path.join(get_var_directory(), 'monitors.json')) self.monitors = Monitors(monitors_dir, self.config, self) self.alerts = Alerts(self, alerts_dir)
Example #21
Source File: __init__.py From bazarr with GNU General Public License v3.0 | 5 votes |
def __init__(self, section, parser): self.section = section self.parser = parser
Example #22
Source File: config.py From pytorch_NER_BiLSTM_CNN_CRF with Apache License 2.0 | 5 votes |
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults=defaults) self.add_sec = "Additional"
Example #23
Source File: loadwsgi.py From pulsar with Apache License 2.0 | 5 votes |
def __init__(self, filename): self.filename = filename = filename.strip() defaults = { 'here': os.path.dirname(os.path.abspath(filename)), '__file__': os.path.abspath(filename) } self.parser = NicerConfigParser(filename, defaults=defaults) self.parser.optionxform = str # Don't lower-case keys with open(filename) as f: self.parser.read_file(f)
Example #24
Source File: cli.py From certidude with MIT License | 5 votes |
def __init__(self, path, *args, **kwargs): ConfigParser.__init__(self, *args, **kwargs) if os.path.exists(path): with open(path) as fh: click.echo("Parsing: %s" % fh.name) self.readfp(fh) if os.path.exists(path + ".d"): for filename in os.listdir(path + ".d"): if not filename.endswith(".conf"): continue with open(os.path.join(path + ".d", filename)) as fh: click.echo("Parsing: %s" % fh.name) self.readfp(fh)
Example #25
Source File: fusesocconfigparser.py From fusesoc with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, config_file): if sys.version[0] == "2": CP.__init__(self) else: super().__init__() if not os.path.exists(config_file): raise Exception("Could not find " + config_file) f = open(config_file) id_string = f.readline().split("=") if id_string[0].strip().upper() in ["CAPI", "SAPI"]: self.type = id_string[0] else: raise SyntaxError("Could not find API type in " + config_file) try: self.version = int(id_string[1].strip()) except ValueError: raise SyntaxError("Unknown version '{}'".format(id_string[1].strip())) except IndexError: raise SyntaxError("Could not find API version in " + config_file) if sys.version[0] == "2": exceptions = (configparser.ParsingError, configparser.DuplicateSectionError) else: exceptions = ( configparser.ParsingError, configparser.DuplicateSectionError, configparser.DuplicateOptionError, ) try: if sys.version[0] == "2": self.readfp(f) else: self.read_file(f) except configparser.MissingSectionHeaderError: raise SyntaxError("Missing section header") except exceptions as e: raise SyntaxError(e.message)
Example #26
Source File: config.py From PumpkinLB with GNU General Public License v3.0 | 5 votes |
def __init__(self, localAddr, localPort, workers): self.localAddr = localAddr or '' self.localPort = int(localPort) self.workers = workers
Example #27
Source File: config.py From PumpkinLB with GNU General Public License v3.0 | 5 votes |
def __init__(self, configFilename): ConfigParser.__init__(self) self.configFilename = configFilename self._options = { 'pre_resolve_workers' : True, 'buffer_size' : DEFAULT_BUFFER_SIZE, } self._mappings = {}
Example #28
Source File: config.py From biweeklybudget with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, keyring_name='ofxclient', keyring_available=KEYRING_AVAILABLE, **kwargs): if sys.version_info >= (3,): # python 3 ConfigParser.__init__(self, interpolation=None) else: # python 2 ConfigParser.__init__(self) self.keyring_name = keyring_name self.keyring_available = keyring_available self._unsaved = {} self.keyring_name = keyring_name
Example #29
Source File: config.py From biweeklybudget with GNU Affero General Public License v3.0 | 5 votes |
def __init__(self, file_name=None): self.secured_field_names = [ 'institution.username', 'institution.password' ] f = file_name or DEFAULT_CONFIG if f is None: raise ValueError('file_name is required') self._load(f)
Example #30
Source File: loadwsgi.py From pulsar with Apache License 2.0 | 5 votes |
def __init__(self, filename, *args, **kw): ConfigParser.__init__(self, *args, **kw) self.filename = filename if hasattr(self, '_interpolation'): self._interpolation = self.InterpolateWrapper(self._interpolation)