Skip to content

Instantly share code, notes, and snippets.

@talfco
Created February 4, 2019 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talfco/6c777b998aaddbd9d18c6bbfff2343fd to your computer and use it in GitHub Desktop.
Save talfco/6c777b998aaddbd9d18c6bbfff2343fd to your computer and use it in GitHub Desktop.
def __check_for_party(self, user_list):
party_column = []
# iterate through each user account
for user in user_list:
# iterate trough all parties
for party in self.__cfg.get('parties'):
res = "unknown"
# Check first all abbreviations
# We don't do lower here because that could result to false positive
for abbr in party['abbrs']:
if abbr in user.description or abbr in user.screen_name:
res = party['abbrs'][0]
break
# Check now if the party twitter screen name is referenced
if res == "unknown":
if user.description is not None \
and party['twitter'] is not None\
and len(party['twitter']) > 0:
if party['twitter'].lower() in user.description.lower():
res = party['abbrs'][0]
break
# Check now if a kewyword is referenced
if res == "unknown":
if user.description is not None:
for keyword in party['keywords']:
if keyword.lower() in user.description.lower():
res = party['abbrs'][0]
break
# We are exiting here the party list iterations in
# case we found a result
if res != "unknown":
break
party_column.append(res)
return party_column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment