Rename "blenderpack" module to "bpackage"

Also split code into files by class
This commit is contained in:
gandalf3
2017-07-06 22:58:17 -07:00
parent bc6f5bcdd4
commit bbc1c8b3bf
6 changed files with 62 additions and 62 deletions

39
bpackage/package.py Normal file
View File

@@ -0,0 +1,39 @@
#!/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))