(path)
return _path_join(head, base_filename + SOURCE_SUFFIXES[0])
Given the path to a .pyc. file, return the path to its .py file.

    The .pyc file does not need to exist; this simply returns the path to
    the .py file calculated to correspond to the .pyc file.  If path does
    not conform to PEP 3147/488 format, ValueError will be raised. If
    sys.implementation.cache_tag is None then NotImplementedError is raised.
Given the path to a .pyc. file, return the path to its .py file.
Given the path to a . pyc . file return the path to its . py file .
def source_from_cache(path):
    """Given the path to a .pyc. file, return the path to its .py file.

    The .pyc file does not need to exist; this simply returns the path to
    the .py file calculated to correspond to the .pyc file.  If path does
    not conform to PEP 3147/488 format, ValueError will be raised. If
    sys.implementation.cache_tag is None then NotImplementedError is raised.

    """
    if sys.implementation.cache_tag is None:
        raise NotImplementedError('sys.implementation.cache_tag is None')
    path = _os.fspath(path)
    head, pycache_filename = _path_split(path)
    found_in_pycache_prefix = False
    if sys.pycache_prefix is not None:
        stripped_path = sys.pycache_prefix.rstrip(path_separators)
        if head.startswith(stripped_path + path_sep):
            head = head[len(stripped_path):]
            found_in_pycache_prefix = True
    if not found_in_pycache_prefix:
        head, pycache = _path_split(head)
        if pycache != _PYCACHE:
            raise ValueError(f'{_PYCACHE} not bottom-level directory in '
                             f'{path!r}')
    dot_count = pycache_filename.count('.')
    if dot_count not in {2, 3}:
        raise ValueError(f'expected only 2 or 3 dots in {pycache_filename!r}')
    elif dot_count == 3:
        optimization = pycache_filename.rsplit('.', 2)[-2]
        if not optimization.startswith(_OPT):
            raise ValueError("optimization portion of filename does not start "
                             f"with {_OPT!r}")
        opt_level = optimization[len(_OPT):]
        if not opt_level.isalnum():
            raise ValueError(f"optimization level {optimization!r} is not an "
                             "alphanumeric value")
    base_filename = pycache_filename.partition('.')[0]
    return _path_join(head, base_filename + SOURCE_SUFFIXES[0])
def source_from_cache ( path ) : if sys . implementation . cache_tag is None : raise NotImplementedError ( 'sys.implementation.cache_tag is None' ) path = _os . fspath ( path ) head , pycache_filename = _path_split ( path ) found_in_pycache_prefix = False if sys . pycache_prefix is not None : stripped_path = sys . pycache_prefix . rstrip ( path_separators ) if head . startswith ( stripped_path + path_sep ) : head = head [ len ( stripped_path ) : ] found_in_pycache_prefix = True if not found_in_pycache_prefix : head , pycache = _path_split ( head ) if pycache != _PYCACHE : raise ValueError ( f'{_PYCACHE} not bottom-level directory in ' f'{path!r}' ) dot_count = pycache_filename . count ( '.' ) if dot_count not in { 2 , 3 } : raise ValueError ( f'expected only 2 or 3 dots in {pycache_filename!r}' ) elif dot_count == 3 : optimization = pycache_filename . rsplit ( '.' , 2 ) [ - 2 ] if not optimization . startswith ( _OPT ) : raise ValueError ( "optimization portion of filename does not start " f"with {_OPT!r}" ) opt_level = optimization [ len ( _OPT ) : ] if not opt_level . isalnum ( ) : raise ValueError ( f"optimization level {optimization!r} is not an " "alphanumeric value" ) base_filename = pycache_filename . partition ( '.' ) [ 0 ] return _path_join ( head , base_filename + SOURCE_SUFFIXES [ 0 ] )