# Path: lametro/utils.py
# def format_full_text(full_text):
#     '''
#     The search results and board report titles (on the BillDetail) should show the "SUBJECT:" header from the board report when present.
#     The ocr_full_text contains this information. Some example snippets:
# 
#     # Subject header followed by two linebreaks.
#     ..Subject\nSUBJECT:\tFOOD SERVICE OPERATOR\n\n..Action\nACTION:\tAWARD SERVICES CONTRACT\n\n..
# 
#     # Subject header followed by a return carriage and linebreak.
#     ..Subject/Action\r\nSUBJECT: MONTHLY REPORT ON CRENSHAW/LAX SAFETY\r\nACTION: RECEIVE AND FILE\r\n
# 
#     # Subject header with a linebreak in the middle and without an ACTION header.
#     ..Subject\nSUBJECT:    REVISED MOTION BY DIRECTORS HAHN, SOLIS, \nGARCIA, AND DUPONT-WALKER\n..Title\n
#     '''
#     results = ''
# 
#     if full_text:
#         clean_full_text = full_text.replace('\n\n', 'NEWLINE').replace('\r\n', 'NEWLINE').replace('\n..', 'NEWLINE').replace('\n', ' ')
#         match = re.search('(SUBJECT:)(.*?)(NEWLINE|ACTION:)', clean_full_text)
#         if match:
#             results = match.group(2)
# 
#     return results
# 
# def parse_subject(text):
#     if ('[PROJECT OR SERVICE NAME]' not in text) and ('[DESCRIPTION]' not in text) and ('[CONTRACT NUMBER]' not in text):
#         return text.strip()


from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.db import models, connection
from django.db.models.expressions import RawSQL
from django.core.exceptions import ObjectDoesNotExist
from django.utils import timezone
from django.utils.functional import cached_property
from django.contrib.auth.models import User
from django.db.models import Max, Min, Prefetch, Case, When, Value, Q, F
from django.db.models.functions import Now, Cast
from django.contrib.staticfiles.templatetags.staticfiles import static
from opencivicdata.legislative.models import EventMedia, EventDocument, \
    EventDocumentLink, EventAgendaItem, EventRelatedEntity, RelatedBill, \
    BillVersion
from proxy_overrides.related import ProxyForeignKey
from councilmatic_core.models import Bill, Event, Post, Person, Organization, \
    EventManager, Membership
from lametro.utils import format_full_text, parse_subject
from councilmatic.settings_jurisdiction import BILL_STATUS_DESCRIPTIONS
import logging
import pytz
import re
import requests
import django.contrib.postgres.fields as postgres_fields
import councilmatic_core.models





app_timezone = pytz.timezone(settings.TIME_ZONE)
logger = logging.getLogger(__name__)

class SourcesMixin(object):

    @property
    def web_source(self):

# Path: lametro/utils.py
# def format_full_text(full_text):
#     '''
#     The search results and board report titles (on the BillDetail) should show the "SUBJECT:" header from the board report when present.
#     The ocr_full_text contains this information. Some example snippets:
# 
#     # Subject header followed by two linebreaks.
#     ..Subject\nSUBJECT:\tFOOD SERVICE OPERATOR\n\n..Action\nACTION:\tAWARD SERVICES CONTRACT\n\n..
# 
#     # Subject header followed by a return carriage and linebreak.
#     ..Subject/Action\r\nSUBJECT: MONTHLY REPORT ON CRENSHAW/LAX SAFETY\r\nACTION: RECEIVE AND FILE\r\n
# 
#     # Subject header with a linebreak in the middle and without an ACTION header.
#     ..Subject\nSUBJECT:    REVISED MOTION BY DIRECTORS HAHN, SOLIS, \nGARCIA, AND DUPONT-WALKER\n..Title\n
#     '''
#     results = ''
# 
#     if full_text:
#         clean_full_text = full_text.replace('\n\n', 'NEWLINE').replace('\r\n', 'NEWLINE').replace('\n..', 'NEWLINE').replace('\n', ' ')
#         match = re.search('(SUBJECT:)(.*?)(NEWLINE|ACTION:)', clean_full_text)
#         if match:
#             results = match.group(2)
# 
#     return results
# 
# def parse_subject(text):
#     if ('[PROJECT OR SERVICE NAME]' not in text) and ('[DESCRIPTION]' not in text) and ('[CONTRACT NUMBER]' not in text):
#         return text.strip()


# Path: lametro/models.py
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.db import models, connection
from django.db.models.expressions import RawSQL
from django.core.exceptions import ObjectDoesNotExist
from django.utils import timezone
from django.utils.functional import cached_property
from django.contrib.auth.models import User
from django.db.models import Max, Min, Prefetch, Case, When, Value, Q, F
from django.db.models.functions import Now, Cast
from django.contrib.staticfiles.templatetags.staticfiles import static
from opencivicdata.legislative.models import EventMedia, EventDocument, \
    EventDocumentLink, EventAgendaItem, EventRelatedEntity, RelatedBill, \
    BillVersion
from proxy_overrides.related import ProxyForeignKey
from councilmatic_core.models import Bill, Event, Post, Person, Organization, \
    EventManager, Membership
from lametro.utils import format_full_text, parse_subject
from councilmatic.settings_jurisdiction import BILL_STATUS_DESCRIPTIONS
import logging
import pytz
import re
import requests
import django.contrib.postgres.fields as postgres_fields
import councilmatic_core.models






app_timezone = pytz.timezone(settings.TIME_ZONE)
logger = logging.getLogger(__name__)

class SourcesMixin(object):

    @property
    def web_source(self):

        return self.sources.get(note='web')