1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/db/sqlite3/src/sqlite-version.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +import sys 1.9 +import re 1.10 + 1.11 +# Define RegEx for finding and breaking apart SQLITE_VERSION string 1.12 +versionString = "^#define SQLITE_VERSION\D*(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?\D*" 1.13 + 1.14 +#Use command line argument pointing to sqlite3.h to open the file and use 1.15 +#the RegEx to search for the line #define SQLITE_VERSION. When the RegEx 1.16 +#matches and the line is found, print the version strings to the console 1.17 +#with #definey goodness. 1.18 +for line in open(sys.argv[1]): 1.19 + result = re.search(versionString, line) 1.20 + if result is not None: #If RegEx matches, print version numbers and stop 1.21 + splitVersion = list(result.groups()) 1.22 + if splitVersion[3] is None: #Make 4th list element 0 if undefined 1.23 + splitVersion[3:] = ['0'] 1.24 + print "#define SQLITE_VERSION_MAJOR " + splitVersion[0] 1.25 + print "#define SQLITE_VERSION_MINOR " + splitVersion[1] 1.26 + print "#define SQLITE_VERSION_PATCH " + splitVersion[2] 1.27 + print "#define SQLITE_VERSION_SUBPATCH " + splitVersion[3] 1.28 + break