Пример #1
0
 def _dict_for(self, song):
     d = {}
     for tag in SAVED_METATAGS + song.realkeys():
         val = song(tag)
         if val:
             if isinstance(val, basestring):
                 if tag in QUOTED_TAGS:
                     val = util.qdecode(val)
                 else:
                     val = util.fsdecode(val)
                 if not tag in SINGLETON_TAGS:
                     val = val.split("\n")
             d[tag] = val
     for tag, default in DEFAULTS.items():
         if not tag in song: song[tag] = default
     d["~path"] = d["~filename"].split(os.path.sep)
     # CouchDB doesn't like apostrophes in keys for some reason...
     d["_id"] = _id(song.key)
     return d
Пример #2
0
 def docs_beneath(self, path):
     path = util.qdecode(path).split(os.path.sep)
     return [row.value for row in self.db.view('_view/tree/by-path', startkey=path, endkey=path + [{}])]