jgdv.structs.locator.location

Classes

Location

A Location is an abstraction higher than a path.

Module Contents

class jgdv.structs.locator.location.Location(*args, **kwargs)[source]

Bases: jgdv.structs.strang.Strang

A Location is an abstraction higher than a path.

ie: a path, with metadata.

Doesn’t expand on its own, requires a JGDVLocator store

It is a Strang subclass, of the form “{meta}+::a/path/location”. eg:

file/clean::.temp/docs/blah.rst

TODO use annotations to require certain metaflags. eg:

ProtectedLoc = Location['protect']
Cleanable    = Location['clean']
FileLoc      = Location['file']

TODO add an ExpandedLoc subclass that holds the expanded path, and removes the need for much of PathManip_m?

TODO add a ShadowLoc subclass using annotations eg:

BackupTo           = ShadowLoc[root='/vols/BackupSD']
a_loc              = BackupTo('file::a/b/c.mp3')
a_loc.path_pair() -> ('/vols/BackupSD/a/b/c.mp3', '~/a/b/c.mp3')
check_wildcards(other) <Unknown>[source]

Return True if other is within self, accounting for wildcards

Parameters:

other (pathlib.Path | jgdv.structs.locator._interface.Location_p)

Return type:

bool

ext(*, last=False) <Unknown>[source]

return the ext, or a tuple of how it is a wildcard. returns nothing if theres no extension, returns all suffixes if there are multiple, or just the last if last=True

Parameters:

last (bool)

Return type:

jgdv.Maybe[str | tuple[jgdv.structs.locator._interface.WildCard_e, str]]

is_concrete() <Unknown>[source]
Return type:

bool

Marks: ClassVar
Wild: ClassVar
_processor: ClassVar
_sections: ClassVar
property body_parent: list[str | jgdv.structs.locator._interface.WildCard_e][source]
Return type:

list[str | jgdv.structs.locator._interface.WildCard_e]

property key: jgdv.Maybe[str | jgdv.structs.locator._interface.Key_p][source]
Abstractmethod:

Return type:

jgdv.Maybe[str | jgdv.structs.locator._interface.Key_p]

property keys: set[str][source]
Abstractmethod:

Return type:

set[str]

property path: pathlib.Path[source]
Return type:

pathlib.Path

property stem: jgdv.Maybe[str | tuple[jgdv.structs.locator._interface.WildCard_e, str]][source]

Return the stem, or a tuple describing how it is a wildcard

Return type:

jgdv.Maybe[str | tuple[jgdv.structs.locator._interface.WildCard_e, str]]