
    =e                        d Z ddlmZ dg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lmZ ddlmZ  ej        d	          Zej        eej        f         ZddZddZddZddZdS )zQUpdate public attributes of the package or the attributes of the package release.    )annotations
add_parserN)errors)get_server_api)parse_specs)detectzbinstar.updatepackagestrargsargparse.Namespacereturn$typing.Tuple[Attributes, Attributes]c                   d}|                      d          rt          j        }n!|                      d          rt          j        }|9t          | dd          5 } ||          fdz  cddd           S # 1 swxY w Y   |j        rt          j        |j                  }nt          j	        |           }|4d|  d	}t                              |           t          j        |          	 t          j        || |
          dd         S # t          $ rB}d|  d|j         d}t                              |           t          j        |          |d}~ww xY w)z#Parse source for attribute details.Nz.json)z.ymlz.yamlrtzutf-8)encoding   z'Could not detect package type of file "z9". Please specify package type with option --package-type)parser_argszTrouble reading metadata from z. Is this a valid source file: ?)endswithjsonloadyaml	safe_loadopenpackage_typer   PackageTypedetect_package_typeloggererrorr   BinstarError	get_attrs	Exceptionlabel)r	   r   loaderstreamr   messager   s          >lib/python3.11/site-packages/binstar_client/commands/update.pyget_attributesr(      s   Z^F    			+	,	,  '4'222 	)fF6NN$q(	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)  ;)$*;<<1'::Eg E E E 	 	W!'***6g4HHH!LL 6 6 6p7pp[g[mpppW!'**56s*   A66A:=A:-D 
E=EENonec                   t          | j        | j                  }|                                 t	          | j        |           t          | j                           }|                    d|          }| j        r7|	                    | j
        j        | j
        j        | j
        j        |           n+|                    | j
        j        | j
        j        |           t                              d| j
                   dS )zProcess update request.public_attrszPackage `%s` has been updated!N)r   tokensitecheck_serverr(   sourceboolreleasegetupdate_releasespecuserr	   versionupdate_packager   info)r   anaconda_apiattrss      r'   mainr;   =   s    !$*di88L&t{D99$t|:L:LMEIIne,,E| 
##INII		
 	
 	
 	
 	##INI	
 	
 	

 KK0$)<<<<<    pathc                r    t           j                            |           r| S t          j        |  d          )z=Validate argument value, that should be a valid path to file.z is not a valid path)osr=   isfileargparseArgumentTypeError)r=   s    r'   	file_typerC   U   s7    	w~~d 

$%B%B%B
C
CCr<   
subparsers
typing.Anyc                v   |                      ddt                    }|                    ddt                     |                    ddt                     |                    d	d
d           |                    d          }|                    ddd           |                    t                     dS )zAdd parser to CLI.updatez
	anaconda update [--release] user/package[/version] CONDA_PACKAGE_1.tar.bz2
	anaconda update [--release] user/package[/version] metadata.json)usagedescriptionr4   z0Package name written as `user/package[/version]`)helptyper/   zPath to the file that consists of metadata that will be updated in the destination package. It may be a valid package file or `.json` file with described attributes to updatez-tz--package-typez,Set the package type. Defaults to autodetect)rJ   zUpdate release)titlez	--releasezPUse `source` file to update public attributes of the release specified in `spec`
store_true)rJ   action)r;   N)r   __doc__add_argumentr   rC   add_argument_groupset_defaultsr;   )rD   parserrelease_groups      r'   r   r   ]   s   ""S  #  F ?    
 a      ;    
 --4D-EEM_     T"""""r<   )r	   r
   r   r   r   r   )r   r   r   r)   )r=   r
   r   r
   )rD   rE   r   r)   )rO   
__future__r   __all__rA   r   loggingr?   typingr   binstar_clientr   binstar_client.utilsr   r   r   	getLoggerr   Mappingr
   Any
Attributesr(   r;   rC   r    r<   r'   <module>r`      s+   X W " " " " " ".    				   ! ! ! ! ! ! / / / / / / , , , , , , ' ' ' ' ' '		+	,	, ^CO,
6 6 6 6B= = = =0D D D D$# $# $# $# $# $#r<   