Skip to content

Commit

Permalink
Allow unicode for json and yaml in TUI
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Feb 13, 2022
1 parent cbca956 commit 073348d
Show file tree
Hide file tree
Showing 55 changed files with 1,512 additions and 1 deletion.
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,32 @@
{
"name": "test[2-:0-task-1 yaml]",
"index": 2,
"comment": "task-1 yaml",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"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: |-",
"^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,32 @@
{
"name": "test[3-:json-task-1 json]",
"index": 3,
"comment": "task-1 json",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
"PLAY [Simple unicode output test:0] ********************************************************************************************************************************************************************",
"TASK [Raw with unicode arg and output] *****************************************************************************************************************************************************************",
"CHANGED: [localhost]",
" 0│{ ▒",
" 1│ \"duration\": 0.015339, ▒",
" 2│ \"end\": \"2022-02-13T18:08:58.017874\", ▒",
" 3│ \"event_loop\": null, ▒",
" 4│ \"host\": \"localhost\", ▒",
" 5│ \"play\": \"Simple unicode output test\", ▒",
" 6│ \"play_pattern\": \"localhost\", ▒",
" 7│ \"playbook\": \"/home/bthornto/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\"",
"^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,32 @@
{
"name": "test[5-:1-task-2 json]",
"index": 5,
"comment": "task-2 json",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"output": [
"PLAY [Simple unicode output test:1] ********************************************************************************************************************************************************************",
"TASK [Debug the output] ********************************************************************************************************************************************************************************",
"OK: [localhost]",
" 0│{ ▒",
" 1│ \"duration\": 0.027339, ▒",
" 2│ \"end\": \"2022-02-13T18:08:58.050685\", ▒",
" 3│ \"event_loop\": null, ▒",
" 4│ \"host\": \"localhost\", ▒",
" 5│ \"play\": \"Simple unicode output test\", ▒",
" 6│ \"play_pattern\": \"localhost\", ▒",
" 7│ \"playbook\": \"/home/bthornto/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,",
"^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,32 @@
{
"name": "test[6-:yaml-task-2 yaml]",
"index": 6,
"comment": "task-2 yaml",
"additional_information": {
"present": [],
"absent": [],
"compared_fixture": true
},
"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",
"^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"
]
}
Loading

0 comments on commit 073348d

Please sign in to comment.