def __init__(self, file_name: Path, default=None) -> None: RawConfigParser.__init__(self, None) # make the options case sensitive self.optionxform = lambda param: str(param) self.file_name = file_name self.read_file() self.default = default
def __init__(self, file_name, default=None): RawConfigParser.__init__(self, None) # make the options case sensitive self.optionxform = str self.file_name = file_name self.read_file() self.default = default
def __init__(self, file_name): self.file_name = file_name RawConfigParser.__init__(self, None) RawConfigParser.read(self, file_name, encoding='utf-8') # Check config integrity and fix it if it’s wrong for section in ('bindings', 'var'): if not self.has_section(section): self.add_section(section)
def __init__(self, *args, **kwargs): RawConfigParser.__init__(self, *args, **kwargs) self._files = [] """List of paths of configuration files read.""" self._stderr = ErrorOutput() """Wrapper around sys.stderr catching en-/decoding errors"""
def __init__(self): RawConfigParser.__init__(self) self._modified = False # sample _cfg dict. Create your own in your derived class. self._cfg = { "sectionname": { "optionname": LazyConfigOption(int, 1, self.getint) } }
def __init__(self, configuration_file, defaults=None): defaults = defaults or {} RawConfigParser.__init__(self) f = codecs.open(configuration_file, 'r', encoding='utf-8') self.read_file(f) f.close() ''' set defaults ''' self.hostname = 'localhost' self.port = 1883 self.username = None self.password = None self.clientid = None self.lwt = None self.skipretained = False self.cleansession = False self.protocol = 3 self.logformat = '%(asctime)-15s %(levelname)-8s [%(name)-25s] %(message)s' self.logfile = None self.loglevel = 'DEBUG' self.functions = None self.num_workers = 1 self.directory = '.' self.ca_certs = None self.tls_version = None self.certfile = None self.keyfile = None self.tls_insecure = False self.tls = False self.__dict__.update(defaults) self.__dict__.update(self.config('defaults')) if HAVE_TLS == False: logger.error("TLS parameters set but no TLS available (SSL)") sys.exit(2) if self.ca_certs is not None: self.tls = True if self.tls_version is not None: if self.tls_version == 'tlsv1_2': self.tls_version = ssl.PROTOCOL_TLSv1_2 if self.tls_version == 'tlsv1_1': self.tls_version = ssl.PROTOCOL_TLSv1_1 if self.tls_version == 'tlsv1': self.tls_version = ssl.PROTOCOL_TLSv1 if self.tls_version == 'sslv3': self.tls_version = ssl.PROTOCOL_SSLv3 self.loglevelnumber = self.level2number(self.loglevel) self.functions = load_functions(self.functions)
def __init__(self, url): ''' Initialize our object :param version: a string like 4.3.1 ''' RawConfigParser.__init__(self) self._url = url self.urlfp = urlopen(self._url) self.read_string(self.urlfp.read().decode())
def __init__(self): #self.default_section = None #DEFAULTSECT # Instantiate parent class with PISA-specific options #super().__init__( RawConfigParser.__init__( self, interpolation=ExtendedInterpolation(), empty_lines_in_values=False, ) self.file_iterators = []
def __init__(self, parsetFile): RawConfigParser.__init__(self) # read parset and replace '#' with ';' to allow # as inline comments # also add [_global] fake section at beginning import StringIO config = StringIO.StringIO() config.write('[_global]\n'+open(parsetFile).read().replace('#',';')) config.seek(0, os.SEEK_SET) self.readfp(config)
def __init__(self, path): RawConfigParser.__init__(self) self.read(path) # Add sections based on the names for sname in self.sections(): if ((sname not in self.__dict__) and sname.replace('_', '').isalnum() and not sname.replace('_', '').isdigit() and '__' not in sname): self.__dict__[sname] = Section(sname, self)
def __init__(self, config, suspect): RawConfigParser.__init__(self) # store weak reference to suspect # otherwise (python 3), the instance of DBConfig does not reduce the # refcount to suspect even if it goes out of scope and the suspect # object does not get freed until a (manual or automatic) run of the # garbage collector "gc.collect()" self.suspect = weakref.ref(suspect) self.logger = logging.getLogger('fuglu.sql.dbconfig') self.cloneFrom(config)
def __init__(self, path, fname=None): RawConfigParser.__init__(self) self.path = path if fname is None: if os.path.isfile(os.path.join(path, 'config.txt')): self.fname = 'config.txt' else: self.fname = filter( lambda x: x.startswith('config') and x.endswith('.txt'), os.listdir(path))[0] else: self.fname = fname self.read(os.path.join(path, self.fname))
def __init__(self, file_name): RawConfigParser.__init__(self) self.file_name = file_name if not os.path.isfile(file_name): raise(zeus.exception.FileNotFoundException(self.file_name)) try: self.read(self.file_name) except MissingSectionHeaderError: raise(zeus.exception.InvalidConfigurationFileException( self.file_name))
def __init__(self, file_name): self.file_name = file_name RawConfigParser.__init__(self, None) # make the options case sensitive self.optionxform = str try: RawConfigParser.read(self, file_name, encoding='utf-8') except TypeError: # python < 3.2 sucks RawConfigParser.read(self, file_name) # Check config integrity and fix it if it’s wrong for section in ('bindings', 'var'): if not self.has_section(section): self.add_section(section)
def __init__(self, path, debug=False, mark_whitespace="`'`"): RawConfigParser.__init__(self) self.config_file = path self.debug = debug self.mrk_ws = mark_whitespace if os.path.exists(path): sanitize_config_file(path) try: self.read(path) except ParsingError: self.write() try: self.read(path) except ParsingError as p: print("Could not start wicd: {1}".format(p.message)) sys.exit(1)
def __init__(self, location=None, default_location=None): """ Sets up the settings manager. Expects a location to a file where settings will be stored. Also sets up periodic saves to disk. :param location: the location to save the settings to, settings will never be stored if this is None :type location: str or None :param default_location: the default location to initialize settings from """ RawConfigParser.__init__(self) self.location = location self._saving = False self._dirty = False self._serial = self.__class__._last_serial = self.__class__._last_serial + 1 if default_location is not None: try: self.read(default_location) except Exception: pass if location is not None: try: self.read(self.location) or self.read( self.location + ".new") or self.read(self.location + ".old") except Exception: pass version = self.get_option('settings/version') if version and version > self.VERSION: raise VersionError(_('Settings version is newer than current.')) if version != self.VERSION: self.set_option('settings/version', self.VERSION) # save settings every 30 seconds if location is not None: self._timeout_save()
def __init__(self, path_conf): """ Init class ServiceConfigFile :param path_conf: string path of the config file """ if THIS.path_conf is None: # first set of path_conf and cfg if path_conf is None: raise Exception( "First call to ServiceConfigFile: path_conf_name is not define" ) THIS.path_conf = path_conf # we call the constructor of mother class RawConfigParser.__init__(self) # we load the configuration file self.read(path_conf) # we save instance of class THIS.cfg = self #initialize_config(self, path_conf) self.path_conf = THIS.path_conf
def __init__(self, location=None, default_location=None): """ Sets up the settings manager. Expects a location to a file where settings will be stored. Also sets up periodic saves to disk. :param location: the location to save the settings to, settings will never be stored if this is None :type location: str or None :param default_location: the default location to initialize settings from """ RawConfigParser.__init__(self) self.location = location self._saving = False self._dirty = False if default_location is not None: try: self.read(default_location) except: pass if location is not None: try: self.read(self.location) or \ self.read(self.location + ".new") or \ self.read(self.location + ".old") except: pass if self.get_option('settings/version', 0) is None: self.set_option('settings/version', self.__version__) # save settings every 30 seconds if location is not None: self._timeout_save()
def __init__(self, defaults=None): RawConfigParser.__init__(self, defaults, strict=False)
def __init__(self, defaults=None, dict_type=_default_dict, allow_no_value=False): RawConfigParser.__init__(self, defaults, dict_type, allow_no_value) self.main_section = __name__
def __init__(self, config_file): RawConfigParser.__init__(self, strict=False) self.read(os.path.join("conf", "default.conf")) self.read(config_file)
def __init__(self, *args, **kwargs): RawConfigParser.__init__(self, *args, **kwargs)
def __init__(self): # RawConfigParser is old-style class, so don't use super() RawConfigParser.__init__(self) self.read(INI_PATH)
def __init__(self): return _RawConfigParser.__init__(self, allow_no_value = True)
def __init__(self): return _RawConfigParser.__init__(self, allow_no_value=True)
def parse_config_files(self, filenames=None): if filenames is None: filenames = self.find_config_files() logger.debug("Distribution.parse_config_files():") parser = RawConfigParser() for filename in filenames: logger.debug(" reading %s", filename) parser.read(filename, encoding='utf-8') if os.path.split(filename)[-1] == 'setup.cfg': self._read_setup_cfg(parser, filename) for section in parser.sections(): if section == 'global': if parser.has_option('global', 'compilers'): self._load_compilers(parser.get('global', 'compilers')) if parser.has_option('global', 'commands'): self._load_commands(parser.get('global', 'commands')) options = parser.options(section) opt_dict = self.dist.get_option_dict(section) for opt in options: if opt == '__name__': continue val = parser.get(section, opt) opt = opt.replace('-', '_') if opt == 'sub_commands': val = split_multiline(val) if isinstance(val, str): val = [val] # Hooks use a suffix system to prevent being overriden # by a config file processed later (i.e. a hook set in # the user config file cannot be replaced by a hook # set in a project config file, unless they have the # same suffix). if (opt.startswith("pre_hook.") or opt.startswith("post_hook.")): hook_type, alias = opt.split(".") hook_dict = opt_dict.setdefault( hook_type, (filename, {}))[1] hook_dict[alias] = val else: opt_dict[opt] = filename, val # Make the RawConfigParser forget everything (so we retain # the original filenames that options come from) parser.__init__() # If there was a "global" section in the config file, use it # to set Distribution options. if 'global' in self.dist.command_options: for opt, (src, val) in self.dist.command_options['global'].items(): alias = self.dist.negative_opt.get(opt) try: if alias: setattr(self.dist, alias, not strtobool(val)) elif opt == 'dry_run': # FIXME ugh! setattr(self.dist, opt, strtobool(val)) else: setattr(self.dist, opt, val) except ValueError as msg: raise PackagingOptionError(msg)
def parse_config_files(self, filenames=None): if filenames is None: filenames = self.find_config_files() logger.debug("Distribution.parse_config_files():") parser = RawConfigParser() for filename in filenames: logger.debug(" reading %s", filename) with open(filename, 'r', encoding='utf-8') as f: parser.readfp(f) if os.path.split(filename)[-1] == 'setup.cfg': self._read_setup_cfg(parser, filename) for section in parser.sections(): if section == 'global': if parser.has_option('global', 'compilers'): self._load_compilers(parser.get('global', 'compilers')) if parser.has_option('global', 'commands'): self._load_commands(parser.get('global', 'commands')) options = parser.options(section) opt_dict = self.dist.get_option_dict(section) for opt in options: if opt == '__name__': continue val = parser.get(section, opt) opt = opt.replace('-', '_') if opt == 'sub_commands': val = split_multiline(val) if isinstance(val, str): val = [val] # Hooks use a suffix system to prevent being overriden # by a config file processed later (i.e. a hook set in # the user config file cannot be replaced by a hook # set in a project config file, unless they have the # same suffix). if (opt.startswith("pre_hook.") or opt.startswith("post_hook.")): hook_type, alias = opt.split(".") hook_dict = opt_dict.setdefault( hook_type, (filename, {}))[1] hook_dict[alias] = val else: opt_dict[opt] = filename, val # Make the RawConfigParser forget everything (so we retain # the original filenames that options come from) parser.__init__() # If there was a "global" section in the config file, use it # to set Distribution options. if 'global' in self.dist.command_options: for opt, (src, val) in self.dist.command_options['global'].items(): alias = self.dist.negative_opt.get(opt) try: if alias: setattr(self.dist, alias, not strtobool(val)) elif opt == 'dry_run': # FIXME ugh! setattr(self.dist, opt, strtobool(val)) else: setattr(self.dist, opt, val) except ValueError as msg: raise PackagingOptionError(msg)
def __init__(self, *a, **kw): RawConfigParser.__init__(self, *a, **kw);
def __init__(self, config, suspect): RawConfigParser.__init__(self) self.suspect = suspect self.logger = logging.getLogger('fuglu.sql.dbconfig') self.cloneFrom(config)
def __init__(self, redis_pool): RawConfigParser.__init__(self) self.redis = redis_pool
def __init__(self, filename=CONFIG_FILE): RawConfigParser.__init__(self) self.filename = filename self.load()
def __init__(self, presets, **args): RawConfigParser.__init__(self, **args) for s in presets.keys(): self.add_section(s) for k, v in presets[s].items(): self.set(s, k, v)
def __init__(self, *a, **kw): RawConfigParser.__init__(self, *a, **kw)
def __init__(self, section="weblate"): """Construct WeblateConfig object.""" RawConfigParser.__init__(self, delimiters=("=",)) self.section = section self.set_defaults()
def __init__(self, *args, **kwargs): RawConfigParser.__init__(self, *args, **kwargs) self.filename = None self.callback = None self.lock = RLock()
def __init__(self, filename, module_name): self.file_name = filename self.module_name = module_name RawConfigParser.__init__(self, None) self.read()
def __init__(self, env, platform): RawConfigParser.__init__(self) self.env = env self.platform = platform
def __init__(self, section='odorik'): """Construct OdorikConfig object.""" RawConfigParser.__init__(self) self.section = section self.set_defaults()
def __init__(self, section='weblate'): """Construct WeblateConfig object.""" RawConfigParser.__init__(self, delimiters=('=', )) self.section = section self.set_defaults()
def __init__(self, defaults=DEFAULTS): RawConfigParser.__init__(self) self.readfp(io.StringIO(defaults)) self.readonce = False
def __init__(self, default_section=None, *args, **kwargs): RawConfigParser.__init__(self, *args, **kwargs) self._default_section = None self.set_default_section(default_section or '__config__')