当前位置: 首页>>代码示例>>Python>>正文


Python PuddleConfig.sections方法代码示例

本文整理汇总了Python中puddlestuff.puddleobjects.PuddleConfig.sections方法的典型用法代码示例。如果您正苦于以下问题:Python PuddleConfig.sections方法的具体用法?Python PuddleConfig.sections怎么用?Python PuddleConfig.sections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在puddlestuff.puddleobjects.PuddleConfig的用法示例。


在下文中一共展示了PuddleConfig.sections方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_shortcuts

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def parse_shortcuts():
    def tr(s):
        s = s.replace('"', r'\"')
        return 'translate("Menus", "%s")' % s
        
    f = tempfile.NamedTemporaryFile('rb+')
    fn = f.name

    loadshortcuts.check_file(fn, ':/shortcuts')
    cparser = PuddleConfig(fn)

    action_strings = []
    setting = cparser.data
    for section in cparser.sections():
        if section.startswith('shortcut'):
            values = dict([(str(k), v) for k,v in  setting[section].items()])
            action_strings.append(tr(values['name']))
            if 'tooltip' in values:
                action_strings.append(tr(values['tooltip']))

    f.close()
    menus = tempfile.NamedTemporaryFile('rb+')
    fn = menus.name
    loadshortcuts.check_file(fn, ':/menus')
    cparser = PuddleConfig(fn)

    action_strings.extend(map(tr, cparser.data['menu']))
    menus.close()

    return action_strings
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:32,代码来源:update_translation.py

示例2: loadSettings

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
    def loadSettings(self, filename=None, actions=None):
        self._names = []
        self._hotkeys = []

        if filename is None:
            filename = os.path.join(ACTIONDIR, 'action_shortcuts')

        self._listbox.clear()
        cparser = PuddleConfig(filename)

        if actions is None:
            self._actions = load_actions()
        else:
            self._actions = actions

        from puddlestuff.puddletag import status
        if status['actions']:
            shortcuts = dict((unicode(a.text()), unicode(a.shortcut().toString()))
                for a in status['actions'])
        else:
            shortcuts = {}

        for section in sorted(cparser.sections()):
            if section.startswith('Shortcut'):
                name = cparser.get(section, NAME, 'Default')
                self._names.append(name)
                filenames = cparser.get(section, FILENAMES, [])
                shortcut = shortcuts.get(name, u'')
                self.addShortcut(name, filenames, shortcut, select=False)
                self._hotkeys.append(shortcut)
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:32,代码来源:action_shortcuts.py

示例3: loadsets

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def loadsets():
    algos = []
    if not os.path.exists(DUPEDIR):
        os.makedirs(DUPEDIR)
        saveset(**DEFAULTSET)
    files = [os.path.join(DUPEDIR, z) for z in os.listdir(DUPEDIR)]
    sets = []

    cparser = PuddleConfig()
    for f in files:
        cparser.filename = f
        name = cparser.get('info', 'name', '')
        disp = cparser.get('info', 'disp', [])
        algos = []
        for section in cparser.sections():
            if section == 'info':
                continue
            tags = cparser.get(section, 'tags', [])
            threshold = float(cparser.get(section, 'threshold', '0.85'))
            func = cparser.get(section, 'func', '')
            matchcase = cparser.get(section, 'matchcase', True)
            maintag = cparser.get(section, 'maintag', 'artist')
            algos.append(Algo(tags, threshold, func, matchcase))
        sets.append([name, disp, algos, maintag])
    return sets
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:27,代码来源:algwin.py

示例4: _load

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def _load(filename):
    cparser = PuddleConfig(filename)
    confirmations = {}
    for section in cparser.sections():
        if section.startswith(SECTION):
            name = cparser.get(section, NAME, u'')
            desc = cparser.get(section, DESC, u'')
            value = cparser.get(section, VALUE, True)
            confirmations[name] = [value, desc]
    return confirmations
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:12,代码来源:confirmations.py

示例5: load_settings

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def load_settings(filename=None, actions=None):
    if filename is None:
        filename = FILENAME

    if not os.path.exists(os.path.dirname(filename)):
        os.makedirs(os.path.dirname(filename))

    cparser = PuddleConfig(filename)

    actions = load_actions() if actions is None else actions

    shortcuts = []
    for section in sorted(cparser.sections()):
        if section.startswith(SHORTCUT_SECTION):
            name = cparser.get(section, NAME, 'Default')
            filenames = cparser.get(section, FILENAMES, [])
            shortcuts.append([name, filenames])
    return actions, shortcuts
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:20,代码来源:action_shortcuts.py

示例6: loadsettings

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def loadsettings(filepath = None):
    settings = PuddleConfig()
    if filepath:
        settings.filename = filepath
    else:
        settings.filename = os.path.join(CONFIGDIR, 'tagpanel')
    numrows = settings.get('panel','numrows',-1, True)
    if numrows > -1:
        sections = settings.sections()
        d = {}
        for row in xrange(numrows):
            section = unicode(row)
            tags = settings.get(section, 'tags', [''])
            titles = settings.get(section, 'titles', [''])
            d[row] = zip(titles, tags)
    else:
        titles = ['&Artist', '&Title', 'Al&bum', 'T&rack', u'&Year', "&Genre", '&Comment']
        tags = ['artist', 'title', 'album', 'track', u'year', 'genre', 'comment']
        newtags = zip(titles, tags)
        d = {0:[newtags[0]], 1:[newtags[1]], 2: [newtags[2]],
             3:[newtags[3], newtags[4], newtags[5]] ,
             4:[newtags[6]]}
    return d
开发者ID:keithgg,项目名称:puddletag,代码行数:25,代码来源:tagpanel.py

示例7: save_shortcut

# 需要导入模块: from puddlestuff.puddleobjects import PuddleConfig [as 别名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import sections [as 别名]
def save_shortcut(name, filenames):
    cparser = PuddleConfig(FILENAME)
    section = SHORTCUT_SECTION + unicode(len(cparser.sections()))
    cparser.set(section, NAME, name)
    cparser.set(section, FILENAMES, filenames)
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:7,代码来源:action_shortcuts.py


注:本文中的puddlestuff.puddleobjects.PuddleConfig.sections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。