diff options
author | wsnk <wsnk@yandex-team.ru> | 2022-02-10 16:49:04 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:04 +0300 |
commit | 5e85b96f0cd76b3abbadf46ecb14f9cbec09de4c (patch) | |
tree | 5e16efe6d6d0e0425b8b6eb91262aa5f4b40b49c | |
parent | 61d3fa4d96da1830f3082608375a77e450c5c9db (diff) | |
download | ydb-5e85b96f0cd76b3abbadf46ecb14f9cbec09de4c.tar.gz |
Restoring authorship annotation for <wsnk@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | contrib/python/protobuf/py2/google/protobuf/json_format.py | 10 | ||||
-rw-r--r-- | contrib/python/protobuf/py3/google/protobuf/json_format.py | 10 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam.cpp | 48 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam.h | 10 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam_ut.cpp | 40 |
5 files changed, 59 insertions, 59 deletions
diff --git a/contrib/python/protobuf/py2/google/protobuf/json_format.py b/contrib/python/protobuf/py2/google/protobuf/json_format.py index 965614d803..2f8d763882 100644 --- a/contrib/python/protobuf/py2/google/protobuf/json_format.py +++ b/contrib/python/protobuf/py2/google/protobuf/json_format.py @@ -120,7 +120,7 @@ def MessageToJson( indent: The JSON object will be pretty-printed with this indent level. An indent level of 0 or negative will only insert newlines. sort_keys: If True, then the output will be sorted by field names. - use_integers_for_enums: If true, print integers instead of enum names. + use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. @@ -157,7 +157,7 @@ def MessageToDict( preserving_proto_field_name: If True, use the original proto field names as defined in the .proto file. If False, convert the field names to lowerCamelCase. - use_integers_for_enums: If true, print integers instead of enum names. + use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. @@ -193,7 +193,7 @@ class _Printer(object): float_precision=None): self.including_default_value_fields = including_default_value_fields self.preserving_proto_field_name = preserving_proto_field_name - self.use_integers_for_enums = use_integers_for_enums + self.use_integers_for_enums = use_integers_for_enums self.descriptor_pool = descriptor_pool if float_precision: self.float_format = '.{}g'.format(float_precision) @@ -284,8 +284,8 @@ class _Printer(object): if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE: return self._MessageToJsonObject(value) elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM: - if self.use_integers_for_enums: - return value + if self.use_integers_for_enums: + return value if field.enum_type.full_name == 'google.protobuf.NullValue': return None enum_value = field.enum_type.values_by_number.get(value, None) diff --git a/contrib/python/protobuf/py3/google/protobuf/json_format.py b/contrib/python/protobuf/py3/google/protobuf/json_format.py index 965614d803..2f8d763882 100644 --- a/contrib/python/protobuf/py3/google/protobuf/json_format.py +++ b/contrib/python/protobuf/py3/google/protobuf/json_format.py @@ -120,7 +120,7 @@ def MessageToJson( indent: The JSON object will be pretty-printed with this indent level. An indent level of 0 or negative will only insert newlines. sort_keys: If True, then the output will be sorted by field names. - use_integers_for_enums: If true, print integers instead of enum names. + use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. @@ -157,7 +157,7 @@ def MessageToDict( preserving_proto_field_name: If True, use the original proto field names as defined in the .proto file. If False, convert the field names to lowerCamelCase. - use_integers_for_enums: If true, print integers instead of enum names. + use_integers_for_enums: If true, print integers instead of enum names. descriptor_pool: A Descriptor Pool for resolving types. If None use the default. float_precision: If set, use this to specify float field valid digits. @@ -193,7 +193,7 @@ class _Printer(object): float_precision=None): self.including_default_value_fields = including_default_value_fields self.preserving_proto_field_name = preserving_proto_field_name - self.use_integers_for_enums = use_integers_for_enums + self.use_integers_for_enums = use_integers_for_enums self.descriptor_pool = descriptor_pool if float_precision: self.float_format = '.{}g'.format(float_precision) @@ -284,8 +284,8 @@ class _Printer(object): if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE: return self._MessageToJsonObject(value) elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM: - if self.use_integers_for_enums: - return value + if self.use_integers_for_enums: + return value if field.enum_type.full_name == 'google.protobuf.NullValue': return None enum_value = field.enum_type.values_by_number.get(value, None) diff --git a/library/cpp/cgiparam/cgiparam.cpp b/library/cpp/cgiparam/cgiparam.cpp index f3277b8e4b..73557812b5 100644 --- a/library/cpp/cgiparam/cgiparam.cpp +++ b/library/cpp/cgiparam/cgiparam.cpp @@ -179,31 +179,31 @@ size_t TCgiParameters::PrintSize() const noexcept { return res; } -TString TCgiParameters::QuotedPrint(const char* safe) const { - if (empty()) { - return TString(); - } - - TString res; - res.ReserveAndResize(PrintSize()); - - char* ptr = res.begin(); - for (auto i = begin();;) { - ptr = Quote(ptr, i->first, safe); - *ptr++ = '='; - ptr = Quote(ptr, i->second, safe); - - if (++i == end()) { - break; - } - - *ptr++ = '&'; - } - +TString TCgiParameters::QuotedPrint(const char* safe) const { + if (empty()) { + return TString(); + } + + TString res; + res.ReserveAndResize(PrintSize()); + + char* ptr = res.begin(); + for (auto i = begin();;) { + ptr = Quote(ptr, i->first, safe); + *ptr++ = '='; + ptr = Quote(ptr, i->second, safe); + + if (++i == end()) { + break; + } + + *ptr++ = '&'; + } + res.ReserveAndResize(ptr - res.data()); - return res; -} - + return res; +} + TCgiParameters::const_iterator TCgiParameters::Find(const TStringBuf name, size_t pos) const noexcept { const auto pair = equal_range(name); diff --git a/library/cpp/cgiparam/cgiparam.h b/library/cpp/cgiparam/cgiparam.h index 87d1ab0ad4..f60cf0ebb4 100644 --- a/library/cpp/cgiparam/cgiparam.h +++ b/library/cpp/cgiparam/cgiparam.h @@ -57,11 +57,11 @@ public: Y_PURE_FUNCTION size_t PrintSize() const noexcept; - /** The same as Print* except that RFC-3986 reserved characters are escaped. - * @param safe - set of characters to be skipped in escaping - */ - TString QuotedPrint(const char* safe = "/") const; - + /** The same as Print* except that RFC-3986 reserved characters are escaped. + * @param safe - set of characters to be skipped in escaping + */ + TString QuotedPrint(const char* safe = "/") const; + Y_PURE_FUNCTION auto Range(const TStringBuf name) const noexcept { return IterateValues(MakeIteratorRange(equal_range(name))); diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a562342084..7af4040a9e 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -215,28 +215,28 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { UNIT_ASSERT_VALUES_EQUAL(c.Print(), "a=a1&a=a2&b=b1"); } - - Y_UNIT_TEST(TestPrintAsQuote) { - TCgiParameters c = { + + Y_UNIT_TEST(TestPrintAsQuote) { + TCgiParameters c = { std::make_pair("aaa", "value/with/slashes"), - std::make_pair("b/b/b", "value_without_slashes"), + std::make_pair("b/b/b", "value_without_slashes"), std::make_pair("ccc", "value")}; - - UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=value/with/slashes&b/b/b=value_without_slashes&ccc=value"); - UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), "aaa=value%2Fwith%2Fslashes&b%2Fb%2Fb=value_without_slashes&ccc=value"); - } - - Y_UNIT_TEST(TestPrintAsQuoteEmpty) { + + UNIT_ASSERT_VALUES_EQUAL(c.Print(), "aaa=value/with/slashes&b/b/b=value_without_slashes&ccc=value"); + UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), "aaa=value%2Fwith%2Fslashes&b%2Fb%2Fb=value_without_slashes&ccc=value"); + } + + Y_UNIT_TEST(TestPrintAsQuoteEmpty) { TCgiParameters c = {}; - UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), ""); - } - - Y_UNIT_TEST(TestPrintAsQuoteEmptyKeyOrValue) { - TCgiParameters c = { - std::make_pair("", "value/of/empty"), + UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), ""); + } + + Y_UNIT_TEST(TestPrintAsQuoteEmptyKeyOrValue) { + TCgiParameters c = { + std::make_pair("", "value/of/empty"), std::make_pair("key/for/empty", "")}; - - UNIT_ASSERT_VALUES_EQUAL(c.Print(), "=value/of/empty&key/for/empty="); - UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), "=value%2Fof%2Fempty&key%2Ffor%2Fempty="); - } + + UNIT_ASSERT_VALUES_EQUAL(c.Print(), "=value/of/empty&key/for/empty="); + UNIT_ASSERT_VALUES_EQUAL(c.QuotedPrint(""), "=value%2Fof%2Fempty&key%2Ffor%2Fempty="); + } } |