Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
988bc7c3
Commit
988bc7c3
authored
8 years ago
by
Greg Wilson
Browse files
Options
Downloads
Patches
Plain Diff
Tidying up utilities
parent
55cb0fa5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
bin/lesson_check.py
+9
-8
9 additions, 8 deletions
bin/lesson_check.py
bin/test_lesson_check.py
+3
-1
3 additions, 1 deletion
bin/test_lesson_check.py
bin/util.py
+1
-1
1 addition, 1 deletion
bin/util.py
bin/workshop_check.py
+18
-11
18 additions, 11 deletions
bin/workshop_check.py
with
33 additions
and
23 deletions
Makefile
+
2
−
2
View file @
988bc7c3
...
...
@@ -38,7 +38,7 @@ clean :
## workshop-check : check workshop homepage.
workshop-check
:
bin/workshop_check.py
index.html
@
bin/workshop_check.py
.
## ----------------------------------------
## Commands specific to lesson websites.
...
...
@@ -67,7 +67,7 @@ HTML_FILES = \
## lesson-check : validate lesson Markdown.
lesson-check
:
bin/lesson_check.py
-s
.
-p
bin/markdown-ast.rb
@
bin/lesson_check.py
-s
.
-p
bin/markdown-ast.rb
unittest
:
python bin/test_lesson_check.py
...
...
This diff is collapsed.
Click to expand it.
bin/lesson_check.py
+
9
−
8
View file @
988bc7c3
...
...
@@ -119,11 +119,13 @@ def parse_args():
def
check_config
(
args
):
"""
Check configuration file.
"""
config_file
=
os
.
path
.
join
(
args
.
source_dir
,
'
_config.yml
'
)
with
open
(
config_file
,
'
r
'
)
as
reader
:
config
=
yaml
.
load
(
reader
)
args
.
reporter
.
check_field
(
config_file
,
'
configuration
'
,
config
,
'
kind
'
,
'
lesson
'
)
try
:
config_file
=
os
.
path
.
join
(
args
.
source_dir
,
'
_config.yml
'
)
with
open
(
config_file
,
'
r
'
)
as
reader
:
config
=
yaml
.
load
(
reader
)
args
.
reporter
.
check_field
(
config_file
,
'
configuration
'
,
config
,
'
kind
'
,
'
lesson
'
)
except
FileNotFoundError
as
e
:
args
.
reporter
.
add
(
'
_config.yml
'
,
'
Missing required file
'
)
def
read_all_markdown
(
args
,
source_dir
):
...
...
@@ -176,11 +178,10 @@ def check_fileset(source_dir, reporter, filenames_present):
"""
Are all required files present? Are extraneous files present?
"""
# Check files with predictable names.
required
=
[
p
[
1
].
replace
(
'
%
'
,
source_dir
)
for
p
in
REQUIRED_FILES
]
missing
=
set
(
required
)
-
set
(
filenames_present
)
for
m
in
missing
:
reporter
.
add
(
None
,
'
Missing required file
{0}
'
,
m
)
reporter
.
add
(
m
,
'
Missing required file
'
)
# Check episode files' names.
seen
=
[]
...
...
@@ -191,7 +192,7 @@ def check_fileset(source_dir, reporter, filenames_present):
if
m
and
m
.
group
(
1
):
seen
.
append
(
m
.
group
(
1
))
else
:
reporter
.
add
(
Non
e
,
'
Episode
{0}
has badly-formatted filename
'
,
filename
)
reporter
.
add
(
filenam
e
,
'
Episode has badly-formatted filename
'
)
# Check episode filename numbering.
reporter
.
check
(
len
(
seen
)
==
len
(
set
(
seen
)),
...
...
This diff is collapsed.
Click to expand it.
bin/test_lesson_check.py
+
3
−
1
View file @
988bc7c3
...
...
@@ -3,9 +3,10 @@ import unittest
import
lesson_check
import
util
class
TestFileList
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
reporter
=
util
.
Reporter
(
None
)
## TODO: refactor reporter class.
self
.
reporter
=
util
.
Reporter
(
None
)
def
test_file_list_has_expected_entries
(
self
):
# For first pass, simply assume that all required files are present
...
...
@@ -15,5 +16,6 @@ class TestFileList(unittest.TestCase):
lesson_check
.
check_fileset
(
''
,
self
.
reporter
,
all_filenames
)
self
.
assertEqual
(
len
(
self
.
reporter
.
messages
),
0
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
bin/util.py
+
1
−
1
View file @
988bc7c3
...
...
@@ -47,5 +47,5 @@ class Reporter(object):
if
not
self
.
messages
:
return
for
m
in
self
.
messages
:
for
m
in
sorted
(
self
.
messages
)
:
print
(
m
,
file
=
stream
)
This diff is collapsed.
Click to expand it.
bin/workshop_check.py
+
18
−
11
View file @
988bc7c3
...
...
@@ -28,7 +28,7 @@ console_handler.setFormatter(formatter)
logger
.
addHandler
(
console_handler
)
#
TODO
: these regexp patterns need comments inside
#
FIXME
: 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}
'
...
...
@@ -400,12 +400,15 @@ def check_file(filename, data, errors):
def
check_config
(
filename
,
errors
):
'''
Check YAML configuration file.
'''
with
open
(
filename
,
'
r
'
)
as
reader
:
config
=
yaml
.
load
(
reader
)
try
:
with
open
(
filename
,
'
r
'
)
as
reader
:
config
=
yaml
.
load
(
reader
)
if
config
[
'
kind
'
]
!=
'
workshop
'
:
msg
=
'
Not configured as a workshop: found
"
{0}
"
instead
'
.
format
(
config
[
'
kind
'
])
add_error
(
msg
,
errors
)
if
config
[
'
kind
'
]
!=
'
workshop
'
:
msg
=
'
Not configured as a workshop: found
"
{0}
"
instead
'
.
format
(
config
[
'
kind
'
])
add_error
(
msg
,
errors
)
except
FileNotFoundError
as
e
:
add_error
(
'
_config.yml not found
'
,
errors
)
def
main
():
...
...
@@ -415,15 +418,19 @@ def main():
print
(
USAGE
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
index_file
=
sys
.
argv
[
1
]
config_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
index_file
),
'
_config.yml
'
)
root_dir
=
sys
.
argv
[
1
]
index_file
=
os
.
path
.
join
(
root_dir
,
'
index.html
'
)
config_file
=
os
.
path
.
join
(
root_dir
,
'
_config.yml
'
)
logger
.
info
(
'
Testing
"
{0}
"
and
"
{1}
"'
.
format
(
index_file
,
config_file
))
errors
=
[]
check_config
(
config_file
,
errors
)
with
open
(
index_file
)
as
reader
:
data
=
reader
.
read
()
check_file
(
index_file
,
data
,
errors
)
try
:
with
open
(
index_file
)
as
reader
:
data
=
reader
.
read
()
check_file
(
index_file
,
data
,
errors
)
except
FileNotFoundError
as
e
:
add_error
(
'
index.html not found
'
,
errors
)
if
errors
:
for
m
in
errors
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment