pystand 2.23__tar.gz → 2.24__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pystand-2.23/pystand.egg-info → pystand-2.24}/PKG-INFO +1 -1
- {pystand-2.23 → pystand-2.24/pystand.egg-info}/PKG-INFO +1 -1
- {pystand-2.23 → pystand-2.24}/pystand.py +56 -54
- {pystand-2.23 → pystand-2.24}/.gitignore +0 -0
- {pystand-2.23 → pystand-2.24}/README.md +0 -0
- {pystand-2.23 → pystand-2.24}/justfile +0 -0
- {pystand-2.23 → pystand-2.24}/pyproject.toml +0 -0
- {pystand-2.23 → pystand-2.24}/pystand.egg-info/SOURCES.txt +0 -0
- {pystand-2.23 → pystand-2.24}/pystand.egg-info/dependency_links.txt +0 -0
- {pystand-2.23 → pystand-2.24}/pystand.egg-info/entry_points.txt +0 -0
- {pystand-2.23 → pystand-2.24}/pystand.egg-info/requires.txt +0 -0
- {pystand-2.23 → pystand-2.24}/pystand.egg-info/top_level.txt +0 -0
- {pystand-2.23 → pystand-2.24}/setup.cfg +0 -0
|
@@ -18,7 +18,6 @@ import sys
|
|
|
18
18
|
import time
|
|
19
19
|
from collections import defaultdict
|
|
20
20
|
from collections.abc import Iterable, Iterator
|
|
21
|
-
from dataclasses import dataclass, field
|
|
22
21
|
from datetime import date, datetime
|
|
23
22
|
from pathlib import Path
|
|
24
23
|
from typing import Any
|
|
@@ -71,14 +70,45 @@ COLORS = [
|
|
|
71
70
|
]
|
|
72
71
|
|
|
73
72
|
|
|
74
|
-
@dataclass
|
|
75
73
|
class ColorTable:
|
|
76
|
-
|
|
77
|
-
table: dict[str, str] = field(default_factory=dict)
|
|
74
|
+
"Base class for color tables"
|
|
78
75
|
|
|
76
|
+
def __init__(self, initval: str, no_color: bool) -> None:
|
|
77
|
+
self.table = None if no_color else {self.parse_key(initval): COLORS[0]}
|
|
78
|
+
self.next = itertools.cycle(COLORS[1:-1])
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
def get_color(self, text: str) -> str:
|
|
81
|
+
"Assign a new color by cycling through the available colors"
|
|
82
|
+
if not self.table:
|
|
83
|
+
return text
|
|
84
|
+
|
|
85
|
+
if not (color := self.table.get(key := self.parse_key(text))):
|
|
86
|
+
self.table[key] = color = next(self.next)
|
|
87
|
+
|
|
88
|
+
return f'{color}{text}{COLORS[-1]}'
|
|
89
|
+
|
|
90
|
+
def parse_key(self, text: str) -> str:
|
|
91
|
+
"Parse text for color table key, default is full text"
|
|
92
|
+
return text
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class ColorRel(ColorTable):
|
|
96
|
+
"Return colored release version string"
|
|
97
|
+
|
|
98
|
+
def format(self, version: str, release: str) -> str:
|
|
99
|
+
"Return a formatted release version string"
|
|
100
|
+
return f'{version} @ {self.get_color(release)}'
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class ColorDist(ColorTable):
|
|
104
|
+
"Return colored distribution string"
|
|
105
|
+
|
|
106
|
+
def format(self, dist: str) -> str:
|
|
107
|
+
return f'distribution="{self.get_color(dist)}"'
|
|
108
|
+
|
|
109
|
+
def parse_key(self, text: str) -> str:
|
|
110
|
+
"Extract key for distribution color"
|
|
111
|
+
return text.split('-', 1)[0]
|
|
82
112
|
|
|
83
113
|
|
|
84
114
|
def is_admin() -> bool:
|
|
@@ -103,36 +133,6 @@ def get_version() -> str:
|
|
|
103
133
|
return ver
|
|
104
134
|
|
|
105
135
|
|
|
106
|
-
def fmtrel(version: str, release: str, args: Namespace) -> str:
|
|
107
|
-
"Return a formatted release version string"
|
|
108
|
-
if not args.no_color:
|
|
109
|
-
if release == args._release:
|
|
110
|
-
color = COLORS[0]
|
|
111
|
-
elif not (color := colors_rel.table.get(release)):
|
|
112
|
-
# Assign a new color for this release by cycling through the
|
|
113
|
-
# available colors.
|
|
114
|
-
colors_rel.table[release] = color = next(colors_rel.next)
|
|
115
|
-
|
|
116
|
-
release = f'{color}{release}{COLORS[-1]}'
|
|
117
|
-
|
|
118
|
-
return f'{version} @ {release}'
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def fmtdist(dist: str, args: Namespace) -> str:
|
|
122
|
-
"Return a formatted distribution string"
|
|
123
|
-
if not args.no_color:
|
|
124
|
-
if dist == args._distribution:
|
|
125
|
-
color = COLORS[0]
|
|
126
|
-
elif not (color := colors_dist.table.get(dist)):
|
|
127
|
-
# Assign a new color for this distribution by cycling through the
|
|
128
|
-
# available colors.
|
|
129
|
-
colors_dist.table[dist] = color = next(colors_dist.next)
|
|
130
|
-
|
|
131
|
-
dist = f'{color}{dist}{COLORS[-1]}'
|
|
132
|
-
|
|
133
|
-
return f'distribution="{dist}"'
|
|
134
|
-
|
|
135
|
-
|
|
136
136
|
def get_json(file: Path) -> dict[str, Any]:
|
|
137
137
|
from json import load
|
|
138
138
|
|
|
@@ -838,6 +838,7 @@ def main() -> str | None:
|
|
|
838
838
|
|
|
839
839
|
args._implementation = 'cpython' # at the moment, only support CPython
|
|
840
840
|
args._distribution = distribution
|
|
841
|
+
args._fmtdist = ColorDist(distribution, args.no_color).format
|
|
841
842
|
args._data = f'{PROG}.json'
|
|
842
843
|
|
|
843
844
|
args._versions = prefix_dir
|
|
@@ -855,6 +856,7 @@ def main() -> str | None:
|
|
|
855
856
|
try:
|
|
856
857
|
with locks[0].acquire(blocking=False), locks[1].acquire(blocking=False):
|
|
857
858
|
args._release = get_release_tag(args)
|
|
859
|
+
args._fmtrel = ColorRel(args._release, args.no_color).format
|
|
858
860
|
result = args.func(args)
|
|
859
861
|
purge_unused_releases(args)
|
|
860
862
|
update_version_symlinks(args)
|
|
@@ -944,7 +946,7 @@ class install_:
|
|
|
944
946
|
for version in args.version:
|
|
945
947
|
full_version = matcher.match(version)
|
|
946
948
|
if not full_version:
|
|
947
|
-
return f'Version {
|
|
949
|
+
return f'Version {args._fmtrel(version, release)} not found.'
|
|
948
950
|
|
|
949
951
|
version = full_version
|
|
950
952
|
vdir = args._versions / version
|
|
@@ -956,7 +958,7 @@ class install_:
|
|
|
956
958
|
if error := install(args, vdir, release, args._distribution, files):
|
|
957
959
|
return error
|
|
958
960
|
|
|
959
|
-
print(f'Version {
|
|
961
|
+
print(f'Version {args._fmtrel(version, release)} installed.')
|
|
960
962
|
|
|
961
963
|
|
|
962
964
|
# COMMAND
|
|
@@ -1018,9 +1020,9 @@ class update_:
|
|
|
1018
1020
|
|
|
1019
1021
|
if nextver == version and args.keep and release:
|
|
1020
1022
|
print(
|
|
1021
|
-
f'Error: {
|
|
1022
|
-
f'if update to {
|
|
1023
|
-
f'{
|
|
1023
|
+
f'Error: {args._fmtrel(version, release)} would not be kept '
|
|
1024
|
+
f'if update to {args._fmtrel(nextver, release_target)} '
|
|
1025
|
+
f'{args._fmtdist(distribution)}',
|
|
1024
1026
|
file=sys.stderr,
|
|
1025
1027
|
)
|
|
1026
1028
|
continue
|
|
@@ -1030,9 +1032,9 @@ class update_:
|
|
|
1030
1032
|
continue
|
|
1031
1033
|
|
|
1032
1034
|
print(
|
|
1033
|
-
f'{
|
|
1034
|
-
f'{
|
|
1035
|
-
f'{
|
|
1035
|
+
f'{args._fmtrel(version, release)} updating to '
|
|
1036
|
+
f'{args._fmtrel(nextver, release_target)} '
|
|
1037
|
+
f'{args._fmtdist(distribution)} ..'
|
|
1036
1038
|
)
|
|
1037
1039
|
|
|
1038
1040
|
# If the source was originally included, then include it in
|
|
@@ -1084,7 +1086,7 @@ class remove_:
|
|
|
1084
1086
|
release = get_json(dfile).get('release') or '?'
|
|
1085
1087
|
if not release_del or release == release_del:
|
|
1086
1088
|
remove(args, version)
|
|
1087
|
-
print(f'Version {
|
|
1089
|
+
print(f'Version {args._fmtrel(version, release)} removed.')
|
|
1088
1090
|
|
|
1089
1091
|
|
|
1090
1092
|
# COMMAND
|
|
@@ -1147,7 +1149,7 @@ class list_:
|
|
|
1147
1149
|
)
|
|
1148
1150
|
app = (
|
|
1149
1151
|
f' not eligible for '
|
|
1150
|
-
f'update because {
|
|
1152
|
+
f'update because {args._fmtrel(nextver, nrelease)} '
|
|
1151
1153
|
'is already installed.'
|
|
1152
1154
|
)
|
|
1153
1155
|
else:
|
|
@@ -1155,19 +1157,19 @@ class list_:
|
|
|
1155
1157
|
# this same distribution anymore
|
|
1156
1158
|
if nextver and distribution in files.get(nextver, {}):
|
|
1157
1159
|
upd = (
|
|
1158
|
-
f' updatable to {
|
|
1160
|
+
f' updatable to {args._fmtrel(nextver, release_target)}'
|
|
1159
1161
|
)
|
|
1160
1162
|
elif args.verbose:
|
|
1161
1163
|
app = (
|
|
1162
1164
|
' not eligible for update because '
|
|
1163
|
-
f'{
|
|
1164
|
-
f'not provide {
|
|
1165
|
+
f'{args._fmtrel(nextver, release_target)} does '
|
|
1166
|
+
f'not provide {args._fmtdist(distribution)}.'
|
|
1165
1167
|
)
|
|
1166
1168
|
|
|
1167
1169
|
if release:
|
|
1168
1170
|
print(
|
|
1169
|
-
f'{
|
|
1170
|
-
f'{
|
|
1171
|
+
f'{args._fmtrel(version, release)}{upd} '
|
|
1172
|
+
f'{args._fmtdist(distribution)}{app}'
|
|
1171
1173
|
)
|
|
1172
1174
|
|
|
1173
1175
|
|
|
@@ -1239,12 +1241,12 @@ class show_:
|
|
|
1239
1241
|
args.re_match, f'{version}+{distribution}'
|
|
1240
1242
|
):
|
|
1241
1243
|
print(
|
|
1242
|
-
f'{
|
|
1243
|
-
f'{
|
|
1244
|
+
f'{args._fmtrel(version, release)} '
|
|
1245
|
+
f'{args._fmtdist(distribution)}{app}'
|
|
1244
1246
|
)
|
|
1245
1247
|
if not installable:
|
|
1246
1248
|
print(
|
|
1247
|
-
f'Warning: no {
|
|
1249
|
+
f'Warning: no {args._fmtdist(args._distribution)} '
|
|
1248
1250
|
f'versions found in release "{release}".'
|
|
1249
1251
|
)
|
|
1250
1252
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|