Beispiel #1
0
    def set_folder_thumbnail(self, event_index, photo_index, verbose = False):
        """
        set_folder_thumbnail: change the thumbnail used for an event
        
        20130103/RB: started function
        
        INPUT:
        - event_index (int): index of the event in event_array. Use 'list_events' with 'show_photos = True' to find the correct index.
        - photo_index (int): index if the photo used for the thumbnail       
        
        OUTPUT:
        - True: success, False: the one of the indices does not exist.
        
        """
        
        try:
            HBFUN.verbose("set_folder_thumbnail, event: " + str(event_index) + " photo: " + str(photo_index), verbose)
            self.event_array[event_index].photo_array[photo_index]
        except IndexError:
            HBFUN.printError("Either the event_index or photo_index is incorrect", inspect.stack())
            return False
        
        self.event_array[event_index].event_thumb = photo_index

        self.save_events_in_csv(verbose)

        return True
Beispiel #2
0
    def check_event_exists(self, event_title, event_dir, verbose = False):
        """
        check_event_exists
        
        20130103/RB: started function
        
        INPUT:
        - 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 
        
        OUTPUT:
        - True: if it does not exist, False if it does exist
        """
        
        HBFUN.verbose("HBalbum/check_event_exists(): " + event_title + ", " + event_dir, verbose)
        
        ev_titles = []
        ev_dirs = []

        for i in range(len(self.event_array)):
            ev_titles.append(self.event_array[i].event_title)
            ev_dirs.append(self.event_array[i].event_dir)

        if event_title in ev_titles:
            HBFUN.printError("the event_title does already exist!", inspect.stack())
            return False
        elif event_dir in ev_dirs:
            HBFUN.printError("the event_dir does already exist!", inspect.stack())
            return False
        else:
            HBFUN.verbose("  HBalbum/check_event_exists(): event_title and event_dir do not yet exist", verbose)
            return True
Beispiel #3
0
 def make_folders(self, verbose = False):
     """
     make_folders: create the web-folders
     
     20130103/RB: started the function
     
     INPUT:
     None
     
     OUTPUT:
     - True: success, or False: failure
     """
     HBFUN.verbose("\nHBalbum/make_folders()", verbose)
     
     if self.album_path == self._default_source_path:
         HBFUN.printError("album_path and default_source_path are the same, this is not allowed!", inspect.stack())
         return False
     
     path = self.album_path + self.pics_dir
     HBFUN.check_and_make_folder(path, verbose)
     
     path = self.album_path + self.thumbs_dir
     HBFUN.check_and_make_folder(path, verbose)
     
     path = self.album_path + self.resources_dir
     HBFUN.check_and_make_folder(path, verbose)
             
     path = self.album_path + self.html_dir
     HBFUN.check_and_make_folder(path, verbose)  
     
     return True      
Beispiel #4
0
    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
Beispiel #5
0
    def disable_photo(self, event_index, photo_index, disable, verbose = False):
        """
        disable_photo: disable or enable an event. 
        
        20130103/RB: started function
        
        INPUT:
        - event_index (int): index of the event in event_array. Use 'list_events' to find the correct index.
        - disable (BOOL): True to disable, False to enable. If you try to re-disable an event, it will give a warning and continue
        
        OUTPUT:
        - True: success or False: failure
        
        """
        # use a bit of shorthand... sorry
        ev = self.event_array[event_index]
        ph = ev.photo_array[photo_index]
        
        if disable:
            dis = "disabled"
        else:
            dis = "enabled"
    
        HBFUN.verbose("HBalbum/disable_photo(): event " + ev.event_title + " photo " + ph.photo_filename + " to " + dis, verbose)
    
        if event_index > len(self.event_array):
            HBFUN.printError("The event index exceeds the length of the event_array", inspect.stack())
            return False

        if photo_index > len(ev.photo_array):
            HBFUN.printError("The photo_index exceeds the length of the photo_array", inspect.stack())
            return False

           
        if ph.disabled == disable:
            HBFUN.printWarning("Event " + ev.event_title + " photo " + ph.photo_filename + " is already " + dis, inspect.stack())

        HBFUN.verbose("  event_title: " + ev.event_title, verbose)
        HBFUN.verbose("  event_dir: " + ev.event_dir, verbose)           
        HBFUN.verbose("  photo_title: " + ph.photo_title, verbose)
        HBFUN.verbose("  photo_filename: " + ph.photo_filename, verbose)  
                
        ph.disabled = disable
        
        return True
Beispiel #6
0
    def disable_event(self, index, disable, verbose = False):
        """
        disable_event: disable or enable an event. 
        
        20130103/RB: started function
        
        INPUT:
        - index (int): index of the event in event_array. Use 'list_events' to find the correct index. If index is -1, it will affect all albums.
        - disable (BOOL): True to disable, False to enable. If you try to re-disable an event, it will give a warning and continue
        
        OUTPUT:
        - True: success or False: failure
        
        """
        
        ev = ev = self.event_array[index]
        
        if disable:
            dis = "disabled"
        else:
            dis = "enabled"

        HBFUN.verbose("HBalbum/disable_event(): index " + str(index) + " to " + dis, verbose)

        if index > len(self.event_array) or index < -1:
            HBFUN.printError("The index exceeds the length of the array", inspect.stack())
            return False
            
        if index == -1:
            HBFUN.verbose("  all events will be set to " + dis, verbose)
            for i in range(len(self.event_array)):
                ev.disabled = disable
        
        else:
            if ev.disabled == disable:
                HBFUN.printWarning("Event " + ev.event_title + " is already " + dis, inspect.stack())
            
            HBFUN.verbose("  event_title: " + ev.event_title, verbose)
            HBFUN.verbose("  event_dir: " + ev.event_dir, verbose)          
            ev.disabled = disable
        
        return True