Add touch.py.
This commit is contained in:
parent
4fa8265be2
commit
df02690361
1 changed files with 24 additions and 0 deletions
24
voussoirkit/touch.py
Normal file
24
voussoirkit/touch.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue