# Path: ice/logs.py
# STREAM_STRING_FORMAT = '%(leveltag)s%(message)s'
# FILE_STRING_FORMAT = '%(asctime)s [%(levelname)s][%(filename)s][%(funcName)s:%(lineno)s]: %(message)s'
# def is_test_stack_frame(frame):
# def is_running_in_test():
#   def _tag_for_level(self, levelno):
#   def filter(self, record):
# def create_stream_handler(level):
# def create_file_handler(level):
# def create_logger():
# class IceLevelTagFilter(logging.Formatter):
# 
# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])


import os
from ice.logs import logger
from ice.model import Emulator



class EmulatorBackedObjectAdapter(object):

  def __init__(self, filesystem):
    self.filesystem = filesystem

  def new(self, backing_store, identifier):
    name     = identifier
    location = backing_store.get(identifier, 'location')
    fmt      = backing_store.get(identifier, 'command', "%l %r")

    location = os.path.expanduser(location)

    return Emulator(
      name,
      location,
      fmt,
    )

  def verify(self, emulator):
    if emulator.location is None or emulator.location == "":
      logger.error("Missing location for Emulator: `%s`" % emulator.name)
      return False

    if not self.filesystem.is_file(emulator.location):

# Path: ice/logs.py
# STREAM_STRING_FORMAT = '%(leveltag)s%(message)s'
# FILE_STRING_FORMAT = '%(asctime)s [%(levelname)s][%(filename)s][%(funcName)s:%(lineno)s]: %(message)s'
# def is_test_stack_frame(frame):
# def is_running_in_test():
#   def _tag_for_level(self, levelno):
#   def filter(self, record):
# def create_stream_handler(level):
# def create_file_handler(level):
# def create_logger():
# class IceLevelTagFilter(logging.Formatter):
# 
# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])


# Path: ice/persistence/adapters/emulator_adapter.py
import os
from ice.logs import logger
from ice.model import Emulator




class EmulatorBackedObjectAdapter(object):

  def __init__(self, filesystem):
    self.filesystem = filesystem

  def new(self, backing_store, identifier):
    name     = identifier
    location = backing_store.get(identifier, 'location')
    fmt      = backing_store.get(identifier, 'command', "%l %r")

    location = os.path.expanduser(location)

    return Emulator(
      name,
      location,
      fmt,
    )

  def verify(self, emulator):
    if emulator.location is None or emulator.location == "":
      logger.error("Missing location for Emulator: `%s`" % emulator.name)
      return False

    if not self.filesystem.is_file(emulator.location):

      logger.error("Could not find a file at `%s`, which is set as the " \