예제 #1
0
파일: zgoubi.py 프로젝트: ahebnl/Sirepo
def _prepare_tosca_element(el):
    el.MOD = _MAGNET_TYPE_TO_MOD[el.meshType][el.magnetType]
    if '{{ fileCount }}' in el.MOD:
        el.MOD = el.MOD.replace('{{ fileCount }}', str(el.fileCount))
        el.hasFields = True
    file_count = zgoubi_parser.tosca_file_count(el)
    el.fileNames = el.fileNames[:file_count]

    filename = _SIM_DATA.lib_file_name_with_model_field('TOSCA', 'magnetFile', el.magnetFile)
    if file_count == 1 and not zgoubi_importer.is_zip_file(filename):
        el.fileNames[0] = _SIM_DATA.lib_file_name_with_model_field('TOSCA', 'magnetFile', el.fileNames[0])
예제 #2
0
파일: zgoubi.py 프로젝트: ahebnl/Sirepo
def write_parameters(data, run_dir, is_parallel, python_file=template_common.PARAMETERS_PYTHON_FILE):
    pkio.write_text(
        run_dir.join(python_file),
        _generate_parameters_file(data),
    )
    # unzip the required magnet files
    for el in data.models.elements:
        if el.type != 'TOSCA':
            continue
        filename = str(run_dir.join(_SIM_DATA.lib_file_name_with_model_field('TOSCA', 'magnetFile', el.magnetFile)))
        if zgoubi_importer.is_zip_file(filename):
            with zipfile.ZipFile(filename, 'r') as z:
                for info in z.infolist():
                    if info.filename in el.fileNames:
                        z.extract(info, str(run_dir))