rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
return context.come_back(replace)
return context.come_back(message)
def new_resource(self, context): class_id = context.get_form_value('class_id') name = context.get_form_value('name') title = context.get_form_value('dc:title')
self._set_message(msgid, msgstrm, comments)
self._set_message(msgid, msgstr, comments)
def next_entry(self): # Load the next line line_type, value = self.next_line()
def set_message(self, msgid, msgstr=[''], comments=[], references={}):
def set_message(self, msgid, msgstr=[u''], comments=[], references={}):
def set_message(self, msgid, msgstr=[''], comments=[], references={}): self._set_message(msgid, msgstr, comments, references) self.save()
def _set_message(self, msgid, msgstr=[''], comments=[], references={}):
def _set_message(self, msgid, msgstr=[u''], comments=[], references={}):
def _set_message(self, msgid, msgstr=[''], comments=[], references={}): if isinstance(msgid, (str, unicode)): msgid = [msgid] if isinstance(msgstr, (str, unicode)): msgstr = [msgstr]
context.messages.add(attribute.value)
value = attribute.value.strip() if value: context.messages.add(attribute.value)
def before(node, context): message = context.message if isinstance(node, XML.Raw): message.append(node.data) elif isinstance(node, XML.Element): # Skip <script> (XXX do the same with <style>??) if node.name == 'script': process_message(context) return True # Attributes for attribute in node.attributes: if node.is_trans...
for x, context in handler.traverse2(context):
for x, context in handler.traverse2(context, caching=caching):
def traverse2(self, context=None, caching=True): if context is None: context = Context()
atom = Query.Simple(key, value) if query is None: query = atom
if key in field_numbers: atom = Query.Simple(key, value) if query is None: query = atom else: query = Query.Complex(query, 'and', atom)
def _search(self, query=None, **kw): # Build the query if it is passed through keyword parameters if query is None: for key, value in kw.items(): atom = Query.Simple(key, value) if query is None: query = atom else: query = Query.Complex(query, 'and', atom) # Check wether there is a query at all if query is None: raise ...
query = Query.Complex(query, 'and', atom)
warnings.warn('unknown field "%s"' % key)
def _search(self, query=None, **kw): # Build the query if it is passed through keyword parameters if query is None: for key, value in kw.items(): atom = Query.Simple(key, value) if query is None: query = atom else: query = Query.Complex(query, 'and', atom) # Check wether there is a query at all if query is None: raise ...
resource = memory.Folder()
self.resource = memory.Folder()
def __init__(self, resource=None, **kw): self.cache = {}
else: skeleton = None self.resource = resource if skeleton is not None:
def __init__(self, resource=None, **kw): self.cache = {}
@staticmethod def get_mimetype(reference):
@classmethod def get_mimetype(cls, reference):
def get_atime(reference): raise NotImplementedError
if self.is_file(reference):
if cls.is_file(reference):
def get_mimetype(reference): """ Try to guess the mimetype for a resource, given the resource itself and its name. To guess from the name we need to extract the type extension, we use an heuristic for this task, but it needs to be improved because there are many patterns:
data = unicode(context.get_form_value('data'), 'UTF-8') self.set_data(data)
data = context.get_form_value('data') resource = memory.File(data) self.load_state(resource)
def edit(self, context): data = unicode(context.get_form_value('data'), 'UTF-8') self.set_data(data)
date = self.get_current_date()
date = self.get_current_date(context.get_form_value('DTSTART1'))
def edit_event(self, context): if context.has_form_value('remove'): return self.remove(context)
goto = ';table_view?date=%s' % date
goto = ';table_view?date=%s' % date.strftime('%Y-%m-%d')
def edit_event(self, context): if context.has_form_value('remove'): return self.remove(context)
print '****************************************************************'
print '*'
def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the config file config = get_config() if options.root: config.set('instance', 'root', options.root) if options.port: config.set('instance', 'port', options.port) config.writ...
print '* A user with administration rights has been created for you:' print '* username: admin' print '* password: %s' % password
if options.source is None: print '* A user with administration rights has been created for you:' print '* username: admin' print '* password: %s' % password
def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the config file config = get_config() if options.root: config.set('instance', 'root', options.root) if options.port: config.set('instance', 'port', options.port) config.writ...
version = "0.9.1",
version = "0.9.2",
def finalize_options (self): self.set_undefined_options('install', ('install_purelib', 'install_dir'), ('root', 'root'), ('force', 'force'), )
data = str(data)
if isinstance(data, str): pass elif isinstance(data, unicode): data = data.encode('utf-8') else: data = str(data)
def substitute(data, stack, repeat_stack, encoding='utf-8'): data = str(data) # Solo, preserve the value None match = subs_expr_solo.match(data) if match is not None: expr = Expression(match.group(1)) value = expr.evaluate(stack, repeat_stack) # Preserve the value None if value is None: return None, 1 # Send the string...
type, default = schema[name] if issubclass(type, SimpleType): value = unicode(node.children) value = type.decode(value) elif issubclass(type, ComplexType): value = type.decode(node)
if name in schema: type, default = schema[name] if issubclass(type, SimpleType): value = unicode(node.children) value = type.decode(value) elif issubclass(type, ComplexType): value = type.decode(node) else: raise ValueError, 'bad type for "%s"' % name if 'lang' in node.attributes: language = node.attributes['lang'].va...
def decode(cls, node): schema = cls.schema property = cls() for node in node.get_elements(): name = node.name # Decode the value type, default = schema[name] if issubclass(type, SimpleType): value = unicode(node.children) value = type.decode(value) elif issubclass(type, ComplexType): value = type.decode(node) else: rai...
raise ValueError, 'bad type for "%s"' % name if 'lang' in node.attributes: language = node.attributes['lang'].value else: language = None property.set_property(name, value, language=language)
warnings.warn('The schema does not define "%s"' % name)
def decode(cls, node): schema = cls.schema property = cls() for node in node.get_elements(): name = node.name # Decode the value type, default = schema[name] if issubclass(type, SimpleType): value = unicode(node.children) value = type.decode(value) elif issubclass(type, ComplexType): value = type.decode(node) else: rai...
mtime = mtime()
mtime = mtime().replace(microsecond=0)
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 ...
def _load_state(self, resource): data = resource.read()
row_class = iRow
def _load_state(self, resource): data = resource.read()
lines = [] index = 0 for line in parse(data, self.schema): row = Row(line) row.index = index lines.append(row) index = index + 1
def _load_state(self, resource): data = resource.read()
self.state.lines = lines self.state.encoding = self.guess_encoding(data)
def _load_state(self, resource): data = resource.read()
if name.startswith('.') or name.endswith('.metadata'):
if (name.startswith('.') or name.endswith('.metadata') or name.endswith('.lock')):
def on_del_handler(self, segment): from root import Root
def __init__(self, id, title, description, state): self.id = id
def __init__(self, title, description, state='open'):
def __init__(self, id, title, description, state): self.id = id self.title = title self.description = description self.state = state
root = server.pool.pop()
root = server.root
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 ...
server.pool.push(root)
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 ...
self.pool = Pool(root)
self.root = root
def __init__(self, root, address='127.0.0.1', port=None, access_log=None, error_log=None, pid_file=None): if port is None: port = 8080 # The application's root self.pool = Pool(root) # The address and port the server will listen to self.address = address self.port = port # The access and error logs if access_log is not...
return cls('%s/database')
return cls('%s/database' % target)
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')
def to_str(self):
def to_str(self, encoding='UTF-8'):
def to_str(self): s = [] # The comments for comment in self.comments: s.append('#%s\n' % comment) # The reference comments for filename, lines in self.references.items(): for line in lines: s.append('#: %s:%s\n' % (filename, line)) # The Fuzzy flag if self.fuzzy: s.append('#, fuzzy\n') # The msgid s.append('msgid "%s"\...
s.append('msgid "%s"\n' % escape(self.msgid[0]))
s.append('msgid "%s"\n' % escape(self.msgid[0].encode(encoding)))
def to_str(self): s = [] # The comments for comment in self.comments: s.append('#%s\n' % comment) # The reference comments for filename, lines in self.references.items(): for line in lines: s.append('#: %s:%s\n' % (filename, line)) # The Fuzzy flag if self.fuzzy: s.append('#, fuzzy\n') # The msgid s.append('msgid "%s"\...
s.append('"%s"\n' % escape(string))
s.append('"%s"\n' % escape(string.encode(encoding)))
def to_str(self): s = [] # The comments for comment in self.comments: s.append('#%s\n' % comment) # The reference comments for filename, lines in self.references.items(): for line in lines: s.append('#: %s:%s\n' % (filename, line)) # The Fuzzy flag if self.fuzzy: s.append('#, fuzzy\n') # The msgid s.append('msgid "%s"\...
s.append('msgstr "%s"\n' % escape(self.msgstr[0]))
s.append('msgstr "%s"\n' % escape(self.msgstr[0].encode(encoding)))
def to_str(self): s = [] # The comments for comment in self.comments: s.append('#%s\n' % comment) # The reference comments for filename, lines in self.references.items(): for line in lines: s.append('#: %s:%s\n' % (filename, line)) # The Fuzzy flag if self.fuzzy: s.append('#, fuzzy\n') # The msgid s.append('msgid "%s"\...
def to_str(self, encoding=None):
def to_str(self, encoding='UTF-8'):
def to_str(self, encoding=None): messages = self.state.messages message_ids = messages.keys() message_ids.sort() messages = [ messages[x].to_str() for x in message_ids ] return '\n'.join(messages)
messages = [ messages[x].to_str() for x in message_ids ]
messages = [ messages[x].to_str(encoding) for x in message_ids ]
def to_str(self, encoding=None): messages = self.state.messages message_ids = messages.keys() message_ids.sort() messages = [ messages[x].to_str() for x in message_ids ] return '\n'.join(messages)
def is_allowed_to_register(self): return get_context().root.get_property('ikaaro:website_is_open')
def is_allowed_to_register(self, user, object): return self.get_property('ikaaro:website_is_open')
def is_allowed_to_register(self): return get_context().root.get_property('ikaaro:website_is_open')
source = root_class(username='a', password='a').resource
password = [ random.choice(string.ascii_letters + string.digits) for x in range(8) ] password = ''.join(password) source = root_class(username='admin', password=password).resource
def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the config file config = get_config() if options.root: config.set('instance', 'root', options.root) if options.port: config.set('instance', 'port', options.port) config.writ...
print 'To start the new instance type:' print ' %s start %s' % (parser.get_prog_name(), target)
print '****************************************************************' print '* Welcome to itools.cms' print '* A user with administration rights has been created for you:' print '* username: admin' print '* password: %s' % password print '*' print '* To start the new instance type:' print '* %s start %s' % (pa...
def init(parser, options, target): try: os.mkdir(target) except OSError: parser.error('can not create the instance (check permissions)') # Create the config file config = get_config() if options.root: config.set('instance', 'root', options.root) if options.port: config.set('instance', 'port', options.port) config.writ...
XXX It does not work if name is 'itools-0.7.0.pdf', because it thinks the extension is '0'.
def get_mimetype(self): """ Try to guess the mimetype for a resource, given the resource itself and its name. To guess from the name we need to extract the type extension, we use an heuristic for this task, but it needs to be improved because there are many patterns:
if len(name) > 1: if len(name) > 2: extension = name[-2] else: extension = name[-1] mimetype, encoding = mimetypes.guess_type('.%s' % extension) else: mimetype = 'application/octet-stream'
if name[-1] in i18n.languages: name = name[:-1] mimetype, encoding = mimetypes.guess_type('.'.join(name)) if mimetype is None: return 'application/octet-stream'
def get_mimetype(self): """ Try to guess the mimetype for a resource, given the resource itself and its name. To guess from the name we need to extract the type extension, we use an heuristic for this task, but it needs to be improved because there are many patterns:
raise NotImplementedError
language = os.environ.get('LANGUAGE') language = language.split('.')[0] language = language.replace('_', '-') accept_language = AcceptLanguage(language) return accept_language.select_language(languages)
def select_language(self, languages): raise NotImplementedError
handler_path = context.handler.get_abspath() method = context.method
response = context.response encoding = 'UTF-8'
def send_email(self, from_addr, to_addr, subject, body, **kw): context = get_context() handler_path = context.handler.get_abspath() method = context.method # Build the message message_pattern = u'To: %(to_addr)s\n' \ u'From: %(from_addr)s\n' \ u'Subject: %(subject)s\n' \ u'\n' \ u'%(body)s\n' message = message_pattern...
message_pattern = u'To: %(to_addr)s\n' \ u'From: %(from_addr)s\n' \ u'Subject: %(subject)s\n' \ u'\n' \ u'%(body)s\n'
message_pattern = ( u'To: %(to_addr)s\n' u'From: %(from_addr)s\n' u'Subject: %(subject)s\n' u'Content-Transfer-Encoding: 8bit\n' u'Content-Type: text/plain; charset="%(encoding)s"\n' u'\n' u'%(body)s\n')
def send_email(self, from_addr, to_addr, subject, body, **kw): context = get_context() handler_path = context.handler.get_abspath() method = context.method # Build the message message_pattern = u'To: %(to_addr)s\n' \ u'From: %(from_addr)s\n' \ u'Subject: %(subject)s\n' \ u'\n' \ u'%(body)s\n' message = message_pattern...
'body': body} message = message.encode('UTF-8')
'body': body, 'encoding': encoding} message = message.encode(encoding)
def send_email(self, from_addr, to_addr, subject, body, **kw): context = get_context() handler_path = context.handler.get_abspath() method = context.method # Build the message message_pattern = u'To: %(to_addr)s\n' \ u'From: %(from_addr)s\n' \ u'Subject: %(subject)s\n' \ u'\n' \ u'%(body)s\n' message = message_pattern...
now = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S') uri = "%s/;%s" % (handler_path , method)
def send_email(self, from_addr, to_addr, subject, body, **kw): context = get_context() handler_path = context.handler.get_abspath() method = context.method # Build the message message_pattern = u'To: %(to_addr)s\n' \ u'From: %(from_addr)s\n' \ u'Subject: %(subject)s\n' \ u'\n' \ u'%(body)s\n' message = message_pattern...
'user_theme': String(default='surf'),
'user_theme': String(default='aruni'),
def encode(cls, value): lines = [] for key, value in value.items(): prefix, local_name = key datatype = schemas.get_datatype(key) value = datatype.encode(value) qname = QName.encode(key) lines.append('\n <%s>%s</%s>' % (qname, value, qname)) return ''.join(lines) + '\n'
data.append('HTTP/1.1 %d %s' % (status_code, status_message))
data.append('HTTP/1.0 %d %s' % (status_code, status_message))
def to_str(self): state = self.state
data.append('Connection: close')
def to_str(self): state = self.state
parameters.append('; Expires=%s' % cookie.expires)
parameters.append('; expires=%s' % cookie.expires)
def to_str(self): state = self.state
parameters.append('; Domain=%s' % cookie.domain)
parameters.append('; domain=%s' % cookie.domain)
def to_str(self): state = self.state
parameters.append('; Path=%s' % cookie.path)
parameters.append('; path=%s' % cookie.path) else: parameters.append('; path=/')
def to_str(self): state = self.state
parameters.append('; Max-Age=%s' % cookie.max_age)
parameters.append('; max-Age=%s' % cookie.max_age)
def to_str(self): state = self.state
parameters.append('; Comment=%s' % cookie.comment)
parameters.append('; comment=%s' % cookie.comment)
def to_str(self): state = self.state
parameters.append('; Secure=%s' % cookie.secure)
parameters.append('; secure=%s' % cookie.secure)
def to_str(self): state = self.state
parser.StartCdataSectionHandler = self.null_handler parser.EndCdataSectionHandler = self.null_handler
def parse(self, data): self.namespaces = {}
from_handler=context.object)
from_handler=context.handler)
def __init__(self, handler, depth=None, count=None): from Folder import Folder as DatabaseFolder
def _search(self, query):
def __search(self, query):
def _search(self, query): if isinstance(query, Query.Simple): # A simple query fields = self.get_handler('fields') documents = {} field_number = fields.field_numbers[query.name] field = fields.fields[field_number] if field_number in fields.indexed_fields: tree = self.get_handler('f%d' % field_number) # XXX Analyse valu...
r1 = self._search(query.left) r2 = self._search(query.right)
r1 = self.__search(query.left) r2 = self.__search(query.right)
def _search(self, query): if isinstance(query, Query.Simple): # A simple query fields = self.get_handler('fields') documents = {} field_number = fields.field_numbers[query.name] field = fields.fields[field_number] if field_number in fields.indexed_fields: tree = self.get_handler('f%d' % field_number) # XXX Analyse valu...
def search(self, query=None, **kw):
def _search(self, query=None, **kw):
def search(self, query=None, **kw): # Build the query if it is passed through keyword parameters if query is None: for key, value in kw.items(): atom = Query.Simple(key, value) if query is None: query = atom else: query = Query.Complex(query, 'and', atom) # Check wether there is a query at all if query is None: raise V...
documents = self._search(query)
return self.__search(query) def how_many(self, query=None, **kw): """ Returns the number of documents found. """ return len(self._search(query, **kw)) def search(self, query=None, **kw): documents = self._search(query, **kw)
def search(self, query=None, **kw): # Build the query if it is passed through keyword parameters if query is None: for key, value in kw.items(): atom = Query.Simple(key, value) if query is None: query = atom else: query = Query.Complex(query, 'and', atom) # Check wether there is a query at all if query is None: raise V...
return self.get_end_tag()
return '</%s>' % self.qname
def get_end_tag_as_html(self): if self.name in empty_elements: return '' return self.get_end_tag()
self.target = target if target.endswith('/'): self.target = target[:-1]
self.target = target.rstrip('/')
def __init__(self, target, address=None, port=None): self.target = target # FIXME This is not robust, what if the target has two or more # trailing slashes. TODO "self.target" should be a Path object. if target.endswith('/'): self.target = target[:-1]
raise NotImplementedError
return None
def get_atime(self): raise NotImplementedError
raise NotImplementedError
return None
def get_ctime(self): raise NotImplementedError
head.append(self.get_content(encoding))
content = self.get_content(encoding) lines = content.splitlines() while lines and lines[0].strip() == u'': lines = lines[1:] head.append('\n'.join(lines))
def to_unicode(self, encoding='UTF-8'): head = [] head.append(u'<head>\n') head.append(u' <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=%s" />\n' % encoding) head.append(self.get_content(encoding)) head.append(u'</head>') return ''.join(head)
if expr.startswith('not '):
if expr.startswith('not') and expr[3].isspace():
def decode(data): attributes = [] for x in data.split(';'): x = x.strip().split(' ', 1) if len(x) == 1: raise STLSyntaxError, \ 'attributes expression expects two fields'
if data.startswith('not '):
if data.startswith('not') and data[3].isspace():
def decode(data): if data.startswith('not '): return NotExpression(data) return Expression(data)
frequency = IO.encode_uint32(0)
frequency = IO.encode_link(None)
def _get_free_slot(self): """ Internal method that returns a free slot. If none exists a new one is allocated.
slot_number = self.root.tree_handler._get_free_slot() subtree = self.children[prefix] = Tree(self.root, slot_number)
free_slot_n = self.root.tree_handler._get_free_slot() subtree = self.children[prefix] = Tree(self.root, free_slot_n)
def index_word(self, word, doc_number, position): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.root.tree_handler._get_free_slot() # Update data structure on memoty subtree = self.children[prefix] = Tree(self.root, sl...
base = 16 + slot_number * 16 r[base:base+4] = IO.encode_character(prefix) r[base+4:base+8] = IO.encode_link(None) r[base+8:base+12] = IO.encode_link(None)
free_slot = 16 + free_slot_n * 16 r[free_slot:free_slot+4] = IO.encode_character(prefix) r[free_slot+4:free_slot+8] = IO.encode_link(None) r[free_slot+8:free_slot+12] = IO.encode_link(None)
def index_word(self, word, doc_number, position): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.root.tree_handler._get_free_slot() # Update data structure on memoty subtree = self.children[prefix] = Tree(self.root, sl...
this_base = 16 + self.slot * 16 r[base+12:base+16] = r[this_base+8:this_base+12] r[this_base+8:this_base+12] = IO.encode_link(slot_number)
this_slot = 16 + self.slot * 16 r[free_slot+12:free_slot+16] = r[this_slot+8:this_slot+12] r[this_slot+8:this_slot+12] = IO.encode_link(free_slot_n)
def index_word(self, word, doc_number, position): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.root.tree_handler._get_free_slot() # Update data structure on memoty subtree = self.children[prefix] = Tree(self.root, sl...
fdoc_slot_n = IO.decode_link(tree_rsrc[tree_slot+4:tree_slot+8])
fdoc_slot_r = tree_rsrc[tree_slot+4:tree_slot+8] fdoc_slot_n = IO.decode_link(fdoc_slot_r)
def index_word(self, word, doc_number, position): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.root.tree_handler._get_free_slot() # Update data structure on memoty subtree = self.children[prefix] = Tree(self.root, sl...
docs_rsrc[doc_slot+8:doc_slot+12] = IO.encode_link(fdoc_slot_n)
docs_rsrc[doc_slot+8:doc_slot+12] = fdoc_slot_r
def index_word(self, word, doc_number, position): if word: prefix, suffix = word[0], word[1:] if prefix in self.children: subtree = self.children[prefix] else: # Get an empty slot slot_number = self.root.tree_handler._get_free_slot() # Update data structure on memoty subtree = self.children[prefix] = Tree(self.root, sl...
docs_slot_n = IO.decode_link(tree_rsrc[tree_slot+4:tree_slot+8])
docs_slot_r = tree_rsrc[tree_slot+4:tree_slot+8] docs_slot_n = IO.decode_link(docs_slot_r)
def unindex_word(self, word, doc_number): if word: prefix, suffix = word[0], word[1:] subtree = self.children[prefix] subtree.unindex_word(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 # Sear...
docs_rsrc[8:12] = IO.encode_link(docs_slot_n)
docs_rsrc[8:12] = docs_slot_r
def unindex_word(self, word, doc_number): if word: prefix, suffix = word[0], word[1:] subtree = self.children[prefix] subtree.unindex_word(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 # Sear...
if referrer and referrer.path[-1].param != 'login_form': return referrer
if referrer: if not referrer.path: return referrer elif referrer.path[-1].param != 'login_form': return referrer
def login(self, context, goto=None): username = context.get_form_value('username') password = context.get_form_value('password')
if isinstance(value, list) or isinstance(value, set):
if isinstance(value, (list, set, frozenset)):
def Keyword(value): if value: if isinstance(value, list) or isinstance(value, set): for x in value: yield unicode(x), 0 else: yield unicode(value), 0
bytes = resource.get_size()
bytes = vfs.get_size(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 vfs.get_names(self.uri) if not x.startswit...
root = self.get_root()
self.set_handler(name, handler) handler = self.get_handler(name) root = self.get_site_root()
def new_resource(self, context): class_id = context.get_form_value('class_id') name = context.get_form_value('name')
default_language = languages[0] kw = {} kw['dc:title'] = {default_language: context.get_form_value('dc:title')} self.set_handler(name, handler, **kw)
title = context.get_form_value('dc:title') handler.set_property('dc:title', title, languages[0])
def new_resource(self, context): class_id = context.get_form_value('class_id') name = context.get_form_value('name')
self.save()
def set_message(self, msgid, msgstr=[u''], comments=[], references={}): self._set_message(msgid, msgstr, comments, references) self.save()
self.set_changed()
def _set_message(self, msgid, msgstr=[u''], comments=[], references={}): self.set_changed() if isinstance(msgid, (str, unicode)): msgid = [msgid] if isinstance(msgstr, (str, unicode)): msgstr = [msgstr]
resource = get_resource('addressbook.xml')
resource = get_resource('addressbook_view.xml')
def view(self): # Load the STL template resource = get_resource('addressbook.xml') template = XML.Document(resource)
pass
continue
def set_user(self, email, password): user = User()
char = unichr(codepoint).encode(self.encoding) self.events.append((TEXT, char, self.getpos()[0]))
char = unichr(codepoint) try: char = char.encode(self.encoding) except UnicodeEncodeError: pass else: self.events.append((TEXT, char, self.getpos()[0]))
def handle_entityref(self, name): # XXX Copied from 'itools.xml.parser.Parser.skipped_entity_handler' if name in htmlentitydefs.name2codepoint: codepoint = htmlentitydefs.name2codepoint[name] char = unichr(codepoint).encode(self.encoding) self.events.append((TEXT, char, self.getpos()[0])) else: warnings.warn('Unknown e...
if hasattr(container, 'on_del_handler'): container.on_del_handler(segment)
def del_handler(self, path): if not isinstance(path, uri.Path): path = uri.Path(path)
cache['.metadata'] = self.build_metadata(self, **{'ikaaro:admins': (username,)})
cache['.metadata'] = self.build_metadata(self)
def new(self, username=None, password=None): # Call the parent WebSite.new(self)
metadata = self.build_metadata(users, owner=None, **{'dc:title': {'en': u'Users'}}) cache['users.metadata'] = metadata
cache['users.metadata'] = self.build_metadata(users, owner=None, **{'dc:title': {'en': u'Users'}})
def new(self, username=None, password=None): # Call the parent WebSite.new(self)
charser = charset.strip()
charset = charset.strip()
def next_entry(self): # Load the next line line_type, value = self.next_line()
charser = charset.strip()
charset = charset.strip()
def _load(self): """ A PO file is made of entries, where entries are separated by one or more blank lines. Each entry consists of a msgid and a msgstr, optionally preceded by comments; if there are comments at the end of the entry they are ignored. So, an entry looks like:
def _load(self, resource): self.documents = [ int(x[1:]) for x in resource.get_resources() if x.startswith('d') ] self.documents.sort()
def _load(self, resource): self.documents = [ int(x[1:]) for x in resource.get_resources() if x.startswith('d') ] self.documents.sort()
if self.documents: return self.documents[-1] + 1 return 0
documents = [ int(x[1:]) for x in self.resource.get_resources() if x.startswith('d') ] documents.sort() return documents[-1] + 1
def get_new_document_number(self): if self.documents: return self.documents[-1] + 1 return 0
self.documents.append(doc_number)
def index_document(self, document): # Get the document number, and name doc_number = self.get_new_document_number() doc_name = 'd%d' % doc_number
i = self.documents.index(doc_number) del self.documents[i]
def unindex_document(self, doc_number): document = self.get_handler('d%d' % doc_number) for name in document.get_resources(): if name.startswith('i'): field = document.get_handler(name) ii = self.get_handler('f' + name[1:]) for term in field.terms: ii.unindex_word(term, doc_number) # Remove the document i = self.docume...
version = "0.4.4",
version = "0.4.5",
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"
tree_file.write(''.joint([VERSION, ZERO, NULL, NULL]))
tree_file.write(''.join([VERSION, ZERO, NULL, NULL]))
def init_tree_file(self, tree_file): tree_file.write(''.joint([VERSION, ZERO, NULL, NULL]))
node.children[c] = Tree({}, {}, slot_number)
node.children[c] = _Node({}, {}, slot_number)
def index_term(self, tree_file, docs_file, word, documents): """ Indexes the given documents for the given words.
first_doc = encode_link(dosc_n_slots) docs_n_slots = docs_slots_n + 3 + frequency
first_doc = encode_link(docs_n_slots) docs_n_slots = docs_n_slots + 3 + frequency
def index_term(self, tree_file, docs_file, word, documents): """ Indexes the given documents for the given words.