rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if field['type'] == 'select' or field['name'] == 'owner': | if field['type'] == 'select' and field['name'] != 'milestone' \ or field['name'] == 'owner': | def _render_view(self, req, db, milestone): req.hdf['title'] = 'Milestone %s' % milestone.name req.hdf['milestone.mode'] = 'view' |
by = req.args.get('by', 'component') | if component_group_available: by = req.args.get('by', 'component') else: by = req.args.get('by', available_groups[0]['name']) | def _render_view(self, req, db, milestone): req.hdf['title'] = 'Milestone %s' % milestone.name req.hdf['milestone.mode'] = 'view' |
from docutils.__init__ import __version__ | from docutils import __version__ | def render(self, req, mimetype, content, filename=None, rev=None): try: from docutils import nodes from docutils.core import publish_string from docutils.parsers import rst from docutils.__init__ import __version__ except ImportError: raise TrarError, 'Docutils >= %s not found' % docutils_required if __version__ < '0.3... |
if __version__ < '0.3.3': | if StrictVersion(__version__) < StrictVersion('0.3.3'): | def render(self, req, mimetype, content, filename=None, rev=None): try: from docutils import nodes from docutils.core import publish_string from docutils.parsers import rst from docutils.__init__ import __version__ except ImportError: raise TrarError, 'Docutils >= %s not found' % docutils_required if __version__ < '0.3... |
def get_info (self, id): | def sql_sub_vars(self, sql, args): m = re.search(dynvars_re, sql) if not m: return sql aname=m.group()[1:] try: arg = args[aname] except KeyError: raise Exception("Dynamic variable '$%s' not defined." % aname) self.cgi.hdf.setValue('report.var.'+aname , arg) sql = m.string[:m.start()] + arg + m.string[m.end():] return ... | def get_info (self, id): cursor = self.db.cursor() |
sql = row[1] | sql = self.sql_sub_vars(row[1], args) | def get_info (self, id): cursor = self.db.cursor() |
def render_report_list(self, id): | def render_report_list(self, id, args={}): | def render_report_list(self, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ if self.perm.has_permission(perm.REPORT_CREATE): self.cgi.hdf.setValue('report.create_href', href.report(None, 'new')) if id != -1: if self.perm.has_permission(perm.R... |
[self.cols, self.rows, title] = self.get_info(id) | [self.cols, self.rows, title] = self.get_info(id, args) self.error = None | def render_report_list(self, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ if self.perm.has_permission(perm.REPORT_CREATE): self.cgi.hdf.setValue('report.create_href', href.report(None, 'new')) if id != -1: if self.perm.has_permission(perm.R... |
def get_var_args(self): report_args = {} for arg in self.args.keys(): if not arg == arg.upper(): continue m = re.search(dynvars_disallowed_var_chars_re, arg) if m: raise ValueError("The character '%s' is not allowed " " in variable names." % m.group()) val = self.args[arg] m = re.search(dynvars_disallowed_value_chars_r... | def render_report_list(self, id): """ uses a user specified sql query to extract some information from the database and presents it as a html table. """ if self.perm.has_permission(perm.REPORT_CREATE): self.cgi.hdf.setValue('report.create_href', href.report(None, 'new')) if id != -1: if self.perm.has_permission(perm.R... | |
self.render_report_list(id) | self.render_report_list(id, report_args) | def render(self): self.perm.assert_permission(perm.REPORT_VIEW) # did the user ask for any special report? id = int(self.args.get('id', -1)) action = self.args.get('action', 'list') |
@param interface: the `Interface` class that defines the protocol for the extension point | @param interface: the `Interface` subclass that defines the protocol for the extension point | def __init__(self, interface): """Create the extension point. @param interface: the `Interface` class that defines the protocol for the extension point """ self.interface = interface |
def __get__(self, instance, owner): | def extensions(self, component): | def __get__(self, instance, owner): """Return a list of components that declare to implement the extension point interface.""" if instance: extensions = ComponentMeta._registry.get(self.interface, []) return filter(None, [instance.compmgr[cls] for cls in extensions]) return self |
if instance: extensions = ComponentMeta._registry.get(self.interface, []) return filter(None, [instance.compmgr[cls] for cls in extensions]) return self | extensions = ComponentMeta._registry.get(self.interface, []) return filter(None, [component.compmgr[cls] for cls in extensions]) | def __get__(self, instance, owner): """Return a list of components that declare to implement the extension point interface.""" if instance: extensions = ComponentMeta._registry.get(self.interface, []) return filter(None, [instance.compmgr[cls] for cls in extensions]) return self |
field = [field for field in self.fields if field['name'] == name] if not field: return field = field[0] | def __setitem__(self, name, value): """Log ticket modifications so the table ticket_change can be updated""" if self.values.has_key(name) and self.values[name] == value: return field = [field for field in self.fields if field['name'] == name] if not field: return field = field[0] if not self._old.has_key(name): # Chang... | |
if value and field['type'] != 'textarea': value = value.strip() | if value: field = [field for field in self.fields if field['name'] == name] if field and field[0].get('type') != 'textarea': value = value.strip() | def __setitem__(self, name, value): """Log ticket modifications so the table ticket_change can be updated""" if self.values.has_key(name) and self.values[name] == value: return field = [field for field in self.fields if field['name'] == name] if not field: return field = field[0] if not self._old.has_key(name): # Chang... |
i = 1 | def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > ... | |
big = [] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue | big = [f for f in tkt.fields if f['type'] == 'textarea' and f['name'] != 'description'] i = 0 for f in [f['name'] for f in fields]: if not tkt.values.has_key(f): continue | def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > ... |
big.append((f.capitalize(), fval)) | big.append((f.capitalize(), CRLF.join(fval.splitlines()))) | def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not tkt.values.has_key(f): continue fval = tkt[f] if fval.find('\n') > ... |
content = content_to_unicode(self.env, content, mimetype) content = content.encode('utf-8') | def code_block(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ Create a code-block directive for docutils. | |
distributions.scan([os.path.join(env.path, 'plugins')]) | distributions.scan([plugins_dir]) | def load_components(env): loaded_components = [] # Load configured modules for section in env.config.sections(): for name, value in env.config.options(section): if name == 'module': loaded_components.append(value) path = env.config.get(section, 'path') or None env.log.debug('Loading component module %s from %s' % (val... |
elif os.listdir(os.path.join(env.path, 'plugins')): self.env.warning('setuptools is required for plugin deployment') | elif os.path.exists(plugins_dir) and os.listdir(plugins_dir): env.log.warning('setuptools is required for plugin deployment') | def load_components(env): loaded_components = [] # Load configured modules for section in env.config.sections(): for name, value in env.config.options(section): if name == 'module': loaded_components.append(value) path = env.config.get(section, 'path') or None env.log.debug('Loading component module %s from %s' % (val... |
list = filter(None, self.path.split('/')) | links = [''] + filter(None, self.path.split('/')) | def generate_path_links(self, req, rev, rev_specified): list = filter(None, self.path.split('/')) path = '/' req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.br... |
req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.browser(path, rev)) else: req.hdf.setValue('log.path.0.url', self.env.href.browser(path)) | def generate_path_links(self, req, rev, rev_specified): list = filter(None, self.path.split('/')) path = '/' req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.br... | |
for part in list[:-1]: i = i + 1 | for part in links: | def generate_path_links(self, req, rev, rev_specified): list = filter(None, self.path.split('/')) path = '/' req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.br... |
req.hdf.setValue('log.path.%d' % i, part) | req.hdf.setValue('log.path.%d' % i, part or 'root') | def generate_path_links(self, req, rev, rev_specified): list = filter(None, self.path.split('/')) path = '/' req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.br... |
if i == len(list) - 1: | if i == len(links) - 1: | def generate_path_links(self, req, rev, rev_specified): list = filter(None, self.path.split('/')) path = '/' req.hdf.setValue('log.filename', list[-1]) req.hdf.setValue('log.href' , self.env.href.log(self.path)) req.hdf.setValue('log.path.0', 'root') if rev_specified: req.hdf.setValue('log.path.0.url', self.env.href.br... |
options = field['options'][:] for option in field['options']: if Milestone(self.env, option, db=db).is_completed: options.remove(option) | options = [opt for opt in field['options'] if not Milestone(self.env, opt, db=db).is_completed] | def process_newticket_request(self, req): req.perm.require('TICKET_CREATE') data = {} db = self.env.get_db_cnx() |
name = field['name'] | def _insert_ticket_data(self, req, db, ticket, data, reporter_id): """Insert ticket data into the hdf""" replyto = req.args.get('replyto') data['replyto'] = replyto | |
if action.isupper() and action not in self.get_actions(): raise TracError, '%s is not a valid action.' % action | def revoke_permission(self, username, action): """Revokes the permission of the specified user to perform an action.""" # TODO: Validate that this permission does in fact exist if action.isupper() and action not in self.get_actions(): raise TracError, '%s is not a valid action.' % action | |
if self._old.items() != self.items(): | if self._old != self: | def save(self): if not self._old and not self.items(): # The session doesn't have associated data, so there's no need to # persist it return |
self.session.save() | if self.session: self.session.save() | def redirect(self, url): """ Send a redirect to the client, forwarding to the specified URL. The `url` may be relative or absolute, relative URLs will be translated appropriately. """ self.session.save() # has to be done before the redirect is sent self.send_response(302) if not url.startswith('http://') and not url.st... |
def get_path_links(href, path, rev): links = [] parts = path.split('/') if not parts[-1]: parts.pop() path = '/' for part in parts: path = path + part + '/' links.append({ 'name': part or 'root', 'href': href.browser(path, rev=rev) }) | def get_path_links(href, fullpath, rev): links = [{'name': 'root', 'href': href.browser(rev=rev)}] path = '' for part in [p for p in fullpath.split('/') if p]: path += part + '/' links.append({'name': part, 'href': href.browser(path, rev=rev)}) | def get_path_links(href, path, rev): links = [] parts = path.split('/') if not parts[-1]: parts.pop() path = '/' for part in parts: path = path + part + '/' links.append({ 'name': part or 'root', 'href': href.browser(path, rev=rev) }) return links |
cnx.db.execute("BEGIN") | cursor = cnx.cursor() cursor.execute("UPDATE system SET name=NULL WHERE name IS NULL") | def do_hotcopy(self, line): arg = self.arg_tokenize(line) if arg[0]: dest = arg[0] else: self.do_help('hotcopy') return cnx = self.db_open() # Lock the database while copying files cnx.db.execute("BEGIN") print 'Hotcopying %s to %s ...' % (self.__env.path, dest), try: shutil.copytree(self.__env.path, dest, symlinks=1) ... |
cnx.db.execute("ROLLBACK") | cnx.rollback() | def do_hotcopy(self, line): arg = self.arg_tokenize(line) if arg[0]: dest = arg[0] else: self.do_help('hotcopy') return cnx = self.db_open() # Lock the database while copying files cnx.db.execute("BEGIN") print 'Hotcopying %s to %s ...' % (self.__env.path, dest), try: shutil.copytree(self.__env.path, dest, symlinks=1) ... |
'subject': self.newticket and subject or 'Re: ' + subject, | 'subject': subject, | def notify(self, ticket, newticket=True, modtime=None): self.ticket = ticket self.modtime = modtime self.newticket = newticket |
self.out.write('<h%d id="%s">%s</h%d>' % (depth, anchor.encode('utf-8'), | self.out.write('<h%d id="%s">%s</h%d>' % (depth, anchor, | def _heading_formatter(self, match, fullmatch): match = match.strip() self.close_table() self.close_paragraph() self.close_indentation() self.close_list() self.close_def_list() |
% (path, revision), 'Not such file or directory') | % (path, revision), 'No such file or directory') | def get_info(self, path, revision, rev_specified): """ Extracts information for a given path and revision """ try: root = fs.revision_root(self.fs_ptr, revision, self.pool) except core.SubversionException: raise TracError('Invalid revision number: %d' % revision) |
next_href = req.href.changeset(next_rev, path) | if repos.has_node(path, next_rev): next_href = req.href.changeset(next_rev, path) else: next_href = req.href.changeset(next_rev) | def _changeset_title(rev): if restricted: return 'Changeset %s for %s' % (rev, path) else: return 'Changeset %s' % rev |
'href': query.get_href(order=col, desc=(col == query.order)) | 'href': query.get_href(order=col, desc=(col == query.order and not query.desc)) | def display_html(self, req, query): req.hdf['title'] = 'Custom Query' add_stylesheet(req, 'common/css/report.css') |
if 'q' in req.args: query = orig_query = req.args.get('q') | query = req.args.get('q') if query: | def process_request(self, req): req.perm.assert_permission('SEARCH_VIEW') |
req.hdf['search.q'] = orig_query.replace('"', "& | req.hdf['search.q'] = req.args.get('q').replace('"', "& | def process_request(self, req): req.perm.assert_permission('SEARCH_VIEW') |
from trac.wiki.formatter import wiki_to_html | from trac.wiki.formatter import wiki_to_html, system_message | def render_macro(self, req, name, content): from trac.wiki.formatter import wiki_to_html from trac.wiki import WikiSystem wiki = WikiSystem(self.env) |
descr = macro_provider.get_macro_description(macro_name) yield (macro_name, descr or '') | try: descr = macro_provider.get_macro_description(macro_name) descr = wiki_to_html(descr or '', self.env, req) except Exception, e: descr = Markup(system_message( "Error: Can't get description for macro %s" \ % macro_name, e)) yield (macro_name, descr) | def get_macro_descr(): for macro_provider in wiki.macro_providers: for macro_name in macro_provider.get_macros(): if content and macro_name != content: continue descr = macro_provider.get_macro_description(macro_name) yield (macro_name, descr or '') |
html.DD[wiki_to_html(description, self.env, req)]) | html.DD[description]) | def get_macro_descr(): for macro_provider in wiki.macro_providers: for macro_name in macro_provider.get_macros(): if content and macro_name != content: continue descr = macro_provider.get_macro_description(macro_name) yield (macro_name, descr or '') |
"WHERE type=%s AND value=%s", (self.name, self.value, self.type, self._old_value)) | "WHERE type=%s AND name=%s", (self.name, self.value, self.type, self._old_name)) | def update(self, db=None): assert self.exists, 'Cannot update non-existent %s' % self.type assert self.name, 'Cannot update %s with no name' % self.type if not db: db = self.env.get_db_cnx() handle_ta = True else: handle_ta = False |
obj.name = name obj.value = value | obj.name = obj._old_name = name obj.value = obj._old_value = value | def select(cls, env, db=None): if not db: db = env.get_db_cnx() cursor = db.cursor() cursor.execute("SELECT name,value FROM enum WHERE type=%s " "ORDER BY value", (cls.type,)) for name, value in cursor: obj = cls(env) obj.name = name obj.value = value yield obj |
_rules = [r"""(?P<svnimg>(source|repos):([^ ]+)(\.png|\.jpg|\.jpeg|\.gif))"""] + \ | _rules = [r"""(?P<svnimg>(source|repos):([^ ]+)\.(PNG|png|JPG|jpg|JPEG|jpeg|GIF|gif))"""] + \ | def format(self, text, out): if not text: return self.out = out self._open_tags = [] rules = self._compiled_rules |
print mimeviewer, exists, name | def handle_code_block(self, line): if line.strip() == '{{{': self.in_code_block += 1 if self.in_code_block == 1: self.code_processor = None self.code_text = '' else: self.code_text += line + os.linesep if not self.code_processor: self.code_processor = Formatter.builtin_processors['default'] elif line.strip() == '}}}': ... | |
print version, latest_version | def process_request(self, req): action = req.args.get('action', 'view') pagename = req.args.get('page', 'WikiStart') version = req.args.get('version') | |
quoted_re = re.compile("^(?:& | quoted_re = re.compile("^(?:\";|')(.*)(?:\";|')$") | 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... |
return ('', 'text/plain;charset=utf-8') | return ('', 'text/plain;charset=utf-8', '.txt') | def convert_content(self, req, mimetype, content, key, filename=None, url=None): """Convert the given content to the target MIME type represented by `key`, which can be either a MIME type or a key. Returns a tuple of (content, output_mime_type, extension).""" if not content: return ('', 'text/plain;charset=utf-8') |
cr_re = re.compile('\r$', re.MULTILINE) | def render(self, req, mimetype, content, filename=None, rev=None): import SilverCity try: typelang = types[mimetype] lang = typelang[0] module = getattr(SilverCity, lang) generator = getattr(module, lang + "HTMLGenerator") try: allprops = typelang[1] propset = SilverCity.PropertySet() for p in allprops.keys(): propset[... | |
r, r"""(?P<endtt>\}\}\})""", | r, | def populate_page_dict(db): """Extract wiki page names. This is used to detect broken wiki-links""" global page_dict page_dict = {'TitleIndex': 1} cursor = db.cursor() cursor.execute('SELECT DISTINCT name FROM wiki') while 1: row = cursor.fetchone() if not row: break page_dict[row[0]] = 1 |
def _begintt_formatter(self, match, fullmatch): return '<tt>' def _endtt_formatter(self, match, fullmatch): return '</tt>' | def _inlinecode_formatter(self, match, fullmatch): return '<tt>%s</tt>' % fullmatch.group('inline') | def _begintt_formatter(self, match, fullmatch): return '<tt>' |
'linkname', 'macroname', 'macroargs') | 'linkname', 'macroname', 'macroargs', 'inline') | def format(self, text, out): if not text: return '' self.out = out self._open_tags = [] rules = self._compiled_rules |
env.log.debug('Loading plugin %s from %s', name, | env.log.debug('Loading egg plugin %s from %s', name, | def flatten(dists): for dist in dists: if dist in memo: continue memo.add(dist) try: predecessors = ws.resolve([dist.as_requirement()]) for predecessor in flatten(predecessors): yield predecessor yield dist except pkg_resources.DistributionNotFound, e: env.log.error('Skipping "%s" ("%s" not found)', dist, e) except pkg... |
if os.path.dirname(egg.location) == plugins_dir: | if os.path.dirname(egg.location) == plugins_dirs[0]: | def flatten(dists): for dist in dists: if dist in memo: continue memo.add(dist) try: predecessors = ws.resolve([dist.as_requirement()]) for predecessor in flatten(predecessors): yield predecessor yield dist except pkg_resources.DistributionNotFound, e: env.log.error('Skipping "%s" ("%s" not found)', dist, e) except pkg... |
'path': path, 'rev': node.rev, | 'path': path, 'rev': node.rev, 'stickyrev': rev, | def process_request(self, req): path = req.args.get('path', '/') rev = req.args.get('rev') or None |
encoding = locale.getlocale(locale.LC_TIME)[1] or \ locale.getpreferredencoding() | lc_time_encoding = sys.platform != 'win32' and getlocale(locale.LC_TIME)[1] encoding = lc_time_encoding or locale.getpreferredencoding() | def format_datetime(t=None, format='%x %X', gmt=False): if t is None: t = time.time() if not isinstance(t, (list, tuple, time.struct_time)): if gmt: t = time.gmtime(int(t)) else: t = time.localtime(int(t)) text = time.strftime(format, t) encoding = locale.getlocale(locale.LC_TIME)[1] or \ locale.getpreferredencoding()... |
html = PhpDeuglifier().format(odata.splitlines()[1]) | fst_nl = odata.find('\n') snd_nl = odata.find('\n', fst_nl + 1) odata = odata[snd_nl + 1:] html = PhpDeuglifier().format(odata) | def render(self, req, mimetype, content, filename=None, rev=None): cmdline = self.config.get('mimeviewer', 'php_path') cmdline += ' -s' self.env.log.debug("PHP command line: %s" % cmdline) |
Markup('<a href="%s" accesskey="2">Timeline</a>', self.env.href.timeline())) | Markup('<a href="%s">About Trac</a>', self.env.href.about())) | def get_navigation_items(self, req): yield ('metanav', 'about', Markup('<a href="%s" accesskey="2">Timeline</a>', self.env.href.timeline())) |
return '<a class="ext-link" href="%s"%s>%s</a>' \ % (url, title_attr, text) | return '<a class="ext-link" href="%s"%s><span class="icon">' \ '</span>%s</a>' % (url, title_attr, text) | def _make_ext_link(self, url, text, title=''): title_attr = title and ' title="%s"' % title or '' if Formatter.img_re.search(url) and self.flavor != 'oneliner': return '<img src="%s" alt="%s" />' % (url, title or text) if not url.startswith(self._local): return '<a class="ext-link" href="%s"%s>%s</a>' \ % (url, title_a... |
if i % 2: | if not i % 2: | def format_props(self): tkt = self.ticket fields = [f for f in tkt.fields if f['type'] != 'textarea' and f['name'] not in ('summary', 'cc')] t = self.modtime or tkt.time_changed width = [0, 0, 0, 0] for i, f in enum([f['name'] for f in fields]): if not f in tkt.values.keys(): continue fval = tkt[f] if fval.find('\n') >... |
def readline(self): return self.req.readline() | def readline(self, size=-1): return self.req.readline(size) | def readline(self): return self.req.readline() |
if port == 80: self.base_url = 'http://%s%s' % (host, self.cgi_location) elif port == 443: self.base_url = 'https://%s%s' % (host, self.cgi_location) | proto_port = '' if port == 443: proto = 'https' | def init_request(self): core.Request.init_request(self) options = self.req.get_options() |
self.base_url = 'http://%s:%d%s' % (host, port, self.cgi_location) | proto = 'http' if port != 80: proto_port = ':%d' % port self.base_url = '%s://%s%s%s' % (proto, host, proto_port, self.cgi_location) | def init_request(self): core.Request.init_request(self) options = self.req.get_options() |
req.hdf['wiki.action'] = 'preview' | action = 'preview' | def process_request(self, req): action = req.args.get('action', 'view') pagename = req.args.get('page', 'WikiStart') |
if os.path.samefile(os.path.dirname(egg_path), plugins_dir): for module in modules: env.config.setdefault('components', module + '.*', 'enabled') | try: if os.path.samefile(os.path.dirname(egg_path), plugins_dir): for module in modules: env.config.setdefault('components', module + '.*', 'enabled') except OSError: pass | def enable_modules(egg_path, modules): """Automatically enable any components provided by plugins loaded from the environment plugins directory.""" if os.path.samefile(os.path.dirname(egg_path), plugins_dir): for module in modules: env.config.setdefault('components', module + '.*', 'enabled') |
from trac.Browser import BrowserModule | from trac.versioncontrol.web_ui import BrowserModule | 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... |
return '<a href="%s" style="%s"><img src="%s" %s style="%s" /></a>' \ % (url, a_style, raw_url, img_attr, img_style) | result = '<img src="%s" %s style="%s" />' \ % (raw_url, img_attr, img_style) if not nolink: result = '<a href="%s" style="%s">%s</a>' % (url, a_style, result) return result | 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... |
q['all_tickets'] = env.href.query(milestone=milestone, grouped_by=group) q['active_tickets'] = env.href.query(milestone=milestone, grouped_by=group, | q['all_tickets'] = env.href.query({grouped_by: group}, milestone=milestone) q['active_tickets'] = env.href.query({grouped_by: group}, milestone=milestone, | def get_query_links(env, milestone, grouped_by='component', group=None): q = {} if not group: q['all_tickets'] = env.href.query(milestone=milestone) q['active_tickets'] = env.href.query(milestone=milestone, status=('new', 'assigned', 'reopened')) q['closed_tickets'] = env.href.query(milestone=milestone, status='closed'... |
q['closed_tickets'] = env.href.query(milestone=milestone, grouped_by=group, | q['closed_tickets'] = env.href.query({grouped_by: group}, milestone=milestone, | def get_query_links(env, milestone, grouped_by='component', group=None): q = {} if not group: q['all_tickets'] = env.href.query(milestone=milestone) q['active_tickets'] = env.href.query(milestone=milestone, status=('new', 'assigned', 'reopened')) q['closed_tickets'] = env.href.query(milestone=milestone, status='closed'... |
_rules = [r"(?P<bold>''')", | _rules = [r"(?P<bolditalic>''''')", r"(?P<bold>''')", | def process(self, req, text, inline=False): if self.error: return system_message('Error: Failed to load processor <code>%s</code>' % self.name, self.error) text = self.processor(req, text, self.env) if inline: code_block_start = re.compile('^<div class="code-block">') code_block_end = re.compile('</div>$') text, nr = c... |
for i in range(len(self._open_tags)-1, -1, -1): if self._open_tags[i] == tag: tmp += self._open_tags[i] | for i in xrange(len(self._open_tags)-1, -1, -1): tmp += self._open_tags[i][1] if self._open_tags[i][1] == tag: | def close_tag(self, tag): tmp = '' for i in range(len(self._open_tags)-1, -1, -1): if self._open_tags[i] == tag: tmp += self._open_tags[i] del self._open_tags[i] break return tmp |
def open_tag(self, tag): self._open_tags.append(tag) | def open_tag(self, open, close): self._open_tags.append((open, close)) | def open_tag(self, tag): self._open_tags.append(tag) |
if self.tag_open_p(close_tag): | if self.tag_open_p((open_tag, close_tag)): | def simple_tag_handler(self, open_tag, close_tag): """Generic handler for simple binary style tags""" if self.tag_open_p(close_tag): return self.close_tag(close_tag) else: self.open_tag(close_tag) return open_tag |
self.open_tag(close_tag) | self.open_tag(open_tag, close_tag) | def simple_tag_handler(self, open_tag, close_tag): """Generic handler for simple binary style tags""" if self.tag_open_p(close_tag): return self.close_tag(close_tag) else: self.open_tag(close_tag) return open_tag |
self.out.write(self._open_tags.pop()) | self.out.write(self._open_tags.pop()[1]) | def close_paragraph(self): if self.paragraph_open: while self._open_tags != []: self.out.write(self._open_tags.pop()) self.out.write('</p>' + os.linesep) self.paragraph_open = 0 |
result += self.close_tag(None) | def format(self, text, out, escape_newlines=False): self.out = out self._open_tags = [] self._list_stack = [] | |
from docutils.core import publish_string | from docutils.core import publish_parts | def render(self, req, mimetype, content, filename=None, rev=None): try: from docutils import nodes from docutils.core import publish_string from docutils.parsers import rst from docutils import __version__ except ImportError: raise TracError, 'Docutils not found' if StrictVersion(__version__) < StrictVersion('0.3.9'): ... |
content = content.encode('utf-8') html = publish_string(content, writer_name='html', parser=_parser, | parts = publish_parts(content, writer_name='html', parser=_parser, | def code_block(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ Create a code-block directive for docutils. |
'raw_enabled': 0}) html = html.decode('utf-8') return html[html.find('<body>') + 6:html.find('</body>')].strip() | 'raw_enabled': 0}) return parts['html_body'] | def code_block(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ Create a code-block directive for docutils. |
if lspace_re.match(text): text = ' ' + text[1:] text = space_re.sub(' ', text.expandtabs(self.tabwidth)) | text = space_re.sub(lambda m: len(m.group(0)) / 2 * ' ' + len(m.group(0)) % 2 * ' ', text.expandtabs(self.tabwidth)) | def writeline(self, text): match = header_re.search(text) if match: self.hdf.setValue('%s.name.old' % self.prefix, match.group(1)) self.hdf.setValue('%s.name.new' % self.prefix, match.group(2)) return if text[0:2] in ['++', '--']: return match = line_re.search(text) if match: self.print_block() self.changeno += 1 self.... |
rows.append((action, user)) | rows.append((user, action)) | def _do_permission_list(self, user=None): if not self._permsys: self._permsys = PermissionSystem(self.env_open()) if user: rows = [] perms = self._permsys.get_user_permissions(user) for action in perms: if perms[action]: rows.append((action, user)) else: rows = self._permsys.get_all_permissions() rows.sort() self.print... |
sqlite = None | using_pysqlite2 = False | def executemany(self, sql, args=None): if args: sql = sql % tuple(['?'] * len(args[0])) sqlite.Cursor.executemany(self, sql, args or []) |
global sqlite | global using_pysqlite2 | def __init__(self, path, params={}): global sqlite self.cnx = None if path != ':memory:': if not os.access(path, os.F_OK): raise TracError, 'Database "%s" not found.' % path |
if sqlite is not None: | if using_pysqlite2: global sqlite | def __init__(self, path, params={}): global sqlite self.cnx = None if path != ':memory:': if not os.access(path, os.F_OK): raise TracError, 'Database "%s" not found.' % path |
global sqlite if sqlite is not None: | global using_pysqlite2 if using_pysqlite2: | def cursor(self): global sqlite if sqlite is not None: # Using PySQLite 2.x return self.cnx.cursor(PyFormatCursor) else: return self.cnx.cursor() |
file = StringIO(pair[1]) self.list.append(util.Field(pair[0], file, "text/plain", {}, None, {})) | qsargs.append(util.Field(pair[0], StringIO(pair[1]), "text/plain", {}, None, {})) self.list += qsargs | def __getattr__(self, name): return getattr(self.req, name) |
def _execute(self, cmd): | def _execute(self, cmd, strip_trailing_space=True): | def _execute(self, cmd): try: _err = sys.stderr _out = sys.stdout sys.stderr = sys.stdout = out = StringIO() try: self._admin.docmd(cmd) except SystemExit, e: pass return STRIP_TRAILING_SPACE.sub('', out.getvalue()) finally: sys.stderr = _err sys.stdout = _out |
return STRIP_TRAILING_SPACE.sub('', out.getvalue()) | if strip_trailing_space: return STRIP_TRAILING_SPACE.sub('', out.getvalue()) else: return out.getvalue() | def _execute(self, cmd): try: _err = sys.stderr _out = sys.stdout sys.stderr = sys.stdout = out = StringIO() try: self._admin.docmd(cmd) except SystemExit, e: pass return STRIP_TRAILING_SPACE.sub('', out.getvalue()) finally: sys.stderr = _err sys.stdout = _out |
test_results = self._execute('about') | test_results = self._execute('about', strip_trailing_space=False) | def test_about(self): """ Tests the 'about' command in trac-admin. Since the 'about' command has no command arguments, it is hard to call it incorrectly. As a result, there is only this one test. """ |
if id == -1: | if not id: | def save_milestone(self, id): self.perm.assert_permission(perm.MILESTONE_MODIFY) if self.args.has_key('save'): name = self.args.get('name', '') if not name: raise TracError('You must provide a name for the milestone.', 'Required Field Missing') datemode = self.args.get('datemode', 'manual') if datemode == 'now': date =... |
elif id != -1: | elif id: | def save_milestone(self, id): self.perm.assert_permission(perm.MILESTONE_MODIFY) if self.args.has_key('save'): name = self.args.get('name', '') if not name: raise TracError('You must provide a name for the milestone.', 'Required Field Missing') datemode = self.args.get('datemode', 'manual') if datemode == 'now': date =... |
id = self.args.get('id', -1) | id = self.args.get('id') | def render(self): self.perm.assert_permission(perm.MILESTONE_VIEW) |
self.render_editor(-1) | self.render_editor() | def render(self): self.perm.assert_permission(perm.MILESTONE_VIEW) |
def render_editor(self, id): if id == -1: | def render_editor(self, id=None): if not id: | def render_editor(self, id): if id == -1: milestone = { 'name': '', 'date': '', 'descr': '' } self.req.hdf.setValue('title', 'New Milestone') self.req.hdf.setValue('milestone.mode', 'new') else: milestone = self.get_milestone(id) self.req.hdf.setValue('title', 'Milestone %s' % milestone['name']) self.req.hdf.setValue('... |
space_re = re.compile(' ( +)|^ ') | space_re = re.compile('(?P<spaces> (?: +))|' '^(?P<tag><\w+.*?>)?( )') | def _annotate(self, lines, annotations): buf = StringIO() buf.write('<table class="code-block listing"><thead><tr>') annotators = [] for annotator in self.annotators: atype, alabel, adesc = annotator.get_annotation_type() if atype in annotations: buf.write('<th class="%s">%s</th>' % (atype, alabel)) annotators.append(a... |
div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' | m = match.group('spaces') if m: div, mod = divmod(len(m), 2) return div * ' ' + mod * ' ' return (match.group('tag') or '') + ' ' | def htmlify(match): div, mod = divmod(len(match.group(0)), 2) return div * ' ' + mod * ' ' |
return '<th id="l%s">%s</th>' % (number, number) | return '<th id="l%s"><a href=" number) | def annotate_line(self, number, content): return '<th id="l%s">%s</th>' % (number, number) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.