/usr/share/pyshared/pyrrd/util/dist.py is in python-pyrrd 0.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import os
import re
from pyrrd import meta
legalReSTFiles = [
'README',
'TODO',
'DEPENDENCIES',
]
def setup(*args, **kwds):
"""
Compatibility wrapper.
"""
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
return setup(*args, **kwds)
def findPackages():
"""
Compatibility wrapper.
Taken from storm setup.py.
"""
try:
from setuptools import find_packages
return find_packages()
except ImportError:
pass
packages = []
for directory, subdirectories, files in os.walk(meta.library_name):
if '__init__.py' in files:
packages.append(directory.replace(os.sep, '.'))
return packages
def hasDocutils():
"""
Check to see if docutils is installed.
"""
try:
import docutils
return True
except ImportError:
return False
def _validateReST(text):
"""
Make sure that the given ReST text is valid.
Taken from Zope Corp's zc.twist setup.py.
"""
import docutils.utils
import docutils.parsers.rst
import StringIO
doc = docutils.utils.new_document('validator')
# our desired settings
doc.reporter.halt_level = 5
doc.reporter.report_level = 1
stream = doc.reporter.stream = StringIO.StringIO()
# docutils buglets (?)
doc.settings.tab_width = 2
doc.settings.pep_references = doc.settings.rfc_references = False
doc.settings.trim_footnote_reference_space = None
# and we're off...
parser = docutils.parsers.rst.Parser()
parser.parse(text, doc)
return stream.getvalue()
def validateReST(text):
"""
A wrapper that ensafens the validation for pythons that are not embiggened
with docutils.
"""
if hasDocutils():
return _validateReST(text)
print " *** No docutils; can't validate ReST."
return ''
def catReST(*args, **kwds):
"""
Concatenate the contents of one or more ReST files.
Taken from Zope Corp's zc.twist setup.py.
"""
# note: distutils explicitly disallows unicode for setup values :-/
# http://docs.python.org/dist/meta-data.html
tmp = []
for arg in args:
if arg in legalReSTFiles or arg.endswith('.txt'):
f = open(os.path.join(*arg.split('/')))
tmp.append(f.read())
f.close()
tmp.append('\n\n')
else:
print "Warning: '%s' not a legal ReST filename."
tmp.append(arg)
if len(tmp) == 1:
res = tmp[0]
else:
res = ''.join(tmp)
out = kwds.get('out')
stop_on_errors = kwds.get('stop_on_errors')
if out is True:
out = 'CHECK_THIS_BEFORE_UPLOAD.txt'
if out:
f = open(out, 'w')
f.write(res)
f.close()
report = validateReST(res)
if report:
print report
if stop_on_errors:
print 'ReST validation error'
print
print 'See the following:'
print ' http://docutils.sourceforge.net/docs/user/rst/cheatsheet.txt'
print ' http://docutils.sourceforge.net/docs/user/rst/quickstart.html'
print
raise ValueError('ReST validation error')
return res
|