This repository has been archived on 2023-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-package-manager-addon/bpackage/package.py

40 lines
942 B
Python
Raw Normal View History

#!/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))