rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.data = data | self.data.seek(0) self.data.truncate() self.data.write(data) | def set_data(self, data): self.data = data self.mtime = datetime.now() |
schema = namespace.get_element_schema() | schema = namespace.get_element_schema(self.name) | def get_start_tag(self): s = '<%s' % self.qname # Output the attributes for namespace_uri, local_name, value in self.get_attributes(): qname = self.get_attribute_qname(namespace_uri, local_name) type = self.get_attribute_type(namespace_uri, local_name) value = type.to_unicode(value) s += ' %s="%s"' % (qname, value) # C... |
schema = namespace.get_element_schema() | schema = namespace.get_element_schema(self.name) | def get_end_tag(self): namespace = namespaces.get_namespace(self.namespace) schema = namespace.get_element_schema() is_empty = schema.get('is_empty', False) if is_empty: return u'' return u'</%s>' % self.qname |
return self.data.replace('<', '<') | return self.data.replace('<', '<').replace('&', '&') | def __unicode__(self): return self.data.replace('<', '<') |
* itools.lucene -- An underway implementation of the famous Jakarta's indexing and search tool. | * itools.catalog -- An Index & Search engine. | 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" |
version = "0.4.1", | version = "0.4.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" |
def _load_state(self, resource): self.translations = GNUTranslations(resource) | def _load_state_from_file(self, file): self.translations = GNUTranslations(file) | def _load_state(self, resource): self.translations = GNUTranslations(resource) |
if name.startswith('.'): | if name.startswith('.') or name.endswith('.metadata'): | def before_set_handler(self, segment, handler, format=None, id=None, move=False, **kw): name = segment.name if name.startswith('.'): return |
if name.startswith('.'): | if name.startswith('.') or name.endswith('.metadata'): | def after_set_handler(self, segment, handler, format=None, id=None, move=False, **kw): from root import Root |
if not self.states.has_key(name): | if name not in self.states: | def set_initstate(self, name): """ Sets the default initial state. """ if not self.states.has_key(name): raise WorkflowError, "invalid initial state: '%s'" % name self.initstate = name |
class State: | class State(object): | def add_trans(self, name, state_from, state_to, **kw): """ Adds a new transition, 'state_from' and 'state_to' are respectively the origin and destination states of the transition. |
class Transition: | class Transition(object): | def __getitem__(self, key): """ Access to the metadata as a mapping. """ return self.metadata.get(key) |
def __init__(self, workflow, initstate=None, *args, **kw): """ Initialize the workflow aware object. initstate is the workflow state that should be taken on initially (if omitted or None, the workflow must provide a default initial state). Extra arguments are passed to the enter-state handler (if any) of the initial st... | def __getitem__(self, key): """ Access to the metadata as a mapping. """ return self.metadata.get(key) | |
return root.unrestrictedTraverse(self._path) | return root.unrestrictedTraverse(self._path).aq_base | def _get_object(self): root = get_context().request.zope_request['PARENTS'][-1] return root.unrestrictedTraverse(self._path) |
mtime = object.bobobase_modification_time() mtime = mtime.timeTime() return datetime.fromtimestamp(mtime) | mtime = getattr(object, 'mtime', None) if mtime is None or mtime < self.bobo_time: return self.bobo_time return mtime | def get_mtime(self): object = self._get_object() mtime = object.bobobase_modification_time() mtime = mtime.timeTime() return datetime.fromtimestamp(mtime) |
data = str(object.data) | def __setitem__(self, index, value): object = self._get_object() | |
if context.uri.path.endswith_slash: | if request.method == 'GET' and context.uri.path.endswith_slash: | def handle_request(self, connection): # Build the request object resource = File(connection) try: request = Request(resource) except BadRequest, exception: request = None request_line = exception.args[0] except: self.log_error() request = None request_line = 'XXX' else: # Keep here (though redundant) to be used later i... |
raise ValueError, "resource '%s' not found" % str(path[:i+1]) | raise LookupError, "resource '%s' not found" % str(path[:i+1]) | def get_resource(self, path): """ Returns the required resource, or None if it does not exists. """ # Normalize the path if not isinstance(path, uri.Path): path = uri.Path(path) |
server = Server(root, port=options.port, access_log='%s/access_log' % target, | if options.port: port = options.port elif config.has_option('instance', 'port'): port = config.getint('instance', 'port') else: port = None server = Server(root, port=port, access_log='%s/access_log' % target, | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
data.append('HTTP/1.1 %d %s\n' % (status_code, status_message)) | data.append('HTTP/1.1 %d %s' % (status_code, status_message)) | def to_str(self): state = self.state |
data.append('%s: %s\n' % (name, value)) | data.append('%s: %s' % (name, value)) data.append('Server: Zope') now = datetime.utcnow() data.append('Date: %s' % now.strftime("%a, %d %b %Y %H:%M:%S +0000")) | def to_str(self): state = self.state |
data.append('Content-Length: %d\n' % len(state.body)) | data.append('Content-Length: %d' % len(state.body)) data.append('Connection: close') | def to_str(self): state = self.state |
data.append( 'Set-Cookie: %s="%s"%s\n' % (name, value, ''.join(parameters))) | data.append('Set-Cookie: %s="%s"%s' % (name, value, ''.join(parameters))) | def to_str(self): state = self.state |
data.append('\n') | data.append('') | def to_str(self): state = self.state |
return ''.join(data) | return '\r\n'.join(data) | def to_str(self): state = self.state |
class Distance(object): def __init__(self, first_text, second_text): self.first_text = first_text self.second_text = second_text | class Fuzzy_test(unittest.TestCase): def test_fuzzy_abrevation(self): first_text = """ Mr toto is here """ second_text = """ toto is here Monsieur """ p = fuzzy.Distance(first_text, second_text) print 'test_fuzzy_abrevation', p.distance() | def create_new_text(self): """ Return a text without abrevation. """ t = ' '+self.text+' ' for i in punctuations: t = t.replace(i , ' '+i+' ') for word, abrevations in dictionary.items(): for abrevation in abrevations: t = t.replace(' '+abrevation+' ', ' '+word+' ') return t |
def distance(self): | def test_fuzzy_no_abrevation(self): first_text = """ Monsieur toto is here | def distance(self): """ Return a gap and a percent that takes account of abrevations. """ a = SelectText(self.first_text) b = SelectText(self.second_text) a_create = a.create_new_text() b_create = b.create_new_text() dist = max (len(a.text), len(b.text)) dist_create = 5*(max (len(a_create), len(b_create))) gap = self.g... |
Return a gap and a percent that takes account of abrevations. | second_text = """ toto is here Monsieur | def distance(self): """ Return a gap and a percent that takes account of abrevations. """ a = SelectText(self.first_text) b = SelectText(self.second_text) a_create = a.create_new_text() b_create = b.create_new_text() dist = max (len(a.text), len(b.text)) dist_create = 5*(max (len(a_create), len(b_create))) gap = self.g... |
a = SelectText(self.first_text) b = SelectText(self.second_text) a_create = a.create_new_text() b_create = b.create_new_text() dist = max (len(a.text), len(b.text)) dist_create = 5*(max (len(a_create), len(b_create))) gap = self.gap(self.first_text, self.second_text) gap_create = 5*(self.gap(a_create, b_create)) percen... | p = fuzzy.Distance(first_text, second_text) print 'test_fuzzy_no_abrevation', p.distance() | def distance(self): """ Return a gap and a percent that takes account of abrevations. """ a = SelectText(self.first_text) b = SelectText(self.second_text) a_create = a.create_new_text() b_create = b.create_new_text() dist = max (len(a.text), len(b.text)) dist_create = 5*(max (len(a_create), len(b_create))) gap = self.g... |
def gap(self, a, b): | def test_fuzzy_abrevation_differente(self): first_text = """ Why toto is here | def gap(self, a, b): """ This function was giving by Magnus Lie Hetland. It calculates the gap (mathematical distance) between two strings with the cost of word's translation inside the string. """ c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): f... |
This function was giving by Magnus Lie Hetland. It calculates the gap (mathematical distance) between two strings with the cost of word's translation inside the string. | second_text = """ toto is here Monsieur | def gap(self, a, b): """ This function was giving by Magnus Lie Hetland. It calculates the gap (mathematical distance) between two strings with the cost of word's translation inside the string. """ c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): f... |
c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): for j in range(1,m+1): x = c[i-1,j] + 1 y = c[i,j-1] + 1 if a[i-1] == b[j-1]: z = c[i-1,j-1] else: z = c[i-1,j-1] + 1 c[i,j] = min(x,y,z) return c[n,m] | p = fuzzy.Distance(first_text, second_text) print 'test_fuzzy_abrevation_differente', p.distance() | def gap(self, a, b): """ This function was giving by Magnus Lie Hetland. It calculates the gap (mathematical distance) between two strings with the cost of word's translation inside the string. """ c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): f... |
def test_fuzzy_translation(self): first_text = """ toto is here now """ second_text = """ now toto is here """ p = fuzzy.Distance(first_text, second_text) print 'test_fuzzy_translation', p.distance() def test_fuzzy_not_all_translation(self): first_text = """ Juan is here now """ second_text = """ now toto is here """... | def gap(self, a, b): """ This function was giving by Magnus Lie Hetland. It calculates the gap (mathematical distance) between two strings with the cost of word's translation inside the string. """ c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): f... | |
value = value.strip() | def decode(cls, value): value = value.strip() if not value: return None return int(value) | |
value = value.strip() | def decode(cls, value, encoding='utf8'): value = value.strip() return unicode(value, encoding) | |
value = value.strip() | def encode(cls, value): value = value.strip() return value | |
value = value.strip() | def decode(cls, value): value = value.strip() return value | |
value = value.strip() | def decode(cls, value): value = value.strip() return bool(int(value)) | |
value = value.strip() | def decode(cls, value): value = value.strip() if not value: return None year, month, day = value.split('-') year, month, day = int(year), int(month), int(day) return datetime.date(year, month, day) | |
value = value.strip() | def decode(cls, value): value = value.strip() if not value: return None date, time = value.split() year, month, day = date.split('-') year, month, day = int(year), int(month), int(day) hours, minutes = time.split(':') hours, minutes = int(hours), int(minutes) return datetime.datetime(year, month, day, hours, minutes) | |
version = "0.9.2", | version = "0.9.3", | def finalize_options (self): self.set_undefined_options('install', ('install_purelib', 'install_dir'), ('root', 'root'), ('force', 'force'), ) |
for x in handler.traverse(): root.unindex_handler(x) | for x, context in handler.traverse2(): if x.real_handler is None: root.unindex_handler(x) else: context.skip = True | def on_del_handler(self, segment): from root import Root |
def view(self): | def view(self, context): | def view(self): namespace = {} namespace['format'] = self.get_mimetype() |
version = "0.6.2", | version = "0.6.3", | 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" |
gettext = self.object.gettext(message) | gettext = self.handler.gettext(message) | def come_back(self, message, **kw): # Translate the source message, gettext = self.object.gettext(message) message = Template(message).substitute(kw) # Build and the return the uri reference to go referrer = self.request.referrer return referrer.replace(message=message) |
def new(self, title=''): | def new(self): | def new(self, title=''): # XXX Old style (like in the "get_skeleton" times) skeleton = self.get_skeleton(title) file = StringIO() file.write(skeleton) file.seek(0) self.load_state_from_file(file) |
skeleton = self.get_skeleton(title) file = StringIO() file.write(skeleton) file.seek(0) self.load_state_from_file(file) | skeleton = self.get_skeleton() self.load_state_from_string(skeleton) | def new(self, title=''): # XXX Old style (like in the "get_skeleton" times) skeleton = self.get_skeleton(title) file = StringIO() file.write(skeleton) file.seek(0) self.load_state_from_file(file) |
conn = HTTPConnection(str(reference.authority)) conn.request('HEAD', str(reference.path)) response = conn.getresponse() | response = HTTPFS._head(reference) | def exists(reference): conn = HTTPConnection(str(reference.authority)) # XXX Add the query conn.request('HEAD', str(reference.path)) response = conn.getresponse() status = int(response.status) return status < 400 or status >= 500 |
def open(reference): | def open(reference, mode=None): | def open(reference): reference = str(reference) return urlopen(reference) |
query = urllib.unquote_plus(query) | def __init__(self, query): if query: query = urllib.unquote_plus(query) for x in query.split('&'): if x: key, value = x.split('=', 1) dict.__setitem__(self, key, value) | |
message = u'We did not find results for "%s".' namespace['not_found'] = self.gettext(message) % text | message = u'We did not find results for "%s".' % text namespace['not_found'] = self.gettext(message) | def site_search(self, context): text = context.get_form_value('site_search_text').strip() if not text: return context.come_back(u"Empty search value.") |
if context.has_parameter('add_and_return'): | if context.has_form_value('add_and_return'): | def new_user(self, context): username = context.get_form_value('username') password = context.get_form_value('password') password2 = context.get_form_value('password2') groups = context.get_form_values('groups') |
new_query(('%s:int' % key, str(value))) | new_query.append(('%s:int' % 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... |
storage = FileStorage('%s/database.fs' % target) database = zodb.Database(storage) | def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the database storage = FileStorage('%s/database.fs' % target) database = zodb.Database(storage) # Create the config file config = RawConfigParser() config.add_section('inst... | |
config = RawConfigParser() config.add_section('instance') | config = get_config() | def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the database storage = FileStorage('%s/database.fs' % target) database = zodb.Database(storage) # Create the config file config = RawConfigParser() config.add_section('inst... |
print ' icms.py start %s' % target | print ' %s start %s' % (parser.get_prog_name(), target) | def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the database storage = FileStorage('%s/database.fs' % target) database = zodb.Database(storage) # Create the config file config = RawConfigParser() config.add_section('inst... |
if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... | |
config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini' % target]) storage = FileStorage('%s/database.fs' % target) database = zodb.Database(storage) root_resource = database.get_resource('/') | config = get_config(target) | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
metadata = root_resource.get_resource('.metadata') metadata = Metadata(metadata) format = metadata.get_property('format') root = Root.build_handler(root_resource, format=format) | database = get_database(target) root = get_root(database) | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
' icms.py init creates a new instance\n' ' icms.py start starts the web server') | ' %prog init creates a new instance\n' ' %prog start starts the web server\n' ' %prog update updates the instance (if needed)') | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
'-i', '--import', help='use the SOURCE directory to init the database', dest='source') | '-s', '--source', help='use the SOURCE directory to init the database') | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
command, target = args if command == 'init': init(parser, options, target) elif command == 'start': start(parser, options, target) else: parser.error('unexpected command "%s"' % command) | command_name, target = args commands = {'init': (init, ['source', 'root', 'port']), 'start': (start, ['port']), 'update': (update, [])} if command_name not in commands: parser.error('unexpected command "%s"' % command_name) command, allowed_options = commands[command_name] for key, value in options.__dict__.items... | def start(parser, options, target): if options.source is not None: parser.error('option --import not allowed in this context') if options.root is not None: parser.error('option --root not allowed in this context') # Load the config config = RawConfigParser() config.add_section('instance') config.read(['%s/config.ini'... |
pid = open('%s/pid' % self.target).read() | try: pid = open('%s/pid' % self.target).read() except IOError: return None | def get_pid(self): pid = open('%s/pid' % self.target).read() pid = int(pid) try: # XXX This only works on Unix os.getpgid(pid) except OSError: return None |
html = self.to_html().encode('UTF-8') | html = self.to_html() | def to_text(self): if self.__text_output__ is not None: return self.__text_output__ |
request_uri.path = uri.Path(request.get_parameter('REAL_PATH')) | real_path = request.get_parameter('REAL_PATH') request_uri.path = uri.Path('/' + real_path) | def __init__(self, request): self.request = request self.response = Response() |
parent = None | def __cmp__(self, other): if not isinstance(other, self.__class__): return 1 return cmp(self.data, other.data) | |
clone.children = deepcopy(self.children) | for child in self.children: if isinstance(child, unicode): self.children.append(child) else: self.children.append(child.copy()) | def copy(self): """ DOM: cloneNode. """ # Build a new node clone = self.__class__(self.prefix, self.name) # Copy the attributes clone.attributes = self.attributes.copy() clone.prefixes = self.prefixes.copy() # Copy the children (XXX) clone.children = deepcopy(self.children) |
for handler in list(self): if hasattr(handler, 'before_commit'): handler.before_commit() | try: for handler in list(self): if hasattr(handler, 'before_commit'): handler.before_commit() except: self.rollback() raise | def commit(self): # Event: before commit for handler in list(self): if hasattr(handler, 'before_commit'): handler.before_commit() |
def update_20060503(self): | def update_20060602(self): | def update_20060503(self): root = vfs.open(self.uri) # Remove ".archive" root.remove('.archive') |
def update_20060602(self): | def update_20060503(self): root = vfs.open(self.uri) # Remove ".archive" root.remove('.archive') | |
admins = self.get_handler('admins/.users').get_usernames() self.set_handler('.admins.users', ListOfUsers(users=admins)) | root.move('admins/.users', '.admins.users') | def update_20060602(self): # Add '.admins.users' admins = self.get_handler('admins/.users').get_usernames() self.set_handler('.admins.users', ListOfUsers(users=admins)) # Remove handlers self.del_handler('.users') self.del_handler('admins') self.del_handler('.admins.metadata') self.del_handler('reviewers') self.del_han... |
self.del_handler('.users') self.del_handler('admins') self.del_handler('.admins.metadata') self.del_handler('reviewers') self.del_handler('.reviewers.metadata') | root.remove('.users') root.remove('admins') root.remove('admins.metadata') root.remove('reviewers') root.remove('reviewers.metadata') | def update_20060602(self): # Add '.admins.users' admins = self.get_handler('admins/.users').get_usernames() self.set_handler('.admins.users', ListOfUsers(users=admins)) # Remove handlers self.del_handler('.users') self.del_handler('admins') self.del_handler('.admins.metadata') self.del_handler('reviewers') self.del_han... |
self.del_handler('en.po') | if root.exists('en.po'): root.remove('en.po') root.remove('en.po.metadata') | def update_20060602(self): # Add '.admins.users' admins = self.get_handler('admins/.users').get_usernames() self.set_handler('.admins.users', ListOfUsers(users=admins)) # Remove handlers self.del_handler('.users') self.del_handler('admins') self.del_handler('.admins.metadata') self.del_handler('reviewers') self.del_han... |
self.uri = uri.get_reference('http://%s/%s' % (authority, path)) | if request.has_parameter('REAL_PATH'): real_path = request.get_parameter('REAL_PATH') reference = 'http://%s/%s' % (authority, real_path) else: reference = 'http://%s/%s' % (authority, path) self.uri = uri.get_reference(reference) | def __init__(self, request, authority): self.request = request self.response = Response() |
handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) self.assertEqual(handler.to_str(), u'"python","http://python.org","52343","2003-10-23"\n' + | handler.schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} handler.load_state(resource) self.assertEqual( handler.to_str(), u'"python","http://python.org","52343","2003-10-23"\n' | def test_to_str_with_schema(self): resource = memory.File(TEST_DATA_1) handler = itools_csv.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.... |
self.assertEqual(handler.to_str(), u'"python","http://python.org","52343","2003-10-23"\n' + | self.assertEqual( handler.to_str(), u'"python","http://python.org","52343","2003-10-23"\n' | def test_to_str_without_schema(self): resource = memory.File(TEST_DATA_1) handler = itools_csv.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"') |
stored_field = doc_handler.get_handler('s%d' %field.number) setattr(document, field.name, stored_field.value) | name = 's%d' % field.number if doc_handler.has_handler(name): stored_field = doc_handler.get_handler(name) value = stored_field.value else: value = None setattr(document, field.name, value) | def search(self, query=None, **kw): # Search documents = self._search(query, **kw) # Sort by weight documents = [ (weight, doc_number) for doc_number, weight in documents.items() ] documents.sort() documents.reverse() # Build the document objects fields = self.get_handler('fields') for i, document in enumerate(document... |
version = "0.5.1", | version = "0.6.0", | 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" |
self.removed_documents.append(doc_n) | else: self.removed_documents.append(doc_n) | def unindex_document(self, doc_n): if doc_n in self.added_documents: self.added_documents.remove(doc_n) self.removed_documents.append(doc_n) |
for i, document in enumerate(documents): | for document in documents: | def search(self, query=None, **kw): # Search documents = self._search(query, **kw) # Sort by weight documents = [ (weight, doc_number) for doc_number, weight in documents.items() ] documents.sort() documents.reverse() # Build the document objects fields = self.get_handler('fields') for i, document in enumerate(document... |
documents[i] = document return documents | yield document | def search(self, query=None, **kw): # Search documents = self._search(query, **kw) # Sort by weight documents = [ (weight, doc_number) for doc_number, weight in documents.items() ] documents.sort() documents.reverse() # Build the document objects fields = self.get_handler('fields') for i, document in enumerate(document... |
remains = size - len(buffer[0]) | def non_blocking_load(self, read): buffer = '' # Read the first line while True: data = read(512) data_size = len(data) # Check there is some data, if not we abort the request, something # may be wrong. if data_size == 0: raise BadRequest buffer += data buffer = buffer.split('\r\n', 1) if len(buffer) == 2: request_line... | |
if body and 'content-type' in self.headers: | if body: | def non_blocking_load(self, read): buffer = '' # Read the first line while True: data = read(512) data_size = len(data) # Check there is some data, if not we abort the request, something # may be wrong. if data_size == 0: raise BadRequest buffer += data buffer = buffer.split('\r\n', 1) if len(buffer) == 2: request_line... |
self._body = uri.generic.Query.decode(body) | self.body = uri.generic.Query.decode(body) | def non_blocking_load(self, read): buffer = '' # Read the first line while True: data = read(512) data_size = len(data) # Check there is some data, if not we abort the request, something # may be wrong. if data_size == 0: raise BadRequest buffer += data buffer = buffer.split('\r\n', 1) if len(buffer) == 2: request_line... |
' %prog update updates the instance (if needed)') | ' %prog update updates the instance (if needed)\n' ' %prog pack packs the database') | def update(parser, options, target): # Load the config config = get_config(target) # Import the root class if is not the default if config.has_option('instance', 'root'): exec('import %s' % config.get('instance', 'root')) # Load the root resource database = get_database(target) root = get_root(database) instance_ver... |
'update': (update, [])} | 'update': (update, []), 'pack': (pack, [])} | def update(parser, options, target): # Load the config config = get_config(target) # Import the root class if is not the default if config.has_option('instance', 'root'): exec('import %s' % config.get('instance', 'root')) # Load the root resource database = get_database(target) root = get_root(database) instance_ver... |
size = len([ x for x in resource.get_names() | size = len([ x for x in vfs.get_names(self.uri) | def get_human_size(self): uri = self.uri if vfs.is_file(uri): bytes = resource.get_size() kbytes = bytes / 1024.0 if kbytes >= 1024: mbytes = kbytes / 1024.0 size = self.gettext(u'%.01f MB') % mbytes else: size = self.gettext(u'%.01f KB') % kbytes else: size = len([ x for x in resource.get_names() if not x.startswith('... |
version = "0.9.0", | version = "0.9.1", | def finalize_options (self): self.set_undefined_options('install', ('install_purelib', 'install_dir'), ('root', 'root'), ('force', 'force'), ) |
message = i18n.segment.Message(node.children) | message = Message(node.children) | 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] yield x # Right strip if message: x = message[-1] if isinstance(x, unicode) and x.strip() == u'': del message[-1] yield x # Proces... |
message = i18n.segment.Message() | message = Message() | def f(match): x = match.group(0) if x.endswith(';'): return x return "&" + x[1:] |
message = i18n.segment.Message(node.children) | message = Message(node.children) | 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: # ... |
message = i18n.segment.Message() | message = Message() | 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: # ... |
def _get_handler(self, segment): | def _get_handler(self, segment, resource): | def _get_handler(self, segment): name = segment.name if self.has_resource(name): resource = self.get_resource(name) if name == 'segments': return Segments(resource) elif name == 'deletable': return Deletable(resource) elif name.count('.') == 1: # Maybe it is a segment file segments = self.get_handler('segments') name, ... |
if self.has_resource(name): resource = self.get_resource(name) if name == 'segments': return Segments(resource) elif name == 'deletable': return Deletable(resource) elif name.count('.') == 1: segments = self.get_handler('segments') name, extension = name.split('.') if name in segments.segments: if extension == 'fnm':... | if name == 'segments': return Segments(resource) elif name == 'deletable': return Deletable(resource) elif name.count('.') == 1: segments = self.get_handler('segments') name, extension = name.split('.') if name in segments.segments: if extension == 'fnm': return Lucene.FieldInfos(resource) elif extension == 'fdx': nd... | def _get_handler(self, segment): name = segment.name if self.has_resource(name): resource = self.get_resource(name) if name == 'segments': return Segments(resource) elif name == 'deletable': return Deletable(resource) elif name.count('.') == 1: # Maybe it is a segment file segments = self.get_handler('segments') name, ... |
version = "0.4.3", | version = "0.4.4", | 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" |
def finish_commit(folder): """Continue to replace resources by their new state.""" for name in folder.get_names(): if name == '.catalog': if folder.exists('.catalog.bak'): folder.remove('.catalog.bak') folder.copy(name, '.catalog.bak') elif name == '.catalog.bak': continue elif folder.is_folder(name): subfolder = folde... | def get_root(target): # Get the root resource metadata = Metadata('%s/database/.metadata' % target) format = metadata.get_property('format') # Build and return the root handler cls = registry.get_object_class(format) return cls('%s/database' % target) | |
codepoint = htmlentitydefs.name2codepoint[name] char = unichr(codepoint).encode(self._encoding) self.char_data_handler(char) | if name in htmlentitydefs.name2codepoint: codepoint = htmlentitydefs.name2codepoint[name] char = unichr(codepoint).encode(self._encoding) self.char_data_handler(char) else: warnings.warn('Unknown entity reference "%s" (ignoring)' % name) | def skipped_entity_handler(self, name, is_param_entity): # XXX HTML specific codepoint = htmlentitydefs.name2codepoint[name] char = unichr(codepoint).encode(self._encoding) self.char_data_handler(char) |
def get_lines(data): """ Unfold the folded lines. """ i = 0 lines = data.splitlines() line = '' while i < len(lines): next = lines[i] if next.startswith(' ') or next.startswith('\t'): line += next[1:] else: if line: yield line line = next i += 1 if line: yield line NAME, PNAME, PVALUE, VALUE = range(4) def parse_lin... | if __name__ == '__main__': unittest.main() | def get_lines(data): """ Unfold the folded lines. """ i = 0 lines = data.splitlines() line = '' while i < len(lines): next = lines[i] if next.startswith(' ') or next.startswith('\t'): line += next[1:] else: if line: yield line line = next i += 1 if line: yield line |
if( char.direction != direction ): char.direction = direction char.update() | char.turnto( item ) | def onUse( char, item ): # Either the dummy is swinging or we aren't assigned to a dummy if( item.id != 0x1070 and item.id != 0x1074 ): return 1 # Distance & Direction checks if( char.distanceto( item ) > 1 ): char.message( 'You must be standing in front of or behind the dummy to use it.' ) return 1 # Calculates the... |
if( skill != wolfpack.FENCING and skill != wolfpack.MACEFIGHTING and skill != wolfpack.SWORDSMANSHIP and skill != wolfpack.WRESTLING ): | if( skill != FENCING and skill != MACEFIGHTING and skill != SWORDSMANSHIP and skill != WRESTLING ): | def onUse( char, item ): # Either the dummy is swinging or we aren't assigned to a dummy if( item.id != 0x1070 and item.id != 0x1074 ): return 1 # Distance & Direction checks if( char.distanceto( item ) > 1 ): char.message( 'You must be standing in front of or behind the dummy to use it.' ) return 1 # Calculates the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.