zephyr/scripts/west_commands/fetchers/core.py
Carles Cufi 336aa9dc88 modules: Basic binary blob infrastructure
This patch introduces the basic infrastructure to list and fetch binary
blobs. This includes:

- The new 'blobs' extension command
- An implementation of the `west blobs list` command
  with custom formatting
- A very simple mechanism for loading fetchers
- A basic implementation of an HTTP fetcher

In order to ensure consistency among the west extension commands in the
main zephyr tree, we reuse a similar class factory pattern that is present
for ZephyrBinaryRunner instances in the ZephyrBlobFetcher case. This
could be achieved with a simpler mechanism, but opted for consistency
before simplicity.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-08-16 05:59:02 -07:00

24 lines
628 B
Python

# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
from abc import ABC, abstractmethod
from pathlib import Path
from typing import List, Type
class ZephyrBlobFetcher(ABC):
@staticmethod
def get_fetchers() -> List[Type['ZephyrBlobFetcher']]:
'''Get a list of all currently defined fetcher classes.'''
return ZephyrBlobFetcher.__subclasses__()
@classmethod
@abstractmethod
def schemes(cls) -> List[str]:
'''Return this fetcher's schemes.'''
@abstractmethod
def fetch(self, url: str, path: Path):
''' Fetch a blob and store it '''