blob: 2721d07f9bdc9a909c9514a8f3841e688a240369 [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001'''Replace auto-generated classes with our own, where necessary.
2'''
3
Adam Israelc3e6c2e2018-03-01 09:31:50 -05004from . import _client, _definitions, overrides # isort:skip
Adam Israeldcdf82b2017-08-15 15:26:43 -04005
6for o in overrides.__all__:
Adam Israel1a15d1c2017-10-23 12:00:49 -04007 if "Facade" not in o:
Adam Israeldcdf82b2017-08-15 15:26:43 -04008 # Override stuff in _definitions, which is all imported
9 # into _client. We Monkey patch both the original class and
10 # the ref in _client (import shenanigans are fun!)
11 setattr(_definitions, o, getattr(overrides, o))
12 setattr(_client, o, getattr(overrides, o))
13 # We shouldn't be overriding Facades!
14 else:
15 raise ValueError(
16 "Cannot override a versioned Facade class -- you must patch "
17 "it instead.")
18
19for o in overrides.__patches__:
20 # Patch a versioned Facade.
21 for client_version in _client.CLIENTS.values():
22 try:
23 c_type = getattr(client_version, o)
24 except AttributeError:
25 # Not all the _client<version> modules may have the
26 # facade. That's okay -- we just skip over them.
27 continue
28 o_type = getattr(overrides, o)
29 for a in dir(o_type):
30 if not a.startswith('_'):
31 setattr(c_type, a, getattr(o_type, a))
32
Adam Israelc3e6c2e2018-03-01 09:31:50 -050033from ._client import * # noqa, isort:skip