fairyfly-core 0.2.3__py3-none-any.whl → 0.2.4__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.
fairyfly/dictutil.py ADDED
@@ -0,0 +1,40 @@
1
+ # coding=utf-8
2
+ """Utilities to convert any dictionary to Python objects.
3
+
4
+ Note that importing this module will import almost all modules within the
5
+ library in order to be able to re-serialize almost any dictionary produced
6
+ from the library.
7
+ """
8
+ from fairyfly.model import Model
9
+ from fairyfly.shape import Shape
10
+ from fairyfly.boundary import Boundary
11
+
12
+
13
+ def dict_to_object(fairyfly_dict, raise_exception=True):
14
+ """Re-serialize a dictionary of almost any object within fairyfly.
15
+
16
+ This includes any Model, Shape or Boundary object.
17
+
18
+ Args:
19
+ fairyfly_dict: A dictionary of any Fairyfly object. Note
20
+ that this should be a non-abridged dictionary to be valid.
21
+ raise_exception: Boolean to note whether an exception should be raised
22
+ if the object is not identified as a part of fairyfly.
23
+ Default: True.
24
+
25
+ Returns:
26
+ A Python object derived from the input fairyfly_dict.
27
+ """
28
+ try: # get the type key from the dictionary
29
+ obj_type = fairyfly_dict['type']
30
+ except KeyError:
31
+ raise ValueError('Fairyfly dictionary lacks required "type" key.')
32
+
33
+ if obj_type == 'Model':
34
+ return Model.from_dict(fairyfly_dict)
35
+ elif obj_type == 'Shape':
36
+ return Shape.from_dict(fairyfly_dict)
37
+ elif obj_type == 'Boundary':
38
+ return Boundary.from_dict(fairyfly_dict)
39
+ elif raise_exception:
40
+ raise ValueError('{} is not a recognized fairyfly object'.format(obj_type))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fairyfly-core
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: A library to represent construction detail geometry for environmental simulation.
5
5
  Home-page: https://github.com/ladybug-tools/fairyfly-core
6
6
  Author: Ladybug Tools
@@ -6,6 +6,7 @@ fairyfly/boundary.py,sha256=e-O-3IxgU0KbZX3BbW6R1DmFaFZgLMghsaab9NqvHJk,13056
6
6
  fairyfly/checkdup.py,sha256=wO_LN6Mr72i-tlrGxy1qbvfzCwz5gDcDxXfaQumkz7o,8207
7
7
  fairyfly/config.json,sha256=Sd5gBLwKM8e88InpFFzYG8UB77WHlfQPT4jap09D6s4,131
8
8
  fairyfly/config.py,sha256=VfQ-vRX-q1CLja4xFMGVte-FpdFStdMXj98WKpmMOFA,10633
9
+ fairyfly/dictutil.py,sha256=nVwoWG4FsoV9nYjQxI3jBxVeZcdy2TQd1FKhEquVLR8,1469
9
10
  fairyfly/extensionutil.py,sha256=5MQV0gZBc6_vfbVr4j8l_8JslMsj4bBbsZ4yqZ2VPG4,2716
10
11
  fairyfly/logutil.py,sha256=Urxl0U14-qffIt6NiGLT6pV-796oAGUvnnf2ypj1j9Q,2564
11
12
  fairyfly/model.py,sha256=2S7yGWZCNa7To1CyAhZ44IgIgBcMveu1t6hTfSo4czk,44282
@@ -20,9 +21,9 @@ fairyfly/writer/__init__.py,sha256=D4FdE2LUVCMvfud3qL2UquH1uCz3EGlKOEMgstMjtXc,2
20
21
  fairyfly/writer/boundary.py,sha256=skpfcFyxWLvjTSStbCh5f4wehSHeI-eKMgoeSCzvO7Q,190
21
22
  fairyfly/writer/model.py,sha256=6Y15NVGCjmYcBdimxyQWnE8AAhQAJi6A7QfMi4P49M4,181
22
23
  fairyfly/writer/shape.py,sha256=pMlLbk3WkrNPbNvowDQ_JFgNkhHNOlqL52TMZKB7zKo,181
23
- fairyfly_core-0.2.3.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
24
- fairyfly_core-0.2.3.dist-info/METADATA,sha256=bdmVF7kM_c_Z11yK7yUSPekfDjcego07zbLHr59iF8Q,3291
25
- fairyfly_core-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- fairyfly_core-0.2.3.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
27
- fairyfly_core-0.2.3.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
28
- fairyfly_core-0.2.3.dist-info/RECORD,,
24
+ fairyfly_core-0.2.4.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
25
+ fairyfly_core-0.2.4.dist-info/METADATA,sha256=BkBBBHkyQNFLXpFc6Rw3W3PWILm6v6Mq-XzFstofUHQ,3291
26
+ fairyfly_core-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ fairyfly_core-0.2.4.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
28
+ fairyfly_core-0.2.4.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
29
+ fairyfly_core-0.2.4.dist-info/RECORD,,