Example #1
0
    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')
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
 def __init__(self,config):
     '''
         必须初始化ConfigParser类,否则无法获取section
     '''
     ConfigParser.__init__(self)
     self.ftpvars={}
     self.config = config
Example #5
0
 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))
Example #6
0
    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, filename):
     ConfigParser.__init__(self)
     self.filename = filename
     try:
         self.read(filename)
     except:
         pass
Example #8
0
 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)
Example #9
0
    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__()
Example #10
0
 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()
Example #11
0
 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))
Example #12
0
 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()
Example #13
0
 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
Example #14
0
 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)
Example #15
0
 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)
Example #16
0
    def __init__(self):
        '''
        Gets configuration of pertinent services and roles
        '''
        ConfigParser.__init__(self)

        self.optionxform = str
        self.read('/root/bin/cm_client.ini')
Example #17
0
 def __init__(self):
     self.fname = os.path.expanduser('./config')
         
     ConfigParser.__init__(self)
     try:
         self.read([self.fname])
     except IOError:
         return
 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])
Example #19
0
 def __init__(self):
     self.fp = StringIO.StringIO(settings.DEFAULT_CONFIG)
         
     ConfigParser.__init__(self)
     try:
         self.readfp(self.fp, "internal")
     except IOError:
         return
Example #20
0
 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)
Example #21
0
    def __init__(self):
        """
        Gets configuration of pertinent services and roles
        """
        ConfigParser.__init__(self)

        self.optionxform = str
        self.read("/root/bin/cm_client.ini")
Example #22
0
 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, 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')
Example #24
0
 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)
Example #25
0
 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')
Example #26
0
    def __init__(self, configFilename):
        ConfigParser.__init__(self)
        self.configFilename = configFilename

        self._options = {
            'pre_resolve_workers' : True,
            'buffer_size'         : DEFAULT_BUFFER_SIZE,
        }
        self._mappings = {}
Example #27
0
    def __init__(self, path=None):
        ConfigParser.__init__(self)

        self.repos = []
        self.main_repo = None

        if path:
            self.readfp(open(path))
            self.config_repos()
Example #28
0
 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)
Example #29
0
File: auth.py Project: allgi/mmc
 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()
Example #30
0
    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))