Example #1
0
def _cleanupPyLintComments(filename, abort):
    from baron.parser import (  # pylint: disable=I0021,import-error,no-name-in-module
        ParsingError,  # @UnresolvedImport
    )
    from redbaron import (  # pylint: disable=I0021,import-error,no-name-in-module
        RedBaron,  # @UnresolvedImport
    )

    old_code = getFileContents(filename)

    try:
        red = RedBaron(old_code)
        # red = RedBaron(old_code.rstrip()+'\n')
    except ParsingError:
        if abort:
            raise

        my_print("PARSING ERROR.")
        return 2

    for node in red.find_all("CommentNode"):
        try:
            _updateCommentNode(node)
        except Exception:
            my_print("Problem with", node)
            node.help(deep=True, with_formatting=True)
            raise

    new_code = red.dumps()

    if new_code != old_code:
        with open(filename, "w") as source_code:
            source_code.write(red.dumps())
Example #2
0
def main(meetup, tc=(255, 255, 255), bg=None, *tags):
    target_url = meetup

    soup = BeautifulSoup(requests.get(target_url).content, "html.parser")

    description = soup.find("div", id="groupDesc")
    description = (" " * 4).join(map(lambda x: str(x), description.contents)) + (" " * 4)
    description = "\n".join(map(lambda x: x.rstrip(), description.split("\n")))

    target_meetup_name = target_url.split("/")[-2]
    target = target_url.split("/")[-2].lower().replace("-", "_")

    if re.match("^\d", target):
        target = "_" + target

    logo_url = soup.find("img", "photo")["src"] if soup.find("img", "photo") else None

    if bg == None:
        if logo_url:
            palette = extract_colors(Image.open(BytesIO(requests.get(logo_url).content)))

            colors = palette.colors
            background_color = colors[0].value
            text_color = tc
        else:
            h = (random.randint(1, 100) * 0.618033988749895) % 1
            background_color = hsv_to_rgb(h, .5, .95)
            text_color = "#000000"

        h, s, v = rgb_to_hsv(background_color)
    else:
        background_color = bg

        text_color = tc

    # background_color = map(lambda x: (x + 255)/2, background_color)

    red = RedBaron(open("agendas/be.py", "r").read())

    for i in red("def", recursive=False):
        if target < i.name:
            break

    i.insert_before(template % {
        "background_color": rgb_to_hex(background_color) if not (isinstance(background_color, basestring) and background_color.startswith("#")) else background_color,
        "text_color": rgb_to_hex(text_color) if not (isinstance(text_color, basestring) and text_color.startswith("#")) else text_color,
        "url": target_url,
        "tags": ", ".join(map(repr, tags)),
        "function_name": target,
        "description": description,
        "meetup_name": target_meetup_name,
    })

    red.dumps()

    open("agendas/be.py", "w").write(red.dumps())

    os.system("python manage.py fetch_events %s" % target)
Example #3
0
def main():
    """Rewrite Thrift-generated Python clients to handle recursive structs. For
    more details see: https://issues.apache.org/jira/browse/THRIFT-2642.

    Requires package `RedBaron`, available via pip:
    $ pip install redbaron

    To use:

    $ thrift -gen py mapd.thrift
    $ mv gen-py/mapd/ttypes.py gen-py/mapd/ttypes-backup.py
    $ python fix_recursive_structs.py gen-py/mapd/ttypes-backup.py gen-py/mapd/ttypes.py

    """
    in_file = open(sys.argv[1], 'r')
    out_file = open(sys.argv[2], 'w')

    red_ast = RedBaron(in_file.read())

    thrift_specs = [ts.parent for ts in red_ast.find_all(
        'name', 'thrift_spec') if ts.parent.type == 'assignment' and ts.parent.parent.name in ['TDatumVal', 'TColumnData']]

    nodes = []
    for ts in thrift_specs:
        node = ts.copy()
        node.target = ts.parent.name + '.' + str(node.target)
        nodes.append(node)
        ts.value = 'None'

    red_ast.extend(nodes)
    out_file.write(red_ast.dumps())
Example #4
0
def insert_output_start_stop_indicators(src):
    """
    Insert identifier strings so that output can be segregated from input.

    Parameters
    ----------
    src : str
        String containing input and output lines.

    Returns
    -------
    str
        String with output demarked.
    """
    rb = RedBaron(src)

    # find lines with trailing comments so we can preserve them properly
    lines_with_comments = {}
    comments = rb.findAll('comment')
    for c in comments:
        if c.previous and c.previous.type != 'endl':
            lines_with_comments[c.previous] = c

    input_block_number = 0

    # find all nodes that might produce output
    nodes = rb.findAll(lambda identifier: identifier in ['print', 'atomtrailers'])
    for r in nodes:
        # assume that whatever is in the try block will fail and produce no output
        # this way we can properly handle display of error messages in the except
        if hasattr(r.parent, 'type') and r.parent.type == 'try':
            continue

        # Output within if/else statements is not a good idea for docs, because
        # we don't know which branch execution will follow and thus where to put
        # the output block. Regardless of which branch is taken, though, the
        # output blocks must start with the same block number.
        if hasattr(r.parent, 'type') and r.parent.type == 'if':
            if_block_number = input_block_number
        if hasattr(r.parent, 'type') and r.parent.type in ['elif', 'else']:
            input_block_number = if_block_number

        if is_output_node(r):
            # if there was a trailing comment on this line, output goes after it
            if r in lines_with_comments:
                r = lines_with_comments[r]  # r is now the comment

            # find the correct node to 'insert_after'
            while hasattr(r, 'parent') and not hasattr(r.parent, 'insert'):
                r = r.parent

            r.insert_after('print(">>>>>%d")\n' % input_block_number)
            input_block_number += 1

    # curse you, redbaron! stop inserting endl before trailing comments!
    for l, c in lines_with_comments.items():
        if c.previous and c.previous.type == 'endl':
            c.previous.value = ''

    return rb.dumps()
Example #5
0
def test_comma_proxy_list_indented_set_item():
    red = RedBaron("[\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list[0] = "42"
    assert comma_proxy_list[0].type == "int"
    assert comma_proxy_list[0].value == "42"
    comma_proxy_list[0] = "plop"
    assert comma_proxy_list[0].type == "name"
    assert comma_proxy_list[0].value == "plop"
    assert red.dumps() == "[\n    plop,\n]"
Example #6
0
def functionalize(src):
    red = RedBaron(src)
    red.insert(0, 'import pync')
    for func in red.find_all('def'):
        func.decorators.append('@pync.curry')

    for l in red.find_all('list') + red.find_all('list_comprehension'):
        l.replace("pync.list(%s)" % l)

    return red.dumps()
Example #7
0
def test_comma_proxy_list_set_item():
    red = RedBaron("[1]")
    comma_proxy_list = red[0].value
    comma_proxy_list[0] = "42"
    assert comma_proxy_list[0].type == "int"
    assert comma_proxy_list[0].value == 42
    comma_proxy_list[0] = "plop"
    assert comma_proxy_list[0].type == "name"
    assert comma_proxy_list[0].value == "plop"
    assert red.dumps() == "[plop]"
Example #8
0
def remove_raise_skip_tests(src):
    """
    Remove from the code any raise unittest.SkipTest lines since we don't want those in
    what the user sees.
    """
    rb = RedBaron(src)
    raise_nodes = rb.findAll("RaiseNode")
    for rn in raise_nodes:
        # only the raise for SkipTest
        if rn.value[:2].dumps() == 'unittestSkipTest':
            rn.parent.value.remove(rn)
    return rb.dumps()
    def handle(self, *args, **options):
        call_command('migrate', interactive = False)
        
        try:
            company = Entity.objects.get(owner=True)
            self.stdout.write('Already configured')
        except Entity.DoesNotExist:
            entity = Entity()
            entity.name = 'Your company'
            entity.description = 'Your company description'
            entity.endpoint = 'http://*****:*****@test.test'
            liaison.phone = '123456789'
            liaison.address = 'Testing Road'
            liaison.zip = '123456'
            liaison.city = 'Testicity'
            liaison.provider = entity
            liaison.save()
            
            base = getattr(settings, 'BASE_DIR')
            settings_path = os.path.join(base, 'Exchange', 'settings.py')
            
            with open(settings_path, 'r+') as f:
                read_data = f.read()
                f.seek(0)
                red = RedBaron(read_data)
                
                red.find("assignment", target=lambda x: x.dumps() == "SENDER").value.replace("'" + str(entity.id) + "'")
                
                secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
                red.find("assignment", target=lambda x: x.dumps() == "SECRET_KEY").value.replace("'" + secret_key + "'")

                f.truncate()
                code = red.dumps()
                
                f.write(code)
            f.closed
            
            print('Database content created')
            print('Provider configured')
            print('New secret key generated')
            
            self.stdout.write('Setup complete')
Example #10
0
def reform_input(args, method="foo"):
    """Re-give the def repr.

    - args: a list of dicts, representing redbaron's arguments

    - return: something like "def foo(args):" (without 'pass')
    """
    # https://redbaron.readthedocs.io/en/latest/nodes_reference.html#funcdefnode
    args = interpose_commas(args)
    newdef = "def {}(): pass".format(method)
    red = RedBaron(newdef)
    red[0].arguments = args
    res = red.dumps().strip()
    res = res.strip(" pass")
    return res
Example #11
0
def replace_asserts_with_prints(source_code):
    """
    Replace asserts with print statements.

    Using RedBaron, replace some assert calls with print statements that print the actual
    value given in the asserts.

    Depending on the calls, the actual value can be the first or second
    argument.
    """

    rb = RedBaron(source_code)  # convert to RedBaron internal structure

    for assert_type in ['assertAlmostEqual', 'assertLess', 'assertGreater', 'assertEqual',
                        'assert_equal_arrays', 'assertTrue', 'assertFalse']:
        assert_nodes = rb.findAll("NameNode", value=assert_type)
        for assert_node in assert_nodes:
            assert_node = assert_node.parent
            remove_redbaron_node(assert_node, 0)  # remove 'self' from the call
            assert_node.value[0].replace('print')
            if assert_type not in ['assertTrue', 'assertFalse']:
                remove_redbaron_node(assert_node.value[1], 1)  # remove the expected value argument

    assert_nodes = rb.findAll("NameNode", value='assert_rel_error')
    for assert_node in assert_nodes:
        assert_node = assert_node.parent
        # If relative error tolerance is specified, there are 4 arguments
        if len(assert_node.value[1]) == 4:
            remove_redbaron_node(assert_node.value[1], -1)  # remove the relative error tolerance
        remove_redbaron_node(assert_node.value[1], -1)  # remove the expected value
        remove_redbaron_node(assert_node.value[1], 0)  # remove the first argument which is
        #                                                  the TestCase
        assert_node.value[0].replace("print")

    assert_nodes = rb.findAll("NameNode", value='assert_almost_equal')
    for assert_node in assert_nodes:
        assert_node = assert_node.parent
        # If relative error tolerance is specified, there are 3 arguments
        if len(assert_node.value[1]) == 3:
            remove_redbaron_node(assert_node.value[1], -1)  # remove the relative error tolerance
        remove_redbaron_node(assert_node.value[1], -1)  # remove the expected value
        assert_node.value[0].replace("print")

    source_code_with_prints = rb.dumps()  # get back the string representation of the code
    return source_code_with_prints
Example #12
0
def test_line_proxy_with_blank_line_list_delslice():
    red = RedBaron("while a:\n    pass\n\n    plop\n    caramba\n    compote\n    plop\n    z\n")
    del red[0].value[1:4]
    assert red.dumps() == "while a:\n    pass\n    compote\n    plop\n    z\n"
Example #13
0
def test_line_proxy_with_blank_line_list_remove_2():
    red = RedBaron("while a:\n    pass\n\n    plop\n    c\n    pass\n")
    red[0].value.remove(red[0].value[1])
    assert red.dumps() == "while a:\n    pass\n    plop\n    c\n    pass\n"
Example #14
0
def test_line_proxy_with_blank_line_dont_break_next_block_identation():
    red = RedBaron(forwarded_indented_code)
    red.while_.append("plop")
    assert red.dumps() == forwarded_indented_code_result
Example #15
0
def test_comma_proxy_list_indented_del_2_at_top():
    red = RedBaron("[\n    2,\n    1,\n]")
    comma_proxy_list = red[0].value
    del comma_proxy_list[0]
    assert red.dumps() == "[\n    1,\n]"
Example #16
0
def test_comma_proxy_list_indented_delslice():
    red = RedBaron("[\n    1,\n    2,\n    3,\n    4,\n    5,\n    6,\n]")
    comma_proxy_list = red[0].value
    del comma_proxy_list[1:4]
    assert red.dumps() == "[\n    1,\n    5,\n    6,\n]"
Example #17
0
def test_comma_proxy_list_indented_del_2_at_top():
    red = RedBaron("[\n    2,\n    1,\n]")
    comma_proxy_list = red[0].value
    del comma_proxy_list[0]
    assert red.dumps() == "[\n    1,\n]"
Example #18
0
def test_comma_proxy_list_indented_insert_2_middle():
    red = RedBaron("[\n    1,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.insert(1, "2")
    assert red.dumps() == "[\n    1,\n    2,\n    3,\n]"
Example #19
0
def test_decorator_line_proxy_list_insert_2_at_middle():
    red = RedBaron("@plop\n@plouf\ndef a():\n    pass\n")
    red[0].decorators.insert(1, "@pop")
    assert red.dumps() == "@plop\n@pop\n@plouf\ndef a():\n    pass\n"
Example #20
0
def test_decorator_line_proxy_list_insert():
    red = RedBaron("def a():\n    pass\n")
    red[0].decorators.insert(0, "@plop")
    assert red.dumps() == "@plop\ndef a():\n    pass\n"
Example #21
0
def test_comma_proxy_list_indented_in_indentation_case():
    red = RedBaron(comma_proxy_list_indented_code_to_test)
    red.find("list").value.append_with_new_line("2")
    assert red.dumps(
    ) == comma_proxy_list_indented_code_to_test_expected_result
Example #22
0
def test_comma_proxy_list_indented_delslice():
    red = RedBaron("[\n    1,\n    2,\n    3,\n    4,\n    5,\n    6,\n]")
    comma_proxy_list = red[0].value
    del comma_proxy_list[1:4]
    assert red.dumps() == "[\n    1,\n    5,\n    6,\n]"
Example #23
0
def test_comma_proxy_list_indented_set_slice():
    red = RedBaron("[\n    1,\n    2,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list[1:2] = ["42", "31", "23"]
    assert red.dumps() == "[\n    1,\n    42,\n    31, 23, 3,\n]"
Example #24
0
def test_comma_proxy_list_pop_no_index():
    red = RedBaron("[1, 2, 3]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop()
    assert red.dumps() == "[1, 2]"
Example #25
0
def test_comma_proxy_list_indented_remove_2_at_top():
    red = RedBaron("[\n    2,\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.remove(comma_proxy_list[0])
    assert red.dumps() == "[\n    1,\n]"
Example #26
0
def test_line_proxy_with_blank_line_list_different_indentation():
    red = RedBaron("while a:\n        pass\n\n        plop\n")
    red[0].value.append("c")
    assert red.dumps() == "while a:\n        pass\n\n        plop\n        c\n"
Example #27
0
def test_line_proxy_with_blank_line_dont_break_next_block_identation():
    red = RedBaron(forwarded_indented_code)
    red.while_.append("plop")
    assert red.dumps() == forwarded_indented_code_result
Example #28
0
def test_decorator_line_proxy_list_append():
    red = RedBaron("@plop\ndef a():\n    pass\n\n")
    red[0].decorators.append("@c.d.e")
    assert red.dumps() == "@plop\[email protected]\ndef a():\n    pass\n\n"
Example #29
0
def test_comma_proxy_list_pop_2_middle():
    red = RedBaron("[1, 2, 3]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop(1)
    assert red.dumps() == "[1, 3]"
Example #30
0
def test_decorator_line_proxy_list_pop_2():
    red = RedBaron("@a\n@b\n@c\ndef a():\n    pass\n")
    red[0].decorators.pop(2)
    assert red.dumps() == "@a\n@b\ndef a():\n    pass\n"
Example #31
0
def test_comma_proxy_list_pop_2_at_top():
    red = RedBaron("[2, 1]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop(0)
    assert red.dumps() == "[1]"
Example #32
0
def test_decorator_line_proxy_list_del():
    red = RedBaron("@plop\n@qsd\ndef a():\n    pass\n")
    del red[0].decorators[0]
    assert red.dumps() == "@qsd\ndef a():\n    pass\n"
Example #33
0
def test_line_proxy_with_blank_line_list_different_indentation():
    red = RedBaron("while a:\n        pass\n\n        plop\n")
    red[0].value.append("c")
    assert red.dumps() == "while a:\n        pass\n\n        plop\n        c\n"
Example #34
0
def test_decorator_line_proxy_list_remove():
    red = RedBaron("@a\n@b\ndef a():\n    pass\n")
    red[0].decorators.remove(red[0].decorators[0])
    assert red.dumps() == "@b\ndef a():\n    pass\n"
Example #35
0
def test_comma_proxy_list_indented_insert_2():
    red = RedBaron("[\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.insert(1, "2")
    assert comma_proxy_list.style == "indented"
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #36
0
def test_decorator_line_proxy_list_set_slice():
    red = RedBaron("def a():\n    pass\n")
    red[0].decorators[1:2] = ["@caramba", "@compote"]
    assert red.dumps() == "@caramba\n@compote\ndef a():\n    pass\n"
    assert isinstance(red[0].decorators, LineProxyList)
Example #37
0
def test_line_proxy_with_blank_line_list_del_blank_line():
    red = RedBaron("while a:\n    pass\n\n    plop\n    c\n    pass\n")
    del red[0].value[1]
    assert red.dumps() == "while a:\n    pass\n    plop\n    c\n    pass\n"
Example #38
0
def test_decorator_line_proxy_list_delslice():
    red = RedBaron("@a\n@b\n@c\ndef a():\n    pass\n")
    del red[0].decorators[1:4]
    assert red.dumps() == "@a\ndef a():\n    pass\n"
Example #39
0
def test_line_proxy_with_blank_line_list_set_slice():
    red = RedBaron("while a:\n    pass\n\n    plop\n    a\n    plop\n    z\n")
    red[0].value[1:2] = ["caramba", "compote"]
    assert red.dumps() == "while a:\n    pass\n    caramba\n    compote\n    plop\n    a\n    plop\n    z\n"
Example #40
0
def test_decorator_line_proxy_list_extend():
    red = RedBaron("def a():\n    pass\n")
    red[0].decorators.extend(["@zob"])
    assert red.dumps() == "@zob\ndef a():\n    pass\n"
Example #41
0
def test_line_proxy_with_blank_line_list_extend():
    red = RedBaron("while a:\n    pass\n\n    plop\n")
    red[0].value.extend(["zob"])
    assert red.dumps() == "while a:\n    pass\n\n    plop\n    zob\n"
Example #42
0
def test_comma_proxy_list_del_2_at_top():
    red = RedBaron("[2, 1]")
    comma_proxy_list = red[0].value
    del comma_proxy_list[0]
    assert red.dumps() == "[1]"
Example #43
0
def test_comma_proxy_list_pop_2_at_top():
    red = RedBaron("[2, 1]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop(0)
    assert red.dumps() == "[1]"
Example #44
0
def test_decorator_line_proxy_dont_break_next_block_identation():
    red = RedBaron(forwarded_indented_code_decorators)
    red.find("def").decorators.append("@plop")
    assert red.dumps() == forwarded_indented_code_result_decorators
Example #45
0
def test_comma_proxy_list_indented_insert_2():
    red = RedBaron("[\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.insert(1, "2")
    assert comma_proxy_list.style == "indented"
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #46
0
def test_line_proxy_correctly_indent_code_block():
    red = RedBaron("while True:\n    pass\n")
    red[0].extend(["if a:\n    pass\n\n"])
    assert red.dumps() == "while True:\n    pass\n    if a:\n        pass\n\n"
Example #47
0
def test_comma_proxy_list_indented_append_2():
    red = RedBaron("[\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.append("2")
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #48
0
import copy
import sys

from redbaron import RedBaron


in_file = out_file = sys.argv[1]

code = open(in_file).read()
red_baron = RedBaron(code)

super_nodes = red_baron.find_all('AtomtrailersNode')

for super_node in super_nodes:
    node = copy.copy(super_node)
    class_name = node.find_all('name')[1].name.dumps()

    while node.parent:
        node = node.parent
        if node.name == class_name:
            super_node.value[1] = '()'

with open(out_file, "w") as fh:
    fh.write(red_baron.dumps())
Example #49
0
def test_comma_proxy_list_indented_pop_no_index():
    red = RedBaron("[\n    1,\n    2,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop()
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #50
0
def test_comma_proxy_list_pop_2_middle():
    red = RedBaron("[1, 2, 3]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop(1)
    assert red.dumps() == "[1, 3]"
Example #51
0
def test_comma_proxy_list_indented_remove_2_at_top():
    red = RedBaron("[\n    2,\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.remove(comma_proxy_list[0])
    assert red.dumps() == "[\n    1,\n]"
Example #52
0
def test_root_as_line_proxy_list_pop_2():
    red = RedBaron("a\nb\nc\n")
    red.pop(0)
    assert red.dumps() == "b\nc\n"
Example #53
0
def test_comma_proxy_list_indented_set_slice():
    red = RedBaron("[\n    1,\n    2,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list[1:2] = ["42", "31", "23"]
    assert red.dumps() == "[\n    1,\n    42,\n    31,\n    23,\n    3,\n]"
Example #54
0
def test_root_as_line_proxy_list_del():
    red = RedBaron("b\nc\n")
    del red[0]
    assert red.dumps() == "c\n"
Example #55
0
def test_comma_proxy_list_indented_append_2():
    red = RedBaron("[\n    1,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.append("2")
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #56
0
def test_comma_proxy_list_indented_insert_2_middle():
    red = RedBaron("[\n    1,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.insert(1, "2")
    assert red.dumps() == "[\n    1,\n    2,\n    3,\n]"
Example #57
0
def test_root_as_line_proxy_list_insert():
    red = RedBaron("a\nb\nc\n")
    red.insert(1, "c\n")
    assert red.dumps() == "a\nc\nb\nc\n"
Example #58
0
def test_comma_proxy_list_indented_pop_no_index():
    red = RedBaron("[\n    1,\n    2,\n    3,\n]")
    comma_proxy_list = red[0].value
    comma_proxy_list.pop()
    assert red.dumps() == "[\n    1,\n    2,\n]"
Example #59
0
    try:
        updateString(node)
    except Exception:
        print("Problem with", node)
        node.help(deep = True, with_formatting = True)
        raise

for node in red.find_all("DefNode"):
    try:
        updateDefNode(node)
    except Exception:
        print("Problem with", node)
        node.help(deep = True, with_formatting = True)
        raise

new_code = red.dumps()

if new_code != old_code:

    new_name = sys.argv[1] + ".new"

    with open(new_name, "w") as source_code:
        source_code.write(red.dumps())

    # There is no way to safely replace a file on Windows, but lets try on Linux
    # at least.
    old_stat = os.stat(sys.argv[1])

    try:
        os.rename(new_name, sys.argv[1])
    except OSError:
Example #60
0
def test_root_as_line_proxy_list_append():
    red = RedBaron("a\nb\nc\n")
    red.append("c\n")
    assert red.dumps() == "a\nb\nc\nc\n"