salabim 24.0.7__py3-none-any.whl → 24.0.9__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
salabim/salabim.py CHANGED
@@ -1,13 +1,13 @@
1
- # _ _ _ ____ _ _ ___ _____
2
- # ___ __ _ | | __ _ | |__ (_) _ __ ___ |___ \ | || | / _ \ |___ |
3
- # / __| / _` || | / _` || '_ \ | || '_ ` _ \ __) || || |_ | | | | / /
4
- # \__ \| (_| || || (_| || |_) || || | | | | | / __/ |__ _| _ | |_| | _ / /
5
- # |___/ \__,_||_| \__,_||_.__/ |_||_| |_| |_| |_____| |_| (_) \___/ (_) /_/
1
+ # _ _ _ ____ _ _ ___ ___
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.7"
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 constan or a parameterless function
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,6 +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:
9022
+ return # ***
9020
9023
  if self.env._yieldless:
9021
9024
  if self is self.env._current_component:
9022
9025
  self.env._glet.switch()
@@ -10243,12 +10246,12 @@ class Environment:
10243
10246
 
10244
10247
  self.an_clocktext()
10245
10248
 
10246
- ap_parameters= [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
10247
- ap_kwargs={}
10248
- 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()):
10249
10252
  if k in ap_parameters:
10250
- del kwargs[k]
10251
- ap_kwargs[k]=v
10253
+ del kwargs[k]
10254
+ ap_kwargs[k] = v
10252
10255
  if ap_kwargs:
10253
10256
  self.animation_parameters(**ap_kwargs)
10254
10257
 
@@ -15650,6 +15653,12 @@ class Animate:
15650
15653
 
15651
15654
  This may be either a filename or a PIL image
15652
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
+
15653
15662
  text : str, tuple or list
15654
15663
  the text to be displayed
15655
15664
 
@@ -16190,6 +16199,11 @@ class Animate:
16190
16199
 
16191
16200
  This may be either a filename or a PIL image (default see below)
16192
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
+
16193
16207
  text : str
16194
16208
  the text to be displayed (default see below)
16195
16209
 
@@ -19351,6 +19365,11 @@ class AnimateImage(Animate2dBase):
19351
19365
  if used as function or method or in direct assigmnent,
19352
19366
  the image should be a file containing an image or a PIL image
19353
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
+
19354
19373
  x : float
19355
19374
  position of anchor point (default 0)
19356
19375
 
@@ -26679,7 +26698,7 @@ class ImageContainer:
26679
26698
  can_animate(try_only=True) # to load PIL
26680
26699
 
26681
26700
  if isinstance(spec, (str, Path)):
26682
- spec=str(spec) # to process Path correctly
26701
+ spec = str(spec) # to process Path correctly
26683
26702
 
26684
26703
  if spec == "":
26685
26704
  im = Image.new("RGBA", (1, 1), (0, 0, 0, 0))
@@ -26702,7 +26721,18 @@ class ImageContainer:
26702
26721
  except Exception as e:
26703
26722
  raise FileNotFoundError(f"could not open URL {spec}: {e}")
26704
26723
  else:
26705
- im = Image.open(spec)
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)
26706
26736
  else: # it's a PIL Image, for sure
26707
26737
  im = spec
26708
26738
 
@@ -27089,8 +27119,7 @@ class redirect_stdout:
27089
27119
  self.mode = mode
27090
27120
  sys.stdout = self
27091
27121
 
27092
- def __enter__(self):
27093
- ...
27122
+ def __enter__(self): ...
27094
27123
 
27095
27124
  def close(self):
27096
27125
  self.flush()
@@ -27118,6 +27147,7 @@ reset()
27118
27147
  set_environment_aliases()
27119
27148
 
27120
27149
  if __name__ == "__main__":
27150
+
27121
27151
  sys.path.insert(0, str(Path(__file__).parent / ".." / "misc"))
27122
27152
  try:
27123
27153
  import salabim_exp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.7
3
+ Version: 24.0.9
4
4
  Summary: salabim - discrete event simulation in Python
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://salabim.org
@@ -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=4Us0WVX4WgUAFPJHhqhqNy4KIbvUVT8y6OzARNKxcdY,1094652
7
- salabim-24.0.7.dist-info/METADATA,sha256=WPcaUjh7FP9IU0rPz0LhpjadyuclSJ3nppG4jV5NMhs,3449
8
- salabim-24.0.7.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
9
- salabim-24.0.7.dist-info/top_level.txt,sha256=UE6zVlbi3F6T5ma1a_5TrojMaF21GYKDt9svvm0U4cQ,8
10
- salabim-24.0.7.dist-info/RECORD,,
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,,