OpenQuizz
Une application de gestion des contenus pédagogiques
pip._internal.req.req_file Namespace Reference

Data Structures

class  OptionParsingError
 
class  ParsedLine
 
class  ParsedRequirement
 
class  RequirementsFileParser
 

Functions

def parse_requirements (filename, session, finder=None, options=None, constraint=False)
 
def preprocess (content)
 
def handle_requirement_line (line, options=None)
 
def handle_option_line (opts, filename, lineno, finder=None, options=None, session=None)
 
def handle_line (line, options=None, finder=None, session=None)
 
def get_line_parser (finder)
 
def break_args_options (line)
 
def build_parser ()
 
def join_lines (lines_enum)
 
def ignore_comments (lines_enum)
 
def expand_env_variables (lines_enum)
 
def get_file_content (url, session)
 

Variables

 ReqFileLines
 
 LineParser
 
 SCHEME_RE
 
 COMMENT_RE
 
 ENV_VAR_RE
 
 SUPPORTED_OPTIONS
 
 SUPPORTED_OPTIONS_REQ
 
 SUPPORTED_OPTIONS_REQ_DEST
 

Detailed Description

Requirements file parsing

Function Documentation

◆ break_args_options()

def pip._internal.req.req_file.break_args_options (   line)
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.

◆ build_parser()

def pip._internal.req.req_file.build_parser ( )
Return a parser for parsing requirement lines

◆ expand_env_variables()

def pip._internal.req.req_file.expand_env_variables (   lines_enum)
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).

◆ get_file_content()

def pip._internal.req.req_file.get_file_content (   url,
  session 
)
Gets 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.

◆ get_line_parser()

def pip._internal.req.req_file.get_line_parser (   finder)

◆ handle_line()

def pip._internal.req.req_file.handle_line (   line,
  options = None,
  finder = None,
  session = None 
)
Handle 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.

◆ handle_option_line()

def pip._internal.req.req_file.handle_option_line (   opts,
  filename,
  lineno,
  finder = None,
  options = None,
  session = None 
)

◆ handle_requirement_line()

def pip._internal.req.req_file.handle_requirement_line (   line,
  options = None 
)

◆ ignore_comments()

def pip._internal.req.req_file.ignore_comments (   lines_enum)
Strips comments and filter empty lines.

◆ join_lines()

def pip._internal.req.req_file.join_lines (   lines_enum)
Joins a line ending in '\' with the previous line (except when following
comments).  The joined line takes on the index of the first line.

◆ parse_requirements()

def pip._internal.req.req_file.parse_requirements (   filename,
  session,
  finder = None,
  options = None,
  constraint = False 
)
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 options:     cli options.
:param constraint:  If true, parsing a constraint file rather than
    requirements file.

◆ preprocess()

def pip._internal.req.req_file.preprocess (   content)
Split, filter, and join lines, and return a line iterator

:param content: the content of the requirements file

Variable Documentation

◆ COMMENT_RE

COMMENT_RE

◆ ENV_VAR_RE

ENV_VAR_RE

◆ LineParser

LineParser

◆ ReqFileLines

ReqFileLines

◆ SCHEME_RE

SCHEME_RE

◆ SUPPORTED_OPTIONS

SUPPORTED_OPTIONS

◆ SUPPORTED_OPTIONS_REQ

SUPPORTED_OPTIONS_REQ

◆ SUPPORTED_OPTIONS_REQ_DEST

SUPPORTED_OPTIONS_REQ_DEST