# Path: lametro/models.py
# class LAMetroSubject(models.Model):
# 
#     CLASSIFICATION_CHOICES = [
#         ('bill_type_exact', 'Board Report Type'),
#         ('lines_and_ways_exact', 'Lines / Ways'),
#         ('phase_exact', 'Phase'),
#         ('project_exact', 'Project'),
#         ('metro_location_exact', 'Metro Location'),
#         ('geo_admin_location_exact', 'Geographic / Administrative Location'),
#         ('significant_date_exact', 'Significant Date'),
#         ('motion_by_exact', 'Motion By'),
#         ('topics_exact', 'Subject'),
#         ('plan_program_policy_exact', 'Plan, Program, or Policy')
#     ]
# 
#     class Meta:
#         unique_together = ['guid', 'name']
# 
#     name = models.CharField(max_length=256, unique=True)
#     guid = models.CharField(max_length=256, blank=True, null=True)
#     classification = models.CharField(
#         max_length=256,
#         default='topics_exact',
#         choices=CLASSIFICATION_CHOICES
#     )
# 
#     def __str__(self):
#         if self.guid is not None:
#             return '{0} ({1})'.format(self.name, self.guid)
# 
#         else:
#             return self.name
# 
# Path: lametro/smartlogic.py
# class SmartLogic(object):
#     BASE_URL = 'https://cloud.smartlogic.com/'
#     SERVICE_URL = 'svc/0dcee7c7-1667-4164-81e5-c16e46f2f74c/ses/v1.2/CombinedModel/'
# 
#     def __init__(self, api_key):
#         self.api_key = api_key
#         self._token = self.token()['access_token']
# 
#     @property
#     def auth_headers(self):
#         return {
#             'Content-Type': 'application/x-www-form-urlencoded',
#             'Authorization': 'Bearer {}'.format(self._token)
#         }
# 
#     def endpoint(self, method, route, **kwargs):
#         url = self.BASE_URL + route
# 
#         try:
#             response = getattr(requests, method)(url, **kwargs)
#         except HTTPError as e:
#             raise
# 
#         try:
#             return response.json()
#         except json.JSONDecodeError:
#             return response
# 
#     def token(self):
#         data = {'grant_type': 'apikey', 'key': self.api_key}
#         return self.endpoint('post', 'token', data=data)
# 
#     def terms(self, params):
#         return self.endpoint(
#             'post',
#             self.SERVICE_URL + 'terms.json',
#             params=params,
#             headers=self.auth_headers
#         )


from collections import ChainMap
from itertools import chain
from django.core.management.base import BaseCommand
from django.conf import settings
from django.db.utils import IntegrityError
from legistar.bills import LegistarAPIBillScraper
from opencivicdata.legislative.models import Bill
from lametro.models import LAMetroSubject
from lametro.smartlogic import SmartLogic
            'Project Development',
            'Project Finance',
            'Capital Project',
            'Construction Project',
            'Grant Project',
            'Other Working Project',
        ),
        'metro_location_exact': (
            'All Transportation Locations',
            'Alignment',
            'Division',
            'Employee Parking Lot',
            'Pank ‘n’ Ride',
            'Radio Station',
            'Route',
            'Station',
            'Surplus, Temporary And Miscellaneous Property',
            'Terminal',
            'Transportation Location',
        ),
        'geo_admin_location_exact': (
            'All Location',
            'Administrative Division',
            'Electoral Districts',
            'Sector',
            'Corridor',
            'Geographic Location',
            'City',
            'Country',
            'County',

# Path: lametro/models.py
# class LAMetroSubject(models.Model):
# 
#     CLASSIFICATION_CHOICES = [
#         ('bill_type_exact', 'Board Report Type'),
#         ('lines_and_ways_exact', 'Lines / Ways'),
#         ('phase_exact', 'Phase'),
#         ('project_exact', 'Project'),
#         ('metro_location_exact', 'Metro Location'),
#         ('geo_admin_location_exact', 'Geographic / Administrative Location'),
#         ('significant_date_exact', 'Significant Date'),
#         ('motion_by_exact', 'Motion By'),
#         ('topics_exact', 'Subject'),
#         ('plan_program_policy_exact', 'Plan, Program, or Policy')
#     ]
# 
#     class Meta:
#         unique_together = ['guid', 'name']
# 
#     name = models.CharField(max_length=256, unique=True)
#     guid = models.CharField(max_length=256, blank=True, null=True)
#     classification = models.CharField(
#         max_length=256,
#         default='topics_exact',
#         choices=CLASSIFICATION_CHOICES
#     )
# 
#     def __str__(self):
#         if self.guid is not None:
#             return '{0} ({1})'.format(self.name, self.guid)
# 
#         else:
#             return self.name
# 
# Path: lametro/smartlogic.py
# class SmartLogic(object):
#     BASE_URL = 'https://cloud.smartlogic.com/'
#     SERVICE_URL = 'svc/0dcee7c7-1667-4164-81e5-c16e46f2f74c/ses/v1.2/CombinedModel/'
# 
#     def __init__(self, api_key):
#         self.api_key = api_key
#         self._token = self.token()['access_token']
# 
#     @property
#     def auth_headers(self):
#         return {
#             'Content-Type': 'application/x-www-form-urlencoded',
#             'Authorization': 'Bearer {}'.format(self._token)
#         }
# 
#     def endpoint(self, method, route, **kwargs):
#         url = self.BASE_URL + route
# 
#         try:
#             response = getattr(requests, method)(url, **kwargs)
#         except HTTPError as e:
#             raise
# 
#         try:
#             return response.json()
#         except json.JSONDecodeError:
#             return response
# 
#     def token(self):
#         data = {'grant_type': 'apikey', 'key': self.api_key}
#         return self.endpoint('post', 'token', data=data)
# 
#     def terms(self, params):
#         return self.endpoint(
#             'post',
#             self.SERVICE_URL + 'terms.json',
#             params=params,
#             headers=self.auth_headers
#         )


# Path: lametro/management/commands/refresh_guid.py
from collections import ChainMap
from itertools import chain
from django.core.management.base import BaseCommand
from django.conf import settings
from django.db.utils import IntegrityError
from legistar.bills import LegistarAPIBillScraper
from opencivicdata.legislative.models import Bill
from lametro.models import LAMetroSubject
from lametro.smartlogic import SmartLogic

            'Project Development',
            'Project Finance',
            'Capital Project',
            'Construction Project',
            'Grant Project',
            'Other Working Project',
        ),
        'metro_location_exact': (
            'All Transportation Locations',
            'Alignment',
            'Division',
            'Employee Parking Lot',
            'Pank ‘n’ Ride',
            'Radio Station',
            'Route',
            'Station',
            'Surplus, Temporary And Miscellaneous Property',
            'Terminal',
            'Transportation Location',
        ),
        'geo_admin_location_exact': (
            'All Location',
            'Administrative Division',
            'Electoral Districts',
            'Sector',
            'Corridor',
            'Geographic Location',
            'City',
            'Country',
            'County',

            'Neighborhood',