def check_config(cls, config: Dict[Any, Any]) -> ImageCrawlerConfig: subreddit = config["subreddit"] if type(subreddit) is not str: raise TypeError("subreddit {!r} is not str".format(subreddit)) if 0 == len(subreddit): raise ValueError("subreddit {!r} is empty".format(subreddit)) return ImageCrawlerConfig(subreddit=subreddit, )
def check_config(cls, config: Dict[Any, Any]) -> ImageCrawlerConfig: user_name = config["user_name"] if type(user_name) is not str: raise TypeError("user_name {!r} is not str".format(user_name)) if 0 == len(user_name): raise ValueError("user_name {!r} is empty".format(user_name)) return ImageCrawlerConfig(user_name=user_name.lower(), )
def check_config(cls, config: Dict[Any, Any]) -> ImageCrawlerConfig: image_uri = config["image_uri"] if type(image_uri) is not str: raise TypeError("image_uri {!r} is not str".format(image_uri)) if 0 == len(image_uri): raise ValueError("image_uri {!r} is empty".format(image_uri)) return ImageCrawlerConfig( image_uri=image_uri, )
def check_config(cls, config: Dict[Any, Any]) -> ImageCrawlerConfig: promoted = config[ 'promoted'] if 'promoted' in config else True # type: bool if type(promoted) is not bool: raise TypeError('promoted {!r} is not bool'.format(promoted)) tags = config['tags'] if 'tags' in config else None tags = cls.__check_config_tags(tags) return ImageCrawlerConfig( promoted=promoted, tags=tags, )
def check_config(cls, config: Dict[Any, Any]) -> ImageCrawlerConfig: width = config["width"] height = config["height"] if type(width) is not int: raise TypeError("width {!r} is not int".format(width)) if type(height) is not int: raise TypeError("height {!r} is not int".format(height)) if width <= 0: raise ValueError("width {!r} <= 0".format(width)) if height <= 0: raise ValueError("height {!r} <= 0".format(height)) return ImageCrawlerConfig( width=width, height=height, )