Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check single file test #102

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jlc_kicad_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.5"
__version__ = "1.0.6"
49 changes: 34 additions & 15 deletions jlc_kicad_tools/generate_jlc_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,39 +126,58 @@ def main():

netlist_filename = project_name + ".xml"
cpl_filename = project_name + "-all-pos.csv"
netlist_path = None
cpl_path = None
netlist_paths = []
cpl_paths = []

for dir_name, subdir_list, file_list in os.walk(opts.project_dir):
for file_name in file_list:
if file_name == netlist_filename and not netlist_path:
netlist_path = os.path.join(dir_name, file_name)
elif file_name == cpl_filename and not cpl_path:
cpl_path = os.path.join(dir_name, file_name)
if netlist_path and cpl_path:
break

if netlist_path is None:
if file_name == netlist_filename:
netlist_paths.append(os.path.join(dir_name, file_name))
elif file_name == cpl_filename:
cpl_paths.append(os.path.join(dir_name, file_name))

if len(netlist_paths) < 1:
_LOGGER.logger.error(
(
"Failed to find netlist file: {} in {} (and sub-directories). "
f"Failed to find netlist file: {netlist_filename} in {opts.project_dir} (and sub-directories). "
"Is the input directory a KiCad project? "
"If so, run 'Tools -> Generate Bill of Materials' in Eeschema (any format). "
"It will generate an intermediate file we need. "
"Note that this is not the same as a netlist for Pcbnew."
).format(netlist_filename, opts.project_dir)
)
)
return errno.ENOENT

if len(netlist_paths) > 1:
_LOGGER.logger.error(
(
f"Multiple netlist files found - {*netlist_paths,}. "
"There should be exactly one."
)
)
return errno.ENOENT

if cpl_path is None:
if len(cpl_paths) < 1:
_LOGGER.logger.error(
(
"Failed to find CPL file: {} in {} (and sub-directories). "
f"Failed to find CPL file: {cpl_filename} in {opts.project_dir} (and sub-directories). "
"Run 'File -> Fabrication Outputs -> Footprint Position (.pos) File' in Pcbnew. "
"Settings: 'CSV', 'mm', 'single file for board'."
).format(cpl_filename, opts.project_dir)
)
)
return errno.ENOENT

if len(cpl_paths) > 1:
_LOGGER.logger.error(
(
f"Multiple CPL files found - {*cpl_paths,}. "
"There should be exactly one."
)
)
return errno.ENOENT

netlist_path = netlist_paths[0]
cpl_path = cpl_paths[0]

_LOGGER.logger.info("Netlist file found at: {}".format(netlist_path))
_LOGGER.logger.info("CPL file found at: {}".format(cpl_path))
Expand Down
Loading