o
    }h                     @   s`   d dl Z d dlmZ d dlmZ d dlZdd Zdd Zdd	d
Zdd Z	de
de
fddZdS )    N)BytesIO)name_mapc                 C   s*   |  d}d|d  }|d t|| S )Nzfiles/   r   )splitr   get)s3_pathZs3_paths	file_path r	   8/home/cmiss/Jenkins/workspace/SPARC-API/app/utilities.pyget_path_from_mangled_list   s   
r   c                 C   s<   t  }| j|dd |d | }dt|  }|S )zQ
    Take in a Pillow image and convert it to a base64 string in PNG format.
    PNG)formatr   zdata:image/png;base64,)r   saveseekgetvaluebase64	b64encodedecode)imgbufferedZimg_byteZimg_strr	   r	   r
   img_to_base64_str   s   
r    c                 C   s   |   D ]J}t| |  t| | trt| | |d  qt| | trNt| d t| | rGt| | d trGt| | d |d  t| d qd S )Nz  [r   ])keysprint
isinstancedict
print_dictlistlen)dindentkr	   r	   r
   r      s   r   c                 C   s"   t d t| trt|  d S d S )Nzhit:)r   r   r   r   )hitr	   r	   r
   print_hit_structure'   s   
r%   filenamereturnc                 C   s   t j| \}}|S )z
    Extracts and returns the extension of a filename, including the leading dot.
    If the filename has no extension, returns an empty string.
    )ospathsplitext)r&   _extr	   r	   r
   get_extension,   s   r-   )r   )r   ior   Z"app.manifest_name_to_discover_namer   r(   r   r   r   r%   strr-   r	   r	   r	   r
   <module>   s    	
