def __init__(self, album_title, album_path, default_source_path, verbose = False): """ __init__: start an album 20130103/RB: started the function INPUT: - album_title (str): title used for the site - album_path (str): the path with all the resized photos etc - default_source_path (str): the default path to the original photos OUTPUT: - True """ HBFUN.verbose("\nalbum/__init__", verbose) self.album_title = album_title # name of the album self._album_path = HBFUN.check_path(album_path, verbose) # path of the album self._default_source_path = HBFUN.check_path(default_source_path, verbose) self.events_csv_filename = "events" # default source of photos self._pics_dir = "pics/" # pictures self._thumbs_dir = "thumbs/" # thumbs self._resources_dir = "res/" # resources self._html_dir = "html/" # html self.event_array = [] # array with events self.make_folders(verbose)
def test_check_path(): print("HBtest/test_check_path()") verbose = True path = "fiets" out = HBFun.check_path(path, verbose) if out == "fiets/": print(" pass") else: print(" FAIL:", out) path = "/fiets" out = HBFun.check_path(path, verbose) if out == "fiets/": print(" pass") else: print(" FAIL:", out) path = "/Users/fiets" out = HBFun.check_path(path, verbose) if out == "/Users/fiets/": print(" pass") else: print(" FAIL:", out) path = "Users/fiets" out = HBFun.check_path(path, verbose) if out == "/Users/fiets/": print(" pass") else: print(" FAIL:", out)
def add_event(self, index, event_title, event_dir, event_dir_src = "", source_path = "", verbose = False): """ add_event: add an event to the album 20130103/RB: started the function INPUT: - index (int): position of the new album. Use 'list_events' to find the correct position. The newest event should have index = 0 - event_title (str): the title of the event. It usually has the format 'Some event (July 2012)' - event_dir (str): the directory name of the event on the web - event_dir_src (str, opt): if the source directory (with the original photos) has a different directory name - source_path (str, opt): is the source_path of the original photos is not the default. OUTPUT: - True: success or False: fail """ HBFUN.verbose("HBalbum/add_event(): " + str(index) + ", " + event_title + ", " + event_dir + ", " + source_path, verbose) # if no new source_path is given, use the default if source_path == "": source_path = self.default_source_path # if a new source_path is given, check for correctness else: source_path = HBFUN.check_path(source_path, verbose) if self.album_path == source_path: HBFUN.printError("album_path and source_path are the same, this is not allowed!", inspect.stack()) return False # check the event_dir event_dir = HBFUN.check_path(event_dir) # is the source event dir different? if event_dir_src == "": event_dir_src = event_dir else: event_dir_src = HBFUN.check_path(event_dir_src, verbose) # check if the source exists if HBFUN.check_path_exists(source_path + event_dir_src) == False: HBFUN.printError("The source path does not exist!", inspect.stack()) return False # check if the event already exists. If not, make it if self.check_event_exists(event_title, event_dir, verbose): ev = HBEV.event(event_title, event_dir, event_dir_src, self.album_title, self.album_path, source_path, self.pics_dir, self.thumbs_dir, self.resources_dir, self.html_dir, verbose) self.event_array.insert(index, ev) self.save_events_in_csv(verbose) return True
def thumbs_dir(self, path): self._thumbs_dir = HBFUN.check_path(path)
def pics_dir(self, path): self._pics_dir = HBFUN.check_path(path)
def default_source_path(self, path): self._default_source_path = HBFUN.check_path(path)
def album_path(self, path): self._album_path = HBFUN.check_path(path)
def html_dir(self, path): self._html_dir = HBFUN.check_path(path)
def resources_dir(self, path): self._resources_dir = HBFUN.check_path(path)