bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _unindex_term(self, word, documents): """ Un-indexes the given term. The parameter 'documents' is a list with the numbers of the documents that must be un-indexed. """ if word: if self.children is None: self.load_children()
def _unindex_term(self, word, documents): """ Un-indexes the given term. The parameter 'documents' is a list with the numbers of the documents that must be un-indexed. """ if word: if self.children is None: self.load_children()
38,200
def checkid(id): """ Checks wether th id is or not a valid Zope id. If it is the id is returned, but stripped. If it is a bad id None is returned to signal the error. """ if isinstance(id, str): id = unicode(id, 'utf8') id = id.strip().translate(transmap).strip('_') # Check wether the id is empty if len(id) == 0: retu...
def checkid(id): """ Checks wether th id is or not a valid Zope id. If it is the id is returned, but stripped. If it is a bad id None is returned to signal the error. """ if isinstance(id, str): id = unicode(id, 'utf8') id = id.strip().translate(transmap).strip('_') # Check wether the id is empty if len(id) == 0: retu...
38,201
def Bool(value): yield str(int(value)), 0
def Bool(value): yield unicode(int(value)), 0
38,202
def Keyword(value): if value: yield value, 0
def Keyword(value): if value: yield unicode(value), 0
38,203
def __init__(self, query): if query: for x in query.split('&'): x = urllib.unquote_plus(x) if x: key, value = x.split('=', 1) dict.__setitem__(self, key, value)
def __init__(self, query): if query: for x in query.split('&'): x = urllib.unquote_plus(x) if x: key, value = x.split('=', 1) dict.__setitem__(self, key, value)
38,204
def resolve_pointer(uri, offset): if not uri.scheme and not uri.authority: if uri.path.is_relative(): if uri.path or str(uri) == '.': # XXX Here we loss the query and fragment. return offset.resolve(uri.path) return URI.encode(uri)
def resolve_pointer(uri, offset): if not uri.scheme and not uri.authority: if uri.path.is_relative(): if uri.path or str(uri) == '.': # XXX Here we loss the query and fragment. value = offset.resolve(uri.path) return str(value) return URI.encode(uri)
38,205
def get_form(self): return self.form
def get_form(self): return self.form
38,206
def end_commit_on_success(self): target = self.target transaction = get_transaction()
def end_commit_on_success(self): target = self.target transaction = get_transaction()
38,207
def end_commit_on_success(self): target = self.target transaction = get_transaction()
def end_commit_on_success(self): target = self.target transaction = get_transaction()
38,208
def test_get(self): handler = get_handler('../examples/hello.txt.en') self.assertEqual(handler.to_str(), 'hello world\n')
def test_get(self): handler = get_handler('hello.txt') self.assertEqual(handler.to_str(), 'hello world\n')
38,209
def test_language(self): self.assertEqual(self.var.state.records[0].language, 'de')
def test_language(self): self.assertEqual(self.var.state.records[0].language, 'de')
38,210
def test0_class_diagram_from_python(self): data = ('from A import B\n' 'class N(B):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "N" -> "A.B"\n}') self.assertEqual(expect, res)
def test0_class_diagram_from_python(self): data = ('from A import B\n' 'class N(B):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "N" -> "A.B"\n}') self.assertEqual(expect, res)
38,211
def test1_class_diagram_from_python(self): data = ( 'from A.B import C\n' 'from D import E\n' 'class M(C.D):\n' ' pass\n' 'class N(M, E.F.H):\n' ' pass\n' ) dot = Dot() handler = Python(memory.File(data)) dot.class_diagram_from_python([handler]) expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B.C.D"\n' ' "N"...
def test1_class_diagram_from_python(self): data = ('from A.B import C\n' 'from D import E\n' 'class M(C.D):\n' ' pass\n' 'class N(M, E.F.H):\n' ' pass\n' ) dot = Dot() handler = Python(memory.File(data)) dot.class_diagram_from_python([handler]) expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B.C.D"\n' ' "N" -...
38,212
def test2_class_diagram_from_python(self): data = ('from A import B\n' 'class M(B):\n' ' pass\n' 'class N(B):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B"\n' ' "N" -> "A.B"\n}') sel...
def test2_class_diagram_from_python(self): data = ('from A import B\n' 'class M(B):\n' ' pass\n' 'class N(B):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B"\n' ' "N" -> "A.B"\n}') sel...
38,213
def test4_class_diagram_from_python(self): data = ( 'from A.B import C\n' 'from D import E\n' 'class M(C.D):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B.C.D"\n}' ) self.assertEqual(e...
def test4_class_diagram_from_python(self): data = ('from A.B import C\n' 'from D import E\n' 'class M(C.D):\n' ' pass\n' ) handler = Python(memory.File(data)) dot = Dot() dot.class_diagram_from_python([handler]) res = dot.to_str() expect = ('digraph G {\n' 'rankdir=BT;\n' ' "M" -> "A.B.C.D"\n}' ) self.assertEqual(exp...
38,214
def __setattr__(self, name, value): if name == 'number' or name == 'columns': list.__setattr__(self, name, value) else: try: column = self.columns.index(name) except ValueError: message = "'%s' object has no attribute '%s'" raise AttributeError, message % (self.__class__.__name__, name)
def __setattr__(self, name, value): if name in ('number', 'columns', 'parent', 'name'): list.__setattr__(self, name, value) else: try: column = self.columns.index(name) except ValueError: message = "'%s' object has no attribute '%s'" raise AttributeError, message % (self.__class__.__name__, name)
38,215
## def _get_virtual_handler(self, segment):
##def _get_virtual_handler(self, segment): index = int(segment.name) return self.state.lines[index] def _get_virtual_handler(self, segment):
38,216
def get_handler_names(self, path='.'): container = self.get_handler(path) return container.cache.keys()
def get_handler_names(self, path='.'): container = self.get_handler(path) return container.cache.keys()
38,217
def _load_state(self, resource): self.data = resource.read()
def _load_state(self, resource): self.data = resource.read()
38,218
def index_document(self, document): # Mark as changed self.set_changed()
def index_document(self, document): # Mark as changed self.set_changed()
38,219
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...
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...
38,220
def is_translatable(self, attribute_name): # Attributes if self.name == 'img' and attribute_name == 'alt': return True if self.name == 'input' and attribute_name == 'value': if self.has_attribute(namespaces.xhtml, 'type'): return self.get_attribute(namespaces.xhtml, 'type') == 'submit' return False
def is_translatable(self, attribute_name): # Attributes if self.name == 'img' and attribute_name == 'alt': return True if self.name == 'input' and attribute_name == 'value': if self.has_attribute(Namespace.class_uri, 'type'): return self.get_attribute(Namespace.class_uri, 'type') == 'submit' return False
38,221
def lookup(namespace, name): """ Looks for a variable in a namespace (an instance, a mapping, etc..) """ if hasattr(namespace, 'stl_lookup'): return namespace.stl_lookup(name) if isinstance(namespace, dict): if name in namespace: return namespace[name] try: value = getattr(namespace, name) except AttributeError: # XX...
def lookup(namespace, name): """ Looks for a variable in a namespace (an instance, a mapping, etc..) """ if hasattr(namespace, 'stl_lookup'): return namespace.stl_lookup(name) elif isinstance(namespace, dict): if name in namespace: return namespace[name] try: value = getattr(namespace, name) except AttributeError: # X...
38,222
def lookup(namespace, name): """ Looks for a variable in a namespace (an instance, a mapping, etc..) """ if hasattr(namespace, 'stl_lookup'): return namespace.stl_lookup(name) if isinstance(namespace, dict): if name in namespace: return namespace[name] try: value = getattr(namespace, name) except AttributeError: # XX...
def lookup(namespace, name): """ Looks for a variable in a namespace (an instance, a mapping, etc..) """ if hasattr(namespace, 'stl_lookup'): return namespace.stl_lookup(name) if isinstance(namespace, dict): if name in namespace: return namespace[name] try: value = getattr(namespace, name) except AttributeError: # XX...
38,223
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 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"
38,224
def user_has_role(self, user_id, *roles): """ Return True if the given user has any of the the given roles, False otherwise. """ for role in roles: if user_id in self.get_property(rolename): return True return False
def user_has_role(self, user_id, *roles): """ Return True if the given user has any of the the given roles, False otherwise. """ for role in roles: if user_id in self.get_property(role): return True return False
38,225
def tasks_list(self, context): root = context.root
def tasks_list(self, context): root = context.root
38,226
def test_simplenorm(self): """ Test the simple path normalization:
def test_simplenorm(self): """ Test the simple path normalization:
38,227
def test_backnorm(self): """ Test the normalization 'a/../b' = 'b' """ path = uri.Path('a/b/c/../d') assert str(path) == 'a/b/d'
def test_backnorm(self): """ Test the normalization 'a/../b' = 'b' """ path = uri.Path('a/b/c/../d') assert str(path) == 'a/b/d'
38,228
def test_absnorm(self): """ Test the normalization '/..' = '/' """ path = uri.Path('/../../a/b/c') assert str(path) == '/a/b/c'
def test_absnorm(self): """ Test the normalization '/..' = '/' """ path = uri.Path('/../../a/b/c') assert str(path) == '/a/b/c'
38,229
def test_relnorm(self): """ Check that '../' = '../' """ path = uri.Path('../../a//.//b/c') assert str(path) == '../../a/b/c'
def test_relnorm(self): """ Check that '../' = '../' """ path = uri.Path('../../a//.//b/c') assert str(path) == '../../a/b/c'
38,230
def test_full(self): ref = 'http://example.com/a/b/c?query#fragment' ref = uri.Reference(ref) assert ref.scheme == 'http' assert ref.authority == 'example.com' assert ref.path == '/a/b/c' assert ref.query == 'query' assert ref.fragment == 'fragment'
def test_full(self): ref = 'http://example.com/a/b/c?query#fragment' ref = uri.Reference(ref) assert ref.scheme == 'http' assert ref.authority == 'example.com' assert ref.path == '/a/b/c' assert ref.query == 'query' assert ref.fragment == 'fragment'
38,231
def test_network(self): ref = '//example.com/a/b' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert ref.authority == 'example.com' assert ref.path == '/a/b'
def test_network(self): ref = '//example.com/a/b' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert ref.authority == 'example.com' assert ref.path == '/a/b'
38,232
def test_path(self): ref = '/a/b/c' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert bool(ref.authority) is False assert ref.path == '/a/b/c'
def test_path(self): ref = '/a/b/c' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert bool(ref.authority) is False assert ref.path == '/a/b/c'
38,233
def test_query(self): ref = '?query' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert bool(ref.authority) is False assert len(ref.path) == 0 assert ref.query == 'query'
def test_query(self): ref = '?query' ref = uri.Reference(ref) assert bool(ref.scheme) is False assert bool(ref.authority) is False assert len(ref.path) == 0 assert ref.query == 'query'
38,234
def test(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'), ('g?y#s',...
def test_standard(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'),...
38,235
def test(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'), ('g?y#s',...
def test(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'), ('g?y#s',...
38,236
def test(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'), ('g?y#s',...
def test(self): failure = 0 for reference, expected in [('g:h', 'g:h'), ('g', 'http://a/b/c/g'), ('./g', 'http://a/b/c/g'), ('g/', 'http://a/b/c/g/'), ('/g', 'http://a/g'), ('//g', 'http://g'), ('?y', 'http://a/b/c/?y'), ('g?y', 'http://a/b/c/g?y'), ('#s', 'http://a/b/c/d;p?q#s'), ('g#s', 'http://a/b/c/g#s'), ('g?y#s',...
38,237
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 = 8000 # 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...
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...
38,238
def get_handler(self, path): # Be sure path is a Path if not isinstance(path, uri.Path): path = uri.Path(path)
def get_handler(self, path): # Be sure path is a Path if not isinstance(path, uri.Path): path = uri.Path(path)
38,239
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
38,240
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
38,241
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
def _get_handler(self, segment): if self.has_resource(segment.name): resource = self.get_resource(segment.name)
38,242
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
38,243
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
38,244
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
38,245
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
def _load_state(self, resource): state = self.state state.encoding = 'UTF-8' state.document_type = None state.children = []
38,246
def to_str(self, encoding='UTF-8'): s = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
def to_str(self, encoding='UTF-8'): data = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
38,247
def to_str(self, encoding='UTF-8'): s = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
def to_str(self, encoding='UTF-8'): s = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
38,248
def to_str(self, encoding='UTF-8'): s = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
def to_str(self, encoding='UTF-8'): s = [] # The declaration if self.state.document_type is not None: s.append('<!%s>' % self.state.document_type) # The children for child in self.state.children: if isinstance(child, unicode): s.append(child.encode(encoding)) else: s.append(child.to_str(encoding)) return ''.join(s)
38,249
def decode(cls, node): schema = cls.schema property = cls() for node in node.get_elements(): name = node.name # Decode the value if name in schema: type, default = schema[name] if issubclass(type, ComplexType): value = type.decode(node) else: value = unicode(node.children) value = value.encode('utf8') try: value = type...
def decode(cls, node): schema = cls.schema property = cls() for node in node.get_elements(): name = node.name # Decode the value if name in schema: type, default = schema[name] if issubclass(type, ComplexType): value = type.decode(node) else: value = unicode(node.children) value = value.encode('utf8') try: value = type...
38,250
def commit(self, username='', note=''): if not self: return
def commit(self, username='', note=''): if not self: return
38,251
def _index_row(self, row, row_index): """Index one line""" for i, value in enumerate(row): try: if self.schema[self.columns[i]].index == True: if self.state.indexes[i] is None: self.state.indexes[i] = {} if self.state.indexes[i].has_key(value): self.state.indexes[i][value].append(row_index) else: self.state.indexes[i][...
def _index_row(self, row, row_index): """Index one line""" for i, value in enumerate(row): try: if self.schema[self.columns[i]].index == True: if self.state.indexes[i] is None: self.state.indexes[i] = {} if self.state.indexes[i].has_key(value): self.state.indexes[i][value].append(row_index) else: self.state.indexes[i][...
38,252
def fold_line(line): """ Fold the unfolded line over 75 characters. """ i = 1 lines = line.split(' ') res = ' ' + lines[0] size = len(res) while i < len(lines): # Still less than 75c if size+len(lines[i]) <= 75: res = res + ' ' + lines[i] size = size + 1 + len(lines[i]) i = i + 1 # More than 75c, insert new line else: ...
def fold_line(line): """ Fold the unfolded line over 75 characters. """ i = 1 lines = line.split(' ') res = lines[0] size = len(res) while i < len(lines): # Still less than 75c if size+len(lines[i]) <= 75: res = res + ' ' + lines[i] size = size + 1 + len(lines[i]) i = i + 1 # More than 75c, insert new line else: res = ...
38,253
def parse(cls, property, encoding='UTF-8'): """ Parse content line property splitting it into 2 parts: name | [parameters]value """ c, lexeme = property[0], '' # Test first character of name if not c.isalnum() and c != '-': raise SyntaxError, 'unexpected character (%s)' % c # Test if property contains ':' if not ':' in...
def parse(cls, property, encoding='UTF-8'): """ Parse content line property splitting it into 2 parts: name | [parameters]value """ c, lexeme = property[0], '' # Test first character of name if not c.isalnum() and c != '-': raise SyntaxError, "unexpected character '%s' (%s)" % (c, ord(c)) # Test if property contains ':...
38,254
def start_element_handler(self, name, attrs): # Parse the element name: namespace_uri, name and prefix n = name.count(' ') if n == 2: namespace_uri, name, prefix = name.split() elif n == 1: prefix = None namespace_uri, name = name.split() else: prefix = None namespace_uri = None
def start_element_handler(self, name, attrs): # Parse the element name: namespace_uri, name and prefix n = name.count(' ') if n == 2: namespace_uri, name, prefix = name.split() elif n == 1: prefix = None namespace_uri, name = name.split() else: prefix = None namespace_uri = None
38,255
def start_element_handler(self, name, attrs): # Parse the element name: namespace_uri, name and prefix n = name.count(' ') if n == 2: namespace_uri, name, prefix = name.split() elif n == 1: prefix = None namespace_uri, name = name.split() else: prefix = None namespace_uri = None
def start_element_handler(self, name, attrs): # Parse the element name: namespace_uri, name and prefix n = name.count(' ') if n == 2: namespace_uri, name, prefix = name.split() elif n == 1: prefix = None namespace_uri, name = name.split() else: prefix = None namespace_uri = None
38,256
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
38,257
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) previous_week = ";%s?date=%s" % (method, Date.encode(tmp_date)) tmp_date = c_date + timedelta(7) next_week = ";%s?date=%s" % (method, Date.encode(tm...
38,258
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
38,259
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
38,260
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
38,261
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
def add_selector_ns(cls, c_date, method, namespace): # Set header used to navigate into time # Week, current date is first showed week + 1 tmp_date = c_date - timedelta(7) current_week = cls.gettext(u'Week ') current_week = current_week + Unicode.encode(tmp_date.strftime('%U')) previous_week = ";%s?date=%s" % (method, ...
38,262
def days_of_week_ns(cls, date, num=None, ndays=7): ns_days = [] for index in range(ndays): ns = {} ns['name'] = cls.gettext(cls.days[date.weekday()]) ns['nday'] = None if num: ns['nday'] = date.day ns_days.append(ns) date = date + timedelta(1) return ns_days
def days_of_week_ns(cls, date, num=None, ndays=7, c_date=None): ns_days = [] for index in range(ndays): ns = {} ns['name'] = cls.gettext(cls.days[date.weekday()]) ns['nday'] = None if num: ns['nday'] = date.day ns_days.append(ns) date = date + timedelta(1) return ns_days
38,263
def weekly_view(self, context): context = get_context() root = context.root
def weekly_view(self, context): context = get_context() root = context.root
38,264
def __init__(self, language, lexeme=''): self.language = language self.lexeme = lexeme
def __init__(self, language, lexeme=''): self.language = language self.lexeme = lexeme
38,265
def stat_special_char(self): """ return percent of special char for specific language """ stat = {} for lang in language: n = 0 for special_char in lang[2]: n = n + self.text.count(special_char) if len(self.text) != 0: percent = (n*4000)/len(self.text) percent = min (100, percent) else: percent = 0 stat[lang[0]] = per...
def stat_special_char(self): """ return percent of special char for specific language """ stat = {} for lang in language: n = 0 for special_char in lang[2]: n = n + self.text.count(special_char) if len(self.text) != 0: percent = (n*4000)/len(self.text) percent = min (100, percent) else: percent = 0 stat[lang[0]] = per...
38,266
def stat_special_char(self): """ return percent of special char for specific language """ stat = {} for lang in language: n = 0 for special_char in lang[2]: n = n + self.text.count(special_char) if len(self.text) != 0: percent = (n*4000)/len(self.text) percent = min (100, percent) else: percent = 0 stat[lang[0]] = per...
def stat_special_char(self): """ return percent of special char for specific language """ stat = {} for lang in language: n = 0 for special_char in lang[2]: n = n + self.text.count(special_char) if len(self.text) != 0: percent = (n*4000)/len(self.text) percent = min (100, percent) else: percent = 0 stat[lang[0]] = per...
38,267
def __init__(self, id, lexeme=''): self.id = id self.lexeme = lexeme
def __init__(self, id, lexeme=''): self.id = id self.lexeme = lexeme
38,268
def __init__(self, request): self.request = request self.response = Response()
def __init__(self, request): self.request = request self.response = Response()
38,269
def __init__(self, request): self.request = request self.response = Response()
def __init__(self, request): self.request = request self.response = Response()
38,270
def get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package)
def get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package)
38,271
def get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package)
def get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package)
38,272
def normalize_path(path): """ Normalize the path (we don't use os.path because on Windows it converts forward slashes to back slashes). Examples: a//b/c : a/b/c a/./b/c : a/b/c a/b/c/../d : a/b/d /../a/b/c : /a/b/c """ if not isinstance(path, str) and not isinstance(path, unicode): raise TypeError, 'path must...
def normalize_path(path): """ Normalize the path (we don't use os.path because on Windows it converts forward slashes to back slashes). Examples: a//b/c : a/b/c a/./b/c : a/b/c a/b/c/../d : a/b/d /../a/b/c : /a/b/c """ if not isinstance(path, str) and not isinstance(path, unicode): raise TypeError, 'path must...
38,273
def normalize_path(path): """ Normalize the path (we don't use os.path because on Windows it converts forward slashes to back slashes). Examples: a//b/c : a/b/c a/./b/c : a/b/c a/b/c/../d : a/b/d /../a/b/c : /a/b/c """ if not isinstance(path, str) and not isinstance(path, unicode): raise TypeError, 'path must...
def normalize_path(path): """ Normalize the path (we don't use os.path because on Windows it converts forward slashes to back slashes). Examples: a//b/c : a/b/c a/./b/c : a/b/c a/b/c/../d : a/b/d /../a/b/c : /a/b/c """ if not isinstance(path, str) and not isinstance(path, unicode): raise TypeError, 'path must...
38,274
def __add__(self, path): if not isinstance(path, Path): path = Path(path) return self.__class__(list(self) + list(path))
def __add__(self, path): if not isinstance(path, Path): path = Path(path) return self.__class__(list(self) + list(path))
38,275
def __str__(self): return urlunsplit((self.scheme, str(self.authority), str(self.path), str(self.query), self.fragment))
def __str__(self): path = str(self.path) if path == '.': path = '' return urlunsplit((self.scheme, str(self.authority), path, str(self.query), self.fragment))
38,276
def get_resources(self, path='.'): for resource_name in self.get_resource_names(path): yield self.get_resource(resource_name)
def get_resources(self, path='.'): for resource_name in self.get_resource_names(path): yield self.get_resource(resource_name)
38,277
def to_str(self): state = self.state
def to_str(self): state = self.state
38,278
def index_document(self, document): self.set_changed() # Create the document to index doc_number = self.documents.n_documents catalog_document = Document(doc_number)
def index_document(self, document): self.set_changed() # Create the document to index doc_number = self.documents.n_documents catalog_document = Document(doc_number)
38,279
def get_ns_calendar(self, calendar, c_date, cal_fields, shown_fields, timetables, method='browse_calendar', show_conflicts=False): calendar_url = self.get_pathto(calendar) args = 'date=%s&method=%s' % (Date.encode(c_date), method) new_url = '%s/;edit_event_form?%s' % (calendar_url, args)
def get_ns_calendar(self, calendar, c_date, cal_fields, shown_fields, timetables, method='browse_calendar', show_conflicts=False): calendar_url = self.get_pathto(calendar) args = 'date=%s&method=%s' % (Date.encode(c_date), method) new_url = '%s/;edit_event_form?%s' % (calendar_url, args)
38,280
def __init__(self, request): self.request = request self.response = Response()
def __init__(self, request): self.request = request self.response = Response()
38,281
def __ne__(self, other): return str(self) != normalize_path(str(other))
def __ne__(self, other): return str(self) != normalize_path(str(other))
38,282
def __eq__(self, other): return str(self) == normalize_path(str(other))
def __eq__(self, other): return str(self) == normalize_path(str(other))
38,283
def open_tag(node): # The open tag buffer.write(u'<%s' % node.qname) # The attributes for namespace, local_name, value in node.get_attributes(): if node.is_translatable(local_name): value = value.strip() if value: value = catalog.get_msgstr(value) or value qname = node.get_attribute_qname(namespace, local_name) buffer....
def open_tag(node): # The open tag buffer.write(u'<%s' % node.qname) # The attributes for namespace, local_name, value in node.get_attributes(): if node.is_translatable(local_name): value = value.strip() if value: value = catalog.get_msgstr(value) or value qname = node.get_attribute_qname(namespace, local_name) namespa...
38,284
def setup(description='', classifiers=[]): from __init__ import __version__ try: from itools.resources import get_resource from handlers.config import Config except ImportError: # Are we trying to install itools? # XXX This is ugly, because Python does not support relative imports start_local_import() from resources im...
def setup(description='', classifiers=[]): from __init__ import __version__ try: from itools.resources import get_resource from handlers.config import Config except ImportError: # Are we trying to install itools? # XXX This is ugly, because Python does not support relative imports start_local_import() from resources im...
38,285
def _get_handler(self, segment, uri): handler_class = here.get_handler_class(uri) return handler_class(uri)
def _get_handler(self, segment, uri): handler_class = self.get_handler_class(uri) return handler_class(uri)
38,286
def redirect(self, reference, status=302): reference = self.uri.resolve2(reference) self.response.redirect(reference, status)
def redirect(self, reference, status=302): reference = self.uri.resolve(reference) self.response.redirect(reference, status)
38,287
def new(self, data=u''): self.data = data self.encoding = self.guess_encoding(data)
def new(self, data=u''): self.data = data self.encoding = self.guess_encoding(data)
38,288
def is_allowed_to_view(self, user, object): # Objects with workflow from workflow import WorkflowAware if isinstance(self, WorkflowAware): state = self.workflow_state # Anybody can see public objects if state == 'public': return True
def is_allowed_to_view(self, user, object): # Objects with workflow from workflow import WorkflowAware if isinstance(object, WorkflowAware): state = object.workflow_state # Anybody can see public objects if state == 'public': return True
38,289
def parse(data, schema=None): encoding = Text.guess_encoding(data) dialect = csv.Sniffer().sniff(data[:1000]) if schema is None: for line in csv.reader(data.splitlines(), dialect): yield [ unicode(x, encoding) for x in line ] else: for line in csv.reader(data.splitlines(), dialect): yield [ schema[i].decode(value) for ...
def parse(data, schema=None): encoding = Text.guess_encoding(data) if data: dialect = csv.Sniffer().sniff(data[:1000]) reader = csv.reader(data.splitlines(), dialect) else: reader = csv.reader(data.splitlines()) if schema is None: for line in csv.reader(data.splitlines(), dialect): yield [ unicode(x, encoding) for x ...
38,290
def parse(data, schema=None): encoding = Text.guess_encoding(data) dialect = csv.Sniffer().sniff(data[:1000]) if schema is None: for line in csv.reader(data.splitlines(), dialect): yield [ unicode(x, encoding) for x in line ] else: for line in csv.reader(data.splitlines(), dialect): yield [ schema[i].decode(value) for ...
def parse(data, schema=None): encoding = Text.guess_encoding(data) dialect = csv.Sniffer().sniff(data[:1000]) if schema is None: for line in reader: yield [ unicode(x, encoding) for x in line ] else: for line in reader: yield [ schema[i].decode(value) for i, value in enumerate(line) ]
38,291
def parse(data, schema=None): encoding = Text.guess_encoding(data) dialect = csv.Sniffer().sniff(data[:1000]) if schema is None: for line in csv.reader(data.splitlines(), dialect): yield [ unicode(x, encoding) for x in line ] else: for line in csv.reader(data.splitlines(), dialect): yield [ schema[i].decode(value) for ...
def parse(data, schema=None): encoding = Text.guess_encoding(data) dialect = csv.Sniffer().sniff(data[:1000]) if schema is None: for line in reader: yield [ unicode(x, encoding) for x in line ] else: for line in reader: yield [ schema[i].decode(value) for i, value in enumerate(line) ]
38,292
def get_subviews(self, name): views = [['browse_thumbnails', 'browse_list'], ['general_form', 'languages_form'], ['about', 'license']] for subviews in views: if name in subviews: return subviews return Group.get_subviews(self, name)
def get_subviews(self, name): views = [['browse_thumbnails', 'browse_list'], ['general_form', 'languages_form'], ['about', 'license'], ['catalog_form', 'check_groups']] for subviews in views: if name in subviews: return subviews return Group.get_subviews(self, name)
38,293
def join(self, username, password, password2, **kw): users = self.get_handler('users') error = users.new_user(username, password, password2)
defjoin(self,username,password,password2,**kw):users=self.get_handler('users')error=users.new_user(username,password,password2)
38,294
def join(self, username, password, password2, **kw): users = self.get_handler('users') error = users.new_user(username, password, password2)
def join(self, username, password, password2, **kw): users = self.get_handler('users') error = users.new_user(username, password, password2)
38,295
def update_catalog(self): # Initialize a new empty catalog t0 = time() tmp_path = tempfile.mkdtemp() tmp_folder = get_handler(tmp_path) tmp_folder.set_handler('catalog', Catalog(fields=self._catalog_fields)) tmp_folder.save_state() catalog_resource = tmp_folder.resource.get_resource('catalog') catalog = Catalog(catalog...
def update_catalog(self): # Initialize a new empty catalog t0 = time() tmp_path = tempfile.mkdtemp() tmp_folder = get_handler(tmp_path) tmp_folder.set_handler('catalog', Catalog(fields=self._catalog_fields)) tmp_folder.save_state() catalog_resource = tmp_folder.resource.get_resource('catalog') catalog = Catalog(catalog...
38,296
def to_unicode(cls, value): return unicode(value)
def to_unicode(cls, value): return unicode(value)
38,297
def get_pathto(self, path): """ If 'self' and 'path' are absolute, a relative path 'x' is returned so self.resolve(x) = path. """ if not isinstance(path, Path): path = Path(path)
def get_pathto(self, path): """ Returns the relative path from 'self' to 'path'. This operation is the complement of 'resolve2'. So, if 'x = a.get_pathto(b)', then 'b = a.resolve2(x)'. """ if not isinstance(path, Path): path = Path(path)
38,298
def get_closetag(self): if self.name in parser.empty_elements: return '' return XHTML.Element.get_closetag(self)
def get_closetag(self): if self.name in parser.empty_elements: return '' return XHTML.Element.get_closetag(self)
38,299