(filename, package_root, level=None)
return ".".join(dirs)
Given a filename within a package, return the import path of the filename
Given a filename within a package, return the import path of the filename
Given a filename within a package return the import path of the filename
def import_path(filename, package_root, level=None):
    """
    Given a filename within a package, return the import path of the filename
    """
    relative_path = os.path.relpath(filename, package_root)
    path = os.path.splitext(relative_path)[0]
    dirs = path.split(os.path.sep)
    if level != None:
        dirs = dirs[:-level]
    return ".".join(dirs)
def import_path ( filename , package_root , level = None ) : relative_path = os . path . relpath ( filename , package_root ) path = os . path . splitext ( relative_path ) [ 0 ] dirs = path . split ( os . path . sep ) if level != None : dirs = dirs [ : - level ] return "." . join ( dirs )