Home | History | Annotate | Download | only in tools
      1 import os
      2 import sys
      3 import tempfile
      4 
      5 """Shared functions for use in i18n scripts."""
      6 
      7 def CheckDirExists(dir, dirname):
      8   if not os.path.isdir(dir):
      9     print "Couldn't find %s (%s)!" % (dirname, dir)
     10     sys.exit(1)
     11 
     12 def 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 
     20 def SwitchToNewTemporaryDirectory():
     21   tmp_dir = tempfile.mkdtemp('-i18n')
     22   os.chdir(tmp_dir)
     23   print 'Created temporary directory "%s"...' % tmp_dir
     24