Skip to content

Commit 2c33197

Browse files
committed
Update 'variables' in code and template to 'vartext'
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent d0da08b commit 2c33197

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

docs/source/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ Details
139139
$ about attrib --vartext "title=Attribution Notice" --vartext "header=Product 101" LOCATION OUTPUT
140140
141141
Users can use the following in the template to get the vartext:
142-
{{ variables['title'] }}
143-
{{ variables['header'] }}
142+
{{ vartext['title'] }}
143+
{{ vartext['header'] }}
144144
145145
--verbose
146146

src/attributecode/attrib.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939

4040
DEFAULT_LICENSE_SCORE = 100
4141

42-
def generate(abouts, is_about_input, license_dict, scancode, min_license_score, template=None, variables=None):
42+
def generate(abouts, is_about_input, license_dict, scancode, min_license_score, template=None, vartext=None):
4343
"""
4444
Generate an attribution text from an `abouts` list of About objects, a
45-
`template` template text and a `variables` optional dict of extra
45+
`template` template text and a `vartext` optional dict of extra
4646
variables.
4747
4848
Return a tuple of (error, attribution text) where error is an Error object
@@ -179,7 +179,7 @@ def generate(abouts, is_about_input, license_dict, scancode, min_license_score,
179179
licenses_list=licenses_list,
180180
utcnow=utcnow,
181181
tkversion=__version__,
182-
variables=variables
182+
vartext=vartext
183183
)
184184
return error, rendered
185185

@@ -205,10 +205,10 @@ def check_template(template_string):
205205
return e.lineno, e.message
206206

207207

208-
def generate_from_file(abouts, is_about_input, license_dict, scancode, min_license_score, template_loc=None, variables=None):
208+
def generate_from_file(abouts, is_about_input, license_dict, scancode, min_license_score, template_loc=None, vartext=None):
209209
"""
210210
Generate an attribution text from an `abouts` list of About objects, a
211-
`template_loc` template file location and a `variables` optional
211+
`template_loc` template file location and a `vartext` optional
212212
dict of extra variables.
213213
214214
Return a tuple of (error, attribution text) where error is an Error object
@@ -223,13 +223,13 @@ def generate_from_file(abouts, is_about_input, license_dict, scancode, min_licen
223223
template_loc = add_unc(template_loc)
224224
with io.open(template_loc, encoding='utf-8', errors='replace') as tplf:
225225
tpls = tplf.read()
226-
return generate(abouts, is_about_input, license_dict, scancode, min_license_score, template=tpls, variables=variables)
226+
return generate(abouts, is_about_input, license_dict, scancode, min_license_score, template=tpls, vartext=vartext)
227227

228228

229-
def generate_and_save(abouts, is_about_input, license_dict, output_location, scancode=False, min_license_score=0, template_loc=None, variables=None):
229+
def generate_and_save(abouts, is_about_input, license_dict, output_location, scancode=False, min_license_score=0, template_loc=None, vartext=None):
230230
"""
231231
Generate an attribution text from an `abouts` list of About objects, a
232-
`template_loc` template file location and a `variables` optional
232+
`template_loc` template file location and a `vartext` optional
233233
dict of extra variables. Save the generated attribution text in the
234234
`output_location` file.
235235
Return a list of Error objects if any.
@@ -251,7 +251,7 @@ def generate_and_save(abouts, is_about_input, license_dict, output_location, sca
251251
scancode=scancode,
252252
min_license_score=min_license_score,
253253
template_loc=template_loc,
254-
variables=variables,
254+
vartext=vartext,
255255
)
256256

257257
if rendering_error:

src/attributecode/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def attrib(input, output, api_url, api_key, scancode, min_license_score, referen
459459
scancode=scancode,
460460
min_license_score=min_license_score,
461461
template_loc=template,
462-
variables=vartext,
462+
vartext=vartext,
463463
)
464464
errors.extend(attrib_errors)
465465

templates/default_html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<body>
1313
<h1>OPEN SOURCE SOFTWARE INFORMATION</h1>
14-
<h2> {{ variables['subtitle'] }} </h2>
14+
<h2> {{ vartext['subtitle'] }} </h2>
1515
<div>
1616
<p>Licenses, acknowledgments and required copyright notices for
1717
open source components:</p>

templates/license_ref.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
li {font-weight: bold;}
99
#header {font-family: Helvetica; font-style:italic}
1010
</style>
11-
<title>{{ variables['title'] }}</title>
11+
<title>{{ vartext['title'] }}</title>
1212
</head>
1313
<body>
14-
<h1>{{ variables['title'] }}</h1>
14+
<h1>{{ vartext['title'] }}</h1>
1515
<pre id="header">
1616

17-
This document lists the open source and third-party components of a {{ variables['company'] }} product with additional information regarding licenses, acknowledgments and required copyright notices for these components. This document is for internal {{ variables['company'] }} use only.
17+
This document lists the open source and third-party components of a {{ vartext['company'] }} product with additional information regarding licenses, acknowledgments and required copyright notices for these components. This document is for internal {{ vartext['company'] }} use only.
1818

1919
</pre>
2020

templates/scancode_html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<body>
1313
<h1>OPEN SOURCE SOFTWARE INFORMATION</h1>
14-
<h2> {{ variables['subtitle'] }} </h2>
14+
<h2> {{ vartext['subtitle'] }} </h2>
1515
<div>
1616
<p>Licenses, acknowledgments and required copyright notices for
1717
open source components:</p>

tests/testdata/test_attrib/scancode_input/scancode.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Read the JSON file to see what information can be extracted from the licenses.
1616

1717
<body>
1818
<h1>OPEN SOURCE SOFTWARE INFORMATION</h1>
19-
<h2>{{ variables['subtitle'] }}</h2>
19+
<h2>{{ vartext['subtitle'] }}</h2>
2020
<div>
2121
<p>Licenses, acknowledgments and required copyright notices for
2222
open source components:</p>

0 commit comments

Comments
 (0)