# Path: kibitzr/conf.py
# def settings():
#     """
#     Returns singleton instance of settings
#     """
#     return ReloadableSettings.instance()
# 
# Path: kibitzr/bash.py
# def execute_bash(code, stdin=None):
#     if os.name == 'nt':
#         executor = WindowsExecutor
#     else:
#         executor = BashExecutor
#     return executor(code).execute(stdin)
# 
# Path: kibitzr/stash.py
# class LazyStash(Stash):
#     def __init__(self):
#         self._stashobj = None
# 
#     @property
#     def _stash(self):
#         if self._stashobj is None:
#             self._stashobj = self.read()
#         return self._stashobj
# 
#     def __getitem__(self, key):
#         return self._stash[key]
# 
#     def get(self, key, default=None):
#         try:
#             return self._stash[key]
#         except KeyError:
#             return default


import logging
import traceback
from ..conf import settings
from ..bash import execute_bash
from ..stash import LazyStash



logger = logging.getLogger(__name__)
PYTHON_ERROR = "script.python must set global variables ok and content"


def fetch_by_script(conf):
    code = conf['script']
    try:
        python_code = code['python']
    except (KeyError, TypeError):
        # Not a python script
        pass
    else:
        return fetch_by_python(python_code, conf)
    try:
        # Explicit notation:
        bash_script = code['bash']
    except (KeyError, TypeError):
        bash_script = code
    # Pass something to stdin to disable sanity check:

# Path: kibitzr/conf.py
# def settings():
#     """
#     Returns singleton instance of settings
#     """
#     return ReloadableSettings.instance()
# 
# Path: kibitzr/bash.py
# def execute_bash(code, stdin=None):
#     if os.name == 'nt':
#         executor = WindowsExecutor
#     else:
#         executor = BashExecutor
#     return executor(code).execute(stdin)
# 
# Path: kibitzr/stash.py
# class LazyStash(Stash):
#     def __init__(self):
#         self._stashobj = None
# 
#     @property
#     def _stash(self):
#         if self._stashobj is None:
#             self._stashobj = self.read()
#         return self._stashobj
# 
#     def __getitem__(self, key):
#         return self._stash[key]
# 
#     def get(self, key, default=None):
#         try:
#             return self._stash[key]
#         except KeyError:
#             return default


# Path: kibitzr/fetcher/script.py
import logging
import traceback
from ..conf import settings
from ..bash import execute_bash
from ..stash import LazyStash




logger = logging.getLogger(__name__)
PYTHON_ERROR = "script.python must set global variables ok and content"


def fetch_by_script(conf):
    code = conf['script']
    try:
        python_code = code['python']
    except (KeyError, TypeError):
        # Not a python script
        pass
    else:
        return fetch_by_python(python_code, conf)
    try:
        # Explicit notation:
        bash_script = code['bash']
    except (KeyError, TypeError):
        bash_script = code
    # Pass something to stdin to disable sanity check:

    return execute_bash(