o
    ʷ6iy                     @  sn   d dl mZ d dlZd dlZd dlmZ ddlmZmZ dd
dZdddZ	ddddZ
edkr5e
  dS dS )    )annotationsN)Any   )slugifyDEFAULT_SEPARATORargv	list[str]returnargparse.Namespacec                   s  t jdd  jdd}|jdddd |jdd	d
d  jdddddd  jdddddd  jdddddd  jdtddd  jdd	ddd  jd d	dd!d  jd"ttd#t d  jd$d%d&d  jd'd(d)  jd*dd+dd,d  jd-d%d.d  jd/d	dd0d  | d1d  }|jr|j	r 
d2 |jr fd3d4fd5d6|jD |_|jrd7|j|_n	|j	rtj	 |_|jsd8|_|S )9NzSlug string)descriptionInputinput_string*zText to slugify)nargshelpz--stdin
store_truezTake the text from STDIN)actionr   z--no-entitiesstore_falseentitiesTz'Do not convert HTML entities to unicode)r   destdefaultr   z--no-decimaldecimalz&Do not convert HTML decimal to unicodez--no-hexadecimalhexadecimalz*Do not convert HTML hexadecimal to unicodez--max-lengthr   z$Output string length, 0 for no limit)typer   r   z--word-boundaryFzJTruncate to complete word even if length ends up shorter than --max_length)r   r   r   z--save-orderzEWhen set and --max_length > 0 return whole words in the initial orderz--separatorz$Separator between words. By default z--stopwords+zWords to discountz--regex-patternz.Python regex pattern for disallowed characters)r   z--no-lowercase	lowercasezActivate case sensitivityz--replacementsz9Additional replacement rules e.g. "|->or", "%%->percent".z--allow-unicodezAllow unicode charactersr   z.Input strings and --stdin cannot work togetherc                   s*   d}|| vr  dj|d | |dS )Nz->z7Replacements must be of the form: ORIGINAL{SEP}REPLACED)SEPr   )errorformatsplit)replr   )parser U/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/site-packages/slugify/__main__.pysplit_check2   s   zparse_args.<locals>.split_checkc                   s   g | ]} |qS r"   r"   ).0r    )r$   r"   r#   
<listcomp>7   s    zparse_args.<locals>.<listcomp>  )argparseArgumentParseradd_argument_groupadd_argumentintstrr   
parse_argsr   stdinr   replacementsjoinsysread)r   input_groupargsr"   )r!   r$   r#   r/   
   sr   





r/   r6   dict[str, Any]c                 C  s8   t | j| j| j| j| j| j| j| j| j	| j
| j| jdS )N)textr   r   r   
max_lengthword_boundary
save_order	separator	stopwordsr   r1   allow_unicode)dictr   r   r   r   r9   r:   r;   r<   r=   r   r1   r>   )r6   r"   r"   r#   slugify_paramsD   s   r@   list[str] | Nonec                 C  sV   | du rt j} t| }t|}zttdi | W dS  ty*   t d Y dS w )z Run this program Nr"   )r3   r   r/   r@   printr   KeyboardInterruptexit)r   r6   paramsr"   r"   r#   mainU   s   rG   __main__)r   r   r	   r
   )r6   r
   r	   r7   )N)r   rA   )
__future__r   r)   r3   typingr   r   r   r/   r@   rG   __name__r"   r"   r"   r#   <module>   s    

:
