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

[pipreqs/pipreqs.py] Use codec to get an open with encoding arg… #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 17 additions & 1 deletion pipreqs/pipreqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,24 @@
import logging
import ast
import traceback
from codecs import open

from docopt import docopt
import requests
from yarg import json2package
from yarg.exceptions import HTTPError

from pipreqs import __version__
if sys.version[0] == "2":
from itertools import imap as map, ifilter as filter

with open(os.path.join(os.path.dirname(__file__), "__init__.py"), "rt") as f:
__version__ = next(map(
lambda buf: next(map(lambda e: e.value.s, ast.parse(buf).body)),
filter(
lambda line: line.startswith("__version__"),
f,
),
))

REGEXP = [
re.compile(r'^import (.+)$'),
Expand Down Expand Up @@ -190,6 +202,10 @@ def get_imports_info(
logging.debug(
'Package %s does not exist or network problems', item)
continue
except UnicodeDecodeError:
logging.debug(
'Package %s could not be read from server', item)
continue
result.append({'name': item, 'version': data.latest_release_id})
return result

Expand Down