mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
remove conditional code for old snakes (#11048)
* remove conditional code for old snakes * remove conditional code for old snakes * reformat * add changelog frag
This commit is contained in:
@@ -6,25 +6,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as _datetime
|
||||
import sys
|
||||
|
||||
|
||||
_USE_TIMEZONE = sys.version_info >= (3, 6)
|
||||
|
||||
|
||||
def ensure_timezone_info(value):
|
||||
if not _USE_TIMEZONE or value.tzinfo is not None:
|
||||
if value.tzinfo is not None:
|
||||
return value
|
||||
return value.astimezone(_datetime.timezone.utc)
|
||||
|
||||
|
||||
def fromtimestamp(value):
|
||||
if _USE_TIMEZONE:
|
||||
return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc)
|
||||
return _datetime.utcfromtimestamp(value)
|
||||
return _datetime.fromtimestamp(value, tz=_datetime.timezone.utc)
|
||||
|
||||
|
||||
def now():
|
||||
if _USE_TIMEZONE:
|
||||
return _datetime.datetime.now(tz=_datetime.timezone.utc)
|
||||
return _datetime.datetime.utcnow()
|
||||
return _datetime.datetime.now(tz=_datetime.timezone.utc)
|
||||
|
||||
@@ -145,7 +145,6 @@ configured:
|
||||
type: bool
|
||||
"""
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
from xml.etree import ElementTree as et
|
||||
|
||||
@@ -160,9 +159,6 @@ with deps.declare(
|
||||
import jenkins
|
||||
|
||||
|
||||
IS_PYTHON_2 = sys.version_info[0] <= 2
|
||||
|
||||
|
||||
class JenkinsNode:
|
||||
def __init__(self, module: AnsibleModule) -> None:
|
||||
self.module = module
|
||||
@@ -246,10 +242,7 @@ class JenkinsNode:
|
||||
configured = True
|
||||
|
||||
if configured:
|
||||
if IS_PYTHON_2:
|
||||
data = et.tostring(root)
|
||||
else:
|
||||
data = et.tostring(root, encoding="unicode")
|
||||
data = et.tostring(root, encoding="unicode")
|
||||
|
||||
self.instance.reconfig_node(self.name, data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user