Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated proto pb_plugin #347

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.egg-info/
*__pycache__/
*.pyc
.idea/
pb_plugins/generated/
build/
dist/
1 change: 0 additions & 1 deletion pb_plugins/protoc_gen_mavsdk/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
name_parser_factory,
type_info_factory)

import protoc_gen_mavsdk.mavsdk_options_pb2

class AutoGen(object):
""" Autogenerator for the MAVSDK bindings """
Expand Down
2 changes: 1 addition & 1 deletion pb_plugins/protoc_gen_mavsdk/docs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


class Docs():
class Docs:
"""
Docs

Expand Down
109 changes: 54 additions & 55 deletions pb_plugins/protoc_gen_mavsdk/mavsdk_options_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pb_plugins/protoc_gen_mavsdk/name_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from os import environ


class NameParserFactory:
_initialisms = []

Expand Down
1 change: 0 additions & 1 deletion pb_plugins/protoc_gen_mavsdk/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
name_parser_factory,
Param,
type_info_factory)
from jinja2.exceptions import TemplateNotFound


class Struct(object):
Expand Down
4 changes: 2 additions & 2 deletions pb_plugins/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
protobuf>=3.13,<=3.20.1
jinja2>=2.11
protobuf>=5.27.1
jinja2>=3.1.4
6 changes: 2 additions & 4 deletions pb_plugins/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os
import subprocess
import sys

from distutils.command.build import build
from distutils.spawn import find_executable
from setuptools import setup


def parse_requirements(filename):
"""
Helper which parses requirement_?.*.txt files
Expand All @@ -26,6 +23,7 @@ def parse_requirements(filename):
with open(filepath, encoding="utf-8") as f:
return [requires.strip() for requires in f.readlines()]


setup(
name="protoc-gen-mavsdk",
version="1.1.1",
Expand Down
8 changes: 4 additions & 4 deletions pb_plugins/test/test_name_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from protoc_gen_mavsdk.name_parser import (NameParser, NameParserFactory)
from unittest.mock import patch, mock_open

class TestNameParser(unittest.TestCase):

class TestNameParser(unittest.TestCase):
_initialisms_data = """ ["HTTP", "HTTPS", "URL", "ID"] """

def setUp(self):
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_no_initialisms_when_no_initialims_file(self, mock_file):
@patch("builtins.open", new_callable=mock_open, read_data=_initialisms_data)
def test_initalism_is_capitalized_when_camel_case(self, mock_file):
name_parser_factory = NameParserFactory()
name_parser_factory.set_template_path("random/path")
name_parser_factory.set_initialisms_path("random/path")
name = name_parser_factory.create("fileUrl")

self.assertEqual("FileURL", name.upper_camel_case)
Expand All @@ -173,15 +173,15 @@ def test_initalism_is_capitalized_when_camel_case(self, mock_file):
@patch("builtins.open", new_callable=mock_open, read_data=_initialisms_data)
def test_initalism_is_capitalized_when_upper_snake_case(self, mock_file):
name_parser_factory = NameParserFactory()
name_parser_factory.set_template_path("random/path")
name_parser_factory.set_initialisms_path("random/path")
name = name_parser_factory.create("fileUrl")

self.assertEqual("File_URL", name.upper_snake_case)

@patch("builtins.open", new_callable=mock_open, read_data=_initialisms_data)
def test_initalism_is_not_capitalized_when_lower_snake_case(self, mock_file):
name_parser_factory = NameParserFactory()
name_parser_factory.set_template_path("random/path")
name_parser_factory.set_initialisms_path("random/path")
name = name_parser_factory.create("fileUrl")

self.assertEqual("file_url", name.lower_snake_case)
Expand Down
Loading
Loading