]> git.phdru.name Git - m_lib.git/blob - m_lib/clock/mkclock.py
db69be6cb433346644a268df024d4a72d275a585
[m_lib.git] / m_lib / clock / mkclock.py
1 #! /usr/bin/env python
2 """Test if current interpreter do not have clock() and define it as need"""
3
4 from __future__ import print_function
5 import sys, time
6
7 print("Testing...", end=' ')
8 sys.stdout.flush()
9
10 time.sleep(3)
11 print('\n' + " "*len("Testing...") + '\n', end=' ')
12
13 need_clock = time.clock() <> 3
14
15 outfile = open("clock.py", 'w')
16
17 if need_clock:
18    print("Generaing clock.py with custom clock()")
19    outfile.write("""\"\"\"
20    Define clock() for systems that do not have it
21 \"\"\"
22
23 from time import time
24 _clock = time()
25
26 def clock():
27    return int(time() - _clock)
28 """)
29 else:
30    print("Generaing clock.py with standard clock()")
31    outfile.write("""\"\"\"
32    Define clock() shim
33 \"\"\"
34
35 from time import clock
36    """)