[Diff][Schematic][Fixed] Project not copied to variant

- Any info related to the project wasn't applied.

Fixes #438
This commit is contained in:
Salvador E. Tropea 2023-05-16 13:28:51 -03:00
parent 8a4ea1be5a
commit a02999d50a
5 changed files with 22 additions and 17 deletions

View File

@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
SMD components are selected. (See #429)
- Diff:
- KIBOT_TAG with n > 0 skipped n commits, not n tags (#430)
- Details related to the project not applied during a diff involving a
variant (project not copied) (#438)
## [1.6.2] - 2023-04-24
### Added

View File

@ -456,6 +456,20 @@ class GS(object):
copy2(pro_name, pro_copy)
return pro_copy
@staticmethod
def copy_project_sch(sch_dir):
""" Copy the project file to the temporal dir """
ext = GS.pro_ext
source = GS.pro_file
prj_file = os.path.join(sch_dir, GS.sch_basename+ext)
if source is not None and os.path.isfile(source):
copy2(source, prj_file)
GS.fix_page_layout(prj_file) # Alias for KiConf.fix_page_layout
else:
# Create a dummy project file to avoid warnings
f = open(prj_file, 'wt')
f.close()
@staticmethod
def get_pcb_and_pro_names(name):
if GS.ki5:

View File

@ -660,3 +660,7 @@ class KiConf(object):
if ref_dir is None:
ref_dir = os.getcwd()
return expanded if expanded.startswith('${') else os.path.normpath(os.path.join(ref_dir, expanded))
# Avoid circular inclusion
GS.fix_page_layout = KiConf.fix_page_layout

View File

@ -5,30 +5,14 @@
# Project: KiBot (formerly KiPlot)
import os
from tempfile import mkdtemp
from shutil import copy2
from .gs import GS
from .out_base import VariantOptions
from .kicad.config import KiConf
from .macros import macros, document, output_class # noqa: F401
from . import log
logger = log.get_logger()
def copy_project(sch_dir):
""" Copy the project file to the temporal dir """
ext = GS.pro_ext
source = GS.pro_file
prj_file = os.path.join(sch_dir, GS.sch_basename+ext)
if source is not None and os.path.isfile(source):
copy2(source, prj_file)
KiConf.fix_page_layout(prj_file)
else:
# Create a dummy project file to avoid warnings
f = open(prj_file, 'wt')
f.close()
class Any_SCH_PrintOptions(VariantOptions):
def __init__(self):
with document:
@ -62,7 +46,7 @@ class Any_SCH_PrintOptions(VariantOptions):
if self._comps or self.title:
# Save it to a temporal dir
sch_dir = mkdtemp(prefix='tmp-kibot-'+self._expand_ext+'_sch_print-')
copy_project(sch_dir)
GS.copy_project_sch(sch_dir)
fname = GS.sch.save_variant(sch_dir)
sch_file = os.path.join(sch_dir, fname)
self._files_to_remove.append(sch_dir)

View File

@ -423,6 +423,7 @@ class DiffOptions(BaseOptions):
dir_name = mkdtemp()
self.dirs_to_remove.append(dir_name)
fname = GS.sch.save_variant(dir_name)
GS.copy_project_sch(dir_name)
res = self.cache_file(os.path.join(dir_name, fname))
self.git_hash = 'Current'
return res