From d53d0a77cfff807df935fe1739757191b12c5cf5 Mon Sep 17 00:00:00 2001 From: uccu Date: Tue, 17 May 2022 00:53:29 +0800 Subject: [PATCH 1/4] fix: use ruamel instead of yaml --- compose_viz/parser.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compose_viz/parser.py b/compose_viz/parser.py index 8e24687..9b4e892 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -1,7 +1,7 @@ from re import S from compose_viz.compose import Compose from compose_viz.compose import Service -import yaml +from ruamel.yaml import YAML class Parser: @@ -13,9 +13,10 @@ class Parser: # load the yaml file with open(file_path, "r") as f: try: - yaml_data = yaml.safe_load(f) - except yaml.YAMLError as exc: - raise yaml.YAMLError + yaml = YAML() + yaml_data = yaml.load(f) + except YAML.YAMLError as exc: + raise YAML.YAMLError # validate the yaml file if not yaml_data: print("Error: empty yaml file") From b86a1f7fe3fafc0f07d81a88a5bbc1406636b647 Mon Sep 17 00:00:00 2001 From: uccu Date: Tue, 17 May 2022 01:27:59 +0800 Subject: [PATCH 2/4] fix: fix parse yaml test implement --- compose_viz/parser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compose_viz/parser.py b/compose_viz/parser.py index 9b4e892..6d345fb 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -13,7 +13,7 @@ class Parser: # load the yaml file with open(file_path, "r") as f: try: - yaml = YAML() + yaml = YAML(typ='safe', pure=True) yaml_data = yaml.load(f) except YAML.YAMLError as exc: raise YAML.YAMLError @@ -33,7 +33,10 @@ class Parser: service_image = service["image"] #print("image: {}".format(service_image)) if service.get("networks"): - service_networks = service["networks"] + if(type(service["networks"]) is list): + service_networks = service["networks"] + else: + service_networks = list(service["networks"].keys()) #print("networks: {}".format(service_networks)) services.append(Service( name=service_name, From ea2bd6f50b2527cd4f29f6c4259bbc6077bb9b74 Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Tue, 17 May 2022 02:24:04 +0800 Subject: [PATCH 3/4] chore: add ruamel.yaml in dependency --- poetry.lock | 56 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index e47e55f..a3222f9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -131,6 +131,29 @@ category = "main" optional = false python-versions = ">=3.6" +[[package]] +name = "ruamel.yaml" +version = "0.17.21" +description = "ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order" +category = "main" +optional = false +python-versions = ">=3" + +[package.dependencies] +"ruamel.yaml.clib" = {version = ">=0.2.6", markers = "platform_python_implementation == \"CPython\" and python_version < \"3.11\""} + +[package.extras] +docs = ["ryd"] +jinja2 = ["ruamel.yaml.jinja2 (>=0.2)"] + +[[package]] +name = "ruamel.yaml.clib" +version = "0.2.6" +description = "C version of reader, parser and emitter for ruamel.yaml derived from libyaml" +category = "main" +optional = false +python-versions = ">=3.5" + [[package]] name = "tomli" version = "2.0.1" @@ -159,7 +182,7 @@ test = ["shellingham (>=1.3.0,<2.0.0)", "pytest (>=4.4.0,<5.4.0)", "pytest-cov ( [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "f9f303620dc1f23552238ab8cd7c4db52ef8ee897076bb941866826bc7004dfb" +content-hash = "f189e4baf985a53a0388422f970dd8c481332fe1d9f18d7d2bd06e4904c49bdf" [metadata.files] atomicwrites = [ @@ -241,6 +264,37 @@ pyyaml = [ {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, ] +"ruamel.yaml" = [ + {file = "ruamel.yaml-0.17.21-py3-none-any.whl", hash = "sha256:742b35d3d665023981bd6d16b3d24248ce5df75fdb4e2924e93a05c1f8b61ca7"}, + {file = "ruamel.yaml-0.17.21.tar.gz", hash = "sha256:8b7ce697a2f212752a35c1ac414471dc16c424c9573be4926b56ff3f5d23b7af"}, +] +"ruamel.yaml.clib" = [ + {file = "ruamel.yaml.clib-0.2.6-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:6e7be2c5bcb297f5b82fee9c665eb2eb7001d1050deaba8471842979293a80b0"}, + {file = "ruamel.yaml.clib-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:221eca6f35076c6ae472a531afa1c223b9c29377e62936f61bc8e6e8bdc5f9e7"}, + {file = "ruamel.yaml.clib-0.2.6-cp310-cp310-win32.whl", hash = "sha256:1070ba9dd7f9370d0513d649420c3b362ac2d687fe78c6e888f5b12bf8bc7bee"}, + {file = "ruamel.yaml.clib-0.2.6-cp310-cp310-win_amd64.whl", hash = "sha256:77df077d32921ad46f34816a9a16e6356d8100374579bc35e15bab5d4e9377de"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-macosx_10_6_intel.whl", hash = "sha256:cfdb9389d888c5b74af297e51ce357b800dd844898af9d4a547ffc143fa56751"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:7b2927e92feb51d830f531de4ccb11b320255ee95e791022555971c466af4527"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-win32.whl", hash = "sha256:ada3f400d9923a190ea8b59c8f60680c4ef8a4b0dfae134d2f2ff68429adfab5"}, + {file = "ruamel.yaml.clib-0.2.6-cp35-cp35m-win_amd64.whl", hash = "sha256:de9c6b8a1ba52919ae919f3ae96abb72b994dd0350226e28f3686cb4f142165c"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d67f273097c368265a7b81e152e07fb90ed395df6e552b9fa858c6d2c9f42502"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:72a2b8b2ff0a627496aad76f37a652bcef400fd861721744201ef1b45199ab78"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-win32.whl", hash = "sha256:9efef4aab5353387b07f6b22ace0867032b900d8e91674b5d8ea9150db5cae94"}, + {file = "ruamel.yaml.clib-0.2.6-cp36-cp36m-win_amd64.whl", hash = "sha256:846fc8336443106fe23f9b6d6b8c14a53d38cef9a375149d61f99d78782ea468"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0847201b767447fc33b9c235780d3aa90357d20dd6108b92be544427bea197dd"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:78988ed190206672da0f5d50c61afef8f67daa718d614377dcd5e3ed85ab4a99"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-win32.whl", hash = "sha256:a49e0161897901d1ac9c4a79984b8410f450565bbad64dbfcbf76152743a0cdb"}, + {file = "ruamel.yaml.clib-0.2.6-cp37-cp37m-win_amd64.whl", hash = "sha256:bf75d28fa071645c529b5474a550a44686821decebdd00e21127ef1fd566eabe"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a32f8d81ea0c6173ab1b3da956869114cae53ba1e9f72374032e33ba3118c233"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7f7ecb53ae6848f959db6ae93bdff1740e651809780822270eab111500842a84"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-win32.whl", hash = "sha256:89221ec6d6026f8ae859c09b9718799fea22c0e8da8b766b0b2c9a9ba2db326b"}, + {file = "ruamel.yaml.clib-0.2.6-cp38-cp38-win_amd64.whl", hash = "sha256:31ea73e564a7b5fbbe8188ab8b334393e06d997914a4e184975348f204790277"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:dc6a613d6c74eef5a14a214d433d06291526145431c3b964f5e16529b1842bed"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:1866cf2c284a03b9524a5cc00daca56d80057c5ce3cdc86a52020f4c720856f0"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-win32.whl", hash = "sha256:3fb9575a5acd13031c57a62cc7823e5d2ff8bc3835ba4d94b921b4e6ee664104"}, + {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-win_amd64.whl", hash = "sha256:825d5fccef6da42f3c8eccd4281af399f21c02b32d98e113dbc631ea6a6ecbc7"}, + {file = "ruamel.yaml.clib-0.2.6.tar.gz", hash = "sha256:4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd"}, +] tomli = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, diff --git a/pyproject.toml b/pyproject.toml index 0d33426..97d774c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ python = "^3.9" typer = "^0.4.1" PyYAML = "^6.0" graphviz = "^0.20" +"ruamel.yaml" = "^0.17.21" [tool.poetry.dev-dependencies] pytest = "^7.1.2" From 2870b43b12b70d2a97bd6786473578e33f94ef3c Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Tue, 17 May 2022 02:36:41 +0800 Subject: [PATCH 4/4] chore: add graphviz in ci/cd workflows --- .github/workflows/cd.yml | 3 ++- .github/workflows/ci.yml | 4 ++++ .github/workflows/release-tagged-version.yml | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0868300..4377be7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -14,4 +14,5 @@ jobs: - name: Build and Publish to PyPi uses: JRubics/poetry-publish@v1.10 with: - pypi_token: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file + pypi_token: ${{ secrets.PYPI_TOKEN }} + extra_build_dependency_packages: "graphviz" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c40e9d4..c7f38c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,10 @@ jobs: - name: Switch to Current Branch run: git checkout ${{ env.BRANCH }} + + - run: | + sudo apt-get update + sudo apt-get install -y graphviz - name: Setup Python 3.10.4 uses: actions/setup-python@v3 diff --git a/.github/workflows/release-tagged-version.yml b/.github/workflows/release-tagged-version.yml index 3c6d547..d10f37c 100644 --- a/.github/workflows/release-tagged-version.yml +++ b/.github/workflows/release-tagged-version.yml @@ -21,6 +21,10 @@ jobs: - name: Switch to Current Branch run: git checkout ${{ env.BRANCH }} + + - run: | + sudo apt-get update + sudo apt-get install -y graphviz - name: Setup Python 3.10.4 uses: actions/setup-python@v3