avoid inconsistencies
This commit is contained in:
parent
db09ca37e6
commit
95e45ab073
|
@ -2,7 +2,6 @@ import re
|
|||
import fnmatch
|
||||
import os
|
||||
import copy
|
||||
import datetime
|
||||
import xml.etree.ElementTree as ET # noqa
|
||||
import xml.dom.minidom
|
||||
import functools
|
||||
|
@ -1471,9 +1470,8 @@ class Result:
|
|||
path = '/'.join(['/',increment[0],ty[0],x,field[0]])
|
||||
h5_dataset = f[path].create_dataset(r['label'],data=result1)
|
||||
|
||||
now = datetime.datetime.now().astimezone()
|
||||
h5_dataset.attrs['created'] = now.strftime('%Y-%m-%d %H:%M:%S%z') if h5py3 else \
|
||||
now.strftime('%Y-%m-%d %H:%M:%S%z').encode()
|
||||
h5_dataset.attrs['created'] = util.time_stamp() if h5py3 else \
|
||||
util.time_stamp().encode()
|
||||
|
||||
for l,v in r['meta'].items():
|
||||
h5_dataset.attrs[l.lower()]=v.encode() if not h5py3 and type(v) is str else v
|
||||
|
@ -1558,9 +1556,8 @@ class Result:
|
|||
compression_opts = 6 if compress else None,
|
||||
shuffle=True,fletcher32=True)
|
||||
|
||||
now = datetime.datetime.now().astimezone()
|
||||
dataset.attrs['created'] = now.strftime('%Y-%m-%d %H:%M:%S%z') if h5py3 else \
|
||||
now.strftime('%Y-%m-%d %H:%M:%S%z').encode()
|
||||
dataset.attrs['created'] = util.time_stamp() if h5py3 else \
|
||||
util.time_stamp().encode()
|
||||
|
||||
for l,v in result['meta'].items():
|
||||
dataset.attrs[l.lower()]=v.encode() if not h5py3 and type(v) is str else v
|
||||
|
|
|
@ -214,13 +214,15 @@ def open_text(fname: _FileHandle,
|
|||
return fname if not isinstance(fname, (str,_Path)) else \
|
||||
open(_Path(fname).expanduser(),mode,newline=('\n' if mode == 'w' else None))
|
||||
|
||||
def time_stamp() -> str:
|
||||
"""Timestamp the execution of a (function within a) class."""
|
||||
return _datetime.datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S%z')
|
||||
|
||||
def execution_stamp(class_name: str,
|
||||
function_name: _Optional[str] = None) -> str:
|
||||
"""Timestamp the execution of a (function within a) class."""
|
||||
now = _datetime.datetime.now().astimezone().strftime('%Y-%m-%d %H:%M:%S%z')
|
||||
_function_name = '' if function_name is None else f'.{function_name}'
|
||||
return f'damask.{class_name}{_function_name} v{_version} ({now})'
|
||||
return f'damask.{class_name}{_function_name} v{_version} ({time_stamp()})'
|
||||
|
||||
|
||||
def natural_sort(key: str) -> _List[_Union[int, str]]:
|
||||
|
|
Loading…
Reference in New Issue