forked from CommunityToolBox/ArseneWenger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (26 loc) · 1019 Bytes
/
Copy pathutils.py
File metadata and controls
30 lines (26 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
def getTimestamp():
"""
Utility function to get a nicely formatted timestamp
:return: Returns date and time in the following format "DD/MM [HH:MM]"
"""
dt = str(datetime.datetime.now().month) + '/' + str(datetime.datetime.now().day) + ' '
hr = str(datetime.datetime.now().hour) if len(str(datetime.datetime.now().hour)) > 1 else '0' + str(datetime.datetime.now().hour)
min = str(datetime.datetime.now().minute) if len(str(datetime.datetime.now().minute)) > 1 else '0' + str(datetime.datetime.now().minute)
t = '[' + hr + ':' + min + '] '
return dt + t
def clamp_int(value, minimum, maximum):
"""
Clamp integer between 2 values
:param value: Current value
:param minimum: Minimum value
:param maximum: Maximum value
:return: Current value, clamped to between min and max
"""
if value < minimum:
value = minimum
elif value > maximum:
value = maximum
return value