handle.py 699 B

1234567891011121314151617181920212223242526272829303132
  1. # Purpose: handle module
  2. # Created: 11.03.2011
  3. # Copyright (c) 2011-2018, Manfred Moitzi
  4. # License: MIT License
  5. class HandleGenerator:
  6. def __init__(self, start_value: str = '1'):
  7. self._handle = int(start_value, 16)
  8. reset = __init__
  9. def __str__(self):
  10. return "%X" % self._handle
  11. def next(self) -> str:
  12. next_handle = str(self)
  13. self._handle += 1
  14. return next_handle
  15. __next__ = next
  16. class ImageKeyGenerator(HandleGenerator):
  17. def __str__(self):
  18. return "Image%05d" % self._handle
  19. class UnderlayKeyGenerator(HandleGenerator):
  20. def __str__(self):
  21. return "Underlay%05d" % self._handle