rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self._debug("comment %r", data) | debug(FILTER, "%s comment %r", self, data) | def comment (self, data): """a comment; accept only non-empty comments""" if not (self.comments and data): return self._debug("comment %r", data) item = [COMMENT, data] self.htmlparser.tagbuf.append(item) |
self._debug("doctype %r", data) | debug(FILTER, "%s doctype %r", self, data) | def doctype (self, data): self._debug("doctype %r", data) return self._data("<!DOCTYPE%s>"%data) |
self._debug("pi %r", data) | debug(FILTER, "%s pi %r", self, data) | def pi (self, data): self._debug("pi %r", data) return self._data("<?%s?>"%data) |
self._debug("startElement %r", tag) | debug(FILTER, "%s startElement %r", self, tag) if self._is_waiting([STARTTAG, tag, attrs]): return | def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... |
self._debug("using base url %r", self.base_url) | debug(FILTER, "%s using base url %r", self, self.base_url) | def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... |
self._filterStartElement(tag, attrs) | self.filterStartElement(tag, attrs) | def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... |
def _filterStartElement (self, tag, attrs): | def filterStartElement (self, tag, attrs): | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... |
self._debug("matched rule %r on tag %r", rule.title, tag) | debug(FILTER, "%s matched rule %r on tag %r", self, rule.title, tag) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... |
self._debug("put on buffer") | debug(FILTER, "%s put rule %r on buffer", self, rule.title) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... |
self._jsStartElement(tag, attrs) | self.jsStartElement(tag, attrs) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... |
self._debug("endElement %r", tag) | debug(FILTER, "%s endElement %r", self, tag) if self._is_waiting([ENDTAG, tag]): return | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. |
if not self._filterEndElement(tag): | if not self.filterEndElement(tag): | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. |
self._jsEndElement(item) | self.jsEndElement(item) | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. |
elif self.headers.get('Content-Type') != gm[0]: | elif self.headers.get('Content-Type') != gm[0] and \ gm[0] in _fix_content_types: | def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re.... |
if gm[1] in _fix_content_types: self.headers['Content-Encoding'] = gm[1] | self.headers['Content-Encoding'] = gm[1] | def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re.... |
f = file(self['configfile'], 'w') | f = file(self.configfile, 'w') | def write_proxyconf (self): """write proxy configuration""" f = file(self['configfile'], 'w') f.write("""<?xml version="1.0" encoding="%s"?> |
debug(GUI, "Translator catalog %s", str(translator._catalog)) | def __init__ (self, client, url, form, protocol, status=200, msg=i18n._('Ok'), context={}, headers={'Content-Type': 'text/html'}): self.client = client # we pretend to be the server self.connected = True try: lang = i18n.get_headers_lang(headers) # get the template filename path, dirs, lang = get_template_url(url, lang... | |
if compobj: header = compobj['header'] if header: compobj['header'] = '' wc.log.debug(wc.LOG_FILTER, 'writing gzip header') compobj['size'] += len(data) compobj['crc'] = zlib.crc32(data, compobj['crc']) data = "%s%s" % (header, compobj['compressor'].compress(data)) | header = compobj['header'] if header: compobj['header'] = '' wc.log.debug(wc.LOG_FILTER, 'writing gzip header') compobj['size'] += len(data) compobj['crc'] = zlib.crc32(data, compobj['crc']) data = "%s%s" % (header, compobj['compressor'].compress(data)) | def filter (self, data, **attrs): """Compress the string s. Note that compression state is saved outside of this function in the compression object. """ if self.init_compressor: self.set_encoding_header(attrs) self.init_compressor = False if not attrs.has_key('compressobj'): return data compobj = attrs['compressobj'] i... |
if compobj: header = compobj['header'] if header: wc.log.debug(wc.LOG_FILTER, 'final writing gzip header') pass if data: compobj['size'] += len(data) compobj['crc'] = zlib.crc32(data, compobj['crc']) data = "%s%s" % (header, compobj['compressor'].compress(data)) else: data = header wc.log.debug(wc.LOG_FILTER, 'finishin... | header = compobj['header'] if header: wc.log.debug(wc.LOG_FILTER, 'final writing gzip header') pass if data: compobj['size'] += len(data) compobj['crc'] = zlib.crc32(data, compobj['crc']) data = "%s%s" % (header, compobj['compressor'].compress(data)) else: data = header wc.log.debug(wc.LOG_FILTER, 'finishing compressor... | def finish (self, data, **attrs): """final compression of data, flush gzip buffers""" if not attrs.has_key('compressobj'): return data compobj = attrs['compressobj'] if compobj: header = compobj['header'] if header: wc.log.debug(wc.LOG_FILTER, 'final writing gzip header') pass if data: compobj['size'] += len(data) comp... |
res.append(key[len(prefix):], get_item_value(form[key])) | res.append((key[len(prefix):], get_item_value(form[key]))) | def get_prefix_vals (form, prefix): """return a list of (key, value) pairs where ``prefix+key'' is a valid form field""" res = [] for key in form: if key.startswith(prefix): res.append(key[len(prefix):], get_item_value(form[key])) return res |
dstfinfo = dstfss.GetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 dstfss.SetFInfo(dstfinfo) def main(): dir, ok = macfs.GetDirectory() if not ok: sys.exit(0) os.chdir(dir.as_pathname()) | if __name__ == '__main__': run(1) | def mkalias(src, dst): """Create a finder alias""" srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) alias = srcfss.NewAlias() srcfinfo = srcfss.GetFInfo() Res.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) resource.AddResource('a... |
if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0: sys.exit(0) LibFiles = [] allfiles = os.listdir(':') for f in allfiles: if f[-4:] == '.slb': finfo = macfs.FSSpec(f).GetFInfo() if finfo.Flags & 0x8000: os.unlink(f) else: LibFiles.append(f) | def main(): # Ask the user for the plugins directory dir, ok = macfs.GetDirectory() if not ok: sys.exit(0) os.chdir(dir.as_pathname()) # Remove old .slb aliases and collect a list of .slb files if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0: sys.exit(0) LibFiles = [] allfiles = os.listdir(':'... | |
print LibFiles if EasyDialogs.AskYesNoCancel('Proceed with creating new ones?') <= 0: sys.exit(0) for dst, src in goals: if src in LibFiles: mkalias(src, dst) else: EasyDialogs.Message(dst+' not created: '+src+' not found') EasyDialogs.Message('All done!') if __name__ == '__main__': main() | def main(): # Ask the user for the plugins directory dir, ok = macfs.GetDirectory() if not ok: sys.exit(0) os.chdir(dir.as_pathname()) # Remove old .slb aliases and collect a list of .slb files if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0: sys.exit(0) LibFiles = [] allfiles = os.listdir(':'... | |
def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) | class container: def __init__(self): root = Tk() text = self.text = Text(root) text.pack(side=LEFT, fill=BOTH, expand=1) text.insert("insert", "string.split") root.update() self.calltip = CallTip(text) | def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) |
tc = TC() tests = t1, t2, t3, t4, t5, t6, \ tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6 | text.event_add("<<calltip-show>>", "(") text.event_add("<<calltip-hide>>", ")") text.bind("<<calltip-show>>", self.calltip_show) text.bind("<<calltip-hide>>", self.calltip_hide) text.focus_set() | def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) |
test(tests) | def calltip_show(self, event): self.calltip.showtip("Hello world") def calltip_hide(self, event): self.calltip.hidetip() def main(): c=container() if __name__=='__main__': main() | def test( tests ): failed=[] for t in tests: if get_arg_text(t) != t.__doc__: failed.append(t) print "%s - expected %s, but got %s" % (t, `t.__doc__`, `get_arg_text(t)`) print "%d of %d tests failed" % (len(failed), len(tests)) |
/* For now we declare them forward here. They'll go to mactoolbox later */ staticforward PyObject *TXNObj_New(TXNObject); staticforward int TXNObj_Convert(PyObject *, TXNObject *); staticforward PyObject *TXNFontMenuObj_New(TXNFontMenuObject); staticforward int TXNFontMenuObj_Convert(PyObject *, TXNFontMenuObject *); | def makegreylist(self): return [] | #ifdef WITHOUT_FRAMEWORKS |
// ADD declarations //extern PyObject *_CFTypeRefObj_New(CFTypeRef); //extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *); | def makeblacklisttypes(self): return [ "TXNTab", "TXNMargins", "TXNControlData", "TXNATSUIFeatures", "TXNATSUIVariations", "TXNAttributeData", "TXNTypeAttributes", "TXNMatchTextRecord", "TXNBackground", "UniChar", "TXNFindUPP", ] | #ifdef WITHOUT_FRAMEWORKS |
// // /* ** Parse/generate ADD records */ """ initstuff = initstuff + """ // PyMac_INIT_TOOLBOX_OBJECT_NEW(xxxx); """ TXNObject = OpaqueByValueType("TXNObject", "TXNObj") TXNFontMenuObject = OpaqueByValueType("TXNFontMenuObject", "TXNFontMenuObj") TXNFrameID = Type("TXNFrameID", "l") TXNVersionValue = Type("TXNVer... | def makerepairinstructions(self): return [ ([("void", "*", "OutMode"), ("ByteCount", "*", "InMode")], [("MlteInBuffer", "*", "InMode")]), ] if __name__ == "__main__": main() | #ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE |
def print_debug(msg): if debug: print msg def _open(fullpath): | def needs_declaration(fullpath): | def print_debug(msg): if debug: print msg |
size = os.stat(fullpath).st_size except OSError, err: print_debug("%s: permission denied: %s" % (fullpath, err)) | infile = open(fullpath, 'rU') except IOError: | def _open(fullpath): try: size = os.stat(fullpath).st_size except OSError, err: # Permission denied - ignore the file print_debug("%s: permission denied: %s" % (fullpath, err)) return None if size > 1024*1024: # too big print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(f... |
if size > 1024*1024: print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(fullpath, 'rU') except IOError, err: print_debug("%s: access denied: %s" % (fullpath, err)) return None def has_python_ext(fullpath): return fullpath.endswith(".py") or fullpath.endswith(".pyw") def ... | line1 = infile.readline() line2 = infile.readline() if get_declaration(line1) or get_declaration(line2): infile.close() | def _open(fullpath): try: size = os.stat(fullpath).st_size except OSError, err: # Permission denied - ignore the file print_debug("%s: permission denied: %s" % (fullpath, err)) return None if size > 1024*1024: # too big print_debug("%s: the file is too big: %d bytes" % (fullpath, size)) return None try: return open(f... |
line = infile.readline() | rest = infile.read() | def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return Tru... |
if binary_re.search(line): print_debug("%s: appears to be binary" % fullpath) | if has_correct_encoding(line1+line2+rest, "ascii"): | def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return Tru... |
if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return True elif "python" in line: return True return False def can_be_compiled(fullpath): infile = _open(fullpath) if infile is None: return False code = infile.read() infile.close() try: compile(code, fullpath, "exec") except Exception, err: print_debug("... | def looks_like_python(fullpath): infile = _open(fullpath) if infile is None: return False line = infile.readline() infile.close() if binary_re.search(line): # file appears to be binary print_debug("%s: appears to be binary" % fullpath) return False if fullpath.endswith(".py") or fullpath.endswith(".pyw"): return Tru... | |
def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. | usage = """Usage: %s [-cd] paths... -c: recognize Python source files trying to compile them -d: debug output""" % sys.argv[0] | def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of... |
paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of directory base names that should be excluded in the search """ if exclude_dirs is None: exclude_dirs=[] for path in paths: print_debug("testing: %s... | try: opts, args = getopt.getopt(sys.argv[1:], 'cd') except getopt.error, msg: print >>sys.stderr, msg print >>sys.stderr, usage sys.exit(1) is_python = pysource.looks_like_python debug = False for o, a in opts: if o == '-c': is_python = pysource.can_be_compiled elif o == '-d': debug = True if not args: print >>sys.s... | def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of... |
if __name__ == "__main__": for fullpath in walk_python_files(['.']): print fullpath print "----------" for fullpath in walk_python_files(['.'], is_python=can_be_compiled): print fullpath | def walk_python_files(paths, is_python=looks_like_python, exclude_dirs=None): """\ Recursively yield all Python source files below the given paths. paths: a list of files and/or directories to be checked. is_python: a function that takes a file name and checks whether it is a Python source file exclude_dirs: a list of... | |
self.in_list_item = True | self.in_list_item = 1 | def _indent_formatter(self, match, fullmatch): depth = int((len(fullmatch.group('idepth')) + 1) / 2) list_depth = len(self._list_stack) if list_depth > 0 and depth == list_depth + 1: self.in_list_item = True else: self.open_indentation(depth) return '' |
self.send_header('ETag', etag) return self.send_response(304) self.end_headers() raise NotModifiedException() | self._headers.append(('ETag', etag)) else: self.send_response(304) self.end_headers() raise NotModifiedException() | def check_modified(self, timesecs, extra=''): etag = 'W"%s/%d/%s"' % (self.authname, timesecs, extra) inm = self.get_header('If-None-Match') if (not inm or inm != etag): self.send_header('ETag', etag) return self.send_response(304) self.end_headers() raise NotModifiedException() |
options = field.get('options', []) if default and default not in field.get('options', []): | options = field.get('options') if default and options and default not in options: | def _init_defaults(self, db=None): for field in self.fields: default = None if not field.get('custom'): default = self.env.config.get('ticket', 'default_' + field['name']) else: default = field.get('value') options = field.get('options', []) if default and default not in field.get('options', []): try: default_idx = int... |
"""Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of the list content will ... | """Check the request "If-None-Match" header against an entity tag. The entity tag is generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in which case the MD5 sum of t... | def check_modified(self, timesecs, extra=''): """Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in wh... |
Otherwise, it adds the entity tag as as "ETag" header to the response so that consequetive requests can be cached. | Otherwise, it adds the entity tag as an "ETag" header to the response so that consecutive requests can be cached. | def check_modified(self, timesecs, extra=''): """Check the request "If-None-Match" header against an entity tag generated from the specified last modified time in seconds (`timesecs`), optionally appending an `extra` string to indicate variants of the requested resource. That `extra` parameter can also be a list, in wh... |
'value': field['value'] | 'value': value | def insert_custom_fields(env, hdf, vals={}): for idx, field in util.enum(TicketSystem(env).get_custom_fields()): name = field['name'] value = vals.get('custom_' + name, field['value']) prefix = 'ticket.custom.%d' % idx hdf[prefix] = { 'name': field['name'], 'type': field['type'], 'label': field['label'] or field['name'... |
from optparse import OptionParser | from optparse import OptionParser, OptionValueError | def main(): from optparse import OptionParser parser = OptionParser(usage='usage: %prog [options] [projenv] ...', version='%%prog %s' % __version__) auths = {} def _auth_callback(option, opt_str, value, parser, auths, cls): info = value.split(',', 3) if len(info) != 3: usage() env_name, filename, realm = info if env_n... |
usage() | raise OptionValueError("Incorrect number of parameters for %s" % option) usage() | def _auth_callback(option, opt_str, value, parser, auths, cls): info = value.split(',', 3) if len(info) != 3: usage() env_name, filename, realm = info if env_name in auths: print >>sys.stderr, 'Ignoring duplicate authentication option for ' \ 'project: %s' % env_name else: auths[env_name] = cls(filename, realm) |
if os.name == 'posix' and options.daemonize: daemon.daemonize() | if os.name == 'posix': if options.pidfile: options.pidfile = os.path.abspath(options.pidfile) if os.path.exists(options.pidfile): pidfile = open(options.pidfile) try: pid = int(pidfile.read()) finally: pidfile.close() try: os.kill(pid, 0) except OSError, e: if e.errno != errno.ESRCH: raise else: sys.exit("tracd is al... | def serve(): server_cls = __import__('flup.server.%s' % options.protocol, None, None, ['']).WSGIServer ret = server_cls(wsgi_app, bindAddress=server_address).run() sys.exit(ret and 42 or 0) # if SIGHUP exit with status 42 |
old = self.db_query("SELECT text FROM wiki WHERE name='%s' " "ORDER BY version DESC LIMIT 1" % title, cursor) | rows = self.db_query("SELECT text FROM wiki WHERE name='%s' " "ORDER BY version DESC LIMIT 1" % title, cursor) old = list(rows) | def _do_wiki_import(self, filename, title, cursor=None): if not os.path.isfile(filename): print "%s is not a file" % filename return f = open(filename,'r') data = util.to_utf8(f.read()) |
logfile = os.path.join(self.get_log_dir(), logfile) | if not os.path.isabs(logfile): logfile = os.path.join(self.get_log_dir(), logfile) | def setup_log(self): """Initialize the logging sub-system.""" from trac.log import logger_factory logtype = self.config.get('logging', 'log_type') loglevel = self.config.get('logging', 'log_level') logfile = self.config.get('logging', 'log_file') logfile = os.path.join(self.get_log_dir(), logfile) logid = self.path # E... |
if milestone.has_key('date'): | if milestone.has_key('due'): | def write_utctime(name, value, params={}): write_prop(name, strftime('%Y%m%dT%H%M%SZ', value), params) |
if milestone.has_key('date'): write_date('DTSTART', localtime(milestone['due'])) | write_date('DTSTART', localtime(milestone['due'])) | def write_utctime(name, value, params={}): write_prop(name, strftime('%Y%m%dT%H%M%SZ', value), params) |
req.hdf['%s.real' % prefix] = col[0] | req.hdf['%s.real' % prefix] = col | def _render_view(self, req, db, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ actions = {'create': 'REPORT_CREATE', 'delete': 'REPORT_DELETE', 'modify': 'REPORT_MODIFY'} for action in [k for k,v in actions.items() if req.perm.has_permission(v... |
while req.hdf.get('links.%s.%d.href' % (rel, idx)): | while req.hdf.get('chrome.links.%s.%d.href' % (rel, idx)): | def add_link(req, rel, href, title=None, type=None, class_name=None): link = {'href': escape(href)} if title: link['title'] = escape(title) if type: link['type'] = type if class_name: link['class'] = class_name idx = 0 while req.hdf.get('links.%s.%d.href' % (rel, idx)): idx += 1 req.hdf['links.%s.%d' % (rel, idx)] = li... |
req.hdf['links.%s.%d' % (rel, idx)] = link | req.hdf['chrome.links.%s.%d' % (rel, idx)] = link | def add_link(req, rel, href, title=None, type=None, class_name=None): link = {'href': escape(href)} if title: link['title'] = escape(title) if type: link['type'] = type if class_name: link['class'] = class_name idx = 0 while req.hdf.get('links.%s.%d.href' % (rel, idx)): idx += 1 req.hdf['links.%s.%d' % (rel, idx)] = li... |
if not logo_src[0] == '/' and not logo_src_abs: | if not logo_src.startswith('/') and not logo_src_abs: | def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """ |
req.hdf['header_logo'] = { | req.hdf['chrome.logo'] = { | def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """ |
req.hdf['chrome.%s.%s' % (category, name)] = text | req.hdf['chrome.nav.%s.%s' % (category, name)] = text | def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """ |
req.hdf['chrome.%s.%s.active' % (category, name)] = 1 | req.hdf['chrome.nav.%s.%s.active' % (category, name)] = 1 | def populate_hdf(self, req, handler): """ Add chrome-related data to the HDF. """ |
module, id = req.hdf['HTTP.PathInfo'].split('/', 3)[1:] | module, id = 'wiki', 'WikiStart' path_info = req.path_info.split('/',2) if len(path_info) > 1: module = path_info[1] if len(path_info) > 2: id = path_info[2] | def render_macro(self, req, name, content): # args will be null if the macro is called without parenthesis. if not content: return '' # parse arguments # we expect the 1st argument to be a filename (filespec) args = content.split(',') if len(args) == 0: raise Exception("No argument.") filespec = args[0] size_re = re.co... |
'order': 0, 'optional': False}, | 'order': 0}, | def test_custom_field_select(self): self.env.config.set('ticket-custom', 'test', 'select') self.env.config.set('ticket-custom', 'test.label', 'Test') self.env.config.set('ticket-custom', 'test.value', '1') self.env.config.set('ticket-custom', 'test.options', 'option1|option2') fields = TicketSystem(self.env).get_custom... |
'value': '1', 'options': ['', 'option1', 'option2'], | 'value': '1', 'options': ['option1', 'option2'], | def test_custom_field_optional_select(self): self.env.config.set('ticket-custom', 'test', 'select') self.env.config.set('ticket-custom', 'test.label', 'Test') self.env.config.set('ticket-custom', 'test.value', '1') self.env.config.set('ticket-custom', 'test.options', '|option1|option2') fields = TicketSystem(self.env).... |
Generator that produces a (path, kind, change, base_rev, base_path) | Generator that produces a (path, kind, change, base_path, base_rev) | def get_changes(self): """ Generator that produces a (path, kind, change, base_rev, base_path) tuple for every change in the changeset, where change can be one of Changeset.ADD, Changeset.COPY, Changeset.DELETE, Changeset.EDIT or Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. """ raise NotImplementedEr... |
milestone = Milestone(self.env, req.args.get('id'), db) | milestone = Milestone(self.env, milestone_id, db) | def process_request(self, req): req.perm.assert_permission('MILESTONE_VIEW') |
xlist = ['summary', 'description', 'link', 'comment'] | xlist = ['summary', 'description', 'link', 'comment', 'new'] | def _validate_mimebody(self, mime, ticket, newtk): """Validate the body of a ticket notification message""" (mime_decoder, mime_name, mime_charset) = mime tn = TicketNotifyEmail(self.env) tn.notify(ticket, newticket=newtk) message = notifysuite.smtpd.get_message() (headers, body) = parse_smtp_message(message) self.fail... |
q.append('SELECT 2 as type, summary AS title, ' ' description AS message, reporter AS author, keywords,' ' id AS data, time,0 AS ver' ' FROM ticket WHERE %s OR %s OR %s OR %s OR %s' % (self.query_to_sql(query, 'summary'), | q.append('SELECT DISTINCT 2 as type, a.summary AS title, ' ' a.description AS message, a.reporter AS author, a.keywords as keywords,' ' a.id AS data, a.time as time, 0 AS ver' ' FROM ticket a LEFT JOIN ticket_change b ON a.id = b.ticket' ' WHERE (b.field=\'comment\' AND %s ) OR' ' %s OR %s OR %s OR %s OR %s' % (self.qu... | def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ') |
q.append('SELECT 2 as type, a.summary AS title, ' ' b.newvalue AS message, a.reporter AS author,' ' a.keywords as keywords,' ' a.id AS data, a.time AS time,0 AS ver' ' FROM ticket a, ticket_change b' ' WHERE a.id = b.ticket AND b.field=\'comment\' AND %s' % (self.query_to_sql(query, 'b.newvalue'))) | def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ') | |
q_str += ' ORDER BY time DESC LIMIT %d OFFSET %d' % \ | q_str += ' ORDER BY 7 DESC LIMIT %d OFFSET %d' % \ | def perform_query (self, query, changeset, tickets, wiki, page=0): keywords = query.split(' ') |
for f in os.listdir(trac.siteconfig.__default_macro_dir__): | for f in os.listdir(trac.siteconfig.__default_macros_dir__): | def do_initenv(self, line): if self.env_check(): print "Initenv for '%s' failed.\nDoes an environment already exist?" % self.envname return arg = self.arg_tokenize(line) project_name = None repository_dir = None templates_dir = None if len(arg) == 1: returnvals = self.get_initenv_args() project_name = returnvals[0] rep... |
src = os.path.join(trac.siteconfig.__default_macro_dir__, f) | src = os.path.join(trac.siteconfig.__default_macros_dir__, f) | def do_initenv(self, line): if self.env_check(): print "Initenv for '%s' failed.\nDoes an environment already exist?" % self.envname return arg = self.arg_tokenize(line) project_name = None repository_dir = None templates_dir = None if len(arg) == 1: returnvals = self.get_initenv_args() project_name = returnvals[0] rep... |
default_idx = int(default) if default_idx > len(options): raise ValueError default = options[default_idx] except ValueError: self.env.log.warning('Invalid default value for ' 'custom field "%s"' % field['name']) | default = options[int(default)] except (ValueError, IndexError): self.env.log.warning('Invalid default value "%s" ' 'for custom field "%s"' % (default, field['name'])) | def _init_defaults(self, db=None): for field in self.fields: default = None if not field.get('custom'): default = self.env.config.get('ticket', 'default_' + field['name']) else: default = field.get('value') options = field.get('options') if default and options and default not in options: try: default_idx = int(default)... |
break | try: cnx.cursor() break except Exception: cnx.close() | def get_cnx(self, timeout=None): start = time.time() self._available.acquire() try: tid = threading._get_ident() if tid in self._active: self._active[tid][0] += 1 return PooledConnection(self, self._active[tid][1]) while True: if self._dormant: cnx = self._dormant.pop() break elif self._maxsize and self._cursize < self... |
for line in difflines: if line.startswith('--- '): words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None | lines = iter(difflines) for line in lines: if not line.startswith('--- '): | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
if line.startswith('+++ '): words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromrev, 'newrev' : 'new', 'diff' : groups}) continue if line.startswith('Index: ') or line.startswith('======') or line == '': continue if groups... | words = line.split(None, 2) filename, fromrev = words[1], 'old' groups, blocks = None, None line = lines.next() if not line.startswith('+++ '): | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
if line.startswith('@@ '): r = re.match(r'@@ -(\d+),\d+ \+(\d+),\d+ @@', line) | words = line.split(None, 2) if len(words[1]) < len(filename): filename = words[1] groups = [] output.append({'filename' : filename, 'oldrev' : fromrev, 'newrev' : 'new', 'diff' : groups}) for line in lines: r = re.match(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@', line) | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
return None | break | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
fromline,toline = map(int, r.groups()) | fromline,fromend,toline,toend = map(int, r.groups()) | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
continue if blocks == None: return None | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' | |
command, line = line[0], line[1:] | fromend += fromline toend += toline | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
if (command == ' ') != last_type: last_type = command == ' ' blocks.append({'type': last_type and 'unmod' or 'mod', 'base.offset': fromline - 1, 'base.lines': [], 'changed.offset': toline - 1, 'changed.lines': []}) if command == ' ': blocks[-1]['changed.lines'].append(line) blocks[-1]['base.lines'].append(line) fromlin... | while fromline < fromend or toline < toend: line = lines.next() command, line = line[0], line[1:] if (command == ' ') != last_type: last_type = command == ' ' blocks.append({'type': last_type and 'unmod' or 'mod', 'base.offset': fromline - 1, 'base.lines': [], 'changed.offset': toline - 1, 'changed.lines': []}) if c... | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
pass | version = None | def _insert_ticket_data(self, req, db, ticket, data, reporter_id): """Insert ticket data into the hdf""" replyto = req.args.get('replyto') version = req.args.get('version', None) data['replyto'] = replyto if version: try: version = int(version) data['version'] = version except ValueError: pass |
if version is not None and cnum > version: for k, v in change['fields'].iteritems(): if k not in values: values[k] = v['old'] continue changes.append(change) | def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + ['']) | |
if 'replyto' in change: replies.setdefault(change['replyto'], []).append(cnum) comment = '' if replyto == str(cnum): quote_original(change['author'], comment, 'comment:%s' % replyto) if version: | if version is not None and cnum > version: | def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + ['']) |
values[k] = v['new'] if 'description' in change['fields']: data['description_change'] = change | if k not in values: values[k] = v['old'] skip = True else: if 'replyto' in change: replies.setdefault(change['replyto'], []).append(cnum) comment = '' if replyto == str(cnum): quote_original(change['author'], comment, 'comment:%s' % replyto) if version: for k, v in change['fields'].iteritems(): values[k] = v['new'] ... | def quote_original(author, original, link): if 'comment' not in req.args: # i.e. the comment was not yet edited data['comment'] = '\n'.join( ['Replying to [%s %s]:' % (link, author)] + ['> %s' % line for line in original.splitlines()] + ['']) |
if not row: raise TracError('Report %d does not exist.' % id, | try: if not row: raise TracError('Report %d does not exist.' % id, | def get_info(self, id, args): cursor = self.db.cursor() |
title = row[0] try: | title = row[0] | def get_info(self, id, args): cursor = self.db.cursor() |
if path.startswith(self.scope): | if rev > 0 and path.startswith(self.scope): | def get_history(self): history = _get_history(self.scope + self.path, self.authz, self.fs_ptr, self.pool, self.rev) for path, rev in history: if path.startswith(self.scope): yield path[len(self.scope):], rev |
title = Markup('Ticket <em title="%s"> summary, id, type, verb, author) | if format == 'rss': title = 'Ticket (id, type.lower(), verb, summary) else: title = Markup('Ticket <em title="%s"> summary, id, type, verb, author) | def produce((id, t, author, type, summary), status, fields, comment, cid): if status == 'edit': if 'ticket_details' in filters: info = '' if len(fields) > 0: info = ', '.join(['<i>%s</i>' % f for f in \ fields.keys()]) + ' changed<br />' else: return None elif 'ticket' in filters: if status == 'closed' and fields.has_k... |
defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default | def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Expor... | |
default_options = defaults.get(section) | default_options = self.config.getdefaults().get(section) | def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Expor... |
options.append({'name': name, 'value': value, 'valueclass': (value == default and \ 'defaultvalue' or 'value')}) | options.append({ 'name': name, 'value': value, 'valueclass': (unicode(value) == unicode(default) and 'defaultvalue' or 'value')}) | def _render_config(self, req): req.perm.assert_permission('CONFIG_VIEW') req.hdf['about.page'] = 'config' # Gather default values defaults = {} for section, options in self.env.get_default_config().iteritems(): defaults[section] = default_options = {} for opt in options: default_options[opt.name] = opt.default # Expor... |
self._execute('severity change critical end-of-the-world') | self._execute('severity change critical "end-of-the-world"') | def test_severity_change_ok(self): """ Tests the 'severity add' command in trac-admin. This particular test passes valid arguments and checks for success. """ test_name = sys._getframe().f_code.co_name self._execute('severity add critical') self._execute('severity change critical end-of-the-world') test_results = self... |
return self.default | return self.default(component.env) | def implementation(self, component): cfgvalue = component.config.get(self.cfg_section, self.cfg_property) for impl in self.xtnpt.extensions(component): if impl.__class__.__name__ == cfgvalue: return impl if self.default is not None: return self.default raise AttributeError('Cannot find an implementation of the "%s" ' '... |
time = int(t or time.time()) self.date = datetime.fromtimestamp(time, utc) | timestamp = int(t or time.time()) self.date = datetime.fromtimestamp(timestamp, utc) | def insert(self, filename, fileobj, size, t=None, db=None): # FIXME: `t` should probably be switched to `datetime` too if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False |
self.size, time, self.description, self.author, self.ipnr)) | self.size, timestamp, self.description, self.author, self.ipnr)) | def insert(self, filename, fileobj, size, t=None, db=None): # FIXME: `t` should probably be switched to `datetime` too if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False |
def get_ticket (self, id): | def get_ticket (self, id, escape_values=1): | def get_ticket (self, id): global fields cnx = db.get_connection () cursor = cnx.cursor () |
info[fields[i]] = escape(row[i]) | info[fields[i]] = row[i] | def get_ticket (self, id): global fields cnx = db.get_connection () cursor = cnx.cursor () |
hdf.setValue('ticket.changes.%d.author' % idx, author) hdf.setValue('ticket.changes.%d.field' % idx, field) | hdf.setValue('ticket.changes.%d.time' % idx, str(date)) hdf.setValue('ticket.changes.%d.author' % idx, author) hdf.setValue('ticket.changes.%d.field' % idx, field) | def insert_ticket_data(self, hdf, id): """Inserts ticket data into the hdf""" cnx = db.get_connection () cursor = cnx.cursor() cursor.execute('SELECT time, author, field, oldvalue, newvalue ' 'FROM ticket_change ' 'WHERE ticket=%s ORDER BY time', id) curr_author = None curr_date = 0 comment = None idx = 0 |
old = self.get_ticket(id) | old = self.get_ticket(id, 0) | def render (self): action = dict_get_with_default(self.args, 'action', 'view') if action == 'create': self.create_ticket () try: id = int(self.args['id']) except: redirect (href.menu()) |
class BasicAuthentication(HTTPAuthentication): | class PasswordFileAuthentication(HTTPAuthentication): def __init__(self, filename): self.filename = filename self.mtime = os.stat(filename).st_mtime self.load(self.filename) self._lock = threading.Lock() def check_reload(self): self._lock.acquire() try: mtime = os.stat(self.filename).st_mtime if mtime > self.mtime: se... | def do_auth(self, environ, start_response): raise NotImplementedError |
self.hash = {} | def __init__(self, htpasswd, realm): self.hash = {} self.realm = realm try: import crypt self.crypt = crypt.crypt except ImportError: self.crypt = None self.load(htpasswd) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.