def get_details_test(n): # Doc test for class_grabber.get_attrib() """ >>> get_details_test("oneTwo") ['one_two'] >>> get_details_test("allMyText") ['all_my_text'] >>> get_details_test("reverseText") ['reverse_text'] >>> get_details_test("one") ['one'] >>> get_details_test("allMyToys") ['all_my_toys'] """ x = class_grabber.ClassGrabber(new_class_name="some", new_data="()") x.append_details(array=x.attrib, detail=n) return x.attrib
def doc_test3(n): """ >>> doc_test3('getBlock()') 'get_block()' >>> doc_test3('getInt()') 'get_int()' >>> doc_test3('doThis()') 'do_this()' >>> doc_test3('block()') 'block()' >>> doc_test3('getAllFrom()') 'get_all_from()' """ i = class_grabber.ClassGrabber(new_class_name="name", new_data="") return i.formatter(n)
def doc_test4(n): """ >>> doc_test3('getBlock()') 'get_block()' >>> doc_test3('getInt()') 'get_int()' >>> doc_test3('doThis()') 'do_this()' >>> doc_test3('block()') 'block()' >>> doc_test3('getAllFrom()') 'get_all_from()' """ x = class_grabber.ClassGrabber(new_class_name="some", new_data="()") x.append_details(array=x.attrib, detail=n) return x.attrib
def get_details(self): for x, y in self.dict.items(): a_class = class_grabber.ClassGrabber(new_class_name=x, new_data=y) if self.get_rel(a_class.class_name.replace("{", "")): a_class = class_grabber.ClassGrabber(new_class_name=x, new_data=y) self.result.append("import " + self.partner + "\n\n\n") self.result.append("class " + a_class.class_name.replace("{", ":")) self.result.append("\tdef __init__(self, " + self.partner.lower() + ":" + self.partner + "):\n") for line in a_class.attrib: x = "\t\tself." + line.strip(" ") if 'all' in line: self.result.append(x + " = []" + "\n") elif 'int' in line: self.result.append(x + " = 0" + "\n") else: self.result.append(x + "\n") self.result.append("\n") for line in a_class.methods: if line == '': continue if a_class.check_ret(line): r = line.split(" ") self.result.append("\tdef " + r[1].strip(" ") + "->" + r[0].strip(" ") + ": \n") else: a_class.return_val = "None" self.result.append("\tdef " + line.strip(" ") + "-> None: \n") self.result.append("\t\tpass \n") else: self.result.append("class " + a_class.class_name.replace("{", ":")) self.result.append("\tdef __init__(self):\n") for line in a_class.attrib: x = "\t\tself." + line.strip(" ") if 'all' in line: self.result.append(x + " = []" + "\n") elif 'int' in line: self.result.append(x + " = 0" + "\n") else: self.result.append(x + "\n") self.result.append("\n") for line in a_class.methods: if line == '': continue if a_class.check_ret(line): r = line.split(" ") while True: try: r.remove('') except ValueError: break self.result.append("\tdef " + r[1].strip(" ") + "->" + r[0].strip(" ") + ": " + "\n") elif line == "\n": break else: a_class.return_val = "None" self.result.append("\tdef " + line.strip(" ") + "-> None: " + "\n") self.result.append("\t\tpass \n") self.result.append("# ====================================" "===================================\n") # returns new output for i in self.result: self.final = self.final + i print(self.final)
def test_check_ret2(self): arrange = "getWall()" expect = False x = class_grabber.ClassGrabber(new_class_name="Tester", new_data="()") self.assertEqual(x.check_ret(arrange), expect)
def test_formatter3(self): arrange = "someMethod()" expected = 'some_method()' x = class_grabber.ClassGrabber(new_class_name="Tester", new_data="()") self.assertEqual(x.formatter(arrange), expected)
def test_formatter2(self): arrange = "getBox()" expected = 'get_box()' x = class_grabber.ClassGrabber(new_class_name="Tester", new_data="()") self.assertEqual(x.formatter(arrange), expected)