Permalink
Browse files

get_alap.py added

  • Loading branch information...
jabbalaci committed Aug 16, 2012
1 parent 5f5974e commit 4d1f1a1c3f044e39b2264e4f440f5978a9e01fc3
Showing with 103 additions and 0 deletions.
  1. +62 −0 get_alap.py
  2. +13 −0 templates/Alap.java
  3. +8 −0 templates/alap.c
  4. +9 −0 templates/alap.d
  5. +11 −0 templates/alap.py
View
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import shutil
+
+CWD = os.getcwd()
+TEMPLATES = os.path.abspath(os.path.dirname(sys.argv[0])) + '/' + 'templates'
+
+
+def copy(ext, full_name=None):
+ if full_name:
+ source = full_name
+ else:
+ source = 'alap.' + ext
+ #
+ if os.path.isfile(CWD + '/' + source):
+ print >>sys.stderr, 'Warning: {} already exists in the current directory.'.format(source)
+ sys.exit(1)
+ # else
+ shutil.copyfile(TEMPLATES + '/' + source, CWD + '/' + source)
+ if os.path.isfile(CWD + '/' + source):
+ print '# {} is created'.format(source)
+ return 0 # OK
+ else:
+ print "Warning: couldn't copy {}.".format(source)
+ return 1 # problem
+
+
+def main():
+ print """---------------------------
+Create an empty source file
+---------------------------
+1) Python [py]
+2) C [c]
+3) D [d]
+4) Java [java]
+q) quit"""
+ while True:
+ try:
+ ch = raw_input('> ')
+ except (EOFError, KeyboardInterrupt):
+ print
+ ch = 'q'
+ if ch in ['1', 'py']:
+ sys.exit(copy('py'))
+ elif ch in ['2', 'c']:
+ sys.exit(copy('c'))
+ elif ch in ['3', 'd']:
+ sys.exit(copy('d'))
+ elif ch in ['4', 'java']:
+ sys.exit(copy('java', full_name='Alap.java'))
+ elif ch == 'q':
+ print 'bye.'
+ sys.exit(0)
+ else:
+ print 'Wat?'
+
+#############################################################################
+
+if __name__ == "__main__":
+ main()
View
@@ -0,0 +1,13 @@
+class Alap
+{
+ public static void main(String[] args)
+ {
+ Alap alap = new Alap();
+ alap.start();
+ }
+
+ private void start()
+ {
+ // TODO...
+ }
+}
View
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main()
+{
+ /* TODO... */
+
+ return 0;
+}
View
@@ -0,0 +1,9 @@
+#!/usr/bin/rdmd
+
+import std.stdio;
+
+int main()
+{
+ // TODO...
+ return 0;
+}
View
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+
+def main():
+ # TODO...
+ pass
+
+#############################################################################
+
+if __name__ == "__main__":
+ main()

0 comments on commit 4d1f1a1

Please sign in to comment.