packages feed

gvti 0.1.1.1 → 0.2.0.0

raw patch · 6 files changed

+76/−54 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- GVTI: process2 :: String -> String -> String -> String -> String -> String -> IO ()
+ GVTI: process2 :: String -> String -> String -> String -> String -> String -> String -> IO ()

Files

ChangeLog.md view
@@ -12,4 +12,6 @@  * First version revised A. Some documentation improvements. +## 0.2.0.0 -- 2022-11-14 +* Second version. Added the possibility to specify your own list  of Char-delimiters (using -d option).
Formatting.hs view
@@ -38,8 +38,8 @@         ws = map (dropWhile (== ',')) rs         ll1s = map (length . filter (== x)) $ xss         !j2s = map (\wws -> fromMaybe 0 (readMaybe wws::Maybe Int)) js-	lls = zipWith (+) ll1s j2s+        lls = zipWith (+) ll1s j2s         !mx = maximum lls-	!ms = zipWith (\x k -> mx - x - k) ll1s j2s+        !ms = zipWith (\x k -> mx - x - k) ll1s j2s {-# INLINE formatLines #-} 
GVTI.hs view
@@ -42,6 +42,9 @@ isSep :: Char -> Bool isSep = (== ':') +isSepG :: String -> Char -> Bool+isSepG delims c = c `elem` delims+ -- | Returns @True@ if OS is Windows. isWindows :: Bool isWindows = take 5 os == "mingw"@@ -55,14 +58,17 @@ isEscapeChar :: Char -> Bool isEscapeChar x = x == '\n' || x == '\r' -dropEmptyLines :: [String] -> [String]-dropEmptyLines [] = []-dropEmptyLines (ys:yss)- | let ts = dropWhile isSep ys in all isEscapeChar ts || null ts = dropEmptyLines yss- | otherwise = ys:dropEmptyLines yss+dropEmptyLines :: String -> [String] -> [String]+dropEmptyLines _ [] = []+dropEmptyLines delims (ys:yss)+ | let ts = dropWhile (isSepG delims) ys in all isEscapeChar ts || null ts = dropEmptyLines delims yss+ | otherwise = ys:dropEmptyLines delims yss -cells :: String -> Array Int [String]-cells xs = amap (divideString isSep) . listArray (0,l) . dropEmptyLines . map (\rs -> if drop (length rs - 1) rs == "\r" then init rs else rs) $ yss+cells +  :: String -- ^ The list of 'Char' delimiters to be used.+  -> String +  -> Array Int [String] +cells delims xs = amap (divideString (isSepG delims)) . listArray (0,l) . dropEmptyLines delims . map (\rs -> if drop (length rs - 1) rs == "\r" then init rs else rs) $ yss   where (yss,l) = linesL1 xs {-# INLINE cells #-} @@ -80,8 +86,8 @@ processCells xs arr = makeRecordGv xs . convertElemsToStringGv . filterNeeded . changeNeededCells $ arr {-# INLINE processCells #-} -processCellsG :: String -> String -> String-processCellsG xs = processCells xs . cells+processCellsG :: String -> String -> String -> String+processCellsG delims xs = processCells xs . cells delims {-# INLINE processCellsG #-}  -- | Do not change the lengths of element lists@@ -151,18 +157,18 @@ -- executed to obtain a visualization file. The third argument is used for the 'getFormat'. The fourth argument is the -- basic name for the created files (without prefixes and extensions), the fifth one is an option for GraphVize splines -- functionality. The sixth argument is used to specify whether to remove at-signs from the created files.-process2 :: String -> String -> String -> String -> String -> String -> IO ()-process2 text xxs yys bnames splines remAts+process2 :: String -> String -> String -> String -> String -> String -> String -> IO ()+process2 delims xxs yys bnames splines remAts text   | length text > 0 = do       ts <- getCPUTime       [bnames1,splines1] <- proc2Params2 bnames splines       if remAts == "y"         then do-          let ys = filter (/='@') . processCellsG splines1 $ text in writeFile (show ts ++ "." ++ bnames1 ++ ".gv") ys+          let ys = filter (/='@') . processCellsG delims splines1 $ text in writeFile (show ts ++ "." ++ bnames1 ++ ".gv") ys           putStrLn "The visualization will be created without the at-sign."           processFile 'n' ts bnames1 xxs yys         else do-          let ys = processCellsG splines1 text in writeFile ("at." ++ show ts ++ "." ++ bnames1 ++ ".gv") ys+          let ys = processCellsG delims splines1 text in writeFile ("at." ++ show ts ++ "." ++ bnames1 ++ ".gv") ys           putStrLn "The visualization will be created with the at-sign preserved."           processFile 'a' ts bnames1 xxs yys   | otherwise = error "Empty text to be processed! "
Main.hs view
@@ -25,18 +25,21 @@   let args = filter (/= "-g") args00       arg0 = concat . take 1 $ args       arggs = drop 1 args-      xxs = concatMap (take 1 . drop 2) . filter ("-c" `isPrefixOf`) $ arggs-      yys = concatMap (take 2 . drop 2) . filter ("-f" `isPrefixOf`) $ arggs-      bnames = concatMap (drop 2) . filter ("-b" `isPrefixOf`) $ arggs-      splines = concatMap (take 1 . drop 2) . filter ("-s" `isPrefixOf`) $ arggs-      remAts = concatMap (take 1 . drop 1) . filter ("-y" `isPrefixOf`) $ arggs+      xxs = take 1 . drop 2 . concat . filter ("-c" `isPrefixOf`) $ arggs+      yys = take 2 . drop 2 . concat . filter ("-f" `isPrefixOf`) $ arggs+      bnames = drop 2 . concat . filter ("-b" `isPrefixOf`) $ arggs+      splines = take 1 . drop 2 . concat . filter ("-s" `isPrefixOf`) $ arggs+      remAts = take 1 . drop 1 . concat . filter ("-y" `isPrefixOf`) $ arggs       gvti = any (== "-g") args00+      delims +        | any ("-d" `isPrefixOf`) arggs =  drop 2 . concat . filter ("-d" `isPrefixOf`) $ arggs+        | otherwise = ":"   exI <- doesFileExist arg0   if exI      then do -      text2 <- readFile arg0+      text2 <- readFile arg0 -- well, in the future  this can be extended to also stdin.       let txt             | gvti = unlines  . formatLines ':' . filter (any (\x -> isLetter x || isDigit x)) . lines $ text2-	   | otherwise =  unlines . filter (any (\x -> isLetter x || isDigit x)) . lines $ text2-      process2 txt xxs yys bnames splines remAts+           | otherwise =  unlines . filter (any (\x -> isLetter x || isDigit x)) . lines $ text2+      process2 delims xxs yys bnames splines remAts txt     else putStrLn "No file specified exists in the current directory! "  
README.markdown view
@@ -1,6 +1,4 @@-             -             ***** Usage *****-             -----------------+## Usage  1. After installation the executable gvti is created.  Afterwards, it is used to process files. So, open an@@ -8,10 +6,19 @@    [LibreOffice Calc](https://libreoffice.org).    2. Begin to enter the text in the cells. You can use- Unicode characters. No quotation marks should be used,-  instead use some special delimiter except '@' sign.+ UTF-8 characters. No quotation marks should be used,+  instead use some special delimiter except '@' sign+  and (the list of) your delimiter(s).   -3. Do not use colons, instead when needed switch to the+3. The default delimiter is colon. But it is possible to +change it and use also several delimiters. Remember, that+using delimiter inside your textual input in the cells+will result afterwards in splitting the cell input +by the delimiter into different nodes in the visualization+graph and connecting them with an arrow. Remember also+that '@' sign is reserved as a highlighting symbol and,+therefore, should not be used as a delimiter either.+To specify the arrow between  the nodes, instead switch to the  nearest cell to the right.   4. To make a text visually highlighted (yellowish), start@@ -37,23 +44,26 @@      produce no reasonably useful output.       9. After entering all the text, export the sheet as a -  "*.csv" file using colons (':') as separator +  "*.csv" file using colons (':') as separator (if you would+  like to change this default value of the delimiter, then +  you  can do it, see the explanation for the -d... +  option)     in the working directory. Otherwise, the program        won’t work.        10. Run the appropriate executable gvti in the terminal -  or from the command line while being in the directory -    with the created .csv file. Specify as a command line -      argument its name. While executing a program enter -        a basic name of the file to be saved. DO use -          alphanumeric symbols and dashes if needed. -            Then specify the needed visualization scheme -              by specifying the appropriate character -                in the terminal and the format of the -                  resulting visualization file (refer to -                    GraphViz documentation for the default -                      list of formats). For more information, -                        see the +or from the command line while being in the directory +with the created .csv file. Specify as a command line +argument its name. While executing a program enter +a basic name of the file to be saved. DO use +alphanumeric symbols and dashes if needed. +Then specify the needed visualization scheme +by specifying the appropriate character +in the terminal and the format of the +resulting visualization file (refer to +GraphViz documentation for the default +list of formats). For more information, +see the    [GraphViz documentation](https://www.graphviz.org/documentation/).                  11. Your first visualization is then created.@@ -69,23 +79,27 @@    Then you can use the produced visualizations for some other       documents. -    ***** Usage of the Next Command Line Arguments after the First One *****+## Usage of the Next Command Line Arguments after the First One     ------------------------------------------------------------------------  gvti executable supports the following further  command lines arguments (given after the first one -- see above): +-b... — dots are instead of the basic name for the created files (the +name without prefixes and extensions)+ -c... — dots are instead of one letter to specify the first character    of the GraphViz command (e. g. \'n\' — for \'neato\') +-d... — (if present) means the list of Char's each of which is considered a delimiter instead of the+default ':'. Please, do not use here commas and numbers, otherwise, in the -g  mode the gvti+would not function properly. If omitted then it is considered just the default -d: that is the colon as a delimiter.+ -f... — dots are instead of two letters to specify the format (according to    the 'getFormat') of the GraphViz command (e. g. \'jp\' — for \'jpg\') -Besides, supports the following further -command line arguments (additionally to the previous ones):---b... — dots are instead of the basic name for the created files (the -name without prefixes and extensions)+-g — (if present) means that instead of the exporting from the spreadsheets,+you can use gvti specifications (see as an example the following).  -s... — dots are instead of one digit to specify the GraphViz splines  functionality. 0 — for "splines=false"; 1 — for "splines=true"; @@ -95,15 +109,12 @@ -y — (if present) means that the '@' signs will be removed from the created  files. --g — (if present) means that instead of the exporting from the spreadsheets,-you can use gvti specifications (see as an example the following).- They can be given in any combinations (if needed) or omitted. In the latter  one case the program will prompt you the needed information (but this is  not the case for a separator, which must be specified in such a way to be  used instead). -** Example of .gvti File Format Usage+## Example of .gvti File Format Usage  Create a file example.gvti @@ -165,6 +176,6 @@  Afterwards, you will have a visualization in the svg format in the directory. Here, it is: -https://hackage.haskell.org/package/gvti-0.1.1.1/src/4895040000.example.neato.gv.svg+https://hackage.haskell.org/package/gvti-0.2.0.0/src/4895040000.example.neato.gv.svg  
gvti.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                gvti-version:             0.1.1.1+version:             0.2.0.0 synopsis:            GraphViz Tabular Interface description:         Introduces a new file extension .gvti and is a special tabular or line-based GraphViz subset interface. Is a fork of the now deprecated mmsyn4 package. homepage:            https://hackage.haskell.org/package/gvti