Skip to content

Commit

Permalink
Merge pull request #62 from haypo/py3
Browse files Browse the repository at this point in the history
py3: replace "print x" with "print(x)"
  • Loading branch information
Psycojoker committed Mar 3, 2015
2 parents 9b6fcf2 + 97e0341 commit f38b026
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RedBaron is very simple to use, you just need to import it and feed him with a s
from redbaron import RedBaron
red = RedBaron("print 'hello world!'")
red = RedBaron("print('hello world!')")
But what you should be really doing is using RedBaron directly into a shell (I
recommend `IPython <http://ipython.org/>`_ but
Expand All @@ -38,7 +38,7 @@ for it, like BeautifulSoup.
.. ipython:: python
from redbaron import RedBaron
red = RedBaron("hello = 'Hello World!'\nprint hello")
red = RedBaron("hello = 'Hello World!'\nprint(hello)")
red
As you can see, when displayed in a shell, a RedBaron instance renders to the actual
Expand Down Expand Up @@ -111,10 +111,10 @@ You can read their documentation using the :file:`?` magic of ipython:

.. ipython:: python
print red[0].names.__doc__ # you can do "red[0].names?" in IPython shell
print(red[0].names.__doc__) # you can do "red[0].names?" in IPython shell
red[0].names()
print red[0].modules.__doc__
print(red[0].modules.__doc__)
red[0].modules()
If you come with cool helpers, don't hesitate to propose them in a `pull
Expand Down Expand Up @@ -169,7 +169,7 @@ attributes):

In [3]: red[0].value

* node attributes, which are other nodes. They are shown with a :file:`->` followed by the name of the other node
* node attributes, which are other nodes. They are shown with a :file:`->` followed by the name of the other node
at the next line in :file:`.help()`. :file:`.target` and :file:`.value` here for example.

.. ipython::
Expand All @@ -180,7 +180,7 @@ attributes):

In [21]: red[0].target.help()

* nodelist attributes, which are lists of other nodes. They are shown with a :file:`->` followed by a series of names
* nodelist attributes, which are lists of other nodes. They are shown with a :file:`->` followed by a series of names
of the other nodes starting with a :file:`*` for every item of the list. :file:`.value` here for example:

.. ipython::
Expand Down
2 changes: 1 addition & 1 deletion docs/dotproxylist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ __iter__
red
for i in red[0].value:
print i.dumps()
print(i.dumps())
__getslice__
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ And let's see the result of our work:

.. ipython:: python
print red.dumps()
print(red.dumps())
Table of content
----------------
Expand Down
4 changes: 2 additions & 2 deletions docs/lineproxylist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ insert
.. ipython:: python
red
red[0].value.insert(1, "print caribou")
red[0].value.insert(1, "print(caribou)")
red
red[0].value
Expand Down Expand Up @@ -145,7 +145,7 @@ __iter__
red
for i in red[0].value:
print i.dumps()
print(i.dumps())
__getslice__
~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/nodes_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1090,14 +1090,14 @@ A node representing a print statement.

.. ipython:: python
RedBaron("print stuff")[0].help(deep=True)
RedBaron("print(stuff)")[0].help(deep=True)
SetAttr
-------

.. ipython:: python
red = RedBaron("print stuff")
red = RedBaron("print(stuff)")
red
red[0].destination = "some_file"
red
Expand Down
36 changes: 18 additions & 18 deletions docs/other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,31 @@ if you want to iterate on the neighbours of the node.

In [42]: list = red[0]

In [42]: print list.next
In [42]: print list.previous
In [42]: print(list.next)
In [42]: print(list.previous)

In [42]: list.help()
In [42]: print list.value[0]
In [42]: print list.value[0].next
In [42]: print list.value[0].previous
In [42]: print list.value[2]
In [42]: print list.value[2].next
In [42]: print list.value[2].previous
In [42]: print(list.value[0])
In [42]: print(list.value[0].next)
In [42]: print(list.value[0].previous)
In [42]: print(list.value[2])
In [42]: print(list.value[2].next)
In [42]: print(list.value[2].previous)

In [42]: assign = red[2]

In [42]: assign.help()
In [42]: print assign.target.next
In [42]: print assign.target.previous
In [42]: print(assign.target.next)
In [42]: print(assign.target.previous)

In [42]: list.value[2].help(deep=1)
In [42]: print [x for x list.value[2].next_generator()]
In [42]: print [x for x list.value[2].previous_generator()]
In [42]: print([x for x list.value[2].next_generator()])
In [42]: print([x for x list.value[2].previous_generator()])
In [42]: list.value.help(deep=0)
In [42]: print [x for x list.value.next_generator()]
In [42]: print [x for x list.value.previous_generator()]
In [42]: print [x for x assign.target.next_generator()]
In [42]: print [x for x assign.target.previous_generator()]
In [42]: print([x for x list.value.next_generator()])
In [42]: print([x for x list.value.previous_generator()])
In [42]: print([x for x assign.target.next_generator()])
In [42]: print([x for x assign.target.previous_generator()])

.root
-----
Expand Down Expand Up @@ -392,7 +392,7 @@ node you've just got via query. Those helpers are here for that:

.. ipython:: python
red = RedBaron("foo = 42\nprint 'bar'\n")
red = RedBaron("foo = 42\nprint('bar')\n")
red
red.print_.insert_before("baz")
red
Expand All @@ -405,7 +405,7 @@ than one line after or before:

.. ipython:: python
red = RedBaron("foo = 42\nprint 'bar'\n")
red = RedBaron("foo = 42\nprint('bar')\n")
red
red.print_.insert_before("baz", offset=1)
red
Expand Down
2 changes: 1 addition & 1 deletion docs/proxy_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ __iter__
red
for i in red[0].value:
print i.dumps()
print(i.dumps())
__getslice__
~~~~~~~~~~~~
Expand Down
10 changes: 5 additions & 5 deletions docs/tuto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ that has "_formatting" in its name is formatting related):
import json
red = RedBaron("1+2")
print json.dumps(red.fst(), indent=4) # json.dumps is used for pretty printing
print(json.dumps(red.fst(), indent=4)) # json.dumps is used for pretty printing
Use it in a shell
-----------------
Expand All @@ -88,7 +88,7 @@ selected source code, so you'll have a direct idea of what you are working on:

.. ipython:: python
red = RedBaron("stuff = 1 + 2\nprint 'Hello', stuff")
red = RedBaron("stuff = 1 + 2\nprint(stuff)")
red
You might notice the :file:`0` and the :file:`1` on the left: those are the
Expand Down Expand Up @@ -274,7 +274,7 @@ using :file:`.copy()`:

.. ipython:: python
red = RedBaron("stuff = 1 + 2\nprint 'Hello', stuff")
red = RedBaron("stuff = 1 + 2\nprint(stuff)")
red
i = red[0].value.copy()
red[1].value = i
Expand Down Expand Up @@ -354,9 +354,9 @@ is intended as such, see the documentation for more information:

.. ipython:: python
red = RedBaron("a = 1\n\nprint a")
red = RedBaron("a = 1\n\nprint(a)")
red
red.insert(1, "if a:\n print 'a == 1'")
red.insert(1, "if a:\n print('a == 1')")
red
The important things to remember are that:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_initial_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,24 +548,24 @@ def test_replace():


def test_insert_before():
red = RedBaron("a = 1\nprint pouet\n")
red = RedBaron("a = 1\nprint(pouet)\n")
red.print_.insert_before("chocolat")
assert red.dumps() == "a = 1\nchocolat\nprint pouet\n"
assert red.dumps() == "a = 1\nchocolat\nprint(pouet)\n"


def test_insert_after():
red = RedBaron("a = 1\nprint pouet\n")
red = RedBaron("a = 1\nprint(pouet)\n")
red.print_.insert_after("chocolat")
assert red.dumps() == "a = 1\nprint pouet\nchocolat\n"
assert red.dumps() == "a = 1\nprint(pouet)\nchocolat\n"


def test_insert_before_offset():
red = RedBaron("a = 1\nprint pouet\n")
red = RedBaron("a = 1\nprint(pouet)\n")
red.print_.insert_before("chocolat", offset=1)
assert red.dumps() == "chocolat\na = 1\nprint pouet\n"
assert red.dumps() == "chocolat\na = 1\nprint(pouet)\n"


def test_insert_after_offset():
red = RedBaron("a = 1\nprint pouet\n")
red = RedBaron("a = 1\nprint(pouet)\n")
red[0].insert_after("chocolat", offset=1)
assert red.dumps() == "a = 1\nprint pouet\nchocolat\n"
assert red.dumps() == "a = 1\nprint(pouet)\nchocolat\n"
2 changes: 1 addition & 1 deletion tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def test_mixmatch_with_redbaron_base_node_and_proxy_list_on_parent():
red = RedBaron("foo = 42\nprint 'bar'\n")
red = RedBaron("foo = 42\nprint('bar')\n")
red.insert(0, "baz")
assert red[0].on_attribute == "root"
assert red[0].parent is red
4 changes: 2 additions & 2 deletions utils/indentation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
def walk(node):
if node is None:
return
print [node.indentation, node]
print([node.indentation, node])
for i in node._dict_keys:
walk(getattr(node, i))

for i in node._list_keys:
map(walk, getattr(node, i))

map(walk, red)
# print walk(red[0])
# print(walk(red[0]))

0 comments on commit f38b026

Please sign in to comment.