diff options
author | kotfu <kotfu@kotfu.net> | 2018-01-07 12:09:31 -0700 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-01-07 12:09:31 -0700 |
commit | 4f54d10f4c8d5b5c03626a88f8198318a8080fc6 (patch) | |
tree | c567676617cbb0cad1139b9267e00e7ad8f531dc /cmd2.py | |
parent | d63c878413006630834324d71bd22f012bc543a8 (diff) | |
parent | 2a474dc8f13a3a4558136215a7a1706ba13ba732 (diff) | |
download | cmd2-git-4f54d10f4c8d5b5c03626a88f8198318a8080fc6.tar.gz |
Merge branch 'master' of github.com:python-cmd2/cmd2 into argparse
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 40 |
1 files changed, 28 insertions, 12 deletions
@@ -53,16 +53,6 @@ except ImportError: # noinspection PyUnresolvedReferences from pyperclip import PyperclipException -# On some systems, pyperclip will import gtk for its clipboard functionality. -# The following code is a workaround for gtk interfering with printing from a background -# thread while the CLI thread is blocking in raw_input() in Python 2 on Linux. -try: - # noinspection PyUnresolvedReferences - import gtk - gtk.set_interactive(0) -except ImportError: - pass - # next(it) gets next item of iterator it. This is a replacement for calling it.next() in Python 2 and next(it) in Py3 from six import next @@ -105,7 +95,18 @@ if six.PY3: else: BROKEN_PIPE_ERROR = IOError -__version__ = '0.7.9a' +# On some systems, pyperclip will import gtk for its clipboard functionality. +# The following code is a workaround for gtk interfering with printing from a background +# thread while the CLI thread is blocking in raw_input() in Python 2 on Linux. +if six.PY2 and sys.platform.startswith('lin'): + try: + # noinspection PyUnresolvedReferences + import gtk + gtk.set_interactive(0) + except ImportError: + pass + +__version__ = '0.7.9' # Pyparsing enablePackrat() can greatly speed up parsing, but problems have been seen in Python 3 in the past pyparsing.ParserElement.enablePackrat() @@ -2424,7 +2425,22 @@ class Cmd2TestCase(unittest.TestCase): self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message) def _transform_transcript_expected(self, s): - """parse the string with slashed regexes into a valid regex""" + """parse the string with slashed regexes into a valid regex + + Given a string like: + + Match a 10 digit phone number: /\d{3}-\d{3}-\d{4}/ + + Turn it into a valid regular expression which matches the literal text + of the string and the regular expression. We have to remove the slashes + because they differentiate between plain text and a regular expression. + Unless the slashes are escaped, in which case they are interpreted as + plain text, or there is only one slash, which is treated as plain text + also. + + Check the tests in tests/test_transcript.py to see all the edge + cases. + """ regex = '' start = 0 |