Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 support #3

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "easywebdav"]
path = easywebdav
url = https://github.com/Kxrr/easywebdav
1 change: 1 addition & 0 deletions easywebdav
Submodule easywebdav added at 8beb4b
4 changes: 3 additions & 1 deletion nutstore_cli/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from nutstore_cli.client.utils import check_local_path
from nutstore_cli.client.path_helper import *

import easywebdav
from nutstore_cli import easywebdav

from six.moves.urllib.parse import unquote

class BaseNutStoreClient(object):
"""坚果云"""
Expand Down Expand Up @@ -49,6 +50,7 @@ def download(self, remote_path, local_path=None):

def ls(self):
def file_in_dir(filename, directory):
filename=unquote(filename)
return (directory in filename) and (filename != directory)

real_path = self.np.real
Expand Down
2 changes: 1 addition & 1 deletion nutstore_cli/client/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
from easywebdav.client import WebdavException
from nutstore_cli.easywebdav.client import WebdavException


class NutStoreClientException(WebdavException):
Expand Down
3 changes: 2 additions & 1 deletion nutstore_cli/client/path_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
basename,
splitext,
)
from urlparse import urljoin

from six.moves.urllib.parse import urljoin

__all__ = (
'join',
Expand Down
5 changes: 3 additions & 2 deletions nutstore_cli/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import os

from nutstore_cli.client.exceptions import FileNotExistException
from six import string_types


def get_attr(obj, attr_or_fn):
if isinstance(attr_or_fn, basestring):
if isinstance(attr_or_fn, string_types):
return getattr(obj, attr_or_fn)
elif callable(attr_or_fn):
return attr_or_fn(obj)
Expand All @@ -22,4 +23,4 @@ def deco(*args, **kwargs):
raise FileNotExistException.make_exception(local_path)
return func(*args, **kwargs)

return deco
return deco
2 changes: 1 addition & 1 deletion nutstore_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def load(self, filename):
return config
debug('Loading config from {}'.format(filename))
with open(filename) as f:
for line in f.xreadlines():
for line in f.readlines():
m = self.PARSE_RE.search(line)
if m and (m.group(1).strip() in CONFIG_KEYS):
k = m.group(1).strip()
Expand Down
1 change: 1 addition & 0 deletions nutstore_cli/easywebdav/__init__.py
1 change: 1 addition & 0 deletions nutstore_cli/easywebdav/__version__.py
1 change: 1 addition & 0 deletions nutstore_cli/easywebdav/client.py
7 changes: 4 additions & 3 deletions nutstore_cli/execution.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# encoding: utf-8
import re
from os import path
from itertools import ifilter

from six.moves import filter

import click
import tabulate
Expand Down Expand Up @@ -73,10 +74,10 @@ def visit_ls(self, node, children):
LS_LABELS
)
grep_keywords = children[2].children[4].children[0].text if children[2].children else None
rows = ifilter(lambda row: bool(row[0]), rows)
rows = filter(lambda row: bool(row[0]), rows)
if grep_keywords:
echo.debug('Issue a grep "{}"'.format(grep_keywords))
rows = ifilter(lambda row: re.search(grep_keywords, row[0], flags=re.IGNORECASE), rows)
rows = filter(lambda row: re.search(grep_keywords, row[0], flags=re.IGNORECASE), rows)
rows = list(rows)
rows.sort(key=lambda row: row[2]) # order by mtime
echo.echo(tabulate.tabulate(rows, headers=labels))
Expand Down