Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Submission_Document_Builder/create_submission_document.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
32 lines (27 sloc)
1.22 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from config import Configuration | |
import os | |
import subprocess | |
if __name__ == '__main__': | |
# Grab the Python source-code files to include in the submission document | |
files = [f for f in os.listdir('src') if os.path.isfile(os.path.join('src/', f))] | |
# Create the Markdown version of the submission document | |
with open(f'{Configuration.STUDENT_ID}_submission_document.md', 'w') as f: | |
yml = open('header.yml', 'r') | |
f.write(f'{yml.read()}') | |
f.write('\n') | |
yml.close() | |
f.write('# GitHub Repository Link\n') | |
f.write(f'{Configuration.GIT_REPO_LINK}\n') | |
for file in files: | |
f.write(f'\n\\newpage\n') | |
f.write(f'# {file}\n') | |
f.write(f'```python\n') | |
f.write(f'!include src/{file}\n') | |
f.write(f'```\n') | |
# Create the PDF for submission | |
mdDoc = os.path.join(f'{Configuration.STUDENT_ID}_submission_document.md') | |
pdfDoc = os.path.join(f'{Configuration.STUDENT_ID}_submission_document.pdf') | |
cmd = f'pandoc -s {mdDoc} --listings --filter pandoc-include -o out/{pdfDoc}'.split() | |
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate() | |
# Delete the Markdown File | |
os.remove(mdDoc) |