marshal-parser 0.1.1

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

�Y�ec@spddlZddlZddlmZddlmZddd�Zdeefdd�Z	deefd	d
�Z
dedeefdd
�ZdS)iN)�Optional)�InvalidFeatureErrorc
Cs�t��}|jdddd�|��}|jddd�}|jddd	d
d�|jdd
d	dd�|jddd	dd�|jddddd�|jdd�|jddd�}|jddddd�|jddd	dd�|jdd�|jddd�}|jdddd d�|jddd	dd�|jdd�|jd!d"d�}|jd!d�|jd#d$d�}|jd#d�|jd%d&d�}|jd%d�|jd'd(d�}	|	jd'd�|jd)d*d�}
|
jd#d+d�|
jd)d�|jd,d-d�}|jd#d.d�|jd,d�|jd/d0d�}|jd/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))�helpZ
buildrequiresz*Print BuildRequires for the current crate.z-tz--with-checkZ
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)rZrequiresz;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.Zprovidesz;Print Provides for the current crate and the given feature.z-Name of the feature to generate Provides for.Znamez$Print the name of the current crate.Zversionz'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.Z
semver2rpmz7Convert SemVer version string to equivalent RPM format.zSemVer compliant version stringZ
rpm2semverz7Convert RPM version string to equivalent SemVer format.zRPM version stringzparse-vendor-manifestz:Parse vendor manifest generated by %%cargo_vendor_manifest)�argparseZArgumentParserZadd_argumentZadd_subparsersZ
add_parserZset_defaultsZ
parse_args)
ZargsZparserZaction_parsersZ
action_brsZ
action_reqZaction_provZaction_nameZaction_versionZ
action_is_libZ
action_is_binZaction_semver_to_rpmZaction_rpm_to_semverZaction_parse_vendor_manifest�r�3/home/deca/Projects/rust/cargo2rpm/cargo2rpm/cli.py�get_argssL�
rZreturncC�"dd�tj��D�}dd�|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.
    cS�h|]}|�d��qS�Z
�Zrstrip�Z.0Zlinerrr�	<setcomp>J�z2get_cargo_toml_paths_from_stdin.<locals>.<setcomp>cS�h|]	}|�d�r|�qS)z/Cargo.toml��endswithrrrrr
K���sysZstdinZ	readlines�Zlinesrrr�get_cargo_toml_paths_from_stdinD�rcCr)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.
    cSr	r
rrrrrr
Trz8get_cargo_vendor_txt_paths_from_stdin.<locals>.<setcomp>cSr)z/cargo-vendor.txtrrrrrr
Urrrrrr�%get_cargo_vendor_txt_paths_from_stdinNrr�
subpackagecCs`|�d�s	td��|�d�std��|�d��d�}d|vr.|�dd�\}}|s,td��|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)z+izNInvalid subpackage name (crate name cannot be empty or contain '+' characters)N)Z
startswithrrZremoveprefixZremovesuffixZsplit)rZcrate_plus_featureZcrateZfeaturerrr�get_feature_from_subpackageXs

r)N)rrZtypingrZ
cargo2rpm.rpmrrZsetZstrrrrrrrrZ<module>s
<