honeybee-core 1.64.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- honeybee/__init__.py +23 -0
- honeybee/__main__.py +4 -0
- honeybee/_base.py +331 -0
- honeybee/_basewithshade.py +310 -0
- honeybee/_lockable.py +99 -0
- honeybee/altnumber.py +47 -0
- honeybee/aperture.py +997 -0
- honeybee/boundarycondition.py +358 -0
- honeybee/checkdup.py +173 -0
- honeybee/cli/__init__.py +118 -0
- honeybee/cli/compare.py +132 -0
- honeybee/cli/create.py +265 -0
- honeybee/cli/edit.py +559 -0
- honeybee/cli/lib.py +103 -0
- honeybee/cli/setconfig.py +43 -0
- honeybee/cli/validate.py +224 -0
- honeybee/colorobj.py +363 -0
- honeybee/config.json +5 -0
- honeybee/config.py +347 -0
- honeybee/dictutil.py +54 -0
- honeybee/door.py +746 -0
- honeybee/extensionutil.py +208 -0
- honeybee/face.py +2360 -0
- honeybee/facetype.py +153 -0
- honeybee/logutil.py +79 -0
- honeybee/model.py +4272 -0
- honeybee/orientation.py +132 -0
- honeybee/properties.py +845 -0
- honeybee/room.py +3485 -0
- honeybee/search.py +107 -0
- honeybee/shade.py +514 -0
- honeybee/shademesh.py +362 -0
- honeybee/typing.py +498 -0
- honeybee/units.py +88 -0
- honeybee/writer/__init__.py +7 -0
- honeybee/writer/aperture.py +6 -0
- honeybee/writer/door.py +6 -0
- honeybee/writer/face.py +6 -0
- honeybee/writer/model.py +6 -0
- honeybee/writer/room.py +6 -0
- honeybee/writer/shade.py +6 -0
- honeybee/writer/shademesh.py +6 -0
- honeybee_core-1.64.12.dist-info/METADATA +94 -0
- honeybee_core-1.64.12.dist-info/RECORD +48 -0
- honeybee_core-1.64.12.dist-info/WHEEL +5 -0
- honeybee_core-1.64.12.dist-info/entry_points.txt +2 -0
- honeybee_core-1.64.12.dist-info/licenses/LICENSE +661 -0
- honeybee_core-1.64.12.dist-info/top_level.txt +1 -0
honeybee/_lockable.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""Descriptor that for locking and unlocking an object, preventing attribute setting."""
|
|
3
|
+
from functools import wraps
|
|
4
|
+
from inspect import getmro
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def lockable(cls):
|
|
8
|
+
"""A decorator for making lockable class.
|
|
9
|
+
|
|
10
|
+
If a class is locked, attributes can no longer be set on the class.
|
|
11
|
+
The class will throw an AttributeError if one tries to do so.
|
|
12
|
+
|
|
13
|
+
Classes start out as unlocked but can be locked by calling the `lock()` method.
|
|
14
|
+
If the class needs to be unlocked again, calling the `unlock()` method will
|
|
15
|
+
unlock it and allow you to edit attributes on the class. You can also create
|
|
16
|
+
a class that starts out as locked by putting `self._locked = True` at the end
|
|
17
|
+
of a class's `__init__` method.
|
|
18
|
+
|
|
19
|
+
Note that classes using __slots__ must specify a '_locked' variable within
|
|
20
|
+
the __slots__ in order to work correctly with this decorator.
|
|
21
|
+
|
|
22
|
+
This example if modified from:
|
|
23
|
+
http://stackoverflow.com/questions/3603502/prevent-creating-new-attributes-outside-init
|
|
24
|
+
|
|
25
|
+
Usage:
|
|
26
|
+
|
|
27
|
+
.. code-block:: python
|
|
28
|
+
|
|
29
|
+
@lockable
|
|
30
|
+
class Foo(object):
|
|
31
|
+
def __init__(self):
|
|
32
|
+
self.bar = 10
|
|
33
|
+
|
|
34
|
+
foo = Foo()
|
|
35
|
+
foo.bar = 20
|
|
36
|
+
|
|
37
|
+
foo.lock()
|
|
38
|
+
try:
|
|
39
|
+
foo.bar = 30
|
|
40
|
+
except AttributeError as e:
|
|
41
|
+
print(e)
|
|
42
|
+
> Failed to set bar to 30. bar cannot be set on Foo while it is locked.
|
|
43
|
+
The unlock() method can unlock the class but you do so at your own risk.
|
|
44
|
+
Objects are typically locked when they are referenced from many other objects.
|
|
45
|
+
So it is usually better to make a new instance of Foo and proceed using that.
|
|
46
|
+
|
|
47
|
+
foo.unlock()
|
|
48
|
+
foo.bar = 30
|
|
49
|
+
foo.lock()
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def lockedsetattr(self, key, value):
|
|
53
|
+
"""Method to overwrite __setattr__ on the decorated class."""
|
|
54
|
+
if hasattr(self, '_locked') and self._locked and not key == '_locked':
|
|
55
|
+
raise AttributeError(
|
|
56
|
+
'Failed to set {1} to {2}. {1} cannot be set on {0} while it is locked.'
|
|
57
|
+
'\nThe unlock() method can unlock the class but you do so at '
|
|
58
|
+
'your own risk.\nObjects are typically locked when they are referenced '
|
|
59
|
+
'from several other objects.\n So it is usually better practice to'
|
|
60
|
+
'make a new instance of {0} and proceed using that.'.format(
|
|
61
|
+
cls.__name__, key, value))
|
|
62
|
+
else:
|
|
63
|
+
object.__setattr__(self, key, value)
|
|
64
|
+
|
|
65
|
+
def init_decorator(func):
|
|
66
|
+
"""Initialize the lockable decorator for the class."""
|
|
67
|
+
|
|
68
|
+
@wraps(func)
|
|
69
|
+
def wrapper(self, *args, **kwargs):
|
|
70
|
+
func(self, *args, **kwargs)
|
|
71
|
+
return wrapper
|
|
72
|
+
|
|
73
|
+
def lock(self):
|
|
74
|
+
self._locked = True
|
|
75
|
+
|
|
76
|
+
def unlock(self):
|
|
77
|
+
self._locked = False
|
|
78
|
+
|
|
79
|
+
# overwrite the various methods on the class to support lockability
|
|
80
|
+
cls.__setattr__ = lockedsetattr
|
|
81
|
+
cls.__init__ = init_decorator(cls.__init__)
|
|
82
|
+
if not hasattr(cls, 'lock'): # allow developers to add their own lock method
|
|
83
|
+
cls.lock = lock
|
|
84
|
+
if not hasattr(cls, 'unlock'): # allow developers to add their own unlock method
|
|
85
|
+
cls.unlock = unlock
|
|
86
|
+
|
|
87
|
+
# if the class uses __slots__, check that _locked is somewhere in inheritance tree
|
|
88
|
+
if hasattr(cls, '__slots__'):
|
|
89
|
+
_all_good = False
|
|
90
|
+
for parent_class in getmro(cls)[:-1]:
|
|
91
|
+
if '_locked' in parent_class.__slots__:
|
|
92
|
+
_all_good = True
|
|
93
|
+
break
|
|
94
|
+
if not _all_good:
|
|
95
|
+
raise AttributeError(
|
|
96
|
+
'When using the @lockable decorator on a class with __slots__, '
|
|
97
|
+
'a "_locked" variable must be specified within __slots__.')
|
|
98
|
+
|
|
99
|
+
return cls
|
honeybee/altnumber.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Objects used as alternatives to various numerical properties."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _AltNumber(object):
|
|
5
|
+
__slots__ = ()
|
|
6
|
+
|
|
7
|
+
def __init__(self):
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def name(self):
|
|
12
|
+
return self.__class__.__name__
|
|
13
|
+
|
|
14
|
+
def to_dict(self):
|
|
15
|
+
"""Get the object as a dictionary."""
|
|
16
|
+
return {'type': self.name}
|
|
17
|
+
|
|
18
|
+
def ToString(self):
|
|
19
|
+
return self.__repr__()
|
|
20
|
+
|
|
21
|
+
def __eq__(self, other):
|
|
22
|
+
return self.__class__ == other.__class__
|
|
23
|
+
|
|
24
|
+
def __ne__(self, other):
|
|
25
|
+
return not self.__eq__(other)
|
|
26
|
+
|
|
27
|
+
def __repr__(self):
|
|
28
|
+
return self.name
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class NoLimit(_AltNumber):
|
|
32
|
+
"""Object representing no limit to a certain numerical value."""
|
|
33
|
+
__slots__ = ()
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Autocalculate(_AltNumber):
|
|
38
|
+
"""Object representing when a certain numerical value is automatically calculated.
|
|
39
|
+
|
|
40
|
+
Typically, this means that the value is determined from other variables.
|
|
41
|
+
"""
|
|
42
|
+
__slots__ = ()
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
no_limit = NoLimit()
|
|
47
|
+
autocalculate = Autocalculate()
|