OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
wheel
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/17/2025 09:32:20 AM
rwxr-xr-x
📄
__init__.py
96 bytes
09/10/2017 09:52:41 PM
rw-r--r--
📄
__main__.py
419 bytes
07/26/2017 12:20:11 AM
rw-r--r--
📁
__pycache__
-
05/09/2024 06:58:00 AM
rwxr-xr-x
📄
archive.py
2.32 KB
07/29/2017 04:05:11 PM
rw-r--r--
📄
bdist_wheel.py
18.41 KB
08/06/2017 10:02:13 AM
rw-r--r--
📄
decorator.py
541 bytes
07/25/2017 09:21:00 PM
rw-r--r--
📄
egg2wheel.py
2.97 KB
07/26/2017 12:20:11 AM
rw-r--r--
📄
install.py
18 KB
01/23/2023 10:46:47 AM
rw-r--r--
📄
metadata.py
11.29 KB
07/29/2017 04:17:38 PM
rw-r--r--
📄
paths.py
1.1 KB
07/26/2017 12:20:11 AM
rw-r--r--
📄
pep425tags.py
5.63 KB
09/03/2017 02:03:28 PM
rw-r--r--
📄
pkginfo.py
1.23 KB
07/29/2017 03:48:00 PM
rw-r--r--
📁
signatures
-
05/09/2024 06:58:00 AM
rwxr-xr-x
📁
tool
-
05/09/2024 06:58:00 AM
rwxr-xr-x
📄
util.py
4.62 KB
08/06/2017 01:25:31 PM
rw-r--r--
📄
wininst2wheel.py
7.59 KB
07/26/2017 12:20:11 AM
rw-r--r--
Editing: util.py
Close
"""Utility functions.""" import base64 import hashlib import json import os import sys from collections import OrderedDict __all__ = ['urlsafe_b64encode', 'urlsafe_b64decode', 'utf8', 'to_json', 'from_json', 'matches_requirement'] # For encoding ascii back and forth between bytestrings, as is repeatedly # necessary in JSON-based crypto under Python 3 if sys.version_info[0] < 3: text_type = unicode # noqa: F821 def native(s): return s else: text_type = str def native(s): if isinstance(s, bytes): return s.decode('ascii') return s def urlsafe_b64encode(data): """urlsafe_b64encode without padding""" return base64.urlsafe_b64encode(data).rstrip(binary('=')) def urlsafe_b64decode(data): """urlsafe_b64decode without padding""" pad = b'=' * (4 - (len(data) & 3)) return base64.urlsafe_b64decode(data + pad) def to_json(o): """Convert given data to JSON.""" return json.dumps(o, sort_keys=True) def from_json(j): """Decode a JSON payload.""" return json.loads(j) def open_for_csv(name, mode): if sys.version_info[0] < 3: nl = {} bin = 'b' else: nl = {'newline': ''} bin = '' return open(name, mode + bin, **nl) def utf8(data): """Utf-8 encode data.""" if isinstance(data, text_type): return data.encode('utf-8') return data def binary(s): if isinstance(s, text_type): return s.encode('ascii') return s class HashingFile(object): def __init__(self, path, mode, hashtype='sha256'): self.fd = open(path, mode) self.hashtype = hashtype self.hash = hashlib.new(hashtype) self.length = 0 def write(self, data): self.hash.update(data) self.length += len(data) self.fd.write(data) def close(self): self.fd.close() def digest(self): if self.hashtype == 'md5': return self.hash.hexdigest() digest = self.hash.digest() return self.hashtype + '=' + native(urlsafe_b64encode(digest)) def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.fd.close() class OrderedDefaultDict(OrderedDict): def __init__(self, *args, **kwargs): if not args: self.default_factory = None else: if not (args[0] is None or callable(args[0])): raise TypeError('first argument must be callable or None') self.default_factory = args[0] args = args[1:] super(OrderedDefaultDict, self).__init__(*args, **kwargs) def __missing__(self, key): if self.default_factory is None: raise KeyError(key) self[key] = default = self.default_factory() return default if sys.platform == 'win32': import ctypes.wintypes # CSIDL_APPDATA for reference - not used here for compatibility with # dirspec, which uses LOCAL_APPDATA and COMMON_APPDATA in that order csidl = dict(CSIDL_APPDATA=26, CSIDL_LOCAL_APPDATA=28, CSIDL_COMMON_APPDATA=35) def get_path(name): SHGFP_TYPE_CURRENT = 0 buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH) ctypes.windll.shell32.SHGetFolderPathW(0, csidl[name], 0, SHGFP_TYPE_CURRENT, buf) return buf.value def save_config_path(*resource): appdata = get_path("CSIDL_LOCAL_APPDATA") path = os.path.join(appdata, *resource) if not os.path.isdir(path): os.makedirs(path) return path def load_config_paths(*resource): ids = ["CSIDL_LOCAL_APPDATA", "CSIDL_COMMON_APPDATA"] for id in ids: base = get_path(id) path = os.path.join(base, *resource) if os.path.exists(path): yield path else: def save_config_path(*resource): import xdg.BaseDirectory return xdg.BaseDirectory.save_config_path(*resource) def load_config_paths(*resource): import xdg.BaseDirectory return xdg.BaseDirectory.load_config_paths(*resource) def matches_requirement(req, wheels): """List of wheels matching a requirement. :param req: The requirement to satisfy :param wheels: List of wheels to search. """ try: from pkg_resources import Distribution, Requirement except ImportError: raise RuntimeError("Cannot use requirements without pkg_resources") req = Requirement.parse(req) selected = [] for wf in wheels: f = wf.parsed_filename dist = Distribution(project_name=f.group("name"), version=f.group("ver")) if dist in req: selected.append(wf) return selected