# Path: calfire_tracker/manager_calfire.py
# class RetrieveCalFireCurrentIncidents(object):
#     """
#     """
# 
#     req = Requester()
#     prep = Prepper()
#     norm = Normalizer()
#     svr = Saver()
#     source = WildfireSource.objects.filter(source_short="calfire", source_active=True)[0]
# 
#     def _init(self, *args, **kwargs):
#         """
#         """
#         self.source.raw_html = self.req._make_request_to(self.source.source_url)
#         self.source.soup = self.req._make_soup_from(self.source.raw_html)
#         if self.source.extraction_type == "Simple Scrape":
#             self.req._extract_simple_data_from(self.source)
#         else:
#             logger.debug("**need a new scraper**")
#         for table in self.source.target_content:
#             f = self.prep.give_fire()
#             f["name"] = table.findAll("tr")[0].findAll("td")[0].text.encode("utf-8")
#             f["name"] = f["name"].replace(":", "").replace("more info...", "").strip()
#             f["details_source"] = self.source.source_short
#             table_row = table.findAll("tr")[1:]
#             f = self.prep.tablerow_to_dicts(table_row, f)
#             f["details_link"] = self.prep.has_calfire_link(table.findAll("tr")[0].findAll("td")[0])
#             if f["details_link"]:
#                 logger.debug("gonna need to request the details url")
#                 raw_html = self.req._make_request_to(f["details_link"])
#                 soup = self.req._make_soup_from(raw_html)
#                 table = soup.findAll("table", {"id": "incident_information"})
#                 table_row = table[0].findAll("tr")[1:]
#                 f = self.prep.tablerow_to_dicts(table_row, f)
#             f["update_this_fire"] = self.prep.fire_exists_and_is_new(f)
#             # f = {k: v for k, v in f.iteritems() if v is not None}
#             output = self.norm.marshal_fire_data(f)
#             self.svr.save_dict_to_model(output)


from django.conf import settings
from django.core.management.base import BaseCommand
from calfire_tracker.manager_calfire import RetrieveCalFireCurrentIncidents
import datetime
import logging

logger = logging.getLogger("calfire_tracker")

class Command(BaseCommand):

    help = "Scrapes California Wildfires data from CalFire and some Inciweb Pages"


# Path: calfire_tracker/manager_calfire.py
# class RetrieveCalFireCurrentIncidents(object):
#     """
#     """
# 
#     req = Requester()
#     prep = Prepper()
#     norm = Normalizer()
#     svr = Saver()
#     source = WildfireSource.objects.filter(source_short="calfire", source_active=True)[0]
# 
#     def _init(self, *args, **kwargs):
#         """
#         """
#         self.source.raw_html = self.req._make_request_to(self.source.source_url)
#         self.source.soup = self.req._make_soup_from(self.source.raw_html)
#         if self.source.extraction_type == "Simple Scrape":
#             self.req._extract_simple_data_from(self.source)
#         else:
#             logger.debug("**need a new scraper**")
#         for table in self.source.target_content:
#             f = self.prep.give_fire()
#             f["name"] = table.findAll("tr")[0].findAll("td")[0].text.encode("utf-8")
#             f["name"] = f["name"].replace(":", "").replace("more info...", "").strip()
#             f["details_source"] = self.source.source_short
#             table_row = table.findAll("tr")[1:]
#             f = self.prep.tablerow_to_dicts(table_row, f)
#             f["details_link"] = self.prep.has_calfire_link(table.findAll("tr")[0].findAll("td")[0])
#             if f["details_link"]:
#                 logger.debug("gonna need to request the details url")
#                 raw_html = self.req._make_request_to(f["details_link"])
#                 soup = self.req._make_soup_from(raw_html)
#                 table = soup.findAll("table", {"id": "incident_information"})
#                 table_row = table[0].findAll("tr")[1:]
#                 f = self.prep.tablerow_to_dicts(table_row, f)
#             f["update_this_fire"] = self.prep.fire_exists_and_is_new(f)
#             # f = {k: v for k, v in f.iteritems() if v is not None}
#             output = self.norm.marshal_fire_data(f)
#             self.svr.save_dict_to_model(output)


# Path: calfire_tracker/management/commands/scraper_wildfires.py
from django.conf import settings
from django.core.management.base import BaseCommand
from calfire_tracker.manager_calfire import RetrieveCalFireCurrentIncidents
import datetime
import logging


logger = logging.getLogger("calfire_tracker")

class Command(BaseCommand):

    help = "Scrapes California Wildfires data from CalFire and some Inciweb Pages"


    def calfire_current_incidents(self, *args, **options):