示例#1
0
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
示例#2
0
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)
示例#3
0
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
示例#4
0
    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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 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)