bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def widget_factory(type, col): if bulk: w = bulk_widgets[type](db, col, parent) else: w = widgets[type](db, col, parent) w.initialize(book_id) return w | def widget_factory(type, col): if bulk: w = bulk_widgets[type](db, col, parent) else: w = widgets[type](db, col, parent) w.initialize(book_id) return w | 451,900 |
def __init__(self, stream): self.stream = stream data = self.data = StreamSlicer(stream) self.type = data[60:68] | def __init__(self, stream): self.stream = stream data = self.data = StreamSlicer(stream) self.type = data[60:68] | 451,901 |
def create_exth(self, new_title=None, exth=None): # Add an EXTH block to record 0, rewrite the stream # self.hexdump(self.record0) | def create_exth(self, new_title=None, exth=None): # Add an EXTH block to record 0, rewrite the stream # self.hexdump(self.record0) | 451,902 |
def get_pdbrecords(self): pdbrecords = [] for i in xrange(self.nrecs): offset, a1,a2,a3,a4 = struct.unpack('>LBBBB', self.data[78+i*8:78+i*8+8]) flags, val = a1, a2<<16|a3<<8|a4 pdbrecords.append( [offset, flags, val] ) return pdbrecords | def get_pdbrecords(self): pdbrecords = [] for i in xrange(self.nrecs): offset, a1,a2,a3,a4 = unpack('>LBBBB', self.data[78+i*8:78+i*8+8]) flags, val = a1, a2<<16|a3<<8|a4 pdbrecords.append( [offset, flags, val] ) return pdbrecords | 451,903 |
def bookmark(self): return self.javascript('calculate_bookmark(%d)'%(self.ypos+25), 'string') | def bookmark(self): return self.javascript('calculate_bookmark(%d)'%(self.ypos+25), 'string') | 451,904 |
def write_settings(self): m = dynamic[self.__class__.__name__+'column width map'] if m is None: m = {} for i,c in enumerate(self.model().column_map): m[c] = self.columnWidth(i) dynamic[self.__class__.__name__+'column width map'] = m self.cw = m | def write_settings(self): m = dynamic[self.__class__.__name__+'column width map'] if m is None: m = {} cmap = getattr(self.model(), 'column_map', None) if cmap is not None: for i,c in enumerate(cmap): m[c] = self.columnWidth(i) dynamic[self.__class__.__name__+'column width map'] = m self.cw = m | 451,905 |
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,906 |
def txt2rtf(text): if not isinstance(text, unicode): return text buf = cStringIO.StringIO() for x in text: val = ord(x) if val <= 127: buf.write(x) else: repl = ascii_text(x) c = r'\uc{2}\u{0:d}{1}'.format(val, repl, len(repl)) buf.write(c) return buf.getvalue() | def txt2rtf(text): if not isinstance(text, unicode): return text buf = cStringIO.StringIO() for x in text: val = ord(x) if val == 160: buf.write('\\~') elif val <= 127: buf.write(x) else: repl = ascii_text(x) c = r'\uc{2}\u{0:d}{1}'.format(val, repl, len(repl)) buf.write(c) return buf.getvalue() | 451,907 |
def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | 451,908 |
def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | 451,909 |
def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | def accept(self): col = unicode(self.column_name_box.text()).lower() if not col: return self.simple_error('', _('No lookup name was provided')) if not col.isalnum() or not col[0].isalpha(): return self.simple_error('', _('The label must contain only letters and digits, and start with a letter')) col_heading = unicode(s... | 451,910 |
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()") | 451,911 |
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()") | 451,912 |
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()") | 451,913 |
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()") | 451,914 |
def section_data(self, number): start = self.section_offset(number) if number == self.num_sections -1: end = os.stat(self.stream.name).st_size else: end = self.section_offset(number + 1) self.stream.seek(start) return self.stream.read(end - start) | def section_data(self, number): start = self.section_offset(number) if number == self.num_sections -1: end = os.stat(self.stream.name).st_size else: end = self.section_offset(number + 1) self.stream.seek(start) return self.stream.read(end - start) | 451,915 |
def iterate_over_builtin_recipe_files(): exclude = ['craigslist', 'iht', 'outlook_india', 'toronto_sun', 'indian_express', 'india_today'] d = os.path.dirname base = os.path.join(d(d(d(d(d(d(os.path.abspath(__file__))))))), 'resources', 'recipes') for x in os.walk(base): for f in x[-1]: fbase, ext = os.path.splitext(f) ... | def iterate_over_builtin_recipe_files(): exclude = ['craigslist', 'iht', 'outlook_india', 'toronto_sun', 'indian_express', 'india_today', 'livemint'] d = os.path.dirname base = os.path.join(d(d(d(d(d(d(os.path.abspath(__file__))))))), 'resources', 'recipes') for x in os.walk(base): for f in x[-1]: fbase, ext = os.path.... | 451,916 |
def ExtractFiles(self, output_dir=os.getcwdu()): for path in self.Contents(): lpath = os.path.join(output_dir, path) self._ensure_dir(lpath) data = self.GetFile(path) if lpath.find(';') != -1: # fix file names with ";<junk>" at the end, see _reformat() lpath = lpath.split(';')[0] try: with open(lpath, 'wb') as f: if gu... | def ExtractFiles(self, output_dir=os.getcwdu()): for path in self.Contents(): lpath = os.path.join(output_dir, path) self._ensure_dir(lpath) try: data = self.GetFile(path) except: self.log.exception('Failed to extract %s from CHM, ignoring'%path) continue if lpath.find(';') != -1: # fix file names with ";<junk>" at the... | 451,917 |
def set_search_string(self, txt, store_in_history=False): self.setFocus(Qt.OtherFocusReason) if not txt: self.clear() else: self.normalize_state() self.setEditText(txt) self.line_edit.end(False) self.changed.emit() self._do_search(store_in_history=store_in_history) self.focus_to_library.emit() | def set_search_string(self, txt, store_in_history=False, emit_changed=True): self.setFocus(Qt.OtherFocusReason) if not txt: self.clear() else: self.normalize_state() self.setEditText(txt) self.line_edit.end(False) self.changed.emit() self._do_search(store_in_history=store_in_history) self.focus_to_library.emit() | 451,918 |
def set_search_string(self, txt, store_in_history=False): self.setFocus(Qt.OtherFocusReason) if not txt: self.clear() else: self.normalize_state() self.setEditText(txt) self.line_edit.end(False) self.changed.emit() self._do_search(store_in_history=store_in_history) self.focus_to_library.emit() | def set_search_string(self, txt, store_in_history=False): self.setFocus(Qt.OtherFocusReason) if not txt: self.clear() else: self.normalize_state() self.setEditText(txt) self.line_edit.end(False) if emit_changed: self.changed.emit() self._do_search(store_in_history=store_in_history) self.focus_to_library.emit() | 451,919 |
def saved_search_selected(self, qname): qname = unicode(qname) if qname is None or not qname.strip(): self.search_box.clear() return if not saved_searches().lookup(qname): self.search_box.clear() self.setEditText(qname) return self.search_box.set_search_string(u'search:"%s"' % qname) self.setEditText(qname) self.setToo... | def saved_search_selected(self, qname): qname = unicode(qname) if qname is None or not qname.strip(): self.search_box.clear() return if not saved_searches().lookup(qname): self.search_box.clear() self.setEditText(qname) return self.search_box.set_search_string(u'search:"%s"' % qname, emit_changed=False) self.setEditTex... | 451,920 |
def _build_exth(self): oeb = self._oeb exth = StringIO() nrecs = 0 for term in oeb.metadata: if term not in EXTH_CODES: continue code = EXTH_CODES[term] items = oeb.metadata[term] if term == 'creator': if self._prefer_author_sort: creators = [unicode(c.file_as or c) for c in items] else: creators = [unicode(c) for c in... | def _build_exth(self): oeb = self._oeb exth = StringIO() nrecs = 0 for term in oeb.metadata: if term not in EXTH_CODES: continue code = EXTH_CODES[term] items = oeb.metadata[term] if term == 'creator': if self._prefer_author_sort: creators = [unicode(c.file_as or c) for c in items] else: creators = [unicode(c) for c in... | 451,921 |
def _generate_index(self): self._oeb.log('Generating INDX ...') self._primary_index_record = None | def _generate_index(self): self._oeb.log('Generating INDX ...') self._primary_index_record = None | 451,922 |
def _clean_text_value(self, text): if not text: text = u'(none)' text = text.strip() if not isinstance(text, unicode): text = text.decode('utf-8', 'replace') text = text.encode('cp1252','replace') return text | def _clean_text_value(self, text): if not text: text = u'(none)' text = text.strip() if not isinstance(text, unicode): text = text.decode('utf-8', 'replace') text = text.encode('ascii','replace') return text | 451,923 |
def _write_chapter_node(self, indxt, indices, index, offset, length, count): # Writes an INDX1 NCXEntry of entryType 0x0F - chapter if self.opts.verbose > 2: # *** GR: Turn this off while I'm developing my code #self._oeb.log.debug('Writing TOC node to IDXT:', node.title, 'href:', node.href) pass | def _write_chapter_node(self, indxt, indices, index, offset, length, count): # Writes an INDX1 NCXEntry of entryType 0x0F - chapter if self.opts.verbose > 2: # *** GR: Turn this off while I'm developing my code #self._oeb.log.debug('Writing TOC node to IDXT:', node.title, 'href:', node.href) pass | 451,924 |
def seriescmp(self, x, y): try: ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][9], self._data[y][9]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | def seriescmp(self, x, y): try: ans = cmp(self._data[x][sidx].lower(), self._data[y][sidx].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][9], self._data[y][9]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | 451,925 |
def seriescmp(self, x, y): try: ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][9], self._data[y][9]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | def seriescmp(self, x, y): try: ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][sidx], self._data[y][sidx]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | 451,926 |
def seriescmp(self, x, y): try: ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][9], self._data[y][9]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | def seriescmp(self, x, y): try: ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) except AttributeError: # Some entries may be None ans = cmp(self._data[x][9], self._data[y][9]) if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) | 451,927 |
def delete_publisher_using_id(self, old_id): self.dirty_books_referencing('publisher', id, commit=False) self.conn.execute('''DELETE FROM books_publishers_link WHERE publisher=?''', (old_id,)) self.conn.execute('DELETE FROM publishers WHERE id=?', (old_id,)) self.conn.commit() | def delete_publisher_using_id(self, old_id): self.dirty_books_referencing('publisher', old_id, commit=False) self.conn.execute('''DELETE FROM books_publishers_link WHERE publisher=?''', (old_id,)) self.conn.execute('DELETE FROM publishers WHERE id=?', (old_id,)) self.conn.commit() | 451,928 |
def contentid_from_path(self, path, ContentType): if ContentType == 6: ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either ContentID = ContentID.replace(self._main_prefix, '') if self._card_a_prefix is not None: ContentID = ContentID.replace(self._card_a_prefix, '') else: # Conten... | def contentid_from_path(self, path, ContentType): if ContentType == 6: ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either ContentID = ContentID.replace(self._main_prefix, '') if self._card_a_prefix is not None: ContentID = ContentID.replace(self._card_a_prefix, '') else: # Conten... | 451,929 |
def upshift_markup(self, root): self.log.debug('Converting style information to CSS...') size_map = { 'xx-small': '0.5', 'x-small': '1', 'small': '2', 'medium': '3', 'large': '4', 'x-large': '5', 'xx-large': '6', } mobi_version = self.book_header.mobi_version for x in root.xpath('//ncx'): x.getparent().remove(x) for i,... | def upshift_markup(self, root): self.log.debug('Converting style information to CSS...') size_map = { 'xx-small': '0.5', 'x-small': '1', 'small': '2', 'medium': '3', 'large': '4', 'x-large': '5', 'xx-large': '6', } mobi_version = self.book_header.mobi_version for x in root.xpath('//ncx'): x.getparent().remove(x) for i,... | 451,930 |
def __init__(self, urn, title, default_icon, custom_icon, builtin, custom, scheduler_config, parent): NewsTreeItem.__init__(self, builtin, custom, scheduler_config, parent) self.urn, self.title = urn, title if 'custom:' in self.urn: self.icon = custom_icon else: icon = I('news/%s.png'%self.urn[8:]) if os.path.exists(ic... | def __init__(self, urn, title, default_icon, custom_icon, builtin, custom, scheduler_config, parent): NewsTreeItem.__init__(self, builtin, custom, scheduler_config, parent) self.urn, self.title = urn, title if 'custom:' in self.urn: self.icon = custom_icon else: icon = I('news/%s.png'%self.urn[8:]) if os.path.exists(ic... | 451,931 |
def update_device_database_collections(self, booklists, collections_attributes): | def update_device_database_collections(self, booklists, collections_attributes): | 451,932 |
def update_device_database_collections(self, booklists, collections_attributes): | def update_device_database_collections(self, booklists, collections_attributes): | 451,933 |
def update_device_database_collections(self, booklists, collections_attributes): | def update_device_database_collections(self, booklists, collections_attributes): | 451,934 |
def sync_booklists(self, booklists, end_session=True): | def sync_booklists(self, booklists, end_session=True): | 451,935 |
def accept(self): try: if self.formats_changed: self.sync_formats() title = unicode(self.title.text()) self.db.set_title(self.id, title, notify=False) au = unicode(self.authors.text()) if au: self.db.set_authors(self.id, string_to_authors(au), notify=False) aus = unicode(self.author_sort.text()) if aus: self.db.set_aut... | defself.save_state() accept(self):self.save_state() try:self.save_state() ifself.save_state() self.formats_changed:self.save_state() self.sync_formats()self.save_state() titleself.save_state() =self.save_state() unicode(self.title.text())self.save_state() self.db.set_title(self.id,self.save_state() title,self.save_stat... | 451,936 |
def stringFromInt(self, intToTranslate): # Convert intToTranslate to string # intToTranslate is a three-digit number | def stringFromInt(self, intToTranslate): # Convert intToTranslate to string # intToTranslate is a three-digit number | 451,937 |
def fetchBooksByTitle(self): | def fetchBooksByTitle(self): | 451,938 |
def fetchBooksByAuthor(self): # Generate a list of titles sorted by author from the database | def fetchBooksByAuthor(self): # Generate a list of titles sorted by author from the database | 451,939 |
def mousePressEvent(self, event): if event.button() == Qt.LeftButton: self.drag_start_pos = event.pos() return QTableView.mousePressEvent(self, event) | def mousePressEvent(self, event): if event.button() == Qt.LeftButton and not self.event_has_mods(): self.drag_start_pos = event.pos() return QTableView.mousePressEvent(self, event) | 451,940 |
def mouseMoveEvent(self, event): if not (event.buttons() & Qt.LeftButton) or \ self.drag_start_pos is None or \ QApplication.keyboardModifiers() != Qt.NoModifier or \ (event.pos() - self.drag_start_pos).manhattanLength() \ < QApplication.startDragDistance(): return QTableView.mouseMoveEvent(self, event) | def mouseMoveEvent(self, event): if not (event.buttons() & Qt.LeftButton) or \ (event.pos() - self.drag_start_pos).manhattanLength() \ < QApplication.startDragDistance(): return QTableView.mouseMoveEvent(self, event) | 451,941 |
def mouseMoveEvent(self, event): if not (event.buttons() & Qt.LeftButton) or \ self.drag_start_pos is None or \ QApplication.keyboardModifiers() != Qt.NoModifier or \ (event.pos() - self.drag_start_pos).manhattanLength() \ < QApplication.startDragDistance(): return QTableView.mouseMoveEvent(self, event) | def mouseMoveEvent(self, event): if not (event.buttons() & Qt.LeftButton) or \ self.drag_start_pos is None or \ QApplication.keyboardModifiers() != Qt.NoModifier or \ (event.pos() - self.drag_start_pos).manhattanLength() \ < QApplication.startDragDistance(): return QTableView.mouseMoveEvent(self, event) | 451,942 |
def do_add_empty(db, title, authors, isbn): from calibre.ebooks.metadata import MetaInformation, string_to_authors mi = MetaInformation(None) if title is not None: mi.title = title if authors: mi.authors = string_to_authors(authors) if isbn: mi.isbn = isbn db.import_book(mi, []) write_dirtied() send_message() | def do_add_empty(db, title, authors, isbn): from calibre.ebooks.metadata import MetaInformation, string_to_authors mi = MetaInformation(None) if title is not None: mi.title = title if authors: mi.authors = string_to_authors(authors) if isbn: mi.isbn = isbn db.import_book(mi, []) write_dirtied(db) send_message() | 451,943 |
def do_set_metadata(db, id, stream): mi = OPF(stream).to_book_metadata() db.set_metadata(id, mi) db.clean() do_show_metadata(db, id, False) write_dirtied() send_message() | def do_set_metadata(db, id, stream): mi = OPF(stream).to_book_metadata() db.set_metadata(id, mi) db.clean() do_show_metadata(db, id, False) write_dirtied(db) send_message() | 451,944 |
def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | 451,945 |
def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | 451,946 |
def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | 451,947 |
def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | 451,948 |
def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | def rescale(self, qt=True): from PyQt4.Qt import QImage, Qt from calibre.gui2 import pixmap_to_data try: from PIL import Image as PILImage PILImage except ImportError: import Image as PILImage | 451,949 |
def run_tests(parser, result, tests): failed = [] for test in tests: print '\tTesting:', test[0], res = parser.parseString(test[0]) if list(res.get(result, None)) == test[1]: print 'OK' else: print 'FAILED:', 'Expected:', test[1], 'Got:', list(res.get(result, None)) failed.append(test[0]) return failed | def run_tests(parser, result, tests): failed = [] for test in tests: print '\tTesting:', test[0], res = parser.parseString(test[0]) if list(res.get(result, None)) == test[1]: print 'OK' else: print 'FAILED:', 'Expected:', test[1], 'Got:', list(res.get(result, None)) failed.append(test[0]) return failed | 451,950 |
def run_tests(parser, result, tests): failed = [] for test in tests: print '\tTesting:', test[0], res = parser.parseString(test[0]) if list(res.get(result, None)) == test[1]: print 'OK' else: print 'FAILED:', 'Expected:', test[1], 'Got:', list(res.get(result, None)) failed.append(test[0]) return failed | def run_tests(parser, result, tests): failed = [] for test in tests: print '\tTesting:', test[0], res = parser.parseString(test[0]) if list(res.get(result, None)) == test[1]: print 'OK' else: print 'FAILED:', 'Expected:', test[1], 'Got:', list(res.get(result, None)) failed.append(test[0]) return failed | 451,951 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,952 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,953 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,954 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,955 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,956 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,957 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,958 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,959 |
def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | def __init__(self, test=False): self._tests_failed = False # Define a token locations = map(lambda x : CaselessLiteral(x)+Suppress(':'), self.LOCATIONS) location = NoMatch() for l in locations: location |= l location = Optional(location, default='all') word_query = CharsNotIn(string.whitespace + '()') quoted_quer... | 451,960 |
def parse(self, query): res = self._parser.parseString(query)[0] return self.evaluate(res) | def parse(self, query): res = self._parser.parseString(query)[0] return self.evaluate(res) | 451,961 |
def method(self, group_name): return getattr(self, 'evaluate_'+group_name) | def method(self, group_name): return getattr(self, 'evaluate_'+group_name) | 451,962 |
def evaluate(self, parse_result): return self.method(parse_result.getName())(parse_result) | def evaluate(self, parse_result): return self.method(parse_result.getName())(parse_result) | 451,963 |
def evaluate_parenthesis(self, argument): return self.evaluate(argument[0]) | def evaluate_parenthesis(self, argument): return self.evaluate(argument[0]) | 451,964 |
def evaluate_token(self, argument): return self.get_matches(argument[0], argument[1]) | def evaluate_token(self, argument): return self.get_matches(argument[0], argument[1]) | 451,965 |
def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | 451,966 |
def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | 451,967 |
def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | def get_matches(self, location, query): ''' Should return the set of matches for :param:'location` and :param:`query`. :param:`location` is one of the items in :member:`SearchQueryParser.LOCATIONS`. :param:`query` is a string literal. ''' return set([]) | 451,968 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,969 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,970 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,971 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,972 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,973 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,974 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,975 |
def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | def universal_set(self): ''' Should return the set of all matches. ''' return set([]) | 451,976 |
def universal_set(self): return self._universal_set | def universal_set(self): return self._universal_set | 451,977 |
def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | 451,978 |
def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | 451,979 |
def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | def get_matches(self, location, query): location = location.lower() if location in self.fields.keys(): getter = operator.itemgetter(self.fields[location]) elif location == 'all': getter = lambda y: ''.join(x if x else '' for x in y) else: getter = lambda x: '' if not query: return set([]) query = query.lower() return ... | 451,980 |
def run_tests(self): failed = [] for query in self.tests.keys(): print 'Testing query:', query, res = self.parse(query) if res != self.tests[query]: print 'FAILED', 'Expected:', self.tests[query], 'Got:', res failed.append(query) else: print 'OK' return failed | def run_tests(self): failed = [] for query in self.tests.keys(): print 'Testing query:', query, res = self.parse(query) if res != self.tests[query]: print 'FAILED', 'Expected:', self.tests[query], 'Got:', res failed.append(query) else: print 'OK' return failed | 451,981 |
def run_tests(self): failed = [] for query in self.tests.keys(): print 'Testing query:', query, res = self.parse(query) if res != self.tests[query]: print 'FAILED', 'Expected:', self.tests[query], 'Got:', res failed.append(query) else: print 'OK' return failed | def run_tests(self): failed = [] for query in self.tests.keys(): print 'Testing query:', query, res = self.parse(query) if res != self.tests[query]: print 'FAILED', 'Expected:', self.tests[query], 'Got:', res failed.append(query) else: print 'OK' return failed | 451,982 |
def main(args=sys.argv): tester = Tester(test=True) failed = tester.run_tests() if tester._tests_failed or failed: print '>>>>>>>>>>>>>> Tests Failed <<<<<<<<<<<<<<<' return 1 return 0 | def main(args=sys.argv): tester = Tester(test=True) failed = tester.run_tests() if tester._tests_failed or failed: print '>>>>>>>>>>>>>> Tests Failed <<<<<<<<<<<<<<<' return 1 return 0 | 451,983 |
def _generate_ctoc(self): # Generate the compiled TOC strings # Each node has 1-4 CTOC entries: # Periodical (0xDF) # title, class # Section (0xFF) # title, class # Article (0x3F) # title, class, description, author # Chapter (0x0F) # title, class # nb: Chapters don't actually have @class, so we synthesize it # ... | def _generate_ctoc(self): # Generate the compiled TOC strings # Each node has 1-4 CTOC entries: # Periodical (0xDF) # title, class # Section (0xFF) # title, class # Article (0x3F) # title, class, description, author # Chapter (0x0F) # title, class # nb: Chapters don't actually have @class, so we synthesize it # ... | 451,984 |
def accept(self): try: if self.formats_changed: self.sync_formats() title = unicode(self.title.text()) self.db.set_title(self.id, title, notify=False) au = unicode(self.authors.text()) if au: self.db.set_authors(self.id, string_to_authors(au), notify=False) aus = unicode(self.author_sort.text()) if aus: self.db.set_aut... | def accept(self): try: if self.formats_changed: self.sync_formats() title = unicode(self.title.text()) self.db.set_title(self.id, title, notify=False) au = unicode(self.authors.text()) if au: self.db.set_authors(self.id, string_to_authors(au), notify=False) aus = unicode(self.author_sort.text()) if aus: self.db.set_aut... | 451,985 |
def ok(urn): if restrict_to_urns is None: return False return not restrict_to_urns or urn in restrict_to_urns | def ok(urn): if restrict_to_urns is None: return False return not restrict_to_urns or urn in restrict_to_urns | 451,986 |
def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir self.updateProgressFullStep("'Descriptions'") | def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir self.updateProgressFullStep("'Descriptions'") | 451,987 |
def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir self.updateProgressFullStep("'Descriptions'") | def generateHTMLDescriptions(self): # Write each title to a separate HTML file in contentdir self.updateProgressFullStep("'Descriptions'") | 451,988 |
def write_card_prefix(prefix, listid): if prefix is not None and hasattr(booklists[listid], 'write'): if not os.path.exists(prefix): os.makedirs(prefix) f = open(prefix + self.__class__.CACHE_XML, 'wb') booklists[listid].write(f) f.close() | def write_card_prefix(prefix, listid): if prefix is not None and hasattr(booklists[listid], 'write'): if not os.path.exists(prefix): os.makedirs(prefix) f = open(prefix + self.__class__.CACHE_XML, 'wb') booklists[listid].write(f) f.close() | 451,989 |
def mouseReleaseEvent(self, ev): self.emit(SIGNAL('mr(int)'), 1) | def mouseReleaseEvent(self, ev): self.emit(SIGNAL('mr(int)'), 1) | 451,990 |
def strftime(fmt, t=None): ''' A version of strftime that returns unicode strings and tries to handle dates before 1900 ''' if t is None: t = time.localtime() if hasattr(t, 'timetuple'): t = t.timetuple() early_year = t[0] < 1900 if early_year: replacement = 1900 if t[0]%4 == 0 else 1901 fmt = fmt.replace('%Y', '_early... | def strftime(fmt, t=None): ''' A version of strftime that returns unicode strings and tries to handle dates before 1900 ''' if t is None: t = time.localtime() if hasattr(t, 'timetuple'): t = t.timetuple() early_year = t[0] < 1900 if early_year: replacement = 1900 if t[0]%4 == 0 else 1901 fmt = fmt.replace('%Y', '_early... | 451,991 |
def create_cc_metadata(self): self.books.sort(key=itemgetter('timestamp')) m = {} fields = ('label', 'name', 'datatype', 'is_multiple', 'is_editable', 'display') for b in self.books: for key in b['mi'].custom_field_keys(): cfm = b['mi'].metadata_for_field(key) args = [] for x in fields: if x in cfm: if x == 'is_multipl... | def create_cc_metadata(self): self.books.sort(key=itemgetter('timestamp')) m = {} fields = ('label', 'name', 'datatype', 'is_multiple', 'is_editable', 'display') for b in self.books: for key in b['mi'].custom_field_keys(): cfm = b['mi'].metadata_for_field(key) args = [] for x in fields: if x in cfm: if x == 'is_multipl... | 451,992 |
def __init__(self, parent=None): QComboBox.__init__(self, parent) self.normal_background = 'rgb(255, 255, 255, 0%)' self.line_edit = SearchLineEdit(self) self.setLineEdit(self.line_edit) self.connect(self.line_edit, SIGNAL('key_pressed(PyQt_PyObject)'), self.key_pressed, Qt.DirectConnection) self.connect(self.line_edit... | def __init__(self, parent=None): QComboBox.__init__(self, parent) self.normal_background = 'rgb(255, 255, 255, 0%)' self.line_edit = SearchLineEdit(self) self.setLineEdit(self.line_edit) self.connect(self.line_edit, SIGNAL('key_pressed(PyQt_PyObject)'), self.key_pressed, Qt.DirectConnection) self.connect(self.line_edit... | 451,993 |
def none_cmp(xx, yy): x = xx[1] y = yy[1] if x is None and y is None: # No sort_key needed here, because defaults are ascii return cmp(xx[2], yy[2]) if x is None: return 1 if y is None: return -1 c = cmp(sort_key(x), sort_key(y)) if c != 0: return c # same as above -- no sort_key needed here return cmp(xx[2], yy[2]) | def none_cmp(xx, yy): x = xx[1] y = yy[1] if x is None and y is None: # No sort_key needed here, because defaults are ascii return cmp(xx[2], yy[2]) if x is None: return 1 if y is None: return -1 if isinstance(x, unicode): c = cmp(sort_key(x), sort_key(y)) else: c = cmp(x, y) if c != 0: return c # same as above -- no s... | 451,994 |
def updateProgressFullStep(self, description): | def updateProgressFullStep(self, description): | 451,995 |
def updateProgressMicroStep(self, description, micro_step_pct): step_range = 100/self.total_steps self.progressString = description self.progressInt = ((self.current_step-1)*100)/self.total_steps + (micro_step_pct*step_range)/100 self.reporter(self.progressInt, self.progressString) return "%d%% %s" % (self.progressInt,... | def updateProgressMicroStep(self, description, micro_step_pct): step_range = 100/self.total_steps self.progressString = description self.progressInt = ((self.current_step-1)*100)/self.total_steps + (micro_step_pct*step_range)/100 self.reporter(self.progressInt/100., self.progressString) return "%d%% %s" % (self.progres... | 451,996 |
def mlize_spine(self): output = self.header() if 'titlepage' in self.oeb_book.guide: href = self.oeb_book.guide['titlepage'].href item = self.oeb_book.manifest.hrefs[href] if item.spine_position is None: stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts, self.opts.output_profile) output += self.dump_te... | def mlize_spine(self): output = self.header() if 'titlepage' in self.oeb_book.guide: href = self.oeb_book.guide['titlepage'].href item = self.oeb_book.manifest.hrefs[href] if item.spine_position is None: stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts, self.opts.output_profile) output += self.dump_te... | 451,997 |
def mlize_spine(self): output = self.header() if 'titlepage' in self.oeb_book.guide: href = self.oeb_book.guide['titlepage'].href item = self.oeb_book.manifest.hrefs[href] if item.spine_position is None: stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts, self.opts.output_profile) output += self.dump_te... | def mlize_spine(self): output = self.header() if 'titlepage' in self.oeb_book.guide: href = self.oeb_book.guide['titlepage'].href item = self.oeb_book.manifest.hrefs[href] if item.spine_position is None: stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts, self.opts.output_profile) output += self.dump_te... | 451,998 |
def has_cover(self, index, index_is_id=False): id = index if index_is_id else self.id(index) path = os.path.join(self.library_path, self.path(id, index_is_id=True), 'cover.jpg') 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), 'cover.jpg') except: return False return os.access(path, os.R_OK) | 451,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.