snips lines from text files (automate creation of student copy from solution)
Project description
snip_copy
snip_copy creates copies of a file, snipping away portions of the original.
Our motivating use-case is to allow instructors to manage only a rubric.py copy of their assignment which contains student instructions, solutions to all problems and, grading criteria to be shared with TAs. Using snip_copy one can quickly create solution.py and student.py versions of the same assignment from rubric.py.
Installation
pip install snip_copy
Quick-start
Consider an example input file input.txt:
this text will be left unmodified in all copies
#! snip: a, b
this text will be removed in copies a and b
#! snip-end
this text will (also) be left unmodified in all copies
Running snip_copy as:
$ python3 -m snip_copy input.txt
generates two files, a.txt and b.txt where each has removed the snipped section.
Jupyter Notebooks
You can add snip commands to jupyter notebook cells (code or markdown) to achieve similar behavior as well. For example, given input rubric.ipynb, running the following command:
$ python3 -m snip_copy rubric.ipynb
generates solution.ipynb and student.ipynb.
Notes:
- a copy is made for each item which appears in a comma separated list after any
snipcommand in the entire document - snip commands are removed in all copies created
- Each snip command line contains
#!, which comments out the line, so it may live unobtrusively in python code. You can modify this string to produce similar behavior in another programming language:
$ python3 -m snip_copy input.txt --cmd '// !'
- It can be cumbersome to type the full names of every output file with every
snipcommand. Consider using--split:
$ python3 -m snip_copy hw_rub.txt --split '_'
which will "split" the input file name at the last occurrence of the given string. For example, if hw_rub.txt has the same contents as input.txt at the top, then the terminal command immediately above creates hw_a.txt and hw_b.txt.
- cells which do not include any snip commands are left unmodified in all copies
- if a cell's snip command would remove its entire contents, then we remove the cell entirely in the copy generated, rather than give a cell which is empty
- You can call
snip_copyfrom within jupyter via a code containing:
>>> #! snip: stud, sol
>>> !python3 -m snip_copy hw_rub.ipynb`
which will make copies, removing this cell from each copy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snip_copy-0.0.3.tar.gz.
File metadata
- Download URL: snip_copy-0.0.3.tar.gz
- Upload date:
- Size: 45.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb1af9909080ad131a1ebc8d350f2b1e436a0c71e4b8bb130b55b92b8b9d34c6
|
|
| MD5 |
20856a1f83280b04be4ff838f847ec25
|
|
| BLAKE2b-256 |
273418a626ba8e0839f874ec8d2370de037fc04e704e5ab7f599bdf98e5d8121
|
File details
Details for the file snip_copy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: snip_copy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6808965ce59b7e8634eeaebfcb7810ac37d756a50cc2fee65308e26247fad37c
|
|
| MD5 |
36d8dcd6b638049aea03103366f9fa98
|
|
| BLAKE2b-256 |
dbea58269013892487900439044cf45969ab09163a92c8e7aa94e60cb6a86167
|