Skip to content

Commit

Permalink
Merge pull request nickjj#50 from ypid/revert-47-jim/just-quote-rolen…
Browse files Browse the repository at this point in the history
…ames

Revert "Wrap role identifiers in quotes"
  • Loading branch information
nickjj authored Aug 5, 2016
2 parents fcc4f7a + dc0803c commit ade5c2b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ansigenome/export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import random
import sys
import re

import constants as c
import ui as ui
Expand Down Expand Up @@ -123,8 +124,8 @@ def graph_dot(self):
color_length = len(adjusted_colors) - 1

random_index = random.randint(1, color_length)
roles_list += ' "{0}" [label = "{1}"]\n' \
.format(name, name)
roles_list += " role_{0} [label = \"{1}\"]\n" \
.format(re.sub(r'[.-/]', '_', name), name)

edge = '\n edge [color = "{0}"];\n' \
.format(adjusted_colors[random_index])
Expand All @@ -135,8 +136,13 @@ def graph_dot(self):

for dependency in sorted(fields["dependencies"]):
dependency_name = utils.role_name(dependency)
dependencies += ' "{0}" -> "{1}"\n' \
.format(name, dependency_name)
dependencies += " role_{0} -> role_{1}\n".format(
re.sub(r'[.-/]', '_', name),
re.sub(r'[.-/]', '_',
utils.normalize_role(dependency_name,
self.config)
)
)

edges += "{0}{1}\n".format(edge, dependencies)

Expand Down Expand Up @@ -167,8 +173,8 @@ def graph_png(self):
cli_flags += "-o {0}".format(self.out_file)

(out, err) = utils.capture_shell(
"ansigenome {0} export -t graph -f dot | dot -Tpng {1}"
.format(self.roles_path, cli_flags))
"ansigenome export -t graph -f dot | dot -Tpng {0}"
.format(cli_flags))

if err:
ui.error(err)
Expand Down
16 changes: 15 additions & 1 deletion ansigenome/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def role_name(role):
"""
Return the role name from a folder name.
"""
if "." in role:
return role.split(".")[1]

return role


Expand Down Expand Up @@ -370,7 +373,18 @@ def normalize_role(role, config):
"""
Normalize a role name.
"""
return role
if role.startswith(config["scm_repo_prefix"]):
role_name = role.replace(config["scm_repo_prefix"], "")
else:
if "." in role:
galaxy_prefix = "{0}.".format(config["scm_user"])
role_name = role.replace(galaxy_prefix, "")
elif "-" in role:
role_name = role.replace("-", "_")
else:
role_name = role

return role_name


def create_meta_main(create_path, config, role, categories):
Expand Down

0 comments on commit ade5c2b

Please sign in to comment.