1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
Description: Allow all data files to be moved to /usr/share/docutils/.
Author: Jakub Wilk <jwilk@debian.org>
Forwarded: not-needed
Last-Update: 2013-07-22
--- a/docutils/parsers/rst/directives/misc.py
+++ b/docutils/parsers/rst/directives/misc.py
@@ -10,6 +10,7 @@
import os.path
import re
import time
+import docutils
from docutils import io, nodes, statemachine, utils
from docutils.utils.error_reporting import SafeString, ErrorString
from docutils.utils.error_reporting import locale_encoding
@@ -47,7 +48,7 @@
'class': directives.class_option,
'name': directives.unchanged}
- standard_include_path = os.path.join(os.path.dirname(states.__file__),
+ standard_include_path = os.path.join(docutils._datadir(states.__file__),
'include')
def run(self):
--- a/docutils/writers/html4css1/__init__.py
+++ b/docutils/writers/html4css1/__init__.py
@@ -44,13 +44,13 @@
default_stylesheet = 'html4css1.css'
default_stylesheet_dirs = ['.', utils.relative_path(
- os.path.join(os.getcwd(), 'dummy'), os.path.dirname(__file__))]
+ os.path.join(os.getcwd(), 'dummy'), docutils._datadir(__file__))]
default_template = 'template.txt'
default_template_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), default_template))
+ os.path.join(docutils._datadir(__file__), default_template))
settings_spec = (
'HTML-Specific Options',
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -23,6 +23,7 @@
import roman
except ImportError:
import docutils.utils.roman as roman
+import docutils
from docutils import frontend, nodes, languages, writers, utils, io
from docutils.utils.error_reporting import SafeString
from docutils.transforms import writer_aux
@@ -34,7 +35,7 @@
"""Formats this writer supports."""
default_template = 'default.tex'
- default_template_path = os.path.dirname(__file__)
+ default_template_path = docutils._datadir(__file__)
default_preamble = '\n'.join([r'% PDF Standard Fonts',
r'\usepackage{mathptmx} % Times',
--- a/docutils/writers/odf_odt/__init__.py
+++ b/docutils/writers/odf_odt/__init__.py
@@ -399,13 +399,13 @@
default_stylesheet_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), default_stylesheet))
+ os.path.join(docutils._datadir(__file__), default_stylesheet))
default_template = 'template.txt'
default_template_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), default_template))
+ os.path.join(docutils._datadir(__file__), default_template))
settings_spec = (
'ODF-Specific Options',
--- a/docutils/writers/pep_html/__init__.py
+++ b/docutils/writers/pep_html/__init__.py
@@ -24,13 +24,13 @@
default_stylesheet_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), default_stylesheet))
+ os.path.join(docutils._datadir(__file__), default_stylesheet))
default_template = 'template.txt'
default_template_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), default_template))
+ os.path.join(docutils._datadir(__file__), default_template))
settings_spec = html4css1.Writer.settings_spec + (
'PEP/HTML-Specific Options',
--- a/docutils/writers/s5_html/__init__.py
+++ b/docutils/writers/s5_html/__init__.py
@@ -21,7 +21,7 @@
themes_dir_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
- os.path.join(os.path.dirname(__file__), 'themes'))
+ os.path.join(docutils._datadir(__file__), 'themes'))
def find_theme(name):
# Where else to look for a theme?
--- a/docutils/__init__.py
+++ b/docutils/__init__.py
@@ -215,3 +215,18 @@
a certain input context or output format.
"""
return format in self.supported
+
+import os
+
+_debian_package = 0
+
+if _debian_package:
+ def _datadir(path):
+ dirname = os.path.dirname(path)
+ prefix = os.path.join(os.path.dirname(__file__), '') # _datadir
+ assert path.startswith(prefix), "%r doesn't start with %r" % (path, prefix)
+ suffix = dirname[len(prefix):]
+ return os.path.join('/usr/share/docutils/', suffix)
+else:
+ def _datadir(path):
+ return os.path.dirname(path)
--- a/test/test_parsers/test_rst/test_directives/test_include.py
+++ b/test/test_parsers/test_rst/test_directives/test_include.py
@@ -11,6 +11,7 @@
import os.path
import sys
from __init__ import DocutilsTestSupport
+import docutils
from docutils.parsers.rst import states
from docutils._compat import b
from docutils.utils.code_analyzer import with_pygments
@@ -45,7 +46,7 @@
utf_16_error_str = ("UnicodeError: Unable to decode input data. "
"Tried the following encodings: 'ascii'.\n"
" (%s)" % utf_16_error_str)
-nonexistent = os.path.join(os.path.dirname(states.__file__),
+nonexistent = os.path.join(docutils._datadir(states.__file__),
'include', 'nonexistent')
nonexistent_rel = DocutilsTestSupport.utils.relative_path(
os.path.join(DocutilsTestSupport.testroot, 'dummy'), nonexistent)
|