Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: recipe_engine/package.py

Issue 2771723006: [recipes.cfg] ONLY support jsonpb. (Closed)
Patch Set: remove comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/fetch.py ('k') | recipe_engine/unittests/fetch_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/package.py
diff --git a/recipe_engine/package.py b/recipe_engine/package.py
index bd47ce474c232284d62a44ae625106e5b36ae1e5..bd0ebf1ea48842beaa5bc6257c35721ac116ab03 100644
--- a/recipe_engine/package.py
+++ b/recipe_engine/package.py
@@ -13,7 +13,6 @@ import sys
from . import env
-from google.protobuf import text_format
from google.protobuf import json_format
from . import package_pb2
from . import fetch
@@ -64,12 +63,6 @@ class ProtoFile(object):
"""
def __init__(self, path):
self._path = path
- # TODO(iannucci): remove text proto support
- self._is_json = False
- try:
- self._is_json = self.read_raw().lstrip().startswith('{')
- except IOError:
- pass
@property
def path(self):
@@ -82,19 +75,12 @@ class ProtoFile(object):
def read(self):
text = self.read_raw()
buf = package_pb2.Package()
- if text.lstrip().startswith('{'):
- self._is_json = True
- json_format.Parse(text, buf, ignore_unknown_fields=True)
- else:
- text_format.Merge(text, buf)
+ json_format.Parse(text, buf, ignore_unknown_fields=True)
return buf
def to_raw(self, buf):
- if self._is_json:
- obj = json_format.MessageToDict(buf, preserving_proto_field_name=True)
- return json.dumps(obj, indent=2, sort_keys=True).replace(' \n', '\n')
- else:
- return text_format.MessageToString(buf)
+ obj = json_format.MessageToDict(buf, preserving_proto_field_name=True)
+ return json.dumps(obj, indent=2, sort_keys=True).replace(' \n', '\n')
def write(self, buf):
with open(self._path, 'w') as fh:
« no previous file with comments | « recipe_engine/fetch.py ('k') | recipe_engine/unittests/fetch_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698