bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def location_for_row(self, row): if row == 0: return 'library' if row == 1: return 'main' if row == 3: return 'cardb' return 'carda' if self.free[1] > -1 else 'cardb' | def location_for_row(self, row): if row == 0: return 'library' if row == 1: return 'main' if row == 3: return 'cardb' return 'carda' if self.free[1] > -1 else 'cardb' | 450,900 |
def eject_clicked(self, *args): self.unmount_device.emit() | def eject_clicked(self, *args): self.unmount_device.emit() | 450,901 |
def generate(): scn = 'calibre_browse_server_sort_' | def generate(): scn = 'calibre_browse_server_sort_' | 450,902 |
def format_field_extended(self, key, series_with_index=True): from calibre.ebooks.metadata import authors_to_string ''' returns the tuple (field_name, formatted_value) ''' | def format_field_extended(self, key, series_with_index=True): from calibre.ebooks.metadata import authors_to_string ''' returns the tuple (field_name, formatted_value) ''' | 450,903 |
def __init__(self, icon_dict): for a in self.category_icons: if a not in icon_dict: raise ValueError('Missing category icon [%s]'%a) self[a] = icon_dict[a] | def __init__(self, icon_dict): for a in self.category_icons: if a not in icon_dict: raise ValueError('Missing category icon [%s]'%a) self[a] = icon_dict[a] | 450,904 |
def __init__(self, parent=None): pictureflow.PictureFlow.__init__(self, parent, config['cover_flow_queue_length']+1) self.setMinimumSize(QSize(300, 150)) self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.setZoomFactor(150) | def __init__(self, parent=None): pictureflow.PictureFlow.__init__(self, parent, config['cover_flow_queue_length']+1) self.setMinimumSize(QSize(300, 150)) self.setFocusPolicy(Qt.WheelFocus) self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.setZoomFactor(150) | 450,905 |
def do_config(self, checked=False, initial_category='general'): if self.job_manager.has_jobs(): d = error_dialog(self, _('Cannot configure'), _('Cannot configure while there are running jobs.')) d.exec_() return if self.must_restart_before_config: d = error_dialog(self, _('Cannot configure'), _('Cannot configure before... | def do_config(self, checked=False, initial_category='general'): if self.job_manager.has_jobs(): d = error_dialog(self, _('Cannot configure'), _('Cannot configure while there are running jobs.')) d.exec_() return if self.must_restart_before_config: d = error_dialog(self, _('Cannot configure'), _('Cannot configure before... | 450,906 |
def build_index(self): self.report_progress(0, _('Fetching feeds...')) try: feeds = feeds_from_index(self.parse_index(), oldest_article=self.oldest_article, max_articles_per_feed=self.max_articles_per_feed, log=self.log) self.report_progress(0, _('Got feeds from index page')) except NotImplementedError: feeds = self.pa... | def build_index(self): self.report_progress(0, _('Fetching feeds...')) try: feeds = feeds_from_index(self.parse_index(), oldest_article=self.oldest_article, max_articles_per_feed=self.max_articles_per_feed, log=self.log) self.report_progress(0, _('Got feeds from index page')) except NotImplementedError: feeds = self.pa... | 450,907 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,908 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,909 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,910 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,911 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,912 |
def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | def break_cycles(self): try: self.view_format.disconnect() except: pass # Fails if view format was never connected self.view_format = None self.db = None self.pi = None self.cover_data = self.cpixmap = None | 450,913 |
def getter(x): return category_meta[x]['name'].lower() | def getter(x): return category_meta[x]['name'].lower() | 450,914 |
def contextMenuEvent(self, event): self.edit_collections_menu.setVisible( self._model.db.supports_collections() and \ prefs['preserve_user_collections']) self.context_menu.popup(event.globalPos()) event.accept() | def contextMenuEvent(self, event): self.edit_collections_menu.setVisible( callable(getattr(self._model.db, 'supports_collections', None)) and \ self._model.db.supports_collections() and \ prefs['preserve_user_collections']) self.context_menu.popup(event.globalPos()) event.accept() | 450,915 |
def run(self, path_to_output, opts, db, notification=DummyReporter()): self.fmt = path_to_output.rpartition('.')[2] self.notification = notification | def run(self, path_to_output, opts, db, notification=DummyReporter()): self.fmt = path_to_output.rpartition('.')[2] self.notification = notification | 450,916 |
def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | 450,917 |
def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | 450,918 |
def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | def books(self, oncard=None, end_session=True): from calibre.ebooks.metadata.meta import path_to_ext | 450,919 |
def delete_via_sql(self, ContentID, ContentType): # Delete Order: # 1) shortcover_page # 2) volume_shorcover # 2) content | defdebug_print('delete_via_sql: ContentID: ', ContentID, 'ContentType: ', ContentType) delete_via_sql(self,debug_print('delete_via_sql: ContentID: ', ContentID, 'ContentType: ', ContentType) ContentID,debug_print('delete_via_sql: ContentID: ', ContentID, 'ContentType: ', ContentType) ContentType):debug_print('delete_vi... | 450,920 |
def get_content_type_from_extension(self, extension): if extension == '.kobo': # Kobo books do not have book files. They do have some images though #print "kobo book" ContentType = 6 elif extension == '.pdf' or extension == '.epub': # print "ePub or pdf" ContentType = 16 elif extension == '.rtf' or extension == '.txt'... | def get_content_type_from_extension(self, extension): if extension == '.kobo': # Kobo books do not have book files. They do have some images though #print "kobo book" ContentType = 6 elif extension == '.pdf' or extension == '.epub': # print "ePub or pdf" ContentType = 16 elif extension == '.rtf' or extension == '.txt'... | 450,921 |
def fix_pubdates(self): dirtied = False opf = self.container.opf for dcdate in opf.xpath('//dc:date', namespaces={'dc':'http://purl.org/dc/elements/1.1/'}): raw = dcdate.text if not raw: raw = '' default = strptime('2000-1-1', '%Y-%m-%d', as_utc=True) try: ts = parse_date(raw, assume_utc=False, as_utc=True, default=def... | def fix_pubdates(self): dirtied = False opf = self.container.opf for dcdate in opf.xpath('//dc:date', namespaces={'dc':'http://purl.org/dc/elements/1.1/'}): raw = dcdate.text if not raw: raw = '' default = strptime('2000-1-1', '%Y-%m-%d', as_utc=True) try: ts = parse_date(raw, assume_utc=False, as_utc=True, default=def... | 450,922 |
def get_value(self, key, args, kwargs): try: b = self.book.get_user_metadata(key, False) key = key.lower() if b is not None and b['datatype'] == 'composite': return self.vformat(b['display']['composite_template'], [], kwargs) if kwargs[key]: return self.sanitize(kwargs[key.lower()]) return '' except: return '' | def get_value(self, key, args, kwargs): try: b = self.book.get_user_metadata(key, False) key = key.lower() if b is not None and b['datatype'] == 'composite': if key in self.composite_values: return self.composite_values[key] self.composite_values[key] = 'RECURSIVE_COMPOSITE FIELD (S2D) ' + key self.composite_values[key... | 450,923 |
def save_book_to_disk(id, db, root, opts, length): mi = db.get_metadata(id, index_is_id=True) available_formats = db.formats(id, index_is_id=True) if not available_formats: available_formats = [] else: available_formats = [x.lower().strip() for x in available_formats.split(',')] if opts.formats == 'all': asked_formats... | def save_book_to_disk(id, db, root, opts, length): mi = db.get_metadata(id, index_is_id=True) available_formats = db.formats(id, index_is_id=True) if not available_formats: available_formats = [] else: available_formats = [x.lower().strip() for x in available_formats.split(',')] if opts.formats == 'all': asked_formats... | 450,924 |
def save_book_to_disk(id, db, root, opts, length): mi = db.get_metadata(id, index_is_id=True) available_formats = db.formats(id, index_is_id=True) if not available_formats: available_formats = [] else: available_formats = [x.lower().strip() for x in available_formats.split(',')] if opts.formats == 'all': asked_formats... | def save_book_to_disk(id, db, root, opts, length): mi = db.get_metadata(id, index_is_id=True) available_formats = db.formats(id, index_is_id=True) if not available_formats: available_formats = [] else: available_formats = [x.lower().strip() for x in available_formats.split(',')] if opts.formats == 'all': asked_formats... | 450,925 |
def _update_iTunes_metadata(self, metadata, db_added, lb_added, this_book): ''' ''' if DEBUG: self.log.info(" ITUNES._update_iTunes_metadata()") | def _update_iTunes_metadata(self, metadata, db_added, lb_added, this_book): ''' ''' if DEBUG: self.log.info(" ITUNES._update_iTunes_metadata()") | 450,926 |
def send_by_mail(self, to, fmts, delete_from_library, send_ids=None, do_auto_convert=True, specific_format=None): ids = [self.library_view.model().id(r) for r in self.library_view.selectionModel().selectedRows()] if send_ids is None else send_ids if not ids or len(ids) == 0: return files, _auto_ids = self.library_view.... | def send_by_mail(self, to, fmts, delete_from_library, send_ids=None, do_auto_convert=True, specific_format=None): ids = [self.library_view.model().id(r) for r in self.library_view.selectionModel().selectedRows()] if send_ids is None else send_ids if not ids or len(ids) == 0: return files, _auto_ids = self.library_view.... | 450,927 |
def emails_sent(self, results, remove=[]): errors, good = [], [] for jobname, exception, tb in results: title = jobname.partition(':')[-1] if exception is not None: errors.append([title, exception, tb]) else: good.append(title) if errors: errors = '\n'.join([ '%s\n\n%s\n%s\n' % (title, e, tb) for \ title, e, tb in erro... | def emails_sent(self, results, remove=[]): errors, good = [], [] for jobname, exception, tb in results: title = jobname.partition(':')[-1] if exception is not None: errors.append([title, exception, tb]) else: good.append(title) if errors: errors = '\n'.join([ '%s\n\n%s\n%s\n' % (title, e, tb) for \ title, e, tb in erro... | 450,928 |
def dcmp(x, y): ''' Sorting based on the following scheme: - disks without partitions are first - sub sorted based on disk number - disks with partitions are sorted first on disk number, then on partition number ''' x = x.rpartition('/')[-1] y = y.rpartition('/')[-1] x, y = nums(x), nums(y) if x[1] == 0 and y[1] > 0: r... | def dcmp(x, y): ''' Sorting based on the following scheme: - disks without partitions are first - sub sorted based on disk number - disks with partitions are sorted first on disk number, then on partition number ''' x = x.rpartition('/')[-1] y = y.rpartition('/')[-1] x, y = nums(x), nums(y) if x[1] == 0 and y[1] > 0: r... | 450,929 |
def update_device_database_collections(self, booklists, collections_attributes, oncard): | def update_device_database_collections(self, booklists, collections_attributes, oncard): | 450,930 |
def update_device_database_collections(self, booklists, collections_attributes, oncard): | def update_device_database_collections(self, booklists, collections_attributes, oncard): | 450,931 |
def abspath(self, index, index_is_id=False): 'Return the absolute path to the directory containing this books files as a unicode string.' path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id)) if not os.path.exists(path): os.makedirs(path) return path | def abspath(self, index, index_is_id=False, create_dirs=True): 'Return the absolute path to the directory containing this books files as a unicode string.' path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id)) if not os.path.exists(path): os.makedirs(path) return path | 450,932 |
def abspath(self, index, index_is_id=False): 'Return the absolute path to the directory containing this books files as a unicode string.' path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id)) if not os.path.exists(path): os.makedirs(path) return path | def abspath(self, index, index_is_id=False): 'Return the absolute path to the directory containing this books files as a unicode string.' path = os.path.join(self.library_path, self.path(index, index_is_id=index_is_id)) if create_dirs and not os.path.exists(path): os.makedirs(path) return path | 450,933 |
def has_cover(self, index, index_is_id=False): id = index if index_is_id else self.id(index) try: path = os.path.join(self.abspath(id, index_is_id=True), 'cover.jpg') except: # Can happen if path has not yet been set return False return os.access(path, os.R_OK) | def has_cover(self, index, index_is_id=False): id = index if index_is_id else self.id(index) try: path = os.path.join(self.abspath(id, index_is_id=True, create_dirs=False), 'cover.jpg') except: # Can happen if path has not yet been set return False return os.access(path, os.R_OK) | 450,934 |
def line_histogram(self, percent): ''' Creates a broad histogram of the document to determine whether it incorporates hard line breaks. Lines are sorted into 20 'buckets' based on length. percent is the percentage of lines that should be in a single bucket to return true The majority of the lines will exist in 1-2 buc... | def line_histogram(self, percent): ''' Creates a broad histogram of the document to determine whether it incorporates hard line breaks. Lines are sorted into 20 'buckets' based on length. percent is the percentage of lines that should be in a single bucket to return true The majority of the lines will exist in 1-2 buc... | 450,935 |
def namelist(self): names = [] for root, dirs, files in os.walk(self.rootdir): for fname in files: fname = os.path.join(root, fname) fname = fname.replace('\\', '/') names.append(fname) return names | def namelist(self): names = [] base = self.rootdir if isinstance(base, unicode): base = base.encode(filesystem_encoding) for root, dirs, files in os.walk(base): for fname in files: fname = os.path.join(root, fname) fname = fname.replace('\\', '/') names.append(fname) return names | 450,936 |
def __init__(self, window, row, db, accepted_callback=None, cancel_all=False): ResizableDialog.__init__(self, window) self.bc_box.layout().setAlignment(self.cover, Qt.AlignCenter|Qt.AlignHCenter) self.cancel_all = False self.normal_aus_tooltip = unicode(self.author_sort.toolTip()) if cancel_all: self.__abort_button = s... | def __init__(self, window, row, db, accepted_callback=None, cancel_all=False): ResizableDialog.__init__(self, window) self.bc_box.layout().setAlignment(self.cover, Qt.AlignCenter|Qt.AlignHCenter) self.cancel_all = False base = unicode(self.author_sort.toolTip()) self.ok_aus_tooltip = '<p>' + textwrap.fill(base+'<br><br... | 450,937 |
def __init__(self, window, row, db, accepted_callback=None, cancel_all=False): ResizableDialog.__init__(self, window) self.bc_box.layout().setAlignment(self.cover, Qt.AlignCenter|Qt.AlignHCenter) self.cancel_all = False self.normal_aus_tooltip = unicode(self.author_sort.toolTip()) if cancel_all: self.__abort_button = s... | def __init__(self, window, row, db, accepted_callback=None, cancel_all=False): ResizableDialog.__init__(self, window) self.bc_box.layout().setAlignment(self.cover, Qt.AlignCenter|Qt.AlignHCenter) self.cancel_all = False self.normal_aus_tooltip = unicode(self.author_sort.toolTip()) if cancel_all: self.__abort_button = s... | 450,938 |
def mark_author_sort(self, normal=True): if normal: col = 'rgb(0, 255, 0, 20%)' else: col = 'rgb(255, 0, 0, 20%)' self.author_sort.setStyleSheet('QLineEdit { color: black; ' 'background-color: %s; }'%col) tt = self.normal_aus_tooltip if not normal: tt = '<p>'+textwrap.fill(tt + '<br><br>'+ _(' The red color indicates t... | def mark_author_sort(self, normal=True): if normal: col = 'rgb(0, 255, 0, 20%)' else: col = 'rgb(255, 0, 0, 20%)' self.author_sort.setStyleSheet('QLineEdit { color: black; ' 'background-color: %s; }'%col) tt = self.ok_aus_tooltip if normal else self.bad_aus_tooltip self.author_sort.setToolTip(tt) | 450,939 |
def refresh(self, ids): with self.lock: for id_ in ids: self.cache.pop(id_, None) self.load_queue.put(id_) | def refresh(self, ids): with self.lock: for id_ in ids: self.cache.pop(id_, None) self.load_queue.put(id_) | 450,940 |
def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | 450,941 |
def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | 450,942 |
def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | def get_categories(self, sort='name', ids=None, icon_map=None): self.books_list_filter.change([] if not ids else ids) | 450,943 |
def mobimlize_content(self, tag, text, bstate, istates): 'Convert text content' if text or tag != 'br': bstate.content = True istate = istates[-1] para = bstate.para if tag in SPECIAL_TAGS and not text: para = para if para is not None else bstate.body elif para is None or tag in ('td', 'th'): body = bstate.body if bsta... | def mobimlize_content(self, tag, text, bstate, istates): 'Convert text content' if text or tag != 'br': bstate.content = True istate = istates[-1] para = bstate.para if tag in SPECIAL_TAGS and not text: para = para if para is not None else bstate.body elif para is None or tag in ('td', 'th'): body = bstate.body if bsta... | 450,944 |
def _shorten(self, val, leading, center_string, trailing): l = int(leading) t = int(trailing) if len(val) > l + len(center_string) + t: return val[0:l] + center_string + val[-t:] else: return val | def _shorten(self, val, leading, center_string, trailing): l = max(0, int(leading)) t = max(0, int(trailing)) if len(val) > l + len(center_string) + t: return val[0:l] + center_string + val[-t:] else: return val | 450,945 |
def _shorten(self, val, leading, center_string, trailing): l = int(leading) t = int(trailing) if len(val) > l + len(center_string) + t: return val[0:l] + center_string + val[-t:] else: return val | def _shorten(self, val, leading, center_string, trailing): l = int(leading) t = int(trailing) if len(val) > l + len(center_string) + t: return val[0:l] + center_string + ('' if t == 0 else val[-t:]) else: return val | 450,946 |
def _xmlescape(data): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | def _xmlescape(data,entities={}): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | 450,947 |
def _xmlescape(data): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | def _xmlescape(data): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | 450,948 |
def _xmlescape(data): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | def _xmlescape(data): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') return data | 450,949 |
def setdefault(self, key, value): if not self.has_key(key): self[key] = value return self[key] | def setdefault(self, key, value): if not self.has_key(key): self[key] = value return self[key] | 450,950 |
def has_key(self, key): try: return hasattr(self, key) or UserDict.has_key(self, key) except AttributeError: return False | def has_key(self, key): try: return hasattr(self, key) or UserDict.has_key(self, key) except AttributeError: return False | 450,951 |
def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) try: return urlparse.urljoin(base, uri) except: uri = urlparse.urlunparse([urllib.quote(part) for part in urlparse.urlparse(uri)]) return urlparse.urljoin(base, uri) | 450,952 |
def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | 450,953 |
def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | 450,954 |
def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | 450,955 |
def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | def _urljoin(base, uri): uri = _urifixer.sub(r'\1\3', uri) return urlparse.urljoin(base, uri) | 450,956 |
def __init__(self, baseuri=None, baselang=None, encoding='utf-8'): if _debug: sys.stderr.write('initializing FeedParser\n') if not self._matchnamespaces: for k, v in self.namespaces.items(): self._matchnamespaces[k.lower()] = v self.feeddata = FeedParserDict() # feed-level data self.encoding = encoding # character enco... | def __init__(self, baseuri=None, baselang=None, encoding='utf-8'): if _debug: sys.stderr.write('initializing FeedParser\n') if not self._matchnamespaces: for k, v in self.namespaces.items(): self._matchnamespaces[k.lower()] = v self.feeddata = FeedParserDict() # feed-level data self.encoding = encoding # character enco... | 450,957 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,958 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,959 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,960 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,961 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,962 |
def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | def unknown_starttag(self, tag, attrs): if _debug: sys.stderr.write('start %s with %s\n' % (tag, attrs)) # normalize attrs attrs = [(k.lower(), v) for k, v in attrs] attrs = [(k, k in ('rel', 'type') and v.lower() or v) for k, v in attrs] # track xml:base and xml:lang attrsD = dict(attrs) baseuri = attrsD.get('xml:bas... | 450,963 |
def handle_entityref(self, ref): # called for each entity reference, e.g. for '©', ref will be 'copy' if not self.elementstack: return if _debug: sys.stderr.write('entering handle_entityref with %s\n' % ref) if ref in ('lt', 'gt', 'quot', 'amp', 'apos'): text = '&%s;' % ref else: # entity resolution graciously don... | def handle_entityref(self, ref): # called for each entity reference, e.g. for '©', ref will be 'copy' if not self.elementstack: return if _debug: sys.stderr.write('entering handle_entityref with %s\n' % ref) if ref in ('lt', 'gt', 'quot', 'amp', 'apos'): text = '&%s;' % ref else: # entity resolution graciously don... | 450,964 |
def name2cp(k): import htmlentitydefs if hasattr(htmlentitydefs, 'name2codepoint'): # requires Python 2.3 return htmlentitydefs.name2codepoint[k] k = htmlentitydefs.entitydefs[k] if k.startswith('&#') and k.endswith(';'): return int(k[2:-1]) # not in latin-1 return ord(k) | def name2cp(k): import htmlentitydefs if hasattr(htmlentitydefs, 'name2codepoint'): # requires Python 2.3 return htmlentitydefs.name2codepoint[k] k = htmlentitydefs.entitydefs[k] if k.startswith('&#') and k.endswith(';'): return int(k[2:-1]) # not in latin-1 return ord(k) | 450,965 |
def parse_declaration(self, i): # override internal declaration handler to handle CDATA blocks if _debug: sys.stderr.write('entering parse_declaration\n') if self.rawdata[i:i+9] == '<![CDATA[': k = self.rawdata.find(']]>', i) if k == -1: k = len(self.rawdata) self.handle_data(_xmlescape(self.rawdata[i+9:k]), 0) return ... | def parse_declaration(self, i): # override internal declaration handler to handle CDATA blocks if _debug: sys.stderr.write('entering parse_declaration\n') if self.rawdata[i:i+9] == '<![CDATA[': k = self.rawdata.find(']]>', i) if k == -1: k = len(self.rawdata) return k self.handle_data(_xmlescape(self.rawdata[i+9:k]), ... | 450,966 |
def parse_declaration(self, i): # override internal declaration handler to handle CDATA blocks if _debug: sys.stderr.write('entering parse_declaration\n') if self.rawdata[i:i+9] == '<![CDATA[': k = self.rawdata.find(']]>', i) if k == -1: k = len(self.rawdata) self.handle_data(_xmlescape(self.rawdata[i+9:k]), 0) return ... | def parse_declaration(self, i): # override internal declaration handler to handle CDATA blocks if _debug: sys.stderr.write('entering parse_declaration\n') if self.rawdata[i:i+9] == '<![CDATA[': k = self.rawdata.find(']]>', i) if k == -1: k = len(self.rawdata) self.handle_data(_xmlescape(self.rawdata[i+9:k]), 0) return ... | 450,967 |
def mapContentType(self, contentType): contentType = contentType.lower() if contentType == 'text': contentType = 'text/plain' elif contentType == 'html': contentType = 'text/html' elif contentType == 'xhtml': contentType = 'application/xhtml+xml' return contentType | def mapContentType(self, contentType): contentType = contentType.lower() if contentType == 'text': contentType = 'text/plain' elif contentType == 'html': contentType = 'text/html' elif contentType == 'xhtml': contentType = 'application/xhtml+xml' return contentType | 450,968 |
def resolveURI(self, uri): return _urljoin(self.baseuri or '', uri) | def resolveURI(self, uri): return _urljoin(self.baseuri or '', uri) | 450,969 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,970 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,971 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,972 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,973 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,974 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,975 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,976 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def if element == 'title' and self.hasTitle: return output pop(self, if element == 'title' and self.hasTitle: return output element, if element == 'title' and self.hasTitle: return output stripWhitespace=1): if element == 'title' and self.hasTitle: return output if if element == 'title' and self.hasTitle: return ou... | 450,977 |
def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | def pop(self, element, stripWhitespace=1): if not self.elementstack: return if self.elementstack[-1][0] != element: return element, expectingText, pieces = self.elementstack.pop() output = ''.join(pieces) if stripWhitespace: output = output.strip() if not expectingText: return output | 450,978 |
def popContent(self, tag): value = self.pop(tag) self.incontent -= 1 self.contentparams.clear() return value | def def lookslikehtml(self, str): if self.version.startswith('atom'): return if self.contentparams.get('type','text/html') != 'text/plain': return if not (re.search(r'</(\w+)>',str) or re.search("& if filter(lambda t: t.lower() not in _HTMLSanitizer.acceptable_elements, re.findall(r'</?(\w+)',str)): return fr... | 450,979 |
def _mapToStandardPrefix(self, name): colonpos = name.find(':') if colonpos <> -1: prefix = name[:colonpos] suffix = name[colonpos+1:] prefix = self.namespacemap.get(prefix, prefix) name = prefix + ':' + suffix return name | def _mapToStandardPrefix(self, name): colonpos = name.find(':') if colonpos <> -1: prefix = name[:colonpos] suffix = name[colonpos+1:] prefix = self.namespacemap.get(prefix, prefix) name = prefix + ':' + suffix return name | 450,980 |
def _itsAnHrefDamnIt(self, attrsD): href = attrsD.get('url', attrsD.get('uri', attrsD.get('href', None))) if href: try: del attrsD['url'] except KeyError: pass try: del attrsD['uri'] except KeyError: pass attrsD['href'] = href return attrsD | def _itsAnHrefDamnIt(self, attrsD): href = attrsD.get('url', attrsD.get('uri', attrsD.get('href', None))) if href: try: del attrsD['url'] except KeyError: pass try: del attrsD['uri'] except KeyError: pass attrsD['href'] = href return attrsD | 450,981 |
def _start_rss(self, attrsD): versionmap = {'0.91': 'rss091u', '0.92': 'rss092', '0.93': 'rss093', '0.94': 'rss094'} if not self.version: attr_version = attrsD.get('version', '') version = versionmap.get(attr_version) if version: self.version = version elif attr_version.startswith('2.'): self.version = 'rss20' else: se... | def _start_rss(self, attrsD): versionmap = {'0.91': 'rss091u', '0.92': 'rss092', '0.93': 'rss093', '0.94': 'rss094'} if not self.version or not self.version.startswith('rss'): attr_version = attrsD.get('version', '') version = versionmap.get(attr_version) if version: self.version = version elif attr_version.startswi... | 450,982 |
def _start_rss(self, attrsD): versionmap = {'0.91': 'rss091u', '0.92': 'rss092', '0.93': 'rss093', '0.94': 'rss094'} if not self.version: attr_version = attrsD.get('version', '') version = versionmap.get(attr_version) if version: self.version = version elif attr_version.startswith('2.'): self.version = 'rss20' else: se... | def _start_rss(self, attrsD): versionmap = {'0.91': 'rss091u', '0.92': 'rss092', '0.93': 'rss093', '0.94': 'rss094'} if not self.version: attr_version = attrsD.get('version', '') version = versionmap.get(attr_version) if version: self.version = version elif attr_version.startswith('2.'): self.version = 'rss20' else: se... | 450,983 |
def _cdf_common(self, attrsD): if attrsD.has_key('lastmod'): self._start_modified({}) self.elementstack[-1][-1] = attrsD['lastmod'] self._end_modified() if attrsD.has_key('href'): self._start_link({}) self.elementstack[-1][-1] = attrsD['href'] self._end_link() | def _cdf_common(self, attrsD): if attrsD.has_key('lastmod'): self._start_modified({}) self.elementstack[-1][-1] = attrsD['lastmod'] self._end_modified() if attrsD.has_key('href'): self._start_link({}) self.elementstack[-1][-1] = attrsD['href'] self._end_link() | 450,984 |
def _end_channel(self): self.infeed = 0 | def _end_channel(self): self.infeed = 0 | 450,985 |
def _start_image(self, attrsD): self.inimage = 1 self.push('image', 0) context = self._getContext() context.setdefault('image', FeedParserDict()) | def _start_image(self, attrsD): context = self._getContext() context.setdefault('image', FeedParserDict()) | 450,986 |
def _start_image(self, attrsD): self.inimage = 1 self.push('image', 0) context = self._getContext() context.setdefault('image', FeedParserDict()) | defself.inimage = 1 self.hasTitle = 0 self.push('image', 0) _start_image(self,self.inimage = 1 self.hasTitle = 0 self.push('image', 0) attrsD):self.inimage = 1 self.hasTitle = 0 self.push('image', 0) self.inimageself.inimage = 1 self.hasTitle = 0 self.push('image', 0) =self.inimage = 1 self.hasTitle = 0 self.push('... | 450,987 |
def _start_textinput(self, attrsD): self.intextinput = 1 self.push('textinput', 0) context = self._getContext() context.setdefault('textinput', FeedParserDict()) | def _start_textinput(self, attrsD): context = self._getContext() context.setdefault('textinput', FeedParserDict()) | 450,988 |
def _start_textinput(self, attrsD): self.intextinput = 1 self.push('textinput', 0) context = self._getContext() context.setdefault('textinput', FeedParserDict()) | def _start_textinput(self, attrsD): self.intextinput = 1 self.push('textinput', 0) context = self._getContext() context.setdefault('textinput', FeedParserDict()) | 450,989 |
def _end_name(self): value = self.pop('name') if self.inpublisher: self._save_author('name', value, 'publisher') elif self.inauthor: self._save_author('name', value) elif self.incontributor: self._save_contributor('name', value) elif self.intextinput: context = self._getContext() context['textinput']['name'] = value | def _end_name(self): value = self.pop('name') if self.inpublisher: self._save_author('name', value, 'publisher') elif self.inauthor: self._save_author('name', value) elif self.incontributor: self._save_contributor('name', value) elif self.intextinput: context = self._getContext() context['textinput']['name'] = value | 450,990 |
def _end_width(self): value = self.pop('width') try: value = int(value) except: value = 0 if self.inimage: context = self._getContext() context['image']['width'] = value | def _end_width(self): value = self.pop('width') try: value = int(value) except: value = 0 if self.inimage: context = self._getContext() context['image']['width'] = value | 450,991 |
def _end_height(self): value = self.pop('height') try: value = int(value) except: value = 0 if self.inimage: context = self._getContext() context['image']['height'] = value | def _end_height(self): value = self.pop('height') try: value = int(value) except: value = 0 if self.inimage: context = self._getContext() context['image']['height'] = value | 450,992 |
def _end_url(self): value = self.pop('href') if self.inauthor: self._save_author('href', value) elif self.incontributor: self._save_contributor('href', value) elif self.inimage: context = self._getContext() context['image']['href'] = value elif self.intextinput: context = self._getContext() context['textinput']['link']... | def _end_url(self): value = self.pop('href') if self.inauthor: self._save_author('href', value) elif self.incontributor: self._save_contributor('href', value) elif self.inimage: context = self._getContext() context['image']['href'] = value elif self.intextinput: context = self._getContext() context['textinput']['link']... | 450,993 |
def _sync_author_detail(self, key='author'): context = self._getContext() detail = context.get('%s_detail' % key) if detail: name = detail.get('name') email = detail.get('email') if name and email: context[key] = '%s (%s)' % (name, email) elif name: context[key] = name elif email: context[key] = email else: author = co... | def _sync_author_detail(self, key='author'): context = self._getContext() detail = context.get('%s_detail' % key) if detail: name = detail.get('name') email = detail.get('email') if name and email: context[key] = '%s (%s)' % (name, email) elif name: context[key] = name elif email: context[key] = email else: author, ema... | 450,994 |
def _sync_author_detail(self, key='author'): context = self._getContext() detail = context.get('%s_detail' % key) if detail: name = detail.get('name') email = detail.get('email') if name and email: context[key] = '%s (%s)' % (name, email) elif name: context[key] = name elif email: context[key] = email else: author = co... | def _sync_author_detail(self, key='author'): context = self._getContext() detail = context.get('%s_detail' % key) if detail: name = detail.get('name') email = detail.get('email') if name and email: context[key] = '%s (%s)' % (name, email) elif name: context[key] = name elif email: context[key] = email else: author = co... | 450,995 |
def _end_subtitle(self): self.popContent('subtitle') | def _end_subtitle(self): self.popContent('subtitle') | 450,996 |
def _start_cc_license(self, attrsD): self.push('license', 1) value = self._getAttribute(attrsD, 'rdf:resource') if value: self.elementstack[-1][2].append(value) self.pop('license') | def _start_cc_license(self, attrsD): context = self._getContext() value = self._getAttribute(attrsD, 'rdf:resource') if value: self.elementstack[-1][2].append(value) self.pop('license') | 450,997 |
def _start_cc_license(self, attrsD): self.push('license', 1) value = self._getAttribute(attrsD, 'rdf:resource') if value: self.elementstack[-1][2].append(value) self.pop('license') | def _start_cc_license(self, attrsD): self.push('license', 1) value = self._getAttribute(attrsD, 'rdf:resource') if value: self.elementstack[-1][2].append(value) self.pop('license') | 450,998 |
def _end_creativecommons_license(self): self.pop('license') | def _end_creativecommons_license(self): self.pop('license') | 450,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.