Skip to content

Commit

Permalink
Checking for .nojekyll file
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Wilson committed Jul 3, 2016
1 parent 2b419e3 commit 68bf4bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/lesson_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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'

Expand Down Expand Up @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions bin/util.py
Original file line number Diff line number Diff line change
@@ -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."""

Expand Down Expand Up @@ -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")
3 changes: 2 additions & 1 deletion bin/workshop_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 68bf4bb

Please sign in to comment.