• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os
2import sys
3import tempfile
4
5"""Shared functions for use in i18n scripts."""
6
7def CheckDirExists(dir, dirname):
8  if not os.path.isdir(dir):
9    print "Couldn't find %s (%s)!" % (dirname, dir)
10    sys.exit(1)
11
12def GetAndroidRootOrDie():
13  value = os.environ.get('ANDROID_BUILD_TOP')
14  if not value:
15    print "ANDROID_BUILD_TOP not defined: run envsetup.sh / lunch"
16    sys.exit(1);
17  CheckDirExists(value, '$ANDROID_BUILD_TOP')
18  return value
19
20def SwitchToNewTemporaryDirectory():
21  tmp_dir = tempfile.mkdtemp('-i18n')
22  os.chdir(tmp_dir)
23  print 'Created temporary directory "%s"...' % tmp_dir
24