Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9230d80

Browse files
authored
Merge pull request #1536 from stonebig/master
small simplification
2 parents c9d44a6 + 2a6fbd9 commit 9230d80

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

winpython/utils.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# -*- coding: utf-8 -*-
22
#
3+
# WinPython utilities
34
# Copyright © 2012 Pierre Raybaut
5+
# Copyright © 2014-2025+ The Winpython development team https://github.com/winpython/
46
# Licensed under the terms of the MIT License
57
# (see winpython/__init__.py for details)
68

7-
"""
8-
WinPython utilities
9-
10-
Created on Tue Aug 14 14:08:40 2012
11-
"""
12-
139
import os
1410
import sys
1511
import stat
@@ -23,7 +19,6 @@
2319
import tarfile
2420
import zipfile
2521
import atexit
26-
import io
2722
import winreg
2823

2924
# SOURCE_PATTERN defines what an acceptable source package name is
@@ -259,13 +254,13 @@ def patch_shebang_line_py(fname, to_movable=True, targetdir=""):
259254
def guess_encoding(csv_file):
260255
"""guess the encoding of the given file"""
261256
# UTF_8_BOM = "\xEF\xBB\xBF"
262-
with io.open(csv_file, "rb") as f:
257+
with open(csv_file, "rb") as f:
263258
data = f.read(5)
264259
if data.startswith(b"\xEF\xBB\xBF"): # UTF-8 with a "BOM" (normally no BOM in utf-8)
265260
return ["utf-8-sig"]
266261
else: # in Windows, guessing utf-8 doesn't work, so we have to try
267262
try:
268-
with io.open(csv_file, encoding="utf-8") as f:
263+
with open(csv_file, encoding="utf-8") as f:
269264
preview = f.read(222222)
270265
return ["utf-8"]
271266
except:

winpython/wppm.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# -*- coding: utf-8 -*-
22
#
3+
# WinPython Package Manager
34
# Copyright © 2012 Pierre Raybaut
5+
# Copyright © 2014-2025+ The Winpython development team https://github.com/winpython/
46
# Licensed under the terms of the MIT License
57
# (see winpython/__init__.py for details)
68

7-
"""
8-
WinPython Package Manager
9-
10-
Created on Fri Aug 03 14:32:26 2012
11-
"""
12-
139
import os
1410
from pathlib import Path
1511
import shutil
@@ -22,15 +18,14 @@
2218
# Local imports
2319
from winpython import utils, piptree
2420

25-
2621
# Workaround for installing PyVISA on Windows from source:
2722
os.environ["HOME"] = os.environ["USERPROFILE"]
2823

2924
class Package:
3025
"standardize a Package from filename or pip list"
31-
def __init__(self, fname, suggested_summary=None):
26+
def __init__(self, fname, suggested_summary=None):
3227
self.fname = fname
33-
self.description = piptree.sum_up(suggested_summary) if suggested_summary else ""
28+
self.description = piptree.sum_up(suggested_summary) if suggested_summary else ""
3429
self.name = None
3530
self.version = None
3631
if fname.endswith((".zip", ".tar.gz", ".whl")):
@@ -39,14 +34,12 @@ def __init__(self, fname, suggested_summary=None):
3934
if infos is not None:
4035
self.name, self.version = infos
4136
self.name = utils.normalize(self.name)
42-
self.url = None
37+
self.url = f"https://pypi.org/project/{self.name}"
4338
self.files = []
4439

45-
setattr(self,'url',"https://pypi.org/project/" + self.name)
46-
4740
def __str__(self):
4841
return f"{self.name} {self.version}\r\n{self.description}\r\nWebsite: {self.url}"
49-
42+
5043

5144
class Distribution:
5245
def __init__(self, target=None, verbose=False):

0 commit comments

Comments
 (0)