Skip to content

Commit 2b71e04

Browse files
committed
tweak Nathan's code and run formatter
1 parent f4d1ee0 commit 2b71e04

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

examples/9_leaderboard/test_leaderboard.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ def test_multiple_metrics():
99
"""Example of setting multiple leaderboard entries."""
1010
# Simulate some work
1111
time.sleep(0.1)
12-
12+
1313
# Add various metrics to the leaderboard
1414
test_multiple_metrics.leaderboard = [
1515
{"name": "Advanced Score", "value": 950},
1616
{"name": "Response Time", "value": 125, "order": "asc"},
1717
{"name": "Rating", "value": "★★★★☆"}
1818
]
19-

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The following "assignments" are used for testing `jmu_pytest_utils` and provided
1010
* [6_provided_data](6_provided_data) -- file I/O assignment
1111
* [7_class_package](7_class_package) -- classes and packages
1212
* [8_test_coverage](8_test_coverage) -- grading student's tests
13+
* [9_leaderboard](9_leaderboard) -- Gradescope leaderboard
1314

1415

1516
## API Docs

jmu_pytest_utils/audit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def count_nodes(filename):
101101
tree = ast.parse(source, filename)
102102
return Counter(type(node).__name__ for node in ast.walk(tree))
103103

104+
104105
def count_while_loops(filename):
105106
"""Count the number of while loops in a program.
106107

jmu_pytest_utils/remove_comments.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
""" Strip comments and docstrings from a file.
2-
#https://gist.github.com/BroHui/aca2b8e6e6bdf3cb4af4b246c9837fa3
3-
"""
1+
""" Strip comments and docstrings from a file."""
2+
3+
# Source: https://gist.github.com/BroHui/aca2b8e6e6bdf3cb4af4b246c9837fa3
4+
5+
import sys
6+
import token
7+
import tokenize
8+
import io
49

5-
import sys, token, tokenize, io
610

711
def remove_comments(fname):
8-
""" Run on just one file.
9-
"""
10-
source = open(fname)
11-
mod = io.StringIO() #open(fname + ",strip", "w")
12+
"""Run on just one file."""
13+
source = open(fname, encoding="utf-8")
14+
mod = io.StringIO() # open(fname + ",strip", "w")
1215

1316
prev_toktype = token.INDENT
14-
first_line = None
1517
last_lineno = -1
1618
last_col = 0
1719

1820
tokgen = tokenize.generate_tokens(source.readline)
1921
for toktype, ttext, (slineno, scol), (elineno, ecol), ltext in tokgen:
20-
if 0: # Change to if 1 to see the tokens fly by.
22+
if 0: # Change to if 1 to see the tokens fly by.
2123
print("%10s %-14s %-20r %r" % (
2224
tokenize.tok_name.get(toktype, toktype),
2325
"%d.%d-%d.%d" % (slineno, scol, elineno, ecol),
2426
ttext, ltext
25-
))
27+
))
2628
if slineno > last_lineno:
2729
last_col = 0
2830
if scol > last_col:
2931
mod.write(" " * (scol - last_col))
3032
if (toktype == token.STRING and
31-
(prev_toktype == token.INDENT or prev_toktype == token.NEWLINE)):
33+
(prev_toktype == token.INDENT or prev_toktype == token.NEWLINE)):
3234
# Docstring
3335
# mod.write("#--")
3436
pass
@@ -43,6 +45,6 @@ def remove_comments(fname):
4345
last_lineno = elineno
4446
return mod.getvalue()
4547

48+
4649
if __name__ == '__main__':
4750
print(remove_comments(sys.argv[1]))
48-

jmu_pytest_utils/template/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ source .venv/bin/activate
1515
pip install --upgrade pip
1616

1717
# Install libraries
18-
pip install git+https://github.com/JMU-CS/jmu_pytest_utils.git@nrs
18+
pip install git+https://github.com/JMU-CS/jmu_pytest_utils.git
1919
if [ -f "requirements.txt" ]; then
2020
pip install -r requirements.txt
2121
fi

0 commit comments

Comments
 (0)