Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9313696
model.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
model.py
View Options
import
os
from
.archive
import
ArchiveInterface
from
pathlib
import
PosixPath
# class Tree:
# def __init__(self, archive: ArchiveInterface, id: bytes):
# self.root = DirectoryEntry(archive, id, PosixPath('.'))
class
TreeEntry
:
def
__init__
(
self
,
id
:
bytes
,
name
:
PosixPath
):
self
.
id
=
id
self
.
name
=
name
class
DirectoryEntry
(
TreeEntry
):
def
__init__
(
self
,
archive
:
ArchiveInterface
,
id
:
bytes
,
name
:
PosixPath
):
super
()
.
__init__
(
id
,
name
)
self
.
archive
=
archive
self
.
children
=
None
def
__iter__
(
self
):
if
self
.
children
is
None
:
self
.
children
=
[]
for
child
in
self
.
archive
.
directory_ls
(
self
.
id
):
if
child
[
'type'
]
==
'dir'
:
self
.
children
.
append
(
DirectoryEntry
(
self
.
archive
,
child
[
'target'
],
PosixPath
(
os
.
fsdecode
(
child
[
'name'
]))
))
elif
child
[
'type'
]
==
'file'
:
self
.
children
.
append
(
FileEntry
(
child
[
'target'
],
PosixPath
(
os
.
fsdecode
(
child
[
'name'
]))
))
return
iter
(
self
.
children
)
class
FileEntry
(
TreeEntry
):
pass
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Jul 3, 11:51 AM (5 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3242170
Attached To
rDPROV Provenance database
Event Timeline
Log In to Comment