Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3io.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
common
KM3io.jl
Commits
cbbcdfff
Verified
Commit
cbbcdfff
authored
1 year ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Workaround for multiline comments in DETX
parent
af58ad14
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hardware.jl
+23
-8
23 additions, 8 deletions
src/hardware.jl
with
23 additions
and
8 deletions
src/hardware.jl
+
23
−
8
View file @
cbbcdfff
...
...
@@ -441,9 +441,7 @@ end
Create a `Detector` instance from an ASCII IO stream using the DETX specification.
"""
function
read_detx
(
io
::
IO
)
lines
=
readlines
(
io
)
comments
=
_extract_comments
(
lines
,
DETECTOR_COMMENT_PREFIX
)
comments
,
lines
=
_split_comments
(
readlines
(
io
),
DETECTOR_COMMENT_PREFIX
)
filter!
(
e
->!
startswith
(
e
,
DETECTOR_COMMENT_PREFIX
)
&&
!
isempty
(
strip
(
e
)),
lines
)
...
...
@@ -557,22 +555,39 @@ end
"""
function _
extrac
t_comments(lines<:Vector{AbstractString}, prefix<:AbstractString)
function _
spli
t_comments(lines<:Vector{AbstractString}, prefix<:AbstractString)
Returns
only the lines which are comments,
identified by the `prefix`.
The prefix is
omitted.
Returns
a tuple of comments and content. Comment lines are
identified by the `prefix`.
The prefix is
omitted.
"""
function
_
extrac
t_comments
(
lines
::
Vector
{
T
},
prefix
::
T
)
where
{
T
<:
AbstractString
}
function
_
spli
t_comments
(
lines
::
Vector
{
T
},
prefix
::
T
)
where
{
T
<:
AbstractString
}
comments
=
String
[]
content
=
String
[]
prefix_length
=
length
(
prefix
)
# Multiline comments are not part of the specification but
# there are DETX containing such (introduced by Jpp).
# This feature is just a workaround until we define proper
# multiline comments for DETX/DATX v6+
multilinemode
=
false
for
line
∈
lines
if
multilinemode
if
length
(
findall
(
raw
"
\"
"
,
line
))
==
1
multilinemode
=
false
end
push!
(
comments
,
line
)
continue
end
if
startswith
(
line
,
prefix
)
comment
=
strip
(
line
[
prefix_length
+
1
:
end
])
if
length
(
findall
(
raw
"
\"
"
,
comment
))
==
1
multilinemode
=
true
end
push!
(
comments
,
comment
)
end
push!
(
content
,
line
)
end
comments
comments
,
content
end
...
...
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