Skip to content

Commit

Permalink
Use py3 compatible print statement syntax
Browse files Browse the repository at this point in the history
except for the Pylons subdirectory, which is not going to
work with python3 anyway
  • Loading branch information
smurfix committed Jun 9, 2014
1 parent 6772e0d commit 8c8d5f4
Show file tree
Hide file tree
Showing 27 changed files with 181 additions and 181 deletions.
4 changes: 2 additions & 2 deletions bootstrap.py
Expand Up @@ -36,9 +36,9 @@ def quote(c):
'try:\n'
' import ConfigParser\n'
'except ImportError:\n'
' print 1\n'
' print(1)\n'
'else:\n'
' print 0\n'],
' print(0)\n'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
has_broken_dash_S = bool(int(stdout.strip()))

Expand Down
32 changes: 16 additions & 16 deletions docs/fields.txt
Expand Up @@ -55,12 +55,12 @@ Render a string field::

Edit mode::

>>> print fs.text.render()
>>> print(fs.text.render())
<input id="One--text" name="One--text" type="text" value="a value" />

Read only mode::

>>> print fs.text.render_readonly()
>>> print(fs.text.render_readonly())
a value

IntegerFieldRenderer
Expand All @@ -82,12 +82,12 @@ Render a string field::

Edit mode::

>>> print fs.passwd.render()
>>> print(fs.passwd.render())
<input id="One--passwd" name="One--passwd" type="password" />

Read only mode::

>>> print fs.passwd.render_readonly()
>>> print(fs.passwd.render_readonly())
******

TextAreaFieldRenderer
Expand All @@ -103,12 +103,12 @@ Render a string field::

Edit mode::

>>> print fs.text.render()
>>> print(fs.text.render())
<textarea id="One--text" name="One--text">a value</textarea>

Read only mode::

>>> print fs.text.render_readonly()
>>> print(fs.text.render_readonly())
a value

HiddenFieldRenderer
Expand All @@ -124,12 +124,12 @@ Render a string field::

Edit mode::

>>> print fs.render()
>>> print(fs.render())
<input id="One--text" name="One--text" type="hidden" value="h" />

Read only mode::

>>> print fs.text.render_readonly()
>>> print(fs.text.render_readonly())
<BLANKLINE>

HiddenFieldRendererFactory
Expand Down Expand Up @@ -163,7 +163,7 @@ Render a date field::

Edit mode::

>>> print pretty_html(fs.date.render()) #doctest: +ELLIPSIS
>>> print(pretty_html(fs.date.render())) #doctest: +ELLIPSIS
<span id="One--date">
<select id="One--date__month" name="One--date__month">
<option value="MM">
Expand Down Expand Up @@ -194,7 +194,7 @@ Edit mode::

Read only mode::

>>> print fs.date.render_readonly()
>>> print(fs.date.render_readonly())
2000-12-31

TimeFieldRenderer
Expand All @@ -211,7 +211,7 @@ Render a time field::

Edit mode::

>>> print pretty_html(fs.time.render()) #doctest: +ELLIPSIS
>>> print(pretty_html(fs.time.render())) #doctest: +ELLIPSIS
<span id="One--time">
<select id="One--time__hour" name="One--time__hour">
<option value="HH">
Expand Down Expand Up @@ -267,7 +267,7 @@ Edit mode::

Read only mode::

>>> print fs.time.render_readonly()
>>> print(fs.time.render_readonly())
09:03:30

DateTimeFieldRenderer
Expand All @@ -284,7 +284,7 @@ Render a datetime field::

Edit mode::

>>> print pretty_html(fs.datetime.render()) #doctest: +ELLIPSIS
>>> print(pretty_html(fs.datetime.render())) #doctest: +ELLIPSIS
<span id="One--datetime">
<select id="One--datetime__month" name="One--datetime__month">
<option value="MM">
Expand Down Expand Up @@ -341,7 +341,7 @@ Edit mode::

Read only mode::

>>> print fs.datetime.render_readonly()
>>> print(fs.datetime.render_readonly())
2000-12-31 09:03:30

HiddenDateFieldRenderer
Expand Down Expand Up @@ -472,7 +472,7 @@ Then bind it to a specific field::

Here is the result for edit mode::

>>> print fs.render()
>>> print(fs.render())
<div>
<label class="field_opt" for="One--link">
Link
Expand All @@ -489,7 +489,7 @@ Here is the result for edit mode::
And for read only mode::

>>> fs.readonly = True
>>> print fs.render()
>>> print(fs.render())
<tbody>
<tr>
<td class="field_readonly">
Expand Down
8 changes: 4 additions & 4 deletions docs/forms.txt
Expand Up @@ -46,7 +46,7 @@ itself appropriately.
:class:`~formalchemy.forms.FieldSet`::

>>> fs = FieldSet(bill)
>>> print fs.name.value
>>> print(fs.name.value)
Bill

If you have an attribute name that conflicts with a built-in
Expand Down Expand Up @@ -146,7 +146,7 @@ Here is a callable exemple::
... return fs.session.query(User).filter(User.name=='Bill')
>>> fs3 = FieldSet(bill)
>>> fs3.configure(options=[fs3.name.dropdown(options=custom_query)])
>>> print fs3.name.render()
>>> print(fs3.name.render())
<select id="User-1-name" name="User-1-name">
<option value="">None</option>
<option value="1">Bill</option>
Expand Down Expand Up @@ -230,7 +230,7 @@ just call the `render` method to get an HTML string suitable for
including in your page::

>>> fs = FieldSet(bill)
>>> print fs.render()
>>> print(fs.render())
<div>
<label class="field_req" for="User-1-email">
Email
Expand Down Expand Up @@ -276,7 +276,7 @@ Note that there is no `form` element! You must provide that yourself.
You can also render individual fields for more fine-grained control::

>>> fs = FieldSet(bill)
>>> print fs.name.render()
>>> print(fs.name.render())
<input id="User-1-name" maxlength="30" name="User-1-name" type="text" value="Bill" />


Expand Down
4 changes: 2 additions & 2 deletions docs/tables.txt
Expand Up @@ -78,7 +78,7 @@ Then you can initialize a `Grid` and bind it to a list of row instance::

This will render instances as an html table::

>>> print tc.render()
>>> print(tc.render())
<thead>
<tr>
<th>
Expand Down Expand Up @@ -118,7 +118,7 @@ You can also add a field to the `Grid` manually::
>>> tc2 = Grid(User, [bill, john])
>>> tc2.append(Field('link', type=types.String, value=lambda item: literal('<a href=%d>link</a>') % item.id))
>>> tc2.configure(readonly=True)
>>> print tc2.render()
>>> print(tc2.render())
<thead>
<tr>
<th>
Expand Down
8 changes: 4 additions & 4 deletions docs/templates.txt
Expand Up @@ -66,7 +66,7 @@ Then you can override the default mako templates::

And see the result::

>>> print FieldSet(User).render()
>>> print(FieldSet(User).render())
<ul>
<li>email</li>
<li>password</li>
Expand All @@ -87,7 +87,7 @@ Same with genshi except that :mod:`formalchemy` don't provide default templates:

And same the result of course::

>>> print FieldSet(User).render()
>>> print(FieldSet(User).render())
<ul>
<li>email</li><li>password</li><li>name</li><li>orders</li>
</ul>
Expand All @@ -105,7 +105,7 @@ You can use it for a specific :class:`~formalchemy.forms.FieldSet`::

>>> fs = FieldSet(User)
>>> fs.engine = MyEngine()
>>> print fs.render()
>>> print(fs.render())
It works !

You can also override the engine in a subclass::
Expand All @@ -120,7 +120,7 @@ Or set it as the global engine with :mod:`formalchemy`'s :mod:`~formalchemy.conf

It should be available for all :class:`~formalchemy.forms.FieldSet`::

>>> print FieldSet(User).render()
>>> print(FieldSet(User).render())
It works !

.. restore config
Expand Down
2 changes: 1 addition & 1 deletion docs/validators.txt
Expand Up @@ -49,7 +49,7 @@ a class instead of an object, the class will be instantiated for you.)
The object will be placed into the current session, if one exists::

>>> if fs.validate(): fs.sync()
>>> print bill.name
>>> print(bill.name)
Sam


Expand Down
4 changes: 2 additions & 2 deletions formalchemy/ext/couchdb.py
Expand Up @@ -41,7 +41,7 @@
>>> # rendering
>>> fs.name.is_required()
True
>>> print fs.render() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
>>> print(fs.render()) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<div>
<label class="field_req" for="Pet--name">Name</label>
<input id="Pet--name" name="Pet--name" type="text" value="dewey" />
Expand All @@ -68,7 +68,7 @@
>>> # grid
>>> grid = couchdb.Grid(Pet, [p, Pet()])
>>> grid.configure(include=[grid.name, grid.type, grid.birthdate, grid.weight_in_pounds, grid.friends])
>>> print grid.render() # doctest: +SKIP +ELLIPSIS +NORMALIZE_WHITESPACE
>>> print(grid.render()) # doctest: +SKIP +ELLIPSIS +NORMALIZE_WHITESPACE
<thead>
<tr>
<th>Name</th>
Expand Down
4 changes: 2 additions & 2 deletions formalchemy/ext/fsblob.py
Expand Up @@ -35,10 +35,10 @@ def image_extension(extensions=['jpeg', 'jpg', 'gif', 'png']):

def normalized_basename(path):
"""
>>> print normalized_basename(u'c:\\Prog files\My fil\xe9.jpg')
>>> print(normalized_basename(u'c:\\Prog files\My fil\xe9.jpg'))
My_fil.jpg
>>> print normalized_basename('c:\\Prog files\My fil\xc3\xa9.jpg')
>>> print(normalized_basename('c:\\Prog files\My fil\xc3\xa9.jpg'))
My_fil.jpg
"""
Expand Down
4 changes: 2 additions & 2 deletions formalchemy/ext/rdf.py
Expand Up @@ -18,7 +18,7 @@
>>> fs.stock.value
['value1']
>>> print fs.render().strip() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
>>> print(fs.render().strip()) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<div>
<label class="field_opt" for="Company--stockDescription">Stockdescription</label>
<input id="Company--stockDescription" name="Company--stockDescription" type="text" value="description" />
Expand All @@ -35,7 +35,7 @@
>>> fs = Grid(Company, [c])
>>> fs.configure(options=[fs.stock.set(options=['value1', 'value2'])], readonly=True)
>>> print fs.render().strip() #doctest: +NORMALIZE_WHITESPACE
>>> print(fs.render().strip()) #doctest: +NORMALIZE_WHITESPACE
<thead>
<tr>
<th>Stockdescription</th>
Expand Down
4 changes: 2 additions & 2 deletions formalchemy/ext/zope/__init__.py
Expand Up @@ -45,7 +45,7 @@
We can use the form::
>>> print fs.render().strip() #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
>>> print(fs.render().strip()) #doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<div>
<label class="field_req" for="Pet--name">Name</label>
<textarea id="Pet--name" name="Pet--name">dewey</textarea>
Expand Down Expand Up @@ -133,7 +133,7 @@
>>> grid = Grid(IPet)
>>> grid = grid.bind([p])
>>> print grid.render().strip() #doctest: +ELLIPSIS
>>> print(grid.render().strip()) #doctest: +ELLIPSIS
<thead>
<tr>
<th>Name</th>
Expand Down
4 changes: 2 additions & 2 deletions formalchemy/fields.py
Expand Up @@ -1704,10 +1704,10 @@ def __init__(self, instrumented_attribute, parent):
"""
>>> from formalchemy.tests import FieldSet, Order
>>> fs = FieldSet(Order)
>>> print fs.user.key
>>> print(fs.user.key)
user
>>> print fs.user.name
>>> print(fs.user.name)
user_id
"""
AbstractField.__init__(self, parent)
Expand Down
18 changes: 9 additions & 9 deletions formalchemy/helpers.py
Expand Up @@ -33,9 +33,9 @@ def content_tag(name, content, **options):
Examples::
>>> print content_tag("p", "Hello world!")
>>> print(content_tag("p", "Hello world!"))
<p>Hello world!</p>
>>> print content_tag("div", content_tag("p", "Hello world!"), class_="strong")
>>> print(content_tag("div", content_tag("p", "Hello world!"), class_="strong"))
<div class="strong"><p>Hello world!</p></div>
"""
if content is None:
Expand Down Expand Up @@ -79,7 +79,7 @@ def text_area(name, content='', **options):
Example::
>>> print text_area("Body", '', size="25x10")
>>> print(text_area("Body", '', size="25x10"))
<textarea cols="25" id="Body" name="Body" rows="10"></textarea>
"""
_update_fa(options, name)
Expand Down Expand Up @@ -114,7 +114,7 @@ def file_field(name, value=None, **options):
Example::
>>> print file_field('myfile')
>>> print(file_field('myfile'))
<input id="myfile" name="myfile" type="file" />
"""
_update_fa(options, name)
Expand All @@ -137,13 +137,13 @@ def tag(name, open=False, **options):
Examples::
>>> print tag("br")
>>> print(tag("br"))
<br />
>>> print tag("br", True)
>>> print(tag("br", True))
<br>
>>> print tag("input", type="text")
>>> print(tag("input", type="text"))
<input type="text" />
>>> print tag("input", type='text', disabled='disabled')
>>> print(tag("input", type='text', disabled='disabled'))
<input disabled="disabled" type="text" />
"""
return HTML.tag(name, _closed=not open, **options)
Expand All @@ -152,7 +152,7 @@ def label(value, **kwargs):
"""
Return a label tag
>>> print label('My label', for_='fieldname')
>>> print(label('My label', for_='fieldname'))
<label for="fieldname">My label</label>
"""
Expand Down
6 changes: 3 additions & 3 deletions formalchemy/tests/__init__.py
Expand Up @@ -38,13 +38,13 @@ def ls(*args):
files.sort()
for f in files:
if os.path.isdir(f):
print 'D %s' % os.path.basename(f)
print('D %s' % os.path.basename(f))
else:
print '- %s' % os.path.basename(f)
print('- %s' % os.path.basename(f))

def cat(*args):
filename = os.path.join(os.path.dirname(__file__), *args)
print open(filename).read()
print(open(filename).read())

def session_mapper(scoped_session):
def mapper(cls, *arg, **kw):
Expand Down

0 comments on commit 8c8d5f4

Please sign in to comment.