Skip to content

Commit b4f3728

Browse files
committed
v1.5 - #16 cleaner debug log when ' is used
Upstream TagUI project has a limitation in live mode. It was a tradeoff to enable dynamic variables working for selectors and parameters in live mode. As a result, TagUI for Python sends the following string to TagUI when a single quote ' is used as parameter (non-identifier parameter). ``` '+"\'"+' ``` With the issue aisingapore/TagUI#465 raised by user, an improvement is made upstream, using a solution for a similar problem while working on this personal side project. Thus a commit can now be made here that replaces single quote ' for non-identifier parameter with ``` \' ``` This may seem like a small improvement, but it helps clarify in debug log tagui_python.log when t.debug(True) is set. Otherwise, whenever there is a ' it would result in some roundabout escape sequence above due to a limitation in upstream live mode. This commit fixes that by escaping ' to \' following standard convention.
1 parent 347552a commit b4f3728

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# TagUI for Python
44

5-
[**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About**](#about) | [**v1.3**](https://github.com/tebelorg/TagUI-Python/releases)
5+
[**Use Cases**](#use-cases) | [**API Reference**](#api-reference) | [**About**](#about) | [**v1.5**](https://github.com/tebelorg/TagUI-Python/releases)
66

77
![TagUI for Python demo in Jupyter notebook](https://raw.githubusercontent.com/tebelorg/Tump/master/tagui_python.gif)
88

sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# use read() to fetch and return text from UI element
1616
search_text = t.read('search-box')
1717

18-
# use echo() to print to output (tracked in debug log)
18+
# use echo() to print to output, same as Python print()
1919
t.echo(search_text)
2020

2121
# use click() to click on an UI element or x, y location

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='tagui',
5-
version='1.4.0',
5+
version='1.5.0',
66
py_modules=['tagui'],
77
author='Ken Soh',
88
author_email='[email protected]',

tagui.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""INTEGRATION ENGINE FOR TAGUI PYTHON PACKAGE ~ TEBEL.ORG"""
22
__author__ = 'Ken Soh <[email protected]>'
3-
__version__ = '1.4.0'
3+
__version__ = '1.5.0'
44

55
import subprocess
66
import os
@@ -131,10 +131,9 @@ def _tagui_output():
131131
return tagui_output_text
132132

133133
def _esq(input_text = ''):
134-
"""function to escape single quote ' for tagui live mode"""
135-
# ie change ' to be `"\'"` which becomes '+"\'"+' in tagui
136-
# "[BACKSLASH_QUOTE]" used in interim to work with send()
137-
return input_text.replace("'",'`"[BACKSLASH_QUOTE]"`')
134+
"""function for selective escape of single quote ' for tagui"""
135+
# [BACKSLASH_QUOTE] marker to work together with send()
136+
return input_text.replace("'",'[BACKSLASH_QUOTE]')
138137

139138
def _sdq(input_text = ''):
140139
"""function to escape ' in xpath for tagui live mode"""
@@ -562,7 +561,7 @@ def send(tagui_instruction = None):
562561
tagui_instruction = tagui_instruction.replace('\f','\\f')
563562

564563
# special handling for single quote to work with _esq() for tagui
565-
tagui_instruction = tagui_instruction.replace('"[BACKSLASH_QUOTE]"','"\\\'"')
564+
tagui_instruction = tagui_instruction.replace('[BACKSLASH_QUOTE]','\\\'')
566565

567566
# escape backslash to display source string correctly after echoing
568567
echo_safe_instruction = tagui_instruction.replace('\\','\\\\')

0 commit comments

Comments
 (0)