Fix icon logic / add some missing icons

This commit is contained in:
blitzmann
2016-05-01 22:21:14 -04:00
parent 57b9b916ed
commit b9dad60b61
18 changed files with 24 additions and 19 deletions

BIN
eve.db

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

View File

@@ -23,6 +23,7 @@ db_path = os.path.abspath(os.path.join(script_dir, '..', 'eve.db'))
icons_dir = os.path.abspath(os.path.join(script_dir, '..', 'imgs', 'icons'))
export_dir = os.path.abspath(os.path.expanduser(os.path.join(args.icons, 'items')))
dirs = [export_dir, os.path.join(export_dir, "Modules")]
db = sqlite3.connect(db_path)
cursor = db.cursor()
@@ -150,21 +151,20 @@ for fname in os.listdir(icons_dir):
print fname,"exists"
existing.add(fname)
for fname in os.listdir(export_dir):
if not os.path.isfile(os.path.join(export_dir, fname)):
continue
stripped = strip_path(fname)
stripped = unzero(stripped)
# Icons in export often specify size in their name, but references often use
# convention without size specification
sizeless = re.sub('^(?P<prefix>[^_]+)_(?P<size>\d+)_(?P<suffix>[^_]+)$', r'\1_\3', stripped)
# Often items referred to with 01_01 format,
fnames = export.setdefault(stripped, set())
fnames.add(fname)
fnames = export.setdefault(sizeless, set())
fnames.add(fname)
for dir in dirs:
for fname in os.listdir(dir):
if not os.path.isfile(os.path.join(dir, fname)):
continue
stripped = strip_path(fname)
stripped = unzero(stripped)
# Icons in export often specify size in their name, but references often use
# convention without size specification
sizeless = re.sub('^(?P<prefix>[^_]+)_(?P<size>\d+)_(?P<suffix>[^_]+)$', r'\1_\3', stripped)
# Often items referred to with 01_01 format,
fnames = export.setdefault(stripped.lower(), set())
fnames.add(fname)
fnames = export.setdefault(sizeless.lower(), set())
fnames.add(fname)
def crop_image(img):
w, h = img.size
@@ -195,10 +195,13 @@ def get_icon_file(request):
return None
# {(h, w): source full path}
sizes = {}
for fname in fnames:
fullpath = os.path.join(export_dir, fname)
img = Image.open(fullpath)
sizes[img.size] = fullpath
for dir in dirs:
for fname in fnames:
fullpath = os.path.join(dir, fname)
if not os.path.isfile(fullpath):
continue
img = Image.open(fullpath)
sizes[img.size] = fullpath
# Try to return image which is already in necessary format
try:
fullpath = sizes[ICON_SIZE]

View File

@@ -204,6 +204,8 @@ def main(db, json_path):
split = row['iconFile'].split('_')
if len(split) == 3:
row['iconFile'] = "{}_{}".format(split[0], split[2])
if jsonName is "icons" and "modules/" in str(row["iconFile"]).lower():
row["iconFile"] = row["iconFile"].lower().replace("modules/", "").replace(".png", "")
for k, v in row.iteritems():
setattr(instance, fieldMap.get(k, k), v)