관리-도구
편집 파일: frontend.cpython-39.opt-1.pyc
a �����`I�����������������������@���s��d�Z�ddlmZ�ddlZddlZddlZddlZddlZddlZddl Z ddl mZ�ddlmZ�ddl mZ�ddlmZ�ddlmZmZ�dd lmZmZmZmZ�dd lmZ�ddlmZ�ddlmZmZm Z m!Z!�dd l"m#Z#�ddl$m%Z%m&Z&�ddl'm(Z(�ddl)m*Z+�ddl,m-Z.�ddl/m0Z0m1Z1�zddl2m3Z3�W�n �e4�yP���ddl5m3Z3�Y�n0�e�r\dndZ6d-dd�Z7G�dd��de.�Z-G�dd��de-�Z8G�dd��de-�Z9dd��Z:G�d d!��d!e-�Z;G�d"d#��d#e-�Z<G�d$d%��d%e=�Z>d&d'��Z?d.d(d)�Z@g�fd*d+�ZAeBd,k�r�e?���dS�)/z� babel.messages.frontend ~~~~~~~~~~~~~~~~~~~~~~~ Frontends for the message extraction functionality. :copyright: (c) 2013-2021 by the Babel Team. :license: BSD, see LICENSE for more details. �����)�print_functionN)�OrderedDict)�datetime)�getpreferredencoding)�__version__)�Locale� localedata)�StringIO�string_types� text_type�PY2)�UnknownLocaleError)�Catalog)�DEFAULT_KEYWORDS�DEFAULT_MAPPING�check_and_call_extract_file�extract_from_dir)�write_mo)�read_po�write_po)�LOCALTZ)�log)�Command)�DistutilsOptionError�DistutilsSetupError)�RawConfigParserZrU�rc�����������������C���sp���g�}t�|�ttf�s|�g}�|�D�]N}|du�r*qt�|ttf�rL|�t||d���q|�dd��t|��|�D����q|S�)a�� Make a list out of an argument. Values from `distutils` argument parsing are always single strings; values from `optparse` parsing may be lists of strings that may need to be further split. No matter the input, this function returns a flat list of whitespace-trimmed strings, with `None` values filtered out. >>> listify_value("foo bar") ['foo', 'bar'] >>> listify_value(["foo bar"]) ['foo', 'bar'] >>> listify_value([["foo"], "bar"]) ['foo', 'bar'] >>> listify_value([["foo"], ["bar", None, "foo"]]) ['foo', 'bar', 'foo'] >>> listify_value("foo, bar, quux", ",") ['foo', 'bar', 'quux'] :param arg: A string or a list of strings :param split: The argument to pass to `str.split()`. :return: N��splitc�����������������s���s���|�]}|����V��qd�S��N��strip)�.0�s��r$����;/usr/lib/python3.9/site-packages/babel/messages/frontend.py� <genexpr>S��������z listify_value.<locals>.<genexpr>)� isinstance�list�tuple�extend� listify_valuer���r���)�argr����out�valr$���r$���r%���r,���.���s���� r,���c�������������������@���s.���e�Zd�ZdZdZdZi�Zi�ZeZ ddd�Z dS�)r���Nr$���c�����������������C���s0���||�_�|�����d�|�_d|�_d�|�_d|�_d|�_d�S�)NFr���)�distribution�initialize_optionsZ_dry_run�verbose�force�helpZ finalized)�self�distr$���r$���r%����__init__v���s����zCommand.__init__)N)�__name__� __module__�__qualname__�as_args�multiple_value_options�boolean_options�option_aliases�option_choices� distutils_logr���r7���r$���r$���r$���r%���r���X���s���r���c�������������������@���sD���e�Zd�ZdZdZg�d�ZddgZdd��Zdd ��Zd d��Z dd ��Z dS�)�compile_cataloga���Catalog compilation command for use in ``setup.py`` scripts. If correctly installed, this command is available to Setuptools-using setup scripts automatically. For projects using plain old ``distutils``, the command needs to be registered explicitly in ``setup.py``:: from babel.messages.frontend import compile_catalog setup( ... cmdclass = {'compile_catalog': compile_catalog} ) .. versionadded:: 0.9 z+compile message catalogs to binary MO files))�domain=�Dz>domains of PO files (space separated list, default 'messages'))z directory=�d�.path to base directory containing the catalogs�zinput-file=�izname of the input file)�output-file=�ozQname of the output file (default '<output_dir>/<locale>/LC_MESSAGES/<domain>.mo')��locale=�lz locale of the catalog to compile)� use-fuzzy�fzalso include fuzzy translations)� statisticsNz#print statistics about translationsrM���rO���c�����������������C���s.���d|�_�d�|�_d�|�_d�|�_d�|�_d|�_d|�_d�S��N�messagesF)�domain� directory� input_file�output_file�locale� use_fuzzyrO����r5���r$���r$���r%���r1�������s����z"compile_catalog.initialize_optionsc�����������������C���s8���t�|�j�|�_|�js |�js td��|�js4|�js4td��d�S�)Nz<you must specify either the input file or the base directoryz=you must specify either the output file or the base directory)r,���rR���rT���rS���r���rU���rX���r$���r$���r%����finalize_options����s ����z compile_catalog.finalize_optionsc�����������������C���sT���d}|�j�D�](}|��|����D�]\}}|t|�7�}qq |rH|�j�d|���|rPdS�dS�)Nr���z%d errors encountered.����)rR����_run_domain�items�lenr����error)r5���Zn_errorsrR����catalog�errorsr$���r$���r%����run����s���� zcompile_catalog.runc�������������� ���C���s���g�}g�}|�j�s�|�jr\|�|�jtj�|�j|�jd|d��f��|�tj�|�j|�jd|d����nbt�|�j�D�]T}tj�|�j|d|d��}tj�|�rh|�||f��|�tj�|�j|d|d����qhnF|�|�j|�j�f��|�j r�|�|�j ��n |�tj�|�j|�jd|d����|�st d��i�}t|�D��]h\}\}}||�}t|d��} t | |�} W�d�����n1��sb0����Y��|�j�r�d}t| �dd���D�]}|j�r�|d7�}�q�d} t| ��r�|d�t| ��} |�j�d |t| �| |��| j�r�|�j�s�|�j�d |���q t| �����|| <�}|D�]*\}}|D�]}|�j�d||j|���q�q|�j�d||��t|d �� }t|| |�jd��W�d�����n1��s~0����Y���q |S�)N�LC_MESSAGES�.poz.mo�no message catalogs found�rbr���rZ����d���z)%d of %d messages (%d%%) translated in %sz'catalog %s is marked as fuzzy, skippingzerror: %s:%d: %szcompiling catalog %s to %s�wb)rW���)rT���rV����append�os�path�joinrS����listdir�existsrU���r���� enumerate�openr���rO���r)����stringr]���r����info�fuzzyrW����checkr^����linenor���)r5���rR����po_filesZmo_filesrV����po_fileZcatalogs_and_errors�idxZmo_file�infiler_���Z translated�messageZ percentageZcatalog_errorsr`���r^����outfiler$���r$���r%���r[�������s~��������� �* � �4zcompile_catalog._run_domainN)r8���r9���r:����__doc__�description�user_optionsr=���r1���rY���ra���r[���r$���r$���r$���r%���rA�������s��� rA���c�������������������@���sb���e�Zd�ZdZdZg�d�Zg�d�ZdZdZddd d d�Z dd iZ dd��Zdd��Zdd��Z dd��ZdS�)�extract_messagesa���Message extraction command for use in ``setup.py`` scripts. If correctly installed, this command is available to Setuptools-using setup scripts automatically. For projects using plain old ``distutils``, the command needs to be registered explicitly in ``setup.py``:: from babel.messages.frontend import extract_messages setup( ... cmdclass = {'extract_messages': extract_messages} ) z1extract localizable strings from the project code))zcharset=Nz3charset to use in the output file (default "utf-8"))z keywords=�kzispace-separated list of keywords to look for in addition to the defaults (may be repeated multiple times))�no-default-keywordsNz#do not include the default keywords)z mapping-file=�Fz&path to the mapping configuration file)�no-locationNz>do not include location comments with filename and line number)z add-location=Nz�location lines format. If it is not given or "full", it generates the lines with both file name and line number. If it is "file", the line number part is omitted. If it is "never", it completely suppresses the lines (same as --no-location).)�omit-headerNz'do not include msgid "" entry in header)rH���rI���zname of the output file�zwidth=�wz"set output line width (default 76)��no-wrapNzVdo not break long message lines, longer than the output line width, into several lines)�sort-outputNz&generate sorted output (default False))�sort-by-fileNz,sort output by file location (default False))zmsgid-bugs-address=Nzset report address for msgid)zcopyright-holder=Nzset copyright holder in output)zproject=Nzset project name in output)zversion=Nzset project version in output)z add-comments=�czuplace comment block with TAG (or those preceding keyword lines) in output file. Separate multiple TAGs with commas(,))�strip-commentsr#���z)strip the comment TAGs from the comments.)zinput-paths=Nzofiles or directories that should be scanned for messages. Separate multiple files or directories with commas(,))zinput-dirs=Nz@alias for input-paths (does allow files as well as directories).)r����r����r����r����r����r����r����zinput-paths)zadd-comments�keywords)z --keyword)z --mapping)z--output)z--strip-comment-tags)r����zmapping-filezoutput-filer����zadd-location)Zfull�file�neverc�����������������C���s����d|�_�d�|�_d|�_d�|�_d|�_d�|�_d|�_d�|�_d�|�_d�|�_ d�|�_ d|�_d|�_d|�_ d�|�_d�|�_d�|�_d�|�_d�|�_d|�_d|�_d�S�)Nzutf-8FT)�charsetr�����no_default_keywords�mapping_file�no_location�add_location�omit_headerrU���� input_dirs�input_paths�width�no_wrap�sort_output�sort_by_file�msgid_bugs_address�copyright_holder�project�version�add_comments�strip_comments�include_linenorX���r$���r$���r%���r1���[��s*����z#extract_messages.initialize_optionsc�����������������C���s���|�j�r|�js|�j�|�_ntd��|�jr*i�}nt���}|�tt|�j ����||�_ |�j sZtd��|�j shtd��|�jr||�jr|td��|�js�|�js�d|�_n|�jd�ur�t |�j�|�_|�jr�|�jr�td��|�jr�t|�jt�r�t�d|�j�|�_n6|�jd�u�rt�dd ��|�jjp�d D������|�_ng�|�_|�j�s$td��|�jD�] }tj�|��s*td|����q*t|�j�pXd d �|�_|�j�r�|�j�s||�j���|�_|�j�s�|�j� ��|�_|�j!dk�r�d|�_"n|�j!dk�r�d|�_#d�S�)Nz1input-dirs and input-paths are mutually exclusivez=you must specify new keywords if you disable the default oneszno output file specified�0'--no-wrap' and '--width' are mutually exclusive�L���z;'--sort-output' and '--sort-by-file' are mutually exclusivez,\s*c�����������������S���s���g�|�]}|��d�d�d��qS�)�.rZ���r���r���)r"���r���r$���r$���r%���� <listcomp>���s����z5extract_messages.finalize_options.<locals>.<listcomp>r$���z'no input files or directories specifiedzInput path: %s does not exist�,r����Tr����F)$r����r����r���r����r����copy�update�parse_keywordsr,���r����rU���r����r�����intr����r����r(���r ����rer���r0����dict�fromkeysZpackages�keysri���rj���rm���r����r����Zget_namer����Zget_versionr����r����r����)r5���r����rj���r$���r$���r%���rY���r��s\���� � � z!extract_messages.finalize_optionsc��������������������sN�������}t�jd���"}t�j�j�j�j�jd�}|D�]�\��}}���fdd�}t j ����r�t ���}t ��|||�j�j�j|�}nt��||�j�j|�jd�}|D�]P\} } }}} t j ����r�| }nt j �t j ���| ��}|j|d�|| fg|| d��q�q8�j�d�j��t||�j�j�j�j�j�jd��W�d�����n1��s@0����Y��d�S�) Nrg���)r����r����r����r����r����c��������������������sl���|dkrd�S�t�j����r��}nt�j�t�j���|���}d}|rXdd�dd��|���D����}�j�d||��d�S�)N�ignore��z (%s)z, c�����������������S���s���g�|�]\}}d�||f��qS�)z%s="%s"r$���)r"���r����vr$���r$���r%���r�������s����z:extract_messages.run.<locals>.callback.<locals>.<listcomp>zextracting messages from %s%s)ri���rj����isfile�normpathrk���r\���r���rq���)�filename�method�options�filepathZoptstr�rj���r5���r$���r%����callback���s����� z&extract_messages.run.<locals>.callback)r����Zcomment_tagsr����Zstrip_comment_tags)Z auto_comments�contextzwriting PO template file to %s)r����r����r����r����r����r����)� _get_mappingsro���rU���r���r����r����r����r����r����ri���rj���r�����getcwdr���r����r����r����r���r����rk����addr���rq���r���r����r����r����r����r����r����)r5����mappingsrz���r_���� method_map�options_mapr����Zcurrent_dirZ extractedr����rt���ry���Zcommentsr����r����r$���r����r%���ra������sN����� ��� �zextract_messages.runc�����������������C���s ��g�}|�j�r`t|�j�t��}t|�\}}W�d�����n1�s80����Y��|�jD�]}|�|||f��qHn�t|�jdd��r�|�jj}|� ��D�]h\}}t |t�r�tt|��\}}n4g�i��}}|D�]$\}} } |�|| f��| p�i�||<�q�|�|||f��q~n|�jD�]}|�|t i�f��q�|S�)N�message_extractors)r����ro����po_file_read_mode� parse_mappingr����rh����getattrr0���r����r\���r(���r ���r ���r���)r5���r�����fileobjr����r����rj���r�����mapping�patternr����r����r$���r$���r%���r�������s&����* zextract_messages._get_mappingsN)r8���r9���r:���r{���r|���r}���r=���r;���r<���r>���r?���r1���rY���ra���r����r$���r$���r$���r%���r~��� ��s"���1��C=r~���c�����������������C���s���t�|t�std��dS�)ag��Validate the ``message_extractors`` keyword argument to ``setup()``. :param dist: the distutils/setuptools ``Distribution`` object :param name: the name of the keyword argument (should always be "message_extractors") :param value: the value of the keyword argument :raise `DistutilsSetupError`: if the value is not valid zDthe value of the "message_extractors" parameter must be a dictionaryN)r(���r����r���)r6����name�valuer$���r$���r%����check_message_extractors��s���� r����c�������������������@���s:���e�Zd�ZdZdZg�d�ZdgZdd��Zdd��Zd d ��Z dS�)�init_cataloga���New catalog initialization command for use in ``setup.py`` scripts. If correctly installed, this command is available to Setuptools-using setup scripts automatically. For projects using plain old ``distutils``, the command needs to be registered explicitly in ``setup.py``:: from babel.messages.frontend import init_catalog setup( ... cmdclass = {'init_catalog': init_catalog} ) z(create a new catalog based on a POT file)�rB���rC���z&domain of PO file (default 'messages')rF���)�output-dir=rD���zpath to output directory�rH���rI���zQname of the output file (default '<output_dir>/<locale>/LC_MESSAGES/<domain>.po'))rK���rL���z$locale for the new localized catalogr����r����r����c�����������������C���s.���d�|�_�d�|�_d�|�_d�|�_d|�_d|�_d�|�_d�S�rP���)� output_dirrU���rT���rV���rR���r����r����rX���r$���r$���r%���r1���A��s����zinit_catalog.initialize_optionsc�������������� ���C���s���|�j�std��|�jstd��zt�|�j�|�_W�n,�tyZ�}�zt|��W�Y�d�}~n d�}~0�0�|�jsp|�jsptd��|�js�t j �|�j|�jd|�jd��|�_t j � t j �|�j��s�t �t j �|�j���|�jr�|�jr�td��|�js�|�js�d|�_n|�jd�ur�t|�j�|�_d�S�)N�you must specify the input filez-you must provide a locale for the new catalogz%you must specify the output directoryrb���rc���r����r����)rT���r���rV���r����parse�_localer ���rU���r����ri���rj���rk���rR���rm����dirname�makedirsr����r����r����)r5����er$���r$���r%���rY���J��s,���� � zinit_catalog.finalize_optionsc�����������������C���s����|�j��d|�j|�j��t|�jd��}t||�jd�}W�d�����n1�sD0����Y��|�j|_t� t �|_d|_t|�jd�� }t |||�jd��W�d�����n1�s�0����Y��d�S�)Nzcreating catalog %s based on %sre���)rV���Frg���)r����)r���rq���rU���rT���ro���r���rV���r����r���Znowr���Z revision_daterr���r���r����)r5���rx���r_���rz���r$���r$���r%���ra���f��s���� �,zinit_catalog.runN� r8���r9���r:���r{���r|���r}���r=���r1���rY���ra���r$���r$���r$���r%���r������s��� r����c�������������������@���s<���e�Zd�ZdZdZg�d�Zg�d�Zdd��Zdd��Zd d ��Z dS�)�update_cataloga���Catalog merging command for use in ``setup.py`` scripts. If correctly installed, this command is available to Setuptools-using setup scripts automatically. For projects using plain old ``distutils``, the command needs to be registered explicitly in ``setup.py``:: from babel.messages.frontend import update_catalog setup( ... cmdclass = {'update_catalog': update_catalog} ) .. versionadded:: 0.9 z'update message catalogs from a POT file)r����rF���)r����rD���rE���r����)r����Nz%do not include msgid entry in headerrJ���r����r����)zignore-obsolete=Nz1whether to omit obsolete messages from the output)�no-fuzzy-matching�Nzdo not use fuzzy matching)�update-header-commentNzupdate target header comment)�previousNz+keep previous msgids of translated messages)r����r����zignore-obsoleter����r����r����c�����������������C���sL���d|�_�d�|�_d�|�_d�|�_d|�_d�|�_d�|�_d|�_d|�_d|�_ d|�_ d|�_d�S�rP���)rR���rT���r����rU���r����rV���r����r�����ignore_obsolete�no_fuzzy_matching�update_header_commentr����rX���r$���r$���r%���r1������s����z!update_catalog.initialize_optionsc�����������������C���s����|�j�std��|�js"|�js"td��|�jr6|�js6td��|�jrJ|�jrJtd��|�js^|�js^d|�_n|�jd�urtt|�j�|�_|�jr�|�j r�d|�_ d�S�)Nr����z-you must specify the output file or directoryzyou must specify the localer����r����F) rT���r���rU���r����rV���r����r����r����r����r����rX���r$���r$���r%���rY������s���� zupdate_catalog.finalize_optionsc�������������� ���C���s>��g�}|�j�s�|�jr:|�|�jtj�|�j|�jd|�jd��f��q�t�|�j�D�]8}tj�|�j|d|�jd��}tj� |�rF|�||f��qFn|�|�j|�j�f��|s�t d��|�j}|s�tj�tj�|�j ��d�}t|�j d��}t|�}W�d�����n1�s�0����Y��|D��]:\}}|�j�d||�j ��t|d��}t|||d�}W�d�����n1��sH0����Y��|j||�j|�jd��tj�tj�|�t���tj�|���} zLt| d ��,} t| ||�j|�j|�j|�jd ��W�d�����n1��s�0����Y��W�n���t�| ����Y�n0�zt�| |��W�q��t�y6���t�|��t �!| |��t�| ��Y�q�0�q�d�S�)Nrb���rc���rd���r���re���zupdating catalog %s based on %s)rV���rR���)r����rg���)r����r����Zinclude_previousr����)"rU���rV���rh���ri���rj���rk���r����rR���rl���rm���r����splitext�basenamerT���ro���r���r���rq���r����r����r����r�����tempfileZ gettempprefixr���r����r����r����r�����remove�rename�OSError�shutilr����)r5���ru���rV���rv���rR���rx����templater����r_���ZtmpnameZtmpfiler$���r$���r%���ra������sj�������&.� ���* zupdate_catalog.runNr����r$���r$���r$���r%���r����x��s���r����c�������������������@���s^���e�Zd�ZdZdZde�Zddddd�Zee e ed�Zd Z dd d�Zdd ��Zdd��Zdd��Zd S�)�CommandLineInterfacez�Command-line interface. This class provides a simple command-line interface to the message extraction and PO file generation functionality. z%%prog %s [options] %sz %%prog %sz$compile message catalogs to MO filesz:extract messages from source files and generate a POT filez+create new message catalogs from a POT filez0update existing message catalogs from a POT file)�compile�extract�initr����Nc�����������������C���s���|du�rt�j}tj|�jd�|�jd�|�_|�j����|�j|�j_ |�jj ddddd��|�jj d d ddtjd d��|�jj ddddtj dd��|�jjdtjd��|�j�|dd���\}}|��|j��|j�r6t���}tdd��|D���}|����d|d��}|D�]>}t�|�}|||jf�} t| �t�jj�p(t���p(dd���q�dS�|�sH|�j� d��|d�} | |�j!v�rl|�j� d| ���|��"| |dd���}|�#��S�)z{Main entry point of the command-line interface. :param argv: list of arguments passed on the command-line N)�commandz[args])�usager����z--list-locales�list_locales� store_truez print all known locales and exit)�dest�actionr4���z-vz --verbose�store_const�loglevelzprint as much as possible)r����r�����constr4���z-qz--quietzprint as little as possibleF)r����r����rZ���c�����������������S���s���g�|�]}t�|��qS�r$����r]���)r"���� identifierr$���r$���r%���r����A��r'���z,CommandLineInterface.run.<locals>.<listcomp>z %%-%ds %%s�ascii�replacer���zQno valid command or option passed. Try the -h/--help option for more information.zunknown command "%s")$�sys�argv�optparse�OptionParserr����r�����parserZdisable_interspersed_args�_help� print_help� add_option�logging�DEBUGZERROR�set_defaults�INFO� parse_args�_configure_loggingr����r����r���Zlocale_identifiers�max�sortr���r����Zenglish_name�print�encode�stdout�encodingr���r^����commands�_configure_commandra���)r5���r����r�����argsZidentifiers�longest�formatr����rV����output�cmdname�cmdinstr$���r$���r%���ra���$��sV����� ��� ��zCommandLineInterface.runc�����������������C���sd���t��d�|�_|�j�|��|�jjr.|�jjd�}nt����}|�j�|��|�|��t��d�}|�|��d�S�)N�babelr���z%(message)s) r���Z getLoggerr���ZsetLevel�handlersZ StreamHandlerZ addHandlerZ FormatterZsetFormatter)r5���r����Zhandler� formatterr$���r$���r%���r��W��s���� z'CommandLineInterface._configure_loggingc�����������������C���sl���t�|�j�����t�d��tdd��|�jD���}dtd|d���}t|�j����}|D�]\}}t�|||f���qNd�S�)Nz commands:c�����������������S���s���g�|�]}t�|��qS�r$���r����)r"���r����r$���r$���r%���r����i��r'���z.CommandLineInterface._help.<locals>.<listcomp>z %%-%ds %%s����rZ���)r��r�����format_helpr��r���sortedr\���)r5���r��r��r��r����r|���r$���r$���r%���r����f��s����zCommandLineInterface._helpc�������������� ���C���s���|�j�|�}|��}|�jr|�j|_|����tj|�j|df�|�j|�d�}t|dd�}|jD�]�\}}} |� d�} t|| � dd��}d| �g}|r�|�d |���|�|j �| d���|j�| d �} | |kr�|�jd| �7��_qV| |jv�r�|j|d| d ���qV| |jv��r|j|d| | d���qV|j|| || d���qV|�|�\}}|�rTt||� dd�|��t|����D�]\}}t|||���q`z|����W�n4�t�y��}�z|�t|���W�Y�d }~n d }~0�0�|S�)zB :type cmdname: str :type argv: list[str] r����)r����r|���r;���r$����=�-�_z--%sz-%sNz<%s>r����)r����r4���rh���)r����r4����choices)r4����defaultr��)�command_classesr���r1���r����r����r����r��r����r}���r!���r����rh���r+���r>����getr?���r=���r����r<���r���setattr�varsr\���Zensure_finalizedr���r^����str)r5���r��r����Zcmdclassr��r����r;���ZlongZshortr4���r����r��Zstrsr��r����r���keyr�����errr$���r$���r%���r ��o��sF���� � $z'CommandLineInterface._configure_command)N)r8���r9���r:���r{���r�����VERSIONr����r��rA���r~���r����r����r��r���ra���r��r����r ��r$���r$���r$���r%���r������s$����� 3 r����c�������������������C���s���t����tj�S�r���)r����ra���r����r����r$���r$���r$���r%����main���s����r'��c����������� ������C���s����i�}g�}i�}t���}t|j�|_tr0|�|�|��n|�|�|��|���D�]V}|dkr`t|�|��}qDdd��|� dd�D��\}}|� ||f��t|�|��||<�qD|r�t|�D�](\} \}}||v�r�||�}||f|| <�q�||fS�)a��Parse an extraction method mapping from a file-like object. >>> buf = StringIO(''' ... [extractors] ... custom = mypackage.module:myfunc ... ... # Python source files ... [python: **.py] ... ... # Genshi templates ... [genshi: **/templates/**.html] ... include_attrs = ... [genshi: **/templates/**.txt] ... template_class = genshi.template:TextTemplate ... encoding = latin-1 ... ... # Some custom extractor ... [custom: **/custom/*.*] ... ''') >>> method_map, options_map = parse_mapping(buf) >>> len(method_map) 4 >>> method_map[0] ('**.py', 'python') >>> options_map['**.py'] {} >>> method_map[1] ('**/templates/**.html', 'genshi') >>> options_map['**/templates/**.html']['include_attrs'] '' >>> method_map[2] ('**/templates/**.txt', 'genshi') >>> options_map['**/templates/**.txt']['template_class'] 'genshi.template:TextTemplate' >>> options_map['**/templates/**.txt']['encoding'] 'latin-1' >>> method_map[3] ('**/custom/*.*', 'mypackage.module:myfunc') >>> options_map['**/custom/*.*'] {} :param fileobj: a readable file-like object containing the configuration text to parse :see: `extract_from_directory` � extractorsc�����������������S���s���g�|�]}|�����qS�r$���r ���)r"����partr$���r$���r%���r�������r'���z!parse_mapping.<locals>.<listcomp>�:rZ���)r���r���Z _sectionsr���ZreadfpZ read_fileZsectionsr����r\���r���rh���rn���) r����r����r(��r����r����r�����sectionr����r����rw���r$���r$���r%���r�������s(����1r����c�����������������C���s����i�}|�D�]�}d|v�r$|��d�\}}n |d�}}||vr|r�g�}|��d�D�]:}|d�dkrt|�t|dd���df��qH|�t|���qHt|�}|||<�q|S�)aQ��Parse keywords specifications from the given list of strings. >>> kw = sorted(parse_keywords(['_', 'dgettext:2', 'dngettext:2,3', 'pgettext:1c,2']).items()) >>> for keyword, indices in kw: ... print((keyword, indices)) ('_', None) ('dgettext', (2,)) ('dngettext', (2, 3)) ('pgettext', ((1, 'c'), 2)) r*��Nr�������r����)r���rh���r����r*���)�stringsr����rp����funcname�indicesZinds�xr$���r$���r%���r�������s���� r�����__main__)N)N)Cr{���Z __future__r���r���r����ri���r����r����r����r�����collectionsr���r���rV���r���r��r���r&��r���r���Z babel._compatr ���r ���r���r���Z babel.corer ���Zbabel.messages.catalogr���Zbabel.messages.extractr���r���r���r���Zbabel.messages.mofiler���Zbabel.messages.pofiler���r���Z babel.utilr���Z distutilsr���r@���Z distutils.cmdr���Z_CommandZdistutils.errorsr���r���ZConfigParserr����ImportErrorZconfigparserr����r,���rA���r~���r����r����r�����objectr����r'��r����r����r8���r$���r$���r$���r%����<module>���s\��� *)� ��[�� N