docstring formatting

This commit is contained in:
Rudi Grinberg 2012-11-16 12:31:10 -05:00
parent e22162cc87
commit 11214d754d
1 changed files with 17 additions and 28 deletions

View File

@ -11,11 +11,10 @@ class AirtimeDB(Loggable):
if reload_now: self.reload_directories() if reload_now: self.reload_directories()
def reload_directories(self): def reload_directories(self):
""" """ this is the 'real' constructor, should be called if you ever
this is the 'real' constructor, should be called if you ever want the want the class reinitialized. there's not much point to doing
class reinitialized. there's not much point to doing it yourself it yourself however, you should just create a new AirtimeDB
however, you should just create a new AirtimeDB instance. instance. """
"""
# dirs_setup is a dict with keys: # dirs_setup is a dict with keys:
# u'watched_dirs' and u'stor' which point to lists of corresponding # u'watched_dirs' and u'stor' which point to lists of corresponding
# dirs # dirs
@ -42,15 +41,11 @@ class AirtimeDB(Loggable):
dirs_setup[u'watched_dirs'] ]) dirs_setup[u'watched_dirs'] ])
def to_id(self, directory): def to_id(self, directory):
""" """ directory path -> id """
directory path -> id
"""
return self.dir_to_id[ directory ] return self.dir_to_id[ directory ]
def to_directory(self, dir_id): def to_directory(self, dir_id):
""" """ id -> directory path """
id -> directory path
"""
return self.id_to_dir[ dir_id ] return self.id_to_dir[ dir_id ]
def storage_path(self) : return self.base_storage def storage_path(self) : return self.base_storage
@ -60,37 +55,31 @@ class AirtimeDB(Loggable):
def recorded_path(self) : return self.storage_paths['recorded'] def recorded_path(self) : return self.storage_paths['recorded']
def list_watched(self): def list_watched(self):
""" """ returns all watched directories as a list """
returns all watched directories as a list
"""
return list(self.watched_directories) return list(self.watched_directories)
def list_storable_paths(self): def list_storable_paths(self):
""" """ returns a list of all the watched directories in the
returns a list of all the watched directories in the datatabase. datatabase. (Includes the imported directory and the recorded
(Includes the imported directory and the recorded directory) directory) """
"""
l = self.list_watched() l = self.list_watched()
l.append(self.import_path()) l.append(self.import_path())
l.append(self.recorded_path()) l.append(self.recorded_path())
return l return l
def dir_id_get_files(self, dir_id, all_files=True): def dir_id_get_files(self, dir_id, all_files=True):
""" """ Get all files in a directory with id dir_id """
Get all files in a directory with id dir_id
"""
base_dir = self.id_to_dir[ dir_id ] base_dir = self.id_to_dir[ dir_id ]
return set(( os.path.join(base_dir,p) for p in return set(( os.path.join(base_dir,p) for p in
self.apc.list_all_db_files( dir_id, all_files ) )) self.apc.list_all_db_files( dir_id, all_files ) ))
def directory_get_files(self, directory, all_files=True): def directory_get_files(self, directory, all_files=True):
""" """ returns all the files(recursively) in a directory. a
returns all the files(recursively) in a directory. a directory is an directory is an "actual" directory path instead of its id. This
"actual" directory path instead of its id. This is super hacky because is super hacky because you create one request for the recorded
you create one request for the recorded directory and one for the directory and one for the imported directory even though they're
imported directory even though they're the same dir in the database so the same dir in the database so you get files for both dirs in 1
you get files for both dirs in 1 request... request... """
"""
normal_dir = os.path.normpath(unicode(directory)) normal_dir = os.path.normpath(unicode(directory))
if normal_dir not in self.dir_to_id: if normal_dir not in self.dir_to_id:
raise NoDirectoryInAirtime( normal_dir, self.dir_to_id ) raise NoDirectoryInAirtime( normal_dir, self.dir_to_id )