summaryrefslogtreecommitdiff
path: root/apexer/apex_manifest.py
diff options
context:
space:
mode:
authorAbhijeet Kaur <abkaur@google.com>2018-12-31 15:34:37 +0000
committerAbhijeet Kaur <abkaur@google.com>2018-12-31 16:04:26 +0000
commite4db3d618b598e010ecd00548273cc04b3275616 (patch)
tree2562c374313274a66c99aceb818bad70be8458bc /apexer/apex_manifest.py
parentadbee5d0c204cfcf9ddfcc7ace3dddf0225f576e (diff)
Move field names to camelCase for consistency with protobuf.
Protobuf saves the field names in camelCase. To avoid converting to and from camelCase, using consistent field names for apex manifest schema. Bug: 121546801 Test: mmma system/apex out/host/linux-x86/testcases/apex_file_test/x86/apex_file_test out/host/linux-x86/testcases/apex_manifest_test/x86/apex_manifest_test Change-Id: Iffaa099d5bff100e09c41eab3d3e9af15dfbad53
Diffstat (limited to 'apexer/apex_manifest.py')
-rw-r--r--apexer/apex_manifest.py17
1 files changed, 3 insertions, 14 deletions
diff --git a/apexer/apex_manifest.py b/apexer/apex_manifest.py
index 8c7eca4..8bd8d75 100644
--- a/apexer/apex_manifest.py
+++ b/apexer/apex_manifest.py
@@ -23,12 +23,12 @@ class ApexManifest:
# Default values
package_name = ""
version_number = 0
- pre_install_hook = ""
+ preInstallHook = ""
def __init__(self, manifest_json):
self.package_name = manifest_json["name"]
self.version_number = manifest_json["version"]
- if('pre_install_hook' in manifest_json):
- self.pre_install_hook = manifest_json["pre_install_hook"]
+ if('preInstallHook' in manifest_json):
+ self.preInstallHook = manifest_json["preInstallHook"]
class ApexManifestError(Exception):
def __init__(self, errmessage):
@@ -38,13 +38,6 @@ class ApexManifestError(Exception):
def ValidateApexManifest(manifest_raw):
try:
manifest_json = json.loads(manifest_raw)
- # TODO: The version of protobuf library present in the Android tree at the time of writing
- # doesn't support the json_name field name. Proto converts underscore field names to
- # camelCase. To use protobuf with "pre_install_hook" field name, converting to camelCase
- # explicitly. b/121546801
- # Convert field names to camelCase
- for field, value in manifest_json.items():
- manifest_json[to_camel_case(field)] = manifest_json.pop(field)
manifest_pb = Parse(json.dumps(manifest_json), manifest_schema_pb2.ManifestSchema())
except (ParseError, ValueError) as err:
raise ApexManifestError(err)
@@ -54,7 +47,3 @@ def ValidateApexManifest(manifest_raw):
if manifest_pb.version == 0:
raise ApexManifestError("'version' field is required.")
return ApexManifest(manifest_json)
-
-def to_camel_case(snake_str):
- components = snake_str.split('_')
- return components[0] + ''.join(x.title() for x in components[1:]) \ No newline at end of file