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