Add plaintext.proto
Update Makefile to handle the import in `plaintext.proto`.
Import path is modified to be relative to the project root.
And we run `protoc` from where `Makefile` locates, i.e. the project
root.
Reference:
- plaintext.proto: 62b2c6c482/sec/insecure/pb/plaintext.proto
This commit is contained in:
parent
7bc363f2fa
commit
59b373b48a
18
Makefile
18
Makefile
|
@ -1,4 +1,10 @@
|
||||||
FILES_TO_LINT = libp2p tests examples setup.py
|
FILES_TO_LINT = libp2p tests examples setup.py
|
||||||
|
PB = libp2p/crypto/pb/crypto.proto libp2p/pubsub/pb/rpc.proto libp2p/security/insecure/pb/plaintext.proto
|
||||||
|
PY = $(PB:.proto=_pb2.py)
|
||||||
|
PYI = $(PB:.proto=_pb2.pyi)
|
||||||
|
|
||||||
|
# Set default to `protobufs`, otherwise `format` is called when typing only `make`
|
||||||
|
all: protobufs
|
||||||
|
|
||||||
format:
|
format:
|
||||||
black $(FILES_TO_LINT)
|
black $(FILES_TO_LINT)
|
||||||
|
@ -10,6 +16,12 @@ lintroll:
|
||||||
isort --recursive --check-only $(FILES_TO_LINT)
|
isort --recursive --check-only $(FILES_TO_LINT)
|
||||||
flake8 $(FILES_TO_LINT)
|
flake8 $(FILES_TO_LINT)
|
||||||
|
|
||||||
protobufs:
|
protobufs: $(PY)
|
||||||
cd libp2p/crypto/pb && protoc --python_out=. --mypy_out=. crypto.proto
|
|
||||||
cd libp2p/pubsub/pb && protoc --python_out=. --mypy_out=. rpc.proto
|
%_pb2.py: %.proto
|
||||||
|
protoc --python_out=. --mypy_out=. $<
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(PY) $(PYI)
|
||||||
|
|
0
libp2p/security/insecure/pb/__init__.py
Normal file
0
libp2p/security/insecure/pb/__init__.py
Normal file
10
libp2p/security/insecure/pb/plaintext.proto
Normal file
10
libp2p/security/insecure/pb/plaintext.proto
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
|
package plaintext.pb;
|
||||||
|
|
||||||
|
import "libp2p/crypto/pb/crypto.proto";
|
||||||
|
|
||||||
|
message Exchange {
|
||||||
|
optional bytes id = 1;
|
||||||
|
optional crypto.pb.PublicKey pubkey = 2;
|
||||||
|
}
|
79
libp2p/security/insecure/pb/plaintext_pb2.py
Normal file
79
libp2p/security/insecure/pb/plaintext_pb2.py
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
|
# source: libp2p/security/insecure/pb/plaintext.proto
|
||||||
|
|
||||||
|
import sys
|
||||||
|
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||||
|
from google.protobuf import descriptor as _descriptor
|
||||||
|
from google.protobuf import message as _message
|
||||||
|
from google.protobuf import reflection as _reflection
|
||||||
|
from google.protobuf import symbol_database as _symbol_database
|
||||||
|
from google.protobuf import descriptor_pb2
|
||||||
|
# @@protoc_insertion_point(imports)
|
||||||
|
|
||||||
|
_sym_db = _symbol_database.Default()
|
||||||
|
|
||||||
|
|
||||||
|
from libp2p.crypto.pb import crypto_pb2 as libp2p_dot_crypto_dot_pb_dot_crypto__pb2
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||||
|
name='libp2p/security/insecure/pb/plaintext.proto',
|
||||||
|
package='plaintext.pb',
|
||||||
|
syntax='proto2',
|
||||||
|
serialized_pb=_b('\n+libp2p/security/insecure/pb/plaintext.proto\x12\x0cplaintext.pb\x1a\x1dlibp2p/crypto/pb/crypto.proto\"<\n\x08\x45xchange\x12\n\n\x02id\x18\x01 \x01(\x0c\x12$\n\x06pubkey\x18\x02 \x01(\x0b\x32\x14.crypto.pb.PublicKey')
|
||||||
|
,
|
||||||
|
dependencies=[libp2p_dot_crypto_dot_pb_dot_crypto__pb2.DESCRIPTOR,])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_EXCHANGE = _descriptor.Descriptor(
|
||||||
|
name='Exchange',
|
||||||
|
full_name='plaintext.pb.Exchange',
|
||||||
|
filename=None,
|
||||||
|
file=DESCRIPTOR,
|
||||||
|
containing_type=None,
|
||||||
|
fields=[
|
||||||
|
_descriptor.FieldDescriptor(
|
||||||
|
name='id', full_name='plaintext.pb.Exchange.id', index=0,
|
||||||
|
number=1, type=12, cpp_type=9, label=1,
|
||||||
|
has_default_value=False, default_value=_b(""),
|
||||||
|
message_type=None, enum_type=None, containing_type=None,
|
||||||
|
is_extension=False, extension_scope=None,
|
||||||
|
options=None, file=DESCRIPTOR),
|
||||||
|
_descriptor.FieldDescriptor(
|
||||||
|
name='pubkey', full_name='plaintext.pb.Exchange.pubkey', index=1,
|
||||||
|
number=2, type=11, cpp_type=10, label=1,
|
||||||
|
has_default_value=False, default_value=None,
|
||||||
|
message_type=None, enum_type=None, containing_type=None,
|
||||||
|
is_extension=False, extension_scope=None,
|
||||||
|
options=None, file=DESCRIPTOR),
|
||||||
|
],
|
||||||
|
extensions=[
|
||||||
|
],
|
||||||
|
nested_types=[],
|
||||||
|
enum_types=[
|
||||||
|
],
|
||||||
|
options=None,
|
||||||
|
is_extendable=False,
|
||||||
|
syntax='proto2',
|
||||||
|
extension_ranges=[],
|
||||||
|
oneofs=[
|
||||||
|
],
|
||||||
|
serialized_start=92,
|
||||||
|
serialized_end=152,
|
||||||
|
)
|
||||||
|
|
||||||
|
_EXCHANGE.fields_by_name['pubkey'].message_type = libp2p_dot_crypto_dot_pb_dot_crypto__pb2._PUBLICKEY
|
||||||
|
DESCRIPTOR.message_types_by_name['Exchange'] = _EXCHANGE
|
||||||
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||||
|
|
||||||
|
Exchange = _reflection.GeneratedProtocolMessageType('Exchange', (_message.Message,), dict(
|
||||||
|
DESCRIPTOR = _EXCHANGE,
|
||||||
|
__module__ = 'libp2p.security.insecure.pb.plaintext_pb2'
|
||||||
|
# @@protoc_insertion_point(class_scope:plaintext.pb.Exchange)
|
||||||
|
))
|
||||||
|
_sym_db.RegisterMessage(Exchange)
|
||||||
|
|
||||||
|
|
||||||
|
# @@protoc_insertion_point(module_scope)
|
45
libp2p/security/insecure/pb/plaintext_pb2.pyi
Normal file
45
libp2p/security/insecure/pb/plaintext_pb2.pyi
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# @generated by generate_proto_mypy_stubs.py. Do not edit!
|
||||||
|
import sys
|
||||||
|
from google.protobuf.descriptor import (
|
||||||
|
Descriptor as google___protobuf___descriptor___Descriptor,
|
||||||
|
)
|
||||||
|
|
||||||
|
from google.protobuf.message import (
|
||||||
|
Message as google___protobuf___message___Message,
|
||||||
|
)
|
||||||
|
|
||||||
|
from libp2p.crypto.pb.crypto_pb2 import (
|
||||||
|
PublicKey as libp2p___crypto___pb___crypto_pb2___PublicKey,
|
||||||
|
)
|
||||||
|
|
||||||
|
from typing import (
|
||||||
|
Optional as typing___Optional,
|
||||||
|
)
|
||||||
|
|
||||||
|
from typing_extensions import (
|
||||||
|
Literal as typing_extensions___Literal,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Exchange(google___protobuf___message___Message):
|
||||||
|
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
|
||||||
|
id = ... # type: bytes
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pubkey(self) -> libp2p___crypto___pb___crypto_pb2___PublicKey: ...
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
*,
|
||||||
|
id : typing___Optional[bytes] = None,
|
||||||
|
pubkey : typing___Optional[libp2p___crypto___pb___crypto_pb2___PublicKey] = None,
|
||||||
|
) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def FromString(cls, s: bytes) -> Exchange: ...
|
||||||
|
def MergeFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
|
||||||
|
def CopyFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
|
||||||
|
if sys.version_info >= (3,):
|
||||||
|
def HasField(self, field_name: typing_extensions___Literal[u"id",u"pubkey"]) -> bool: ...
|
||||||
|
def ClearField(self, field_name: typing_extensions___Literal[u"id",u"pubkey"]) -> None: ...
|
||||||
|
else:
|
||||||
|
def HasField(self, field_name: typing_extensions___Literal[u"id",b"id",u"pubkey",b"pubkey"]) -> bool: ...
|
||||||
|
def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"pubkey",b"pubkey"]) -> None: ...
|
Loading…
Reference in New Issue
Block a user