MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / main

Function main

scripts/itemDiff.py:36–480  ·  view source on GitHub ↗
(old, new, groups=True, effects=True, attributes=True, renames=True)

Source from the content-addressed store, hash-verified

34default_old = os.path.join(script_dir, "..", "eve.db")
35
36def main(old, new, groups=True, effects=True, attributes=True, renames=True):
37 # Open both databases and get their cursors
38 old_db = sqlite3.connect(os.path.expanduser(old))
39 old_cursor = old_db.cursor()
40 new_db = sqlite3.connect(os.path.expanduser(new))
41 new_cursor = new_db.cursor()
42
43 # Force some of the items to make them published
44 FORCEPUB_TYPES = (
45 "% Propulsion Mode",
46 "% Sharpshooter Mode",
47 "% Defense Mode",
48 "% Primary Mode",
49 "% Secondary Mode",
50 "% Tertiary Mode",
51 )
52 OVERRIDES_TYPEPUB = 'UPDATE invtypes SET published = 1 WHERE typeName like ?'
53 for typename in FORCEPUB_TYPES:
54 old_cursor.execute(OVERRIDES_TYPEPUB, (typename,))
55 new_cursor.execute(OVERRIDES_TYPEPUB, (typename,))
56
57 # Initialization of few things used by both changed/renamed effects list
58 script_dir = os.path.dirname(__file__)
59 effectspath = os.path.join(script_dir, "..", "eos", "effects.py")
60 implemented = set()
61
62 with open(effectspath) as f:
63 for line in f:
64 for m in re.finditer(r'class Effect(?P<eid>\d+)\(BaseEffect\):', line):
65 effectid = int(m.group('eid'))
66 implemented.add(effectid)
67
68 # Effects' names are used w/o any special symbols by eos
69 stripspec = "[^A-Za-z0-9]"
70
71 # Method to get data if effect is implemented in eos or not
72 def geteffst(effectid):
73 return effectid in implemented
74
75 def findrenames(ren_dict, query, strip=False):
76
77 old_namedata = {}
78 new_namedata = {}
79
80 for cursor, dictionary in ((old_cursor, old_namedata), (new_cursor, new_namedata)):
81 cursor.execute(query)
82 for row in cursor:
83 id = row[0]
84 name = row[1]
85 if strip is True:
86 name = re.sub(stripspec, "", name)
87 dictionary[id] = name
88
89 for id in set(old_namedata.keys()).intersection(list(new_namedata.keys())):
90 oldname = old_namedata[id] if old_namedata[id] is not None else 'None'
91 newname = new_namedata[id] if new_namedata[id] is not None else 'None'
92 if oldname != newname:
93 ren_dict[id] = (oldname, newname)

Callers 1

itemDiff.pyFile · 0.70

Calls 11

findrenamesFunction · 0.85
printrenamesFunction · 0.85
getitemnameFunction · 0.85
getgroupcatFunction · 0.85
getgroupnameFunction · 0.85
geteffectnameFunction · 0.85
geteffstFunction · 0.85
getattrnameFunction · 0.85
keysMethod · 0.45
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected