Hotel support

This commit is contained in:
Emilia Allison 2024-01-11 11:23:31 -05:00
parent 4e4b9f6d1d
commit 51fa9b6409
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
3 changed files with 32 additions and 12 deletions

10
main.py
View File

@ -8,14 +8,8 @@ def main():
client = AdgClient(ADG_EXE, ADG_DIR) client = AdgClient(ADG_EXE, ADG_DIR)
cache = Cache() cache = Cache()
c1 = parser.commands[0] for command in parser.commands:
c1.execute(client, cache) command.execute(client, cache)
c2 = parser.commands[1]
c2.execute(client, cache)
c3 = parser.commands[2]
c3.execute(client, cache)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -2,7 +2,7 @@ from enum import StrEnum, auto
from adg_control import AdgClient from adg_control import AdgClient
from cache import Cache from cache import Cache
import ntpath import ntpath
from adg_control import ADG_DIR from adg_control import ADG_DIR, StorageType
class CommandType(StrEnum): class CommandType(StrEnum):
@ -24,7 +24,7 @@ class Command():
elif self.type == CommandType.NEWSYSTEM: elif self.type == CommandType.NEWSYSTEM:
self._init_system(**kwargs) self._init_system(**kwargs)
elif self.type == CommandType.HOTEL: elif self.type == CommandType.HOTEL:
pass self._init_hotel(**kwargs)
except KeyError as e: except KeyError as e:
raise Exception("Required argument not found!", e) raise Exception("Required argument not found!", e)
@ -37,7 +37,7 @@ class Command():
case CommandType.NEWSYSTEM: case CommandType.NEWSYSTEM:
self._execute_newsystem(client, cache) self._execute_newsystem(client, cache)
case CommandType.HOTEL: case CommandType.HOTEL:
pass self._execute_hotel(client, cache)
def _init_newdb(self, **kwargs): def _init_newdb(self, **kwargs):
self.name = kwargs["name"] self.name = kwargs["name"]
@ -59,6 +59,22 @@ class Command():
if "system" in kwargs: if "system" in kwargs:
self.system = kwargs["system"] self.system = kwargs["system"]
def _init_hotel(self, **kwargs):
self.name = kwargs["name"]
self.location = kwargs["location"]
self.envelope = kwargs["location"]
if "rows" in kwargs:
self.rows = int(kwargs["rows"])
if "storage_type" in kwargs:
storage_type_str = kwargs["storage_type"]
if storage_type_str in list(StorageType):
self.storage_type = StorageType(storage_type_str)
else:
raise ValueError("StorageType passed was invalid: "
+ f"{storage_type_str} not in "
+ "{RANDOM,SERIAL}")
def _init_system(self, **kwargs): def _init_system(self, **kwargs):
if "name" in kwargs: if "name" in kwargs:
self.name = kwargs["name"] self.name = kwargs["name"]
@ -99,6 +115,15 @@ class Command():
if hasattr(self, "connection_parameters") else "", if hasattr(self, "connection_parameters") else "",
system=self.system if hasattr(self, "system") else "") system=self.system if hasattr(self, "system") else "")
def _execute_hotel(self, client: AdgClient, cache: Cache):
client.create_platehotel(
self.name,
self.location,
self.envelope,
rows=self.rows if hasattr(self, "rows") else -1,
type=self.storage_type if hasattr(self, "storage_type") else None
)
class Parser(): class Parser():
def __init__(self, path: str): def __init__(self, path: str):

3
test
View File

@ -1,3 +1,4 @@
newdb;name=horsedb newdb;name=horsedb
newsystem; newsystem;
normal;name=PlateOrient 1.1;location=0;envelope=0;device=HRB.PlateOrient normal;name=PlateOrient 1.1;location=0;envelope=1;device=HRB.PlateOrient
hotel;name=PlateHotel 1.1;location=100;envelope=1;rows=8;storage_type=random