Copy the files bootstrap.sh
, Vagrantfile
and test_baron.sh
.
In the same directory:
git clone https://github.com/Psycojoker/baron.git
git clone https://github.com/Psycojoker/redbaron.git
vagrant up
INFO interface: output: Box 'archlinux-x86_64' could not be found. Attempting to find and install... | |
INFO interface: output: ==> build: Box 'archlinux-x86_64' could not be found. Attempting to find and install... | |
==> build: Box 'archlinux-x86_64' could not be found. Attempting to find and install... | |
INFO interface: detail: Box Provider: virtualbox | |
INFO interface: detail: build: Box Provider: virtualbox | |
build: Box Provider: virtualbox | |
INFO interface: detail: Box Version: >= 0 | |
INFO interface: detail: build: Box Version: >= 0 | |
build: Box Version: >= 0 | |
INFO runner: Preparing hooks for middleware sequence... |
============== GOOD =============== | |
.. ipython:: python | |
from baron import parse, dumps | |
source_code_string = "a = 1" | |
ast = parse(source_code_string) | |
generated_source_code = dumps(ast) |
class MyClass: | |
def __init__(self): | |
self.errors = [] | |
self.warnings = [] | |
def apply(self, function, *args): | |
result, self.errors, self.warnings = function(*args, errors=self.errors, warnings=self.warnings) | |
return result | |
def applicative_functor_style(self, ast): |
from .render import RenderWalker | |
def dumps(tree): | |
return Dumper().dump(tree) | |
class Dumper(RenderWalker): | |
def on_constant(self, constant, pos, key): | |
self.dump += constant |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.define :raspberry do |box| | |
box.vm.box = "precise64" | |
box.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
box.vm.network :private_network, ip: "192.168.42.12" | |
box.vm.provision :shell, :path => "bootstrap_prod.sh" |
"comparison": [ | |
("key", "first", True), | |
("formatting", "first_formatting", True), | |
("key", "middle_left_formatting", "complex"), # not ou is | |
("formatting", "middle_formatting", "complex"), | |
("key", "middle_right_formatting", "complex"), # in ou not | |
("key", "value", "no_complex"), | |
("formatting", "second_formatting", True), | |
("key", "second", True), |
============================================== FAILURES ============================================== | |
__________________________________ test_backslash_not_in_formatting __________________________________ | |
def test_backslash_not_in_formatting(): | |
> check_dumps("if a not \\\n in b: pass\n") | |
tests/test_dumper.py:527: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
>>> tokenize("from future import feature") | |
[('NAME', 'f'), ('NAME', 'r'), ('NAME', 'o'), ('NAME', 'm'), ('SPACE', ' '), ('NAME', 'f'), ('NAME', 'u'), ('NAME', 't'), ('NAME', 'u'), ('NAME', 'r'), ('NAME', 'e'), ('SPACE', ' '), ('NAME', 'i'), ('NAME', 'm'), ('NAME', 'p'), ('NAME', 'o'), ('NAME', 'r'), ('NAME', 't'), ('SPACE', ' '), ('NAME', 'f'), ('NAME', 'e'), ('NAME', 'a'), ('NAME', 't'), ('NAME', 'u'), ('NAME', 'r'), ('NAME', 'e'), ('ENDMARKER', ''), None] |
# 3.2 | |
>>> open("test_oauth.py", "r").read()[:30] | |
'\xef\xbb\xbf# -*- coding: utf-8 -*-\n\n""' | |
>>> import baron.helpers | |
>>> baron.helpers.show(open('test_oauth.py').read()) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/vagrant/baron/baron/helpers.py", line 7, in show |