partcad-cli 0.3.70__tar.gz → 0.3.82__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/PKG-INFO +2 -2
  2. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/pyproject.toml +1 -1
  3. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/requirements.txt +1 -1
  4. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/__init__.py +1 -1
  5. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli.py +22 -1
  6. partcad-cli-0.3.82/src/partcad_cli/cli_add.py +94 -0
  7. partcad-cli-0.3.82/src/partcad_cli/cli_info.py +78 -0
  8. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli_init.py +2 -10
  9. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli_list.py +15 -36
  10. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli_show.py +20 -2
  11. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/PKG-INFO +2 -2
  12. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/SOURCES.txt +2 -3
  13. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/requires.txt +1 -1
  14. partcad-cli-0.3.70/src/partcad_cli/cli_add.py +0 -66
  15. partcad-cli-0.3.70/src/partcad_cli/template/init-private.yaml +0 -16
  16. partcad-cli-0.3.70/src/partcad_cli/template/init-public.yaml +0 -19
  17. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/README.md +0 -0
  18. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/setup.cfg +0 -0
  19. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli_install.py +0 -0
  20. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli/cli_render.py +0 -0
  21. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/dependency_links.txt +0 -0
  22. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/entry_points.txt +0 -0
  23. {partcad-cli-0.3.70 → partcad-cli-0.3.82}/src/partcad_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partcad-cli
3
- Version: 0.3.70
3
+ Version: 0.3.82
4
4
  Summary: Command-line interface to PartCAD
5
5
  Author-email: Roman Kuzmenko <openvmp@proton.me>
6
6
  Maintainer-email: Roman Kuzmenko <openvmp@proton.me>
@@ -12,7 +12,7 @@ Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
- Requires-Dist: partcad==0.3.70
15
+ Requires-Dist: partcad==0.3.82
16
16
  Requires-Dist: pycairo
17
17
  Requires-Dist: renderlab
18
18
  Requires-Dist: rlPyCairo
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "partcad-cli"
3
- version = "0.3.70"
3
+ version = "0.3.82"
4
4
  description = "Command-line interface to PartCAD"
5
5
  readme = "README.md"
6
6
  keywords = ["cadquery", "build123d", "cad", "design", "openscad", "step", "stl"]
@@ -1,4 +1,4 @@
1
- partcad==0.3.70
1
+ partcad==0.3.82
2
2
  pycairo
3
3
  renderlab
4
4
  rlPyCairo
@@ -4,4 +4,4 @@ __all__ = [
4
4
  "main_cli",
5
5
  ]
6
6
 
7
- __version__: str = "0.3.70"
7
+ __version__: str = "0.3.82"
@@ -15,6 +15,7 @@ import partcad as pc
15
15
 
16
16
  from .cli_add import *
17
17
  from .cli_init import *
18
+ from .cli_info import *
18
19
  from .cli_install import *
19
20
  from .cli_list import *
20
21
  from .cli_render import *
@@ -29,6 +30,13 @@ def main():
29
30
  parser = argparse.ArgumentParser(
30
31
  description="PartCAD command line tool",
31
32
  )
33
+ parser.add_argument(
34
+ "-v",
35
+ help="Increase the level of verbosity",
36
+ dest="verbosity",
37
+ action="count",
38
+ default=0,
39
+ )
32
40
  parser.add_argument(
33
41
  "-p",
34
42
  help="Package path (a YAML file or a directory with 'partcad.yaml')",
@@ -40,6 +48,7 @@ def main():
40
48
  subparsers = parser.add_subparsers(dest="command")
41
49
  cli_help_add(subparsers)
42
50
  cli_help_init(subparsers)
51
+ cli_help_info(subparsers)
43
52
  cli_help_install(subparsers)
44
53
  cli_help_list(subparsers)
45
54
  cli_help_render(subparsers)
@@ -47,14 +56,26 @@ def main():
47
56
 
48
57
  args = parser.parse_args()
49
58
 
50
- logging.basicConfig(level=logging.INFO)
59
+ if args.verbosity > 0:
60
+ logging.basicConfig(level=logging.DEBUG)
61
+ else:
62
+ logging.basicConfig(level=logging.INFO)
51
63
 
52
64
  if args.command == "add":
53
65
  cli_add(args)
54
66
 
67
+ elif args.command == "add-part":
68
+ cli_add_part(args)
69
+
70
+ elif args.command == "add-assembly":
71
+ cli_add_assembly(args)
72
+
55
73
  elif args.command == "init":
56
74
  cli_init(args)
57
75
 
76
+ elif args.command == "info":
77
+ cli_info(args)
78
+
58
79
  elif args.command == "install":
59
80
  cli_install(args)
60
81
 
@@ -0,0 +1,94 @@
1
+ #
2
+ # OpenVMP, 2023
3
+ #
4
+ # Author: Roman Kuzmenko
5
+ # Created: 2023-12-23
6
+ #
7
+ # Licensed under Apache License, Version 2.0.
8
+ #
9
+
10
+
11
+ from pathlib import Path
12
+
13
+ import partcad as pc
14
+
15
+
16
+ def cli_help_add(subparsers):
17
+ parser_add = subparsers.add_parser(
18
+ "add",
19
+ help="Import a package",
20
+ )
21
+ parser_add.add_argument(
22
+ "alias",
23
+ help="Alias to be used to reference the package",
24
+ type=str,
25
+ )
26
+ parser_add.add_argument(
27
+ "location",
28
+ help="Path or URL to the package",
29
+ type=str,
30
+ )
31
+
32
+ parser_add_part = subparsers.add_parser(
33
+ "add-part",
34
+ help="Add a part",
35
+ )
36
+ parser_add_part.add_argument(
37
+ "kind",
38
+ help="Type of the part",
39
+ type=str,
40
+ choices=["cadquery", "build123d", "step", "stl", "3mf"],
41
+ )
42
+ parser_add_part.add_argument(
43
+ "path",
44
+ help="Path to the file",
45
+ type=str,
46
+ )
47
+
48
+ parser_add_assembly = subparsers.add_parser(
49
+ "add-assembly",
50
+ help="Add a assembly",
51
+ )
52
+ parser_add_assembly.add_argument(
53
+ "kind",
54
+ help="Type of the assembly",
55
+ type=str,
56
+ choices=["assy"],
57
+ )
58
+ parser_add_assembly.add_argument(
59
+ "path",
60
+ help="Path to the file",
61
+ type=str,
62
+ )
63
+
64
+
65
+ def cli_add(args):
66
+ if not args.config_path is None:
67
+ ctx = pc.init(args.config_path)
68
+ else:
69
+ ctx = pc.init()
70
+
71
+ prj = ctx.get_project(pc.THIS)
72
+ prj.add_import(args.alias, args.location)
73
+
74
+
75
+ def cli_add_part(args):
76
+ if not args.config_path is None:
77
+ ctx = pc.init(args.config_path)
78
+ else:
79
+ ctx = pc.init()
80
+
81
+ prj = ctx.get_project(pc.THIS)
82
+ if prj.add_part(args.kind, args.path):
83
+ Path(args.path).touch()
84
+
85
+
86
+ def cli_add_assembly(args):
87
+ if not args.config_path is None:
88
+ ctx = pc.init(args.config_path)
89
+ else:
90
+ ctx = pc.init()
91
+
92
+ prj = ctx.get_project(pc.THIS)
93
+ if prj.add_assembly(args.kind, args.path):
94
+ Path(args.path).touch()
@@ -0,0 +1,78 @@
1
+ #
2
+ # OpenVMP, 2023
3
+ #
4
+ # Author: Roman Kuzmenko
5
+ # Created: 2024-01-23
6
+ #
7
+ # Licensed under Apache License, Version 2.0.
8
+ #
9
+
10
+ import logging
11
+ from pprint import pprint
12
+
13
+ import partcad as pc
14
+ from partcad.utils import total_size
15
+
16
+
17
+ def cli_help_info(subparsers):
18
+ parser_info = subparsers.add_parser(
19
+ "info",
20
+ help="Show detailed info a part, assembly or scene",
21
+ )
22
+ group_type = parser_info.add_mutually_exclusive_group(required=False)
23
+ group_type.add_argument(
24
+ "-a",
25
+ help="The object is an assembly",
26
+ dest="assembly",
27
+ action="store_true",
28
+ )
29
+ group_type.add_argument(
30
+ "-s",
31
+ help="The object is a scene",
32
+ dest="scene",
33
+ action="store_true",
34
+ )
35
+
36
+ parser_info.add_argument(
37
+ "object",
38
+ help="Part (default), assembly or scene to show",
39
+ type=str,
40
+ )
41
+ parser_info.add_argument(
42
+ "package",
43
+ help="Package to retrieve the object from",
44
+ type=str,
45
+ nargs="?",
46
+ )
47
+
48
+
49
+ def cli_info(args):
50
+ if not args.config_path is None:
51
+ ctx = pc.init(args.config_path)
52
+ else:
53
+ ctx = pc.init()
54
+
55
+ if args.package is None:
56
+ package = "this"
57
+ else:
58
+ package = args.package
59
+
60
+ if args.assembly:
61
+ obj = ctx.get_assembly(args.object, package)
62
+ else:
63
+ obj = ctx.get_part(args.object, package)
64
+
65
+ if obj is None:
66
+ if args.package is None:
67
+ logging.error("Object %s not found" % args.object)
68
+ else:
69
+ logging.error(
70
+ "Object %s not found in package %s" % (args.object, args.package)
71
+ )
72
+ else:
73
+ print("CONFIGURATION:")
74
+ pprint(obj.config)
75
+ print()
76
+ print("RUNTIME PROPERTIES:")
77
+ obj.get_shape()
78
+ print("Memory: %d KB" % ((total_size(obj) + 1023) / 1024))
@@ -9,7 +9,6 @@
9
9
 
10
10
  import logging
11
11
  import os
12
- import shutil
13
12
  import sys
14
13
 
15
14
  import partcad as pc
@@ -29,12 +28,6 @@ def cli_help_init(subparsers):
29
28
 
30
29
 
31
30
  def cli_init(args):
32
- if args.private:
33
- template_name = "init-private.yaml"
34
- else:
35
- template_name = "init-public.yaml"
36
- src_path = os.path.join(os.path.dirname(__file__), "template", template_name)
37
-
38
31
  if not args.config_path is None:
39
32
  if os.path.isdir(args.config_path):
40
33
  dst_path = os.path.join(args.config_path, "partcad.yaml")
@@ -43,7 +36,6 @@ def cli_init(args):
43
36
  else:
44
37
  dst_path = "partcad.yaml"
45
38
 
46
- if os.path.exists(dst_path):
47
- logging.error("'%s' already exists!" % dst_path)
39
+ if not pc.create_package(dst_path, args.private):
40
+ logging.error("Failed creating '%s'!" % dst_path)
48
41
  sys.exit(1)
49
- shutil.copyfile(src_path, dst_path)
@@ -119,32 +119,21 @@ def cli_list_parts(args):
119
119
  continue
120
120
  project = ctx.projects[project_name]
121
121
 
122
- if args.used_by is None:
123
- if (
124
- "parts" in project.config_obj
125
- and project.config_obj["parts"] is not None
126
- ):
127
- part_names = project.config_obj["parts"].keys()
128
- else:
129
- part_names = []
130
- else:
131
- part_names = project.parts.keys()
132
- for part_name in part_names:
122
+ for part_name, part in project.parts.items():
123
+ if args.used_by is not None and part.count == 0:
124
+ continue
125
+
133
126
  line = "\t"
134
127
  if args.recursive:
135
128
  line += "%s" % project_name
136
- line += " " * (36 - len(project_name))
129
+ line += " " + " " * (35 - len(project_name))
137
130
  line += "%s" % part_name
138
131
  if args.used_by is not None:
139
132
  part = project.parts[part_name]
140
133
  line += "(%d)" % part.count
141
134
  part_count = part_count + part.count
142
- line += " " * (36 - len(part_name))
143
- if (
144
- project.config_obj["parts"][part_name] is not None
145
- and "desc" in project.config_obj["parts"][part_name]
146
- ):
147
- line += "%s" % project.config_obj["parts"][part_name]["desc"]
135
+ line += " " + " " * (35 - len(part_name))
136
+ line += "%s" % part.desc
148
137
  print(line)
149
138
  part_kinds = part_kinds + 1
150
139
 
@@ -167,6 +156,7 @@ def cli_list_assemblies(args):
167
156
 
168
157
  if args.used_by is not None:
169
158
  print("Instantiating %s..." % args.used_by)
159
+ # TODO(clairbee): do not call it twice in 'list-all'
170
160
  pc.get_assembly(args.used_by)
171
161
 
172
162
  print()
@@ -178,32 +168,21 @@ def cli_list_assemblies(args):
178
168
  continue
179
169
  project = ctx.projects[project_name]
180
170
 
181
- if args.used_by is None:
182
- if (
183
- "assemblies" in project.config_obj
184
- and project.config_obj["assemblies"] is not None
185
- ):
186
- assy_names = project.config_obj["assemblies"].keys()
187
- else:
188
- assy_names = []
189
- else:
190
- assy_names = project.assemblies.keys()
191
- for assy_name in assy_names:
171
+ for assy_name, assy in project.assemblies.items():
172
+ if args.used_by is not None and assy.count == 0:
173
+ continue
174
+
192
175
  line = "\t"
193
176
  if args.recursive:
194
177
  line += "%s" % project_name
195
- line += " " * (36 - len(project_name))
178
+ line += " " + " " * (35 - len(project_name))
196
179
  line += "%s" % assy_name
197
180
  if args.used_by is not None:
198
181
  assy = project.assemblies[assy_name]
199
182
  line += "(%d)" % assy.count
200
183
  assy_count = assy_count + assy.count
201
- line += " " * (36 - len(assy_name))
202
- if (
203
- project.config_obj["assemblies"][assy_name] is not None
204
- and "desc" in project.config_obj["assemblies"][assy_name]
205
- ):
206
- line += "%s" % project.config_obj["assemblies"][assy_name]["desc"]
184
+ line += " " + " " * (35 - len(assy_name))
185
+ line += "%s" % assy.desc
207
186
  print(line)
208
187
  assy_kinds = assy_kinds + 1
209
188
 
@@ -7,11 +7,14 @@
7
7
  # Licensed under Apache License, Version 2.0.
8
8
  #
9
9
 
10
+ # import argparse
10
11
  import logging
11
12
 
12
13
  import partcad as pc
13
14
 
14
15
 
16
+ # TODO(clairbee): fix type checking here
17
+ # def cli_help_show(subparsers: argparse._SubParsersAction[argparse.ArgumentParser]):
15
18
  def cli_help_show(subparsers):
16
19
  parser_show = subparsers.add_parser(
17
20
  "show",
@@ -31,6 +34,15 @@ def cli_help_show(subparsers):
31
34
  action="store_true",
32
35
  )
33
36
 
37
+ parser_show.add_argument(
38
+ "-p",
39
+ "--param",
40
+ metavar="<param_name>=<param_value>",
41
+ help="Assign a value to the parameter",
42
+ dest="params",
43
+ action="append",
44
+ )
45
+
34
46
  parser_show.add_argument(
35
47
  "object",
36
48
  help="Part (default), assembly or scene to show",
@@ -55,10 +67,16 @@ def cli_show(args):
55
67
  else:
56
68
  package = args.package
57
69
 
70
+ params = {}
71
+ if not args.params is None:
72
+ for kv in args.params:
73
+ k, v = kv.split("=")
74
+ params[k] = v
75
+
58
76
  if args.assembly:
59
- obj = ctx.get_assembly(args.object, package)
77
+ obj = ctx.get_assembly(args.object, package, params=params)
60
78
  else:
61
- obj = ctx.get_part(args.object, package)
79
+ obj = ctx.get_part(args.object, package, params=params)
62
80
 
63
81
  if obj is None:
64
82
  if args.package is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partcad-cli
3
- Version: 0.3.70
3
+ Version: 0.3.82
4
4
  Summary: Command-line interface to PartCAD
5
5
  Author-email: Roman Kuzmenko <openvmp@proton.me>
6
6
  Maintainer-email: Roman Kuzmenko <openvmp@proton.me>
@@ -12,7 +12,7 @@ Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
- Requires-Dist: partcad==0.3.70
15
+ Requires-Dist: partcad==0.3.82
16
16
  Requires-Dist: pycairo
17
17
  Requires-Dist: renderlab
18
18
  Requires-Dist: rlPyCairo
@@ -4,6 +4,7 @@ requirements.txt
4
4
  src/partcad_cli/__init__.py
5
5
  src/partcad_cli/cli.py
6
6
  src/partcad_cli/cli_add.py
7
+ src/partcad_cli/cli_info.py
7
8
  src/partcad_cli/cli_init.py
8
9
  src/partcad_cli/cli_install.py
9
10
  src/partcad_cli/cli_list.py
@@ -14,6 +15,4 @@ src/partcad_cli.egg-info/SOURCES.txt
14
15
  src/partcad_cli.egg-info/dependency_links.txt
15
16
  src/partcad_cli.egg-info/entry_points.txt
16
17
  src/partcad_cli.egg-info/requires.txt
17
- src/partcad_cli.egg-info/top_level.txt
18
- src/partcad_cli/template/init-private.yaml
19
- src/partcad_cli/template/init-public.yaml
18
+ src/partcad_cli.egg-info/top_level.txt
@@ -1,4 +1,4 @@
1
- partcad==0.3.70
1
+ partcad==0.3.82
2
2
  pycairo
3
3
  renderlab
4
4
  rlPyCairo
@@ -1,66 +0,0 @@
1
- #
2
- # OpenVMP, 2023
3
- #
4
- # Author: Roman Kuzmenko
5
- # Created: 2023-12-23
6
- #
7
- # Licensed under Apache License, Version 2.0.
8
- #
9
-
10
- import logging
11
- import os
12
- import ruamel.yaml
13
- import sys
14
-
15
- import partcad as pc
16
-
17
-
18
- def cli_help_add(subparsers):
19
- parser_add = subparsers.add_parser(
20
- "add",
21
- help="Import a package",
22
- )
23
- parser_add.add_argument(
24
- "alias",
25
- help="Alias to be used to reference the package",
26
- type=str,
27
- )
28
- parser_add.add_argument(
29
- "location",
30
- help="Path or URL to the package",
31
- type=str,
32
- )
33
-
34
-
35
- def cli_add(args):
36
- if not os.path.exists("partcad.yaml"):
37
- logging.error("'partcad.yaml' not found!")
38
- sys.exit(1)
39
-
40
- if ":" in args.location:
41
- location_param = "url"
42
- if args.location.endswith(".tar.gz"):
43
- location_type = "tar"
44
- else:
45
- location_type = "git"
46
- else:
47
- location_param = "path"
48
- location_type = "local"
49
-
50
- yaml = ruamel.yaml.YAML()
51
- yaml.preserve_quotes = True
52
- with open("partcad.yaml") as fp:
53
- config = yaml.load(fp)
54
- fp.close()
55
-
56
- for elem in config:
57
- if elem == "import":
58
- imports = config["import"]
59
- imports[args.alias] = {
60
- location_param: args.location,
61
- "type": location_type,
62
- }
63
- break # no need to iterate further
64
- with open("partcad.yaml", "w") as fp:
65
- yaml.dump(config, fp)
66
- fp.close()
@@ -1,16 +0,0 @@
1
- import:
2
- # Add dependencies here
3
- # <package-name>:
4
- # desc: <package description> # optional
5
- # type: <local|git|tar>
6
- # path: <relative path> # type:local only
7
- # url: <url of the package> # type:git|tar only
8
- # relPath: <relative path within the repo> # type:git|tar only
9
- # web: <package's or maintainer's url> # optional
10
- # poc: <maintainer's email> # optional
11
-
12
- parts:
13
- # Add parts here
14
-
15
- assemblies:
16
- # Add assemblies here
@@ -1,19 +0,0 @@
1
- import:
2
- # Add dependencies here
3
- # <package-name>:
4
- # desc: <package description> # optional
5
- # type: <local|git|tar>
6
- # path: <relative path> # type:local only
7
- # url: <url of the package> # type:git|tar only
8
- # relPath: <relative path within the repo> # type:git|tar only
9
- # web: <package's or maintainer's url> # optional
10
- # poc: <maintainer's email> # optional
11
- partcad-index:
12
- type: git
13
- url: https://github.com/openvmp/partcad-index.git
14
-
15
- parts:
16
- # Add parts here
17
-
18
- assemblies:
19
- # Add assemblies here
File without changes
File without changes