Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

hggtk/hglib: add Settings class to manage persistent app data

Changeset e0c29a31db58

Parent b4bf54ece7f9

by TK Soh

Changes to one file · Browse files at e0c29a31db58 Showing diff from parent b4bf54ece7f9 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​shlib.py Stacked
 
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@@ -11,6 +11,25 @@
 import shelve  import time   +class Settings(dict): + def __init__(self, key): + self.key = key + self.path = os.path.join(os.path.expanduser('~'), '.hgext', 'tortoisehg') + if not os.path.exists(os.path.dirname(self.path)): + os.makedirs(os.path.dirname(self.path)) + self.read() + + def read(self): + self.clear() + dbase = shelve.open(self.path) + self.update(dbase.get(self.key, {})) + dbase.close() + + def write(self): + dbase = shelve.open(self.path) + dbase[self.key] = self + dbase.close() +  def get_system_times():   t = os.times()   if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()