Skip to main content

pathvalidate is a python library to validate/sanitize a string such as filename/LTSV-label/variable-name/excel-sheet-name.

Project description

pathvalidate

https://badge.fury.io/py/pathvalidate.svg https://img.shields.io/pypi/pyversions/pathvalidate.svg Linux CI test status Windows CI test status https://coveralls.io/repos/github/thombashi/pathvalidate/badge.svg?branch=master

Summary

pathvalidate is a python library to validate/sanitize a string such as filename/LTSV-label/variable-name/excel-sheet-name.

Feature

Examples

Validate a filename

import pathvalidate

try:
    pathvalidate.validate_filename("_a*b:c<d>e%f/(g)h+i_0.txt")
except ValueError:
    print("invalid filename!")
invalid filename!

Sanitize a filename

import pathvalidate

filename = "_a*b:c<d>e%f/(g)h+i_0.txt"
print(pathvalidate.sanitize_filename(filename))
_abcde%f(g)h+i_0.txt

Sanitize a variable name

import pathvalidate

print(pathvalidate.sanitize_python_var_name("_a*b:c<d>e%f/(g)h+i_0.txt"))
abcdefghi_0txt

For more information

More examples are available at http://pathvalidate.readthedocs.org/en/latest/pages/examples/index.html

Installation

pip install pathvalidate

Dependencies

Python 2.7 or 3.3+

Test dependencies

Documentation

http://pathvalidate.readthedocs.org/en/latest/

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pathvalidate-0.10.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pathvalidate-0.10.0-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pathvalidate-0.10.0.tar.gz.

File metadata

  • Download URL: pathvalidate-0.10.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pathvalidate-0.10.0.tar.gz
Algorithm Hash digest
SHA256 8b1c8102b523ef97b84a00ce66582d6b874303ee782b69da26f2a5f22b927d3c
MD5 b0a4d48e73e687b576d82cbdf24b8c81
BLAKE2b-256 d872b3ac1c1aa74e8a363ac2b3b27110e44931c1da6e4ac098c2d8d67536c7a9

See more details on using hashes here.

File details

Details for the file pathvalidate-0.10.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pathvalidate-0.10.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4e5352954989ae7e915c34a4c9399568765575f5c4884feefd331083ceb893b3
MD5 7e962cc56064d32e9b7b76403740f92d
BLAKE2b-256 2130ad571f65d1b3255c89ca3bbf2a63afe2ed21c6f202511f51f90a32bda571

See more details on using hashes here.

Supported by

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