mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
c.library.cli: use csv module for check_library
- use the builtin csv module for check_library output - enable the comma-escaping test in test_cli
This commit is contained in:
parent
fd70317171
commit
0dd2c54510
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
Command line interface to the calibre database.
|
||||
'''
|
||||
|
||||
import sys, os, cStringIO, re
|
||||
import cStringIO, csv, os, re, sys
|
||||
import unicodedata
|
||||
from textwrap import TextWrapper
|
||||
from optparse import OptionValueError, OptionGroup
|
||||
@ -1379,9 +1379,13 @@ def _print_check_library_results(checker, check, opts):
|
||||
list = getattr(checker, attr, None)
|
||||
if list is None:
|
||||
return
|
||||
|
||||
if opts.csv:
|
||||
for i in list:
|
||||
print check[1] + ',' + i[0] + ',' + i[1]
|
||||
to_output = [(check[1], i[0], i[1]) for i in list]
|
||||
csv_print = csv.writer(sys.stdout)
|
||||
for line in to_output:
|
||||
csv_print.writerow(line)
|
||||
|
||||
else:
|
||||
print check[1]
|
||||
for i in list:
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
Test the CLI of the calibre database management tool
|
||||
'''
|
||||
import csv, sys
|
||||
import csv
|
||||
import unittest
|
||||
from StringIO import StringIO
|
||||
|
||||
@ -88,7 +88,6 @@ class PrintCheckLibraryResultsTest(unittest.TestCase):
|
||||
"""
|
||||
Test more complex csv output
|
||||
"""
|
||||
raise unittest.SkipTest('This test fails, as csv output does not currently escape')
|
||||
checker = Mock(name='checker', speck=CheckLibrary)
|
||||
data = [['I, Caesar', 'second']]
|
||||
opts = Mock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user