Skip to content

Commit e943297

Browse files
committed
Fixed #67
Add code/test code for handling blank line
1 parent 555d8f3 commit e943297

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

about_code_tool/genabout.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,25 @@ def read_input(self, input_file, mapping):
118118
if not version == 'version':
119119
del line[version]
120120
if not line['about_file']:
121-
missing_about_file = "'about_file' field value is missing. Generation is skipped."
122-
self.errors.append(Error('about_file', None, missing_about_file))
121+
# This code is to handle blank line
122+
for key in line.keys():
123+
if line[key]:
124+
missing_about_file = "'about_file' field value is missing. Generation is skipped."
125+
self.errors.append(Error('about_file', None, missing_about_file))
126+
break
123127
continue
124128
except Exception as e:
125129
print(repr(e))
126130
print("The input does not have the 'about_file' key which is required.")
127131
sys.exit(errno.EINVAL)
128132
try:
129133
if not line['about_resource']:
130-
missing_about_resource = "'about_resource' is missing. Generation is skipped."
131-
self.errors.append(Error('about_resource', line['about_file'], missing_about_resource))
134+
# This code is to handle blank line
135+
for key in line.keys():
136+
if line[key]:
137+
missing_about_resource = "'about_resource' is missing. Generation is skipped."
138+
self.errors.append(Error('about_resource', line['about_file'], missing_about_resource))
139+
break
132140
continue
133141
except Exception as e:
134142
print(repr(e))

about_code_tool/tests/test_genabout.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ def test_read_input(self):
3535
list = gen.read_input(test_input, False)
3636
self.assertTrue(list, "List shouldn't be empty.")
3737

38+
def test_read_input_with_blank_line(self):
39+
gen = genabout.GenAbout()
40+
test_input = join(TESTDATA_PATH, "test_files_for_genabout/contains_blank_line.csv")
41+
list = gen.read_input(test_input, False)
42+
self.assertTrue(list, "List shouldn't be empty.")
43+
3844
def test_read_input_missing_about_file(self):
3945
gen = genabout.GenAbout()
4046
test_input = join(TESTDATA_PATH, "test_files_for_genabout/missing_about_file.csv")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
about_file,about_resource,name,version
2+
test_blank line,/tmp/,blank line,0.8.1
3+
blank line below,/tmp/1/,,
4+
,,,
5+
blank line above,/tmp/2/,,

0 commit comments

Comments
 (0)