# autolatex - xmi2pdf_umbrello.transdef2 # -*- coding: utf-8 -*- # # Copyright (C) 1998-2026 Stephane Galland # # This program is free library; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 3 of the # License, or any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; see the file COPYING. If not, # write to the Free Software Foundation, Inc., 59 Temple Place - Suite # 330, Boston, MA 02111-1307, USA. --- input_extensions: - .xmi output_extensions for pdf: - .pdf output_extensions for eps: - .eps all_output_files: - ${outwoext}_*${outext} - $out translator_python_dependencies: - os - re - shutil - from pathlib import Path - import autolatex2.utils.utilfunctions as genutils translator_function: | umbrello_cmd = shutil.which('umbrello') if not umbrello_cmd: umbrello_cmd = shutil.which('umbrello5') if not umbrello_cmd: umbrello_cmd = shutil.which('umbrello6') if not umbrello_cmd: raise Exception('Cannot find the umbrello binary file') outdir = genutils.basename2(_out, _outexts) if os.path.isdir(outdir): shutil.rmtree(outdir) os.makedirs(outdir, exist_ok=True) try: runner_output = Runner.run_command(umbrello_cmd, '--export', 'eps', '--directory', outdir, _in) Runner.check_runner_status(runner_output) generatedFiles = list() with os.scandir(outdir) as fdir: for fn in fdir: if fn.is_file(): nm = fn.name if nm != '..' and nm != '.' and nm.lower().endswith('.eps'): ffn = os.path.join(outdir, nm) if os.path.isfile(ffn): generatedFiles.append(ffn) if _pdfmode: if len(generatedFiles) > 1: template = genutils.basename2(_out, _outexts) + '_' for file in generatedFiles: bn = genutils.basename(file, ['.eps']) bn = re.sub('\\s+', '_', bn) outfile = template + bn + '.pdf' _runner.generate_image(in_file = file, out_file = outfile, only_more_recent = False) Path(_out).touch() elif len(generatedFiles) > 0: file = generatedFiles[0] _runner.generate_image(in_file = file, out_file = _out, only_more_recent = False) else: raise Exception("No file generated") else: if len(generatedFiles) > 1: template = genutils.basename2(_out, _outexts) + '_' for file in generatedFiles: bn = os.path.basename(file) bn = re.sub('\\s+', '_', bn) outfile = template + bn shutil.move(file, outfile) Path(_out).touch() elif len(generatedFiles) > 0: file = generatedFiles[0] shutil.move(file, _out) else: raise Exception("No file generated") finally: if os.path.isdir(outdir): shutil.rmtree(outdir) ...