Treat `None` community name/index as an empty string

none-community-index
Ilya Etingof 2018-08-28 09:36:59 +02:00
parent ac0b956d00
commit 3c16a9a8a1
2 changed files with 6 additions and 0 deletions

View File

@ -32,6 +32,9 @@ class CommunityData(object):
def __init__(self, communityName, mpModel=1):
self.mpModel = mpModel
# Treat `None` as an empty string
if communityName is None:
communityName = ''
self.communityName = communityName
def __hash__(self):

View File

@ -107,6 +107,9 @@ class CommunityData(object):
self.contextName = contextName
if tag is not None:
self.tag = tag
# Treat `None` as an empty string
if communityIndex is None:
communityIndex = ''
# a single arg is considered as a community name
if communityName is None:
communityName, communityIndex = communityIndex, None