packages feed

hledger-lib 1.19 → 1.19.1

raw patch · 7 files changed

+47/−19 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hledger.Data.AccountName: accountNameToAccountOnlyRegexCI :: AccountName -> Regexp
+ Hledger.Data.AccountName: accountNameToAccountRegexCI :: AccountName -> Regexp

Files

CHANGES.md view
@@ -1,6 +1,17 @@ Internal/api/developer-ish changes in the hledger-lib (and hledger) packages. For user-visible changes, see the hledger package changelog. +# 1.19.1 2020-09-07++- Allow megaparsec 9++- stripAnsi: correctly strip ansi sequences with no+  numbers/semicolons. (Stephen Morgan)++- Added case-insensitive accountNameToAccountRegexCI,+  accountNameToAccountOnlyRegexCI, made the default account type+  queries case insensitive again. (#1341)+ # 1.19 2020-09-01  - Added a missing lower bound for aeson, making cabal installs more
Hledger/Data/AccountName.hs view
@@ -16,7 +16,9 @@   ,accountNameFromComponents   ,accountNameLevel   ,accountNameToAccountOnlyRegex+  ,accountNameToAccountOnlyRegexCI   ,accountNameToAccountRegex+  ,accountNameToAccountRegexCI   ,accountNameTreeFrom   ,accountSummarisedName   ,acctsep@@ -218,9 +220,19 @@ accountNameToAccountRegex :: AccountName -> Regexp accountNameToAccountRegex a = toRegex' $ '^' : escapeName a ++ "(:|$)"  -- PARTIAL: Is this safe after escapeName? +-- | Convert an account name to a regular expression matching it and its subaccounts,+-- case insensitively.+accountNameToAccountRegexCI :: AccountName -> Regexp+accountNameToAccountRegexCI a = toRegexCI' $ '^' : escapeName a ++ "(:|$)"  -- PARTIAL: Is this safe after escapeName?+ -- | Convert an account name to a regular expression matching it but not its subaccounts. accountNameToAccountOnlyRegex :: AccountName -> Regexp accountNameToAccountOnlyRegex a = toRegex' $ '^' : escapeName a ++ "$" -- PARTIAL: Is this safe after escapeName?++-- | Convert an account name to a regular expression matching it but not its subaccounts,+-- case insensitively.+accountNameToAccountOnlyRegexCI :: AccountName -> Regexp+accountNameToAccountOnlyRegexCI a = toRegexCI' $ '^' : escapeName a ++ "$" -- PARTIAL: Is this safe after escapeName?  -- -- | Does this string look like an exact account-matching regular expression ? --isAccountRegex  :: String -> Bool
Hledger/Data/Amount.hs view
@@ -439,8 +439,7 @@     fromInteger i = Mixed [fromInteger i]     negate (Mixed as) = Mixed $ map negate as     (+) (Mixed as) (Mixed bs) = normaliseMixedAmount $ Mixed $ as ++ bs-    -- PARTIAL:-    (*)    = error' "error, mixed amounts do not support multiplication"+    (*)    = error' "error, mixed amounts do not support multiplication" -- PARTIAL:     abs    = error' "error, mixed amounts do not support abs"     signum = error' "error, mixed amounts do not support signum" 
Hledger/Data/Journal.hs view
@@ -300,7 +300,7 @@ -- or otherwise for accounts with names matched by the case-insensitive  -- regular expression @^assets?(:|$)@. journalAssetAccountQuery :: Journal -> Query-journalAssetAccountQuery = journalAccountTypeQuery [Asset,Cash] (toRegex' "^assets?(:|$)")+journalAssetAccountQuery = journalAccountTypeQuery [Asset,Cash] (toRegexCI' "^assets?(:|$)")  -- | A query for "Cash" (liquid asset) accounts in this journal, ie accounts -- declared as Cash by account directives, or otherwise with names matched by the @@ -309,7 +309,7 @@ journalCashAccountQuery  :: Journal -> Query journalCashAccountQuery j =   case M.lookup Cash (jdeclaredaccounttypes j) of-    Nothing -> And [ journalAssetAccountQuery j, Not . Acct $ toRegex' "(investment|receivable|:A/R|:fixed)" ]+    Nothing -> And [ journalAssetAccountQuery j, Not . Acct $ toRegexCI' "(investment|receivable|:A/R|:fixed)" ]     Just _  -> journalAccountTypeQuery [Cash] notused j       where notused = error' "journalCashAccountQuery: this should not have happened!"  -- PARTIAL: @@ -318,28 +318,28 @@ -- accounts with names matched by the case-insensitive regular expression -- @^(debts?|liabilit(y|ies))(:|$)@. journalLiabilityAccountQuery :: Journal -> Query-journalLiabilityAccountQuery = journalAccountTypeQuery [Liability] (toRegex' "^(debts?|liabilit(y|ies))(:|$)")+journalLiabilityAccountQuery = journalAccountTypeQuery [Liability] (toRegexCI' "^(debts?|liabilit(y|ies))(:|$)")  -- | A query for accounts in this journal which have been -- declared as Equity by account directives, or otherwise for -- accounts with names matched by the case-insensitive regular expression -- @^equity(:|$)@. journalEquityAccountQuery :: Journal -> Query-journalEquityAccountQuery = journalAccountTypeQuery [Equity] (toRegex' "^equity(:|$)")+journalEquityAccountQuery = journalAccountTypeQuery [Equity] (toRegexCI' "^equity(:|$)")  -- | A query for accounts in this journal which have been -- declared as Revenue by account directives, or otherwise for -- accounts with names matched by the case-insensitive regular expression -- @^(income|revenue)s?(:|$)@. journalRevenueAccountQuery :: Journal -> Query-journalRevenueAccountQuery = journalAccountTypeQuery [Revenue] (toRegex' "^(income|revenue)s?(:|$)")+journalRevenueAccountQuery = journalAccountTypeQuery [Revenue] (toRegexCI' "^(income|revenue)s?(:|$)")  -- | A query for accounts in this journal which have been -- declared as Expense by account directives, or otherwise for -- accounts with names matched by the case-insensitive regular expression -- @^expenses?(:|$)@. journalExpenseAccountQuery  :: Journal -> Query-journalExpenseAccountQuery = journalAccountTypeQuery [Expense] (toRegex' "^expenses?(:|$)")+journalExpenseAccountQuery = journalAccountTypeQuery [Expense] (toRegexCI' "^expenses?(:|$)")  -- | A query for Asset, Liability & Equity accounts in this journal. -- Cf <http://en.wikipedia.org/wiki/Chart_of_accounts#Balance_Sheet_Accounts>.
Hledger/Utils/Regex.hs view
@@ -193,7 +193,7 @@               case read s of n | n `elem` indices grps -> Right $ fst (grps ! n)                              _                         -> Left $ "no match group exists for backreference \"\\"++s++"\""             lookupMatchGroup _ s = Left $ "lookupMatchGroup called on non-numeric-backreference \""++s++"\", shouldn't happen"-    backrefRegex = toRegex' "\\\\[0-9]+"  -- PARTIAL: should not happen+    backrefRegex = toRegex' "\\\\[0-9]+"  -- PARTIAL: should not fail  -- regexReplace' :: Regexp -> Replacement -> String -> String -- regexReplace' re repl s =@@ -213,7 +213,7 @@ --               -- PARTIAL: --                              _                         -> error' $ "no match group exists for backreference \"\\"++s++"\"" --             lookupMatchGroup _ s = error' $ "lookupMatchGroup called on non-numeric-backreference \""++s++"\", shouldn't happen"---     backrefRegex = toRegex' "\\\\[0-9]+"  -- PARTIAL: should not error happen+--     backrefRegex = toRegex' "\\\\[0-9]+"  -- PARTIAL: should not fail   -- helpers
Hledger/Utils/String.hs view
@@ -50,8 +50,8 @@  import Data.Char (isDigit, isSpace, toLower, toUpper) import Data.List (intercalate, transpose)-import Text.Megaparsec (Parsec, (<|>), (<?>), between, many, noneOf, oneOf,-                        parseMaybe, sepBy, takeWhile1P)+import Text.Megaparsec (Parsec, (<|>), (<?>), anySingle, between, many, noneOf,+                        oneOf, parseMaybe, sepBy, takeWhileP, try) import Text.Megaparsec.Char (char, string) import Text.Printf (printf) @@ -337,12 +337,18 @@ strWidth :: String -> Int strWidth = maximum . (0:) . map (foldr (\a b -> charWidth a + b) 0) . lines . stripAnsi +-- | Strip ANSI escape sequences from a string.+--+-- >>> stripAnsi "\ESC[31m-1\ESC[m"+-- "-1" stripAnsi :: String -> String-stripAnsi s = maybe s concat $ parseMaybe (many $ takeWhile1P Nothing (/='\ESC') <|> "" <$ ansi) s+stripAnsi s = case parseMaybe (many $ "" <$ try ansi <|> pure <$> anySingle) s of+    Nothing -> error "Bad ansi escape"  -- PARTIAL: should not happen+    Just xs -> concat xs   where     -- This parses lots of invalid ANSI escape codes, but that should be fine     ansi = string "\ESC[" *> digitSemicolons *> suffix <?> "ansi" :: Parsec CustomErr String Char-    digitSemicolons = takeWhile1P Nothing (\c -> isDigit c || c == ';')+    digitSemicolons = takeWhileP Nothing (\c -> isDigit c || c == ';')     suffix = oneOf ['A', 'B', 'C', 'D', 'H', 'J', 'K', 'f', 'm', 's', 'u']  -- | Get the designated render width of a character: 0 for a combining
hledger-lib.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 562b07c743e67f55f539704cf37da021e6ec23c3b47b3bc3f673875b1feb256f+-- hash: 4cff01322093c9a60a07a65c0ed150394360e71104dd3e7b52fc6782c5cf5a57  name:           hledger-lib-version:        1.19+version:        1.19.1 synopsis:       A reusable library providing the core functionality of hledger description:    A reusable library containing hledger's core functionality.                 This is used by most hledger* packages so that they support the same@@ -130,7 +130,7 @@     , file-embed >=0.0.10     , filepath     , hashtables >=1.2.3.1-    , megaparsec >=7.0.0 && <8.1+    , megaparsec >=7.0.0 && <9.1     , mtl >=2.2.1     , old-time     , parsec >=3@@ -183,7 +183,7 @@     , file-embed >=0.0.10     , filepath     , hashtables >=1.2.3.1-    , megaparsec >=7.0.0 && <8.1+    , megaparsec >=7.0.0 && <9.1     , mtl >=2.2.1     , old-time     , parsec >=3@@ -238,7 +238,7 @@     , filepath     , hashtables >=1.2.3.1     , hledger-lib-    , megaparsec >=7.0.0 && <8.1+    , megaparsec >=7.0.0 && <9.1     , mtl >=2.2.1     , old-time     , parsec >=3