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

Allow unicode character output for json and yaml in TUI #944

Merged
merged 6 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/changelog-fragments.d/944.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed presentation of unicode characters while using mode interactive. -- by {user}`cidrblock`
1 change: 1 addition & 0 deletions src/ansible_navigator/_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class YamlStyle(NamedTuple):

default_flow_style: bool = False
explicit_start: bool = True
allow_unicode: bool = True


def human_dump(obj: Any, filename: str = None, file_mode: str = "w") -> Union[str, None]:
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_navigator/ui_framework/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def _serialize_color(self, obj: Any) -> CursesLines:
if self.serialization_format() == "source.yaml":
string = human_dump(obj)
elif self.serialization_format() == "source.json":
string = json.dumps(obj, indent=4, sort_keys=True)
string = json.dumps(obj, indent=4, sort_keys=True, ensure_ascii=False)
else:
string = obj

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/integration/actions/run_unicode/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
11 changes: 11 additions & 0 deletions tests/fixtures/integration/actions/run_unicode/site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Simple unicode output test
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Raw with unicode arg and output
raw: echo 航海家
register: output
- name: Debug the output
debug:
var: output
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "test[0-ansible-navigator run /tests/fixtures/integration/actions/run_unicode/site.yaml -i /tests/fixtures/integration/actions/run_unicode/inventory --ee True --ll debug --mode interactive-ansible-navigator run playbook]",
"index": 0,
"comment": "ansible-navigator run playbook",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" PLAY NAME OK CHANGED UNREACHABLE FAILED SKIPPED IGNORED IN PROGRESS TASK COUNT PROGRESS",
"0│Simple unicode output test 2 1 0 0 0 0 0 2 COMPLETE",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test[1-:0-play-1 details]",
"index": 1,
"comment": "play-1 details",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" RESULT HOST NUMBER CHANGED TASK TASK ACTION DURATION",
"0│OK localhost 0 True Raw with unicode arg and output raw 0s",
"1│OK localhost 1 False Debug the output debug 0s",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "test[2-:0-task-1 yaml]",
"index": 2,
"comment": "task-1 yaml",
"additional_information": {
"present": [
"航海家"
],
"absent": [],
"compared_fixture": false
},
"output": [
"PLAY [Simple unicode output test:0] ********************************************************************************************************************************************************************",
"TASK [Raw with unicode arg and output] *****************************************************************************************************************************************************************",
"CHANGED: [localhost]",
" 0│---",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
" 3│event_loop: null",
" 4│host: localhost",
" 5│play: Simple unicode output test",
" 6│play_pattern: localhost",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
" 8│remote_addr: localhost",
" 9│res:",
"10│ _ansible_no_log: false",
"11│ changed: true",
"12│ rc: 0",
"13│ stderr: ''",
"14│ stderr_lines: []",
"15│ stdout: |-",
"16│ 航海家",
"17│ stdout_lines:",
"18│ - 航海家",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"20│task: Raw with unicode arg and output",
"21│task_action: raw",
"22│task_args: ''",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back - previous + next [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "test[3-:json-task-1 json]",
"index": 3,
"comment": "task-1 json",
"additional_information": {
"present": [
"航海家"
],
"absent": [],
"compared_fixture": false
},
"output": [
"PLAY [Simple unicode output test:0] ********************************************************************************************************************************************************************",
"TASK [Raw with unicode arg and output] *****************************************************************************************************************************************************************",
"CHANGED: [localhost]",
" 0│{",
" 1│ \"duration\": 0.057188,",
" 2│ \"end\": \"2022-02-13T18:28:45.394242\",",
" 3│ \"event_loop\": null,",
" 4│ \"host\": \"localhost\",",
" 5│ \"play\": \"Simple unicode output test\",",
" 6│ \"play_pattern\": \"localhost\",",
" 7│ \"playbook\": \"/home/user/github/ansible-navigator/tests/fixtures/integration/actions/run_unicode/site.yaml\",",
" 8│ \"remote_addr\": \"localhost\",",
" 9│ \"res\": {",
"10│ \"_ansible_no_log\": false,",
"11│ \"changed\": true,",
"12│ \"rc\": 0,",
"13│ \"stderr\": \"\",",
"14│ \"stderr_lines\": [],",
"15│ \"stdout\": \"航海家,n\"",
"16│ \"stdout_lines\": [",
"17│ \"航海家\"",
"18│ ]",
"19│ },",
"20│ \"start\": \"2022-02-13T18:28:45.337054\",",
"21│ \"task\": \"Raw with unicode arg and output\",",
"22│ \"task_action\": \"raw\",",
"23│ \"task_args\": \"\",",
"24│ \"task_path\": \"/home/user/github/ansible-navigator/tests/fixtures/integration/actions/run_unicode/site.yaml:6\"",
"25│}",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back - previous + next [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test[4-:back-play-1 details]",
"index": 4,
"comment": "play-1 details",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" RESULT HOST NUMBER CHANGED TASK TASK ACTION DURATION",
"0│OK localhost 0 True Raw with unicode arg and output raw 0s",
"1│OK localhost 1 False Debug the output debug 0s",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "test[5-:1-task-2 json]",
"index": 5,
"comment": "task-2 json",
"additional_information": {
"present": [
"航海家"
],
"absent": [],
"compared_fixture": false
},
"output": [
"PLAY [Simple unicode output test:1] ********************************************************************************************************************************************************************",
"TASK [Debug the output] ********************************************************************************************************************************************************************************",
"OK: [localhost]",
" 0│{",
" 1│ \"duration\": 0.109558,",
" 2│ \"end\": \"2022-02-13T18:28:45.525577\",",
" 3│ \"event_loop\": null,",
" 4│ \"host\": \"localhost\",",
" 5│ \"play\": \"Simple unicode output test\",",
" 6│ \"play_pattern\": \"localhost\",",
" 7│ \"playbook\": \"/home/user/github/ansible-navigator/tests/fixtures/integration/actions/run_unicode/site.yaml\",",
" 8│ \"remote_addr\": \"localhost\",",
" 9│ \"res\": {",
"10│ \"_ansible_no_log\": false,",
"11│ \"_ansible_verbose_always\": true,",
"12│ \"changed\": false,",
"13│ \"output\": {",
"14│ \"changed\": true,",
"15│ \"failed\": false,",
"16│ \"rc\": 0,",
"17│ \"stderr\": \"\",",
"18│ \"stderr_lines\": [],",
"19│ \"stdout\": \"航海家,n\"",
"20│ \"stdout_lines\": [",
"21│ \"航海家\"",
"22│ ]",
"23│ }",
"24│ },",
"25│ \"start\": \"2022-02-13T18:28:45.416019\",",
"26│ \"task\": \"Debug the output\",",
"27│ \"task_action\": \"debug\",",
"28│ \"task_args\": \"\",",
"29│ \"task_path\": \"/home/user/github/ansible-navigator/tests/fixtures/integration/actions/run_unicode/site.yaml:9\"",
"30│}",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back - previous + next [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "test[6-:yaml-task-2 yaml]",
"index": 6,
"comment": "task-2 yaml",
"additional_information": {
"present": [
"航海家"
],
"absent": [],
"compared_fixture": false
},
"output": [
"PLAY [Simple unicode output test:1] ********************************************************************************************************************************************************************",
"TASK [Debug the output] ********************************************************************************************************************************************************************************",
"OK: [localhost]",
" 0│---",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
" 3│event_loop: null",
" 4│host: localhost",
" 5│play: Simple unicode output test",
" 6│play_pattern: localhost",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
" 8│remote_addr: localhost",
" 9│res:",
"10│ _ansible_no_log: false",
"11│ _ansible_verbose_always: true",
"12│ changed: false",
"13│ output:",
"14│ changed: true",
"15│ failed: false",
"16│ rc: 0",
"17│ stderr: ''",
"18│ stderr_lines: []",
"19│ stdout: |-",
"20│ 航海家",
"21│ stdout_lines:",
"22│ - 航海家",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"24│task: Debug the output",
"25│task_action: debug",
"26│task_args: ''",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back - previous + next [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test[7-:back-play-1 details]",
"index": 7,
"comment": "play-1 details",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" RESULT HOST NUMBER CHANGED TASK TASK ACTION DURATION",
"0│OK localhost 0 True Raw with unicode arg and output raw 0s",
"1│OK localhost 1 False Debug the output debug 0s",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "test[8-:back-all play details]",
"index": 8,
"comment": "all play details",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" PLAY NAME OK CHANGED UNREACHABLE FAILED SKIPPED IGNORED IN PROGRESS TASK COUNT PROGRESS",
"0│Simple unicode output test 2 1 0 0 0 0 0 2 COMPLETE",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "test[9-:st-display stream]",
"index": 9,
"comment": "display stream",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" 0│",
" 1│PLAY [Simple unicode output test] **********************************************",
" 2│",
" 3│TASK [Raw with unicode arg and output] *****************************************",
" 4│changed: [localhost]",
" 5│",
" 6│TASK [Debug the output] ********************************************************",
" 7│ok: [localhost] => {",
" 8│ \"output\": {",
" 9│ \"changed\": true,",
"10│ \"failed\": false,",
"11│ \"rc\": 0,",
"12│ \"stderr\": \"\",",
"13│ \"stderr_lines\": [],",
"14│ \"stdout\": \"航海家\\n\",",
"15│ \"stdout_lines\": [",
"16│ \"航海家\"",
"17│ ]",
"18│ }",
"19│}",
"20│",
"21│PLAY RECAP *********************************************************************",
"22│localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "test[0-ansible-navigator run /tests/fixtures/integration/actions/run_unicode/site.yaml -i /tests/fixtures/integration/actions/run_unicode/inventory --ee False --ll debug --mode interactive-ansible-navigator run playbook]",
"index": 0,
"comment": "ansible-navigator run playbook",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" PLAY NAME OK CHANGED UNREACHABLE FAILED SKIPPED IGNORED IN PROGRESS TASK COUNT PROGRESS",
"0│Simple unicode output test 2 1 0 0 0 0 0 2 COMPLETE",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test[1-:0-play-1 details]",
"index": 1,
"comment": "play-1 details",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
" RESULT HOST NUMBER CHANGED TASK TASK ACTION DURATION",
"0│OK localhost 0 True Raw with unicode arg and output raw 0s",
"1│OK localhost 1 False Debug the output debug 0s",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help SUCCESSFUL"
]
}
Loading