bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def length(self): """Return the number of unique terms in the lexicon.""" return self.__nextwid - 1
def length(self): """Return the number of unique terms in the lexicon.""" return self.__nextwid - 1
2,800
def words(self): return self.__wids.keys()
def words(self): return self.__wids.keys()
2,801
def wids(self): return self.__words.keys()
def wids(self): return self.__words.keys()
2,802
def items(self): return self.__wids.items()
def items(self): return self.__wids.items()
2,803
def sourceToWordIds(self, text): last = _text2list(text) for element in self.__pipeline: last = element.process(last) return map(self._getWordIdCreate, last)
def sourceToWordIds(self, text): last = _text2list(text) for element in self._pipeline: last = element.process(last) return map(self._getWordIdCreate, last)
2,804
def termToWordIds(self, text): last = _text2list(text) for element in self.__pipeline: last = element.process(last) wids = [] for word in last: wid = self.__wids.get(word) if wid is not None: wids.append(wid) return wids
def termToWordIds(self, text): last = _text2list(text) for element in self._pipeline: last = element.process(last) wids = [] for word in last: wid = self.__wids.get(word) if wid is not None: wids.append(wid) return wids
2,805
def termToWordIds(self, text): last = _text2list(text) for element in self.__pipeline: last = element.process(last) wids = [] for word in last: wid = self.__wids.get(word) if wid is not None: wids.append(wid) return wids
def termToWordIds(self, text): last = _text2list(text) for element in self.__pipeline: last = element.process(last) wids = [] for word in last: wid = self._wids.get(word) if wid is not None: wids.append(wid) return wids
2,806
def get_word(self, wid): """Return the word for the given word id""" return self.__words[wid]
def get_word(self, wid): """Return the word for the given word id""" return self.__words[wid]
2,807
def globToWordIds(self, pattern): if not re.match("^\w+\*$", pattern): return [] pattern = pattern.lower() assert pattern.endswith("*") prefix = pattern[:-1] assert prefix and not prefix.endswith("*") keys = self.__wids.keys(prefix) # Keys starting at prefix wids = [] words = [] for key in keys: if not key.startswith(prefix): break wids.append(self.__wids[key]) words.append(key) return wids
def globToWordIds(self, pattern): if not re.match("^\w+\*$", pattern): return [] pattern = pattern.lower() assert pattern.endswith("*") prefix = pattern[:-1] assert prefix and not prefix.endswith("*") keys = self._wids.keys(prefix) # Keys starting at prefix wids = [] words = [] for key in keys: if not key.startswith(prefix): break wids.append(self.__wids[key]) words.append(key) return wids
2,808
def globToWordIds(self, pattern): if not re.match("^\w+\*$", pattern): return [] pattern = pattern.lower() assert pattern.endswith("*") prefix = pattern[:-1] assert prefix and not prefix.endswith("*") keys = self.__wids.keys(prefix) # Keys starting at prefix wids = [] words = [] for key in keys: if not key.startswith(prefix): break wids.append(self.__wids[key]) words.append(key) return wids
def globToWordIds(self, pattern): if not re.match("^\w+\*$", pattern): return [] pattern = pattern.lower() assert pattern.endswith("*") prefix = pattern[:-1] assert prefix and not prefix.endswith("*") keys = self.__wids.keys(prefix) # Keys starting at prefix wids = [] words = [] for key in keys: if not key.startswith(prefix): break wids.append(self._wids[key]) words.append(key) return wids
2,809
def _getWordIdCreate(self, word): wid = self.__wids.get(word) if wid is None: wid = self.__new_wid() self.__wids[word] = wid self.__words[wid] = word return wid
def _getWordIdCreate(self, word): wid = self._wids.get(word) if wid is None: wid = self.__new_wid() self.__wids[word] = wid self.__words[wid] = word return wid
2,810
def _getWordIdCreate(self, word): wid = self.__wids.get(word) if wid is None: wid = self.__new_wid() self.__wids[word] = wid self.__words[wid] = word return wid
def _getWordIdCreate(self, word): wid = self.__wids.get(word) if wid is None: wid = self._new_wid() self._wids[word] = wid self._words[wid] = word return wid
2,811
def __new_wid(self): wid = self.__nextwid self.__nextwid += 1 return wid
def _new_wid(self): wid = self._nextwid self._nextwid += 1 return wid
2,812
def manage_convertBTrees(self, threshold=200): """Convert the catalog's data structures to use BTrees package""" tt=time.time() ct=time.clock() self._catalog._convertBTrees(threshold *1 #make sure ints an int) ) tt=time.time()-tt ct=time.clock()-ct return 'Finished conversion in %s seconds (%s cpu)' % (tt, ct)
def manage_convertBTrees(self, threshold=200): """Convert the catalog's data structures to use BTrees package""" tt=time.time() ct=time.clock() self._catalog._convertBTrees(threshold *1 #make sure ints an int) ) tt=time.time()-tt ct=time.clock()-ct return 'Finished conversion in %s seconds (%s cpu)' % (tt, ct)
2,813
def __call__(self,*args,**kw): method=self.method if method=='PUT' and len(args)==1 and not kw: query=[args[0]] args=() else: query=[] for i in range(len(args)): try: k=self.args[i] if kw.has_key(k): raise TypeError, 'Keyword arg redefined' kw[k]=args[i] except IndexError: raise TypeError, 'Too many arguments'
def __call__(self,*args,**kw): method=self.method if method=='PUT' and len(args)==1 and not kw: query=[args[0]] args=() else: query=[] for i in range(len(args)): try: k=self.args[i] if kw.has_key(k): raise TypeError, 'Keyword arg redefined' kw[k]=args[i] except IndexError: raise TypeError, 'Too many arguments'
2,814
def main(): import getopt from string import split user=None try: optlist, args = getopt.getopt(sys.argv[1:],'u:') url=args[0] u =filter(lambda o: o[0]=='-u', optlist) if u: [user, pw] = split(u[0][1],':') kw={} for arg in args[1:]: [name,v]=split(arg,'=') if name[-5:]==':file': name=name[:-5] if v=='-': v=sys.stdin else: v=open(v) kw[name]=v except: print usage sys.exit(1) # The "main" program for this module f=Function(url) if user: f.username, f.password = user, pw headers, body = apply(f,(),kw) sys.stderr.write(join(map(lambda h: "%s: %s\n" % h, headers.items()),"") +"\n\n") print body
def main(): import getopt from string import splituser=Nonetry: optlist, args = getopt.getopt(sys.argv[1:],'u:') url=args[0] u =filter(lambda o: o[0]=='-u', optlist) if u: [user, pw] = split(u[0][1],':')kw={} for arg in args[1:]: [name,v]=split(arg,'=') if name[-5:]==':file': name=name[:-5] if v=='-': v=sys.stdin else: v=open(v) kw[name]=vexcept: print usage sys.exit(1)# The "main" program for this module f=Function(url) if user: f.username, f.password = user, pw headers, body = apply(f,(),kw) sys.stderr.write(join(map(lambda h: "%s: %s\n" % h, headers.items()),"") +"\n\n") print body
2,815
def __init__(self, product, dest, REQUEST): if hasattr(product,'aq_base'): product=product.aq_base self._product=product self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
def __init__(self, product, dest, REQUEST=None): if hasattr(product,'aq_base'): product=product.aq_base self._product=product self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
2,816
def __init__(self, product, dest, REQUEST): if hasattr(product,'aq_base'): product=product.aq_base self._product=product self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
def __init__(self, product, dest, REQUEST): if hasattr(product,'aq_base'): product=product.aq_base self._product=product self._d=dest v=REQUEST['URL'] v=v[:rfind(v,'/')] self._u=v[:rfind(v,'/')]
2,817
def testAddWithRequestButNoFile(self): """Collector #596: manage_add with text but no file""" request = self.app.REQUEST self._addPT('pt1', text=self.text, REQUEST=request) # no object is returned when REQUEST is passed. pt = self.app.pt1 self.assertEqual(pt.document_src(), self.text)
def testAddWithRequestButNoFile(self): """Collector #596: manage_add with text but no file""" request = self.app.REQUEST self._addPT('pt1', text=self.text, REQUEST=request) # no object is returned when REQUEST is passed. pt = self.app.pt1 self.assertEqual(pt.document_src(), self.text)
2,818
def _textInput(self,n,t,v): return ('<TEXTAREA NAME="%s" ROWS="10" COLS="40">%s</TEXTAREA>'
def _textInput(self,n,t,v): return ('<TEXTAREA NAME="%s" ROWS="10" COLS="40">%s</TEXTAREA>'
2,819
def manage_catalogClear(self, REQUEST, RESPONSE, URL1): """ clears the whole enchelada """ self._catalog.clear()
def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None): """ clears the whole enchelada """ self._catalog.clear()
2,820
def manage_catalogClear(self, REQUEST, RESPONSE, URL1): """ clears the whole enchelada """ self._catalog.clear()
def manage_catalogClear(self, REQUEST, RESPONSE, URL1): """ clears the whole enchelada """ self._catalog.clear()
2,821
def manage_addColumn(self, name, REQUEST, RESPONSE, URL1): """ add a column """ self._catalog.addColumn(name)
def manage_addColumn(self, name, REQUEST=None, RESPONSE=None, URL1=None): """ add a column """ self._catalog.addColumn(name)
2,822
def manage_addColumn(self, name, REQUEST, RESPONSE, URL1): """ add a column """ self._catalog.addColumn(name)
def manage_addColumn(self, name, REQUEST, RESPONSE, URL1): """ add a column """ self._catalog.addColumn(name)
2,823
def manage_delColumns(self, names, REQUEST, RESPONSE, URL1): """ del a column """ for name in names: self._catalog.delColumn(name)
def manage_delColumns(self, names, REQUEST, RESPONSE, URL1): """ del a column """ for name in names: self._catalog.delColumn(name)
2,824
def manage_addIndex(self, name, type, REQUEST, RESPONSE, URL1): """ add an index """ self._catalog.addIndex(name, type) RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Added')
def manage_addIndex(self, name, type, REQUEST, RESPONSE, URL1): """ add an index """ self._catalog.addIndex(name, type) RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Added')
2,825
def manage_delIndexes(self, names, REQUEST, RESPONSE, URL1): """ del an index """ for name in names: self._catalog.delIndex(name) RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted')
def manage_delIndexes(self, names, REQUEST, RESPONSE, URL1): """ del an index """ for name in names: self._catalog.delIndex(name) RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted')
2,826
def apply_diff(state, diff, expand): if not diff: return s=[None, state] diff.reverse() __traceback_info__=s, diff while diff: id=diff[-1] del diff[-1] if len(s)==1: s.append([]) s=list(s[1]) loc=-1 for i in range(len(s)): if s[i][0]==id: loc=i break if loc >= 0: if not diff and not expand: del s[loc] else: s=s[loc] elif diff or expand: s.append([id,[]]) s=s[-1][1] while diff: id=diff[-1] del diff[-1] if diff or expand: s.append([id,[]]) s=s[-1][1]
def apply_diff(state, diff, expand): if not diff: return s=[None, state] diff.reverse() __traceback_info__=s, diff while diff: id=diff[-1] del diff[-1] if len(s)==1: s.append([]) s=s[1] if type(s)==type(()): s=list(s) loc=-1 for i in range(len(s)): if s[i][0]==id: loc=i break if loc >= 0: if not diff and not expand: del s[loc] else: s=s[loc] elif diff or expand: s.append([id,[]]) s=s[-1][1] while diff: id=diff[-1] del diff[-1] if diff or expand: s.append([id,[]]) s=s[-1][1]
2,827
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
def search(self, text, start=0, name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, end_match=regex.compile('[\0- ]*\(/\|end\)', regex.casefold).match, start_search=regex.compile('[<&]').search, ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, find=find, strip=strip ):
2,828
def has_permission(self, permission, object): return 1
def has_permission(self, permission, object): return 1
2,829
def _view_widget_for_type(self, t, id): if t not in ('lines', 'tokens'): return '<!--#var %s-->' % id return """ <!--#in %s--> <!--#var sequence-item--> <!--#in %s--> """
def _view_widget_for_type(self, t, id): if t not in ('lines', 'tokens'): return '<!--#var %s-->' % id return """ % (id, id) <!--#in %s--> <!--#var sequence-item--> <!--#in %s--> """
2,830
def __init__(self,*args): """Return a new date-time object
def __init__(self,*args): """Return a new date-time object
2,831
def _parse(self,string):
def _parse(self,string):
2,832
def schemaComponentSource(self, package, file): parts = package.split(".") if not parts: raise ZConfig.SchemaError( "illegal schema component name: " + `package`) if "" in parts: # '' somewhere in the package spec; still illegal raise ZConfig.SchemaError( "illegal schema component name: " + `package`) file = file or "component.xml" try: __import__(package) except ImportError, e: raise ZConfig.SchemaResourceError( "could not load package %s: %s" % (package, str(e)), filename=file, package=package) pkg = sys.modules[package] if not hasattr(pkg, "__path__"): raise ZConfig.SchemaResourceError( "import name does not refer to a package", filename=file, package=package) for dir in pkg.__path__: dirname = os.path.abspath(dir) fn = os.path.join(dirname, file) if os.path.exists(fn): return "file://" + urllib.pathname2url(fn) else: raise ZConfig.SchemaResourceError("schema component not found", filename=file, package=package, path=pkg.__path__)
def schemaComponentSource(self, package, file): parts = package.split(".") if not parts: raise ZConfig.SchemaError( "illegal schema component name: " + `package`) if "" in parts: # '' somewhere in the package spec; still illegal raise ZConfig.SchemaError( "illegal schema component name: " + `package`) file = file or "component.xml" try: __import__(package) except ImportError, e: raise ZConfig.SchemaResourceError( "could not load package %s: %s" % (package, repr(e)), filename=file, package=package) pkg = sys.modules[package] if not hasattr(pkg, "__path__"): raise ZConfig.SchemaResourceError( "import name does not refer to a package", filename=file, package=package) for dir in pkg.__path__: dirname = os.path.abspath(dir) fn = os.path.join(dirname, file) if os.path.exists(fn): return "file://" + urllib.pathname2url(fn) else: raise ZConfig.SchemaResourceError("schema component not found", filename=file, package=package, path=pkg.__path__)
2,833
def objectItems_d(self,t=None): r=[] a=r.append g=self._getOb for id in self.objectIds_d(spec): a((id, g(id))) return r
def objectItems_d(self,t=None): r=[] a=r.append g=self._getOb for id in self.objectIds_d(t): a((id, g(id))) return r
2,834
def translate(self, msgid, domain=None, mapping=None, default=None):
def translate(self, msgid, domain=None, mapping=None, default=None):
2,835
def realize(self, *args, **kw): ZDOptions.realize(self, *args, **kw) config = self.configroot self.directory = config.instancehome self.clienthome = config.clienthome self.program = [os.path.join(self.directory, "bin", "runzope")] self.sockname = os.path.join(self.clienthome, "zopectlsock") self.user = None self.python = sys.executable self.zdrun = os.path.join(os.path.dirname(zdaemon.__file__), "zdrun.py") self.exitcodes = [0, 2] if self.logfile is None and config.eventlog is not None: for handler in config.eventlog.handler_factories: if isinstance(handler, FileHandlerFactory): self.logfile = handler.section.path if self.logfile not in ("STDERR", "STDOUT"): break
def realize(self, *args, **kw): ZDOptions.realize(self, *args, **kw) config = self.configroot self.directory = config.instancehome self.clienthome = config.clienthome if config.runner and config.runner.program: self.program = config.runner.program else: self.program = [os.path.join(self.directory, "bin", "runzope")] self.sockname = os.path.join(self.clienthome, "zopectlsock") self.user = None self.python = sys.executable self.zdrun = os.path.join(os.path.dirname(zdaemon.__file__), "zdrun.py") self.exitcodes = [0, 2] if self.logfile is None and config.eventlog is not None: for handler in config.eventlog.handler_factories: if isinstance(handler, FileHandlerFactory): self.logfile = handler.section.path if self.logfile not in ("STDERR", "STDOUT"): break
2,836
def get_startup_cmd(self, python, more): cmdline = ( '%s -c "from Zope.Startup.options import ZopeOptions; ' 'from Zope.Startup import handlers as h; ' 'from App import config; ' 'opts=ZopeOptions(); ' 'opts.configfile=\'%s\'; ' 'opts.realize(); ' 'h.handleConfig(opts.configroot,opts.confighandlers);' 'config.setConfiguration(opts.configroot); ' % (python, self.options.configfile) ) return cmdline + more + '\"'
def get_startup_cmd(self, python, more): cmdline = ( '%s -c "from Zope.Startup.options import ZopeOptions; ' 'from Zope.Startup import handlers as h; ' 'from App import config; ' 'opts=ZopeOptions(); ' 'opts.configfile=\'%s\'; ' 'opts.realize(); ' 'h.handleConfig(opts.configroot,opts.confighandlers);' 'config.setConfiguration(opts.configroot); ' 'from Zope.Startup import do_posix_stuff; ' 'do_posix_stuff(opts.configroot); '% (python, self.options.configfile) ) return cmdline + more + '\"'
2,837
def do_debug( self, arg ): cmdline = self.get_startup_cmd(self.options.python + ' -i', 'import Zope; app=Zope.app()') print ('Starting debugger (the name "app" is bound to the top-level ' 'Zope object)') os.system(cmdline)
def do_debug(self, arg): cmdline = self.get_startup_cmd(self.options.python + ' -i', 'import Zope; app=Zope.app()') print ('Starting debugger (the name "app" is bound to the top-level ' 'Zope object)') os.system(cmdline)
2,838
def do_run( self, arg ): cmdline = self.get_startup_cmd(self.options.python, 'import Zope; app=Zope.app(); execfile(\'%s\')' % arg) os.system(cmdline)
def do_run(self, arg): self.setuid() cmdline = self.get_startup_cmd(self.options.python, 'import Zope; app=Zope.app(); execfile(\'%s\')' % arg) os.system(cmdline)
2,839
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(value, '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(str(value), ' ') elif type=='lines': value=join(value, '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
2,840
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(value, '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(str(value), '\n') # check for xml property attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # Quote non-xml items here? attrs=''
2,841
def dav__propstat(self, name, result, propstat=propstat, propdesc=propdesc, join=string.join): # DAV helper method - return a propstat element indicating # property name and value for the requested property. xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id) code='404 Not Found' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return else: item=propdict[name] name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(value, '\n') # allow for xml properties attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # quote non-xml items here? attrs='' prop='<n:%s%s xmlns:n="%s">%s</n:%s>\n' % ( name, attrs, xml_id, value, name) code='200 OK' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return
def dav__propstat(self, name, result, propstat=propstat, propdesc=propdesc, join=string.join): # DAV helper method - return a propstat element indicating # property name and value for the requested property. xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id) code='404 Not Found' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return else: item=propdict[name] name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(str(value), ' ') elif type=='lines': value=join(value, '\n') # allow for xml properties attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # quote non-xml items here? attrs='' prop='<n:%s%s xmlns:n="%s">%s</n:%s>\n' % ( name, attrs, xml_id, value, name) code='200 OK' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return
2,842
def dav__propstat(self, name, result, propstat=propstat, propdesc=propdesc, join=string.join): # DAV helper method - return a propstat element indicating # property name and value for the requested property. xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id) code='404 Not Found' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return else: item=propdict[name] name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(value, '\n') # allow for xml properties attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # quote non-xml items here? attrs='' prop='<n:%s%s xmlns:n="%s">%s</n:%s>\n' % ( name, attrs, xml_id, value, name) code='200 OK' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return
def dav__propstat(self, name, result, propstat=propstat, propdesc=propdesc, join=string.join): # DAV helper method - return a propstat element indicating # property name and value for the requested property. xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id) code='404 Not Found' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return else: item=propdict[name] name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': value=join(value, ' ') elif type=='lines': value=join(str(value), '\n') # allow for xml properties attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) attrs=join(attrs, '') else: # quote non-xml items here? attrs='' prop='<n:%s%s xmlns:n="%s">%s</n:%s>\n' % ( name, attrs, xml_id, value, name) code='200 OK' if not result.has_key(code): result[code]=[prop] else: result[code].append(prop) return
2,843
def db_name(self): return self._p_jar.db.file_name
def db_name(self): return self._p_jar.db.file_name
2,844
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1, obj_metatypes=None, obj_ids=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_roles=None, obj_permission=None): """ Find object according to search criteria and Catalog them """
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1, obj_metatypes=None, obj_ids=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_roles=None, obj_permission=None): """ Find object according to search criteria and Catalog them """
2,845
def doc_strong(self, s, expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines. ):
def doc_strong(self, s, expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search #expr = re.compile(r'\s*\*\*([ \n\r%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*\*(?!\*|-)' % letters).search, # old expr, inconsistent punc, failed to cross newlines. ):
2,846
def signalHandler(self, signum, frame): """Meta signal handler that dispatches to registered handlers.""" signame = zdaemon.Daemon.get_signal_name(signum) zLOG.LOG('Z2', zLOG.INFO , "Caught signal %s" % signame)
def signalHandler(self, signum, frame): """Meta signal handler that dispatches to registered handlers.""" signame = zdaemon.Daemon.get_signal_name(signum) zLOG.LOG('Z2', zLOG.INFO , "Caught signal %s" % signame)
2,847
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") reopen = getattr(getattr(sys, '__lg', None), 'reopen', None) if reopen is not None: reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
2,848
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") reopen = getattr(getattr(sys, '__detailedlog', None), 'reopen', None) if reopen is not None: reopen() zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
2,849
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
2,850
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
def sigusr2Handler(self): """Reopen log files on SIGUSR2. This is registered first, so it should be called after all other SIGUSR2 handlers.""" zLOG.LOG('Z2', zLOG.INFO , "Reopening log files") if hasattr(sys, '__lg') and hasattr(sys.__lg, 'reopen'): sys.__lg.reopen() zLOG.LOG('Z2', zLOG.BLATHER, "Reopened access log") if (hasattr(sys, '__detailedlog') and hasattr(sys.__detailedlog, 'reopen')): zLOG.LOG('Z2', zLOG.BLATHER,"Reopened detailed request log") sys.__detailedlog.reopen() if hasattr(zLOG, '_set_stupid_dest'): zLOG._set_stupid_dest(None) else: zLOG._stupid_dest = None ZLogger.stupidFileLogger._stupid_dest = None zLOG.LOG('Z2', zLOG.BLATHER, "Reopened event log") zLOG.LOG('Z2', zLOG.INFO, "Log files reopened successfully")
2,851
def __init__(self, blocks):
def __init__(self, blocks):
2,852
def manage_addZCatalog(self,id,title,REQUEST=None): """Add a ZCatalog object """ c=ZCatalog(id,title) self._setObject(id,c) if REQUEST is not None: return self.manage_main(self,REQUEST)
def manage_addZCatalog(self,id,title,REQUEST=None): """Add a ZCatalog object """ c=ZCatalog(id,title) self._setObject(id,c) if REQUEST is not None: return self.manage_main(self,REQUEST)
2,853
def _setProperty(self, id, value, type='string'): if not self.valid_property_id(id): raise 'Bad Request', 'Invalid or duplicate property id' self._properties=self._properties+({'id':id,'type':type},) self._setPropValue(id, value)
def _setProperty(self, id, value, type='string'): if not self.valid_property_id(id): raise 'Bad Request', 'Invalid or duplicate property id' self._properties=self._properties+({'id':id,'type':type},) self._setPropValue(id, value)
2,854
def getFirstChild(self): """Returns a NodeList that contains all children of this node. If there are no children, this is a empty NodeList""" return None
def getFirstChild(self): """The first child of this node. If there is no such node this returns None.""" return None
2,855
def getLastChild(self): """The last child of this node. If ther is no such node this returns None.""" return None
def getLastChild(self): """The last child of this node. If there is no such node this returns None.""" return None
2,856
def getFirstChild(self): """Returns a NodeList that contains all children of this node. If there are no children, this is a empty NodeList""" children = self.getChildNodes() if children: return children._data[0] return None
def getFirstChild(self): """The first child of this node. If there is no such node this returns None""" children = self.getChildNodes() if children: return children._data[0] return None
2,857
def getLastChild(self): """The last child of this node. If ther is no such node this returns None.""" children = self.getChildNodes() if children: return children._data[-1] return None
def getLastChild(self): """The last child of this node. If there is no such node this returns None.""" children = self.getChildNodes() if children: return children._data[-1] return None
2,858
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType()==ELEMENT_NODE and \ child.getTagName()==tagname or tagname== '*'): nodeList.append( child ) n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
def getElementsByTagName(self, tagname): """ Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree. Parameter: tagname The name of the tag to match (* = all tags). Return Value: A new NodeList object containing all the matched Elements. """ nodeList = [] for child in self.objectValues(): if (child.getNodeType()==ELEMENT_NODE and \ child.getTagName()==tagname or tagname== '*'): nodeList.append(child) n1 = child.getElementsByTagName(tagname) nodeList = nodeList + n1._data return NodeList(nodeList)
2,859
def package_home(globals_dict):
def package_home(globals_dict):
2,860
# def response(anHTTPResponse):
# def response(anHTTPResponse):
2,861
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
2,862
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
2,863
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
def exception(self, fatal=0, info=None, absuri_match=None, tag_search=None): # Fetch our exception info. t is type, v is value and tb is the # traceback object. if type(info) is type(()) and len(info)==3: t,v,tb = info else: t,v,tb = sys.exc_info()
2,864
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,865
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,866
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,867
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,868
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,869
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,870
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
2,871
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
2,872
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
def manage_addZCatalog(self, id, title, vocab_id=None, REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) if vocab_id == 'create_default_catalog_': vocab_id = None c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
2,873
def manage_cache_size(self,value,REQUEST):
def manage_cache_size(self,value,REQUEST):
2,874
def tpValues(self): # Return a list of subobjects, used by tree tag. r=[] if hasattr(aq_base(self), 'tree_ids'): tree_ids=self.tree_ids try: tree_ids=list(tree_ids) except TypeError: pass if hasattr(tree_ids, 'sort'): tree_ids.sort() for id in tree_ids: if hasattr(self, id): r.append(self._getOb(id)) else: obj_ids=self.objectIds() obj_ids.sort() for id in obj_ids: for id in self._objects: o=self._getOb(id) if hasattr(o, 'isPrincipiaFolderish') and \ o.isPrincipiaFolderish: r.append(o) return r
def tpValues(self): # Return a list of subobjects, used by tree tag. r=[] if hasattr(aq_base(self), 'tree_ids'): tree_ids=self.tree_ids try: tree_ids=list(tree_ids) except TypeError: pass if hasattr(tree_ids, 'sort'): tree_ids.sort() for id in tree_ids: if hasattr(self, id): r.append(self._getOb(id)) else: obj_ids=self.objectIds() obj_ids.sort() for id in obj_ids: o=self._getOb(id) if hasattr(o, 'isPrincipiaFolderish') and \ o.isPrincipiaFolderish: r.append(o) return r
2,875
def _manage_remove_product_data(self, type, product, id): values=filter( lambda d, product=product, id=id: not (d['product']==product and d['id']==id), self.aq_maybe('_getProductRegistryData')(type) )
def _manage_remove_product_data(self, type, product, id): values=filter( lambda d, product=product, id=id: not (d['product'] in (product, 'methods') and d['id']==id), self.aq_maybe('_getProductRegistryData')(type) )
2,876
def _read_data(self, file): n=1<<16 if type(file) is type(''): size=len(file) if size < n: return file, size return Pdata(file), size seek=file.seek read=file.read seek(0,2) size=end=file.tell() jar=self._p_jar if size <= 2*n or jar is None or Globals.DatabaseVersion=='2': seek(0) if size < n: read(size), size return Pdata(read(size)), size
def _read_data(self, file): n=1<<16 if type(file) is type(''): size=len(file) if size < n: return file, size return Pdata(file), size seek=file.seek read=file.read seek(0,2) size=end=file.tell() jar=self._p_jar if size <= 2*n or jar is None or Globals.DatabaseVersion=='2': seek(0) if size < n: return read(size), size return Pdata(read(size)), size
2,877
def __init__(self, id, title, object_type, initial, product=None): self.id=id self.title=title self.object_type=object_type self.initial=initial if product is not None: self.__of__(product)._register()
def __init__(self, id, title, object_type, initial, product=None): self.id=id self.title=title self.object_type=object_type self.initial=initial if product is not None: self.__of__(product)._register()
2,878
def manage_afterAdd(self, item, container): if hasattr(self, 'aq_parent'): container=self.aq_parent elif item is not self: container=None
def manage_afterAdd(self, item, container): if hasattr(self, 'aq_parent'): container=self.aq_parent elif item is not self: container=None
2,879
def manage_beforeDelete(self, item, container): if hasattr(self, 'aq_parent'): container=self.aq_parent elif item is not self: container=None
def manage_beforeDelete(self, item, container): if hasattr(self, 'aq_parent'): container=self.aq_parent elif item is not self: container=None
2,880
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
2,881
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
def renderwb(self, md): expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
2,882
def renderwob(self, md): """RENDER WithOutBatch""" expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
def renderwob(self, md): """RENDER WithOutBatch""" expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
2,883
def renderwob(self, md): """RENDER WithOutBatch""" expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
def renderwob(self, md): """RENDER WithOutBatch""" expr=self.expr name=self.__name__ if expr is None: sequence=md[name] cache={ name: sequence } else: sequence=expr(md) cache=None
2,884
def sort_sequence(self, sequence):
def sort_sequence(self, sequence):
2,885
def sort_sequence(self, sequence):
def sort_sequence(self, sequence):
2,886
def sort_sequence(self, sequence):
def sort_sequence(self, sequence):
2,887
def sort_sequence(self, sequence):
def sort_sequence(self, sequence):
2,888
def lic_check(product_name): default_license=0 path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: f, val = None, default_license if f is not None: dat=lcd(f.read()) f.close() if dat is None: name, val = '', default_license else: [name, val]=dat[:2] if name != product_name: val=default_license elif val is None: return 1 if not bobobase.has_key('_t_'): t=bobobase['_t_']={} else: t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t if (t[product_name] + (86400.0 * val)) <= time.time(): # License has expired! product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) return 0 return 1
def lic_check(product_name): default_license=30 path_join =os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') package_dir=path_join(product_dir, product_name) bobobase =Globals.Bobobase try: f=open(path_join(package_dir,'%s.lic' % product_name), 'rb') except: f, val = None, default_license if f is not None: dat=lcd(f.read()) f.close() if dat is None: name, val = '', default_license else: [name, val]=dat[:2] if name != product_name: val=default_license elif val is None: return 1 if not bobobase.has_key('_t_'): t=bobobase['_t_']={} else: t=bobobase['_t_'] if not t.has_key(product_name): t[product_name]=time.time() bobobase['_t_']=t if (t[product_name] + (86400.0 * val)) <= time.time(): # License has expired! product=getattr(__import__("Products.%s" % product_name), product_name) for s in pgetattr(product, 'classes', ()): p=rfind(s,'.') m='Products.%s.%s' % (product_name, s[:p]) c=s[p+1:] try: __import__(m) except: m=s[:p] __import__(m) setattr(sys.modules[m], c, Expired) return 0 return 1
2,889
def first(self,name):
def first(self,name):
2,890
def last(self,name):
def last(self,name):
2,891
def statistics(self,name):
def statistics(self,name):
2,892
def statistics(self,name):
def statistics(self,name):
2,893
def previous_batches(self, suffix='batches'):
def previous_batches(self, suffix='batches'):
2,894
def previous_batches(self, suffix='batches'):
def previous_batches(self, suffix='batches'):
2,895
def __getitem__(self,key, special_prefixes=special_prefixes, special_prefix=special_prefixes.has_key ): data=self.data if data.has_key(key): return data[key]
def __getitem__(self,key, special_prefixes=special_prefixes, special_prefix=special_prefixes.has_key ): data=self.data if data.has_key(key): return data[key]
2,896
def decapitate(html, RESPONSE=None, header_re=ts_regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=ts_regex.compile('\([ \t]+\)'), name_re=ts_regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): ts_results = header_re.match_group(html, (1,3)) if not ts_results: return html headers, html = ts_reulsts[1] headers=string.split(headers,'\n') i=1 while i < len(headers): if not headers[i]: del headers[i] else: ts_results = space_re.match_group(headers[i], (1,)) if ts_reults: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(ts_reults[1]):]) del headers[i] else: i=i+1 for i in range(len(headers)): ts_results = name_re.match_group(headers[i], (1,2)) if ts_reults: k, v = ts_reults[1] v=string.strip(v) else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) RESPONSE.setHeader(k,v) return html
def decapitate(html, RESPONSE=None, header_re=ts_regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=ts_regex.compile('\([ \t]+\)'), name_re=ts_regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): ts_results = header_re.match_group(html, (1,3)) if not ts_results: return html headers, html = ts_results[1] headers=string.split(headers,'\n') i=1 while i < len(headers): if not headers[i]: del headers[i] else: ts_results = space_re.match_group(headers[i], (1,)) if ts_reults: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(ts_reults[1]):]) del headers[i] else: i=i+1 for i in range(len(headers)): ts_results = name_re.match_group(headers[i], (1,2)) if ts_reults: k, v = ts_reults[1] v=string.strip(v) else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) RESPONSE.setHeader(k,v) return html
2,897
def decapitate(html, RESPONSE=None, header_re=ts_regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=ts_regex.compile('\([ \t]+\)'), name_re=ts_regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): ts_results = header_re.match_group(html, (1,3)) if not ts_results: return html headers, html = ts_reulsts[1] headers=string.split(headers,'\n') i=1 while i < len(headers): if not headers[i]: del headers[i] else: ts_results = space_re.match_group(headers[i], (1,)) if ts_reults: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(ts_reults[1]):]) del headers[i] else: i=i+1 for i in range(len(headers)): ts_results = name_re.match_group(headers[i], (1,2)) if ts_reults: k, v = ts_reults[1] v=string.strip(v) else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) RESPONSE.setHeader(k,v) return html
def decapitate(html, RESPONSE=None, header_re=ts_regex.compile( '\(\(' '[^\0- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=ts_regex.compile('\([ \t]+\)'), name_re=ts_regex.compile('\([^\0- <>:]+\):\([^\n]*\)'), ): ts_results = header_re.match_group(html, (1,3)) if not ts_results: return html headers, html = ts_reulsts[1] headers=string.split(headers,'\n') i=1 while i < len(headers): if not headers[i]: del headers[i] else: ts_results = space_re.match_group(headers[i], (1,)) if ts_results: headers[i-1]="%s %s" % (headers[i-1], headers[i][len(ts_reults[1]):]) del headers[i] else: i=i+1 for i in range(len(headers)): ts_results = name_re.match_group(headers[i], (1,2)) if ts_results: k, v = ts_reults[1] v=string.strip(v) else: raise ValueError, 'Invalid Header (%d): %s ' % (i,headers[i]) RESPONSE.setHeader(k,v) return html
2,898
def __getitem__(self,key):
def __getitem__(self,key):
2,899