コード例 #1
0
ファイル: loader.py プロジェクト: muma378/moose
 def get_value(self):
     if six.PY2:
         # type of str
         value = self.value.decode(self.default_charset)
     else:
         # type of str (unicode in python3)
         value = self.value
     # splited by a sep such as ','
     return tuple(stripl(value.split(settings.CONFIG_LIST_SEP)))
コード例 #2
0
ファイル: loader.py プロジェクト: yuwenhui/moose
    def _parse(self):
        # A wrapper to parse config files
        config_parser = ConfigParser.ConfigParser()
        config_parser.read(self.path)

        # TODO: a more clear format of config
        # Config always starts with a [meta] section, which lists the following
        # sections to use in the option `keys`
        sections_str = config_parser.get(settings.CONFIG_META_KEYWORD,
                                         settings.CONFIG_KEYS_KEYWORD)
        sections = stripl(sections_str.split(settings.CONFIG_LIST_SEP))

        # init a config instance, it contains the fields in file only
        config = Config()
        section_parser = SectionParser(config_parser)
        for section in sections:
            setattr(config, section, section_parser.parse(section))

        return config
コード例 #3
0
ファイル: loader.py プロジェクト: yuwenhui/moose
 def get_value(self):
     if self.value.find(settings.CONFIG_RANGE_SEP) == -1:
         raise ImproperlyConfigured("Format of range is incorrect.")
     start, end = stripl(self.value.split(settings.CONFIG_RANGE_SEP))
     return range(int(start), int(end) + 1)
コード例 #4
0
ファイル: loader.py プロジェクト: yuwenhui/moose
 def get_value(self):
     # splited by a sep such as ','
     return tuple(stripl(self.value.split(settings.CONFIG_LIST_SEP)))