L0laapk3 / FactorioMaps

L0laapk3's FactorioMaps mod
https://mods.factorio.com/mod/L0laapk3_FactorioMaps
Other
118 stars 22 forks source link

doesn't work with folder names that don't have a version in them. #99

Closed suisseWalter closed 1 year ago

suisseWalter commented 3 years ago

many newer mods don't have their version number included in the Folder name. If it deosn't find it it just crashes outright once it tires to fetch icons.

saulrh commented 3 years ago

Can confirm this bug. Backtrace:

Disabling FactorioMaps mod
Traceback (most recent call last):
  File "auto.py", line 880, in <module>
    auto(*sys.argv[1:])
  File "auto.py", line 804, in auto
    zipInfo = zipObj.getinfo(os.path.join(mod[2], icon + ".png").replace('\\', '/'))
  File "/usr/lib/python3.8/zipfile.py", line 1441, in getinfo
    raise KeyError(
KeyError: "There is no item named 'space-exploration-graphics_0.5.10/graphics/icons/astronomic/planet-small.png' in the archive"
MysticMia commented 1 year ago

I made a temporary workaround for myself by removing the version from the name if it crashes, by removing everything after the underscore. It won't work in all cases, probably, because it would trigger falsely if it crashes and someone put multiple underscores in their name, but anyway:

replace: zipInfo = zipObj.getinfo(os.path.join(mod[2], icon + ".png").replace('\', '/')) with:

                                try:
                                    zipInfo = zipObj.getinfo(os.path.join(mod[2], icon + ".png").replace('\\', '/'))
                                except KeyError:
                                    print(mod[2])
                                    tempName = os.path.join(mod[2], icon + ".png").replace('\\', '/')
                                    temptemp = tempName.split("/")
                                    temptemp[0] = temptemp[0].split("_")[0]
                                    tempName = '/'.join(temptemp)
                                    zipInfo = zipObj.getinfo(tempName)