OpenQuizz
Une application de gestion des contenus pédagogiques
pip._internal.utils.misc Namespace Reference

Data Structures

class  HiddenText
 
class  StreamWrapper
 

Functions

def get_pip_version ()
 
def normalize_version_info (py_version_info)
 
def ensure_dir (path)
 
def get_prog ()
 
def rmtree (dir, ignore_errors=False)
 
def rmtree_errorhandler (func, path, exc_info)
 
def display_path (path)
 
def backup_dir (dir, ext=".bak")
 
def ask_path_exists (message, options)
 
def ask (message, options)
 
def ask_input (message)
 
def ask_password (message)
 
def strtobool (val)
 
def format_size (bytes)
 
def tabulate (rows)
 
bool is_installable_dir (str path)
 
def read_chunks (file, size=io.DEFAULT_BUFFER_SIZE)
 
def normalize_path (path, resolve_symlinks=True)
 
def splitext (path)
 
def renames (old, new)
 
def is_local (path)
 
def dist_is_local (dist)
 
def dist_in_usersite (dist)
 
def dist_in_site_packages (dist)
 
def dist_is_editable (dist)
 
def get_installed_distributions (local_only=True, skip=stdlib_pkgs, include_editables=True, editables_only=False, user_only=False, paths=None)
 
def get_distribution (req_name)
 
def egg_link_path (dist)
 
def dist_location (dist)
 
def write_output (msg, *args)
 
def captured_output (stream_name)
 
def captured_stdout ()
 
def captured_stderr ()
 
def enum (*sequential, **named)
 
def build_netloc (host, port)
 
def build_url_from_netloc (netloc, scheme="https")
 
def parse_netloc (netloc)
 
def split_auth_from_netloc (netloc)
 
def redact_netloc (netloc)
 
def split_auth_netloc_from_url (url)
 
def remove_auth_from_url (url)
 
def redact_auth_from_url (url)
 
def hide_value (value)
 
def hide_url (url)
 
def protect_pip_from_modification_on_windows (modifying_pip)
 
def is_console_interactive ()
 
def hash_file (path, blocksize=1<< 20)
 
def is_wheel_installed ()
 
def pairwise (iterable)
 
def partition (pred, iterable)
 

Variables

 logger
 
 T
 
 ExcInfo
 
 VersionInfo
 
 NetlocTuple
 

Function Documentation

◆ ask()

def pip._internal.utils.misc.ask (   message,
  options 
)
Ask the message interactively, with the given possible responses

◆ ask_input()

def pip._internal.utils.misc.ask_input (   message)
Ask for input interactively.

◆ ask_password()

def pip._internal.utils.misc.ask_password (   message)
Ask for a password interactively.

◆ ask_path_exists()

def pip._internal.utils.misc.ask_path_exists (   message,
  options 
)

◆ backup_dir()

def pip._internal.utils.misc.backup_dir (   dir,
  ext = ".bak" 
)
Figure out the name of a directory to back up the given dir to
(adding .bak, .bak2, etc)

◆ build_netloc()

def pip._internal.utils.misc.build_netloc (   host,
  port 
)
Build a netloc from a host-port pair

◆ build_url_from_netloc()

def pip._internal.utils.misc.build_url_from_netloc (   netloc,
  scheme = "https" 
)
Build a full URL from a netloc.

◆ captured_output()

def pip._internal.utils.misc.captured_output (   stream_name)
Return a context manager used by captured_stdout/stdin/stderr
that temporarily replaces the sys stream *stream_name* with a StringIO.

Taken from Lib/support/__init__.py in the CPython repo.

◆ captured_stderr()

def pip._internal.utils.misc.captured_stderr ( )
See captured_stdout().

◆ captured_stdout()

def pip._internal.utils.misc.captured_stdout ( )
Capture the output of sys.stdout:

   with captured_stdout() as stdout:
       print('hello')
   self.assertEqual(stdout.getvalue(), 'hello\n')

Taken from Lib/support/__init__.py in the CPython repo.

◆ display_path()

def pip._internal.utils.misc.display_path (   path)
Gives the display value for a given path, making it relative to cwd
if possible.

◆ dist_in_site_packages()

def pip._internal.utils.misc.dist_in_site_packages (   dist)
Return True if given Distribution is installed in
sysconfig.get_python_lib().

◆ dist_in_usersite()

def pip._internal.utils.misc.dist_in_usersite (   dist)
Return True if given Distribution is installed in user site.

◆ dist_is_editable()

def pip._internal.utils.misc.dist_is_editable (   dist)
Return True if given Distribution is an editable install.

◆ dist_is_local()

def pip._internal.utils.misc.dist_is_local (   dist)
Return True if given Distribution object is installed locally
(i.e. within current virtualenv).

Always True if we're not in a virtualenv.

◆ dist_location()

def pip._internal.utils.misc.dist_location (   dist)
Get the site-packages location of this distribution. Generally
this is dist.location, except in the case of develop-installed
packages, where dist.location is the source code location, and we
want to know where the egg-link file is.

The returned location is normalized (in particular, with symlinks removed).

◆ egg_link_path()

def pip._internal.utils.misc.egg_link_path (   dist)
Return the path for the .egg-link file if it exists, otherwise, None.

There's 3 scenarios:
1) not in a virtualenv
   try to find in site.USER_SITE, then site_packages
2) in a no-global virtualenv
   try to find in site_packages
3) in a yes-global virtualenv
   try to find in site_packages, then site.USER_SITE
   (don't look in global location)

For #1 and #3, there could be odd cases, where there's an egg-link in 2
locations.

This method will just return the first one found.

◆ ensure_dir()

def pip._internal.utils.misc.ensure_dir (   path)
os.path.makedirs without EEXIST.

◆ enum()

def pip._internal.utils.misc.enum ( sequential,
**  named 
)

◆ format_size()

def pip._internal.utils.misc.format_size (   bytes)

◆ get_distribution()

def pip._internal.utils.misc.get_distribution (   req_name)
Given a requirement name, return the installed Distribution object.

This searches from *all* distributions available in the environment, to
match the behavior of ``pkg_resources.get_distribution()``.

Left for compatibility until direct pkg_resources uses are refactored out.

◆ get_installed_distributions()

def pip._internal.utils.misc.get_installed_distributions (   local_only = True,
  skip = stdlib_pkgs,
  include_editables = True,
  editables_only = False,
  user_only = False,
  paths = None 
)
Return a list of installed Distribution objects.

Left for compatibility until direct pkg_resources uses are refactored out.

◆ get_pip_version()

def pip._internal.utils.misc.get_pip_version ( )

◆ get_prog()

def pip._internal.utils.misc.get_prog ( )

◆ hash_file()

def pip._internal.utils.misc.hash_file (   path,
  blocksize = 1 << 20 
)
Return (hash, length) for path using hashlib.sha256()

◆ hide_url()

def pip._internal.utils.misc.hide_url (   url)

◆ hide_value()

def pip._internal.utils.misc.hide_value (   value)

◆ is_console_interactive()

def pip._internal.utils.misc.is_console_interactive ( )
Is this console interactive?

◆ is_installable_dir()

bool pip._internal.utils.misc.is_installable_dir ( str  path)
Is path is a directory containing pyproject.toml, setup.cfg or setup.py?

◆ is_local()

def pip._internal.utils.misc.is_local (   path)
Return True if path is within sys.prefix, if we're running in a virtualenv.

If we're not in a virtualenv, all paths are considered "local."

Caution: this function assumes the head of path has been normalized
with normalize_path.

◆ is_wheel_installed()

def pip._internal.utils.misc.is_wheel_installed ( )
Return whether the wheel package is installed.

◆ normalize_path()

def pip._internal.utils.misc.normalize_path (   path,
  resolve_symlinks = True 
)
Convert a path to its canonical, case-normalized, absolute version.

◆ normalize_version_info()

def pip._internal.utils.misc.normalize_version_info (   py_version_info)
Convert a tuple of ints representing a Python version to one of length
three.

:param py_version_info: a tuple of ints representing a Python version,
    or None to specify no version. The tuple can have any length.

:return: a tuple of length three if `py_version_info` is non-None.
    Otherwise, return `py_version_info` unchanged (i.e. None).

◆ pairwise()

def pip._internal.utils.misc.pairwise (   iterable)
Return paired elements.

For example:
    s -> (s0, s1), (s2, s3), (s4, s5), ...

◆ parse_netloc()

def pip._internal.utils.misc.parse_netloc (   netloc)
Return the host-port pair from a netloc.

◆ partition()

def pip._internal.utils.misc.partition (   pred,
  iterable 
)
Use a predicate to partition entries into false entries and true entries,
like

    partition(is_odd, range(10)) --> 0 2 4 6 8   and  1 3 5 7 9

◆ protect_pip_from_modification_on_windows()

def pip._internal.utils.misc.protect_pip_from_modification_on_windows (   modifying_pip)
Protection of pip.exe from modification on Windows

On Windows, any operation modifying pip should be run as:
    python -m pip ...

◆ read_chunks()

def pip._internal.utils.misc.read_chunks (   file,
  size = io.DEFAULT_BUFFER_SIZE 
)
Yield pieces of data from a file-like object until EOF.

◆ redact_auth_from_url()

def pip._internal.utils.misc.redact_auth_from_url (   url)
Replace the password in a given url with ****.

◆ redact_netloc()

def pip._internal.utils.misc.redact_netloc (   netloc)
Replace the sensitive data in a netloc with "****", if it exists.

For example:
    - "user:pass@example.com" returns "user:****@example.com"
    - "accesstoken@example.com" returns "****@example.com"

◆ remove_auth_from_url()

def pip._internal.utils.misc.remove_auth_from_url (   url)
Return a copy of url with 'username:password@' removed.

◆ renames()

def pip._internal.utils.misc.renames (   old,
  new 
)
Like os.renames(), but handles renaming across devices.

◆ rmtree()

def pip._internal.utils.misc.rmtree (   dir,
  ignore_errors = False 
)

◆ rmtree_errorhandler()

def pip._internal.utils.misc.rmtree_errorhandler (   func,
  path,
  exc_info 
)
On Windows, the files in .svn are read-only, so when rmtree() tries to
remove them, an exception is thrown.  We catch that here, remove the
read-only attribute, and hopefully continue without problems.

◆ split_auth_from_netloc()

def pip._internal.utils.misc.split_auth_from_netloc (   netloc)
Parse out and remove the auth information from a netloc.

Returns: (netloc, (username, password)).

◆ split_auth_netloc_from_url()

def pip._internal.utils.misc.split_auth_netloc_from_url (   url)
Parse a url into separate netloc, auth, and url with no auth.

Returns: (url_without_auth, netloc, (username, password))

◆ splitext()

def pip._internal.utils.misc.splitext (   path)
Like os.path.splitext, but take off .tar too

◆ strtobool()

def pip._internal.utils.misc.strtobool (   val)
Convert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
'val' is anything else.

◆ tabulate()

def pip._internal.utils.misc.tabulate (   rows)
Return a list of formatted rows and a list of column sizes.

For example::

>>> tabulate([['foobar', 2000], [0xdeadbeef]])
(['foobar     2000', '3735928559'], [10, 4])

◆ write_output()

def pip._internal.utils.misc.write_output (   msg,
args 
)

Variable Documentation

◆ ExcInfo

ExcInfo

◆ logger

logger

◆ NetlocTuple

NetlocTuple

◆ T

T

◆ VersionInfo

VersionInfo