Changeset 567
- Timestamp:
- 02/24/07 20:50:46 (2 years ago)
- Files:
-
- trunk/Makefile.in (modified) (1 diff)
- trunk/src/mesk/log.py (modified) (1 diff)
- trunk/src/mesk/playlist/m3u.py (modified) (2 diffs)
- trunk/src/mesk/playlist/pls.py (modified) (2 diffs)
- trunk/src/mesk/playlist/xspf.py (modified) (3 diffs)
- trunk/src/playlist_control.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Makefile.in
r559 r567 144 144 -rm doc/mesk.1 145 145 -rm ./etc/mesk.desktop 146 -rm aclocal.m4 146 147 147 148 WIKI_README=http://trac.nicfit.net/wiki/Installation?format=txt trunk/src/mesk/log.py
r527 r567 41 41 def __init__(self, name): 42 42 logging.Logger.__init__(self, name) 43 self.format = ' %(name)s:[%(levelname)s]%(message)s'43 self.format = '[%(asctime)s][%(levelname)s]%(name)s: %(message)s' 44 44 45 45 self.console_handler = logging.StreamHandler() trunk/src/mesk/playlist/m3u.py
r536 r567 77 77 meta_artist = u'' 78 78 79 def save(pl_file, pl): 80 fp = file(pl_file, 'w') 81 79 def save(fp, pl): 82 80 fp.write('#EXTM3U\n') 83 81 for src in pl: … … 94 92 fp.write(str(uri)) 95 93 fp.write('\n') 96 fp.close()trunk/src/mesk/playlist/pls.py
r536 r567 64 64 pl.append(src) 65 65 66 def save(pl_path, pl): 67 fp = file(pl_path, 'w') 66 def save(fp, pl): 68 67 fp.write('[playlist]\n') 69 68 fp.write('Version=2\n') … … 84 83 85 84 count += 1 86 fp.close()trunk/src/mesk/playlist/xspf.py
r536 r567 79 79 mesk_elems = ext_elem.getElementsByTagNameNS(MESK_NS, 'browse-dir') 80 80 if mesk_elems: 81 browse_dir = _get_elem_text(mesk_elems[0])81 pl.browse_dir = _get_elem_text(mesk_elems[0]) 82 82 83 83 # Playlist queue indexes … … 139 139 pass 140 140 141 def save( pl_path, pl):141 def save(fp, pl): 142 142 import xml.sax.saxutils as saxutils 143 143 def pad(n): 144 144 return ' ' * n 145 145 146 fp = file(pl_path, 'w')147 146 # We are only serializing pl, so building a DOM would just waste time. 148 147 fp.write('<?xml version="1.0" encoding="UTF-8"?>\n') … … 219 218 fp.write(pad(indent) + '</trackList>\n') 220 219 fp.write('</playlist>\n') 221 fp.close()222 223 220 224 221 def _get_elem_text(elem): trunk/src/playlist_control.py
r558 r567 19 19 ################################################################################ 20 20 import os 21 import datetime 21 import datetime, tempfile, shutil 22 22 23 23 import gobject, gtk, gtk.gdk, gtk.glade … … 224 224 def _save_cb(): 225 225 self._pl_config.update() 226 mesk.playlist.xspf.save(mesk.uri.unescape(self._pl_config.uri.path), 227 self._playlist) 226 227 # Write to a tempfile to avoid corruptions on errors 228 (tmp_fd, tmp_filename) = tempfile.mkstemp() 229 temp_file = os.fdopen(tmp_fd, 'wb+') 230 mesk.playlist.xspf.save(temp_file, self._playlist) 231 temp_file.close() 232 # Move temp file over playlist 233 shutil.copyfile(tmp_filename, 234 mesk.uri.unescape(self._pl_config.uri.path)) 235 os.unlink(tmp_filename) 236 228 237 # XXX: For debugging 229 238 #self._debug_show_playlist() … … 1147 1156 buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, 1148 1157 gtk.STOCK_ADD, gtk.RESPONSE_OK) 1149 dialog = gtk.FileChooserDialog(title=_('Add Music'),1158 dialog = gtk.FileChooserDialog(title=_('Add Audio'), 1150 1159 action=gtk.FILE_CHOOSER_ACTION_OPEN, 1151 1160 buttons=buttons) … … 1414 1423 module = dialog.get_selected_type() 1415 1424 filename = dialog.get_filename() 1416 # Add an extension if none provided1425 # Add an extension if none specified 1417 1426 if not os.path.splitext(filename)[1]: 1418 1427 filename += module.EXTENSIONS[0] 1419 module.save(filename, self._playlist) 1428 1429 pl_file = file(filename, 'wb+') 1430 module.save(pl_file, self._playlist) 1431 pl_file.close() 1420 1432 1421 1433 self._set_status_msg(_('Playlist \'%s\' exported') % \
