Skip to content

file_system

BucketFileSystemLocator dataclass

Source code in zendriver/cdp/file_system.py
@dataclass
class BucketFileSystemLocator:
    #: Storage key
    storage_key: storage.SerializedStorageKey

    #: Path to the directory using each path component as an array item.
    path_components: typing.List[str]

    #: Bucket name. Not passing a ``bucketName`` will retrieve the default Bucket. (https://developer.mozilla.org/en-US/docs/Web/API/Storage_API#storage_buckets)
    bucket_name: typing.Optional[str] = None

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["storageKey"] = self.storage_key.to_json()
        json["pathComponents"] = [i for i in self.path_components]
        if self.bucket_name is not None:
            json["bucketName"] = self.bucket_name
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> BucketFileSystemLocator:
        return cls(
            storage_key=storage.SerializedStorageKey.from_json(json["storageKey"]),
            path_components=[str(i) for i in json["pathComponents"]],
            bucket_name=str(json["bucketName"])
            if json.get("bucketName", None) is not None
            else None,
        )

bucket_name: typing.Optional[str] = None class-attribute instance-attribute

path_components: typing.List[str] instance-attribute

storage_key: storage.SerializedStorageKey instance-attribute

__init__(storage_key, path_components, bucket_name=None)

from_json(json) classmethod

Source code in zendriver/cdp/file_system.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> BucketFileSystemLocator:
    return cls(
        storage_key=storage.SerializedStorageKey.from_json(json["storageKey"]),
        path_components=[str(i) for i in json["pathComponents"]],
        bucket_name=str(json["bucketName"])
        if json.get("bucketName", None) is not None
        else None,
    )

to_json()

Source code in zendriver/cdp/file_system.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["storageKey"] = self.storage_key.to_json()
    json["pathComponents"] = [i for i in self.path_components]
    if self.bucket_name is not None:
        json["bucketName"] = self.bucket_name
    return json

Directory dataclass

Source code in zendriver/cdp/file_system.py
@dataclass
class Directory:
    name: str

    nested_directories: typing.List[str]

    #: Files that are directly nested under this directory.
    nested_files: typing.List[File]

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["name"] = self.name
        json["nestedDirectories"] = [i for i in self.nested_directories]
        json["nestedFiles"] = [i.to_json() for i in self.nested_files]
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> Directory:
        return cls(
            name=str(json["name"]),
            nested_directories=[str(i) for i in json["nestedDirectories"]],
            nested_files=[File.from_json(i) for i in json["nestedFiles"]],
        )

name: str instance-attribute

nested_directories: typing.List[str] instance-attribute

nested_files: typing.List[File] instance-attribute

__init__(name, nested_directories, nested_files)

from_json(json) classmethod

Source code in zendriver/cdp/file_system.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> Directory:
    return cls(
        name=str(json["name"]),
        nested_directories=[str(i) for i in json["nestedDirectories"]],
        nested_files=[File.from_json(i) for i in json["nestedFiles"]],
    )

to_json()

Source code in zendriver/cdp/file_system.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["name"] = self.name
    json["nestedDirectories"] = [i for i in self.nested_directories]
    json["nestedFiles"] = [i.to_json() for i in self.nested_files]
    return json

File dataclass

Source code in zendriver/cdp/file_system.py
@dataclass
class File:
    name: str

    #: Timestamp
    last_modified: network.TimeSinceEpoch

    #: Size in bytes
    size: float

    type_: str

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["name"] = self.name
        json["lastModified"] = self.last_modified.to_json()
        json["size"] = self.size
        json["type"] = self.type_
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> File:
        return cls(
            name=str(json["name"]),
            last_modified=network.TimeSinceEpoch.from_json(json["lastModified"]),
            size=float(json["size"]),
            type_=str(json["type"]),
        )

last_modified: network.TimeSinceEpoch instance-attribute

name: str instance-attribute

size: float instance-attribute

type_: str instance-attribute

__init__(name, last_modified, size, type_)

from_json(json) classmethod

Source code in zendriver/cdp/file_system.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> File:
    return cls(
        name=str(json["name"]),
        last_modified=network.TimeSinceEpoch.from_json(json["lastModified"]),
        size=float(json["size"]),
        type_=str(json["type"]),
    )

to_json()

Source code in zendriver/cdp/file_system.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["name"] = self.name
    json["lastModified"] = self.last_modified.to_json()
    json["size"] = self.size
    json["type"] = self.type_
    return json

get_directory(bucket_file_system_locator)

Parameters:

Name Type Description Default
bucket_file_system_locator BucketFileSystemLocator
required

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, Directory]

Returns the directory object at the path.

Source code in zendriver/cdp/file_system.py
def get_directory(
    bucket_file_system_locator: BucketFileSystemLocator,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, Directory]:
    """
    :param bucket_file_system_locator:
    :returns: Returns the directory object at the path.
    """
    params: T_JSON_DICT = dict()
    params["bucketFileSystemLocator"] = bucket_file_system_locator.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "FileSystem.getDirectory",
        "params": params,
    }
    json = yield cmd_dict
    return Directory.from_json(json["directory"])