Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
os:
- linux
python:
- "2.7"
- "3.6"
- "nightly" # currently points to 3.7-dev

dist: trusty
sudo: required
language: python


before_install:
# Show build setup
- uname -a
- cat /etc/os-release
- pwd
- free -tm
- python --version
- git --version
- pip install -r requirements.txt

install:
# git describe requires complete history
# - travis_retry git fetch --unshallow
- python setup.py install
script:
- python helpTest.py | grep batbelt

after_success:
- echo "OK, all done."

notifications:
email:
recipients:
- ralic.lo.eng@ieee.org
on_success: always # default: change
on_failure: never # default: always


10 changes: 5 additions & 5 deletions batbelt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

__version__ = "0.5.2"

from strings import (slugify, normalize, escape_html,
from .strings import (slugify, normalize, escape_html,
unescape_html, json_dumps, json_loads)
from structs import (chunks, get, dmerge, sset, dswap, window,
from .structs import (chunks, get, dmerge, sset, dswap, window,
subdict, iget, flatten, skip_duplicates)
from objects import attr, import_from_path, Null
from utils import to_timestamp
from hack import decorator_with_args
from .objects import attr, import_from_path, Null
from .utils import to_timestamp
from .hack import decorator_with_args
2 changes: 1 addition & 1 deletion batbelt/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import threading
import multiprocessing
from functools import wraps
from Queue import Queue, Empty
from queue import Queue, Empty

__all__ = ['process', 'thread']

Expand Down
12 changes: 6 additions & 6 deletions batbelt/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from datetime import datetime, timedelta, date, time
from xml.sax.saxutils import escape, unescape

from utils import CLASSIC_DATETIME_FORMAT, CLASSIC_DATETIME_PATTERN
from .utils import CLASSIC_DATETIME_FORMAT, CLASSIC_DATETIME_PATTERN



Expand All @@ -81,7 +81,7 @@ def unicode_slugify(string, separator=r'-'):

string = re.sub(r'[^\w\s' + separator + ']', '', string, flags=re.U)
string = string.strip().lower()
return unicode(re.sub(r'[' + separator + '\s]+',
return str(re.sub(r'[' + separator + '\s]+',
separator, string, flags=re.U))


Expand All @@ -101,7 +101,7 @@ def unicodedata_slugify(string, separator=r'-'):

string = unicodedata.normalize('NFKD', string).encode('ascii', 'ignore')
string = re.sub(r'[^\w\s' + separator + ']', '', string).strip().lower()
return unicode(re.sub(r'[' + separator + '\s]+', separator, string))
return str(re.sub(r'[' + separator + '\s]+', separator, string))


def unidecode_slugify(string, separator=r'-'):
Expand All @@ -120,7 +120,7 @@ def unidecode_slugify(string, separator=r'-'):

string = unidecode.unidecode(string)
string = re.sub(r'[^\w\s' + separator + ']', '', string).strip().lower()
return unicode(re.sub(r'[' + separator + '\s]+', separator, string))
return str(re.sub(r'[' + separator + '\s]+', separator, string))


def unicodedata_normalize(string):
Expand Down Expand Up @@ -270,7 +270,7 @@ def decode_on_match(self, obj):
parse it and returns a Python object.
"""

string = unicode(obj)
string = str(obj)

match = re.search(self.datetime_pattern, string)
if match:
Expand Down Expand Up @@ -418,7 +418,7 @@ def write(path, *args, **kwargs):
if isinstance(line, str):
line = line.decode(encoding, errors)

if not isinstance(line, unicode):
if not isinstance(line, str):
line = repr(line)

f.write(line + os.linesep)
Expand Down
14 changes: 7 additions & 7 deletions batbelt/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def chunks(seq, chunksize, process=tuple):
"""
it = iter(seq)
while True:
yield process(chain([it.next()], islice(it, chunksize - 1)))
yield process(chain([next(it)], islice(it, chunksize - 1)))



Expand Down Expand Up @@ -52,7 +52,7 @@ def dmerge(d1, d2, merge_func=None):
d.update(d2)
return d

for k, v in d2.iteritems():
for k, v in list(d2.items()):
if k in d:
d[k] = merge_func(d[k], v)
else:
Expand All @@ -75,7 +75,7 @@ def dswap(dct):
>>> sorted(dswap({'a': 1, 'b': 2}).items())
[(1, 'a'), (2, 'b')]
"""
return dict((value, key) for key, value in dct.iteritems())
return dict((value, key) for key, value in list(dct.items()))


def get(data, *keys, **kwargs):
Expand Down Expand Up @@ -189,9 +189,9 @@ def subdict(dct, include=(), exclude=()):
"""

if include:
return dict((k, v) for k, v in dct.iteritems() if k in include)
return dict((k, v) for k, v in list(dct.items()) if k in include)

return dict((k, v) for k, v in dct.iteritems() if k not in exclude)
return dict((k, v) for k, v in list(dct.items()) if k not in exclude)



Expand Down Expand Up @@ -381,7 +381,7 @@ def remove_duplicates(lst, equals=lambda x, y: x == y):



KEY, PREV, NEXT = range(3)
KEY, PREV, NEXT = list(range(3))


class sset(MutableSet):
Expand Down Expand Up @@ -509,7 +509,7 @@ class Flattener(object):
tuple,
set,
(x for x in ()).__class__,
xrange,
range,
deque,
MutableSet,
# Sequence # warning, a string is a subclass of Sequence
Expand Down
2 changes: 2 additions & 0 deletions helpTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
help("modules")

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest