Commit b0463caa805f54ff6e78eb9c0331d207b7d092fe
1 parent
e0376d66
Exists in
master
and in
6 other branches
STYLE: Renamed invdir to tempdir
Showing
1 changed file
with
11 additions
and
11 deletions
Show diff stats
invesalius/session.py
@@ -37,10 +37,10 @@ class Session(object): | @@ -37,10 +37,10 @@ class Session(object): | ||
37 | 37 | ||
38 | # InVesalius default projects' directory | 38 | # InVesalius default projects' directory |
39 | homedir = self.homedir = os.path.expanduser('~') | 39 | homedir = self.homedir = os.path.expanduser('~') |
40 | - invdir = os.path.join(homedir, ".invesalius", "temp") | ||
41 | - if not os.path.isdir(invdir): | ||
42 | - os.makedirs(invdir) | ||
43 | - self.invdir = invdir | 40 | + tempdir = os.path.join(homedir, ".invesalius", "temp") |
41 | + if not os.path.isdir(tempdir): | ||
42 | + os.makedirs(tempdir) | ||
43 | + self.tempdir = tempdir | ||
44 | 44 | ||
45 | # GUI language | 45 | # GUI language |
46 | self.language = "" # "pt_BR", "es" | 46 | self.language = "" # "pt_BR", "es" |
@@ -75,10 +75,10 @@ class Session(object): | @@ -75,10 +75,10 @@ class Session(object): | ||
75 | def CreateProject(self, filename): | 75 | def CreateProject(self, filename): |
76 | print "-- CreateProject" | 76 | print "-- CreateProject" |
77 | # Set session info | 77 | # Set session info |
78 | - self.project_path = (self.invdir, filename) | 78 | + self.project_path = (self.tempdir, filename) |
79 | self.project_status = const.PROJ_NEW | 79 | self.project_status = const.PROJ_NEW |
80 | self.temp_item = True | 80 | self.temp_item = True |
81 | - return self.invdir | 81 | + return self.tempdir |
82 | 82 | ||
83 | def OpenProject(self, filepath): | 83 | def OpenProject(self, filepath): |
84 | print "-- OpenProject" | 84 | print "-- OpenProject" |
@@ -116,12 +116,12 @@ class Session(object): | @@ -116,12 +116,12 @@ class Session(object): | ||
116 | 116 | ||
117 | def SavePlist(self): | 117 | def SavePlist(self): |
118 | filename = 'session.conf' | 118 | filename = 'session.conf' |
119 | - filepath = os.join(self.invdir, filename) | 119 | + filepath = os.join(self.tempdir, filename) |
120 | plistlib.writePlist(self.__dict__, filepath) | 120 | plistlib.writePlist(self.__dict__, filepath) |
121 | 121 | ||
122 | def OpenPlist(self): | 122 | def OpenPlist(self): |
123 | filename = 'session.conf' | 123 | filename = 'session.conf' |
124 | - filepath = os.join(self.invdir, filename) | 124 | + filepath = os.join(self.tempdir, filename) |
125 | # TODO: try/except | 125 | # TODO: try/except |
126 | dict = plistlib.readPlist(main_plist) | 126 | dict = plistlib.readPlist(main_plist) |
127 | for key in dict: | 127 | for key in dict: |
@@ -146,9 +146,9 @@ class Session(object): | @@ -146,9 +146,9 @@ class Session(object): | ||
146 | self.language = config.get('session','language') | 146 | self.language = config.get('session','language') |
147 | self.recent_projects = eval(config.get('project','recent_projects')) | 147 | self.recent_projects = eval(config.get('project','recent_projects')) |
148 | self.homedir = config.get('paths','homedir') | 148 | self.homedir = config.get('paths','homedir') |
149 | - self.invdir = config.get('paths','invdir') | 149 | + self.tempdir = config.get('paths','tempdir') |
150 | return True | 150 | return True |
151 | - except(ConfigParser.NoSectionError): | 151 | + except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): |
152 | return False | 152 | return False |
153 | 153 | ||
154 | class WriteSession(Thread): | 154 | class WriteSession(Thread): |
@@ -181,7 +181,7 @@ class WriteSession(Thread): | @@ -181,7 +181,7 @@ class WriteSession(Thread): | ||
181 | 181 | ||
182 | config.add_section('paths') | 182 | config.add_section('paths') |
183 | config.set('paths','homedir',self.session.homedir) | 183 | config.set('paths','homedir',self.session.homedir) |
184 | - config.set('paths','invdir',self.session.invdir) | 184 | + config.set('paths','tempdir',self.session.tempdir) |
185 | path = os.path.join(self.session.homedir , | 185 | path = os.path.join(self.session.homedir , |
186 | '.invesalius', 'config.cfg') | 186 | '.invesalius', 'config.cfg') |
187 | configfile = open(path, 'wb') | 187 | configfile = open(path, 'wb') |