aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarshall Greenblatt <magreenblatt@gmail.com>2017-05-28 15:15:50 +0200
committerMarshall Greenblatt <magreenblatt@gmail.com>2017-05-28 15:15:50 +0200
commita542ad4df81d651a7a3680fa7034588e53c20f01 (patch)
treeac83e37ba43aa53662673ac709f39e28f6f0f586 /tools
parent1d95dd69b9936175ff01e5e4bfff5efc93639ee1 (diff)
downloadjcef-a542ad4df81d651a7a3680fa7034588e53c20f01.tar.gz
Apply yapf formatting to all Python files (issue #272)
Diffstat (limited to 'tools')
-rw-r--r--tools/date_util.py10
-rw-r--r--tools/exec_util.py18
-rw-r--r--tools/file_util.py256
-rw-r--r--tools/git_util.py13
-rw-r--r--tools/make_readme.py38
-rw-r--r--tools/make_version_header.py177
-rw-r--r--tools/readme_util.py37
7 files changed, 305 insertions, 244 deletions
diff --git a/tools/date_util.py b/tools/date_util.py
index ca447f3..2cde329 100644
--- a/tools/date_util.py
+++ b/tools/date_util.py
@@ -4,10 +4,12 @@
import datetime
+
def get_year():
- """ Returns the current year. """
- return str(datetime.datetime.now().year)
+ """ Returns the current year. """
+ return str(datetime.datetime.now().year)
+
def get_date():
- """ Returns the current date. """
- return datetime.datetime.now().strftime('%B %d, %Y')
+ """ Returns the current date. """
+ return datetime.datetime.now().strftime('%B %d, %Y')
diff --git a/tools/exec_util.py b/tools/exec_util.py
index 7bc4d79..ceabc5b 100644
--- a/tools/exec_util.py
+++ b/tools/exec_util.py
@@ -5,6 +5,7 @@
from subprocess import Popen, PIPE
import sys
+
def exec_cmd(cmd, path, input_string=None):
""" Execute the specified command and return the result. """
out = ''
@@ -12,12 +13,21 @@ def exec_cmd(cmd, path, input_string=None):
parts = cmd.split()
try:
if input_string is None:
- process = Popen(parts, cwd=path, stdout=PIPE, stderr=PIPE,
- shell=(sys.platform == 'win32'))
+ process = Popen(
+ parts,
+ cwd=path,
+ stdout=PIPE,
+ stderr=PIPE,
+ shell=(sys.platform == 'win32'))
out, err = process.communicate()
else:
- process = Popen(parts, cwd=path, stdin=PIPE, stdout=PIPE, stderr=PIPE,
- shell=(sys.platform == 'win32'))
+ process = Popen(
+ parts,
+ cwd=path,
+ stdin=PIPE,
+ stdout=PIPE,
+ stderr=PIPE,
+ shell=(sys.platform == 'win32'))
out, err = process.communicate(input=input_string)
except IOError, (errno, strerror):
raise
diff --git a/tools/file_util.py b/tools/file_util.py
index a5fb765..12e12db 100644
--- a/tools/file_util.py
+++ b/tools/file_util.py
@@ -8,134 +8,152 @@ import shutil
import sys
import time
-def read_file(name, normalize = True):
- """ Read a file. """
- try:
- f = open(name, 'r')
- # read the data
- data = f.read()
- if normalize:
- # normalize line endings
- data = data.replace("\r\n", "\n")
- return data
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to read file '+name+': '+strerror)
- raise
- else:
- f.close()
-
+
+def read_file(name, normalize=True):
+ """ Read a file. """
+ try:
+ f = open(name, 'r')
+ # read the data
+ data = f.read()
+ if normalize:
+ # normalize line endings
+ data = data.replace("\r\n", "\n")
+ return data
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to read file ' + name + ': ' + strerror)
+ raise
+ else:
+ f.close()
+
+
def write_file(name, data):
- """ Write a file. """
- try:
- f = open(name, 'w')
- # write the data
- f.write(data)
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to write file '+name+': '+strerror)
- raise
- else:
- f.close()
-
+ """ Write a file. """
+ try:
+ f = open(name, 'w')
+ # write the data
+ f.write(data)
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to write file ' + name + ': ' + strerror)
+ raise
+ else:
+ f.close()
+
+
def path_exists(name):
- """ Returns true if the path currently exists. """
- return os.path.exists(name)
+ """ Returns true if the path currently exists. """
+ return os.path.exists(name)
+
def backup_file(name):
- """ Rename the file to a name that includes the current time stamp. """
- move_file(name, name+'.'+time.strftime('%Y-%m-%d-%H-%M-%S'))
-
-def copy_file(src, dst, quiet = True):
- """ Copy a file. """
- try:
- shutil.copy(src, dst)
- if not quiet:
- sys.stdout.write('Transferring '+src+' file.\n')
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to copy file from '+src+' to '+dst+': '+strerror)
- raise
-
-def move_file(src, dst, quiet = True):
- """ Move a file. """
- try:
- shutil.move(src, dst)
- if not quiet:
- sys.stdout.write('Moving '+src+' file.\n')
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to move file from '+src+' to '+dst+': '+strerror)
- raise
-
-def copy_files(src_glob, dst_folder, quiet = True):
- """ Copy multiple files. """
- for fname in iglob(src_glob):
- dst = os.path.join(dst_folder, os.path.basename(fname))
- if os.path.isdir(fname):
- copy_dir(fname, dst, quiet)
- else:
- copy_file(fname, dst, quiet)
-
-def remove_file(name, quiet = True):
- """ Remove the specified file. """
- try:
- if path_exists(name):
- os.remove(name)
- if not quiet:
- sys.stdout.write('Removing '+name+' file.\n')
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to remove file '+name+': '+strerror)
- raise
-
-def copy_dir(src, dst, quiet = True):
- """ Copy a directory tree. """
- try:
- remove_dir(dst, quiet)
- shutil.copytree(src, dst)
- if not quiet:
- sys.stdout.write('Transferring '+src+' directory.\n')
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to copy directory from '+src+' to '+dst+': '+strerror)
- raise
-
-def remove_dir(name, quiet = True):
- """ Remove the specified directory. """
- try:
- if path_exists(name):
- shutil.rmtree(name)
- if not quiet:
- sys.stdout.write('Removing '+name+' directory.\n')
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to remove directory '+name+': '+strerror)
- raise
-
-def make_dir(name, quiet = True):
- """ Create the specified directory. """
- try:
- if not path_exists(name):
- if not quiet:
- sys.stdout.write('Creating '+name+' directory.\n')
- os.makedirs(name)
- except IOError, (errno, strerror):
- sys.stderr.write('Failed to create directory '+name+': '+strerror)
- raise
+ """ Rename the file to a name that includes the current time stamp. """
+ move_file(name, name + '.' + time.strftime('%Y-%m-%d-%H-%M-%S'))
+
+
+def copy_file(src, dst, quiet=True):
+ """ Copy a file. """
+ try:
+ shutil.copy(src, dst)
+ if not quiet:
+ sys.stdout.write('Transferring ' + src + ' file.\n')
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to copy file from ' + src + ' to ' + dst + ': ' +
+ strerror)
+ raise
+
+
+def move_file(src, dst, quiet=True):
+ """ Move a file. """
+ try:
+ shutil.move(src, dst)
+ if not quiet:
+ sys.stdout.write('Moving ' + src + ' file.\n')
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to move file from ' + src + ' to ' + dst + ': ' +
+ strerror)
+ raise
+
+
+def copy_files(src_glob, dst_folder, quiet=True):
+ """ Copy multiple files. """
+ for fname in iglob(src_glob):
+ dst = os.path.join(dst_folder, os.path.basename(fname))
+ if os.path.isdir(fname):
+ copy_dir(fname, dst, quiet)
+ else:
+ copy_file(fname, dst, quiet)
+
+
+def remove_file(name, quiet=True):
+ """ Remove the specified file. """
+ try:
+ if path_exists(name):
+ os.remove(name)
+ if not quiet:
+ sys.stdout.write('Removing ' + name + ' file.\n')
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to remove file ' + name + ': ' + strerror)
+ raise
+
+
+def copy_dir(src, dst, quiet=True):
+ """ Copy a directory tree. """
+ try:
+ remove_dir(dst, quiet)
+ shutil.copytree(src, dst)
+ if not quiet:
+ sys.stdout.write('Transferring ' + src + ' directory.\n')
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to copy directory from ' + src + ' to ' + dst +
+ ': ' + strerror)
+ raise
+
+
+def remove_dir(name, quiet=True):
+ """ Remove the specified directory. """
+ try:
+ if path_exists(name):
+ shutil.rmtree(name)
+ if not quiet:
+ sys.stdout.write('Removing ' + name + ' directory.\n')
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to remove directory ' + name + ': ' + strerror)
+ raise
+
+
+def make_dir(name, quiet=True):
+ """ Create the specified directory. """
+ try:
+ if not path_exists(name):
+ if not quiet:
+ sys.stdout.write('Creating ' + name + ' directory.\n')
+ os.makedirs(name)
+ except IOError, (errno, strerror):
+ sys.stderr.write('Failed to create directory ' + name + ': ' + strerror)
+ raise
+
def get_files(search_glob):
- """ Returns all files matching the search glob. """
- # Sort the result for consistency across platforms.
- return sorted(iglob(search_glob))
+ """ Returns all files matching the search glob. """
+ # Sort the result for consistency across platforms.
+ return sorted(iglob(search_glob))
+
def read_version_file(file, args):
- """ Read and parse a version file (key=value pairs, one per line). """
- lines = read_file(file).split("\n")
- for line in lines:
- parts = line.split('=', 1)
- if len(parts) == 2:
- args[parts[0]] = parts[1]
+ """ Read and parse a version file (key=value pairs, one per line). """
+ lines = read_file(file).split("\n")
+ for line in lines:
+ parts = line.split('=', 1)
+ if len(parts) == 2:
+ args[parts[0]] = parts[1]
+
def eval_file(src):
- """ Loads and evaluates the contents of the specified file. """
- return eval(read_file(src), {'__builtins__': None}, None)
+ """ Loads and evaluates the contents of the specified file. """
+ return eval(read_file(src), {'__builtins__': None}, None)
+
def normalize_path(path):
- """ Normalizes the path separator to match the Unix standard. """
- if sys.platform == 'win32':
- return path.replace('\\', '/')
- return path
+ """ Normalizes the path separator to match the Unix standard. """
+ if sys.platform == 'win32':
+ return path.replace('\\', '/')
+ return path
diff --git a/tools/git_util.py b/tools/git_util.py
index 177ab41..f0313e3 100644
--- a/tools/git_util.py
+++ b/tools/git_util.py
@@ -9,11 +9,13 @@ import sys
# Git must be in the system PATH.
git_exe = 'git'
+
def is_checkout(path):
""" Returns true if the path represents a git checkout. """
return os.path.isdir(os.path.join(path, '.git'))
-def get_hash(path = '.', branch = 'HEAD'):
+
+def get_hash(path='.', branch='HEAD'):
""" Returns the git hash for the specified branch/tag/hash. """
cmd = "%s rev-parse %s" % (git_exe, branch)
result = exec_cmd(cmd, path)
@@ -21,7 +23,8 @@ def get_hash(path = '.', branch = 'HEAD'):
return result['out'].strip()
return 'Unknown'
-def get_url(path = '.'):
+
+def get_url(path='.'):
""" Returns the origin url for the specified path. """
cmd = "%s config --get remote.origin.url" % git_exe
result = exec_cmd(cmd, path)
@@ -29,7 +32,8 @@ def get_url(path = '.'):
return result['out'].strip()
return 'Unknown'
-def get_commit_number(path = '.', branch = 'HEAD'):
+
+def get_commit_number(path='.', branch='HEAD'):
""" Returns the number of commits in the specified branch/tag/hash. """
cmd = "%s rev-list --count %s" % (git_exe, branch)
result = exec_cmd(cmd, path)
@@ -37,6 +41,7 @@ def get_commit_number(path = '.', branch = 'HEAD'):
return result['out'].strip()
return '0'
+
def get_changed_files(path, hash):
""" Retrieves the list of changed files. """
if hash == 'unstaged':
@@ -54,6 +59,7 @@ def get_changed_files(path, hash):
return files.strip().split("\n")
return []
+
def write_indented_output(output):
""" Apply a fixed amount of intent to lines before printing. """
if output == '':
@@ -64,6 +70,7 @@ def write_indented_output(output):
continue
sys.stdout.write('\t%s\n' % line)
+
def git_apply_patch_file(patch_path, patch_dir):
""" Apply |patch_path| to files in |patch_dir|. """
patch_name = os.path.basename(patch_path)
diff --git a/tools/make_readme.py b/tools/make_readme.py
index 8a87b0f..8f59e89 100644
--- a/tools/make_readme.py
+++ b/tools/make_readme.py
@@ -14,6 +14,7 @@ import git_util as git
import sys
import zipfile
+
def get_readme_component(name):
""" Loads a README file component. """
paths = []
@@ -25,12 +26,13 @@ def get_readme_component(name):
# load the file if it exists
for path in paths:
- file = os.path.join(path, 'README.' +name + '.txt')
+ file = os.path.join(path, 'README.' + name + '.txt')
if path_exists(file):
return read_file(file)
raise Exception('Readme component not found: ' + name)
+
def create_readme():
""" Creates the README.TXT file. """
# gather the components
@@ -67,6 +69,7 @@ def create_readme():
if not options.quiet:
sys.stdout.write('Creating README.TXT file.\n')
+
# cannot be loaded as a module
if __name__ != "__main__":
sys.stderr.write('This file cannot be loaded as a module!')
@@ -78,13 +81,22 @@ This utility builds the JCEF README.txt for the distribution.
"""
parser = OptionParser(description=disc)
-parser.add_option('--output-dir', dest='outputdir', metavar='DIR',
- help='output directory [required]')
-parser.add_option('--platform', dest='platform',
- help='target platform for distribution [required]')
-parser.add_option('-q', '--quiet',
- action='store_true', dest='quiet', default=False,
- help='do not output detailed status information')
+parser.add_option(
+ '--output-dir',
+ dest='outputdir',
+ metavar='DIR',
+ help='output directory [required]')
+parser.add_option(
+ '--platform',
+ dest='platform',
+ help='target platform for distribution [required]')
+parser.add_option(
+ '-q',
+ '--quiet',
+ action='store_true',
+ dest='quiet',
+ default=False,
+ help='do not output detailed status information')
(options, args) = parser.parse_args()
# the outputdir option is required
@@ -94,11 +106,10 @@ if options.outputdir is None or options.platform is None:
output_dir = options.outputdir
# Test the operating system.
-platform = options.platform;
+platform = options.platform
if (platform != 'linux32' and platform != 'linux64' and
- platform != 'macosx64' and
- platform != 'win32' and platform != 'win64'):
- print 'Unsupported target \"'+platform+'\"'
+ platform != 'macosx64' and platform != 'win32' and platform != 'win64'):
+ print 'Unsupported target \"' + platform + '\"'
sys.exit(1)
# script directory
@@ -118,7 +129,8 @@ if not git.is_checkout(jcef_dir):
jcef_commit_number = git.get_commit_number(jcef_dir)
jcef_commit_hash = git.get_hash(jcef_dir)
jcef_url = git.get_url(jcef_dir)
-jcef_ver = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['CEF_BUILD'], jcef_commit_number, jcef_commit_hash[:7])
+jcef_ver = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['CEF_BUILD'],
+ jcef_commit_number, jcef_commit_hash[:7])
date = get_date()
diff --git a/tools/make_version_header.py b/tools/make_version_header.py
index 5085336..ada2c6d 100644
--- a/tools/make_version_header.py
+++ b/tools/make_version_header.py
@@ -12,8 +12,8 @@ import sys
# cannot be loaded as a module
if __name__ != "__main__":
- sys.stderr.write('This file cannot be loaded as a module!')
- sys.exit(1)
+ sys.stderr.write('This file cannot be loaded as a module!')
+ sys.exit(1)
# script directory
script_dir = os.path.dirname(__file__)
@@ -21,103 +21,114 @@ script_dir = os.path.dirname(__file__)
# JCEF root directory
jcef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
-
# parse command-line options
disc = """
This utility creates the version header file.
"""
parser = OptionParser(description=disc)
-parser.add_option('--header', dest='header', metavar='FILE',
- help='output version header file [required]')
-parser.add_option('--cef-path', dest='cefpath',
- help='path to the CEF binary distribution [required]')
-parser.add_option('-q', '--quiet',
- action='store_true', dest='quiet', default=False,
- help='do not output detailed status information')
+parser.add_option(
+ '--header',
+ dest='header',
+ metavar='FILE',
+ help='output version header file [required]')
+parser.add_option(
+ '--cef-path',
+ dest='cefpath',
+ help='path to the CEF binary distribution [required]')
+parser.add_option(
+ '-q',
+ '--quiet',
+ action='store_true',
+ dest='quiet',
+ default=False,
+ help='do not output detailed status information')
(options, args) = parser.parse_args()
# the header option is required
if options.header is None or options.cefpath is None:
- parser.print_help(sys.stdout)
- sys.exit(1)
+ parser.print_help(sys.stdout)
+ sys.exit(1)
+
def write_svn_header(header):
- """ Creates the header file for the current revision
+ """ Creates the header file for the current revision
if the information has changed or if the file doesn't already exist. """
- if path_exists(header):
- oldcontents = read_file(header)
- else:
- oldcontents = ''
-
- if not git.is_checkout(jcef_dir):
- raise Exception('Not a valid checkout')
-
- commit_number = git.get_commit_number(jcef_dir)
- commit_hash = git.get_hash(jcef_dir)
-
- year = get_year()
-
- # Read and parse the CEF version file.
- args = {}
- read_readme_file(os.path.join(options.cefpath, 'README.txt'), args)
-
- version = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['CEF_BUILD'], commit_number, commit_hash[:7])
-
- newcontents = '// Copyright (c) '+year+' The Chromium Embedded Framework Authors. All rights\n'+\
- '// reserved. Use of this source code is governed by a BSD-style license that\n'+\
- '// can be found in the LICENSE file.\n'+\
- '//\n'+\
- '// Redistribution and use in source and binary forms, with or without\n'+\
- '// modification, are permitted provided that the following conditions are\n'+\
- '// met:\n'+\
- '//\n'+\
- '// * Redistributions of source code must retain the above copyright\n'+\
- '// notice, this list of conditions and the following disclaimer.\n'+\
- '// * Redistributions in binary form must reproduce the above\n'+\
- '// copyright notice, this list of conditions and the following disclaimer\n'+\
- '// in the documentation and/or other materials provided with the\n'+\
- '// distribution.\n'+\
- '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\
- '// Framework nor the names of its contributors may be used to endorse\n'+\
- '// or promote products derived from this software without specific prior\n'+\
- '// written permission.\n'+\
- '//\n'+\
- '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\
- '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\
- '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\
- '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\
- '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\
- '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\
- '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\
- '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\
- '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\
- '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\
- '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\
- '//\n'+\
- '// ---------------------------------------------------------------------------\n'+\
- '//\n'+\
- '// This file is generated by the make_version_header.py tool.\n'+\
- '//\n\n'+\
- '#ifndef JCEF_INCLUDE_JCEF_VERSION_H_\n'+\
- '#define JCEF_INCLUDE_JCEF_VERSION_H_\n\n'+\
- '#define JCEF_VERSION "' + version + '"\n'+\
- '#define JCEF_COMMIT_NUMBER ' + commit_number + '\n'+\
- '#define JCEF_COMMIT_HASH "' + commit_hash + '"\n'+\
- '#define JCEF_COPYRIGHT_YEAR ' + year + '\n\n'+\
- '#define DO_MAKE_STRING(p) #p\n'+\
- '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\
- '#endif // JCEF_INCLUDE_JCEF_VERSION_H_\n'
- if newcontents != oldcontents:
- write_file(header, newcontents)
- return True
-
- return False
+ if path_exists(header):
+ oldcontents = read_file(header)
+ else:
+ oldcontents = ''
+
+ if not git.is_checkout(jcef_dir):
+ raise Exception('Not a valid checkout')
+
+ commit_number = git.get_commit_number(jcef_dir)
+ commit_hash = git.get_hash(jcef_dir)
+
+ year = get_year()
+
+ # Read and parse the CEF version file.
+ args = {}
+ read_readme_file(os.path.join(options.cefpath, 'README.txt'), args)
+
+ version = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['CEF_BUILD'],
+ commit_number, commit_hash[:7])
+
+ newcontents = '// Copyright (c) '+year+' The Chromium Embedded Framework Authors. All rights\n'+\
+ '// reserved. Use of this source code is governed by a BSD-style license that\n'+\
+ '// can be found in the LICENSE file.\n'+\
+ '//\n'+\
+ '// Redistribution and use in source and binary forms, with or without\n'+\
+ '// modification, are permitted provided that the following conditions are\n'+\
+ '// met:\n'+\
+ '//\n'+\
+ '// * Redistributions of source code must retain the above copyright\n'+\
+ '// notice, this list of conditions and the following disclaimer.\n'+\
+ '// * Redistributions in binary form must reproduce the above\n'+\
+ '// copyright notice, this list of conditions and the following disclaimer\n'+\
+ '// in the documentation and/or other materials provided with the\n'+\
+ '// distribution.\n'+\
+ '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\
+ '// Framework nor the names of its contributors may be used to endorse\n'+\
+ '// or promote products derived from this software without specific prior\n'+\
+ '// written permission.\n'+\
+ '//\n'+\
+ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\
+ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\
+ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\
+ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\
+ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\
+ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\
+ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\
+ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\
+ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\
+ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\
+ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\
+ '//\n'+\
+ '// ---------------------------------------------------------------------------\n'+\
+ '//\n'+\
+ '// This file is generated by the make_version_header.py tool.\n'+\
+ '//\n\n'+\
+ '#ifndef JCEF_INCLUDE_JCEF_VERSION_H_\n'+\
+ '#define JCEF_INCLUDE_JCEF_VERSION_H_\n\n'+\
+ '#define JCEF_VERSION "' + version + '"\n'+\
+ '#define JCEF_COMMIT_NUMBER ' + commit_number + '\n'+\
+ '#define JCEF_COMMIT_HASH "' + commit_hash + '"\n'+\
+ '#define JCEF_COPYRIGHT_YEAR ' + year + '\n\n'+\
+ '#define DO_MAKE_STRING(p) #p\n'+\
+ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\
+ '#endif // JCEF_INCLUDE_JCEF_VERSION_H_\n'
+ if newcontents != oldcontents:
+ write_file(header, newcontents)
+ return True
+
+ return False
+
written = write_svn_header(options.header)
if not options.quiet:
if written:
- sys.stdout.write('File '+options.header+' updated.\n')
+ sys.stdout.write('File ' + options.header + ' updated.\n')
else:
- sys.stdout.write('File '+options.header+' is already up to date.\n')
+ sys.stdout.write('File ' + options.header + ' is already up to date.\n')
diff --git a/tools/readme_util.py b/tools/readme_util.py
index 1bedff4..eb84769 100644
--- a/tools/readme_util.py
+++ b/tools/readme_util.py
@@ -1,21 +1,22 @@
from file_util import read_file
+
def read_readme_file(file, args):
- """ Read a README.txt and try to parse its containing version numbers """
- lines = read_file(file).split("\n")
- for line in lines:
- parts = line.split(':', 1)
- if len(parts) != 2:
- continue
- if parts[0].startswith('CEF Version'):
- args['CEF_VER'] = parts[1].strip()
- verparts = args['CEF_VER'].split('.')
- if len(verparts) >= 2:
- args['CEF_MAJOR'] = verparts[0]
- args['CEF_BUILD'] = verparts[1]
- elif parts[0].startswith('CEF URL'):
- args['CEF_URL'] = parts[1].strip()
- elif parts[0].startswith('Chromium Verison'):
- args['CHROMIUM_VER'] = parts[1].strip()
- elif parts[0].startswith('Chromium URL'):
- args['CHROMIUM_URL'] = parts[1].strip()
+ """ Read a README.txt and try to parse its containing version numbers """
+ lines = read_file(file).split("\n")
+ for line in lines:
+ parts = line.split(':', 1)
+ if len(parts) != 2:
+ continue
+ if parts[0].startswith('CEF Version'):
+ args['CEF_VER'] = parts[1].strip()
+ verparts = args['CEF_VER'].split('.')
+ if len(verparts) >= 2:
+ args['CEF_MAJOR'] = verparts[0]
+ args['CEF_BUILD'] = verparts[1]
+ elif parts[0].startswith('CEF URL'):
+ args['CEF_URL'] = parts[1].strip()
+ elif parts[0].startswith('Chromium Verison'):
+ args['CHROMIUM_VER'] = parts[1].strip()
+ elif parts[0].startswith('Chromium URL'):
+ args['CHROMIUM_URL'] = parts[1].strip()