Skip to content

Commit

Permalink
Fix some python 3.4 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Aug 31, 2015
1 parent f41397a commit fe1e526
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: python
python: 3.4

jdk: oraclejdk7

Expand Down
4 changes: 3 additions & 1 deletion luigi/contrib/hdfs/snakebite_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def __init__(self):
def list_path(path):
if isinstance(path, list) or isinstance(path, tuple):
return path
if isinstance(path, str) or isinstance(path, unicode):
# TODO: Should this be:
# isinstance(path, (six.text_type, six.binary_type))?
if isinstance(path, six.string_types):
return [path, ]
return [str(path), ]

Expand Down
11 changes: 4 additions & 7 deletions luigi/contrib/hdfs/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
from luigi.contrib.hdfs.config import tmppath
from luigi.contrib.hdfs import format as hdfs_format
from luigi.contrib.hdfs import clients as hdfs_clients

try:
from urlparse import urlsplit
except ImportError:
from urllib.parse import urlsplit
from luigi.six.moves.urllib import parse as urlparse
from luigi.six.moves import range


class HdfsTarget(FileSystemTarget):
Expand Down Expand Up @@ -89,7 +86,7 @@ def __init__(self, path=None, format=None, is_tmp=False, fs=None):
self.format = format

self.is_tmp = is_tmp
(scheme, netloc, path, query, fragment) = urlsplit(path)
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(path)
if ":" in path:
raise ValueError('colon is not allowed in hdfs filenames')
self._fs = fs or hdfs_clients.get_autoconfig_client()
Expand Down Expand Up @@ -167,7 +164,7 @@ def is_writable(self):
parts = self.path.split("/")
# start with the full path and then up the tree until we can check
length = len(parts)
for part in xrange(length):
for part in range(length):
path = "/".join(parts[0:length - part]) + "/"
if self.fs.exists(path):
# if the path exists and we can write there, great!
Expand Down
3 changes: 2 additions & 1 deletion luigi/date_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def __cmp__(self, other):
if not isinstance(self, type(other)):
# doing this because it's not well defined if eg. 2012-01-01-2013-01-01 == 2012
raise TypeError('Date interval type mismatch')
return cmp((self.date_a, self.date_b), (other.date_a, other.date_b))

return (self > other) - (self < other)

def __lt__(self, other):
if not isinstance(self, type(other)):
Expand Down

0 comments on commit fe1e526

Please sign in to comment.