18 |
18 |
19 |
19 |
20 def formatTime(seconds): |
20 def formatTime(seconds): |
21 """ |
21 """ |
22 Module function to return a formatted time string. |
22 Module function to return a formatted time string. |
23 |
23 |
24 @param seconds time in seconds since epoch to be formatted (float or long) |
24 @param seconds time in seconds since epoch to be formatted (float or long) |
25 @return formatted time string (string) |
25 @return formatted time string (string) |
26 """ |
26 """ |
27 return ( |
27 return ( |
28 QDateTime.fromSecsSinceEpoch(int(seconds)) |
28 QDateTime.fromSecsSinceEpoch(int(seconds)) |
32 |
32 |
33 |
33 |
34 def dateFromTime_t(seconds): |
34 def dateFromTime_t(seconds): |
35 """ |
35 """ |
36 Module function to return the date. |
36 Module function to return the date. |
37 |
37 |
38 @param seconds time in seconds since epoch to be formatted (float or long) |
38 @param seconds time in seconds since epoch to be formatted (float or long) |
39 @return date (QDate) |
39 @return date (QDate) |
40 """ |
40 """ |
41 return QDateTime.fromSecsSinceEpoch(int(seconds)).toTimeSpec( |
41 return ( |
42 Qt.TimeSpec.LocalTime).date() |
42 QDateTime.fromSecsSinceEpoch(int(seconds)) |
|
43 .toTimeSpec(Qt.TimeSpec.LocalTime) |
|
44 .date() |
|
45 ) |
43 |
46 |
44 |
47 |
45 def getServersPath(): |
48 def getServersPath(): |
46 """ |
49 """ |
47 Module function to get the filename of the servers file. |
50 Module function to get the filename of the servers file. |
48 |
51 |
49 @return filename of the servers file (string) |
52 @return filename of the servers file (string) |
50 """ |
53 """ |
51 if Utilities.isWindowsPlatform(): |
54 if Utilities.isWindowsPlatform(): |
52 appdata = os.environ["APPDATA"] |
55 appdata = os.environ["APPDATA"] |
53 return os.path.join(appdata, "Subversion", "servers") |
56 return os.path.join(appdata, "Subversion", "servers") |
57 |
60 |
58 |
61 |
59 def getConfigPath(): |
62 def getConfigPath(): |
60 """ |
63 """ |
61 Module function to get the filename of the config file. |
64 Module function to get the filename of the config file. |
62 |
65 |
63 @return filename of the config file (string) |
66 @return filename of the config file (string) |
64 """ |
67 """ |
65 if Utilities.isWindowsPlatform(): |
68 if Utilities.isWindowsPlatform(): |
66 appdata = os.environ["APPDATA"] |
69 appdata = os.environ["APPDATA"] |
67 return os.path.join(appdata, "Subversion", "config") |
70 return os.path.join(appdata, "Subversion", "config") |
89 try: |
92 try: |
90 with open(config, "r") as f: |
93 with open(config, "r") as f: |
91 configList = f.read().splitlines() |
94 configList = f.read().splitlines() |
92 except OSError: |
95 except OSError: |
93 return |
96 return |
94 |
97 |
95 newConfig = [] |
98 newConfig = [] |
96 ignoresFound = False |
99 ignoresFound = False |
97 amendList = [] |
100 amendList = [] |
98 for line in configList: |
101 for line in configList: |
99 if line.find("global-ignores") in [0, 2]: |
102 if line.find("global-ignores") in [0, 2]: |
119 for amend in oldAmends: |
122 for amend in oldAmends: |
120 if amend not in line: |
123 if amend not in line: |
121 amendList.append(amend) |
124 amendList.append(amend) |
122 else: |
125 else: |
123 newConfig.append(line) |
126 newConfig.append(line) |
124 |
127 |
125 if newConfig != configList: |
128 if newConfig != configList: |
126 with contextlib.suppress(OSError), open(config, "w") as f: |
129 with contextlib.suppress(OSError), open(config, "w") as f: |
127 f.write("\n".join(newConfig)) |
130 f.write("\n".join(newConfig)) |