Passed
Push — master ( dfe4f2...9c85cc )
by Matěj
02:22
created

ssg.build_cpe.extract_subelement()   A

Complexity

Conditions 4

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 6
nop 2
dl 0
loc 6
ccs 6
cts 6
cp 1
crap 4
rs 10
c 0
b 0
f 0
1
"""
2
Common functions for building CPEs
3
"""
4
5 1
from __future__ import absolute_import
6 1
from __future__ import print_function
7
8 1
def extract_subelement(objects, sub_elem_type):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
9 1
    for obj in objects:
10 1
        for subelement in obj.getiterator():
11 1
            if subelement.get(sub_elem_type):
12 1
                sub_element = subelement.get(sub_elem_type)
13 1
                return sub_element
14
15
16 1
def extract_env_obj(objects, local_var):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
17 1
    for obj in objects:
18 1
        env_id = extract_subelement(local_var, 'object_ref')
19 1
        if env_id == obj.get('id'):
20 1
            return obj
21
22
23 1
def extract_referred_nodes(tree_with_refs, tree_with_ids, attrname):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
24 1
    reflist = []
25 1
    elementlist = []
26
27 1
    for element in tree_with_refs.getiterator():
28 1
        value = element.get(attrname)
29 1
        if value is not None:
30 1
            reflist.append(value)
31
32 1
    for element in tree_with_ids.getiterator():
33 1
        if element.get("id") in reflist:
34 1
            elementlist.append(element)
35
36
    return elementlist
37