Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Macao Legacy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MACAO
Macao Legacy
Commits
c9d7b51d
Commit
c9d7b51d
authored
1 year ago
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Minor type annotation fix
parent
41c6c727
Branches
Branches containing commit
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tetras_extraction/macao_12/script/extract.py
+11
-3
11 additions, 3 deletions
tetras_extraction/macao_12/script/extract.py
with
11 additions
and
3 deletions
tetras_extraction/macao_12/script/extract.py
+
11
−
3
View file @
c9d7b51d
...
@@ -40,21 +40,21 @@ def export_graph(g: Graph):
...
@@ -40,21 +40,21 @@ def export_graph(g: Graph):
print
(
f
"
Exported
{
len
(
g
)
}
triples to
{
RESULT_FILE
}
.
"
)
print
(
f
"
Exported
{
len
(
g
)
}
triples to
{
RESULT_FILE
}
.
"
)
def
ns_find
(
elem
:
etree
.
Element
Base
,
query
:
str
):
def
ns_find
(
elem
:
etree
.
_
Element
,
query
:
str
):
"""
Wrapper for lxml
'
s `find()` function that automatically uses the default
"""
Wrapper for lxml
'
s `find()` function that automatically uses the default
namespace for all unprefixed tag names.
namespace for all unprefixed tag names.
"""
"""
return
elem
.
find
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
return
elem
.
find
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
def
ns_findall
(
elem
:
etree
.
Element
Base
,
query
:
str
):
def
ns_findall
(
elem
:
etree
.
_
Element
,
query
:
str
):
"""
Wrapper for lxml
'
s `findall()` function that automatically uses the default
"""
Wrapper for lxml
'
s `findall()` function that automatically uses the default
namespace for all unprefixed tag names.
namespace for all unprefixed tag names.
"""
"""
return
elem
.
findall
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
return
elem
.
findall
(
query
,
namespaces
=
{
""
:
elem
.
nsmap
[
None
]})
def
ns_localname
(
elem
:
etree
.
Element
Base
)
->
str
:
def
ns_localname
(
elem
:
etree
.
_
Element
)
->
str
:
"""
Get an element
'
s local name, stripping the namespace.
"""
"""
Get an element
'
s local name, stripping the namespace.
"""
return
etree
.
QName
(
elem
).
localname
return
etree
.
QName
(
elem
).
localname
...
@@ -119,10 +119,18 @@ def parse_manifest_rec(
...
@@ -119,10 +119,18 @@ def parse_manifest_rec(
extract_mosetp
.
parse_mosetp
(
graph
,
f
"
{
SOURCE_DIR
}
/sco/
{
id
}
.html
"
,
id
)
extract_mosetp
.
parse_mosetp
(
graph
,
f
"
{
SOURCE_DIR
}
/sco/
{
id
}
.html
"
,
id
)
import
extract_page
def
main
():
def
main
():
g
=
create_graph
()
g
=
create_graph
()
parse_manifest
(
g
)
parse_manifest
(
g
)
export_graph
(
g
)
export_graph
(
g
)
# extract_page.parse_page(
# g,
# f"{SOURCE_DIR}/contenu/pages/pg60.html",
# "pg60",
# )
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment