Skip to content
Snippets Groups Projects
Commit ee058855 authored by Thibault Allançon's avatar Thibault Allançon
Browse files

fs: move ArtifactEntry class to artifact.py

parent 3c79873a
No related branches found
Tags debian/upstream/0.6.3
No related merge requests found
......@@ -5,18 +5,36 @@
from typing import Any, AsyncIterator
from swh.fuse.fs.entry import ArtifactEntry, EntryMode
from swh.fuse.fs.entry import EntryMode, FuseEntry
from swh.model.identifiers import CONTENT, DIRECTORY, SWHID
# Avoid cycling import
Fuse = "Fuse"
def typify(name: str, mode: int, fuse: Fuse, swhid: SWHID, prefetch: Any = None) -> Any:
class ArtifactEntry(FuseEntry):
""" FUSE virtual entry for a Software Heritage Artifact
Attributes:
swhid: Software Heritage persistent identifier
prefetch: optional prefetched metadata used to set entry attributes
"""
def __init__(
self, name: str, mode: int, fuse: Fuse, swhid: SWHID, prefetch: Any = None
):
super().__init__(name, mode, fuse)
self.swhid = swhid
self.prefetch = prefetch
def typify(
name: str, mode: int, fuse: Fuse, swhid: SWHID, prefetch: Any = None
) -> ArtifactEntry:
""" Create an artifact entry corresponding to the given artifact type """
constructor = {CONTENT: Content, DIRECTORY: Directory}
return constructor[swhid.object_type](name, mode, fuse, swhid, prefetch)
getters = {CONTENT: Content, DIRECTORY: Directory}
return getters[swhid.object_type](name, mode, fuse, swhid, prefetch)
class Content(ArtifactEntry):
......
......@@ -5,9 +5,6 @@
from enum import IntEnum
from stat import S_IFDIR, S_IFREG
from typing import Any
from swh.model.identifiers import SWHID
# Avoid cycling import
Fuse = "Fuse"
......@@ -49,19 +46,3 @@ class FuseEntry:
async def __aiter__(self):
return None
class ArtifactEntry(FuseEntry):
""" FUSE virtual entry for a Software Heritage Artifact
Attributes:
swhid: Software Heritage persistent identifier
prefetch: optional prefetched metadata used to set entry attributes
"""
def __init__(
self, name: str, mode: int, fuse: Fuse, swhid: SWHID, prefetch: Any = None
):
super().__init__(name, mode, fuse)
self.swhid = swhid
self.prefetch = prefetch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment