bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def testUnderlinesWithoutWithspaces(self): """ underscores in literals shouldn't do unterlining """
def testUnderlinesWithoutWithspaces(self): """ underscores in literals shouldn't do unterlining """
2,600
def server_info(old, v, offset=0): # interpret v as a port or address/port and get new value if v == '-': v='' l=v.find(':') if l >= 0: a=v[:l] v=v[l+1:] else: a=IP_ADDRESS if not v: return v try: v=int(v) if v < 0: raise 'Invalid port', v v=v+offset except: raise 'Invalid port', v if isinstance(old, IntType): old=[(a,v)] else: old.append((a,v)) return old
def server_info(old, v, offset=0): # interpret v as a port or address/port and get new value if v == '-': v='' l=v.find(':') if l >= 0: a=v[:l] v=v[l+1:] else: a=IP_ADDRESS if not v: return v try: v=int(v) if v < 0: raise 'Invalid port', v v=v+offset except: raise 'Invalid port', v if isinstance(old, IntType): old=[(a,v)] else: old.append((a,v)) return old
2,601
def server_info(old, v, offset=0): # interpret v as a port or address/port and get new value if v == '-': v='' l=v.find(':') if l >= 0: a=v[:l] v=v[l+1:] else: a=IP_ADDRESS if not v: return v try: v=int(v) if v < 0: raise 'Invalid port', v v=v+offset except: raise 'Invalid port', v if isinstance(old, IntType): old=[(a,v)] else: old.append((a,v)) return old
def server_info(old, v, offset=0): # interpret v as a port or address/port and get new value if v == '-': v='' l=v.find(':') if l >= 0: a=v[:l] v=v[l+1:] else: a=IP_ADDRESS if not v: return v try: v=int(v) if v < 0: raise 'Invalid port', v v=v+offset except: raise 'Invalid port', v if isinstance(old, IntType): old=[(a,v)] else: old.append((a,v)) return old
2,602
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
2,603
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
def set_locale(val): try: import locale except: raise SystemExit, ( 'The locale module could not be imported.\n' 'To use localization options, you must ensure\n' 'that the locale module is compiled into your\n' 'Python installation.' ) try: locale.setlocale(locale.LC_ALL, val) except: raise SystemExit, ( 'The specified locale is not supported by your system.\n' 'See your operating system documentation for more\n' 'information on locale support.' )
2,604
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
2,605
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
2,606
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
2,607
def allowed(self, parent, roles=None): """Check whether the user has access to parent, assuming that parent.__roles__ is the given roles.""" if roles is None or 'Anonymous' in roles: return 1 usr_roles=self.getRolesInContext(parent) for role in roles: if role in usr_roles: if (hasattr(self,'aq_parent') and hasattr(self.aq_parent,'aq_parent')): if parent is None: return 1 if (not hasattr(parent, 'aq_inContextOf') and hasattr(parent, 'im_self')): # This is a method, grab it's self. parent=parent.im_self if (hasattr(parent, 'aq_inContextOf') and not parent.aq_inContextOf(self.aq_parent.aq_parent,1)): if 'Shared' in roles: # Damn, old role setting. Waaa roles=self._shared_roles(parent) if 'Anonymous' in roles: return 1 return None return 1
def allowed(self, parent, roles=None): """Check whether the user has access to parent, assuming that parent.__roles__ is the given roles.""" if roles is None or 'Anonymous' in roles: return 1 usr_roles=self.getRolesInContext(parent) for role in roles: if role in usr_roles: if (hasattr(self,'aq_parent') and hasattr(self.aq_parent,'aq_parent')): if parent is None: return 1 if (not hasattr(parent, 'aq_inContextOf') and hasattr(parent, 'im_self')): # This is a method, grab it's self. parent=parent.im_self if not parent.aq_inContextOf(self.aq_parent.aq_parent,1): if 'Shared' in roles: # Damn, old role setting. Waaa roles=self._shared_roles(parent) if 'Anonymous' in roles: return 1 return None return 1
2,608
def read_file(name): f = open(os.path.join(here, name), 'rb') res = f.read() f.close() return res
def read_file(name): f = open(os.path.join(here, name), 'r') res = f.read() f.close() return res
2,609
def d(**kw): return kw
defd(**kw):returnkw
2,610
def __init__(self,key,**kw): for k in kw.keys(): self.__dict__[k]=kw[k]
def __init__(self,key,**kw): for k in kw.keys(): self.__dict__[k]=kw[k]
2,611
def modified_in_session(self):
def modified_in_session(self):
2,612
def manage_addImage(id, file, title='', precondition='', content_type=''): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """
def manage_addImage(id, file, title='', precondition='', content_type=''): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """
2,613
def __call__(self): return 'dummy'
def __call__(self): return 'dummy'
2,614
def setUp(self): self.e = e = Expressions.getEngine() self.ec = e.getContext( one = 1, d = {'one': 1, 'b': 'b', '': 'blank', '_': 'under'}, blank = '', dummy = Dummy() )
def setUp(self): self.e = e = Expressions.getEngine() self.ec = e.getContext( one = 1, d = {'one': 1, 'b': 'b', '': 'blank', '_': 'under'}, blank = '', dummy = Dummy() )
2,615
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
2,616
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
2,617
def get_module_info(self, server_name, module_name, module):
def get_module_info(self, server_name, module_name, module):
2,618
def publish(self, module_name, after_list, published='web_objects',
def publish(self, module_name, after_list, published='web_objects',
2,619
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match THdivider = re.compile("[\=]+").match col = re.compile('\|').search innertable = re.compile('\|([-]+|[=]+)\|').search text = strip(text) rows = split(text,'\n') foo = "" for row in range(len(rows)): rows[row] = strip(rows[row]) # have indexes store if a row is a divider # or a cell part for index in range(len(rows)): tmpstr = rows[index][1:len(rows[index])-1] if TDdivider(tmpstr): indexes.append("TDdivider") elif THdivider(tmpstr): indexes.append("THdivider") else: indexes.append("cell")
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match THdivider = re.compile("[\=]+").match col = re.compile('\|').search innertable = re.compile('\|([-]+|[=]+)\|').search text = strip(text) rows = split(text,'\n') foo = "" for row in range(len(rows)): rows[row] = strip(rows[row]) # have indexes store if a row is a divider # or a cell part for index in range(len(rows)): tmpstr = rows[index][1:len(rows[index])-1] if TDdivider(tmpstr): indexes.append("TDdivider") elif THdivider(tmpstr): indexes.append("THdivider") else: indexes.append("cell")
2,620
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match THdivider = re.compile("[\=]+").match col = re.compile('\|').search innertable = re.compile('\|([-]+|[=]+)\|').search text = strip(text) rows = split(text,'\n') foo = "" for row in range(len(rows)): rows[row] = strip(rows[row]) # have indexes store if a row is a divider # or a cell part for index in range(len(rows)): tmpstr = rows[index][1:len(rows[index])-1] if TDdivider(tmpstr): indexes.append("TDdivider") elif THdivider(tmpstr): indexes.append("THdivider") else: indexes.append("cell")
def doc_table(self, paragraph, expr = re.compile(r'\s*\|[-]+\|').match): text = paragraph.getColorizableTexts()[0] m = expr(text) subs = paragraph.getSubparagraphs() if not (m): return None rows = [] spans = [] ROWS = [] COLS = [] indexes = [] ignore = [] TDdivider = re.compile("[\-]+").match THdivider = re.compile("[\=]+").match col = re.compile('\|').search innertable = re.compile('\|([-]+|[=]+)\|').search text = strip(text) rows = split(text,'\n') foo = "" for row in range(len(rows)): rows[row] = strip(rows[row]) # have indexes store if a row is a divider # or a cell part for index in range(len(rows)): tmpstr = rows[index][1:len(rows[index])-1] if TDdivider(tmpstr): indexes.append("TDdivider") elif THdivider(tmpstr): indexes.append("THdivider") else: indexes.append("cell")
2,621
def dav__init(self, request, response): # Init expected HTTP 1.1 / WebDAV headers which are not # currently set by the response object automagically. # Note we set an borg-specific header for ie5 :( response.setHeader('Date', rfc1123_date(), 1) response.setHeader('MS-Author-Via', 'DAV')
def dav__init(self, request, response): # Init expected HTTP 1.1 / WebDAV headers which are not # currently set by the response object automagically. # Note we set an borg-specific header for ie5 :( response.setHeader('Date', rfc1123_date(), 1) response.setHeader('MS-Author-Via', 'DAV')
2,622
def SearchableText(self): "The full text of the Help Topic, for indexing purposes" return '%s %s' % (self.title, self.obj)
def SearchableText(self): "The full text of the Help Topic, for indexing purposes" return '%s %s' % (self.title, self.obj)
2,623
def index_html(self, REQUEST): """ """ return self.index_html_(self, REQUEST)
def index_html(self, REQUEST): """ """ return self.index_html_(self, REQUEST)
2,624
def getUser(self, name): """ Returns the user object specified by name. If there is no user named 'name' in the user folder, return None.
def getUser(name): """ Returns the user object specified by name. If there is no user named 'name' in the user folder, return None.
2,625
def getUser(self, name): """ Returns the user object specified by name. If there is no user named 'name' in the user folder, return None.
defgetUser(self,name):"""Returnstheuserobjectspecifiedbyname.Ifthereisnousernamed'name'intheuserfolder,returnNone.
2,626
def getUsers(self): """ Returns a sequence of all user objects which reside in the user folder.
def getUsers(): """ Returns a sequence of all user objects which reside in the user folder.
2,627
def getUsers(self): """ Returns a sequence of all user objects which reside in the user folder.
defgetUsers(self):"""Returnsasequenceofalluserobjectswhichresideintheuserfolder.
2,628
def getUserNames(self): """ Returns a sequence of names of the users which reside in the user folder.
def getUserNames(): """ Returns a sequence of names of the users which reside in the user folder.
2,629
def getUserNames(self): """ Returns a sequence of names of the users which reside in the user folder.
defgetUserNames(self):"""Returnsasequenceofnamesoftheuserswhichresideintheuserfolder.
2,630
def manage_addUser(self, name, password, roles, domains): """ API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects. Implementations that do not support dynamic creation of user objects will raise an error for this method.
def manage_addUser(name, password, roles, domains): """ API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects. Implementations that do not support dynamic creation of user objects will raise an error for this method.
2,631
def manage_addUser(self, name, password, roles, domains): """ API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects. Implementations that do not support dynamic creation of user objects will raise an error for this method.
defmanage_addUser(self,name,password,roles,domains):"""APImethodforcreatinganewuserobject.Notethatnotalluserfolderimplementationssupportdynamiccreationofuserobjects.Implementationsthatdonotsupportdynamiccreationofuserobjectswillraiseanerrorforthismethod.
2,632
def manage_addUser(self, name, password, roles, domains): """ API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects. Implementations that do not support dynamic creation of user objects will raise an error for this method.
def manage_addUser(self, name, password, roles, domains): """ API method for creating a new user object. Note that not all user folder implementations support dynamic creation of user objects. Implementations that do not support dynamic creation of user objects will raise an error for this method.
2,633
def manage_editUser(self, name, password, roles, domains): """ API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes. Implementations that do not support changing of user object attributes will raise an error for this method.
defmanage_editUser(self,name,password,roles,domains):"""APImethodforchanginguserobjectattributes.Notethatnotalluserfolderimplementationssupportchangingofuserobjectattributes.Implementationsthatdonotsupportchangingofuserobjectattributeswillraiseanerrorforthismethod.
2,634
def manage_editUser(self, name, password, roles, domains): """ API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes. Implementations that do not support changing of user object attributes will raise an error for this method.
def manage_editUser(self, name, password, roles, domains): """ API method for changing user object attributes. Note that not all user folder implementations support changing of user object attributes. Implementations that do not support changing of user object attributes will raise an error for this method.
2,635
def manage_delUsers(self, names): """ API method for deleting one or more user objects. Note that not all user folder implementations support deletion of user objects. Implementations that do not support deletion of user objects will raise an error for this method.
defmanage_delUsers(self,names):"""APImethodfordeletingoneormoreuserobjects.Notethatnotalluserfolderimplementationssupportdeletionofuserobjects.Implementationsthatdonotsupportdeletionofuserobjectswillraiseanerrorforthismethod.
2,636
def get_signal_name(n): """Return the symbolic name for signal n. Returns 'unknown' if there is no SIG name bound to n in the signal module. """ global _signals if _signals is None: _signals = {} for k, v in signal.__dict__.items(): startswith = getattr(k, 'startswith', None) if startswith is None: continue if startswith('SIG') and not startswith('SIG_'): _signals[v] = k return _signals.get(n, 'unknown')
def get_signal_name(n): """Return the symbolic name for signal n. Returns 'unknown' if there is no SIG name bound to n in the signal module. """ global _signals if _signals is None: _signals = {} for k, v in signal.__dict__.items(): startswith = getattr(k, 'startswith', None) if startswith is None: continue if startswith('SIG') and not startswith('SIG_'): _signals[v] = k return _signals.get(n, 'signal %d' % n)
2,637
def tpId(self): return self.id
def tpId(self): return self.id
2,638
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, vocab='', vocab_id='', 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,639
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, vocab, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self,REQUEST)
2,640
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) def VocabularyIDs(self): """ returns a list of acquireable vocabularies. Stole this from ZSQLMethods """ ids={} have_id=ids.has_key StringType=type('') while self is not None: if hasattr(self, 'objectValues'): for o in self.objectValues(): if (hasattr(o,'_isAVocabulary') and o._isAVocabulary and hasattr(o,'id')): id=o.id if type(id) is not StringType: id=id() if not have_id(id): if hasattr(o,'title_and_id'): o=o.title_and_id() else: o=id ids[id]=id if hasattr(self, 'aq_parent'): self=self.aq_parent else: self=None ids=map(lambda item: (item[1], item[0]), ids.items()) ids.sort() return ids
2,641
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,642
def __init__(self,id,title=''): self.id=id self.title=title self.threshold = 10000 self._v_total = 0 self._catalog = Catalog()
def __init__(self,id,title=''): self.id=id self.title=title self.threshold = 10000 self._v_total = 0 self._catalog = Catalog()
2,643
def __init__(self,id,title=''): self.id=id self.title=title self.threshold = 10000 self._v_total = 0 self._catalog = Catalog()
def self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) __init__(self,id,title=''): self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) self.id=id self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) self.title=title self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) self.threshold self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) = self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) 10000 self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) self._v_total self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) = self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) 0 self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) self._catalog self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) = self._catalog.addColumn('absolute_url') self._catalog.addIndex('absolute_url', 'FieldIndex') def getVocabulary(self): """ more ack! """ return getattr(self, self.vocab_id) Catalog()
2,644
def catalog_object(self, obj, uid): """ wrapper around catalog """ self._v_total = (self._v_total + self._catalog.catalogObject(obj, uid, self.threshold))
def catalog_object(self, obj, uid): """ wrapper around catalog """ self._v_total = (self._v_total + self._catalog.catalogObject(obj, uid, self.threshold))
2,645
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_permission=None, obj_roles=None, search_sub=0, REQUEST=None, result=None, pre='', apply_func=None, apply_path=''): """Zope Find interface and apply
def ZopeFindAndApply(self, obj, obj_ids=None, obj_metatypes=None, obj_searchterm=None, obj_expr=None, obj_mtime=None, obj_mspec=None, obj_permission=None, obj_roles=None, search_sub=0, REQUEST=None, result=None, pre='', apply_func=None, apply_path=''): """Zope Find interface and apply
2,646
def render(self, md): args=self.args have_arg=args.has_key name=self.__name__
def render(self, md): args=self.args have_arg=args.has_key name=self.__name__
2,647
def validate(self,request,auth='',roles=None):
def validate(self,request,auth='',roles=None):
2,648
def encode_seq(state): "Convert a sequence to an encoded string" state=compress(str(state)) l=len(state) if l > 57: states=[] for i in range(0,l,57): states.append(b2a_base64(state[i:i+57])[:-1]) state=join(states,'') else: state=b2a_base64(state)[:-1] l=find(state,'=') if l >= 0: state=state[:l] return state
def state=translate(state, tplus) encode_seq(state): state=translate(state, tplus) "Convert state=translate(state, tplus) a state=translate(state, tplus) sequence state=translate(state, tplus) to state=translate(state, tplus) an state=translate(state, tplus) encoded state=translate(state, tplus) string" state=translate(state, tplus) state=compress(str(state)) state=translate(state, tplus) l=len(state) state=translate(state, tplus) state=translate(state, tplus) if state=translate(state, tplus) l state=translate(state, tplus) > state=translate(state, tplus) 57: state=translate(state, tplus) states=[] state=translate(state, tplus) for state=translate(state, tplus) i state=translate(state, tplus) in state=translate(state, tplus) range(0,l,57): state=translate(state, tplus) states.append(b2a_base64(state[i:i+57])[:-1]) state=translate(state, tplus) state=join(states,'') state=translate(state, tplus) else: state=translate(state, tplus) state=b2a_base64(state)[:-1] state=translate(state, tplus) state=translate(state, tplus) l=find(state,'=') state=translate(state, tplus) if state=translate(state, tplus) l state=translate(state, tplus) >= state=translate(state, tplus) 0: state=translate(state, tplus) state=state[:l] state=translate(state, tplus) state=translate(state, tplus) return state=translate(state, tplus) state state=translate(state, tplus)
2,649
def decode_seq(state): "Convert an encoded string to a sequence" l=len(state) if l > 76: states=[] j=0 for i in range(l/76): k=j+76 states.append(a2b_base64(state[j:k])) j=k if j < l: state=state[j:] l=len(state) k=l%4 if k: state=state+'='*(4-k) states.append(a2b_base64(state)) state=join(states,'') else: l=len(state) k=l%4 if k: state=state+'='*(4-k) state=a2b_base64(state) state=decompress(state) if find(state,'*') >= 0: raise 'Illegal State', state try: return list(eval(state,{'__builtins__':{}})) except: return []
defstate=translate(state, tminus) decode_seq(state):state=translate(state, tminus) "Convertstate=translate(state, tminus) anstate=translate(state, tminus) encodedstate=translate(state, tminus) stringstate=translate(state, tminus) tostate=translate(state, tminus) astate=translate(state, tminus) sequence"state=translate(state, tminus) state=translate(state, tminus) l=len(state)state=translate(state, tminus) state=translate(state, tminus) ifstate=translate(state, tminus) lstate=translate(state, tminus) >state=translate(state, tminus) 76:state=translate(state, tminus) states=[]state=translate(state, tminus) j=0state=translate(state, tminus) forstate=translate(state, tminus) istate=translate(state, tminus) instate=translate(state, tminus) range(l/76):state=translate(state, tminus) k=j+76state=translate(state, tminus) states.append(a2b_base64(state[j:k]))state=translate(state, tminus) j=kstate=translate(state, tminus) state=translate(state, tminus) ifstate=translate(state, tminus) jstate=translate(state, tminus) <state=translate(state, tminus) l:state=translate(state, tminus) state=state[j:]state=translate(state, tminus) l=len(state)state=translate(state, tminus) k=l%4state=translate(state, tminus) ifstate=translate(state, tminus) k:state=translate(state, tminus) state=state+'='*(4-k)state=translate(state, tminus) states.append(a2b_base64(state))state=translate(state, tminus) state=join(states,'')state=translate(state, tminus) else:state=translate(state, tminus) l=len(state)state=translate(state, tminus) k=l%4state=translate(state, tminus) ifstate=translate(state, tminus) k:state=translate(state, tminus) state=state+'='*(4-k)state=translate(state, tminus) state=a2b_base64(state)state=translate(state, tminus) state=translate(state, tminus) state=decompress(state)state=translate(state, tminus) ifstate=translate(state, tminus) find(state,'*')state=translate(state, tminus) >=state=translate(state, tminus) 0:state=translate(state, tminus) raisestate=translate(state, tminus) 'Illegalstate=translate(state, tminus) State',state=translate(state, tminus) statestate=translate(state, tminus) try:state=translate(state, tminus) returnstate=translate(state, tminus) list(eval(state,{'__builtins__':{}}))state=translate(state, tminus) except:state=translate(state, tminus) returnstate=translate(state, tminus) []state=translate(state, tminus) state=translate(state, tminus)
2,650
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateFactory=0, REQUEST=None): """Add a Z Class """ bases=[] for b in baseclasses: if Products.meta_classes.has_key(b): bases.append(Products.meta_classes[b]) elif hasattr(self, b): bases.append(getattr(self, b)) else: # If self is the "methods" propertysheet # of a ZClass, get the class from the # propertysheet. bases.append(self._getOb(b)) Z=ZClass(id,title,bases) if meta_type: Z._zclass_.meta_type=meta_type self._setObject(id, Z) if CreateFactory and meta_type: self.manage_addDTMLMethod( id+'_addForm', id+' constructor input form', addFormDefault % {'id': id, 'meta_type': meta_type}, ) self.manage_addDTMLMethod( id+'_add', id+' constructor', addDefault % {'id': id}, ) self.manage_addPrincipiaFactory( id+'_factory', id+' factory', meta_type, id+'_addForm', ) if REQUEST is not None: return self.manage_main(self,REQUEST)
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateFactory=0, REQUEST=None): """Add a Z Class """ bases=[] for b in baseclasses: if Products.meta_classes.has_key(b): bases.append(Products.meta_classes[b]) else: # If self is the "methods" propertysheet # of a ZClass, get the class from the # propertysheet. bases.append(self._getOb(b)) Z=ZClass(id,title,bases) if meta_type: Z._zclass_.meta_type=meta_type self._setObject(id, Z) if CreateFactory and meta_type: self.manage_addDTMLMethod( id+'_addForm', id+' constructor input form', addFormDefault % {'id': id, 'meta_type': meta_type}, ) self.manage_addDTMLMethod( id+'_add', id+' constructor', addDefault % {'id': id}, ) self.manage_addPrincipiaFactory( id+'_factory', id+' factory', meta_type, id+'_addForm', ) if REQUEST is not None: return self.manage_main(self,REQUEST)
2,651
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateFactory=0, REQUEST=None): """Add a Z Class """ bases=[] for b in baseclasses: if Products.meta_classes.has_key(b): bases.append(Products.meta_classes[b]) elif hasattr(self, b): bases.append(getattr(self, b)) else: # If self is the "methods" propertysheet # of a ZClass, get the class from the # propertysheet. bases.append(self._getOb(b)) Z=ZClass(id,title,bases) if meta_type: Z._zclass_.meta_type=meta_type self._setObject(id, Z) if CreateFactory and meta_type: self.manage_addDTMLMethod( id+'_addForm', id+' constructor input form', addFormDefault % {'id': id, 'meta_type': meta_type}, ) self.manage_addDTMLMethod( id+'_add', id+' constructor', addDefault % {'id': id}, ) self.manage_addPrincipiaFactory( id+'_factory', id+' factory', meta_type, id+'_addForm', ) if REQUEST is not None: return self.manage_main(self,REQUEST)
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateFactory=0, REQUEST=None): """Add a Z Class """ bases=[] for b in baseclasses: if Products.meta_classes.has_key(b): bases.append(Products.meta_classes[b]) elif hasattr(self, b): bases.append(getattr(self, b)) else: # If self is the "methods" propertysheet # of a ZClass, get the class from the # propertysheet. bases.append(self._getOb(b)) Z=ZClass(id,title,bases) if meta_type: Z._zclass_.meta_type=meta_type self._setObject(id, Z) if CreateFactory and meta_type: self.manage_addDTMLMethod( id+'_addForm', id+' constructor input form', addFormDefault % {'id': id, 'meta_type': meta_type}, ) self.manage_addDTMLMethod( id+'_add', id+' constructor', addDefault % {'id': id}, ) self.manage_addPrincipiaFactory( id+'_factory', id+' factory', meta_type, id+'_addForm', ) if REQUEST is not None: return self.manage_main(self,REQUEST)
2,652
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
2,653
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(requests,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
2,654
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(requests,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
2,655
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(requests,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
2,656
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(timeDict,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
def analyze(files, top, sortf, start=None, end=None, mode='cumulative', resolution=60): beginrequests = {} cumulative = {} finished = [] unfinished = {} decidelines = {} # filename to filepos computed_start = None computed_end = None while 1: tup = get_earliest_file_data(files) if tup is None: break code, id, fromepoch, desc = tup if computed_start is None: computed_start = fromepoch computed_end = fromepoch if start is not None and fromepoch < start: continue if end is not None and fromepoch > end: break if code == 'U': finished.extend(unfinished.values()) unfinished.clear() request = StartupRequest() request.url = desc request.start = int(fromepoch) finished.append(request) continue request = unfinished.get(id) if request is None: if code != "B": continue # garbage at beginning of file request = Request() for pending_req in unfinished.values(): pending_req.active = pending_req.active + 1 unfinished[id] = request t = int(fromepoch) try: request.put(code, t, desc) except: print "Unable to handle entry: %s %s %s"%(code, t, desc) if request.isfinished(): del unfinished[id] finished.append(request) finished.extend(unfinished.values()) requests = finished if mode == 'cumulative': for request in requests: url = request.url stats = cumulative.get(url) if stats is None: stats = Cumulative(url) cumulative[url] = stats stats.put(request) cumulative = cumulative.values() if mode == 'cumulative': dict = cumulative elif mode == 'detailed': dict = requests elif mode == 'timed': dict = requests else: raise "Invalid mode." if mode=='timed': timeDict = {} timesort(timeDict,requests) if start and end: timewrite(timeDict,start,end,resolution) if start and not end: timewrite(timeDict,start,computed_end,resolution) if end and not start: timewrite(timeDict,computed_start,end,resolution) if not end and not start: timewrite(requests,computed_start,computed_end,resolution) else: dict.sort(sortf) write(dict, top)
2,657
def getdate(val): try: val = string.strip(val) year, month, day = int(val[:4]), int(val[5:7]), int(val[8:10]) hour,minute,second=int(val[11:13]),int(val[14:16]),int(val[17:19]) t = time.mktime((year, month, day, hour, minute, second, 0, 0, -1)) return t except: raise ProfileException, "bad date %s" % val
def getdate(val): try: val = string.strip(val) year, month, day = int(val[:4]), int(val[5:7]), int(val[8:10]) hour,minute,second=int(val[11:13]),int(val[14:16]),int(val[17:19]) t = time.mktime((year, month, day, hour, minute, second, 0, 0, -1)) return t except: raise ProfileException, "bad date %s" % val
2,658
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start), tick2str(end), resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
2,659
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" d = {} for r in requests: t = r.start slice = getTimeslice(resolution,t) if d.has_key(slice): d[slice] = d[slice] + 1 else: d[slice] = 1 num = 0 hits = 0 avg_requests = None slices = d.keys() slices.sort() for slice in slices: num = d[slice] if num>max_requests: max_requests = num hits = hits + num if avg_requests is None: avg_requests = num else: avg_requests = (avg_requests + num) / 2 s = tick2str(slice) s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
2,660
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print " Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
2,661
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %s End: %s Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Time #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + " %6d %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak: %6d %4.2lf" % \ (max_requests,max_requests*1.0/resolution)
def timewrite(dict,start,end,resolution): max_requests = 0 print "Start: %sprint " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) End: %sprint " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) Resolution: %d secs" % \ (tick2str(start),tick2str(end),resolution) print "-" * 78 print print "Date/Timeprint " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) #requests requests/second" for t in range(start,end,resolution): s = tick2str(t) num = 0 for tick in range(t,t+resolution): if dict.has_key(tick): num = num + dict[tick] if num>max_requests: max_requests = num s = s + "print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) %6dprint " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) %4.2lf" % (num,num*1.0/resolution) print s print '='*78 print "Peak:print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) %6dprint " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits) %4.2lf" % \ (max_requests,max_requests*1.0/resolution)print " Avg: %6d %4.2lf" % \ (avg_requests,avg_requests*1.0/resolution) print "Total: %6d n/a " % (hits)
2,662
def tick2str(t): return time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime(t))
def tick2str(t): return time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime(t))
2,663
def usage(basic=1): usage = ( """
defusage(basic=1):usage=("""
2,664
def usage(basic=1): usage = ( """
def usage(basic=1): usage = ( """
2,665
def value(self): return str(self._v)[:-1]
def value(self): return str(self._v)[:-1]
2,666
def testStrftimeUnicode(self): dt = DateTime('2002-05-02T08:00:00+00:00') self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), u'Le 02/05/2002 \xe0 10h00')
def testStrftimeUnicode(self): dt = DateTime('2002-05-02T08:00:00+00:00') self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), u'Le 02/05/2002 \xe0 10h00')
2,667
def time(function,*args,**kwargs): from timing import start, finish, milli repeat_range=range(repeat_count) apply(function,args,kwargs) start() for i in repeat_range: apply(function,args,kwargs) finish() return float(milli())/len(repeat_range)
def time(function,*args,**kwargs): repeat_range=range(repeat_count) apply(function,args,kwargs) start() for i in repeat_range: apply(function,args,kwargs) finish() return float(milli())/len(repeat_range)
2,668
def time(function,*args,**kwargs): from timing import start, finish, milli repeat_range=range(repeat_count) apply(function,args,kwargs) start() for i in repeat_range: apply(function,args,kwargs) finish() return float(milli())/len(repeat_range)
def time(function,*args,**kwargs): from timing import start, finish, milli repeat_range=range(repeat_count) apply(function,args,kwargs) t=time.clock() for i in repeat_range: apply(function,args,kwargs) finish() return float(milli())/len(repeat_range)
2,669
def time(function,*args,**kwargs): from timing import start, finish, milli repeat_range=range(repeat_count) apply(function,args,kwargs) start() for i in repeat_range: apply(function,args,kwargs) finish() return float(milli())/len(repeat_range)
def time(function,*args,**kwargs): from timing import start, finish, milli repeat_range=range(repeat_count) apply(function,args,kwargs) start() for i in repeat_range: apply(function,args,kwargs) t=(time.clock()-t)/1000.0 return float(t)/len(repeat_range)
2,670
def restrictedTraverse(self, path, securityManager, get=getattr, has=hasattr, N=None, M=[], TupleType=type(()) ): REQUEST = {'path': path} REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy! if not path[0]: # If the path starts with an empty string, go to the root first. self = self.getPhysicalRoot() if not securityManager.validateValue(self): raise Unauthorized, name path.pop(0) path.reverse() validate = securityManager.validate object = self while path: __traceback_info__ = REQUEST name = path.pop() if isinstance(name, TupleType): object = apply(object, name) continue if name[0] == '_': # Never allowed in a URL. raise AttributeError, name if name=='..': o = get(object, 'aq_parent', M) if o is not M: if not validate(object, object, name, o): raise Unauthorized, name object=o continue t=get(object, '__bobo_traverse__', N) if t is not N: o=t(REQUEST, name) container = None if has(o, 'im_self'): container = o.im_self elif (has(get(object, 'aq_base', object), name) and get(object, name) == o): container = object if not validate(object, container, name, o): raise Unauthorized, name else: # Try an attribute. o = get(object, name, M) if o is not M: # Check access to the attribute. if has(object, 'aq_acquire'): object.aq_acquire( name, validate2, validate) else: if not validate(object, object, name, o): raise Unauthorized, name else: # Try an item. try: # XXX maybe in Python 2.2 we can just check whether # the object has the attribute "__getitem__" # instead of blindly catching exceptions. o = object[name] except AttributeError, exc: if str(exc).find('__getitem__') >= 0: # The object does not support the item interface. # Try to re-raise the original attribute error. # XXX I think this only happens with # ExtensionClass instances. get(object, name) raise except TypeError, exc: if str(exc).find('unsubscriptable') >= 0: # The object does not support the item interface. # Try to re-raise the original attribute error. # XXX This is sooooo ugly. get(object, name) raise else: # Check access to the item. if not validate(object, object, name, o): raise Unauthorized, name object = o return object
def restrictedTraverse(self, path, securityManager, get=getattr, has=hasattr, N=None, M=[], TupleType=type(()) ): REQUEST = {'path': path} REQUEST['TraversalRequestNameStack'] = path = path[:] # Copy! if not path[0]: # If the path starts with an empty string, go to the root first. self = self.getPhysicalRoot() if not securityManager.validateValue(self): raise Unauthorized, name path.pop(0) path.reverse() validate = securityManager.validate object = self while path: __traceback_info__ = REQUEST name = path.pop() if isinstance(name, TupleType): object = apply(object, name) continue if name[0] == '_': # Never allowed in a URL. raise AttributeError, name if name=='..': o = get(object, 'aq_parent', M) if o is not M: if not validate(object, object, name, o): raise Unauthorized, name object=o continue t=get(object, '__bobo_traverse__', N) if t is not N: o=t(REQUEST, name) container = None if aq_base(o) is not o: container = aq_parent(aq_inner(o)) elif has(o, 'im_self'): container = o.im_self elif (has(get(object, 'aq_base', object), name) and get(object, name) == o): container = object if not validate(object, container, name, o): raise Unauthorized, name else: # Try an attribute. o = get(object, name, M) if o is not M: # Check access to the attribute. if has(object, 'aq_acquire'): object.aq_acquire( name, validate2, validate) else: if not validate(object, object, name, o): raise Unauthorized, name else: # Try an item. try: # XXX maybe in Python 2.2 we can just check whether # the object has the attribute "__getitem__" # instead of blindly catching exceptions. o = object[name] except AttributeError, exc: if str(exc).find('__getitem__') >= 0: # The object does not support the item interface. # Try to re-raise the original attribute error. # XXX I think this only happens with # ExtensionClass instances. get(object, name) raise except TypeError, exc: if str(exc).find('unsubscriptable') >= 0: # The object does not support the item interface. # Try to re-raise the original attribute error. # XXX This is sooooo ugly. get(object, name) raise else: # Check access to the item. if not validate(object, object, name, o): raise Unauthorized, name object = o return object
2,671
def manage_product_zclass_info(self): r=[] Z=self._zclass Z=getattr(Z, 'aq_self', Z) for d in self.aq_acquire('_getProductRegistryData')('zclasses'): z=d['meta_class'] if hasattr(z._zclass_,'_p_deactivate'): # Eek, persistent continue x={} x.update(d) x['selected'] = (z is Z) and 'selected' or '' del x['meta_class'] r.append(x)
def manage_product_zclass_info(self): r=[] Z=self._zclass Z=getattr(Z, 'aq_self', Z) for d in self.aq_acquire('_getProductRegistryData')('zclasses'): z=d['meta_class'] if hasattr(z._zclass_,'_p_deactivate'): # Eek, persistent continue x={} x.update(d) x['selected'] = (z is Z) and 'selected' or '' del x['meta_class'] r.append(x)
2,672
def setColorizableTexts(self, v): pass
def setColorizableTexts(self, v): pass
2,673
def doc_numbered( self, paragraph, expr = re.compile(r'(\s*[%s]+\.)|(\s*[0-9]+\.)|(\s*[0-9]+\s+)' % letters).match): # This is the old expression. It had a nasty habit # of grabbing paragraphs that began with a single # letter word even if there was no following period. #expr = re.compile('\s*' # '(([a-zA-Z]|[0-9]+|[ivxlcdmIVXLCDM]+)\.)*' # '([a-zA-Z]|[0-9]+|[ivxlcdmIVXLCDM]+)\.?' # '\s+').match): top=paragraph.getColorizableTexts()[0] m=expr(top) if not m: return None subs=paragraph.getSubparagraphs() if top[-2:]=='::': subs=[StructuredTextExample(subs)] top=top[:-1] return StructuredTextNumbered(top[m.span()[1]:], subs, indent=paragraph.indent, number=top[:m.span()[1]])
def doc_numbered( self, paragraph, expr = re.compile(r'(\s*[%s]\.)|(\s*[0-9]+\.)|(\s*[0-9]+\s+)' % letters).match): # This is the old expression. It had a nasty habit # of grabbing paragraphs that began with a single # letter word even if there was no following period. #expr = re.compile('\s*' # '(([a-zA-Z]|[0-9]+|[ivxlcdmIVXLCDM]+)\.)*' # '([a-zA-Z]|[0-9]+|[ivxlcdmIVXLCDM]+)\.?' # '\s+').match): top=paragraph.getColorizableTexts()[0] m=expr(top) if not m: return None subs=paragraph.getSubparagraphs() if top[-2:]=='::': subs=[StructuredTextExample(subs)] top=top[:-1] return StructuredTextNumbered(top[m.span()[1]:], subs, indent=paragraph.indent, number=top[:m.span()[1]])
2,674
def doc_header(self, paragraph, expr=re.compile(r'[ %s0-9.:/,-_*<>\?\'\"]+' % letters).match): subs=paragraph.getSubparagraphs() if not subs: return None top=paragraph.getColorizableTexts()[0] if not strip(top): return None if top[-2:]=='::': subs=StructuredTextExample(subs) if strip(top)=='::': return subs # copy attrs when returning a paragraph kw = {} atts = getattr(paragraph, '_attributes', []) for att in atts: kw[att] = getattr(paragraph, att) return apply(ST.StructuredTextParagraph, (top[:-1], [subs]), kw)
def doc_header(self, paragraph): subs=paragraph.getSubparagraphs() if not subs: return None top=paragraph.getColorizableTexts()[0] if not strip(top): return None if top[-2:]=='::': subs=StructuredTextExample(subs) if strip(top)=='::': return subs # copy attrs when returning a paragraph kw = {} atts = getattr(paragraph, '_attributes', []) for att in atts: kw[att] = getattr(paragraph, att) return apply(ST.StructuredTextParagraph, (top[:-1], [subs]), kw)
2,675
def doc_literal( self, s, expr=re.compile( r"(?:\s|^)'" # open r"([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents r"'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
def doc_literal( self, s, expr=re.compile( r"(?:\s|^)'" # open r"([^ \t\n\r\f\v']|[^ \t\n\r\f\v'][^\n']*[^ \t\n\r\f\v'])" # contents r"'(?:\s|[,.;:!?]|$)" # close ).search): r=expr(s) if r: start, end = r.span(1) return (StructuredTextLiteral(s[start:end]), start-1, end+1) else: return None
2,676
def doc_emphasize( self, s, expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search ):
def doc_emphasize( self, s, expr = re.compile(r'\*([%s%s%s\s]+?)\*' % (letters, digits, strongem_punc)).search ):
2,677
def doc_inner_link(self, s, expr1 = re.compile(r"\.\.\s*").search, expr2 = re.compile(r"\[[%s0-9]+\]" % letters ).search): # make sure we dont grab a named link if expr2(s) and expr1(s): start1,end1 = expr1(s).span() start2,end2 = expr2(s).span() if end1 == start2: # uh-oh, looks like a named link return None else: # the .. is somewhere else, ignore it return (StructuredTextInnerLink(s[start2+1,end2-1],start2,end2)) return None elif expr2(s) and not expr1(s): start,end = expr2(s).span() return (StructuredTextInnerLink(s[start+1:end-1]),start,end) return None
def doc_inner_link(self, s, expr1 = re.compile(r"\.\.\s*").search, expr2 = re.compile(r"\[[%s%s]+\]" % (letters, digits) ).search): # make sure we dont grab a named link if expr2(s) and expr1(s): start1,end1 = expr1(s).span() start2,end2 = expr2(s).span() if end1 == start2: # uh-oh, looks like a named link return None else: # the .. is somewhere else, ignore it return (StructuredTextInnerLink(s[start2+1,end2-1],start2,end2)) return None elif expr2(s) and not expr1(s): start,end = expr2(s).span() return (StructuredTextInnerLink(s[start+1:end-1]),start,end) return None
2,678
def doc_underline(self, s, expr=re.compile(r"\_([%s0-9\s\.,\?]+)\_" % letters).search): result = expr(s) if result: start,end = result.span(1) st,e = result.span() return (StructuredTextUnderline(s[start:end]),st,e) else: return None
def doc_underline(self, s, expr=re.compile(r'_([%s%s%s\s]+)_' % (letters, digits, under_punc)).search): result = expr(s) if result: start,end = result.span(1) st,e = result.span() return (StructuredTextUnderline(s[start:end]),st,e) else: return None
2,679
def doc_strong(self, s, expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search ):
def doc_strong(self, s, expr = re.compile(r'\*\*([%s%s%s\s]+?)\*\*' % (letters, digits, strongem_punc)).search ):
2,680
def doc_strong(self, s, expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search ):
def doc_strong(self, s, expr = re.compile(r'\s*\*([ \n%s0-9.:/;,\'\"\?\-\_\/\=\-\>\<\(\)]+)\*(?!\*|-)' % letters).search ):
2,681
def doc_xref(self, s, expr = re.compile('\[([%s0-9\-.:/;,\n\~]+)\]' % letters).search ): r = expr(s) if r: start, end = r.span(1) return (StructuredTextXref(s[start:end]), start-1, end+1) else: return None
def doc_xref(self, s, expr = re.compile('\[([%s0-9\-.:/;,\n\r\~]+)\]' % letters).search ): r = expr(s) if r: start, end = r.span(1) return (StructuredTextXref(s[start:end]), start-1, end+1) else: return None
2,682
def render(self, md):
def render(self, md):
2,683
def manage_addZCatalog(self, id, title, vocab_id='', REQUEST=None): """Add a ZCatalog object """ id=str(id) title=str(title) vocab_id=str(vocab_id) 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) c=ZCatalog(id, title, vocab_id, self) self._setObject(id, c) if REQUEST is not None: return self.manage_main(self, REQUEST)
2,684
def __init__(self, id, title='', vocab_id='', container=None): self.id=id self.title=title self.vocab_id = vocab_id self.threshold = 10000 self._v_total = 0
def __init__(self, id, title='', vocab_id=None, container=None): self.id=id self.title=title self.vocab_id = vocab_id self.threshold = 10000 self._v_total = 0
2,685
def evaluateBoolean(self, expr): return not not self.evaluate(expr)
def evaluateBoolean(self, expr): return not not self.evaluate(expr)
2,686
def evaluateText(self, expr): text = self.evaluate(expr) if text is not None: text = str(text) return text
def evaluateText(self, expr): text = self.evaluate(expr) if text not in (None, Undefined): text = str(text) return text
2,687
def __init__(self, attrs): distutils.core.Distribution.__init__(self, attrs) self.cmdclass["install"] = ZopeInstall self.cmdclass["install_data"] = ZopeInstallData
def __init__(self, attrs): distutils.core.Distribution.__init__(self, attrs) self.cmdclass["install"] = ZopeInstall self.cmdclass["install_data"] = ZopeInstallData
2,688
def all_meta_types(self): return self.meta_types
def all_meta_types(self): return self.meta_types
2,689
def guarded_getitem(object, index): v = object[index] if getSecurityManager().validate(object, object, index, v): return v raise Unauthorized, 'unauthorized access to element %s' % `i`
def guarded_getitem(object, index): v = object[index] if getSecurityManager().validate(object, object, index, v): return v raise Unauthorized, 'unauthorized access to element %s' % `i`
2,690
def simple_marshal(v): if isinstance(v, StringType): return '' if BooleanType and isinstance(v, BooleanType): return ':boolean' if isinstance(v, IntType): return ':int' if isinstance(v, FloatType): return ':float' if isinstance(v, DateTime): return ':date' return ''
def simple_marshal(v): if isinstance(v, StringType): return '' if isinstance(v, BooleanType): return ':boolean' if isinstance(v, IntType): return ':int' if isinstance(v, FloatType): return ':float' if isinstance(v, DateTime): return ':date' return ''
2,691
def indention(str,front = re.compile("^\s+").match): """ Convert all tabs to the appropriate number of spaces. Find the number of leading spaces. If none, return 0 """ if front(str): start,end = front(str).span() return end-start-1 else: return 0 # no leading spaces
def indention(str,front = re.compile("^\s+").match): """ Convert all tabs to the appropriate number of spaces. Find the number of leading spaces. If none, return 0 """ result = front(str) if result is not None: start, end = result.span() return end-start else: return 0 # no leading spaces
2,692
def ZCache_set(self, ob, data, view_name, keywords, mtime_func): # Note the blatant ignorance of view_name, keywords, and # mtime_func. Standard HTTP accelerators are not able to make # use of this data. REQUEST = ob.REQUEST RESPONSE = REQUEST.RESPONSE anon = 1 u = REQUEST.get('AUTHENTICATED_USER', None) if u is not None: if u.getUserName() != 'Anonymous User': anon = 0 phys_path = ob.getPhysicalPath() if self.hit_counts.has_key(phys_path): hits = self.hit_counts[phys_path] else: self.hit_counts[phys_path] = hits = [0,0] if anon: hits[0] = hits[0] + 1 else: hits[1] = hits[1] + 1
def ZCache_set(self, ob, data, view_name, keywords, mtime_func): # Note the blatant ignorance of view_name, keywords, and # mtime_func. Standard HTTP accelerators are not able to make # use of this data. REQUEST = ob.REQUEST RESPONSE = REQUEST.RESPONSE anon = 1 u = REQUEST.get('AUTHENTICATED_USER', None) if u is not None: if u.getUserName() != 'Anonymous User': anon = 0 phys_path = ob.getPhysicalPath() if self.hit_counts.has_key(phys_path): hits = self.hit_counts[phys_path] else: self.hit_counts[phys_path] = hits = [0,0] if anon: hits[0] = hits[0] + 1 else: hits[1] = hits[1] + 1
2,693
def logmsg(self, event): # log a service event using servicemanager.LogMsg try: servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, event, (self._svc_name_, " (%s)" % self._svc_display_name_)) except win32api.error, details: # Failed to write a log entry - most likely problem is # that the event log is full. We don't want this to kill us print "FAILED to write INFO event", event, ":", details
def logmsg(self, event): # log a service event using servicemanager.LogMsg try: servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, event, (self._svc_name_, " (%s)" % self._svc_display_name_)) except win32api.error, details: # Failed to write a log entry - most likely problem is # that the event log is full. We don't want this to kill us print "FAILED to write INFO event", event, ":", details
2,694
def _dolog(self, func, msg): try: fullmsg = "%s (%s): %s" % \ (self._svc_name_, self._svc_display_name_, msg) func(fullmsg) except win32api.error, details: # Failed to write a log entry - most likely problem is # that the event log is full. We don't want this to kill us print "FAILED to write event log entry:", details print msg
def _dolog(self, func, msg): try: fullmsg = "%s (%s): %s" % \ (self._svc_name_, self._svc_display_name_, msg) func(fullmsg) except win32api.error, details: # Failed to write a log entry - most likely problem is # that the event log is full. We don't want this to kill us print "FAILED to write event log entry:", details print msg
2,695
def do_start(self, arg): self.get_status() if not self.zd_up: args = [ self.options.python, self.options.zdrun, ] args += self._get_override("-S", "schemafile") args += self._get_override("-C", "configfile") args += self._get_override("-b", "backofflimit") args += self._get_override("-d", "daemon", flag=1) args += self._get_override("-f", "forever", flag=1) args += self._get_override("-s", "sockname") args += self._get_override("-u", "user") args += self._get_override("-m", "umask") args += self._get_override( "-x", "exitcodes", ",".join(map(str, self.options.exitcodes))) args += self._get_override("-z", "directory") args.extend(self.options.program) if self.options.daemon: flag = os.P_NOWAIT else: flag = os.P_WAIT os.spawnvp(flag, args[0], args) elif not self.zd_pid: self.send_action("start") else: print "daemon process already running; pid=%d" % self.zd_pid return self.awhile(lambda: self.zd_pid, "daemon process started, pid=%(zd_pid)d")
def do_start(self, arg): self.get_status() if not self.zd_up: args = [ self.options.python, self.options.zdrun, ] args += self._get_override("-S", "schemafile") args += self._get_override("-C", "configfile") args += self._get_override("-b", "backofflimit") args += self._get_override("-d", "daemon", flag=1) args += self._get_override("-f", "forever", flag=1) args += self._get_override("-s", "sockname") args += self._get_override("-u", "user") args += self._get_override("-m", "umask", oct(self.options.umask)) args += self._get_override( "-x", "exitcodes", ",".join(map(str, self.options.exitcodes))) args += self._get_override("-z", "directory") args.extend(self.options.program) if self.options.daemon: flag = os.P_NOWAIT else: flag = os.P_WAIT os.spawnvp(flag, args[0], args) elif not self.zd_pid: self.send_action("start") else: print "daemon process already running; pid=%d" % self.zd_pid return self.awhile(lambda: self.zd_pid, "daemon process started, pid=%(zd_pid)d")
2,696
def import_products(): # Try to import each product, checking for and catching errors. done={} products = get_products() debug_mode = App.config.getConfiguration().debug_mode for priority, product_name, index, product_dir in products: if done.has_key(product_name): LOG.warn('Duplicate Product name', 'After loading Product %s from %s,\n' 'I skipped the one in %s.\n' % ( `product_name`, `done[product_name]`, `product_dir`) ) continue done[product_name]=product_dir import_product(product_dir, product_name, raise_exc=debug_mode) return done.keys()
def import_products(): # Try to import each product, checking for and catching errors. done={} products = get_products() debug_mode = App.config.getConfiguration().debug_mode for priority, product_name, index, product_dir in products: if done.has_key(product_name): LOG.warn('Duplicate Product name: ' 'After loading Product %s from %s, ' 'I skipped the one in %s.' % ( `product_name`, `done[product_name]`, `product_dir`) ) continue done[product_name]=product_dir import_product(product_dir, product_name, raise_exc=debug_mode) return done.keys()
2,697
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,698
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,699