def _process_srcs(self, srcs):
        """
        Process sources which could be regular files, directories or
        location references.
        """
        for s in srcs:
            if isinstance(s, tuple):
                src, dst = s
            elif isinstance(s, str):
                src, dst = s, ''
            else:
                self.error_exit('Invalid src %s. src should be either str or tuple.' % s)

            m = LOCATION_RE.search(src)
            if m:
                self._add_location_reference(m, dst)
            else:
                self._add_package_source(src, dst)
Beispiel #2
0
    def _process_test_data(self, testdata):
        """
        Process test data of which the source could be regular file
        or location reference.
        """
        self.data['testdata'], self.data['locations'] = [], []
        for td in testdata:
            if isinstance(td, tuple):
                src, dst = td
            elif isinstance(td, str):
                src, dst = td, ''
            else:
                self.error_exit('Invalid testdata %s. Test data should be either str or tuple.' % td)

            m = LOCATION_RE.search(src)
            if m:
                key, type = self._add_location_reference_target(m)
                self.data['locations'].append((key, type, dst))
            else:
                self.data['testdata'].append(td)
Beispiel #3
0
    def _process_resources(self, resources):
        """
        Process resources which could be regular files/directories or
        location references.
        """
        self.data['resources'], self.data['location_resources'] = [], []
        for resource in resources:
            if isinstance(resource, tuple):
                src, dst = resource
            elif isinstance(resource, str):
                src, dst = resource, ''
            else:
                self.error_exit('Invalid resource %s. Resource should be either a str or a tuple.' %
                                resource)

            m = LOCATION_RE.search(src)
            if m:
                key, type = self._add_location_reference_target(m)
                self.data['location_resources'].append((key, type, dst))
            else:
                self.data['resources'].append((src, dst))