Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8395573
test_mappings.py
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
779 B
Subscribers
None
test_mappings.py
View Options
import
os
import
os.path
import
pprint
from
swh.indexer.metadata_dictionary
import
MAPPINGS
BASE_DIR
=
os
.
path
.
expanduser
(
'~/datasets/'
)
CATEGORIES
=
{
(
'GemspecMapping'
,
'gemspec'
),
(
'PythonPkginfoMapping'
,
'pkginfo'
),
}
def
test_category
(
mapping_name
,
category
):
mapping
=
MAPPINGS
[
mapping_name
]
dataset_dir
=
os
.
path
.
join
(
BASE_DIR
,
category
)
for
filename
in
os
.
listdir
(
dataset_dir
):
path
=
os
.
path
.
join
(
dataset_dir
,
filename
)
with
open
(
path
,
'rb'
)
as
fd
:
file_content
=
fd
.
read
()
print
(
'Parsing {}:'
.
format
(
path
))
pprint
.
pprint
(
mapping
.
translate
(
file_content
))
def
main
():
for
(
mapping_name
,
category
)
in
CATEGORIES
:
test_category
(
mapping_name
,
category
)
if
__name__
==
'__main__'
:
main
()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jun 4 2025, 7:41 PM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3241140
Attached To
rDSNIP Code snippets
Event Timeline
Log In to Comment