From df02690361f04ac341c58be2e79ed055f9ebd690 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 22 Jun 2020 17:45:54 -0700 Subject: [PATCH] Add touch.py. --- voussoirkit/touch.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 voussoirkit/touch.py diff --git a/voussoirkit/touch.py b/voussoirkit/touch.py new file mode 100644 index 0000000..5e10d5d --- /dev/null +++ b/voussoirkit/touch.py @@ -0,0 +1,24 @@ +''' +Create the file, or update the last modified timestamp. +''' +import os +import sys + +from voussoirkit import clipext +from voussoirkit import safeprint +from voussoirkit import winglob + +def touch(glob_pattern): + filenames = winglob.glob(glob_pattern) + if len(filenames) == 0: + safeprint.safeprint(glob_pattern) + open(glob_pattern, 'a').close() + else: + for filename in filenames: + safeprint.safeprint(filename) + os.utime(filename) + +if __name__ == '__main__': + glob_patterns = [clipext.resolve(x).strip() for x in sys.argv[1:]] + for glob_pattern in glob_patterns: + touch(glob_pattern)