Skip to content

Commit

Permalink
Refactor imports using "isort"
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Nov 24, 2018
1 parent feeea8f commit 5cdd36c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 17 deletions.
8 changes: 4 additions & 4 deletions loguru/_datetime.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import datetime as datetime_, timezone, timedelta
from calendar import day_name, day_abbr, month_name, month_abbr
from time import time, localtime
import re

from calendar import day_abbr, day_name, month_abbr, month_name
from datetime import datetime as datetime_
from datetime import timedelta, timezone
from time import localtime, time

tokens = r"H{1,2}|h{1,2}|m{1,2}|s{1,2}|S{1,6}|YYYY|YY|M{1,4}|D{1,4}|Z{1,2}|zz|A|X|x|E|Q|dddd|ddd|d"

Expand Down
1 change: 1 addition & 0 deletions loguru/_defaults.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import environ


def env(key, type_, default=None):
if key not in environ:
return default
Expand Down
7 changes: 2 additions & 5 deletions loguru/_file_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def compress(path_in, path_out):
return compress

def make_compress_zipped():
import zlib, zipfile
import zipfile
def compress(path_in, path_out):
with zipfile.ZipFile(path_out, 'w', compression=zipfile.ZIP_DEFLATED) as f_comp:
f_comp.write(path_in, os.path.basename(path_in))
Expand All @@ -223,7 +223,7 @@ def compress(path_in, path_out):
ext = compression.strip().lstrip('.')

if ext == 'gz':
import zlib, gzip
import gzip
compress = make_compress_generic(gzip.open)
elif ext == 'bz2':
import bz2
Expand All @@ -237,13 +237,10 @@ def compress(path_in, path_out):
elif ext == 'tar':
compress = make_compress_archive('')
elif ext == 'tar.gz':
import zlib, gzip
compress = make_compress_archive('gz')
elif ext == 'tar.bz2':
import bz2
compress = make_compress_archive('bz2')
elif ext == 'tar.xz':
import lzma
compress = make_compress_archive('xz')
elif ext == 'zip':
compress = make_compress_zipped()
Expand Down
2 changes: 1 addition & 1 deletion loguru/_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import functools
import json
import multiprocessing
import string
import sys
import threading
import traceback
import string

import ansimarkup

Expand Down
6 changes: 3 additions & 3 deletions loguru/_logger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import functools
import itertools
import logging
import os
import threading
from collections import namedtuple
from datetime import timedelta
Expand All @@ -18,7 +17,8 @@
from ._file_sink import FileSink
from ._get_frame import get_frame
from ._handler import Handler
from ._recattrs import LevelRecattr, FileRecattr, ThreadRecattr, ProcessRecattr, ExceptionRecattr
from ._recattrs import (ExceptionRecattr, FileRecattr, LevelRecattr,
ProcessRecattr, ThreadRecattr)

Level = namedtuple('Level', ['no', 'color', 'icon'])

Expand Down Expand Up @@ -228,7 +228,7 @@ def start(self, sink, *, level=_defaults.LOGURU_LEVEL, format=_defaults.LOGURU_F
elif hasattr(sink, 'write') and callable(sink.write):
try:
converter = AnsiToWin32(sink, convert=None, strip=False)
except:
except Exception:
if colorize is None:
colorize = False
stream = sink
Expand Down
2 changes: 0 additions & 2 deletions loguru/_notifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import textwrap

import notifiers


Expand Down
2 changes: 0 additions & 2 deletions loguru/_recattrs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import random
import re
import sys
import traceback
from collections import namedtuple

from better_exceptions_fork import ExceptionFormatter


loguru_traceback = namedtuple('loguru_traceback', ('tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next'))


Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
extras_require={
'dev': [
'coveralls>=1.3.0',
'isort>=4.3.4',
'pytest>=3.5.0',
'pytest-cov>=2.5.1',
],
Expand Down

0 comments on commit 5cdd36c

Please sign in to comment.