Commit b15e6cc0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '33-python37' into 'master'

Resolve "migrate to python 3.7"

Closes #33

See merge request !45
parents 862aec78 68697732
# -*- coding: utf-8 -*-
"""
Configure the build process for the plugin dbui
"""
import datetime
import os
import re
import tempfile
from subprocess import call, check_output
from IPython.utils.io import stderr
NOW = datetime.datetime.now()
# ............................................................................
#
# JAVASCRIPT LIBRARY
# JavaScript source code and compile version
# paths are relative to the static directory
#
SENCHA_CLS = [
"plugin_extjs/packages/core/src",
"plugin_extjs/classic/classic/src",
"plugin_extjs/classic/classic/overrides",
"plugin_dbui/src"]
SENCHA_NS = "Ext"
JSLIBDEBUG = "plugin_dbui/dbui-debug.js"
JSLIBMIN = "plugin_dbui/dbui-min.js"
# ...........................................................................
#
# DOCUMENTATION
# output directories for documentation
# paths are relative to the static directory
#
DOCS_DIR = "plugin_dbui/docs"
JSDOC = "plugin_dbui/docs/jsduck"
LATEXDOC = "plugin_dbui/docs/latex"
PDFDOC = "plugin_dbui/docs/pdf"
# ...........................................................................
#
# PLUGINS
# ace, dbui, extjs and mathjax
# paths are relative to the application directory
#
PLUGINS_FILES = {}
PLUGINS_FILES["default"] = [
"controllers/plugin_%s.py",
"models/plugin_%s.py",
"modules/plugin_%s",
"private/plugin_%s",
"static/plugin_%s",
"views/plugin_%s"]
PLUGINS_FILES["ace"] = [
"static/plugin_ace/src-noconflict/",
"static/plugin_ace/src-min-noconflict/ace.js",
"static/plugin_ace/src-min-noconflict/mode-javascript.js",
"static/plugin_ace/src-min-noconflict/mode-json.js",
"static/plugin_ace/src-min-noconflict/mode-markdown.js",
"static/plugin_ace/src-min-noconflict/mode-python.js",
"static/plugin_ace/src-min-noconflict/mode-text.js",
"static/plugin_ace/src-min-noconflict/theme-crimson_editor.js",
"static/plugin_ace/src-min-noconflict/worker-javascript.js",
"static/plugin_ace/src-min-noconflict/worker-json.js",
"static/plugin_ace/src-min-noconflict/snippets/javascript.js",
"static/plugin_ace/src-min-noconflict/snippets/json.js",
"static/plugin_ace/src-min-noconflict/snippets/markdown.js",
"static/plugin_ace/src-min-noconflict/snippets/python.js",
"static/plugin_ace/src-min-noconflict/snippets/text.js"]
PLUGINS_FILES["dbui"] = [
"modules/plugin_dbui",
"controllers/plugin_dbui.py",
"static/plugin_dbui",
"views/plugin_dbui"]
PLUGINS_FILES["extjs"] = [
"static/plugin_extjs/build/classic/locale",
"static/plugin_extjs/build/classic/theme-classic",
"static/plugin_extjs/build/ext-all.js",
"static/plugin_extjs/build/ext-all-debug.js",
"static/plugin_extjs/classic/classic/src",
"static/plugin_extjs/classic/classic/overrides",
"static/plugin_extjs/packages/core/src",
"static/plugin_extjs/version.properties"]
PLUGINS_FILES["mathjax"] = [
"static/plugin_mathjax/fonts/HTML-CSS/TeX/woff",
"static/plugin_mathjax/jax",
"static/plugin_mathjax/extensions",
"static/plugin_mathjax/MathJax.js"]
# ............................................................................
#
# REFERENCE FILES
#
CHANGELOG = "static/plugin_dbui/CHANGELOG"
DBUIJS = "static/plugin_dbui/src/Dbui.js"
VERSION = "VERSION"
def commit_release():
"""Commit release CHANGELOG, VERSION and DBUIJS files
"""
print "\n", "."*79
print "\n\tCommit CHANGELOG, DBUIJS, VERSION, ..."
# move to the master branch
with tempfile.TemporaryFile() as fi:
print "\tMove to the master branch"
call(["git", "checkout", "master"], stdout=fi, stderr=fi)
# Commit modified files
print "\n\tgit add", DBUIJS, CHANGELOG, VERSION
call(["git", "add", DBUIJS, CHANGELOG, VERSION])
msg = "Start release candidate %s" % get_version()
print "\tgit commit:", msg
call(["git", "commit", "-m", msg])
def get_plugin_version(plugin):
"""
Args:
plugin (str): name of the plugin
Return:
str: the plugin version
"""
if plugin == "ace":
cwd = os.getcwd()
os.chdir("static/plugin_ace")
with tempfile.TemporaryFile() as tmpfile:
call(["git", "describe", "--tags"], stdout=tmpfile)
tmpfile.seek(0)
release = tmpfile.read()
release = release.replace("v", "").replace("\n", "")
os.chdir(cwd)
elif plugin == "dbui":
with open(VERSION, "rb") as tmpfile:
release = tmpfile.read()
elif plugin == "extjs":
fn = os.path.join("static", "plugin_extjs", "version.properties")
if not os.path.exists(fn):
error("\n\tNo version file for the plugin extjs !")
sys.exit(1)
with open(fn, "rb") as fi:
s = fi.read()
match = re.search(r"version.release=(\d+(\.\d+)*)", s)
if not match:
error("\n\tExt JS release number not defined !")
sys.exit(1)
release = match.group(1)
# shrink the release identifier 4.2.1 or 4.2.1.883 -> 421
li = release.split(".")
release = "".join(li) if len(li) < 4 else "".join(li[:-1])
elif plugin == "mathjax":
filename = os.path.join("static", "plugin_mathjax", "MathJax.js")
with open(filename, "rb") as tmpfile:
text = tmpfile.read()
match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL)
if not match:
error("\n\tMathJax release number not defined !")
sys.exit(1)
release = match.group(1)
else:
error("\n\tUnknown plugin %" % plugin)
sys.exit(1)
release = release.replace(".", "")
if len(release) == 2:
release = "%s0" % release
return release
def get_version():
"""Get the current release identifier in VERSION.
Returns:
str: the version number
"""
with open(VERSION, "rb") as fi:
return fi.read()
def set_version(version):
"""Set release identifier in CHANGELOG, VERSION and Dbui.js
Args:
version (str): release identifier
"""
print "\n", "."*79
print "\tUpdate CHANGELOG and Dbui.js files with release", version, "..."
# check tag in git
if version in check_output(["git", "tag"]).split("\n"):
print "\n\tRelease %s already exit in git" % version
sys.exit(1)
print "\tSet release", version, "in", DBUIJS
with open(DBUIJS) as fi:
txt = fi.read()
# look for a pattern Dbui.version = "0.8.3"; in appbase.js
# split the the string in 3 parts (pre, version, post)
match = re.match(r'(.+ version: ")([\w._-]*)(".+)', txt, re.DOTALL)
if match.group(2) == version:
msg = "\n\tVersion '%s' already exists in the Dbui.js file !"
print msg % 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
txt = match.group(1) + version + match.group(3)
with open(DBUIJS, "w") as fi:
fi.write(txt)
# look for a pattern HEAD in the CHANGELOG
# split the the string in 2 parts (pre HEAD, post HEAD)
print "\tSet release", version, "in", CHANGELOG
with open(CHANGELOG) as fi:
txt = fi.read()
match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL)
if match is 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
tpl = (match.group(1), version, NOW.strftime("%b %Y"), match.group(2))
txt = "%s\n%s (%s)\n%s" % tpl
with open(CHANGELOG, "w") as fi:
fi.write(txt)
call(["vim", CHANGELOG])
# update VERSION
print "\tSet release", version, "in", VERSION
with open(VERSION, "w") as fi:
fi.write(version)
# cleaning
fn = "%s~" % CHANGELOG
if os.path.exists(fn):
os.remove(fn)
......@@ -105,13 +105,13 @@ def dbui_conf():
# build the dictionary required by Ext.direct
# containing the definition of the remote procedure
for (k, f) in directSvc.procedures.iteritems():
for k, f in directSvc.procedures.items():
action, method = k.split(".")
if action == DBUI:
nargs = f.func_code.co_argcount
nargs = f.__code__.co_argcount
else:
nargs = f.__func__.func_code.co_argcount - 1
nargs = f.__func__.__code__.co_argcount - 1
if action not in di:
di[action] = []
......@@ -424,41 +424,36 @@ def latex2pdf():
# create the latex file in the private directory
cwd = os.getcwd()
os.chdir(os.path.join(request.folder, "private"))
os.chdir("/tmp")
fn = str(uuid4())
fi = open("%s.tex" % fn, "wb")
fi = open("%s.tex" % fn, "w")
fi.write(latex_string)
fi.close()
# convert the latex file into pdf
# convert the latex file into PDF
# run latex twice for longtable, ...
cmd = ["pdflatex", "-interaction", "nonstopmode", "%s.tex" % fn]
call(cmd, stdout=TemporaryFile())
call(cmd, stdout=TemporaryFile())
# clean latex processing
for ext in ("aux", "log", "tex"):
for ext in ("aux", "log", "out", "tex"):
f = "%s.%s" % (fn, ext)
if os.path.exists(f):
os.remove(f)
# dummy pdf if latex processing failed
# inform user when latex processing failed
pdf = "%s.pdf" % fn
if not os.path.exists(pdf):
return "Empty PDF file since LaTeX processing failed."
# copy the pdf file into a string an clean
fi = open(pdf, "rb")
pdf_string = fi.read()
fi.close()
os.remove(pdf)
# go back to the web2py main directory
os.chdir(cwd)
return dict(data=pdf_string)
# download the PDF file
path_pdf = os.path.join("/tmp", pdf)
return response.stream(path_pdf)
def status():
......
plugin_dbui.validator.IS_IN_USET
================================
.. currentmodule:: plugin_dbui.validator
.. autoclass:: IS_IN_USET
:show-inheritance:
.. rubric:: Methods
# -*- coding: utf-8 -*-
#
# plugin_dbui documentation build configuration file, created by
# sphinx-quickstart on Sat Apr 11 11:17:03 2015.
......@@ -16,28 +15,26 @@ import re
import sys
from datetime import datetime
from pathlib import Path
def get_plugin_dbui_release():
JSBASE = "../../static/plugin_dbui/src/Dbui.js"
s = open(JSBASE, "rb").read()
m = re.match('(.+ version: ")([\w._-]*)(".+)', s, re.DOTALL)
return m.group(2)
def get_version():
return Path("../../../VERSION").read_text()
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../../modules"))
sys.path.insert(0, os.path.abspath("../../../modules"))
# docker image
# web2py module from the my docker image running sphinx-build
if os.path.exists("/opt/web2py"):
sys.path.insert(0, os.path.abspath("/opt/web2py"))
# older running environment
else:
sys.path.insert(0, os.path.abspath("../../../web2py"))
print("error: missing source code for web2py!!!")
sys.exit(1)
# -- General configuration -----------------------------------------------------
......@@ -55,10 +52,10 @@ extensions = ["sphinx.ext.autodoc",
"sphinx.ext.viewcode"]
# autosummary configuration
autosummary_generate = False
autosummary_generate = True
# intersphinx configuration
intersphinx_mapping = {"python": ("http://docs.python.org/2.7", None)}
intersphinx_mapping = {"python": ("http://docs.python.org/3.7", None)}
# napoleon configuration
napoleon_user_rtype = False
......@@ -77,15 +74,15 @@ master_doc = "index"
# General information about the project.
now = datetime.now()
project = u"plugin_dbui"
copyright = u"2009-%s, R. Le Gac, licensed under CeCILL" % now.year
project = "plugin_dbui"
copyright = "2009-%s, R. Le Gac, licensed under CeCILL" % now.year
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The full version, including alpha/beta/rc tags.
release = get_plugin_dbui_release()
release = get_version()
# The short X.Y version.
version = release[:release.rfind(".")]
......@@ -221,8 +218,8 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
("index", "plugin_dbui.tex", u"plugin\\_dbui Documentation",
u"R. Le Gac", "manual"),
("index", "plugin_dbui_api.tex", r"plugin\_dbui API Guide",
"R. Le Gac", "manual"),
]
# The name of an image file (relative to this directory) to place at the top of
......@@ -251,8 +248,8 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
("index", "plugin_dbui", u"plugin_dbui Documentation",
[u"R. Le Gac"], 1)
("index", "plugin_dbui_api", "plugin_dbui Documentation",
["R. Le Gac"], 1)
]
# If true, show URL addresses after external links.
......@@ -265,8 +262,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
("index", "plugin_dbui", u"plugin_dbui Documentation",
u"R. Le Gac", "plugin_dbui", "One line description of project.",
("index", "plugin_dbui_api", "plugin_dbui Documentation",
"R. Le Gac", "plugin_dbui", "One line description of project.",
"Miscellaneous"),
]
......
......@@ -32,13 +32,3 @@ Filters
CLEAN_COMMA
CLEAN_SPACES
Validators
^^^^^^^^^^
.. currentmodule:: plugin_dbui.validator
.. autosummary::
:toctree: generated/
IS_IN_USET
......@@ -2,13 +2,13 @@
Links to the Ext JS classes
.. _ExtJS: http://docs-origin.sencha.com/extjs/4.2.1/#!/api
.. _ExtJS: https://docs.sencha.com/extjs/6.2.0/classic
.. _Ext.data.ArrayStore:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.ArrayStore
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.ArrayStore.html
.. _Ext.form.field.Checkbox:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Checkbox
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Checkbox.html
.. _Dbui.form.field.CombBox:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.CombBox
......@@ -17,16 +17,16 @@
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.data.DirectStore
.. _Ext.form.field.Field:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Field
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Field.html
.. _Dbui.form.field.AceEditor:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.AceEditor
.. _Ext.form.FieldContainer:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.FieldContainer
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.FieldContainer.html
.. _Ext.form.field.Date:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Date.html
.. _Dbui.form.field.Dict:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.Dict
......@@ -35,28 +35,28 @@
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.List
.. _Ext.form.field.Number:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Number
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Number.html
.. _Ext.form.FieldSet:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.FieldSet
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.FieldSet.html
.. _Ext.form.field.Text:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Text
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Text.html
.. _Ext.form.field.TextArea:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.TextArea
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.TextArea.html
.. _Ext.form.field.Time:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Time
https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Time.html
.. _Dbui.form.Panel:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.Panel
.. _Ext.grid.Column:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.Column
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.Column.html
.. _Ext.grid.ColumnModel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.ColumnModel
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.ColumnModel.html
.. _Dbui.grid.Filter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.grid.Filter
......@@ -65,43 +65,43 @@
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.grid.Panel
.. _Ext.grid.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.Panel
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.Panel.html
.. _Ext.grid.column.RowNumberer:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.column.RowNumberer
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.column.RowNumberer
.. _Ext.grid.TemplateColumn:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.TemplateColumn
https://docs.sencha.com/extjs/6.2.0/classic/Ext.grid.TemplateColumn
.. _Dbui.panel.GridWithFilter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.panel.GridWithFilter
.. _Ext.data.JsonStore:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.JsonStore
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.JsonStore.html
.. _Ext.data.Model:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.Model
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.Model.html
.. _Ext.toolbar.Paging:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.toolbar.Paging
https://docs.sencha.com/extjs/6.2.0/classic/Ext.toolbar.Paging
.. _Ext.panel.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.panel.Panel
https://docs.sencha.com/extjs/6.2.0/classic/Ext.panel.Panel.html
.. _Dbui.panel.WithUrlSelector:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.panel.WithUrlSelector
.. _Ext.data.Store:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.Store.html
.. _Ext.tab.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.tab.Panel
https://docs.sencha.com/extjs/6.2.0/classic/Ext.tab.Panel.html
.. _Dbui.container.Viewport:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.container.Viewport
.. _Ext.Window:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.Window
https://docs.sencha.com/extjs/6.2.0/classic/Ext.Window.html
.. _Ext.data.XmlStore:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.XmlStore
https://docs.sencha.com/extjs/6.2.0/classic/Ext.data.XmlStore.html