# Path: xpathwebdriver/base.py
# class XpathWdBase(object):
#     log = Logger('xpath root', color=solve_settings().get('log_color'))
# 
#     @property
#     def global_settings(self):
#         return solve_settings()
# 
# class singleton_decorator(object):
# 
#     '''
#       Singleton pattern decorator.
#       There will be only one instance of the decorated class.
#     '''
# 
#     def __init__(self, class_):
#         self.class_ = class_
#         self.instance = None
# 
#     def __call__(self, *a, **ad):
#         if self.instance is None:
#             self.instance = self.class_(*a, **ad)
#         return self.instance
# 
# Path: xpathwebdriver/levels.py
# TEST_ROUND_LIFE = -2
# 
# MANAGER_LIFE = -3


import rel_imp; rel_imp.init()
import os
import logging
import json
import shlex
    import time
from selenium import webdriver
from pyvirtualdisplay import Display
from threading import RLock
from functools import wraps
from selenium.common.exceptions import UnexpectedAlertPresentException, WebDriverException
from .base import XpathWdBase, singleton_decorator
from xpathwebdriver.levels import TEST_ROUND_LIFE, MANAGER_LIFE
from selenium.webdriver.remote.webdriver import WebDriver
from collections import namedtuple
                from selenium.webdriver.chrome.options import Options
        from .logger import Logger
        from .xpath_browser import XpathBrowser
    from .logger import log_test
        return wdrivers_report

    def get_browser_name(self, browser_name=None):
        '''
        Get the current browser name in usage
        If not set, we use the one specified in global settings
        or PhantomJS as the final default
        '''
        browser = (browser_name
                   or self.global_settings.get('webdriver_browser'))
        return self.expand_browser_name(browser)

    def expand_browser_name(self, browser=None):
        '''
        Expand a partial or lower case Browser's name into its full name.
        Eg:
            firefo -> Firefox
            chrom -> Chrome
        :param browser: partial browser's name string
        '''
        # TODO: add IE and Opera
        char_browser = dict(f='Firefox',
                            c='Chrome',
                            p='PhantomJS',
                            )
        char = browser.lower()[0]
        assert char in char_browser, 'Could not find browser %r' % browser
        return char_browser.get(char)

    def __del__(self):

# Path: xpathwebdriver/base.py
# class XpathWdBase(object):
#     log = Logger('xpath root', color=solve_settings().get('log_color'))
# 
#     @property
#     def global_settings(self):
#         return solve_settings()
# 
# class singleton_decorator(object):
# 
#     '''
#       Singleton pattern decorator.
#       There will be only one instance of the decorated class.
#     '''
# 
#     def __init__(self, class_):
#         self.class_ = class_
#         self.instance = None
# 
#     def __call__(self, *a, **ad):
#         if self.instance is None:
#             self.instance = self.class_(*a, **ad)
#         return self.instance
# 
# Path: xpathwebdriver/levels.py
# TEST_ROUND_LIFE = -2
# 
# MANAGER_LIFE = -3


# Path: xpathwebdriver/webdriver_manager.py
import rel_imp; rel_imp.init()
import os
import logging
import json
import shlex
    import time
from selenium import webdriver
from pyvirtualdisplay import Display
from threading import RLock
from functools import wraps
from selenium.common.exceptions import UnexpectedAlertPresentException, WebDriverException
from .base import XpathWdBase, singleton_decorator
from xpathwebdriver.levels import TEST_ROUND_LIFE, MANAGER_LIFE
from selenium.webdriver.remote.webdriver import WebDriver
from collections import namedtuple
                from selenium.webdriver.chrome.options import Options
        from .logger import Logger
        from .xpath_browser import XpathBrowser
    from .logger import log_test

        return wdrivers_report

    def get_browser_name(self, browser_name=None):
        '''
        Get the current browser name in usage
        If not set, we use the one specified in global settings
        or PhantomJS as the final default
        '''
        browser = (browser_name
                   or self.global_settings.get('webdriver_browser'))
        return self.expand_browser_name(browser)

    def expand_browser_name(self, browser=None):
        '''
        Expand a partial or lower case Browser's name into its full name.
        Eg:
            firefo -> Firefox
            chrom -> Chrome
        :param browser: partial browser's name string
        '''
        # TODO: add IE and Opera
        char_browser = dict(f='Firefox',
                            c='Chrome',
                            p='PhantomJS',
                            )
        char = browser.lower()[0]
        assert char in char_browser, 'Could not find browser %r' % browser
        return char_browser.get(char)

    def __del__(self):

        self.exit_level(MANAGER_LIFE)