예제 #1
0
    def resolve(
            self,
            line,  # type: LogicalLine
            origin,  # type: str
            is_constraints=False,  # type: bool
            fetcher=None,  # type: Optional[URLFetcher]
    ):
        # type: (...) -> Iterator[Source]
        def create_parse_error(msg):
            # type: (str) -> ParseError
            return ParseError(
                line,
                "Problem resolving {} file: {}".format(
                    "constraints" if is_constraints else "requirements", msg),
            )

        url = urlparse.urlparse(urlparse.urljoin(self.origin, origin))
        if url.scheme and url.netloc:
            if fetcher is None:
                raise create_parse_error(
                    "The source is a url but no fetcher was supplied to resolve its contents with."
                )
            try:
                with self.from_url(fetcher, origin) as source:
                    yield source
            except OSError as e:
                raise create_parse_error(str(e))
            return

        path = url.path if url.scheme == "file" else origin
        try:
            with self.from_file(path, is_constraints=is_constraints) as source:
                yield source
        except (IOError, OSError) as e:
            raise create_parse_error(str(e))
예제 #2
0
파일: link.py 프로젝트: jsirois/pex
  def join(self, href):
    """Given a href relative to this link, return the :class:`Link` of the absolute url.

    :param href: A string-like path relative to this link.
    """
    return self.wrap(urlparse.urljoin(self.url, href))
예제 #3
0
파일: link.py 프로젝트: zuoxiaolei/pex
    def join(self, href):
        """Given a href relative to this link, return the :class:`Link` of the absolute url.

    :param href: A string-like path relative to this link.
    """
        return self.wrap(urlparse.urljoin(self.url, href))
예제 #4
0
파일: link.py 프로젝트: jsirois/pex
 def _normalize(cls, filename):
   return urlparse.urljoin('file:', pathname2url(
       os.path.realpath(os.path.expanduser(filename))))
예제 #5
0
파일: link.py 프로젝트: zuoxiaolei/pex
 def _normalize(cls, filename):
     return urlparse.urljoin(
         'file:',
         pathname2url(os.path.realpath(os.path.expanduser(filename))))