Skip to content

Commit 188b041

Browse files
Refactor to plugin + GSSHA
1 parent ddbba8d commit 188b041

4 files changed

Lines changed: 259 additions & 46 deletions

File tree

src/xarray_data_accessor/data_converters/factory.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DataConversionFactory:
1010
1111
Protected Attributes:
1212
__data_converters: A dictionary of names : registered data converters.
13-
__conversion_function_provenance: Associated conversion function names
13+
__conversion_function_provenance: Associated conversion function names
1414
with the data converter that registered them.
1515
__conversion_functions: A dictionary of names : conversion functions.
1616
"""
@@ -58,7 +58,7 @@ def register(
5858

5959
if len(cls.__conversion_functions) != len_i:
6060
cls.__data_converters[data_converter.__name__] = data_converter
61-
61+
6262
# update the data conversion functions
6363
DataConversionFunctions.add_functions()
6464

@@ -75,30 +75,34 @@ def unregister(
7575
f'{data_converter.__name__} is not registered with the '
7676
f'DataConversionFactory.',
7777
)
78-
78+
7979
@classmethod
8080
def get_functions(
8181
cls,
8282
) -> Dict[str, DataConverterBase.ConversionFunctionType]:
8383
"""Returns a dictionary of conversion functions."""
8484
return cls.__conversion_functions
85-
85+
8686
@classmethod
8787
def get_converter_classes(
8888
cls,
8989
) -> Dict[str, DataConverterBase]:
9090
return cls.__data_converters
9191

92+
9293
class DataConversionFunctions:
9394
"""A class for accessing data conversion functions."""
94-
95+
9596
__data_conversion_factory = DataConversionFactory
9697

9798
@classmethod
98-
def add_functions(cls):
99+
def get_factory(cls) -> DataConversionFactory:
100+
"""Returns the factory."""
101+
return cls.__data_conversion_factory
102+
103+
@classmethod
104+
def add_functions(cls):
99105
# add the data conversion functions
100106
for name, func in cls.__data_conversion_factory.get_functions().items():
101107
if name not in cls.__dict__.keys():
102108
setattr(cls, name, func)
103-
104-

0 commit comments

Comments
 (0)