本文整理汇总了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)
示例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)]
示例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
示例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'')
示例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()
示例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)
示例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))
示例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)
示例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
示例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
示例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()
示例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
示例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()
示例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
示例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)