fs

URI

mypygui.core.fs.uri.URI

URI.Schema

URI.Schema
Enum (static)
Currently recognized Schemas are
  • file
  • http
  • https

URI.schema

URI.host

URI.host
str
The host of the uri

URI.path

URI.path
pathlib.Path
The path pertaining to the uri

URI.queries

URI.queries
list[str]
Queries in the uri

URI.fragment

URI.fragment
str
Fragments of the uri

URI.parent

The parent of the uri

URI.make

URI.make
( ) -> URI
Creates a new uri relative to the current uri
NOTE: This function keeps in mind that http and file uris have to be handled differently
NOTE: This function is used by mypygui to handle urls present in the html
Parameters:
  • uri_string : str
    The uri_string (or partial uri string in the case of local url)
Returns:
The uri that was made (a uri relative to the current one)

URI.join

URI.join
(*parts) → URI
Creates a new uri based on the parts given
Parameters:
  • *parts : [...str]
Returns:
The joined URI

URI.to_string

URI.to_string
( ) → str
Converts the uri to a string

URI.from_uri_string

URI.from_uri_string
classmethod (uri, _resolve_path?) → URI
Forms the uri using a string
Parameters:
  • uri : str
    The string representation of the uri
  • _resolve_path : bool
    Resolves the path of the given uri if set to true (False by default )
Returns:
A uri from the string

URI.from_local_path_string

URI.from_local_path_string
classmethod (path) → URI
Forms a uri using a path to the given local resource
NOTE: The paths must be absolute paths
Parameters:
  • path : str
    The absolute path
Returns:
A uri from the string

Reading

mypygui.core.asynchronous.fs.reading

FileType

FileType
Enum
Currently recognized filetypes are
  • text
  • bytes

load

load
(uri, file_type?) → any
Loads a file given a uri
NOTE: Will load files present both on the web or present locally NOTE: This process is synchronous
Parameters:
  • uri : fs.URI
    URI of the resources that needs to be loaded
  • file_type : FileType
    The FileType of the resource (FileType.text as default)
Returns:
The content

load_web

load_web
(uri, file_type?) → any
Loads a given uri using requests.get
NOTE: This process is synchronous
Parameters:
  • uri : fs.URI
    URI of the resources that needs to be loaded
  • file_type : FileType
    The FileType of the resource (FileType.text as default)
Returns:
The content

load_local

load_local
(uri, file_type?) → any
Loads a file given a uri using pathlib.Path.read_text or pathlib.Path.read_bytes as needed
NOTE: This process is synchronous
Parameters:
  • uri : fs.URI
    URI of the resources that needs to be loaded
  • file_type : FileType
    The FileType of the resource (FileType.text as default)
Returns:
The content