diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..427189c --- /dev/null +++ b/.travis.yml @@ -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 + + diff --git a/batbelt/__init__.py b/batbelt/__init__.py index c45e927..8af658e 100644 --- a/batbelt/__init__.py +++ b/batbelt/__init__.py @@ -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 diff --git a/batbelt/parallel.py b/batbelt/parallel.py index cf656a4..c944886 100644 --- a/batbelt/parallel.py +++ b/batbelt/parallel.py @@ -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'] diff --git a/batbelt/strings.py b/batbelt/strings.py index 3e3d9b4..6dcefc8 100644 --- a/batbelt/strings.py +++ b/batbelt/strings.py @@ -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 @@ -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)) @@ -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'-'): @@ -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): @@ -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: @@ -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) diff --git a/batbelt/structs.py b/batbelt/structs.py index 8b72cf9..4b84d63 100644 --- a/batbelt/structs.py +++ b/batbelt/structs.py @@ -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))) @@ -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: @@ -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): @@ -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) @@ -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): @@ -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 diff --git a/helpTest.py b/helpTest.py new file mode 100644 index 0000000..fe88887 --- /dev/null +++ b/helpTest.py @@ -0,0 +1,2 @@ +help("modules") + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..55b033e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pytest \ No newline at end of file