Skip to content

Commit 23420c9

Browse files
committed
Revert to use orderdict for about_resource and about_resource_path
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 0369bc2 commit 23420c9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/attributecode/gen.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,22 @@ def generate(location, base_dir, license_notice_text_location=None,
234234

235235
try:
236236
# Generate value for 'about_resource' if it does not exist
237+
# Note: The `about_resource` and `about_resource_path` have
238+
# OrderDict as the value type from PathField
237239
if not about.about_resource.value:
240+
about.about_resource.value = OrderedDict()
238241
if about.about_file_path.endswith('/'):
239-
about.about_resource.value.append(u'.')
242+
about.about_resource.value[u'.'] = None
240243
about.about_resource.original_value = u'.'
241244
else:
242-
about.about_resource.value.append(posixpath.basename(about.about_file_path))
245+
about.about_resource.value[posixpath.basename(about.about_file_path)] = None
243246
about.about_resource.original_value = posixpath.basename(about.about_file_path)
244247
about.about_resource.present = True
245248

246249
# Generate value for 'about_resource_path' if it does not exist
247250
# Basically, this should be the same as the 'about_resource'
248251
if not about.about_resource_path.value:
252+
about.about_resource_path.value = OrderedDict()
249253
about.about_resource_path.value = about.about_resource.value
250254
about.about_resource_path.present = True
251255

tests/test_gen.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,20 @@ def test_generation_with_no_about_resource(self):
111111
location = get_test_loc('gen/inv2.csv')
112112
base_dir = get_temp_dir()
113113
errors, abouts = gen.generate(location, base_dir)
114-
expected = [u'.']
115-
assert abouts[0].about_resource.value == expected
114+
expected_dict = OrderedDict()
115+
expected_dict[u'.'] = None
116+
assert abouts[0].about_resource.value == expected_dict
116117
assert len(errors) == 0
117118

118119
def test_generation_with_no_about_resource_reference(self):
119120
location = get_test_loc('gen/inv3.csv')
120121
base_dir = get_temp_dir()
121122

122123
errors, abouts = gen.generate(location, base_dir)
123-
expected = [u'test.tar.gz']
124+
expected_dict = OrderedDict()
125+
expected_dict[u'test.tar.gz'] = None
124126

125-
assert abouts[0].about_resource.value == expected
127+
assert abouts[0].about_resource.value == expected_dict
126128
assert len(errors) == 1
127129
msg = u'The reference file'
128130
assert msg in errors[0].message

0 commit comments

Comments
 (0)