This commit is contained in:
Paulus Schoutsen
2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View File

@ -11,16 +11,16 @@ from homeassistant.scripts.check_config import color
def explore_module(package):
"""Explore the modules."""
module = importlib.import_module(package)
if not hasattr(module, '__path__'):
if not hasattr(module, "__path__"):
return []
for _, name, _ in pkgutil.iter_modules(module.__path__, package + '.'):
for _, name, _ in pkgutil.iter_modules(module.__path__, package + "."):
yield name
def main():
"""Run the script."""
if not os.path.isfile('requirements_all.txt'):
print('Run this from HA root dir')
if not os.path.isfile("requirements_all.txt"):
print("Run this from HA root dir")
return
msg = {}
@ -31,29 +31,34 @@ def main():
msg[key] = []
msg[key].append(item)
for package in explore_module('homeassistant.components'):
for package in explore_module("homeassistant.components"):
module = importlib.import_module(package)
module_name = getattr(module, 'DOMAIN', module.__name__)
module_name = getattr(module, "DOMAIN", module.__name__)
if hasattr(module, 'PLATFORM_SCHEMA'):
if hasattr(module, 'CONFIG_SCHEMA'):
add_msg('WARNING', "Module {} contains PLATFORM and CONFIG "
"schemas".format(module_name))
add_msg('PLATFORM SCHEMA', module_name)
if hasattr(module, "PLATFORM_SCHEMA"):
if hasattr(module, "CONFIG_SCHEMA"):
add_msg(
"WARNING",
"Module {} contains PLATFORM and CONFIG "
"schemas".format(module_name),
)
add_msg("PLATFORM SCHEMA", module_name)
continue
if not hasattr(module, 'CONFIG_SCHEMA'):
add_msg('NO SCHEMA', module_name)
if not hasattr(module, "CONFIG_SCHEMA"):
add_msg("NO SCHEMA", module_name)
continue
schema_type, schema = _identify_config_schema(module)
add_msg("CONFIG_SCHEMA " + str(schema_type), module_name + ' ' +
color('cyan', str(schema)[:60]))
add_msg(
"CONFIG_SCHEMA " + str(schema_type),
module_name + " " + color("cyan", str(schema)[:60]),
)
for key in sorted(msg):
print("\n{}\n - {}".format(key, '\n - '.join(msg[key])))
print("\n{}\n - {}".format(key, "\n - ".join(msg[key])))
if __name__ == '__main__':
if __name__ == "__main__":
main()