コード例 #1
0
 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
コード例 #2
0
ファイル: config.py プロジェクト: mathieui/poezio
 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
コード例 #3
0
ファイル: config.py プロジェクト: Perdu/poezio
 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
コード例 #4
0
ファイル: config.py プロジェクト: stressrelief/poezio
 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
コード例 #5
0
ファイル: config.py プロジェクト: labedz/poezio
 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)
コード例 #6
0
    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"""
コード例 #7
0
ファイル: config.py プロジェクト: kmohrf/vmm
 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)
         }
     }
コード例 #8
0
    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)
コード例 #9
0
    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())
コード例 #10
0
 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 = []
コード例 #11
0
ファイル: lib_losoto.py プロジェクト: tammojan/losoto
    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)
コード例 #12
0
 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)
コード例 #13
0
ファイル: sql.py プロジェクト: danBLA/fuglu
    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)
コード例 #14
0
 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))
コード例 #15
0
ファイル: parser.py プロジェクト: cfauchard/zeus
    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))
コード例 #16
0
 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)
コード例 #17
0
ファイル: config.py プロジェクト: David96/poezio_lima-gold
 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)
コード例 #18
0
 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)
コード例 #19
0
ファイル: settings.py プロジェクト: unkie/exaile
    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()
コード例 #20
0
 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
コード例 #21
0
    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()
コード例 #22
0
ファイル: CraftBar.py プロジェクト: WesRoach/KortsCalculator
 def __init__(self, defaults=None):
     RawConfigParser.__init__(self, defaults, strict=False)
コード例 #23
0
ファイル: config.py プロジェクト: bootc/nrpe-ng
 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__
コード例 #24
0
 def __init__(self, config_file):
     RawConfigParser.__init__(self, strict=False)
     self.read(os.path.join("conf", "default.conf"))
     self.read(config_file)
コード例 #25
0
ファイル: config.py プロジェクト: DirkR/capturadio
 def __init__(self, *args, **kwargs):
     RawConfigParser.__init__(self, *args, **kwargs)
コード例 #26
0
 def __init__(self):
     # RawConfigParser is old-style class, so don't use super()
     RawConfigParser.__init__(self)
     self.read(INI_PATH)
コード例 #27
0
 def __init__(self):
     return _RawConfigParser.__init__(self, allow_no_value = True)    
コード例 #28
0
 def __init__(self):
     return _RawConfigParser.__init__(self, allow_no_value=True)
コード例 #29
0
ファイル: config.py プロジェクト: MrMalina/Source.Python
    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)
コード例 #30
0
    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)
コード例 #31
0
ファイル: config.py プロジェクト: DarkDNA/Schongo
	def __init__(self, *a, **kw):
		RawConfigParser.__init__(self, *a, **kw);
コード例 #32
0
ファイル: sql.py プロジェクト: oasiswork/fuglu
 def __init__(self, config, suspect):
     RawConfigParser.__init__(self)
     self.suspect = suspect
     self.logger = logging.getLogger('fuglu.sql.dbconfig')
     self.cloneFrom(config)
コード例 #33
0
 def __init__(self, redis_pool):
     RawConfigParser.__init__(self)
     self.redis = redis_pool
コード例 #34
0
ファイル: lookitconfig.py プロジェクト: josephwegner/lookit
 def __init__(self, filename=CONFIG_FILE):
     RawConfigParser.__init__(self)
     self.filename = filename
     self.load()
コード例 #35
0
 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)
コード例 #36
0
 def __init__(self, *a, **kw):
     RawConfigParser.__init__(self, *a, **kw)
コード例 #37
0
ファイル: cli.py プロジェクト: healthchecks/hchk
 def __init__(self):
     # RawConfigParser is old-style class, so don't use super()
     RawConfigParser.__init__(self)
     self.read(INI_PATH)
コード例 #38
0
ファイル: config.py プロジェクト: WeblateOrg/wlc
 def __init__(self, section="weblate"):
     """Construct WeblateConfig object."""
     RawConfigParser.__init__(self, delimiters=("=",))
     self.section = section
     self.set_defaults()
コード例 #39
0
ファイル: config.py プロジェクト: sit79/podhorst
 def __init__(self, *args, **kwargs):
     RawConfigParser.__init__(self, *args, **kwargs)
コード例 #40
0
ファイル: configparser.py プロジェクト: xoriole/tribler
 def __init__(self, *args, **kwargs):
     RawConfigParser.__init__(self, *args, **kwargs)
     self.filename = None
     self.callback = None
     self.lock = RLock()
コード例 #41
0
ファイル: plugin.py プロジェクト: adamkijak/poezio
 def __init__(self, filename, module_name):
     self.file_name = filename
     self.module_name = module_name
     RawConfigParser.__init__(self, None)
     self.read()
コード例 #42
0
ファイル: config.py プロジェクト: tehmaze-labs/wright
 def __init__(self, env, platform):
     RawConfigParser.__init__(self)
     self.env = env
     self.platform = platform
コード例 #43
0
 def __init__(self, config, suspect):
     RawConfigParser.__init__(self)
     self.suspect = suspect
     self.logger = logging.getLogger('fuglu.sql.dbconfig')
     self.cloneFrom(config)
コード例 #44
0
ファイル: config.py プロジェクト: nijel/odorik
 def __init__(self, section='odorik'):
     """Construct OdorikConfig object."""
     RawConfigParser.__init__(self)
     self.section = section
     self.set_defaults()
コード例 #45
0
ファイル: config.py プロジェクト: mbehrle/wlc
 def __init__(self, section='weblate'):
     """Construct WeblateConfig object."""
     RawConfigParser.__init__(self, delimiters=('=', ))
     self.section = section
     self.set_defaults()
コード例 #46
0
 def __init__(self, defaults=DEFAULTS):
     RawConfigParser.__init__(self)
     self.readfp(io.StringIO(defaults))
     self.readonce = False
コード例 #47
0
    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__')
コード例 #48
0
ファイル: utils.py プロジェクト: 2216288075/meiduo_project
    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__')