Handle dot decimal separator in parameters
This commit is contained in:
parent
e4128212b1
commit
b419aa7b08
@ -73,6 +73,7 @@ library
|
||||
, pcre-heavy
|
||||
, process
|
||||
, uri-encode
|
||||
, MissingH
|
||||
default-language: Haskell2010
|
||||
|
||||
executable geval
|
||||
|
@ -1,4 +1,5 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module GEval.ParseParams(parseParamsFromFilePath,
|
||||
parseParamsFromSourceSpec,
|
||||
@ -9,6 +10,12 @@ import Data.Map.Strict as M
|
||||
import Data.Text
|
||||
import Data.Attoparsec.Text
|
||||
|
||||
import Text.Regex.PCRE.Heavy
|
||||
|
||||
import Data.Monoid ((<>))
|
||||
|
||||
import qualified Data.String.Utils as DSU
|
||||
|
||||
import System.FilePath
|
||||
|
||||
import Data.Conduit.SmartSource (SourceSpec(..), recoverPath)
|
||||
@ -22,7 +29,17 @@ parseParamsFromSourceSpec spec = OutputFileParsed (recoverPath spec) M.empty
|
||||
|
||||
parseParamsFromFilePath :: FilePath -> OutputFileParsed
|
||||
parseParamsFromFilePath filePath = parseParamsFromBaseName fileBaseName
|
||||
where fileBaseName = dropExtensions $ takeBaseName filePath
|
||||
where fileBaseName = backDecimalSeparator $ dropExtensions $ hideDecimalSeparator $ takeBaseName filePath
|
||||
|
||||
dotReplacement :: Char
|
||||
dotReplacement = '•'
|
||||
|
||||
hideDecimalSeparator :: String -> String
|
||||
hideDecimalSeparator = gsub [re|([0-9])\.([0-9])|] (\(a:b:_) -> a <> [dotReplacement] <> b)
|
||||
|
||||
backDecimalSeparator :: String -> String
|
||||
backDecimalSeparator = DSU.replace [dotReplacement] "."
|
||||
|
||||
|
||||
parseParamsFromBaseName :: FilePath -> OutputFileParsed
|
||||
parseParamsFromBaseName baseName = case parseOnly (parser <* endOfInput) (pack baseName) of
|
||||
|
Loading…
Reference in New Issue
Block a user