Skip to content
Snippets Groups Projects
Commit fdc766a4 authored by Greg Wilson's avatar Greg Wilson
Browse files

Merge branch 'new-style' of github.com:swcarpentry/styles into new-style

parents 349fdb07 c29abf91
Branches
Tags
No related merge requests found
......@@ -29,10 +29,14 @@ logger.addHandler(console_handler)
# TODO: these regexp patterns need comments inside
EMAIL_PATTERN = r'[^@]+@[^@]+\.[^@]+'
HUMANTIME_PATTERN = r'((0?[1-9]|1[0-2]):[0-5]\d(am|pm)(-|to)(0?[1-9]|1[0-2]):[0-5]\d(am|pm))|((0?\d|1\d|2[0-3]):[0-5]\d(-|to)(0?\d|1\d|2[0-3]):[0-5]\d)'
EVENTBRITE_PATTERN = r'\d{9,10}'
URL_PATTERN = r'https?://.+'
CARPENTRIES = ("dc", "swc")
DEFAULT_CONTACT_EMAIL = 'admin@software-carpentry.org'
USAGE = 'Usage: "check-workshop path/to/index.html"\n'
# Country and language codes. Note that codes mean different things: 'ar'
......@@ -110,6 +114,13 @@ def check_layout(layout):
return layout == 'workshop'
@look_for_fixme
def check_carpentry(layout):
'''"carpentry" in YAML header must be "dc" or "swc".'''
return layout in CARPENTRIES
@look_for_fixme
def check_country(country):
'''"country" must be a lowercase ISO-3166 two-letter code.'''
......@@ -204,6 +215,16 @@ def check_helpers(helpers):
return isinstance(helpers, list) and len(helpers) >= 0
@look_for_fixme
def check_email(email):
'''"contact" must be a valid email address consisting of characters, a
@, and more characters. It should not be the default contact
email address "admin@software-carpentry.org".'''
return bool(re.match(EMAIL_PATTERN, email)) and \
(email != DEFAULT_CONTACT_EMAIL)
def check_eventbrite(eventbrite):
'''"eventbrite" (the Eventbrite registration key) must be 9 or more digits.'''
......@@ -231,9 +252,13 @@ def check_pass(value):
HANDLERS = {
'layout': (True, check_layout, 'layout isn\'t "workshop"'),
'carpentry': (True, check_carpentry, 'carpentry isn\'t in ' +
', '.join(CARPENTRIES)),
'country': (True, check_country,
'country invalid: must use lowercase two-letter ISO code ' +
'from ' + ', '.join(ISO_COUNTRY)),
'language': (False, check_language,
'language invalid: must use lowercase two-letter ISO code' +
' from ' + ', '.join(ISO_LANGUAGE)),
......@@ -241,11 +266,14 @@ HANDLERS = {
'humandate': (True, check_humandate,
'humandate invalid. Please use three-letter months like ' +
'"Jan" and four-letter years like "2025".'),
'humantime': (True, check_humantime,
'humantime doesn\'t include numbers'),
'startdate': (True, check_date,
'startdate invalid. Must be of format year-month-day, ' +
'i.e., 2014-01-31.'),
'enddate': (False, check_date,
'enddate invalid. Must be of format year-month-day, i.e.,' +
' 2014-01-31.'),
......@@ -257,14 +285,21 @@ HANDLERS = {
'instructor': (True, check_instructors,
'instructor list isn\'t a valid list of format ' +
'["First instructor", "Second instructor",..].'),
'helper': (True, check_helpers,
'helper list isn\'t a valid list of format ' +
'["First helper", "Second helper",..].'),
'contact': (True, check_email,
'contact email invalid or still set to ' +
'"{0}".'.format(DEFAULT_CONTACT_EMAIL)),
'eventbrite': (False, check_eventbrite, 'Eventbrite key appears invalid.'),
'etherpad': (False, check_etherpad, 'Etherpad URL appears invalid.'),
'venue': (False, check_pass, 'venue name not specified'),
'address': (False, check_pass, 'address not specified')
}
......
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