本文整理汇总了Python中puddlestuff.puddleobjects.PuddleConfig类的典型用法代码示例。如果您正苦于以下问题:Python PuddleConfig类的具体用法?Python PuddleConfig怎么用?Python PuddleConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PuddleConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: create_tool_windows
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,代码行数:55,代码来源:puddletag.py
示例17: save
def save(filename=None, confirmations=None):
if filename is None:
filename = _filename
cparser = PuddleConfig(filename)
if confirmations is None:
confirmations = _confirmations
for i, name in enumerate(confirmations):
set_value = lambda k,v: cparser.set(SECTION + unicode(i), k, v)
set_value(NAME, name)
set_value(VALUE, confirmations[name][0])
set_value(DESC, confirmations[name][1])
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:13,代码来源:confirmations.py
示例18: savesettings
def savesettings(d, filepath=None):
settings = PuddleConfig()
if filepath:
settings.filename = filepath
else:
settings.filename = os.path.join(settings.savedir, 'tagpanel')
settings.set('panel', 'numrows', unicode(len(d)))
for row, rowtags in d.items():
settings.set(unicode(row), 'tags', [z[1] for z in rowtags])
settings.set(unicode(row), 'titles', [z[0] for z in rowtags])
开发者ID:keithgg,项目名称:puddletag,代码行数:10,代码来源:tagpanel.py
示例19: load_plugins
def load_plugins(plugins=None, parent=None):
[sys.path.insert(0, d) for d in PLUGIN_DIRS]
cparser = PuddleConfig()
to_load = cparser.get('plugins', 'to_load', [])
functions = {}
tagsources = []
dialogs = []
musiclibs = []
modules = []
functions_no_preview = []
join = os.path.join
if plugins is None:
plugins = []
[plugins.extend(get_plugins(d)) for d in PLUGIN_DIRS]
plugins.sort(key=lambda d: d.get(NAME, u''))
for plugin in plugins:
if plugin[MODULE_NAME] not in to_load:
continue
try:
module = __import__(plugin[MODULE_NAME])
except:
print u'Failed to load plugin: ', plugin['name']
traceback.print_exc()
continue
if hasattr(module, 'functions'):
functions.update(module.functions)
if hasattr(module, 'functions_no_preview'):
functions_no_preview.extend(module.functions_no_preview)
if hasattr(module, 'tagsources'):
tagsources.extend(module.tagsources)
if hasattr(module, 'dialogs'):
dialogs.extend(module.dialogs)
if hasattr(module, 'musiclibs'):
musiclibs.extend(module.musiclibs)
modules.append(module)
for d in PLUGIN_DIRS:
del(sys.path[0])
return {FUNCTIONS: functions, TAGSOURCE: tagsources, DIALOGS: dialogs,
MUSICLIBS: musiclibs, MODULES: modules, FUNCTIONS_NO_PREVIEW: functions_no_preview}
开发者ID:chincheta0815,项目名称:puddletag,代码行数:50,代码来源:pluginloader.py
示例20: updateOrder
def updateOrder(self):
self.listbox.clear()
self.macros = self.loadMacros()
cparser = PuddleConfig()
to_check = cparser.get('actions', 'checked', [])
for i, m in sorted(self.macros.items()):
func_name = m.name
item = QListWidgetItem(func_name)
item.setFlags(item.flags() | Qt.ItemIsEditable)
if func_name in to_check:
item.setCheckState(Qt.Checked)
else:
item.setCheckState(Qt.Unchecked)
self.listbox.addItem(item)
开发者ID:RaphaelRochet,项目名称:puddletag,代码行数:14,代码来源:action_dialogs.py
注:本文中的puddlestuff.puddleobjects.PuddleConfig类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论