Skip to content

Commit

Permalink
Merge RosiaBaish's pull request
Browse files Browse the repository at this point in the history
Add logic to allow mods with different special characters
  • Loading branch information
redruin1 committed Jan 3, 2025
1 parent 1ff322d commit 5f87af6
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.1
* Merge RosiaBaish's pull request:
* Add logic to allow mods with different special characters

## 2.0.0
* Updated `factorio-data` to version `2.0.28` (latest)
* Updated `compatibility/defines.lua` to `2.0.28` (latest)
Expand Down
Binary file modified draftsman/data/entities.pkl
Binary file not shown.
Binary file modified draftsman/data/fluids.pkl
Binary file not shown.
Binary file modified draftsman/data/items.pkl
Binary file not shown.
Binary file modified draftsman/data/mods.pkl
Binary file not shown.
Binary file modified draftsman/data/modules.pkl
Binary file not shown.
Binary file modified draftsman/data/planets.pkl
Binary file not shown.
Binary file modified draftsman/data/recipes.pkl
Binary file not shown.
Binary file modified draftsman/data/signals.pkl
Binary file not shown.
Binary file modified draftsman/data/tiles.pkl
Binary file not shown.
22 changes: 16 additions & 6 deletions draftsman/environment/mod_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,22 @@ def register_mod(mod_name, mod_location, mod_list_json={"mods": {}}):
# If there's multiple, but one matches exactly, use that
mod_folder = folder_name
else:
# Otherwise, who knows! Fix your mods or update the wiki!
# Why do I always get the short end of the stick!?
raise IncorrectModFormatError(
"Mod archive '{}' has more than one internal folder, and "
"none of the internal folders match it's external name".format(mod_name)
)
# Try a case insensitive alphanumeric only comparison,
# and succeed if we get exactly one hit.
dirs = list(topdirs)
simplified_dirs = [re.sub(r'[^a-zA-Z0-9]', '', s).lower() for s in dirs]
simplified_foldername = re.sub(r'[^a-zA-Z0-9]', '', folder_name).lower()
if simplified_dirs.count(simplified_foldername) == 1:
# we want the original folder, so get the index.
index = simplified_dirs.index(simplified_foldername)
mod_folder = dirs[index]
else:
# Otherwise, who knows! Fix your mods or update the wiki!
# Why do I always get the short end of the stick!?
raise IncorrectModFormatError(
"Mod archive '{}' has more than one internal folder, and "
"none of the internal folders match it's external name".format(mod_name)
)

try:
# Zipfiles don't like backslashes on Windows, so we manually
Expand Down

0 comments on commit 5f87af6

Please sign in to comment.