FileContent
¶
- class starlark_tugger.FileContent¶
This type represents the content of a single file.
Instances essentially track the following:
The content of a file (either a reference to a filesystem path or in-memory data).
Whether the file is executable.
The filename associated with the content. This is just the file name: directory components are not allowed.
Unfortunately, since Starlark doesn’t expose a
bytes
type, we are unable to expose the raw content tracked by instances of this type.- executable¶
(
bool
)Whether a materialized file should be marked as executable.
- filename¶
(
str
)The filename associated with this instance.
This is just the filename.
- __init__(path: Optional[str] = None, filename: Optional[str] = None, content: Optional[str] = None, executable: Optional[bool] = None) FileContent ¶
Construct a new instance given an existing filesystem
path
or stringcontent
.1 of
path
orcontent
must be provided to define the content tracked by this instance.If
content
is provided,filename
must also be provided.filename
must be just a file name: no directory components are allowed.If
path
is provided, it must refer to an existing filesystem path or an error will occur. Relative paths are interpreted as relative to the globalCWD
variable. Absolute paths are used as-is.If
path
is provided, by defaultfilename
andexecutable
will be resolved from the given path. However, if thefilename
orexecutable
arguments are notNone
, their values will be override those derived frompath
.If
content
is provided andexecutable
is not,executable
defaults toFalse
.