From dda86f900a5a0571e8c14551971bb21a63f865ec Mon Sep 17 00:00:00 2001
From: Marco Ciotola <848222@stud.unive.it>
Date: Tue, 19 Feb 2019 22:31:15 +0100
Subject: [PATCH] Explicit some more imports removing almost all conflicting
 'import *'

---
 helios/forms.py                               |  4 +-
 .../commands/helios_trustee_decrypt.py        |  6 +-
 .../management/commands/load_voter_files.py   | 74 ++++++++++---------
 .../management/commands/verify_cast_votes.py  |  6 +-
 helios/security.py                            |  6 +-
 helios/stats_views.py                         | 19 ++---
 helios_auth/auth_systems/cas.py               | 11 ++-
 helios_auth/auth_systems/clever.py            | 11 +--
 helios_auth/auth_systems/google.py            | 10 +--
 helios_auth/auth_systems/yahoo.py             |  6 +-
 10 files changed, 73 insertions(+), 80 deletions(-)

diff --git a/helios/forms.py b/helios/forms.py
index cb10cfa..86fc18e 100644
--- a/helios/forms.py
+++ b/helios/forms.py
@@ -4,8 +4,8 @@ Forms for Helios
 
 from django import forms
 from models import Election
-from widgets import *
-from fields import *
+from widgets import SplitSelectDateTimeWidget
+from fields import SplitDateTimeField
 from django.conf import settings
 
 
diff --git a/helios/management/commands/helios_trustee_decrypt.py b/helios/management/commands/helios_trustee_decrypt.py
index 3dc75a4..4788330 100644
--- a/helios/management/commands/helios_trustee_decrypt.py
+++ b/helios/management/commands/helios_trustee_decrypt.py
@@ -8,12 +8,10 @@ ben@adida.net
 2010-05-22
 """
 
-from django.core.management.base import BaseCommand, CommandError
-import csv, datetime
+from django.core.management.base import BaseCommand
 
-from helios import utils as helios_utils
+from helios.models import Trustee
 
-from helios.models import *
 
 class Command(BaseCommand):
     args = ''
diff --git a/helios/management/commands/load_voter_files.py b/helios/management/commands/load_voter_files.py
index 5b82285..c34e682 100644
--- a/helios/management/commands/load_voter_files.py
+++ b/helios/management/commands/load_voter_files.py
@@ -8,12 +8,15 @@ ben@adida.net
 2010-05-22
 """
 
-from django.core.management.base import BaseCommand, CommandError
-import csv, datetime
+import datetime
+
+import csv
+import uuid
+from django.core.management.base import BaseCommand
 
 from helios import utils as helios_utils
+from helios.models import User, Voter, VoterFile
 
-from helios.models import *
 
 ##
 ## UTF8 craziness for CSV
@@ -27,42 +30,45 @@ def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
         # decode UTF-8 back to Unicode, cell by cell:
         yield [unicode(cell, 'utf-8') for cell in row]
 
+
 def utf_8_encoder(unicode_csv_data):
     for line in unicode_csv_data:
         yield line.encode('utf-8')
-  
+
+
 def process_csv_file(election, f):
     reader = unicode_csv_reader(f)
-    
+
     num_voters = 0
     for voter in reader:
-      # bad line
-      if len(voter) < 1:
-        continue
-    
-      num_voters += 1
-      voter_id = voter[0]
-      name = voter_id
-      email = voter_id
-    
-      if len(voter) > 1:
-        email = voter[1]
-    
-      if len(voter) > 2:
-        name = voter[2]
-    
-      # create the user
-      user = User.update_or_create(user_type='password', user_id=voter_id, info = {'password': helios_utils.random_string(10), 'email': email, 'name': name})
-      user.save()
-    
-      # does voter for this user already exist
-      voter = Voter.get_by_election_and_user(election, user)
-    
-      # create the voter
-      if not voter:
-        voter_uuid = str(uuid.uuid1())
-        voter = Voter(uuid= voter_uuid, voter_type = 'password', voter_id = voter_id, name = name, election = election)
-        voter.save()
+        # bad line
+        if len(voter) < 1:
+            continue
+
+        num_voters += 1
+        voter_id = voter[0]
+        name = voter_id
+        email = voter_id
+
+        if len(voter) > 1:
+            email = voter[1]
+
+        if len(voter) > 2:
+            name = voter[2]
+
+        # create the user
+        user = User.update_or_create(user_type='password', user_id=voter_id,
+                                     info={'password': helios_utils.random_string(10), 'email': email, 'name': name})
+        user.save()
+
+        # does voter for this user already exist
+        voter = Voter.get_by_election_and_user(election, user)
+
+        # create the voter
+        if not voter:
+            voter_uuid = str(uuid.uuid1())
+            voter = Voter(uuid=voter_uuid, voter_type='password', voter_id=voter_id, name=name, election=election)
+            voter.save()
 
     return num_voters
 
@@ -70,7 +76,7 @@ def process_csv_file(election, f):
 class Command(BaseCommand):
     args = ''
     help = 'load up voters from unprocessed voter files'
-    
+
     def handle(self, *args, **options):
         # load up the voter files in order of last uploaded
         files_to_process = VoterFile.objects.filter(processing_started_at=None).order_by('uploaded_at')
@@ -86,5 +92,3 @@ class Command(BaseCommand):
             file_to_process.processing_finished_at = datetime.datetime.utcnow()
             file_to_process.num_voters = num_voters
             file_to_process.save()
-            
-            
diff --git a/helios/management/commands/verify_cast_votes.py b/helios/management/commands/verify_cast_votes.py
index 5b7f392..e2fab71 100644
--- a/helios/management/commands/verify_cast_votes.py
+++ b/helios/management/commands/verify_cast_votes.py
@@ -6,12 +6,10 @@ ben@adida.net
 2010-05-22
 """
 
-from django.core.management.base import BaseCommand, CommandError
-import csv, datetime
+from django.core.management.base import BaseCommand
 
-from helios import utils as helios_utils
+from helios.models import CastVote
 
-from helios.models import *
 
 def get_cast_vote_to_verify():
     # fixme: add "select for update" functionality here
diff --git a/helios/security.py b/helios/security.py
index c022821..0e1861d 100644
--- a/helios/security.py
+++ b/helios/security.py
@@ -8,11 +8,11 @@ Ben Adida (ben@adida.net)
 from functools import update_wrapper
 
 from django.core.urlresolvers import reverse
-from django.core.exceptions import *
-from django.http import *
+from django.core.exceptions import PermissionDenied
+from django.http import Http404
 from django.conf import settings
 
-from models import *
+from models import Voter, Trustee, Election
 from helios_auth.security import get_user
 
 from django.http import HttpResponseRedirect
diff --git a/helios/stats_views.py b/helios/stats_views.py
index 74c12f9..9c01a7f 100644
--- a/helios/stats_views.py
+++ b/helios/stats_views.py
@@ -2,18 +2,19 @@
 Helios stats views
 """
 
-from django.core.urlresolvers import reverse
-from django.core.mail import send_mail
-from django.core.paginator import Paginator
-from django.http import *
-from django.db import transaction
-from django.db.models import *
+import datetime
 
-from security import *
-from helios_auth.security import get_user, save_in_session_across_logouts
-from view_utils import *
+from django.core.paginator import Paginator
+from django.core.urlresolvers import reverse
+from django.db.models import Max, Count
+from django.http import HttpResponseRedirect
 
 from helios import tasks
+from helios.models import CastVote, Election
+from helios_auth.security import get_user
+from security import PermissionDenied
+from view_utils import render_template
+
 
 def require_admin(request):
   user = get_user(request)
diff --git a/helios_auth/auth_systems/cas.py b/helios_auth/auth_systems/cas.py
index 8202ad2..6d0055f 100644
--- a/helios_auth/auth_systems/cas.py
+++ b/helios_auth/auth_systems/cas.py
@@ -5,11 +5,14 @@ Some code borrowed from
 https://sp.princeton.edu/oit/sdp/CAS/Wiki%20Pages/Python.aspx
 """
 
-from django.http import *
-from django.core.mail import send_mail
+import datetime
+import re
+import urllib
+import urllib2
+import uuid
 from django.conf import settings
-
-import sys, os, cgi, urllib, urllib2, re, uuid, datetime
+from django.core.mail import send_mail
+from django.http import HttpResponseRedirect
 from xml.etree import ElementTree
 
 CAS_EMAIL_DOMAIN = "princeton.edu"
diff --git a/helios_auth/auth_systems/clever.py b/helios_auth/auth_systems/clever.py
index dcd52d0..498951f 100644
--- a/helios_auth/auth_systems/clever.py
+++ b/helios_auth/auth_systems/clever.py
@@ -3,14 +3,11 @@ Clever Authentication
 
 """
 
-from django.http import *
-from django.core.mail import send_mail
+import base64
+import httplib2
+import json
+import urllib
 from django.conf import settings
-
-import httplib2,json,base64
-
-import sys, os, cgi, urllib, urllib2, re
-
 from oauth2client.client import OAuth2WebServerFlow, OAuth2Credentials
 
 # some parameters to indicate that status updating is not possible
diff --git a/helios_auth/auth_systems/google.py b/helios_auth/auth_systems/google.py
index 7caa32f..0341991 100644
--- a/helios_auth/auth_systems/google.py
+++ b/helios_auth/auth_systems/google.py
@@ -3,14 +3,10 @@ Google Authentication
 
 """
 
-from django.http import *
-from django.core.mail import send_mail
+import httplib2
+import json
 from django.conf import settings
-
-import httplib2,json
-
-import sys, os, cgi, urllib, urllib2, re
-
+from django.core.mail import send_mail
 from oauth2client.client import OAuth2WebServerFlow
 
 # some parameters to indicate that status updating is not possible
diff --git a/helios_auth/auth_systems/yahoo.py b/helios_auth/auth_systems/yahoo.py
index 16bc034..5131a19 100644
--- a/helios_auth/auth_systems/yahoo.py
+++ b/helios_auth/auth_systems/yahoo.py
@@ -3,12 +3,8 @@ Yahoo Authentication
 
 """
 
-from django.http import *
-from django.core.mail import send_mail
 from django.conf import settings
-
-import sys, os, cgi, urllib, urllib2, re
-from xml.etree import ElementTree
+from django.core.mail import send_mail
 
 from openid import view_helpers
 
-- 
GitLab