Skip to content

Instantly share code, notes, and snippets.

View Roang-zero1's full-sized avatar

Lucas Brandstätter Roang-zero1

View GitHub Profile
@Roang-zero1
Roang-zero1 / argparse-dir-arg.py
Last active October 28, 2020 12:37 — forked from Tatsh/argparse-dir-arg.py
Check if a directory argument is writeable or readable.
import argparse
from os import R_OK, W_OK, access
from pathlib import Path
class ReadableDirectoryAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
prospective_dir = Path(values)
if not prospective_dir.is_dir():