Move generic saving / loading functions

These belong under path/
This commit is contained in:
Bryan Schumaker 2010-11-20 10:01:25 -05:00
parent 751af55575
commit 42948165a3
6 changed files with 15 additions and 13 deletions

View File

@ -1,7 +1,7 @@
# Bryan Schumaker (8/7/2010)
__all__ = [ "audio", "sources",
"data", "event", "map", "path", "plugin"]
"event", "map", "path", "plugin"]
__major__ = 1
__minor__ = 2

View File

@ -3,6 +3,7 @@
import os
import tagpy
import libsaria
import libsaria.path.files
import string
from track import Track
splitext = libsaria.path.splitext
@ -52,7 +53,7 @@ def load():
global index
global tracks
global sources
objects = libsaria.data.load("library", ".lib")
objects = libsaria.path.files.load("library", ".lib")
if objects == None or len(objects) != 5:
reset()
return
@ -61,7 +62,7 @@ def load():
def save():
global sources
libsaria.data.save( (sources, tracks, fs_tree, tag_tree, index),
libsaria.path.files.save( (sources, tracks, fs_tree, tag_tree, index),
"library", ".lib")
def walk():

View File

@ -3,6 +3,7 @@
import random as rand
import libsaria
import libsaria.path.files
from libsaria.sources import library
call = libsaria.event.call
@ -32,7 +33,7 @@ def load():
global song_list
global song_set
global visible
song_list = libsaria.data.load("playlist", ".list")
song_list = libsaria.path.files.load("playlist", ".list")
if song_list == None:
reset()
return

View File

@ -1,6 +1,6 @@
# Bryan Schumaker (11/06/2010)
from libsaria import data
from libsaria.path import files
from libsaria.path import sep
class Tree(dict):
@ -227,15 +227,15 @@ class PersPrefTree(PrefTree):
def init_pref(self, pref, value):
PrefTree.init_pref(self, pref, value)
if self.file != None:
data.save(self, self.file, ".tree")
files.save(self, self.file, ".tree")
def set_pref(self, pref, value):
PrefTree.set_pref(self, pref, value)
if self.file != None:
data.save(self, self.file, ".tree")
files.save(self, self.file, ".tree")
def get_pref_tree(file):
tree = data.load(file, ".tree")
tree = files.load(file, ".tree")
if tree == None:
tree = PersPrefTree(file)
return tree

View File

@ -3,7 +3,7 @@
import ocarina
libsaria = ocarina.libsaria
gtk = ocarina.gtk
data = None
files = None
TARGET_TYPE_URI_LIST = 80
@ -42,12 +42,12 @@ def resized(widget, geom):
def dnd_receive(widget, context, x, y, selection, type, time):
global data
if data == None:
from libsaria import data
global files
if files == None:
from libsaria.path import files
if type == TARGET_TYPE_URI_LIST:
uri = selection.data.strip('\r\n\x00')
import os
for file in uri.split():
file = file[7:]
data.universal_open(file)
files.universal_open(file)