mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-07 12:15:46 +03:00
support tools cleanup
This commit is contained in:
parent
f27e96d4a7
commit
34ebd9e3df
2
Makefile
2
Makefile
@ -27,7 +27,7 @@ test:
|
||||
@./hledger.hs test
|
||||
@./regtest.py
|
||||
|
||||
haddock:
|
||||
docs haddock:
|
||||
haddock -h -o doc *.hs
|
||||
|
||||
overview:
|
||||
|
54
data/test.dat
Normal file
54
data/test.dat
Normal file
@ -0,0 +1,54 @@
|
||||
; test ledger
|
||||
; set up this account tree:
|
||||
;
|
||||
; assets
|
||||
; cash
|
||||
; checking
|
||||
; saving
|
||||
; equity
|
||||
; expenses
|
||||
; food
|
||||
; shelter
|
||||
; income
|
||||
; salary
|
||||
; liabilities
|
||||
; debts
|
||||
|
||||
2007/01/01 * save
|
||||
assets:saving $1000
|
||||
equity
|
||||
|
||||
2007/01/01 * eat
|
||||
assets:cash
|
||||
expenses:food $1
|
||||
|
||||
2007/01/01 * hide
|
||||
expenses:shelter $1
|
||||
assets:cash
|
||||
|
||||
2007/01/20 * test
|
||||
expenses:food $1
|
||||
assets:cash:petty
|
||||
|
||||
2007/01/21 * atm
|
||||
assets:cash $40.00
|
||||
expenses:banking $2.00
|
||||
expenses:banking $2.00
|
||||
assets:checking $-44.00
|
||||
|
||||
2007/01/22 * test xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
|
||||
assets:checking $10 ; xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
|
||||
expenses:food xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx $1234567890
|
||||
income:salary
|
||||
|
||||
; 2007/01/23 * test
|
||||
; assets:fruit APPLES1
|
||||
; assets:cash
|
||||
|
||||
2007/01/24 * test
|
||||
liabilities:debts $1.
|
||||
assets:checking
|
||||
|
||||
2007/01/25 * test
|
||||
liabilities:debts $2.00
|
||||
assets:checking ;test 3
|
8
data/test1.dat
Normal file
8
data/test1.dat
Normal file
@ -0,0 +1,8 @@
|
||||
2007/01/21 * test
|
||||
expenses:shelter $1
|
||||
assets:cash
|
||||
|
||||
2007/01/22 * test xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
|
||||
assets:checking $10 ; xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
|
||||
expenses:food xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx $1234567890
|
||||
income:salary
|
6
data/test2.dat
Normal file
6
data/test2.dat
Normal file
@ -0,0 +1,6 @@
|
||||
2007/01/01 * atm
|
||||
assets:cash $40.00
|
||||
expenses:banking $2.00
|
||||
expenses:banking $2.00
|
||||
assets:checking
|
||||
|
60
tools/listbydeps.hs
Normal file
60
tools/listbydeps.hs
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
|
||||
import System
|
||||
import System.Directory
|
||||
import IO
|
||||
import Data.List
|
||||
import Data.Char
|
||||
import Data.Maybe
|
||||
import Data.Ord
|
||||
|
||||
{-
|
||||
Read a Haskell *.hs file and get a list of all the modules
|
||||
that it imports.
|
||||
-}
|
||||
findDeps base pkg = do
|
||||
let hi = base ++ (map dotToSlash pkg) ++ ".hs"
|
||||
ex <- doesFileExist hi
|
||||
if not ex then return [] else do
|
||||
src <- readFile hi
|
||||
let imps = filter isImport (lines src)
|
||||
return $ catMaybes $ map getTargetModule imps
|
||||
|
||||
where dotToSlash '.' = '/'
|
||||
dotToSlash x = x
|
||||
|
||||
isImport (' ':t) = isImport t
|
||||
isImport ('\t':t) = isImport t
|
||||
isImport t = "import" `isPrefixOf` t
|
||||
|
||||
getTargetModule s = let pre = takeWhile (/= '(') s in
|
||||
find (isUpper . head) (words pre)
|
||||
|
||||
{-
|
||||
Find the transitive, reflexive closure of the relation defined
|
||||
by the findDeps function. This returns a list of ALL modules
|
||||
that this one uses or depends on, directly or indirectly.
|
||||
-}
|
||||
allDeps base mod = allDeps' [mod] [mod] where
|
||||
allDeps' (m:ms) full = do d <- findDeps base m
|
||||
let d' = filter (not . flip elem full) d
|
||||
t <- allDeps' (d' ++ ms) (d' ++ full)
|
||||
return (m : t)
|
||||
allDeps' [] _ = return []
|
||||
|
||||
{-
|
||||
Usage: OrderByComplexity
|
||||
|
||||
= directory where source code is found. This MUST
|
||||
end in '/'
|
||||
= file that lists the modules you're interested in,
|
||||
one per line. This is often taken from a .cabal
|
||||
-}
|
||||
main = do [ base, pkgFile ] <- getArgs
|
||||
pkgStr <- readFile pkgFile
|
||||
let pkgs = lines pkgStr
|
||||
mods <- mapM (allDeps base) pkgs
|
||||
let deps = zip pkgs mods
|
||||
let deps' = sortBy (comparing fst) deps
|
||||
mapM_ print $ map fst $ sortBy (comparing $ length . snd) deps'
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
{-
|
||||
overview.hs - print an overview of functions from a given list of modules
|
||||
Simon Michael 2007
|
||||
|
||||
Usage: ./overview.hs somefile
|
||||
|
@ -1,12 +1,13 @@
|
||||
#!/usr/bin/python
|
||||
# test whether hledger output matches ledger's
|
||||
# Simon Michael 2007
|
||||
|
||||
from os import *
|
||||
from posix import *
|
||||
|
||||
files = [
|
||||
'test.dat',
|
||||
'test1.dat',
|
||||
'data/test.dat',
|
||||
'data/test1.dat',
|
||||
# getenv('LEDGER'),
|
||||
]
|
||||
|
14
tools/simplifyprof.hs
Normal file
14
tools/simplifyprof.hs
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
-- filters uninteresting fields from profile data lines
|
||||
-- Simon Michael 2007
|
||||
import Data.List
|
||||
main = interact $ unlines . map print . filter (/=[]) .
|
||||
(["cost-centre - - entries %time %mem %t-inh %m-inh"]++) . tail .
|
||||
dropWhile (notElem "entries" . words) . lines
|
||||
where
|
||||
print line = tabcat [paddedfirst, field 3, field 4, field 5, field 6, field 7]
|
||||
where
|
||||
tabcat = concat . intersperse "\t"
|
||||
first = takeWhile (==' ') line ++ (takeWhile (/=' ') $ dropWhile (==' ') line)
|
||||
paddedfirst = first ++ (take (60 - (length first)) $ repeat ' ')
|
||||
field n = words line !! n
|
Loading…
Reference in New Issue
Block a user