Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
pip._internal.req.req_file Namespace Reference

Classes

class  OptionParsingError
 
class  ParsedLine
 
class  ParsedRequirement
 
class  RequirementsFileParser
 

Functions

Generator[ParsedRequirement, None, None] parse_requirements (str filename, PipSession session, Optional["PackageFinder"] finder=None, Optional[optparse.Values] options=None, bool constraint=False)
 
ReqFileLines preprocess (str content)
 
ParsedRequirement handle_requirement_line (ParsedLine line, Optional[optparse.Values] options=None)
 
None handle_option_line (Values opts, str filename, int lineno, Optional["PackageFinder"] finder=None, Optional[optparse.Values] options=None, Optional[PipSession] session=None)
 
Optional[ParsedRequirementhandle_line (ParsedLine line, Optional[optparse.Values] options=None, Optional["PackageFinder"] finder=None, Optional[PipSession] session=None)
 
LineParser get_line_parser (Optional["PackageFinder"] finder)
 
Tuple[str, str] break_args_options (str line)
 
optparse.OptionParser build_parser ()
 
ReqFileLines join_lines (ReqFileLines lines_enum)
 
ReqFileLines ignore_comments (ReqFileLines lines_enum)
 
ReqFileLines expand_env_variables (ReqFileLines lines_enum)
 
Tuple[str, str] get_file_content (str url, PipSession session)
 

Variables

 ReqFileLines = Iterable[Tuple[int, str]]
 
 LineParser = Callable[[str], Tuple[str, Values]]
 
 SCHEME_RE = re.compile(r"^(http|https|file):", re.I)
 
 COMMENT_RE = re.compile(r"(^|\s+)#.*$")
 
 ENV_VAR_RE = re.compile(r"(?P<var>\$\{(?P<name>[A-Z0-9_]+)\})")
 
list SUPPORTED_OPTIONS
 
list SUPPORTED_OPTIONS_REQ
 
list SUPPORTED_OPTIONS_EDITABLE_REQ
 
list SUPPORTED_OPTIONS_REQ_DEST = [str(o().dest) for o in SUPPORTED_OPTIONS_REQ]
 
list SUPPORTED_OPTIONS_EDITABLE_REQ_DEST
 
 logger = logging.getLogger(__name__)
 

Detailed Description

Requirements file parsing

Function Documentation

◆ break_args_options()

Tuple[str, str] pip._internal.req.req_file.break_args_options ( str  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()

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

◆ expand_env_variables()

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

Tuple[str, str] pip._internal.req.req_file.get_file_content ( str  url,
PipSession  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.

◆ handle_line()

Optional[ParsedRequirement] pip._internal.req.req_file.handle_line ( ParsedLine  line,
Optional[optparse.Values]   options = None,
Optional["PackageFinder"]   finder = None,
Optional[PipSession]   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.

◆ ignore_comments()

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

◆ join_lines()

ReqFileLines pip._internal.req.req_file.join_lines ( ReqFileLines  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()

Generator[ParsedRequirement, None, None] pip._internal.req.req_file.parse_requirements ( str  filename,
PipSession  session,
Optional["PackageFinder"]   finder = None,
Optional[optparse.Values]   options = None,
bool   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()

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

:param content: the content of the requirements file

Variable Documentation

◆ SUPPORTED_OPTIONS

list pip._internal.req.req_file.SUPPORTED_OPTIONS
Initial value:
1= [
2 cmdoptions.index_url,
3 cmdoptions.extra_index_url,
4 cmdoptions.no_index,
5 cmdoptions.constraints,
6 cmdoptions.requirements,
7 cmdoptions.editable,
8 cmdoptions.find_links,
9 cmdoptions.no_binary,
10 cmdoptions.only_binary,
11 cmdoptions.prefer_binary,
12 cmdoptions.require_hashes,
13 cmdoptions.pre,
14 cmdoptions.trusted_host,
15 cmdoptions.use_new_feature,
16]

◆ SUPPORTED_OPTIONS_EDITABLE_REQ

list pip._internal.req.req_file.SUPPORTED_OPTIONS_EDITABLE_REQ
Initial value:
1= [
2 cmdoptions.config_settings,
3]

◆ SUPPORTED_OPTIONS_EDITABLE_REQ_DEST

list pip._internal.req.req_file.SUPPORTED_OPTIONS_EDITABLE_REQ_DEST
Initial value:
1= [
2 str(o().dest) for o in SUPPORTED_OPTIONS_EDITABLE_REQ
3]

◆ SUPPORTED_OPTIONS_REQ

list pip._internal.req.req_file.SUPPORTED_OPTIONS_REQ
Initial value:
1= [
2 cmdoptions.global_options,
3 cmdoptions.hash,
4 cmdoptions.config_settings,
5]