rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
raise LookupError, 'object "%s" not found' % str(path) | raise LookupError, 'object "%s" not found' % str(self.path) | def _get_object(self): connection = self.connection() object = connection.root() for segment in self.path: try: object = object[segment.name] except KeyError: raise LookupError, 'object "%s" not found' % str(path) |
raise LookupError, 'object "%s" not found' % str(path) | raise LookupError, 'object "%s" not found' % str(self.path) | def _get_parent(self): connection = self.connection() object = connection.root() for segment in self.path[:-1]: try: object = object[segment.name] except KeyError: raise LookupError, 'object "%s" not found' % str(path) |
self.load_state_from(file) | self.load_state_from_string(data) | def upload(self, context): file = context.get_form_value('file') |
mpath = os.path.splitdrive(mpath)[1] mpath = os.path.join(mpath, local_path) | drive, mpath = os.path.splitdrive(mpath) mpath = drive + os.path.join(mpath, local_path) | def get_abspath(globals_namespace, local_path): """ Returns the absolute path to the required file. """ mname = globals_namespace['__name__'] if mname == '__main__': mpath = os.getcwd() else: module = sys.modules[mname] if hasattr(module, '__path__'): mpath = module.__path__[0] elif '.' in mname: mpath = sys.modules[m... |
transitions.append({'name': transition[(None, 'name')], | transitions.append({'title': transition[(None, 'name')], | def state_form(self, context): namespace = {} # State state = self.get_state() namespace['state'] = self.gettext(state['title']) # Posible transitions ac = self.get_access_control() transitions = [] for name, trans in state.transitions.items(): if ac.is_allowed_to_trans(context.user, self, name) is False: continue desc... |
'pubDate': Unicode, | 'pubDate': TZDateTime, | def to_unicode(value): if value is None: return u'' return unicode(value.strftime('%Y-%m-%d %H:%M')) |
'lastBuildDate': Unicode, | 'lastBuildDate': TZDateTime, | def to_unicode(value): if value is None: return u'' return unicode(value.strftime('%Y-%m-%d %H:%M')) |
if not isinstance(uri_reference, uri.Reference): | if isinstance(uri_reference, uri.Reference): pass elif isinstance(uri_reference, uri.Path): uri_reference = uri.get_reference(str(uri_reference)) elif isinstance(uri_reference, StringTypes): | def __init__(self, uri_reference): if not isinstance(uri_reference, uri.Reference): uri_reference = uri.get_reference(uri_reference) self.uri = uri_reference |
def _index_term(self, word, doc_number, positions): if word: prefix, suffix = word[0], word[1:] | def _index_term(self, term, documents): """ Indexes the given term. The parameter 'documents' is a mapping from document number to list of positions: {<document number>: [postion, ...], ...} """ if term: prefix, suffix = term[0], term[1:] | def _index_term(self, word, doc_number, positions): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot free_slot_n = self.root.tree_handler._get_free_slot() # Update data structure on memory subtree = self.children[prefix] = Tree(self.root, ... |
subtree._index_term(suffix, doc_number, positions) | subtree._index_term(suffix, documents) | def _index_term(self, word, doc_number, positions): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot free_slot_n = self.root.tree_handler._get_free_slot() # Update data structure on memory subtree = self.children[prefix] = Tree(self.root, ... |
if doc_number in self.documents: aux = self.documents[doc_number] aux.extend(positions) positions = aux doc_slot_n = docs_handler._get_document_slot(fdoc_slot_n, doc_number) doc_slot = 12 + doc_slot_n * 12 else: self.documents[doc_number] = positions doc_slot_n = docs_handler._get_free_slot() doc_slot = 12 + doc_slot... | for doc_number, doc_positions in documents.items(): if doc_number in self.documents: positions = self.documents[doc_number] positions.extend(doc_positions) doc_slot_n = docs_handler._get_document_slot(fdoc_slot_n, doc_number) doc_slot = 12 + doc_slot_n * 12 frequency = len(positions) else: self.documents[doc_number] ... | def _index_term(self, word, doc_number, positions): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot free_slot_n = self.root.tree_handler._get_free_slot() # Update data structure on memory subtree = self.children[prefix] = Tree(self.root, ... |
subtree = self.children[prefix] subtree._unindex_term(suffix, doc_number) | if prefix in self.children: subtree = self.children[prefix] subtree._unindex_term(suffix, doc_number) | def _unindex_term(self, word, doc_number): if word: prefix, suffix = word[0], word[1:] subtree = self.children[prefix] subtree._unindex_term(suffix, doc_number) else: del self.documents[doc_number] # Update resource tree_rsrc = self.root.tree_handler.resource docs = self.root.docs_handler docs_rsrc = docs.resource # Se... |
for term, documents in self.removed_terms.keys(): | for term, documents in self.removed_terms.items(): | def _save(self): # Removed terms for term, documents in self.removed_terms.keys(): for doc_number in documents: self._unindex_term(term, doc_number) self.removed_terms = {} # Added terms for term, documents in self.removed_terms.keys(): for doc_number, positions in documents.keys(): self._index_term(term, doc_number, p... |
for term, documents in self.removed_terms.keys(): for doc_number, positions in documents.keys(): self._index_term(term, doc_number, positions) | for term, documents in self.added_terms.items(): self._index_term(term, documents) | def _save(self): # Removed terms for term, documents in self.removed_terms.keys(): for doc_number in documents: self._unindex_term(term, doc_number) self.removed_terms = {} # Added terms for term, documents in self.removed_terms.keys(): for doc_number, positions in documents.keys(): self._index_term(term, doc_number, p... |
def _index_term(self, word, doc_number, positions): prefix, suffix = word[0], word[1:] | def _index_term(self, term, documents): """ Indexes the given term. The parameter 'documents' is a mapping from document number to list of positions: {<document number>: [postion, ...], ...} """ prefix, suffix = term[0], term[1:] | def _index_term(self, word, doc_number, positions): prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.tree_handler._get_free_slot() subtree = self.children[prefix] = Tree(self, slot_number) # Update resource r = self.tree_handler.... |
subtree._index_term(suffix, doc_number, positions) | subtree._index_term(suffix, documents) | def _index_term(self, word, doc_number, positions): prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.tree_handler._get_free_slot() subtree = self.children[prefix] = Tree(self, slot_number) # Update resource r = self.tree_handler.... |
def get_handler(self, segment, resource): | def _get_handler(self, segment, resource): | def get_handler(self, segment, resource): return ListOfUsers(resource) |
resource = memory.File(data) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(data) | def test_unicode(self): data = '"Martin von Löwis","Marc André Lemburg","Guido van Rossum"\n' resource = memory.File(data) handler = CSV(resource) self.assertEqual(handler.get_rows(), [[u"Martin von Löwis", u"Marc André Lemburg", u"Guido van Rossum"]]) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) self.assertEqual(len(handler.get_rows()), 3) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) rows = list(handler.get_rows()) self.assertEqual(len(rows), 3) | def test_num_of_lines(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) self.assertEqual(len(handler.get_rows()), 3) |
resource = memory.File(data) handler = CSV(resource) self.assertEqual(len(handler.get_rows()), 3) | handler = CSV() handler.load_state_from_string(data) rows = list(handler.get_rows()) self.assertEqual(len(rows), 3) | def test_num_of_lines_with_last_new_line(self): data = TEST_DATA_2 + '\r\n' resource = memory.File(data) handler = CSV(resource) self.assertEqual(len(handler.get_rows()), 3) |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) | handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state_from_string(TEST_DATA_1) | def test_load_state_with_schema(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) self.assertEqual(handler.get_rows(), [ [u"python", URI.decode('http:... |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) | handler = CSV() handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state_from_string(TEST_DATA_1) | def test_load_state_without_schema(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) self.assertEqual(handler.get_rows(), [ [u"python", u'http://python.org', u'52343', u'2003-10-23'], [u"ruby", u'http:/... |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) | handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state_from_string(TEST_DATA_1) | def test_to_str_with_schema(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) self.assertEqual( handler.to_str(), u'"python","http://python.org","5234... |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.load_state(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_1) | def test_to_str_without_schema(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.load_state(resource) self.assertEqual( handler.to_str(), u'"python","http://python.org","52343","2003-10-23"\n' u'"ruby","http://ruby-lang.org","42352","2001-03-28"') |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_get_row(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) self.assertEqual(handler.get_row(1), ['four', 'five', 'six']) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_get_rows(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) self.assertEqual(handler.get_rows([0, 1]), [ ['one', 'two', 'three'], ['four', 'five', 'six']]) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_add_row(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) handler.add_row(['a', 'b', 'c']) self.assertEqual(handler.get_row(3), ['a', 'b', 'c']) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_del_row(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) handler.del_row(1) self.assertEqual(handler.get_row(1), ['seven', 'eight', 'nine']) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_del_rows(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) handler.del_rows([0, 1]) self.assertEqual(handler.get_row(0), ['seven', 'eight', 'nine']) |
resource = memory.File(TEST_DATA_2) handler = CSV(resource) | handler = CSV() handler.load_state_from_string(TEST_DATA_2) | def test_set_state_in_memory_resource(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) handler.add_row(['a', 'b', 'c']) handler.save_state() handler2 = CSV(resource) self.assertEqual(handler2.get_row(3), ['a', 'b', 'c']) |
handler2 = CSV(resource) | handler2 = CSV() handler2.load_state_from_string(TEST_DATA_2) | def test_set_state_in_memory_resource(self): resource = memory.File(TEST_DATA_2) handler = CSV(resource) handler.add_row(['a', 'b', 'c']) handler.save_state() handler2 = CSV(resource) self.assertEqual(handler2.get_row(3), ['a', 'b', 'c']) |
resource = get_resource('test.csv') handler = CSV(resource) | handler = CSV('test.csv') | def test_set_state_in_file_resource(self): resource = get_resource('test.csv') handler = CSV(resource) handler.add_row(['d1', 'e1', 'f1']) handler.save_state() |
resource2 = get_resource('test.csv') handler2 = CSV(resource2) | handler2 = CSV('test.csv') | def test_set_state_in_file_resource(self): resource = get_resource('test.csv') handler = CSV(resource) handler.add_row(['d1', 'e1', 'f1']) handler.save_state() |
data = TEST_DATA_1 resource = memory.File(data) | def test_indexes_hit_in_one_row(self): data = TEST_DATA_1 resource = memory.File(data) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer(index=True), 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(len(handler.ind... | |
'number': Integer(index=True), 'date': Date(index=True)} handler.load_state(resource) | 'number': Integer(index='keyword'), 'date': Date(index='keyword')} handler.load_state_from_string(TEST_DATA_1) | def test_indexes_hit_in_one_row(self): data = TEST_DATA_1 resource = memory.File(data) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer(index=True), 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(len(handler.ind... |
resource = memory.File(data) handler = CSV() | handler = CSV() handler.load_state_from_string(data) | def test_indexes_hit_in_many_rows(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(handler.search(date=Date.d... |
handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) | handler.schema = {'name': Unicode, 'date': Date(index='keyword')} handler.load_state_from_string(data) | def test_indexes_hit_in_many_rows(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(handler.search(date=Date.d... |
resource = memory.File(data) handler = CSV() | handler = CSV() handler.load_state_from_string(data) | def test_index_new_row(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) handler.add_row(['flower', Date.decode('2005-05-10')])... |
handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) | handler.schema = {'name': Unicode, 'date': Date(index='keyword')} handler.load_state_from_string(data) | def test_index_new_row(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode, 'date': Date(index=True)} handler.load_state(resource) handler.add_row(['flower', Date.decode('2005-05-10')])... |
resource = memory.File(data) handler = CSV() | handler = CSV() handler.load_state_from_string(data) | def test_index_del_row(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(handler.search(name='wind... |
handler.schema = {'name': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) | handler.schema = {'name': Unicode(index='text'), 'date': Date(index='keyword')} handler.load_state_from_string(data) | def test_index_del_row(self): data = 'house,2005-10-10\nwindow,2005-05-10\ncomputer,2005-10-10' resource = memory.File(data) handler = CSV() handler.columns = ['name', 'date'] handler.schema = {'name': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) self.assertEqual(handler.search(name='wind... |
resource = memory.File('') | def test_build_csv_data(self): resource = memory.File('') handler = CSV() handler.columns = ['name', 'surname', 'date'] handler.schema = {'name': Unicode, 'surname': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) handler.add_row(['Piotr', 'Macuk', '1975-12-08']) handler.add_row(['Basia', 'M... | |
handler.schema = {'name': Unicode, 'surname': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) | handler.schema = {'name': Unicode, 'surname': Unicode(index='text'), 'date': Date(index='keyword')} handler.load_state_from_string('') | def test_build_csv_data(self): resource = memory.File('') handler = CSV() handler.columns = ['name', 'surname', 'date'] handler.schema = {'name': Unicode, 'surname': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) handler.add_row(['Piotr', 'Macuk', '1975-12-08']) handler.add_row(['Basia', 'M... |
resource = get_resource('test_adv.csv') | def test_advanced_search(self): resource = get_resource('test_adv.csv') handler = CSV() handler.columns = ['id', 'name', 'country', 'date'] handler.schema = {'id': Integer, 'name': Unicode(index=True), 'country': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) result1 = handler.search(name='... | |
handler.schema = {'id': Integer, 'name': Unicode(index=True), 'country': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) | handler.schema = {'id': Integer, 'name': Unicode(index='text'), 'country': Unicode(index='text'), 'date': Date(index='text')} handler.load_state_from_file('test_adv.csv') | def test_advanced_search(self): resource = get_resource('test_adv.csv') handler = CSV() handler.columns = ['id', 'name', 'country', 'date'] handler.schema = {'id': Integer, 'name': Unicode(index=True), 'country': Unicode(index=True), 'date': Date(index=True)} handler.load_state(resource) result1 = handler.search(name='... |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) | handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state_from_string(TEST_DATA_1) | def test_access_by_name(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) |
resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) | handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state_from_string(TEST_DATA_1) | def test_get_row_as_handler(self): resource = memory.File(TEST_DATA_1) handler = CSV() handler.columns = ['name', 'url', 'number', 'date'] handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) |
resource = memory.File(TEST_SYNTAX_ERROR) self.assertRaises(ValueError, CSV, resource) | load_state = CSV().load_state_from_string self.assertRaises(ValueError, load_state, TEST_SYNTAX_ERROR) | def test_bad_syntax_csv_file(self): resource = memory.File(TEST_SYNTAX_ERROR) self.assertRaises(ValueError, CSV, resource) |
resource = memory.File(TEST_SYNTAX_ERROR) | def test_bad_syntax_csv_file_with_schema(self): resource = memory.File(TEST_SYNTAX_ERROR) handler = CSV() handler.columns = ['one', 'two', 'three'] handler.schema = {'one': Unicode, 'two': Unicode, 'three': Unicode} self.assertRaises(ValueError, handler.load_state, resource) | |
self.assertRaises(ValueError, handler.load_state, resource) | load_state = handler.load_state_from_string self.assertRaises(ValueError, load_state, TEST_SYNTAX_ERROR) | def test_bad_syntax_csv_file_with_schema(self): resource = memory.File(TEST_SYNTAX_ERROR) handler = CSV() handler.columns = ['one', 'two', 'three'] handler.schema = {'one': Unicode, 'two': Unicode, 'three': Unicode} self.assertRaises(ValueError, handler.load_state, resource) |
return self.get_cookie(name) is None | return self.get_cookie(name) is not None | def has_cookie(self, name): return self.get_cookie(name) is None |
for name in target.resource.get_names(): if name.startswith('.'): | user = context.user filter = (Folder, filter_type) for handler in target.search_handlers(handler_class=filter): ac = handler.get_access_control() if not ac.is_allowed_to_view(user, handler): | def __init__(self, filter_type=Handler, root=None, start=None): """ The 'start' must be a handler, 'filter_type' must be a handler class. """ context = get_context() request, response = context.request, context.response |
handler = target.get_handler(name) if handler.is_allowed_to_view(): path = here.get_pathto(handler) bc_target = str(root.get_pathto(handler)) url = context.uri.replace(bc_target=bc_target) is_folder = isinstance(handler, Folder) is_selectable = False if is_folder or isinstance(handler, filter_type): is_selectable = Tr... | path = here.get_pathto(handler) bc_target = str(root.get_pathto(handler)) url = context.uri.replace(bc_target=bc_target) self.is_submit = True path_to_icon = handler.get_path_to_icon(16) if path: path_to_handler = uri.Path(str(path) + '/') path_to_icon = path_to_handler.resolve(path_to_icon) objects.append({'name': h... | def __init__(self, filter_type=Handler, root=None, start=None): """ The 'start' must be a handler, 'filter_type' must be a handler class. """ context = get_context() request, response = context.request, context.response |
version = "0.6.1", | version = "0.6.2", | def build_module(self, module, module_file, package): if isinstance(package, str): package = package.split('.') elif not isinstance(package, (list, tuple)): raise TypeError, \ "'package' must be a string (dot-separated), list, or tuple" |
s.append(node.replace('&', '&').replace('<', '<')) | s.append(XML_encoder.encode(Unicode.encode(node, encoding))) | def get_content_as_html(self, encoding='UTF-8'): s = [] for node in self.children: if isinstance(node, unicode): # XXX This is equivalent to 'Unicode.encode', # there should be a single place. s.append(node.replace('&', '&').replace('<', '<')) elif isinstance(node, Element): s.append(node.get_start_tag_as_html()... |
return self.resource.get_size() | return vfs.get_size(self.uri) | def get_size(self): """ Returns the size of this object. """ return self.resource.get_size() |
resource = self.resource | def external_edit(self, context): # TODO check if zopeedit really needs the meta_type. encoding = context.get_form_value('encoding') | |
'content_type:%s' % resource.get_mimetype(), | 'content_type:%s' % self.get_mimetype(), | def external_edit(self, context): # TODO check if zopeedit really needs the meta_type. encoding = context.get_form_value('encoding') |
self.timestamp = datetime.datetime.now() | self.timestamp = resource.get_mtime() | def load(self, resource=None): if resource is None: resource = self.resource |
def set_uriprefix(self, prefix): if self.name in ('href', 'src'): scheme, host, path, query, fragment = urlsplit(self.value) if not scheme: return u'%s="%s"' % (self.qname, prefix + self.value) return unicode(self) | def set_uriprefix(self, prefix): if self.name in ('href', 'src'): scheme, host, path, query, fragment = urlsplit(self.value) if not scheme: return u'%s="%s"' % (self.qname, prefix + self.value) | |
def set_uriprefix(self, prefix): """ Outputs the document, adds the given prefix to with the relative uris. XXX Rewrite with walk. """ s = u'' for child in self.children: if isinstance(child, Element): s += self._set_uriprefix(child, prefix) else: s += unicode(child) return s def _set_uriprefix(self, node, prefix): ... | def set_uriprefix(self, prefix): """ Outputs the document, adds the given prefix to with the relative uris. | |
if context.method is None: method = handler.get_method(request.method) | method_name = context.method if method_name is None: method_name = request.method try: getattr(handler, method_name) except AttributeError: response.set_status(404) method = root.not_found | def handle_request(connection, server): # Build the request object resource = File(connection) try: request = Request(resource) except BadRequest, exception: request = None request_line = exception.args[0] else: # Keep here (though redundant) to be used later in the access log request_line = request.state.request_line ... |
method = handler.get_method(context.method) if method is None: if user is None: method = root.login_form else: method = root.forbidden | method = handler.get_method(method_name) if method is None: if user is None: method = root.login_form else: method = root.forbidden | def handle_request(connection, server): # Build the request object resource = File(connection) try: request = Request(resource) except BadRequest, exception: request = None request_line = exception.args[0] else: # Keep here (though redundant) to be used later in the access log request_line = request.state.request_line ... |
tests = get_handler('tests') if tests.has_handler('catalog'): tests.del_handler('catalog') tests.set_handler('catalog', catalog) tests.save_state() catalog_resource = tests.resource.get_resource('catalog') | tmp = get_handler('/tmp') if tmp.has_handler('catalog_prof'): tmp.del_handler('catalog_prof') tmp.set_handler('catalog_prof', catalog) tmp.save_state() catalog_resource = tmp.resource.get_resource('catalog_prof') | def create_catalog(): print 'Creating catalog...', global catalog # Create and get a new empty index catalog = Catalog(fields=[('title', 'text', True, True), ('body', 'text', True, False)]) tests = get_handler('tests') if tests.has_handler('catalog'): tests.del_handler('catalog') tests.set_handler('catalog', catalog) t... |
resource_names = [ x for x in src.get_resource_names()[:101] | resource_names = [ x for x in src.get_resource_names() | def load_documents(): print 'Loading documents...', src = get_resource(docs_path) resource_names = [ x for x in src.get_resource_names()[:101] if x.endswith('.html') ] resource_names.sort() for name in resource_names: try: doc = Document(src.get_resource(name)) except: pass else: doc = {'title': doc.title(), 'body': do... |
pass | print name, '!!' | def load_documents(): print 'Loading documents...', src = get_resource(docs_path) resource_names = [ x for x in src.get_resource_names()[:101] if x.endswith('.html') ] resource_names.sort() for name in resource_names: try: doc = Document(src.get_resource(name)) except: pass else: doc = {'title': doc.title(), 'body': do... |
for document in documents[:100]: | for document in documents: | def profile_indexing(): for document in documents[:100]: catalog.index_document(document) catalog.save_state() |
catalog.save_state() | get_transaction().commit() | def profile_indexing(): for document in documents[:100]: catalog.index_document(document) catalog.save_state() |
query = {} | query = [] | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
query[key] = value | query.append((key, value)) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
query.update(kw) | for key in kw: for i, x in enumerate(query): if x is not None and x[0] == key: query[i] = None query = [ x for x in query if x is not None ] for key, value in kw.items(): query.append((key, value)) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
for key, value in query.items(): | new_query = [] for key, value in query: | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
continue del query[key] if isinstance(value, unicode): query['%s:utf8:ustring' % key] = value.encode('utf8') | new_query.append((key, value)) elif isinstance(value, unicode): new_query.append('%s:utf8:ustring' % key, value.encode('utf8')) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
query['%s:int' % key] = str(value) | new_query(('%s:int' % key, str(value))) elif isinstance(value, list): for x in value: new_query.append(('%s:list' % key, x)) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
query[key] = str(value) | new_query.append((key, str(value))) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
query_string = urlencode(query) | query_string = urlencode(new_query) | def build_url(self, url=None, preserve=[], **kw): """ Builds and returns a new url from the one we are now. Preserves only the query parameters that start with any of the specified prefixes in the 'preserve' argument. The keywords argument is used to add or modify query parameters. """ if url is None: url = self.uri.pa... |
for handler in self.traverse(): | for handler, context in self.traverse2(): | def copy_handler(self): resource = memory.Folder() for handler in self.traverse(): if handler.real_handler is not None: continue if handler is not self: path = self.get_pathto(handler) resource.set_resource(path, handler.resource) self.save_state(resource) return self.__class__(resource) |
continue if handler is not self: | context.skip = True elif handler is not self: | def copy_handler(self): resource = memory.Folder() for handler in self.traverse(): if handler.real_handler is not None: continue if handler is not self: path = self.get_pathto(handler) resource.set_resource(path, handler.resource) self.save_state(resource) return self.__class__(resource) |
return tuple(data.split(':')) | return tuple(data.split(':', 1)) | def decode(cls, data): if ':' in data: return tuple(data.split(':')) |
self.revisions = [] self.set_data(data) | self.data = data self.ctime = self.mtime = datetime.now() | def __init__(self, data): self.revisions = [] self.set_data(data) |
data = self.revisions[-1].data | data = self.data | def __setitem__(self, index, value): data = self.revisions[-1].data if isinstance(index, slice): # XXX So far 'step' is not supported start, stop = index.start, index.stop else: start, stop = index, index + 1 data = data[:start] + value + data[stop:] self.set_data(data) |
data = data[:start] + value + data[stop:] self.set_data(data) | self.data = data[:start] + value + data[stop:] self.mtime = datetime.now() def __setslice__(self, start, stop, value): self.data = self.data[:start] + value + self.data[stop:] self.mtime = datetime.now() def append(self, value): self.data += value | def __setitem__(self, index, value): data = self.revisions[-1].data if isinstance(index, slice): # XXX So far 'step' is not supported start, stop = index.start, index.stop else: start, stop = index, index + 1 data = data[:start] + value + data[stop:] self.set_data(data) |
return self.revisions[-1].data | return self.data | def __str__(self): return self.revisions[-1].data |
revision = Revision(data) self.revisions.append(revision) | self.data = data self.mtime = datetime.now() | def set_data(self, data): revision = Revision(data) self.revisions.append(revision) |
return self.revisions[0].date | return self.ctime | def get_ctime(self): return self.revisions[0].date |
return self.revisions[-1].date | return self.mtime | def get_mtime(self): return self.revisions[-1].date |
self.ctime = self.mtime = datetime.datetime.now() | self.ctime = self.mtime = datetime.now() | def __init__(self): self.resources = {} self.ctime = self.mtime = datetime.datetime.now() |
self.mtime = datetime.datetime.now() | self.mtime = datetime.now() | def _set_file_resource(self, name, resource): data = resource.get_data() self.resources[name] = File(data) self.mtime = datetime.datetime.now() |
self.mtime = datetime.datetime.now() | self.mtime = datetime.now() | def _set_folder_resource(self, name, resource): self.resources[name] = Folder() self.mtime = datetime.datetime.now() |
self.mtime = datetime.datetime.now() | self.mtime = datetime.now() | def _del_file_resource(self, name): del self.resources[name] self.mtime = datetime.datetime.now() |
goto = '/;login_form?username=%s' % self.name | goto = '/;login_form?username=%s' % self.get_property('ikaaro:email') | def confirm_registration(self, context): must_confirm = self.get_property('ikaaro:user_must_confirm') if context.get_form_value('key') != must_confirm: return self.gettext(u"Bad key.").encode('utf-8') |
def resolve_pointer(self, uri, offset): if uri.path.is_relative(): return offset.resolve(uri.path) return uri def set_template_prefix(self, offset): data = [] data.append(self.header_to_unicode()) for node, context in self.traverse2(): if isinstance(node, XML.Element): if context.start: data.append(u'<%s' % nod... | def process_message(message, keep_spaces): # Normalize the message message.normalize() # Left strip if message: x = message[0] if isinstance(x, unicode) and x.strip() == u'': del message[0] # Right strip if message: x = message[-1] if isinstance(x, unicode) and x.strip() == u'': del message[-1] # Process if message: # ... | |
type = None language = None | def decode(cls, data): data = data.split('.') | |
if data[-1] in i18n.languages: language = data[-1] data = data[:-1] if '.%s' % data[-1] in mimetypes.types_map: type = data[-1] data = data[:-1] name = '.'.join(data) | n = len(data) if n == 1: return data[0], None, None elif n == 2: if '.%s' % data[-1] in mimetypes.types_map: name, type = data return name, type, None elif data[-1] in i18n.languages: name, language = data return name, None, language else: return '.'.join(data), None, None else: type = language = None if data[-1] in... | def decode(cls, data): data = data.split('.') |
abspaths = [ x.get_abspath() for x in transaction ] | open('%s/state' % target, 'w').write('END') abspaths = [] for handler in transaction: if handler.real_handler is not None: handler = handler.real_handler abspaths.append(handler.get_abspath()) | def end_commit_on_success(self): target = self.target db = '%s/database' % target db2 = '%s/database.bak' % target |
open('%s/state' % target, 'w').write('END') | def end_commit_on_success(self): target = self.target db = '%s/database' % target db2 = '%s/database.bak' % target | |
if request.uri.path.endswith_slash: | if context.uri.path.endswith_slash: | def GET(self, context): request, response = context.request, context.response # This is a safe method context.commit = False # Our canonical URLs never end with an slash if request.uri.path.endswith_slash: goto = copy(context.uri) goto.path.endswith_slash = False return 302, goto # Traverse status, method = self.traver... |
def get_ctime(self): return self.ctime def get_mtime(self): return self.mtime | def get_ctime(self): return self.ctime | |
def get_mtime(self): return self.mtime def get_ctime(self): return self.ctime | def get_mimetype(self): # XXX This method should be removed as soon as the Folder class # becomes a new style class, because this method is here only # to workaround the wrong inheritance algorithm of classic Python # classes. return base.Folder.get_mimetype(self) | |
except OSError, e: context = get_context() context.server.log_error(context) return '', str(e) | except OSError: vfs.remove(path) raise | def convert(handler, cmdline, outfile=None): cmdline = cmdline % 'stdin' # Serialize the handler to a temporary file in the file system path = tempfile.mkdtemp('itools') file_path = path_join(path, 'stdin') open(file_path, 'w').write(handler.to_str()) # stdout & stderr stdout_path = path_join(path, 'stdout') stdout =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.