summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrançois Pietka <francois@pietka.fr>2017-07-27 14:08:12 +0200
committerFrançois Pietka <francois@pietka.fr>2017-07-27 14:08:12 +0200
commita9f4864d73241602b96f515edd219b6204dcb4bd (patch)
tree87a6226d70239af784216ca122c3ad6189c95db0
parent1a2932ec0459325be1a531c280d3f26ec5d6cd7f (diff)
Use raw strings where needed to avoid backslash ambiguity
-rwxr-xr-xpgcli/main.py4
-rw-r--r--pgcli/packages/parseutils/utils.py4
-rw-r--r--pgcli/packages/sqlcompletion.py2
-rw-r--r--pgcli/pgbuffer.py2
-rw-r--r--pgcli/pgcompleter.py2
-rw-r--r--pgcli/pgexecute.py2
6 files changed, 8 insertions, 8 deletions
diff --git a/pgcli/main.py b/pgcli/main.py
index 42bbdd7c..45149f8f 100755
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -367,7 +367,7 @@ class PGCli(object):
self.pgexecute = pgexecute
def handle_editor_command(self, cli, document):
- """
+ r"""
Editor command is any query that is prefixed or suffixed
by a '\e'. The reason for a while loop is because a user
might edit a query multiple times.
@@ -929,7 +929,7 @@ def is_select(status):
def quit_command(sql):
return (sql.strip().lower() == 'exit'
or sql.strip().lower() == 'quit'
- or sql.strip() == '\q'
+ or sql.strip() == r'\q'
or sql.strip() == ':q')
diff --git a/pgcli/packages/parseutils/utils.py b/pgcli/packages/parseutils/utils.py
index e52ecee8..f419b1ba 100644
--- a/pgcli/packages/parseutils/utils.py
+++ b/pgcli/packages/parseutils/utils.py
@@ -12,12 +12,12 @@ cleanup_regex = {
# This matches everything except spaces, parens, colon, comma, and period
'most_punctuations': re.compile(r'([^\.():,\s]+)$'),
# This matches everything except a space.
- 'all_punctuations': re.compile('([^\s]+)$'),
+ 'all_punctuations': re.compile(r'([^\s]+)$'),
}
def last_word(text, include='alphanum_underscore'):
- """
+ r"""
Find the last word in a sentence.
>>> last_word('abc')
diff --git a/pgcli/packages/sqlcompletion.py b/pgcli/packages/sqlcompletion.py
index 70a39b9b..bb3a3680 100644
--- a/pgcli/packages/sqlcompletion.py
+++ b/pgcli/packages/sqlcompletion.py
@@ -174,7 +174,7 @@ def _strip_named_query(txt):
return txt
-function_body_pattern = re.compile('(\\$.*?\\$)([\s\S]*?)\\1', re.M)
+function_body_pattern = re.compile(r'(\$.*?\$)([\s\S]*?)\1', re.M)
def _find_function_body(text):
diff --git a/pgcli/pgbuffer.py b/pgcli/pgbuffer.py
index 15494305..2eba48cf 100644
--- a/pgcli/pgbuffer.py
+++ b/pgcli/pgbuffer.py
@@ -33,7 +33,7 @@ def _is_complete(sql):
def _multiline_exception(text):
text = text.strip()
return (text.startswith('\\') or # Special Command
- text.endswith('\e') or # Ended with \e which should launch the editor.
+ text.endswith(r'\e') or # Ended with \e which should launch the editor.
_is_complete(text) or # A complete SQL command
(text == 'exit') or # Exit doesn't need semi-colon
(text == 'quit') or # Quit doesn't need semi-colon
diff --git a/pgcli/pgcompleter.py b/pgcli/pgcompleter.py
index 34fbe0d8..8613d6f9 100644
--- a/pgcli/pgcompleter.py
+++ b/pgcli/pgcompleter.py
@@ -114,7 +114,7 @@ class PGCompleter(Completer):
self.reserved_words = set()
for x in self.keywords:
self.reserved_words.update(x.split())
- self.name_pattern = re.compile("^[_a-z][_a-z0-9\$]*$")
+ self.name_pattern = re.compile(r"^[_a-z][_a-z0-9\$]*$")
self.databases = []
self.dbmetadata = {'tables': {}, 'views': {}, 'functions': {},
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py
index b7fd1568..a934aaf8 100644
--- a/pgcli/pgexecute.py
+++ b/pgcli/pgexecute.py
@@ -642,7 +642,7 @@ class PGExecute(object):
def casing(self):
"""Yields the most common casing for names used in db functions"""
with self.conn.cursor() as cur:
- query = '''
+ query = r'''
WITH Words AS (
SELECT regexp_split_to_table(prosrc, '\W+') AS Word, COUNT(1)
FROM pg_catalog.pg_proc P