def get_localizer_file_path(self, ldir, fpath): if file_utils.is_absolute_path(fpath): if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return fpath else: fpath = os.path.abspath(os.path.join(ldir, fpath)) if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return fpath
def get_deps_dir_path(fpath): from arjuna.core.utils import file_utils if file_utils.is_absolute_path(fpath): if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception("Not a directory: {}".format(fpath)) return fpath else: fpath = os.path.abspath( os.path.join( self.ref_config.value(ArjunaOption.PROJECT_ROOT_DIR), fpath)) if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception("Not a directory: {}".format(fpath)) return fpath
def load_options_from_file(self, fpath): if file_utils.is_absolute_path(fpath): if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) else: from arjuna import Arjuna, ArjunaOption conf_dir = self.__default_ref_config.arjuna_options.value( ArjunaOption.CONF_DIR) fpath = os.path.abspath(os.path.join(conf_dir, fpath)) if not file_utils.is_file(fpath): if file_utils.is_dir(fpath): raise Exception("Not a file: {}".format(fpath)) else: raise Exception("File does not exist: {}".format(fpath)) return EditableConfig.from_file( file_path=fpath, creation_context=f"Ad-hoc configuration file at {fpath}")
def __init__(self, path=None, delimiter="\t"): super().__init__() self.path = path self.delimiter = delimiter data_dir = Arjuna.get_central_config().get_arjuna_option_value(ArjunaOption.DATA_SOURCES_DIR).as_str() if file_utils.is_absolute_path(self.path): if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path)) else: self.path = os.path.abspath(os.path.join(data_dir, self.path)) if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path))
def get_arjuna_project_path_and_name(fpath): from arjuna.core.utils import file_utils if not file_utils.is_absolute_path(fpath): fpath = os.path.abspath(os.path.join(project_root_dir, fpath)) if not file_utils.is_dir(fpath): if file_utils.is_file(fpath): raise Exception( "The Linked Arjuna Project path is a file. It should be a directory: {}" .format(fpath)) else: raise Exception( "The Linked Arjuna Project path does not exist: {}". format(fpath)) else: if not os.path.exists( os.path.join(fpath, "script", "arjuna_launcher.py")): raise Exception( "The Linked Arjuna Project path exists but is not an Arjuna test project: {}" .format(fpath)) return os.path.basename(fpath), fpath, os.path.abspath(fpath + "/..")