bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def library(self, start='0', num='50', sort=None, search=None, _=None, order='ascending'): ''' Serves metadata from the calibre database as XML. | def library(self, start='0', num='50', sort=None, search=None, _=None, order='ascending'): ''' Serves metadata from the calibre database as XML. | 451,600 |
def __init__(self, parent, library_view, server=None, initial_category='general'): ResizableDialog.__init__(self, parent) self._category_model = CategoryModel() | def __init__(self, parent, library_view, server=None, initial_category='general'): ResizableDialog.__init__(self, parent) self._category_model = CategoryModel() | 451,601 |
def get_soup(self, src): nmassage = copy.copy(BeautifulSoup.MARKUP_MASSAGE) nmassage.extend(self.preprocess_regexps) nmassage += [(re.compile(r'<!DOCTYPE .+?>', re.DOTALL), lambda m: '')] # Some websites have buggy doctype declarations that mess up beautifulsoup # Remove comments as they can leave detritus when extract... | def get_soup(self, src): nmassage = copy.copy(BeautifulSoup.MARKUP_MASSAGE) nmassage.extend(self.preprocess_regexps) nmassage += [(re.compile(r'<!DOCTYPE .+?>', re.DOTALL), lambda m: '')] # Some websites have buggy doctype declarations that mess up beautifulsoup # Remove comments as they can leave detritus when extract... | 451,602 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus, MimeType): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug... | 451,603 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | 451,604 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | 451,605 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | 451,606 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | 451,607 |
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus): changed = False # if path_to_ext(path) in self.FORMATS: try: lpath = path.partition(self.normalize_path(prefix))[2] if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') # debug_print("LP... | 451,608 |
def contentid_from_path(self, path, ContentType): if ContentType == 6: if self.has_kepubs == False: ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either ContentID = ContentID.replace(self._main_prefix, '') else: ContentID = path ContentID = ContentID.replace(self._main_prefix + sel... | def contentid_from_path(self, path, ContentType): if ContentType == 6: extension = os.path.splitext(path)[1] if extension == '.kobo': ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either ContentID = ContentID.replace(self._main_prefix, '') else: ContentID = path ContentID = Conten... | 451,609 |
def path_from_contentid(self, ContentID, ContentType, oncard): path = ContentID | def path_from_contentid(self, ContentID, ContentType, MimeType, oncard): path = ContentID | 451,610 |
def path_from_contentid(self, ContentID, ContentType, oncard): path = ContentID | def path_from_contentid(self, ContentID, ContentType, oncard): path = ContentID | 451,611 |
def path_from_contentid(self, ContentID, ContentType, oncard): path = ContentID | def path_from_contentid(self, ContentID, ContentType, oncard): path = ContentID | 451,612 |
def commit(self, book_ids, notify=False): if self.process_each_book(): for book_id in book_ids: val = self.db.get_custom(book_id, num=self.col_id, index_is_id=True) new_val = self.getter(val) if set(val) != new_val or True: self.db.set_custom(book_id, new_val, num=self.col_id, notify=notify) else: val = self.getter() v... | def commit(self, book_ids, notify=False): if self.process_each_book(): for book_id in book_ids: val = self.db.get_custom(book_id, num=self.col_id, index_is_id=True) new_val = self.getter(val) if set(val) != new_val: self.db.set_custom(book_id, new_val, num=self.col_id, notify=notify) else: val = self.getter() val = sel... | 451,613 |
def __init__(self, title, author, publisher, isbn, key): QThread.__init__(self) self.title = title self.author = author self.publisher = publisher self.isbn = isbn self.key = key | def __init__(self, title, author, publisher, isbn, key): Thread.__init__(self) self.daemon = True self.title = title self.author = author self.publisher = publisher self.isbn = isbn self.key = key | 451,614 |
def hangcheck(self): if not (self.fetcher.isFinished() or time.time() - self.start_time > 75): return self._hangcheck.stop() try: if self.fetcher.isRunning(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.fetcher.terminate() return s... | def hangcheck(self): if self.fetcher.is_alive() and \ time.time() - self.start_time < self.HANG_TIME: return self._hangcheck.stop() try: if self.fetcher.isRunning(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.fetcher.terminate() r... | 451,615 |
def hangcheck(self): if not (self.fetcher.isFinished() or time.time() - self.start_time > 75): return self._hangcheck.stop() try: if self.fetcher.isRunning(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.fetcher.terminate() return s... | def hangcheck(self): if not (self.fetcher.isFinished() or time.time() - self.start_time > 75): return self._hangcheck.stop() try: if self.fetcher.is_alive(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.fetcher.terminate() return se... | 451,616 |
def hangcheck(self): if not (self.fetcher.isFinished() or time.time() - self.start_time > 75): return self._hangcheck.stop() try: if self.fetcher.isRunning(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.fetcher.terminate() return s... | def hangcheck(self): if not (self.fetcher.isFinished() or time.time() - self.start_time > 75): return self._hangcheck.stop() try: if self.fetcher.isRunning(): error_dialog(self, _('Could not find metadata'), _('The metadata download seems to have stalled. ' 'Try again later.')).exec_() self.terminate() return self.queu... | 451,617 |
def terminate(self): if hasattr(self, 'fetcher') and self.fetcher.isRunning(): self.fetcher.terminate() if hasattr(self, '_hangcheck') and self._hangcheck.isActive(): self._hangcheck.stop() | def terminate(self): if hasattr(self, 'fetcher') and self.fetcher.is_alive(): _hung_fetchers.add(self.fetcher) if hasattr(self, '_hangcheck') and self._hangcheck.isActive(): self._hangcheck.stop() | 451,618 |
def set_database(self, db, tag_match, sort_by): self.hidden_categories = config['tag_browser_hidden_categories'] self._model = TagsModel(db, parent=self, hidden_categories=self.hidden_categories, search_restriction=None) self.sort_by = sort_by self.tag_match = tag_match self.db = db self.search_restriction = None self.... | def set_database(self, db, tag_match, sort_by): self.hidden_categories = config['tag_browser_hidden_categories'] self._model = TagsModel(db, parent=self, hidden_categories=self.hidden_categories, search_restriction=None) self.sort_by = sort_by self.tag_match = tag_match self.db = db self.search_restriction = None self.... | 451,619 |
def fetch(self): try: self.results = search(self.title, self.book_author, self.publisher, self.isbn, max_results=5, verbose=self.verbose, lang='all') except Exception, e: self.exception = e self.tb = traceback.format_exc() | def fetch(self): try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = search(self.title, self.book_author, self.publisher, self.isbn, max_results=5, verbose=self.verbose, lang='all') except Exception, e: self.exception = e self.tb = traceback.format_exc() | 451,620 |
def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(AmazonError, s... | def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(AmazonError, s... | 451,621 |
def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(AmazonError, s... | def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(get_social_met... | 451,622 |
def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(AmazonError, s... | def fetch(self): if not self.isbn: return try: lang = get_lang() lang = lang[:2] if re.match(r'(fr.*|de.*)', lang) else 'all' if lang == 'all': self.results = get_social_metadata(self.title, self.book_author, self.publisher, self.isbn, verbose=self.verbose, lang='all')[0] else: tmploc = ThreadwithResults(AmazonError, s... | 451,623 |
def __init__(self, error, verb, func, *args, **kargs): self.func = func self.args = args self.kargs = kargs self.verbose = verb self.ex = error self.result = None Thread.__init__(self) | def __init__(self, func, *args, **kargs): self.func = func self.args = args self.kargs = kargs self.verbose = verb self.ex = error self.result = None Thread.__init__(self) | 451,624 |
def __init__(self, error, verb, func, *args, **kargs): self.func = func self.args = args self.kargs = kargs self.verbose = verb self.ex = error self.result = None Thread.__init__(self) | def __init__(self, error, verb, func, *args, **kargs): self.func = func self.args = args self.kargs = kargs self.result = None Thread.__init__(self) | 451,625 |
def run(self): try: self.result = self.func(*self.args, **self.kargs) except Exception, e: report(self.verbose) raise self.ex(_('An error was encountered in the function threading')) | def run(self): try: self.result = self.func(*self.args, **self.kargs) except Exception, e: report(self.verbose) raise self.ex(_('An error was encountered in the function threading')) | 451,626 |
def __init__(self, title=None, author=None, publisher=None, isbn=None, keywords=None, max_results=10, rlang='all'): assert not(title is None and author is None and publisher is None \ and isbn is None and keywords is None) assert (max_results < 11) | def __init__(self, title=None, author=None, publisher=None, isbn=None, keywords=None, max_results=20, rlang='all'): assert not(title is None and author is None and publisher is None \ and isbn is None and keywords is None) assert (max_results < 11) | 451,627 |
def __init__(self, title=None, author=None, publisher=None, isbn=None, keywords=None, max_results=10, rlang='all'): assert not(title is None and author is None and publisher is None \ and isbn is None and keywords is None) assert (max_results < 11) | def __init__(self, title=None, author=None, publisher=None, isbn=None, keywords=None, max_results=10, rlang='all'): assert not(title is None and author is None and publisher is None \ and isbn is None and keywords is None) assert (max_results < 11) | 451,628 |
def populate(self, entries, br, verbose=False): res = [] for x in entries: entry = self.get_individual_metadata(x, br, verbose) if entry is not None: mi = self.fill_MI(entry, verbose) if mi is not None: mi.tags, atag = self.get_tags(entry, verbose) if atag: tags = self.get_individual_metadata(mi.tags, br, verbose) if t... | def fetchdatathread(self, qbr, qsync, nb, url, verbose): try: browser = qbr.get(True) entry = self.get_individual_metadata(url, browser, verbose) except: report(verbose) entry = None finally: qbr.put(browser, True) qsync.put(nb, True) return entry def producer(self, sync, urls, br, verbose=False): for i in xrange(len(... | 451,629 |
def populate(self, entries, br, verbose=False): res = [] for x in entries: entry = self.get_individual_metadata(x, br, verbose) if entry is not None: mi = self.fill_MI(entry, verbose) if mi is not None: mi.tags, atag = self.get_tags(entry, verbose) if atag: tags = self.get_individual_metadata(mi.tags, br, verbose) if t... | def populate(self, entries, br, verbose=False): res = [] for x in entries: entry = self.get_individual_metadata(x, br, verbose) if entry is not None: mi = self.fill_MI(entry, verbose) if mi is not None: mi.tags, atag = self.get_tags(entry, verbose) if atag: tags = self.get_individual_metadata(mi.tags, br, verbose) if t... | 451,630 |
def option_parser(): parser = OptionParser(textwrap.dedent(\ _('''\ %prog [options] Fetch book metadata from Amazon. You must specify one of title, author, ISBN, publisher or keywords. Will fetch a maximum of 10 matches, so you should make your query as specific as possible. You can chose the language for metadata ret... | def option_parser(): parser = OptionParser(textwrap.dedent(\ _('''\ %prog [options] Fetch book metadata from Amazon. You must specify one of title, author, ISBN, publisher or keywords. Will fetch a maximum of 20 matches, so you should make your query as specific as possible. You can chose the language for metadata ret... | 451,631 |
def setup_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = get_pdf_printer() custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(paper_size(opts.... | def get_pdf_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = get_pdf_printer() custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(paper_size(opt... | 451,632 |
def setup_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = get_pdf_printer() custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(paper_size(opts.... | def setup_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = QPrinter(QPrinter.HighResolution) custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(... | 451,633 |
def setup_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = get_pdf_printer() custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(paper_size(opts.... | def setup_printer(opts, for_comic=False): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): raise Exception('Not OK to use Qt') printer = get_pdf_printer() custom_size = get_custom_size(opts) if opts.output_profile.short_name == 'default': if custom_size is None: printer.setPaperSize(paper_size(opts.... | 451,634 |
def get_printer_page_size(opts, for_comic=False): printer = setup_printer(opts, for_comic=for_comic) size = printer.paperSize(QPrinter.Millimeter) return size.width() / 10., size.height() / 10. | def get_printer_page_size(opts, for_comic=False): printer = get_pdf_printer(opts, for_comic=for_comic) size = printer.paperSize(QPrinter.Millimeter) return size.width() / 10., size.height() / 10. | 451,635 |
def get_printer(self, set_horz_margins=False): printer = get_pdf_printer() printer.setPaperSize(QSizeF(self.size[0] * 10, self.size[1] * 10), QPrinter.Millimeter) if set_horz_margins: printer.setPageMargins(0., self.opts.margin_top, 0., self.opts.margin_bottom, QPrinter.Point) else: printer.setPageMargins(0, 0, 0, 0, Q... | def get_printer(self, set_horz_margins=False): printer = get_pdf_printer() printer.setPaperSize(QSizeF(self.size[0] * 10, self.size[1] * 10), QPrinter.Millimeter) if set_horz_margins: printer.setPageMargins(0., self.opts.margin_top, 0., self.opts.margin_bottom, QPrinter.Point) else: printer.setPageMargins(0, 0, 0, 0, Q... | 451,636 |
def _render_html(self, ok): if ok: item_path = os.path.join(self.tmp_path, '%i.pdf' % len(self.combine_queue)) self.logger.debug('\tRendering item %s as %i' % (os.path.basename(str(self.view.url().toLocalFile())), len(self.combine_queue))) printer = self.get_printer(set_horz_margins=True) printer.setOutputFileName(item... | def _render_html(self, ok): if ok: item_path = os.path.join(self.tmp_path, '%i.pdf' % len(self.combine_queue)) self.logger.debug('\tRendering item %s as %i.pdf' % (os.path.basename(str(self.view.url().toLocalFile())), len(self.combine_queue))) printer = get_pdf_printer(self.opts) printer.setOutputFileName(item_path) se... | 451,637 |
def render_images(self, outpath, mi, items): printer = get_pdf_printer() printer.setPaperSize(QSizeF(self.size[0] * 10, self.size[1] * 10), QPrinter.Millimeter) printer.setPageMargins(0, 0, 0, 0, QPrinter.Point) printer.setOrientation(orientation(self.opts.orientation)) printer.setOutputFormat(QPrinter.PdfFormat) print... | def render_images(self, outpath, mi, items): printer = get_pdf_printer(self.opts) printer.setOutputFileName(outpath) printer.setDocName(mi.title) printer.setCreator(u'%s [%s]'%(__appname__, __version__)) # Seems to be no way to set author printer.setFullPage(True) | 451,638 |
def render_images(self, outpath, mi, items): printer = get_pdf_printer() printer.setPaperSize(QSizeF(self.size[0] * 10, self.size[1] * 10), QPrinter.Millimeter) printer.setPageMargins(0, 0, 0, 0, QPrinter.Point) printer.setOrientation(orientation(self.opts.orientation)) printer.setOutputFormat(QPrinter.PdfFormat) print... | def render_images(self, outpath, mi, items): printer = get_pdf_printer() printer.setPaperSize(QSizeF(self.size[0] * 10, self.size[1] * 10), QPrinter.Millimeter) printer.setPageMargins(0, 0, 0, 0, QPrinter.Point) printer.setOrientation(orientation(self.opts.orientation)) printer.setOutputFormat(QPrinter.PdfFormat) print... | 451,639 |
def _postprocess_html(self, soup, first_fetch, job_info): if self.no_stylesheets: for link in list(soup.findAll('link', type=re.compile('css')))+list(soup.findAll('style')): link.extract() head = soup.find('head') if not head: head = soup.find('body') if not head: head = soup.find(True) style = BeautifulSoup(u'<style t... | def _postprocess_html(self, soup, first_fetch, job_info): if self.no_stylesheets: for link in list(soup.findAll('link', type=re.compile('css')))+list(soup.findAll('style')): link.extract() head = soup.find('head') if not head: head = soup.find('body') if not head: head = soup.find(True) style = BeautifulSoup(u'<style t... | 451,640 |
def first_pass(data): try: data = etree.fromstring(data, parser=parser) except etree.XMLSyntaxError, err: self.oeb.log.exception('Initial parse failed:') repl = lambda m: ENTITYDEFS.get(m.group(1), m.group(0)) data = ENTITY_RE.sub(repl, data) try: data = etree.fromstring(data, parser=parser) except etree.XMLSyntaxError... | def first_pass(data): try: data = etree.fromstring(data, parser=parser) except etree.XMLSyntaxError, err: self.oeb.log.exception('Initial parse failed:') repl = lambda m: ENTITYDEFS.get(m.group(1), m.group(0)) data = ENTITY_RE.sub(repl, data) try: data = etree.fromstring(data, parser=parser) except etree.XMLSyntaxError... | 451,641 |
def _generate(self, article, style=None, extra_css=None): content = article.content if article.content else '' summary = article.summary if article.summary else '' text = content if len(content) > len(summary) else summary head = HEAD(TITLE(article.title)) if style: head.append(STYLE(style, type='text/css')) if extra_c... | def _generate(self, article, style=None, extra_css=None): content = article.content if article.content else '' summary = article.summary if article.summary else '' text = content if len(content) > len(summary) else summary head = HEAD(TITLE(article.title)) if style: head.append(STYLE(style, type='text/css')) if extra_c... | 451,642 |
def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir if self.verbose: print self.updateProgressFullStep("generateHTMLDescriptions()") | def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir if self.verbose: print self.updateProgressFullStep("generateHTMLDescriptions()") | 451,643 |
def mlize(self): output = [ u'' ] stylizer = Stylizer(self.item.data, self.item.href, self.oeb_book, self.opts, self.opts.output_profile) content = unicode(etree.tostring(self.item.data.find(XHTML('body')), encoding=unicode)) content = self.remove_newlines(content) trees = { } for subitem, subtitle in self.subitems: sn... | def mlize(self): output = [ u'' ] stylizer = Stylizer(self.item.data, self.item.href, self.oeb_book, self.opts, self.opts.output_profile) content = unicode(etree.tostring(self.item.data.find(XHTML('body')), encoding=unicode)) content = self.remove_newlines(content) trees = { } for subitem, subtitle in self.subitems: sn... | 451,644 |
def mobimlize_elem(self, elem, stylizer, bstate, istates, ignore_valign=False): if not isinstance(elem.tag, basestring) \ or namespace(elem.tag) != XHTML_NS: return style = stylizer.style(elem) # <mbp:frame-set/> does not exist lalalala if style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot') \ or style['visib... | def mobimlize_elem(self, elem, stylizer, bstate, istates, ignore_valign=False): if not isinstance(elem.tag, basestring) \ or namespace(elem.tag) != XHTML_NS: id_ = elem.get('id', None) if id_: elem.clear() elem.text = None elem.set('id', id_) else: return style = stylizer.style(elem) # <mbp:frame-set/> does not exist... | 451,645 |
def update(self, booklists, collections_attributes): debug_print('Starting update', collections_attributes) for i, booklist in booklists.items(): playlist_map = self.build_id_playlist_map(i) debug_print('Updating XML Cache:', i) root = self.record_roots[i] lpath_map = self.build_lpath_map(root) for book in booklist: pa... | def update(self, booklists, collections_attributes): debug_print('Starting update', collections_attributes) for i, booklist in booklists.items(): playlist_map = self.build_id_playlist_map(i) debug_print('Updating XML Cache:', i) root = self.record_roots[i] lpath_map = self.build_lpath_map(root) for book in booklist: pa... | 451,646 |
def check_timestamp(self, record, book, path): ''' Checks the timestamp in the Sony DB against the file. If different, return the file timestamp. Otherwise return None. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | def update_text_record(self, record, book, path, bl_index): ''' Checks the timestamp in the Sony DB against the file. If different, return the file timestamp. Otherwise return None. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | 451,647 |
def check_timestamp(self, record, book, path): ''' Checks the timestamp in the Sony DB against the file. If different, return the file timestamp. Otherwise return None. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | def check_timestamp(self, record, book, path): ''' Update the Sony database from the book. This is done if the timestamp in the db differs from the timestamp on the file. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | 451,648 |
def check_timestamp(self, record, book, path): ''' Checks the timestamp in the Sony DB against the file. If different, return the file timestamp. Otherwise return None. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | def check_timestamp(self, record, book, path): ''' Checks the timestamp in the Sony DB against the file. If different, return the file timestamp. Otherwise return None. ''' timestamp = os.path.getmtime(path) date = strftime(timestamp) if date != record.get('date', None): return date return None | 451,649 |
def initialize(self, library_path, db, listener, actions): opts = self.opts self.last_time = datetime.datetime.now() self.preferences_action, self.quit_action = actions self.library_path = library_path self.spare_servers = [] self.must_restart_before_config = False # Initialize fontconfig in a separate thread as this c... | def initialize(self, library_path, db, listener, actions): opts = self.opts self.last_time = datetime.datetime.now() self.preferences_action, self.quit_action = actions self.library_path = library_path self.spare_servers = [] self.must_restart_before_config = False # Initialize fontconfig in a separate thread as this c... | 451,650 |
def initialize(self, library_path, db, listener, actions): opts = self.opts self.last_time = datetime.datetime.now() self.preferences_action, self.quit_action = actions self.library_path = library_path self.spare_servers = [] self.must_restart_before_config = False # Initialize fontconfig in a separate thread as this c... | def initialize(self, library_path, db, listener, actions): opts = self.opts self.last_time = datetime.datetime.now() self.preferences_action, self.quit_action = actions self.library_path = library_path self.spare_servers = [] self.must_restart_before_config = False # Initialize fontconfig in a separate thread as this c... | 451,651 |
def recount(self, *args): if not is_gui_thread(): # Re-call in GUI thread return Dispatcher(self.recount)(*args) ci = self.currentIndex() if not ci.isValid(): ci = self.indexAt(QPoint(10, 10)) try: self.model().refresh() except: #Database connection could be closed if an integrity check is happening pass if ci.isValid(... | def recount(self, *args): if not is_gui_thread(): # Re-call in GUI thread return Dispatcher(self.recount)(*args) ci = self.currentIndex() if not ci.isValid(): ci = self.indexAt(QPoint(10, 10)) try: self.model().refresh() except: #Database connection could be closed if an integrity check is happening pass if ci.isValid(... | 451,652 |
def recount(self, *args): if not is_gui_thread(): # Re-call in GUI thread return Dispatcher(self.recount)(*args) ci = self.currentIndex() if not ci.isValid(): ci = self.indexAt(QPoint(10, 10)) try: self.model().refresh() except: #Database connection could be closed if an integrity check is happening pass if ci.isValid(... | def recount(self, *args): if not is_gui_thread(): # Re-call in GUI thread return Dispatcher(self.recount)(*args) ci = self.currentIndex() if not ci.isValid(): ci = self.indexAt(QPoint(10, 10)) try: self.model().refresh() except: #Database connection could be closed if an integrity check is happening pass if ci.isValid(... | 451,653 |
def generateSortTitle(self, title): # Convert the actual title to a string suitable for sorting. # Ignore leading stop words # Optionally convert leading numbers to strings from calibre.ebooks.metadata import title_sort # Strip stop words title_words = title_sort(title).split() translated = [] | def generateSortTitle(self, title): # Convert the actual title to a string suitable for sorting. # Ignore leading stop words # Optionally convert leading numbers to strings from calibre.ebooks.metadata import title_sort # Strip stop words title_words = title_sort(title).split() translated = [] | 451,654 |
def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile, "File is not a zip file" if self.debug > 1: print endrec size_cd = endrec[_ECD_SIZE] # bytes in central directory offset_cd = endrec[_ECD_OFFSET] #... | def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp endrec = _EndRecData(fp) if not endrec: raise BadZipfile, "File is not a zip file" if self.debug > 1: print endrec size_cd = endrec[_ECD_SIZE] # bytes in central directory offset_cd = endrec[_ECD_OFFSET] #... | 451,655 |
def _calculate_file_offsets(self): for zip_info in self.filelist: self.fp.seek(zip_info.header_offset, 0) fheader = self.fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) # file_offset is computed here, since the extr... | def _calculate_file_offsets(self): for zip_info in self.filelist: self.fp.seek(zip_info.header_offset, 0) fheader = self.fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) # file_offset is computed here, since the extr... | 451,656 |
def _calculate_file_offsets(self): for zip_info in self.filelist: self.fp.seek(zip_info.header_offset, 0) fheader = self.fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) # file_offset is computed here, since the extr... | def _calculate_file_offsets(self): for zip_info in self.filelist: self.fp.seek(zip_info.header_offset, 0) fheader = self.fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) # file_offset is computed here, since the extr... | 451,657 |
def delete(self, name): """Delete the file from the archive. If it appears multiple times only the first instance will be deleted.""" for i in range (0, len(self.filelist)): if self.filelist[i].filename == name: if self.debug: print "Removing", name deleted_offset = self.filelist[i].header_offset deleted_size = (self... | def delete(self, name): """Delete the file from the archive. If it appears multiple times only the first instance will be deleted.""" for i in range (0, len(self.filelist)): if self.filelist[i].filename == name: if self.debug: print "Removing", name deleted_offset = self.filelist[i].header_offset deleted_size = (self... | 451,658 |
def delete(self, name): """Delete the file from the archive. If it appears multiple times only the first instance will be deleted.""" for i in range (0, len(self.filelist)): if self.filelist[i].filename == name: if self.debug: print "Removing", name deleted_offset = self.filelist[i].header_offset deleted_size = (self... | def delete(self, name): """Delete the file from the archive. If it appears multiple times only the first instance will be deleted.""" for i in range (0, len(self.filelist)): if self.filelist[i].filename == name: if self.debug: print "Removing", name deleted_offset = self.filelist[i].header_offset deleted_size = (self... | 451,659 |
def _extract_member(self, member, targetpath, pwd): """Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ # build the destination pathname, replacing # forward slashes to platform specific separators. if targetpath[-1:] == "/": targetpath = targetpath[:-1] | def _extract_member(self, member, targetpath, pwd): """Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ # build the destination pathname, replacing # forward slashes to platform specific separators. if targetpath[-1:] == "/": targetpath = targetpath[:-1] | 451,660 |
def _extract_member(self, member, targetpath, pwd): """Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ # build the destination pathname, replacing # forward slashes to platform specific separators. if targetpath[-1:] == "/": targetpath = targetpath[:-1] | def _extract_member(self, member, targetpath, pwd): """Extract the ZipInfo object 'member' to a physical file on the path targetpath. """ # build the destination pathname, replacing # forward slashes to platform specific separators. if targetpath[-1:] == "/": targetpath = targetpath[:-1] | 451,661 |
def writestr(self, zinfo_or_arcname, bytes, permissions=0600, compression=ZIP_DEFLATED): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.""" if not isinstance(zinfo_or_arcname, ZipInfo): if isinstance(zinfo_or... | def writestr(self, zinfo_or_arcname, bytes, permissions=0600, compression=ZIP_DEFLATED): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or the name of the file in the archive.""" if not isinstance(zinfo_or_arcname, ZipInfo): if isinstance(zinfo_or... | 451,662 |
def add_dir(self, path, prefix=''): ''' Add a directory recursively to the zip file with an optional prefix. ''' if prefix: self.writestr(prefix+'/', '', 0700) cwd = os.path.abspath(os.getcwd()) try: os.chdir(path) fp = (prefix + ('/' if prefix else '')).replace('//', '/') for f in os.listdir('.'): arcname = fp + f if ... | def add_dir(self, path, prefix=''): ''' Add a directory recursively to the zip file with an optional prefix. ''' if prefix: self.writestr(prefix+'/', '', 0700) cwd = os.path.abspath(os.getcwd()) try: os.chdir(path) fp = (prefix + ('/' if prefix else '')).replace('//', '/') for f in os.listdir('.'): arcname = fp + f if ... | 451,663 |
def add_dir(self, path, prefix=''): ''' Add a directory recursively to the zip file with an optional prefix. ''' if prefix: self.writestr(prefix+'/', '', 0700) cwd = os.path.abspath(os.getcwd()) try: os.chdir(path) fp = (prefix + ('/' if prefix else '')).replace('//', '/') for f in os.listdir('.'): arcname = fp + f if ... | def add_dir(self, path, prefix=''): ''' Add a directory recursively to the zip file with an optional prefix. ''' if prefix: self.writestr(prefix+'/', '', 0700) cwd = os.path.abspath(os.getcwd()) try: os.chdir(path) fp = (prefix + ('/' if prefix else '')).replace('//', '/') for f in os.listdir('.'): arcname = fp + f if ... | 451,664 |
def close(self): """Close the file, and for mode "w" and "a" write the ending records.""" if self.fp is None: return | def close(self): """Close the file, and for mode "w" and "a" write the ending records.""" if self.fp is None: return | 451,665 |
def safe_replace(zipstream, name, datastream): ''' Replace a file in a zip file in a safe manner. This proceeds by extracting and re-creating the zipfile. This is neccessary because :method:`ZipFile.replace` sometimes created corrupted zip files. :param zipstream: Stream from a zip file :param name: The name of... | def safe_replace(zipstream, name, datastream): ''' Replace a file in a zip file in a safe manner. This proceeds by extracting and re-creating the zipfile. This is neccessary because :method:`ZipFile.replace` sometimes created corrupted zip files. :param zipstream: Stream from a zip file :param name: The name of... | 451,666 |
def is_match(fname): return (name is not None and fname == name) or \ (match is not None and match.search(fname) is not None) | def is_match(fname): return (name is not None and fname == name) or \ (match is not None and match.search(fname) is not None) | 451,667 |
def set_books_in_library(self, booklists, reset=False): # Force a reset if the caches are not initialized if reset or not hasattr(self, 'db_book_title_cache'): # It might be possible to get here without having initialized the # library view. In this case, simply give up if not hasattr(self, 'library_view') or self.libr... | def set_books_in_library(self, booklists, reset=False): # Force a reset if the caches are not initialized if reset or not hasattr(self, 'db_book_title_cache'): # It might be possible to get here without having initialized the # library view. In this case, simply give up if not hasattr(self, 'library_view') or self.libr... | 451,668 |
def set_books_in_library(self, booklists, reset=False): # Force a reset if the caches are not initialized if reset or not hasattr(self, 'db_book_title_cache'): # It might be possible to get here without having initialized the # library view. In this case, simply give up if not hasattr(self, 'library_view') or self.libr... | def set_books_in_library(self, booklists, reset=False): # Force a reset if the caches are not initialized if reset or not hasattr(self, 'db_book_title_cache'): # It might be possible to get here without having initialized the # library view. In thi... | 451,669 |
def index_to_soup(self, url_or_raw, raw=False): ''' Convenience method that takes an URL to the index page and returns a `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/documentation.html>`_ of it. | def index_to_soup(self, url_or_raw, raw=False): ''' Convenience method that takes an URL to the index page and returns a `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/documentation.html>`_ of it. | 451,670 |
def extract(self): """Destructively rips this element out of the tree.""" if self.parent: try: self.parent.contents.remove(self) except ValueError: pass | def extract(self): """Destructively rips this element out of the tree.""" if self.parent: try: self.parent.contents.remove(self) except ValueError: pass | 451,671 |
def _feed(self, inDocumentEncoding=None): # Convert the document to Unicode. markup = self.markup if isinstance(markup, unicode): if not hasattr(self, 'originalEncoding'): self.originalEncoding = None else: # Changed detection by Kovid markup, self.originalEncoding = chardet.xml_to_unicode(markup) if markup: if self.ma... | def _feed(self, inDocumentEncoding=None): # Convert the document to Unicode. markup = self.markup if isinstance(markup, unicode): if not hasattr(self, 'originalEncoding'): self.originalEncoding = None else: # Changed detection by Kovid markup, self.originalEncoding = chardet.xml_to_unicode(markup) if markup: if self.ma... | 451,672 |
def _feed(self, inDocumentEncoding=None): # Convert the document to Unicode. markup = self.markup if isinstance(markup, unicode): if not hasattr(self, 'originalEncoding'): self.originalEncoding = None else: # Changed detection by Kovid markup, self.originalEncoding = chardet.xml_to_unicode(markup) if markup: if self.ma... | def _feed(self, inDocumentEncoding=None): # Convert the document to Unicode. markup = self.markup if isinstance(markup, unicode): if not hasattr(self, 'originalEncoding'): self.originalEncoding = None else: # Changed detection by Kovid markup, self.originalEncoding = chardet.xml_to_unicode(markup) if markup: if self.ma... | 451,673 |
def handle_charref(self, ref): "Handle character references as data." if self.convertEntities: if ref.lower().startswith('x'): # ref = int(ref[1:], 16) # Added by Kovid to handle hex numeric entities try: data = unichr(int(ref)) except ValueError: # Bad numerical entity. Added by Kovid data = u'' else: data = '&#%... | def handle_charref(self, ref): "Handle character references as data." if self.convertEntities: if ref.lower().startswith('x'): # ref = int(ref[1:], 16) # Added by Kovid to handle hex numeric entities try: data = unichr(int(ref)) except ValueError: # Bad numerical entity. Added by Kovid data = u'' else: data = '&#%... | 451,674 |
def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml'): self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) ... | def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml'): self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) ... | 451,675 |
def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml'): self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) ... | def __init__(self, markup, overrideEncodings=[], smartQuotesTo='xml'): self.markup, documentEncoding, sniffedEncoding = \ self._detectEncoding(markup) self.smartQuotesTo = smartQuotesTo self.triedEncodings = [] if markup == '' or isinstance(markup, unicode): self.originalEncoding = None self.unicode = unicode(markup) ... | 451,676 |
def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' | def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' | 451,677 |
def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' | def _toUnicode(self, data, encoding): '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' | 451,678 |
def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | 451,679 |
def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | 451,680 |
def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | 451,681 |
def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | def _detectEncoding(self, xml_data): """Given a document, tries to detect its XML encoding.""" xml_encoding = sniffed_xml_encoding = None try: if xml_data[:4] == '\x4c\x6f\xa7\x94': # EBCDIC xml_data = self._ebcdic_to_ascii(xml_data) # By Kovid commented out all the recoding to UTF-8 of UTF-16 and UTF-32 # as this doe... | 451,682 |
def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | 451,683 |
def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | 451,684 |
def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | 451,685 |
def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | def setup_desktop_integration(self): try: from PyQt4.Qt import QFile, QImage, Qt | 451,686 |
def render_svg(image, dest, width=128, height=128): from PyQt4.QtGui import QPainter, QImage from PyQt4.QtSvg import QSvgRenderer image = image.readAll() if hasattr(image, 'readAll') else image svg = QSvgRenderer(image) painter = QPainter() image = QImage(width, height, QImage.Format_ARGB32) painter.begin(image) painte... | def render_img(image, dest, width=128, height=128): from PyQt4.Qt import QImage, Qt img = QImage(I(image)).scaled(width, height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation) img.save(dest) | 451,687 |
def main(): # Handy tab-completers for %cd, %run, import etc. # Try commenting this out if you have completion problems/slowness import ipy_stock_completers # uncomment if you want to get ipython -p sh behaviour # without having to use command line switches import ipy_profile_sh # Configure your favourite editor? #... | def main(): # Handy tab-completers for %cd, %run, import etc. # Try commenting this out if you have completion problems/slowness import ipy_stock_completerssys.argv = old_argv # uncomment if you want to get ipython -p sh behaviour # without having to use command line switchessys.argv = old_argv import ipy_profile_s... | 451,688 |
def serialize_elem(self, elem, item, nsrmap=NSRMAP): buffer = self.buffer if not isinstance(elem.tag, basestring) \ or namespace(elem.tag) not in nsrmap: return tag = prefixname(elem.tag, nsrmap) # Previous layers take care of @name id = elem.attrib.pop('id', None) if id is not None: href = '#'.join((item.href, id)) of... | def serialize_elem(self, elem, item, nsrmap=NSRMAP): buffer = self.buffer if not isinstance(elem.tag, basestring) \ or namespace(elem.tag) not in nsrmap: return tag = prefixname(elem.tag, nsrmap) # Previous layers take care of @name id = elem.attrib.pop('id', None) if id is not None: href = '#'.join((item.href, id)) of... | 451,689 |
def get(name, category, field='name'): ans = self.conn.get('SELECT DISTINCT %s FROM %s'%(field, name)) ans = [x[0].strip() for x in ans] try: ans.remove('') except ValueError: pass categories[category] = list(map(Tag, ans)) tags = categories[category] if name != 'data': for tag in tags: id = self.conn.get('SELECT id FR... | for x in ('tags', 'series', 'news', 'publishers', 'authors'): query = 'SELECT id,name,count FROM tag_browser_'+x if sort_on_count: query += ' ORDER BY count DESC' else: for tag in tags: tag.count = self.conn.get('SELECT COUNT(format) FROM data WHERE format=?', (tag.name,), all=False) tags.sort(reverse=sort_on_count, cm... | 451,690 |
def get(name, category, field='name'): ans = self.conn.get('SELECT DISTINCT %s FROM %s'%(field, name)) ans = [x[0].strip() for x in ans] try: ans.remove('') except ValueError: pass categories[category] = list(map(Tag, ans)) tags = categories[category] if name != 'data': for tag in tags: id = self.conn.get('SELECT id FR... | def get(name, category, field='name'): ans = self.conn.get('SELECT DISTINCT %s FROM %s'%(field, name)) ans = [x[0].strip() for x in ans] try: ans.remove('') except ValueError: pass categories[category] = list(map(Tag, ans)) tags = categories[category] if name != 'data': for tag in tags: id = self.conn.get('SELECT id FR... | 451,691 |
def get(name, category, field='name'): ans = self.conn.get('SELECT DISTINCT %s FROM %s'%(field, name)) ans = [x[0].strip() for x in ans] try: ans.remove('') except ValueError: pass categories[category] = list(map(Tag, ans)) tags = categories[category] if name != 'data': for tag in tags: id = self.conn.get('SELECT id FR... | defget(name,category,field='name'):ans=self.conn.get('SELECTDISTINCT%sFROM%s'%(field,name))ans=[x[0].strip()forxinans]try:ans.remove('')exceptValueError:passcategories[category]=list(map(Tag,ans))tags=categories[category]ifname!='data':fortagintags:id=self.conn.get('SELECTidFROM%sWHERE%s=?'%(name,field),(tag.name,),all... | 451,692 |
def detect(aBuf): import calibre.ebooks.chardet.universaldetector as universaldetector u = universaldetector.UniversalDetector() u.reset() u.feed(aBuf) u.close() return u.result | def detect(aBuf): import calibre.ebooks.chardet.universaldetector as universaldetector u = universaldetector.UniversalDetector() u.reset() u.feed(aBuf) u.close() return u.result | 451,693 |
def __init__(self, window, rows, db): QDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) self.setupUi(self) self.db = db self.ids = [ db.id(r) for r in rows] self.write_series = False self.write_rating = False self.changed = False QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync) QObjec... | def __init__(self, window, rows, db): QDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) self.setupUi(self) self.db = db self.ids = [ db.id(r) for r in rows] self.write_series = False self.changed = False QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync) QObject.connect(self.rating, SIG... | 451,694 |
def __init__(self, window, rows, db): QDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) self.setupUi(self) self.db = db self.ids = [ db.id(r) for r in rows] self.write_series = False self.write_rating = False self.changed = False QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync) QObjec... | def __init__(self, window, rows, db): QDialog.__init__(self, window) Ui_MetadataBulkDialog.__init__(self) self.setupUi(self) self.db = db self.ids = [ db.id(r) for r in rows] self.write_series = False self.write_rating = False self.changed = False QObject.connect(self.button_box, SIGNAL("accepted()"), self.sync) QObjec... | 451,695 |
def sync(self): for id in self.ids: au = unicode(self.authors.text()) if au: au = string_to_authors(au) self.db.set_authors(id, au, notify=False) if self.auto_author_sort.isChecked(): aut = self.db.authors(id, index_is_id=True) aut = aut if aut else '' aut = [a.strip().replace('|', ',') for a in aut.strip().split(',')]... | def sync(self): for id in self.ids: au = unicode(self.authors.text()) if au: au = string_to_authors(au) self.db.set_authors(id, au, notify=False) if self.auto_author_sort.isChecked(): aut = self.db.authors(id, index_is_id=True) aut = aut if aut else '' aut = [a.strip().replace('|', ',') for a in aut.strip().split(',')]... | 451,696 |
def can_handle(cls, dev, debug=False): return dev[-1] == '1.00' and not dev[-2] and not dev[-3] | def can_handle(cls, dev, debug=False): return dev[-1] == '1.00' and not dev[-2] and not dev[-3] | 451,697 |
def get_collections(self, collection_attributes): from calibre.devices.usbms.driver import debug_print debug_print('Starting get_collections:', prefs['manage_device_metadata']) collections = {} series_categories = set([]) # This map of sets is used to avoid linear searches when testing for # book equality collections_l... | def get_collections(self, collection_attributes): from calibre.devices.usbms.driver import debug_print debug_print('Starting get_collections:', prefs['manage_device_metadata']) collections = {} series_categories = set([]) # This map of sets is used to avoid linear searches when testing for # book equality collections_l... | 451,698 |
def color_to_string(col): ans = '#000000' if col.isValid(): col = col.toRgb() if col.isValid(): ans = unicode(col.name()) return ans | def color_to_string(col): ans = '#000000' if col.isValid(): col = col.toRgb() if col.isValid(): ans = unicode(col.name()) return ans | 451,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.