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