Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Get a list of Python files within the supplied package directory.
Return:
Generator of Python file names.
"""
for root, dirs, files in os.walk(directory):
# Don't include directories that aren't Python packages,
# nor their subdirectories.
if '__init__.py' not in files:
[dirs.remove(d) for d in list(dirs)]
continue
# Don't include hidden directories.
dotdirs = [d for d in dirs if d.startswith('.')]
for d in dotdirs:
dirs.remove(d)
for filename in files:
if is_python_file(filename):
yield os.path.abspath(os.path.join(root, filename))