#!/usr/bin/env python3 # HACK: seems 'requests' module bundled with blender isn't bundled with 'idna' module. So force system python for now import sys sys.path.insert(0, '/usr/lib/python3.6/site-packages') import logging log = logging.getLogger(__name__) class Package: """ Stores package methods and metadata """ def __init__(self, package_dict:dict = None): self.from_dict(package_dict) def to_dict(self) -> dict: """ Return a dict representation of the package """ return { 'bl_info': self.bl_info, 'url': self.url, } def from_dict(self, package_dict: dict): """ Get attributes from a dict such as produced by `to_dict` """ if package_dict is None: package_dict = {} for attr in ('name', 'url', 'bl_info'): setattr(self, attr, package_dict.get(attr))