Skip to main content

AppDirectoriesFinder

A static files finder that looks in the directory of each app as specified in the source_dir attribute.

Attributes

AttributeTypeDescription
storage_classclass = FileSystemStorageThe storage class used to instantiate storage instances for each discovered application directory.
source_dirstring = "static"The name of the subdirectory within each app where the finder looks for static files.

Constructor

Signature

def AppDirectoriesFinder(
app_names: list|set|null = None,
*args: any,
**kwargs: any
) - > null

Parameters

NameTypeDescription
app_names`listset
*argsanyVariable length argument list passed to the parent class constructor.
**kwargsanyArbitrary keyword arguments passed to the parent class constructor.

Signature

def AppDirectoriesFinder(
app_names: list = None
) - > null

Parameters

NameTypeDescription
app_nameslist = NoneAn optional list of specific application names to restrict the search to; if None, all installed apps are used.

Methods


list()

@classmethod
def list(
ignore_patterns: list
) - > generator

List all files in all app storages.

Parameters

NameTypeDescription
ignore_patternslistA list of glob patterns used to exclude specific files or directories from the resulting list.

Returns

TypeDescription
generatorA generator yielding tuples of the relative file path and the storage instance where the file was found.

find()

@classmethod
def find(
path: string,
find_all: boolean = False
) - > string|list

Look for files in the app directories.

Parameters

NameTypeDescription
pathstringThe relative path of the static file to locate within the app directories.
find_allboolean = FalseA flag determining whether to return the first match found or a list of all matches across all apps.

Returns

TypeDescription
`stringlist`

find_in_app()

@classmethod
def find_in_app(
app: string,
path: string
) - > string|null

Find a requested static file in an app's static locations.

Parameters

NameTypeDescription
appstringThe name of the application to search within.
pathstringThe relative path of the file to look for in the app's static storage.

Returns

TypeDescription
`stringnull`