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 -shuffle tool app bug in action replace value from dictionary #387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 4 additions & 6 deletions shuffle-tools/1.2.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,11 @@ def replace_value_from_dictionary(self, input_data, mapping, default_value=""):
"reason": "Mapping is not valid JSON: %s" % e,
}

for key, value in mapping.items():
try:
input_data = input_data.replace(key, str(value), -1)
except:
self.logger.info(f"Failed mapping output data for key {key}")
# Ensure input_data is treated as a whole key
input_data = str(input_data) # Convert to string to match dictionary key format
Copy link
Member

Choose a reason for hiding this comment

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

Does this always work? What if the key is a number? Does it still work?

result = mapping.get(input_data, default_value)

return input_data
return result

# Changed with 1.1.0 to run with different returns
def regex_capture_group(self, input_data, regex):
Expand Down
Loading