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
7a3143a3
Commit
7a3143a3
authored
10 years ago
by
Andy Boughton
Browse files
Options
Downloads
Plain Diff
Merge pull request #131 from r-gaia-cs/core-check-required-files
Validator should check that required files exist
parents
3178d121
c89124ef
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/check.py
+52
-10
52 additions, 10 deletions
tools/check.py
with
52 additions
and
10 deletions
tools/check.py
+
52
−
10
View file @
7a3143a3
...
...
@@ -668,6 +668,48 @@ def command_line():
return
parser
.
parse_args
()
def
check_required_files
(
dir_to_validate
):
"""
Check if required files exists.
"""
REQUIRED_FILES
=
[
"
01-*.md
"
,
"
discussion.md
"
,
"
index.md
"
,
"
instructors.md
"
,
"
LICENSE.md
"
,
"
motivation.md
"
,
"
README.md
"
,
"
reference.md
"
]
valid
=
True
for
required
in
REQUIRED_FILES
:
req_fn
=
os
.
path
.
join
(
dir_to_validate
,
required
)
if
not
glob
.
glob
(
req_fn
):
logging
.
error
(
"
Missing file {0}.
"
.
format
(
required
))
valid
=
False
return
valid
def
get_files_to_validate
(
file_or_path
):
"""
Generate list of files to validate.
"""
files_to_validate
=
[]
dirs_to_validate
=
[]
for
fn
in
file_or_path
:
if
os
.
path
.
isdir
(
fn
):
search_str
=
os
.
path
.
join
(
fn
,
"
*.md
"
)
files_to_validate
.
extend
(
glob
.
glob
(
search_str
))
dirs_to_validate
.
append
(
fn
)
elif
os
.
path
.
isfile
(
fn
):
files_to_validate
.
append
(
fn
)
else
:
logging
.
error
(
"
The specified file or folder {0} does not exist;
"
"
could not perform validation
"
.
format
(
fn
))
return
files_to_validate
,
dirs_to_validate
def
main
(
parsed_args_obj
):
if
parsed_args_obj
.
debug
:
log_level
=
"
DEBUG
"
...
...
@@ -678,16 +720,16 @@ def main(parsed_args_obj):
template
=
parsed_args_obj
.
template
all_valid
=
True
for
fn
in
parsed_args_obj
.
file_or_path
:
if
os
.
path
.
isdir
(
fn
):
res
=
validate_folder
(
fn
,
template
=
template
)
elif
os
.
path
.
isfile
(
fn
):
res
=
validate_single
(
fn
,
template
=
template
)
els
e
:
res
=
False
logging
.
error
(
"
The specified file or folder {0} does not exist;
"
"
could not perform validation
"
.
format
(
fn
)
)
files_to_validate
,
dirs_to_validate
=
get_files_to_validate
(
parsed_args_obj
.
file_or_path
)
# If user ask to validate only one file don't check for required files.
for
d
in
dirs_to_validat
e
:
all_valid
=
all_valid
and
check_required_files
(
d
)
for
fn
in
files_to_validate
:
res
=
validate_single
(
fn
,
template
=
template
)
all_valid
=
all_valid
and
res
...
...
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