summaryrefslogtreecommitdiff
path: root/apexer/apex_manifest.py
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-06-03 21:36:53 +0900
committerJiyong Park <jiyong@google.com>2019-06-03 21:52:47 +0900
commit34c821c86d0b054f687cd6eaf86eeeaf7e80beb1 (patch)
treef24d5d4fa0f6246d9daf2ab56e774389552e2a20 /apexer/apex_manifest.py
parent361fed27e39378072baf6afcffeb6d0cb4f3fbe2 (diff)
Run pyformat on apexer
Test: presubmit tests Change-Id: Ifa233810fb0b78933c69a19c30f17379853c3de6
Diffstat (limited to 'apexer/apex_manifest.py')
-rw-r--r--apexer/apex_manifest.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/apexer/apex_manifest.py b/apexer/apex_manifest.py
index 216dcd0..290924e 100644
--- a/apexer/apex_manifest.py
+++ b/apexer/apex_manifest.py
@@ -19,22 +19,29 @@ import apex_manifest_pb2
from google.protobuf.json_format import Parse
from google.protobuf.json_format import ParseError
+
class ApexManifestError(Exception):
- def __init__(self, errmessage):
- # Apex Manifest parse error (extra fields) or if required fields not present
- self.errmessage = errmessage
+
+ def __init__(self, errmessage):
+ # Apex Manifest parse error (extra fields) or if required fields not present
+ self.errmessage = errmessage
+
def ValidateApexManifest(manifest_raw):
- try:
- manifest_json = json.loads(manifest_raw)
- manifest_pb = Parse(json.dumps(manifest_json), apex_manifest_pb2.ApexManifest())
- except (ParseError, ValueError) as err:
- raise ApexManifestError(err)
- # Checking required fields
- if manifest_pb.name == "":
- raise ApexManifestError("'name' field is required.")
- if manifest_pb.version == 0:
- raise ApexManifestError("'version' field is required.")
- if manifest_pb.noCode and (manifest_pb.preInstallHook or manifest_pb.postInstallHook):
- raise ApexManifestError("'noCode' can't be true when either preInstallHook or postInstallHook is set")
- return manifest_pb
+ try:
+ manifest_json = json.loads(manifest_raw)
+ manifest_pb = Parse(
+ json.dumps(manifest_json), apex_manifest_pb2.ApexManifest())
+ except (ParseError, ValueError) as err:
+ raise ApexManifestError(err)
+ # Checking required fields
+ if manifest_pb.name == "":
+ raise ApexManifestError("'name' field is required.")
+ if manifest_pb.version == 0:
+ raise ApexManifestError("'version' field is required.")
+ if manifest_pb.noCode and (manifest_pb.preInstallHook or
+ manifest_pb.postInstallHook):
+ raise ApexManifestError(
+ "'noCode' can't be true when either preInstallHook or postInstallHook is set"
+ )
+ return manifest_pb