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'
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()
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."""
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")
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.
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)