mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
Remove use of deprecated datetime.utcnow()
To fix warnings below: ``` <python-input-1>:1: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). ```
This commit is contained in:
@@ -72,9 +72,7 @@ class IfcExporter:
|
|||||||
|
|
||||||
def set_header(self):
|
def set_header(self):
|
||||||
self.file.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file)
|
self.file.header.file_name.name = os.path.basename(self.ifc_export_settings.output_file)
|
||||||
self.file.header.file_name.time_stamp = (
|
self.file.header.file_name.time_stamp = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat()
|
||||||
datetime.datetime.utcnow().replace(tzinfo=datetime.UTC).astimezone().replace(microsecond=0).isoformat()
|
|
||||||
)
|
|
||||||
self.file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
|
self.file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
|
||||||
self.file.header.file_name.originating_system = "{} {}".format(
|
self.file.header.file_name.originating_system = "{} {}".format(
|
||||||
self.get_application_name(), tool.Blender.get_bonsai_version()
|
self.get_application_name(), tool.Blender.get_bonsai_version()
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ def create_file(version: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4") -> ifcope
|
|||||||
"""
|
"""
|
||||||
file = ifcopenshell.file(schema=version)
|
file = ifcopenshell.file(schema=version)
|
||||||
file.header.file_name.name = "/dev/null" # Hehehe
|
file.header.file_name.name = "/dev/null" # Hehehe
|
||||||
file.header.file_name.time_stamp = (
|
file.header.file_name.time_stamp = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat()
|
||||||
datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
|
|
||||||
)
|
|
||||||
file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
|
file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
|
||||||
file.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
|
file.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
|
||||||
file.header.file_name.authorization = "Nobody"
|
file.header.file_name.authorization = "Nobody"
|
||||||
|
|||||||
@@ -57,13 +57,7 @@ class Patcher:
|
|||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
self.file.header.file_name.name = "Rabbit"
|
self.file.header.file_name.name = "Rabbit"
|
||||||
self.file.header.file_name.time_stamp = (
|
self.file.header.file_name.time_stamp = datetime.datetime.now().astimezone().replace(microsecond=0).isoformat()
|
||||||
datetime.datetime.utcnow()
|
|
||||||
.replace(tzinfo=datetime.timezone.utc)
|
|
||||||
.astimezone()
|
|
||||||
.replace(microsecond=0)
|
|
||||||
.isoformat()
|
|
||||||
)
|
|
||||||
self.file.header.file_name.preprocessor_version = "Rabbit"
|
self.file.header.file_name.preprocessor_version = "Rabbit"
|
||||||
self.file.header.file_name.originating_system = "Rabbit"
|
self.file.header.file_name.originating_system = "Rabbit"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
from database.neo4j import db
|
from database.neo4j import db
|
||||||
from fastapi import Depends, HTTPException, Security, status
|
from fastapi import Depends, HTTPException, Security, status
|
||||||
@@ -33,10 +33,8 @@ credentials_exception = HTTPException(
|
|||||||
|
|
||||||
def create_access_token(data: dict, expires_delta: timedelta | None = None):
|
def create_access_token(data: dict, expires_delta: timedelta | None = None):
|
||||||
payload = data.copy()
|
payload = data.copy()
|
||||||
if expires_delta:
|
expires_delta = expires_delta or timedelta(minutes=15)
|
||||||
expire = datetime.utcnow() + expires_delta
|
expire = datetime.now(timezone.utc) + expires_delta
|
||||||
else:
|
|
||||||
expire = datetime.utcnow() + timedelta(minutes=15)
|
|
||||||
payload.update({"expires": str(expire)})
|
payload.update({"expires": str(expire)})
|
||||||
encoded_jwt = jwt.encode(payload, secrets["security_secret_key"], algorithm=os.environ["SECURITY_ALGORITHM"])
|
encoded_jwt = jwt.encode(payload, secrets["security_secret_key"], algorithm=os.environ["SECURITY_ALGORITHM"])
|
||||||
return encoded_jwt
|
return encoded_jwt
|
||||||
|
|||||||
Reference in New Issue
Block a user