Skip to content

Commit a466a56

Browse files
committedFeb 20, 2014
updated str.format() for python 2.6 compatibily
1 parent 6ff7736 commit a466a56

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed
 

Diff for: ‎dbparti/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
try:
6-
backend = __import__('dbparti.backends.{}'.format(connection.vendor), fromlist='*')
6+
backend = __import__('dbparti.backends.{0}'.format(connection.vendor), fromlist='*')
77
except ImportError:
88
import pkgutil, os
99
raise BackendError(

Diff for: ‎dbparti/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, *args, **kwargs):
1717
)
1818

1919
try:
20-
self.filter = getattr(backend.filters, '{}PartitionFilter'.format(
20+
self.filter = getattr(backend.filters, '{0}PartitionFilter'.format(
2121
self.opts.partition_type.capitalize()))(self.partition_show, **self.opts.__dict__)
2222
except AttributeError:
2323
import re

Diff for: ‎dbparti/backends/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ def __init__(self, column_value, column_type, **kwargs):
1313

1414
def prepare(self):
1515
"""Prepares everything that is needed to initialize partitioning"""
16-
raise NotImplementedError('Prepare method not implemented for partition type: {}'.format(self.__class__.__name__))
16+
raise NotImplementedError('Prepare method not implemented for partition type: {0}'.format(self.__class__.__name__))
1717

1818
def exists(self):
1919
"""Checks if partition exists"""
20-
raise NotImplementedError('Exists method not implemented for partition type: {}'.format(self.__class__.__name__))
20+
raise NotImplementedError('Exists method not implemented for partition type: {0}'.format(self.__class__.__name__))
2121

2222
def create(self):
2323
"""Creates new partition"""
24-
raise NotImplementedError('Create method not implemented for partition type: {}'.format(self.__class__.__name__))
24+
raise NotImplementedError('Create method not implemented for partition type: {0}'.format(self.__class__.__name__))
2525

2626
def _get_name(self):
2727
"""Defines name for a new partition"""
28-
raise NotImplementedError('Name method not implemented for partition type: {}'.format(self.__class__.__name__))
28+
raise NotImplementedError('Name method not implemented for partition type: {0}'.format(self.__class__.__name__))
2929

3030
def _get_partition_function(self):
3131
"""Contains a partition function that is used to create new partitions at database level"""
32-
raise NotImplementedError('Partition function method not implemented for partition type: {}'.format(self.__class__.__name__))
32+
raise NotImplementedError('Partition function method not implemented for partition type: {0}'.format(self.__class__.__name__))
3333

3434

3535
class BasePartitionFilter(object):
@@ -42,4 +42,4 @@ def __init__(self, partition_show, **kwargs):
4242

4343
def apply(self):
4444
"""Contains a filter that needs to be applied to queryset"""
45-
raise NotImplementedError('Filter not implemented for type: {}'.format(self.__class__.__name__))
45+
raise NotImplementedError('Filter not implemented for type: {0}'.format(self.__class__.__name__))

Diff for: ‎dbparti/backends/mysql/filters.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
2222
def apply(self):
2323
"""Dynamically loads needed partition filter depending on the partition subtype"""
2424
try:
25-
return getattr(self, '_get_{}_filter'.format(self.partition_subtype))()
25+
return getattr(self, '_get_{0}_filter'.format(self.partition_subtype))()
2626
except AttributeError:
2727
import re
2828
raise PartitionRangeSubtypeError(
@@ -36,20 +36,20 @@ def _get_date_filter(self):
3636
"""Contains a partition filter for date partition subtype"""
3737
ranges = {
3838
'year': [
39-
"EXTRACT(YEAR FROM {}.{}) = EXTRACT(YEAR FROM {})",
39+
"EXTRACT(YEAR FROM {0}.{1}) = EXTRACT(YEAR FROM {2})",
4040
],
4141
'month': [
42-
"EXTRACT(YEAR FROM {}.{}) = EXTRACT(YEAR FROM NOW())",
43-
"EXTRACT(MONTH FROM {}.{}) = EXTRACT(MONTH FROM {})",
42+
"EXTRACT(YEAR FROM {0}.{1}) = EXTRACT(YEAR FROM NOW())",
43+
"EXTRACT(MONTH FROM {2}.{3}) = EXTRACT(MONTH FROM {4})",
4444
],
4545
'week': [
46-
"EXTRACT(YEAR FROM {}.{}) = EXTRACT(YEAR FROM NOW())",
47-
"EXTRACT(WEEK FROM {}.{}) = EXTRACT(WEEK FROM {})",
46+
"EXTRACT(YEAR FROM {0}.{1}) = EXTRACT(YEAR FROM NOW())",
47+
"EXTRACT(WEEK FROM {2}.{3}) = EXTRACT(WEEK FROM {4})",
4848
],
4949
'day': [
50-
"EXTRACT(YEAR FROM {}.{}) = EXTRACT(YEAR FROM NOW())",
51-
"EXTRACT(MONTH FROM {}.{}) = EXTRACT(MONTH FROM NOW())",
52-
"EXTRACT(DAY FROM {}.{}) = EXTRACT(DAY FROM {})",
50+
"EXTRACT(YEAR FROM {0}.{1}) = EXTRACT(YEAR FROM NOW())",
51+
"EXTRACT(MONTH FROM {2}.{3}) = EXTRACT(MONTH FROM NOW())",
52+
"EXTRACT(DAY FROM {4}.{5}) = EXTRACT(DAY FROM {6})",
5353
],
5454
}
5555

@@ -60,7 +60,7 @@ def _get_date_filter(self):
6060

6161
shows = {
6262
'current': 'NOW()',
63-
'previous': 'NOW() - INTERVAL 1 {}',
63+
'previous': 'NOW() - INTERVAL 1 {0}',
6464
}
6565

6666
try:

Diff for: ‎dbparti/backends/mysql/partition.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def create(self):
8585
def _get_name(self):
8686
"""Dynamically defines new partition name depending on the partition subtype"""
8787
try:
88-
return getattr(self, '_get_{}_name'.format(self.partition_subtype))()
88+
return getattr(self, '_get_{0}_name'.format(self.partition_subtype))()
8989
except AttributeError:
9090
import re
9191
raise PartitionRangeSubtypeError(
@@ -97,7 +97,7 @@ def _get_name(self):
9797

9898
def _get_date_name(self):
9999
"""Defines name for a new partition for date partition subtype"""
100-
return '{}_{}'.format(self.table, self.datetime.get_name())
100+
return '{0}_{1}'.format(self.table, self.datetime.get_name())
101101

102102
def _get_partition_function(self):
103103
"""Returns correct partition function depending on the MySQL column type"""

Diff for: ‎dbparti/backends/postgresql/filters.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs):
2222
def apply(self):
2323
"""Dynamically loads needed partition filter depending on the partition subtype"""
2424
try:
25-
return getattr(self, '_get_{}_filter'.format(self.partition_subtype))()
25+
return getattr(self, '_get_{0}_filter'.format(self.partition_subtype))()
2626
except AttributeError:
2727
import re
2828
raise PartitionRangeSubtypeError(
@@ -36,20 +36,20 @@ def _get_date_filter(self):
3636
"""Contains a partition filter for date partition subtype"""
3737
ranges = {
3838
'year': [
39-
"EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM {})",
39+
"EXTRACT('year' FROM {0}.{1}) = EXTRACT('year' FROM {2})",
4040
],
4141
'month': [
42-
"EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM NOW())",
43-
"EXTRACT('month' FROM {}.{}) = EXTRACT('month' FROM {})",
42+
"EXTRACT('year' FROM {0}.{1}) = EXTRACT('year' FROM NOW())",
43+
"EXTRACT('month' FROM {2}.{3}) = EXTRACT('month' FROM {4})",
4444
],
4545
'week': [
46-
"EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM NOW())",
47-
"EXTRACT('week' FROM {}.{}) = EXTRACT('week' FROM {})",
46+
"EXTRACT('year' FROM {0}.{1}) = EXTRACT('year' FROM NOW())",
47+
"EXTRACT('week' FROM {2}.{3}) = EXTRACT('week' FROM {4})",
4848
],
4949
'day': [
50-
"EXTRACT('year' FROM {}.{}) = EXTRACT('year' FROM NOW())",
51-
"EXTRACT('month' FROM {}.{}) = EXTRACT('month' FROM NOW())",
52-
"EXTRACT('day' FROM {}.{}) = EXTRACT('day' FROM {})",
50+
"EXTRACT('year' FROM {0}.{1}) = EXTRACT('year' FROM NOW())",
51+
"EXTRACT('month' FROM {2}.{3}) = EXTRACT('month' FROM NOW())",
52+
"EXTRACT('day' FROM {4}.{5}) = EXTRACT('day' FROM {6})",
5353
],
5454
}
5555

@@ -60,7 +60,7 @@ def _get_date_filter(self):
6060

6161
shows = {
6262
'current': 'NOW()',
63-
'previous': "NOW() - '1 {}'::interval",
63+
'previous': "NOW() - '1 {0}'::interval",
6464
}
6565

6666
try:

Diff for: ‎dbparti/backends/postgresql/partition.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self, *args, **kwargs):
8585
def _get_partition_function(self):
8686
"""Dynamically loads needed before insert function body depending on the partition subtype"""
8787
try:
88-
return getattr(self, '_get_{}_partition_function'.format(self.partition_subtype))()
88+
return getattr(self, '_get_{0}_partition_function'.format(self.partition_subtype))()
8989
except AttributeError:
9090
import re
9191
raise PartitionRangeSubtypeError(

Diff for: ‎dbparti/backends/utilities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_name(self):
2727
def get_period(self):
2828
"""Dynamically returns beginning and an end depending on the given period"""
2929
try:
30-
return getattr(self, '_get_{}_period'.format(self.period))()
30+
return getattr(self, '_get_{0}_period'.format(self.period))()
3131
except AttributeError:
3232
import re
3333
raise PartitionRangeError(

Diff for: ‎dbparti/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_partition(self):
2626
)
2727

2828
try:
29-
return getattr(backend.partition, '{}Partition'.format(
29+
return getattr(backend.partition, '{0}Partition'.format(
3030
self._meta.partition_type.capitalize()))(column_value, column_type, **self._meta.__dict__)
3131
except AttributeError:
3232
import re

0 commit comments

Comments
 (0)
Please sign in to comment.