From 3dd3f9ab074fe6bc60012fac874173f3c3c6468d Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Thu, 19 Aug 2021 19:20:31 +0000 Subject: [PATCH] Rename "game" to "gamecode" in Model class, to be more accurate. --- bemani/backend/base.py | 8 ++++---- bemani/backend/bishi/factory.py | 6 +++--- bemani/backend/ddr/factory.py | 14 +++++++------- bemani/backend/iidx/factory.py | 14 +++++++------- bemani/backend/jubeat/factory.py | 14 +++++++------- bemani/backend/museca/factory.py | 6 +++--- bemani/backend/popn/factory.py | 20 ++++++++++---------- bemani/backend/reflec/factory.py | 12 ++++++------ bemani/backend/sdvx/factory.py | 8 ++++---- bemani/common/model.py | 18 +++++++++--------- 10 files changed, 60 insertions(+), 60 deletions(-) diff --git a/bemani/backend/base.py b/bemani/backend/base.py index edb90e1..05d445a 100644 --- a/bemani/backend/base.py +++ b/bemani/backend/base.py @@ -157,15 +157,15 @@ class Base: this model. Its possible to return None from this function if a registered game has no way of handling this particular modelstring. """ - if model.game not in cls.__registered_games: + if model.gamecode not in cls.__registered_games: # Return just this base model, which will provide nothing return Base(data, config, model) else: # Return the registered module providing this game - return cls.__registered_games[model.game].create(data, config, model, parentmodel=parentmodel) + return cls.__registered_games[model.gamecode].create(data, config, model, parentmodel=parentmodel) @classmethod - def register(cls, game: str, handler: Type[Factory]) -> None: + def register(cls, gamecode: str, handler: Type[Factory]) -> None: """ Register a factory to handle a game. Note that the game should be the game code as returned by a game, such as "LDJ" or "MDX". @@ -174,7 +174,7 @@ class Base: game - 3-character string identifying a game handler - A factory which has a create() method that can spawn game classes. """ - cls.__registered_games[game] = handler + cls.__registered_games[gamecode] = handler cls.__registered_handlers.add(handler) @classmethod diff --git a/bemani/backend/bishi/factory.py b/bemani/backend/bishi/factory.py index f32620e..af17c72 100644 --- a/bemani/backend/bishi/factory.py +++ b/bemani/backend/bishi/factory.py @@ -14,13 +14,13 @@ class BishiBashiFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['IBB']: - Base.register(game, BishiBashiFactory) + for gamecode in ['IBB']: + Base.register(gamecode, BishiBashiFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: - if model.game == 'IBB': + if model.gamecode == 'IBB': return TheStarBishiBashi(data, config, model) # Unknown game version diff --git a/bemani/backend/ddr/factory.py b/bemani/backend/ddr/factory.py index 8ef0b02..685f57b 100644 --- a/bemani/backend/ddr/factory.py +++ b/bemani/backend/ddr/factory.py @@ -48,8 +48,8 @@ class DDRFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['HDX', 'JDX', 'KDX', 'MDX']: - Base.register(game, DDRFactory) + for gamecode in ['HDX', 'JDX', 'KDX', 'MDX']: + Base.register(gamecode, DDRFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -65,20 +65,20 @@ class DDRFactory(Factory): return VersionConstants.DDR_A20 return None - if model.game == 'HDX': + if model.gamecode == 'HDX': return DDRX(data, config, model) - if model.game == 'JDX': + if model.gamecode == 'JDX': return DDRX2(data, config, model) - if model.game == 'KDX': + if model.gamecode == 'KDX': return DDRX3(data, config, model) - if model.game == 'MDX': + if model.gamecode == 'MDX': if model.version is None: if parentmodel is None: return None # We have no way to tell apart newer versions. However, we can make # an educated guess if we happen to be summoned for old profile lookup. - if parentmodel.game not in ['HDX', 'JDX', 'KDX', 'MDX']: + if parentmodel.gamecode not in ['HDX', 'JDX', 'KDX', 'MDX']: return None parentversion = version_from_date(parentmodel.version) diff --git a/bemani/backend/iidx/factory.py b/bemani/backend/iidx/factory.py index 9e16382..c12e911 100644 --- a/bemani/backend/iidx/factory.py +++ b/bemani/backend/iidx/factory.py @@ -70,8 +70,8 @@ class IIDXFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['JDJ', 'JDZ', 'KDZ', 'LDJ']: - Base.register(game, IIDXFactory) + for gamecode in ['JDJ', 'JDZ', 'KDZ', 'LDJ']: + Base.register(gamecode, IIDXFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -97,20 +97,20 @@ class IIDXFactory(Factory): return VersionConstants.IIDX_BISTROVER return None - if model.game == 'JDJ': + if model.gamecode == 'JDJ': return IIDXSirius(data, config, model) - if model.game == 'JDZ': + if model.gamecode == 'JDZ': return IIDXResortAnthem(data, config, model) - if model.game == 'KDZ': + if model.gamecode == 'KDZ': return IIDXLincle(data, config, model) - if model.game == 'LDJ': + if model.gamecode == 'LDJ': if model.version is None: if parentmodel is None: return None # We have no way to tell apart newer versions. However, we can make # an educated guess if we happen to be summoned for old profile lookup. - if parentmodel.game not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']: + if parentmodel.gamecode not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']: return None parentversion = version_from_date(parentmodel.version) if parentversion == VersionConstants.IIDX_SPADA: diff --git a/bemani/backend/jubeat/factory.py b/bemani/backend/jubeat/factory.py index 46a2d55..27b8c41 100644 --- a/bemani/backend/jubeat/factory.py +++ b/bemani/backend/jubeat/factory.py @@ -40,29 +40,29 @@ class JubeatFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['H44', 'I44', 'J44', 'K44', 'L44']: - Base.register(game, JubeatFactory) + for gamecode in ['H44', 'I44', 'J44', 'K44', 'L44']: + Base.register(gamecode, JubeatFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: - if model.game == 'H44': + if model.gamecode == 'H44': return Jubeat(data, config, model) - if model.game == 'I44': + if model.gamecode == 'I44': if model.version >= 2010031800: return JubeatRipplesAppend(data, config, model) else: return JubeatRipples(data, config, model) - if model.game == 'J44': + if model.gamecode == 'J44': if model.version >= 2011032300: return JubeatKnitAppend(data, config, model) else: return JubeatKnit(data, config, model) - if model.game == 'K44': + if model.gamecode == 'K44': if model.version >= 2012031400: return JubeatCopiousAppend(data, config, model) else: return JubeatCopious(data, config, model) - if model.game == 'L44': + if model.gamecode == 'L44': if model.version <= 2014022400: return JubeatSaucer(data, config, model) if model.version >= 2014030300 and model.version < 2015022000: diff --git a/bemani/backend/museca/factory.py b/bemani/backend/museca/factory.py index 924b420..b6e521b 100644 --- a/bemani/backend/museca/factory.py +++ b/bemani/backend/museca/factory.py @@ -16,8 +16,8 @@ class MusecaFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['PIX']: - Base.register(game, MusecaFactory) + for gamecode in ['PIX']: + Base.register(gamecode, MusecaFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -29,7 +29,7 @@ class MusecaFactory(Factory): return VersionConstants.MUSECA_1_PLUS return None - if model.game == 'PIX': + if model.gamecode == 'PIX': version = version_from_date(model.version) if version == VersionConstants.MUSECA: return Museca1(data, config, model) diff --git a/bemani/backend/popn/factory.py b/bemani/backend/popn/factory.py index 6c3bb74..1342be7 100644 --- a/bemani/backend/popn/factory.py +++ b/bemani/backend/popn/factory.py @@ -64,8 +64,8 @@ class PopnMusicFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']: - Base.register(game, PopnMusicFactory) + for gamecode in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']: + Base.register(gamecode, PopnMusicFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -83,26 +83,26 @@ class PopnMusicFactory(Factory): return VersionConstants.POPN_MUSIC_PEACE return None - if model.game == 'G15': + if model.gamecode == 'G15': return PopnMusicAdventure(data, config, model) - if model.game == 'H16': + if model.gamecode == 'H16': return PopnMusicParty(data, config, model) - if model.game == 'I17': + if model.gamecode == 'I17': return PopnMusicTheMovie(data, config, model) - if model.game == 'J39': + if model.gamecode == 'J39': return PopnMusicSengokuRetsuden(data, config, model) - if model.game == 'K39': + if model.gamecode == 'K39': return PopnMusicTuneStreet(data, config, model) - if model.game == 'L39': + if model.gamecode == 'L39': return PopnMusicFantasia(data, config, model) - if model.game == 'M39': + if model.gamecode == 'M39': if model.version is None: if parentmodel is None: return None # We have no way to tell apart newer versions. However, we can make # an educated guess if we happen to be summoned for old profile lookup. - if parentmodel.game not in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']: + if parentmodel.gamecode not in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']: return None parentversion = version_from_date(parentmodel.version) if parentversion == VersionConstants.POPN_MUSIC_LAPISTORIA: diff --git a/bemani/backend/reflec/factory.py b/bemani/backend/reflec/factory.py index 6fdf9c4..8970ebb 100644 --- a/bemani/backend/reflec/factory.py +++ b/bemani/backend/reflec/factory.py @@ -24,8 +24,8 @@ class ReflecBeatFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['KBR', 'LBR', 'MBR']: - Base.register(game, ReflecBeatFactory) + for gamecode in ['KBR', 'LBR', 'MBR']: + Base.register(gamecode, ReflecBeatFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -43,16 +43,16 @@ class ReflecBeatFactory(Factory): return VersionConstants.REFLEC_BEAT_REFLESIA return None - if model.game == 'KBR': + if model.gamecode == 'KBR': return ReflecBeat(data, config, model) - if model.game == 'LBR': + if model.gamecode == 'LBR': return ReflecBeatLimelight(data, config, model) - if model.game == 'MBR': + if model.gamecode == 'MBR': if model.version is None: if parentmodel is None: return None - if parentmodel.game not in ['KBR', 'LBR', 'MBR']: + if parentmodel.gamecode not in ['KBR', 'LBR', 'MBR']: return None parentversion = version_from_date(parentmodel.version) if parentversion == VersionConstants.REFLEC_BEAT_COLETTE: diff --git a/bemani/backend/sdvx/factory.py b/bemani/backend/sdvx/factory.py index 8da7bdf..1f10d29 100644 --- a/bemani/backend/sdvx/factory.py +++ b/bemani/backend/sdvx/factory.py @@ -22,8 +22,8 @@ class SoundVoltexFactory(Factory): @classmethod def register_all(cls) -> None: - for game in ['KFC']: - Base.register(game, SoundVoltexFactory) + for gamecode in ['KFC']: + Base.register(gamecode, SoundVoltexFactory) @classmethod def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]: @@ -39,14 +39,14 @@ class SoundVoltexFactory(Factory): return VersionConstants.SDVX_HEAVENLY_HAVEN return None - if model.game == 'KFC': + if model.gamecode == 'KFC': if model.version is None: if parentmodel is None: return None # We have no way to tell apart newer versions. However, we can make # an educated guess if we happen to be summoned for old profile lookup. - if parentmodel.game != 'KFC': + if parentmodel.gamecode != 'KFC': return None parentversion = version_from_date(parentmodel.version) diff --git a/bemani/common/model.py b/bemani/common/model.py index e011ae3..0631567 100644 --- a/bemani/common/model.py +++ b/bemani/common/model.py @@ -6,19 +6,19 @@ class Model: Object representing a parsed Model String. """ - def __init__(self, game: str, dest: str, spec: str, rev: str, version: Optional[int]) -> None: + def __init__(self, gamecode: str, dest: str, spec: str, rev: str, version: Optional[int]) -> None: """ Initialize a Model object. Parameters: - game - Game code (such as LDJ) + gamecode - Game code (such as LDJ) dest - Destination region for the game (such as J) spec - Spec for the game (such as A) rev - Revision of the game (such as A) version - Integer representing version, usually in the form of YYYYMMDDXX where YYYY is a year, MM is a month, DD is a day and XX is sub-day versioning. """ - self.game = game + self.gamecode = gamecode self.dest = dest self.spec = spec self.rev = rev @@ -38,15 +38,15 @@ class Model: """ parts = model.split(':') if len(parts) == 5: - game, dest, spec, rev, version = parts - return Model(game, dest, spec, rev, int(version)) + gamecode, dest, spec, rev, version = parts + return Model(gamecode, dest, spec, rev, int(version)) elif len(parts) == 4: - game, dest, spec, rev = parts - return Model(game, dest, spec, rev, None) + gamecode, dest, spec, rev = parts + return Model(gamecode, dest, spec, rev, None) raise Exception(f'Couldn\'t parse model {model}') def __str__(self) -> str: if self.version is None: - return f'{self.game}:{self.dest}:{self.spec}:{self.rev}' + return f'{self.gamecode}:{self.dest}:{self.spec}:{self.rev}' else: - return f'{self.game}:{self.dest}:{self.spec}:{self.rev}:{self.version}' + return f'{self.gamecode}:{self.dest}:{self.spec}:{self.rev}:{self.version}'