forked from upstream/IPod-Shuffle-4g
Safe file handling, closes #18
This commit is contained in:
parent
bcde228a62
commit
15b305739a
1 changed files with 4 additions and 6 deletions
10
shuffle.py
10
shuffle.py
|
|
@ -440,9 +440,8 @@ class Playlist(Record):
|
||||||
return fullPath
|
return fullPath
|
||||||
|
|
||||||
def populate(self, filename):
|
def populate(self, filename):
|
||||||
f = open(filename, "rb")
|
with open(filename, 'rb') as f:
|
||||||
data = f.readlines()
|
data = f.readlines()
|
||||||
f.close()
|
|
||||||
|
|
||||||
extension = os.path.splitext(filename)[1].lower()
|
extension = os.path.splitext(filename)[1].lower()
|
||||||
if extension == '.pls':
|
if extension == '.pls':
|
||||||
|
|
@ -529,9 +528,8 @@ class Shuffler(object):
|
||||||
self.lists.append(os.path.abspath(os.path.join(dirpath, filename)))
|
self.lists.append(os.path.abspath(os.path.join(dirpath, filename)))
|
||||||
|
|
||||||
def write_database(self):
|
def write_database(self):
|
||||||
f = open(os.path.join(self.base, "iPod_Control", "iTunes", "iTunesSD"), "wb")
|
with open(os.path.join(self.base, "iPod_Control", "iTunes", "iTunesSD"), "wb") as f:
|
||||||
f.write(self.tunessd.construct())
|
f.write(self.tunessd.construct())
|
||||||
f.close()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read all files from the directory
|
# Read all files from the directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue