Closed demisjohn closed 4 years ago
How to import all files in a subfolder, in attached file.
import os # file path manipulations import glob # file-name matching
all = [ os.path.basename(f)[:-3] for f in glob.glob( os.path.dirname(file) + "/*.py" ) ]
Initial implementation in: 070b87965d9a3b3f8a76125b4b09cc2dc12d4d2d Used these hints:
.
: https://stackoverflow.com/questions/34753206/init-py-cant-find-local-modulesimportlib.import_module()
documentation: https://docs.python.org/3/library/importlib.htmlUsage is a bit ugly, because it doesn't get added directly to the Job like a normal Image would.
Example usage:
import ASML_JobCreator.Images as Images
PM = Images.PM.get_Image()
MyJob.add_Images( PM )
PM.distribute( cellCR=[4,4], shiftXY=[2.00, 2.00] )
PM.distribute( cellCR=[4,4], shiftXY=[-2.00, -2.00] )
PM.distribute( cellCR=[4,4], shiftXY=[-2.00, 2.00] )
PM.distribute( cellCR=[4,4], shiftXY=[2.00, -2.00] )
Would like instead to use like so:
MyJob.add_Images( asml.Images.PM )
PM.distribute( cellCR=[4,4], shiftXY=[2.00, 2.00] )
This requires
Images objects
inside the files *.py
to be visible in it's namespace, andASML_JobCreator
's __init__.py
makes Images
available in it's namespace after importing.Improved this in 2a0d3cc, new syntax is much simpler (same as regular Image def.):
SPM_X = MyJob.Image( asml.Images.SPM_X )
in Images/__init__.py
,
Used this hint: https://stackoverflow.com/a/11553818/2453202
and iterated through the file list and had to require that the user set the Image object's name the same as the file basename.
predefined images (in separate module sub-folder, imported into Images namespace?)
Eg.
ImagePF=MyJob.Images.MarkClearout - pre-defined image for this ImagePM=MyJob.Images.PrimaryMark/SPM_X/SPM_Y- pre-defined image for this ImagePM=MyJob.Images.UCSB_Res/ResOPC/MA6/EBLpos+neg/GCA
Envision a sub-folder, eg.
ASML_JobCreator/Images/
with separate files for each predefined Image.ASML_JobCreator/Images/__init__.py
would import each file in the folder into theImages
namespace.Each file could be like this:
Images/UCSB_Res.py
ImageID = "UCSB_Res" ReticleID = "UCSB-OPC1" ImageSize = [5, 5] ImageShift = [-3, 4]