Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional file ID to document state #198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions jupyter_ydoc/ybasedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ def path(self) -> Optional[str]:
"""
return self._ystate.get("path")

@property
def file_id(self) -> Optional[str]:
"""
Returns document's file ID.

:return: Document's file ID.
:rtype: Optional[str]
"""
return self._ystate.get("file_id")

@path.setter
def path(self, value: str) -> None:
"""
Expand All @@ -119,6 +129,16 @@ def path(self, value: str) -> None:
"""
self._ystate["path"] = value

@file_id.setter
def file_id(self, value: str) -> None:
"""
Sets document's file ID.

:param value: Document's file ID.
:type value: str
"""
self._ystate["file_id"] = value

@abstractmethod
def get(self) -> Any:
"""
Expand Down
2 changes: 1 addition & 1 deletion jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def set(self, value: Dict) -> None:
# clear document
self._ymeta.clear()
self._ycells.clear()
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path")]:
for key in [k for k in self._ystate.keys() if k not in ("dirty", "path", "file_id")]:
del self._ystate[key]

# initialize document
Expand Down
Loading