def __init__(self): """Constructs the ConfigParser and fills it with the hardcoded defaults""" ConfigParser.__init__(self) for section,content in _defaults.iteritems(): self.add_section(section) for key,value in content.iteritems(): self.set(section,key,value) self.read(self.configFiles()) self.validSections={} for s in self.sections(): minusPos=s.find('-') if minusPos<0: name=s else: name=s[:minusPos] try: self.validSections[name].append(s) except KeyError: self.validSections[name]=[s] for name,sections in self.validSections.iteritems(): if not name in sections: print "Invalid configuration for",name,"there is no default section for it in",sections
def __init__(self, cpath=None): ConfigParser.__init__(self) if not cpath: self.configpath = os.path.join(os.getcwd(), 'concordia', 'matchtool', 'data.cfg') else: self.configpath = os.path.abspath(cpath) self.read(self.configpath)
def __init__(self, name, defaults=None, load=True, version=None, subfolder=None): ConfigParser.__init__(self) self.subfolder = subfolder if (version is not None) and (re.match('^(\d+).(\d+).(\d+)$', version) is None): raise RuntimeError("Version number %r is incorrect - must be in X.Y.Z format" % version) self.name = name if isinstance(defaults, dict): defaults = [ (self.default_section_name, defaults) ] self.defaults = defaults if defaults is not None: self.reset_to_defaults(save=False) if load: # If config file already exists, it overrides Default options: self.load_from_ini() if version != self.get_version(version): # Version has changed -> overwriting .ini file self.reset_to_defaults(save=False) self.__remove_deprecated_options() # Set new version number self.set_version(version, save=False) if defaults is None: # If no defaults are defined, set .ini file settings as default self.set_as_defaults() # In any case, the resulting config is saved in config file: self.__save()
def __init__(self, defaults=None, optionxformf=str.upper): self.optionxform = optionxformf defs = {} if defaults: for key, value in defaults.items(): defs[self.optionxform(key)] = value ConfigParser.__init__(self, defs)
def __init__(self, inifile, saveimmediately=False, encoding=None): ConfigParser.__init__(self) self.inifile = inifile self.saveimmediately = saveimmediately self.encoding = encoding if inifile: self.read(inifile)
def __init__(self, filename, *args, **kwargs): ConfigParser.__init__(self, *args, **kwargs) if filename: if os.access(filename, os.R_OK): self.read([filename]) else: raise IOError('Could not open {} for reading'.format(filename))
def __init__(self, filepath): ConfigParser.__init__(self) if filepath is not None: if not os.path.exists(filepath): raise IOError("Config file doesn't exist (%s)" % filepath) self.read(filepath)
def __init__(self, filename): ConfigParser.__init__(self) self.filename = filename try: self.read(filename) except: pass
def __init__(self,config): ''' 必须初始化ConfigParser类,否则无法获取section ''' ConfigParser.__init__(self) self.ftpvars={} self.config = config
def parse_config_files (self, filenames=None): from ConfigParser import ConfigParser from distutils.core import DEBUG if filenames is None: filenames = self.find_config_files() if DEBUG: print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: if DEBUG: print " reading", filename parser.read(filename) for section in parser.sections(): options = parser.options(section) opt_dict = self.get_option_dict(section) for opt in options: if opt != '__name__': opt_dict[opt] = (filename, parser.get(section,opt)) # Make the ConfigParser forget everything (so we retain # the original filenames that options come from) -- gag, # retch, puke -- another good reason for a distutils- # specific config parser (sigh...) parser.__init__()
def __init__(self, keyring_name='ofxclient', keyring_available=KEYRING_AVAILABLE, **kwargs): ConfigParser.__init__(self) self.keyring_name = keyring_name self.keyring_available = keyring_available self._unsaved = {} self.keyring_name = keyring_name
def __init__(self, config_path=CONFIG_PATH): ConfigParser.__init__(self, allow_no_value=True) self.config_path = config_path try: self.read(self.config_path) except: # It doesn't exist! self.createDefaultConfig()
def __init__(self, filename='config.ini'): ConfigParser.__init__(self) self.path = CONFIG_PATH + filename if os.path.exists(self.path): self.read(self.path) else: raise ConfigFileException('Config file not exists or not available.Please check {}.'.format(self.path))
def __init__(self, path): ConfigParser.__init__(self) self.read(path) self.path = path for section in ('image', 'data', 'network', 'seek'): setattr(self, section, Section(section)) self.image.size = self.get_nums('image', 'size', 'x', int)[0:2] self.image.dir_name = self.get('image', 'dir') self.image.files = sorted(os.listdir(self.image.dir_name)) self.data.margins = {name: self.get_percent('data', '%s-margin' % name) for name in self.margin_types} self.data.alpha_levels = self.get_nums('data', 'alpha-levels') self.data.noise_levels = self.get_nums('data', 'noise-levels') self.data.background_colors = self.getint('data', 'background-colors') self.network.epochs = self.getint('network', 'epochs') self.network.in_size = self.image.size[0] * self.image.size[1] self.network.out_size = len(os.listdir(self.image.dir_name)) self.network.path = self.get('network', 'path') self.seek.dir_name = self.get('seek', 'dir') self.seek.ratio = self.get_range('seek', 'ratio-range') self.seek.size = self.get_range('seek', 'size-range') self.seek.lum_sigma = self.get_percent('seek', 'lum-sigma')
def __init__(self): """ Gets configuration of pertinent services and roles """ ConfigParser.__init__(self) self.optionxform = str self.read("/root/bin/cm_client.ini")
def __init__(self): self.fp = StringIO.StringIO(settings.DEFAULT_CONFIG) ConfigParser.__init__(self) try: self.readfp(self.fp, "internal") except IOError: return
def __init__(self, filename=None, defaults=None): ConfigParser.__init__(self) if defaults != None: self.readstr(defaults) self.filename = filename if filename != None: self.read(filename)
def __init__(self, config_type, path=config_path, names=config_names): ConfigParser.__init__(self) self.config_path = path self.config_names = names self.config_type = config_type self.config_file = gen_config_file_names()[self.config_type] with closing(open(self.config_file)) as f: self.readfp(f)
def __init__(self): ''' Gets configuration of pertinent services and roles ''' ConfigParser.__init__(self) self.optionxform = str self.read('/root/bin/cm_client.ini')
def __init__(self): self.fname = os.path.expanduser('./config') ConfigParser.__init__(self) try: self.read([self.fname]) except IOError: return
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)
def __init__(self): ConfigParser.__init__(self) # XXX better use ScPaths->... path = os.path.expanduser("~/.scribus/scripter") if not os.path.exists(path): os.makedirs(path) self.filename = os.path.join(path, "runtime.cfg") self.read([self.filename])
def __init__(self, defaults=None, dict_type=_default_dict, allow_no_value=False): ConfigParser.__init__(self, defaults=defaults, dict_type=dict_type, allow_no_value=allow_no_value) self._envcre = re.compile( r'name\s*(?P<vi>[=])\s*(?P<option>[^,]*),\s*' r'value\s*=\s*(?P<value>.*)$' ) self._envvre = re.compile(r'\\x2c')
def __init__(self, configFilename): ConfigParser.__init__(self) self.configFilename = configFilename self._options = { 'pre_resolve_workers' : True, 'buffer_size' : DEFAULT_BUFFER_SIZE, } self._mappings = {}
def __init__(self, config_filename): ConfigParser.__init__(self) self.add_section('gtd') self.set('gtd', 'database', u'~/.gtd/todo.sqlite') self.set('gtd', 'backup', u'false') self.set('gtd', 'backup_dir', u'~/.gtd/backups') self.read(os.path.expanduser(config_filename))
def __init__(self, path=None): ConfigParser.__init__(self) self.repos = [] self.main_repo = None if path: self.readfp(open(path)) self.config_repos()
def __init__(self, conf_file): ConfigParser.__init__(self) self.server = {} self.user = {} self.read(conf_file) self.server = self._map_config('Server') self.user = self._map_config('User') self.client = self._map_config('Client')
def __init__(self, *args, **kwargs): """Init with our specific interpolation class (for Python 3)""" try: interpolation = EnvironmentAwareInterpolation() kwargs['interpolation'] = interpolation except Exception: # Python 2 pass ConfigParser.__init__(self, *args, **kwargs)
def __init__(self, id): ConfigParser.__init__(self) try: userData = id.getUserData() except EC2DataRetrievalError: userData = '' self.fd = INIFileStub(userData, name='EC2UserData') self.fd.sanitize() self.readfp(self.fd)
def __init__(self, conffile, section): ConfigParser.__init__(self) self.conffile = conffile self.section = section self.setDefault() fp = file(self.conffile, "r") self.readfp(fp, self.conffile) self.readConf() fp.close()
def __init__(self, country_file): ConfigParser.__init__(self, defaults={ 'url': "", 'title': None, 'fill': "", 'stroke-width': "", 'stroke-fill': "" }) self.country_data = [] for file in country_file: if not os.path.exists(file): print 'Error: unable to find requested data file for %s' % file sys.exit() self.read(country_file) self.parse_file()
def parse_config_files(self, filenames=None): from ConfigParser import ConfigParser from distutils.core import DEBUG if filenames is None: filenames = self.find_config_files() if DEBUG: print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: if DEBUG: print " reading", filename parser.read(filename) for section in parser.sections(): options = parser.options(section) opt_dict = self.get_option_dict(section) for opt in options: if opt != '__name__': val = parser.get(section, opt) opt = string.replace(opt, '-', '_') opt_dict[opt] = (filename, val) # Make the ConfigParser forget everything (so we retain # the original filenames that options come from) -- gag, # retch, puke -- another good reason for a distutils- # specific config parser (sigh...) parser.__init__() # If there was a "global" section in the config file, use it # to set Distribution options. if self.command_options.has_key('global'): for (opt, (src, val)) in self.command_options['global'].items(): alias = self.negative_opt.get(opt) try: if alias: setattr(self, alias, not strtobool(val)) elif opt in ('verbose', 'dry_run'): # ugh! setattr(self, opt, strtobool(val)) except ValueError, msg: raise DistutilsOptionError, msg
def parse_config_files(self, filenames=None): from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files() if DEBUG: self.announce("Distribution.parse_config_files():") parser = ConfigParser() for filename in filenames: if DEBUG: self.announce(" reading %s" % filename) parser.read(filename) for section in parser.sections(): options = parser.options(section) opt_dict = self.get_option_dict(section) for opt in options: if opt != '__name__': val = parser.get(section,opt) opt = opt.replace('-', '_') opt_dict[opt] = (filename, val) # Make the ConfigParser 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.command_options: for (opt, (src, val)) in self.command_options['global'].items(): alias = self.negative_opt.get(opt) try: if alias: setattr(self, alias, not strtobool(val)) elif opt in ('verbose', 'dry_run'): # ugh! setattr(self, opt, strtobool(val)) else: setattr(self, opt, val) except ValueError, msg: raise DistutilsOptionError, msg
def __init__(self): ConfigParser.__init__(self) USER_PREFS_PATH = '~/.totalopenstation/totalopenstation.cfg' self.upref = os.path.expanduser(USER_PREFS_PATH) if os.path.exists(self.upref): self.read(self.upref) try: self.getvalue('model') except NoSectionError: self.initfile() elif not os.path.exists(os.path.dirname(self.upref)): os.mkdir(os.path.dirname(self.upref)) self.initfile() else: self.initfile()
def __init__(self, *args, **kwargs): """ :param args: :param kwargs: """ ConfigParser.__init__(self, *args, **kwargs) self.autoconfig_filename = None local = path.abspath("./sputnik.ini") root = path.abspath( path.join(path.dirname(__file__), "./server/config/sputnik.ini")) dist = path.abspath( path.join(path.dirname(__file__), "../../dist/config/sputnik.ini")) default = path.abspath( path.join(path.dirname(__file__), "../config/sputnik.ini")) self.autoconfig_files = [local, root, dist, default] self.autoconfig()
def SetFilename(self, basefilename): """ Build this ConfigParser object and load the file asked for. """ if platform == "win32": import win32api cfgpath = environ['APPDATA'] self.filename = path.join(cfgpath, basefilename) self.username = win32api.GetUserName() elif platform in ["linux2", "linux", "darwin"]: cfgpath = path.expanduser("~") self.filename = path.join(cfgpath, "." + basefilename) self.username = environ['LOGNAME'] else: self.filename = basefilename self.username = None ConfigParser.__init__(self) if path.isfile(self.filename): self.read(self.filename)
def __init__(self, filename, section, defaults=None): if defaults is None: defaults = {} ConfigParser.__init__(self) self.defaults = defaults self.defaultvalues = { 'string': '', 'int': 0, 'float': 0.0, 'boolean': False, 'color': None, 'bencode-list': [], 'bencode-string': '', 'bencode-fontinfo': { 'name': None, 'size': None, 'style': None, 'weight': None } } self.filename = filename self.section = section dirname = os.path.dirname(self.filename) if not os.access(dirname, os.F_OK): os.makedirs(dirname) if filename.endswith('abc.conf') and not os.access(filename, os.F_OK): defaults['minport'] = str(DEFAULTPORT) try: self.read(self.filename) except MissingSectionHeaderError: oldfile = open(self.filename, 'r') oldconfig = oldfile.readlines() oldfile.close() newfile = open(self.filename, 'w') newfile.write('[' + self.section + ']\n') newfile.writelines(oldconfig) newfile.close() self.read(self.filename) except ParsingError: self.tryRepair() self.read(self.filename)
def __init__(self, configName, baseConfigDir, mode=MODE_LOGICAL): """ :param configName: Name of the configuration object; e.g., "application.conf". :param baseConfigDir: Base configuration directory :param mode: configuration load mode: Config.MODE_LOGICAL or Config.MODE_OVERRIDE_ONLY. Defaults to Config.MODE_LOGICAL. :raises: ValueError if the baseline config corresponding to configName doesn't exist """ # Initialize base class ConfigParser.__init__(self) if not isinstance(configName, types.StringTypes): raise TypeError("Expected a string configName=%r, but got %r instead" % (configName, type(configName))) head, tail = os.path.split(configName) if head: raise TypeError("Hierarchical configuration object names not supported: " "%r" % (configName,)) if not tail: raise TypeError("Empty configuration object name: %r" % (configName,)) self._configName = configName self._mode = mode self._baselineLoaded = False # Namespace used in generating environment variable names for overriding # configuration settings (for testing) self._envVarNamespace = self._getEnvVarOverrideNamespace(configName) # Value of getmtime at the time when override config was last loaded self._lastModTime = 0 self.baseConfigDir = baseConfigDir self.loadConfig()
def __init__(self): ConfigParser.__init__(self) # # Regular expressions for parsing section headers and options. # self.SECTCRE = re.compile( r'\[' # [ r'(?P<header>[^]\s\.]+)\s*' # very permissive! r'(\"(?P<sub_section>[\w]+)\")?' # very permissive! r'\]' # ] ) self.OPTCRE = re.compile( r'\s*(?P<option>[^:=\s][^:=]*)' # very permissive! r'\s*(?P<vi>[:=])\s*' # any number of space/tab, # followed by separator # (either : or =), followed # by any # space/tab r'(?P<value>.*)$' # everything up to eol )
def __init__(self, *args): self.file = os.path.join(CONFIG_FILE_DIR, "owa.conf") # Setup default options self.timeoutms = 7000 self.showface = 1 self.blink = 0 self.mail_pos = "top-right" self.mail_opacity = 90 self.workspace = 0 self.mail_display = ":0.0" self.cal_display = ":0.0" self.folder_list = "inbox" self.debuglog = 0 ConfigParser.__init__(self, *args) if os.path.exists(self.file): self.read_config() else: self.save_config() self.mtime = os.path.getmtime(self.file)
def parse_config_files(self, filenames=None): from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files() if DEBUG: self.announce('Distribution.parse_config_files():') parser = ConfigParser() for filename in filenames: if DEBUG: self.announce(' reading %s' % filename) parser.read(filename) for section in parser.sections(): options = parser.options(section) opt_dict = self.get_option_dict(section) for opt in options: if opt != '__name__': val = parser.get(section, opt) opt = opt.replace('-', '_') opt_dict[opt] = (filename, val) parser.__init__() if 'global' in self.command_options: for opt, (src, val) in self.command_options['global'].items(): alias = self.negative_opt.get(opt) try: if alias: setattr(self, alias, not strtobool(val)) elif opt in ('verbose', 'dry_run'): setattr(self, opt, strtobool(val)) else: setattr(self, opt, val) except ValueError as msg: raise DistutilsOptionError, msg return
def __init__(self): ConfigParser.__init__(self) self.set('platform', detect_platform()) # TODO: move this out arch, board = detect_architecture() self.set('arch', arch) self.set('board', board)
def __init__(self): ConfigParser.__init__(self)
def __init__(self, name=''): PythonConfigParser.__init__(self) self._sections = OrderedDict() self.filename = None self._callbacks = [] self.name = name
def __init__(self, filename, *args, **kw): ConfigParser.__init__(self, *args, **kw) self.filename = filename if hasattr(self, '_interpolation'): self._interpolation = self.InterpolateWrapper(self._interpolation)
def __init__(self, defaults=None, printer=logger.info): ConfigParser.__init__(self, defaults) self.printer = printer
def __init__(self, *args, **kwargs): ConfigParser.__init__(self, *args, **kwargs) self.read(CONFIG_DIR + '/{}.cfg'.format(str(self)))
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults=defaults)
def __init__(self, config_filenames=__default_files__): ConfigParser.__init__(self) self.read([os.path.expanduser(i) for i in config_filenames])
def __init__(self, config_content=None): ConfigParser.__init__(self) self.optionxform = str if config_content is not None: self._set_content(config_content)
def __init__(self, defaults=None): ConfigParser.__init__(self, defaults) self._list_separator = ';'
def __init__(self): ConfigParser.__init__(self) self.load_config()
def __init__(self, filename=None): ConfigParser.__init__(self) self.filename = filename or os.path.expanduser('~/.calzion') self.read(self.filename)
def __init__(self, *args): ConfigParser.__init__(self, *args)
def __init__(self, id, clear_links=True, *args, **kwargs): ConfigParser.__init__(self, *args, **kwargs) self.id = id self._clear_links = clear_links
def __init__(self): PythonConfigParser.__init__(self) self._sections = OrderedDict() self.filename = None
def __init__(self, ignorecase_option=True, **kwargs): self._ignorecase_option = ignorecase_option ConfigParser.__init__(self, **kwargs)
def __init__(self, output_dir, defaults=None, printer=logger.info): ConfigParser.__init__(self, defaults) self.output_dir = output_dir self.printer = printer self.reverse_included = dict()
def __init__(self, cfgFile, cfgDefaults=None): """ cfgFile - string, fully specified configuration file name """ self.file = cfgFile ConfigParser.__init__(self, defaults=cfgDefaults)
def __init__(self, path): ConfigParser.__init__(self) self.read(path) self.data = self._asDict()