Skip to content

Commit 4bf46c9

Browse files
author
Ludvig Kihlman
committed
Fixes as suggested in the comments for pull request #1238
1 parent fe3ef73 commit 4bf46c9

File tree

23 files changed

+37
-124
lines changed

23 files changed

+37
-124
lines changed

nbgrader/apps/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def __init__(self, coursedir=None, authenticator=None, exchange=None, **kwargs):
5959
authenticator : :class:~`nbgrader.auth.BaseAuthenticator`
6060
(Optional) An authenticator instance for communicating with an
6161
external database.
62+
exchange : :class:~`nbgrader.exchange.ExchangeFactory`
63+
(Optional) A factory for creating the exchange classes used
64+
for distributing assignments and feedback.
6265
kwargs:
6366
Additional keyword arguments (e.g. ``parent``, ``config``)
6467

nbgrader/apps/dbapp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from . import NbGrader
1414
from ..api import Gradebook, MissingEntry, Student, Assignment
15-
from ..exchange import ExchangeList
1615
from .. import dbutil
1716

1817
aliases = {

nbgrader/docs/source/exchange/exchange_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ When writing your own Exchange
306306
- nbgrader functionality requires a file called ``timestamp.txt`` to be in the submission, containing the timestamp of that submission. The creation of this file is the responsibility of this class.
307307
- Whilst nothing is done *as yet*, the default exchange checks the names of submitted notebooks, and logs differences.
308308
- Submissions need to record ``student_id``, as well as ``course_id`` & ``assignment_id``
309-
- The default exchange copies files to both an ``inbound`` and ``cache`` store. This may be significant considering ``ExchangeList``
309+
- The default exchange copies files to both an ``inbound`` and ``cache`` store.
310310

311311
ExchangeList Date Return structure
312312
----------------------------------

nbgrader/docs/source/exchange/exchange_plugin.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The exchange package is organised as follows::
2121
│ └── submit.py
2222
└── exchange_factory.py
2323

24-
The ``exchange.abc`` package contain all the Abstract Base Classes that custom exchange packages need to implement.
24+
The ``exchange.abc`` package contains all the Abstract Base Classes that custom exchange packages need to implement.
2525
The ``exchange.default`` package is a default filesystem based implementation. The exchange_factory.py file contains
2626
the defintion for the ExchangeFactory class that is used to create instances of the exchange classes.
2727

nbgrader/exchange/abc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"ExchangeReleaseAssignment",
2222
"ExchangeReleaseFeedback",
2323
"ExchangeSubmit"
24-
]
24+
]

nbgrader/exchange/abc/collect.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,3 @@ class ExchangeCollect(Exchange):
1414
default_value=True,
1515
help="Whether to cross-check the student_id with the UNIX-owner of the submitted directory."
1616
).tag(config=True)
17-
18-
19-
def init_src(self):
20-
pass
21-
22-
def init_dest(self):
23-
pass
24-
25-
def copy_files(self):
26-
pass

nbgrader/exchange/abc/exchange.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import os
21
import datetime
3-
import sys
42

53
from textwrap import dedent
64

75
from dateutil.tz import gettz
86
from dateutil.parser import parse
97
from traitlets.config import LoggingConfigurable
10-
from traitlets import Unicode, Bool, Instance, Type, default, validate, TraitError
11-
from jupyter_core.paths import jupyter_data_dir
8+
from traitlets import Unicode, Instance, validate, TraitError
129

13-
from nbgrader.utils import check_directory, ignore_patterns, self_owned
1410
from nbgrader.coursedir import CourseDirectory
1511
from nbgrader.auth import Authenticator
1612

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import os
2-
import shutil
3-
41
from traitlets import Bool
52

63
from .exchange import Exchange
7-
from nbgrader.utils import check_mode
84

95

106
class ExchangeFetchAssignment(Exchange):
117

128
replace_missing_files = Bool(False, help="Whether to replace missing files on fetch").tag(config=True)
13-
14-
def copy_if_missing(self, src, dest, ignore=None):
15-
pass
16-

nbgrader/exchange/abc/list.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
2-
import hashlib
3-
41
from traitlets import Bool
52
from .exchange import Exchange
63

74

8-
def _checksum(path):
9-
m = hashlib.md5()
10-
m.update(open(path, 'rb').read())
11-
return m.hexdigest()
12-
13-
145
class ExchangeList(Exchange):
156

167
inbound = Bool(False, help="List inbound files rather than outbound.").tag(config=True)
178
cached = Bool(False, help="List assignments in submission cache.").tag(config=True)
189
remove = Bool(False, help="Remove, rather than list files.").tag(config=True)
1910

20-
def parse_assignment(self, assignment):
21-
pass
22-
23-
def format_inbound_assignment(self, info):
24-
pass
11+
def list_files(self):
12+
"""Return list of available files """
13+
raise NotImplementedError
2514

26-
def format_outbound_assignment(self, info):
27-
pass
15+
def remove_files(self):
16+
"""Remove available files """
17+
raise NotImplementedError
2818

29-
def parse_assignments(self):
30-
pass
19+
def start(self):
20+
if self.inbound and self.cached:
21+
self.fail("Options --inbound and --cached are incompatible.")
3122

32-
def list_files(self):
33-
pass
23+
super(ExchangeList, self).start()
3424

35-
def remove_files(self):
36-
pass
25+
if self.remove:
26+
return self.remove_files()
27+
else:
28+
return self.list_files()

nbgrader/exchange/abc/release_feedback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
class ExchangeReleaseFeedback(Exchange):
5-
pass
5+
pass

0 commit comments

Comments
 (0)