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