def option_parser(): writers = set([]) for w in metadata_writers(): writers = writers.union(set(w.file_types)) ft, w = ', '.join(sorted(filetypes())), ', '.join(sorted(writers)) return config().option_parser(USAGE % dict(read=ft, write=w))
def option_parser(): writers = set() for w in metadata_writers(): writers = writers.union(set(w.file_types)) ft, w = ', '.join(sorted(filetypes())), ', '.join(sorted(writers)) return config().option_parser(USAGE.format(ft, w))
def initialize(self): def field_cmp(x, y): if x.startswith('#'): if y.startswith('#'): return cmp(x.lower(), y.lower()) else: return 1 elif y.startswith('#'): return -1 else: return cmp(x.lower(), y.lower()) ConfigWidgetBase.initialize(self) self.current_plugboards = copy.deepcopy(self.db.prefs.get('plugboards',{})) self.current_device = None self.current_format = None if self.gui.device_manager.connected_device is not None: self.device_label.setText(_('Device currently connected: ') + self.gui.device_manager.connected_device.__class__.__name__) else: self.device_label.setText(_('Device currently connected: None')) self.devices = ['', 'APPLE', 'FOLDER_DEVICE'] self.disabled_devices = [] self.device_to_formats_map = {} for device in device_plugins(): n = device_name_for_plugboards(device) self.device_to_formats_map[n] = set(device.settings().format_map) if getattr(device, 'CAN_DO_DEVICE_DB_PLUGBOARD', False): self.device_to_formats_map[n].add('device_db') if n not in self.devices: self.devices.append(n) for device in disabled_device_plugins(): n = device_name_for_plugboards(device) if n not in self.disabled_devices: self.disabled_devices.append(n) self.devices.sort(cmp=lambda x, y: cmp(x.lower(), y.lower())) self.devices.insert(1, plugboard_save_to_disk_value) self.devices.insert(1, plugboard_content_server_value) self.device_to_formats_map[plugboard_content_server_value] = \ plugboard_content_server_formats self.devices.insert(1, plugboard_email_value) self.device_to_formats_map[plugboard_email_value] = \ plugboard_email_formats self.devices.insert(1, plugboard_any_device_value) self.new_device.addItems(self.devices) self.formats = [''] self.format_to_writers_map = defaultdict(list) for w in metadata_writers(): for f in w.file_types: if f not in self.formats: self.formats.append(f) self.format_to_writers_map[f].append(w) self.formats.append('device_db') self.formats.sort() self.formats.insert(1, plugboard_any_format_value) self.new_format.addItems(self.formats) self.dest_fields = ['', 'authors', 'author_sort', 'language', 'publisher', 'tags', 'title', 'title_sort'] self.source_widgets = [] self.dest_widgets = [] for i in range(0, len(self.dest_fields)-1): w = TemplateLineEditor(self) self.source_widgets.append(w) self.fields_layout.addWidget(w, 5+i, 0, 1, 1) w = QComboBox(self) self.dest_widgets.append(w) self.fields_layout.addWidget(w, 5+i, 1, 1, 1) self.edit_device.currentIndexChanged[str].connect(self.edit_device_changed) self.edit_format.currentIndexChanged[str].connect(self.edit_format_changed) self.new_device.currentIndexChanged[str].connect(self.new_device_changed) self.new_format.currentIndexChanged[str].connect(self.new_format_changed) self.existing_plugboards.itemClicked.connect(self.existing_pb_clicked) self.ok_button.clicked.connect(self.ok_clicked) self.del_button.clicked.connect(self.del_clicked) self.refilling = False self.refill_all_boxes()
def initialize(self): ConfigWidgetBase.initialize(self) self.current_plugboards = copy.deepcopy( self.db.prefs.get('plugboards', {})) self.current_device = None self.current_format = None if self.gui.device_manager.connected_device is not None: self.device_label.setText( _('Device currently connected: ') + self.gui.device_manager.connected_device.__class__.__name__) else: self.device_label.setText(_('Device currently connected: None')) self.devices = ['', 'APPLE', 'FOLDER_DEVICE'] self.disabled_devices = [] self.device_to_formats_map = {} for device in device_plugins(): n = device_name_for_plugboards(device) self.device_to_formats_map[n] = set(device.settings().format_map) if getattr(device, 'CAN_DO_DEVICE_DB_PLUGBOARD', False): self.device_to_formats_map[n].add('device_db') if n not in self.devices: self.devices.append(n) for device in disabled_device_plugins(): n = device_name_for_plugboards(device) if n not in self.disabled_devices: self.disabled_devices.append(n) self.devices.sort(key=lambda x: x.lower()) self.devices.insert(1, plugboard_save_to_disk_value) self.devices.insert(1, plugboard_content_server_value) self.device_to_formats_map[plugboard_content_server_value] = \ plugboard_content_server_formats self.devices.insert(1, plugboard_email_value) self.device_to_formats_map[plugboard_email_value] = \ plugboard_email_formats self.devices.insert(1, plugboard_any_device_value) self.new_device.addItems(self.devices) self.formats = [''] self.format_to_writers_map = defaultdict(list) for w in metadata_writers(): for f in w.file_types: if f not in self.formats: self.formats.append(f) self.format_to_writers_map[f].append(w) self.formats.append('device_db') self.formats.sort() self.formats.insert(1, plugboard_any_format_value) self.new_format.addItems(self.formats) self.dest_fields = [ '', 'authors', 'author_sort', 'language', 'publisher', 'series', 'tags', 'title', 'title_sort', 'comments' ] self.source_widgets = [] self.dest_widgets = [] for i in range(0, len(self.dest_fields) - 1): w = TemplateLineEditor(self) self.source_widgets.append(w) self.fields_layout.addWidget(w, 5 + i, 0, 1, 1) w = QComboBox(self) self.dest_widgets.append(w) self.fields_layout.addWidget(w, 5 + i, 1, 1, 1) self.edit_device.currentIndexChanged[native_string_type].connect( self.edit_device_changed) self.edit_format.currentIndexChanged[native_string_type].connect( self.edit_format_changed) self.new_device.currentIndexChanged[native_string_type].connect( self.new_device_changed) self.new_format.currentIndexChanged[native_string_type].connect( self.new_format_changed) self.existing_plugboards.itemClicked.connect(self.existing_pb_clicked) self.ok_button.clicked.connect(self.ok_clicked) self.del_button.clicked.connect(self.del_clicked) self.refilling = False self.refill_all_boxes()
def option_parser(): writers = set([]) for w in metadata_writers(): writers = writers.union(set(w.file_types)) ft, w = ', '.join(sorted(filetypes())), ', '.join(sorted(writers)) return config().option_parser(USAGE.format(ft, w))