def add_resource( self, resource_type: ResourceTypeStr, name: types.PathType, resource ): if resource_type not in RESOURCE_TYPES: raise InvalidParamError(resource_type, RESOURCE_TYPES) url = core.Url(name) self.addResource(RESOURCE_TYPES[resource_type], url, resource)
def set_feature_permission( self, url: types.UrlType, feature: FeatureStr, policy: PermissionPolicyStr, ): url = core.Url(url) self.setFeaturePermission(url, FEATURE[feature], PERMISSION_POLICY[policy])
def get_files( self, namespace_name: str, filter_name: str, extension_filter: str | None = None, ) -> list[core.Url]: if extension_filter is None: extension_filter = "" return [ core.Url(i) for i in self.files(namespace_name, filter_name, extension_filter) ]
def serialize_fields(self): return dict( audio_muted=self.isAudioMuted(), background_color=self.backgroundColor(), # has_selection=self.hasSelection(), lifecycle_state=self.get_lifecycle_state(), # scroll_position=self.scrollPosition(), url=core.Url(self.url()), visible=self.isVisible(), history=core.DataStream.create_bytearray(self.history()), zoom_factor=self.zoomFactor(), )
def set_url(self, url: types.PathType): """Set the url of the WebEnginePage. Clears the Page and loads the URL. Args: url: URL to set """ if isinstance(url, os.PathLike): url = core.Url.fromLocalFile(os.fspath(url)) elif isinstance(url, str): url = core.Url(url) self.setUrl(url)
def load_data( self, data: types.ByteArrayType, url: types.UrlType | None = None, ): if isinstance(data, str): data = data.encode() if isinstance(data, bytes): data = QtCore.QByteArray(data) if isinstance(url, str): url = core.Url.from_user_input(url) elif url is None: url = core.Url() self.loadData(data, url)
def test_networkrequest(): req = network.NetworkRequest() headers = {"a": "b"} req.set_headers(headers) assert req.get_headers() == headers req.set_priority("low") assert req.get_priority() == "low" req.set_url("http://www.google.de") assert req.get_url() == core.Url("http://www.google.de") with pytest.raises(InvalidParamError): req.set_header("test", "test") req.set_header("location", "test") with pytest.raises(InvalidParamError): req.get_header("test") assert req.get_header("location") == "test"
def load_url(self, url: types.UrlType | types.PathType): """Load the URL. Loads the specified url and displays it. Note: The Page remains the same until enough data has arrived to display the new URL. Args: url: URL to load """ if isinstance(url, os.PathLike): url = core.Url.fromLocalFile(os.fspath(url)) elif isinstance(url, str): url = core.Url(url) self.load(url)
def find_file(self, url: types.UrlType) -> core.Url: if not isinstance(url, QtCore.QUrl): url = QtCore.QUrl(url) return core.Url(self.findFile(url))
def set_url(self, url: str | QtCore.QUrl): url = core.Url(url) self.setUrl(url)
def get_url(self) -> core.Url: return core.Url(self.url())
def set_url(self, url: types.UrlType): url = core.Url(url) self.setUrl(url)
def get_link_at(self, point: types.PointType) -> core.Url: if isinstance(point, tuple): point = core.Point(*point) return core.Url(self.linkAt(point))
def test_placesupplier(): supplier = location.PlaceSupplier() supplier.set_url("http://") assert supplier.get_url() == core.Url("http://") supplier.get_icon() assert bool(supplier) is True
def get_requested_url(self) -> core.Url: return core.Url(self.requestedUrl())
def test_helpsearchresult(): result = qthelp.HelpSearchResult(core.Url(""), "", "") result.get_url()
def get_primary_website(self) -> core.Url: return core.Url(self.primaryWebsite())
def get_icon_url(self) -> core.Url: return core.Url(self.iconUrl())
def get(self, request: types.UrlType | QtNetwork.QNetworkRequest): if isinstance(request, str): request = core.Url(request) request = network.NetworkRequest(request) return super().get(request)
def get_link_url(self) -> core.Url: return core.Url(self.linkUrl())
def get_media_url(self) -> core.Url: return core.Url(self.mediaUrl())
def get_base_url(self) -> core.Url: return core.Url(self.baseUrl())
def test_helpengine(): engine = qthelp.HelpEngine("") engine.get_file_data(core.Url("")) engine.get_files("", "")
def test_placeimage(): image = location.PlaceImage() image.get_supplier() assert str(image) == "" image.set_url("http://") assert image.get_url() == core.Url("http://")
def test_url(): path = pathlib.Path.home() url = core.Url(path) # TODO: fails on Osx and linux # assert str(url) == str(url.to_path()) assert url.is_local_file()
def select_url(self, url: types.UrlType) -> core.Url: if isinstance(url, str): url = QtCore.QUrl(url) return core.Url(self.select(url))