MCPcopy Index your code
hub / github.com/python/cpython / _convert_name

Function _convert_name

Lib/unittest/main.py:30–44  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

28"""
29
30def _convert_name(name):
31 # on Linux / Mac OS X 'foo.PY' is not importable, but on
32 # Windows it is. Simpler to do a case insensitive match
33 # a better check would be to check that the name is a
34 # valid Python module name.
35 if os.path.isfile(name) and name.lower().endswith('.py'):
36 if os.path.isabs(name):
37 rel_path = os.path.relpath(name, os.getcwd())
38 if os.path.isabs(rel_path) or rel_path.startswith(os.pardir):
39 return name
40 name = rel_path
41 # on Windows both '\' and '/' are used as path
42 # separators. Better to replace both than rely on os.path.sep
43 return os.path.normpath(name)[:-3].replace('\\', '.').replace('/', '.')
44 return name
45
46def _convert_names(names):
47 return [_convert_name(name) for name in names]

Callers 1

_convert_namesFunction · 0.85

Calls 6

isfileMethod · 0.45
endswithMethod · 0.45
lowerMethod · 0.45
isabsMethod · 0.45
startswithMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…