Skip to content

Commit 076f9d7

Browse files
committed
Restore the --vartext code.
Not sure why the code was lost.
1 parent 0e2cc47 commit 076f9d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/attributecode/attrib.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
os.path.dirname(os.path.realpath(__file__)), '../../templates', 'default_html.template')
3939

4040

41-
def generate(abouts, template=None, variables=None):
41+
def generate(abouts, template=None, vartext_dict=None):
4242
"""
4343
Generate an attribution text from an `abouts` list of About objects, a
4444
`template` template text and a `variables` optional dict of extra
@@ -125,7 +125,7 @@ def generate(abouts, template=None, variables=None):
125125
license_name_to_license_key=license_name_to_license_key,
126126
utcnow=utcnow,
127127
tkversion=__version__,
128-
variables=variables
128+
vartext_dict=vartext_dict
129129
)
130130
except Exception as e:
131131
lineno = getattr(e, 'lineno', '') or ''
@@ -150,7 +150,7 @@ def check_template(template_string):
150150
return e.lineno, e.message
151151

152152

153-
def generate_from_file(abouts, template_loc=DEFAULT_TEMPLATE_FILE, variables=None):
153+
def generate_from_file(abouts, template_loc=DEFAULT_TEMPLATE_FILE, vartext_dict=None):
154154
"""
155155
Generate an attribution text from an `abouts` list of About objects, a
156156
`template_loc` template file location and a `variables` optional
@@ -163,7 +163,7 @@ def generate_from_file(abouts, template_loc=DEFAULT_TEMPLATE_FILE, variables=Non
163163
template_loc = add_unc(template_loc)
164164
with io.open(template_loc, encoding='utf-8') as tplf:
165165
tpls = tplf.read()
166-
return generate(abouts, template=tpls, variables=variables)
166+
return generate(abouts, template=tpls, vartext_dict=vartext_dict)
167167

168168

169169
def generate_and_save(abouts, output_location, template_loc=None, variables=None):
@@ -186,10 +186,16 @@ def generate_and_save(abouts, output_location, template_loc=None, variables=None
186186
str(special_char_in_expression))
187187
errors.append(Error(ERROR, msg))
188188

189+
vartext_dict = {}
190+
if variables:
191+
keys = variables.keys()
192+
for k in keys:
193+
vartext_dict[k] = (variables[k])[0]
194+
189195
rendering_error, rendered = generate_from_file(
190196
abouts,
191197
template_loc=template_loc,
192-
variables=variables
198+
vartext_dict=vartext_dict
193199
)
194200

195201
if rendering_error:

0 commit comments

Comments
 (0)