Import future print in case of python2 environment
[rnaseq-cwl-training.git] / bin / lesson_check.py
index 016b395451659e299cdeb2f60af299cd0f9e96bc..95ceb5ee260aa2f3eb413aaa879c76ea52f41562 100755 (executable)
@@ -11,7 +11,7 @@ import json
 import re
 from optparse import OptionParser
 
-from util import Reporter, read_markdown, load_yaml, check_unwanted_files
+from util import Reporter, read_markdown, load_yaml, check_unwanted_files, require, IMAGE_FILE_SUFFIX
 
 __version__ = '0.2'
 
@@ -67,6 +67,7 @@ KNOWN_CODEBLOCKS = {
     'source',
     'bash',
     'make',
+    'matlab',
     'python',
     'r',
     'sql'
@@ -149,13 +150,6 @@ def check_config(reporter, source_dir):
     reporter.check_field(config_file, 'configuration', config, 'carpentry', ('swc', 'dc'))
     reporter.check_field(config_file, 'configuration', config, 'title')
     reporter.check_field(config_file, 'configuration', config, 'email')
-    reporter.check_field(config_file, 'configuration', config, 'repo')
-    reporter.check_field(config_file, 'configuration', config, 'root')
-    if ('repo' in config) and ('root' in config):
-        reporter.check(config['repo'].endswith(config['root']),
-                       config_file,
-                       'Repository name "{0}" not consistent with root "{1}"',
-                       config['repo'], config['root'])
 
 
 def read_all_markdown(source_dir, parser):
@@ -227,9 +221,9 @@ def check_figures(source_dir, reporter):
                      'File not found')
         return
 
-    # Get actual files.
+    # Get actual image files (ignore non-image files).
     fig_dir_path = os.path.join(source_dir, 'fig')
-    actual = [f for f in os.listdir(fig_dir_path) if not f.startswith('.')]
+    actual = [f for f in os.listdir(fig_dir_path) if os.path.splitext(f)[1] in IMAGE_FILE_SUFFIX]
 
     # Report differences.
     unexpected = set(actual) - set(referenced)
@@ -252,14 +246,6 @@ def create_checker(args, filename, info):
             return cls(args, filename, **info)
 
 
-def require(condition, message):
-    """Fail if condition not met."""
-
-    if not condition:
-        print(message, file=sys.stderr)
-        sys.exit(1)
-
-
 class CheckBase(object):
     """Base class for checking Markdown files."""