Skip to content

Commit 3390985

Browse files
committed
python26: Update all instances of .format() to use positional arguments to support python 2.6
1 parent c730f05 commit 3390985

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

influxdb/_dataframe_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _convert_dataframe_to_json(self, dataframe, measurement, tags=None,
119119
time_precision=None):
120120

121121
if not isinstance(dataframe, pd.DataFrame):
122-
raise TypeError('Must be DataFrame, but type was: {}.'
122+
raise TypeError('Must be DataFrame, but type was: {0}.'
123123
.format(type(dataframe)))
124124
if not (isinstance(dataframe.index, pd.tseries.period.PeriodIndex) or
125125
isinstance(dataframe.index, pd.tseries.index.DatetimeIndex)):

influxdb/client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,12 @@ def alter_retention_policy(self, name, database=None,
530530
should be set. Otherwise the operation will fail.
531531
"""
532532
query_string = (
533-
"ALTER RETENTION POLICY {} ON {}"
533+
"ALTER RETENTION POLICY {0} ON {1}"
534534
).format(name, database or self._database)
535535
if duration:
536-
query_string += " DURATION {}".format(duration)
536+
query_string += " DURATION {0}".format(duration)
537537
if replication:
538-
query_string += " REPLICATION {}".format(replication)
538+
query_string += " REPLICATION {0}".format(replication)
539539
if default is True:
540540
query_string += " DEFAULT"
541541

@@ -643,7 +643,7 @@ def create_user(self, username, password, admin=False):
643643
privileges or not
644644
:type admin: boolean
645645
"""
646-
text = "CREATE USER {} WITH PASSWORD '{}'".format(username, password)
646+
text = "CREATE USER {0} WITH PASSWORD '{1}'".format(username, password)
647647
if admin:
648648
text += ' WITH ALL PRIVILEGES'
649649
self.query(text)
@@ -654,7 +654,7 @@ def drop_user(self, username):
654654
:param username: the username to drop
655655
:type username: str
656656
"""
657-
text = "DROP USER {}".format(username)
657+
text = "DROP USER {0}".format(username)
658658
self.query(text)
659659

660660
def set_user_password(self, username, password):
@@ -665,7 +665,7 @@ def set_user_password(self, username, password):
665665
:param password: the new password for the user
666666
:type password: str
667667
"""
668-
text = "SET PASSWORD FOR {} = '{}'".format(username, password)
668+
text = "SET PASSWORD FOR {0} = '{1}'".format(username, password)
669669
self.query(text)
670670

671671
def delete_series(self, database=None, measurement=None, tags=None):
@@ -683,10 +683,10 @@ def delete_series(self, database=None, measurement=None, tags=None):
683683
database = database or self._database
684684
query_str = 'DROP SERIES'
685685
if measurement:
686-
query_str += ' FROM "{}"'.format(measurement)
686+
query_str += ' FROM "{0}"'.format(measurement)
687687

688688
if tags:
689-
query_str += ' WHERE ' + ' and '.join(["{}='{}'".format(k, v)
689+
query_str += ' WHERE ' + ' and '.join(["{0}='{1}'".format(k, v)
690690
for k, v in tags.items()])
691691
self.query(query_str, database=database)
692692

@@ -699,7 +699,7 @@ def revoke_admin_privileges(self, username):
699699
.. note:: Only a cluster administrator can create/ drop databases
700700
and manage users.
701701
"""
702-
text = "REVOKE ALL PRIVILEGES FROM {}".format(username)
702+
text = "REVOKE ALL PRIVILEGES FROM {0}".format(username)
703703
self.query(text)
704704

705705
def grant_privilege(self, privilege, database, username):
@@ -713,7 +713,7 @@ def grant_privilege(self, privilege, database, username):
713713
:param username: the username to grant the privilege to
714714
:type username: str
715715
"""
716-
text = "GRANT {} ON {} TO {}".format(privilege,
716+
text = "GRANT {0} ON {1} TO {2}".format(privilege,
717717
database,
718718
username)
719719
self.query(text)
@@ -729,7 +729,7 @@ def revoke_privilege(self, privilege, database, username):
729729
:param username: the username to revoke the privilege from
730730
:type username: str
731731
"""
732-
text = "REVOKE {} ON {} FROM {}".format(privilege,
732+
text = "REVOKE {0} ON {1} FROM {2}".format(privilege,
733733
database,
734734
username)
735735
self.query(text)
@@ -911,15 +911,15 @@ def parse_dsn(dsn):
911911
modifier, scheme = scheme_info
912912

913913
if scheme != 'influxdb':
914-
raise ValueError('Unknown scheme "{}".'.format(scheme))
914+
raise ValueError('Unknown scheme "{0}".'.format(scheme))
915915

916916
if modifier:
917917
if modifier == 'udp':
918918
init_args['use_udp'] = True
919919
elif modifier == 'https':
920920
init_args['ssl'] = True
921921
else:
922-
raise ValueError('Unknown modifier "{}".'.format(modifier))
922+
raise ValueError('Unknown modifier "{0}".'.format(modifier))
923923

924924
netlocs = conn_params.netloc.split(',')
925925

@@ -937,7 +937,7 @@ def parse_dsn(dsn):
937937

938938

939939
def _parse_netloc(netloc):
940-
info = urlparse("http://{}".format(netloc))
940+
info = urlparse("http://{0}".format(netloc))
941941
return {'username': info.username or None,
942942
'password': info.password or None,
943943
'host': info.hostname or 'localhost',

influxdb/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def __new__(cls, *args, **kwargs):
5151
_meta = getattr(cls, 'Meta')
5252
except AttributeError:
5353
raise AttributeError(
54-
'Missing Meta class in {}.'.format(
54+
'Missing Meta class in {0}.'.format(
5555
cls.__name__))
5656

5757
for attr in ['series_name', 'fields', 'tags']:
5858
try:
5959
setattr(cls, '_' + attr, getattr(_meta, attr))
6060
except AttributeError:
6161
raise AttributeError(
62-
'Missing {} in {} Meta class.'.format(
62+
'Missing {0} in {1} Meta class.'.format(
6363
attr,
6464
cls.__name__))
6565

@@ -68,22 +68,22 @@ def __new__(cls, *args, **kwargs):
6868
cls._client = getattr(_meta, 'client', None)
6969
if cls._autocommit and not cls._client:
7070
raise AttributeError(
71-
'In {}, autocommit is set to True, but no client is set.'
71+
'In {0}, autocommit is set to True, but no client is set.'
7272
.format(cls.__name__))
7373

7474
try:
7575
cls._bulk_size = getattr(_meta, 'bulk_size')
7676
if cls._bulk_size < 1 and cls._autocommit:
7777
warn(
78-
'Definition of bulk_size in {} forced to 1, '
78+
'Definition of bulk_size in {0} forced to 1, '
7979
'was less than 1.'.format(cls.__name__))
8080
cls._bulk_size = 1
8181
except AttributeError:
8282
cls._bulk_size = -1
8383
else:
8484
if not cls._autocommit:
8585
warn(
86-
'Definition of bulk_size in {} has no affect because'
86+
'Definition of bulk_size in {0} has no affect because'
8787
' autocommit is false.'.format(cls.__name__))
8888

8989
cls._datapoints = defaultdict(list)

influxdb/influxdb08/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ def from_DSN(dsn, **kwargs):
145145
modifier, scheme = scheme_info
146146

147147
if scheme != 'influxdb':
148-
raise ValueError('Unknown scheme "{}".'.format(scheme))
148+
raise ValueError('Unknown scheme "{0}".'.format(scheme))
149149
if modifier:
150150
if modifier == 'udp':
151151
init_args['use_udp'] = True
152152
elif modifier == 'https':
153153
init_args['ssl'] = True
154154
else:
155-
raise ValueError('Unknown modifier "{}".'.format(modifier))
155+
raise ValueError('Unknown modifier "{0}".'.format(modifier))
156156

157157
if conn_params.hostname:
158158
init_args['host'] = conn_params.hostname
@@ -838,7 +838,7 @@ def alter_database_user(self, username, password=None, permissions=None):
838838
url = "db/{0}/users/{1}".format(self._database, username)
839839

840840
if not password and not permissions:
841-
raise ValueError("Nothing to alter for user {}.".format(username))
841+
raise ValueError("Nothing to alter for user {0}.".format(username))
842842

843843
data = {}
844844

influxdb/influxdb08/dataframe_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _to_dataframe(self, json_result, time_precision):
121121

122122
def _convert_dataframe_to_json(self, dataframe, name, time_precision='s'):
123123
if not isinstance(dataframe, pd.DataFrame):
124-
raise TypeError('Must be DataFrame, but type was: {}.'
124+
raise TypeError('Must be DataFrame, but type was: {0}.'
125125
.format(type(dataframe)))
126126
if not (isinstance(dataframe.index, pd.tseries.period.PeriodIndex) or
127127
isinstance(dataframe.index, pd.tseries.index.DatetimeIndex)):

influxdb/influxdb08/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def __new__(cls, *args, **kwargs):
5151
_meta = getattr(cls, 'Meta')
5252
except AttributeError:
5353
raise AttributeError(
54-
'Missing Meta class in {}.'.format(
54+
'Missing Meta class in {0}.'.format(
5555
cls.__name__))
5656

5757
for attr in ['series_name', 'fields']:
5858
try:
5959
setattr(cls, '_' + attr, getattr(_meta, attr))
6060
except AttributeError:
6161
raise AttributeError(
62-
'Missing {} in {} Meta class.'.format(
62+
'Missing {0} in {1} Meta class.'.format(
6363
attr,
6464
cls.__name__))
6565

@@ -68,22 +68,22 @@ def __new__(cls, *args, **kwargs):
6868
cls._client = getattr(_meta, 'client', None)
6969
if cls._autocommit and not cls._client:
7070
raise AttributeError(
71-
'In {}, autocommit is set to True, but no client is set.'
71+
'In {0}, autocommit is set to True, but no client is set.'
7272
.format(cls.__name__))
7373

7474
try:
7575
cls._bulk_size = getattr(_meta, 'bulk_size')
7676
if cls._bulk_size < 1 and cls._autocommit:
7777
warn(
78-
'Definition of bulk_size in {} forced to 1, '
78+
'Definition of bulk_size in {0} forced to 1, '
7979
'was less than 1.'.format(cls.__name__))
8080
cls._bulk_size = 1
8181
except AttributeError:
8282
cls._bulk_size = -1
8383
else:
8484
if not cls._autocommit:
8585
warn(
86-
'Definition of bulk_size in {} has no affect because'
86+
'Definition of bulk_size in {0} has no affect because'
8787
' autocommit is false.'.format(cls.__name__))
8888

8989
cls._datapoints = defaultdict(list)

influxdb/line_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _escape_tag(tag):
5252
def _escape_value(value):
5353
value = _get_unicode(value)
5454
if isinstance(value, text_type) and value != '':
55-
return "\"{}\"".format(
55+
return "\"{0}\"".format(
5656
value.replace(
5757
"\"", "\\\""
5858
).replace(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy