nox/sessions.py
def _normalize_path(envdir: str, path: Union[str, bytes]) -> str:
    """Normalizes a string to be a "safe" filesystem path for a virtualenv."""
    if isinstance(path, bytes):
        path = path.decode("utf-8")

    path = unicodedata.normalize("NFKD", path).encode("ascii", "ignore")
    path = path.decode("ascii")
    path = re.sub(r"[^\w\s-]", "-", path).strip().lower()
    path = re.sub(r"[-\s]+", "-", path)
    path = path.strip("-")

    full_path = os.path.join(envdir, path)
    if len(full_path) > 100 - len("bin/pythonX.Y"):
        if len(envdir) < 100 - 9:
            path = hashlib.sha1(path.encode("ascii")).hexdigest()[:8]
            full_path = os.path.join(envdir, path)
            logger.warning("The virtualenv name was hashed to avoid being too long.")
        else:
            logger.error(
                f"The virtualenv path {full_path} is too long and will cause issues on "
                "some environments. Use the --envdir path to modify where "
                "nox stores virtualenvs."
            )

    return full_path
Normalizes a string to be a "safe" filesystem path for a virtualenv.
Normalizes a string to be a "safe" filesystem path for a virtualenv.
Normalizes a string to be a " safe " filesystem path for a virtualenv .
def _normalize_path(envdir: str, path: Union[str, bytes]) -> str:
    if isinstance(path, bytes):
        path = path.decode("utf-8")
    path = unicodedata.normalize("NFKD", path).encode("ascii", "ignore")
    path = path.decode("ascii")
    path = re.sub(r"[^\w\s-]", "-", path).strip().lower()
    path = re.sub(r"[-\s]+", "-", path)
    path = path.strip("-")
    full_path = os.path.join(envdir, path)
    if len(full_path) > 100 - len("bin/pythonX.Y"):
        if len(envdir) < 100 - 9:
            path = hashlib.sha1(path.encode("ascii")).hexdigest()[:8]
            full_path = os.path.join(envdir, path)
            logger.warning("The virtualenv name was hashed to avoid being too long.")
        else:
            logger.error(
                f"The virtualenv path {full_path} is too long and will cause issues on "
                "some environments. Use the --envdir path to modify where "
                "nox stores virtualenvs."
            )
    return full_path
def _normalize_path ( envdir : str , path : Union [ str , bytes ] ) -> str : if isinstance ( path , bytes ) : path = path . decode ( "utf-8" ) path = unicodedata . normalize ( "NFKD" , path ) . encode ( "ascii" , "ignore" ) path = path . decode ( "ascii" ) path = re . sub ( r"[^\w\s-]" , "-" , path ) . strip ( ) . lower ( ) path = re . sub ( r"[-\s]+" , "-" , path ) path = path . strip ( "-" ) full_path = os . path . join ( envdir , path ) if len ( full_path ) > 100 - len ( "bin/pythonX.Y" ) : if len ( envdir ) < 100 - 9 : path = hashlib . sha1 ( path . encode ( "ascii" ) ) . hexdigest ( ) [ : 8 ] full_path = os . path . join ( envdir , path ) logger . warning ( "The virtualenv name was hashed to avoid being too long." ) else : logger . error ( f"The virtualenv path {full_path} is too long and will cause issues on " "some environments. Use the --envdir path to modify where " "nox stores virtualenvs." ) return full_path
Normalizes a string to be a "safe" filesystem path for a virtualenv.
Normalizes a string to be a " safe " filesystem path for a virtualenv .
"""Normalizes a string to be a "safe" filesystem path for a virtualenv."""
envdir
str
path
Union[str, bytes]