mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-07-05 02:59:25 +09:00
refactor: rename files which define modules
This commit is contained in:
parent
f8df4932db
commit
c02531442d
5 changed files with 4 additions and 4 deletions
61
src/QaqcMasterLog.jl
Normal file
61
src/QaqcMasterLog.jl
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""
|
||||
Module for QAQC master log parser.
|
||||
"""
|
||||
module QaqcMasterLog
|
||||
|
||||
using Dates
|
||||
|
||||
"""
|
||||
Metadata(not results) of QAQC run from master log.
|
||||
|
||||
# Fields
|
||||
- `timestamp`: in UTC
|
||||
- `runid`
|
||||
- `shifters`
|
||||
- `shiftscript_version::VersionNumber`
|
||||
"""
|
||||
struct QaqcMasterLogMetadata
|
||||
timestamp::DateTime
|
||||
runid::Int64
|
||||
shifters::String
|
||||
shiftscript_version::VersionNumber
|
||||
end
|
||||
|
||||
"""
|
||||
parse_master_log(logfile::AbstractString)
|
||||
|
||||
Parse master log.
|
||||
If the `logfile` is empty, return `nothing`.
|
||||
"""
|
||||
function parse_master_log(logfile::AbstractString)
|
||||
open(logfile) do f
|
||||
first_line = readline(f)
|
||||
if isempty(first_line)
|
||||
@debug "file $(logfile) is empty"
|
||||
@assert read(logfile) |> isempty
|
||||
return nothing
|
||||
end
|
||||
shiftscript_version = split(first_line) |> last |> VersionNumber
|
||||
|
||||
@assert readline(f) |> contains("-----")
|
||||
|
||||
date_line = readline(f)
|
||||
@assert date_line |> split |> first |> contains("Date")
|
||||
date_part = split(date_line) |> last
|
||||
datetime, timezone = split(date_part, '+')
|
||||
@assert timezone == "0000" "Unexpected timestamp: timezone is not UTC"
|
||||
# Maybe use ZonedDateTime here
|
||||
timestamp = datetime |> DateTime
|
||||
|
||||
runid_line = readline(f)
|
||||
runid = parse(Int64, runid_line |> split |> last)
|
||||
|
||||
shifters_line = readline(f)
|
||||
@assert shifters_line |> split |> first |> contains("Shifters")
|
||||
shifters = shifters_line |> split |> last
|
||||
|
||||
return QaqcMasterLogMetadata(timestamp, runid, shifters, shiftscript_version)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue