|
45 | 45 | } |
46 | 46 |
|
47 | 47 |
|
| 48 | +def _combine_localized_attributes(pvsystem=None, location=None, **kwargs): |
| 49 | + """ |
| 50 | + Get and combine attributes from the pvsystem and/or location |
| 51 | + with the rest of the kwargs. |
| 52 | + """ |
| 53 | + if pvsystem is not None: |
| 54 | + pv_dict = pvsystem.__dict__ |
| 55 | + else: |
| 56 | + pv_dict = {} |
| 57 | + |
| 58 | + if location is not None: |
| 59 | + loc_dict = location.__dict__ |
| 60 | + else: |
| 61 | + loc_dict = {} |
| 62 | + |
| 63 | + new_kwargs = dict( |
| 64 | + list(pv_dict.items()) + list(loc_dict.items()) + list(kwargs.items()) |
| 65 | + ) |
| 66 | + return new_kwargs |
| 67 | + |
| 68 | + |
48 | 69 | # not sure if this belongs in the pvsystem module. |
49 | 70 | # maybe something more like core.py? It may eventually grow to |
50 | 71 | # import a lot more functionality from other modules. |
@@ -830,22 +851,11 @@ class LocalizedPVSystem(PVSystem, Location): |
830 | 851 | """ |
831 | 852 | def __init__(self, pvsystem=None, location=None, **kwargs): |
832 | 853 |
|
833 | | - # get and combine attributes from the pvsystem and/or location |
834 | | - # with the rest of the kwargs |
835 | | - |
836 | | - if pvsystem is not None: |
837 | | - pv_dict = pvsystem.__dict__ |
838 | | - else: |
839 | | - pv_dict = {} |
840 | | - |
841 | | - if location is not None: |
842 | | - loc_dict = location.__dict__ |
843 | | - else: |
844 | | - loc_dict = {} |
845 | | - |
846 | | - new_kwargs = dict(list(pv_dict.items()) + |
847 | | - list(loc_dict.items()) + |
848 | | - list(kwargs.items())) |
| 854 | + new_kwargs = _combine_localized_attributes( |
| 855 | + pvsystem=pvsystem, |
| 856 | + location=location, |
| 857 | + **kwargs, |
| 858 | + ) |
849 | 859 |
|
850 | 860 | PVSystem.__init__(self, **new_kwargs) |
851 | 861 | Location.__init__(self, **new_kwargs) |
|
0 commit comments