Code Duplication    Length = 27-27 lines in 2 locations

utils/fix_file_ocilclause.py 1 location

@@ 11-37 (lines=27) @@
8
import ssg
9
10
11
def _create_profile_cache(ssg_root):
12
    profile_cache = {}
13
14
    product_list = ['debian9', 'debian10', 'fedora', 'ol7', 'opensuse',
15
                    'rhel7', 'sle12', 'ubuntu1604', 'ubuntu1804',
16
                    'wrlinux']
17
18
    for product in product_list:
19
        found_obj_name = False
20
        prod_profiles_dir = os.path.join(ssg_root, product, "profiles")
21
        for _, _, files in os.walk(prod_profiles_dir):
22
            for filename in files:
23
                profile_path = os.path.join(prod_profiles_dir, filename)
24
                parsed_profile = yaml.load(open(profile_path, 'r'))
25
                for _obj in parsed_profile['selections']:
26
                    obj = _obj
27
                    if '=' in obj:
28
                        # is a var with non-default value
29
                        obj = _obj[:_obj.index('=')]
30
                    if not obj[0].isalpha():
31
                        obj = obj[1:]
32
33
                    if obj not in profile_cache:
34
                        profile_cache[obj] = set()
35
36
                    profile_cache[obj].add(product)
37
38
    return profile_cache
39
40

utils/duplicated_prodtypes.py 1 location

@@ 11-37 (lines=27) @@
8
import ssg
9
10
11
def _create_profile_cache(ssg_root):
12
    profile_cache = {}
13
14
    product_list = ['debian9', 'debian10', 'fedora', 'ol7', 'opensuse',
15
                    'rhel7', 'sle12', 'ubuntu1604', 'ubuntu1804',
16
                    'wrlinux']
17
18
    for product in product_list:
19
        found_obj_name = False
20
        prod_profiles_dir = os.path.join(ssg_root, product, "profiles")
21
        for _, _, files in os.walk(prod_profiles_dir):
22
            for filename in files:
23
                profile_path = os.path.join(prod_profiles_dir, filename)
24
                parsed_profile = yaml.load(open(profile_path, 'r'))
25
                for _obj in parsed_profile['selections']:
26
                    obj = _obj
27
                    if '=' in obj:
28
                        # is a var with non-default value
29
                        obj = _obj[:_obj.index('=')]
30
                    if not obj[0].isalpha():
31
                        obj = obj[1:]
32
33
                    if obj not in profile_cache:
34
                        profile_cache[obj] = set()
35
36
                    profile_cache[obj].add(product)
37
38
    return profile_cache
39
40