def exists(self, path: str) -> bool: """Checks, whether a given path or file exists. Args: path: Path to check. Returns: Whether it exists or not """ # split root if not path.endswith("/"): path += "/" root, path = VirtualFileSystem.split_root(path) # get root class from pyobs.object import get_class_from_string klass = get_class_from_string(self._roots[root]["class"]) # get exists method exists = getattr(klass, "exists") # and call it return exists(path, **self._roots[root])
def find(self, path: str, pattern: str): """Find a file in the given path. Args: path: Path to search in. pattern: Pattern to search for. Returns: List of found files. """ # split root if not path.endswith("/"): path += "/" root, path = VirtualFileSystem.split_root(path) # get root class from pyobs.object import get_class_from_string klass = get_class_from_string(self._roots[root]["class"]) # get find method find = getattr(klass, "find") # and call it return find(path, pattern, **self._roots[root])
def __init__(self, triggers: list, *args, **kwargs): """Initialize a new trigger module. Args: triggers: List of dictionaries defining the trigger. Must contain fields for event, module and method, may contain a sender. """ Module.__init__(self, *args, **kwargs) # store self._running = False # store triggers and convert event strings to actual classes self._triggers = triggers for trigger in self._triggers: # get class and store it kls = get_class_from_string(trigger['event']) trigger['event'] = kls
def exists(self, path: str) -> bool: """Checks, whether a given path or file exists. Args: path: Path to check. Returns: Whether it exists or not """ # split root if not path.endswith('/'): path += '/' root, path = VirtualFileSystem.split_root(path) # get root class klass = get_class_from_string(self._roots[root]['class']) # get exists method exists = getattr(klass, 'exists') # and call it return exists(path, **self._roots[root])
def find(self, path: str, pattern: str): """Find a file in the given path. Args: path: Path to search in. pattern: Pattern to search for. Returns: List of found files. """ # split root if not path.endswith('/'): path += '/' root, path = VirtualFileSystem.split_root(path) # get root class klass = get_class_from_string(self._roots[root]['class']) # get find method find = getattr(klass, 'find') # and call it return find(path, pattern, **self._roots[root])