Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/__pycache__/req_file.cpython-35.pyc



t_K@sedZddlmZddlZddlZddlZddlZddlZddlm	Z
ddlmZddl
mZmZddlmZddlmZdd	lmZdd
lmZddlmZerddlmZdd
lmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ee$e)e#fZ*ee#ge$e+effZ,dgZ-ej.dej/Z0ej.dZ1ej.dZ2ej3ej4ej5ej6ej7ej8ej9ej:ej;ej<ej=ej>ej?ej@gZAejBejCejDgZEddeEDZFGdddeGZHGdddeGZIddddddZJddZKdddZLdddd d!ZMdddd"d#ZNGd$d%d%eGZOd&d'ZPd(d)ZQGd*d+d+eRZSd,d-ZTd.d/ZUd0d1ZVd2d3ZWdd4d5ZXej.d6ej/ZYdS)7z
Requirements file parsing
)absolute_importN)parse)
cmdoptions)InstallationErrorRequirementsFileParseError)SearchScope)raise_for_status)auto_decode)MYPY_CHECK_RUNNING)get_url_scheme)Values)	AnyCallableDictIteratorListNoReturnOptionalTextTuple)
PackageFinder)
PipSessionparse_requirementsz^(http|https|file):z(^|\s+)#.*$z#(?P<var>\$\{(?P<name>[A-Z0-9_]+)\})cCs"g|]}t|jqS)strdest).0orr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.py
<listcomp>Ls	rc@s"eZdZddddZdS)ParsedRequirementNcCs:||_||_||_||_||_||_dS)N)requirementis_editable
comes_fromoptions
constraintline_source)selfr!r"r#r%r$r&rrr__init__Ps
					zParsedRequirement.__init__)__name__
__module____qualname__r(rrrrr Osr c@seZdZddZdS)
ParsedLinecCs||_||_||_||_||_|rQd|_d|_||_n7|jrd|_d|_|jd|_n	d|_dS)NTFr)	filenamelinenor#optsr%is_requirementr"r!	editables)r'r-r.r#argsr/r%rrrr(cs
										zParsedLine.__init__N)r)r*r+r(rrrrr,bsr,Fc
	csnt|}t|||}xI|j||D]5}t|d|d|d|}	|	dk	r1|	Vq1WdS)aParse a requirements file and yield ParsedRequirement instances.

    :param filename:    Path or url of requirements file.
    :param session:     PipSession instance.
    :param finder:      Instance of pip.index.PackageFinder.
    :param comes_from:  Origin description of requirements.
    :param options:     cli options.
    :param constraint:  If true, parsing a constraint file rather than
        requirements file.
    r$findersessionN)get_line_parserRequirementsFileParserrhandle_line)
r-r4r3r#r$r%line_parserparserparsed_line
parsed_reqrrrrs	cCs@t|jdd}t|}t|}t|}|S)zxSplit, filter, and join lines, and return a line iterator

    :param content: the content of the requirements file
    start)	enumerate
splitlines
join_linesignore_commentsexpand_env_variables)content
lines_enumrrr
preprocesss
rEc
Cs dj|jrdnd|j|j}|js9t|jrjtd|jd|jd|d|jS|rt	j
||ji}xDtD]<}||jj
kr|jj
|r|jj
|||<qWdj|j|j}td|jd|jd|d|jd	|d
|SdS)Nz{} {} (line {})z-cz-rr!r"r#r%z
line {} of {}r$r&)formatr%r-r.r0AssertionErrorr"r r!rcheck_install_build_globalr/SUPPORTED_OPTIONS_REQ_DEST__dict__)liner$line_comes_fromreq_optionsrr&rrrhandle_requirement_lines.$			

"			rNcsrJ|jr|j_|jrJjjfdd|jD|r|j}|j}|jrw|jg}|jdkrg}|jr|j|j|jr|jd}tj	j
tj	j|}	tj	j|	|}
tj	j
|
r|
}|j|td|d|}||_|jrD|j|jrW|j|rx<|jplgD]+}dj||}
|j|d|
qmWdS)	Nc3s$|]}|jkr|VqdS)N)features_enabled)rf)r$rr	<genexpr>sz%handle_option_line.<locals>.<genexpr>Tr
find_links
index_urlsz
line {} of {}source)require_hashesrOextendrRrS	index_urlno_indexextra_index_urlsospathdirnameabspathjoinexistsappendrsearch_scopepreset_allow_all_prereleases
prefer_binaryset_prefer_binary
trusted_hostsrFadd_trusted_host)r/r-r.r3r$r4rRrSvaluereq_dirrelative_to_reqs_filerahostrTr)r$rhandle_option_linesD
								

			
	
rlcCsF|jrt||}|St|j|j|j|||dSdS)aHandle a single parsed requirements line; This can result in
    creating/yielding requirements, or updating the finder.

    :param line:        The parsed line to be processed.
    :param options:     CLI options.
    :param finder:      The finder - updated by non-requirement lines.
    :param session:     The session - updated by non-requirement lines.

    Returns a ParsedRequirement object if the line is a requirement line,
    otherwise returns None.

    For lines that contain requirements, the only options that have an effect
    are from SUPPORTED_OPTIONS_REQ, and they are scoped to the
    requirement. Other options from SUPPORTED_OPTIONS may be present, but are
    ignored.

    For lines that do not contain requirements, the only options that have an
    effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may
    be present, but are ignored. These lines may contain multiple options
    (although our docs imply only one is supported), and all our parsed and
    affect the finder.
    N)r0rNrlr/r-r.)rKr$r3r4r;rrrr7s	r7c@s@eZdZddZddZddZddZd	S)
r6cCs||_||_||_dS)N)_session_line_parser_comes_from)r'r4r8r#rrrr(Cs		zRequirementsFileParser.__init__ccs&x|j||D]}|VqWdS)z3Parse a given file, yielding parsed lines.
        N)_parse_and_recurse)r'r-r%rKrrrrNszRequirementsFileParser.parseccsx|j||D]}|jr|jjs;|jjr|jjr`|jjd}d}n|jjd}d}tj|rtj||}n0tj|st	j
jt	j
j||}x'|j
||D]}|VqWq|VqWdS)NrFT)_parse_filer0r/requirementsconstraints	SCHEME_REsearchurllib_parseurljoinrZr[r^r\rp)r'r-r%rKreq_pathnested_constraint
inner_linerrrrpUs"
			z)RequirementsFileParser._parse_and_recurseccst||jd|j\}}t|}x|D]\}}y|j|\}}	WnFtk
r}
z&dj||
j}t|WYdd}
~
XnXt	|||j||	|Vq4WdS)Nr#zInvalid requirement: {}
{})
get_file_contentrmrorErnOptionParsingErrorrFmsgrr,)r'r-r%_rCrDline_numberrKargs_strr/er}rrrrqvs z"RequirementsFileParser._parse_fileN)r)r*r+r(rrprqrrrrr6Bs!r6csfdd}|S)Ncst}|j}d|_r0j|_t|\}}tjdkr`|jd}|jt	j
||\}}||fS)Nutf8)rrr)build_parserget_default_valuesrWformat_controlbreak_args_optionssysversion_infoencode
parse_argsshlexsplit)rKr9defaultsroptions_strr/r~)r3rr
parse_lines		z#get_line_parser.<locals>.parse_liner)r3rr)r3rr5sr5cCs|jd}g}|dd}xJ|D]B}|jdsP|jdrTPq,|j||jdq,Wdj|dj|fS)zBreak up the line into an args and options string.  We only want to shlex
    (and then optparse) the options, not the args.  args can contain markers
    which are corrupted by shlex.
     N-z--r)r
startswithr`popr^)rKtokensr2r$tokenrrrrs

rc@seZdZddZdS)r|cCs
||_dS)N)r})r'r}rrrr(szOptionParsingError.__init__N)r)r*r+r(rrrrr|sr|cCs\tjdd}tt}x$|D]}|}|j|q#Wdd}||_|S)z7
    Return a parser for parsing requirement lines
    add_help_optionFcSst|dS)N)r|)r'r}rrrparser_exitsz!build_parser.<locals>.parser_exit)optparseOptionParserSUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQ
add_optionexit)r9option_factoriesoption_factoryoptionrrrrrs

		rccsd}g}x|D]\}}|jds>tj|rtj|rWd|}|r|j||dk	s|t|dj|fVg}q||fVq|s|}|j|jdqW|r|dk	st|dj|fVdS)zJoins a line ending in '' with the previous line (except when following
    comments).  The joined line takes on the index of the first line.
    N\r)endswith
COMMENT_REmatchr`rGr^strip)rDprimary_line_numbernew_linerrKrrrr@s$

	r@ccsJxC|D];\}}tjd|}|j}|r||fVqWdS)z1
    Strips comments and filter empty lines.
    rN)rsubr)rDrrKrrrrAs
rAccspxi|D]a\}}xGtj|D]6\}}tj|}|sGq#|j||}q#W||fVqWdS)aReplace all environment variables that can be retrieved via `os.getenv`.

    The only allowed format for environment variables defined in the
    requirement file is `${MY_VARIABLE_1}` to ensure two things:

    1. Strings that contain a `$` aren't accidentally (partially) expanded.
    2. Ensure consistency across platforms for requirement files.

    These points are the result of a discussion on the `github pull
    request #3514 <https://github.com/pypa/pip/pull/3514>`_.

    Valid characters in variable names follow the `POSIX standard
    <http://pubs.opengroup.org/onlinepubs/9699919799/>`_ and are limited
    to uppercase letter, digits and the `_` (underscore).
    N)
ENV_VAR_REfindallrZgetenvreplace)rDrrKenv_varvar_namerhrrrrBsrBc
Cst|}|d
krA|j|}t||j|jfS|dkr|rz|jdrztdj|||jddd}|j	dd}t
j|}|r|jdd|jd	dd}t
j|}|jdrd|jd}|}y/t|d
}t|j}WdQRXWn:tk
r}	ztdj|	WYdd}	~	XnX||fS)aZGets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode.
    Respects # -*- coding: declarations on the retrieved files.

    :param url:         File path or url.
    :param session:     PipSession instance.
    :param comes_from:  Origin description of requirements.
    httphttpsfilez6Requirements file {} references URL {}, which is local:r=r/|rbNz$Could not open requirements file: {})rr)rgetrurltextrrrFrr_url_slash_drive_rergrouprvunquotelstripopenr	readIOError)
rr4r#schemerespr[rrPrCexcrrrr{#s4

'%r{z/*([a-z])\|)Z__doc__
__future__rrrZrerrZpip._vendor.six.moves.urllibrrvZpip._internal.clirpip._internal.exceptionsrr!pip._internal.models.search_scoperpip._internal.network.utilsrpip._internal.utils.encodingr	pip._internal.utils.typingr
pip._internal.utils.urlsrrtypingr
rrrrrrrr"pip._internal.index.package_finderrpip._internal.network.sessionrintZReqFileLinesrZ
LineParser__all__compileIrtrrrWextra_index_urlrXrsrreditablerR	no_binaryonly_binaryrdrUrbtrusted_hostuse_new_featurerinstall_optionsglobal_optionshashrrIobjectr r,rrErNrlr7r6r5r	Exceptionr|rr@rArBr{rrrrr<module>s@	!.7)N -
Back to Directory File Manager