Skip to content

Commit

Permalink
Fix naming conventions (#1872)
Browse files Browse the repository at this point in the history
* fix naming convention

* fix worng changes
  • Loading branch information
dvora-h committed Feb 2, 2022
1 parent 7f7f4f6 commit 7ea1bf7
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 230 deletions.
22 changes: 11 additions & 11 deletions redis/commands/bf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,70 @@ class AbstractBloom(object):
"""

@staticmethod
def appendItems(params, items):
def append_items(params, items):
"""Append ITEMS to params."""
params.extend(["ITEMS"])
params += items

@staticmethod
def appendError(params, error):
def append_error(params, error):
"""Append ERROR to params."""
if error is not None:
params.extend(["ERROR", error])

@staticmethod
def appendCapacity(params, capacity):
def append_capacity(params, capacity):
"""Append CAPACITY to params."""
if capacity is not None:
params.extend(["CAPACITY", capacity])

@staticmethod
def appendExpansion(params, expansion):
def append_expansion(params, expansion):
"""Append EXPANSION to params."""
if expansion is not None:
params.extend(["EXPANSION", expansion])

@staticmethod
def appendNoScale(params, noScale):
def append_no_scale(params, noScale):
"""Append NONSCALING tag to params."""
if noScale is not None:
params.extend(["NONSCALING"])

@staticmethod
def appendWeights(params, weights):
def append_weights(params, weights):
"""Append WEIGHTS to params."""
if len(weights) > 0:
params.append("WEIGHTS")
params += weights

@staticmethod
def appendNoCreate(params, noCreate):
def append_no_create(params, noCreate):
"""Append NOCREATE tag to params."""
if noCreate is not None:
params.extend(["NOCREATE"])

@staticmethod
def appendItemsAndIncrements(params, items, increments):
def append_items_and_increments(params, items, increments):
"""Append pairs of items and increments to params."""
for i in range(len(items)):
params.append(items[i])
params.append(increments[i])

@staticmethod
def appendValuesAndWeights(params, items, weights):
def append_values_and_weights(params, items, weights):
"""Append pairs of items and weights to params."""
for i in range(len(items)):
params.append(items[i])
params.append(weights[i])

@staticmethod
def appendMaxIterations(params, max_iterations):
def append_max_iterations(params, max_iterations):
"""Append MAXITERATIONS to params."""
if max_iterations is not None:
params.extend(["MAXITERATIONS", max_iterations])

@staticmethod
def appendBucketSize(params, bucket_size):
def append_bucket_size(params, bucket_size):
"""Append BUCKETSIZE to params."""
if bucket_size is not None:
params.extend(["BUCKETSIZE", bucket_size])
Expand Down
42 changes: 21 additions & 21 deletions redis/commands/bf/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def create(self, key, errorRate, capacity, expansion=None, noScale=None):
For more information see `BF.RESERVE <https://oss.redis.com/redisbloom/master/Bloom_Commands/#bfreserve>`_.
""" # noqa
params = [key, errorRate, capacity]
self.appendExpansion(params, expansion)
self.appendNoScale(params, noScale)
self.append_expansion(params, expansion)
self.append_no_scale(params, noScale)
return self.execute_command(BF_RESERVE, *params)

def add(self, key, item):
Expand Down Expand Up @@ -102,12 +102,12 @@ def insert(
For more information see `BF.INSERT <https://oss.redis.com/redisbloom/master/Bloom_Commands/#bfinsert>`_.
""" # noqa
params = [key]
self.appendCapacity(params, capacity)
self.appendError(params, error)
self.appendExpansion(params, expansion)
self.appendNoCreate(params, noCreate)
self.appendNoScale(params, noScale)
self.appendItems(params, items)
self.append_capacity(params, capacity)
self.append_error(params, error)
self.append_expansion(params, expansion)
self.append_no_create(params, noCreate)
self.append_no_scale(params, noScale)
self.append_items(params, items)

return self.execute_command(BF_INSERT, *params)

Expand Down Expand Up @@ -177,9 +177,9 @@ def create(
For more information see `CF.RESERVE <https://oss.redis.com/redisbloom/master/Cuckoo_Commands/#cfreserve>`_.
""" # noqa
params = [key, capacity]
self.appendExpansion(params, expansion)
self.appendBucketSize(params, bucket_size)
self.appendMaxIterations(params, max_iterations)
self.append_expansion(params, expansion)
self.append_bucket_size(params, bucket_size)
self.append_max_iterations(params, max_iterations)
return self.execute_command(CF_RESERVE, *params)

def add(self, key, item):
Expand Down Expand Up @@ -207,9 +207,9 @@ def insert(self, key, items, capacity=None, nocreate=None):
For more information see `CF.INSERT <https://oss.redis.com/redisbloom/master/Cuckoo_Commands/#cfinsert>`_.
""" # noqa
params = [key]
self.appendCapacity(params, capacity)
self.appendNoCreate(params, nocreate)
self.appendItems(params, items)
self.append_capacity(params, capacity)
self.append_no_create(params, nocreate)
self.append_items(params, items)
return self.execute_command(CF_INSERT, *params)

def insertnx(self, key, items, capacity=None, nocreate=None):
Expand All @@ -220,9 +220,9 @@ def insertnx(self, key, items, capacity=None, nocreate=None):
For more information see `CF.INSERTNX <https://oss.redis.com/redisbloom/master/Cuckoo_Commands/#cfinsertnx>`_.
""" # noqa
params = [key]
self.appendCapacity(params, capacity)
self.appendNoCreate(params, nocreate)
self.appendItems(params, items)
self.append_capacity(params, capacity)
self.append_no_create(params, nocreate)
self.append_items(params, items)
return self.execute_command(CF_INSERTNX, *params)

def exists(self, key, item):
Expand Down Expand Up @@ -315,7 +315,7 @@ def incrby(self, key, items, increments):
>>> topkincrby('A', ['foo'], [1])
""" # noqa
params = [key]
self.appendItemsAndIncrements(params, items, increments)
self.append_items_and_increments(params, items, increments)
return self.execute_command(TOPK_INCRBY, *params)

def query(self, key, *items):
Expand Down Expand Up @@ -383,7 +383,7 @@ def add(self, key, values, weights):
>>> tdigestadd('A', [1500.0], [1.0])
""" # noqa
params = [key]
self.appendValuesAndWeights(params, values, weights)
self.append_values_and_weights(params, values, weights)
return self.execute_command(TDIGEST_ADD, *params)

def merge(self, toKey, fromKey):
Expand Down Expand Up @@ -465,7 +465,7 @@ def incrby(self, key, items, increments):
>>> cmsincrby('A', ['foo'], [1])
""" # noqa
params = [key]
self.appendItemsAndIncrements(params, items, increments)
self.append_items_and_increments(params, items, increments)
return self.execute_command(CMS_INCRBY, *params)

def query(self, key, *items):
Expand All @@ -487,7 +487,7 @@ def merge(self, destKey, numKeys, srcKeys, weights=[]):
""" # noqa
params = [destKey, numKeys]
params += srcKeys
self.appendWeights(params, weights)
self.append_weights(params, weights)
return self.execute_command(CMS_MERGE, *params)

def info(self, key):
Expand Down
20 changes: 10 additions & 10 deletions redis/commands/graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, client, name=random_string()):
self.edges = []
self._labels = [] # List of node labels.
self._properties = [] # List of properties.
self._relationshipTypes = [] # List of relation types.
self._relationship_types = [] # List of relation types.
self.version = 0 # Graph version

@property
Expand All @@ -32,7 +32,7 @@ def name(self):
def _clear_schema(self):
self._labels = []
self._properties = []
self._relationshipTypes = []
self._relationship_types = []

def _refresh_schema(self):
self._clear_schema()
Expand All @@ -49,15 +49,15 @@ def _refresh_labels(self):
self._labels[i] = l[0]

def _refresh_relations(self):
rels = self.relationshipTypes()
rels = self.relationship_types()

# Unpack data.
self._relationshipTypes = [None] * len(rels)
self._relationship_types = [None] * len(rels)
for i, r in enumerate(rels):
self._relationshipTypes[i] = r[0]
self._relationship_types[i] = r[0]

def _refresh_attributes(self):
props = self.propertyKeys()
props = self.property_keys()

# Unpack data.
self._properties = [None] * len(props)
Expand Down Expand Up @@ -91,11 +91,11 @@ def get_relation(self, idx):
The index of the relation
"""
try:
relationship_type = self._relationshipTypes[idx]
relationship_type = self._relationship_types[idx]
except IndexError:
# Refresh relationship types.
self._refresh_relations()
relationship_type = self._relationshipTypes[idx]
relationship_type = self._relationship_types[idx]
return relationship_type

def get_property(self, idx):
Expand Down Expand Up @@ -155,8 +155,8 @@ def call_procedure(self, procedure, *args, read_only=False, **kwagrs):
def labels(self):
return self.call_procedure("db.labels", read_only=True).result_set

def relationshipTypes(self):
def relationship_types(self):
return self.call_procedure("db.relationshipTypes", read_only=True).result_set

def propertyKeys(self):
def property_keys(self):
return self.call_procedure("db.propertyKeys", read_only=True).result_set
2 changes: 1 addition & 1 deletion redis/commands/graph/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, src_node, relation, dest_node, edge_id=None, properties=None)
self.src_node = src_node
self.dest_node = dest_node

def toString(self):
def to_string(self):
res = ""
if self.properties:
props = ",".join(
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, node_id=None, alias=None, label=None, properties=None):

self.properties = properties or {}

def toString(self):
def to_string(self):
res = ""
if self.properties:
props = ",".join(
Expand Down
4 changes: 2 additions & 2 deletions redis/commands/graph/query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def parse_profile(self, response):
# record = []
# for idx, cell in enumerate(row):
# if type(cell) is Node:
# record.append(cell.toString())
# record.append(cell.to_string())
# elif type(cell) is Edge:
# record.append(cell.toString())
# record.append(cell.to_string())
# else:
# record.append(cell)
# tbl.add_row(record)
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def quote_string(v):
return f'"{v}"'


def decodeDictKeys(obj):
def decode_dict_keys(obj):
"""Decode the keys of the given dictionary with utf-8."""
newobj = copy.copy(obj)
for k in obj.keys():
Expand Down

0 comments on commit 7ea1bf7

Please sign in to comment.