Skip to content

Commit

Permalink
simple fix
Browse files Browse the repository at this point in the history
  • Loading branch information
walchko committed Aug 27, 2023
1 parent 3254ac3 commit e19fbcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "the_collector"
version = "2023.08.13"
version = "2023.08.26"
description = "A library to store data in common formats"
authors = ["walchko <walchko@users.noreply.github.com>"]
readme = "readme.md"
Expand All @@ -23,14 +23,10 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.10"
# numpy = { version = "*", optional = true }

[tool.poetry.dev-dependencies]
pytest = "*"

# [tool.poetry.extras]
# numpy = ["numpy"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
21 changes: 12 additions & 9 deletions the_collector/ver_2/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,25 @@ def write(self, fname, data, info=None):
data: list of sampled data
info: optional dictonary providing useful info about data
"""
if not isinstance(data,list):
try:
data = data.tolist()
except:
print("*** data needs to be a list ***")
return
# if not isinstance(data,list):
# try:
# data = data.tolist()
# except:
# print("*** data needs to be a list ***")
# return

if info is None:
info = {}

info["timestamp"] = str(dt.datetime.now().isoformat())
save = {"info": info, "data": data}

# print(">>", fname)

p = self.__set_name(fname)
suffix = p.suffix
fname = str(p)
# print(suffix, fname)
# print(">>",suffix, fname)
# return

match suffix:
Expand Down Expand Up @@ -110,15 +112,16 @@ def write(self, fname, data, info=None):
with gzip.open(fname, 'wt', encoding="ascii") as fd:
json.dump(save, fd)

print(f"Saving {len(data)} data points in {fmt} to:\n--> {fname}")
print(f"Saving data points in {fmt} to:\n--> {fname}")
return fname

def __set_name(self, fname):
p = Path(fname)
# print(">>", p.name, str(p))
ts = "/"
if self.timestamp:
ts += dt.datetime.today().isoformat(sep='_', timespec='seconds') + "_"
ts = ts.replace(':','.')
ts = ts.replace(':','-')
fname = str(p.parent) + ts + str(p.name)
p = Path(fname)
return p
Expand Down

0 comments on commit e19fbcb

Please sign in to comment.