File tree Expand file tree Collapse file tree 4 files changed +15
-8
lines changed
Expand file tree Collapse file tree 4 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 99inventory.
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
Original file line number Diff line number Diff line change 66The input file should be a csv format which contains information about the
77file 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
1111import copy
1212import csv
1515import logging
1616import optparse
1717import os
18+ import posixpath
1819import shutil
1920import sys
2021import 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 ):
Original file line number Diff line number Diff line change 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
2019import sys
2120import string
Original file line number Diff line number Diff line change 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
1919import os
2020import 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 ()
You can’t perform that action at this time.
0 commit comments