Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use slashes in folder names instead of division slashes added by Gazer #152

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions looker_deployer/commands/deploy_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def create_or_return_space(space_name, parent_id, sdk):

try:
target_id = get_space_ids_from_name(space_name, parent_id, sdk)
if len(target_id) == 0 and "/" in space_name:
# If the folder name contains slashes then also check if it was previously imported with
# the slashes replaced with division slashes (Unicode character 2215) prior to PR #152.
target_id = get_space_ids_from_name(space_name.replace("/", "\u2215"), parent_id, sdk)
logger.debug("Space ID from name", extra={"id": target_id})
assert len(target_id) == 1
except AssertionError as e:
Expand Down Expand Up @@ -134,6 +138,9 @@ def build_spaces(spaces, sdk):
id_tracker = ["0"]

for space in spaces:
# Gazer replaces slashes in folder names with division slashes (Unicode character 2215), so undo that.
space = space.replace("\u2215", "/")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an admittedly kludgy way to do this, and runs the risk of mangling folders which had division slashes in their original names. However, I'm betting the number of cases where folders have normal slashes in their names is vastly greater than cases where folders legitimately have division slashes in their names, and the needs of the many outweigh the needs of the few.

The folder JSON files exported by Gazer do contain the original unmangled folder names, so a more robust approach could be to use those folder JSON files when present, but I didn't see a straightforward way to do that given the existing code patterns and Looker Deployer's feature to deploy to a different target folder.


logger.debug("parent_id to use", extra={"id_tracker": id_tracker})
# Pull last value from id_tracker
space_parent = id_tracker.pop()
Expand Down
Loading