File: is_valid_filename_code.txt

package info (click to toggle)
python-pathvalidate 3.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 692 kB
  • sloc: python: 3,987; makefile: 262; sh: 6
file content (17 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
:Sample Code:
    .. code-block:: python

        from pathvalidate import is_valid_filename, sanitize_filename

        fname = "fi:l*e/p\"a?t>h|.t<xt"
        print(f"is_valid_filename('{fname}') return {is_valid_filename(fname)}\n")

        sanitized_fname = sanitize_filename(fname)
        print(f"is_valid_filename('{sanitized_fname}') return {is_valid_filename(sanitized_fname)}\n")

:Output:
    .. code-block:: none

        is_valid_filename('fi:l*e/p"a?t>h|.t<xt') return False

        is_valid_filename('filepath.txt') return True