rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
runner=unittest.TextTestRunner(verbosity=VERBOSE) | runner=unittest.TextTestRunner(verbosity=self.verbosity) | def runSuite(self, suite): runner=unittest.TextTestRunner(verbosity=VERBOSE) runner.run(suite) |
fname, ext=os.path.splitext(name) if name[:4]=='test' and name[-3:]=='.py' and \ name != 'testrunner.py': filepath=os.path.join(pathname, name) if self.smellsLikeATest(filepath): self.runFile(filepath) for name in names: | def runPath(self, pathname): """Run all tests found in the directory named by pathname and all subdirectories.""" if not os.path.isabs(pathname): pathname = os.path.join(self.basepath, pathname) names=os.listdir(pathname) for name in names: fname, ext=os.path.splitext(name) if name[:4]=='test' and name[-3:]=='.py' and ... | |
try: suite=self.getSuiteFromFile(filename) | try: suite=self.getSuiteFromFile(name) | def runFile(self, filename): """Run the test suite defined by filename.""" working_dir = os.getcwd() dirname, name = os.path.split(filename) if dirname: os.chdir(dirname) self.report('Running: %s' % filename) try: suite=self.getSuiteFromFile(filename) except: traceback.print_exc() suite=None if suite is None: self.r... |
suite=None if suite is None: self.report('No test suite found in file:\n%s' % filename) return self.runSuite(suite) | suite=None if suite is not None: self.runSuite(suite) else: self.report('No test suite found in file:\n%s\n' % filename) | def runFile(self, filename): """Run the test suite defined by filename.""" working_dir = os.getcwd() dirname, name = os.path.split(filename) if dirname: os.chdir(dirname) self.report('Running: %s' % filename) try: suite=self.getSuiteFromFile(filename) except: traceback.print_exc() suite=None if suite is None: self.r... |
whether it succeeded. Quiet mode prints a period as each test runs. | whether it succeeded. Running with -q is the same as running with -v1. | def main(args): usage_msg="""Usage: python testrunner.py options If run without options, testrunner will display this usage message. If you want to run all test suites found in all subdirectories of the current working directory, use the -a option. options: -a Run all tests found in all subdirectories of the curre... |
options, arg=getopt.getopt(args, 'ahd:f:q') | verbosity = VERBOSE options, arg=getopt.getopt(args, 'ahd:f:v:q') | def main(args): usage_msg="""Usage: python testrunner.py options If run without options, testrunner will display this usage message. If you want to run all test suites found in all subdirectories of the current working directory, use the -a option. options: -a Run all tests found in all subdirectories of the curre... |
global VERBOSE VERBOSE = 1 | verbosity = 1 | def main(args): usage_msg="""Usage: python testrunner.py options If run without options, testrunner will display this usage message. If you want to run all test suites found in all subdirectories of the current working directory, use the -a option. options: -a Run all tests found in all subdirectories of the curre... |
testrunner=TestRunner(os.getcwd()) | testrunner = TestRunner(os.getcwd(), verbosity=verbosity) | def main(args): usage_msg="""Usage: python testrunner.py options If run without options, testrunner will display this usage message. If you want to run all test suites found in all subdirectories of the current working directory, use the -a option. options: -a Run all tests found in all subdirectories of the curre... |
'--ignore-pyexpat', 'prefix=', | 'ignore-pyexpat', 'prefix=', | def main(): # below assumes this script is in the BASE_DIR/inst directory global PREFIX BASE_DIR=os.path.abspath(os.path.dirname(os.path.dirname(sys.argv[0]))) BUILD_BASE=os.path.join(os.getcwd(), 'build-base') PYTHON=sys.executable MAKEFILE=open(os.path.join(BASE_DIR, 'inst', IN_MAKEFILE)).read() REQUIRE_LF_ENABLED = ... |
if uri[0]=='/': uri=uri[1:] return uri | return urllib.unquote(uri) | def url(self, ftype=urllib.splittype, fhost=urllib.splithost): """Return a SCRIPT_NAME-based url for an object.""" if hasattr(self, 'DestinationURL') and \ callable(self.DestinationURL): url='%s/%s' % (self.DestinationURL(), self.id) else: url=self.absolute_url() type, uri=ftype(url) host, uri=fhost(uri) script_name=se... |
if md.has_key(args['header']): output(md.getitem(args['header'],0)( | doc=args['header'] if hasattr(self, doc): doc=getattr(self, doc) elif md.has_key(doc): doc=md.getitem(args['header'],0) else: doc=None if doc is not None: output(doc( | 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 ... |
treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(md.getitem(args['leaves'],0)( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIGN="TOP">' % (h, (dataspan > 1 and (' COLSPAN="%s"' % dataspan) or ''))), standard_html_footer='</TD></TR>', )) md._pop(1) | doc=args['leaves'] if hasattr(self, doc): doc=getattr(self, doc) elif md.has_key(doc): doc=md.getitem(args['header'],0) else: doc=None if doc is not None: treeData['-tree-substate-']=sub treeData['tree-level']=level md._push(treeData) output(doc( self,md, standard_html_header=( '<TR>%s<TD WIDTH="16"></TD>' '<TD%s VALIG... | 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 ... |
if md.has_key(args['footer']): output(md.getitem(args['footer'],0)( | doc=args['footer'] if hasattr(self, doc): doc=getattr(self, doc) elif md.has_key(doc): doc=md.getitem(args['header'],0) else: doc=None if doc is not None: output(doc( | 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 ... |
$Id: Publish.py,v 1.22 1996/10/25 19:34:27 jim Exp $""" | $Id: Publish.py,v 1.23 1996/10/28 22:13:45 jim Exp $""" | def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam |
__version__='$Revision: 1.22 $'[11:-2] | __version__='$Revision: 1.23 $'[11:-2] | def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam |
self.code[at:at]=rcode | self.code[at + 1:at + 1] = [self.code[at]] self.code[at + 1:at + 1] = rcode del self.code[at] | def insert_code(self, rcode, at = None): opn = self.opn # rcode is passed as a (callables, args) pair rcode = map(apply, rcode[0], rcode[1]) if at is None: at = opn self.code[at:at]=rcode self.opn = opn + len(rcode) return rcode |
result.append(r"fters") | def query(self, pattern): """ """ result = [] for x in self.lexicon.get(pattern): if self.globbing: result.append(self.lexicon._inverseLex[x]) else: result.append(pattern) | |
LOG('UnTextIndex', PROBLEM, | LOG('UnTextIndex', ERROR, | def unindex_object(self, i, tt=type(()) ): """ carefully unindex document with integer id 'i' from the text index and do not fail if it does not exist """ index = self._index unindex = self._unindex val = unindex.get(i, None) if val is not None: for n in val: v = index.get(n, None) if type(v) is tt: del index[n] elif v... |
result[key] = positionsr | result[key] = score,positionsr | def near(self, x, distance = 1): '''\ near(rl, distance = 1) Returns a ResultList containing documents which contain''' result = self.__class__() for key, v in self.items(): try: value = x[key] except KeyError: value = None if value is None: continue positions = v[1] + value[1] positions.sort() positionsr = [] rel... |
return self.__snd_request('UNLOCK', self.uri, headers, body) | return self.__snd_request('UNLOCK', self.uri, headers) | def unlock(self, token, **kw): """Remove the lock identified by token from the resource and all other resources included in the lock. If all resources which have been locked under the submitted lock token can not be unlocked the unlock method will fail.""" headers=self.__get_headers(kw) token='<opaquelocktoken:%s>' % ... |
r.data_record_score__ = 1 | r.data_record_score_ = 1 | def __getitem__(self, index, ttype=type(())): """ Returns instances of self._v_brains, or whatever is passed into self.useBrains. """ if type(index) is ttype: normalized_score, score, key = index r=self._v_result_class(self.data[key]).__of__(self.aq_parent) r.data_record_id_ = key r.data_record_score_ = score r.data_re... |
return '%s&%s=%s' % (url, name, bid) | return '%s&%s=%s' % (url, name, bid) | def encodeUrl(self, url, create=1): """ encode a URL with the browser id as a postfixed query string element """ bid = self.getBrowserId(create) if bid is None: raise BrowserIdManagerErr, 'There is no current browser id.' name = self.getBrowserIdName() if '?' in url: return '%s&%s=%s' % (url, name, bid) else: return '%... |
def objectIds(self,t=None): | def objectIds(self, spec=None): | def objectIds(self,t=None): # Return a list of subobject ids |
if t is not None: if type(t)==type('s'): t=(t,) return filter(None, map(lambda x,v=t: (x['meta_type'] in v) and x['id'] or None, self._objects)) | if spec is not None: if type(spec)==type('s'): spec=[spec] set=[] for ob in self._objects: if ob['meta_type'] in spec: set.append(ob['id']) return set | def objectIds(self,t=None): # Return a list of subobject ids |
def objectValues(self,t=None): | def objectValues(self, spec=None): | def objectValues(self,t=None): # Return a list of the actual subobjects |
if t is not None: if type(t)==type('s'): t=(t,) return filter(None, map(lambda x,v=t,s=self: (x['meta_type'] in v) and getattr(s,x['id']) or None, self._objects)) | if spec is not None: if type(spec)==type('s'): spec=[spec] set=[] for ob in self._objects: if ob['meta_type'] in spec: set.append(getattr(self, ob['id'])) return set | def objectValues(self,t=None): # Return a list of the actual subobjects |
def objectItems(self,t=None): | def objectItems(self, spec=None): | def objectItems(self,t=None): # Return a list of (id, subobject) tuples |
if t is not None: if type(t)==type('s'): t=(t,) return filter(None, map(lambda x,v=t,s=self: (x['meta_type'] in v) and \ (x['id'],getattr(s,x['id'])) or None, self._objects)) | if spec is not None: if type(spec)==type('s'): spec=[spec] set=[] for ob in self._objects: if ob['meta_type'] in spec: set.append((ob['id'], getattr(self, ob['id']))) | def objectItems(self,t=None): # Return a list of (id, subobject) tuples |
CVS = os.path.normcase("CVS") | CVS_DIRS = [os.path.normcase("CVS"), os.path.normcase(".svn")] | def copyskel(sourcedir, targetdir, uid, gid, **replacements): """ This is an independent function because we'd like to import and call it from mkzopeinstance """ # Create the top of the instance: if not os.path.exists(targetdir): os.makedirs(targetdir) # This is fairly ugly. The chdir() makes path manipulation in the... |
if os.path.normcase(name) == CVS: | if os.path.normcase(name) in CVS_DIRS: | def copydir((targetdir, replacements, uid, gid), sourcedir, names): # Don't recurse into CVS directories: for name in names[:]: if os.path.normcase(name) == CVS: names.remove(name) elif os.path.isfile(os.path.join(sourcedir, name)): # Copy the file: sn, ext = os.path.splitext(name) if os.path.normcase(ext) == ".in": ds... |
if k=='' or k in '().012FGIJKLMNTUVX]adeghjlpqrstu}': | if k=='' or k in '().012FGIJKLMNTUVXS]adeghjlpqrstu}': | def refuse_to_unpickle(self): raise pickle.UnpicklingError, 'Refused' |
elif k in [pickle.STRING]: pass | def refuse_to_unpickle(self): raise pickle.UnpicklingError, 'Refused' | |
_should_fail('hello',0) | def _test(): _should_fail('hello',0) _should_succeed('hello') _should_succeed(1) _should_succeed(1L) _should_succeed(1.0) _should_succeed((1,2,3)) _should_succeed([1,2,3]) _should_succeed({1:2,3:4}) _should_fail(open) _should_fail(_junk_class) _should_fail(_junk_class()) | |
manage_menu =HTMLFile('dtml/menu', globals()) | manage_menu =DTMLFile('dtml/menu', globals()) | def tabs_path_info(self, script, path, # Static vars quote=urllib.quote, ): out=[] while path[:1]=='/': path=path[1:] while path[-1:]=='/': path=path[:-1] while script[:1]=='/': script=script[1:] while script[-1:]=='/': script=script[:-1] path=split(path,'/')[:-1] if script: path=[script]+path if not path: return '' sc... |
manage_zmi_prefs=HTMLFile('dtml/manage_zmi_prefs', globals()) | manage_zmi_prefs=DTMLFile('dtml/manage_zmi_prefs', globals()) | def manage_zmi_logout(self, REQUEST, RESPONSE): """Logout current user""" p = getattr(REQUEST, '_logout_path', None) if p is not None: return apply(self.restrictedTraverse(p)) |
else: hide_tracebacks=None | else: hide_tracebacks=1 | def get_module_info(module_name, modules={}, acquire=_l.acquire, release=_l.release, ): if modules.has_key(module_name): return modules[module_name] if module_name[-4:]=='.cgi': module_name=module_name[:-4] acquire() tb=None try: try: module=__import__(module_name, globals(), globals(), ('__doc__',)) realm=module_n... |
self.pt_edit(REQUEST.get('BODY', '')) | text = REQUEST.get('BODY', '') content_type = guess_type('', text) self.pt_edit(text, content_type, self.output_encoding) | def PUT(self, REQUEST, RESPONSE): """ Handle HTTP PUT requests """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) ## XXX this should be unicode or we must pass an encoding self.pt_edit(REQUEST.get('BODY', '')) RESPONSE.setStatus(204) return RESPONSE |
self.REQUEST.RESPONSE.setHeader('Content-Type', self.content_type) return self.read() | return self.pt_render() | def manage_FTPget(self): "Get source for FTP download" self.REQUEST.RESPONSE.setHeader('Content-Type', self.content_type) return self.read() |
for sub in ast[2][2][1:]: | for sub in ast[i][2][1:]: | def item_munge(ast, i): # Munge an item access into a function call name=ast[i][2][1] args=[arglist] append=args.append a=(factor, (power, (atom, (NAME, '_vars')))) a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) append([COMMA,... |
[trailer, [LPAR, '('], args, [RPAR, ')'], ] | [trailer, [LPAR, '('], args, [RPAR, ')']], | def dot_munge(ast, i): # Munge an attribute access into a function call name=ast[i][2][1] args=[arglist] append=args.append a=(factor, (power, (atom, (NAME, '_vars')))) a=(argument, (test, (and_test, (not_test, (comparison, (expr, (xor_expr, (and_expr, (shift_expr, (arith_expr, (term, a))))))))))) append(a) append([CO... |
if not hasattr(Folder, name): setattr(Folder, name, method) | if not hasattr(Folder.Folder, name): setattr(Folder.Folder, name, method) | def install_product(app, product_dir, product_name, meta_types, folder_permissions, raise_exc=0, log_exc=1): path_join=os.path.join isdir=os.path.isdir exists=os.path.exists DictType=type({}) global_dict=globals() silly=('__doc__',) if 1: # Preserve indentation for diff :-) package_dir=path_join(product_dir, product... |
tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl | if level >= 0: tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl | 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 tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl root_url = root_url or tpUrl treeData['tree-item-url']=url treeData['tree-... |
header_re=regex.compile( | header_re=ts_regex.compile( | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), | space_re=ts_regex.compile('\([ \t]+\)'), name_re=ts_regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
if header_re.match(html) < 0: | ts_results = header_re.match_group(html, (1,3)) if not ts_results: | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
headers, html = header_re.group(1,3) | headers, html = ts_results[1] | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
elif space_re.match(headers[i]) >= 0: | continue ts_results = space_re.match_group(headers[i], (1,)) if ts_results: | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
headers[i][len(space_re.group(1)):]) | headers[i][len(ts_results[1]):]) | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
else: i=i+1 | continue i=i+1 | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
if name_re.match(headers[i]) >= 0: k, v = name_re.group(1,2) | ts_results = name_re.match_group(headers[i], (1,2)) if ts_results: k, v = ts_results[1] | def decapitate(html, RESPONSE=None, header_re=regex.compile( '\(\(' '[^\n\0\- <>:]+:[^\n]*\n' '\|' '[ \t]+[^\0\- ][^\n]*\n' '\)+\)[ \t]*\n\([\0-\377]+\)' ), space_re=regex.compile('\([ \t]+\)'), name_re=regex.compile('\([^\0\- <>:]+\):\([^\n]*\)'), ): if header_re.match(html) < 0: return html headers, html = header_re.... |
for key, value in default_stop_words: | for key, value in default_stop_words.items(): | def __init__(self, index_dictionary = None, synstop = None): 'Create an inverted index' if (synstop is None): synstop = {} for key, value in default_stop_words: synstop[key] = value self.synstop = synstop |
try: v,expires,domain,path,secure=self.cookies[name] except: v,expires,domain,path,secure='','','','','' self.cookies[name]=v+value,expires,domain,path,secure | self.setCookie(name,value) | def appendCookie(self, name, value): |
self.cookies[name]='deleted','01-Jan-96 11:11:11 GMT','','','' def setCookie(self,name, value=None, expires=None, domain=None, path=None, secure=None): | self.setCookie(name,'deleted', max_age=0) def setCookie(self,name,value,**kw): | def expireCookie(self, name): |
except: cookie=('')*5 def f(a,b): if b is not None: return b return a self.cookies[name]=tuple(map(f,cookie, (value,expires,domain,path,secure) ) ) | except: cookie=self.cookies[name]={} for k, v in kw.items(): cookie[k]=v cookie['value']=value | def setCookie(self,name, value=None, |
for name in self.cookies.keys(): value,expires,domain,path,secure=self.cookies[name] cookie='set-cookie: %s=%s' % (name,value) if expires: cookie = "%s; expires=%s" % (cookie,expires) if domain: cookie = "%s; domain=%s" % (cookie,domain) if path: cookie = "%s; path=%s" % (cookie,path) if secure: cookie = cookie+'; secu... | for name, attrs in self.cookies.items(): if attrs.has_key('expires'): cookie='set-cookie: %s="%s"' % (name,attrs['value']) else: cookie=('set-cookie: %s="%s"; Version="1"' % (name,attrs['value'])) for name, v in attrs.items(): if name=='expires': cookie = '%s; Expires="%s"' % (cookie,v) elif name=='domain': cookie = '%... | def _cookie_list(self): |
REQUEST['RESPONSE'].setCookie('cp_', 'deleted', | REQUEST['RESPONSE'].setCookie('__cp', 'deleted', | 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_... |
tnamelast='' | tnamelast=None | def _read_and_report(file, rpt=None, fromEnd=0, both=0, n=99999999, show=0): """\ Read a file's index up to the given time. """ first=1 seek=file.seek read=file.read unpack=struct.unpack split=string.split join=string.join find=string.find seek(0,2) file_size=file.tell() gmtime=time.gmtime if fromEnd: pos=file_size el... |
if __name__=='__main__': | def main(argv): | def xmls(pos, oid, start, tname, user, t, p, first, newtrans): write=sys.stdout.write if first: write('<?xml version="1.0">\n<transactions>\n') if pos is None: write('</transaction>\n') write('</transactioons>\n') return if newtrans: if pos > 9: write('</transaction>\n') write('<transaction name="%s" user="%s">\n%s\n... |
opts, args = getopt.getopt(sys.argv[1:],'r:ebl:s:f:p:') | opts, args = getopt.getopt(argv,'r:ebl:s:f:p:') | def xmls(pos, oid, start, tname, user, t, p, first, newtrans): write=sys.stdout.write if first: write('<?xml version="1.0">\n<transactions>\n') if pos is None: write('</transaction>\n') write('</transactioons>\n') return if newtrans: if pos > 9: write('</transaction>\n') write('<transaction name="%s" user="%s">\n%s\n... |
print s | def doc_underline(self, s, expr=re.compile("_([%s0-9\s\.,\?\/]+)_" % letters).search): | |
print "got it" | def doc_underline(self, s, expr=re.compile("_([%s0-9\s\.,\?\/]+)_" % letters).search): | |
_DQUOTEDTEXT = r'("[%s0-9\n%s]+")' % (letters,punctuation) _URL_AND_PUNC = r'([%s0-9_\@%s]+)' % (letters,punctuation) | _DQUOTEDTEXT = r'("[%s0-9\n%s]+")' % (letters,punctuations) _URL_AND_PUNC = r'([%s0-9_\@%s]+)' % (letters,punctuations) | def doc_strong(self, s, expr = re.compile(r'\s*\*\*([ \n%s0-9]+)\*\*' % lettpunc).search ): |
self.getFunction() | self.getFunction(1) | def manage_edit(self, title, module, function, REQUEST=None): |
def getFunction(self): | def getFunction(self, check=0): | def getFunction(self): |
if self.func_defaults != ff.func_defaults: self.func_defaults = ff.func_defaults func_code=FuncCode(ff,f is not ff) if func_code != self.func_code: self.func_code=func_code | func_code=FuncCode(ff,f is not ff) if func_code != self.func_code: self.func_code=func_code | def getFunction(self): |
(othr.co_argcount, othr.co_varnames)) | (other.co_argcount, other.co_varnames)) | def __cmp__(self,other): |
self.handlers = [] for tname,nargs,nsection in blocks[1:]: for errname in string.split(nargs): self.handlers.append((errname,nsection.blocks)) if string.strip(nargs)=='': self.handlers.append(('',nsection.blocks)) | if len(blocks) == 2 and blocks[1][0] == 'finally': self.finallyBlock = blocks[1][2].blocks else: self.handlers = [] defaultHandlerFound = 0 for tname,nargs,nsection in blocks[1:]: if tname == 'else': if not self.elseBlock is None: raise ParseError, ( 'No more than one else block is allowed', self.name) self.elseBlo... | def __init__(self, blocks): tname, args, section = blocks[0] |
return render_blocks(self.section, md) | result = render_blocks(self.section, md) | def render(self, md): # first we try to render the first block try: return render_blocks(self.section, md) except DTReturn: raise except: # but an error occurs.. save the info. t,v = sys.exc_info()[:2] if type(t)==type(''): errname = t else: errname = t.__name__ |
else: if (self.elseBlock is None): return result else: return result + render_blocks(self.elseBlock, md) def render_try_finally(self, md): result = '' try: result = render_blocks(self.section, md) finally: result = result + render_blocks(self.finallyBlock, md) return result | def render(self, md): # first we try to render the first block try: return render_blocks(self.section, md) except DTReturn: raise except: # but an error occurs.. save the info. t,v = sys.exc_info()[:2] if type(t)==type(''): errname = t else: errname = t.__name__ | |
(item.filename is not None or 'content-type' in map(lower, item.headers.keys()))): | (item.filename is not None )): | def processInputs( self, # "static" variables that we want to be local for speed SEQUENCE=1, DEFAULT=2, RECORD=4, RECORDS=8, REC=12, # RECORD|RECORDS EMPTY=16, CONVERTED=32, hasattr=hasattr, getattr=getattr, setattr=setattr, search_type=regex.compile(':[a-zA-Z][a-zA-Z0-9_]+$').search, rfind=string.rfind, ): """Process ... |
fields=self._class(fields, self._parent) | parent=self._parent fields=self._class(fields, parent) | def __getitem__(self,index): |
return fields | if parent is None: return fields return fields.__of__(parent) | def __getitem__(self,index): |
ob=self._p_jar.importFile(file) | connection=self._p_jar obj=self while connection is None: obj=obj.aq_parent connection=obj._p_jar ob=connection.importFile(file) | def manage_importObject(self, file, REQUEST=None): """Import an object from a file""" dirname, file=os.path.split(file) if dirname: raise 'Bad Request', 'Invalid file name %s' % file file=os.path.join(INSTANCE_HOME, 'import', file) if not os.path.exists(file): raise 'Bad Request', 'File does not exist: %s' % file ob=se... |
if isop(q[i]): q[i] = operator_dict[q[i]] | if type(q[i]) is not ListType and isop(q[i]): q[i] = operator_dict[q[i]] | def parse2(q, default_operator, operator_dict = {AndNot: AndNot, And: And, Or: Or, Near: Near}, ListType=type([]), ): '''Find operators and operands''' i = 0 isop=operator_dict.has_key while (i < len(q)): if (type(q[i]) is ListType): q[i] = parse2(q[i], default_operator) # every other item, starting with the first, sh... |
REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method)) | try: REQUEST.RESPONSE.notFoundError("%s\n%s" % (name, method)) except AttributeError: raise KeyError, name | def __bobo_traverse__(self, REQUEST, name=None): |
self._init() | self._index=BTree() | def clear(self): |
ts=os.stat(self.filepath()) if not hasattr(self, '_v_last_read') or \ (ts != self._v_last_read): | ts=os.stat(self.filepath())[stat.ST_MTIME] if (not hasattr(self, '_v_last_read') or (ts != self._v_last_read)): | def __call__(self, *args, **kw): """Call an ExternalMethod |
class Foo(Acquisition.Implicit): pass | class DummyAqImplicit(Acquisition.Implicit): pass class DummyPersistent(Persistent): pass | def _delDB(): transaction.abort() del stuff['db'] |
def testSubcommit(self): sd = self.app.session_data_manager.getSessionData() sd.set('foo', 'bar') | def testSubcommitAssignsPJar(self): sd = self.app.session_data_manager.getSessionData() dummy = DummyPersistent() sd.set('dp', dummy) self.failUnless(sd['dp']._p_jar is None) | def testSubcommit(self): sd = self.app.session_data_manager.getSessionData() sd.set('foo', 'bar') # TODO: this is used to test that transaction.commit(1) returned # None, but transaction.commit(whatever) always returns None (unless # there's an exception). What is this really trying to test? transaction.savepoint(opti... |
a = Foo() b = Foo() | a = DummyAqImplicit() b = DummyAqImplicit() | def testAqWrappedObjectsFail(self): a = Foo() b = Foo() aq_wrapped = a.__of__(b) sd = self.app.session_data_manager.getSessionData() sd.set('foo', aq_wrapped) self.assertRaises(TypeError, transaction.commit) |
that interacts correctly with objects requiring.""" | that interacts correctly with objects providing OFS.interfaces.ITraversable. """ | def boboTraverseAwareSimpleTraverse(object, path_items, econtext): """A slightly modified version of zope.tales.expressions.simpleTraverse that interacts correctly with objects requiring.""" request = getattr(econtext, 'request', None) path_items = list(path_items) path_items.reverse() while path_items: name = path_it... |
'import Zope2; app=Zope2.app();' 'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);' 'transaction.commit()' | 'import Zope2; ' 'app = Zope2.app(); ' 'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []); ' 'import transaction; ' 'transaction.commit(); ' | def do_adduser(self, arg): try: name, password = arg.split() except: print "usage: adduser <name> <password>" return cmdline = self.get_startup_cmd( self.options.python , 'import Zope2; app=Zope2.app();' 'app.acl_users._doAddUser(\'%s\', \'%s\', [\'Manager\'], []);' 'transaction.commit()' ) % (name, password) os.system... |
result = self._lexicon.get(pattern, ()) | result = self._lexicon.get(pattern, None) if result is None: return () | def get(self, pattern): """ Query the lexicon for words matching a pattern.""" wc_set = [self.multi_wc, self.single_wc] |
if object.aq_inContextOf(context, 1): return 1 | return object.aq_inContextOf(context, 1) | def _check_context(self, object): # Check that 'object' exists in the acquisition context of # the parent of the acl_users object containing this user, # to prevent "stealing" access through acquisition tricks. # Return true if in context, false if not or if context # cannot be determined (object is not wrapped). paren... |
elif kw.kas_key('sort_order'): | elif kw.has_key('sort_order'): | def searchResults(self, REQUEST=None, used=None, query_map={ type(regex.compile('')): Query.Regex, type([]): orify, type(''): Query.String, }, **kw): |
if not xhas(id): result[id] = xdict[id]+score | if not xhas(id): result[id] = score | def and_not(self, x): result = {} dict = self._dict xdict = x._dict xhas = xdict.has_key for id, score in dict.items(): if not xhas(id): result[id] = xdict[id]+score return self.__class__(result, self._words, self._index) |
parents=[] | request['PARENTS']=parents=[] | def publish(self, module_name, after_list, published='web_objects', |
else: if (entry_name=='manage' or entry_name[:7]=='manage_'): roles='manage', | def publish(self, module_name, after_list, published='web_objects', | |
parents.append(object) | def publish(self, module_name, after_list, published='web_objects', | |
for i in range(last_parent_index): if hasattr(parents[i],'__allow_groups__'): groups=parents[i].__allow_groups__ else: continue | if hasattr(object, '__allow_groups__'): groups=object.__allow_groups__ inext=0 else: inext=None for i in range(last_parent_index): if hasattr(parents[i],'__allow_groups__'): groups=parents[i].__allow_groups__ inext=i+1 break if inext is not None: i=inext | def publish(self, module_name, after_list, published='web_objects', |
if groups is None: break auth=self.HTTP_AUTHORIZATION | if groups is None: roles=None auth='' | def publish(self, module_name, after_list, published='web_objects', |
break | def publish(self, module_name, after_list, published='web_objects', | |
del parents[0] | def publish(self, module_name, after_list, published='web_objects', | |
if parents: selfarg=parents[0] for i in range(len(parents)): parent=parents[i] if hasattr(parent,'aq_self'): p=parent.aq_self parents[i]=p request['PARENTS']=parents | def publish(self, module_name, after_list, published='web_objects', | |
if argument_name=='self': args.append(selfarg) elif name_index < nrequired: self.badRequestError(argument_name) else: args.append(defaults[name_index-nrequired]) else: args.append(v) if debug: result=self.call_object(object,tuple(args)) else: result=apply(object,tuple(args)) | if argument_name=='self': args.append(parents[0]) elif name_index < nrequired: self.badRequestError(argument_name) else: args.append(defaults[name_index-nrequired]) else: args.append(v) args=tuple(args) if debug: result=self.call_object(object,args) else: result=apply(object,args) | def publish(self, module_name, after_list, published='web_objects', |
str(self,'other'),str(self,'environ')) | str(self,'form'),str(self,'environ')) | def str(self,name): dict=getattr(self,name) return "%s:\n\t%s\n\n" % ( name, join( map(lambda k, d=dict: "%s: %s" % (k, `d[k]`), dict.keys()), "\n\t" ) ) |
if lower(HTTP_AUTHORIZATION[:6]) != 'basic ': return None | if lower(HTTP_AUTHORIZATION[:6]) != 'basic ': if roles is None: return '' return None | def old_validation(groups, HTTP_AUTHORIZATION, roles=UNSPECIFIED_ROLES): global base64 if base64 is None: import base64 if lower(HTTP_AUTHORIZATION[:6]) != 'basic ': return None [name,password] = string.splitfields( base64.decodestring( split(HTTP_AUTHORIZATION)[-1]), ':') if roles is None: return name keys=None try... |
if find('\\') < 0 or (find('\\t') < 0 and find('\\n') < 0): return s | if find(s,'\\') < 0 or (find(s,'\\t') < 0 and find(s,'\\n') < 0): return s | def parse_text(s): if find('\\') < 0 or (find('\\t') < 0 and find('\\n') < 0): return s r=[] for x in split(s,'\\\\'): x=join(split(x,'\\n'),'\n') r.append(join(split(x,'\\t'),'\t')) return join(r,'\\') |
except: doc=getattr(subobject, entry_name+'__doc__') | except: doc=getattr(object, entry_name+'__doc__') | def publish(self, module_name, after_list, published='web_objects', |
if len(e) > 2: | if len(e) >= 2: | def handler(self, conn): from string import split, join, atoi hdr = conn.recv(10) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.