summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarien Zwart <marienz@gentoo.org>2006-02-16 23:05:51 +0000
committerMarien Zwart <marienz@gentoo.org>2006-02-16 23:05:51 +0000
commit32aa9a1a0fa3e6c3ab97f2fecc977868862005c9 (patch)
tree29e5b0c370b155143083c4fcd4559c671d2d68a3 /dev-python/docutils/files
parentRemove block of package that is no longer in the tree and is only in one vers... (diff)
downloadgentoo-2-32aa9a1a0fa3e6c3ab97f2fecc977868862005c9.tar.gz
gentoo-2-32aa9a1a0fa3e6c3ab97f2fecc977868862005c9.tar.bz2
gentoo-2-32aa9a1a0fa3e6c3ab97f2fecc977868862005c9.zip
Remove old versions.
(Portage version: 2660-svn)
Diffstat (limited to 'dev-python/docutils/files')
-rw-r--r--dev-python/docutils/files/digest-docutils-0.3-r11
-rw-r--r--dev-python/docutils/files/digest-docutils-0.3.3-r11
-rw-r--r--dev-python/docutils/files/digest-docutils-0.3_pre20030530-r31
-rw-r--r--dev-python/docutils/files/docutils-0.3-extramodules.patch32
-rw-r--r--dev-python/docutils/files/docutils-0.3.3-extramodules.patch32
-rw-r--r--dev-python/docutils/files/glep-0.3-r1/glep.py27
-rw-r--r--dev-python/docutils/files/glep-0.3-r1/glep_htmlwrite.py112
-rw-r--r--dev-python/docutils/files/glep-0.3-r1/glepread.py53
-rw-r--r--dev-python/docutils/files/glep-0.3-r1/glepstrans.py293
-rw-r--r--dev-python/docutils/files/glep-0.3.3/glep.py27
-rw-r--r--dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py94
-rw-r--r--dev-python/docutils/files/glep-0.3.3/glepread.py61
-rw-r--r--dev-python/docutils/files/glep-0.3.3/glepstrans.py303
-rw-r--r--dev-python/docutils/files/glep.py27
-rw-r--r--dev-python/docutils/files/glep_htmlwrite.py112
-rw-r--r--dev-python/docutils/files/glepread.py53
-rw-r--r--dev-python/docutils/files/glepstrans.py293
17 files changed, 0 insertions, 1522 deletions
diff --git a/dev-python/docutils/files/digest-docutils-0.3-r1 b/dev-python/docutils/files/digest-docutils-0.3-r1
deleted file mode 100644
index bdb677fa30f3..000000000000
--- a/dev-python/docutils/files/digest-docutils-0.3-r1
+++ /dev/null
@@ -1 +0,0 @@
-MD5 d8c78dd09610055431ac8df30312bdb9 docutils-0.3.tar.gz 485575
diff --git a/dev-python/docutils/files/digest-docutils-0.3.3-r1 b/dev-python/docutils/files/digest-docutils-0.3.3-r1
deleted file mode 100644
index 6fd639a7f34c..000000000000
--- a/dev-python/docutils/files/digest-docutils-0.3.3-r1
+++ /dev/null
@@ -1 +0,0 @@
-MD5 e2ee36b7e878cb53fcee564aaba1f067 docutils-0.3.3-alpha.tar.gz 539340
diff --git a/dev-python/docutils/files/digest-docutils-0.3_pre20030530-r3 b/dev-python/docutils/files/digest-docutils-0.3_pre20030530-r3
deleted file mode 100644
index 82fdd4ba805e..000000000000
--- a/dev-python/docutils/files/digest-docutils-0.3_pre20030530-r3
+++ /dev/null
@@ -1 +0,0 @@
-MD5 fe067d12639ff29d2e307d36a52fcfe0 docutils-0.3_pre20030530.tgz 460854
diff --git a/dev-python/docutils/files/docutils-0.3-extramodules.patch b/dev-python/docutils/files/docutils-0.3-extramodules.patch
deleted file mode 100644
index a7e34def3165..000000000000
--- a/dev-python/docutils/files/docutils-0.3-extramodules.patch
+++ /dev/null
@@ -1,32 +0,0 @@
---- docutils-0.3/setup.py 2003-06-25 02:47:04.000000000 +0100
-+++ docutils-0.3/setup.py.new 2003-07-08 00:21:59.000000000 +0100
-@@ -78,20 +78,15 @@
- List of (module name, minimum __version__ string, [attribute names])."""
-
- def get_extras():
-- extras = []
-- for module_name, version, attributes in extra_modules:
-- try:
-- module = __import__(module_name)
-- if version and module.__version__ < version:
-- raise ValueError
-- for attribute in attributes or []:
-- getattr(module, attribute)
-- print ('"%s" module already present; ignoring extras/%s.py.'
-- % (module_name, module_name))
-- except (ImportError, AttributeError, ValueError):
-- extras.append(module_name)
-- return extras
--
-+ # old method does not work for upgrading/downgrading docutils.
-+ # so we use a simple rule, 'optparse' and 'textwrap' are not installed
-+ # for >=python-2.3
-+
-+ pyver = sys.version_info
-+ if pyver[0] == 2 and pyver[1] > 2:
-+ return ["roman"]
-+ else:
-+ return ["optparse","textwrap","roman"]
-
- class dual_build_py(build_py):
-
diff --git a/dev-python/docutils/files/docutils-0.3.3-extramodules.patch b/dev-python/docutils/files/docutils-0.3.3-extramodules.patch
deleted file mode 100644
index 49d49df3dc29..000000000000
--- a/dev-python/docutils/files/docutils-0.3.3-extramodules.patch
+++ /dev/null
@@ -1,32 +0,0 @@
---- docutils-0.3.3/setup.py 2003-06-25 02:47:04.000000000 +0100
-+++ docutils-0.3.3/setup.py.new 2003-07-08 00:21:59.000000000 +0100
-@@ -78,20 +78,15 @@
- List of (module name, minimum __version__ string, [attribute names])."""
-
- def get_extras():
-- extras = []
-- for module_name, version, attributes in extra_modules:
-- try:
-- module = __import__(module_name)
-- if version and module.__version__ < version:
-- raise ValueError
-- for attribute in attributes or []:
-- getattr(module, attribute)
-- print ('"%s" module already present; ignoring extras/%s.py.'
-- % (module_name, module_name))
-- except (ImportError, AttributeError, ValueError):
-- extras.append(module_name)
-- return extras
--
-+ # old method does not work for upgrading/downgrading docutils.
-+ # so we use a simple rule, 'optparse' and 'textwrap' are not installed
-+ # for >=python-2.3
-+
-+ pyver = sys.version_info
-+ if pyver[0] == 2 and pyver[1] > 2:
-+ return ["roman"]
-+ else:
-+ return ["optparse","textwrap","roman"]
-
- class dual_build_py(build_py):
-
diff --git a/dev-python/docutils/files/glep-0.3-r1/glep.py b/dev-python/docutils/files/glep-0.3-r1/glep.py
deleted file mode 100644
index f023008f2bf7..000000000000
--- a/dev-python/docutils/files/glep-0.3-r1/glep.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2003/07/07 23:39:10 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-A minimal front end to the Docutils Publisher, producing HTML from PEP
-(Python Enhancement Proposal) documents.
-"""
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = ('Generates (X)HTML from reStructuredText-format PEP files. '
- + default_description)
-
-publish_cmdline(reader_name='glep', writer_name='glep_html',
- description=description)
diff --git a/dev-python/docutils/files/glep-0.3-r1/glep_htmlwrite.py b/dev-python/docutils/files/glep-0.3-r1/glep_htmlwrite.py
deleted file mode 100644
index 7d4b7f9bdf99..000000000000
--- a/dev-python/docutils/files/glep-0.3-r1/glep_htmlwrite.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2003/07/07 23:39:10 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-PEP HTML Writer.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import docutils
-from docutils import nodes, frontend, utils
-from docutils.writers import html4css1
-
-class Writer(html4css1.Writer):
-
- settings_spec = html4css1.Writer.settings_spec + (
- 'PEP/HTML-Specific Options',
- 'The HTML --footnote-references option is set to "brackets" by '
- 'default.',
- (('Specify a PEP stylesheet URL, used verbatim. Default is '
- '--stylesheet\'s value. If given, --pep-stylesheet overrides '
- '--stylesheet.',
- ['--pep-stylesheet'],
- {'metavar': '<URL>'}),
- ('Specify a PEP stylesheet file, relative to the current working '
- 'directory. The path is adjusted relative to the output HTML '
- 'file. Overrides --pep-stylesheet and --stylesheet-path.',
- ['--pep-stylesheet-path'],
- {'metavar': '<path>'}),
- ('Specify a template file. Default is "pep-html-template".',
- ['--pep-template'],
- {'default': 'pep-html-template', 'metavar': '<file>'}),
- ('Python\'s home URL. Default is ".." (parent directory).',
- ['--python-home'],
- {'default': '..', 'metavar': '<URL>'}),
- ('Home URL prefix for PEPs. Default is "." (current directory).',
- ['--pep-home'],
- {'default': '.', 'metavar': '<URL>'}),
- # Workaround for SourceForge's broken Python
- # (``import random`` causes a segfault).
- (frontend.SUPPRESS_HELP,
- ['--no-random'], {'action': 'store_true'}),))
-
- settings_default_overrides = {'footnote_references': 'brackets'}
-
- relative_path_settings = ('pep_stylesheet_path', 'pep_template')
-
- def __init__(self):
- html4css1.Writer.__init__(self)
- self.translator_class = HTMLTranslator
-
- def translate(self):
- html4css1.Writer.translate(self)
- settings = self.document.settings
- template = open(settings.pep_template).read()
- # Substitutions dict for template:
- subs = {}
- subs['encoding'] = settings.output_encoding
- subs['version'] = docutils.__version__
- subs['stylesheet'] = ''.join(self.stylesheet)
- pyhome = settings.python_home
- subs['pyhome'] = pyhome
- subs['pephome'] = settings.pep_home
- if pyhome == '..':
- subs['pepindex'] = '.'
- else:
- subs['pepindex'] = 'http://www.gentoo.org/proj/en/glep'
- index = self.document.first_child_matching_class(nodes.field_list)
- header = self.document[index]
- pepnum = header[0][1].astext()
- subs['pep'] = pepnum
- if settings.no_random:
- subs['banner'] = 0
- else:
- import random
- subs['banner'] = random.randrange(64)
- try:
- subs['pepnum'] = '%04i' % int(pepnum)
- except:
- subs['pepnum'] = pepnum
- subs['title'] = header[1][1].astext()
- subs['body'] = ''.join(
- self.body_pre_docinfo + self.docinfo + self.body)
- subs['body_suffix'] = ''.join(self.body_suffix)
- self.output = template % subs
-
-
-class HTMLTranslator(html4css1.HTMLTranslator):
-
- def get_stylesheet_reference(self, relative_to=None):
- settings = self.settings
- if relative_to == None:
- relative_to = settings._destination
- if settings.pep_stylesheet_path:
- return utils.relative_path(relative_to,
- settings.pep_stylesheet_path)
- elif settings.pep_stylesheet:
- return settings.pep_stylesheet
- elif settings._stylesheet_path:
- return utils.relative_path(relative_to, settings.stylesheet_path)
- else:
- return settings.stylesheet
-
- def depart_field_list(self, node):
- html4css1.HTMLTranslator.depart_field_list(self, node)
- if node.get('class') == 'rfc2822':
- self.body.append('<hr />\n')
diff --git a/dev-python/docutils/files/glep-0.3-r1/glepread.py b/dev-python/docutils/files/glep-0.3-r1/glepread.py
deleted file mode 100644
index ec3b4cb23592..000000000000
--- a/dev-python/docutils/files/glep-0.3-r1/glepread.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2003/07/07 23:39:10 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Gentoo Linux Enhancement Proposal (GLEP) Reader.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import os
-import re
-from docutils import nodes
-from docutils.readers import standalone
-from docutils.transforms import gleps, references
-from docutils.parsers import rst
-
-
-class Reader(standalone.Reader):
-
- supported = ('glep',)
- """Contexts this reader supports."""
-
- settings_spec = (
- 'PEP Reader Option Defaults',
- 'The --pep-references and --rfc-references options (for the '
- 'reStructuredText parser) are on by default.',
- ())
-
- default_transforms = (references.Substitutions,
- gleps.Headers,
- gleps.Contents,
- references.ChainedTargets,
- references.AnonymousHyperlinks,
- references.IndirectHyperlinks,
- gleps.TargetNotes,
- references.Footnotes,
- references.ExternalTargets,
- references.InternalTargets,)
-
- settings_default_overrides = {'pep_references': 1, 'rfc_references': 1}
-
- inliner_class = rst.states.Inliner
-
- def __init__(self, parser=None, parser_name=None):
- """`parser` should be ``None``."""
- if parser is None:
- parser = rst.Parser(rfc2822=1, inliner=self.inliner_class())
- standalone.Reader.__init__(self, parser, '')
diff --git a/dev-python/docutils/files/glep-0.3-r1/glepstrans.py b/dev-python/docutils/files/glep-0.3-r1/glepstrans.py
deleted file mode 100644
index 5d59c9687604..000000000000
--- a/dev-python/docutils/files/glep-0.3-r1/glepstrans.py
+++ /dev/null
@@ -1,293 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.2 $
-# Date: $Date: 2003/07/29 00:15:37 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Transforms for GLEP processing.
-
-- `Headers`: Used to transform a PEP's initial RFC-2822 header. It remains a
- field list, but some entries get processed.
-- `Contents`: Auto-inserts a table of contents.
-"""
-
-__docformat__ = 'reStructuredText'
-
-import sys
-import os
-import re
-import time
-from docutils import nodes, utils
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
-from docutils.transforms import parts, references, misc
-
-
-class Headers(Transform):
-
- """
- Process fields in a GLEP's initial RFC-2822 header.
- """
-
- default_priority = 360
-
- pep_url = 'glep-%04d.html'
- pep_cvs_url = ('http://www.gentoo.org/cgi-bin/viewcvs.cgi/'
- 'xml/htdocs/proj/en/glep/glep-%04d.txt?cvsroot=gentoo')
- rcs_keyword_substitutions = (
- (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'),
- (re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),)
-
- def apply(self):
- if not len(self.document):
- # @@@ replace these DataErrors with proper system messages
- raise DataError('Document tree is empty.')
- header = self.document[0]
- if not isinstance(header, nodes.field_list) or \
- header.get('class') != 'rfc2822':
- raise DataError('Document does not begin with an RFC-2822 '
- 'header; it is not a PEP.')
- pep = None
- for field in header:
- if field[0].astext().lower() == 'glep': # should be the first field
- value = field[1].astext()
- try:
- pep = int(value)
- cvs_url = self.pep_cvs_url % pep
- except ValueError:
- pep = value
- cvs_url = None
- msg = self.document.reporter.warning(
- '"GLEP" header must contain an integer; "%s" is an '
- 'invalid value.' % pep, base_node=field)
- msgid = self.document.set_id(msg)
- prb = nodes.problematic(value, value or '(none)',
- refid=msgid)
- prbid = self.document.set_id(prb)
- msg.add_backref(prbid)
- if len(field[1]):
- field[1][0][:] = [prb]
- else:
- field[1] += nodes.paragraph('', '', prb)
- break
- if pep is None:
- raise DataError('Document does not contain an RFC-2822 "GLEP" '
- 'header.')
- if pep == 0:
- # Special processing for PEP 0.
- pending = nodes.pending(PEPZero)
- self.document.insert(1, pending)
- self.document.note_pending(pending)
- if len(header) < 2 or header[1][0].astext().lower() != 'title':
- raise DataError('No title!')
- for field in header:
- name = field[0].astext().lower()
- body = field[1]
- if len(body) > 1:
- raise DataError('GLEP header field body contains multiple '
- 'elements:\n%s' % field.pformat(level=1))
- elif len(body) == 1:
- if not isinstance(body[0], nodes.paragraph):
- raise DataError('GLEP header field body may only contain '
- 'a single paragraph:\n%s'
- % field.pformat(level=1))
- elif name == 'last-modified':
- date = time.strftime(
- '%d-%b-%Y',
- time.localtime(os.stat(self.document['source'])[8]))
- if cvs_url:
- body += nodes.paragraph(
- '', '', nodes.reference('', date, refuri=cvs_url))
- else:
- # empty
- continue
- para = body[0]
- if name == 'author':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node))
- elif name == 'discussions-to':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node, pep))
- elif name in ('replaces', 'replaced-by', 'requires'):
- newbody = []
- space = nodes.Text(' ')
- for refpep in re.split(',?\s+', body.astext()):
- pepno = int(refpep)
- newbody.append(nodes.reference(
- refpep, refpep, refuri=self.pep_url % pepno))
- newbody.append(space)
- para[:] = newbody[:-1] # drop trailing space
- elif name == 'last-modified':
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
- if cvs_url:
- date = para.astext()
- para[:] = [nodes.reference('', date, refuri=cvs_url)]
- elif name == 'content-type':
- pep_type = para.astext()
- uri = self.pep_url % 2
- para[:] = [nodes.reference('', pep_type, refuri=uri)]
- elif name == 'version' and len(body):
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
-
-
-class Contents(Transform):
-
- """
- Insert a table of contents transform placeholder into the document after
- the RFC 2822 header.
- """
-
- default_priority = 380
-
- def apply(self):
- pending = nodes.pending(parts.Contents, {'title': None})
- self.document.insert(1, pending)
- self.document.note_pending(pending)
-
-
-class TargetNotes(Transform):
-
- """
- Locate the "References" section, insert a placeholder for an external
- target footnote insertion transform at the end, and schedule the
- transform to run immediately.
- """
-
- default_priority = 520
-
- def apply(self):
- doc = self.document
- i = len(doc) - 1
- refsect = copyright = None
- while i >= 0 and isinstance(doc[i], nodes.section):
- title_words = doc[i][0].astext().lower().split()
- if 'references' in title_words:
- refsect = doc[i]
- break
- elif 'copyright' in title_words:
- copyright = i
- i -= 1
- if not refsect:
- refsect = nodes.section()
- refsect += nodes.title('', 'References')
- doc.set_id(refsect)
- if copyright:
- # Put the new "References" section before "Copyright":
- doc.insert(copyright, refsect)
- else:
- # Put the new "References" section at end of doc:
- doc.append(refsect)
- pending = nodes.pending(references.TargetNotes)
- refsect.append(pending)
- self.document.note_pending(pending, 0)
- pending = nodes.pending(misc.CallBack,
- details={'callback': self.cleanup_callback})
- refsect.append(pending)
- self.document.note_pending(pending, 1)
-
- def cleanup_callback(self, pending):
- """
- Remove an empty "References" section.
-
- Called after the `references.TargetNotes` transform is complete.
- """
- if len(pending.parent) == 2: # <title> and <pending>
- pending.parent.parent.remove(pending.parent)
-
-
-class PEPZero(Transform):
-
- """
- Special processing for PEP 0.
- """
-
- default_priority =760
-
- def apply(self):
- visitor = PEPZeroSpecial(self.document)
- self.document.walk(visitor)
- self.startnode.parent.remove(self.startnode)
-
-
-class PEPZeroSpecial(nodes.SparseNodeVisitor):
-
- """
- Perform the special processing needed by PEP 0:
-
- - Mask email addresses.
-
- - Link PEP numbers in the second column of 4-column tables to the PEPs
- themselves.
- """
-
- pep_url = Headers.pep_url
-
- def unknown_visit(self, node):
- pass
-
- def visit_reference(self, node):
- node.parent.replace(node, mask_email(node))
-
- def visit_field_list(self, node):
- if node.hasattr('class') and node['class'] == 'rfc2822':
- raise nodes.SkipNode
-
- def visit_tgroup(self, node):
- self.pep_table = node['cols'] == 4
- self.entry = 0
-
- def visit_colspec(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2:
- node['class'] = 'num'
-
- def visit_row(self, node):
- self.entry = 0
-
- def visit_entry(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2 and len(node) == 1:
- node['class'] = 'num'
- p = node[0]
- if isinstance(p, nodes.paragraph) and len(p) == 1:
- text = p.astext()
- try:
- pep = int(text)
- ref = self.pep_url % pep
- p[0] = nodes.reference(text, text, refuri=ref)
- except ValueError:
- pass
-
-
-non_masked_addresses = ('peps@python.org',
- 'python-list@python.org',
- 'python-dev@python.org')
-
-def mask_email(ref, pepno=None):
- """
- Mask the email address in `ref` and return a replacement node.
-
- `ref` is returned unchanged if it contains no email address.
-
- For email addresses such as "user@host", mask the address as "user at
- host" (text) to thwart simple email address harvesters (except for those
- listed in `non_masked_addresses`). If a PEP number (`pepno`) is given,
- return a reference including a default email subject.
- """
- if ref.hasattr('refuri') and ref['refuri'].startswith('mailto:'):
- if ref['refuri'][8:] in non_masked_addresses:
- replacement = ref[0]
- else:
- replacement_text = ref.astext().replace('@', '&#32;&#97;t&#32;')
- replacement = nodes.raw('', replacement_text, format='html')
- if pepno is None:
- return replacement
- else:
- ref['refuri'] += '?subject=PEP%%20%s' % pepno
- ref[:] = [replacement]
- return ref
- else:
- return ref
diff --git a/dev-python/docutils/files/glep-0.3.3/glep.py b/dev-python/docutils/files/glep-0.3.3/glep.py
deleted file mode 100644
index e3fb18848833..000000000000
--- a/dev-python/docutils/files/glep-0.3.3/glep.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2004/07/20 18:23:59 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-A minimal front end to the Docutils Publisher, producing HTML from PEP
-(Python Enhancement Proposal) documents.
-"""
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = ('Generates (X)HTML from reStructuredText-format PEP files. '
- + default_description)
-
-publish_cmdline(reader_name='glep', writer_name='glep_html',
- description=description)
diff --git a/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py b/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py
deleted file mode 100644
index 710c9d2264fa..000000000000
--- a/dev-python/docutils/files/glep-0.3.3/glep_htmlwrite.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2004/07/20 18:23:59 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-PEP HTML Writer.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import docutils
-from docutils import frontend, nodes, utils
-from docutils.writers import html4css1
-
-
-class Writer(html4css1.Writer):
-
- settings_spec = html4css1.Writer.settings_spec + (
- 'PEP/HTML-Specific Options',
- """The HTML --footnote-references option's default is set to """
- '"brackets".',
- (('Specify a template file. Default is "pep-html-template".',
- ['--template'],
- {'default': 'pep-html-template', 'metavar': '<file>'}),
- ('Python\'s home URL. Default is ".." (parent directory).',
- ['--python-home'],
- {'default': '..', 'metavar': '<URL>'}),
- ('Home URL prefix for PEPs. Default is "." (current directory).',
- ['--pep-home'],
- {'default': '.', 'metavar': '<URL>'}),
- # Workaround for SourceForge's broken Python
- # (``import random`` causes a segfault).
- (frontend.SUPPRESS_HELP,
- ['--no-random'],
- {'action': 'store_true', 'validator': frontend.validate_boolean}),))
-
- settings_default_overrides = {'footnote_references': 'brackets'}
-
- relative_path_settings = (html4css1.Writer.relative_path_settings
- + ('template',))
-
- config_section = 'pep_html writer'
- config_section_dependencies = ('writers', 'html4css1 writer')
-
- def __init__(self):
- html4css1.Writer.__init__(self)
- self.translator_class = HTMLTranslator
-
- def translate(self):
- html4css1.Writer.translate(self)
- settings = self.document.settings
- template = open(settings.template).read()
- # Substitutions dict for template:
- subs = {}
- subs['encoding'] = settings.output_encoding
- subs['version'] = docutils.__version__
- subs['stylesheet'] = ''.join(self.stylesheet)
- pyhome = settings.python_home
- subs['pyhome'] = pyhome
- subs['pephome'] = settings.pep_home
- if pyhome == '..':
- subs['pepindex'] = '.'
- else:
- subs['pepindex'] = 'http://www.gentoo.org/proj/en/glep'
- index = self.document.first_child_matching_class(nodes.field_list)
- header = self.document[index]
- pepnum = header[0][1].astext()
- subs['pep'] = pepnum
- if settings.no_random:
- subs['banner'] = 0
- else:
- import random
- subs['banner'] = random.randrange(64)
- try:
- subs['pepnum'] = '%04i' % int(pepnum)
- except:
- subs['pepnum'] = pepnum
- subs['title'] = header[1][1].astext()
- subs['body'] = ''.join(
- self.body_pre_docinfo + self.docinfo + self.body)
- subs['body_suffix'] = ''.join(self.body_suffix)
- self.output = template % subs
-
-
-class HTMLTranslator(html4css1.HTMLTranslator):
-
- def depart_field_list(self, node):
- html4css1.HTMLTranslator.depart_field_list(self, node)
- if node.get('class') == 'rfc2822':
- self.body.append('<hr />\n')
diff --git a/dev-python/docutils/files/glep-0.3.3/glepread.py b/dev-python/docutils/files/glep-0.3.3/glepread.py
deleted file mode 100644
index 807c13161839..000000000000
--- a/dev-python/docutils/files/glep-0.3.3/glepread.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2004/07/20 18:23:59 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Gentoo Linux Enhancement Proposal (GLEP) Reader.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-from docutils.readers import standalone
-from docutils.transforms import gleps, references
-from docutils.parsers import rst
-
-
-class Inliner(rst.states.Inliner):
-
- """
- Extend `rst.Inliner` for local PEP references.
- """
-
- pep_url = rst.states.Inliner.pep_url_local
-
-
-class Reader(standalone.Reader):
-
- supported = ('glep',)
- """Contexts this reader supports."""
-
- settings_spec = (
- 'PEP Reader Option Defaults',
- 'The --pep-references and --rfc-references options (for the '
- 'reStructuredText parser) are on by default.',
- ())
-
- config_section = 'pep reader'
- config_section_dependencies = ('readers', 'standalone reader')
-
- default_transforms = (references.Substitutions,
- gleps.Headers,
- gleps.Contents,
- references.ChainedTargets,
- references.AnonymousHyperlinks,
- references.IndirectHyperlinks,
- gleps.TargetNotes,
- references.Footnotes,
- references.ExternalTargets,
- references.InternalTargets,)
-
- settings_default_overrides = {'pep_references': 1, 'rfc_references': 1}
-
- inliner_class = Inliner
-
- def __init__(self, parser=None, parser_name=None):
- """`parser` should be ``None``."""
- if parser is None:
- parser = rst.Parser(rfc2822=1, inliner=self.inliner_class())
- standalone.Reader.__init__(self, parser, '')
diff --git a/dev-python/docutils/files/glep-0.3.3/glepstrans.py b/dev-python/docutils/files/glep-0.3.3/glepstrans.py
deleted file mode 100644
index 64dafd174b03..000000000000
--- a/dev-python/docutils/files/glep-0.3.3/glepstrans.py
+++ /dev/null
@@ -1,303 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2004/07/20 18:23:59 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Transforms for PEP processing.
-
-- `Headers`: Used to transform a PEP's initial RFC-2822 header. It remains a
- field list, but some entries get processed.
-- `Contents`: Auto-inserts a table of contents.
-- `PEPZero`: Special processing for PEP 0.
-"""
-
-__docformat__ = 'reStructuredText'
-
-import sys
-import os
-import re
-import time
-from docutils import nodes, utils, languages
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
-from docutils.transforms import parts, references, misc
-
-
-class Headers(Transform):
-
- """
- Process fields in a GLEP's initial RFC-2822 header.
- """
-
- default_priority = 360
-
- pep_url = 'glep-%04d.html'
- pep_cvs_url = ('http://www.gentoo.org/cgi-bin/viewcvs/'
- 'xml/htdocs/proj/en/glep/glep-%04d.txt?cvsroot=gentoo')
- rcs_keyword_substitutions = (
- (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'),
- (re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),)
-
- def apply(self):
- if not len(self.document):
- # @@@ replace these DataErrors with proper system messages
- raise DataError('Document tree is empty.')
- header = self.document[0]
- if not isinstance(header, nodes.field_list) or \
- header.get('class') != 'rfc2822':
- raise DataError('Document does not begin with an RFC-2822 '
- 'header; it is not a GLEP.')
- pep = None
- for field in header:
- if field[0].astext().lower() == 'glep': # should be the first field
- value = field[1].astext()
- try:
- pep = int(value)
- cvs_url = self.pep_cvs_url % pep
- except ValueError:
- pep = value
- cvs_url = None
- msg = self.document.reporter.warning(
- '"GLEP" header must contain an integer; "%s" is an '
- 'invalid value.' % pep, base_node=field)
- msgid = self.document.set_id(msg)
- prb = nodes.problematic(value, value or '(none)',
- refid=msgid)
- prbid = self.document.set_id(prb)
- msg.add_backref(prbid)
- if len(field[1]):
- field[1][0][:] = [prb]
- else:
- field[1] += nodes.paragraph('', '', prb)
- break
- if pep is None:
- raise DataError('Document does not contain an RFC-2822 "GLEP" '
- 'header.')
- if pep == 0:
- # Special processing for PEP 0.
- pending = nodes.pending(PEPZero)
- self.document.insert(1, pending)
- self.document.note_pending(pending)
- if len(header) < 2 or header[1][0].astext().lower() != 'title':
- raise DataError('No title!')
- for field in header:
- name = field[0].astext().lower()
- body = field[1]
- if len(body) > 1:
- raise DataError('GLEP header field body contains multiple '
- 'elements:\n%s' % field.pformat(level=1))
- elif len(body) == 1:
- if not isinstance(body[0], nodes.paragraph):
- raise DataError('GLEP header field body may only contain '
- 'a single paragraph:\n%s'
- % field.pformat(level=1))
- elif name == 'last-modified':
- date = time.strftime(
- '%d-%b-%Y',
- time.localtime(os.stat(self.document['source'])[8]))
- if cvs_url:
- body += nodes.paragraph(
- '', '', nodes.reference('', date, refuri=cvs_url))
- else:
- # empty
- continue
- para = body[0]
- if name == 'author':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node))
- elif name == 'discussions-to':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node, pep))
- elif name in ('replaces', 'replaced-by', 'requires'):
- newbody = []
- space = nodes.Text(' ')
- for refpep in re.split(',?\s+', body.astext()):
- pepno = int(refpep)
- newbody.append(nodes.reference(
- refpep, refpep, refuri=self.pep_url % pepno))
- newbody.append(space)
- para[:] = newbody[:-1] # drop trailing space
- elif name == 'last-modified':
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
- if cvs_url:
- date = para.astext()
- para[:] = [nodes.reference('', date, refuri=cvs_url)]
- elif name == 'content-type':
- pep_type = para.astext()
- uri = self.pep_url % 12
- para[:] = [nodes.reference('', pep_type, refuri=uri)]
- elif name == 'version' and len(body):
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
-
-
-class Contents(Transform):
-
- """
- Insert an empty table of contents topic and a transform placeholder into
- the document after the RFC 2822 header.
- """
-
- default_priority = 380
-
- def apply(self):
- language = languages.get_language(self.document.settings.language_code)
- name = language.labels['contents']
- title = nodes.title('', name)
- topic = nodes.topic('', title, CLASS='contents')
- name = nodes.fully_normalize_name(name)
- if not self.document.has_name(name):
- topic['name'] = name
- self.document.note_implicit_target(topic)
- pending = nodes.pending(parts.Contents)
- topic += pending
- self.document.insert(1, topic)
- self.document.note_pending(pending)
-
-
-class TargetNotes(Transform):
-
- """
- Locate the "References" section, insert a placeholder for an external
- target footnote insertion transform at the end, and schedule the
- transform to run immediately.
- """
-
- default_priority = 520
-
- def apply(self):
- doc = self.document
- i = len(doc) - 1
- refsect = copyright = None
- while i >= 0 and isinstance(doc[i], nodes.section):
- title_words = doc[i][0].astext().lower().split()
- if 'references' in title_words:
- refsect = doc[i]
- break
- elif 'copyright' in title_words:
- copyright = i
- i -= 1
- if not refsect:
- refsect = nodes.section()
- refsect += nodes.title('', 'References')
- doc.set_id(refsect)
- if copyright:
- # Put the new "References" section before "Copyright":
- doc.insert(copyright, refsect)
- else:
- # Put the new "References" section at end of doc:
- doc.append(refsect)
- pending = nodes.pending(references.TargetNotes)
- refsect.append(pending)
- self.document.note_pending(pending, 0)
- pending = nodes.pending(misc.CallBack,
- details={'callback': self.cleanup_callback})
- refsect.append(pending)
- self.document.note_pending(pending, 1)
-
- def cleanup_callback(self, pending):
- """
- Remove an empty "References" section.
-
- Called after the `references.TargetNotes` transform is complete.
- """
- if len(pending.parent) == 2: # <title> and <pending>
- pending.parent.parent.remove(pending.parent)
-
-
-class PEPZero(Transform):
-
- """
- Special processing for PEP 0.
- """
-
- default_priority =760
-
- def apply(self):
- visitor = PEPZeroSpecial(self.document)
- self.document.walk(visitor)
- self.startnode.parent.remove(self.startnode)
-
-
-class PEPZeroSpecial(nodes.SparseNodeVisitor):
-
- """
- Perform the special processing needed by PEP 0:
-
- - Mask email addresses.
-
- - Link PEP numbers in the second column of 4-column tables to the PEPs
- themselves.
- """
-
- pep_url = Headers.pep_url
-
- def unknown_visit(self, node):
- pass
-
- def visit_reference(self, node):
- node.parent.replace(node, mask_email(node))
-
- def visit_field_list(self, node):
- if node.hasattr('class') and node['class'] == 'rfc2822':
- raise nodes.SkipNode
-
- def visit_tgroup(self, node):
- self.pep_table = node['cols'] == 4
- self.entry = 0
-
- def visit_colspec(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2:
- node['class'] = 'num'
-
- def visit_row(self, node):
- self.entry = 0
-
- def visit_entry(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2 and len(node) == 1:
- node['class'] = 'num'
- p = node[0]
- if isinstance(p, nodes.paragraph) and len(p) == 1:
- text = p.astext()
- try:
- pep = int(text)
- ref = self.pep_url % pep
- p[0] = nodes.reference(text, text, refuri=ref)
- except ValueError:
- pass
-
-
-non_masked_addresses = ('peps@python.org',
- 'python-list@python.org',
- 'python-dev@python.org')
-
-def mask_email(ref, pepno=None):
- """
- Mask the email address in `ref` and return a replacement node.
-
- `ref` is returned unchanged if it contains no email address.
-
- For email addresses such as "user@host", mask the address as "user at
- host" (text) to thwart simple email address harvesters (except for those
- listed in `non_masked_addresses`). If a PEP number (`pepno`) is given,
- return a reference including a default email subject.
- """
- if ref.hasattr('refuri') and ref['refuri'].startswith('mailto:'):
- if ref['refuri'][8:] in non_masked_addresses:
- replacement = ref[0]
- else:
- replacement_text = ref.astext().replace('@', '&#32;&#97;t&#32;')
- replacement = nodes.raw('', replacement_text, format='html')
- if pepno is None:
- return replacement
- else:
- ref['refuri'] += '?subject=PEP%%20%s' % pepno
- ref[:] = [replacement]
- return ref
- else:
- return ref
diff --git a/dev-python/docutils/files/glep.py b/dev-python/docutils/files/glep.py
deleted file mode 100644
index b4a6c8517c8a..000000000000
--- a/dev-python/docutils/files/glep.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2003/06/01 03:57:44 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-A minimal front end to the Docutils Publisher, producing HTML from PEP
-(Python Enhancement Proposal) documents.
-"""
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-
-description = ('Generates (X)HTML from reStructuredText-format PEP files. '
- + default_description)
-
-publish_cmdline(reader_name='glep', writer_name='glep_html',
- description=description)
diff --git a/dev-python/docutils/files/glep_htmlwrite.py b/dev-python/docutils/files/glep_htmlwrite.py
deleted file mode 100644
index 2ac959de04bc..000000000000
--- a/dev-python/docutils/files/glep_htmlwrite.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.3 $
-# Date: $Date: 2003/06/04 19:39:20 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-PEP HTML Writer.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import docutils
-from docutils import nodes, optik, utils
-from docutils.writers import html4css1
-
-class Writer(html4css1.Writer):
-
- settings_spec = html4css1.Writer.settings_spec + (
- 'PEP/HTML-Specific Options',
- 'The HTML --footnote-references option is set to "brackets" by '
- 'default.',
- (('Specify a PEP stylesheet URL, used verbatim. Default is '
- '--stylesheet\'s value. If given, --pep-stylesheet overrides '
- '--stylesheet.',
- ['--pep-stylesheet'],
- {'metavar': '<URL>'}),
- ('Specify a PEP stylesheet file, relative to the current working '
- 'directory. The path is adjusted relative to the output HTML '
- 'file. Overrides --pep-stylesheet and --stylesheet-path.',
- ['--pep-stylesheet-path'],
- {'metavar': '<path>'}),
- ('Specify a template file. Default is "pep-html-template".',
- ['--pep-template'],
- {'default': 'pep-html-template', 'metavar': '<file>'}),
- ('Python\'s home URL. Default is ".." (parent directory).',
- ['--python-home'],
- {'default': '..', 'metavar': '<URL>'}),
- ('Home URL prefix for PEPs. Default is "." (current directory).',
- ['--pep-home'],
- {'default': '.', 'metavar': '<URL>'}),
- # Workaround for SourceForge's broken Python
- # (``import random`` causes a segfault).
- (optik.SUPPRESS_HELP,
- ['--no-random'], {'action': 'store_true'}),))
-
- settings_default_overrides = {'footnote_references': 'brackets'}
-
- relative_path_settings = ('pep_stylesheet_path', 'pep_template')
-
- def __init__(self):
- html4css1.Writer.__init__(self)
- self.translator_class = HTMLTranslator
-
- def translate(self):
- html4css1.Writer.translate(self)
- settings = self.document.settings
- template = open(settings.pep_template).read()
- # Substitutions dict for template:
- subs = {}
- subs['encoding'] = settings.output_encoding
- subs['version'] = docutils.__version__
- subs['stylesheet'] = ''.join(self.stylesheet)
- pyhome = settings.python_home
- subs['pyhome'] = pyhome
- subs['pephome'] = settings.pep_home
- if pyhome == '..':
- subs['pepindex'] = '.'
- else:
- subs['pepindex'] = 'http://www.gentoo.org/proj/en/glep'
- index = self.document.first_child_matching_class(nodes.field_list)
- header = self.document[index]
- pepnum = header[0][1].astext()
- subs['pep'] = pepnum
- if settings.no_random:
- subs['banner'] = 0
- else:
- import random
- subs['banner'] = random.randrange(64)
- try:
- subs['pepnum'] = '%04i' % int(pepnum)
- except:
- subs['pepnum'] = pepnum
- subs['title'] = header[1][1].astext()
- subs['body'] = ''.join(
- self.body_pre_docinfo + self.docinfo + self.body)
- subs['body_suffix'] = ''.join(self.body_suffix)
- self.output = template % subs
-
-
-class HTMLTranslator(html4css1.HTMLTranslator):
-
- def get_stylesheet_reference(self, relative_to=None):
- settings = self.settings
- if relative_to == None:
- relative_to = settings._destination
- if settings.pep_stylesheet_path:
- return utils.relative_path(relative_to,
- settings.pep_stylesheet_path)
- elif settings.pep_stylesheet:
- return settings.pep_stylesheet
- elif settings._stylesheet_path:
- return utils.relative_path(relative_to, settings.stylesheet_path)
- else:
- return settings.stylesheet
-
- def depart_field_list(self, node):
- html4css1.HTMLTranslator.depart_field_list(self, node)
- if node.get('class') == 'rfc2822':
- self.body.append('<hr />\n')
diff --git a/dev-python/docutils/files/glepread.py b/dev-python/docutils/files/glepread.py
deleted file mode 100644
index ad1d6333c802..000000000000
--- a/dev-python/docutils/files/glepread.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.1 $
-# Date: $Date: 2003/06/01 03:57:44 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Gentoo Linux Enhancement Proposal (GLEP) Reader.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import os
-import re
-from docutils import nodes
-from docutils.readers import standalone
-from docutils.transforms import gleps, references
-from docutils.parsers import rst
-
-
-class Reader(standalone.Reader):
-
- supported = ('glep',)
- """Contexts this reader supports."""
-
- settings_spec = (
- 'PEP Reader Option Defaults',
- 'The --pep-references and --rfc-references options (for the '
- 'reStructuredText parser) are on by default.',
- ())
-
- default_transforms = (references.Substitutions,
- gleps.Headers,
- gleps.Contents,
- references.ChainedTargets,
- references.AnonymousHyperlinks,
- references.IndirectHyperlinks,
- gleps.TargetNotes,
- references.Footnotes,
- references.ExternalTargets,
- references.InternalTargets,)
-
- settings_default_overrides = {'pep_references': 1, 'rfc_references': 1}
-
- inliner_class = rst.states.Inliner
-
- def __init__(self, parser=None, parser_name=None):
- """`parser` should be ``None``."""
- if parser is None:
- parser = rst.Parser(rfc2822=1, inliner=self.inliner_class())
- standalone.Reader.__init__(self, parser, '')
diff --git a/dev-python/docutils/files/glepstrans.py b/dev-python/docutils/files/glepstrans.py
deleted file mode 100644
index 1c2f5e0f562b..000000000000
--- a/dev-python/docutils/files/glepstrans.py
+++ /dev/null
@@ -1,293 +0,0 @@
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision: 1.2 $
-# Date: $Date: 2003/06/04 19:39:20 $
-# Copyright: This module has been placed in the public domain.
-
-"""
-Transforms for GLEP processing.
-
-- `Headers`: Used to transform a PEP's initial RFC-2822 header. It remains a
- field list, but some entries get processed.
-- `Contents`: Auto-inserts a table of contents.
-"""
-
-__docformat__ = 'reStructuredText'
-
-import sys
-import os
-import re
-import time
-from docutils import nodes, utils
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
-from docutils.transforms import parts, references, misc
-
-
-class Headers(Transform):
-
- """
- Process fields in a GLEP's initial RFC-2822 header.
- """
-
- default_priority = 360
-
- pep_url = 'glep-%04d.html'
- pep_cvs_url = ('http://cvs.gentoo.org/cgi-bin/viewcvs.cgi/gentoo/'
- 'xml/htdocs/proj/en/glep/glep-%04d.txt')
- rcs_keyword_substitutions = (
- (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'),
- (re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),)
-
- def apply(self):
- if not len(self.document):
- # @@@ replace these DataErrors with proper system messages
- raise DataError('Document tree is empty.')
- header = self.document[0]
- if not isinstance(header, nodes.field_list) or \
- header.get('class') != 'rfc2822':
- raise DataError('Document does not begin with an RFC-2822 '
- 'header; it is not a PEP.')
- pep = None
- for field in header:
- if field[0].astext().lower() == 'glep': # should be the first field
- value = field[1].astext()
- try:
- pep = int(value)
- cvs_url = self.pep_cvs_url % pep
- except ValueError:
- pep = value
- cvs_url = None
- msg = self.document.reporter.warning(
- '"GLEP" header must contain an integer; "%s" is an '
- 'invalid value.' % pep, base_node=field)
- msgid = self.document.set_id(msg)
- prb = nodes.problematic(value, value or '(none)',
- refid=msgid)
- prbid = self.document.set_id(prb)
- msg.add_backref(prbid)
- if len(field[1]):
- field[1][0][:] = [prb]
- else:
- field[1] += nodes.paragraph('', '', prb)
- break
- if pep is None:
- raise DataError('Document does not contain an RFC-2822 "GLEP" '
- 'header.')
- if pep == 0:
- # Special processing for PEP 0.
- pending = nodes.pending(PEPZero)
- self.document.insert(1, pending)
- self.document.note_pending(pending)
- if len(header) < 2 or header[1][0].astext().lower() != 'title':
- raise DataError('No title!')
- for field in header:
- name = field[0].astext().lower()
- body = field[1]
- if len(body) > 1:
- raise DataError('GLEP header field body contains multiple '
- 'elements:\n%s' % field.pformat(level=1))
- elif len(body) == 1:
- if not isinstance(body[0], nodes.paragraph):
- raise DataError('GLEP header field body may only contain '
- 'a single paragraph:\n%s'
- % field.pformat(level=1))
- elif name == 'last-modified':
- date = time.strftime(
- '%d-%b-%Y',
- time.localtime(os.stat(self.document['source'])[8]))
- if cvs_url:
- body += nodes.paragraph(
- '', '', nodes.reference('', date, refuri=cvs_url))
- else:
- # empty
- continue
- para = body[0]
- if name == 'author':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node))
- elif name == 'discussions-to':
- for node in para:
- if isinstance(node, nodes.reference):
- node.parent.replace(node, mask_email(node, pep))
- elif name in ('replaces', 'replaced-by', 'requires'):
- newbody = []
- space = nodes.Text(' ')
- for refpep in re.split(',?\s+', body.astext()):
- pepno = int(refpep)
- newbody.append(nodes.reference(
- refpep, refpep, refuri=self.pep_url % pepno))
- newbody.append(space)
- para[:] = newbody[:-1] # drop trailing space
- elif name == 'last-modified':
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
- if cvs_url:
- date = para.astext()
- para[:] = [nodes.reference('', date, refuri=cvs_url)]
- elif name == 'content-type':
- pep_type = para.astext()
- uri = self.pep_url % 2
- para[:] = [nodes.reference('', pep_type, refuri=uri)]
- elif name == 'version' and len(body):
- utils.clean_rcs_keywords(para, self.rcs_keyword_substitutions)
-
-
-class Contents(Transform):
-
- """
- Insert a table of contents transform placeholder into the document after
- the RFC 2822 header.
- """
-
- default_priority = 380
-
- def apply(self):
- pending = nodes.pending(parts.Contents, {'title': None})
- self.document.insert(1, pending)
- self.document.note_pending(pending)
-
-
-class TargetNotes(Transform):
-
- """
- Locate the "References" section, insert a placeholder for an external
- target footnote insertion transform at the end, and schedule the
- transform to run immediately.
- """
-
- default_priority = 520
-
- def apply(self):
- doc = self.document
- i = len(doc) - 1
- refsect = copyright = None
- while i >= 0 and isinstance(doc[i], nodes.section):
- title_words = doc[i][0].astext().lower().split()
- if 'references' in title_words:
- refsect = doc[i]
- break
- elif 'copyright' in title_words:
- copyright = i
- i -= 1
- if not refsect:
- refsect = nodes.section()
- refsect += nodes.title('', 'References')
- doc.set_id(refsect)
- if copyright:
- # Put the new "References" section before "Copyright":
- doc.insert(copyright, refsect)
- else:
- # Put the new "References" section at end of doc:
- doc.append(refsect)
- pending = nodes.pending(references.TargetNotes)
- refsect.append(pending)
- self.document.note_pending(pending, 0)
- pending = nodes.pending(misc.CallBack,
- details={'callback': self.cleanup_callback})
- refsect.append(pending)
- self.document.note_pending(pending, 1)
-
- def cleanup_callback(self, pending):
- """
- Remove an empty "References" section.
-
- Called after the `references.TargetNotes` transform is complete.
- """
- if len(pending.parent) == 2: # <title> and <pending>
- pending.parent.parent.remove(pending.parent)
-
-
-class PEPZero(Transform):
-
- """
- Special processing for PEP 0.
- """
-
- default_priority =760
-
- def apply(self):
- visitor = PEPZeroSpecial(self.document)
- self.document.walk(visitor)
- self.startnode.parent.remove(self.startnode)
-
-
-class PEPZeroSpecial(nodes.SparseNodeVisitor):
-
- """
- Perform the special processing needed by PEP 0:
-
- - Mask email addresses.
-
- - Link PEP numbers in the second column of 4-column tables to the PEPs
- themselves.
- """
-
- pep_url = Headers.pep_url
-
- def unknown_visit(self, node):
- pass
-
- def visit_reference(self, node):
- node.parent.replace(node, mask_email(node))
-
- def visit_field_list(self, node):
- if node.hasattr('class') and node['class'] == 'rfc2822':
- raise nodes.SkipNode
-
- def visit_tgroup(self, node):
- self.pep_table = node['cols'] == 4
- self.entry = 0
-
- def visit_colspec(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2:
- node['class'] = 'num'
-
- def visit_row(self, node):
- self.entry = 0
-
- def visit_entry(self, node):
- self.entry += 1
- if self.pep_table and self.entry == 2 and len(node) == 1:
- node['class'] = 'num'
- p = node[0]
- if isinstance(p, nodes.paragraph) and len(p) == 1:
- text = p.astext()
- try:
- pep = int(text)
- ref = self.pep_url % pep
- p[0] = nodes.reference(text, text, refuri=ref)
- except ValueError:
- pass
-
-
-non_masked_addresses = ('peps@python.org',
- 'python-list@python.org',
- 'python-dev@python.org')
-
-def mask_email(ref, pepno=None):
- """
- Mask the email address in `ref` and return a replacement node.
-
- `ref` is returned unchanged if it contains no email address.
-
- For email addresses such as "user@host", mask the address as "user at
- host" (text) to thwart simple email address harvesters (except for those
- listed in `non_masked_addresses`). If a PEP number (`pepno`) is given,
- return a reference including a default email subject.
- """
- if ref.hasattr('refuri') and ref['refuri'].startswith('mailto:'):
- if ref['refuri'][8:] in non_masked_addresses:
- replacement = ref[0]
- else:
- replacement_text = ref.astext().replace('@', '&#32;&#97;t&#32;')
- replacement = nodes.raw('', replacement_text, format='html')
- if pepno is None:
- return replacement
- else:
- ref['refuri'] += '?subject=PEP%%20%s' % pepno
- ref[:] = [replacement]
- return ref
- else:
- return ref