Checking for .nojekyll file
authorGreg Wilson <gvwilson@third-bit.com>
Sun, 3 Jul 2016 21:43:08 +0000 (17:43 -0400)
committerGreg Wilson <gvwilson@third-bit.com>
Sun, 3 Jul 2016 21:43:08 +0000 (17:43 -0400)
bin/lesson_check.py
bin/util.py
bin/workshop_check.py

index 6de771470a11a4ccdcdb6b25af8649b7885eb6b4..9e051bdb2b331a28ec504495544285040f658034 100755 (executable)
@@ -11,7 +11,7 @@ import json
 import re
 from optparse import OptionParser
 
-from util import Reporter, read_markdown, load_yaml
+from util import Reporter, read_markdown, load_yaml, check_unwanted_files
 
 __version__ = '0.2'
 
@@ -100,6 +100,7 @@ def main():
     check_config(args.reporter, args.source_dir)
     docs = read_all_markdown(args.source_dir, args.parser)
     check_fileset(args.source_dir, args.reporter, docs.keys())
+    check_unwanted_files(args.source_dir, args.reporter)
     for filename in docs.keys():
         checker = create_checker(args, filename, docs[filename])
         checker.check()
index f7aaf2e3fa47606f7ae71f2b75f359aaac952e7e..8ce17fea6bd4840adad137b8193f25337fee5a15 100644 (file)
@@ -1,13 +1,21 @@
 import sys
+import os
 import json
 from subprocess import Popen, PIPE
 
+# Import this way to produce a more useful error message.
 try:
     import yaml
 except ImportError:
     print('Unable to import YAML module: please install PyYAML', file=sys.stderr)
     sys.exit(1)
 
+
+UNWANTED_FILES = [
+    '.nojekyll'
+]
+
+
 class Reporter(object):
     """Collect and report errors."""
 
@@ -124,3 +132,15 @@ def load_yaml(filename):
     except (yaml.YAMLError, FileNotFoundError) as e:
         print('Unable to load YAML file {0}:\n{1}'.format(filename, e), file=sys.stderr)
         sys.exit(1)
+
+
+def check_unwanted_files(dir_path, reporter):
+    """
+    Check that unwanted files are not present.
+    """
+
+    for filename in UNWANTED_FILES:
+        path = os.path.join(dir_path, filename)
+        reporter.check(not os.path.exists(path),
+                       path,
+                       "Unwanted file found")
index d018b78906171d3427350ad1dcba0d627435effd..1dcd33c2c431512dc24d0149c1f25a770c31ecfc 100755 (executable)
@@ -8,7 +8,7 @@ import sys
 import os
 import re
 from datetime import date
-from util import Reporter, split_metadata
+from util import Reporter, split_metadata, load_yaml, check_unwanted_files
 
 
 # Metadata field patterns.
@@ -400,6 +400,7 @@ def main():
 
     reporter = Reporter()
     check_config(reporter, config_file)
+    check_unwanted_files(root_dir, reporter)
     with open(index_file) as reader:
         data = reader.read()
         check_file(reporter, index_file, data)