1.1 --- a/XSLForms/Prepare.py Mon Oct 24 18:17:02 2005 +0000
1.2 +++ b/XSLForms/Prepare.py Mon Oct 24 21:34:09 2005 +0000
1.3 @@ -26,6 +26,14 @@
1.4
1.5 resource_dir = os.path.join(os.path.split(__file__)[0], "XSL")
1.6
1.7 +# Generic functions.
1.8 +
1.9 +def _ensure_stylesheet(template_name, output_name, fn, *args, **kw):
1.10 + if not os.path.exists(output_name) or \
1.11 + os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.12 +
1.13 + fn(template_name, output_name, *args, **kw)
1.14 +
1.15 # Web template functions.
1.16
1.17 def make_stylesheet(template_name, output_name, stylesheet_names=["PrepareMacro.xsl", "Prepare.xsl"], encoding=None):
1.18 @@ -60,10 +68,7 @@
1.19 given 'output_name'.
1.20 """
1.21
1.22 - if not os.path.exists(output_name) or \
1.23 - os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.24 -
1.25 - make_stylesheet(template_name, output_name)
1.26 + _ensure_stylesheet(template_name, output_name, make_stylesheet)
1.27
1.28 def ensure_stylesheet_fragment(template_name, output_name, element_id):
1.29
1.30 @@ -74,10 +79,7 @@
1.31 'element_id'.
1.32 """
1.33
1.34 - if not os.path.exists(output_name) or \
1.35 - os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.36 -
1.37 - make_stylesheet_fragment(template_name, output_name, element_id)
1.38 + _ensure_stylesheet(template_name, output_name, make_stylesheet_fragment, element_id)
1.39
1.40 # Document initialisation functions.
1.41
1.42 @@ -102,10 +104,7 @@
1.43 given 'input_name'.
1.44 """
1.45
1.46 - if not os.path.exists(input_name) or \
1.47 - os.path.getmtime(input_name) < os.path.getmtime(template_name):
1.48 -
1.49 - make_input_stylesheet(template_name, input_name)
1.50 + _ensure_stylesheet(template_name, input_name, make_input_stylesheet)
1.51
1.52 # Qt Designer functions.
1.53
1.54 @@ -115,9 +114,20 @@
1.55 proc.send_output(open(output_name, "wb"), encoding, template)
1.56
1.57 def ensure_qt_fragment(template_name, output_name, widget_name):
1.58 - if not os.path.exists(output_name) or \
1.59 - os.path.getmtime(output_name) < os.path.getmtime(template_name):
1.60 + _ensure_stylesheet(template_name, output_name, make_qt_fragment, widget_name)
1.61 +
1.62 +# Qt Designer Web functions.
1.63 +
1.64 +def make_qt_template(template_name, output_name, stylesheet_names=["QtDesigner.xsl"], encoding=None):
1.65 + return make_stylesheet(template_name, output_name, stylesheet_names, encoding)
1.66
1.67 - make_qt_fragment(template_name, output_name, widget_name)
1.68 +def ensure_qt_template(template_name, output_name):
1.69 + _ensure_stylesheet(template_name, output_name, make_qt_template)
1.70 +
1.71 +def make_qt_stylesheet(template_name, output_name, stylesheet_names=["QtDesigner.xsl", "PrepareMacro.xsl", "Prepare.xsl"], encoding=None):
1.72 + return make_stylesheet(template_name, output_name, stylesheet_names, encoding)
1.73 +
1.74 +def ensure_qt_stylesheet(template_name, output_name):
1.75 + _ensure_stylesheet(template_name, output_name, make_qt_stylesheet)
1.76
1.77 # vim: tabstop=4 expandtab shiftwidth=4