def parse_components(version: str = "master"): components = {} components_with_tests = [] with tempfile.TemporaryDirectory() as tmp: with urlopen( f"https://github.com/home-assistant/home-assistant/archive/{version}.tar.gz" ) as response: tarfile.open(fileobj=BytesIO(response.read())).extractall(tmp) # Use part of a script from the Home Assistant codebase core_path = os.path.join(tmp, f"core-{version}") for entry in os.scandir(os.path.join(core_path, "tests/components")): if entry.is_dir(): components_with_tests.append(entry.name) sys.path.append(core_path) from script.hassfest.model import Integration integrations = Integration.load_dir( pathlib.Path( os.path.join(core_path, "homeassistant/components") ) ) for domain in sorted(integrations): integration = integrations[domain] if not integration.disabled: components[domain] = integration.manifest return components, components_with_tests
def gather_requirements_from_manifests(errors, reqs): """Gather all of the requirements from manifests.""" integrations = Integration.load_dir(Path("homeassistant/components")) for domain in sorted(integrations): integration = integrations[domain] if not integration.manifest: errors.append(f"The manifest for integration {domain} is invalid.") continue process_requirements(errors, integration.requirements, f"homeassistant.components.{domain}", reqs)
def gather_requirements_from_manifests(errors, reqs): """Gather all of the requirements from manifests.""" integrations = Integration.load_dir( pathlib.Path('homeassistant/components')) for domain in sorted(integrations): integration = integrations[domain] if not integration.manifest: errors.append( 'The manifest for integration {} is invalid.'.format(domain)) continue process_requirements(errors, integration.manifest['requirements'], 'homeassistant.components.{}'.format(domain), reqs)
def parse_components(version='master'): components = {} with tempfile.TemporaryDirectory() as tmp: with urlopen(f'https://github.com/home-assistant/home-assistant/archive/{version}.tar.gz') as response: tarfile.open(fileobj=BytesIO(response.read())).extractall(tmp) # Use part of a script from the Home Assistant codebase sys.path.append(os.path.join(tmp, f'home-assistant-{version}')) from script.hassfest.model import Integration integrations = Integration.load_dir(pathlib.Path( os.path.join(tmp, f'home-assistant-{version}', 'homeassistant/components') )) for domain in sorted(integrations): integration = integrations[domain] components[domain] = integration.manifest return components
def parse_components(version='master'): components = {} with tempfile.TemporaryDirectory() as tmp: with urlopen( f'https://github.com/home-assistant/home-assistant/archive/{version}.tar.gz' ) as response: tarfile.open(fileobj=BytesIO(response.read())).extractall(tmp) # Use part of a script from the Home Assistant codebase sys.path.append(os.path.join(tmp, f'home-assistant-{version}')) from script.hassfest.model import Integration integrations = Integration.load_dir( pathlib.Path( os.path.join(tmp, f'home-assistant-{version}', 'homeassistant/components'))) for domain in sorted(integrations): integration = integrations[domain] components[domain] = integration.manifest return components