Commit 68bf4bb0 authored by Greg Wilson's avatar Greg Wilson
Browse files

Checking for .nojekyll file

parent 2b419e33
......@@ -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()
......
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")
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment