Skip to main content

pathvalidate is a python library to validate filename.

Project description

pathvalidate

https://img.shields.io/pypi/pyversions/pathvalidate.svg https://travis-ci.org/thombashi/pathvalidate.svg?branch=master https://coveralls.io/repos/github/thombashi/pathvalidate/badge.svg?branch=master

Summary

pathvalidate is a python library to validate filename.

Installation

pip install pathvalidate

Usage

Filename validation

import pathvalidate

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

Replace invalid chars

import pathvalidate

filename = "a*b:c<d>e%f(g)h.txt"
print(pathvalidate.sanitize_filename(filename))
abcde%f(g)h+i.txt

Replace symbols

import pathvalidate

filename = "a*b:c<d>e%f(g)h.txt"
print(pathvalidate.replace_symbol(filename))
abcdefgh+itxt

Dependencies

Python 2.6+ or 3.3+

Test dependencies

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.1.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

pathvalidate-0.1.0-py2.py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 2 Python 3

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