Skip to content

Commit

Permalink
setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
panyanyany committed Aug 26, 2016
1 parent af465a5 commit 001133c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.*
*.pyc
__pycache__/
beeprint.egg-info/*
build/*
dist/*
17 changes: 12 additions & 5 deletions beeprint/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

from . import constants as C
from . import settings as S
from .utils import pyv
from .utils import pyv, _unicode
from .terminal_size import get_terminal_size
# from kitchen.text import display

if pyv == 3:
xrange = range


def typeval(context, v):
try:
Expand Down Expand Up @@ -46,7 +49,7 @@ def pstr(s):
'''
res = u''

if isinstance(s, unicode):
if isinstance(s, _unicode):
res += s
elif isinstance(s, str):
# in python 2/3, it's utf8
Expand Down Expand Up @@ -82,7 +85,7 @@ def string_type(s):
# in py2, string literal is both instance of str and bytes
# a literal string is str (i.e: coding encoded, eg: utf8)
# a u-prefixed string is unicode
if isinstance(s, unicode):
if isinstance(s, _unicode):
return C._ST_UNICODE_
elif isinstance(s, str): # same as isinstance(v, bytes)
return C._ST_LITERAL_ | C._ST_BYTES_
Expand Down Expand Up @@ -139,7 +142,7 @@ def string_handle(context, s, st):
left_margin%2*u' ',
seg_list[i],
])
s = '\n'.join(seg_list)
s = "\n".join(seg_list)

str_encloser.body = s

Expand Down Expand Up @@ -172,6 +175,10 @@ def wrap_string(s, width):
t = urwid.Text(s)
seg_list = t.render((width,)).text
seg_list = [seg.rstrip() for seg in seg_list]
if pyv == 3:
# seg is the type of <class 'bytes'> in py3
# seg is the type of <type 'str'> in py2
seg_list = [seg.decode('utf8') for seg in seg_list]
return seg_list

def is_extendable(obj):
Expand Down Expand Up @@ -202,7 +209,7 @@ def object_attr_default_filter(obj, name, val):

for prop in S.prop_filters:
# filter is a string
if isinstance(prop, str) or isinstance(prop, unicode):
if isinstance(prop, str) or isinstance(prop, _unicode):
if name == prop:
return True
# filter is a type
Expand Down
2 changes: 0 additions & 2 deletions beeprint/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

reload(sys)
sys.setdefaultencoding('utf-8')
else:
unicode = str

from . import settings as S
from . import constants as C
Expand Down
3 changes: 3 additions & 0 deletions beeprint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import types


_unicode = None
if sys.version_info < (3, 0):
pyv = 2
_unicode = unicode
else:
pyv = 3
_unicode = str

def is_class_method(name, val):
if pyv == 2:
Expand Down
4 changes: 3 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ register:
python setup.py register -r pypitest || true

full:
python setup.py sdist bdist_egg upload
python2.7 setup.py bdist_egg upload
python3.5 setup.py bdist_egg upload
python setup.py sdist upload

test27:
python2.7 -m unittest discover tests || true
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from distutils.core import setup
from setuptools import setup
setup(
name = 'beeprint',
packages = ['beeprint'], # this must be the same as the name above
version = '0.1',
description = 'print object in beautiful format, like pprint',
version = '2.2.1',
description = 'make your debug printing more friendly',
author = 'Yangyang Pan',
author_email = '[email protected]',
url = 'https://github.com/panyanyany/beeprint', # use the URL to the github repo
download_url = 'https://github.com/panyanyany/beeprint/archive/master.zip', # I'll explain this in a second
keywords = ['print', 'pprint', 'format'], # arbitrary keywords
keywords = ['print', 'pprint', 'format', 'debug'], # arbitrary keywords
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 2",
Expand All @@ -22,7 +22,7 @@
"Topic :: Software Development",
"Topic :: Utilities",
],
install_requires=[
install_requires = [
'urwid',
],
)

0 comments on commit 001133c

Please sign in to comment.