o
    sg!                     @   s   d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ G dd dZG dd dZG dd dZG dd dZG dd dZdS )z  Slide layout for the pptx file     N)RGBColor)PP_ALIGN)Inches)DefaultSettingsSlideWorkArea)SlideCreator)PublicComparables)format_for_table)
parsed_urlc                	   @   B   e Zd ZdZ			ddedededdfdd	Zd
d Zdd Z	dS )
SideBySidezDefining layout A and BTN	work_areaslide_contentresearchreturnc	           	      C   N   || _ || _|d | _|d | _|| _td| _t|||| j| j |d| _d S )Nleft_hand_sideright_hand_side      ?conduct_research_flagclientprs_slide_objr   )	ppt_slide_objectr   left_side_contentright_side_contentclient_configr   spacingr   
make_slide	selfr   r   r   projectslider   r   r    r#   F/var/www/html/XCapMarket/services/ppt_generator/layouts/xcm/layouts.py__init__      


zSideBySide.__init__c                 C   s>   | j j| j }|| j| jj| jj| jj| j d | jj	 dS zAdd left side content   N)
r   item_to_function_mappingr   r   r   topleftwidthr   heightr    slide_functionr#   r#   r$   	left_side0   s   zSideBySide.left_sidec                 C   sP   | j j| j }|| j| jj| jj| jj| j d  | jj| j d | jj	 dS zAdd right side contentr(   N)
r   r)   r   r   r   r*   r+   r,   r   r-   r.   r#   r#   r$   
right_side>   s   zSideBySide.right_sideTNN)
__name__
__module____qualname____doc__r   dictstrr%   r0   r2   r#   r#   r#   r$   r      s     		

r   c                	   @   r   )	TopBottomzDefining layout CTNr   r   r   r   c	           	      C   r   )Ntop_halfbottom_halfr   r   )	r   r   top_half_contentbottom_half_contentr   r   r   r   r   r   r#   r#   r$   r%   P   r&   zTopBottom.__init__c                 C   s>   | j j| j }|| j| jj| jj| jj| jj| j	 d  dS r'   )
r   r)   r=   r   r   r*   r+   r,   r-   r   r.   r#   r#   r$   r;   l   s   zTopBottom.top_halfc                 C   sP   | j j| j }|| j| jj| jj| j d  | jj| jj	| jj| j d  dS r1   )
r   r)   r>   r   r   r*   r-   r   r+   r,   r.   r#   r#   r$   r<   x   s   zTopBottom.bottom_halfr3   )
r4   r5   r6   r7   r   r8   r9   r%   r;   r<   r#   r#   r#   r$   r:   M   s     		

r:   c                	   @   s:   e Zd ZdZ			ddedededdfdd	Zd
d ZdS )FullPageDefining layout DTNr   r   r   r   c	           	      C   s6   || _ || _|| _|| _t|||| j| j |d| _d S )Nr   )r   r   contentr   r   r   r   r#   r#   r$   r%      s   zFullPage.__init__c                 C   sb   z| j j| jd  }|| j| jj| jj| jj| jj W dS  t	y0   t
d td Y dS w )zAdd content to the slide	full_pagezLayout not foundN)r   r)   rA   r   r   r*   r+   r,   r-   KeyErrorprintloggingerrorr.   r#   r#   r$   add_content   s   
zFullPage.add_contentr3   )	r4   r5   r6   r7   r   r8   r9   r%   rG   r#   r#   r#   r$   r?      s    		

r?   c                   @   sT   e Zd ZdZdededdfddZdded	ee fd
dZ	dd Z
defddZdS )
CompsTabler@   r   public_compsr   Nc                 C   s(   || _ || _| || _| | j d S N)r   r   format_to_tabletable_content
make_table)r    r   r   rI   r#   r#   r$   r%      s   zCompsTable.__init__dataheadersc                 C   s   t |j}|S )zLTake the public comps data and format it to a table that can used in the ppt)pc_format_for_tablerN   )r    rN   rO   
table_datar#   r#   r$   rK      s   
zCompsTable.format_to_tablec                 C   s  t |tr	|d }t| jjt|d  }t|d }t|d }| jjj||| jj	| jj
| jj| jjdj}t|d D ](\}}|dkrL||j| _ntd|j| _|d|}||_tj|jjd _q=t|dd dd	D ]\}	}
t|
D ]\}}t| |||	|_qxqpdS )
zMake a table from the datarN   r      )r+   r*   r,   r-    g?Nr(   )start)
isinstancer8   intr   r,   lenr   shapes	add_tabler+   r*   r-   table	enumeratecolumnsr   celltextr   CENTER
text_frame
paragraphs	alignmentr9   format_string)r    rQ   	col_widthrowscolsrZ   	col_indexheader_textr]   	row_indexrow_data
cell_valuer#   r#   r$   rM      s:   

zCompsTable.make_table_inputc                 C   s8   |du rdS z
t |}d|W S  ty   | Y S w )z"Format the string to fit the tableNrS   z{:,.1f})floatformat
ValueError)r    rl   r#   r#   r$   rc      s   zCompsTable.format_stringrJ   )r4   r5   r6   r7   r   r   r%   listr9   rK   rM   rc   r#   r#   r#   r$   rH      s    
&rH   c                   @   s*   e Zd ZdZdedededdfddZdS )	CompanyProfilez#Defining the company profile layoutr   company_urldefault_settingsr   Nc                 C   sB   |d u rt  }|d u rtd|| _|| _t|| _| jj| _d S )NzCompany URL is required)r   ro   r   r   r
   urlrr   )r    r   r   rr   rs   r#   r#   r$   r%     s   
zCompanyProfile.__init__)r4   r5   r6   r7   r   r9   r   r%   r#   r#   r#   r$   rq      s    rq   )r7   rE   pptx.dml.colorr   pptx.enum.textr   	pptx.utilr   /services.ppt_generator.configs.standard_configsr   r   $services.ppt_generator.slide_creatorr   %services.stock_info.public_comparabler   2services.stock_info.public_comparable_format_tabler	   rP   utils.url_parserr
   r   r:   r?   rH   rq   r#   r#   r#   r$   <module>   s    <:1G