🔨 reformat code

This commit is contained in:
chfw 2019-04-04 21:42:02 +01:00
parent 1a47d9e917
commit ec62f384ef
31 changed files with 84 additions and 68 deletions

View File

@ -7,13 +7,12 @@ document:
sphinx-autogen -o docs/source/generated/ docs/source/*.rst
sphinx-build -b html docs/source/ docs/build/
<<<<<<< HEAD
format:
isort -y $(find pyexcel_io -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
black -l 79 pyexcel_io
black -l 79 tests
=======
lint:
bash lint.sh
>>>>>>> master

View File

@ -69,4 +69,4 @@ html_static_path = ['static']
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'https://docs.python.org/': None}

View File

@ -8,13 +8,14 @@
:license: New BSD License, see LICENSE for more details
"""
import logging
import pyexcel_io.plugins as plugins
from .io import get_data, iget_data, save_data # noqa
from ._compact import NullHandler
logging.getLogger(__name__).addHandler(NullHandler()) # noqa
from .io import get_data, iget_data, save_data # noqa
import pyexcel_io.plugins as plugins
BLACK_LIST = [__name__, "pyexcel_webio", "pyexcel_text"]
WHITE_LIST = [
@ -25,7 +26,5 @@ WHITE_LIST = [
PREFIX_PATTERN = "^pyexcel_.*$"
plugins.load_plugins(
PREFIX_PATTERN,
__path__, # noqa: F821
BLACK_LIST,
WHITE_LIST)
PREFIX_PATTERN, __path__, BLACK_LIST, WHITE_LIST # noqa: F821
)

View File

@ -9,6 +9,7 @@
"""
import pyexcel_io.manager as manager
from pyexcel_io._compact import PY2, OrderedDict, isstream
from .constants import MESSAGE_ERROR_03, MESSAGE_WRONG_IO_INSTANCE

View File

@ -8,8 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
from pyexcel_io.plugins import IOPluginInfoChain
from pyexcel_io.constants import DB_DJANGO, DB_SQL
from pyexcel_io.constants import DB_SQL, DB_DJANGO
IOPluginInfoChain(__name__).add_a_reader(
relative_plugin_class_path="exporters.django.DjangoBookReader",

View File

@ -46,11 +46,13 @@ class IntegerAccuracyLossError(Exception):
b=get_sheet(file_name='abc.ods')
b[0,0] != s[0,0]
"""
def __init__(self, message):
custom_message = (
message + '\n' +
"In order to keep its accuracy, please save as string. Then " +
"convert to int, long or float after the value will be read back"
message
+ "\n"
+ "In order to keep its accuracy, please save as string. Then "
+ "convert to int, long or float after the value will be read back"
)
super(IntegerAccuracyLossError, self).__init__(custom_message)

View File

@ -11,8 +11,9 @@ import os
import warnings
from types import GeneratorType
from pyexcel_io._compact import isstream, PY2
from pyexcel_io import constants
from pyexcel_io.plugins import READERS, WRITERS
from pyexcel_io._compact import PY2, isstream
from pyexcel_io.exceptions import NoSupportingPluginFound
@ -124,7 +125,7 @@ def save_data(afile, data, file_type=None, **keywords):
keywords.update(dict(file_stream=afile, file_type=file_type))
else:
keywords.update(dict(file_name=afile, file_type=file_type))
keywords['single_sheet_in_book'] = single_sheet_in_book
keywords["single_sheet_in_book"] = single_sheet_in_book
with get_writer(**keywords) as writer:
writer.write(to_store)

View File

@ -7,14 +7,12 @@
:copyright: (c) 2014-2017 by Onni Software Ltd.
:license: New BSD License, see LICENSE for more details
"""
from lml.loader import scan_plugins_regex
from lml.plugin import PluginManager
from lml.plugin import PluginInfoChain, PluginInfo
import pyexcel_io.utils as ioutils
import pyexcel_io.manager as manager
import pyexcel_io.constants as constants
import pyexcel_io.exceptions as exceptions
from lml.loader import scan_plugins_regex
from lml.plugin import PluginInfo, PluginManager, PluginInfoChain
ERROR_MESSAGE_FORMATTER = "one of these plugins for %s data in '%s': %s"
UPGRADE_MESSAGE = "Please upgrade the plugin '%s' according to \
@ -137,5 +135,5 @@ def load_plugins(plugin_name_patterns, path, black_list, white_list):
plugin_name_patterns=plugin_name_patterns,
pyinstaller_path=path,
black_list=black_list,
white_list=white_list
white_list=white_list,
)

View File

@ -9,7 +9,6 @@
"""
from pyexcel_io.plugins import IOPluginInfoChain
IOPluginInfoChain(__name__).add_a_reader(
relative_plugin_class_path="csvr.CSVBookReader",
file_types=["csv"],

View File

@ -12,6 +12,7 @@ import zipfile
from pyexcel_io.book import BookReader
from pyexcel_io._compact import PY2, StringIO
from pyexcel_io.constants import FILE_FORMAT_CSVZ
from .csvr import NamedContent, CSVinMemoryReader

View File

@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
import pyexcel_io.constants as constants
from .csvr import CSVBookReader

View File

@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
from pyexcel_io.constants import FILE_FORMAT_TSVZ, KEYWORD_TSV_DIALECT
from .csvz import CSVZipBookReader

View File

@ -11,9 +11,8 @@ import re
import math
import datetime
from pyexcel_io import constants, exceptions
from pyexcel_io._compact import PY2
from pyexcel_io import constants
from pyexcel_io import exceptions
def has_no_digits_in_float(value):
@ -234,7 +233,7 @@ ODS_VALUE_CONVERTERS = {
"boolean": ods_bool_value,
"timedelta": ods_timedelta_value,
"float": ods_float_value,
"long": ods_float_value
"long": ods_float_value,
}

View File

@ -9,7 +9,6 @@
"""
from pyexcel_io.plugins import IOPluginInfoChain
IOPluginInfoChain(__name__).add_a_writer(
relative_plugin_class_path="csvw.CSVBookWriter",
file_types=["csv"],

View File

@ -12,6 +12,7 @@ import zipfile
from pyexcel_io.book import BookWriter
from pyexcel_io._compact import PY2, StringIO
from pyexcel_io.constants import FILE_FORMAT_CSVZ, DEFAULT_SHEET_NAME
from .csvw import UnicodeWriter, CSVSheetWriter

View File

@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
import pyexcel_io.constants as constants
from .csvw import CSVBookWriter

View File

@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
from pyexcel_io.constants import FILE_FORMAT_TSVZ, KEYWORD_TSV_DIALECT
from .csvz import CSVZipBookWriter

View File

@ -1,8 +1,9 @@
from nose.tools import raises
from pyexcel_io.book import BookWriter
from pyexcel_io.sheet import SheetReader, SheetWriter, NamedContent
from pyexcel_io.utils import is_empty_array
from nose.tools import raises
@raises(NotImplementedError)
def test_book_writer():

View File

@ -1,6 +1,7 @@
from nose.tools import raises
from pyexcel_io.book import BookReader, BookWriter, RWInterface
from nose.tools import raises
@raises(NotImplementedError)
def test_rwinterface():

View File

@ -6,7 +6,6 @@ from textwrap import dedent
from unittest import TestCase
import pyexcel_io.manager as manager
from nose.tools import eq_, raises
from pyexcel_io.sheet import NamedContent
from pyexcel_io._compact import PY2, BytesIO, StringIO
from pyexcel_io.readers.csvr import (
@ -16,6 +15,8 @@ from pyexcel_io.readers.csvr import (
)
from pyexcel_io.writers.csvw import CSVFileWriter, CSVMemoryWriter
from nose.tools import eq_, raises
class TestReaders(TestCase):
def setUp(self):

View File

@ -1,4 +1,3 @@
from nose.tools import eq_, raises
from pyexcel_io import save_data
from pyexcel_io._compact import OrderedDict
from pyexcel_io.constants import DB_DJANGO
@ -17,6 +16,8 @@ from pyexcel_io.database.importers.django import (
DjangoModelWriter,
)
from nose.tools import eq_, raises
class Package:
def __init__(self, raiseException=False, **keywords):

View File

@ -1,10 +1,11 @@
import os
import pyexcel_io.constants as constants
from nose.tools import eq_
from pyexcel_io import get_data, save_data
from pyexcel_io.utils import _index_filter
from nose.tools import eq_
def test_index_filter():
current_index, start, limit, expected = (0, 1, -1, constants.SKIP_DATA)

View File

@ -6,11 +6,12 @@ from unittest import TestCase
import pyexcel_io.manager as manager
import pyexcel_io.exceptions as exceptions
from nose.tools import eq_, raises
from pyexcel_io import get_data, iget_data, save_data
from pyexcel_io.io import load_data, get_writer
from pyexcel_io._compact import BytesIO, StringIO, OrderedDict, is_string
from nose.tools import eq_, raises
PY2 = sys.version_info[0] == 2
@ -25,7 +26,7 @@ def test_force_file_type():
@raises(IOError)
def test_invalid_file():
load_data('/something/does/not/exist')
load_data("/something/does/not/exist")
@raises(IOError)

View File

@ -4,11 +4,11 @@
import os
import pyexcel as p
from pyexcel_io import get_data, save_data
from pyexcel_io._compact import PY26
from nose import SkipTest
from nose.tools import eq_
from pyexcel_io import get_data, save_data
from pyexcel_io._compact import PY26
IN_TRAVIS = "TRAVIS" in os.environ

View File

@ -3,13 +3,14 @@ from textwrap import dedent
from unittest import TestCase
import pyexcel_io.manager as manager
from nose.tools import raises
from pyexcel_io._compact import OrderedDict
from pyexcel_io.readers.tsv import TSVBookReader
from pyexcel_io.writers.tsv import TSVBookWriter
from pyexcel_io.readers.csvr import CSVBookReader
from pyexcel_io.writers.csvw import CSVBookWriter
from nose.tools import raises
class TestCSVReaders(TestCase):
file_type = "csv"

View File

@ -5,7 +5,6 @@ import zipfile
from unittest import TestCase
import pyexcel_io.manager as manager
from nose.tools import raises
from pyexcel_io import save_data
from pyexcel_io._compact import OrderedDict
from pyexcel_io.readers.csvz import CSVZipBookReader
@ -13,6 +12,8 @@ from pyexcel_io.readers.tsvz import TSVZipBookReader
from pyexcel_io.writers.csvz import CSVZipBookWriter
from pyexcel_io.writers.tsvz import TSVZipBookWriter
from nose.tools import raises
PY2 = sys.version_info[0] == 2

View File

@ -4,7 +4,6 @@ from textwrap import dedent
from unittest import TestCase
import pyexcel as pe
from pyexcel_io._compact import text_type

View File

@ -1,8 +1,9 @@
import os
from nose.tools import eq_
from pyexcel_io import get_data, save_data
from nose.tools import eq_
class TestRenderer:
def setUp(self):

View File

@ -1,13 +1,17 @@
from nose.tools import eq_, raises
from pyexcel_io.service import date_value, time_value
from pyexcel_io.service import detect_int_value
from pyexcel_io.service import detect_float_value
from pyexcel_io.service import ODS_WRITE_FORMAT_COVERSION
from pyexcel_io.service import ods_float_value
from pyexcel_io.service import throw_exception
from pyexcel_io.service import (
ODS_WRITE_FORMAT_COVERSION,
date_value,
time_value,
ods_float_value,
throw_exception,
detect_int_value,
detect_float_value,
)
from pyexcel_io._compact import PY2
from pyexcel_io.exceptions import IntegerAccuracyLossError
from nose import SkipTest
from nose.tools import eq_, raises
def test_date_util_parse():
@ -100,7 +104,7 @@ def test_detect_float_value_on_custom_nan_text2():
def test_ods_write_format_conversion():
if PY2:
expected = ODS_WRITE_FORMAT_COVERSION[long] # noqa: F821
eq_('long', expected)
eq_("long", expected)
else:
raise SkipTest()
@ -120,7 +124,7 @@ def test_max_value_on_python_2():
@raises(IntegerAccuracyLossError)
def test_really_long_value_on_python2():
if PY2:
ods_float_value(long(999999999999999+1))
ods_float_value(long(999999999999999 + 1))
else:
raise SkipTest("No long in python 3")

View File

@ -1,7 +1,8 @@
import pyexcel_io.constants as constants
from nose.tools import eq_
from pyexcel_io.sheet import SheetReader, SheetWriter
from nose.tools import eq_
class MyWriter(SheetWriter):
def set_size(self, size):

View File

@ -3,6 +3,24 @@ import json
import datetime
import platform
from pyexcel_io._compact import OrderedDict
from pyexcel_io.database.common import (
SQLTableExporter,
SQLTableImporter,
SQLTableExportAdapter,
SQLTableImportAdapter,
)
from pyexcel_io.database.querysets import QuerysetsReader
from pyexcel_io.database.exporters.sqlalchemy import (
SQLBookReader,
SQLTableReader,
)
from pyexcel_io.database.importers.sqlalchemy import (
SQLBookWriter,
SQLTableWriter,
PyexcelSQLSkipRowException,
)
from nose.tools import eq_, raises
from sqlalchemy import (
Date,
@ -15,24 +33,7 @@ from sqlalchemy import (
create_engine,
)
from sqlalchemy.orm import backref, relationship, sessionmaker
from pyexcel_io._compact import OrderedDict
from pyexcel_io.database.common import (
SQLTableExporter,
SQLTableImporter,
SQLTableExportAdapter,
SQLTableImportAdapter,
)
from sqlalchemy.ext.declarative import declarative_base
from pyexcel_io.database.querysets import QuerysetsReader
from pyexcel_io.database.exporters.sqlalchemy import (
SQLBookReader,
SQLTableReader,
)
from pyexcel_io.database.importers.sqlalchemy import (
SQLBookWriter,
SQLTableWriter,
PyexcelSQLSkipRowException,
)
PY3 = sys.version_info[0] == 3
PY36 = PY3 and sys.version_info[1] == 6