enum.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # coding: utf-8
  2. """
  3. Author: Sten Vercamman
  4. Univeristy of Antwerp
  5. Example code for paper: Efficient model transformations for novices
  6. url: http://msdl.cs.mcgill.ca/people/hv/teaching/MSBDesign/projects/Sten.Vercammen
  7. The main goal of this code is to give an overview, and an understandable
  8. implementation, of known techniques for pattern matching and solving the
  9. sub-graph homomorphism problem. The presented techniques do not include
  10. performance adaptations/optimizations. It is not optimized to be efficient
  11. but rather for the ease of understanding the workings of the algorithms.
  12. The paper does list some possible extensions/optimizations.
  13. It is intended as a guideline, even for novices, and provides an in-depth look
  14. at the workings behind various techniques for efficient pattern matching.
  15. """
  16. class Enum(object):
  17. """
  18. Custom Enum object for compatibility (enum is introduced in python 3.4)
  19. Usage create : a = Enum(['e0', 'e1', ...])
  20. Usage call : a.e0
  21. """
  22. def __init__(self, args):
  23. next = 0
  24. for arg in args:
  25. self.__dict__[arg] = next
  26. next += 1