Commit 1f7d1293 authored by Niall McDaid's avatar Niall McDaid
Browse files

rename file_load to parse

parent 5bf359ad
from pathlib import Path
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..file_loader import LasParser, LocalFileLoader, FileUtilities
from ..record_mapper import LasToRecordMapper
from ..configuration import Configuration
from ..json_writer import JsonToFile
logger = get_logger(__name__)
def printlas(input_path):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser = LasParser(LocalFileLoader())
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
print(las_data.header)
def convert(input_path: str, wellbore_id: str, config_path: str = None):
"""
Convert a LAS file to Wellbore and Well Log and write to json files.
:param str input_path: Path and filename of a LAS file or folder containing LAS files
:param str wellbore_id: The wellbore id
:param str config_path: Path to the configuration file
"""
config_path = EnvironmentVarHelper.get_config_path(config_path)
las_parser = LasParser(LocalFileLoader())
config = Configuration(LocalFileLoader(), config_path)
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
mapper = LasToRecordMapper(las_data, config)
wellbore_record = mapper.map_to_wellbore_record()
welllog_record = mapper.map_to_well_log_record(wellbore_id)
path = Path(file_path)
writer = JsonToFile()
writer.write(vars(wellbore_record), path.with_suffix('.wellbore.json'))
logger.warning(f"Wellbore record file created: {path.with_suffix('.wellbore.json')}")
writer.write(vars(welllog_record), path.with_suffix('.welllog.json'))
logger.warning(f"Well log record file created: {path.with_suffix('.welllog.json')}")
from pathlib import Path
from knack.log import get_logger
from ..environment_var_helper import EnvironmentVarHelper
from ..file_loader import LasParser, LocalFileLoader, FileUtilities
from ..record_mapper import LasToRecordMapper
from ..configuration import Configuration
from ..json_writer import JsonToFile
logger = get_logger(__name__)
def printlas(input_path):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser = LasParser(LocalFileLoader())
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
print(las_data.header)
def convert(input_path: str, wellbore_id: str, config_path: str = None):
"""
Convert a LAS file to Wellbore and Well Log and write to json files.
:param str input_path: Path and filename of a LAS file or folder containing LAS files
:param str wellbore_id: The wellbore id
:param str config_path: Path to the configuration file
"""
config_path = EnvironmentVarHelper.get_config_path(config_path)
las_parser = LasParser(LocalFileLoader())
config = Configuration(LocalFileLoader(), config_path)
logger.info(f"LAS path: {input_path}")
for file_path in FileUtilities.get_filenames(Path(input_path), '.las'):
logger.warning(f"LAS file: {file_path}")
las_data = las_parser.load_las_file(file_path)
mapper = LasToRecordMapper(las_data, config)
wellbore_record = mapper.map_to_wellbore_record()
welllog_record = mapper.map_to_well_log_record(wellbore_id)
path = Path(file_path)
writer = JsonToFile()
writer.write(vars(wellbore_record), path.with_suffix('.wellbore.json'))
logger.warning(f"Wellbore record file created: {path.with_suffix('.wellbore.json')}")
writer.write(vars(welllog_record), path.with_suffix('.welllog.json'))
logger.warning(f"Well log record file created: {path.with_suffix('.welllog.json')}")
......@@ -34,7 +34,7 @@ class DdmsCommandLoader(CLICommandsLoader):
def load_command_table(self, args):
"""Load all commands"""
with CommandGroup(self, 'fileload', MODULE_NAME + '.commands.file_load#{}') as group:
with CommandGroup(self, 'parse', MODULE_NAME + '.commands.parse#{}') as group:
group.command('convert', 'convert')
group.command('print', 'printlas')
......@@ -66,11 +66,11 @@ class DdmsCommandLoader(CLICommandsLoader):
help='''The path and filename of the configuration file.
Defaults to \'CONFIGPATH\' environment variable if not set.''')
# 'fileload'
with ArgumentsContext(self, 'fileload') as arg_context:
# 'parse'
with ArgumentsContext(self, 'parse') as arg_context:
self._register_input_path_argument(arg_context)
with ArgumentsContext(self, 'fileload convert') as arg_context:
with ArgumentsContext(self, 'parse convert') as arg_context:
self._register_wellbore_id_flag(arg_context)
# 'ingest'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment