MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / main

Function main

seleniumbase/console_scripts/sb_mkfile.py:92–428  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90
91
92def main():
93 c1 = ""
94 c5 = ""
95 c7 = ""
96 cr = ""
97 if "linux" not in sys.platform:
98 c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
99 c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
100 c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
101 cr = colorama.Style.RESET_ALL
102
103 basic = False
104 use_uc = False
105 help_me = False
106 recorder = False
107 error_msg = None
108 start_page = None
109 invalid_cmd = None
110 syntax = "BaseCase"
111 language = "English"
112
113 command_args = sys.argv[2:]
114 file_name = command_args[0]
115 if file_name == "-h" or file_name == "--help":
116 invalid_run_command("help")
117 elif not file_name.endswith(".py"):
118 error_msg = 'File name must end with ".py"!'
119 elif "*" in file_name or len(str(file_name)) < 4:
120 error_msg = "Invalid file name!"
121 elif file_name.startswith("-"):
122 error_msg = 'File name cannot start with "-"!'
123 elif "/" in str(file_name) or "\\" in str(file_name):
124 error_msg = "File must be created in the current directory!"
125 elif os.path.exists(os.getcwd() + "/" + file_name):
126 error_msg = 'File "%s" already exists in this directory!' % file_name
127 if error_msg:
128 error_msg = c5 + "ERROR: " + error_msg + cr
129 invalid_run_command(error_msg)
130
131 if len(command_args) >= 2:
132 options = command_args[1:]
133 for option in options:
134 option = option.lower()
135 if option == "-h" or option == "--help":
136 help_me = True
137 elif option.startswith("--url=") and len(option) > 6:
138 from seleniumbase.fixtures import page_utils
139 start_page = option.split("--url=")[1]
140 if not page_utils.is_valid_url(start_page):
141 if page_utils.is_valid_url("https://" + start_page):
142 start_page = "https://" + start_page
143 else:
144 raise Exception("Invalid URL: %s" % start_page)
145 basic = True
146 elif option == "-b" or option == "--basic":
147 basic = True
148 elif option == "-r" or option == "--rec":
149 recorder = True

Callers

nothing calls this directly

Calls 5

get_import_lineMethod · 0.80
get_lang_parent_classMethod · 0.80
closeMethod · 0.80
invalid_run_commandFunction · 0.70
is_valid_urlMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…