Ejemplo n.º 1
0
    def __init__(self, query, is_regex=False):
        """Create query object.

		@type is_regex: bool
		@param is_regex: query is a regular expression
		"""

        # We need at least one of these chars for a valid query
        needed_chars = ascii_letters + '*'
        if not set(query).intersection(needed_chars):
            raise errors.GentoolkitInvalidPackage(query)

        # Separate repository
        repository = None
        if query.count(':') == 2:
            query, repository = query.rsplit(':', 1)
        self.query = query.rstrip(':')  # Don't leave dangling colon
        self.repo_filter = repository
        self.is_regex = is_regex
        self.query_type = self._get_query_type()

        # Name the rest of the chunks, if possible
        if self.query_type != "set":
            try:
                atom = Atom(self.query)
                self.__dict__.update(atom.__dict__)
            except errors.GentoolkitInvalidAtom:
                CPV.__init__(self, self.query)
                self.operator = ''
                self.atom = self.cpv
Ejemplo n.º 2
0
    def __init__(self, cpv, validate=False, local_config=True):
        if isinstance(cpv, CPV):
            self.__dict__.update(cpv.__dict__)
        else:
            CPV.__init__(self, cpv, validate=validate)

        if validate and not all(
                hasattr(self, x) for x in ('category', 'version')):
            # CPV allows some things that Package must not
            raise errors.GentoolkitInvalidPackage(self.cpv)

        if local_config:
            self._settings = default_settings
        else:
            self._settings = nolocal_settings

        # Set dynamically
        self._package_path = None
        self._dblink = None
        self._metadata = None
        self._deps = None
        self._portdir_path = None