mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Added plural version of the tickets role
This commit is contained in:
parent
baf1ad251e
commit
2231578922
4
NEWS
4
NEWS
|
@ -122,7 +122,7 @@ What's new in psycopg 2.4.6
|
||||||
- 'register_hstore()', 'register_composite()', 'tpc_recover()' work with
|
- 'register_hstore()', 'register_composite()', 'tpc_recover()' work with
|
||||||
RealDictConnection and Cursor (:ticket:`#114`).
|
RealDictConnection and Cursor (:ticket:`#114`).
|
||||||
- Fixed broken pool for Zope and connections re-init across ZSQL methods
|
- Fixed broken pool for Zope and connections re-init across ZSQL methods
|
||||||
in the same request (tickets #123, #125, #142).
|
in the same request (:tickets:`#123, #125, #142`).
|
||||||
- connect() raises an exception instead of swallowing keyword arguments
|
- connect() raises an exception instead of swallowing keyword arguments
|
||||||
when a connection string is specified as well (:ticket:`#131`).
|
when a connection string is specified as well (:ticket:`#131`).
|
||||||
- Discard any result produced by 'executemany()' (:ticket:`#133`).
|
- Discard any result produced by 'executemany()' (:ticket:`#133`).
|
||||||
|
@ -144,7 +144,7 @@ What's new in psycopg 2.4.5
|
||||||
- Error and its subclasses are picklable, useful for multiprocessing
|
- Error and its subclasses are picklable, useful for multiprocessing
|
||||||
interaction (:ticket:`#90`).
|
interaction (:ticket:`#90`).
|
||||||
- Better efficiency and formatting of timezone offset objects thanks
|
- Better efficiency and formatting of timezone offset objects thanks
|
||||||
to Menno Smits (tickets #94, #95).
|
to Menno Smits (:tickets:`#94, #95`).
|
||||||
- Fixed 'rownumber' during iteration on cursor subclasses.
|
- Fixed 'rownumber' during iteration on cursor subclasses.
|
||||||
Regression introduced in 2.4.4 (:ticket:`#100`).
|
Regression introduced in 2.4.4 (:ticket:`#100`).
|
||||||
- Added support for 'inet' arrays.
|
- Added support for 'inet' arrays.
|
||||||
|
|
|
@ -8,26 +8,24 @@
|
||||||
:copyright: Copyright 2013 by Daniele Varrazzo.
|
:copyright: Copyright 2013 by Daniele Varrazzo.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
from docutils import nodes, utils
|
from docutils import nodes, utils
|
||||||
from docutils.parsers.rst import roles
|
from docutils.parsers.rst import roles
|
||||||
|
|
||||||
def ticket_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
def ticket_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
try:
|
|
||||||
num = int(text.replace('#', ''))
|
|
||||||
except ValueError:
|
|
||||||
msg = inliner.reporter.error(
|
|
||||||
"ticket number must be... a number, got '%s'" % text)
|
|
||||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
|
||||||
return [prb], [msg]
|
|
||||||
|
|
||||||
cfg = inliner.document.settings.env.app.config
|
cfg = inliner.document.settings.env.app.config
|
||||||
url_pattern = cfg.ticket_url
|
if cfg.ticket_url is None:
|
||||||
if url_pattern is None:
|
|
||||||
msg = inliner.reporter.warning(
|
msg = inliner.reporter.warning(
|
||||||
"ticket not configured: please configure ticket_url in conf.py")
|
"ticket not configured: please configure ticket_url in conf.py")
|
||||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||||
return [prb], [msg]
|
return [prb], [msg]
|
||||||
|
|
||||||
|
rv = [nodes.Text(name + ' ')]
|
||||||
|
tokens = re.findall(r'(#?\d+)|([^\d#]+)', text)
|
||||||
|
for ticket, noise in tokens:
|
||||||
|
if ticket:
|
||||||
|
num = int(ticket.replace('#', ''))
|
||||||
|
|
||||||
# Push numbers of the oldel tickets ahead.
|
# Push numbers of the oldel tickets ahead.
|
||||||
# We moved the tickets from a different tracker to GitHub and the
|
# We moved the tickets from a different tracker to GitHub and the
|
||||||
# latter already had a few ticket numbers taken (as merge
|
# latter already had a few ticket numbers taken (as merge
|
||||||
|
@ -38,15 +36,24 @@ def ticket_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
if num <= remap_until:
|
if num <= remap_until:
|
||||||
num += remap_offset
|
num += remap_offset
|
||||||
|
|
||||||
url = url_pattern % num
|
url = cfg.ticket_url % num
|
||||||
roles.set_classes(options)
|
roles.set_classes(options)
|
||||||
node = nodes.reference(rawtext, 'ticket ' + utils.unescape(text),
|
node = nodes.reference(ticket, utils.unescape(ticket),
|
||||||
refuri=url, **options)
|
refuri=url, **options)
|
||||||
return [node], []
|
|
||||||
|
rv.append(node)
|
||||||
|
|
||||||
|
else:
|
||||||
|
assert noise
|
||||||
|
rv.append(nodes.Text(noise))
|
||||||
|
|
||||||
|
return rv, []
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
app.add_config_value('ticket_url', None, 'env')
|
app.add_config_value('ticket_url', None, 'env')
|
||||||
app.add_config_value('ticket_remap_until', None, 'env')
|
app.add_config_value('ticket_remap_until', None, 'env')
|
||||||
app.add_config_value('ticket_remap_offset', None, 'env')
|
app.add_config_value('ticket_remap_offset', None, 'env')
|
||||||
app.add_role('ticket', ticket_role)
|
app.add_role('ticket', ticket_role)
|
||||||
|
app.add_role('tickets', ticket_role)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user