1 # Copyright (C) 2012 W. Trevor King <wking@tremily.us>
3 # This file is part of pygrader.
5 # pygrader is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
10 # pygrader is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # pygrader. If not, see <http://www.gnu.org/licenses/>.
17 """List grading that still needs to be done.
21 import os.path as _os_path
24 def mtime(path, walk_directories=True):
25 if walk_directories and _os.path.isdir(path):
26 time = mtime(path, walk_directories=False)
27 for dirpath,dirnames,filenames in _os.walk(path):
28 for filename in filenames:
29 t = mtime(_os_path.join(dirpath, filename))
36 """Return ``True`` if ``a`` is newer than ``b``.
38 return mtime(a) > mtime(b)
40 def todo(basedir, source, target):
41 """Yield ``source``\s in ``basedir`` with old/missing ``target``\s.
43 for dirpath,dirnames,filenames in _os.walk(basedir):
44 names = dirnames + filenames
46 s = _os_path.join(dirpath, source)
47 t = _os_path.join(dirpath, target)
54 def print_todo(basedir, source, target):
55 """Print ``source``\s in ``basedir`` with old/missing ``target``\s.
57 for path in sorted(todo(basedir, source, target)):