bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def info(self,t=None): idx=self.index(t)[0] zs =self.az[self.tinfo[idx][2]:] return self.tinfo[idx][0],self.tinfo[idx][1],zs[:find(zs,'\000')]
def info(self,t=None): idx=self.index(t)[0] zs =self.az[self.tinfo[idx][2]:] return self.tinfo[idx][0],self.tinfo[idx][1],zs[:find(zs,'\000')]
2,700
def _housekeep(self, delete_end): """ do garbage collection, bucket replentishing and notification """ data = self._data period = self._period min_spares = self._min_spare_buckets DEBUG and TLOG( '_housekeep: current slice %s' % self._getCurrentTimeslice() ) notify = {} while 1: try: k, v = self.notify_queue.get_nowait() # duplicates will be ignored notify[k] = v except Queue.Empty: break
def _housekeep(self, delete_end): """ do garbage collection, bucket replentishing and notification """ data = self._data period = self._period min_spares = self._min_spare_buckets DEBUG and TLOG( '_housekeep: current slice %s' % self._getCurrentTimeslice() ) notify = {} while 1: try: k, v = self.notify_queue.get_nowait() # duplicates will be ignored notify[k] = v except Queue.Empty: break
2,701
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
2,702
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
2,703
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
def index_html(self, REQUEST, RESPONSE): """ The default view of the contents of a File or Image.
2,704
def _compare(dt1, dt2): '''Compares the internal representation of dt1 with the representation in dt2. Allows sub-millisecond variations. Primarily for testing.''' assert dt1.millis() == dt2.millis(), \ '%s != %s' % (dt1.millis(),dt2.millis()) assert math.floor(dt1._t * 1000.0) == \ math.floor(dt2._t * 1000.0) assert math.floor(dt1._d * 86400000.0) == \ math.floor(dt2._d * 86400000.0) assert math.floor(dt1.time * 86400000.0) == \ math.floor(dt2.time * 86400000.0)
2,705
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1s = '%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone()) dt1 = DateTime(dt1s) _compare(dt, dt1)
def testConstructor3(self): '''Constructor from date/time string''' dt = DateTime() dt1s = '%d/%d/%d %d:%d:%f %s' % ( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone()) dt1 = DateTime(dt1s) _compare(dt, dt1)
2,706
def testConstructor4(self): '''Constructor from time float''' dt = DateTime() dt1 = DateTime(float(dt)) assert dt.debugCompare(dt1), (dt, dt1)
def testConstructor4(self): '''Constructor from time float''' dt = DateTime() dt1 = DateTime(float(dt)) assert dt.debugCompare(dt1), (dt, dt1)
2,707
def testConstructor6(self): '''Constructor from year and julian date''' # This test must normalize the time zone, or it *will* break when # DST changes! dt1 = DateTime(2000, 5.500000578705) dt = DateTime('2000/1/5 12:00:00.050 pm %s' % dt1.localZone()) _compare(dt, dt1)
def testConstructor6(self): '''Constructor from year and julian date''' # This test must normalize the time zone, or it *will* break when # DST changes! dt1 = DateTime(2000, 5.500000578705) dt = DateTime('2000/1/5 12:00:00.050 pm %s' % dt1.localZone()) _compare(dt, dt1)
2,708
def testConstructor7(self): '''Constructor from parts''' dt = DateTime() dt1 = DateTime( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone()) assert dt.debugCompare(dt1), (dt, dt1)
def testConstructor7(self): '''Constructor from parts''' dt = DateTime() dt1 = DateTime( dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), dt.timezone()) self.assertEqual(repr(dt),repr(dt1))
2,709
def structure(list): if not list: return [] i=0 l=len(list) r=[] while i < l: sublen=paragraphs(list,i) i=i+1 r.append((list[i-1][1],structure(list[i:i+sublen]))) i=i+sublen return r
def structure(list): if not list: return [] i=0 l=len(list) r=[] while i < l: sublen=paragraphs(list,i) i=i+1 r.append((list[i-1][1],structure(list[i:i+sublen]))) i=i+sublen return r
2,710
def ctag(s): if s is None: s='' s=regsub.gsub(strong,' <strong>\\1</strong>\\2',s) s=regsub.gsub(code,' <code>\\1</code>\\3',s) s=regsub.gsub(em,' <em>\\1</em>\\2',s) return s
def ctag(s): if s is None: s='' s=gsub(strong,'\\1<strong>\\2</strong>\\3',s) s=gsub(code, '\\1<code>\\2</code>\\3',s) s=gsub(em, '\\1<em>\\2</em>\\3',s) return s
2,711
def __str__(self):
def __str__(self):
2,712
def __str__(self):
def __str__(self):
2,713
def _str(self,structure,level):
def _str(self,structure,level):
2,714
def pre(self,structure,tagged=0):
def pre(self,structure,tagged=0):
2,715
def pre(self,structure,tagged=0):
def pre(self,structure,tagged=0):
2,716
def html_with_references(text): import regsub text = regsub.gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = regsub.gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = regsub.gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
def html_with_references(text): text = gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = regsub.gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = regsub.gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
2,717
def html_with_references(text): import regsub text = regsub.gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = regsub.gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = regsub.gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
def html_with_references(text): import regsub text = gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
2,718
def html_with_references(text): import regsub text = regsub.gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = regsub.gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = regsub.gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
def html_with_references(text): import regsub text = gsub( '[\0\n].. \[\([-_0-9_a-zA-Z]+\)\]', '\n <a name="\\1">[\\1]</a>', text) text = gsub( '\([\0- ,]\)\[\([0-9_a-zA-Z]+\)\]\([\0- ,.:]\)', '\\1<a href="#\\2">[\\2]</a>\\3', text) text = gsub( '\([\0- ]\)\([a-z]+://[^\0- ]+\)', '\\1<a href="\\2">\\2</a>', text) return HTML(text,level=1)
2,719
def main(): import sys print html_with_references(sys.stdin.read())
def main(): import sys if '-t' in sys.argv: import regex, string s=sys.stdin.read() r=regex.compile('\([\0-\n]*\n\)') if r.match(s) >= 0: s=s[len(r.group(1)):] s=str(html_with_references(s)) if s[:4]=='<h1>': t=s[4:string.find(s,'</h1>')] s='''<html><head><title>%s</title> </head><body> %s </body></html> ''' % (t,s) print s else: print html_with_references(sys.stdin.read())
2,720
def document_src(self, REQUEST, RESPONSE): """Return unprocessed document source.""" RESPONSE.setHeader('Content-Type', 'text/plain') return self.read()
def document_src(self, REQUEST=None, RESPONSE=None): """Return unprocessed document source.""" RESPONSE.setHeader('Content-Type', 'text/plain') return self.read()
2,721
def document_src(self, REQUEST, RESPONSE): """Return unprocessed document source.""" RESPONSE.setHeader('Content-Type', 'text/plain') return self.read()
def document_src(self, REQUEST, RESPONSE): """Return unprocessed document source.""" if RESPONSE is not None: RESPONSE.setHeader('Content-Type', 'text/plain') return self.read()
2,722
def _cook_check(self): if self._v_last_read and not DevelopmentMode: return __traceback_info__ = self.filename try: mtime=os.stat(self.filename)[8] except: mtime=0 if mtime == self._v_last_read: return self.pt_edit(open(self.filename), None) self._cook() if self._v_errors: LOG('PageTemplateFile', ERROR, 'Error in template', join(self._v_errors, '\n')) return self._v_last_read = mtime
def _cook_check(self): if self._v_last_read and not DevelopmentMode: return __traceback_info__ = self.filename try: mtime=os.stat(self.filename)[8] except: mtime=0 if hasattr(self, '_v_program') and mtime == self._v_last_read: return self.pt_edit(open(self.filename), None) self._cook() if self._v_errors: LOG('PageTemplateFile', ERROR, 'Error in template', join(self._v_errors, '\n')) return self._v_last_read = mtime
2,723
def tpValuesIds(self, branches, args, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): # This should build the ids of subitems which are # expandable (non-empty). Leaves should never be # in the state - it will screw the colspan counting. r=[] idattr=args['id'] try: try: items=getattr(self, branches)() except AttributeError: items=() for item in items: try: if getattr(item, branches)(): if hasattr(self, idattr): id=getattr(self, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=oid(item) else: id=pyid(item) e=tpValuesIds(item, branches, args) if e: id=[id,e] else: id=[id] r.append(id) except: pass except: pass return r
def tpValuesIds(self, branches, args, simple_type={type(''):0, type(1):0, type(1.0):0}.has_key, ): # This should build the ids of subitems which are # expandable (non-empty). Leaves should never be # in the state - it will screw the colspan counting. r=[] idattr=args['id'] try: try: items=getattr(self, branches)() except AttributeError: items=() for item in items: try: if getattr(item, branches)(): if hasattr(item, idattr): id=getattr(item, idattr) if not simple_type(type(id)): id=id() elif hasattr(item, '_p_oid'): id=oid(item) else: id=pyid(item) e=tpValuesIds(item, branches, args) if e: id=[id,e] else: id=[id] r.append(id) except: pass except: pass return r
2,724
def set_cdata_mode(self): self.interesting = interesting_cdata
cdata_endtag = None def set_cdata_mode(self, endtag=None): self.cdata_endtag = endtag self.interesting = interesting_cdata
2,725
def parse_starttag(self, i): self.__starttag_text = None endpos = self.check_for_whole_start_tag(i) if endpos < 0: return endpos rawdata = self.rawdata self.__starttag_text = rawdata[i:endpos]
def parse_starttag(self, i): self.__starttag_text = None endpos = self.check_for_whole_start_tag(i) if endpos < 0: return endpos rawdata = self.rawdata self.__starttag_text = rawdata[i:endpos]
2,726
def parse_endtag(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag" match = endendtag.search(rawdata, i+1) # > if not match: return -1 j = match.end() match = endtagfind.match(rawdata, i) # </ + tag + > if not match: self.error("bad end tag: %s" % `rawdata[i:j]`) tag = match.group(1) self.handle_endtag(tag.lower()) return j
def parse_endtag(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag" match = endendtag.search(rawdata, i+1) # > if not match: return -1 j = match.end() match = endtagfind.match(rawdata, i) # </ + tag + > if not match: self.error("bad end tag: %s" % `rawdata[i:j]`) tag = match.group(1).lower() if ( self.cdata_endtag is not None and tag != self.cdata_endtag): self.handle_data(match.group(0)) else: self.handle_endtag(tag) return j
2,727
def authenticate(self, password, request): passwrd=self._getPassword()
def authenticate(self, password, request): passwrd=self._getPassword()
2,728
def authenticate(self, password, request): passwrd=self._getPassword()
def authenticate(self, password, request): passwrd=self._getPassword()
2,729
def validate(self,request,auth='',roles=None):
def validate(self,request,auth='',roles=None):
2,730
def validate(self,request,auth='',roles=None):
def validate(self,request,auth='',roles=None):
2,731
def validate(self,request,auth='',roles=None):
def validate(self,request,auth='',roles=None):
2,732
def validate(self,request,auth='',roles=None): parent=request['PARENTS'][0] e=request.environ if e.has_key('REMOTE_USER'): name=e['REMOTE_USER'] else: for ob in self.getUsers(): domains=ob.getDomains() if domains: if ob.authenticate('', request): if ob.allowed(parent, roles): ob=ob.__of__(self) return ob nobody=self._nobody if self._isTop() and nobody.allowed(parent, roles): ob=nobody.__of__(self) return ob return None
def validate(self,request,auth='',roles=None): parent=request['PARENTS'][0] e=request.environ if e.has_key('REMOTE_USER'): name=e['REMOTE_USER'] else: for ob in self.getUsers(): domains=ob.getDomains() if domains: if ob.authenticate('', request): if ob.allowed(parent, roles): ob=ob.__of__(self) return ob nobody=self._nobody if self._isTop() and nobody.allowed(parent, roles): ob=nobody.__of__(self) return ob return None
2,733
def validate(self,request,auth='',roles=None): parent=request['PARENTS'][0] e=request.environ if e.has_key('REMOTE_USER'): name=e['REMOTE_USER'] else: for ob in self.getUsers(): domains=ob.getDomains() if domains: if ob.authenticate('', request): if ob.allowed(parent, roles): ob=ob.__of__(self) return ob nobody=self._nobody if self._isTop() and nobody.allowed(parent, roles): ob=nobody.__of__(self) return ob return None
def validate(self,request,auth='',roles=None): parent=request['PARENTS'][0] e=request.environ if e.has_key('REMOTE_USER'): name=e['REMOTE_USER'] else: for ob in self.getUsers(): domains=ob.getDomains() if domains: if ob.authenticate('', request): if ob.allowed(parent, roles): ob=ob.__of__(self) return ob nobody=self._nobody if self._isTop() and nobody.allowed(parent, roles): ob=nobody.__of__(self) return ob return None
2,734
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,735
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,736
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,737
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,738
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,739
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
2,740
def prepare(self, defaulthost=None, dnsresolver=None, module=None, env=None, portbase=None): if defaulthost: hostname = defaulthost ip = socket.gethostbyname(hostname) elif defaulthost is '': hostname = '' ip = '127.0.0.1' else: hostname, ip = get_default_host_info() if not self.host: self._set_default_host(hostname, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
def prepare(self, defaulthost='', dnsresolver=None, module=None, env=None, portbase=None): if defaulthost: hostname = defaulthost ip = socket.gethostbyname(hostname) elif defaulthost is '': hostname = '' ip = '127.0.0.1' else: hostname, ip = get_default_host_info() if not self.host: self._set_default_host(hostname, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
2,741
def prepare(self, defaulthost=None, dnsresolver=None, module=None, env=None, portbase=None): if defaulthost: hostname = defaulthost ip = socket.gethostbyname(hostname) elif defaulthost is '': hostname = '' ip = '127.0.0.1' else: hostname, ip = get_default_host_info() if not self.host: self._set_default_host(hostname, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
def prepare(self, defaulthost=None, dnsresolver=None, module=None, env=None, portbase=None): if not self.host: self._set_default_host(hostname, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
2,742
def prepare(self, defaulthost=None, dnsresolver=None, module=None, env=None, portbase=None): if defaulthost: hostname = defaulthost ip = socket.gethostbyname(hostname) elif defaulthost is '': hostname = '' ip = '127.0.0.1' else: hostname, ip = get_default_host_info() if not self.host: self._set_default_host(hostname, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
def prepare(self, defaulthost=None, dnsresolver=None, module=None, env=None, portbase=None): if defaulthost: hostname = defaulthost ip = socket.gethostbyname(hostname) elif defaulthost is '': hostname = '' ip = '127.0.0.1' else: hostname, ip = get_default_host_info() if not self.host: ip = socket.gethostbyname(defaulthost) self._set_default_host(defaulthost, ip) else: self.ip = socket.gethostbyname(self.host) self.dnsresolver = dnsresolver self.module = module self.cgienv = env if portbase and self.port is not None: self.port += portbase
2,743
def create(self): from ZServer import HTTPServer from ZServer.AccessLogger import access_logger handler = self.createHandler() handler._force_connection_close = self.force_connection_close if self.webdav_source_clients: handler.set_webdav_source_clients(self.webdav_source_clients) server = HTTPServer.zhttp_server(ip=self.host, port=self.port, resolver=self.dnsresolver, logger_object=access_logger) server.install_handler(handler) return server
def create(self): from ZServer import HTTPServer from ZServer.AccessLogger import access_logger handler = self.createHandler() handler._force_connection_close = self.force_connection_close if self.webdav_source_clients: handler.set_webdav_source_clients(self.webdav_source_clients) server = HTTPServer.zhttp_server(ip=self.ip, port=self.port, resolver=self.dnsresolver, logger_object=access_logger) server.install_handler(handler) return server
2,744
def create(self): from ZServer.AccessLogger import access_logger from ZServer.FTPServer import FTPServer return FTPServer(ip=self.host, hostname=self.host, port=self.port, module=self.module, resolver=self.dnsresolver, logger_object=access_logger)
def create(self): from ZServer.AccessLogger import access_logger from ZServer.FTPServer import FTPServer return FTPServer(ip=self.ip, hostname=self.host, port=self.port, module=self.module, resolver=self.dnsresolver, logger_object=access_logger)
2,745
def create(self): from ZServer.AccessLogger import access_logger from ZServer.PCGIServer import PCGIServer return PCGIServer(ip=self.host, port=self.port, module=self.module, resolver=self.dnsresolver, pcgi_file=self.path, logger_object=access_logger)
def create(self): from ZServer.AccessLogger import access_logger from ZServer.PCGIServer import PCGIServer return PCGIServer(ip=self.ip, port=self.port, module=self.module, resolver=self.dnsresolver, pcgi_file=self.path, logger_object=access_logger)
2,746
def create(self): from ZServer.AccessLogger import access_logger from ZServer.FCGIServer import FCGIServer return FCGIServer(ip=self.host, port=self.port, socket_file=self.path, module=self.module, resolver=self.dnsresolver, logger_object=access_logger)
def create(self): from ZServer.AccessLogger import access_logger from ZServer.FCGIServer import FCGIServer return FCGIServer(ip=self.ip, port=self.port, socket_file=self.path, module=self.module, resolver=self.dnsresolver, logger_object=access_logger)
2,747
def tables(self,*args,**kw): if self.db is None: self.open() return map(lambda name: { 'TABLE_NAME': name, 'TABLE_TYPE': 'TABLE', }, self.db.table_names())
def tables(self,*args,**kw): if self.db is None: self.open() return map( lambda name: { 'TABLE_NAME': name, 'TABLE_TYPE': 'TABLE', }, self.db.table_names())
2,748
def tables(self,*args,**kw): if self.db is None: self.open() return map(lambda name: { 'TABLE_NAME': name, 'TABLE_TYPE': 'TABLE', }, self.db.table_names())
def tables(self,*args,**kw): if self.db is None: self.open() return map(lambda name: { 'TABLE_NAME': name, 'TABLE_TYPE': 'TABLE', }, self.db.table_names())
2,749
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """A slightly modified version of zope.tales.expressions.simpleTraverse that interacts correctly with objects requiring.""" request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
2,750
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
2,751
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
2,752
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """ a slightly modified version of zope.tales.expressions.simpleTraverse() that interacts correctly with objects implementing bobo_traverse(). """ request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_items.pop() if ITraversable.providedBy(object): try: object = object.restrictedTraverse(name) except (NotFound, Unauthorized), e: # OFS.Traversable.restrictedTraverse spits out # NotFound or Unauthorized (the Zope 2 version) which # Zope 3's ZPT implementation obviously doesn't know # as an exception indicating failed traversal. # Perhaps Zope 2's NotFound should be made to extend # LookupError at some point (or it should just be # replaced with Zope 3's version). For the time # being, however, we simply converting NotFounds into # LookupErrors: raise LookupError(*e.args) else: object = traversePathElement(object, name, path_items, request=request) return object
2,753
def translate(self, msgid, domain, mapping=None, context=None, target_language=None, default=None): if context is None: context = self.contexts.get('context') return getGlobalTranslationService().translate( domain, msgid, mapping=mapping, context=context, default=default, target_language=target_language)
def translate(self, msgid, domain=None, mapping=None, default=None): context = self.contexts.get('context') return getGlobalTranslationService().translate( domain, msgid, mapping=mapping, context=context, default=default, target_language=target_language)
2,754
def translate(self, msgid, domain, mapping=None, context=None, target_language=None, default=None): if context is None: context = self.contexts.get('context') return getGlobalTranslationService().translate( domain, msgid, mapping=mapping, context=context, default=default, target_language=target_language)
def translate(self, msgid, domain, mapping=None, context=None, target_language=None, default=None): if context is None: context = self.contexts.get('context') return getGlobalTranslationService().translate( domain, msgid, mapping=mapping, context=context, default=default, target_language=target_language)
2,755
def unindex_object(self, documentId): """ Unindex the object with integer id 'documentId' and don't raise an exception if we fail """
def unindex_object(self, documentId): """ Unindex the object with integer id 'documentId' and don't raise an exception if we fail """
2,756
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline().strip() while line != "------": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
2,757
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline().strip() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline().strip() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline().strip() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline().strip() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline().strip() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
2,758
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
2,759
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline().strip() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline().strip() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline().strip() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline().strip() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline().strip() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
2,760
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------\n": self.fail("couldn't find end of traceback") if line == last: break
def verifyEntry(self, f, time=None, subsys=None, severity=None, summary=None, detail=None, error=None): # skip to the beginning of next entry line = f.readline() while line != "------\n": if not line: self.fail("can't find entry in log file") line = f.readline() line = f.readline().strip() _time, rest = line.split(" ", 1) if time is not None: self.assertEqual(_time, time) if subsys is not None: self.assert_(rest.find(subsys) != -1, "subsystem mismatch") if severity is not None and severity >= self._severity: s = severity_string[severity] self.assert_(rest.find(s) != -1, "severity mismatch") if summary is not None: self.assert_(rest.find(summary) != -1, "summary mismatch") if detail is not None: line = f.readline() self.assert_(line.find(detail) != -1, "missing detail") if error is not None: line = f.readline() self.assert_(line.startswith('Traceback'), "missing traceback") last = "%s: %s\n" % (error[0], error[1]) if last.startswith("exceptions."): last = last[len("exceptions."):] while 1: line = f.readline() if not line: self.fail("couldn't find end of traceback") if line == "------": self.fail("couldn't find end of traceback") if line == last: break
2,761
def _shared_roles(self, parent): r=[] while 1: if hasattr(parent, 'aq_parent'): while hasattr(parent.aq_self,'aq_self'): parent=parent.aq_self parent=parent.aq_parent else: return r roles=parent.__roles__ if roles is None: return 'Anonymous', if 'Shared' in roles: roles=list(roles) roles.remove('Shared') r=r+roles else: try: return r+list(roles) except: return r
def _shared_roles(self, parent): r=[] while 1: if hasattr(parent, 'aq_parent'): while hasattr(parent.aq_self,'aq_self'): parent=parent.aq_self parent=parent.aq_parent else: return r roles=parent.__roles__ if roles is None: return 'Anonymous', if 'Shared' in roles: roles=list(roles) roles.remove('Shared') r=r+roles else: try: return r+list(roles) except: return r
2,762
def allowed(self,parent,roles=None):
def allowed(self,parent,roles=None):
2,763
def checkSimpleTransactionalUndo(self): oid = self._storage.new_oid() revid = self._dostore(oid, data=23) revid = self._dostore(oid, revid=revid, data=24) revid = self._dostore(oid, revid=revid, data=25) # Now start an undo transaction self._storage.tpc_begin(self._transaction) oids = self._storage.transactionalUndo(revid, self._transaction) self._storage.tpc_vote(self._transaction) self._storage.tpc_finish(self._transaction) assert len(oids) == 1 assert oids[0] == oid data, revid = self._storage.load(oid, '') assert pickle.loads(data) == 24 # Do another one self._storage.tpc_begin(self._transaction) oids = self._storage.transactionalUndo(revid, self._transaction) self._storage.tpc_vote(self._transaction) self._storage.tpc_finish(self._transaction) assert len(oids) == 1 assert oids[0] == oid data, revid = self._storage.load(oid, '') assert pickle.loads(data) == 23 # Can't undo the first record self._storage.tpc_begin(self._transaction) self.assertRaises(POSException.UndoError, self._storage.transactionalUndo, revid, self._transaction) self._storage.tpc_abort(self._transaction)
def checkSimpleTransactionalUndo(self): oid = self._storage.new_oid() revid = self._dostore(oid, data=23) revid = self._dostore(oid, revid=revid, data=24) revid = self._dostore(oid, revid=revid, data=25) # Now start an undo transaction self._storage.tpc_begin(self._transaction) oids = self._storage.transactionalUndo(revid, self._transaction) self._storage.tpc_vote(self._transaction) self._storage.tpc_finish(self._transaction) assert len(oids) == 1 assert oids[0] == oid data, revid = self._storage.load(oid, '') assert pickle.loads(data) == 24 # Do another one self._storage.tpc_begin(self._transaction) oids = self._storage.transactionalUndo(revid, self._transaction) self._storage.tpc_vote(self._transaction) self._storage.tpc_finish(self._transaction) assert len(oids) == 1 assert oids[0] == oid data, revid = self._storage.load(oid, '') assert pickle.loads(data) == 23 # Can't undo the first record self._storage.tpc_begin(self._transaction) self.assertRaises(POSException.UndoError, self._storage.transactionalUndo, revid, self._transaction) self._storage.tpc_abort(self._transaction)
2,764
def connect(self,s):
def connect(self,s):
2,765
def manage_addLexicon(self, id, title='', elements=[], REQUEST=None): """Add ZCTextIndex Lexicon""" pipeline = [] for el_record in elements: if not hasattr(el_record, 'name'): continue # Skip over records that only specify element group element = element_factory.instantiate(el_record.group, el_record.name) if element is not None: if el_record.group == 'Word Splitter': # I don't like hardcoding this, but its a simple solution # to get the splitter element first in the pipeline pipeline.insert(0, element) else: pipeline.append(element) lexicon = PLexicon(id, title, *pipeline) self._setObject(id, lexicon) if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1)
def manage_addLexicon(self, id, title='', elements=[], REQUEST=None): """Add ZCTextIndex Lexicon""" pipeline = [] for el_record in elements: if not hasattr(el_record, 'name'): continue # Skip over records that only specify element group element = element_factory.instantiate(el_record.group, el_record.name) if element is not None: if el_record.group == 'Word Splitter': # I don't like hardcoding this, but its a simple solution # to get the splitter element first in the pipeline pipeline.insert(0, element) else: pipeline.append(element) lexicon = PLexicon(id, title, *pipeline) self._setObject(id, lexicon) if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1)
2,766
def getPipelineNames(self): """Return list of names of pipeline element classes""" return [element.__class__.__name__ for element in self._pipeline]
def _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) getPipelineNames(self): _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) """Return _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) list _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) of _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) names _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) of _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) pipeline _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) element _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) classes""" _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) return _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) [element.__class__.__name__ _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) for _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) element _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) in _queryLexicon = DTMLFile('dtml/queryLexicon', globals()) def queryLexicon(self, REQUEST, words=None, page=0, rows=20, cols=4): """Lexicon browser/query user interface """ if words: wids = [] for word in words: wids.extend(self.globToWordIds(word)) words = [self.get_word(wid) for wid in wids] else: words = self.words() word_count = len(words) rows = max(min(rows, 500),1) cols = max(min(cols, 12), 1) page_count = word_count / (rows * cols) + \ (word_count % (rows * cols) > 0) page = max(min(page, page_count - 1), 0) start = rows * cols * page end = min(rows * cols * (page + 1), word_count) if word_count: words = list(words[start:end]) else: words = [] columns = [] i = 0 while i < len(words): columns.append(words[i:i + rows]) i += rows return self._queryLexicon(self, REQUEST, page=page, rows=rows, cols=cols, start_word=start+1, end_word=end, word_count=word_count, page_count=page_count, page_columns=columns) self._pipeline]
2,767
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} ind = [] # structure based on indention levels top = -1 # which header are we under numbers = [0] # Which levels have paragraphs struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) current_indent = indention(paragraphs[0]) levels[0] = current_indent for indent,paragraph in ind : if indent == 0: struct.append([paragraph,[]]) current_level = 0 current_indent = 0 numbers = [0] levels = {0:0} top = top + 1 elif indent == current_indent: run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) elif indent > current_indent: current_level = current_level + 1 current_indent = indent levels[current_level] = indent run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) levels[current_level] = indent elif indent < current_indent: l = parent_level(levels,current_level) if indent > 0 and indent < levels[0]: levels[0] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} ind = [] # structure based on indention levels top = -1 # which header are we under numbers = [0] # Which levels have paragraphs struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) current_indent = indention(paragraphs[0]) levels[0] = current_indent for indent,paragraph in ind : if indent == 0: struct.append([paragraph,[]]) current_level = 0 current_indent = 0 numbers = [0] levels = {0:0} top = top + 1 elif indent == current_indent: run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) elif indent > current_indent: current_level = current_level + 1 current_indent = indent levels[current_level] = indent run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) levels[current_level] = indent elif indent < current_indent: l = parent_level(levels,current_level) if indent > 0 and indent < levels[0]: levels[0] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) return struct
2,768
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} ind = [] # structure based on indention levels top = -1 # which header are we under numbers = [0] # Which levels have paragraphs struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) current_indent = indention(paragraphs[0]) levels[0] = current_indent for indent,paragraph in ind : if indent == 0: struct.append([paragraph,[]]) current_level = 0 current_indent = 0 numbers = [0] levels = {0:0} top = top + 1 elif indent == current_indent: run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) elif indent > current_indent: current_level = current_level + 1 current_indent = indent levels[current_level] = indent run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) levels[current_level] = indent elif indent < current_indent: l = parent_level(levels,current_level) if indent > 0 and indent < levels[0]: levels[0] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} ind = [] # structure based on indention levels top = -1 # which header are we under numbers = [0] # Which levels have paragraphs struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) current_indent = indention(paragraphs[0]) levels[0] = current_indent for indent,paragraph in ind : if indent == 0: struct.append([paragraph,[]]) current_level = 0 current_indent = 0 numbers = [0] levels = {0:0} top = top + 1 elif indent == current_indent: run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) elif indent > current_indent: current_level = current_level + 1 current_indent = indent levels[current_level] = indent run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) levels[current_level] = indent elif indent < current_indent: l = parent_level(levels,current_level) if indent > 0 and indent < levels[0]: levels[0] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) return struct
2,769
def add(self, report_id, report_title, report_style, input_id, input_title, queries=[], REQUEST=None): 'add a report' if not queries: raise ValueError, ( 'No <em>searchable objects</em> were selected') if not report_id: raise ValueError, ( 'No <em>report id</em> were specified') if input_title and not input_id: raise ValueError, ( 'No <em>input id</em> were specified') qs=map(lambda q, self=self: _getquery(self, q), queries) for q in qs: id=q.id arguments={} for name, arg in q._searchable_arguments().items(): arguments["%s/%s" % (id,name)]=arg if q._searchable_result_columns() is None: raise 'Unusable Searchable Error',( """The input searchable object, <em>%s</em>, has not been tested. Until it has been tested, it\'s outpuit schema is unknown, and a report cannot be generated. Before creating a report from this query, you must try out the query. To try out the query, <a href="%s">click hear</a>. """ % (q.title_and_id(), q.id)) if input_id: self.manage_addDocument( input_id,input_title, default_input_form(arguments, report_id)) self.manage_addDocument( report_id,report_title, ('<!--#var standard_html_header-->\n%s\n' '<!--#var standard_html_footer-->' % join(map(lambda q, report_style=report_style: custom_default_report(q.id, q, no_table=report_style), qs), '\n<hr>\n'))) if REQUEST: return self.manage_main(self,REQUEST)
def add(self, report_id, report_title, report_style, input_id, input_title, queries=[], REQUEST=None): 'add a report' if not queries: raise ValueError, ( 'No <em>searchable objects</em> were selected') if not report_id: raise ValueError, ( 'No <em>report id</em> were specified') if input_title and not input_id: raise ValueError, ( 'No <em>input id</em> were specified') qs=map(lambda q, self=self: _getquery(self, q), queries) for q in qs: id=q.id if input_id: for name, arg in q._searchable_arguments().items(): if len(qs) > 1: key="%s/%s" % (id,name) else: key=name arguments[key]=arg keys.append(key) if q._searchable_result_columns() is None: raise 'Unusable Searchable Error',( """The input searchable object, <em>%s</em>, has not been tested. Until it has been tested, it\'s outpuit schema is unknown, and a report cannot be generated. Before creating a report from this query, you must try out the query. To try out the query, <a href="%s">click hear</a>. """ % (q.title_and_id(), q.id)) if input_id: self.manage_addDocument( input_id,input_title, default_input_form(arguments, report_id)) self.manage_addDocument( report_id,report_title, ('<!--#var standard_html_header-->\n%s\n' '<!--#var standard_html_footer-->' % join(map(lambda q, report_style=report_style: custom_default_report(q.id, q, no_table=report_style), qs), '\n<hr>\n'))) if REQUEST: return self.manage_main(self,REQUEST)
2,770
def add(self, report_id, report_title, report_style, input_id, input_title, queries=[], REQUEST=None): 'add a report' if not queries: raise ValueError, ( 'No <em>searchable objects</em> were selected') if not report_id: raise ValueError, ( 'No <em>report id</em> were specified') if input_title and not input_id: raise ValueError, ( 'No <em>input id</em> were specified') qs=map(lambda q, self=self: _getquery(self, q), queries) for q in qs: id=q.id arguments={} for name, arg in q._searchable_arguments().items(): arguments["%s/%s" % (id,name)]=arg if q._searchable_result_columns() is None: raise 'Unusable Searchable Error',( """The input searchable object, <em>%s</em>, has not been tested. Until it has been tested, it\'s outpuit schema is unknown, and a report cannot be generated. Before creating a report from this query, you must try out the query. To try out the query, <a href="%s">click hear</a>. """ % (q.title_and_id(), q.id)) if input_id: self.manage_addDocument( input_id,input_title, default_input_form(arguments, report_id)) self.manage_addDocument( report_id,report_title, ('<!--#var standard_html_header-->\n%s\n' '<!--#var standard_html_footer-->' % join(map(lambda q, report_style=report_style: custom_default_report(q.id, q, no_table=report_style), qs), '\n<hr>\n'))) if REQUEST: return self.manage_main(self,REQUEST)
def add(self, report_id, report_title, report_style, input_id, input_title, queries=[], REQUEST=None): 'add a report' if not queries: raise ValueError, ( 'No <em>searchable objects</em> were selected') if not report_id: raise ValueError, ( 'No <em>report id</em> were specified') if input_title and not input_id: raise ValueError, ( 'No <em>input id</em> were specified') qs=map(lambda q, self=self: _getquery(self, q), queries) for q in qs: id=q.id arguments={} for name, arg in q._searchable_arguments().items(): arguments["%s/%s" % (id,name)]=arg if q._searchable_result_columns() is None: raise 'Unusable Searchable Error',( """The input searchable object, <em>%s</em>, has not been tested. Until it has been tested, it\'s outpuit schema is unknown, and a report cannot be generated. Before creating a report from this query, you must try out the query. To try out the query, <a href="%s">click hear</a>. """ % (q.title_and_id(), id)) if input_id: self.manage_addDocument( input_id,input_title, default_input_form(arguments, report_id)) self.manage_addDocument( report_id,report_title, ('<!--#var standard_html_header-->\n%s\n' '<!--#var standard_html_footer-->' % join(map(lambda q, report_style=report_style: custom_default_report(q.id, q, no_table=report_style), qs), '\n<hr>\n'))) if REQUEST: return self.manage_main(self,REQUEST)
2,771
def default_input_form(arguments,action='query', tabs=''): if arguments: items=arguments.items() items.sort() return ( "%s\n%s%s" % ( '<!--#var standard_html_header-->\n%s\n' '<form action="%s" method="get">\n' '<h2><!--#var document_title--></h2>\n' 'Enter query parameters:<br>' '<table>\n' % (tabs,action), join( map( lambda a: ('<tr>\t<th>%s</th>\n' '\t<td><input name="%s"\n' '\t width=30 value="%s">' '</td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<!--#if HTTP_REFERER-->\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<!--#var HTTP_REFERER-->">\n' '<!--#/if HTTP_REFERER-->\n' '</td></tr>\n</table>\n</form>\n' '<!--#var standard_html_footer-->\n' ) ) else: return ( '<!--#var standard_html_header-->\n%s\n' '<form action="%s" method="get">\n' '<h2><!--#var document_title--></h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<!--#if HTTP_REFERER-->\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<!--#var HTTP_REFERER-->">\n' '<!--#/if HTTP_REFERER-->\n' '</td></tr>\n</table>\n</form>\n' '<!--#var standard_html_footer-->\n' % (tabs, action) )
def default_input_form(arguments,action='query', tabs=''): if arguments: items=arguments.items() return ( "%s\n%s%s" % ( '<!--#var standard_html_header-->\n%s\n' '<form action="%s" method="get">\n' '<h2><!--#var document_title--></h2>\n' 'Enter query parameters:<br>' '<table>\n' % (tabs,action), join( map( lambda a: ('<tr>\t<th>%s</th>\n' '\t<td><input name="%s"\n' '\t width=30 value="%s">' '</td></tr>' % (nicify(a[0]), ( a[1].has_key('type') and ("%s:%s" % (a[0],a[1]['type'])) or a[0] ), a[1].has_key('default') and a[1]['default'] or '' )) , items ), '\n'), '\n<tr><td colspan=2 align=center>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<!--#if HTTP_REFERER-->\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<!--#var HTTP_REFERER-->">\n' '<!--#/if HTTP_REFERER-->\n' '</td></tr>\n</table>\n</form>\n' '<!--#var standard_html_footer-->\n' ) ) else: return ( '<!--#var standard_html_header-->\n%s\n' '<form action="%s" method="get">\n' '<h2><!--#var document_title--></h2>\n' 'This query requires no input.<p>\n' '<input type="SUBMIT" name="SUBMIT" value="Submit Query">\n' '<!--#if HTTP_REFERER-->\n' ' <input type="SUBMIT" name="SUBMIT" value="Cancel">\n' ' <INPUT NAME="CANCEL_ACTION" TYPE="HIDDEN"\n' ' VALUE="<!--#var HTTP_REFERER-->">\n' '<!--#/if HTTP_REFERER-->\n' '</td></tr>\n</table>\n</form>\n' '<!--#var standard_html_footer-->\n' % (tabs, action) )
2,772
def authenticate(self, password, request): passwrd=self._getPassword()
defif not result: LOG('Zope', WARNING, 'invalid password for user %s' % self.getUserName()) authenticate(self,if not result: LOG('Zope', WARNING, 'invalid password for user %s' % self.getUserName()) password,if not result: LOG('Zope', WARNING, 'invalid password for user %s' % self.getUserName()) request):if not result: LOG('Zope', WARNING, 'invalid password for user %s' % self.getUserName()) passwrd=self._getPassword()
2,773
def authenticate(self, password, request): passwrd=self._getPassword()
def authenticate(self, password, request): passwrd=self._getPassword()
2,774
def index_object(self, i, obj, tupleType=type(()), dictType=type({}), callable=callable): """Recompute index data for data with ids >= start. if 'obj' is passed in, it is indexed instead of _data[i]"""
def index_object(self, i, obj, tupleType=type(()), dictType=type({}), callable=callable): """Recompute index data for data with ids >= start. if 'obj' is passed in, it is indexed instead of _data[i]"""
2,775
def index_object(self, i, obj, tupleType=type(()), dictType=type({}), callable=callable): """Recompute index data for data with ids >= start. if 'obj' is passed in, it is indexed instead of _data[i]"""
def index_object(self, i, obj, tupleType=type(()), dictType=type({}), callable=callable): """Recompute index data for data with ids >= start. if 'obj' is passed in, it is indexed instead of _data[i]"""
2,776
def __init__(self,file,brains=NoBrains, parent=None, zbrains=None):
def __init__(self,file,brains=NoBrains, parent=None, zbrains=None):
2,777
def aq_base(ob, hasattr=hasattr): # Return the aq_base of an object. if hasattr(ob, 'aq_base'): return ob.aq_base return ob
def aq_base(ob, getattr=getattr): # Return the aq_base of an object. if hasattr(ob, 'aq_base'): return ob.aq_base return ob
2,778
def aq_base(ob, hasattr=hasattr): # Return the aq_base of an object. if hasattr(ob, 'aq_base'): return ob.aq_base return ob
def aq_base(ob, hasattr=hasattr): # Return the aq_base of an object. return getattr(ob, 'aq_base', ob)
2,779
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(parent, absId): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(parent, absId): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
2,780
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(parent, absId): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
2,781
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(parent, absId): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
def is_acquired(ob, hasattr=hasattr, aq_base=aq_base, absattr=absattr): # Return true if this object is not a direct # subobject of its aq_parent object. if not hasattr(ob, 'aq_parent'): return 0 parent = aq_base(ob.aq_parent) absId = absattr(ob.id) if hasattr(parent,'_objects'): if absId+' ' in parent.objectIds(): return 0 if hasattr(parent, absId): return 0 if hasattr(aq_base(ob), 'isTopLevelPrincipiaApplicationObject') and \ ob.isTopLevelPrincipiaApplicationObject: return 0 return 1
2,782
def indention(str): """ Convert all tabs to the appropriate number of spaces. Find the number of leading spaces. If none, return 0 """ if str == '\n': return -1 #str = expandtabs(str) # covert tabs into spaces front = re.compile('( *)') m = front.match(str) if m: start,end = m.span() # find number of leading spaces return end-start else: return 0 # no leading spaces
defindention(str):"""Convertalltabstotheappropriatenumberofspaces.Findthenumberofleadingspaces.Ifnone,return0"""ifstr=='\n':return-1#str=expandtabs(str)#coverttabsintospacesfront=re.compile('(*)')m=front.match(str)ifm:start,end=m.span()#findnumberofleadingspacesreturnend-startelse:return0#noleadingspaces
2,783
def runner(struct,top,level,numbers): """ returns run which is a pointer to struct to be appended to """ i = 3 run = struct[top][1] if level == 0: return struct if level == 1: return run if level == 2: a = numbers[level-2] return run[a-1][1] a = numbers[level-2] run = run[a-1][1] while i <= level: a = numbers[i-2] run = run[a-1][1] i = i + 1 return run
def runner(struct,top,level,numbers): """ returns run which is a pointer to struct to be appended to """ i = 3 run = struct[top][1] if level == 0: return struct if level == 1: return run if level == 2: a = numbers[level-2] return run[a-1][1] a = numbers[level-2] run = run[a-1][1] while i <= level: a = numbers[i-2] run = run[a-1][1] i = i + 1 return run
2,784
def split_paragraphs(paragraphs): """ each paragraph is denoted by the end of a line and a blank line before the beginning of a new paragraph """ tmp = '' par = re.compile('\n[ ]*\n') if type(paragraphs).__name__ == "list": for paragraph in paragraphs: tmp = tmp + expandtabs(paragraph) paragraphs = par.split(tmp) elif type(paragraphs).__name__ == "string": paragraphs = par.split(expandtabs(paragraphs)) else: print "paragraphs in unacceptable format, must be string or list" return [] for i in range(len(paragraphs)): paragraphs[i] = paragraphs[i] + '\n\n' return paragraphs
defsplit_paragraphs(paragraphs):"""eachparagraphisdenotedbytheendofalineandablanklinebeforethebeginningofanewparagraph"""tmp=''par=re.compile('\n[]*\n')iftype(paragraphs).__name__=="list":forparagraphinparagraphs:tmp=tmp+expandtabs(paragraph)paragraphs=par.split(tmp)eliftype(paragraphs).__name__=="string":paragraphs=par.split(expandtabs(paragraphs))else:print"paragraphsinunacceptableformat,mustbestringorlist"return[]foriinrange(len(paragraphs)):paragraphs[i]=paragraphs[i]+'\n\n'returnparagraphs
2,785
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,786
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = [0] # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,787
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,788
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,789
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,790
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent == 0: struct.append([paragraph,[]]) current_level = 0 current_indent = 0 numbers = [0] levels = {0:0} top = top + 1 elif indent == current_indent: run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) elif indent > current_indent: current_level = current_level + 1 current_indent = indent levels[current_level] = indent run,numbers = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) levels[current_level] = indent elif indent < current_indent: l = parent_level(levels,current_level) if indent > 0 and indent < levels[0]: levels[0] = indent current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
2,791
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif (indent == current_indent): if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent if not numbers.has_key(current_level-1): numbers[current_level-1] = 0 run = runner(struct,top,current_level,numbers) run.append([paragraph,[]]) numbers[current_level-1] = numbers[current_level-1] + 1 return struct
def StructuredText(paragraphs): """ StructuredText accepts paragraphs, which is a list of lines to be parsed. StructuredText creates a structure which mimics the structure of the paragraphs. Structure => [raw_paragraph,parsed_paragraph,[sub-paragraphs]] """ current_level = 0 current_indent = 0 levels = {0:0} # what level ind = [] # structure based on indention levels top = -1 # which header are we under numbers = {0:0} # how many sub-paragraphs already at a level struct = [] # the structure to be returned paragraphs = split_paragraphs(paragraphs) if not paragraphs: result = ["",[]] return result for paragraph in paragraphs: if paragraph == '\n': ind.append([-1, paragraph]) else : ind.append([indention(paragraph), strip(paragraph)+"\n"]) for indent,paragraph in ind : if indent > -1: if indent == 0: """ a new top header, start over, everything underneath is a sub-paragraph """ current_level = 0 current_indent = 0 top = top + 1 levels = {0:0} numbers = {0:0} struct.append([paragraph,[]]) elif indent > current_indent: current_indent = indent current_level = current_level + 1 levels[current_indent] = current_level run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) elif (indent == current_indent):run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) elif indent < current_indent : current_level = find_level(indent,levels) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif find_level(levels,indent) != -1: current_level = find_level(levels,indent) current_indent = indent run,numbers = runner(struct,top,current_level,numbers) elif levels[current_level] > indent and levels[l] < indent: levels[current_level] = indent current_indent = indent run,numbers = runner(struct,top,current_level,numbers) current_level = l else: tmp = {} for i in range(current_level): if indent > levels[i]: tmp[i] = levels[i] elif indent == levels[i]: current_level = i current_indent = indent run,numbers = runner(struct,top,current_level,numbers) levels = tmp run.append([paragraph,[]]) return struct
2,792
def __init__(self,str=''): self.expr = re.compile('\"[ a-zA-Z0-9.:/;,]+\":[a-zA-Z0-9.:/;,]+(?=(\s+|\.|\!|\?))').search self.str = [str] self.typ = "href1"
def __init__(self,str=''): self.expr = re.compile('\"[ a-zA-Z0-9.:/;,\n]+\":[a-zA-Z0-9.:/;,\n]+(?=(\s+|\.|\!|\?))').search self.str = [str] self.typ = "href1"
2,793
def span(self): return self.start,self.end
defspan(self):returnself.start,self.end
2,794
def _supports(self, ob): try: ob[0] except TypeError: return 0 except: pass return 1
def _supports(self, ob): try: ob[0] except (TypeError, AttributeError): return 0 except: pass return 1
2,795
def import_product(product_dir, product_name, raise_exc=0, log_exc=1): path_join=os.path.join isdir=os.path.isdir exists=os.path.exists _st=type('') global_dict=globals() silly=('__doc__',) modules=sys.modules have_module=modules.has_key if 1: # Preserve indentation for diff :-) try: package_dir=path_join(product_dir, product_name) if not isdir(package_dir): return if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): if not exists(path_join(package_dir, '__init__.pyo')): return pname="Products.%s" % product_name try: product=__import__(pname, global_dict, global_dict, silly) if hasattr(product, '__module_aliases__'): for k, v in product.__module_aliases__: if not have_module(k): if type(v) is _st and have_module(v): v=modules[v] modules[k]=v except: exc = sys.exc_info() if log_exc: LOG('Zope', ERROR, 'Could not import %s' % pname, error=exc) f=StringIO() traceback.print_exc(100,f) f=f.getvalue() try: modules[pname].__import_error__=f except: pass if raise_exc: raise exc[0], exc[1], exc[2] finally: exc = None
def import_product(product_dir, product_name, raise_exc=0, log_exc=1): path_join=os.path.join isdir=os.path.isdir exists=os.path.exists _st=type('') global_dict=globals() silly=('__doc__',) modules=sys.modules have_module=modules.has_key if 1: # Preserve indentation for diff :-) try: package_dir=path_join(product_dir, product_name) if not isdir(package_dir): return if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): if not exists(path_join(package_dir, '__init__.pyo')): return pname="Products.%s" % product_name try: product=__import__(pname, global_dict, global_dict, silly) if hasattr(product, '__module_aliases__'): for k, v in product.__module_aliases__: if not have_module(k): if type(v) is _st and have_module(v): v=modules[v] modules[k]=v except: exc = sys.exc_info() if log_exc: LOG('Zope', ERROR, 'Could not import %s' % pname, error=exc) f=StringIO() traceback.print_exc(100,f) f=f.getvalue() try: modules[pname].__import_error__=f except: pass if raise_exc: raise exc[0], exc[1], exc[2] finally: exc = None
2,796
def install_product(app, product_dir, product_name, meta_types, folder_permissions, raise_exc=0, log_exc=1): path_join=os.path.join isdir=os.path.isdir exists=os.path.exists DictType=type({}) global_dict=globals() silly=('__doc__',) if 1: # Preserve indentation for diff :-) package_dir=path_join(product_dir, product_name) __traceback_info__=product_name if not isdir(package_dir): return if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): if not exists(path_join(package_dir, '__init__.pyo')): return try: product=__import__("Products.%s" % product_name, global_dict, global_dict, silly) # Install items into the misc_ namespace, used by products # and the framework itself to store common static resources # like icon images. misc_=pgetattr(product, 'misc_', {}) if misc_: if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ # Here we create a ProductContext object which contains # information about the product and provides an interface # for registering things like classes and help topics that # should be associated with that product. Products are # expected to implement a method named 'initialize' in # their __init__.py that takes the ProductContext as an # argument. productObject=App.Product.initializeProduct( product, product_name, package_dir, app) context=ProductContext(productObject, app, product) # Look for an 'initialize' method in the product. If it does # not exist, then this is an old product that has never been # updated. In that case, we will analyze the product and # build up enough information to do initialization manually. initmethod=pgetattr(product, 'initialize', None) if initmethod is not None: initmethod(context) # Support old-style product metadata. Older products may # define attributes to name their permissions, meta_types, # constructors, etc. permissions={} new_permissions={} for p in pgetattr(product, '__ac_permissions__', ()): permission, names, default = ( tuple(p)+('Manager',))[:3] if names: for name in names: permissions[name]=permission elif not folder_permissions.has_key(permission): new_permissions[permission]=() for meta_type in pgetattr(product, 'meta_types', ()): # Modern product initialization via a ProductContext # adds 'product' and 'permission' keys to the meta_type # mapping. We have to add these here for old products. pname=permissions.get(meta_type['action'], None) if pname is not None: meta_type['permission']=pname meta_type['product']=productObject.id meta_type['visibility'] = 'Global' meta_types.append(meta_type) for name,method in pgetattr( product, 'methods', {}).items(): if not hasattr(Folder.Folder, name): setattr(Folder.Folder, name, method) if name[-9:]!='__roles__': # not Just setting roles if (permissions.has_key(name) and not folder_permissions.has_key( permissions[name])): permission=permissions[name] if new_permissions.has_key(permission): new_permissions[permission].append(name) else: new_permissions[permission]=[name] if new_permissions: new_permissions=new_permissions.items() for permission, names in new_permissions: folder_permissions[permission]=names new_permissions.sort() Folder.Folder.__dict__['__ac_permissions__']=tuple( list(Folder.Folder.__ac_permissions__)+new_permissions) if (os.environ.get('ZEO_CLIENT') and not os.environ.get('FORCE_PRODUCT_LOAD')): # we don't want to install products from clients # (unless FORCE_PRODUCT_LOAD is defined). get_transaction().abort() else: get_transaction().note('Installed product '+product_name) get_transaction().commit() except: if log_exc: LOG('Zope',ERROR,'Couldn\'t install %s' % product_name, error=sys.exc_info()) get_transaction().abort() if raise_exc: raise
def install_product(app, product_dir, product_name, meta_types, folder_permissions, raise_exc=0, log_exc=1): path_join=os.path.join isdir=os.path.isdir exists=os.path.exists DictType=type({}) global_dict=globals() silly=('__doc__',) if 1: # Preserve indentation for diff :-) package_dir=path_join(product_dir, product_name) __traceback_info__=product_name if not isdir(package_dir): return if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): if not exists(path_join(package_dir, '__init__.pyo')): return try: product=__import__("Products.%s" % product_name, global_dict, global_dict, silly) # Install items into the misc_ namespace, used by products # and the framework itself to store common static resources # like icon images. misc_=pgetattr(product, 'misc_', {}) if misc_: if type(misc_) is DictType: misc_=Misc_(product_name, misc_) Application.misc_.__dict__[product_name]=misc_ # Here we create a ProductContext object which contains # information about the product and provides an interface # for registering things like classes and help topics that # should be associated with that product. Products are # expected to implement a method named 'initialize' in # their __init__.py that takes the ProductContext as an # argument. productObject=App.Product.initializeProduct( product, product_name, package_dir, app) context=ProductContext(productObject, app, product) # Look for an 'initialize' method in the product. If it does # not exist, then this is an old product that has never been # updated. In that case, we will analyze the product and # build up enough information to do initialization manually. initmethod=pgetattr(product, 'initialize', None) if initmethod is not None: initmethod(context) # Support old-style product metadata. Older products may # define attributes to name their permissions, meta_types, # constructors, etc. permissions={} new_permissions={} for p in pgetattr(product, '__ac_permissions__', ()): permission, names, default = ( tuple(p)+('Manager',))[:3] if names: for name in names: permissions[name]=permission elif not folder_permissions.has_key(permission): new_permissions[permission]=() for meta_type in pgetattr(product, 'meta_types', ()): # Modern product initialization via a ProductContext # adds 'product' and 'permission' keys to the meta_type # mapping. We have to add these here for old products. pname=permissions.get(meta_type['action'], None) if pname is not None: meta_type['permission']=pname meta_type['product']=productObject.id meta_type['visibility'] = 'Global' meta_types.append(meta_type) for name,method in pgetattr( product, 'methods', {}).items(): if not hasattr(Folder.Folder, name): setattr(Folder.Folder, name, method) if name[-9:]!='__roles__': # not Just setting roles if (permissions.has_key(name) and not folder_permissions.has_key( permissions[name])): permission=permissions[name] if new_permissions.has_key(permission): new_permissions[permission].append(name) else: new_permissions[permission]=[name] if new_permissions: new_permissions=new_permissions.items() for permission, names in new_permissions: folder_permissions[permission]=names new_permissions.sort() Folder.Folder.__dict__['__ac_permissions__']=tuple( list(Folder.Folder.__ac_permissions__)+new_permissions) if (os.environ.get('ZEO_CLIENT') and not os.environ.get('FORCE_PRODUCT_LOAD')): # we don't want to install products from clients # (unless FORCE_PRODUCT_LOAD is defined). get_transaction().abort() else: get_transaction().note('Installed product '+product_name) get_transaction().commit() except: if log_exc: LOG('Zope',ERROR,'Couldn\'t install %s' % product_name, error=sys.exc_info()) get_transaction().abort() if raise_exc: raise
2,797
def __init__(self, *pipeline): self.__wids = OIBTree() # word -> wid self.__words = IOBTree() # wid -> word # XXX we're reserving wid 0, but that might be yagni self.__nextwid = 1 self.__pipeline = pipeline
def __init__(self, *pipeline): self.__wids = OIBTree() # word -> wid self.__words = IOBTree() # wid -> word # XXX we're reserving wid 0, but that might be yagni self.__nextwid = 1 self.__pipeline = pipeline
2,798
def __init__(self, *pipeline): self.__wids = OIBTree() # word -> wid self.__words = IOBTree() # wid -> word # XXX we're reserving wid 0, but that might be yagni self.__nextwid = 1 self.__pipeline = pipeline
def __init__(self, *pipeline): self.__wids = OIBTree() # word -> wid self.__words = IOBTree() # wid -> word # XXX we're reserving wid 0, but that might be yagni self.__nextwid = 1 self.__pipeline = pipeline
2,799