Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/env python
      2 # Copyright 2014 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 """Converts a dotted-quad version string to a single numeric value suitable for
      7 an Android package's internal version number."""
      8 
      9 import sys
     10 
     11 def main():
     12   if len(sys.argv) != 2:
     13     print "Usage: %s version-string" % sys.argv[0]
     14     exit(1)
     15 
     16   version_string = sys.argv[1]
     17   version_components = version_string.split('.')
     18   if len(version_components) != 4:
     19     print "Expected 4 components."
     20     exit(1)
     21 
     22   branch = int(version_components[2])
     23   patch = int(version_components[3])
     24   print branch * 1000 + patch
     25 
     26 
     27 if __name__ == '__main__':
     28   main()
     29