
"""Embeds Chrome user data files in C++ code."""

import optparse
import os
import sys

import chrome_paths
import cpp_source

sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
import lastchange


def main():
  parser = optparse.OptionParser()
  parser.add_option('', '--version-file')
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h  file should be created')
  options, args = parser.parse_args()

  version = open(options.version_file, 'r').read().strip()
  revision = lastchange.FetchVersionInfo(None).revision.strip()
  global_string_map = {
      'kChromeDriverVersion': version + '.' + revision
  }
  cpp_source.WriteSource('version',
                         'chrome/test/chromedriver',
                         options.directory, global_string_map)


if __name__ == '__main__':
  sys.exit(main())



"""Embeds Chrome user data files in C++ code."""

import optparse
import os
import sys

import chrome_paths
import cpp_source

sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
import lastchange


def main():
  parser = optparse.OptionParser()
  parser.add_option('', '--version-file')
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h  file should be created')
  options, args = parser.parse_args()

  version = open(options.version_file, 'r').read().strip()
  revision = lastchange.FetchVersionInfo(None).revision
  if revision:
    version += '.' + revision.strip()

  global_string_map = {
      'kChromeDriverVersion': version
  }
  cpp_source.WriteSource('version',
                         'chrome/test/chromedriver',
                         options.directory, global_string_map)


if __name__ == '__main__':
  sys.exit(main())


Add revision info only if available.
[chromedriver] Add revision info only if available.

This may not be available if building on a branch.
BUG=305371
NOTRY=true

Review URL: https://codereview.chromium.org/26754002

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@227842 0039d316-1c4b-4281-b951-d872f2087c98

  
  """Embeds Chrome user data files in C++ code."""
  
  import optparse
  import os
  import sys
  
  import chrome_paths
  import cpp_source
  
  sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
  import lastchange
  
  
  def main():
    parser = optparse.OptionParser()
    parser.add_option('', '--version-file')
    parser.add_option(
        '', '--directory', type='string', default='.',
        help='Path to directory where the cc/h  file should be created')
    options, args = parser.parse_args()
  
    version = open(options.version_file, 'r').read().strip()
-   revision = lastchange.FetchVersionInfo(None).revision.strip()
+   revision = lastchange.FetchVersionInfo(None).revision
+   if revision:
+     version += '.' + revision.strip()
+ 
    global_string_map = {
-       'kChromeDriverVersion': version + '.' + revision
+       'kChromeDriverVersion': version
    }
    cpp_source.WriteSource('version',
                           'chrome/test/chromedriver',
                           options.directory, global_string_map)
  
  
  if __name__ == '__main__':
    sys.exit(main())
  
  
Add revision info only if available.
## Code Before:

"""Embeds Chrome user data files in C++ code."""

import optparse
import os
import sys

import chrome_paths
import cpp_source

sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
import lastchange


def main():
  parser = optparse.OptionParser()
  parser.add_option('', '--version-file')
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h  file should be created')
  options, args = parser.parse_args()

  version = open(options.version_file, 'r').read().strip()
  revision = lastchange.FetchVersionInfo(None).revision.strip()
  global_string_map = {
      'kChromeDriverVersion': version + '.' + revision
  }
  cpp_source.WriteSource('version',
                         'chrome/test/chromedriver',
                         options.directory, global_string_map)


if __name__ == '__main__':
  sys.exit(main())


## Instruction:
Add revision info only if available.
## Code After:

"""Embeds Chrome user data files in C++ code."""

import optparse
import os
import sys

import chrome_paths
import cpp_source

sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
import lastchange


def main():
  parser = optparse.OptionParser()
  parser.add_option('', '--version-file')
  parser.add_option(
      '', '--directory', type='string', default='.',
      help='Path to directory where the cc/h  file should be created')
  options, args = parser.parse_args()

  version = open(options.version_file, 'r').read().strip()
  revision = lastchange.FetchVersionInfo(None).revision
  if revision:
    version += '.' + revision.strip()

  global_string_map = {
      'kChromeDriverVersion': version
  }
  cpp_source.WriteSource('version',
                         'chrome/test/chromedriver',
                         options.directory, global_string_map)


if __name__ == '__main__':
  sys.exit(main())

