Skip to content

Commit

Permalink
rename cq_cli.py->main.py and resolve import issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justbuchanan committed Oct 25, 2023
1 parent 5c76236 commit b540ec8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
]

[project.scripts]
cq-cli = "cq_cli.cq_cli:main"
cq-cli = "cq_cli.main:main"

[project.optional-dependencies]
dev = [
Expand Down
6 changes: 5 additions & 1 deletion src/cq_cli/cq_cli.py → src/cq_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

import os
import sys

# Add parent directory to path so that `import cq_cli.* resolves correctly.
sys.path.append(os.path.dirname(__file__) + "/..")

import argparse
import cadquery as cq
from cadquery import cqgi
import fileinput
import traceback
import json
from cqcodecs import loader
from cq_cli.cqcodecs import loader


def build_and_parse(script_str, params, errfile):
Expand Down
32 changes: 16 additions & 16 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_no_cli_arguments():
"""
Runs the CLI with no arguments, which you should not do unless you want the usage message.
"""
command = ["python", "src/cq_cli/cq_cli.py"]
command = ["python", "src/cq_cli/main.py"]
out, err, exitcode = helpers.cli_call(command)

assert (
Expand All @@ -26,7 +26,7 @@ def test_codec_and_infile_arguments_file_nonexistent():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand All @@ -45,7 +45,7 @@ def test_codec_and_infile_arguments():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand All @@ -67,7 +67,7 @@ def test_codec_infile_and_outfile_arguments():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_codec_infile_outfile_errfile_arguments():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_parameter_file():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_parameter_json_string():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_parameter_delimited_string():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand All @@ -219,7 +219,7 @@ def test_parameter_analysis():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--getparams",
"true",
"--infile",
Expand Down Expand Up @@ -260,7 +260,7 @@ def test_parameter_file_input_output():
# Save the parameters from the script to a file
command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--getparams",
temp_file,
"--infile",
Expand All @@ -271,7 +271,7 @@ def test_parameter_file_input_output():
# Run the script with baseline parameters
command2 = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand All @@ -294,7 +294,7 @@ def test_parameter_file_input_output():
# Run the command with the new parameters
command3 = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_params_stl_output():
# Execute the script with the current parameters and save the new parameter metadata to the customizer file
command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand Down Expand Up @@ -360,7 +360,7 @@ def test_params_stl_output():
# Write an STL using the default parameters so that we can compare it to what was generated with customized parameters
command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand All @@ -385,7 +385,7 @@ def test_exit_codes():
"""

# Test to make sure we get the correct exit code when no parameters are specified
command = ["python", "src/cq_cli/cq_cli.py"]
command = ["python", "src/cq_cli/main.py"]
out, err, exitcode = helpers.cli_call(command)

# Make sure that we got exit code 2
Expand All @@ -397,7 +397,7 @@ def test_exit_codes():
# Execute the script with the current parameters and save the new parameter metadata to the customizer file
command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gltf_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_gltf_codec():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"gltf",
"--infile",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_step_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_step_codec():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"step",
"--infile",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_stl_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_stl_codec():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand All @@ -29,7 +29,7 @@ def test_stl_codec_quality():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand All @@ -43,7 +43,7 @@ def test_stl_codec_quality():
# Attempt to adjust the quality of the resulting STL
command2 = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"stl",
"--infile",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_svg_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_svg_codec():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"svg",
"--infile",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_threejs_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_threejs_codec():

command = [
"python",
"src/cq_cli/cq_cli.py",
"src/cq_cli/main.py",
"--codec",
"threejs",
"--infile",
Expand Down

0 comments on commit b540ec8

Please sign in to comment.