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
| rendering_dictionnary = { | |
| "assignment": [ | |
| ("key", "target" ), | |
| ("list", "first_formatting" ), | |
| ("key", "operator" ), # ceci devrait être optionnel | |
| ("constant", "=" ), | |
| ("list", "second_formatting"), | |
| ("key", "value" ) | |
| ], | |
| } |
| from baron.rendering_dictionnary import rendering_dictionnary as d | |
| from baron.dumper import dumps | |
| import json | |
| class Position: | |
| def __init__(self, line, column): | |
| self.line = line | |
| self.column = column |
| # 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 |
| >>> 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] |
| ============================================== 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: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
| "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), |
| 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" |
| from .render import RenderWalker | |
| def dumps(tree): | |
| return Dumper().dump(tree) | |
| class Dumper(RenderWalker): | |
| def on_constant(self, constant, pos, key): | |
| self.dump += constant |
| 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): |