Skip to content

Commit

Permalink
Wrap role names "" in the DOT output to handle /-. chars
Browse files Browse the repository at this point in the history
Rather than have a bunch of rules about valid role names,
the dot format allows quoting identifiers, so this is much easier
and should fix related issues including #46
  • Loading branch information
jimbocoder committed May 25, 2016
1 parent eb85483 commit 86a62d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
11 changes: 2 additions & 9 deletions ansigenome/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ def graph_dot(self):
color_length = len(adjusted_colors) - 1

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

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

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

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

Expand Down
16 changes: 1 addition & 15 deletions ansigenome/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ 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 @@ -373,18 +370,7 @@ def normalize_role(role, config):
"""
Normalize a role name.
"""
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
return role


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

0 comments on commit 86a62d4

Please sign in to comment.