salabim 24.0.8__py3-none-any.whl → 24.0.9__py3-none-any.whl
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.
- salabim/salabim.py +49 -20
- {salabim-24.0.8.dist-info → salabim-24.0.9.dist-info}/METADATA +1 -1
- {salabim-24.0.8.dist-info → salabim-24.0.9.dist-info}/RECORD +5 -5
- {salabim-24.0.8.dist-info → salabim-24.0.9.dist-info}/WHEEL +0 -0
- {salabim-24.0.8.dist-info → salabim-24.0.9.dist-info}/top_level.txt +0 -0
salabim/salabim.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# _ _ _ ____ _ _ ___ ___
|
2
|
-
# ___ __ _ | | __ _ | |__ (_) _ __ ___ |___ \ | || | / _ \
|
3
|
-
# / __| / _` || | / _` || '_ \ | || '_ ` _ \ __) || || |_ | | | |
|
4
|
-
# \__ \| (_| || || (_| || |_) || || | | | | | / __/ |__ _| _ | |_| | _ |
|
5
|
-
# |___/ \__,_||_| \__,_||_.__/ |_||_| |_| |_| |_____| |_| (_) \___/ (_)
|
2
|
+
# ___ __ _ | | __ _ | |__ (_) _ __ ___ |___ \ | || | / _ \ / _ \
|
3
|
+
# / __| / _` || | / _` || '_ \ | || '_ ` _ \ __) || || |_ | | | | | (_) |
|
4
|
+
# \__ \| (_| || || (_| || |_) || || | | | | | / __/ |__ _| _ | |_| | _ \__, |
|
5
|
+
# |___/ \__,_||_| \__,_||_.__/ |_||_| |_| |_| |_____| |_| (_) \___/ (_) /_/
|
6
6
|
# discrete event simulation
|
7
7
|
#
|
8
8
|
# see www.salabim.org for more information, the documentation and license information
|
9
9
|
|
10
|
-
__version__ = "24.0.
|
10
|
+
__version__ = "24.0.9"
|
11
11
|
|
12
12
|
import heapq
|
13
13
|
import random
|
@@ -42,6 +42,7 @@ import datetime
|
|
42
42
|
import urllib.request
|
43
43
|
import urllib.error
|
44
44
|
import base64
|
45
|
+
import zipfile
|
45
46
|
|
46
47
|
from pathlib import Path
|
47
48
|
|
@@ -71,8 +72,7 @@ def a_log(*args):
|
|
71
72
|
print(*args, file=a_logfile)
|
72
73
|
|
73
74
|
|
74
|
-
class g:
|
75
|
-
...
|
75
|
+
class g: ...
|
76
76
|
|
77
77
|
|
78
78
|
if PythonInExcel:
|
@@ -3384,7 +3384,6 @@ class _StateMonitor(Monitor):
|
|
3384
3384
|
self.parent.set(value)
|
3385
3385
|
|
3386
3386
|
|
3387
|
-
|
3388
3387
|
class _SystemMonitor(Monitor):
|
3389
3388
|
@property
|
3390
3389
|
def value(self) -> Any:
|
@@ -3444,6 +3443,10 @@ class DynamicClass:
|
|
3444
3443
|
if callable(c):
|
3445
3444
|
if inspect.isfunction(c):
|
3446
3445
|
nargs = c.__code__.co_argcount
|
3446
|
+
if c.__defaults__ is not None:
|
3447
|
+
c.__defaults__ = tuple(self if x == object else x for x in c.__defaults__) # indicate that object refers to animation object itself
|
3448
|
+
nargs -= len(c.__defaults__)
|
3449
|
+
|
3447
3450
|
if nargs == 0:
|
3448
3451
|
return lambda t: c()
|
3449
3452
|
if nargs == 1:
|
@@ -3456,7 +3459,7 @@ class DynamicClass:
|
|
3456
3459
|
def getattribute_spec(self, attr):
|
3457
3460
|
"""
|
3458
3461
|
special version of getattribute.
|
3459
|
-
When it's dynamic it will return the value in case of a
|
3462
|
+
When it's dynamic it will return the value in case of a constant or a parameterless function
|
3460
3463
|
Used only in AnimateCombined
|
3461
3464
|
"""
|
3462
3465
|
|
@@ -8323,7 +8326,6 @@ by adding:
|
|
8323
8326
|
|
8324
8327
|
for store in to_stores:
|
8325
8328
|
self.enter(store._to_store_requesters)
|
8326
|
-
|
8327
8329
|
self.status._value = requesting
|
8328
8330
|
self._to_store_item = item
|
8329
8331
|
self._to_store_priority = priority
|
@@ -9017,7 +9019,7 @@ by adding:
|
|
9017
9019
|
self.status._value = waiting
|
9018
9020
|
self._reschedule(scheduled_time, schedule_priority, urgent, "wait", cap_now)
|
9019
9021
|
else:
|
9020
|
-
return
|
9022
|
+
return # ***
|
9021
9023
|
if self.env._yieldless:
|
9022
9024
|
if self is self.env._current_component:
|
9023
9025
|
self.env._glet.switch()
|
@@ -10244,12 +10246,12 @@ class Environment:
|
|
10244
10246
|
|
10245
10247
|
self.an_clocktext()
|
10246
10248
|
|
10247
|
-
ap_parameters= [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
|
10248
|
-
ap_kwargs={}
|
10249
|
-
for k,v in list(kwargs.items()):
|
10249
|
+
ap_parameters = [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
|
10250
|
+
ap_kwargs = {}
|
10251
|
+
for k, v in list(kwargs.items()):
|
10250
10252
|
if k in ap_parameters:
|
10251
|
-
del kwargs[k]
|
10252
|
-
ap_kwargs[k]=v
|
10253
|
+
del kwargs[k]
|
10254
|
+
ap_kwargs[k] = v
|
10253
10255
|
if ap_kwargs:
|
10254
10256
|
self.animation_parameters(**ap_kwargs)
|
10255
10257
|
|
@@ -15651,6 +15653,12 @@ class Animate:
|
|
15651
15653
|
|
15652
15654
|
This may be either a filename or a PIL image
|
15653
15655
|
|
15656
|
+
if image is a string consisting of a zipfile-name, a bar (|) and a filename,
|
15657
|
+
the given filename will be read from the specified zip archive, e.g
|
15658
|
+
|
15659
|
+
sim.AnimateImage(image="cars.zip|bmw.png")
|
15660
|
+
|
15661
|
+
|
15654
15662
|
text : str, tuple or list
|
15655
15663
|
the text to be displayed
|
15656
15664
|
|
@@ -16191,6 +16199,11 @@ class Animate:
|
|
16191
16199
|
|
16192
16200
|
This may be either a filename or a PIL image (default see below)
|
16193
16201
|
|
16202
|
+
if image is a string consisting of a zipfile-name, a bar (|) and a filename,
|
16203
|
+
the given filename will be read from the specified zip archive, e.g
|
16204
|
+
|
16205
|
+
sim.AnimateImage(image="cars.zip|bmw.png")
|
16206
|
+
|
16194
16207
|
text : str
|
16195
16208
|
the text to be displayed (default see below)
|
16196
16209
|
|
@@ -19352,6 +19365,11 @@ class AnimateImage(Animate2dBase):
|
|
19352
19365
|
if used as function or method or in direct assigmnent,
|
19353
19366
|
the image should be a file containing an image or a PIL image
|
19354
19367
|
|
19368
|
+
if image is a string consisting of a zipfile-name, a bar (|) and a filename,
|
19369
|
+
the given filename will be read from the specified zip archive, e.g
|
19370
|
+
|
19371
|
+
sim.AnimateImage(image="cars.zip|bmw.png")
|
19372
|
+
|
19355
19373
|
x : float
|
19356
19374
|
position of anchor point (default 0)
|
19357
19375
|
|
@@ -26680,7 +26698,7 @@ class ImageContainer:
|
|
26680
26698
|
can_animate(try_only=True) # to load PIL
|
26681
26699
|
|
26682
26700
|
if isinstance(spec, (str, Path)):
|
26683
|
-
spec=str(spec) # to process Path correctly
|
26701
|
+
spec = str(spec) # to process Path correctly
|
26684
26702
|
|
26685
26703
|
if spec == "":
|
26686
26704
|
im = Image.new("RGBA", (1, 1), (0, 0, 0, 0))
|
@@ -26703,7 +26721,18 @@ class ImageContainer:
|
|
26703
26721
|
except Exception as e:
|
26704
26722
|
raise FileNotFoundError(f"could not open URL {spec}: {e}")
|
26705
26723
|
else:
|
26706
|
-
|
26724
|
+
if "|" in spec:
|
26725
|
+
zip_part, image_part = spec.split("|")
|
26726
|
+
zip_part = zip_part.strip()
|
26727
|
+
if zip_part.lower().endswith(".zip"):
|
26728
|
+
image_part = image_part.strip()
|
26729
|
+
with zipfile.ZipFile(zip_part) as ziphandle:
|
26730
|
+
image_data = ziphandle.read(image_part)
|
26731
|
+
im = Image.open(io.BytesIO(image_data))
|
26732
|
+
else:
|
26733
|
+
im = Image.open(spec)
|
26734
|
+
else:
|
26735
|
+
im = Image.open(spec)
|
26707
26736
|
else: # it's a PIL Image, for sure
|
26708
26737
|
im = spec
|
26709
26738
|
|
@@ -27090,8 +27119,7 @@ class redirect_stdout:
|
|
27090
27119
|
self.mode = mode
|
27091
27120
|
sys.stdout = self
|
27092
27121
|
|
27093
|
-
def __enter__(self):
|
27094
|
-
...
|
27122
|
+
def __enter__(self): ...
|
27095
27123
|
|
27096
27124
|
def close(self):
|
27097
27125
|
self.flush()
|
@@ -27119,6 +27147,7 @@ reset()
|
|
27119
27147
|
set_environment_aliases()
|
27120
27148
|
|
27121
27149
|
if __name__ == "__main__":
|
27150
|
+
|
27122
27151
|
sys.path.insert(0, str(Path(__file__).parent / ".." / "misc"))
|
27123
27152
|
try:
|
27124
27153
|
import salabim_exp
|
@@ -3,8 +3,8 @@ salabim/LICENSE.txt,sha256=qHlBa-POyexatCxDTjSKMlYtkBFQDn9lu-YV_1L6V0U,1106
|
|
3
3
|
salabim/__init__.py,sha256=r7qPLvlmX0dkZDyjuTo8Jo3ex3sD1L4pmK6K5ib9vyw,56
|
4
4
|
salabim/calibri.ttf,sha256=RWpf8Uo31RfvGGNaSt9-2sXSuN87AVE_NFMRsV3LhBk,1330156
|
5
5
|
salabim/mplus-1m-regular.ttf,sha256=EuFHr90BJjuAn_r5MleJFN-WfkeWJ4tf7DweI5zr8tU,289812
|
6
|
-
salabim/salabim.py,sha256=
|
7
|
-
salabim-24.0.
|
8
|
-
salabim-24.0.
|
9
|
-
salabim-24.0.
|
10
|
-
salabim-24.0.
|
6
|
+
salabim/salabim.py,sha256=QCmOEMNNgJ_TSkFMZhzXLQrVWL3VajLzgoDF5joM6dk,1096190
|
7
|
+
salabim-24.0.9.dist-info/METADATA,sha256=1x4DIhVpOpk3qkAPccvsgezV3xXVFbhFf-eOajz2rsc,3449
|
8
|
+
salabim-24.0.9.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
9
|
+
salabim-24.0.9.dist-info/top_level.txt,sha256=UE6zVlbi3F6T5ma1a_5TrojMaF21GYKDt9svvm0U4cQ,8
|
10
|
+
salabim-24.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|