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