當前位置: 首頁>>代碼示例>>Python>>正文


Python PuddleConfig.get方法代碼示例

本文整理匯總了Python中puddlestuff.puddleobjects.PuddleConfig.get方法的典型用法代碼示例。如果您正苦於以下問題:Python PuddleConfig.get方法的具體用法?Python PuddleConfig.get怎麽用?Python PuddleConfig.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在puddlestuff.puddleobjects.PuddleConfig的用法示例。


在下文中一共展示了PuddleConfig.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: loadSettings

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [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

示例2: load_patterns

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
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,代碼行數:10,代碼來源:patterncombo.py

示例3: _load

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [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

示例4: convert_mtp

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
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,代碼行數:33,代碼來源:config.py

示例5: loadSettings

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
    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,代碼行數:35,代碼來源:dirview.py

示例6: connect_action_shortcuts

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
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,代碼行數:9,代碼來源:puddletag.py

示例7: _loadSettings

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
    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,代碼行數:10,代碼來源:shortcutsettings.py

示例8: __init__

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)
        cparser = PuddleConfig()
        get_color = lambda key, default: QColor.fromRgb(
            *cparser.get('extendedtags', key, default, True))
        add = get_color('add', [0,255,0])
        edit = get_color('edit', [255,255,0])
        remove = get_color('remove', [255,0,0])

        get_color = lambda key, default: QColor.fromRgb(
            *cparser.get('table', key, default, True))

        preview = get_color('preview_color', [192, 255, 192])
        selection_default = QPalette().color(QPalette.Mid).getRgb()[:-1]
        
        selection = get_color('selected_color', selection_default)
        
        colors = (add, edit, remove, preview, selection)

        text = translate("Colour Settings", '<p>Below are the backgrounds used for various controls in puddletag. <br /> Double click the desired action to change its colour.</p>')
        label = QLabel(text)

        self.listbox = QTableWidget(0, 1, self)
        self.listbox.setEditTriggers(QAbstractItemView.NoEditTriggers)
        header = self.listbox.horizontalHeader()
        self.listbox.setSortingEnabled(False)
        header.setVisible(True)
        header.setStretchLastSection (True)
        self.listbox.setHorizontalHeaderLabels(['Action'])
        self.listbox.setRowCount(len(colors))

        titles = [
            (translate("Colour Settings", 'Row selected in file-view.'), selection),
            (translate("Colour Settings", 'Row colour for files with previews.'), preview),
            (translate("Colour Settings", 'Field added in Extended Tags.'), add),
            (translate("Colour Settings", 'Field edited in Extended Tags.'), edit),
            (translate("Colour Settings", 'Field removed in Extended Tags.'), remove),]

        for i, z in enumerate(titles):
            self.listbox.setItem(i, 0, StatusWidgetItem(*z))

        vbox = QVBoxLayout()
        vbox.addWidget(label)
        vbox.addWidget(self.listbox)
        self.setLayout(vbox)
        self.connect(self.listbox, SIGNAL('cellDoubleClicked(int,int)'), self.edit)
開發者ID:RaphaelRochet,項目名稱:puddletag,代碼行數:48,代碼來源:puddlesettings.py

示例9: load_settings

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [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

示例10: load_gen_settings

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
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,代碼行數:11,代碼來源:puddlesettings.py

示例11: editSortOptions

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
    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,代碼行數:12,代碼來源:puddlesettings.py

示例12: create_tool_windows

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
def create_tool_windows(parent, extra=None):
    """Creates the dock widgets for the main window (parent) using
    the modules stored in puddlestuff/mainwin.

    Returns (the toggleViewActions of the docks, the dockWidgets the
    mselves)."""
    actions = []
    docks = []
    cparser = PuddleConfig()
    cparser.filename = ls.menu_path
    widgets = (
        mainwin.tagpanel,
        mainwin.artwork,
        mainwin.dirview,
        mainwin.patterncombo,
        mainwin.filterwin,
        puddlestuff.webdb,
        mainwin.storedtags,
        mainwin.logdialog,
        puddlestuff.masstag.dialogs,
    )

    controls = [z.control for z in widgets]
    controls.extend(mainwin.action_dialogs.controls)
    if extra:
        controls.extend(extra)
    for z in controls:
        name = z[0]
        try:
            if not z[2]:
                PuddleDock._controls[name] = z[1](status=status)
                continue
        except IndexError:
            pass

        p = PuddleDock(z[0], z[1], parent, status)

        parent.addDockWidget(z[2], p)

        try:
            if z[4]:
                p.setFloating(True)
            p.move(parent.rect().center())
        except IndexError:
            pass

        p.setVisible(z[3])
        docks.append(p)
        action = p.toggleViewAction()
        action.setText(name)
        scut = cparser.get("winshortcuts", name, "")
        if scut:
            action.setShortcut(scut)
        actions.append(action)
    return actions, docks
開發者ID:chincheta0815,項目名稱:puddletag,代碼行數:57,代碼來源:puddletag.py

示例13: clipboard_to_tag

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
def clipboard_to_tag(parent=None):
    win = helperwin.ImportTextFile(parent, clipboard = True)
    win.setModal(True)
    win.patterncombo.addItems(status['patterns'])

    cparser = PuddleConfig()
    last_dir = cparser.get('importwindow', 'lastdir', HOMEDIR)
    win.lastDir = last_dir
    last_pattern = cparser.get('importwindow', 'lastpattern', u'')
    if last_pattern:
        win.patterncombo.setEditText(last_pattern)

    def fin_edit(taglist, pattern):
        cparser.set('importwindow', 'lastdir', win.lastDir)
        cparser.set('importwindow', 'lastpattern', pattern)
        emit('writeselected', taglist)
    
    win.connect(win, SIGNAL("Newtags"), fin_edit)
    
    win.show()
開發者ID:keithgg,項目名稱:puddletag,代碼行數:22,代碼來源:funcs.py

示例14: loadsets

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [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

示例15: savePlayList

# 需要導入模塊: from puddlestuff.puddleobjects import PuddleConfig [as 別名]
# 或者: from puddlestuff.puddleobjects.PuddleConfig import get [as 別名]
    def savePlayList(self):
        tags = status['selectedfiles']
        if not tags:
            tags = status['alltags']
        settings = PuddleConfig()
        try:
            dirname = self._lastdir[0]
        except IndexError:
            dirname = constants.HOMEDIR
        filepattern = settings.get('playlist', 'filepattern','puddletag.m3u')
        default = encode_fn(findfunc.tagtofilename(filepattern, tags[0]))
        f = unicode(QFileDialog.getSaveFileName(self,
            translate("Playlist", 'Save Playlist...'), os.path.join(dirname, default)))
        if f:
            if settings.get('playlist', 'extinfo', 1, True):
                pattern = settings.get('playlist', 'extpattern','%artist% - %title%')
            else:
                pattern = None

            reldir = settings.get('playlist', 'reldir', 0, True)
            windows_separator = settings.get('playlist', 'windows_separator', 0, False)
            m3u.exportm3u(tags, f, pattern, reldir, windows_separator)
開發者ID:RaphaelRochet,項目名稱:puddletag,代碼行數:24,代碼來源:puddletag.py


注:本文中的puddlestuff.puddleobjects.PuddleConfig.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。