
    iYf<-                        d dl mZ d dlZd dlmZ d dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ ddZd	 Zd
 Zd Zd ZddZd Zd Zd ZddZd Zd ZddZd Zd Zdej        j        ddfdZ dd e!            fdZ"dS )    )unicode_literalsN)log)options)versionFTc                 0   |rt           j        }t           j        }nd }d }t          j                                        }|r|                    |           t          j        | |||          }|                                }|j        r+|r)t          j
                            d| |j        fz            t          |          dk    s"|d         r|d                                         sdS |d                                                             dd          S )N)stdoutstderrenvz%s returned %dr    utf-8replace)
subprocessPIPEosenvironcopyupdatePopencommunicate
returncode	distutilserrorsDistutilsErrorlenstripdecode)	cmdthrow_on_errorbufferr
   out_locationerr_locationnewenvoutputouts	            C:\Users\Admin\Desktop\cercetare\experiment de trasmitere a informatiei din viitor in prezent\qiskit_env\Lib\site-packages\pbr/git.py_run_shell_commandr&   "   s    !!Z__F
 cc%1%1"(* * *F 



C 9^ 9--V%6779 9 	9
3xx1}}CF}#a&,,..}r q6<<>>  )444    c                 j    t          | t          t          f          s| g} t          dd|z  g| z   fi |S )Ngitz--git-dir=%s)
isinstancelisttupler&   )r   git_dirkwargss      r%   _run_git_commandr/   =   sP    cD%=)) e	()C/; ;39; ; ;r'   c                      	 t          g d          S # t          $ r!} | j        t          j        k    rY d } ~ dS  d } ~ ww xY w)N)r)   z	rev-parsez	--git-dirr   )r&   OSErrorerrnoENOENT)es    r%   _get_git_directoryr5   D   sZ    !"C"C"CDDD   7el""22222	s    
>99>c                  N    	 t          ddg           n# t          $ r Y dS w xY wdS )Nr)   z	--versionFT)r&   r1    r'   r%   _git_is_installedr8   N   sF     	E;/0000   uu4s    
""c                 8    t          | t          j                  S )zFind the highest tag from a list.

    Pass in a list of tag strings and this will return the highest
    (latest) as sorted by the pkg_resources version parser.
    )key)maxpkg_resourcesparse_version)tagss    r%   _get_highest_tagr?   Y   s     t45555r'   r   c                     g }|t                      }|rNt          j        d           t          ddg|          }|                    d                    d                    }d |D             S )zBehave like a file finder entrypoint plugin.

    We don't actually use the entrypoints system for this because it runs
    at absurd times. We only want to do this when we are building an sdist.
    Nz2[pbr] In git context, generating filelist from gitzls-filesz-z    r   c                     g | ]}||S r7   r7   ).0fs     r%   
<listcomp>z#_find_git_files.<locals>.<listcomp>q   s    &&&!A&A&&&r'   )_run_git_functionsr   infor/   splitr   )dirnamer-   	file_lists      r%   _find_git_filesrK   b   sy     I$&& =EFFF$j$%7AA	 OOGNN7$;$;<<	&&y&&&&r'   c                 v    t          ddg|           }d|v r|                    dd          d         S d|v rdS d S )Ndescribez--always-   .r   )r/   rsplit)r-   rM   s     r%   _get_raw_tag_inforS   t   sK    Z 8'BBH
hsA&&r**
hq4r'   c                 (    t          |           dk    S )Nr   )rS   r-   s    r%   get_is_releaserV   }   s    W%%**r'   c                  F    d } t                      rt                      } | pd S N)r8   r5   rU   s    r%   rF   rF      s*    G '$&&?dr'   c                 N    | st                      } | rt          g d|           S dS )z1Return the short sha for this repo, if it exists.)r   z-n1z--pretty=format:%hN)rF   r/   rU   s    r%   get_git_short_sharZ      s?     '$&& ;000'; ; 	;4r'   c                     |                      dd          } |                      dd          } |                      dd          } | S )a  Cleans any instances of invalid sphinx wording.

    This escapes/removes any instances of invalid characters
    that can be interpreted by sphinx as a warning or error
    when translating the Changelog into an HTML file for
    documentation building within projects.

    * Escapes '_' which is interpreted as a link
    * Escapes '*' which is interpreted as a new line
    * Escapes '`' which is interpreted as a literal
    *z\*_z\_`z\`)r   msgs    r%   _clean_changelog_messagera      sB     ++c5
!
!C
++c5
!
!C
++c5
!
!CJr'   c              #   n  K   d}d}|dfV  | D ]\  }}}|rAt          |          }t          |          dz  }|s|dfV  |dt          ||          z  fV  |                    d          sE|                    d	          r
|dd
         }t          |          }|dt          |          z  fV  d}dS )zConvert a oneline log iterator to formatted strings.

    :param changelog: An iterator of one line log entries like
        that given by _iter_log_oneline.
    :return: An iterator over (release, formatted changelog) tuples.
    TNzCHANGES
=======

rN   
z%(tag)s
%(underline)s

)tag	underlinezMerge rQ   z
* %(msg)s
r_   F)r?   r   dict
startswithendswithra   )	changelog
first_linecurrent_releasehashr>   r`   re   s          r%   _iter_changelogrn      s!      JO
1
1111$  dC 	@.t44OO,,s2I ,%t++++!,I>>>?@ @ @ @ ~~h'' 	A||C   #2#h*3//C!=4C===#@@@@@

 r'   c                 H    | t                      } | sg S t          |           S )aQ  Iterate over --oneline log entries if possible.

    This parses the output into a structured form but does not apply
    presentation logic to the output - making it suitable for different
    uses.

    :return: An iterator of (hash, tags_set, 1st_line) tuples, or None if
        changelog generation is disabled / not available.
    )r5   _iter_log_innerrU   s    r%   _iter_log_onelinerq      s/     $&& 	7###r'   c                 h    	 t           j                            |            dS # t          $ r Y dS w xY w)NTF)r   SemanticVersionfrom_pip_string
ValueError)	candidates    r%   _is_valid_versionrw      sE    //	:::t   uus   # 
11c              #   8  K   t          j        d           g d}t          ||           }|                    d          D ]}|                    d          }t	          |          dk    r+|\  }}}t                      }d|v r|                                dd         }|                    d          dd	         D ]U}	|	                    d
          d                             dd          }
t          |
          r|	                    |
           V|||fV  d	S )a  Iterate over --oneline log entries.

    This parses the output intro a structured form but does not apply
    presentation logic to the output - making it suitable for different
    uses.

    .. caution:: this function risk to return a tag that doesn't exist really
                 inside the git objects list due to replacement made
                 to tag name to also list pre-release suffix.
                 Compliant with the SemVer specification (e.g 1.2.3-rc1)

    :return: An iterator of (hash, tags_set, 1st_line) tuples.
    z[pbr] Generating ChangeLog)r   z--decorate=fullz--format=%h%x00%s%x00%drc       z
refs/tags/   rf   Nz, r   rN   rQ   )
r   rG   r/   rH   r   setr   r   rw   add)r-   log_cmdrj   line
line_partsshar`   refnamer>   
tag_stringrv   s              r%   rp   rp      s=      H)***CCCG '22I%%  ZZ''
z??a&S'uu 7""mmooad+G &mmL99!""= ( (
 ',,T2215==c3GG	$Y// (HHY'''4n1 r'   c                    t          j                     }|si }t          j        |dd          }|rdS |s!t          |           }|rt	          |          }|sdS t
          j                            |d          }t
          j                            |          r5t          j	        |t
          j
                  st          j        d           dS t          j        d           t          j        |dd	
          5 }|D ]\  }}	|                    |	           	 ddd           n# 1 swxY w Y   t          j                     }
t          j        d|
|z
  z             dS )z-Write a changelog based on the git changelog.skip_changelogSKIP_WRITE_GIT_CHANGELOGNrU   	ChangeLogzI[pbr] ChangeLog not written (file already exists and it is not writeable)z[pbr] Writing ChangeLogwr   )encodingz![pbr] ChangeLog complete (%0.1fs))timer   get_boolean_optionrq   rn   r   pathjoinexistsaccessW_OKr   rG   ioopenwrite)r-   dest_diroption_dictrj   startshould_skipnew_changelogchangelog_filereleasecontentstops              r%   write_git_changelogr     s    IKKE ,[:J-GI IK  3%g666	 	3'	22I GLL;77M	w~~m$$ RY}bg-N-N  4 	5 	5 	5H&'''	g	6	6	6 *. ) 	* 	*GW  ))))	** * * * * * * * * * * * * * * 9;;DH0D5LABBBBBs   8D##D'*D'rQ   c                    t          j        |dd          }|rdS t          j                    }t          j                            |d          }t          j                            |d          }t          j                            |          r!t          j        |t          j                  sdS t          j
        d           d| t                      } | rkg }dd	g}|t          ||                               d
          z  }fd|D             }t          d|           }	t          j        d|	t          j                  }
d |
D             }
||
z  }t#          t%          |                    }t'          |d          5 }t          j                            |          rOt'          |d          5 }|                    |                                           ddd           n# 1 swxY w Y   |                    d
                    |          d
z                       d                     ddd           n# 1 swxY w Y   t          j                    }t          j
        d||z
  z             dS )z&Create AUTHORS file using git commits.skip_authorsSKIP_GENERATE_AUTHORSNz
AUTHORS.inAUTHORSz[pbr] Generating AUTHORSz5((jenkins|zuul)@review|infra@lists|jenkins@openstack)r   z--format=%aN <%aE>rc   c                 >    g | ]}t          j        |          |S r7   )research)rC   aignore_emailss     r%   rE   z$generate_authors.<locals>.<listcomp>?  s*    IIIRY}a-H-HI1IIIr'   zCo-authored-by:.+c                 n    g | ]2}||                     d d          d                                         3S ):r{   )rH   r   )rC   signeds     r%   rE   z$generate_authors.<locals>.<listcomp>E  sK     : : : &:fll3**1-3355 : : :r'   wbrbr   z[pbr] AUTHORS complete (%0.1fs))r   r   r   r   r   r   r   r   r   r   rG   r5   r/   rH   r   findall	MULTILINEsortedr|   r   r   readencode)r-   r   r   r   r   old_authorsnew_authorsauthorsgit_log_cmdco_authors_out
co_authorsnew_authors_fhold_authors_fhr   r   s                 @r%   generate_authorsr   '  s   ,[.-DF FK IKKE',,x66K',,x33K	w~~k"" 29["'+J+J H'(((KM$&& 3 23#K99??EEEIIIIgIII *%99Z 3^ ". .
: :$.: : :
 	:W&&+t$$ 	3w~~k** @+t,, @"(()<)<)>)>???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @  $))G"4"4t";"(&//3 3 3		3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 9;;DH.$,?@@@@@s7   ?0H8/(G#H8#G'	'H8*G'	+AH88H<?H<)FTN)r   NrX   )#
__future__r   distutils.errorsr   r   r2   r   r   r   r   r   r<   pbrr   r   r&   r/   r5   r8   r?   rK   rS   rV   rF   rZ   ra   rn   rq   rw   rp   r   curdirr   rg   r   r7   r'   r%   <module>r      s  " ( ' ' ' ' '            				 				 				                     5 5 5 56; ; ;    6 6 6' ' ' '$  + + +       (  8$ $ $ $"  ) ) )X !%rw~$(DC C C C@ "CTTVV +A +A +A +A +A +Ar'   