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
3af96c18
Commit
3af96c18
authored
1 year ago
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Automatic log file comparison between parsers
parent
d868282f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tetras_extraction/macao_12/script/extract.py
+21
-6
21 additions, 6 deletions
tetras_extraction/macao_12/script/extract.py
tetras_extraction/macao_12/script/extract_page.py
+1
-1
1 addition, 1 deletion
tetras_extraction/macao_12/script/extract_page.py
with
22 additions
and
7 deletions
tetras_extraction/macao_12/script/extract.py
+
21
−
6
View file @
3af96c18
import
filecmp
from
pprint
import
pprint
from
typing
import
Optional
...
...
@@ -122,18 +123,32 @@ def parse_manifest_rec(
extract_mosetp
.
parse_mosetp
(
graph
,
f
"
{
SOURCE_DIR
}
/sco/
{
id
}
.html
"
,
id
)
import
extract_page
def
compare_files
(
f1
,
f2
):
print
(
"
Files {} and {} {}.
"
.
format
(
f1
,
f2
,
"
are identical
"
if
filecmp
.
cmp
(
f1
,
f2
)
else
"
differ
"
)
)
def
main
():
g
=
create_graph
()
# Create or reset debug log files for all activity parsers, to compare their
# results afterwards
parsers
=
(
"
Match
"
,
"
Xpath
"
,
"
Regex
"
)
logfiles
=
[
f
"
/tmp/
{
p
}
Parser_debuglog.txt
"
for
p
in
parsers
]
for
logfile
in
logfiles
:
with
open
(
logfile
,
"
w
"
)
as
f
:
print
(
""
,
file
=
f
)
parse_manifest
(
g
)
export_graph
(
g
)
# extract_page.parse_page(
#
g,
# f"{SOURCE_DIR}/contenu/pages/pg60.html",
# "pg60",
#
)
#
Compare log files 2 by 2
compare_files
(
logfiles
[
0
],
logfiles
[
1
])
compare_files
(
logfiles
[
0
],
logfiles
[
2
])
compare_files
(
logfiles
[
1
],
logfiles
[
2
]
)
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
tetras_extraction/macao_12/script/extract_page.py
+
1
−
1
View file @
3af96c18
...
...
@@ -301,7 +301,7 @@ def parse_page(graph: Graph, filepath: str, id: str):
# Try different parsers, each writing to a different file to compare their results
for
parser
in
[
XpathParser
(),
MatchParser
(
graph
,
id
),
RegexParser
(
graph
,
id
)]:
with
open
(
f
"
/tmp/
{
str
(
parser
)
}
.txt
"
,
"
a
"
)
as
f
:
with
open
(
f
"
/tmp/
{
str
(
parser
)
}
_debuglog
.txt
"
,
"
a
"
)
as
f
:
print
(
f
"
{
id
:
8
}
"
,
end
=
""
,
file
=
f
)
try
:
parser
.
parse
(
js
,
output
=
f
)
...
...
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