|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing some common utility functions for the pysvn package. |
|
8 """ |
|
9 |
|
10 import sys |
|
11 import os |
|
12 |
|
13 from PyQt4.QtCore import QDateTime, Qt |
|
14 |
|
15 import Utilities |
|
16 |
|
17 def formatTime(seconds): |
|
18 """ |
|
19 Module function to return a formatted time string. |
|
20 |
|
21 @param seconds time in seconds since epoch to be formatted (float or long) |
|
22 @return formatted time string (string) |
|
23 """ |
|
24 return QDateTime.fromTime_t(long(seconds))\ |
|
25 .toTimeSpec(Qt.LocalTime)\ |
|
26 .toString("yyyy-MM-dd hh:mm:ss") |
|
27 |
|
28 def dateFromTime_t(seconds): |
|
29 """ |
|
30 Module function to return the date. |
|
31 |
|
32 @param seconds time in seconds since epoch to be formatted (float or long) |
|
33 @return date (QDate) |
|
34 """ |
|
35 return QDateTime.fromTime_t(long(seconds)).toTimeSpec(Qt.LocalTime).date() |
|
36 |
|
37 def getServersPath(): |
|
38 """ |
|
39 Public method to get the filename of the servers file. |
|
40 |
|
41 @return filename of the servers file (string) |
|
42 """ |
|
43 if Utilities.isWindowsPlatform(): |
|
44 appdata = os.environ["APPDATA"] |
|
45 return os.path.join(appdata, "Subversion", "servers") |
|
46 else: |
|
47 homedir = Utilities.getHomeDir() |
|
48 return os.path.join(homedir, ".subversion", "servers") |
|
49 |
|
50 def getConfigPath(): |
|
51 """ |
|
52 Public method to get the filename of the config file. |
|
53 |
|
54 @return filename of the config file (string) |
|
55 """ |
|
56 if Utilities.isWindowsPlatform(): |
|
57 appdata = os.environ["APPDATA"] |
|
58 return os.path.join(appdata, "Subversion", "config") |
|
59 else: |
|
60 homedir = Utilities.getHomeDir() |
|
61 return os.path.join(homedir, ".subversion", "config") |