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

ó
“tÆ_c@@sVdZddlmZddlZddlZddlZddlZddlZddlm	Z
ddlmZddl
mZmZddlmZddlmZdd	lmZdd
lmZddlmZer‚dd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,ndgZ-ej.dej/ƒZ0ej.dƒZ1ej.dƒZ2ej3ej4ej5ej6ej7ej8ej9ej:ej;ej<ej=ej>ej?ej@gZAejBejCejDgZEgeED]ZFe+eFƒjGƒ^q7ZHdeIfd„ƒYZJdeIfd„ƒYZKdddeMd„ZNd„ZOdd„ZPdddd„ZQdddd„ZRdeIfd„ƒYZSd„ZTd „ZUd!eVfd"„ƒYZWd#„ZXd$„ZYd%„ZZd&„Z[dd'„Z\ej.d(ej/ƒZ]dS()s
Requirements file parsing
i(tabsolute_importN(tparse(t
cmdoptions(tInstallationErrortRequirementsFileParseError(tSearchScope(traise_for_status(tauto_decode(tMYPY_CHECK_RUNNING(tget_url_scheme(tValues(	tAnytCallabletDicttIteratortListtNoReturntOptionaltTexttTuple(t
PackageFinder(t
PipSessiontparse_requirementss^(http|https|file):s(^|\s+)#.*$s#(?P<var>\$\{(?P<name>[A-Z0-9_]+)\})tParsedRequirementcB@seZddd„ZRS(cC@s:||_||_||_||_||_||_dS(N(trequirementtis_editablet
comes_fromtoptionst
constrainttline_source(tselfRRRRRR((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyt__init__Ps
					N(t__name__t
__module__tNoneR(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyROst
ParsedLinecB@seZd„ZRS(cC@sŒ||_||_||_||_||_|rQt|_t|_||_	n7|j
rt|_t|_|j
d|_	n	t|_dS(Ni(tfilenametlinenoRtoptsRtTruetis_requirementtFalseRRt	editables(RR$R%RtargsR&R((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRcs
										(R R!R(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR#bsc
	c@sqt|ƒ}t|||ƒ}xL|j||ƒD]8}t|d|d|d|ƒ}	|	dk	r1|	Vq1q1WdS(s­Parse 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.
    RtfindertsessionN(tget_line_parsertRequirementsFileParserRthandle_lineR"(
R$R-R,RRRtline_parsertparsertparsed_linet
parsed_req((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR€s	cC@s@t|jƒddƒ}t|ƒ}t|ƒ}t|ƒ}|S(sxSplit, filter, and join lines, and return a line iterator

    :param content: the content of the requirements file
    tstarti(t	enumeratet
splitlinest
join_linestignore_commentstexpand_env_variables(tcontentt
lines_enum((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyt
preprocess¡s
c
C@s&dj|jrdnd|j|jƒ}|js9t‚|jrjtd|jd|jd|d|jƒS|r†t	j
||jƒni}xGtD]?}||jj
kr“|jj
|r“|jj
|||<q“q“Wdj|j|jƒ}td|jd|jd|d|jd	|d
|ƒSdS(Ns{} {} (line {})s-cs-rRRRRs
line {} of {}RR(tformatRR$R%R(tAssertionErrorRRRRtcheck_install_build_globalR&tSUPPORTED_OPTIONS_REQ_DESTt__dict__(tlineRtline_comes_fromtreq_optionstdestR((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pythandle_requirement_line®s.$			

"			c@sÁˆrP|jr|jˆ_n|jrPˆjj‡fd†|jDƒƒqPn|r½|j}|j}|jr€|jg}n|jtkr˜g}n|jr´|j|jƒn|jr(|jd}t	j
jt	j
j|ƒƒ}	t	j
j
|	|ƒ}
t	j
j|
ƒr|
}n|j|ƒntd|d|ƒ}||_|jr\|jƒn|jrr|jƒn|r½x?|jp‡gD]+}dj||ƒ}
|j|d|
ƒqˆWq½ndS(Nc3@s$|]}|ˆjkr|VqdS(N(tfeatures_enabled(t.0tf(R(sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pys	<genexpr>êsit
find_linkst
index_urlss
line {} of {}tsource(trequire_hashesRHtextendRKRLt	index_urltno_indexR'textra_index_urlstostpathtdirnametabspathtjointexiststappendRtsearch_scopetpretset_allow_all_prereleasest
prefer_binarytset_prefer_binaryt
trusted_hostsR>tadd_trusted_host(R&R$R%R,RR-RKRLtvaluetreq_dirtrelative_to_reqs_fileRZthostRM((RsK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pythandle_option_lineÚsD
			 						
				
	
cC@sF|jrt||ƒ}|St|j|j|j|||ƒdSdS(sHandle 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(R(RGReR&R$R%R"(RCRR,R-R4((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR0s	R/cB@s,eZd„Zd„Zd„Zd„ZRS(cC@s||_||_||_dS(N(t_sessiont_line_parsert_comes_from(RR-R1R((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRCs		cc@s&x|j||ƒD]}|VqWdS(s3Parse a given file, yielding parsed lines.
        N(t_parse_and_recurse(RR$RRC((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRNscc@sÿxø|j||ƒD]ä}|jrò|jjs;|jjrò|jjr`|jjd}t}n|jjd}t}tj|ƒršt	j
||ƒ}n3tj|ƒsÍtjj
tjj|ƒ|ƒ}nx'|j||ƒD]}|VqàWq|VqWdS(Ni(t_parse_fileR(R&trequirementstconstraintsR)R't	SCHEME_REtsearchturllib_parseturljoinRSRTRWRURi(RR$RRCtreq_pathtnested_constraintt
inner_line((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRiUs"
			cc@sµt||jd|jƒ\}}t|ƒ}x|D]y\}}y|j|ƒ\}}	Wn4tk
r}
dj||
jƒ}t|ƒ‚nXt	|||j||	|ƒVq4WdS(NRsInvalid requirement: {}
{}(
tget_file_contentRfRhR=RgtOptionParsingErrorR>tmsgRR#(RR$Rt_R;R<tline_numberRCtargs_strR&teRv((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRjvs (R R!RRRiRj(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR/Bs			!c@s‡fd†}|S(Nc@s‘tƒ}|jƒ}d|_ˆr3ˆj|_nt|ƒ\}}tjdkrf|jdƒ}n|j	t
j|ƒ|ƒ\}}||fS(Niiitutf8(iii(tbuild_parsertget_default_valuesR"RPtformat_controltbreak_args_optionstsystversion_infotencodet
parse_argstshlextsplit(RCR2tdefaultsRytoptions_strR&Rw(R,(sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyt
parse_line’s		((R,Rˆ((R,sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR.scC@s…|jdƒ}g}|}xJ|D]B}|jdƒsG|jdƒrKPq#|j|ƒ|jdƒq#Wdj|ƒdj|ƒfS(s½Break 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.
    t t-s--i(R…t
startswithRYtpopRW(RCttokensR+Rttoken((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR«s

RucB@seZd„ZRS(cC@s
||_dS(N(Rv(RRv((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR¾s(R R!R(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRu½scC@sYtjdtƒ}tt}x$|D]}|ƒ}|j|ƒq#Wd„}||_|S(s7
    Return a parser for parsing requirement lines
    tadd_help_optioncS@st|ƒ‚dS(N(Ru(RRv((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pytparser_exitÑs(toptparsetOptionParserR)tSUPPORTED_OPTIONStSUPPORTED_OPTIONS_REQt
add_optiontexit(R2toption_factoriestoption_factorytoptionR((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR|Ãs

			cc@sd}g}xÄ|D]¼\}}|jdƒs>tj|ƒrªtj|ƒrZd|}n|rœ|j|ƒ|dk	st‚|dj|ƒfVg}qÏ||fVq|s¹|}n|j|jdƒƒqW|r|dk	sët‚|dj|ƒfVndS(s’Joins a line ending in '' with the previous line (except when following
    comments).  The joined line takes on the index of the first line.
    s\R‰tN(R"tendswitht
COMMENT_REtmatchRYR?RWtstrip(R<tprimary_line_numbertnew_lineRxRC((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR8Ûs$

		cc@sMxF|D]>\}}tjd|ƒ}|jƒ}|r||fVqqWdS(s1
    Strips comments and filter empty lines.
    RšN(RœtsubRž(R<RxRC((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR9ûs
cc@ssxl|D]d\}}xJtj|ƒD]9\}}tj|ƒ}|sJq#n|j||ƒ}q#W||fVqWdS(s«Replace 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(t
ENV_VAR_REtfindallRStgetenvtreplace(R<RxRCtenv_vartvar_nameRa((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyR:sc
C@s„t|ƒ}|d
krA|j|ƒ}t|ƒ|j|jfS|dkr!|r}|jdƒr}tdj||ƒƒ‚n|jddƒd}|j	ddƒ}t
j|ƒ}|rä|jdƒd|jd	dƒd}nt
j|ƒ}|jdƒrd|jdƒ}n|}ny.t|d
ƒ}t|jƒƒ}WdQXWn(tk
ry}	tdj|	ƒƒ‚nX||fS(sZGets 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.
    thttpthttpstfiles6Requirements file {} references URL {}, which is localt:is\t/t|trbNs$Could not open requirements file: {}(R¨R©(R	tgetRturlttextR‹RR>R…R¥t_url_slash_drive_reRtgroupRotunquotetlstriptopenRtreadtIOError(
R°R-RtschemetrespRTRRJR;texc((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyRt#s4

*	s/*([a-z])\|(^t__doc__t
__future__RR‘RStreR„R€tpip._vendor.six.moves.urllibRRotpip._internal.cliRtpip._internal.exceptionsRRt!pip._internal.models.search_scopeRtpip._internal.network.utilsRtpip._internal.utils.encodingRtpip._internal.utils.typingRtpip._internal.utils.urlsR	R
ttypingRRR
RRRRRRt"pip._internal.index.package_finderRtpip._internal.network.sessionRtinttReqFileLineststrt
LineParsert__all__tcompiletIRmRœR¢RPtextra_index_urlRQRlRkteditableRKt	no_binarytonly_binaryR]RNR[ttrusted_hosttuse_new_featureR“tinstall_optionstglobal_optionsthashR”toRFRAtobjectRR#R"R)RR=RGReR0R/R.Rt	ExceptionRuR|R8R9R:RtR²(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/req_file.pyt<module>s†@ 	%!	.7)N				 		-
Back to Directory File Manager