Skip to main content

Simple python package to handle cli user input.

Project description

Travis CI build SonarCloud Quality SonarCloud Maintainability Codacy Maintainability Maintainability Pypi project Pypi total project downloads

Simple python package to handle cli user input.

How do I install this package?

As usual, just download it using pip:

pip install userinput

Tests Coverage

Since some software handling coverages sometimes

get slightly different results, here’s three of them:

Coveralls Coverage SonarCloud Coverage Code Climate Coverate

Available validators

Some commonly used validators are available with the package.

Validator name

Description

email

Check if given input string is a valid email.

version_code

Check if given input string is a valid version code.

url

Check if given input string is a valid URL. Does not check if given URL is online.

human_bool

Check if given input string is a human Boolean, such as “yes”, “y”, “true”, “si”, “no”, “n”, “false”.

integer

Check if given input string is a integer numeric value.

positive_integer

Check if given input string is a positive integer numeric value.

non_empty

Check if given input string is not empty.

hostname

Check if given input string is a reachable host name.

ip

Check if given input string is a reachable IP address.

Use them as follows:

from userinput import userinput

result = userinput(
    "my_label",
    validator="validator name goes here"
)

You can also chain validators. They will be called in the order you provide.

from userinput import userinput

result = userinput(
    "my_label",
    validator=[
        "validator name goes here",
        my_custom_validation_function
    ]
)

Available sanitizers

Some commonly used sanitizers are available with the package.

Validator name

Description

human_bool

Cast human Boolean specified above in validators to python Booleans.

strip

Remove padding spaces and repeated spaces.

Use them as follows:

from userinput import userinput

result = userinput(
    "my_label",
    sanitizer="sanitizer name goes here"
)

You can also chain sanitizers. They will be called in the order you provide.

from userinput import userinput

result = userinput(
    "my_label",
    sanitizer=[
        "sanitizer name goes here",
        my_custom_sanitification_function
    ]
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

userinput-1.0.10.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file userinput-1.0.10.tar.gz.

File metadata

  • Download URL: userinput-1.0.10.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for userinput-1.0.10.tar.gz
Algorithm Hash digest
SHA256 cb69b6b997fa9ba8e647fa7afad5d5d4fcb844f73848a402652f321e1a6a83b2
MD5 81ba45089c44f79e088a44dd76ace9f3
BLAKE2b-256 75e887b24c46f7d94bb85b3c8342e55fffabc8ac66dda60cec0b4bc94c7024a5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page