def add(self, package=None, filename=None, glob=None): """ Add launch or other configuration files to Job. Files may be specified using relative, absolute, or package-relative paths. Files may also be specified using shell globs. :param package: Optionally specify a package to search for the file or glob relative-to. :type package: str :param filename: Name of a file to add to the job. Relative to the package path, if specified. :type filename: str :param glob: Shell glob of files to add to the job. Relative to the package path, if specified. :type glob: str """ if package: search_paths = reversed(find_in_workspaces(project=package)) else: search_paths = ('.',) if glob and filename: raise RuntimeError("You must specify only an exact filename or a glob, not both.") # See: https://docs.python.org/2/library/os.html#os.getlogin if filename: for path in search_paths: candidate = os.path.join(path, filename) if os.path.isfile(candidate): self.files.append(candidate) if glob: for path in search_paths: self.files.extend(glob_files(os.path.join(path, glob)))
def get_objs(self, fileglob='**/*'): # Default **/* is any file in folder, recursively return map(self._load_obj, \ glob_files(self._fullpath_from(fileglob), recursive=True))