diff options
Diffstat (limited to 'apexer/apex_manifest.py')
-rw-r--r-- | apexer/apex_manifest.py | 17 |
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 |