o
    ]i                      @   s^  d dl Z d dlZejeZh dZdd ZdddZd d	d
Z	g dZ
g dZedd edd  Zed ddZedd eg Zedd edd  ZedkrejeZe jddZejdeejdeejeddd ejddddd e ZejZedej  e edZ!eee!ej" W d   dS 1 sw   Y  dS dS )!    N>   zLICENSE.rstzLICENSE.txtLICENSEzCOPYING.BSDc           
   	   C   s   i }t | D ]l\}}}ttt|@ }|rs|dd }t j||d }zt|}W n t	y;   t	d| d w ||g||gd}	||v ro|| d |krd|| d 
| || d 
| q|	||d	| d
 < q|	||< q|S )N/r   z$could not identify license file for )NameFilesLicenseLicense_filer   r   r   z ())oswalklistlicensessetsplitpathjoinidentify_license
ValueErrorappend)
current	collectedrootdirsfileslicensenamelicense_fileidentval r   ;/home/app/PyTorch/test/pytorch/third_party/build_bundled.pycollect_license
   s8   r!   Fc              	   C   sP  t | }t| }|d |d g }|D ]U}|| }d|d }d|d }	|d |d|d  d	 |d
|d  d	 |d| d	 |d |rc|d ||d 7 }n|d ||	 q|D ]5}
|d ||
 |d	dt|
  d	  t|
d}||  W d   n1 sw   Y  qpdS )z*Write the information to an open outstreamzSThe PyTorch repository and source distributions bundle several libraries that are 
z)compatibly licensed.  We list these here.z,
     r   r   z

zName: r   
z	License: r   zFiles: z  For details, seez the files concatenated below: z: -rN)r!   sortedkeyswriter   lenopenread)dZ	outstreaminclude_filesr   Zsorted_keysZfiles_to_includekcr   r   fnamefidr   r   r    create_bundled(   s8   







r1    c                    sf  dd  t | }| |s$dv r$t| d}|d W  d   S  dv r5	 W d   dS dv rB	 W d   d	S d
v rO	 W d   dS dv r\	 W d   dS dv ri	 W d   dS dv rv	 W d   dS dv r	 W d   dS dv r	 W d   dS dv r	 W d   dS dv r	 W d   dS  dv r	 W d   dS t fddtD r	 W d   dS t fddtD r	 W d   dS t fddtD r	 W d   dS t fddtD r	 W d   dS t fddt	D r$	 W d   d	S t
d 1 s,w   Y  dS )!z
    Read f and try to identify the license type
    This is __very__ rough and probably not legally binding, it is specific for
    this repo.
    c                 S   s,   |  dd dd} |  dd dd} | S )z,Remove 'n and ' ', normalize quotes
        r"   r2    z``"z'')replace)tr   r   r    squeezeM   s   z!identify_license.<locals>.squeeze	exceptionz with exceptionNZApacheLicensez
Apache-2.0Z
MITLicenseZMITzBSD-3-ClauseLicensezBSD-3-ClausezBSD3-ClauseLicensezBoostSoftwareLicense-Version1.0zBSL-1.0ZgettimeofdayZlibhungarianzPermissive (free to use)ZPDCurseszPublic Domain for coreZ&Copyright1999UniversityofNorthCarolinaZsigslotzPublic DomainzClarified Artistic Licensec                       g | ]
} |  v qS r   lower.0mr7   txtr   r    
<listcomp>z       z$identify_license.<locals>.<listcomp>c                    r9   r   r:   r<   r?   r   r    rA   |   rB   c                    r9   r   r:   r<   r?   r   r    rA   ~   rB   zBSD-2-Clausec                    r9   r   r:   r<   r?   r   r    rA      rB   zBSD-Source-Codec                    r9   r   r:   r<   r?   r   r    rA      rB   zunknown license)r)   r*   r   allbsd3_txtbsd3_v1_txtbsd2_txtbsd3_src_txtanymit_txtr   )fr8   r0   r   r   r?   r    r   G   st   
	!$&(*,.1r   )z<permission is hereby granted, free of charge, to any person z?obtaining a copy of this software and associated documentation z8files (the "software"), to deal in the software without zCrestriction, including without limitation the rights to use, copy, zCmodify, merge, publish, distribute, sublicense, and/or sell copies z?of the software, and to permit persons to whom the software is z8furnished to do so, subject to the following conditions:z?the above copyright notice and this permission notice shall be z?included in all copies or substantial portions of the software.z@the software is provided "as is", without warranty of any kind, zCexpress or implied, including but not limited to the warranties of z6merchantability, fitness for a particular purpose and zDnoninfringement. in no event shall the authors or copyright holders zCbe liable for any claim, damages or other liability, whether in an zBaction of contract, tort or otherwise, arising from, out of or in zAconnection with the software or the use or other dealings in the z	software.)zredistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:zredistributions of source codezredistributions in binary formzneither the namezthis software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed.      zand contributors   __main__zGenerate bundled licenses file)descriptionz
--out-fileZ(PYTORCH_THIRD_PARTY_BUNDLED_LICENSE_FILEzLICENSES_BUNDLED.txtz,location to output new bundled licenses file)typedefaulthelpz--include-files
store_truez*include actual license terms to the output)actionrQ   rR   z+ Writing bundled licenses to w)F)r2   )#argparser
   r   dirname__file__Zmydirr   r!   r1   r   rI   rD   rF   r5   Zv1rE   rG   __name__relpaththird_partyArgumentParserparseradd_argumentstrenvirongetr   
parse_argsargsout_filer/   printr)   r0   r,   r   r   r   r    <module>   sP   

@	"