2f3e49d98d44e7b1d76a00898841c26096a99678
1 '''Replace auto-generated classes with our own, where necessary.
4 from . import _client
, _definitions
, overrides
7 for o
in overrides
.__all
__:
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!
17 "Cannot override a versioned Facade class -- you must patch "
20 for o
in overrides
.__patches
__:
21 # Patch a versioned Facade.
22 for client_version
in _client
.CLIENTS
.values():
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.
29 o_type
= getattr(overrides
, o
)
31 if not a
.startswith('_'):
32 setattr(c_type
, a
, getattr(o_type
, a
))
34 from ._client
import * # noqa