/usr/bin/ufl2py is in python-ufl 2017.2.0.0-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #!/usr/bin/python
from __future__ import with_statement
import os, sys, optparse
from ufl.algorithms import validate_form, ufl2latex, tree_format
from ufl.algorithms.formfiles import read_ufl_file
# Get commandline options
usage = """Convert a .ufl file to an executable .py file for debugging.
Example:
ufl2py Poisson.ufl"""
def opt(long, short, t, default, help):
return optparse.make_option("--%s" % long, "-%s" % short, action="store", type=t, dest=long, default=default, help=help)
option_list = []
# opt("quiet", "q", "int", 1, "Do not print form information to screen."),
# opt("write", "w", "int", 0, "Write form information to file."),
# ]
parser = optparse.OptionParser(usage=usage, option_list=option_list)
args = sys.argv[1:]
(options, args) = parser.parse_args(args=args)
if not args:
print("Missing files!")
print()
parser.print_usage()
sys.exit(-1)
filenames = args
header = """#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ufl import *
set_level(DEBUG)
"""
footer = ""
# Handle each form file separately
for filename in filenames:
if not filename.endswith(".ufl"):
print("Warning: Filename '%s' doesn't end with .ufl." % filename)
# Read code
fcode = read_ufl_file(filename)
code = header + fcode + footer
# Dump code to python file
basename = os.path.splitext(os.path.basename(filename))[0]
basename = "%s_debug" % basename
pyname = "%s.py" % basename
with file(pyname, "w") as f:
f.write(code)
|