Revision 79eef90b htools/Ganeti/HTools/Utils.hs
b/htools/Ganeti/HTools/Utils.hs | ||
---|---|---|
31 | 31 |
, select |
32 | 32 |
, applyIf |
33 | 33 |
, commaJoin |
34 |
, ensureQuoted |
|
34 | 35 |
, tryRead |
35 | 36 |
, formatTable |
36 | 37 |
, printTable |
... | ... | |
42 | 43 |
, exitUnless |
43 | 44 |
) where |
44 | 45 |
|
45 |
import Data.Char (toUpper) |
|
46 |
import Data.Char (toUpper, isAlphaNum)
|
|
46 | 47 |
import Data.List |
47 | 48 |
|
48 | 49 |
import Debug.Trace |
... | ... | |
91 | 92 |
plural 1 s _ = s |
92 | 93 |
plural _ _ p = p |
93 | 94 |
|
95 |
-- | Ensure a value is quoted if needed. |
|
96 |
ensureQuoted :: String -> String |
|
97 |
ensureQuoted v = if not (all (\c -> isAlphaNum c || c == '.') v) |
|
98 |
then '\'':v ++ "'" |
|
99 |
else v |
|
100 |
|
|
94 | 101 |
-- * Mathematical functions |
95 | 102 |
|
96 | 103 |
-- Simple and slow statistical functions, please replace with better |
Also available in: Unified diff