Added global options to control the date format.
This commit is contained in:
parent
779399c4db
commit
a503c5fdc6
|
|
@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- **%bc**, **%bd**, **%bf**, **%bF**, **%bp** and **%br** board data
|
||||
- **%sc**, **%sd**, **%sf**, **%sF**, **%sp** and **%sr** schematic data
|
||||
- Now patterns are also expanded in the out_dir name.
|
||||
- Global options to control the date format.
|
||||
|
||||
### Changed
|
||||
- Internal BoM: now components with different Tolerance, Voltage, Current
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
* [Default *dir* option](#default-dir-option)
|
||||
* [Default *variant* option](#default-variant-option)
|
||||
* [Output directory option](#output-directory-option)
|
||||
* [Date format option](#date-format-option)
|
||||
* [Filtering KiBot warnings](#filtering-kibot-warnings)
|
||||
* [Filters and variants](#filters-and-variants)
|
||||
* [Supported filters](#supported-filters)
|
||||
|
|
@ -256,6 +257,14 @@ Note that the command line option has precedence over it.
|
|||
Expansion patterns are applied to this value, but you should avoid using patterns that expand according to the context, i.e. **%c**, **%d**, **%f**, **%F**, **%p** and **%r**.
|
||||
The behavior of these patterns isn't fully defined in this case and the results may change in the future.
|
||||
|
||||
#### Date format option
|
||||
|
||||
* The **%d**, **%sd** and **%bd** patterns use the date and time from the PCB and schematic. When abscent they use the file timestamp. The `date_time_format` global option controls the format used.
|
||||
* The **%D** format is controlled by the `date_format` global option.
|
||||
* The **%T** format is controlled by the `time_format` global option.
|
||||
|
||||
In all cases the format is the one used by the `strftime` POSIX function, for more information visit this [site](https://strftime.org/).
|
||||
|
||||
#### Filtering KiBot warnings
|
||||
|
||||
KiBot warnings are marked with `(Wn)` where *n* is the warning id.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
* [Default *dir* option](#default-dir-option)
|
||||
* [Default *variant* option](#default-variant-option)
|
||||
* [Output directory option](#output-directory-option)
|
||||
* [Date format option](#date-format-option)
|
||||
* [Filtering KiBot warnings](#filtering-kibot-warnings)
|
||||
* [Filters and variants](#filters-and-variants)
|
||||
* [Supported filters](#supported-filters)
|
||||
|
|
@ -235,6 +236,14 @@ Note that the command line option has precedence over it.
|
|||
Expansion patterns are applied to this value, but you should avoid using patterns that expand according to the context, i.e. **%c**, **%d**, **%f**, **%F**, **%p** and **%r**.
|
||||
The behavior of these patterns isn't fully defined in this case and the results may change in the future.
|
||||
|
||||
#### Date format option
|
||||
|
||||
* The **%d**, **%sd** and **%bd** patterns use the date and time from the PCB and schematic. When abscent they use the file timestamp. The `date_time_format` global option controls the format used.
|
||||
* The **%D** format is controlled by the `date_format` global option.
|
||||
* The **%T** format is controlled by the `time_format` global option.
|
||||
|
||||
In all cases the format is the one used by the `strftime` POSIX function, for more information visit this [site](https://strftime.org/).
|
||||
|
||||
#### Filtering KiBot warnings
|
||||
|
||||
KiBot warnings are marked with `(Wn)` where *n* is the warning id.
|
||||
|
|
|
|||
|
|
@ -329,6 +329,9 @@ class CfgYamlReader(object):
|
|||
GS.global_output = GS.global_from_cli.get('output', None)
|
||||
GS.global_dir = GS.global_from_cli.get('dir', None)
|
||||
GS.global_variant = GS.global_from_cli.get('variant', None)
|
||||
GS.global_date_time_format = GS.global_from_cli.get('date_time_format', None)
|
||||
GS.global_date_format = GS.global_from_cli.get('date_format', None)
|
||||
GS.global_time_format = GS.global_from_cli.get('time_format', None)
|
||||
GS.global_kiauto_wait_start = GS.global_from_cli.get('kiauto_wait_start', None)
|
||||
GS.global_kiauto_time_out_scale = GS.global_from_cli.get('kiauto_time_out_scale', None)
|
||||
# List of outputs
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ class Globals(FiltersOptions):
|
|||
""" Time to wait for KiCad in KiAuto operations """
|
||||
self.kiauto_time_out_scale = 0.0
|
||||
""" Time-out multiplier for KiAuto operations """
|
||||
self.date_time_format = '%Y-%m-%d_%H-%M-%S'
|
||||
""" Format used for the PCB and schematic date when using the file timestamp. Uses the `strftime` format """
|
||||
self.date_format = '%Y-%m-%d'
|
||||
""" Format used for the day we started the script. Uses the `strftime` format """
|
||||
self.time_format = '%H-%M-%S'
|
||||
""" Format used for the time we started the script. Uses the `strftime` format """
|
||||
self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ")
|
||||
self._filter_what = 'KiBot warnings'
|
||||
self._unkown_is_error = True
|
||||
|
|
@ -47,6 +53,9 @@ class Globals(FiltersOptions):
|
|||
GS.global_output = self.set_global(GS.global_output, self.output, 'output')
|
||||
GS.global_dir = self.set_global(GS.global_dir, self.dir, 'dir')
|
||||
GS.global_variant = self.set_global(GS.global_variant, self.variant, 'variant')
|
||||
GS.global_date_time_format = self.set_global(GS.global_date_time_format, self.date_time_format, 'date_time_format')
|
||||
GS.global_date_format = self.set_global(GS.global_date_format, self.date_format, 'date_format')
|
||||
GS.global_time_format = self.set_global(GS.global_time_format, self.time_format, 'time_format')
|
||||
GS.global_kiauto_wait_start = self.set_global(GS.global_kiauto_wait_start, self.kiauto_wait_start, 'kiauto_wait_start')
|
||||
if GS.global_kiauto_wait_start and int(GS.global_kiauto_wait_start) != GS.global_kiauto_wait_start:
|
||||
GS.global_kiauto_wait_start = int(GS.global_kiauto_wait_start)
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ class GS(object):
|
|||
debug_enabled = False
|
||||
debug_level = 0
|
||||
n = datetime.now()
|
||||
today = n.strftime('%Y-%m-%d')
|
||||
time = n.strftime('%H-%M-%S')
|
||||
kicad_version = ''
|
||||
kicad_conf_path = None
|
||||
kicad_share_path = None
|
||||
|
|
@ -78,6 +76,9 @@ class GS(object):
|
|||
global_kiauto_time_out_scale = None
|
||||
global_opts_class = None
|
||||
global_3D_model_field = '_3D_model'
|
||||
global_date_time_format = None
|
||||
global_date_format = None
|
||||
global_time_format = None
|
||||
test_boolean = True
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -121,7 +122,7 @@ class GS(object):
|
|||
GS.pcb_date = title_block.GetDate()
|
||||
if not GS.pcb_date:
|
||||
file_mtime = os.path.getmtime(GS.pcb_file)
|
||||
GS.pcb_date = datetime.fromtimestamp(file_mtime).strftime('%Y-%m-%d_%H-%M-%S')
|
||||
GS.pcb_date = datetime.fromtimestamp(file_mtime).strftime(GS.global_date_time_format)
|
||||
GS.pcb_title = title_block.GetTitle()
|
||||
if not GS.pcb_title:
|
||||
GS.pcb_title = GS.pcb_basename
|
||||
|
|
|
|||
|
|
@ -1494,7 +1494,7 @@ class Schematic(object):
|
|||
# Fill in some missing info
|
||||
if not self.date:
|
||||
file_mtime = os.path.getmtime(fname)
|
||||
self.date = datetime.fromtimestamp(file_mtime).strftime('%Y-%m-%d_%H-%M-%S')
|
||||
self.date = datetime.fromtimestamp(file_mtime).strftime(GS.global_date_time_format)
|
||||
if not self.title:
|
||||
self.title = os.path.splitext(os.path.basename(fname))[0]
|
||||
logger.debug("SCH title: `{}`".format(self.title))
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ class Optionable(object):
|
|||
name = name.replace('%bf', GS.pcb_basename)
|
||||
name = name.replace('%bp', GS.pcb_title)
|
||||
name = name.replace('%br', GS.pcb_rev)
|
||||
name = name.replace('%D', GS.today)
|
||||
if GS.solved_global_variant:
|
||||
name = name.replace('%g', GS.solved_global_variant.file_id)
|
||||
name = name.replace('%G', GS.solved_global_variant.name)
|
||||
|
|
@ -230,7 +229,8 @@ class Optionable(object):
|
|||
name = name.replace('%sf', GS.sch_basename)
|
||||
name = name.replace('%sp', GS.sch_title)
|
||||
name = name.replace('%sr', GS.sch_rev)
|
||||
name = name.replace('%T', GS.time)
|
||||
name = name.replace('%D', GS.n.strftime(GS.global_date_format))
|
||||
name = name.replace('%T', GS.n.strftime(GS.global_time_format))
|
||||
if self:
|
||||
name = name.replace('%i', self._expand_id)
|
||||
name = name.replace('%v', self._find_variant())
|
||||
|
|
|
|||
Loading…
Reference in New Issue