salabim 24.0.8__tar.gz → 24.0.9.post0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. {salabim-24.0.8 → salabim-24.0.9.post0}/PKG-INFO +3 -3
  2. {salabim-24.0.8 → salabim-24.0.9.post0}/README.md +2 -2
  3. {salabim-24.0.8 → salabim-24.0.9.post0}/pyproject.toml +1 -1
  4. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/salabim.py +54 -22
  5. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim.egg-info/PKG-INFO +3 -3
  6. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/DejaVuSansMono.ttf +0 -0
  7. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/LICENSE.txt +0 -0
  8. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/__init__.py +0 -0
  9. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/calibri.ttf +0 -0
  10. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim/mplus-1m-regular.ttf +0 -0
  11. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim.egg-info/SOURCES.txt +0 -0
  12. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim.egg-info/dependency_links.txt +0 -0
  13. {salabim-24.0.8 → salabim-24.0.9.post0}/salabim.egg-info/top_level.txt +0 -0
  14. {salabim-24.0.8 → salabim-24.0.9.post0}/setup.cfg +0 -0
  15. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test salabim.py +0 -0
  16. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_cap_now.py +0 -0
  17. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_componentgenerator.py +0 -0
  18. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_datetime.py +0 -0
  19. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_distributions.py +0 -0
  20. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_misc.py +0 -0
  21. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_monitor.py +0 -0
  22. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_process.py +0 -0
  23. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_queue.py +0 -0
  24. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_state.py +0 -0
  25. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_store.py +0 -0
  26. {salabim-24.0.8 → salabim-24.0.9.post0}/tests/test_timeunit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.8
3
+ Version: 24.0.9.post0
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
@@ -46,11 +46,11 @@ In contrast to some other Python DES packages, salabim does not require the use
46
46
  ### Features and documentation
47
47
 
48
48
  - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
49
- - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
49
+ - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
50
50
 
51
51
  ### Resources
52
52
 
53
- The salabim package can be found on GitHub: www.github.com/salabim/salabim
53
+ The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
54
54
 
55
55
  And on PyPI: https://pypi.org/project/salabim/
56
56
 
@@ -33,11 +33,11 @@ In contrast to some other Python DES packages, salabim does not require the use
33
33
  ### Features and documentation
34
34
 
35
35
  - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
36
- - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
36
+ - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
37
37
 
38
38
  ### Resources
39
39
 
40
- The salabim package can be found on GitHub: www.github.com/salabim/salabim
40
+ The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
41
41
 
42
42
  And on PyPI: https://pypi.org/project/salabim/
43
43
 
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com"}
9
9
  ]
10
10
  description = "salabim - discrete event simulation in Python"
11
- version = "24.0.8"
11
+ version = "24.0.9-0"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.7"
14
14
  dependencies = [
@@ -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.8"
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
 
@@ -3469,6 +3472,9 @@ class DynamicClass:
3469
3472
  if callable(c):
3470
3473
  if inspect.isfunction(c):
3471
3474
  nargs = c.__code__.co_argcount
3475
+ if c.__defaults__ is not None:
3476
+ c.__defaults__ = tuple(self if x == object else x for x in c.__defaults__) # indicate that object refers to animation object itself
3477
+ nargs -= len(c.__defaults__)
3472
3478
  if nargs == 0:
3473
3479
  return c()
3474
3480
  if nargs == 1:
@@ -8323,7 +8329,6 @@ by adding:
8323
8329
 
8324
8330
  for store in to_stores:
8325
8331
  self.enter(store._to_store_requesters)
8326
-
8327
8332
  self.status._value = requesting
8328
8333
  self._to_store_item = item
8329
8334
  self._to_store_priority = priority
@@ -9017,7 +9022,7 @@ by adding:
9017
9022
  self.status._value = waiting
9018
9023
  self._reschedule(scheduled_time, schedule_priority, urgent, "wait", cap_now)
9019
9024
  else:
9020
- return # ***
9025
+ return # ***
9021
9026
  if self.env._yieldless:
9022
9027
  if self is self.env._current_component:
9023
9028
  self.env._glet.switch()
@@ -10244,12 +10249,12 @@ class Environment:
10244
10249
 
10245
10250
  self.an_clocktext()
10246
10251
 
10247
- ap_parameters= [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
10248
- ap_kwargs={}
10249
- for k,v in list(kwargs.items()):
10252
+ ap_parameters = [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
10253
+ ap_kwargs = {}
10254
+ for k, v in list(kwargs.items()):
10250
10255
  if k in ap_parameters:
10251
- del kwargs[k]
10252
- ap_kwargs[k]=v
10256
+ del kwargs[k]
10257
+ ap_kwargs[k] = v
10253
10258
  if ap_kwargs:
10254
10259
  self.animation_parameters(**ap_kwargs)
10255
10260
 
@@ -14099,7 +14104,7 @@ class Environment:
14099
14104
 
14100
14105
  also the legend for line numbers will be printed
14101
14106
 
14102
- not that the header is only printed if trace=True
14107
+ note that the header is only printed if trace=True
14103
14108
  """
14104
14109
  len_s1 = len(self.time_to_str(0))
14105
14110
  self.print_trace((len_s1 - 4) * " " + "time", "current component", "action", "information", "" if PythonInExcel else "line#")
@@ -14847,7 +14852,7 @@ class Animate2dBase(DynamicClass):
14847
14852
 
14848
14853
  self.env = g.default_env if env is None else env
14849
14854
  self.sequence = self.env.serialize()
14850
- self.arg = self if arg is None else arg
14855
+ self.arg = self if arg in (None, object) else arg
14851
14856
  self.over3d = _default_over3d if over3d is None else over3d
14852
14857
  self.screen_coordinates = screen_coordinates
14853
14858
  self.attached_to = attached_to
@@ -15651,6 +15656,12 @@ class Animate:
15651
15656
 
15652
15657
  This may be either a filename or a PIL image
15653
15658
 
15659
+ if image is a string consisting of a zipfile-name, a bar (|) and a filename,
15660
+ the given filename will be read from the specified zip archive, e.g
15661
+
15662
+ sim.AnimateImage(image="cars.zip|bmw.png")
15663
+
15664
+
15654
15665
  text : str, tuple or list
15655
15666
  the text to be displayed
15656
15667
 
@@ -16191,6 +16202,11 @@ class Animate:
16191
16202
 
16192
16203
  This may be either a filename or a PIL image (default see below)
16193
16204
 
16205
+ if image is a string consisting of a zipfile-name, a bar (|) and a filename,
16206
+ the given filename will be read from the specified zip archive, e.g
16207
+
16208
+ sim.AnimateImage(image="cars.zip|bmw.png")
16209
+
16194
16210
  text : str
16195
16211
  the text to be displayed (default see below)
16196
16212
 
@@ -19352,6 +19368,11 @@ class AnimateImage(Animate2dBase):
19352
19368
  if used as function or method or in direct assigmnent,
19353
19369
  the image should be a file containing an image or a PIL image
19354
19370
 
19371
+ if image is a string consisting of a zipfile-name, a bar (|) and a filename,
19372
+ the given filename will be read from the specified zip archive, e.g
19373
+
19374
+ sim.AnimateImage(image="cars.zip|bmw.png")
19375
+
19355
19376
  x : float
19356
19377
  position of anchor point (default 0)
19357
19378
 
@@ -26680,7 +26701,7 @@ class ImageContainer:
26680
26701
  can_animate(try_only=True) # to load PIL
26681
26702
 
26682
26703
  if isinstance(spec, (str, Path)):
26683
- spec=str(spec) # to process Path correctly
26704
+ spec = str(spec) # to process Path correctly
26684
26705
 
26685
26706
  if spec == "":
26686
26707
  im = Image.new("RGBA", (1, 1), (0, 0, 0, 0))
@@ -26703,7 +26724,18 @@ class ImageContainer:
26703
26724
  except Exception as e:
26704
26725
  raise FileNotFoundError(f"could not open URL {spec}: {e}")
26705
26726
  else:
26706
- im = Image.open(spec)
26727
+ if "|" in spec:
26728
+ zip_part, image_part = spec.split("|")
26729
+ zip_part = zip_part.strip()
26730
+ if zip_part.lower().endswith(".zip"):
26731
+ image_part = image_part.strip()
26732
+ with zipfile.ZipFile(zip_part) as ziphandle:
26733
+ image_data = ziphandle.read(image_part)
26734
+ im = Image.open(io.BytesIO(image_data))
26735
+ else:
26736
+ im = Image.open(spec)
26737
+ else:
26738
+ im = Image.open(spec)
26707
26739
  else: # it's a PIL Image, for sure
26708
26740
  im = spec
26709
26741
 
@@ -27090,8 +27122,7 @@ class redirect_stdout:
27090
27122
  self.mode = mode
27091
27123
  sys.stdout = self
27092
27124
 
27093
- def __enter__(self):
27094
- ...
27125
+ def __enter__(self): ...
27095
27126
 
27096
27127
  def close(self):
27097
27128
  self.flush()
@@ -27119,6 +27150,7 @@ reset()
27119
27150
  set_environment_aliases()
27120
27151
 
27121
27152
  if __name__ == "__main__":
27153
+
27122
27154
  sys.path.insert(0, str(Path(__file__).parent / ".." / "misc"))
27123
27155
  try:
27124
27156
  import salabim_exp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.8
3
+ Version: 24.0.9.post0
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
@@ -46,11 +46,11 @@ In contrast to some other Python DES packages, salabim does not require the use
46
46
  ### Features and documentation
47
47
 
48
48
  - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
49
- - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
49
+ - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
50
50
 
51
51
  ### Resources
52
52
 
53
- The salabim package can be found on GitHub: www.github.com/salabim/salabim
53
+ The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
54
54
 
55
55
  And on PyPI: https://pypi.org/project/salabim/
56
56
 
File without changes