Shared Memory Dictionary utilizing Posix IPC semaphores and shared memory segments and offering permanent disk storage of data if required.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

37 líneas
1.1KB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. __version__ = "2019.08.21.20.19"
  4. __version_info__ = tuple([int(num) for num in __version__.split(".")])
  5. if __name__ == "__main__":
  6. from datetime import datetime
  7. # Open this file in read plus write mode
  8. with open(__file__, "r+") as file:
  9. contents = ""
  10. # Calculate the version strings
  11. old_version = __version__
  12. new_version = datetime.utcnow().strftime("%Y.%m.%d.%H.%M")
  13. # Read through current file and replace
  14. # the old datetime stamp with the new
  15. # UTC datetime stamp
  16. for line in file.read().split("\n"):
  17. if line.startswith("__version__ = "):
  18. line = '__version__ = "{}"'.format(new_version)
  19. contents = "{}{}\n".format(contents, line)
  20. # Remove extraneous newline from end of contents
  21. contents = contents[:-1]
  22. # Seek back to the beginning of the file
  23. file.seek(0)
  24. # Erase the contents
  25. file.truncate()
  26. # Write the new contents
  27. file.write(contents)
  28. print("Changing version from {} to {}".format(old_version, new_version))