summaryrefslogtreecommitdiff
path: root/import_tools/del_repo/yaml_fixer.py
blob: b75e306966e68834ecf88ee8511750e2840cde7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python
#fixes the output of repo_to_yaml.py
import yaml

def has_number(thing):
    result = thing.count("0") + thing.count("1") + thing.count("2") + thing.count("3") + thing.count("4") + thing.count("5") + thing.count("6") + thing.count("7") + thing.count("8") + thing.count("9")
    if result>0: return True
    else: return False

def make_lists(some_dictionary):
    for key in some_dictionary:
        if has_number(key):
            if some_dictionary.has_key(remove_number(key)):
                if isinstance(some_dictionary[key], list):
                    some_dictionary[remove_number(key)].append(some_dictionary[key])
                else: #make it into a list
            else: #actually i'm not so sure what should happen here.
                pass
    for key in some_dictionary:
        if hasattr(some_dictionary[key], "__dict__"):
            some_dictionary[key] = make_lists(some_dictionary[key])
    return some_dictionary

oo = yaml.load(open("roomba.yaml"))
system = oo["roomba.repo.xml"]["System"]