Skip to content

Commit bc91b14

Browse files
committed
Use $FORM for the default args of FormLink()
When `args` is not specified, FormLink() (so form.open()) refers to the environment variable $FORM. If unset, 'form' will be used.
1 parent e51d6b5 commit bc91b14

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

form/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def open(args=None, keep_log=False):
3131
3232
The optional argument `args` is for the FORM command, a string or
3333
a sequence of strings. For example '/path/to/form' or ['tform', '-w4'].
34-
The default value is 'form'.
34+
By default, the value of the environment variable `$FORM` is used if set,
35+
otherwise 'form' will be used.
3536
3637
The other argument `keep_log` indicates whether the log from FORM is kept
3738
and used as detailed information when an error occurs. If the value

form/formlink.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def open(self, args=None, keep_log=False):
106106
107107
The optional argument `args` is for the FORM command, a string or
108108
a sequence of strings. For example '/path/to/form' or ['tform', '-w4'].
109-
The default value is 'form'.
109+
By default, the value of the environment variable `$FORM` is used if
110+
set, otherwise 'form' will be used.
110111
111112
The other argument `keep_log` indicates whether the log from FORM is
112113
kept and used as detailed information when an error occurs.
@@ -120,7 +121,10 @@ def open(self, args=None, keep_log=False):
120121
FORM.
121122
"""
122123
if args is None:
123-
args = 'form'
124+
if 'FORM' in os.environ:
125+
args = os.environ['FORM']
126+
else:
127+
args = 'form'
124128

125129
if isinstance(args, string_types):
126130
args = shlex.split(args) # Split the arguments.

0 commit comments

Comments
 (0)