def setUp(self): self.threedi = Threedi() hydx_path = "hydxlib/tests/example_files_structures_hydx/" self.threedi_db_settings = { "threedi_dbname": "test_gwsw", "threedi_host": "localhost", "threedi_user": "******", "threedi_password": "******", "threedi_port": 5432, } self.hydx = import_hydx(hydx_path) self.threedi.import_hydx(self.hydx)
def setUp(self): self.threedi = Threedi() hydx_path = "hydxlib/tests/example_files_structures_hydx/" self.hydx = import_hydx(hydx_path)
def run_import_export(import_type, export_type, hydx_path=None, threedi_db_settings=None): """ Run import and export functionality of hydxlib Args: import_type (str): import operator ["hydx", "threedi"] export_type (str): export operator ["hydx", "threedi", "json"] hydx_path (str): folder with your hydx *.csv files threedi_db_settings (dict): settings of your threedi database Returns: string: "INFO: method is finished" *import_type* hydx threedi (not yet supported) *export_type* hydx (not yet supported) threedi json (not yet supported) *hydx_path* required when selected operator 'hydx' relative or absolute path to your hydx location files example: hydx_path = "hydxlib\\tests\\example_files_structures_hydx" *threedi_db_settings* required when selected operator 'threedi' example: threedi_db_settings = { "threedi_dbname": "test_gwsw", "threedi_host": "localhost", "threedi_user": "******", "threedi_password": TODO_TREEDI_DB_PASSWORD, "threedi_port": 5432, } threedi_dbname (str): name of your threedi database, e.g. test_gwsw threedi_host (str): host of your threedi database, e.g. localhost threedi_user (str): username of your threedi database, e.g. postgres threedi_password (str): password of your threedi database, e.g. postgres threedi_port (int): port of your threedi database, e.g. 5432 usage example: from hydxlib import run_import_export, write_logging_to_file log_relpath = log_relpath = os.path.join( os.path.abspath(options.hydx_path), "import_hydx_hydxlib.log" ) write_logging_to_file(hydx_path) run_import_export(import_type, export_type, hydx_path, threedi_db_settings) """ logger.info("Started exchange of GWSW-hydx at %s", datetime.now()) logger.info("import type %r ", import_type) logger.info("export type %r ", export_type) if import_type == export_type: raise OptionException( "not allowed to use same import and export type %r" % import_type) if import_type == "hydx": hydx = import_hydx(hydx_path) else: raise OptionException("no available import type %r is selected" % import_type) if export_type == "threedi": export_threedi(hydx, threedi_db_settings) else: raise OptionException("no available export type %r is selected" % export_type) logger.info("Exchange of GWSW-hydx finished") return "method is finished" # Return value only for testing