Merge lp://staging/~oubiwann/txgenshi/506281-util-cleanup into lp://staging/txgenshi

Proposed by Duncan McGreggor
Status: Needs review
Proposed branch: lp://staging/~oubiwann/txgenshi/506281-util-cleanup
Merge into: lp://staging/txgenshi
Diff against target: 302 lines (+180/-31)
7 files modified
ChangeLog (+4/-0)
README (+2/-2)
setup.py (+28/-5)
txgenshi/meta.py (+6/-3)
txgenshi/test/test_util.py (+3/-5)
txgenshi/util/base.py (+4/-16)
txgenshi/util/dist.py (+133/-0)
To merge this branch: bzr merge lp://staging/~oubiwann/txgenshi/506281-util-cleanup
Reviewer Review Type Date Requested Status
Cory Dodt Approve
Review via email: mp+17207@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Duncan McGreggor (oubiwann) wrote :

Okay, I did some cleanup of the util module, dist code, project metadata, and setup.py.

Revision history for this message
Cory Dodt (corydodt) wrote :
Download full text (9.7 KiB)

Any idea why I see this?

cdodt 0 ~/wc/txGenshi% *bzr merge lp:~oubiwann/txgenshi/506281-util-cleanup*
bzr: ERROR:
KnitPackRepository('file:///home/cdodt/wc/txGenshi/.bzr/repository/')
is not compatible with
RemoteRepository(bzr+ssh://
bazaar.launchpad.net/~oubiwann/txgenshi/506281-util-cleanup/.bzr/)
different rich-root support

I actually have something a bit like a test for your setup if you squint.
 I'm working on a Nevow-based framework called Chichimec, and it uses
virtualenv to build directories where Chichimec--and its dependencies,
including txGenshi--is installed. Then it runs tests inside the directory
that it generates. So indirectly it is a test of Chichimec's setup.
 Unfortunately the above error is blocking me (I could just patch, of
course, but it's late and I'd rather know what the error means).

From scanning the patch, I noticed there is a merge conflict marker stuck in
there, and it looks like __init__.py should have a docstring now. There may
be other modules that need them, perhaps that's a chore for your other bug
:-)

C

On Tue, Jan 12, 2010 at 12:12 AM, Duncan McGreggor <email address hidden>wrote:

> Duncan McGreggor has proposed merging
> lp:~oubiwann/txgenshi/506281-util-cleanup into lp:txgenshi.
>
> Requested reviews:
> Cory Dodt (corydodt)
> Related bugs:
> #506281 Cleanup txgenshi.util
> https://bugs.launchpad.net/bugs/506281
>
>
> Okay, I did some cleanup of the util module, dist code, project metadata,
> and setup.py.
> --
>
> https://code.launchpad.net/~oubiwann/txgenshi/506281-util-cleanup/+merge/17207
> You are requested to review the proposed merge of
> lp:~oubiwann/txgenshi/506281-util-cleanup into lp:txgenshi.
>
> === modified file 'ChangeLog'
> --- ChangeLog 2010-01-11 00:46:46 +0000
> +++ ChangeLog 2010-01-12 08:12:15 +0000
> @@ -1,3 +1,7 @@
> +2010.10.11
> +
> +* Cleaned up and re-orged the utility code and library metadata.
> +
> 2010.01.10
>
> * Added unit tests
>
> === modified file 'README'
> --- README 2010-01-11 00:46:46 +0000
> +++ README 2010-01-12 08:12:15 +0000
> @@ -37,7 +37,7 @@
> Changes
> =======
>
> -From txGenshi nothing to 0.0.1
> -------------------------------------
> +0.0.1
> +-----
>
> *
>
> === modified file 'setup.py'
> --- setup.py 2008-07-16 23:59:58 +0000
> +++ setup.py 2010-01-12 08:12:15 +0000
> @@ -1,5 +1,28 @@
> -import txgenshi
> -from txgenshi import util
> -
> -
> -util.setup(**util.setupDict)
> +from txgenshi import meta
> +from txgenshi.util import dist
> +
> +
> +dist.setup(
> + name=meta.display_name,
> + version=meta.version,
> + description=meta.description,
> + author=meta.author,
> + author_email=meta.author_email,
> + url=meta.url,
> + license=meta.license,
> + packages=dist.findPackages(meta.library_name),
> + long_description=dist.catReST(
> + "README",
> + "DEPENDENCIES",
> + stop_on_errors=True,
> + out=True),
> + classifiers=meta.classifiers,
> + package_data={
> + 'txgenshidemo': ['demo.tac',
> + 'templates/genshimix.xhtml',
> + 'templates/genshiinclude.xhtml',
> + 'templates/home.xhtml',
> + ...

Read more...

Revision history for this message
Cory Dodt (corydodt) wrote :

+1 with:

[1] add docstrings to modules you touched if missing (esp. txgenshi.__init__)

[2] conflict marker cruft removed. I just deleted these lines.

This passed the Chichimec installation test.

review: Approve

Unmerged revisions

43. By Duncan McGreggor

Updated ChangeLog.

42. By Duncan McGreggor

* Small tweak to README.

41. By Duncan McGreggor

* Updated the findPackages function to take the library name as a parameter.
* Fixed the dist import in setup.py

40. By Duncan McGreggor

* Moved the setup data out of the dist module and into setup.py.
* Moved metadata out of the init module (which should be empty) and into a meta
module.
* Updated setup.py to use the metadata module.

39. By Duncan McGreggor

Changed the find function name to use camelCase.

38. By Duncan McGreggor

* Moved dist functions out of base and into dist util module.
* Updated the util test module with the new import location.

37. By Duncan McGreggor

Fixed pyflakes.

36. By Duncan McGreggor

* Removed base util code from dist module.
* Removed some unnecessary new lines.

35. By Duncan McGreggor

Removed dist code from base util module.

34. By Duncan McGreggor

Converted the util module to a subpackage.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2010-01-11 00:46:46 +0000
3+++ ChangeLog 2010-01-12 08:12:15 +0000
4@@ -1,3 +1,7 @@
5+2010.10.11
6+
7+* Cleaned up and re-orged the utility code and library metadata.
8+
9 2010.01.10
10
11 * Added unit tests
12
13=== modified file 'README'
14--- README 2010-01-11 00:46:46 +0000
15+++ README 2010-01-12 08:12:15 +0000
16@@ -37,7 +37,7 @@
17 Changes
18 =======
19
20-From txGenshi nothing to 0.0.1
21-------------------------------------
22+0.0.1
23+-----
24
25 *
26
27=== modified file 'setup.py'
28--- setup.py 2008-07-16 23:59:58 +0000
29+++ setup.py 2010-01-12 08:12:15 +0000
30@@ -1,5 +1,28 @@
31-import txgenshi
32-from txgenshi import util
33-
34-
35-util.setup(**util.setupDict)
36+from txgenshi import meta
37+from txgenshi.util import dist
38+
39+
40+dist.setup(
41+ name=meta.display_name,
42+ version=meta.version,
43+ description=meta.description,
44+ author=meta.author,
45+ author_email=meta.author_email,
46+ url=meta.url,
47+ license=meta.license,
48+ packages=dist.findPackages(meta.library_name),
49+ long_description=dist.catReST(
50+ "README",
51+ "DEPENDENCIES",
52+ stop_on_errors=True,
53+ out=True),
54+ classifiers=meta.classifiers,
55+ package_data={
56+ 'txgenshidemo': ['demo.tac',
57+ 'templates/genshimix.xhtml',
58+ 'templates/genshiinclude.xhtml',
59+ 'templates/home.xhtml',
60+ 'templates/mystuff.xhtml',
61+ 'templates/yourstuff.xhtml',
62+ ]}
63+ )
64
65=== added file 'txgenshi/__init__.py'
66=== renamed file 'txgenshi/__init__.py' => 'txgenshi/meta.py'
67--- txgenshi/__init__.py 2010-01-07 18:48:32 +0000
68+++ txgenshi/meta.py 2010-01-12 08:12:15 +0000
69@@ -1,9 +1,12 @@
70-name = 'txGenshi'
71-shortName = 'txGenshi'
72-projectURL = 'https://launchpad.net/txgenshi'
73+display_name = 'txGenshi'
74+library_name = 'txgenshi'
75 summary = 'txGenshi: Twisted-Friendly Genshi Templates for Nevow'
76 description = summary
77+url = 'https://launchpad.net/txgenshi'
78+author = 'Duncan McGreggor, Cory Dodt'
79+author_email = 'oubiwann@adytum.us'
80 version = '0.0.1'
81+license = 'MIT'
82 classifiers = [
83 'Development Status :: 5 - Production/Stable',
84 'Environment :: Web Environment',
85
86=== modified file 'txgenshi/test/test_util.py'
87--- txgenshi/test/test_util.py 2008-07-18 15:51:29 +0000
88+++ txgenshi/test/test_util.py 2010-01-12 08:12:15 +0000
89@@ -2,15 +2,13 @@
90
91 from twisted.trial import unittest
92
93-from txgenshi import util
94+from txgenshi.util.base import boolify
95
96
97 class UtilityTests(unittest.TestCase):
98 """
99 Test the various utility functions.
100 """
101-
102-
103 def test_boolify(self):
104 """
105 Make sure that we get the truth values we expect.
106@@ -20,7 +18,7 @@
107 falses = ['no', '0', 'off', 'disable', 'false', u'no', u'0', u'off',
108 u'disable', u'false', 'NO', 'OFF', 0, False, 'monkeyface']
109 for true in trues:
110- self.assertEqual(util.boolify(true), True)
111+ self.assertEqual(boolify(true), True)
112 for false in falses:
113- self.assertEqual(util.boolify(false), False)
114+ self.assertEqual(boolify(false), False)
115
116
117=== added directory 'txgenshi/util'
118=== added file 'txgenshi/util/__init__.py'
119=== renamed file 'txgenshi/util.py' => 'txgenshi/util/base.py'
120--- txgenshi/util.py 2010-01-12 06:20:09 +0000
121+++ txgenshi/util/base.py 2010-01-12 08:12:15 +0000
122@@ -1,27 +1,12 @@
123-import os
124 import re
125-import sys
126-import crypt
127-import getpass
128
129 import txgenshi
130
131+
132 privKeyFile = 'etc/server.pem'
133 certFile = 'etc/server.pem'
134
135
136-def getPackageName():
137- return "%s-%s" % (txgenshi.name, txgenshi.version)
138-
139-
140-def getDistFilename():
141- return "%s.tar.gz" % getPackageName()
142-
143-
144-def getLocalDist():
145- return "dist/%s" % getDistFilename()
146-
147-
148 def boolify(data):
149 """
150 First, see if the data adheres to common string patterns for a boolean.
151@@ -65,6 +50,7 @@
152 output += nl
153 output += repr(obj)
154 return re.sub('\n\n', '\n', output)
155+<<<<<<< TREE
156
157
158
159@@ -215,3 +201,5 @@
160 sys.argv = ['', 'build', 'sdist']
161 setup(**setupDict)
162 return getDistFilename()
163+=======
164+>>>>>>> MERGE-SOURCE
165
166=== added file 'txgenshi/util/dist.py'
167--- txgenshi/util/dist.py 1970-01-01 00:00:00 +0000
168+++ txgenshi/util/dist.py 2010-01-12 08:12:15 +0000
169@@ -0,0 +1,133 @@
170+import os
171+import sys
172+
173+import txgenshi
174+
175+
176+def getPackageName():
177+ return "%s-%s" % (txgenshi.name, txgenshi.version)
178+
179+
180+def getDistFilename():
181+ return "%s.tar.gz" % getPackageName()
182+
183+
184+def getLocalDist():
185+ return "dist/%s" % getDistFilename()
186+
187+
188+def setup(*args, **kwds):
189+ """
190+ Compatibility wrapper.
191+ """
192+ try:
193+ from setuptools import setup
194+ except ImportError:
195+ from distutils.core import setup
196+ return setup(*args, **kwds)
197+
198+
199+def findPackages(library_name):
200+ """
201+ Compatibility wrapper.
202+
203+ Taken from storm setup.py.
204+ """
205+ try:
206+ from setuptools import find_packages
207+ return find_packages()
208+ except ImportError:
209+ pass
210+ packages = []
211+ for directory, subdirectories, files in os.walk(library_name):
212+ if '__init__.py' in files:
213+ packages.append(directory.replace(os.sep, '.'))
214+ return packages
215+
216+
217+def hasDocutils():
218+ """
219+ Check to see if docutils is installed.
220+ """
221+ try:
222+ import docutils
223+ return True
224+ except ImportError:
225+ return False
226+
227+
228+def _validateReST(text):
229+ """
230+ Make sure that the given ReST text is valid.
231+
232+ Taken from Zope Corp's zc.twist setup.py.
233+ """
234+ import docutils.utils
235+ import docutils.parsers.rst
236+ import StringIO
237+
238+ doc = docutils.utils.new_document('validator')
239+ # our desired settings
240+ doc.reporter.halt_level = 5
241+ doc.reporter.report_level = 1
242+ stream = doc.reporter.stream = StringIO.StringIO()
243+ # docutils buglets (?)
244+ doc.settings.tab_width = 2
245+ doc.settings.pep_references = doc.settings.rfc_references = False
246+ doc.settings.trim_footnote_reference_space = None
247+ # and we're off...
248+ parser = docutils.parsers.rst.Parser()
249+ parser.parse(text, doc)
250+ return stream.getvalue()
251+
252+
253+def validateReST(text):
254+ """
255+ A wrapper that ensafens the validation for pythons that are not embiggened
256+ with docutils.
257+ """
258+ if hasDocutils():
259+ return _validateReST(text)
260+ print " *** No docutils; can't validate ReST."
261+ return ''
262+
263+
264+def catReST(*args, **kwds):
265+ """
266+ Concatenate the contents of one or more ReST files.
267+
268+ Taken from Zope Corp's zc.twist setup.py.
269+ """
270+ # note: distutils explicitly disallows unicode for setup values :-/
271+ # http://docs.python.org/dist/meta-data.html
272+ tmp = []
273+ for a in args:
274+ if a in ['README', 'DEPENDENCIES'] or a.endswith('.txt'):
275+ f = open(os.path.join(*a.split('/')))
276+ tmp.append(f.read())
277+ f.close()
278+ tmp.append('\n\n')
279+ else:
280+ tmp.append(a)
281+ if len(tmp) == 1:
282+ res = tmp[0]
283+ else:
284+ res = ''.join(tmp)
285+ out = kwds.get('out')
286+ if out is True:
287+ out = 'CHECK_THIS_BEFORE_UPLOAD.txt'
288+ if out:
289+ f = open(out, 'w')
290+ f.write(res)
291+ f.close()
292+ report = validateReST(res)
293+ if report:
294+ print report
295+ raise ValueError('ReST validation error')
296+ return res
297+
298+
299+def buildDist():
300+ sys.argv = ['', 'build', 'sdist']
301+ setup(**setupDict)
302+ return getDistFilename()

Subscribers

People subscribed via source and target branches

to all changes: