Skip to content

Commit 199fc6d

Browse files
committed
other: don't create separate folders for plugins
This way - I hope - the weird includes like below would improve: help(mavsdk.action.action) Help on module mavsdk.action.action in mavsdk.action: To: help(mavsdk.action) Help on module mavsdk.action in mavsdk:
1 parent 2ef1875 commit 199fc6d

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

other/templates/py/file.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from .._base import AsyncBase
2+
from ._base import AsyncBase
33
from . import {{ plugin_name.lower_snake_case }}_pb2, {{ plugin_name.lower_snake_case }}_pb2_grpc
44
from enum import Enum
55

other/templates/rst/file.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ plugin_name.upper_camel_case }}
22
====
33

4-
.. automodule:: mavsdk.generated.{{ plugin_name.lower_snake_case }}
4+
.. automodule:: mavsdk.{{ plugin_name.lower_snake_case }}
55
:members:
66
:undoc-members:
77
:show-inheritance:

other/tools/run_protoc.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ function generate {
3434

3535
# We need to create the .original backup files, otherwise we're not compatible with
3636
# BSD sed.
37-
sed -i'.sedoriginal' -e "s/import mavsdk_options_pb2/from .. import mavsdk_options_pb2/" \
37+
sed -i'.sedoriginal' -e "s/import mavsdk_options_pb2/from . import mavsdk_options_pb2/" \
3838
"${GENERATED_DIR}/${plugin}/${plugin}_pb2.py"
3939
sed -i'.sedoriginal' -e "s/from ${plugin} import ${plugin}_pb2/from . import ${plugin}_pb2/" \
4040
"${GENERATED_DIR}/${plugin}/${plugin}_pb2_grpc.py"
41-
## Clean up the backup files.
41+
# Clean up the backup files.
4242
find ${GENERATED_DIR} -name '*.sedoriginal' -delete
4343

44+
mv "${GENERATED_DIR}/${plugin}/${plugin}_pb2.py" "${GENERATED_DIR}/${plugin}_pb2.py"
45+
mv "${GENERATED_DIR}/${plugin}/${plugin}_pb2_grpc.py" "${GENERATED_DIR}/${plugin}_pb2_grpc.py"
46+
47+
4448
echo " -> [+] Generated protobuf and gRPC bindings for ${plugin}"
4549

4650
# Generate plugin
@@ -51,11 +55,7 @@ function generate {
5155
${plugin}/${plugin}.proto
5256

5357
# protoc-gen-dcsdk capitalizes filenames, and we don't want that with python
54-
mv ${GENERATED_DIR}/${plugin}/$(snake_case_to_camel_case ${plugin}).py ${GENERATED_DIR}/${plugin}/${plugin}.py
55-
56-
# Make a module out of it
57-
echo "from .${plugin} import *" > ${GENERATED_DIR}/${plugin}/__init__.py
58-
echo " -> [+] Generated plugin for ${plugin}"
58+
mv ${GENERATED_DIR}/${plugin}/$(snake_case_to_camel_case ${plugin}).py ${GENERATED_DIR}/${plugin}.py
5959

6060
# Generate plugin doc entry
6161
python3 -m grpc_tools.protoc -I${PROTO_DIR}/protos \
@@ -75,6 +75,8 @@ function generate {
7575
echo " ${plugin}" >> ${GENERATED_DIR_RST}/index.rst
7676
fi
7777

78+
rmdir ${GENERATED_DIR}/${plugin}
79+
7880
done
7981
}
8082

0 commit comments

Comments
 (0)