From cdd872f9481a8e71a95bd60be72100d8eb124b55 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <legac@cppm.in2p3.fr> Date: Fri, 17 Apr 2015 17:27:57 +0200 Subject: [PATCH] Remove obsolete function in builVersion.py. --- buildVersion.py | 239 +++++++++++++++--------------------------------- 1 file changed, 76 insertions(+), 163 deletions(-) diff --git a/buildVersion.py b/buildVersion.py index ce4f12c8..76654852 100755 --- a/buildVersion.py +++ b/buildVersion.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" +""" NAME buildVersion -- helper script to build and tag a plugin_dbui version @@ -9,16 +9,16 @@ DESCRIPTION Helper script to build a version of the plugin_dbui. - - The version identifier should contains alphanumeric characters + + The version identifier should contains alphanumeric characters including ".", "-" and "_". - + Push version identifier in the javascript library. Push version number in the CHANGELOG. Build debug and minified version of the javascript library. Commit the new version in git and tag it Build the web2py plugin file - + EXAMPLES > buildVersion -h @@ -27,7 +27,7 @@ R. Le Gac, renaud.legac@free.fr Copyright (c) 2012 R. Le Gac - + """ import datetime @@ -51,85 +51,53 @@ JSDOC = 'static/plugin_dbui/docs/jsduck' JSLIBDEBUG = 'static/plugin_dbui/dbui-debug.js' JSLIBMIN = 'static/plugin_dbui/dbui-min.js' JSLIBSRC = 'static/plugin_dbui/src' -PYDOC = 'static/plugin_dbui/docs/epydoc' +SPHINXDOC = 'static/docs/sphinx' +SPHINXSRC = 'docs/api/' NOW = datetime.datetime.now() PACK_PLUGIN_URL = 'http://localhost:8000/%s/default/pack_plugin' % APP # basic commands -EPYDOC = '/usr/bin/epydoc' GIT = '/usr/bin/git' JSDUCK = os.path.expandvars("$HOME/bin/jsduck") SENCHA = os.path.expandvars("$HOME/bin/sencha") -YUICOMPRESSOR = os.path.expandvars("$HOME/lib/yuicompressor-2.4.8.jar") - -MSG_VERSION = 'Enter the new version: ' - - -def epydoc(): - """Generate the epydoc documentation - The HTML files are located in static/plugin_dbui/docs/epydoc - - """ - if not os.path.exists(GIT): - print '\n\tThe application epydoc is missing !' - print '\tSkip this step.\n' - return - - # create the directory - if not os.path.exists(PYDOC): - os.makedirs(PYDOC) - - # clean the directory - cmd = ["rm", "-rf", PYDOC] - subprocess.call(cmd) +SPHINX = '/usr/bin/sphinx-build' - # run epydoc - cmd = ["epydoc", "--docformat", "epytext", - "--html", - "--name", "plugin_dbui", - "-o", PYDOC, - "--parse-only", - "-v", - "modules/plugin_dbui/*.py"] - - subprocess.call(cmd) - - print "HTML documentation in", PYDOC +MSG_VERSION = 'Enter the new release: ' def compile(): """compile the javascript code and generate the debug version as well as the minified version of the dbui library. - + The compiler verify that the code complied with the class model and order the file in the proper way. - + The minified library can be build in several ways, including the Ext JS class required by the applications. In the current version, the library contains only the dbui classes and the Ext JS ones have to be loaded separately. In that sense this command is very similar to the yuicompressor one. - + Several compressor can be used yui, closure compiler, .... In the current version, the default yui compressor is used? - + This operation relies on the Sencha Cmd: http://www.sencha.com/products/sencha-cmd/download - + The details documantation can be found: http://docs.sencha.com/extjs/4.2.2/#!/guide/command - + """ if not os.path.exists(SENCHA): print '\n\tThe application sencha is missing !' print '\tSee: http://www.sencha.com/products/sencha-cmd/download' print '\tSkip this step.\n' return - + # clean previous version for el in (JSLIBDEBUG, JSLIBMIN): - if os.path.exists(el): + if os.path.exists(el): os.remove(el) print 'Remove javascript library', el @@ -137,9 +105,9 @@ def compile(): print '\nDebug version of the javascript library', JSLIBDEBUG cwd = os.getcwd() - + cmd = ["sencha", "-sdk", os.path.join(cwd, EXTJSSRC), - "compile", "-class", os.path.join(cwd, JSLIBSRC), + "compile", "-class", os.path.join(cwd, JSLIBSRC), "exclude", "--namespace", "Ext", "and", "concat", os.path.join(cwd, JSLIBDEBUG)] @@ -149,16 +117,16 @@ def compile(): print '\nMinified version of the javascript library', JSLIBMIN cmd = ["sencha", "-sdk", os.path.join(cwd, EXTJSSRC), - "compile", "-class", os.path.join(cwd, JSLIBSRC), + "compile", "-class", os.path.join(cwd, JSLIBSRC), "exclude", "--namespace", "Ext", "and", "concat", "--yui", os.path.join(cwd, JSLIBMIN)] - + subprocess.call(cmd) - + def get_version(): """Get the current version identifier. - + """ s = open(JSBASE, 'rb').read() m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) @@ -167,15 +135,15 @@ def get_version(): def git(): """Commit and tag the current release. - + """ if not os.path.exists(GIT): print '\n\tThe application git is missing !' print '\tSkip this step.\n' return - + version = get_version() - + # check tag in git fi = tempfile.TemporaryFile() subprocess.call(["git", "tag"], stdout=fi) @@ -183,19 +151,19 @@ def git(): if version in fi.read(): print "\n\ttag %s already exit in git" % version sys.exit(1) - + # release message m = "Release version %s" % version - + # Commit the new release in git an tag it print 'git add', JSBASE, CHANGELOG cmd = ["git", "add", JSBASE, CHANGELOG] subprocess.call(cmd) - + print 'git commit' cmd = ["git", "commit", "-m", m] subprocess.call(cmd) - + # annotated tag print 'git tag', version cmd = ["git", "tag", "-a", version, "-m", m] @@ -205,13 +173,13 @@ def git(): def jsduck(): """Generate the JavaScript documentation. The HTML files are located in static/plugin_dbui/docs/jsduck - + """ if not os.path.exists(JSDUCK): print '\n\tThe application jsduck is missing !' print '\tSkip this step.\n' return - + # create the directory if not os.path.exists(JSDOC): os.makedirs(JSDOC) @@ -224,8 +192,8 @@ def jsduck(): cmd = ["jsduck", EXTJSSRC, JSLIBSRC, \ "--output", JSDOC, \ "--title", "plugin_dbui %s" % get_version(), \ - "--warnings=-all:"+EXTJSSRC] - + "--warnings=-all:" + EXTJSSRC] + subprocess.call(cmd) print "JavaScript documentation in", JSDOC @@ -233,41 +201,41 @@ def jsduck(): def set_version(version): """Set version identifier in CHANGELOG and appbase.js - + """ print 'Set version in', JSBASE s = open(JSBASE, 'rb').read() - + # look for a pattern App.version = '0.8.3'; in appbase.js # split the the string in 3 parts (pre, version, post) m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) - + if m.group(2) == version: print '\n\tVersion "%s" already exists in the appbase.js file !' % version rep = raw_input('\tDo you want to continue [n]?') if rep not in ('y', 'yes'): sys.exit(1) - # update the version and write a new file + # update the version and write a new file s = m.group(1) + version + m.group(3) fi = open(JSBASE, 'wb') fi.write(s) fi.close() - + # look for a pattern HEAD in the CHANGELOG # split the the string in 2 parts (pre HEAD, post HEAD) print 'Set version in', CHANGELOG s = open(CHANGELOG, 'rb').read() - + m = re.match("(.+HEAD\n)(.*)", s, re.DOTALL) - + if m == None: print '\n\tNo HEAD tag in the CHANGELOG!\n' rep = raw_input('\tDo you want to continue [n]?') if rep not in ('y', 'yes'): sys.exit(1) - # update the version and edit the CHANGELOG + # update the version and edit the CHANGELOG s = '%s\n%s (%s)\n%s' % (m.group(1), version, NOW.strftime('%b %Y'), m.group(2)) fi = open(CHANGELOG, 'wb') fi.write(s) @@ -282,157 +250,103 @@ def set_version(version): def web2py(): """Produce the binary file for the web2py plugin. - + """ print '\nBuild the web2py plugin binary file' rep = raw_input('Check that the web2py service is running ? Type CR to continue.') if rep: print '\n\tSkip this step.\n' return - + f = urllib.urlopen(PACK_PLUGIN_URL) s = f.read() - + fn = DBUI_W2P % get_version().replace('.', '') fi = open(fn, 'wb') fi.write(s) fi.close() - + # move the file to the build directory fn_build = os.path.join(BUILDDIR, fn) if os.path.exists(fn_build): os.remove(fn_build) - - os.rename(fn, fn_build) - - print 'Binary file', fn, 'is created in ', BUILDDIR - - -def yuicompressor(): - """Compresssed and minified the javascript library. - - """ - if not os.path.exists(YUICOMPRESSOR): - print '\n\tThe application yuicompressor is missing !' - print '\tSkip this step.\n' - return - - # clean previous version - for el in (JSLIBDEBUG, JSLIBMIN): - if os.path.exists(el): - os.remove(el) - print 'Remove javascript library', el - # debug version of the javascript library - print 'Debug version of the javascript library', JSLIBDEBUG - - subprocess.call("find %s -iname '*.js' | sort > JsFiles.txt" % JSLIBSRC, shell=True) - jsfiles = ' '.join(open("JsFiles.txt").readlines()).replace('\n', '') - subprocess.call("cat %s > %s" % (jsfiles, JSLIBDEBUG), shell=True) - os.remove("JsFiles.txt") + os.rename(fn, fn_build) - # Minified version of the javascript library - print 'Minified version of the javascript library', JSLIBMIN - cmd = ["java", "-jar", YUICOMPRESSOR, "-o", JSLIBMIN, JSLIBDEBUG] - subprocess.call(cmd) + print 'Binary file', fn, 'is created in ', BUILDDIR if __name__ == '__main__': - - # check that basic commands are there - for cmd in (GIT, YUICOMPRESSOR): - if not os.path.exists(cmd): - print '\n\t%s application is missing !' % cmd - sys.exit(1) - - # define script options + + # define script options ops = optparse.OptionParser() ops.add_option("-a", "--all", action="store_true", - dest= "all", - help= "run all steps.") - + dest="all", + help="run all steps.") + ops.add_option("-c", "--compile", action="store_true", dest="compile", help="compile the javascript library using sencha command.") - - ops.add_option("-e", "--epydoc", - action="store_true", - dest= "epydoc", - help= "generate the epydoc documentation.") - + ops.add_option("-g", "--git", action="store_true", - dest= "git", - help= "commit and tag the current release.") + dest="git", + help="commit and tag the current release.") ops.add_option("-j", "--jsduck", action="store_true", - dest= "jsduck", - help= "generate the JavaScript documentation.") + dest="jsduck", + help="generate the JavaScript documentation.") ops.add_option("-r", "--release", action="store_true", - dest= "get", - help= "get the version of the current release and exit.") - + dest="get", + help="get the version of the current release and exit.") + ops.add_option("-s", "--set_version", action="store_true", - dest= "set", - help= "set the version.") - - ops.add_option("-y", "--yuicompressor", - action="store_true", - dest= "yuicompressor", - help= "compressed and minified the javascript libraries.") - + dest="set", + help="set the version.") + ops.add_option("-w", "--web2py", action="store_true", - dest= "web2py", - help= "pack the web2py plugin.") - + dest="web2py", + help="pack the web2py plugin.") + ops.set_defaults(all=False, compile=False, - epydoc=False, get=False, git=False, jsduck=False, set=False, - yuicompressor=False, web2py=False) - + (opt, args) = ops.parse_args() print '\nStart buildVersion' - + # standalone action if opt.get: version = get_version() print "\nThe version of the current release is %s\n" % version - + if opt.set: version = (args[0] if args else raw_input(MSG_VERSION)) set_version(version) - - if opt.git: + + if opt.git: git() - - if opt.epydoc: - epydoc() if opt.jsduck: jsduck() - + if opt.compile: compile() - if opt.yuicompressor: - yuicompressor() - if opt.web2py: - epydoc() jsduck() compile() web2py() @@ -447,10 +361,9 @@ if __name__ == '__main__': set_version(version) git() - epydoc() jsduck() compile() - web2py() + web2py() print 'Exit buidVersion\n' - sys.exit(0) \ No newline at end of file + sys.exit(0) -- GitLab