|
50 | 50 | 'pvsyst': {'freestanding': (29.0, 0), 'insulated': (15.0, 0)} |
51 | 51 | } |
52 | 52 |
|
| 53 | + |
| 54 | +def _combine_localized_attributes(pvsystem=None, location=None, **kwargs): |
| 55 | + """ |
| 56 | + Get and combine attributes from the pvsystem and/or location |
| 57 | + with the rest of the kwargs. |
| 58 | + """ |
| 59 | + if pvsystem is not None: |
| 60 | + pv_dict = pvsystem.__dict__ |
| 61 | + else: |
| 62 | + pv_dict = {} |
| 63 | + |
| 64 | + if location is not None: |
| 65 | + loc_dict = location.__dict__ |
| 66 | + else: |
| 67 | + loc_dict = {} |
| 68 | + |
| 69 | + new_kwargs = dict(list(pv_dict.items()) + |
| 70 | + list(loc_dict.items()) + |
| 71 | + list(kwargs.items())) |
| 72 | + return new_kwargs |
| 73 | + |
| 74 | + |
53 | 75 | # not sure if this belongs in the pvsystem module. |
54 | 76 | # maybe something more like core.py? It may eventually grow to |
55 | 77 | # import a lot more functionality from other modules. |
@@ -769,22 +791,11 @@ class LocalizedPVSystem(PVSystem, Location): |
769 | 791 | """ |
770 | 792 | def __init__(self, pvsystem=None, location=None, **kwargs): |
771 | 793 |
|
772 | | - # get and combine attributes from the pvsystem and/or location |
773 | | - # with the rest of the kwargs |
774 | | - |
775 | | - if pvsystem is not None: |
776 | | - pv_dict = pvsystem.__dict__ |
777 | | - else: |
778 | | - pv_dict = {} |
779 | | - |
780 | | - if location is not None: |
781 | | - loc_dict = location.__dict__ |
782 | | - else: |
783 | | - loc_dict = {} |
784 | | - |
785 | | - new_kwargs = dict(list(pv_dict.items()) + |
786 | | - list(loc_dict.items()) + |
787 | | - list(kwargs.items())) |
| 794 | + new_kwargs = _combine_localized_attributes( |
| 795 | + pvsystem=pvsystem, |
| 796 | + location=location, |
| 797 | + **kwargs, |
| 798 | + ) |
788 | 799 |
|
789 | 800 | PVSystem.__init__(self, **new_kwargs) |
790 | 801 | Location.__init__(self, **new_kwargs) |
|
0 commit comments