mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-07 12:05:33 +00:00
defined pipreqs default encoding to utf-8
This commit is contained in:
parent
67d134e466
commit
f4db52c5c0
@ -92,7 +92,7 @@ def _open(filename=None, mode="r"):
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
def get_all_imports(path, encoding=None, extra_ignore_dirs=None, follow_links=True):
|
def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links=True):
|
||||||
imports = set()
|
imports = set()
|
||||||
raw_imports = set()
|
raw_imports = set()
|
||||||
candidates = []
|
candidates = []
|
||||||
@ -181,7 +181,7 @@ def filter_ext(file_name, acceptable):
|
|||||||
return os.path.splitext(file_name)[1] in acceptable
|
return os.path.splitext(file_name)[1] in acceptable
|
||||||
|
|
||||||
|
|
||||||
def ipynb_2_py(file_name, encoding=None):
|
def ipynb_2_py(file_name, encoding="utf-8"):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -196,7 +196,7 @@ def ipynb_2_py(file_name, encoding=None):
|
|||||||
exporter = PythonExporter()
|
exporter = PythonExporter()
|
||||||
(body, _) = exporter.from_filename(file_name)
|
(body, _) = exporter.from_filename(file_name)
|
||||||
|
|
||||||
return body.encode(encoding if encoding is not None else "utf-8")
|
return body.encode(encoding)
|
||||||
|
|
||||||
|
|
||||||
def generate_requirements_file(path, imports, symbol):
|
def generate_requirements_file(path, imports, symbol):
|
||||||
@ -255,7 +255,7 @@ def get_imports_info(imports, pypi_server="https://pypi.python.org/pypi/", proxy
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_locally_installed_packages(encoding=None):
|
def get_locally_installed_packages(encoding="utf-8"):
|
||||||
packages = []
|
packages = []
|
||||||
ignore = ["tests", "_tests", "egg", "EGG", "info"]
|
ignore = ["tests", "_tests", "egg", "EGG", "info"]
|
||||||
for path in sys.path:
|
for path in sys.path:
|
||||||
@ -296,7 +296,7 @@ def get_locally_installed_packages(encoding=None):
|
|||||||
return packages
|
return packages
|
||||||
|
|
||||||
|
|
||||||
def get_import_local(imports, encoding=None):
|
def get_import_local(imports, encoding="utf-8"):
|
||||||
local = get_locally_installed_packages()
|
local = get_locally_installed_packages()
|
||||||
result = []
|
result = []
|
||||||
for item in imports:
|
for item in imports:
|
||||||
@ -488,6 +488,9 @@ def init(args):
|
|||||||
extra_ignore_dirs = args.get("--ignore")
|
extra_ignore_dirs = args.get("--ignore")
|
||||||
follow_links = not args.get("--no-follow-links")
|
follow_links = not args.get("--no-follow-links")
|
||||||
input_path = args["<path>"]
|
input_path = args["<path>"]
|
||||||
|
|
||||||
|
if encoding is None:
|
||||||
|
encoding = "utf-8"
|
||||||
if input_path is None:
|
if input_path is None:
|
||||||
input_path = os.path.abspath(os.curdir)
|
input_path = os.path.abspath(os.curdir)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user