summaryrefslogtreecommitdiff
path: root/error.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2021-03-09 09:02:50 +0100
committerAnthon van der Neut <anthon@mnt.org>2021-03-09 09:02:50 +0100
commite73562c6f14d1d71a9fea174d58465e1b13f68af (patch)
tree309851cca7d411b31c27753555871d493282c7f0 /error.py
parent96839d9f64f4698bdc519cbfbd48d51178460714 (diff)
downloadruamel.yaml-e73562c6f14d1d71a9fea174d58465e1b13f68af.tar.gz
remove python 2 specific code
add future deprecation warning to old style functions
Diffstat (limited to 'error.py')
-rw-r--r--error.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/error.py b/error.py
index d5f1553..6853e2d 100644
--- a/error.py
+++ b/error.py
@@ -1,11 +1,9 @@
# coding: utf-8
-from __future__ import absolute_import
-
import warnings
import textwrap
-from ruamel.yaml.compat import utf8
+from ruamel.yaml.compat import _F
if False: # MYPY
from typing import Any, Dict, Optional, List, Text # NOQA
@@ -36,7 +34,12 @@ class StreamMark(object):
def __str__(self):
# type: () -> Any
- where = ' in "%s", line %d, column %d' % (self.name, self.line + 1, self.column + 1)
+ where = _F(
+ ' in "{sname!s}", line {sline1:d}, column {scolumn1:d}',
+ sname=self.name,
+ sline1=self.line + 1,
+ scolumn1=self.column + 1,
+ )
return where
def __eq__(self, other):
@@ -71,7 +74,7 @@ class StringMark(StreamMark):
return None
head = ""
start = self.pointer
- while start > 0 and self.buffer[start - 1] not in u'\0\r\n\x85\u2028\u2029':
+ while start > 0 and self.buffer[start - 1] not in '\0\r\n\x85\u2028\u2029':
start -= 1
if self.pointer - start > max_length / 2 - 1:
head = ' ... '
@@ -79,13 +82,13 @@ class StringMark(StreamMark):
break
tail = ""
end = self.pointer
- while end < len(self.buffer) and self.buffer[end] not in u'\0\r\n\x85\u2028\u2029':
+ while end < len(self.buffer) and self.buffer[end] not in '\0\r\n\x85\u2028\u2029':
end += 1
if end - self.pointer > max_length / 2 - 1:
tail = ' ... '
end -= 5
break
- snippet = utf8(self.buffer[start:end])
+ snippet = self.buffer[start:end]
caret = '^'
caret = '^ (line: {})'.format(self.line + 1)
return (
@@ -101,7 +104,12 @@ class StringMark(StreamMark):
def __str__(self):
# type: () -> Any
snippet = self.get_snippet()
- where = ' in "%s", line %d, column %d' % (self.name, self.line + 1, self.column + 1)
+ where = _F(
+ ' in "{sname!s}", line {sline1:d}, column {scolumn1:d}',
+ sname=self.name,
+ sline1=self.line + 1,
+ scolumn1=self.column + 1,
+ )
if snippet is not None:
where += ':\n' + snippet
return where