Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mmt-errorView
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Maeder
mmt-errorView
Commits
1f6d48e2
Commit
1f6d48e2
authored
Jan 13, 2015
by
Christian Maeder
Browse files
Options
Downloads
Patches
Plain Diff
refactored parsing
parent
980e7ecf
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/ParseXML.scala
+19
-10
19 additions, 10 deletions
src/test/scala/ParseXML.scala
with
19 additions
and
10 deletions
src/test/scala/ParseXML.scala
+
19
−
10
View file @
1f6d48e2
...
...
@@ -14,29 +14,38 @@ object ParseXML {
val
xml
=
XML
.
loadFile
(
f
.
getPath
)
xml
\\
"error"
}
catch
{
case
e
:
SAXParseException
=>
Nil
case
e
:
SAXParseException
=>
println
(
e
.
getLineNumber
+
":"
+
e
.
getColumnNumber
)
Nil
}
}
def
getAttrs
(
attrs
:
List
[
String
],
x
:
Node
)
:
List
[
String
]
=
{
attrs
map
(
a
=>
(
x
\
(
"@"
+
a
)).
toString
())
val
as
=
x
.
attributes
attrs
map
(
a
=>
as
.
get
(
a
).
getOrElse
(
""
).
toString
)
}
def
traverse
(
dir
:
File
,
proc
:
File
=>
Unit
)
:
Unit
=
dir
.
listFiles
foreach
{
f
=>
if
(
f
.
isDirectory
)
traverse
(
f
,
proc
)
else
proc
(
f
)}
dir
.
listFiles
map
{
f
=>
if
(
f
.
isDirectory
)
traverse
(
f
,
proc
)
else
proc
(
f
)}
def
procFile
(
f
:
File
)
:
Unit
=
{
def
procFile
(
proc
:
(
File
,
Node
)
=>
Unit
)(
f
:
File
)
:
Unit
=
{
if
(
f
.
canRead
&&
f
.
getPath
.
endsWith
(
".err"
)
&&
f
.
length
()
>
0
)
{
val
errs
=
readXml
(
f
)
if
(
errs
.
isEmpty
)
println
(
"NOERR: "
+
f
)
else
errs
map
(
x
=>
{
else
errs
map
(
x
=>
procErr
(
f
,
x
))
}
}
def
procErr
(
f
:
File
,
x
:
Node
)
:
Unit
=
{
println
(
f
)
if
((
x
.
child
filter
(
c
=>
c
.
isInstanceOf
[
Elem
])).
isEmpty
)
{
getAttrs
(
List
(
"type"
,
"shortMsg"
,
"level"
),
x
)
map
println
println
(
x
.
text
)
}
)
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
dir
=
new
File
(
"/local/maeder/tptp/Distribution/errors"
)
traverse
(
dir
,
procFile
)
traverse
(
dir
,
procFile
(
procErr
)
)
}
}
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