FileLoc#

pydantic model tollan.utils.fileloc.FileLoc[source]#

A model to hold file location info.

This is a simple wrapper around FileLocData.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Show JSON schema
{
   "title": "FileLoc",
   "description": "A model to hold file location info.\n\nThis is a simple wrapper around ``FileLocData``.",
   "$defs": {
      "FileLocData": {
         "description": "A helper model for storing file loc data.",
         "properties": {
            "url": {
               "anyOf": [
                  {
                     "format": "uri",
                     "minLength": 1,
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Url"
            },
            "path": {
               "anyOf": [
                  {
                     "format": "path",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Path"
            },
            "netloc": {
               "default": "",
               "title": "Netloc",
               "type": "string"
            },
            "local_parent_path": {
               "anyOf": [
                  {
                     "format": "path",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Local Parent Path"
            },
            "remote_parent_path": {
               "anyOf": [
                  {
                     "format": "path",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Remote Parent Path"
            }
         },
         "title": "FileLocData",
         "type": "object"
      }
   },
   "$ref": "#/$defs/FileLocData"
}

Fields:

as_rsync_arg() str[source]#

Return a string suitable to use as rsync argument.

Returns:

Rsync-compatible path string (local path or ‘host:path’)

Return type:

str

exists() bool[source]#

Check if file is local and exists.

Returns:

True if file is local and exists on filesystem

Return type:

bool

is_local() bool[source]#

Return True if file is local.

Returns:

True if file is on localhost

Return type:

bool

is_remote() bool[source]#

Return True if file is remote.

Returns:

True if file is on a remote host

Return type:

bool

property host: str#

The host.

Returns:

Host name or empty string for local

Return type:

str

property netloc: str#

The host.

Returns:

Network location (alias for host)

Return type:

str

property path: Path#

The path.

Returns:

Resolved file path

Return type:

Path

property path_orig: Path | None#

The original unresolved path.

Returns:

Original path before resolution, or None if not set

Return type:

Path | None

property scheme: str#

The URL scheme.

Returns:

URL scheme (e.g., ‘file’, ‘http’, ‘https’)

Return type:

str

property url: str#

The resolved URL string.

Returns:

Full resolved URL as string

Return type:

str