grpc
examples
python
route_guide
route_guide/route_guide_resources.py
Go to the documentation of this file.
1
# Copyright 2015 gRPC authors.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
# http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
"""Common resources used in the gRPC route guide example."""
15
16
import
json
17
18
import
route_guide_pb2
19
20
21
def
read_route_guide_database
():
22
"""Reads the route guide database.
23
24
Returns:
25
The full contents of the route guide database as a sequence of
26
route_guide_pb2.Features.
27
"""
28
feature_list = []
29
with
open
(
"route_guide_db.json"
)
as
route_guide_db_file:
30
for
item
in
json.load(route_guide_db_file):
31
feature =
route_guide_pb2.Feature
(
32
name=item[
"name"
],
33
location=
route_guide_pb2.Point
(
34
latitude=item[
"location"
][
"latitude"
],
35
longitude=item[
"location"
][
"longitude"
]))
36
feature_list.append(feature)
37
return
feature_list
route_guide_resources.read_route_guide_database
def read_route_guide_database()
Definition:
multiplex/route_guide_resources.py:21
route_guide_pb2.Point
Point
Definition:
multiplex/route_guide_pb2.py:242
open
#define open
Definition:
test-fs.c:46
route_guide_pb2.Feature
Feature
Definition:
multiplex/route_guide_pb2.py:256
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:06