WebHost: fix is_zipfile check for flask FileStorage objects
- and assorted cleanup
This commit is contained in:
parent
a6a9989fcf
commit
80b3a5b1d4
|
@ -782,10 +782,9 @@ class RegionType(int, Enum):
|
|||
|
||||
|
||||
class Region(object):
|
||||
|
||||
def __init__(self, name: str, type: str, hint, player: int, world: Optional[MultiWorld] = None):
|
||||
def __init__(self, name: str, type_: RegionType, hint, player: int, world: Optional[MultiWorld] = None):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.type = type_
|
||||
self.entrances = []
|
||||
self.exits = []
|
||||
self.locations = []
|
||||
|
|
|
@ -100,7 +100,7 @@ def uploads():
|
|||
if file.filename == '':
|
||||
flash('No selected file')
|
||||
elif file and allowed_file(file.filename):
|
||||
if zipfile.is_zipfile(file.filename):
|
||||
if zipfile.is_zipfile(file):
|
||||
with zipfile.ZipFile(file, 'r') as zfile:
|
||||
res = upload_zip_to_db(zfile)
|
||||
if type(res) == str:
|
||||
|
|
|
@ -9,6 +9,7 @@ Utils.local_path.cached_path = file_path
|
|||
from BaseClasses import MultiWorld, CollectionState
|
||||
from worlds.alttp.Items import ItemFactory
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
world: MultiWorld
|
||||
_state_cache = {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import NamedTuple
|
||||
from typing import NamedTuple, List
|
||||
import unittest
|
||||
from worlds.AutoWorld import World
|
||||
from Fill import FillError, fill_restrictive
|
||||
|
@ -28,8 +28,8 @@ def generate_multi_world(players: int = 1) -> MultiWorld:
|
|||
class PlayerDefinition(NamedTuple):
|
||||
id: int
|
||||
menu: Region
|
||||
locations: list[Location]
|
||||
prog_items: list[Item]
|
||||
locations: List[Location]
|
||||
prog_items: List[Item]
|
||||
|
||||
|
||||
def generate_player_data(multi_world: MultiWorld, player_id: int, location_count: int, prog_item_count: int) -> PlayerDefinition:
|
||||
|
@ -40,7 +40,7 @@ def generate_player_data(multi_world: MultiWorld, player_id: int, location_count
|
|||
return PlayerDefinition(player_id, menu, locations, prog_items)
|
||||
|
||||
|
||||
def generate_locations(count: int, player_id: int, address: int = None, region: Region = None) -> list[Location]:
|
||||
def generate_locations(count: int, player_id: int, address: int = None, region: Region = None) -> List[Location]:
|
||||
locations = []
|
||||
for i in range(count):
|
||||
name = "player" + str(player_id) + "_location" + str(i)
|
||||
|
@ -50,7 +50,7 @@ def generate_locations(count: int, player_id: int, address: int = None, region:
|
|||
return locations
|
||||
|
||||
|
||||
def generate_items(count: int, player_id: int, advancement: bool = False, code: int = None) -> list[Location]:
|
||||
def generate_items(count: int, player_id: int, advancement: bool = False, code: int = None) -> List[Item]:
|
||||
items = []
|
||||
for i in range(count):
|
||||
name = "player" + str(player_id) + "_item" + str(i)
|
|
@ -4,15 +4,15 @@ from BaseClasses import MultiWorld
|
|||
from worlds.alttp.Dungeons import create_dungeons, get_dungeon_item_pool
|
||||
from worlds.alttp.EntranceShuffle import link_entrances
|
||||
from worlds.alttp.InvertedRegions import mark_dark_world_regions
|
||||
from worlds.alttp.ItemPool import difficulties, generate_itempool
|
||||
from worlds.alttp.ItemPool import difficulties
|
||||
from worlds.alttp.Items import ItemFactory
|
||||
from worlds.alttp.Regions import create_regions
|
||||
from worlds.alttp.Shops import create_shops
|
||||
from worlds.alttp.Rules import set_rules
|
||||
from test.TestBase import TestBase
|
||||
|
||||
from worlds import AutoWorld
|
||||
|
||||
|
||||
class TestMinor(TestBase):
|
||||
def setUp(self):
|
||||
self.world = MultiWorld(1)
|
||||
|
@ -30,8 +30,10 @@ class TestMinor(TestBase):
|
|||
self.world.worlds[1].create_items()
|
||||
self.world.required_medallions[1] = ['Ether', 'Quake']
|
||||
self.world.itempool.extend(get_dungeon_item_pool(self.world))
|
||||
self.world.itempool.extend(ItemFactory(['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1', 'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], 1))
|
||||
self.world.itempool.extend(ItemFactory(
|
||||
['Green Pendant', 'Red Pendant', 'Blue Pendant', 'Beat Agahnim 1', 'Beat Agahnim 2', 'Crystal 1',
|
||||
'Crystal 2', 'Crystal 3', 'Crystal 4', 'Crystal 5', 'Crystal 6', 'Crystal 7'], 1))
|
||||
self.world.get_location('Agahnim 1', 1).item = None
|
||||
self.world.get_location('Agahnim 2', 1).item = None
|
||||
mark_dark_world_regions(self.world, 1)
|
||||
self.world.worlds[1].set_rules()
|
||||
self.world.worlds[1].set_rules()
|
||||
|
|
|
@ -68,16 +68,12 @@ class HKWorld(World):
|
|||
|
||||
self.world.itempool += pool
|
||||
|
||||
|
||||
def set_rules(self):
|
||||
set_rules(self.world, self.player)
|
||||
|
||||
def create_regions(self):
|
||||
create_regions(self.world, self.player)
|
||||
|
||||
def generate_output(self):
|
||||
pass # Hollow Knight needs no output files
|
||||
|
||||
def fill_slot_data(self):
|
||||
slot_data = {}
|
||||
for option_name in self.options:
|
||||
|
|
Loading…
Reference in New Issue