Commons component plugin - Macros - Substitute dates¶
Contents :
- # SUBSTITUTE DATES IN {files} AS {processed_files}
- # SUBSTITUTE DATES IN {files} FOR FILES WHOSE NAMES MATCHING {regex} AS {processed_files}
- # SUBSTITUTE DATES IN {files} FOR FILES WHOSE NAMES NOT MATCHING {regex} AS {processed_files}
- # SUBSTITUTE DATES IN {files} USING {dates} AS {processed_files}
- # SUBSTITUTE DATES IN {files} USING {dates} FOR FILES WHOSE NAMES MATCHING {regex} AS {processed_files}
- # SUBSTITUTE DATES IN {files} USING {dates} FOR FILES WHOSE NAMES NOT MATCHING {regex} AS {processed_files}
# SUBSTITUTE DATES IN {files} AS {processed_files}¶
What ?
This macro allows to replace dates in a bundle of files. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.
> Output :
{processed_files}
: The bundle of files that have been processed.
Example :
# SUBSTITUTE DATES IN resources_folder AS result_bundle First file to process :
Second file to process :
The folder containing files to process which corresponds to
{files}
:SKF script :
In order to check that the macro worked properly, we added in this example the instruction “LOAD result AS resultOutput” to be able to see the result output.
You can access to the result output in the following folder which contains temporary files :
C:\Users\*user name*\AppData\Local\Temp\Squash_TA\20190909_121048_957615127627872437436\tests\tests\substitute_dates.ta\date88302692580700934357655997463584302temp Result output for first file (script executed on 09/09/2019) :
Result output for second file :
# SUBSTITUTE DATES IN {files} FOR FILES WHOSE NAMES MATCHING {regex} AS {processed_files}¶
What ?
This macro allows to replace dates in a bundle of files whose names match a specific regular expression. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) USING $(squashtest.ta.param.include:{regex}) AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.{regex}
: The regular expression used to filter the files in the bundle.
> Output :
{processed_files}
: The bundle of filtered files that have been processed.
Example :
# SUBSTITUTE DATES IN resources_folder FOR FILES WHOSE NAMES MATCHING .xml AS result_bundle This example is based on the previous one. For more details, please check here.
SKF script :
Console output :
The .txt file which does not match the selected regex is properly excluded.
Result output for first file :
Result output for second file :
The .txt file is not processed whereas the .xml is.
# SUBSTITUTE DATES IN {files} FOR FILES WHOSE NAMES NOT MATCHING {regex} AS {processed_files}¶
What ?
This macro allows to replace dates in a bundle of files whose names don’t match a specific regular expression. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) USING $(squashtest.ta.param.exclude:{regex}) AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.{regex}
: The regular expression used to filter the files in the bundle.
> Output :
{processed_files}
: The bundle of filtered files that have been processed.
Example :
# SUBSTITUTE DATES IN resources_folder FOR FILES WHOSE NAMES NOT MATCHING .xml AS result_bundle This example is based on the first one. For more details, please check here.
SKF script :
Console output :
The .xml file which match the selected regex is properly excluded.
Result output for first file :
Result output for second file :
The .xml file is not processed whereas the .txt is.
# SUBSTITUTE DATES IN {files} USING {dates} AS {processed_files}¶
What ?
This macro allows to replace dates in a bundle of files with dates you have specified. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {dates} AS placeholder{%%rand2}.file
CONVERT placeholder{%%rand2}.file TO properties(structured) AS placeholder{%%rand3}.properties
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) USING placeholder{%%rand3}.properties AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.{dates}
: It can either be a path to a properties file or an inline command with keys and values for the dates you want to specify.
Example of inline command : $(date1=01/01/2001 \n date2=31/12/2018). Example of date in file to process : ${date(date1,dd/MM/yyyy).format(dd-MM-yyyy)}
> Output :
{processed_files}
: The bundle of files that have been processed.
Examples :
# SUBSTITUTE DATES IN resources_folder USING resources_folder/dates.properties AS result_bundle Or
# SUBSTITUTE DATES IN resources_folder USING $(date1=01/01/2001 \n date2=31/12/2018) AS result_bundle This example is based on the first one. For more details, please check here.
File to process :
.properties File :
.properties File Location :
SKF script :
Console output :
Result output :
# SUBSTITUTE DATES IN {files} USING {dates} FOR FILES WHOSE NAMES MATCHING {regex} AS {processed_files}¶
What ?
This macro allows to replace dates (with dates you have specified) in a bundle of files whose names match a specific regular expression. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {dates} AS placeholder{%%rand2}.file
CONVERT placeholder{%%rand2}.file TO properties(structured) AS placeholder{%%rand3}.properties
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) USING placeholder{%%rand3}.properties,$(squashtest.ta.param.include:{regex}) AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.{dates}
: It can either be a path to a properties file or an inline command with keys and values for the dates you want to specify.
Example of inline command : $(date1=01/01/2001 \n date2=31/12/2018). Example of date in file to process : ${date(date1,dd/MM/yyyy).format(dd-MM-yyyy)}
{regex}
: The regular expression used to filter the files in the bundle.
> Output :
{processed_files}
: The bundle of filtered files that have been processed.
Examples :
# SUBSTITUTE DATES IN resources_folder USING resources_folder/dates.properties FOR FILES WHOSE NAMES MATCHING .xml AS result_bundle |
Or
# SUBSTITUTE DATES IN resources_folder USING $(date1=01/01/2001 \n date2=31/12/2018) FOR FILES WHOSE NAMES MATCHING .xml AS result_bundle |
For more infomation, please check this example and this one.
# SUBSTITUTE DATES IN {files} USING {dates} FOR FILES WHOSE NAMES NOT MATCHING {regex} AS {processed_files}¶
What ?
This macro allows to replace dates (with dates you have specified) in a bundle of files whose names don’t match a specific regular expression. For more information about the formulas to use in order to replace dates, please check this page.
Underlying instruction :
LOAD {dates} AS placeholder{%%rand2}.file
CONVERT placeholder{%%rand2}.file TO properties(structured) AS placeholder{%%rand3}.properties
LOAD {files} AS __bundle{%%rand1}
CONVERT __bundle{%%rand1} TO file(param.relativedate) USING placeholder{%%rand3}.properties,$(squashtest.ta.param.exclude:{regex}) AS {processed_files}
> Input :
{files}
: The bundle of files where you want to apply the substitution.{dates}
: It can either be a path to a properties file or an inline command with keys and values for the dates you want to specify.
Example of inline command : $(date1=01/01/2001 \n date2=31/12/2018). Example of date in file to process : ${date(date1,dd/MM/yyyy).format(dd-MM-yyyy)}
{regex}
: The regular expression used to filter the files in the bundle.
> Output :
{processed_files}
: The bundle of filtered files that have been processed.
Examples :
# SUBSTITUTE DATES IN resources_folder USING resources_folder/dates.properties FOR FILES WHOSE NAMES NOT MATCHING .txt AS result_bundle |
Or
# SUBSTITUTE DATES IN resources_folder USING $(date1=01/01/2001 \n date2=31/12/2018) FOR FILES WHOSE NAMES NOT MATCHING .txt AS result_bundle |
For more infomation, please check this example and this one.