From 3af5a0143fd735832ce64ba4e4382df55b9abde9 Mon Sep 17 00:00:00 2001 From: Brendan Haines Date: Mon, 20 Sep 2021 22:23:11 -0600 Subject: [PATCH] add autoformatting --- scripting/plugins/BomGeneration/Pipfile | 10 +- scripting/plugins/BomGeneration/Pipfile.lock | 235 +++++++++++-------- scripting/plugins/BomGeneration/jlcparts.py | 32 +-- 3 files changed, 148 insertions(+), 129 deletions(-) diff --git a/scripting/plugins/BomGeneration/Pipfile b/scripting/plugins/BomGeneration/Pipfile index 012a696..6ce7190 100644 --- a/scripting/plugins/BomGeneration/Pipfile +++ b/scripting/plugins/BomGeneration/Pipfile @@ -5,11 +5,15 @@ verify_ssl = true [dev-packages] ipykernel = "*" +black = "*" +ipython = "*" +flake8 = "*" [packages] pandas = "*" -ipython = "*" -cd = "*" [requires] -python_version = "3.9" +python_version = "3.8" + +[pipenv] +allow_prereleases = true diff --git a/scripting/plugins/BomGeneration/Pipfile.lock b/scripting/plugins/BomGeneration/Pipfile.lock index 2518f6d..d8af987 100644 --- a/scripting/plugins/BomGeneration/Pipfile.lock +++ b/scripting/plugins/BomGeneration/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "b7f9628500cff02cd272604cb5a8452caf705baa242e4d7e49e941dae4916a4b" + "sha256": "39582fc55c61462e40925de792f972373f2ca2988710293e5747ad8c059270cc" }, "pipfile-spec": 6, "requires": { - "python_version": "3.9" + "python_version": "3.8" }, "sources": [ { @@ -16,45 +16,6 @@ ] }, "default": { - "backcall": { - "hashes": [ - "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e", - "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255" - ], - "version": "==0.2.0" - }, - "decorator": { - "hashes": [ - "sha256:7b12e7c3c6ab203a29e157335e9122cb03de9ab7264b137594103fd4a683b374", - "sha256:e59913af105b9860aa2c8d3272d9de5a56a4e608db9a2f167a8480b323d529a7" - ], - "markers": "python_version >= '3.5'", - "version": "==5.1.0" - }, - "ipython": { - "hashes": [ - "sha256:58b55ebfdfa260dad10d509702dc2857cb25ad82609506b070cf2d7b7df5af13", - "sha256:75b5e060a3417cf64f138e0bb78e58512742c57dc29db5a5058a2b1f0c10df02" - ], - "index": "pypi", - "version": "==7.27.0" - }, - "jedi": { - "hashes": [ - "sha256:18456d83f65f400ab0c2d3319e48520420ef43b23a086fdc05dff34132f0fb93", - "sha256:92550a404bad8afed881a137ec9a461fed49eca661414be45059329614ed0707" - ], - "markers": "python_version >= '3.6'", - "version": "==0.18.0" - }, - "matplotlib-inline": { - "hashes": [ - "sha256:a04bfba22e0d1395479f866853ec1ee28eea1485c1d69a6faf00dc3e24ff34ee", - "sha256:aed605ba3b72462d64d475a21a9296f400a19c4f74a31b59103d2a99ffd5aa5c" - ], - "markers": "python_version >= '3.5'", - "version": "==0.1.3" - }, "numpy": { "hashes": [ "sha256:09858463db6dd9f78b2a1a05c93f3b33d4f65975771e90d2cf7aadb7c2f66edf", @@ -118,52 +79,6 @@ "index": "pypi", "version": "==1.3.3" }, - "parso": { - "hashes": [ - "sha256:12b83492c6239ce32ff5eed6d3639d6a536170723c6f3f1506869f1ace413398", - "sha256:a8c4922db71e4fdb90e0d0bc6e50f9b273d3397925e5e60a717e719201778d22" - ], - "markers": "python_version >= '3.6'", - "version": "==0.8.2" - }, - "pexpect": { - "hashes": [ - "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937", - "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c" - ], - "markers": "sys_platform != 'win32'", - "version": "==4.8.0" - }, - "pickleshare": { - "hashes": [ - "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", - "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" - ], - "version": "==0.7.5" - }, - "prompt-toolkit": { - "hashes": [ - "sha256:6076e46efae19b1e0ca1ec003ed37a933dc94b4d20f486235d436e64771dcd5c", - "sha256:eb71d5a6b72ce6db177af4a7d4d7085b99756bf656d98ffcc4fecd36850eea6c" - ], - "markers": "python_full_version >= '3.6.2'", - "version": "==3.0.20" - }, - "ptyprocess": { - "hashes": [ - "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", - "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220" - ], - "version": "==0.7.0" - }, - "pygments": { - "hashes": [ - "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380", - "sha256:f398865f7eb6874156579fdf36bc840a03cab64d1cde9e93d68f46a425ec52c6" - ], - "markers": "python_version >= '3.5'", - "version": "==2.10.0" - }, "python-dateutil": { "hashes": [ "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", @@ -186,21 +101,6 @@ ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.16.0" - }, - "traitlets": { - "hashes": [ - "sha256:03f172516916220b58c9f19d7f854734136dd9528103d04e9bf139a92c9f54c4", - "sha256:bd382d7ea181fbbcce157c133db9a829ce06edffe097bcf3ab945b435452b46d" - ], - "markers": "python_version >= '3.7'", - "version": "==5.1.0" - }, - "wcwidth": { - "hashes": [ - "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784", - "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83" - ], - "version": "==0.2.5" } }, "develop": { @@ -211,6 +111,22 @@ ], "version": "==0.2.0" }, + "black": { + "hashes": [ + "sha256:380f1b5da05e5a1429225676655dddb96f5ae8c75bdf91e53d798871b902a115", + "sha256:7de4cfc7eb6b710de325712d40125689101d21d25283eed7e9998722cf10eb91" + ], + "index": "pypi", + "version": "==21.9b0" + }, + "click": { + "hashes": [ + "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a", + "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6" + ], + "markers": "python_version >= '3.6'", + "version": "==8.0.1" + }, "debugpy": { "hashes": [ "sha256:0c523fcbb6fb395403ee8508853767b74949335d5cdacc9f83d350670c2c0db2", @@ -251,6 +167,14 @@ "markers": "python_version >= '2.7'", "version": "==0.3" }, + "flake8": { + "hashes": [ + "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b", + "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907" + ], + "index": "pypi", + "version": "==3.9.2" + }, "ipykernel": { "hashes": [ "sha256:a3f6c2dda2ecf63b37446808a70ed825fea04790779ca524889c596deae0def8", @@ -306,6 +230,20 @@ "markers": "python_version >= '3.5'", "version": "==0.1.3" }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, "nest-asyncio": { "hashes": [ "sha256:76d6e972265063fe92a90b9cc4fb82616e07d586b346ed9d2c89a4187acea39c", @@ -322,6 +260,13 @@ "markers": "python_version >= '3.6'", "version": "==0.8.2" }, + "pathspec": { + "hashes": [ + "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a", + "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1" + ], + "version": "==0.9.0" + }, "pexpect": { "hashes": [ "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937", @@ -337,6 +282,14 @@ ], "version": "==0.7.5" }, + "platformdirs": { + "hashes": [ + "sha256:15b056538719b1c94bdaccb29e5f81879c7f7f0f4a153f46086d155dffcd4f0f", + "sha256:8003ac87717ae2c7ee1ea5a84a1a61e87f3fbd16eb5aadba194ea30a9019f648" + ], + "markers": "python_version >= '3.6'", + "version": "==2.3.0" + }, "prompt-toolkit": { "hashes": [ "sha256:6076e46efae19b1e0ca1ec003ed37a933dc94b4d20f486235d436e64771dcd5c", @@ -352,6 +305,22 @@ ], "version": "==0.7.0" }, + "pycodestyle": { + "hashes": [ + "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", + "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.7.0" + }, + "pyflakes": { + "hashes": [ + "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", + "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.3.1" + }, "pygments": { "hashes": [ "sha256:b8e67fe6af78f492b3c4b3e2970c0624cbf08beb1e493b2c99b9fa1b67a20380", @@ -411,6 +380,52 @@ "markers": "python_version >= '3.6'", "version": "==22.3.0" }, + "regex": { + "hashes": [ + "sha256:04f6b9749e335bb0d2f68c707f23bb1773c3fb6ecd10edf0f04df12a8920d468", + "sha256:08d74bfaa4c7731b8dac0a992c63673a2782758f7cfad34cf9c1b9184f911354", + "sha256:0fc1f8f06977c2d4f5e3d3f0d4a08089be783973fc6b6e278bde01f0544ff308", + "sha256:121f4b3185feaade3f85f70294aef3f777199e9b5c0c0245c774ae884b110a2d", + "sha256:1413b5022ed6ac0d504ba425ef02549a57d0f4276de58e3ab7e82437892704fc", + "sha256:1743345e30917e8c574f273f51679c294effba6ad372db1967852f12c76759d8", + "sha256:28fc475f560d8f67cc8767b94db4c9440210f6958495aeae70fac8faec631797", + "sha256:31a99a4796bf5aefc8351e98507b09e1b09115574f7c9dbb9cf2111f7220d2e2", + "sha256:328a1fad67445550b982caa2a2a850da5989fd6595e858f02d04636e7f8b0b13", + "sha256:473858730ef6d6ff7f7d5f19452184cd0caa062a20047f6d6f3e135a4648865d", + "sha256:4cde065ab33bcaab774d84096fae266d9301d1a2f5519d7bd58fc55274afbf7a", + "sha256:5f6a808044faae658f546dd5f525e921de9fa409de7a5570865467f03a626fc0", + "sha256:610b690b406653c84b7cb6091facb3033500ee81089867ee7d59e675f9ca2b73", + "sha256:66256b6391c057305e5ae9209941ef63c33a476b73772ca967d4a2df70520ec1", + "sha256:6eebf512aa90751d5ef6a7c2ac9d60113f32e86e5687326a50d7686e309f66ed", + "sha256:79aef6b5cd41feff359acaf98e040844613ff5298d0d19c455b3d9ae0bc8c35a", + "sha256:808ee5834e06f57978da3e003ad9d6292de69d2bf6263662a1a8ae30788e080b", + "sha256:8e44769068d33e0ea6ccdf4b84d80c5afffe5207aa4d1881a629cf0ef3ec398f", + "sha256:999ad08220467b6ad4bd3dd34e65329dd5d0df9b31e47106105e407954965256", + "sha256:9b006628fe43aa69259ec04ca258d88ed19b64791693df59c422b607b6ece8bb", + "sha256:9d05ad5367c90814099000442b2125535e9d77581855b9bee8780f1b41f2b1a2", + "sha256:a577a21de2ef8059b58f79ff76a4da81c45a75fe0bfb09bc8b7bb4293fa18983", + "sha256:a617593aeacc7a691cc4af4a4410031654f2909053bd8c8e7db837f179a630eb", + "sha256:abb48494d88e8a82601af905143e0de838c776c1241d92021e9256d5515b3645", + "sha256:ac88856a8cbccfc14f1b2d0b829af354cc1743cb375e7f04251ae73b2af6adf8", + "sha256:b4c220a1fe0d2c622493b0a1fd48f8f991998fb447d3cd368033a4b86cf1127a", + "sha256:b844fb09bd9936ed158ff9df0ab601e2045b316b17aa8b931857365ea8586906", + "sha256:bdc178caebd0f338d57ae445ef8e9b737ddf8fbc3ea187603f65aec5b041248f", + "sha256:c206587c83e795d417ed3adc8453a791f6d36b67c81416676cad053b4104152c", + "sha256:c61dcc1cf9fd165127a2853e2c31eb4fb961a4f26b394ac9fe5669c7a6592892", + "sha256:c7cb4c512d2d3b0870e00fbbac2f291d4b4bf2634d59a31176a87afe2777c6f0", + "sha256:d4a332404baa6665b54e5d283b4262f41f2103c255897084ec8f5487ce7b9e8e", + "sha256:d5111d4c843d80202e62b4fdbb4920db1dcee4f9366d6b03294f45ed7b18b42e", + "sha256:e1e8406b895aba6caa63d9fd1b6b1700d7e4825f78ccb1e5260551d168db38ed", + "sha256:e8690ed94481f219a7a967c118abaf71ccc440f69acd583cab721b90eeedb77c", + "sha256:ed283ab3a01d8b53de3a05bfdf4473ae24e43caee7dcb5584e86f3f3e5ab4374", + "sha256:ed4b50355b066796dacdd1cf538f2ce57275d001838f9b132fab80b75e8c84dd", + "sha256:ee329d0387b5b41a5dddbb6243a21cb7896587a651bebb957e2d2bb8b63c0791", + "sha256:f3bf1bc02bc421047bfec3343729c4bbbea42605bcfd6d6bfe2c07ade8b12d2a", + "sha256:f585cbbeecb35f35609edccb95efd95a3e35824cd7752b586503f7e6087303f1", + "sha256:f60667673ff9c249709160529ab39667d1ae9fd38634e006bec95611f632e759" + ], + "version": "==2021.8.28" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", @@ -419,6 +434,14 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.16.0" }, + "tomli": { + "hashes": [ + "sha256:8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f", + "sha256:a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442" + ], + "markers": "python_version >= '3.6'", + "version": "==1.2.1" + }, "tornado": { "hashes": [ "sha256:0a00ff4561e2929a2c37ce706cb8233b7907e0cdc22eab98888aca5dd3775feb", @@ -474,6 +497,14 @@ "markers": "python_version >= '3.7'", "version": "==5.1.0" }, + "typing-extensions": { + "hashes": [ + "sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e", + "sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7", + "sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34" + ], + "version": "==3.10.0.2" + }, "wcwidth": { "hashes": [ "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784", diff --git a/scripting/plugins/BomGeneration/jlcparts.py b/scripting/plugins/BomGeneration/jlcparts.py index d339da1..237a0eb 100644 --- a/scripting/plugins/BomGeneration/jlcparts.py +++ b/scripting/plugins/BomGeneration/jlcparts.py @@ -59,13 +59,9 @@ footprints = { # TODO: remove hardcoded csv -args.input = ( - "/home/brendan/Documents/tempsync/projects/0034_UniversalController/jlcparts.csv" -) +args.input = "/home/brendan/Documents/tempsync/projects/0034_UniversalController/jlcparts.csv" if args.input: - parts_csv = pd.read_csv( - args.input, encoding_errors="replace", delimiter=",", index_col=False - ) + parts_csv = pd.read_csv(args.input, encoding_errors="replace", delimiter=",", index_col=False) else: raise NotImplementedError() @@ -78,20 +74,12 @@ stock = parts_csv[parts_csv["Stock"] > 0] # resistors resistors = stock[stock["First Category"] == "Resistors"].copy() -resistors["Value"] = ( - resistors["Description"].str.extract(r"(\d+(\.\d+)?)��").astype(float).iloc[:, 0] -) -resistors["Tolerance"] = ( - resistors["Description"].str.extract(r"(\d+)%").astype(float) / 100 -) -resistors["TempCoef"] = ( - resistors["Description"].str.extract(r"(\d+)ppm/��").astype(float) / 1e6 -) +resistors["Value"] = resistors["Description"].str.extract(r"(\d+(\.\d+)?)��").astype(float).iloc[:, 0] +resistors["Tolerance"] = resistors["Description"].str.extract(r"(\d+)%").astype(float) / 100 +resistors["TempCoef"] = resistors["Description"].str.extract(r"(\d+)ppm/��").astype(float) / 1e6 power_frac = resistors["Description"].str.extract(r"(\d+)/(\d+)W").astype(float) power_frac = power_frac.iloc[:, 0] / power_frac.iloc[:, 1] -power_dec = ( - resistors["Description"].str.extract(r"(\d+(\.\d+))W").astype(float).iloc[:, 0] -) +power_dec = resistors["Description"].str.extract(r"(\d+(\.\d+))W").astype(float).iloc[:, 0] power = power_frac.add(power_dec, fill_value=0) power[power_frac.notnull() & power_dec.notnull()] = pd.NA resistors["Power"] = power @@ -114,12 +102,8 @@ value = value.iloc[:, 0].astype(float) * value.iloc[:, 2].replace( ["p", "n", "u", "m", ""], [1e-12, 1e-9, 1e-6, 1e-3, 1] ).astype(float) capacitors["Value"] = value -capacitors["Tolerance"] = ( - capacitors["Description"].str.extract(r"(\d+)%").astype(float) / 100 -) -capacitors["Voltage"] = ( - capacitors["Description"].str.extract(r"(\d+(\.\d+)?)V").astype(float).iloc[:, 0] -) +capacitors["Tolerance"] = capacitors["Description"].str.extract(r"(\d+)%").astype(float) / 100 +capacitors["Voltage"] = capacitors["Description"].str.extract(r"(\d+(\.\d+)?)V").astype(float).iloc[:, 0] # TODO: "MLCC"/"Tantalum" code_np0 = capacitors["Description"].str.contains(r"NP0") code_t1 = capacitors["Description"].str.extract(r"([CBLAMPRSTVU][01234678][GHJKLMN])")