示例#1
0
 def __init__(self, action_element):
     """Initialize file search"""
     self.regex = action_element.getAttribute('regex')
     assert (isinstance(self.regex, (str, unicode, types.NoneType)))
     self.nregex = action_element.getAttribute('nregex')
     assert (isinstance(self.nregex, (str, unicode, types.NoneType)))
     self.wholeregex = action_element.getAttribute('wholeregex')
     assert (isinstance(self.wholeregex, (str, unicode, types.NoneType)))
     self.nwholeregex = action_element.getAttribute('nwholeregex')
     assert (isinstance(self.nwholeregex, (str, unicode, types.NoneType)))
     self.search = action_element.getAttribute('search')
     self.object_type = action_element.getAttribute('type')
     self.path = expanduser(expandvars(action_element.getAttribute('path')))
     if 'nt' == os.name and self.path:
         # convert forward slash to backslash for compatibility with getsize()
         # and for display.  Do not convert an empty path, or it will become
         # the current directory (.).
         self.path = os.path.normpath(self.path)
     self.ds = {}
     if 'deep' == self.search:
         self.ds['regex'] = self.regex
         self.ds['nregex'] = self.nregex
         self.ds['cache'] = General.boolstr_to_bool(
             action_element.getAttribute('cache'))
         self.ds['command'] = action_element.getAttribute('command')
         self.ds['path'] = self.path
     if not any([
             self.object_type, self.regex, self.nregex, self.wholeregex,
             self.nwholeregex
     ]):
         # If the filter is not needed, bypass it for speed.
         self.get_paths = self._get_paths
示例#2
0
 def __init__(self, action_element, path_vars=None):
     """Initialize file search"""
     self.regex = action_element.getAttribute('regex')
     assert(isinstance(self.regex, (str, unicode, types.NoneType)))
     self.nregex = action_element.getAttribute('nregex')
     assert(isinstance(self.nregex, (str, unicode, types.NoneType)))
     self.wholeregex = action_element.getAttribute('wholeregex')
     assert(isinstance(self.wholeregex, (str, unicode, types.NoneType)))
     self.nwholeregex = action_element.getAttribute('nwholeregex')
     assert(isinstance(self.nwholeregex, (str, unicode, types.NoneType)))
     self.search = action_element.getAttribute('search')
     self.object_type = action_element.getAttribute('type')
     self._set_paths(action_element.getAttribute('path'), path_vars)
     self.ds = {}
     if 'deep' == self.search:
         self.ds['regex'] = self.regex
         self.ds['nregex'] = self.nregex
         self.ds['cache'] = General.boolstr_to_bool(
             action_element.getAttribute('cache'))
         self.ds['command'] = action_element.getAttribute('command')
         self.ds['path'] = self.paths[0]
         if not len(self.paths) == 1:
             logger.warning(
                 'deep scan does not support multi-value variables')
     if not any([self.object_type, self.regex, self.nregex,
                 self.wholeregex, self.nwholeregex]):
         # If the filter is not needed, bypass it for speed.
         self.get_paths = self._get_paths
示例#3
0
 def __init__(self, action_element, path_vars=None):
     """Initialize file search"""
     self.regex = action_element.getAttribute('regex')
     assert(isinstance(self.regex, (str, unicode, types.NoneType)))
     self.nregex = action_element.getAttribute('nregex')
     assert(isinstance(self.nregex, (str, unicode, types.NoneType)))
     self.wholeregex = action_element.getAttribute('wholeregex')
     assert(isinstance(self.wholeregex, (str, unicode, types.NoneType)))
     self.nwholeregex = action_element.getAttribute('nwholeregex')
     assert(isinstance(self.nwholeregex, (str, unicode, types.NoneType)))
     self.search = action_element.getAttribute('search')
     self.object_type = action_element.getAttribute('type')
     self._set_paths(action_element.getAttribute('path'), path_vars)
     self.ds = {}
     if 'deep' == self.search:
         self.ds['regex'] = self.regex
         self.ds['nregex'] = self.nregex
         self.ds['cache'] = General.boolstr_to_bool(
             action_element.getAttribute('cache'))
         self.ds['command'] = action_element.getAttribute('command')
         self.ds['path'] = self.paths[0]
         if not len(self.paths) == 1:
             logger.warning(
                 'deep scan does not support multi-value variables')
     if not any([self.object_type, self.regex, self.nregex,
                 self.wholeregex, self.nwholeregex]):
         # If the filter is not needed, bypass it for speed.
         self.get_paths = self._get_paths