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


Python puddleobjects.PuddleConfig类代码示例

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


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

示例1: closeEvent

    def closeEvent(self, e):
        preview_msg = translate('Previews',
            'Some files have uncommited previews. '
            'These changes will be lost once you exit puddletag. <br />'
            'Do you want to exit without writing those changes?<br />')
        if tagmodel.has_previews(parent=self, msg=preview_msg):
            e.ignore()
            return False
        controls = PuddleDock._controls
        for control in PuddleDock._controls.values():
            if hasattr(control, 'saveSettings'):
                try:
                    control.saveSettings(self)
                except TypeError:
                    control.saveSettings()

        cparser = PuddleConfig()
        settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat)
        if self._lastdir:
            cparser.set('main', 'lastfolder', unicode(self._lastdir[0], 'utf8'))
        cparser.set("main", "maximized", self.isMaximized())
        settings.setValue('main/state', QVariant(self.saveState()))

        headstate = self._table.horizontalHeader().saveState()
        settings.setValue('table/header', QVariant(headstate))
        genres.save_genres(status['genres'])
        e.accept()
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:27,代码来源:puddletag.py

示例2: loadSettings

    def loadSettings(self):
        settings = QSettings(QT_CONFIG, QSettings.IniFormat)
        header = self.header()
        header.restoreState(settings.value('dirview/header').toByteArray())
        hide = settings.value('dirview/hide', QVariant(True)).toBool()
        self.setHeaderHidden(hide)

        if self.isVisible() == False:
            return
        
        cparser = PuddleConfig()
        d = cparser.get('main', 'lastfolder', '/')
        while not os.path.exists(d):
            d = os.path.dirname(d)
            if not d:
                return

        def expand_thread_func():
            index = self.model().index(d)
            parents = []
            while index.isValid():
                parents.append(index)
                index = index.parent()
            return parents
        
        def expandindexes(indexes):
            self.setEnabled(False)
            [self.expand(index) for index in indexes]
            self.setEnabled(True)
        
        thread = PuddleThread(expand_thread_func, self)
        thread.connect(thread, SIGNAL('threadfinished'), expandindexes)
        thread.start()
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:33,代码来源:dirview.py

示例3: changeProfile

 def changeProfile(self, index):
     try:
         self.profile = self.profiles[index]
     except IndexError:
         return
     cparser = PuddleConfig()
     cparser.set('masstagging', 'lastindex', index)
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:7,代码来源:dialogs.py

示例4: parse_shortcuts

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,代码行数:30,代码来源:update_translation.py

示例5: applySettings

    def applySettings(self, *args):
        cparser = PuddleConfig(CONFIGPATH)
        fields = self.getItems()
        cparser.set('view_all_fields', 'fields', fields)

        if state:
            show_all_fields()
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:7,代码来源:__init__.py

示例6: loadSettings

    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,代码行数:30,代码来源:action_shortcuts.py

示例7: connect_action_shortcuts

def connect_action_shortcuts(actions):
    cparser = PuddleConfig()
    cparser.filename = ls.menu_path
    for action in actions:
        shortcut = cparser.get('shortcuts', unicode(action.text()), '')
        if shortcut:
            action.setShortcut(shortcut)
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:7,代码来源:puddletag.py

示例8: convert_mtp

def convert_mtp(filename):
        
    cparser = PuddleConfig(filename)
    info_section = 'info'
    name = cparser.get(info_section, NAME, u'')
    numsources = cparser.get(info_section, 'numsources', 0)
    album_bound = cparser.get(info_section, ALBUM_BOUND, 70) / 100.0
    track_bound = cparser.get(info_section, TRACK_BOUND, 80) / 100.0
    match_fields = cparser.get(info_section, FIELDS, ['artist', 'title'])
    pattern = cparser.get(info_section, PATTERN,
        u'%artist% - %album%/%track% - %title%')
    jfdi = cparser.get(info_section, JFDI, True)
    desc = cparser.get(info_section, DESC, u'')
    existing = cparser.get(info_section, EXISTING_ONLY, False)

    ts_profiles = []
    for num in range(numsources):
        section = 'config%s' % num
        get = lambda key, default: cparser.get(section, key, default)

        source = DummyTS()
        source.name = get('source', u'')
        fields = fields_from_text(get('fields', u''))
        no_result = get('no_match', 0)

        ts_profiles.append(TagSourceProfile(None, source, fields,
            no_result))
    
    return MassTagProfile(name, desc, match_fields, None,
            pattern, ts_profiles, album_bound, track_bound, jfdi, existing,
            u'')
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:31,代码来源:config.py

示例9: _loadSettings

    def _loadSettings(self, actions):
        
        cparser = PuddleConfig(os.path.join(CONFIGDIR, 'user_shortcuts'))

        for action in actions:
            shortcut = cparser.get('shortcuts', unicode(action.text()), '')
            if shortcut:
                action.setShortcut(QKeySequence(shortcut))
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:8,代码来源:shortcutsettings.py

示例10: load_patterns

def load_patterns(filepath=None):
    settings = PuddleConfig(filepath)
    return [settings.get('editor', 'patterns',
                            ['%artist% - $num(%track%,2) - %title%',
                            '%artist% - %album% - $num(%track%,2) - %title%',
                            '%artist% - %title%', '%artist% - %album%',
                            '%artist% - Track %track%', '%artist% - %title%']),
           settings.get('editor', 'index', 0, True)]
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:8,代码来源:patterncombo.py

示例11: load_gen_settings

def load_gen_settings(setlist, extras=False):
    settings = PuddleConfig()
    settings.filename = os.path.join(settings.savedir, 'gensettings')
    ret = []
    for setting in setlist:
        desc = setting[0]
        default = setting[1]
        ret.append([desc, settings.get(desc, 'value', default)])
    return ret
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:9,代码来源:puddlesettings.py

示例12: _load

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,代码行数:10,代码来源:confirmations.py

示例13: applyPrefs

 def applyPrefs(self, values):
     musicdir = values[0]
     self.musicdir = musicdir
     cparser = PuddleConfig()
     cparser.set('exampletagsource', 'musicdir', musicdir)
     self.preferences[0][2] = musicdir
     isdir = os.path.isdir
     join = os.path.join
     musicdir = musicdir.encode('utf8')
     self._dirs = [z for z in os.listdir(musicdir) if isdir(join(musicdir,z))]
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:10,代码来源:example.py

示例14: editSortOptions

    def editSortOptions(self):
        cparser = PuddleConfig()
        options = cparser.get('table', 'sortoptions', 
            ['__filename,track,__dirpath','track, album', 
            '__filename,album,__dirpath'])

        from puddlestuff.webdb import SortOptionEditor
        win = SortOptionEditor(options, self)
        self.connect(win, SIGNAL('options'), self.applySortOptions)
        win.show()
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:10,代码来源:puddlesettings.py

示例15: loadsets

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,代码行数:25,代码来源:algwin.py


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