MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / main

Function main

scripts/conversion.py:51–128  ·  view source on GitHub ↗
(old, new)

Source from the content-addressed store, hash-verified

49 """
50
51def main(old, new):
52 # Open both databases and get their cursors
53 old_db = sqlite3.connect(os.path.expanduser(old))
54 old_cursor = old_db.cursor()
55 new_db = sqlite3.connect(os.path.expanduser(new))
56 new_cursor = new_db.cursor()
57
58 renames = {}
59 conversions = {}
60
61 for x in text.splitlines():
62 x = x.strip()
63 if not x:
64 continue
65 if conversion_phrase in x:
66 c = x.split(conversion_phrase)
67 container = conversions
68 elif rename_phrase in x:
69 c = x.split(rename_phrase)
70 container = renames
71 else:
72 print("Unknown format: {}".format(x))
73 sys.exit()
74
75 old_name, new_name = c[0], c[1]
76 old_item, new_item = None, None
77
78 if "Blueprint" in old_name or "Blueprint" in new_name:
79 print("Blueprint: Skipping this line: %s"%x)
80 continue
81
82 # gather item info
83 new_cursor.execute('SELECT "typeID" FROM "invtypes" WHERE "typeName" = ?', (new_name,))
84 for row in new_cursor:
85 new_item = row[0]
86 break
87
88 old_cursor.execute('SELECT "typeID" FROM "invtypes" WHERE "typeName" = ?', (old_name,))
89 for row in old_cursor:
90 old_item = row[0]
91 break
92
93 if not old_item:
94 print("Error finding old item in {} -> {}".format(old_name, new_name))
95 if not new_item:
96 print("Error finding new item in {} -> {}".format(old_name, new_name))
97
98 if not container.get((new_item,new_name), None):
99 container[(new_item,new_name)] = []
100
101
102 container[(new_item,new_name)].append((old_item, old_name))
103
104 print(" # Renamed items")
105
106 for new, old in renames.items():
107 if len(old) != 1:
108 print("Incorrect length, key: {}, value: {}".format(new, old))

Callers 1

conversion.pyFile · 0.70

Calls 3

itemsMethod · 0.80
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected