# Path: wtframework/wtf/_devtools_/page_object_tools.py
# def _process_input_tag(html):
# def _strip_non_chars_from_name(name):
# def generate_page_object(page_name, url):
# 
# Path: wtframework/wtf/_devtools_/test_generation_tools.py
# def generate_empty_test(test_name):
# 
# Path: wtframework/wtf/utils/project_utils.py
# class ProjectUtils(object):
# 
#     """
#     Utility methods for working with the project.
# 
#     """
# 
#     WTF_HOME_CONFIG_ENV_VAR = "WTF_HOME"
# 
#     __WTF_ROOT_FOLDER_FILE = ".wtf_root_folder"
# 
#     __root_folder__ = None
# 
#     @classmethod
#     def get_project_root(cls):
#         '''
#         Return path of the project directory.  Use this method for getting paths relative to the project.
#         However, for data, it's recommended you use WTF_DATA_MANAGER and for assets it's recommended 
#         to use WTF_ASSET_MANAGER, which are already singleton instances that manger the /data, and /assets 
#         folder for you.
# 
#         Returns:
#             str - path of project root directory.
#         '''
#         if(cls.__root_folder__ != None):
#             return cls.__root_folder__
# 
#         # Check for enviornment variable override.
#         try:
#             cls.__root_folder__ = os.environ[cls.WTF_HOME_CONFIG_ENV_VAR]
#         except KeyError:
#             # Means WTF_HOME override isn't specified.
#             pass
# 
#         # Search starting from the current working directory and traverse up parent directories for the
#         # hidden file denoting the project root folder.
#         path = os.getcwd()
#         seperator_matches = re.finditer("/|\\\\", path)
# 
#         paths_to_search = [path]
#         for match in seperator_matches:
#             p = path[:match.start()]
#             paths_to_search.insert(0, p)
# 
#         for path in paths_to_search:
#             target_path = os.path.join(path, cls.__WTF_ROOT_FOLDER_FILE)
#             if os.path.isfile(target_path):
#                 cls.__root_folder__ = path
#                 return cls.__root_folder__
# 
#         raise RuntimeError(u("Missing root project folder locator file '.wtf_root_folder'.")
#                            + u("Check to make sure this file is located in your project directory."))


from optparse import OptionParser
from wtframework.wtf._devtools_ import page_object_tools, test_generation_tools
from wtframework.wtf.utils.project_utils import ProjectUtils
import os
import wtframework
    parser = OptionParser(usage=usage)
    parser.add_option("--version", action="store_true",
                      default=False, dest="version_flag",
                      help="Version info.")

    (options, args) = parser.parse_args()

    if(options.version_flag):
        print(wtframework.__VERSION__)
        exit()

    if len(args) < 2:
        print("Invalid command.", usage)
        exit(1)
        
    if args[0] == "generate-page":
        if len(args) < 3:
            raise RuntimeError("usage: wtf_tools.py generate-page PageName http://page.url.com/somepage")

        pagename = args[1]
        url = args[2]
        print("Generating page object for url:", url)
        file_content = page_object_tools.generate_page_object(pagename, url)
        path = os.path.join(ProjectUtils.get_project_root(), "tests", "pages", pagename.lower() + ".py")
        create_file(path, file_content)

    elif args[0] == "generate-test":
        test_name = args[1]
        print("Generating generic test.")
        file_content = test_generation_tools.generate_empty_test(test_name)

# Path: wtframework/wtf/_devtools_/page_object_tools.py
# def _process_input_tag(html):
# def _strip_non_chars_from_name(name):
# def generate_page_object(page_name, url):
# 
# Path: wtframework/wtf/_devtools_/test_generation_tools.py
# def generate_empty_test(test_name):
# 
# Path: wtframework/wtf/utils/project_utils.py
# class ProjectUtils(object):
# 
#     """
#     Utility methods for working with the project.
# 
#     """
# 
#     WTF_HOME_CONFIG_ENV_VAR = "WTF_HOME"
# 
#     __WTF_ROOT_FOLDER_FILE = ".wtf_root_folder"
# 
#     __root_folder__ = None
# 
#     @classmethod
#     def get_project_root(cls):
#         '''
#         Return path of the project directory.  Use this method for getting paths relative to the project.
#         However, for data, it's recommended you use WTF_DATA_MANAGER and for assets it's recommended 
#         to use WTF_ASSET_MANAGER, which are already singleton instances that manger the /data, and /assets 
#         folder for you.
# 
#         Returns:
#             str - path of project root directory.
#         '''
#         if(cls.__root_folder__ != None):
#             return cls.__root_folder__
# 
#         # Check for enviornment variable override.
#         try:
#             cls.__root_folder__ = os.environ[cls.WTF_HOME_CONFIG_ENV_VAR]
#         except KeyError:
#             # Means WTF_HOME override isn't specified.
#             pass
# 
#         # Search starting from the current working directory and traverse up parent directories for the
#         # hidden file denoting the project root folder.
#         path = os.getcwd()
#         seperator_matches = re.finditer("/|\\\\", path)
# 
#         paths_to_search = [path]
#         for match in seperator_matches:
#             p = path[:match.start()]
#             paths_to_search.insert(0, p)
# 
#         for path in paths_to_search:
#             target_path = os.path.join(path, cls.__WTF_ROOT_FOLDER_FILE)
#             if os.path.isfile(target_path):
#                 cls.__root_folder__ = path
#                 return cls.__root_folder__
# 
#         raise RuntimeError(u("Missing root project folder locator file '.wtf_root_folder'.")
#                            + u("Check to make sure this file is located in your project directory."))


# Path: bin/wtf_tools.py
from optparse import OptionParser
from wtframework.wtf._devtools_ import page_object_tools, test_generation_tools
from wtframework.wtf.utils.project_utils import ProjectUtils
import os
import wtframework

    parser = OptionParser(usage=usage)
    parser.add_option("--version", action="store_true",
                      default=False, dest="version_flag",
                      help="Version info.")

    (options, args) = parser.parse_args()

    if(options.version_flag):
        print(wtframework.__VERSION__)
        exit()

    if len(args) < 2:
        print("Invalid command.", usage)
        exit(1)
        
    if args[0] == "generate-page":
        if len(args) < 3:
            raise RuntimeError("usage: wtf_tools.py generate-page PageName http://page.url.com/somepage")

        pagename = args[1]
        url = args[2]
        print("Generating page object for url:", url)
        file_content = page_object_tools.generate_page_object(pagename, url)
        path = os.path.join(ProjectUtils.get_project_root(), "tests", "pages", pagename.lower() + ".py")
        create_file(path, file_content)

    elif args[0] == "generate-test":
        test_name = args[1]
        print("Generating generic test.")
        file_content = test_generation_tools.generate_empty_test(test_name)

        create_file(ProjectUtils.get_project_root() \