예제 #1
0
 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)
예제 #2
0
 def set_feature_permission(
     self,
     url: types.UrlType,
     feature: FeatureStr,
     policy: PermissionPolicyStr,
 ):
     url = core.Url(url)
     self.setFeaturePermission(url, FEATURE[feature],
                               PERMISSION_POLICY[policy])
예제 #3
0
 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)
     ]
예제 #4
0
 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(),
     )
예제 #5
0
    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)
예제 #6
0
 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)
예제 #7
0
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"
예제 #8
0
    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)
예제 #9
0
 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))
예제 #10
0
 def set_url(self, url: str | QtCore.QUrl):
     url = core.Url(url)
     self.setUrl(url)
예제 #11
0
 def get_url(self) -> core.Url:
     return core.Url(self.url())
예제 #12
0
 def set_url(self, url: types.UrlType):
     url = core.Url(url)
     self.setUrl(url)
예제 #13
0
 def get_link_at(self, point: types.PointType) -> core.Url:
     if isinstance(point, tuple):
         point = core.Point(*point)
     return core.Url(self.linkAt(point))
예제 #14
0
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
예제 #15
0
 def get_requested_url(self) -> core.Url:
     return core.Url(self.requestedUrl())
예제 #16
0
def test_helpsearchresult():
    result = qthelp.HelpSearchResult(core.Url(""), "", "")
    result.get_url()
예제 #17
0
파일: place.py 프로젝트: phil65/PrettyQt
 def get_primary_website(self) -> core.Url:
     return core.Url(self.primaryWebsite())
예제 #18
0
 def get_icon_url(self) -> core.Url:
     return core.Url(self.iconUrl())
예제 #19
0
 def get(self, request: types.UrlType | QtNetwork.QNetworkRequest):
     if isinstance(request, str):
         request = core.Url(request)
     request = network.NetworkRequest(request)
     return super().get(request)
예제 #20
0
 def get_link_url(self) -> core.Url:
     return core.Url(self.linkUrl())
예제 #21
0
 def get_media_url(self) -> core.Url:
     return core.Url(self.mediaUrl())
예제 #22
0
 def get_base_url(self) -> core.Url:
     return core.Url(self.baseUrl())
예제 #23
0
def test_helpengine():
    engine = qthelp.HelpEngine("")
    engine.get_file_data(core.Url(""))
    engine.get_files("", "")
예제 #24
0
def test_placeimage():
    image = location.PlaceImage()
    image.get_supplier()
    assert str(image) == ""
    image.set_url("http://")
    assert image.get_url() == core.Url("http://")
예제 #25
0
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()
예제 #26
0
 def select_url(self, url: types.UrlType) -> core.Url:
     if isinstance(url, str):
         url = QtCore.QUrl(url)
     return core.Url(self.select(url))