コード例 #1
0
 def __init__(self, datadir, name="DistUpgrade.cfg", 
              override_dir=None, defaults_dir=None):
     SafeConfigParser.__init__(self)
     # we support a config overwrite, if DistUpgrade.cfg.dapper exists
     # and the user runs dapper, that one will be used
     from_release = subprocess.Popen(
         ["lsb_release", "-c", "-s"], stdout=subprocess.PIPE,
         universal_newlines=True).communicate()[0].strip()
     self.datadir = datadir
     if os.path.exists(name + "." + from_release):
         name = name + "." + from_release
     maincfg = os.path.join(datadir, name)
     # defaults are read first
     self.config_files = []
     if defaults_dir:
         for cfg in glob.glob(defaults_dir + "/*.cfg"):
             self.config_files.append(cfg)
     # our config file
     self.config_files += [maincfg]
     # overrides are read later
     if override_dir is None:
         override_dir = CONFIG_OVERRIDE_DIR
     if override_dir is not None:
         for cfg in glob.glob(override_dir + "/*.cfg"):
             self.config_files.append(cfg)
     self.read(self.config_files)
コード例 #2
0
ファイル: config.py プロジェクト: jbms/ofxclient
 def __init__(self, keyring_name='ofxclient',
              keyring_available=KEYRING_AVAILABLE, **kwargs):
     ConfigParser.__init__(self, interpolation = None)
     self.keyring_name = keyring_name
     self.keyring_available = keyring_available
     self._unsaved = {}
     self.keyring_name = keyring_name
コード例 #3
0
ファイル: config.py プロジェクト: c-goldschmidt/imgurstream
    def __init__(self, config_file=None):
        ConfigParser.__init__(self)

        self.config_file = config_file

        if config_file is not None:
            self.read(config_file)
コード例 #4
0
ファイル: client.py プロジェクト: brigoldberg/pyeapi
    def __init__(self, filename=None):
        SafeConfigParser.__init__(self)

        self.filename = filename
        self.tags = dict()

        self.autoload()
コード例 #5
0
ファイル: sync.py プロジェクト: bluec0re/python-sftpsync
 def __init__(self, fname, name):
     if sys.version_info.major >= 3:
         super(SettingsFile, self).__init__()
     else:
         ConfigParser.__init__(self)
     self.fname = fname
     self.name = name
コード例 #6
0
    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")
コード例 #7
0
ファイル: lib_losoto.py プロジェクト: revoltek/losoto
    def __init__(self, parsetFile):
        ConfigParser.__init__(self, inline_comment_prefixes=('#',';'))

        config = StringIO()
        # add [_global] fake section at beginning
        config.write('[_global]\n'+open(parsetFile).read())
        config.seek(0, os.SEEK_SET)
        self.readfp(config)
コード例 #8
0
ファイル: config.py プロジェクト: Turgon37/OpenVPN_UAM
    def __init__(self):
        """Constructor : init a new config parser
    """
        ConfigParser.__init__(self)
        self.optionxform = str

        # boolean that indicates if the configparser is available
        self.__is_config_loaded = False
コード例 #9
0
    def __init__(self, filename):
        ConfigParser.__init__(self, {'max_body': '2048', 'headers_to_sign': None})
        logger.debug("loading edgerc from %s", filename)

        self.read(filename)
        self.validate()

        logger.debug("successfully loaded edgerc")
コード例 #10
0
ファイル: marketbook.py プロジェクト: qubase/marketbook
 def __init__(self):
     ConfigParser.__init__(self)
     self.id = None
     self.name = None
     self.on = False
     self.force = False
     self.ttl = 365
     self.sleep = 0
コード例 #11
0
ファイル: config.py プロジェクト: aaae/kazam
 def __init__(self):
     ConfigParser.__init__(self, self.DEFAULTS[0]['keys'])
     if not os.path.isdir(self.CONFIGDIR):
         os.makedirs(self.CONFIGDIR)
     if not os.path.isfile(self.CONFIGFILE):
         self.create_default()
         self.write()
     self.read(self.CONFIGFILE)
コード例 #12
0
ファイル: __init__.py プロジェクト: mozilla-services/konfig
 def __init__(self, filename):
     # let's read the file
     ConfigParser.__init__(self, **self._configparser_kwargs())
     if isinstance(filename, string_types):
         self.filename = filename
         self.read(filename)
     else:
         self.filename = None
         self.read_file(filename)
コード例 #13
0
ファイル: config.py プロジェクト: JaredKerim-Mozilla/ichnaea
 def __init__(self, filename):
     ConfigParser.__init__(self)
     # let's read the file
     if isinstance(filename, basestring):
         self.filename = filename
         self.read(filename)
     else:  # pragma: no cover
         self.filename = None
         self.read_file(filename)
コード例 #14
0
ファイル: common.py プロジェクト: nphilipp/productmd
 def __init__(self, *args, **kwargs):
     if sys.version_info[0] == 2:
         if sys.version_info[:2] >= (2, 6):
             # SafeConfigParser(dict_type=) supported in 2.6+
             kwargs["dict_type"] = SortedDict
         ConfigParser.__init__(self, *args, **kwargs)
     else:
         kwargs["dict_type"] = SortedDict
         super(ConfigParser, self).__init__(*args, **kwargs)
     self.seen = set()
コード例 #15
0
ファイル: dist.py プロジェクト: 5outh/Databases-Fall2014
    def parse_config_files(self, filenames=None):
        from configparser import ConfigParser

        # Ignore install directory options if we have a venv
        if sys.prefix != sys.base_prefix:
            ignore_options = [
                'install-base', 'install-platbase', 'install-lib',
                'install-platlib', 'install-purelib', 'install-headers',
                'install-scripts', 'install-data', 'prefix', 'exec-prefix',
                'home', 'user', 'root']
        else:
            ignore_options = []

        ignore_options = frozenset(ignore_options)

        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__' and opt not in ignore_options:
                        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 as msg:
                    raise DistutilsOptionError(msg)
コード例 #16
0
    def __init__(self, configfile, nodefaults = False):
        """
        Reads settings from INI file, compares with setup defaults,
        adds missing settings

        :param configfile: path and name of INI file
        :param nodefaults: if true, no defaults are written to the INI file,
                    also, if INI is missing, none will be created
        """

        # parse settings ONLY for first time initialization of
        # configuration object, never read twice unnecessary
        if ConfigHandler.cfg is None:
            ConfigParser.__init__(self, interpolation=None)

            self.configfile = configfile
            self.nodefaults = nodefaults

            # read settings
            self.logger.debug("Trying to read configuration file: " + self.configfile)
            try:
                with open(self.configfile) as file:
                    self.read_file(file)
                    self.logger.info("Configuration file successfully loaded.")
            except IOError:
                self.logger.error("Configuration file could not be loaded.")

            # apply new/missing defaults
            if not self.nodefaults:
                for section, options in self._initial_settings.items():
                    if not self.has_section(section):
                        self.add_section(section)
                    for option, value in options.items():
                        if not self.has_option(section, option):
                            self.set(section, option, str(value))

            # check if INI pre-python
            if LooseVersion(self.prg_version) < "8.0.0":
                self.convert_old_format()

            if LooseVersion(self.prg_version) < "8.2.5":
                self.convert_to_opsi41()

            # check current version to version in INI file
            if LooseVersion(self.get("version", "ini")) < oPB.PROGRAM_VERSION:
                self.logger.debug("Old version: " + self.prg_version)
                self.logger.debug("Current version: " + oPB.PROGRAM_VERSION)
                self.prg_version = oPB.PROGRAM_VERSION

            # get usable passwords, if there are any
            self.passwords('decrypt')

            # after all, save parser in class variabel
            ConfigHandler.cfg = self
コード例 #17
0
ファイル: config.py プロジェクト: captin411/ofxclient
 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
コード例 #18
0
    def __init__(self, config_dir=None):
        ConfigParser.__init__(self, CONFIG_DEFAULTS)
        self.changed = False # Flag for self.config changed status
        self.delay_save_timeout = 10

        if config_dir is not None:
            self.config_dir = config_dir

        if not os.path.exists(self.config_dir):
            os.makedirs(self.config_dir)
        self.config_fname = os.path.join(self.config_dir, self.config_fname)
        self.load_config()
コード例 #19
0
    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))
コード例 #20
0
ファイル: config.py プロジェクト: SOFTowaha/ichnaea
    def __init__(self, filename):
        """
        A :class:`configparser.ConfigParser` subclass with added
        functionality.

        :param filename: The path to a configuration file.
        """
        ConfigParser.__init__(self)
        # let's read the file
        if isinstance(filename, string_types):
            self.filename = filename
            self.read(filename)
        else:  # pragma: no cover
            self.filename = None
            self.read_file(filename)
コード例 #21
0
ファイル: PipeConfig.py プロジェクト: ablab/quast
    def __init__(self, conf_file):
        try:
            super(PipeConfig, self).__init__()
        except TypeError:
            ConfigParser.__init__(self)  # Python 2.7

        self.conf_file = conf_file

        try:
            self.readfp(open(self.conf_file), 'r')  # deprecated but kept for 2.7
        except IOError as Err:
            if Err.errno == 2:
                pass
            else:
                raise Err
コード例 #22
0
ファイル: conf.py プロジェクト: leighmacdonald/msort
    def __init__(self, config_path="~/.msort.conf"):
        """ Initialize the configuration. If a existing one doesnt exit a new one will be created
        in, by default, the users home directory, unless otherwise specified by the configPath
        parameter

        :param config_path: Location of the config file
        :type config_path: str
        """
        ConfigParser.__init__(self)
        self.log = getLogger(__name__)
        config_path = expanduser(config_path)
        if not exists(config_path):
            raise ConfigError('Invalid config file, doesnt exist: {0}'.format(config_path))
        self.log.debug('Reading config: {0}'.format(config_path))
        self.read(config_path)
        self._rules = self.parseRules()
コード例 #23
0
ファイル: conf.py プロジェクト: Kopachris/pyfeeder
    def __init__(self):
        self.fname = os.path.expanduser('~/.gvoice')

        if not os.path.exists(self.fname):
            try:
                f = open(self.fname, 'w')
            except IOError:
                return
            f.write(settings.DEFAULT_CONFIG)
            f.close()

        ConfigParser.__init__(self)
        try:
            self.read([self.fname])
        except IOError:
            return
コード例 #24
0
ファイル: config_file.py プロジェクト: asiderop/dcamp
    def __init__(self):
        self.logger = logging.getLogger('dcamp.types.config')
        ConfigParser.__init__(self, allow_no_value=True, delimiters='=')

        self.isvalid = False
        self.__num_errors = 0
        self.__num_warns = 0

        self.global_cfg = {}
        self.metrics = {}
        self.groups = {}

        self.kvdict = {}

        self.metric_sections = {}
        self.group_sections = {}
コード例 #25
0
    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 as msg:
                    raise DistutilsOptionError(msg)
コード例 #26
0
    def __init__(self, configfile=None):
        """ Check the config file and include the defaults. """
        self.CONFIG_FILES = DEFAULT_CFG_FILES

        if configfile is not None:
            if not os.path.exists(configfile):
                raise IOError("Configuration File does not exist.")
            
            self.CONFIG_FILES.append(configfile)

        ## now set up the parent class using defaults ##
        ConfigParser.__init__(self)
        #reset internal configparser variable...
        if sys.version_info[0]==3 and sys.version_info[1]<2:            
            # i know thats bad form, but this is what happens when
            # you dont think ahead 
            self._sections=DEFAULT_CONFIGS
        else:
            #this is in python3.2+ only
            self.read_dict(DEFAULT_CONFIGS) 
コード例 #27
0
ファイル: settings.py プロジェクト: gimu/hitagi-reader.py
    def __init__(self):
        ConfigParser.__init__(self, allow_no_value = True)
        self.optionxform = str
        self.read('config.ini', encoding='utf-8')
        self.check()

        self.defaults = """
        [Hotkeys]
        Exit = Ctrl+X
        Fullscreen = F
        Next = Right
        Previous = Left
        Directory = D
        Slideshow = F3
        Zoom in = Ctrl++
        Zoom out = Ctrl+-
        Zoom original = Ctrl+0
        """
        
        self.locale_code = ['en_US', 'de_DE', 'ja_JP', 'vi_VN']
        self._update_funcs = []
コード例 #28
0
ファイル: config.py プロジェクト: HSOFEUP/artos
 def __init__(self, iniFile):
     """Initializes a new configuration instance and sets appropriate default values."""
     
     SafeConfigParser.__init__(self, allow_no_value = True)
     self.iniFileName = iniFile
     self.read(iniFile)
     self.defaults = { }
     self.applyDefaults({
         'libartos' : {
             'model_dir'             : _Config.findModelDir(),
             'library_path'          : None,
             'debug'                 : 0,
         },
         'ImageNet' : {
             'repository_directory'  : None
         },
         'GUI' : {
             'max_video_width'       : 640,
             'max_video_height'      : 480
         }
     });
コード例 #29
0
ファイル: myconfig.py プロジェクト: fdouchant/myPyApps
    def __init__(self, name, config_path=DEFAULT_PATH, cfg_ext=DEFAULT_CFG_EXT, default_ext=DEFAULT_DEFAULT_EXT):
        """
        Create new MyConfigParser that extends ConfigParser.SafeConfigParser
        
        @param name: name of the config to look for and load
        @param config_path: path where to find the config files. Sort by order of importance.
        This will be used to first load default configuration and fail in there isn't any.
        Then it will load all user configurations in the respecting order of the list. Overriding default and previous user configuration.   
        @param cfg_ext: extension for the user configuration file.
        @param default_ext: extension for the default configuration file.
        
        @raise MyConfigParserException: if no default configuration found. 
        """
        ConfigParser.__init__(self)
        
        self.name = name
        self.cfg_filename = name + cfg_ext
        self.default_filename = name + default_ext
        self.config_path = config_path
        if not hasattr(self.config_path, "__iter__"):
            LOGGER.debug("[%s] convert single config_path to set" % self.name)
            self.config_path = (config_path, )
        
        LOGGER.debug("[%s] remove duplicate configuration path" % self.name)
        self.config_path = list(set(self.config_path))
        
        LOGGER.debug("[%s] find and load default cfg file" % self.name)
        # in list order to respect path importance
        for path in self.config_path:
            full_path = join(path, self.default_filename)
            if isfile(full_path):
                self.default_path = full_path
                LOGGER.debug("[%s] default_path = %s" % (self.name, self.default_path))
                break
        else:
            raise MyConfigParserException(self.name, "Couldn't find default config file")

        # call reload
        self.reload()
コード例 #30
0
    def __init__(self):
        ConfigParser.__init__(self,description="Configuration options description")
        self.add_option('fetchto', default=None, help="Destination for fetched modules", type='')
        #self.add_option('root_module', default=None, help="Path to root module for currently parsed", type='')

        self.add_delimiter()
        self.add_option('syn_name', default=None, help="Name of the folder at remote synthesis machine", type='')
        self.add_option('syn_device', default=None, help = "Target FPGA device", type = '');
        self.add_option('syn_grade', default=None, help = "Speed grade of target FPGA", type = '');
        self.add_option('syn_package', default=None, help = "Package variant of target FPGA", type = '');
        self.add_option('syn_top', default=None, help = "Top level module for synthesis", type = '');
        self.add_option('syn_project', default=None, help = "Project file (.xise, .ise, .qpf)", type = '');

        self.add_delimiter()
        self.add_option('include_dirs', default=None, help="Include dirs for Verilog sources", type = [])
        self.add_type('include_dirs', type = "")

        self.add_delimiter()
# Modification here!
#		self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '');
        self.add_option('vsim_opt', default="", help="Additional options for vsim", type='')
        self.add_option('vcom_opt', default="", help="Additional options for vcom", type='')
        self.add_option('vlog_opt', default="", help="Additional options for vlog", type='')
        self.add_option('vmap_opt', default="", help="Additional options for vmap", type='')

        self.add_delimiter()
        self.add_option('modules', default={}, help="List of local modules", type={})
        self.add_option('target', default=None, help="What is the target architecture", type='')
        self.add_option('action', default=None, help="What is the action that should be taken (simulation/synthesis)", type='')

        self.add_allowed_key('modules', key="svn")
        self.add_allowed_key('modules', key="git")
        self.add_allowed_key('modules', key="local")

        #self.add_delimiter()
        self.add_option('library', default="work",
        help="Destination library for module's VHDL files", type="")
        self.add_option('files', default=[], help="List of files from the current module", type='')
        self.add_type('files', type=[])
コード例 #31
0
ファイル: fgoIniParser.py プロジェクト: showhandss/FGO-py
from configparser import ConfigParser
IniParser = type(
    'IniParser', (ConfigParser, ), {
        '__init__':
        lambda self, file:
        (ConfigParser.__init__(self), self.read(file, 'utf-8'))[0],
        'optionxform':
        lambda self, optionstr: optionstr
    })
コード例 #32
0
 def __init__(self, share_config=None, *args, **kwargs):
     SafeConfigParser.__init__(self, *args, **kwargs)
     self._cfg_share = share_config
コード例 #33
0
 def __init__(self, working_dir=None):
     ConfigParser.__init__(self, converters=converters, interpolation=ExtendedInterpolation())
     self.read(CONFIG_FILE_PATH)
     self._cache = {}
     self._working_dir = os.path.dirname(__file__) if working_dir is None else working_dir
コード例 #34
0
 def __init__(self, path):
     ConfigParser.__init__(
         self)  # ConfigParser is an old-style class... Can't user 'super'
     self.path = path
     self.readfp(ConfigHeader(open(path)))
コード例 #35
0
 def __init__(self, *args, **kwargs):
     ConfigParser.__init__(self, *args, **kwargs)
コード例 #36
0
 def __init__(self, path: str):
     ConfigParser.__init__(self)
     self.file = os.path.join(path, 'config_temp.ini')
     self.read([self.file])
     self.set_property('runtime', 'last_use',
                       str(datetime.datetime.utcnow()))
コード例 #37
0
 def __init__(self, defaults, *args, **kwargs):
     self.defaults = defaults
     ConfigParser.__init__(self, *args, **kwargs)
コード例 #38
0
ファイル: utils.py プロジェクト: chrisking94/pydmlib
 def __init__(self, file_path, *args, **kwargs):
     ConfigParser.__init__(self, *args, **kwargs)
     self.file_path = file_path
     if os.path.exists(file_path):
         self.read(file_path)
コード例 #39
0
 def __init__(self, filepath):
     ConfigParser.__init__(self)
     self.filepath = filepath
     if exists(filepath):
         self.read(filepath)
コード例 #40
0
    def __init__(self, default_config, *args, **kwargs):
        ConfigParser.__init__(self, *args, **kwargs)

        if default_config is not None:
            self.read_string(default_config)
コード例 #41
0
 def __init__(self):
     ConfigParser.__init__(self, interpolation=ExtendedInterpolation())
     if not sys.gettrace():
         self.read([self.PATH_ENV, self.PATH_INI])
     else:
         self.read([self.PATH_ENV_DEBUG, self.PATH_INI_DEBUG])
コード例 #42
0
 def __init__(self):
     ConfigParser.__init__(self)
     self.read(
         self.CONFIG_FILE if not sys.gettrace() else self.CONFIG_FILE_DEV)
コード例 #43
0
 def __init__(self, defaults={}):
     ConfigParser.__init__(self)
     self.defaults = defaults
コード例 #44
0
 def __init__(self, *args, **kwargs):
     BetterLogger.__init__(self)
     ConfigParser.__init__(self, *args, **kwargs)
コード例 #45
0
 def __init__(self, defaults, *args, **kwargs):
     self.defaults = defaults
     ConfigParser.__init__(self, *args, **kwargs)
     self.is_validated = False
コード例 #46
0
ファイル: dist.py プロジェクト: thoonk/Algorithm
    def _parse_config_files(self, filenames=None):  # noqa: C901
        """
        Adapted from distutils.dist.Distribution.parse_config_files,
        this method provides the same functionality in subtly-improved
        ways.
        """
        from configparser import ConfigParser

        # Ignore install directory options if we have a venv
        ignore_options = (
            []
            if sys.prefix == sys.base_prefix
            else [
                'install-base',
                'install-platbase',
                'install-lib',
                'install-platlib',
                'install-purelib',
                'install-headers',
                'install-scripts',
                'install-data',
                'prefix',
                'exec-prefix',
                'home',
                'user',
                'root',
            ]
        )

        ignore_options = frozenset(ignore_options)

        if filenames is None:
            filenames = self.find_config_files()

        if DEBUG:
            self.announce("Distribution.parse_config_files():")

        parser = ConfigParser()
        parser.optionxform = str
        for filename in filenames:
            with io.open(filename, encoding='utf-8') as reader:
                if DEBUG:
                    self.announce("  reading {filename}".format(**locals()))
                parser.read_file(reader)
            for section in parser.sections():
                options = parser.options(section)
                opt_dict = self.get_option_dict(section)

                for opt in options:
                    if opt == '__name__' or opt in ignore_options:
                        continue

                    val = parser.get(section, opt)
                    opt = self.warn_dash_deprecation(opt, section)
                    opt = self.make_option_lowercase(opt, section)
                    opt_dict[opt] = (filename, val)

            # Make the ConfigParser forget everything (so we retain
            # the original filenames that options come from)
            parser.__init__()

        if 'global' not in self.command_options:
            return

        # If there was a "global" section in the config file, use it
        # to set Distribution options.

        for (opt, (src, val)) in self.command_options['global'].items():
            alias = self.negative_opt.get(opt)
            if alias:
                val = not strtobool(val)
            elif opt in ('verbose', 'dry_run'):  # ugh!
                val = strtobool(val)

            try:
                setattr(self, alias or opt, val)
            except ValueError as e:
                raise DistutilsOptionError(e) from e
コード例 #47
0
 def __init__(self, cfgFile, cfgDefaults=None):
     """
     cfgFile - string, fully specified configuration file name
     """
     self.file = cfgFile
     ConfigParser.__init__(self, defaults=cfgDefaults, strict=False)
コード例 #48
0
 def __init__(self, defaults=None):
     ConfigParser.__init__(self, defaults=defaults)
コード例 #49
0
 def __init__(self, path: str):
     ConfigParser.__init__(self)
     self.file = os.path.join(path, 'config_static.ini')
     self.read([self.file])
コード例 #50
0
 def __init__(self, defaults=None):
     ConfigParser.__init__(self, defaults=defaults)
     self.add_sec = "Additional"
コード例 #51
0
 def __init__(self, filename):
     ConfigParser.__init__(self,
                           defaults=None)  #重写optionxform的方法,让option输出区分大小写
     super().__init__()
     self.filename = filename
     self.read(filename)
コード例 #52
0
    def parse_config_files(self, filenames=None):
        from configparser import ConfigParser

        # Ignore install directory options if we have a venv
        if sys.prefix != sys.base_prefix:
            ignore_options = [
                "install-base",
                "install-platbase",
                "install-lib",
                "install-platlib",
                "install-purelib",
                "install-headers",
                "install-scripts",
                "install-data",
                "prefix",
                "exec-prefix",
                "home",
                "user",
                "root",
            ]
        else:
            ignore_options = []

        ignore_options = frozenset(ignore_options)

        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__" and opt not in ignore_options:
                        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 as msg:
                    raise DistutilsOptionError(msg)
コード例 #53
0
ファイル: Parser.py プロジェクト: thearagon/pythia
 def __init__(self, root, defaults=None, macros=None):
     ConfigParser.__init__(
         self, defaults, empty_lines_in_values=False, strict=False)
     if macros is None:
         macros = dict()
     self._sections = Parser.SectionDict(root, macros)
コード例 #54
0
ファイル: config.py プロジェクト: praleena/newpython
 def __init__(self, cfgFile, cfgDefaults=None):
     """
     cfgFile - string, fully specified configuration file name
     """
     self.file = cfgFile  # This is currently '' when testing.
     ConfigParser.__init__(self, defaults=cfgDefaults, strict=False)
コード例 #55
0
 def __init__(self):
     ConfigParser.__init__(self, dict_type=MultiDict)
コード例 #56
0
ファイル: configuration.py プロジェクト: juvoinc/airflow
 def __init__(self, *args, **kwargs):
     ConfigParser.__init__(self, *args, **kwargs)
     self.read_string(parameterized_config(DEFAULT_CONFIG))
     self.is_validated = False
コード例 #57
0
 def __init__(self):
     ConfigParser.__init__(self)
     self.config = ConfigParser()
     self.config.read('files\\config.ini')
コード例 #58
0
    def __init__(self, config_content=None):
        ConfigParser.__init__(self)
        self.optionxform = str

        if config_content is not None:
            self._set_content(config_content)
コード例 #59
0
ファイル: configutil.py プロジェクト: zhuwentao0612/factorset
 def __init__(self):
     ConfigParser.__init__(self)
コード例 #60
0
    def __init__(self, *args, **kwargs):

        # supplied by cryptkeeper_access_methods
        self.ck = kwargs.pop('ck', None)

        ConfigParser.__init__(self, *args, **kwargs)