Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
# python3 compatibility code
i3s_time = i3s_time.decode()
except: # noqa e722
pass
# get datetime and time zone info
parts = i3s_time.split()
i3s_datetime = " ".join(parts[:2])
# occasionally we do not get the timezone name
if len(parts) < 3:
return True
else:
i3s_time_tz = parts[2]
date = datetime.strptime(i3s_datetime, TIME_FORMAT)
# calculate the time delta
utcnow = datetime.utcnow()
delta = datetime(
date.year, date.month, date.day, date.hour, date.minute
) - datetime(utcnow.year, utcnow.month, utcnow.day, utcnow.hour, utcnow.minute)
# create our custom timezone
try:
self.tz = Tz(i3s_time_tz, delta)
except ValueError:
return False
return True
config["order"].append(name)
add_container_items(name)
append_modules(name)
config[name] = remove_any_contained_modules(module)
config["on_click"] = on_click
config["i3s_modules"] = i3s_modules
config["py3_modules"] = py3_modules
config[".module_groups"] = module_groups
# time and tztime modules need a format for correct processing
for name in config:
if name.split()[0] in TIME_MODULES and "format" not in config[name]:
if name.split()[0] == "time":
config[name]["format"] = TIME_FORMAT
else:
config[name]["format"] = TZTIME_FORMAT
if not config["order"]:
notify_user(
"Your configuration file does not list any module"
' to be loaded with the "order" directive.'
)
return config
def set_time_format(self):
config = self.i3status.py3_config.get(self.module_name, {})
time_format = config.get("format", TIME_FORMAT)
# Handle format_time parameter if exists
# Not sure if i3status supports this but docs say it does
if "format_time" in config:
time_format = time_format.replace("%time", config["format_time"])
self.time_format = time_format