Skip to content

Commit

Permalink
🔨 reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Apr 4, 2019
1 parent 1a47d9e commit ec62f38
Show file tree
Hide file tree
Showing 31 changed files with 80 additions and 64 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
# -- 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}
13 changes: 6 additions & 7 deletions pyexcel_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
:license: New BSD License, see LICENSE for more details
"""
import logging
from ._compact import NullHandler

logging.getLogger(__name__).addHandler(NullHandler()) # noqa
import pyexcel_io.plugins as plugins

from .io import get_data, iget_data, save_data # noqa
import pyexcel_io.plugins as plugins
from ._compact import NullHandler

logging.getLogger(__name__).addHandler(NullHandler()) # noqa


BLACK_LIST = [__name__, "pyexcel_webio", "pyexcel_text"]
Expand All @@ -25,7 +26,5 @@
PREFIX_PATTERN = "^pyexcel_.*$"

plugins.load_plugins(
PREFIX_PATTERN,
__path__, # noqa: F821
BLACK_LIST,
WHITE_LIST)
PREFIX_PATTERN, __path__, BLACK_LIST, WHITE_LIST # noqa: F821
)
1 change: 1 addition & 0 deletions pyexcel_io/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 1 addition & 2 deletions pyexcel_io/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions pyexcel_io/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 3 additions & 2 deletions pyexcel_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
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


Expand Down Expand Up @@ -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)

Expand Down
8 changes: 3 additions & 5 deletions pyexcel_io/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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,
)
1 change: 0 additions & 1 deletion pyexcel_io/readers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
from pyexcel_io.plugins import IOPluginInfoChain


IOPluginInfoChain(__name__).add_a_reader(
relative_plugin_class_path="csvr.CSVBookReader",
file_types=["csv"],
Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/readers/csvz.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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


Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/readers/tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
import pyexcel_io.constants as constants

from .csvr import CSVBookReader


Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/readers/tsvz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 2 additions & 3 deletions pyexcel_io/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
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):
Expand Down Expand Up @@ -234,7 +233,7 @@ def ods_timedelta_value(cell):
"boolean": ods_bool_value,
"timedelta": ods_timedelta_value,
"float": ods_float_value,
"long": ods_float_value
"long": ods_float_value,
}


Expand Down
1 change: 0 additions & 1 deletion pyexcel_io/writers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""
from pyexcel_io.plugins import IOPluginInfoChain


IOPluginInfoChain(__name__).add_a_writer(
relative_plugin_class_path="csvw.CSVBookWriter",
file_types=["csv"],
Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/writers/csvz.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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


Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/writers/tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:license: New BSD License, see LICENSE for more details
"""
import pyexcel_io.constants as constants

from .csvw import CSVBookWriter


Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/writers/tsvz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion tests/test_base.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_book.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
3 changes: 2 additions & 1 deletion tests/test_csv_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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 (
Expand All @@ -16,6 +15,8 @@
)
from pyexcel_io.writers.csvw import CSVFileWriter, CSVMemoryWriter

from nose.tools import eq_, raises


class TestReaders(TestCase):
def setUp(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_django_book.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +16,8 @@
DjangoModelWriter,
)

from nose.tools import eq_, raises


class Package:
def __init__(self, raiseException=False, **keywords):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_filter.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

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


Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/test_new_csv_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
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"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_new_csvz_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
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
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


Expand Down
1 change: 0 additions & 1 deletion tests/test_pyexcel_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from unittest import TestCase

import pyexcel as pe

from pyexcel_io._compact import text_type


Expand Down
3 changes: 2 additions & 1 deletion tests/test_renderer.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Loading

0 comments on commit ec62f38

Please sign in to comment.