Add ICU message format support
[chromium-blink-merge.git] / build / android / pylib / sdk / aapt.py
blob3d317ff2c59a85e1182a805a718917103fffce0d
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """This module wraps the Android Asset Packaging Tool."""
7 import os
9 from pylib import cmd_helper
10 from pylib import constants
11 from pylib.utils import timeout_retry
13 _AAPT_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'aapt')
15 def _RunAaptCmd(args):
16 """Runs an aapt command.
18 Args:
19 args: A list of arguments for aapt.
21 Returns:
22 The output of the command.
23 """
24 cmd = [_AAPT_PATH] + args
25 status, output = cmd_helper.GetCmdStatusAndOutput(cmd)
26 if status != 0:
27 raise Exception('Failed running aapt command: "%s" with output "%s".' %
28 (' '.join(cmd), output))
29 return output
31 def Dump(what, apk, assets=None):
32 """Returns the output of the aapt dump command.
34 Args:
35 what: What you want to dump.
36 apk: Path to apk you want to dump information for.
37 assets: List of assets in apk you want to dump information for.
38 """
39 assets = assets or []
40 if isinstance(assets, basestring):
41 assets = [assets]
42 return _RunAaptCmd(['dump', what, apk] + assets).splitlines()