Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 63 lines (54 sloc) 1.571 kb
4d1f1a1 @jabbalaci get_alap.py added
authored
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import shutil
6
7 CWD = os.getcwd()
8 TEMPLATES = os.path.abspath(os.path.dirname(sys.argv[0])) + '/' + 'templates'
9
10
11 def copy(ext, full_name=None):
12 if full_name:
13 source = full_name
14 else:
15 source = 'alap.' + ext
16 #
17 if os.path.isfile(CWD + '/' + source):
18 print >>sys.stderr, 'Warning: {} already exists in the current directory.'.format(source)
19 sys.exit(1)
20 # else
21 shutil.copyfile(TEMPLATES + '/' + source, CWD + '/' + source)
22 if os.path.isfile(CWD + '/' + source):
23 print '# {} is created'.format(source)
24 return 0 # OK
25 else:
26 print "Warning: couldn't copy {}.".format(source)
27 return 1 # problem
28
29
30 def main():
31 print """---------------------------
32 Create an empty source file
33 ---------------------------
34 1) Python [py]
35 2) C [c]
36 3) D [d]
37 4) Java [java]
38 q) quit"""
39 while True:
40 try:
41 ch = raw_input('> ')
42 except (EOFError, KeyboardInterrupt):
43 print
44 ch = 'q'
45 if ch in ['1', 'py']:
46 sys.exit(copy('py'))
47 elif ch in ['2', 'c']:
48 sys.exit(copy('c'))
49 elif ch in ['3', 'd']:
50 sys.exit(copy('d'))
51 elif ch in ['4', 'java']:
52 sys.exit(copy('java', full_name='Alap.java'))
53 elif ch == 'q':
54 print 'bye.'
55 sys.exit(0)
56 else:
57 print 'Wat?'
58
59 #############################################################################
60
61 if __name__ == "__main__":
62 main()
Something went wrong with that request. Please try again.