Miki Tebeka avatar Miki Tebeka committed 4e2fe66

Prolog

Comments (0)

Files changed (1)

 from collections import namedtuple
 
 def which(name):
-    for path in environ["PATH"].split(":"):
+    for path in environ['PATH'].split(':'):
         full = join(path, name)
         if not isfile(full):
             continue
 def with_args(command, **kw):
     name, args = command[0], command[1:]
 
-    full = name if ("/" in name) else which(name)
+    full = name if ('/' in name) else which(name)
 
-    assert full, "can't find %s" % name
+    assert full, 'cannot find %s' % name
 
-    if (not args) and kw.get("arg"):
-        args = [kw["arg"]]
+    if (not args) and kw.get('arg'):
+        args = [kw['arg']]
 
     return [full] + list(args)
 
-Script = namedtuple("Script", ["name", "command"])
+Script = namedtuple('Script', ['name', 'command'])
 
 def script(*args):
-    cmd = with_args(args, arg="/dev/null")
+    cmd = with_args(args, arg='/dev/null')
 
     return Script(args[0].title(), cmd)
 
 scripts = [
-    script("python"),
-    script("ruby"),
-    script("perl"),
-    script("newlisp", "-e", "(exit)"),
-    script("clisp", "-q", "-x", "(exit)"),
-    script("guile", "-c", ""),
-    script("mzscheme", "-e", ""),
+    script('python'),
+    script('ruby'),
+    script('perl'),
+    script('newlisp', '-e', '(exit)'),
+    script('clisp', '-q', '-x', '(exit)'),
+    script('guile', '-c', ''),
+    script('mzscheme', '-e', ''),
+    script('prolog', '-q', '-t', 'halt')
 ]
 
-Program = namedtuple("Program", ["name", "compile", "run"])
+Program = namedtuple('Program', ['name', 'compile', 'run'])
 
 def program(compile, run, **kw):
-    name = kw.get("name") or compile[0]
+    name = kw.get('name') or compile[0]
 
     return Program(name.title(), with_args(compile), with_args(run))
 
 programs = [
-    program(["gcc", "-O3", "-o", "noop", "noop.c"],
-            ["./noop"]),
-    program(["g++", "-O3", "-o", "noopcc", "noop.cc"],
-            ["./noopcc"]),
-    program(["javac", "noop.java"], ["java", "noop"], name="java"),
-    program(["gmcs", "-optimize+", "noop.cs"], ["./noop.exe"], name="mono"),
-    program(["ghc", "-v0", "-O", "-o", "noophs", "noop.hs"], ["./noophs"]),
-    program(["./go.sh", "noop.go"], ["./noopgo"], name="go"),
+    program(['gcc', '-O3', '-o', 'noop', 'noop.c'],
+            ['./noop']),
+    program(['g++', '-O3', '-o', 'noopcc', 'noop.cc'],
+            ['./noopcc']),
+    program(['javac', 'noop.java'], ['java', 'noop'], name='java'),
+    program(['gmcs', '-optimize+', 'noop.cs'], ['./noop.exe'], name='mono'),
+    program(['ghc', '-v0', '-O', '-o', 'noophs', 'noop.hs'], ['./noophs']),
+    program(['./go.sh', 'noop.go'], ['./noopgo'], name='go'),
 ]
 
 def timeit(command):
     start = time()
-    with open("/dev/null", "wb") as fo:
+    with open('/dev/null', 'wb') as fo:
         retval = call(command, shell=0, stdout=fo)
     end = time()
 
-    assert retval == 0, "%s" % " ".join(command)
+    assert retval == 0, '%s' % ' '.join(command)
 
     return end - start
 
     maxlen = max((len(rt[1]) for rt in runtimes)) + 1
     runtimes.sort()
     for runtime, name in runtimes:
-        print "%-*s: %f" % (maxlen, name, runtime)
+        print '%-*s: %f' % (maxlen, name, runtime)
 
-if __name__ == "__main__":
+if __name__ == '__main__':
     run()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.