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.
|
Command line interface to the calibre database.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys, os, cStringIO, re
|
import cStringIO, csv, os, re, sys
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
from optparse import OptionValueError, OptionGroup
|
from optparse import OptionValueError, OptionGroup
|
||||||
@ -1379,9 +1379,13 @@ def _print_check_library_results(checker, check, opts):
|
|||||||
list = getattr(checker, attr, None)
|
list = getattr(checker, attr, None)
|
||||||
if list is None:
|
if list is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if opts.csv:
|
if opts.csv:
|
||||||
for i in list:
|
to_output = [(check[1], i[0], i[1]) for i in list]
|
||||||
print check[1] + ',' + i[0] + ',' + i[1]
|
csv_print = csv.writer(sys.stdout)
|
||||||
|
for line in to_output:
|
||||||
|
csv_print.writerow(line)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print check[1]
|
print check[1]
|
||||||
for i in list:
|
for i in list:
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
'''
|
'''
|
||||||
Test the CLI of the calibre database management tool
|
Test the CLI of the calibre database management tool
|
||||||
'''
|
'''
|
||||||
import csv, sys
|
import csv
|
||||||
import unittest
|
import unittest
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
@ -88,7 +88,6 @@ class PrintCheckLibraryResultsTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Test more complex csv output
|
Test more complex csv output
|
||||||
"""
|
"""
|
||||||
raise unittest.SkipTest('This test fails, as csv output does not currently escape')
|
|
||||||
checker = Mock(name='checker', speck=CheckLibrary)
|
checker = Mock(name='checker', speck=CheckLibrary)
|
||||||
data = [['I, Caesar', 'second']]
|
data = [['I, Caesar', 'second']]
|
||||||
opts = Mock()
|
opts = Mock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user