Example #1
0
 def copy_file_with_pattern(self, path, patterns, exclude):
     """
     Copy a single file or regex, creating the necessary directories
     But grepping for pattern(s)
     """
     if "*" in path:
         paths = _expand_paths(path)
         if not paths:
             logger.debug("Could not expand %s", path)
             return
         for path in paths:
             self._copy_file_with_pattern(path, patterns, exclude)
     else:
         self._copy_file_with_pattern(path, patterns, exclude)
 def copy_file_with_pattern(self, path, patterns, exclude):
     """
     Copy a single file or regex, creating the necessary directories
     But grepping for pattern(s)
     """
     if "*" in path:
         paths = _expand_paths(path)
         if not paths:
             logger.debug("Could not expand %s", path)
             return
         for path in paths:
             self._copy_file_with_pattern(path, patterns, exclude)
     else:
         self._copy_file_with_pattern(path, patterns, exclude)
 def copy_file(self, path):
     """
     Copy a single file or regex, creating the necessary directories
     """
     if "*" in path:
         paths = _expand_paths(path)
         if paths:
             for path in paths:
                 self._copy_file(path)
     else:
         if os.path.isfile(path):
             return self._copy_file(path)
         else:
             logger.debug("File %s does not exist", path)
             return False
    def _parse_file_spec(self, spec):
        '''
        Separate wildcard specs into more specs
        '''
        # separate wildcard specs into more specs
        if '*' in spec['file']:
            expanded_paths = _expand_paths(spec['file'].replace(
                '{CONTAINER_MOUNT_POINT}', self.mountpoint).replace(
                '{DOCKER_IMAGE_NAME}', self.target_name).replace(
                '{DOCKER_CONTAINER_NAME}', self.target_name))
            if not expanded_paths:
                return []

            expanded_specs = []
            for p in expanded_paths:
                _spec = copy.copy(spec)
                _spec['file'] = p
                expanded_specs.append(_spec)
            return expanded_specs

        else:
            return [spec]
Example #5
0
    def _parse_file_spec(self, spec):
        '''
        Separate wildcard specs into more specs
        '''
        # separate wildcard specs into more specs
        if '*' in spec['file']:
            expanded_paths = _expand_paths(spec['file'].replace(
                '{CONTAINER_MOUNT_POINT}', self.mountpoint).replace(
                    '{DOCKER_IMAGE_NAME}',
                    self.target_name).replace('{DOCKER_CONTAINER_NAME}',
                                              self.target_name))
            if not expanded_paths:
                return []

            expanded_specs = []
            for p in expanded_paths:
                _spec = copy.copy(spec)
                _spec['file'] = p
                expanded_specs.append(_spec)
            return expanded_specs

        else:
            return [spec]