chore: apply pre-commit hooks
This commit is contained in:
parent
603b9cb299
commit
a58e2c3af0
1 changed files with 15 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Optional
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
@ -6,6 +6,7 @@ from compose_viz.compose import Compose, Service
|
|||
from compose_viz.extends import Extends
|
||||
from compose_viz.volume import Volume, VolumeType
|
||||
|
||||
|
||||
class Parser:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
@ -25,7 +26,6 @@ class Parser:
|
|||
raise RuntimeError("No services found, aborting.")
|
||||
|
||||
# parse services data into Service objects
|
||||
services_data = yaml_data["services"]
|
||||
services = self.parse_service_data(yaml_data["services"])
|
||||
|
||||
# create Compose object
|
||||
|
@ -33,8 +33,8 @@ class Parser:
|
|||
|
||||
return compose
|
||||
|
||||
def parse_service_data(self, services_yaml_data: List):
|
||||
services = []
|
||||
def parse_service_data(self, services_yaml_data: Dict[str, dict]) -> List[Service]:
|
||||
services: List[Service] = []
|
||||
for service, service_name in zip(services_yaml_data.values(), services_yaml_data.keys()):
|
||||
|
||||
service_image: Optional[str] = None
|
||||
|
@ -43,7 +43,6 @@ class Parser:
|
|||
elif service.get("build"):
|
||||
service_image = "build from " + service["build"]
|
||||
|
||||
|
||||
service_networks: List[str] = []
|
||||
if service.get("networks"):
|
||||
if type(service["networks"]) is list:
|
||||
|
@ -51,12 +50,10 @@ class Parser:
|
|||
else:
|
||||
service_networks = list(service["networks"].keys())
|
||||
|
||||
|
||||
service_extends: Optional[Extends] = None
|
||||
if service.get("extends"):
|
||||
service_extends = Extends(service_name=service["extends"]["service"])
|
||||
|
||||
|
||||
service_ports: List[str] = []
|
||||
if service.get("ports"):
|
||||
service_ports = service["ports"]
|
||||
|
@ -92,7 +89,7 @@ class Parser:
|
|||
ports=service_ports,
|
||||
depends_on=service_depends_on,
|
||||
volumes=service_volumes,
|
||||
links=service_links
|
||||
links=service_links,
|
||||
)
|
||||
)
|
||||
# Service print debug
|
||||
|
@ -105,5 +102,4 @@ class Parser:
|
|||
# print("ports: {}".format(service_ports))
|
||||
# print("depends: {}".format(service_depends_on))
|
||||
|
||||
|
||||
return services
|
||||
|
|
Loading…
Reference in a new issue