diff options
author | kali <kali@leap.se> | 2013-07-17 06:01:03 +0900 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-07-17 20:02:05 +0200 |
commit | f79633b942f2ae5ee844cc4f2e17c0f338e4ba3c (patch) | |
tree | ec3c1e93098da770b0fde6ada1ab044d2a65c4d1 /src/leap/util/__init__.py | |
parent | bff9af8d446d23d73cc900e591a77e2e020683c4 (diff) |
fix locking for raising window
Diffstat (limited to 'src/leap/util/__init__.py')
-rw-r--r-- | src/leap/util/__init__.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/leap/util/__init__.py b/src/leap/util/__init__.py index 5ceaede5..93eb714d 100644 --- a/src/leap/util/__init__.py +++ b/src/leap/util/__init__.py @@ -15,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ -Initializes version and app info +Initializes version and app info, plus some small and handy functions. """ +import datetime +import os __version__ = "unknown" try: @@ -47,3 +49,29 @@ def first(things): return things[0] except TypeError: return None + + +def get_modification_ts(path): + """ + Gets modification time of a file. + + :param path: the path to get ts from + :type path: str + :returns: modification time + :rtype: datetime object + """ + ts = os.path.getmtime(path) + return datetime.datetime.fromtimestamp(ts) + + +def update_modification_ts(path): + """ + Sets modification time of a file to current time. + + :param path: the path to set ts to. + :type path: str + :returns: modification time + :rtype: datetime object + """ + os.utime(path, None) + return get_modification_ts(path) |