Skip to content

Instantly share code, notes, and snippets.

@jxnl
Created January 6, 2015 21:30
Show Gist options
  • Save jxnl/a7d3ad2e0d95fb016108 to your computer and use it in GitHub Desktop.
Save jxnl/a7d3ad2e0d95fb016108 to your computer and use it in GitHub Desktop.
Generates a template for cs116 assginments
"""
This script generates a template rkt file for cs116 assignments
Generates the assignment header. sample contract and sample function.
Usage:
python new_assignment.py A Q NameOfAssignment
Author: Jason Liu
Date: May 20th, 2014
"""
import sys
temp = """
;; *************************************************
;; Jiaxin Liu (20468322)
;; CS 116 Winter 2015
;; Assignment {}, Problem {}
;; ({})
;; *************************************************
;; (function-name inputs) ---
;; Requires: ---
;; Effects: ---
;; function-name: Type -> Type
;; Examples:
(check-expect (function-name inputs) outputs)
(define (function-name inputs) ...)
"""
def main():
_, assignment, question, name = sys.argv
assignment_title = "a{}q{}.rkt".format(assignment, question)
with open(assignment_title, 'a') as fs:
fs.write(temp.format(assignment, question, name))
print('Made {}'.format(assignment_title))
if __name__ == "__main__":
sys.exit(main())
@jxnl
Copy link
Author

jxnl commented Jan 6, 2015

Perhaps it should read a YAML script and turn it into a .rkt template. LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment