summaryrefslogtreecommitdiff
path: root/apexer/apex_manifest.py
diff options
context:
space:
mode:
Diffstat (limited to 'apexer/apex_manifest.py')
-rw-r--r--apexer/apex_manifest.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/apexer/apex_manifest.py b/apexer/apex_manifest.py
index 290924e..b2f08e5 100644
--- a/apexer/apex_manifest.py
+++ b/apexer/apex_manifest.py
@@ -14,11 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
import apex_manifest_pb2
-from google.protobuf.json_format import Parse
-from google.protobuf.json_format import ParseError
-
+from google.protobuf import message
class ApexManifestError(Exception):
@@ -27,12 +24,12 @@ class ApexManifestError(Exception):
self.errmessage = errmessage
-def ValidateApexManifest(manifest_raw):
+def ValidateApexManifest(file):
try:
- manifest_json = json.loads(manifest_raw)
- manifest_pb = Parse(
- json.dumps(manifest_json), apex_manifest_pb2.ApexManifest())
- except (ParseError, ValueError) as err:
+ with open(file, "rb") as f:
+ manifest_pb = apex_manifest_pb2.ApexManifest()
+ manifest_pb.ParseFromString(f.read())
+ except message.DecodeError as err:
raise ApexManifestError(err)
# Checking required fields
if manifest_pb.name == "":