Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
9c844fd7
Verified
Commit
9c844fd7
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: table json converter: timezone handling for datetime
parent
c8ea9f90
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!107
Release v0.11.0
,
!103
xlsx -> json conversion
Pipeline
#50705
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+11
-0
11 additions, 0 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
with
11 additions
and
0 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+
11
−
0
View file @
9c844fd7
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
from
__future__
import
annotations
from
__future__
import
annotations
import
datetime
import
pathlib
import
pathlib
from
types
import
SimpleNamespace
from
types
import
SimpleNamespace
from
typing
import
Any
,
Optional
,
TextIO
,
Union
from
typing
import
Any
,
Optional
,
TextIO
,
Union
...
@@ -155,6 +156,7 @@ class TemplateFiller:
...
@@ -155,6 +156,7 @@ class TemplateFiller:
def
_handle_data
(
self
,
data
:
dict
,
current_path
:
list
[
str
]
=
None
,
def
_handle_data
(
self
,
data
:
dict
,
current_path
:
list
[
str
]
=
None
,
context
:
TemplateFiller
.
Context
=
None
,
context
:
TemplateFiller
.
Context
=
None
,
only_collect_insertables
:
bool
=
False
,
only_collect_insertables
:
bool
=
False
,
utc
:
bool
=
False
,
)
->
Optional
[
dict
[
str
,
Any
]]:
)
->
Optional
[
dict
[
str
,
Any
]]:
"""
Handle the data and write it into ``workbook``.
"""
Handle the data and write it into ``workbook``.
...
@@ -176,6 +178,8 @@ context: TemplateFiller.Context, optional
...
@@ -176,6 +178,8 @@ context: TemplateFiller.Context, optional
only_collect_insertables: bool, optional
only_collect_insertables: bool, optional
If True, do not insert anything on this level, but return a dict with entries to be inserted.
If True, do not insert anything on this level, but return a dict with entries to be inserted.
utc: bool, optional
If True, store times as UTC. Else store as local time on a best-effort base.
Returns
Returns
-------
-------
...
@@ -233,6 +237,13 @@ out: union[dict, None]
...
@@ -233,6 +237,13 @@ out: union[dict, None]
value
=
content
[
0
]
value
=
content
[
0
]
if
isinstance
(
value
,
str
):
if
isinstance
(
value
,
str
):
value
=
ILLEGAL_CHARACTERS_RE
.
sub
(
""
,
value
)
value
=
ILLEGAL_CHARACTERS_RE
.
sub
(
""
,
value
)
if
isinstance
(
value
,
datetime
.
datetime
):
if
value
.
tzinfo
is
not
None
:
if
utc
:
value
=
value
.
astimezone
(
datetime
.
timezone
.
utc
).
replace
(
tzinfo
=
None
)
else
:
# Remove timezone, store in local timezone.
value
=
value
.
astimezone
().
replace
(
tzinfo
=
None
)
path_str
=
p2s
(
path
)
path_str
=
p2s
(
path
)
assert
path_str
not
in
insertables
assert
path_str
not
in
insertables
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment