Assigned filename to variable to deduplicate calculation
This commit is contained in:
parent
cc4b936076
commit
6f158afd15
@ -438,9 +438,10 @@ class Room(object):
|
|||||||
def writeToFile(self):
|
def writeToFile(self):
|
||||||
if not self.isPermanent():
|
if not self.isPermanent():
|
||||||
return
|
return
|
||||||
|
filename = os.path.join(self._roomsDir, self.sanitizeFilename(self._name)+'.room')
|
||||||
if len(self._playlist) == 0:
|
if len(self._playlist) == 0:
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(self._roomsDir, self.sanitizeFilename(self._name)+'.room'))
|
os.remove(filename)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
@ -450,7 +451,7 @@ class Room(object):
|
|||||||
data['playlistIndex'] = self._playlistIndex
|
data['playlistIndex'] = self._playlistIndex
|
||||||
data['position'] = self._position
|
data['position'] = self._position
|
||||||
data['lastSavedUpdate'] = self._lastSavedUpdate
|
data['lastSavedUpdate'] = self._lastSavedUpdate
|
||||||
with open(os.path.join(self._roomsDir, self.sanitizeFilename(self._name)+'.room'), "w") as outfile:
|
with open(filename, "w") as outfile:
|
||||||
json.dump(data, outfile)
|
json.dump(data, outfile)
|
||||||
|
|
||||||
def loadFromFile(self, filename):
|
def loadFromFile(self, filename):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user