Ejemplo n.º 1
0
        def get_tex(self):
            if self._ready_for_export:
                ind = Indenter(enforce_spacing=False)
                ind.add_many_lines(self._latex)

                return ind.code
            else:
                raise Exception(
                    "TikZTree instance incomplete: cannot create latex.")
Ejemplo n.º 2
0
def main():
    with Indenter() as indent:
        indent.print('hi!')
        with indent:
            indent.print('hello')
            indent.print()
            indent.print('hello friend')
            with indent:
                indent.print('bonjour les amis')
        indent.print('hey')
Ejemplo n.º 3
0
 def test_indenter(self, mock_stdout):
     indenter = Indenter()
     indenter.print('abc')
     indenter.print()
     indenter.print('ghi')
     with indenter:
         indenter.print('jkl')
         with indenter:
             indenter.print('mno')
         indenter.print('pqi')
     indenter.print('stu')
     with indenter:
         indenter.print('vwx')
     assert (mock_stdout.getvalue() == 'abc\n\nghi\n    jkl\n        '
             'mno\n    pqi\nstu\n    vwx\n')
Ejemplo n.º 4
0
 def test_indenter_without_context_empty_line(self, mock_stdout):
     indenter = Indenter()
     indenter.print('abc')
     indenter.print()
     indenter.print('ghi')
     assert mock_stdout.getvalue() == 'abc\n\nghi\n'
Ejemplo n.º 5
0
 def test_indenter_without_context_three_times(self, mock_stdout):
     indenter = Indenter()
     indenter.print('abc')
     indenter.print('def')
     indenter.print('ghi')
     assert mock_stdout.getvalue() == 'abc\ndef\nghi\n'
Ejemplo n.º 6
0
 def test_indenter_without_context(self, mock_stdout):
     Indenter().print('abc\ndef')
     assert mock_stdout.getvalue() == 'abc\ndef\n'
Ejemplo n.º 7
0
from indenter import Indenter
from minifier import Minifier

mycode = """
&hello_cloudscript="foo";
#hi_bar="bazz"
@&global_var="foo";
IF(&hello_cloudscript==@&global_var);
LOG("yo")
ENDIF;
"""

# Minify
minifier = Minifier(mycode)
minified_code = minifier.minify(remove_comments=True,
                                inject_collons=True,
                                remove_tabs_and_break_lines=True)
print(minified_code)

# Indent
mylines = mycode.split(';')
indenter = Indenter(mylines)
indented_code = indenter.indent()

print(indented_code)