Skip to content

Commit a011df6

Browse files
committed
Broken down the
return [{k.lower(): v for k, v in r.iteritems()} for r in csvfile] to work with Python 26
1 parent 4e306d9 commit a011df6

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

about_code_tool/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
inventory.
1010
"""
1111

12-
from __future__ import print_function, with_statement
12+
from __future__ import print_function, with_statement # We require Python 2.6 or later
1313

1414
__version__ = '0.9.0'
1515

about_code_tool/genabout.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
The input file should be a csv format which contains information about the
77
file location, origin and license of the software components etc.
88
"""
9-
from __future__ import print_function, with_statement
9+
from __future__ import print_function, with_statement # We require Python 2.6 or later
1010

1111
import copy
1212
import csv
@@ -15,6 +15,7 @@
1515
import logging
1616
import optparse
1717
import os
18+
import posixpath
1819
import shutil
1920
import sys
2021
import urllib
@@ -79,7 +80,14 @@ def get_duplicated_keys(input_file):
7980
@staticmethod
8081
def get_input_list(input_file):
8182
csvfile = csv.DictReader(open(input_file, 'rU'))
82-
return [{k.lower(): v for k, v in r.iteritems()} for r in csvfile]
83+
input_list = []
84+
for row in csvfile:
85+
row_dict = {}
86+
for key in row:
87+
row_dict[key.lower()] = row[key]
88+
input_list.append(row_dict)
89+
return input_list
90+
#return [{k.lower(): v for k, v in r.iteritems()} for r in csvfile]
8391

8492
@staticmethod
8593
def get_non_empty_rows_list(input_list):

about_code_tool/tests/test_about.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
# limitations under the License.
1515
# =============================================================================
1616

17-
from __future__ import print_function
18-
from __future__ import with_statement
17+
from __future__ import print_function, with_statement # We require Python 2.6 or later
1918

2019
import sys
2120
import string

about_code_tool/tests/test_genabout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
# =============================================================================
1616

17-
from __future__ import print_function, with_statement
17+
from __future__ import print_function, with_statement # We require Python 2.6 or later
1818

1919
import os
2020
import shutil
@@ -125,13 +125,13 @@ def test_get_duplicated_keys_have_dup(self):
125125
gen = genabout.GenAbout()
126126
test_input = join(TESTDATA_PATH, "test_files_for_genabout/dup_keys.csv")
127127
expected_list = ['copyright', 'copyright']
128-
self.assertTrue(gen.get_duplicated_keys(test_input))
128+
self.assertTrue(gen.get_duplicated_keys(test_input) == expected_list)
129129

130130
def test_get_duplicated_keys_have_dup_diff_case(self):
131131
gen = genabout.GenAbout()
132132
test_input = join(TESTDATA_PATH, "test_files_for_genabout/dup_keys_with_diff_case.csv")
133133
expected_list = ['copyright', 'Copyright']
134-
self.assertTrue(gen.get_duplicated_keys(test_input))
134+
self.assertTrue(gen.get_duplicated_keys(test_input) == expected_list)
135135

136136
def test_validate_mandatory_fields_no_missing(self):
137137
gen = genabout.GenAbout()

0 commit comments

Comments
 (0)