lib/transient.py
def log_it(self, keyword, overwrite=False, *args, **kargs):
        """
        Generate log entry for analysis_log.
            creates a key with given key in analysis_log, making it:
                - boolean if no other args or kargs are given, flips previous values written in log
                - list if *args are passed
                - dictionary if **kargs are passed
            if overwrite is False, it appends values on previous logs,
            if True, it obviously overwrites them.
            :param key: string with name of analysis function used
            :type overwrite: bool
        """

        # key_string = 'analysis_log[' + key + ']'

        # make the right type of entry for the log
        if kargs or args:
            if kargs:  # make a dictionary of parameters passed
                entry = {}
                for key in kargs:
                    entry[key] = kargs[key]
            if args:  # make a lsit of parameter passed
                entry = []
            for arg in args:
                entry.append(arg)
        else:  # make None to trigger boolean behaviour
            entry = None
        # Check if previous logs with this key and eventually overwrite/append
        # the new entry.
        try:
            # prev = getattr(self, key_string)
            previous_value = self.analysis_log[keyword]
            # if it finds such a key in this library, it overwrites/appends new information.
            if entry == None:  # trigger boolean behaviour, flipping previous registered status if available
                self.analysis_log[keyword] = not previous_value

            elif entry is list:
                if overwrite:
                    self.analysis_log[keyword] = entry
                    # setattr(self, key_string, previous_value + entry)
                else:
                    entry = previous_value.append(entry)
                    self.analysis_log[keyword] = entry
            elif entry is dict:
                if overwrite:
                    self.analysis_log[keyword] = entry
                else:
                    new_entry = {}
                    for key in entry:
                        if key in previous_value:
                            new_entry[key] = previous_value[key].append(entry[key])
                        else:
                            new_entry[key] = entry[key]

                    self.analysis_log[keyword] = new_entry
        except KeyError:  # rises Key error when key was not previously assigned -> no previous record of this analysis
            if entry == None:  # if boolean, its it's first usage, therefore set it to true
                self.analysis_log[keyword] = True
            else:  # otherwise just append the list/dictionary.
                self.analysis_log[keyword] = entry

        Generate log entry for analysis_log.
            creates a key with given key in analysis_log, making it:
                - boolean if no other args or kargs are given, flips previous values written in log
                - list if *args are passed
                - dictionary if **kargs are passed
            if overwrite is False, it appends values on previous logs,
            if True, it obviously overwrites them.
            :param key: string with name of analysis function used
            :type overwrite: bool
        
Generate log entry for analysis_log.
creates a key with given key in analysis_log, making it:
boolean if no other args or kargs are given, flips previous values written in log
list if *args are passed
dictionary if **kargs are passed
if overwrite is False, it appends values on previous logs,
if True, it obviously overwrites them.
:param key: string with name of analysis function used
:type overwrite: bool
Generate log entry for analysis_log . creates a key with given key in analysis_log making it : boolean if no other args or kargs are given flips previous values written in log list if * args are passed dictionary if ** kargs are passed if overwrite is False it appends values on previous logs if True it obviously overwrites them . : param key : string with name of analysis function used : type overwrite : bool
def log_it(self, keyword, overwrite=False, *args, **kargs):
        if kargs or args:
            if kargs:  
                entry = {}
                for key in kargs:
                    entry[key] = kargs[key]
            if args:  
                entry = []
            for arg in args:
                entry.append(arg)
        else:  
            entry = None
        try:
            previous_value = self.analysis_log[keyword]
            if entry == None:  
                self.analysis_log[keyword] = not previous_value
            elif entry is list:
                if overwrite:
                    self.analysis_log[keyword] = entry
                else:
                    entry = previous_value.append(entry)
                    self.analysis_log[keyword] = entry
            elif entry is dict:
                if overwrite:
                    self.analysis_log[keyword] = entry
                else:
                    new_entry = {}
                    for key in entry:
                        if key in previous_value:
                            new_entry[key] = previous_value[key].append(entry[key])
                        else:
                            new_entry[key] = entry[key]
                    self.analysis_log[keyword] = new_entry
        except KeyError:  
            if entry == None:  
                self.analysis_log[keyword] = True
            else:  
                self.analysis_log[keyword] = entry
def log_it ( self , keyword , overwrite = False , * args , ** kargs ) : if kargs or args : if kargs : entry = { } for key in kargs : entry [ key ] = kargs [ key ] if args : entry = [ ] for arg in args : entry . append ( arg ) else : entry = None try : previous_value = self . analysis_log [ keyword ] if entry == None : self . analysis_log [ keyword ] = not previous_value elif entry is list : if overwrite : self . analysis_log [ keyword ] = entry else : entry = previous_value . append ( entry ) self . analysis_log [ keyword ] = entry elif entry is dict : if overwrite : self . analysis_log [ keyword ] = entry else : new_entry = { } for key in entry : if key in previous_value : new_entry [ key ] = previous_value [ key ] . append ( entry [ key ] ) else : new_entry [ key ] = entry [ key ] self . analysis_log [ keyword ] = new_entry except KeyError : if entry == None : self . analysis_log [ keyword ] = True else : self . analysis_log [ keyword ] = entry
Generate log entry for analysis_log.
Generate log entry for analysis_log .
"""
        Generate log entry for analysis_log.
            creates a key with given key in analysis_log, making it:
                - boolean if no other args or kargs are given, flips previous values written in log
                - list if *args are passed
                - dictionary if **kargs are passed
            if overwrite is False, it appends values on previous logs,
            if True, it obviously overwrites them.
            :param key: string with name of analysis function used
            :type overwrite: bool
        """ # key_string = 'analysis_log[' + key + ']' # make the right type of entry for the log # make a dictionary of parameters passed # make a lsit of parameter passed # make None to trigger boolean behaviour # Check if previous logs with this key and eventually overwrite/append # the new entry. # prev = getattr(self, key_string) # if it finds such a key in this library, it overwrites/appends new information. # trigger boolean behaviour, flipping previous registered status if available # setattr(self, key_string, previous_value + entry) # rises Key error when key was not previously assigned -> no previous record of this analysis # if boolean, its it's first usage, therefore set it to true # otherwise just append the list/dictionary.
self
keyword
overwrite