[Added] Warning for wrong dir/output separation

Seen on #493
This commit is contained in:
Salvador E. Tropea 2023-09-08 10:52:10 -03:00
parent 4334de0277
commit 565c3152d9
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Populate:
- Basic support for regular list items (#480)
- Help for the error levels
- Warnings:
- Explain about wrong dir/output separation (#493)
### Changed
- Documentation:

View File

@ -11,7 +11,7 @@ from shutil import rmtree
from tempfile import NamedTemporaryFile, mkdtemp
from .gs import GS
from .kiplot import load_sch, get_board_comps_data
from .misc import Rect, W_WRONGPASTE, DISABLE_3D_MODEL_TEXT, W_NOCRTYD, MOD_ALLOW_MISSING_COURTYARD
from .misc import Rect, W_WRONGPASTE, DISABLE_3D_MODEL_TEXT, W_NOCRTYD, MOD_ALLOW_MISSING_COURTYARD, W_MISSDIR
if not GS.kicad_version_n:
# When running the regression tests we need it
from kibot.__main__ import detect_kicad
@ -194,7 +194,14 @@ class BaseOutput(RegOutput):
def run(self, output_dir):
self.output_dir = output_dir
output = self.options.output if hasattr(self.options, 'output') else ''
self.options.run(self.expand_filename(output_dir, output))
target = self.expand_filename(output_dir, output)
# Ensure the destination dir already exists
target_dir = os.path.dirname(os.path.abspath(target))
if not os.path.isdir(target_dir):
logger.warning(W_MISSDIR+f'Missing target directory `{target_dir}`, creating it')
logger.warning(W_MISSDIR+'Note: use the `dir` option properly or just create the dir before running KiBot')
os.makedirs(target_dir)
self.options.run(target)
class BoMRegex(Optionable):