# Path: kibitzr/conf.py
# def settings():
#     """
#     Returns singleton instance of settings
#     """
#     return ReloadableSettings.instance()
# 
# Path: kibitzr/fetcher/browser/launcher.py
# @contextmanager
# def firefox(headless=True):
#     """
#     Context manager returning Selenium webdriver.
#     Instance is reused and must be cleaned up on exit.
#     """
#     from selenium import webdriver
#     from selenium.webdriver.firefox.options import Options
#     if headless:
#         driver_key = 'headless'
#         firefox_options = Options()
#         firefox_options.add_argument('-headless')
#     else:
#         driver_key = 'headed'
#         firefox_options = None
#     # Load profile, if it exists:
#     if os.path.isdir(PROFILE_DIR):
#         firefox_profile = webdriver.FirefoxProfile(PROFILE_DIR)
#     else:
#         firefox_profile = None
#     if FIREFOX_INSTANCE[driver_key] is None:
#         FIREFOX_INSTANCE[driver_key] = webdriver.Firefox(
#             firefox_profile=firefox_profile,
#             firefox_options=firefox_options,
#         )
#     yield FIREFOX_INSTANCE[driver_key]
# 
# PROFILE_DIR = 'firefox_profile'
# 
# Path: kibitzr/fetcher/browser/trigger.py
# def prompt_return():
#     compat_input(
#         "Press Enter to save Firefox profile; "
#         "or close Firefox to cancel: "
#     )


import os
import time
import shutil
import logging
import traceback
import collections
from selenium.common.exceptions import (
    NoSuchElementException,
    StaleElementReferenceException,
)
from jinja2 import Template
from kibitzr.conf import settings
from .launcher import firefox, PROFILE_DIR
from .trigger import prompt_return




logger = logging.getLogger(__name__)
HOME_PAGE = 'https://kibitzr.github.io/'


def persistent_firefox():

# Path: kibitzr/conf.py
# def settings():
#     """
#     Returns singleton instance of settings
#     """
#     return ReloadableSettings.instance()
# 
# Path: kibitzr/fetcher/browser/launcher.py
# @contextmanager
# def firefox(headless=True):
#     """
#     Context manager returning Selenium webdriver.
#     Instance is reused and must be cleaned up on exit.
#     """
#     from selenium import webdriver
#     from selenium.webdriver.firefox.options import Options
#     if headless:
#         driver_key = 'headless'
#         firefox_options = Options()
#         firefox_options.add_argument('-headless')
#     else:
#         driver_key = 'headed'
#         firefox_options = None
#     # Load profile, if it exists:
#     if os.path.isdir(PROFILE_DIR):
#         firefox_profile = webdriver.FirefoxProfile(PROFILE_DIR)
#     else:
#         firefox_profile = None
#     if FIREFOX_INSTANCE[driver_key] is None:
#         FIREFOX_INSTANCE[driver_key] = webdriver.Firefox(
#             firefox_profile=firefox_profile,
#             firefox_options=firefox_options,
#         )
#     yield FIREFOX_INSTANCE[driver_key]
# 
# PROFILE_DIR = 'firefox_profile'
# 
# Path: kibitzr/fetcher/browser/trigger.py
# def prompt_return():
#     compat_input(
#         "Press Enter to save Firefox profile; "
#         "or close Firefox to cancel: "
#     )


# Path: kibitzr/fetcher/browser/fetcher.py
import os
import time
import shutil
import logging
import traceback
import collections
from selenium.common.exceptions import (
    NoSuchElementException,
    StaleElementReferenceException,
)
from jinja2 import Template
from kibitzr.conf import settings
from .launcher import firefox, PROFILE_DIR
from .trigger import prompt_return





logger = logging.getLogger(__name__)
HOME_PAGE = 'https://kibitzr.github.io/'


def persistent_firefox():

    if not os.path.exists(PROFILE_DIR):