Hotel support
This commit is contained in:
parent
4e4b9f6d1d
commit
51fa9b6409
10
main.py
10
main.py
|
@ -8,14 +8,8 @@ def main():
|
|||
client = AdgClient(ADG_EXE, ADG_DIR)
|
||||
cache = Cache()
|
||||
|
||||
c1 = parser.commands[0]
|
||||
c1.execute(client, cache)
|
||||
|
||||
c2 = parser.commands[1]
|
||||
c2.execute(client, cache)
|
||||
|
||||
c3 = parser.commands[2]
|
||||
c3.execute(client, cache)
|
||||
for command in parser.commands:
|
||||
command.execute(client, cache)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
31
parser.py
31
parser.py
|
@ -2,7 +2,7 @@ from enum import StrEnum, auto
|
|||
from adg_control import AdgClient
|
||||
from cache import Cache
|
||||
import ntpath
|
||||
from adg_control import ADG_DIR
|
||||
from adg_control import ADG_DIR, StorageType
|
||||
|
||||
|
||||
class CommandType(StrEnum):
|
||||
|
@ -24,7 +24,7 @@ class Command():
|
|||
elif self.type == CommandType.NEWSYSTEM:
|
||||
self._init_system(**kwargs)
|
||||
elif self.type == CommandType.HOTEL:
|
||||
pass
|
||||
self._init_hotel(**kwargs)
|
||||
except KeyError as e:
|
||||
raise Exception("Required argument not found!", e)
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Command():
|
|||
case CommandType.NEWSYSTEM:
|
||||
self._execute_newsystem(client, cache)
|
||||
case CommandType.HOTEL:
|
||||
pass
|
||||
self._execute_hotel(client, cache)
|
||||
|
||||
def _init_newdb(self, **kwargs):
|
||||
self.name = kwargs["name"]
|
||||
|
@ -59,6 +59,22 @@ class Command():
|
|||
if "system" in kwargs:
|
||||
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):
|
||||
if "name" in kwargs:
|
||||
self.name = kwargs["name"]
|
||||
|
@ -99,6 +115,15 @@ class Command():
|
|||
if hasattr(self, "connection_parameters") 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():
|
||||
def __init__(self, path: str):
|
||||
|
|
Loading…
Reference in New Issue