def __init__( self, config: dict = {}, downloader: Downloader = Downloader.instance(), ) -> None: self.config = config self.downloader = downloader self.data = {} if 'source' in config: # If this has an external source attached to it, let's try to # install it resource_template = ResourceTemplate.from_json( config, downloader=downloader) # Avoid building context if we can since it may result in downloading # unnecessary external data resource = resource_template.render(**self.default_context) if resource.target_path.exists(): self.resource = resource else: self.resource = resource_template.render(**self.context) self.install() else: self.resource = None self.load()
def __init__( self, urls: List[str], match: str, ttl: int = 86400, downloader: Downloader = Downloader.instance(), ): self.urls = urls self.match = match self.ttl = ttl self.downloader = downloader self.download_dir = Path( f'{tempfile.gettempdir()}/discovery/{self.name}') self._loaded = False
def __init__( self, base_url: str, metadata_url: str, paths: Dict[str, str], ttl: int = 86400, downloader: Downloader = Downloader.instance(), ): self.base_url = base_url self.metadata_url = metadata_url.format(base=base_url) self.paths = paths self.ttl = ttl self.downloader = downloader self.download_dir = Path( f'{tempfile.gettempdir()}/discovery/{self.name}') self._mappings = None
def __init__(self, system: BaseSystem, name: str, protocol: str, url: Optional[str], emulator: Optional[str], resource_templates: Dict[str, dict], auth: Optional[str] = None, discovery: Optional[dict] = None, datlist: Optional[List[str]] = None, downloads: Optional[dict] = None, filters: Optional[dict] = None, context: dict = {}, ): self.system = system self.name = name self.protocol = protocol self.url = url self.emulator = emulator self.downloader = Downloader(auth=auth, **downloads) self.filter_set = FilterSet.from_json(filters or {}, system.config, system.supported_filters) # Configure resources discovery = discovery and BaseDiscovery.from_json(discovery, downloader=self.downloader) self.resource_templates = { name: ResourceTemplate.from_json( config, downloader=self.downloader, discovery=discovery, default_context={'url': url}, ) for name, config in resource_templates.items() } # Internal dat list for systems that don't have dat files if datlist: if type(datlist) is list: self.datlist = [{'name': name} for name in datlist] else: self.datlist = [{'name': name, **attrs} for name, attrs in datlist.items()] else: self.datlist = None self.machines = {} self.load()
def __init__(self, config: dict = {}, downloader: Downloader = Downloader.instance(), ) -> None: self.config = config self.downloader = downloader if 'source' in config: # If this has an external source attached to it, let's try to # install it self.resource_template = ResourceTemplate.from_json( config, downloader=downloader, ) self.install() else: self.resource_template = None self.load()
def __init__( self, source_url_template: str, target_path_template: Optional[str], download_path_template: Optional[str] = None, downloader: Downloader = Downloader.instance(), install_action: BaseAction = Copy(), discovery: Optional[BaseDiscovery] = None, file_identifier: str = 'crc', default_context: dict = {}, ): self.source_url_template = source_url_template self.target_path_template = target_path_template self.download_path_template = download_path_template self.downloader = downloader self.install_action = install_action self.discovery = discovery self.file_identifier = file_identifier self.default_context = default_context
def __init__( self, system: BaseSystem, name: str, protocol: str, url: Optional[str], emulator: Optional[str], resource_templates: Dict[str, dict], auth: Optional[str] = None, discovery: Optional[dict] = None, datlist: Optional[List[str]] = None, downloads: Optional[dict] = None, context: dict = {}, ): self.system = system self.name = name self.protocol = protocol self.url = url self.emulator = emulator self.downloader = Downloader(auth=auth, **downloads) # Configure resources discovery = discovery and BaseDiscovery.from_json( discovery, downloader=self.downloader) self.resource_templates = { name: ResourceTemplate.from_json( config, downloader=self.downloader, discovery=discovery, default_context={'url': url}, ) for name, config in resource_templates.items() } # Internal dat list for systems that don't have dat files self.datlist = datlist self.machines = {} self.load()