# 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
'''
Copyright (c) 2014 Juju. Inc

Code Licensed under MIT License. See LICENSE file.
'''


logger = logging.getLogger(__name__)


def synchronized(lock):
    '''
    Thread synchronization decorator. (for several methods with same lock, use
    re-entrant lock)
    :param lock: lock object (from threading package for example)
    '''
    def wrap_method(method):
        @wraps(method)
        def newFunction(*args, **kw):
            with lock:
                return method(*args, **kw)
        return newFunction
    return wrap_method


WdriverCfg = namedtuple('WdriverCfg', 'browser context shared level')



# 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

'''
Copyright (c) 2014 Juju. Inc

Code Licensed under MIT License. See LICENSE file.
'''


logger = logging.getLogger(__name__)


def synchronized(lock):
    '''
    Thread synchronization decorator. (for several methods with same lock, use
    re-entrant lock)
    :param lock: lock object (from threading package for example)
    '''
    def wrap_method(method):
        @wraps(method)
        def newFunction(*args, **kw):
            with lock:
                return method(*args, **kw)
        return newFunction
    return wrap_method


WdriverCfg = namedtuple('WdriverCfg', 'browser context shared level')



@singleton_decorator