def do_transform(con_file, yaml_file, dest_file, transformation_name): cfg.init(None) if con_file: cfg.import_file(con_file) source_file = con_file elif yaml_file: cfg.open_file(yaml_file) source_file = yaml_file # check destination file if dest_file: file = dest_file else: file = os.path.splitext(source_file)[0] + '.yaml' # replace extension if os.path.isfile(file): raise Exception("File already exists") # apply transformations if transformation_name is not None: for transf in transformation_name: cfg.transform(transf) file_d = open(file, 'w') file_d.write(cfg.document) file_d.close()
def main(): """Launches the import cli.""" parser = argparse.ArgumentParser( description='Import the YAML configuration file from CON format') parser.add_argument('--transformation-name', nargs='*', help='Transformation rules contained in the Model Editor that are ' 'processed after import') parser.add_argument('--destination-file', nargs='?', default=None, help='The destination file if is different from source file') parser.add_argument('--con_file', help='CON input file', required=True) args = parser.parse_args() if args.destination_file: file = args.destination_file else: file = os.path.splitext(args.con_file)[0] + '.yaml' # replace extension if os.path.isfile(file): raise Exception("File already exists") cfg.init(None) cfg.import_file(args.con_file) if args.transformation_name is not None: for transf in args.transformation_name: cfg.transform(transf) file_d = open(file, 'w') file_d.write(cfg.document) file_d.close()
def __init__(self): # load config cfg.init(None) # main window self._app = QtWidgets.QApplication(sys.argv) self._app.setWindowIcon(icon.get_app_icon("me-geomap")) self.mainwindow = MainWindow(self) cfg.main_window = self.mainwindow # set default values self._update_document_name() # show self.mainwindow.show()
def main(): """Launches the export cli.""" parser = argparse.ArgumentParser( description='Export the YAML configuration file to CON format') parser.add_argument('--destination-file', nargs='?', default=None, help='The destination file if is different from source file') parser.add_argument('--yaml_file', help='YAML input file', required=True) args = parser.parse_args() if args.destination_file: file = args.destination_file else: file = os.path.splitext(args.yaml_file)[0] + '.con' # replace extension if os.path.isfile(file): raise Exception("File already exists") cfg.init(None) if cfg.open_file(args.yaml_file): con_text = cfg.export_file() file_d = open(file, 'w') file_d.write(con_text) file_d.close()