diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2016-07-24 00:55:33 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-07-24 00:58:37 +0200 |
commit | 8f54b1960e2050536f34f091c1de291febd486df (patch) | |
tree | 63de297dc93365e67cb2e0af2ee81e9d94e9fabb /pyinflux/client/__init__.py | |
parent | fbb91144484ad729c2d6b54c69d4ce3a6c80aa55 (diff) | |
download | pyinflux-master.tar.gz pyinflux-master.zip |
fix small bug with parsing quoted escaped escapes
Diffstat (limited to 'pyinflux/client/__init__.py')
-rw-r--r-- | pyinflux/client/__init__.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/pyinflux/client/__init__.py b/pyinflux/client/__init__.py index b485861..feb5381 100644 --- a/pyinflux/client/__init__.py +++ b/pyinflux/client/__init__.py @@ -32,13 +32,16 @@ class Line(object): @staticmethod def escape_value(obj): + DBLQ='"' if (isinstance(obj, float) or isinstance(obj, int) or isinstance(obj, bool)): return str(obj) else: obj = str(obj) - return "\"" + obj.replace("\\", "\\\\").replace("\"", "\\\"") + "\"" + obj = obj.replace('\\', '\\\\') + obj = obj.replace(DBLQ, '\\"') + return DBLQ + obj + DBLQ @staticmethod def escape_fields(kvlist): @@ -50,18 +53,10 @@ class Line(object): kvlist)) def __repr__(self): - """ - >>> print(repr(Line('test', [('a','b')], [('value','asd\\\\')]))) - <Line key=test tags=[('a', 'b')] fields=[('value', 'asd\\\\')] timestamp=None> - """ return "<{} key={} tags={} fields={} timestamp={}>".format( self.__class__.__name__, self.key, self.tags, self.fields, self.timestamp) def __str__(self): - """ - >>> print(Line('test', [('a','b')], [('value','asd\\\\')])) - test,a=b value="asd\\\\" - """ result = self.escape_identifier(self.key) if self.tags: @@ -138,6 +133,9 @@ class Influx: class InfluxDB(Influx): + """ + like Influx but with a predefined database + """ def __init__(self, db: str, host: str, port: int = 8086, username: str = None, password: str = None): super().__init__(host, port, username, password) self._db = db |