marshal-parser 0.1.1

Parser for Python's "marshal" serialization format
Documentation
�

�Y�e���ddlZddlZddlmZddlmZd
d�Zdeefd�Z	deefd�Z
dedeefd	�ZdS)�N)�Optional)�InvalidFeatureErrorc�F�tj��}|�ddd���|���}|�dd���}|�ddd	d
���|�dd
d	d���|�ddd	d���|�dddd���|�d���|�dd���}|�dddd���|�ddd	d���|�d���|�dd���}|�dddd ���|�ddd	d���|�d���|�d!d"���}|�d!���|�d#d$���}|�d#���|�d%d&���}|�d%���|�d'd(���}	|	�d'���|�d)d*���}
|
�d#d+���|
�d)���|�d,d-���}|�d#d.���|�d,���|�d/d0���}|�d/���|r|�|��S|���S)1z�
    Constructs the command-line argument parser for cargo2rpm.

    If arguments are passed to this function, they are parsed instead of parsing
    actual command line arguments. This is useful for testing parser behaviour.
    z-pz--pathz8Path to Cargo.toml (for current crate or workspace root))�help�
buildrequiresz*Print BuildRequires for the current crate.z-tz--with-check�
store_truezInclude dev-dependencies.)�actionrz-az--all-featureszEnable all featuresz-nz--no-default-featureszDisable default featuresz-fz-Fz
--featuresz*Comma-separated list of features to enable)r	�requiresz;Print Requires for the current crate and the given feature.z	--featurez-Name of the feature to generate Requires for.z-sz--subpackagez(Treat the argument as a subpackage name.�providesz;Print Provides for the current crate and the given feature.z-Name of the feature to generate Provides for.�namez$Print the name of the current crate.�versionz'Print the version of the current crate.zis-libzDPrint 1 if the current crate is a library target, otherwise print 0.zis-binzCPrint 1 if the current crate has binary targets, otherwise print 0.�
semver2rpmz7Convert SemVer version string to equivalent RPM format.zSemVer compliant version string�
rpm2semverz7Convert RPM version string to equivalent SemVer format.zRPM version stringzparse-vendor-manifestz:Parse vendor manifest generated by %%cargo_vendor_manifest)�argparse�ArgumentParser�add_argument�add_subparsers�
add_parser�set_defaults�
parse_args)
�args�parser�action_parsers�
action_brs�
action_req�action_prov�action_name�action_version�
action_is_lib�
action_is_bin�action_semver_to_rpm�action_rpm_to_semver�action_parse_vendor_manifests
             �3/home/deca/Projects/rust/cargo2rpm/cargo2rpm/cli.py�get_argsr%s����
$�
&�
&�F�
����h�-g��h�h�h��*�*�,�,�N��*�*�?�Am�*�n�n�J����D�.��Lg��h�h�h����D�"2�<�Nc��d�d�d����D�"9�,�Uo��p�p�p����D�$��;g��h�h�h����?��3�3�3��*�*�:�<y�*�z�z�J����D�$��:i��j�j�j����D�.��Lv��w�w�w����:��.�.�.� �+�+�J�=z�+�{�{�K����T�4��;j��k�k�k����T�>�,�Mw��x�x�x����J��/�/�/� �+�+�F�9_�+�`�`�K����F��+�+�+�#�.�.�y�?h�.�i�i�N����y��1�1�1�"�-�-�h�>D�-�E�E�M����h��/�/�/�"�-�-�h�>C�-�D�D�M����h��/�/�/�)�4�4�\�IB�4�C�C���%�%�i�6W�%�X�X�X��%�%�\�%�:�:�:�)�4�4�\�IB�4�C�C���%�%�i�6J�%�K�K�K��%�%�\�%�:�:�:�#1�#<�#<��&b�$=�$�$� �!�-�-�5L�-�M�M�M��#�� � ��&�&�&�� � �"�"�"��returnc�j�d�tj���D��}d�|D��S)z�
    Read lines from standard input and filter out lines that look like paths
    to `Cargo.toml` files. This is how RPM generators pass lists of files.
    c�8�h|]}|�d����S��
��rstrip��.0�lines  r$�	<setcomp>z2get_cargo_toml_paths_from_stdin.<locals>.<setcomp>J�$��A�A�A�4�T�[�[��
�
�A�A�Ar&c�<�h|]}|�d���|��S)z/Cargo.toml��endswithr.s  r$r1z2get_cargo_toml_paths_from_stdin.<locals>.<setcomp>Ks)��C�C�C�T�d�m�m�M�&B�&B�C�D�C�C�Cr&��sys�stdin�	readlines��liness r$�get_cargo_toml_paths_from_stdinr<Ds:��
B�A�3�9�+>�+>�+@�+@�A�A�A�E�C�C�U�C�C�C�Cr&c�j�d�tj���D��}d�|D��S)z�
    Read lines from standard input and filter out lines that look like paths
    to `cargo-vendor.txt` files. This is how RPM generators pass lists of files.
    c�8�h|]}|�d����Sr*r,r.s  r$r1z8get_cargo_vendor_txt_paths_from_stdin.<locals>.<setcomp>Tr2r&c�<�h|]}|�d���|��S)z/cargo-vendor.txtr4r.s  r$r1z8get_cargo_vendor_txt_paths_from_stdin.<locals>.<setcomp>Us*��I�I�I�T�d�m�m�4G�&H�&H�I�D�I�I�Ir&r6r:s r$�%get_cargo_vendor_txt_paths_from_stdinr@Ns:��
B�A�3�9�+>�+>�+@�+@�A�A�A�E�I�I�U�I�I�I�Ir&�
subpackagec�F�|�d��std���|�d��std���|�d���d��}d|vr,|�dd��\}}|std���|SdS)	a
    Parses a Rust crate subpackage name into the name of the corresponding
    crate feature. This is how RPM generators determine which feature to
    generate Provides and Requires for.

    Two formats of arguments are valid:

    - main subpackage (contains source code): `rust-{crate}-devel`
    - feature subpackages (metadata only): `rust-{crate}+{feature}-devel`

    Raises an `InvalidFeatureError` for invalid arguments. This exception
    triggers RPM generators to produce invalid output, which stops RPM builds.
    zrust-z0Invalid subpackage name (missing 'rust-' prefix)z-develz1Invalid subpackage name (missing '-devel' suffix)�+�zNInvalid subpackage name (crate name cannot be empty or contain '+' characters)N)�
startswithrr5�removeprefix�removesuffix�split)rA�crate_plus_feature�crate�features    r$�get_feature_from_subpackagerLXs���� � ��)�)�V�!�"T�U�U�U����x�(�(�W�!�"U�V�V�V�#�0�0��9�9�F�F�x�P�P��
� � � �+�1�1�#�q�9�9���w��	x�%�&v�w�w�w����tr&)N)rr7�typingr�
cargo2rpm.rpmrr%�set�strr<r@rL�r&r$�<module>rRs�������
�
�
�
�������-�-�-�-�-�-�9#�9#�9#�9#�xD��S��D�D�D�D�J�s�3�x�J�J�J�J� �C� �H�S�M� � � � � � r&