Skip to content

Commit 4082b8d

Browse files
committed
Rename constants
1 parent 8505ff2 commit 4082b8d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

manager.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.db import models, connection
66
from django.db.models import sql, query
77

8-
NET_TERMS = {
8+
NET_OPERATORS = {
99
'lt': '%s < %s',
1010
'lte': '%s <= %s',
1111
'exact': '%s = %s',
@@ -22,14 +22,14 @@
2222
'regex': '%s ~* %s',
2323
}
2424

25-
NET_TERMS_TEXT_LOOKUPS = set([
25+
NET_TEXT_LOOKUPS = set([
2626
'contains',
2727
'startswith',
2828
'endswith',
2929
'regex',
3030
])
3131

32-
NET_TERMS_MAPPING = {
32+
NET_MAPPING = {
3333
'iexact': 'exact',
3434
'icontains': 'contains',
3535
'istartswith': 'startswith',
@@ -41,7 +41,7 @@
4141

4242
class NetQuery(sql.Query):
4343
query_terms = sql.Query.query_terms.copy()
44-
query_terms.update(NET_TERMS)
44+
query_terms.update(NET_OPERATORS)
4545

4646
def add_filter(self, (filter_string, value), *args, **kwargs):
4747
# IP(...) == '' fails so make sure to force to string while we can
@@ -64,19 +64,19 @@ def make_atom(self, child, qn):
6464
if lookup_type == 'regex':
6565
lhs = 'HOST(%s)' % field_sql
6666
rhs = '%s'
67-
elif lookup_type in NET_TERMS_TEXT_LOOKUPS:
67+
elif lookup_type in NET_TEXT_LOOKUPS:
6868
lhs = 'UPPER(HOST(%s))' % field_sql
6969
rhs = 'UPPER(%s)'
7070
else:
7171
lhs = field_sql
7272
rhs = '%s'
7373

74-
if lookup_type in NET_TERMS_MAPPING:
75-
lookup_type = NET_TERMS_MAPPING[lookup_type]
74+
if lookup_type in NET_MAPPING:
75+
lookup_type = NET_MAPPING[lookup_type]
7676
child = (table_alias, name, db_type, lookup_type, value_annot, params)
7777
return self.make_atom(child, qn)
78-
elif lookup_type in NET_TERMS:
79-
return (NET_TERMS[lookup_type] % (lhs, rhs), params)
78+
elif lookup_type in NET_OPERATORS:
79+
return (NET_OPERATORS[lookup_type] % (lhs, rhs), params)
8080
elif lookup_type == 'in':
8181
return ('%s IN (%s)' % (lhs, ', '.join([rhs] * len(params))), params)
8282
elif lookup_type == 'range':
@@ -121,11 +121,11 @@ def get_db_prep_lookup(self, lookup_type, value):
121121
if value is None:
122122
return value
123123

124-
if lookup_type in NET_TERMS_MAPPING:
124+
if lookup_type in NET_MAPPING:
125125
return self.get_db_prep_lookup(
126-
NET_TERMS_MAPPING[lookup_type], value)
126+
NET_MAPPING[lookup_type], value)
127127

128-
if lookup_type in NET_TERMS and lookup_type not in NET_TERMS_TEXT_LOOKUPS:
128+
if lookup_type in NET_OPERATORS and lookup_type not in NET_TEXT_LOOKUPS:
129129
return [self.get_db_prep_value(value)]
130130

131131
return super(_NetAddressField, self).get_db_prep_lookup(

0 commit comments

Comments
 (0)