Jelajahi Sumber

move ISO_FORMAT to constants module

also: add ISO_FORMAT_NO_USECS
Thomas Waldmann 7 tahun lalu
induk
melakukan
1cb158a4b5
2 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 0
      src/borg/constants.py
  2. 0 2
      src/borg/testsuite/archiver.py

+ 6 - 0
src/borg/constants.py

@@ -66,6 +66,12 @@ EXIT_SUCCESS = 0  # everything done, no problems
 EXIT_WARNING = 1  # reached normal end of operation, but there were issues
 EXIT_ERROR = 2  # terminated abruptly, did not reach end of operation
 
+# never use datetime.isoformat(), it is evil. always use one of these:
+# datetime.strftime(ISO_FORMAT)  # output always includes .microseconds
+# datetime.strftime(ISO_FORMAT_NO_USECS)  # output never includes microseconds
+ISO_FORMAT_NO_USECS = '%Y-%m-%dT%H:%M:%S'
+ISO_FORMAT = ISO_FORMAT_NO_USECS + '.%f'
+
 DASHES = '-' * 78
 
 PBKDF2_ITERATIONS = 100000

+ 0 - 2
src/borg/testsuite/archiver.py

@@ -61,8 +61,6 @@ from . import key
 
 src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 
-ISO_FORMAT = '%Y-%m-%dT%H:%M:%S.%f'
-
 
 def exec_cmd(*args, archiver=None, fork=False, exe=None, input=b'', binary_output=False, **kw):
     if fork: