Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def to_capabilities(self): caps = self._caps browser_options = {} if self.binary_location: browser_options["binary"] = self.binary_location if self.arguments: browser_options["args"] = self.arguments b...
[ "\n Creates a capabilities with all the options that have been set and\n returns a dictionary with everything\n " ]
Please provide a description of the function:def active_element(self): if self._driver.w3c: return self._driver.execute(Command.W3C_GET_ACTIVE_ELEMENT)['value'] else: return self._driver.execute(Command.GET_ACTIVE_ELEMENT)['value']
[ "\n Returns the element with focus, or BODY if nothing has focus.\n\n :Usage:\n ::\n\n element = driver.switch_to.active_element\n " ]
Please provide a description of the function:def frame(self, frame_reference): if isinstance(frame_reference, basestring) and self._driver.w3c: try: frame_reference = self._driver.find_element(By.ID, frame_reference) except NoSuchElementException: ...
[ "\n Switches focus to the specified frame, by index, name, or webelement.\n\n :Args:\n - frame_reference: The name of the window to switch to, an integer representing the index,\n or a webelement that is an (i)frame to switch to.\n\n :Usage:\n ::\n\...
Please provide a description of the function:def new_window(self, type_hint=None): value = self._driver.execute(Command.NEW_WINDOW, {'type': type_hint})['value'] self._w3c_window(value['handle'])
[ "Switches to a new top-level browsing context.\n\n The type hint can be one of \"tab\" or \"window\". If not specified the\n browser will automatically select it.\n\n :Usage:\n ::\n\n driver.switch_to.new_window('tab')\n " ]
Please provide a description of the function:def window(self, window_name): if self._driver.w3c: self._w3c_window(window_name) return data = {'name': window_name} self._driver.execute(Command.SWITCH_TO_WINDOW, data)
[ "\n Switches focus to the specified window.\n\n :Args:\n - window_name: The name or window handle of the window to switch to.\n\n :Usage:\n ::\n\n driver.switch_to.window('main')\n " ]
Please provide a description of the function:def perform(self): if self._driver.w3c: self.w3c_actions.perform() else: for action in self._actions: action()
[ "\n Performs all stored actions.\n " ]
Please provide a description of the function:def reset_actions(self): if self._driver.w3c: self.w3c_actions.clear_actions() self._actions = []
[ "\n Clears actions that are already stored locally and on the remote end\n " ]
Please provide a description of the function:def click_and_hold(self, on_element=None): if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.click_and_hold() self.w3c_actions.key_action.pause() else: ...
[ "\n Holds down the left mouse button on an element.\n\n :Args:\n - on_element: The element to mouse down.\n If None, clicks on current mouse position.\n " ]
Please provide a description of the function:def context_click(self, on_element=None): if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.context_click() self.w3c_actions.key_action.pause() self.w3...
[ "\n Performs a context-click (right click) on an element.\n\n :Args:\n - on_element: The element to context-click.\n If None, clicks on current mouse position.\n " ]
Please provide a description of the function:def double_click(self, on_element=None): if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.double_click() for _ in range(4): self.w3c_actions.key_a...
[ "\n Double-clicks an element.\n\n :Args:\n - on_element: The element to double-click.\n If None, clicks on current mouse position.\n " ]
Please provide a description of the function:def drag_and_drop(self, source, target): self.click_and_hold(source) self.release(target) return self
[ "\n Holds down the left mouse button on the source element,\n then moves to the target element and releases the mouse button.\n\n :Args:\n - source: The element to mouse down.\n - target: The element to mouse up.\n " ]
Please provide a description of the function:def drag_and_drop_by_offset(self, source, xoffset, yoffset): self.click_and_hold(source) self.move_by_offset(xoffset, yoffset) self.release() return self
[ "\n Holds down the left mouse button on the source element,\n then moves to the target offset and releases the mouse button.\n\n :Args:\n - source: The element to mouse down.\n - xoffset: X offset to move to.\n - yoffset: Y offset to move to.\n " ]
Please provide a description of the function:def key_down(self, value, element=None): if element: self.click(element) if self._driver.w3c: self.w3c_actions.key_action.key_down(value) self.w3c_actions.pointer_action.pause() else: self._acti...
[ "\n Sends a key press only, without releasing it.\n Should only be used with modifier keys (Control, Alt and Shift).\n\n :Args:\n - value: The modifier key to send. Values are defined in `Keys` class.\n - element: The element to send keys.\n If None, sends a key to ...
Please provide a description of the function:def move_by_offset(self, xoffset, yoffset): if self._driver.w3c: self.w3c_actions.pointer_action.move_by(xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute...
[ "\n Moving the mouse to an offset from current mouse position.\n\n :Args:\n - xoffset: X offset to move to, as a positive or negative integer.\n - yoffset: Y offset to move to, as a positive or negative integer.\n " ]
Please provide a description of the function:def move_to_element(self, to_element): if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element) self.w3c_actions.key_action.pause() else: self._actions.append(lambda: self._driver.execute( ...
[ "\n Moving the mouse to the middle of an element.\n\n :Args:\n - to_element: The WebElement to move to.\n " ]
Please provide a description of the function:def move_to_element_with_offset(self, to_element, xoffset, yoffset): if self._driver.w3c: self.w3c_actions.pointer_action.move_to(to_element, xoffset, yoffset) self.w3c_actions.key_action.pause() else: self._action...
[ "\n Move the mouse by an offset of the specified element.\n Offsets are relative to the top-left corner of the element.\n\n :Args:\n - to_element: The WebElement to move to.\n - xoffset: X offset to move to.\n - yoffset: Y offset to move to.\n " ]
Please provide a description of the function:def pause(self, seconds): if self._driver.w3c: self.w3c_actions.pointer_action.pause(seconds) self.w3c_actions.key_action.pause(seconds) else: self._actions.append(lambda: time.sleep(seconds)) return self
[ " Pause all inputs for the specified duration in seconds " ]
Please provide a description of the function:def release(self, on_element=None): if on_element: self.move_to_element(on_element) if self._driver.w3c: self.w3c_actions.pointer_action.release() self.w3c_actions.key_action.pause() else: self....
[ "\n Releasing a held mouse button on an element.\n\n :Args:\n - on_element: The element to mouse up.\n If None, releases on current mouse position.\n " ]
Please provide a description of the function:def send_keys(self, *keys_to_send): typing = keys_to_typing(keys_to_send) if self._driver.w3c: for key in typing: self.key_down(key) self.key_up(key) else: self._actions.append(lambda: s...
[ "\n Sends keys to current focused element.\n\n :Args:\n - keys_to_send: The keys to send. Modifier keys constants can be found in the\n 'Keys' class.\n " ]
Please provide a description of the function:def send_keys_to_element(self, element, *keys_to_send): self.click(element) self.send_keys(*keys_to_send) return self
[ "\n Sends keys to an element.\n\n :Args:\n - element: The element to send keys.\n - keys_to_send: The keys to send. Modifier keys constants can be found in the\n 'Keys' class.\n " ]
Please provide a description of the function:def browser_attach_timeout(self, value): if not isinstance(value, int): raise ValueError('Browser Attach Timeout must be an integer.') self._options[self.BROWSER_ATTACH_TIMEOUT] = value
[ "\n Sets the options Browser Attach Timeout\n\n :Args:\n - value: Timeout in milliseconds\n\n " ]
Please provide a description of the function:def element_scroll_behavior(self, value): if value not in [ElementScrollBehavior.TOP, ElementScrollBehavior.BOTTOM]: raise ValueError('Element Scroll Behavior out of range.') self._options[self.ELEMENT_SCROLL_BEHAVIOR] = value
[ "\n Sets the options Element Scroll Behavior\n\n :Args:\n - value: 0 - Top, 1 - Bottom\n\n " ]
Please provide a description of the function:def file_upload_dialog_timeout(self, value): if not isinstance(value, int): raise ValueError('File Upload Dialog Timeout must be an integer.') self._options[self.FILE_UPLOAD_DIALOG_TIMEOUT] = value
[ "\n Sets the options File Upload Dialog Timeout value\n\n :Args:\n - value: Timeout in milliseconds\n\n " ]
Please provide a description of the function:def to_capabilities(self): caps = self._caps opts = self._options.copy() if len(self._arguments) > 0: opts[self.SWITCHES] = ' '.join(self._arguments) if len(self._additional) > 0: opts.update(self._additional...
[ "Marshals the IE options to the correct object." ]
Please provide a description of the function:def extensions(self): encoded_extensions = [] for ext in self._extension_files: file_ = open(ext, 'rb') # Should not use base64.encodestring() which inserts newlines every # 76 characters (per RFC 1521). Chromedri...
[ "\n :Returns: A list of encoded extensions that will be loaded into chrome\n " ]
Please provide a description of the function:def add_extension(self, extension): if extension: extension_to_add = os.path.abspath(os.path.expanduser(extension)) if os.path.exists(extension_to_add): self._extension_files.append(extension_to_add) else: ...
[ "\n Adds the path to the extension to a list that will be used to extract it\n to the ChromeDriver\n\n :Args:\n - extension: path to the \\\\*.crx file\n " ]
Please provide a description of the function:def headless(self, value): args = {'--headless'} if value is True: self._arguments.extend(args) else: self._arguments = list(set(self._arguments) - args)
[ "\n Sets the headless argument\n\n :Args:\n value: boolean value indicating to set the headless option\n " ]
Please provide a description of the function:def to_capabilities(self): caps = self._caps chrome_options = self.experimental_options.copy() chrome_options["extensions"] = self.extensions if self.binary_location: chrome_options["binary"] = self.binary_location ...
[ "\n Creates a capabilities with all the options that have been set\n\n :Returns: A dictionary with everything\n " ]
Please provide a description of the function:def _find_element(driver, by): try: return driver.find_element(*by) except NoSuchElementException as e: raise e except WebDriverException as e: raise e
[ "Looks up an element. Logs and re-raises ``WebDriverException``\n if thrown." ]
Please provide a description of the function:def text(self): if self.driver.w3c: return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"] else: return self.driver.execute(Command.GET_ALERT_TEXT)["value"]
[ "\n Gets the text of the Alert.\n " ]
Please provide a description of the function:def dismiss(self): if self.driver.w3c: self.driver.execute(Command.W3C_DISMISS_ALERT) else: self.driver.execute(Command.DISMISS_ALERT)
[ "\n Dismisses the alert available.\n " ]
Please provide a description of the function:def accept(self): if self.driver.w3c: self.driver.execute(Command.W3C_ACCEPT_ALERT) else: self.driver.execute(Command.ACCEPT_ALERT)
[ "\n Accepts the alert available.\n\n Usage::\n Alert(driver).accept() # Confirm a alert dialog.\n " ]
Please provide a description of the function:def send_keys(self, keysToSend): if self.driver.w3c: self.driver.execute(Command.W3C_SET_ALERT_VALUE, {'value': keys_to_typing(keysToSend), 'text': keysToSend}) else: ...
[ "\n Send Keys to the Alert.\n\n :Args:\n - keysToSend: The text to be sent to Alert.\n\n\n " ]
Please provide a description of the function:def port(self, port): if not isinstance(port, int): raise WebDriverException("Port needs to be an integer") try: port = int(port) if port < 1 or port > 65535: raise WebDriverException("Port number m...
[ "\n Sets the port that WebDriver will be running on\n " ]
Please provide a description of the function:def encoded(self): self.update_preferences() fp = BytesIO() zipped = zipfile.ZipFile(fp, 'w', zipfile.ZIP_DEFLATED) path_root = len(self.path) + 1 # account for trailing slash for base, dirs, files in os.walk(self.path): ...
[ "\n A zipped, base64 encoded string of profile directory\n for use with remote WebDriver JSON wire protocol\n " ]
Please provide a description of the function:def _write_user_prefs(self, user_prefs): with open(self.userPrefs, "w") as f: for key, value in user_prefs.items(): f.write('user_pref("%s", %s);\n' % (key, json.dumps(value)))
[ "\n writes the current user prefs dictionary to disk\n " ]
Please provide a description of the function:def _install_extension(self, addon, unpack=True): if addon == WEBDRIVER_EXT: addon = os.path.join(os.path.dirname(__file__), WEBDRIVER_EXT) tmpdir = None xpifile = None if addon.endswith('.xpi'): tmpdir = temp...
[ "\n Installs addon from a filepath, url\n or directory of addons in the profile.\n - path: url, absolute path to .xpi, or directory of addons\n - unpack: whether to unpack unless specified otherwise in the install.rdf\n " ]
Please provide a description of the function:def _addon_details(self, addon_path): details = { 'id': None, 'unpack': False, 'name': None, 'version': None } def get_namespace_id(doc, url): attributes = doc.documentElement.attr...
[ "\n Returns a dictionary of details about the addon.\n\n :param addon_path: path to the add-on directory or XPI\n\n Returns::\n\n {'id': u'rainbow@colors.org', # id of the addon\n 'version': u'1.4', # version of the addon\n 'name': u'Rai...
Please provide a description of the function:def submit(self): if self._w3c: form = self.find_element(By.XPATH, "./ancestor-or-self::form") self._parent.execute_script( "var e = arguments[0].ownerDocument.createEvent('Event');" "e.initEvent('submi...
[ "Submits a form." ]
Please provide a description of the function:def get_property(self, name): try: return self._execute(Command.GET_ELEMENT_PROPERTY, {"name": name})["value"] except WebDriverException: # if we hit an end point that doesnt understand getElementProperty lets fake it ...
[ "\n Gets the given property of the element.\n\n :Args:\n - name - Name of the property to retrieve.\n\n :Usage:\n ::\n\n text_length = target_element.get_property(\"text_length\")\n " ]
Please provide a description of the function:def get_attribute(self, name): attributeValue = '' if self._w3c: attributeValue = self.parent.execute_script( "return (%s).apply(null, arguments);" % getAttribute_js, self, name) else: ...
[ "Gets the given attribute or property of the element.\n\n This method will first try to return the value of a property with the\n given name. If a property with that name doesn't exist, it returns the\n value of the attribute with the same name. If there's no attribute with\n that name, ...
Please provide a description of the function:def send_keys(self, *value): # transfer file to another machine only if remote driver is used # the same behaviour as for java binding if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) ...
[ "Simulates typing into the element.\n\n :Args:\n - value - A string for typing, or setting form fields. For setting\n file inputs, this could be a local file path.\n\n Use this to send simple key events or to fill out form fields::\n\n form_textfield = driver.find_e...
Please provide a description of the function:def is_displayed(self): # Only go into this conditional for browsers that don't use the atom themselves if self._w3c: return self.parent.execute_script( "return (%s).apply(null, arguments);" % isDisplayed_js, ...
[ "Whether the element is visible to a user." ]
Please provide a description of the function:def location_once_scrolled_into_view(self): if self._w3c: old_loc = self._execute(Command.W3C_EXECUTE_SCRIPT, { 'script': "arguments[0].scrollIntoView(true); return arguments[0].getBoundingClientRect()", 'args': [s...
[ "THIS PROPERTY MAY CHANGE WITHOUT WARNING. Use this to discover\n where on the screen an element is so that we can click it. This method\n should cause the element to be scrolled into view.\n\n Returns the top lefthand corner location on the screen, or ``None`` if\n the element is not vi...
Please provide a description of the function:def size(self): size = {} if self._w3c: size = self._execute(Command.GET_ELEMENT_RECT)['value'] else: size = self._execute(Command.GET_ELEMENT_SIZE)['value'] new_size = {"height": size["height"], ...
[ "The size of the element." ]
Please provide a description of the function:def location(self): if self._w3c: old_loc = self._execute(Command.GET_ELEMENT_RECT)['value'] else: old_loc = self._execute(Command.GET_ELEMENT_LOCATION)['value'] new_loc = {"x": round(old_loc['x']), ...
[ "The location of the element in the renderable canvas." ]
Please provide a description of the function:def rect(self): if self._w3c: return self._execute(Command.GET_ELEMENT_RECT)['value'] else: rect = self.size.copy() rect.update(self.location) return rect
[ "A dictionary with the size and location of the element." ]
Please provide a description of the function:def screenshot(self, filename): if not filename.lower().endswith('.png'): warnings.warn("name used for saved screenshot does not match file " "type. It should end with a `.png` extension", UserWarning) png = self...
[ "\n Saves a screenshot of the current element to a PNG image file. Returns\n False if there is any IOError, else returns True. Use full paths in\n your filename.\n\n :Args:\n - filename: The full path you wish to save your screenshot to. This\n should end with a `...
Please provide a description of the function:def _execute(self, command, params=None): if not params: params = {} params['id'] = self._id return self._parent.execute(command, params)
[ "Executes a command against the underlying HTML element.\n\n Args:\n command: The name of the command to _execute as a string.\n params: A dictionary of named parameters to send with the command.\n\n Returns:\n The command's JSON response loaded into a dictionary object.\n ...
Please provide a description of the function:def find_element(self, by=By.ID, value=None): if self._w3c: if by == By.ID: by = By.CSS_SELECTOR value = '[id="%s"]' % value elif by == By.TAG_NAME: by = By.CSS_SELECTOR elif...
[ "\n Find an element given a By strategy and locator. Prefer the find_element_by_* methods when\n possible.\n\n :Usage:\n ::\n\n element = element.find_element(By.ID, 'foo')\n\n :rtype: WebElement\n " ]
Please provide a description of the function:def find_elements(self, by=By.ID, value=None): if self._w3c: if by == By.ID: by = By.CSS_SELECTOR value = '[id="%s"]' % value elif by == By.TAG_NAME: by = By.CSS_SELECTOR eli...
[ "\n Find elements given a By strategy and locator. Prefer the find_elements_by_* methods when\n possible.\n\n :Usage:\n ::\n\n element = element.find_elements(By.CLASS_NAME, 'foo')\n\n :rtype: list of WebElement\n " ]
Please provide a description of the function:def quit(self): try: RemoteWebDriver.quit(self) except http_client.BadStatusLine: pass finally: self.service.stop()
[ "\n Closes the browser and shuts down the WebKitGTKDriver executable\n that is started when starting the WebKitGTKDriver\n " ]
Please provide a description of the function:def start(self): try: cmd = [self.path] cmd.extend(self.command_line_args()) self.process = subprocess.Popen(cmd, env=self.env, close_fds=platform.system() != 'Windows', ...
[ "\n Starts the Service.\n\n :Exceptions:\n - WebDriverException : Raised either when it can't start the service\n or when it can't connect to the service\n " ]
Please provide a description of the function:def stop(self): if self.log_file != PIPE and not (self.log_file == DEVNULL and _HAS_NATIVE_DEVNULL): try: self.log_file.close() except Exception: pass if self.process is None: retur...
[ "\n Stops the service.\n " ]
Please provide a description of the function:def launch_browser(self, profile, timeout=30): self.profile = profile self._start_from_profile_path(self.profile.path) self._wait_until_connectable(timeout=timeout)
[ "Launches the browser for the given profile name.\n It is assumed the profile already exists.\n " ]
Please provide a description of the function:def kill(self): if self.process: self.process.kill() self.process.wait()
[ "Kill the browser.\n\n This is useful when the browser is stuck.\n " ]
Please provide a description of the function:def _wait_until_connectable(self, timeout=30): count = 0 while not utils.is_connectable(self.profile.port): if self.process.poll() is not None: # Browser has exited raise WebDriverException( ...
[ "Blocks until the extension is connectable in the firefox." ]
Please provide a description of the function:def _get_firefox_start_cmd(self): start_cmd = "" if platform.system() == "Darwin": start_cmd = "/Applications/Firefox.app/Contents/MacOS/firefox-bin" # fallback to homebrew installation for mac users if not os.path...
[ "Return the command to start firefox." ]
Please provide a description of the function:def which(self, fname): for pe in os.environ['PATH'].split(os.pathsep): checkname = os.path.join(pe, fname) if os.access(checkname, os.X_OK) and not os.path.isdir(checkname): return checkname return None
[ "Returns the fully qualified path by searching Path of the given\n name" ]
Please provide a description of the function:def get_remote_connection_headers(cls, parsed_url, keep_alive=False): system = platform.system().lower() if system == "darwin": system = "mac" headers = { 'Accept': 'application/json', 'Content-Type': 'ap...
[ "\n Get headers for remote request.\n\n :Args:\n - parsed_url - The parsed url\n - keep_alive (Boolean) - Is this a keep-alive connection (default: False)\n " ]
Please provide a description of the function:def execute(self, command, params): command_info = self._commands[command] assert command_info is not None, 'Unrecognised command %s' % command path = string.Template(command_info[1]).substitute(params) if hasattr(self, 'w3c') and sel...
[ "\n Send a command to the remote server.\n\n Any path subtitutions required for the URL mapped to the command should be\n included in the command parameters.\n\n :Args:\n - command - A string specifying the command to execute.\n - params - A dictionary of named parameters...
Please provide a description of the function:def _request(self, method, url, body=None): LOGGER.debug('%s %s %s' % (method, url, body)) parsed_url = parse.urlparse(url) headers = self.get_remote_connection_headers(parsed_url, self.keep_alive) resp = None if body and met...
[ "\n Send an HTTP request to the remote server.\n\n :Args:\n - method - A string for the HTTP method to send the request with.\n - url - A string for the URL to send the request to.\n - body - A string for request body. Ignored unless method is POST or PUT.\n\n :Returns:\...
Please provide a description of the function:def all_selected_options(self): ret = [] for opt in self.options: if opt.is_selected(): ret.append(opt) return ret
[ "Returns a list of all selected options belonging to this select tag" ]
Please provide a description of the function:def select_by_value(self, value): css = "option[value =%s]" % self._escapeString(value) opts = self._el.find_elements(By.CSS_SELECTOR, css) matched = False for opt in opts: self._setSelected(opt) if not self.is...
[ "Select all options that have a value matching the argument. That is, when given \"foo\" this\n would select an option like:\n\n <option value=\"foo\">Bar</option>\n\n :Args:\n - value - The value to match against\n\n throws NoSuchElementException If there is no op...
Please provide a description of the function:def select_by_index(self, index): match = str(index) for opt in self.options: if opt.get_attribute("index") == match: self._setSelected(opt) return raise NoSuchElementException("Could not locate ele...
[ "Select the option at the given index. This is done by examing the \"index\" attribute of an\n element, and not merely by counting.\n\n :Args:\n - index - The option at this index will be selected\n\n throws NoSuchElementException If there is no option with specified index i...
Please provide a description of the function:def deselect_all(self): if not self.is_multiple: raise NotImplementedError("You may only deselect all options of a multi-select") for opt in self.options: self._unsetSelected(opt)
[ "Clear all selected entries. This is only valid when the SELECT supports multiple selections.\n throws NotImplementedError If the SELECT does not support multiple selections\n " ]
Please provide a description of the function:def deselect_by_value(self, value): if not self.is_multiple: raise NotImplementedError("You may only deselect options of a multi-select") matched = False css = "option[value = %s]" % self._escapeString(value) opts = self._...
[ "Deselect all options that have a value matching the argument. That is, when given \"foo\" this\n would deselect an option like:\n\n <option value=\"foo\">Bar</option>\n\n :Args:\n - value - The value to match against\n\n throws NoSuchElementException If there is...
Please provide a description of the function:def deselect_by_index(self, index): if not self.is_multiple: raise NotImplementedError("You may only deselect options of a multi-select") for opt in self.options: if opt.get_attribute("index") == str(index): se...
[ "Deselect the option at the given index. This is done by examing the \"index\" attribute of an\n element, and not merely by counting.\n\n :Args:\n - index - The option at this index will be deselected\n\n throws NoSuchElementException If there is no option with specified in...
Please provide a description of the function:def deselect_by_visible_text(self, text): if not self.is_multiple: raise NotImplementedError("You may only deselect options of a multi-select") matched = False xpath = ".//option[normalize-space(.) = %s]" % self._escapeString(text...
[ "Deselect all options that display text matching the argument. That is, when given \"Bar\" this\n would deselect an option like:\n\n <option value=\"foo\">Bar</option>\n\n :Args:\n - text - The visible text to match against\n " ]
Please provide a description of the function:def to_capabilities(self): capabilities = ChromeOptions.to_capabilities(self) capabilities.update(self._caps) opera_options = capabilities[self.KEY] if self.android_package_name: opera_options["androidPackage"] = self.and...
[ "\n Creates a capabilities with all the options that have been set and\n returns a dictionary with everything\n " ]
Please provide a description of the function:def _upload(auth_http, project_id, bucket_name, file_path, object_name, acl): with open(file_path, 'rb') as f: data = f.read() content_type, content_encoding = mimetypes.guess_type(file_path) headers = { 'x-goog-project-id': project_id, ...
[ "Uploads a file to Google Cloud Storage.\n\n Args:\n auth_http: An authorized httplib2.Http instance.\n project_id: The project to upload to.\n bucket_name: The bucket to upload to.\n file_path: Path to the file to upload.\n object_name: The name within the bucket to upload to....
Please provide a description of the function:def _authenticate(secrets_file): flow = oauthclient.flow_from_clientsecrets( secrets_file, scope=OAUTH_SCOPE, message=('Failed to initialized OAuth 2.0 flow with secrets ' 'file: %s' % secrets_file)) storage = oauthfile.S...
[ "Runs the OAuth 2.0 installed application flow.\n\n Returns:\n An authorized httplib2.Http instance.\n " ]
Please provide a description of the function:def auto_detect(self, value): if isinstance(value, bool): if self.autodetect is not value: self._verify_proxy_type_compatibility(ProxyType.AUTODETECT) self.proxyType = ProxyType.AUTODETECT self.auto...
[ "\n Sets autodetect setting.\n\n :Args:\n - value: The autodetect value.\n " ]
Please provide a description of the function:def ftp_proxy(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.ftpProxy = value
[ "\n Sets ftp proxy setting.\n\n :Args:\n - value: The ftp proxy value.\n " ]
Please provide a description of the function:def http_proxy(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.httpProxy = value
[ "\n Sets http proxy setting.\n\n :Args:\n - value: The http proxy value.\n " ]
Please provide a description of the function:def no_proxy(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.noProxy = value
[ "\n Sets noproxy setting.\n\n :Args:\n - value: The noproxy value.\n " ]
Please provide a description of the function:def proxy_autoconfig_url(self, value): self._verify_proxy_type_compatibility(ProxyType.PAC) self.proxyType = ProxyType.PAC self.proxyAutoconfigUrl = value
[ "\n Sets proxy autoconfig url setting.\n\n :Args:\n - value: The proxy autoconfig url value.\n " ]
Please provide a description of the function:def ssl_proxy(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.sslProxy = value
[ "\n Sets https proxy setting.\n\n :Args:\n - value: The https proxy value.\n " ]
Please provide a description of the function:def socks_proxy(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksProxy = value
[ "\n Sets socks proxy setting.\n\n :Args:\n - value: The socks proxy value.\n " ]
Please provide a description of the function:def socks_username(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksUsername = value
[ "\n Sets socks proxy username setting.\n\n :Args:\n - value: The socks proxy username value.\n " ]
Please provide a description of the function:def socks_password(self, value): self._verify_proxy_type_compatibility(ProxyType.MANUAL) self.proxyType = ProxyType.MANUAL self.socksPassword = value
[ "\n Sets socks proxy password setting.\n\n :Args:\n - value: The socks proxy password value.\n " ]
Please provide a description of the function:def add_to_capabilities(self, capabilities): proxy_caps = {} proxy_caps['proxyType'] = self.proxyType['string'] if self.autodetect: proxy_caps['autodetect'] = self.autodetect if self.ftpProxy: proxy_caps['ftpPr...
[ "\n Adds proxy information as capability in specified capabilities.\n\n :Args:\n - capabilities: The capabilities to which proxy will be added.\n " ]
Please provide a description of the function:def find_connectable_ip(host, port=None): try: addrinfos = socket.getaddrinfo(host, None) except socket.gaierror: return None ip = None for family, _, _, _, sockaddr in addrinfos: connectable = True if port: c...
[ "Resolve a hostname to an IP, preferring IPv4 addresses.\n\n We prefer IPv4 so that we don't change behavior from previous IPv4-only\n implementations, and because some drivers (e.g., FirefoxDriver) do not\n support IPv6 connections.\n\n If the optional port number is provided, only IPs that listen on t...
Please provide a description of the function:def join_host_port(host, port): if ':' in host and not host.startswith('['): return '[%s]:%d' % (host, port) return '%s:%d' % (host, port)
[ "Joins a hostname and port together.\n\n This is a minimal implementation intended to cope with IPv6 literals. For\n example, _join_host_port('::1', 80) == '[::1]:80'.\n\n :Args:\n - host - A hostname.\n - port - An integer port.\n\n " ]
Please provide a description of the function:def is_connectable(port, host="localhost"): socket_ = None try: socket_ = socket.create_connection((host, port), 1) result = True except _is_connectable_exceptions: result = False finally: if socket_: socket_.c...
[ "\n Tries to connect to the server at port to see if it is running.\n\n :Args:\n - port - The port to connect.\n " ]
Please provide a description of the function:def is_url_connectable(port): try: from urllib import request as url_request except ImportError: import urllib2 as url_request try: res = url_request.urlopen("http://127.0.0.1:%s/status" % port) if res.getcode() == 200: ...
[ "\n Tries to connect to the HTTP server at /status path\n and specified port to see if it responds successfully.\n\n :Args:\n - port - The port to connect.\n " ]
Please provide a description of the function:def keys_to_typing(value): typing = [] for val in value: if isinstance(val, Keys): typing.append(val) elif isinstance(val, int): val = str(val) for i in range(len(val)): typing.append(val[i]) ...
[ "Processes the values that will be typed in the element." ]
Please provide a description of the function:def to_html(doc, output="/tmp", style="dep"): # generate filename from first six non-punct tokens file_name = "-".join([w.text for w in doc[:6] if not w.is_punct]) + ".html" html = displacy.render(doc, style=style, page=True) # render markup if output i...
[ "Doc method extension for saving the current state as a displaCy\n visualization.\n " ]
Please provide a description of the function:def overlap_tokens(doc, other_doc): overlap = [] other_tokens = [token.text for token in other_doc] for token in doc: if token.text in other_tokens: overlap.append(token) return overlap
[ "Get the tokens from the original Doc that are also in the comparison Doc.\n " ]
Please provide a description of the function:def iob2json(input_data, n_sents=10, *args, **kwargs): docs = [] for group in minibatch(docs, n_sents): group = list(group) first = group.pop(0) to_extend = first["paragraphs"][0]["sentences"] for sent in group[1:]: to...
[ "\n Convert IOB files into JSON format for use with train cli.\n " ]
Please provide a description of the function:def render( docs, style="dep", page=False, minify=False, jupyter=None, options={}, manual=False ): factories = { "dep": (DependencyRenderer, parse_deps), "ent": (EntityRenderer, parse_ents), } if style not in factories: raise Valu...
[ "Render displaCy visualisation.\n\n docs (list or Doc): Document(s) to visualise.\n style (unicode): Visualisation style, 'dep' or 'ent'.\n page (bool): Render markup as full HTML page.\n minify (bool): Minify HTML markup.\n jupyter (bool): Override Jupyter auto-detection.\n options (dict): Visual...
Please provide a description of the function:def serve( docs, style="dep", page=True, minify=False, options={}, manual=False, port=5000, host="0.0.0.0", ): from wsgiref import simple_server if is_in_jupyter(): user_warning(Warnings.W011) render(docs, style=styl...
[ "Serve displaCy visualisation.\n\n docs (list or Doc): Document(s) to visualise.\n style (unicode): Visualisation style, 'dep' or 'ent'.\n page (bool): Render markup as full HTML page.\n minify (bool): Minify HTML markup.\n options (dict): Visualiser-specific options, e.g. colors.\n manual (bool):...
Please provide a description of the function:def parse_deps(orig_doc, options={}): doc = Doc(orig_doc.vocab).from_bytes(orig_doc.to_bytes()) if not doc.is_parsed: user_warning(Warnings.W005) if options.get("collapse_phrases", False): with doc.retokenize() as retokenizer: for...
[ "Generate dependency parse in {'words': [], 'arcs': []} format.\n\n doc (Doc): Document do parse.\n RETURNS (dict): Generated dependency parse keyed by words and arcs.\n " ]
Please provide a description of the function:def parse_ents(doc, options={}): ents = [ {"start": ent.start_char, "end": ent.end_char, "label": ent.label_} for ent in doc.ents ] if not ents: user_warning(Warnings.W006) title = doc.user_data.get("title", None) if hasattr(doc, ...
[ "Generate named entities in [{start: i, end: i, label: 'label'}] format.\n\n doc (Doc): Document do parse.\n RETURNS (dict): Generated entities keyed by text (original text) and ents.\n " ]
Please provide a description of the function:def set_render_wrapper(func): global RENDER_WRAPPER if not hasattr(func, "__call__"): raise ValueError(Errors.E110.format(obj=type(func))) RENDER_WRAPPER = func
[ "Set an optional wrapper function that is called around the generated\n HTML markup on displacy.render. This can be used to allow integration into\n other platforms, similar to Jupyter Notebooks that require functions to be\n called around the HTML. It can also be used to implement custom callbacks\n on...
Please provide a description of the function:def evaluate( model, data_path, gpu_id=-1, gold_preproc=False, displacy_path=None, displacy_limit=25, return_scores=False, ): msg = Printer() util.fix_random_seed() if gpu_id >= 0: util.use_gpu(gpu_id) util.set_env_log...
[ "\n Evaluate a model. To render a sample of parses in a HTML file, set an\n output directory as the displacy_path argument.\n " ]
Please provide a description of the function:def link(origin, link_name, force=False, model_path=None): msg = Printer() if util.is_package(origin): model_path = util.get_package_path(origin) else: model_path = Path(origin) if model_path is None else Path(model_path) if not model_pat...
[ "\n Create a symlink for models within the spacy/data directory. Accepts\n either the name of a pip package, or the local path to the model data\n directory. Linking models allows loading them via spacy.load(link_name).\n " ]
Please provide a description of the function:def validate(): msg = Printer() with msg.loading("Loading compatibility table..."): r = requests.get(about.__compatibility__) if r.status_code != 200: msg.fail( "Server error ({})".format(r.status_code), ...
[ "\n Validate that the currently installed version of spaCy is compatible\n with the installed models. Should be run after `pip install -U spacy`.\n " ]
Please provide a description of the function:def profile(model, inputs=None, n_texts=10000): msg = Printer() if inputs is not None: inputs = _read_inputs(inputs, msg) if inputs is None: n_inputs = 25000 with msg.loading("Loading IMDB dataset via Thinc..."): imdb_trai...
[ "\n Profile a spaCy pipeline, to find out which functions take the most time.\n Input should be formatted as one JSON object per line with a key \"text\".\n It can either be provided as a JSONL file, or be read from sys.sytdin.\n If no input file is specified, the IMDB dataset is loaded via Thinc.\n ...
Please provide a description of the function:def resolve_pos(token): # TODO: This is a first take. The rules here are crude approximations. # For many of these, full dependencies are needed to properly resolve # PoS mappings. if token.pos == "連体詞,*,*,*": if re.match(r"[こそあど此其彼]の", token.sur...
[ "If necessary, add a field to the POS tag for UD mapping.\n Under Universal Dependencies, sometimes the same Unidic POS tag can\n be mapped differently depending on the literal token or its context\n in the sentence. This function adds information to the POS tag to\n resolve ambiguous mappings.\n " ]