Code Duplication    Length = 15-15 lines in 2 locations

build-scripts/combine_ovals.py 1 location

@@ 74-88 (lines=15) @@
71
    variables = ssg.xml.ElementTree.Element("{%s}variables" % oval_ns)
72
73
    for childnode in tree.findall("./{%s}def-group/*" % oval_ns):
74
        if childnode.tag is ssg.xml.ElementTree.Comment:
75
            continue
76
        elif childnode.tag.endswith("definition"):
77
            ssg.build_ovals.append(definitions, childnode)
78
        elif childnode.tag.endswith("_test"):
79
            ssg.build_ovals.append(tests, childnode)
80
        elif childnode.tag.endswith("_object"):
81
            ssg.build_ovals.append(objects, childnode)
82
        elif childnode.tag.endswith("_state"):
83
            ssg.build_ovals.append(states, childnode)
84
        elif childnode.tag.endswith("_variable"):
85
            ssg.build_ovals.append(variables, childnode)
86
        else:
87
            sys.stderr.write("Warning: Unknown element '%s'\n"
88
                             % (childnode.tag))
89
90
    root = ssg.xml.ElementTree.fromstring(("%s%s" % (header, footer)).encode("utf-8"))
91
    root.append(definitions)

tests/oval_tester.py 1 location

@@ 51-65 (lines=15) @@
48
            "{%s}variables" % ssg.constants.oval_namespace)
49
        for childnode in shorthand_tree.findall(".//{%s}def-group/*" %
50
                                                ssg.constants.oval_namespace):
51
            if childnode.tag is ssg.xml.ElementTree.Comment:
52
                continue
53
            elif childnode.tag.endswith("definition"):
54
                ssg.build_ovals.append(definitions, childnode)
55
            elif childnode.tag.endswith("_test"):
56
                ssg.build_ovals.append(tests, childnode)
57
            elif childnode.tag.endswith("_object"):
58
                ssg.build_ovals.append(objects, childnode)
59
            elif childnode.tag.endswith("_state"):
60
                ssg.build_ovals.append(states, childnode)
61
            elif childnode.tag.endswith("_variable"):
62
                ssg.build_ovals.append(variables, childnode)
63
            else:
64
                sys.stderr.write(
65
                    "Warning: Unknown element '%s'\n" % (childnode.tag))
66
67
        header = ssg.xml.oval_generated_header("test", "5.11", "1.0")
68
        skeleton = header + ssg.constants.oval_footer