diff --git a/gooey/code_prep.py b/gooey/code_prep.py index d8b4bff..a9fc220 100644 --- a/gooey/code_prep.py +++ b/gooey/code_prep.py @@ -38,11 +38,8 @@ def split_line(line): # splits an assignment statement into varname and command strings # in: "parser = ArgumentParser(description='Example Argparse Program')" # out: "parser", "ArgumentParser(description='Example Argparse Program" - # take/dropwhile used to avoid splitting on multiple '=' signs - not_equal_sign = lambda x: x != '=' - varname = ''.join(takewhile(not_equal_sign, line)).strip() - command = ''.join(dropwhile(not_equal_sign, line))[2:] - return varname, command + pieces = line.split('=', 1) + return pieces[0].strip(), ''.join(pieces[1:]).lstrip() def update_parser_varname(new_varname, code): # lines = source.split('\n')[1:] diff --git a/gooey/code_prep_unittest.py b/gooey/code_prep_unittest.py index ce7ce4b..c66805e 100644 --- a/gooey/code_prep_unittest.py +++ b/gooey/code_prep_unittest.py @@ -8,7 +8,7 @@ class TestCodePrep(unittest.TestCase): def test_split_line(self): line = "parser = ArgumentParser(description='Example Argparse Program')" self.assertEqual("parser", code_prep.split_line(line)[0]) - self.assertEqual("= ArgumentParser(description='Example Argparse Program')", code_prep.split_line(line)[1]) + self.assertEqual("ArgumentParser(description='Example Argparse Program')", code_prep.split_line(line)[1]) def test_update_parser_varname_assigns_new_name_to_parser_var(self): line = ["parser = ArgumentParser(description='Example Argparse Program')"] @@ -54,4 +54,4 @@ parser.parse_args() if __name__ == "__main__": #import sys;sys.argv = ['', 'Test.testName'] - unittest.main() \ No newline at end of file + unittest.main()