diff --git a/eva_3d/__init__.py b/eva_3d/__init__.py
index b794fd4..3dc1f76 100644
--- a/eva_3d/__init__.py
+++ b/eva_3d/__init__.py
@@ -1 +1 @@
-__version__ = '0.1.0'
+__version__ = "0.1.0"
diff --git a/eva_3d/__main__.py b/eva_3d/__main__.py
index 08436e8..ad72094 100644
--- a/eva_3d/__main__.py
+++ b/eva_3d/__main__.py
@@ -1,15 +1,51 @@
+import csv
+from pathlib import Path
+import shutil
+import zipfile
+
import click
+
@click.group()
def main():
pass
@main.command()
-@click.argument('bom-file', type=click.File('rb'))
-def parse_bom(bom_file):
+@click.argument("bom-file", type=click.File("r"))
+@click.argument("zip-file", type=click.Path(exists=True))
+@click.argument("stl-out-dir", type=click.Path())
+def unpack_stls(bom_file, zip_file, stl_out_dir):
+ files = set()
+ reader = csv.DictReader(bom_file, delimiter=",", quotechar='"')
+ for row in reader:
+ if "Material" not in row:
+ raise Exception("export a BOM with a material column")
+ if "Name" not in row:
+ raise Exception("export a BOM with a name column")
+ if row["Material"].upper() == "PETG":
+ files.add(f"{row['Name']}.stl")
+
+ stl_out_dir = Path(stl_out_dir)
+ # if Path(stl_out_dir).exists():
+ # shutil.rmtree(stl_out_dir)
+ stl_out_dir.mkdir(exist_ok=True)
+
+ with zipfile.ZipFile(zip_file, 'r') as zip_ref:
+ for file_name in zip_ref.namelist():
+ for target_file in files:
+ if target_file in file_name:
+ zip_ref.extract(file_name, stl_out_dir)
+
+ for stl_file in stl_out_dir.iterdir():
+ try:
+ new_name = stl_file.name.split(" - ")[1]
+ except IndexError:
+ continue
+ stl_file.rename(Path(stl_file.parent, new_name))
+
print("works!")
-if __name__ == '__main__':
- main(prog_name='python -m eva-3d')
+if __name__ == "__main__":
+ main(prog_name="python -m eva-3d")
diff --git a/eva_3d/bom.py b/eva_3d/bom.py
index 3f974de..3de5e4c 100644
--- a/eva_3d/bom.py
+++ b/eva_3d/bom.py
@@ -2,23 +2,46 @@
from pprint import pprint
from pathlib import Path
+
def define_env(env):
- env.variables.download_url = f'{env.conf["repo_url"]}/archive/{env.conf["version"]}.zip'
+ env.variables.download_url = (
+ f'{env.conf["repo_url"]}/archive/{env.conf["version"]}.zip'
+ )
+ # import ipdb; ipdb.set_trace()
def generate_bom_table(reader, indent_str=""):
for index, row in enumerate(reader):
+ if index != 0:
+ if row[3].upper() == "PETG":
+ row[2] = f"[{row[2]}](stls/{row[2]}.stl)"
yield "{}| {} |".format(indent_str, " | ".join(row))
if index == 0:
- yield "{}| {} |".format(indent_str, " | ".join(["-" * len(col) for col in row]))
+ yield "{}| {} |".format(
+ indent_str, " | ".join(["-" * len(col) for col in row])
+ )
@env.macro
- def bom(file_name, indent=0):
+ def bom(file_path: str, indent=0):
indent_str = " " * indent
- with open(Path(env.project_dir) / "bom" / file_name, newline='') as csvfile:
- reader = csv.reader(csvfile, delimiter=',', quotechar='"')
+ with open(Path(env.conf["docs_dir"]) / file_path, newline="") as csvfile:
+ reader = csv.reader(csvfile, delimiter=",", quotechar='"')
return "\n".join(generate_bom_table(reader, indent_str))
@env.macro
def eva_link(name):
return f'[:octicons-mark-github-16: EVA 2 / {name}]({env.conf["eva_links"][name.lower()]})'
+
+ @env.macro
+ def onshape_link(name):
+ return f'[:octicons-file-binary-24: Onshape: {name}]({env.conf["onshape"][name.lower()]})'
+
+ @env.macro
+ def doc_env():
+ return {
+ name: getattr(env, name) for name in dir(env) if not name.startswith("_")
+ }
+
+ @env.macro
+ def badge(content):
+ return f""
diff --git a/eva_3d/plugin.py b/eva_3d/plugin.py
new file mode 100644
index 0000000..3246b9b
--- /dev/null
+++ b/eva_3d/plugin.py
@@ -0,0 +1,8 @@
+from mkdocs.plugins import BasePlugin
+
+
+class EVAPlugin(BasePlugin):
+ def on_page_markdown(self, markdown, page, config, files):
+ for badge in page.meta.get("badges", []):
+ markdown = f'\n{markdown}'
+ return markdown
diff --git a/poetry.lock b/poetry.lock
index 9c33766..0379b3e 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,3 +1,12 @@
+[[package]]
+category = "dev"
+description = "Disable App Nap on OS X 10.9"
+marker = "python_version >= \"3.4\" and sys_platform == \"darwin\""
+name = "appnope"
+optional = false
+python-versions = "*"
+version = "0.1.0"
+
[[package]]
category = "dev"
description = "Atomic file writes."
@@ -21,6 +30,15 @@ docs = ["furo", "sphinx", "zope.interface"]
tests = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"]
tests_no_zope = ["coverage (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six"]
+[[package]]
+category = "dev"
+description = "Specifications for callback functions passed in to an API"
+marker = "python_version >= \"3.4\""
+name = "backcall"
+optional = false
+python-versions = "*"
+version = "0.2.0"
+
[[package]]
category = "main"
description = "Composable command line interface toolkit"
@@ -32,12 +50,94 @@ version = "7.1.2"
[[package]]
category = "dev"
description = "Cross-platform colored terminal text."
-marker = "sys_platform == \"win32\""
+marker = "python_version >= \"3.4\" and sys_platform == \"win32\" or sys_platform == \"win32\""
name = "colorama"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "0.4.4"
+[[package]]
+category = "dev"
+description = "Decorators for Humans"
+marker = "python_version >= \"3.4\""
+name = "decorator"
+optional = false
+python-versions = ">=2.6, !=3.0.*, !=3.1.*"
+version = "4.4.2"
+
+[[package]]
+category = "dev"
+description = "IPython-enabled pdb"
+name = "ipdb"
+optional = false
+python-versions = ">=2.7"
+version = "0.13.4"
+
+[package.dependencies]
+setuptools = "*"
+
+[package.dependencies.ipython]
+python = ">=3.4"
+version = ">=5.1.0"
+
+[[package]]
+category = "dev"
+description = "IPython: Productive Interactive Computing"
+marker = "python_version >= \"3.4\""
+name = "ipython"
+optional = false
+python-versions = ">=3.7"
+version = "7.19.0"
+
+[package.dependencies]
+appnope = "*"
+backcall = "*"
+colorama = "*"
+decorator = "*"
+jedi = ">=0.10"
+pexpect = ">4.3"
+pickleshare = "*"
+prompt-toolkit = ">=2.0.0,<3.0.0 || >3.0.0,<3.0.1 || >3.0.1,<3.1.0"
+pygments = "*"
+setuptools = ">=18.5"
+traitlets = ">=4.2"
+
+[package.extras]
+all = ["Sphinx (>=1.3)", "ipykernel", "ipyparallel", "ipywidgets", "nbconvert", "nbformat", "nose (>=0.10.1)", "notebook", "numpy (>=1.14)", "pygments", "qtconsole", "requests", "testpath"]
+doc = ["Sphinx (>=1.3)"]
+kernel = ["ipykernel"]
+nbconvert = ["nbconvert"]
+nbformat = ["nbformat"]
+notebook = ["notebook", "ipywidgets"]
+parallel = ["ipyparallel"]
+qtconsole = ["qtconsole"]
+test = ["nose (>=0.10.1)", "requests", "testpath", "pygments", "nbformat", "ipykernel", "numpy (>=1.14)"]
+
+[[package]]
+category = "dev"
+description = "Vestigial utilities from IPython"
+marker = "python_version >= \"3.4\""
+name = "ipython-genutils"
+optional = false
+python-versions = "*"
+version = "0.2.0"
+
+[[package]]
+category = "dev"
+description = "An autocompletion tool for Python that can be used for text editors."
+marker = "python_version >= \"3.4\""
+name = "jedi"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+version = "0.17.2"
+
+[package.dependencies]
+parso = ">=0.7.0,<0.8.0"
+
+[package.extras]
+qa = ["flake8 (3.7.9)"]
+testing = ["Django (<3.1)", "colorama", "docopt", "pytest (>=3.9.0,<5.0.0)"]
+
[[package]]
category = "dev"
description = "More routines for operating on iterables, beyond itertools"
@@ -58,6 +158,39 @@ version = "20.4"
pyparsing = ">=2.0.2"
six = "*"
+[[package]]
+category = "dev"
+description = "A Python Parser"
+marker = "python_version >= \"3.4\""
+name = "parso"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
+version = "0.7.1"
+
+[package.extras]
+testing = ["docopt", "pytest (>=3.0.7)"]
+
+[[package]]
+category = "dev"
+description = "Pexpect allows easy control of interactive console applications."
+marker = "python_version >= \"3.4\" and sys_platform != \"win32\""
+name = "pexpect"
+optional = false
+python-versions = "*"
+version = "4.8.0"
+
+[package.dependencies]
+ptyprocess = ">=0.5"
+
+[[package]]
+category = "dev"
+description = "Tiny 'shelve'-like database with concurrency support"
+marker = "python_version >= \"3.4\""
+name = "pickleshare"
+optional = false
+python-versions = "*"
+version = "0.7.5"
+
[[package]]
category = "dev"
description = "plugin and hook calling mechanisms for python"
@@ -69,6 +202,27 @@ version = "0.13.1"
[package.extras]
dev = ["pre-commit", "tox"]
+[[package]]
+category = "dev"
+description = "Library for building powerful interactive command lines in Python"
+marker = "python_version >= \"3.4\""
+name = "prompt-toolkit"
+optional = false
+python-versions = ">=3.6.1"
+version = "3.0.8"
+
+[package.dependencies]
+wcwidth = "*"
+
+[[package]]
+category = "dev"
+description = "Run a subprocess in a pseudo terminal"
+marker = "python_version >= \"3.4\" and sys_platform != \"win32\""
+name = "ptyprocess"
+optional = false
+python-versions = "*"
+version = "0.6.0"
+
[[package]]
category = "dev"
description = "library with cross-python path, ini-parsing, io, code, log facilities"
@@ -77,6 +231,15 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "1.9.0"
+[[package]]
+category = "dev"
+description = "Pygments is a syntax highlighting package written in Python."
+marker = "python_version >= \"3.4\""
+name = "pygments"
+optional = false
+python-versions = ">=3.5"
+version = "2.7.2"
+
[[package]]
category = "dev"
description = "Python parsing module"
@@ -115,6 +278,21 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
version = "1.15.0"
+[[package]]
+category = "dev"
+description = "Traitlets Python configuration system"
+marker = "python_version >= \"3.4\""
+name = "traitlets"
+optional = false
+python-versions = ">=3.7"
+version = "5.0.5"
+
+[package.dependencies]
+ipython-genutils = "*"
+
+[package.extras]
+test = ["pytest"]
+
[[package]]
category = "dev"
description = "Measures the displayed width of unicode strings in a terminal"
@@ -124,11 +302,15 @@ python-versions = "*"
version = "0.2.5"
[metadata]
-content-hash = "03a7877df5df1c9feba6ceab80038b667a90ebecb8f328fc75ad58d516dddddd"
+content-hash = "6ef46f8dfc7f476b5e0a0ce58ef14d0b5a9cff37d39e88a64b741d4163176e43"
lock-version = "1.0"
python-versions = "^3.8"
[metadata.files]
+appnope = [
+ {file = "appnope-0.1.0-py2.py3-none-any.whl", hash = "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0"},
+ {file = "appnope-0.1.0.tar.gz", hash = "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71"},
+]
atomicwrites = [
{file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"},
{file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"},
@@ -137,6 +319,10 @@ attrs = [
{file = "attrs-20.3.0-py2.py3-none-any.whl", hash = "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6"},
{file = "attrs-20.3.0.tar.gz", hash = "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700"},
]
+backcall = [
+ {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"},
+ {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"},
+]
click = [
{file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"},
{file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"},
@@ -145,6 +331,25 @@ colorama = [
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
]
+decorator = [
+ {file = "decorator-4.4.2-py2.py3-none-any.whl", hash = "sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760"},
+ {file = "decorator-4.4.2.tar.gz", hash = "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"},
+]
+ipdb = [
+ {file = "ipdb-0.13.4.tar.gz", hash = "sha256:c85398b5fb82f82399fc38c44fe3532c0dde1754abee727d8f5cfcc74547b334"},
+]
+ipython = [
+ {file = "ipython-7.19.0-py3-none-any.whl", hash = "sha256:c987e8178ced651532b3b1ff9965925bfd445c279239697052561a9ab806d28f"},
+ {file = "ipython-7.19.0.tar.gz", hash = "sha256:cbb2ef3d5961d44e6a963b9817d4ea4e1fa2eb589c371a470fed14d8d40cbd6a"},
+]
+ipython-genutils = [
+ {file = "ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8"},
+ {file = "ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"},
+]
+jedi = [
+ {file = "jedi-0.17.2-py2.py3-none-any.whl", hash = "sha256:98cc583fa0f2f8304968199b01b6b4b94f469a1f4a74c1560506ca2a211378b5"},
+ {file = "jedi-0.17.2.tar.gz", hash = "sha256:86ed7d9b750603e4ba582ea8edc678657fb4007894a12bcf6f4bb97892f31d20"},
+]
more-itertools = [
{file = "more-itertools-8.6.0.tar.gz", hash = "sha256:b3a9005928e5bed54076e6e549c792b306fddfe72b2d1d22dd63d42d5d3899cf"},
{file = "more_itertools-8.6.0-py3-none-any.whl", hash = "sha256:8e1a2a43b2f2727425f2b5839587ae37093f19153dc26c0927d1048ff6557330"},
@@ -153,14 +358,38 @@ packaging = [
{file = "packaging-20.4-py2.py3-none-any.whl", hash = "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"},
{file = "packaging-20.4.tar.gz", hash = "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"},
]
+parso = [
+ {file = "parso-0.7.1-py2.py3-none-any.whl", hash = "sha256:97218d9159b2520ff45eb78028ba8b50d2bc61dcc062a9682666f2dc4bd331ea"},
+ {file = "parso-0.7.1.tar.gz", hash = "sha256:caba44724b994a8a5e086460bb212abc5a8bc46951bf4a9a1210745953622eb9"},
+]
+pexpect = [
+ {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"},
+ {file = "pexpect-4.8.0.tar.gz", hash = "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"},
+]
+pickleshare = [
+ {file = "pickleshare-0.7.5-py2.py3-none-any.whl", hash = "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56"},
+ {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"},
+]
pluggy = [
{file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"},
{file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"},
]
+prompt-toolkit = [
+ {file = "prompt_toolkit-3.0.8-py3-none-any.whl", hash = "sha256:7debb9a521e0b1ee7d2fe96ee4bd60ef03c6492784de0547337ca4433e46aa63"},
+ {file = "prompt_toolkit-3.0.8.tar.gz", hash = "sha256:25c95d2ac813909f813c93fde734b6e44406d1477a9faef7c915ff37d39c0a8c"},
+]
+ptyprocess = [
+ {file = "ptyprocess-0.6.0-py2.py3-none-any.whl", hash = "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"},
+ {file = "ptyprocess-0.6.0.tar.gz", hash = "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0"},
+]
py = [
{file = "py-1.9.0-py2.py3-none-any.whl", hash = "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2"},
{file = "py-1.9.0.tar.gz", hash = "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"},
]
+pygments = [
+ {file = "Pygments-2.7.2-py3-none-any.whl", hash = "sha256:88a0bbcd659fcb9573703957c6b9cff9fab7295e6e76db54c9d00ae42df32773"},
+ {file = "Pygments-2.7.2.tar.gz", hash = "sha256:381985fcc551eb9d37c52088a32914e00517e57f4a21609f48141ba08e193fa0"},
+]
pyparsing = [
{file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"},
{file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"},
@@ -173,6 +402,10 @@ six = [
{file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
{file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
]
+traitlets = [
+ {file = "traitlets-5.0.5-py3-none-any.whl", hash = "sha256:69ff3f9d5351f31a7ad80443c2674b7099df13cc41fc5fa6e2f6d3b0330b0426"},
+ {file = "traitlets-5.0.5.tar.gz", hash = "sha256:178f4ce988f69189f7e523337a3e11d91c786ded9360174a3d9ca83e79bc5396"},
+]
wcwidth = [
{file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"},
{file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"},
diff --git a/pyproject.toml b/pyproject.toml
index 173a281..4acc197 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,18 +1,22 @@
[tool.poetry]
name = "eva-3d"
-version = "0.1.0"
+version = "0.1.3"
description = ""
authors = ["Paweł Kucmus "]
[tool.poetry.scripts]
eva-3d = 'eva_3d.__main__:main'
+[tool.poetry.plugins."mkdocs.plugins"]
+eva-3d-plugin = 'eva_3d.plugin:EVAPlugin'
+
[tool.poetry.dependencies]
python = "^3.8"
click = "^7.1.2"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
+ipdb = "^0.13.4"
[build-system]
requires = ["poetry>=0.12"]
diff --git a/tests/test_eva_docs_builder.py b/tests/test_eva_docs_builder.py
index 74c6d5e..2a7292b 100644
--- a/tests/test_eva_docs_builder.py
+++ b/tests/test_eva_docs_builder.py
@@ -2,4 +2,4 @@
def test_version():
- assert __version__ == '0.1.0'
+ assert __version__ == "0.1.0"