aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/touch.py
diff options
context:
space:
mode:
authoralbert <albert@yandex-team.ru>2022-02-10 16:48:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:15 +0300
commita817f5de12611ec73085eba17f8ec7740a46bdb7 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /build/scripts/touch.py
parent9f25ef3232c288ca664ceee6c376cf64e4349a2e (diff)
downloadydb-a817f5de12611ec73085eba17f8ec7740a46bdb7.tar.gz
Restoring authorship annotation for <albert@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/touch.py')
-rwxr-xr-xbuild/scripts/touch.py92
1 files changed, 46 insertions, 46 deletions
diff --git a/build/scripts/touch.py b/build/scripts/touch.py
index 4c9296e65d..e01ba7f86b 100755
--- a/build/scripts/touch.py
+++ b/build/scripts/touch.py
@@ -1,50 +1,50 @@
-#!/usr/bin/env python
-
-import optparse
-import os
-import sys
-import time
-
-
-def main(argv):
+#!/usr/bin/env python
+
+import optparse
+import os
+import sys
+import time
+
+
+def main(argv):
parser = optparse.OptionParser(add_help_option=False)
- parser.disable_interspersed_args()
-
+ parser.disable_interspersed_args()
+
parser.add_option('-?', '--help', dest='help',
action='store_true', default=None, help='print help')
parser.add_option('-t', dest='t', action='store', default=None)
-
- opts, argv_rest = parser.parse_args(argv)
- if getattr(opts, 'help', False):
- parser.print_help()
- return 0
-
- tspec = opts.t
- if tspec is None:
- times = None
- else:
- head, sep, tail = tspec.partition('.')
- if 8 > len(head):
- raise Exception("time spec must follow format [[CC]YY]MMDDhhmm[.SS]: " + tspec + '; ' + head)
- tfmt = ''
- if 12 == len(head):
- tfmt += '%Y'
- elif 10 == len(head):
- tfmt += '%y'
- tfmt += '%m%d%H%M'
- if 2 == len(tail):
- tfmt += '.%S'
- mtime = time.mktime(time.strptime(tspec, tfmt))
- times = (mtime, mtime)
-
- for file in argv_rest:
- try:
- os.utime(file, times)
- except:
- open(file, 'w').close()
- if times is not None:
- os.utime(file, times)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+
+ opts, argv_rest = parser.parse_args(argv)
+ if getattr(opts, 'help', False):
+ parser.print_help()
+ return 0
+
+ tspec = opts.t
+ if tspec is None:
+ times = None
+ else:
+ head, sep, tail = tspec.partition('.')
+ if 8 > len(head):
+ raise Exception("time spec must follow format [[CC]YY]MMDDhhmm[.SS]: " + tspec + '; ' + head)
+ tfmt = ''
+ if 12 == len(head):
+ tfmt += '%Y'
+ elif 10 == len(head):
+ tfmt += '%y'
+ tfmt += '%m%d%H%M'
+ if 2 == len(tail):
+ tfmt += '.%S'
+ mtime = time.mktime(time.strptime(tspec, tfmt))
+ times = (mtime, mtime)
+
+ for file in argv_rest:
+ try:
+ os.utime(file, times)
+ except:
+ open(file, 'w').close()
+ if times is not None:
+ os.utime(file, times)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))