Skip to content

Commit 58ada8a

Browse files
authored
One more change to import naming
1 parent 41f24b9 commit 58ada8a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ with grpc.insecure_channel(target) as channel:
3333
the equivalent using `yagrc.reflector` would be:
3434
```python
3535
import grpc
36-
from yagrc import reflector
36+
from yagrc import reflector as yagrc_reflector
3737

3838
...
3939

40-
grpc_reflector = reflector.GrpcReflectionClient()
40+
reflector = yagrc_reflector.GrpcReflectionClient()
4141

4242
with grpc.insecure_channel(target) as channel:
43-
grpc_reflector.load_protocols(channel, symbols=["Arithmetic.Subtraction"])
44-
stub_class = grpc_reflector.service_stub_class("Arithmetic.Subtraction")
45-
request_class = grpc_reflector.message_class("Arithmetic.Minuend")
43+
reflector.load_protocols(channel, symbols=["Arithmetic.Subtraction"])
44+
stub_class = reflector.service_stub_class("Arithmetic.Subtraction")
45+
request_class = reflector.message_class("Arithmetic.Minuend")
4646

4747
stub = stub_class(channel)
4848
response = stub.SubtractOne(request_class(number=5))
@@ -51,14 +51,14 @@ with grpc.insecure_channel(target) as channel:
5151
and the equivalent using `yagrc.importer` would be:
5252
```python
5353
import grpc
54-
from yagrc import importer
54+
from yagrc import importer as yagrc_importer
5555

5656
...
5757

58-
grpc_importer = importer.GrpcImporter()
58+
importer = yagrc_importer.GrpcImporter()
5959

6060
with grpc.insecure_channel(target) as channel:
61-
grpc_importer.configure(channel, filenames=["arithmetic/subtract.proto"])
61+
importer.configure(channel, filenames=["arithmetic/subtract.proto"])
6262

6363
from arithmetic import subtract_pb2
6464
from arithmetic import subtract_pb2_grpc
@@ -72,17 +72,17 @@ In both cases, the relevant protocol files must first be loaded, using `GrpcRefl
7272
There is also a lazy importer in `yagrc.importer`, which is simpler to use but less flexible:
7373
```python
7474
import grpc
75-
from yagrc import importer
75+
from yagrc import importer as yagrc_importer
7676

77-
importer.add_lazy_packages(["arithmetic"])
77+
yagrc_importer.add_lazy_packages(["arithmetic"])
7878

7979
from arithmetic import subtract_pb2
8080
from arithmetic import subtract_pb2_grpc
8181

8282
...
8383

8484
with grpc.insecure_channel(target) as channel:
85-
importer.resolve_lazy_imports(channel)
85+
yagrc_importer.resolve_lazy_imports(channel)
8686

8787
stub = subtract_pb2_grpc.SubtractionStub(channel)
8888
response = stub.SubtractOne(subtract_pb2.Minuend(number=5))
@@ -101,17 +101,18 @@ try:
101101
from arithmetic import subtract_pb2_grpc
102102
import_ok = True
103103
except ImportError:
104-
from yagrc import importer
104+
from yagrc import importer as yagrc_importer
105105
import_ok = False
106106

107107
def import_protocols(channel):
108-
grpc_importer = importer.GrpcImporter()
109-
grpc_importer.configure(channel, filenames=["arithmetic/subtract.proto"])
108+
importer = yagrc_importer.GrpcImporter()
109+
importer.configure(channel, filenames=["arithmetic/subtract.proto"])
110110

111111
global subtract_pb2
112112
global subtract_pb2_grpc
113113
from arithmetic import subtract_pb2
114114
from arithmetic import subtract_pb2_grpc
115+
115116
global import_ok
116117
import_ok = True
117118

0 commit comments

Comments
 (0)