Skip to content

Commit 838e5fc

Browse files
committed
Refactored package
1 parent 3d9c969 commit 838e5fc

19 files changed

Lines changed: 32 additions & 24 deletions

File tree

codext/__common__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import re
66
import sys
77
from functools import wraps
8+
from importlib import import_module
89
from six import binary_type, string_types, text_type
910
from types import FunctionType
1011
try: # Python3
1112
from inspect import getfullargspec
1213
except ImportError:
1314
from inspect import getargspec as getfullargspec
14-
try:
15+
try: # Python3
1516
from importlib import reload
1617
except ImportError:
1718
pass
@@ -163,10 +164,17 @@ def reset():
163164
Reset codext's local registry of search functions.
164165
"""
165166
clear()
166-
for f in os.listdir(os.path.dirname(__file__)):
167-
if not f.endswith(".py") or f.startswith("_"):
167+
tmp = os.getcwd()
168+
wd = os.path.dirname(__file__)
169+
for root, _, files in os.walk(wd):
170+
if root.split(os.sep)[-1].startswith("_"):
168171
continue
169-
reload(__import__(f[:-3], globals(), locals(), [], 1))
172+
for f in files:
173+
if not f.endswith(".py") or f.startswith("_"):
174+
continue
175+
os.chdir(root)
176+
reload(import_module(f[:-3]))
177+
os.chdir(tmp)
170178
codecs.reset = reset
171179

172180

codext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: UTF-8 -*-
2-
"""Module for enhancing codecs preimport.
2+
"""Codecs extension module.
33
44
"""
55
from .__common__ import *

codext/base/__init__.py

Whitespace-only changes.

codext/_base.py renamed to codext/base/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from string import printable
88
from types import FunctionType
99

10-
from .__common__ import *
10+
from codext.__common__ import *
1111

1212

1313
# generic base en/decoding functions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"""
55
from math import ceil, log
66

7-
from .__common__ import *
8-
from ._base import base, _get_charset, BaseError
7+
from _base import base, _get_charset, BaseError
8+
from codext.__common__ import *
99

1010

1111
# base en/decoding functions for N a power of 2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212
import base64
1313

14-
from .__common__ import *
14+
from codext.__common__ import *
1515

1616

1717
if PY3:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- decodes file content to str (read)
1111
- encodes file content from str to bytes (write)
1212
"""
13-
from .__common__ import *
13+
from codext.__common__ import *
1414

1515

1616
if PY3:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- decodes file content to str (read)
88
- encodes file content from str to bytes (write)
99
"""
10-
from .__common__ import *
10+
from codext.__common__ import *
1111

1212

1313
def base122_encode(input, errors="strict"):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212
import base64
1313

14-
from .__common__ import *
14+
from codext.__common__ import *
1515

1616

1717
if PY3:

codext/base.py renamed to codext/base/baseN.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"""
1010
from string import ascii_lowercase as lower, ascii_uppercase as upper, digits
1111

12-
from .__common__ import *
13-
from ._base import base
14-
from ._base2n import base2n
12+
from _base import base
13+
from _base2n import base2n
14+
from codext.__common__ import *
1515

1616

1717
B2 = {r'': "01", r'[-_]inv(erted)?': "10"}

0 commit comments

Comments
 (0)