Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
74c439b1
Commit
74c439b1
authored
Aug 11, 2016
by
Michael Roytman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor to split get_resource_name into functions to get playbook name and role name separately
parent
397661d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
util/parsefiles.py
+19
-21
No files found.
util/parsefiles.py
View file @
74c439b1
...
@@ -178,7 +178,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
...
@@ -178,7 +178,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
# if the change set file is in the set of role files
# if the change set file is in the set of role files
if
file_path
in
candidate_files
:
if
file_path
in
candidate_files
:
# get name of role and add it to set of roles of the change set
# get name of role and add it to set of roles of the change set
items
.
add
(
_get_r
esource_name
(
file_path
,
"roles"
))
items
.
add
(
_get_r
ole_name_from_file
(
file_path
))
return
items
return
items
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
def
get_plays
(
files
,
git_dir
,
playbooks_dirs
):
...
@@ -207,35 +207,33 @@ def get_plays(files, git_dir, playbooks_dirs):
...
@@ -207,35 +207,33 @@ def get_plays(files, git_dir, playbooks_dirs):
# if the change set file is in the set of playbook files
# if the change set file is in the set of playbook files
if
file_path
in
candidate_files
:
if
file_path
in
candidate_files
:
# if looking in playbooks directory
plays
.
add
(
_get_playbok_name_from_file
(
file_path
))
if
play_dir
==
"playbooks"
:
play
=
_get_resource_name
(
file_path
,
"playbooks"
)
# remove ".yml" file ending
play
=
play
[:
-
4
]
plays
.
add
(
play
)
elif
play_dir
==
"playbooks/edx-east"
:
play
=
_get_resource_name
(
file_path
,
"edx-east"
)
# remove ".yml" file ending
play
=
play
[:
-
4
]
plays
.
add
(
play
)
return
plays
return
plays
def
_get_resource_name
(
path
,
kind
):
def
_get_playbook_name_from_file
(
path
):
"""
Gets name of playbook from the filepath, which is the last part of the filepath.
Input:
path: A path to the playbook
"""
# get last part of filepath
return
path
.
stem
def
_get_role_name_from_file
(
path
):
"""
"""
Gets name of r
esource from the filepath, which is the directory following occurence of kind
.
Gets name of r
ole from the filepath, which is the directory following occurence of the word "roles"
.
Input:
Input:
path: A path to the resource (e.g. a role or a playbook)
path: A path to the role
kind: A description of the type of resource; this keyword precedes the name of a role or a playbook
in a file path and allows for the separation of its name;
e.g. for "configuration/playbooks/roles/discovery/...", kind = "roles" returns
"discovery" as the role name
"""
"""
# get individual parts of a file path
# get individual parts of a file path
dirs
=
path
.
parts
dirs
=
path
.
parts
#
type of resource is the next part of the file path after kind (e.g. after "roles" or "playbooks")
#
name of role is the next part of the file path after "roles"
return
dirs
[
dirs
.
index
(
kind
)
+
1
]
return
dirs
[
dirs
.
index
(
"roles"
)
+
1
]
def
get_dependencies
(
roles
,
graph
):
def
get_dependencies
(
roles
,
graph
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment