def parse_cfg(cfgfile):
    """ Parses the configuration file.

    Args:
        cfgfile: The YOLOv3 configuration file.

    Returns:
        The list of blocks of the configuration file parsed.
    """

    # Opens the configuration file and read it removing unnecessary characters
    # like '\n' and '#'
    with open(cfgfile, 'r') as file:
        # Stores all the lines of the configuration file
        lines = [line.rstrip('\n') for line in file if line != '\n' and line[0] != '#']
    
    holder = {}
    blocks = []
    
    # Loops over lines reading every attribute and stores them in the blocks
    for line in lines:
        if line[0] == '[':
            line = 'type=' + line[1:-1].rstrip()
            
            if len(holder) != 0:
                blocks.append(holder)
                holder = {}
        
        key, value = line.split("=")
        holder[key.rstrip()] = value.lstrip()
    
    blocks.append(holder)

    return blocks