def _okClicked(self): source = self.tag_sources[self.source.currentIndex()] no_result = self.no_match.currentIndex() fields = fields_from_text(unicode(self.fields.text())) replace_fields = fields_from_text(unicode(self.replace_fields.text())) profile = TagSourceProfile(None, source, fields, no_result, replace_fields) self.close() self.emit(SIGNAL('profileChanged'), profile)
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'')
def mtp_from_file(filename=CONFIG, tag_sources=None): if tag_sources is None: tag_sources = {} else: tag_sources = dict((z.name, z) for z in tag_sources) cparser = PuddleConfig(filename) info_section = 'info' name = cparser.get(info_section, NAME, '') 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, '%artist% - %album%/%track% - %title%') jfdi = cparser.get(info_section, JFDI, True) desc = cparser.get(info_section, DESC, u'') leave_existing = cparser.get(info_section, EXISTING_ONLY, False) regexps = u'' ts_profiles = [] for num in range(numsources): section = 'config%s' % num get = lambda key, default: cparser.get(section, key, default) source = tag_sources.get(get('source', u''), None) no_result = get('no_match', 0) fields = fields_from_text(get('fields', u'')) replace_fields = fields_from_text(get('replace_fields', u'')) ts_profiles.append(TagSourceProfile(None, source, fields, no_result, replace_fields)) mtp = MassTagProfile(name, desc, match_fields, None, pattern, ts_profiles, album_bound, track_bound, jfdi, leave_existing, regexps) return mtp
def mtp_from_file(filename=CONFIG, tag_sources=None): if tag_sources is None: tag_sources = {} else: tag_sources = dict((z.name, z) for z in tag_sources) cparser = PuddleConfig(filename) info_section = 'info' name = cparser.get(info_section, NAME, '') 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, '%artist% - %album%/%track% - %title%') jfdi = cparser.get(info_section, JFDI, True) desc = cparser.get(info_section, DESC, u'') leave_existing = cparser.get(info_section, EXISTING_ONLY, False) regexps = u'' ts_profiles = [] for num in range(numsources): section = 'config%s' % num get = lambda key, default: cparser.get(section, key, default) source = tag_sources.get(get('source', u''), None) no_result = get('no_match', 0) fields = fields_from_text(get('fields', u'')) replace_fields = fields_from_text(get('replace_fields', u'')) ts_profiles.append( TagSourceProfile(None, source, fields, no_result, replace_fields)) mtp = MassTagProfile(name, desc, match_fields, None, pattern, ts_profiles, album_bound, track_bound, jfdi, leave_existing, regexps) return mtp