rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
class Prefix: __no_side_effects__=1 def __init__(self, path): self.value = len(path), path def __cmp__(self, o): l,v = self.value rval = cmp(o[:l],v) return rval | def manage_undo_transactions(self, transaction_info=(), REQUEST=None): """ """ undo=Globals.UndoManager.undo for tid in transaction_info: tid=tid.split() if tid: get_transaction().note("Undo %s" % ''.join(tid[1:])) tid=decode64(tid[0]) undo(tid) | |
code = func.func_code return find_source(code.co_filename, code)[1] | return find_source(func.func_globals['__file__'], func.func_code)[1] | def get_source(func): """Less silly interface to find_source""" # Sheesh code = func.func_code return find_source(code.co_filename, code)[1] |
_interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/%(n)s)*)}' % {'n': NAME_RE}) | _interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE}) | def __repr__(self): return '%s:%s' % (self._name, `self._s`) |
LOG.warn('Duplicate Product name', 'After loading Product %s from %s,\n' 'I skipped the one in %s.\n' % ( | LOG.warn('Duplicate Product name: ' 'After loading Product %s from %s, ' 'I skipped the one in %s.' % ( | 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 Pr... |
self._registered=1 | self._registered = 1 self._finalize = 0 | def _register(self): if not self._registered: try: get_transaction().register(Surrogate(self)) self._begin() self._registered=1 except: pass |
commit=tpc_abort=tpc_begin | commit=tpc_begin | def tpc_begin(self, *ignored): pass |
try: self._finish() finally: self._registered=0 | if self._finalize: try: self._finish() finally: self._registered=0 | def tpc_finish(self, *ignored): try: self._finish() finally: self._registered=0 |
else: host='' | def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: try: host=socket.gethostbyaddr(addr)[0] except: pass if not addr: try: addr=so... | |
else: addr='' | def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: try: host=socket.gethostbyaddr(addr)[0] except: pass if not addr: try: addr=so... | |
if _sz != _alen: continue | def domainSpecMatch(spec, request): if request.has_key('REMOTE_HOST'): host=request['REMOTE_HOST'] else: host='' if request.has_key('REMOTE_ADDR'): addr=request['REMOTE_ADDR'] else: addr='' if not host and not addr: return 0 if not host: try: host=socket.gethostbyaddr(addr)[0] except: pass if not addr: try: addr=so... | |
print handler | def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): """ clear the catalog, then re-index everything """ | |
def manage_edit(self,file,title,content_type='',acl_type='A',acl_roles=[], REQUEST=None): | def manage_edit(self,title,file='',content_type='',acl_type='A',acl_roles=[], REQUEST=None): | def manage_edit(self,file,title,content_type='',acl_type='A',acl_roles=[], REQUEST=None): |
vself=self.v_self() | def manage_changeProperties(self, REQUEST=None, **kw): """Change existing object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters.""" if REQUEST is None: props={} else: props=REQUEST if kw: for name, value in kw.items(): props[name]=value propdict=self._propdi... | |
vself._updateProperty(name, value) | self._updateProperty(name, value) | def manage_changeProperties(self, REQUEST=None, **kw): """Change existing object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters.""" if REQUEST is None: props={} else: props=REQUEST if kw: for name, value in kw.items(): props[name]=value propdict=self._propdi... |
message='The title is now "%s"<br>' 'The base is now "%s"<br>' 'The path is now "%s"<br>' % map(escape, (title, base, path)), | message='SiteRoot changed.', | def manage_edit(self, title, base, path, REQUEST=None): '''Set the title, base, and path''' self.__init__(title, base, path) if REQUEST: return MessageDialog(title='SiteRoot changed.', message='The title is now "%s"<br>' 'The base is now "%s"<br>' 'The path is now "%s"<br>' % map(escape, (title, base, path)), action='%... |
stdin = TemporaryFile('wb') | stdin = TemporaryFile('w+b') | def handler(self, conn): from string import split, join, atoi hdr = conn.recv(10) |
raise | def testRunIgnoresParentSignals(self): # Spawn a process which will in turn spawn a zdrun process. # We make sure that the zdrun process is still running even if # its parent process receives an interrupt signal (it should # not be passed to zdrun). zdrun_socket = os.path.join(self.here, 'testsock') zdctlpid = os.spawn... | |
raise | def send_action(action, sockname): """Send an action to the zdrun server and return the response. Return None if the server is not up or any other error happened. """ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: sock.connect(sockname) sock.send(action + "\n") sock.shutdown(1) # We're not writing any m... | |
r=self.ul(r,p,self._str(s[1],level)) | if s[0][-2:]=='::' and s[1]: ps=self.pre(s[1]) else: ps=self._str(s[1],level) r=self.ul(r,p,ps) continue ts_results = ol(s[0], (3,)) if ts_results: p = ts_results[1] if s[0][-2:]=='::' and s[1]: ps=self.pre(s[1]) else: ps=self._str(s[1],level) r=self.ol(r,p,ps) continue ts_results = olp(s[0], (1,)) if ts_results: p = t... | def _str(self,structure,level, # Static bullet=ts_regex.compile('[ \t\n]*[o*-][ \t\n]+\([^\0]*\)' ).match_group, example=ts_regex.compile('[\0- ]examples?:[\0- ]*$' ).search, dl=ts_regex.compile('\([^\n]+\)[ \t]+--[ \t\n]+\([^\0]*\)' ).match_group, nl=ts_regex.compile('\n').search, ol=ts_regex.compile( '[ \t]*\(\([0-9]... |
ts_results = ol(s[0], (3,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) | if nl(s[0]) < 0 and s[1] and s[0][-1:] != ':': t=s[0] r=self.head(r,t,level, self._str(s[1],level and level+1)) | def _str(self,structure,level, # Static bullet=ts_regex.compile('[ \t\n]*[o*-][ \t\n]+\([^\0]*\)' ).match_group, example=ts_regex.compile('[\0- ]examples?:[\0- ]*$' ).search, dl=ts_regex.compile('\([^\n]+\)[ \t]+--[ \t\n]+\([^\0]*\)' ).match_group, nl=ts_regex.compile('\n').search, ol=ts_regex.compile( '[ \t]*\(\([0-9]... |
ts_results = olp(s[0], (1,)) if ts_results: p = ts_results[1] r=self.ol(r,p,self._str(s[1],level)) else: ts_results = dl(s[0], (1,2)) if ts_results: t,d = ts_results[1] r=self.dl(r,t,d,self._str(s[1],level)) else: if example(s[0]) >= 0 and s[1]: r=self.normal(r,s[0],self.pre(s[1])) else: if s[0][-2:]=='::' and s[1]: ... | r=self.normal(r,s[0],self._str(s[1],level)) | def _str(self,structure,level, # Static bullet=ts_regex.compile('[ \t\n]*[o*-][ \t\n]+\([^\0]*\)' ).match_group, example=ts_regex.compile('[\0- ]examples?:[\0- ]*$' ).search, dl=ts_regex.compile('\([^\n]+\)[ \t]+--[ \t\n]+\([^\0]*\)' ).match_group, nl=ts_regex.compile('\n').search, ol=ts_regex.compile( '[ \t]*\(\([0-9]... |
user = str(stat_info[stat.ST_UID].replace(' ','_')) group= str(stat_info[stat.ST_GID].replace(' ','_')) | user = str(stat_info[stat.ST_UID]).replace(' ','_') group= str(stat_info[stat.ST_GID]).replace(' ','_') | def unix_longify (file, stat_info): # for now, only pay attention to the lower bits mode = ('%o' % stat_info[stat.ST_MODE])[-3:] mode = string.join (map (lambda x: mode_table[x], mode), '') if stat.S_ISDIR (stat_info[stat.ST_MODE]): dirchar = 'd' else: dirchar = '-' date = ls_date (long(time.time()), stat_info[stat.ST_... |
mhost.send(self.section(md.this, md), self.mailto, self.mailfrom, self.subject) | def render(self, md): | |
onClick="javascript:window.open("%s/manage_main", "manage_main").focus()" | onClick="javascript:window.open('%s/manage_main', 'manage_main').focus()" | def tutorialShowLesson(self, id, REQUEST): """ Navigate management frame to a given lesson's screen. """ url=self.lessonURL(id, REQUEST) if not url: return """\ |
def extractLayer(func): def wrap(*args, **kw): suite = func(*args, **kw) tc = kw.get('test_class', None) if tc and hasattr(tc, 'layer'): suite.layer = tc.layer return suite return wrap | def extractLayer(func): def wrap(*args, **kw): suite = func(*args, **kw) tc = kw.get('test_class', None) if tc and hasattr(tc, 'layer'): suite.layer = tc.layer return suite return wrap | |
return doctest.DocTestSuite(*self._args, **self._kw) | suite = doctest.DocTestSuite(*self._args, **self._kw) if self._layer is not None: suite.layer = self._layer return suite | def doctestsuite(self): return doctest.DocTestSuite(*self._args, **self._kw) |
return doctest.DocFileSuite(*self._args, **self._kw) | suite = doctest.DocFileSuite(*self._args, **self._kw) if self._layer is not None: suite.layer = self._layer return suite | def docfilesuite(self): return doctest.DocFileSuite(*self._args, **self._kw) |
@extractLayer | def setup_optionflags(self): if 'optionflags' not in self._kw: self._kw['optionflags'] = (doctest.ELLIPSIS | doctest.REPORT_NDIFF | doctest.NORMALIZE_WHITESPACE) | |
module = doctest._normalize_module(module, depth=3) | module = doctest._normalize_module(module) | def ZopeDocTestSuite(module=None, **kw): module = doctest._normalize_module(module, depth=3) return ZopeSuiteFactory(module, **kw).doctestsuite() |
@extractLayer | def ZopeDocTestSuite(module=None, **kw): module = doctest._normalize_module(module, depth=3) return ZopeSuiteFactory(module, **kw).doctestsuite() | |
kw['package'] = doctest._normalize_module(kw.get('package'), depth=3) | kw['package'] = doctest._normalize_module(kw.get('package')) | def ZopeDocFileSuite(*paths, **kw): if kw.get('module_relative', True): kw['package'] = doctest._normalize_module(kw.get('package'), depth=3) return ZopeSuiteFactory(*paths, **kw).docfilesuite() |
@extractLayer | def ZopeDocFileSuite(*paths, **kw): if kw.get('module_relative', True): kw['package'] = doctest._normalize_module(kw.get('package'), depth=3) return ZopeSuiteFactory(*paths, **kw).docfilesuite() | |
module = doctest._normalize_module(module, depth=3) | module = doctest._normalize_module(module) | def FunctionalDocTestSuite(module=None, **kw): module = doctest._normalize_module(module, depth=3) return FunctionalSuiteFactory(module, **kw).doctestsuite() |
@extractLayer | def FunctionalDocTestSuite(module=None, **kw): module = doctest._normalize_module(module, depth=3) return FunctionalSuiteFactory(module, **kw).doctestsuite() | |
kw['package'] = doctest._normalize_module(kw.get('package'), depth=3) | kw['package'] = doctest._normalize_module(kw.get('package')) | def FunctionalDocFileSuite(*paths, **kw): if kw.get('module_relative', True): kw['package'] = doctest._normalize_module(kw.get('package'), depth=3) return FunctionalSuiteFactory(*paths, **kw).docfilesuite() |
self.libdir = os.path.realpath(os.path.join(self.cwd, libdir)) else: self.libdir = os.path.realpath(os.path.join(self.cwd, self.libdir)) if self.libdir not in sys.path: sys.path.insert(0, self.libdir) | self.libdir = os.path.join(self.cwd, libdir) else: self.libdir = os.path.join(self.cwd, self.libdir) real_libdir = os.path.realpath(self.libdir) if real_libdir not in sys.path: sys.path.insert(0, real_libdir) | def __init__(self, build, libdir=None): # Calculate which directories we're going to add to sys.path. self.libdir = "lib/python" # Hack sys.path self.home = os.path.dirname(os.path.realpath(sys.argv[0])) # test.py lives in $ZOPE_HOME/bin when installed ... dir, file = os.path.split(self.home) if file == 'bin': self.hom... |
aq_get=aq_get, None=None, | aq_get=aq_get, | def getOwner(self, info=0, aq_get=aq_get, None=None, UnownableOwner=UnownableOwner, getSecurityManager=getSecurityManager, ): """Get the owner |
expr=re.compile("\_([%s0-9\s\.,\?\/]+)\_" % letters).search): | expr=re.compile("\s*\_([%s0-9\s\.,\?\/]+)\_" % letters).search): | def doc_underline(self, s, expr=re.compile("\_([%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 |
if level > 3: output('<TD COLSPAN="%s"></TD>' % level) elif level > 1: output('<TD></TD>' * level) | if level > 2: output('<TD COLSPAN="%s"></TD>' % level) elif level > 0: output('<TD></TD>' * level) | def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0, args=None): have_arg=args.has_key try: items=self.tpValues() except: items=None if not items and have_arg('leaves'): items=1 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-ite... |
self.stream_write("\n") | self._stream_write("\n") self.col = 0 | def __call__(self): assert self.level == 0 assert self.scopeLevel == 0 self.interpret(self.program) assert self.level == 0 assert self.scopeLevel == 0 if self.col > 0: self.stream_write("\n") |
self.stream.write(s) i = string.rfind(s, '\n') | self._stream_write(s) i = rfind(s, '\n') | def stream_write(self, s): self.stream.write(s) i = string.rfind(s, '\n') if i < 0: self.col = self.col + len(s) else: self.col = len(s) - (i + 1) |
for item in program: methodName = "do_" + item[0] args = item[1:] if self.debug: s = "%s%s%s\n" % (" "*self.level, methodName, | if self.debug: for (opcode, args) in program: s = "%sdo_%s%s\n" % (" "*self.level, opcode, | def interpret(self, program): self.level = self.level + 1 try: for item in program: methodName = "do_" + item[0] args = item[1:] if self.debug: s = "%s%s%s\n" % (" "*self.level, methodName, repr(args)) if len(s) > 80: s = s[:76] + "...\n" sys.stderr.write(s) method = getattr(self, methodName) apply(method, args) fin... |
method = getattr(self, methodName) apply(method, args) | _apply(handlers[opcode], tup + args) else: for (opcode, args) in program: _apply(handlers[opcode], tup + args) | def interpret(self, program): self.level = self.level + 1 try: for item in program: methodName = "do_" + item[0] args = item[1:] if self.debug: s = "%s%s%s\n" % (" "*self.level, methodName, repr(args)) if len(s) > 80: s = s[:76] + "...\n" sys.stderr.write(s) method = getattr(self, methodName) apply(method, args) fin... |
self.startTagCommon(name, attrList, self.endsep) def do_startTag(self, name, attrList): self.startTagCommon(name, attrList, ">") def startTagCommon(self, name, attrList, end): | self.do_startTag(name, attrList, self.endsep) bytecode_handlers["startEndTag"] = do_startEndTag def do_startTag(self, name, attrList, end=">"): | def do_startEndTag(self, name, attrList): self.startTagCommon(name, attrList, self.endsep) |
self.stream_write("<%s%s" % (name, end)) return self.stream_write("<" + name) align = self.col+1 | s = "<%s%s" % (name, end) self.do_rawtextOffset(s, len(s)) return _len = len self._stream_write("<" + name) self.col = self.col + _len(name) + 1 align = self.col + 1 + _len(name) | def startTagCommon(self, name, attrList, end): if not attrList: self.stream_write("<%s%s" % (name, end)) return self.stream_write("<" + name) align = self.col+1 if align >= self.wrap/2: align = 4 # Avoid a narrow column far to the right for item in attrList: if len(item) == 2: name, value = item[:2] else: ok, name, val... |
if len(item) == 2: name, value = item[:2] | if _len(item) == 2: name, value = item | def startTagCommon(self, name, attrList, end): if not attrList: self.stream_write("<%s%s" % (name, end)) return self.stream_write("<" + name) align = self.col+1 if align >= self.wrap/2: align = 4 # Avoid a narrow column far to the right for item in attrList: if len(item) == 2: name, value = item[:2] else: ok, name, val... |
self.col + 1 + len(s) > self.wrap): self.stream_write("\n" + " "*align + s) | self.col + 1 + _len(s) > self.wrap): self._stream_write("\n" + " "*align) self.col = self.col + align | def startTagCommon(self, name, attrList, end): if not attrList: self.stream_write("<%s%s" % (name, end)) return self.stream_write("<" + name) align = self.col+1 if align >= self.wrap/2: align = 4 # Avoid a narrow column far to the right for item in attrList: if len(item) == 2: name, value = item[:2] else: ok, name, val... |
self.stream_write(" " + s) self.stream_write(end) | s = " " + s self._stream_write(s) if "\n" in s: self.col = _len(s) - (rfind(s, "\n") + 1) else: self.col = self.col + _len(s) self._stream_write(end) self.col = self.col + _len(end) bytecode_handlers["startTag"] = do_startTag | def startTagCommon(self, name, attrList, end): if not attrList: self.stream_write("<%s%s" % (name, end)) return self.stream_write("<" + name) align = self.col+1 if align >= self.wrap/2: align = 4 # Avoid a narrow column far to the right for item in attrList: if len(item) == 2: name, value = item[:2] else: ok, name, val... |
if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: | if self.html and lower(name) in BOOLEAN_HTML_ATTRS: | def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva... |
elif not evalue: | elif evalue: value = None else: | def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva... |
else: value = None | def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva... | |
i = string.rfind(name, ":") + 1 | i = rfind(name, ":") + 1 | def attrAction(self, item): name, value = item[:2] try: action = self.actionIndex[item[2]] except KeyError: raise TALError, ('Error in TAL program', self.position) if not self.showtal and action > 1: return 0, name, value ok = 1 if action <= 1 and self.tal: if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS: eva... |
self.stream_write("</%s>" % name) | s = "</%s>" % name self._stream_write(s) self.col = self.col + len(s) bytecode_handlers["endTag"] = do_endTag | def do_endTag(self, name): self.stream_write("</%s>" % name) |
if not self.tal: return value = self.engine.evaluateValue(expr) self.engine.setLocal(name, value) | if self.tal: value = self.engine.evaluateValue(expr) self.engine.setLocal(name, value) bytecode_handlers["setLocal"] = do_setLocal | def do_setLocal(self, name, expr): if not self.tal: return value = self.engine.evaluateValue(expr) self.engine.setLocal(name, value) |
if not self.tal: return value = self.engine.evaluateValue(expr) self.engine.setGlobal(name, value) | if self.tal: value = self.engine.evaluateValue(expr) self.engine.setGlobal(name, value) bytecode_handlers["setGlobal"] = do_setGlobal | def do_setGlobal(self, name, expr): if not self.tal: return value = self.engine.evaluateValue(expr) self.engine.setGlobal(name, value) |
text = cgi.escape(text) self.stream_write(text) | self.stream_write(cgi.escape(text)) bytecode_handlers["insertText"] = do_insertText | def do_insertText(self, expr, block): if not self.tal: self.interpret(block) return text = self.engine.evaluateText(expr) if text is None: return if text is self.Default: self.interpret(block) return text = cgi.escape(text) self.stream_write(text) |
if not repldict and not self.strictinsert: | if not (repldict or self.strictinsert): | def do_insertStructure(self, expr, repldict, block): if not self.tal: self.interpret(block) return structure = self.engine.evaluateStructure(expr) if structure is None: return if structure is self.Default: self.interpret(block) return text = str(structure) if not repldict and not self.strictinsert: # Take a shortcut, n... |
def do_rawtext(self, text): self.stream_write(text) | bytecode_handlers["loop"] = do_loop def do_rawtextColumn(self, s, col): self._stream_write(s) self.col = col bytecode_handlers["rawtextColumn"] = do_rawtextColumn def do_rawtextOffset(self, s, offset): self._stream_write(s) self.col = self.col + offset bytecode_handlers["rawtextOffset"] = do_rawtextOffset | def do_loop(self, name, expr, block): if not self.tal: self.interpret(block) return iterator = self.engine.setRepeat(name, expr) while iterator.next(): self.interpret(block) |
if useSplitter: self.useSplitter = userSplitter | self.useSplitter = useSplitter | def __init__(self,useSplitter=None): self.clear() if useSplitter: self.useSplitter = userSplitter self.SplitterFunc = Splitter.getSplitter(self.useSplitter) |
@extractLayer | def setup_optionflags(self): if 'optionflags' not in self._kw: self._kw['optionflags'] = (doctest.ELLIPSIS | doctest.REPORT_NDIFF | doctest.NORMALIZE_WHITESPACE) | |
@extractLayer | def ZopeDocTestSuite(module=None, **kw): module = doctest._normalize_module(module) return ZopeSuiteFactory(module, **kw).doctestsuite() | |
@extractLayer | def ZopeDocFileSuite(*paths, **kw): if kw.get('module_relative', True): kw['package'] = doctest._normalize_module(kw.get('package')) return ZopeSuiteFactory(*paths, **kw).docfilesuite() | |
@extractLayer | def FunctionalDocTestSuite(module=None, **kw): module = doctest._normalize_module(module) return FunctionalSuiteFactory(module, **kw).doctestsuite() | |
x, wx = merge.pop_smallest() y, wy = merge.pop_smallest() | (x, wx), dummy = merge.pop_smallest() (y, wy), dummy = merge.pop_smallest() | def _union(self, L): if not L: return IIBTree() # Balance unions as closely as possible, smallest to largest. merge = NBest(len(L)) for x, weight in L: merge.add((x, weight), len(x)) while len(merge) > 1: # Merge the two smallest so far, and add back to the queue. x, wx = merge.pop_smallest() y, wy = merge.pop_smallest... |
__tracenack_info__=type(ob), ob.__class__ | def manage_pasteObjects(self, cb_copy_data=None, REQUEST=None): """Paste previously copied objects into the current object. If calling manage_pasteObjects from python code, pass the result of a previous call to manage_cutObjects or manage_copyObjects as the first argument.""" cp=None if cb_copy_data is not None: cp=cb_... | |
if name != 'Anonymous': | if name != 'Anonymous User': | def _setObject(self,id,object,roles=None,user=None): v=self._checkId(id) if v is not None: id=v try: t=object.meta_type except: t=None self._objects=self._objects+({'id':id,'meta_type':t},) self._setOb(id,object) # Try to give user the local role "Owner". if hasattr(self, 'REQUEST') and hasattr(object, '__ac_local_r... |
pid = os.fork() if pid: sys.exit(0) posix.setsid() | if not os.environ.has_key('Z_DEBUG_MODE'): pid = os.fork() if pid: sys.exit(0) posix.setsid() | def run(argv, pidfile=''): if os.environ.has_key('ZDAEMON_MANAGED'): # We're the child at this point. Don't ask. :/ return os.environ['ZDAEMON_MANAGED']='TRUE' while 1: pid = os.fork() if pid: sys.exit(0) posix.setsid() lastt=time.time() try: pid = forkit() if pid is None: raise ForkError elif pid: # Parent psta... |
base64.decodestring(split(auth)[-1]).split(':') | base64.decodestring(auth.split()[-1]).split(':') | def _authUserPW(self): global base64 auth=self._auth if auth: if auth[:6].lower() == 'basic ': if base64 is None: import base64 [name,password] = \ base64.decodestring(split(auth)[-1]).split(':') return name, password |
manage_FTPget=index_html | def manage_FTPget(self): """Return body for ftp.""" return str(self.data) | def __len__(self): return 1 |
output('<TD WIDTH="16"></TD>\n') | output('<TD WIDTH="16">%s</TD>\n' % icoSpace) | def tpRenderTABLE(self, id, root_url, url, state, substate, diff, data, colspan, section, md, treeData, level=0, args=None): "Render a tree as a table" have_arg=args.has_key if level >= 0: tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url ... |
return marshal.dumps((self.id,stat)) | if callable(self.id): id=self.id() else: id=self.id return marshal.dumps((id,stat)) | def manage_FTPlist(self,REQUEST): """Directory listing for FTP. In the case of non-Foldoid objects, the listing should contain one object, the object itself.""" stat=marshal.loads(self.manage_FTPstat(REQUEST)) return marshal.dumps((self.id,stat)) |
for name in ('version.txt', 'VERSION.TXT', 'VERSION.txt'): version_txt=path_join(package_dir, name) if not exists(version_txt): continue | version_txt = None for name in ('VERSION.TXT', 'VERSION.txt', 'version.txt'): if exists(path_join(package_dir, name)): version_txt = v break if version_txt is not None: | def version_list(self): # Return a list of currently installed products/versions path_join=os.path.join isdir=os.path.isdir exists=os.path.exists strip=string.strip |
RESPONSE.setHeader('Content-Length', self.size) | def _if_modified_since_request_handler(self, REQUEST, RESPONSE): # HTTP If-Modified-Since header handling: return True if # we can handle this request by returning a 304 response header=REQUEST.get_header('If-Modified-Since', None) if header is not None: header=header.split( ';')[0] # Some proxies seem to send invalid ... | |
$Id: Publish.py,v 1.27 1996/12/30 14:36:12 jim Exp $""" | $Id: Publish.py,v 1.28 1997/01/08 23:22:45 jim Exp $""" | def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam |
__version__='$Revision: 1.27 $'[11:-2] | __version__='$Revision: 1.28 $'[11:-2] | def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam |
return string.atoi(v) | if v: return string.atoi(v) raise ValueError, 'Empty entry when integer expected' | def field2int(v): try: v=v.read() except: v=str(v) return string.atoi(v) |
return string.atof(v) | if v: return string.atof(v) raise ValueError, 'Empty entry when floating-point number expected' | def field2float(v): try: v=v.read() except: v=str(v) return string.atof(v) |
return string.atol(v) | if v: return string.atol(v) raise ValueError, 'Empty entry when integer expected' | def field2long(v): try: v=v.read() except: v=str(v) return string.atol(v) |
if not withValues: | if not withLengths: | def uniqueValues( self, name=None, withLengths=0 ): """ Return a list of unique values for 'name'. |
def absolute_url(self, relative=0): """Return an absolute url to the object. Note that the url will reflect the acquisition path of the object if the object has been acquired.""" if relative: return '' return self.aq_acquire('REQUEST').script | def MOVE(self, REQUEST, RESPONSE): """Move a resource to a new location.""" self.dav__init(REQUEST, RESPONSE) raise 'Forbidden', 'This resource cannot be moved.' | |
try: import pwd try: try: UID = int(UID) except: pass gid = None if type(UID) == type(""): uid = pwd.getpwnam(UID)[2] gid = pwd.getpwnam(UID)[3] elif type(UID) == type(1): uid = pwd.getpwuid(UID)[2] gid = pwd.getpwuid(UID)[3] else: raise KeyError try: if gid is not None: try: os.setgid(gid) except OSError: pass os.s... | 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... | |
info = format_exception(exc[0], exc[1], exc[2], limit=200) | info = ''.join(format_exception(exc[0], exc[1], exc[2], limit=200)) | def logBadRefresh(productid): exc = sys.exc_info() try: LOG('Refresh', ERROR, 'Exception while refreshing %s' % productid, error=exc) if hasattr(exc[0], '__name__'): error_type = exc[0].__name__ else: error_type = str(exc[0]) error_value = str(exc[1]) info = format_exception(exc[0], exc[1], exc[2], limit=200) refresh_e... |
self.insertBase() | def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base self.insertBase() | |
if self.headers.get('content-type', '')[:9] != 'text/html': | content_type = self.headers.get('content-type', '')[:9] if content_type and (content_type != 'text/html'): | def insertBase(self, base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)', regex.casefold).search ): # Only insert a base tag if content appears to be html. if self.headers.get('content-type', '')[:9] != 'text/html': return |
def getOwner(self, info=0): | def getOwner(self, info=0, aq_get=aq_get, None=None, UnownableOwner=UnownableOwner, getSecurityManager=getSecurityManager, ): | def getOwner(self, info=0): """Get the owner |
return self.getOwnerTuple() return aq_base(self.getWrappedOwner()) | owner=aq_get(self, '_owner', None, 1) if info or (owner is None): return owner if owner is UnownableOwner: return None udb, oid = owner root=self.getPhysicalRoot() udb=root.unrestrictedTraverse(udb, None) if udb is None: user = SpecialUsers.nobody else: user = udb.getUserById(oid, None) if user is None: user = Speci... | def getOwner(self, info=0): """Get the owner |
self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), u'Le 02/05/2002 \xe0 10h00') | ok = dt.strftime('Le %d/%m/%Y a %Hh%M').replace('a', u'\xe0') self.assertEqual(dt.strftime(u'Le %d/%m/%Y \xe0 %Hh%M'), ok) | 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') |
return getattr(folder, id) | return folder._getOb(id) | def createInObjectManager(self, id, REQUEST, RESPONSE=None): """ Create Z instance. If called with a RESPONSE, the RESPONSE will be redirected to the management screen of the new instance's parent Folder. Otherwise, the instance will be returned. """ i=mapply(self._zclass_, (), REQUEST) if not hasattr(i, 'id') or not i... |
if StructuredText is None: from StructuredText import html_with_references return str(html_with_references(str(v),level=3,header=0)) | if StructuredText is None: from StructuredText.StructuredText import HTML return HTML(str(v),level=3,header=0) | def structured_text(v, name='(Unknown name)', md={}): global StructuredText if StructuredText is None: from StructuredText import html_with_references return str(html_with_references(str(v),level=3,header=0)) |
print "setting addNotificationTarget to %s" % f | def setAddNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface print "setting addNotificationTarget to %s" % f self._addCallback = f | |
print "setting delNotificationTarget to %s" % f | def setDelNotificationTarget(self, f): # We should assert that the callback function 'f' implements # the TransientNotification interface print "setting delNotificationTarget to %s" % f self._delCallback = f | |
elif rawdata.startswith("<!--", i): | elif _contains_at(rawdata, "<!--", i): | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
elif rawdata.startswith("<?", i): | elif _contains_at(rawdata, "<?", i): | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
elif rawdata.startswith("<!", i): | elif _contains_at(rawdata, "<?", i): | def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: match = self.interesting.search(rawdata, i) # < or & if match: j = match.start() else: j = n if i < j: self.handle_data(rawdata[i:j]) i = self.updatepos(i, j) if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): # < ... |
for keys, values in defaults.items(): if not form.has_key(keys) and not form == {}: form[keys]=values else: if not form == {}: if hasattr(values, '__class__') and values.__class__ is record: r = form[keys] for k, v in values.__dict__.items(): if not hasattr(r, k): setattr(r,k,v) form[keys] = r | for keys, values in defaults.items(): if not form.has_key(keys) and not form == {}: form[keys]=values else: if not form == {}: if hasattr(values, '__class__') and values.__class__ is record: r = form[keys] for k, v in values.__dict__.items(): if not hasattr(r, k): setattr(r,k,v) form[keys] = r else: l = form... | def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ") |
l = form[keys] for x in values: if hasattr(x, '__class__') and x.__class__ is record: for k, v in x.__dict__.items(): for y in l: if not hasattr(y, k): setattr(y, k, v) else: if not a in l: l.append(a) form[keys] = l for key in tuple_items.keys(): k=split(key, ".") k,attr=join(k[:-1], "."), k[-1] a = attr w... | for x in item: if hasattr(x, attr): value=tuple(getattr(x,attr)) setattr(x,attr,value) else: if form.has_key(key): item=form[key] item=tuple(form[key]) form[key]=item | def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ") |
if hasattr(productp, 'import_error_'): ie=productp.import_error_ | if hasattr(productp, '__import_error__'): ie=productp.__import_error__ | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p... |
return | return old | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p... |
return product | def initializeProduct(productp, name, home, app): # Initialize a levered product products=app.Control_Panel.Products if hasattr(productp, 'import_error_'): ie=productp.import_error_ else: ie=None try: fver=strip(open(home+'/version.txt').read()) except: fver='' old=None try: if ihasattr(products,name): old=getattr(p... | |
return ('%s:long=%s' % (name, val))[:-1] | value = '%s:long=%s' % (name, val) if value[-1] == 'L': value = value[:-1] return value | def marshal_long(name, val): return ('%s:long=%s' % (name, val))[:-1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.