From 08559bff349b8266331389c9a0c579798ce94b4c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Feb 2009 14:04:50 -0400 Subject: Moved scripts from contrib/scripts/ into contrib/ --- contrib/README | 4 ++++ contrib/bal | 21 ++++++++++++++++++++ contrib/bal-huquq | 21 ++++++++++++++++++++ contrib/entry | 16 ++++++++++++++++ contrib/getquote.pl | 16 ++++++++++++++++ contrib/ledger-du | 49 +++++++++++++++++++++++++++++++++++++++++++++++ contrib/report | 21 ++++++++++++++++++++ contrib/scripts/README | 4 ---- contrib/scripts/bal | 21 -------------------- contrib/scripts/bal-huquq | 21 -------------------- contrib/scripts/entry | 16 ---------------- contrib/scripts/getquote | 16 ---------------- contrib/scripts/ledger-du | 49 ----------------------------------------------- contrib/scripts/report | 21 -------------------- contrib/scripts/tc | 7 ------- contrib/scripts/ti | 5 ----- contrib/scripts/to | 3 --- contrib/scripts/trend | 30 ----------------------------- contrib/tc | 7 +++++++ contrib/ti | 5 +++++ contrib/to | 3 +++ contrib/trend | 30 +++++++++++++++++++++++++++++ 22 files changed, 193 insertions(+), 193 deletions(-) create mode 100644 contrib/README create mode 100755 contrib/bal create mode 100755 contrib/bal-huquq create mode 100755 contrib/entry create mode 100755 contrib/getquote.pl create mode 100755 contrib/ledger-du create mode 100755 contrib/report delete mode 100644 contrib/scripts/README delete mode 100755 contrib/scripts/bal delete mode 100755 contrib/scripts/bal-huquq delete mode 100755 contrib/scripts/entry delete mode 100755 contrib/scripts/getquote delete mode 100755 contrib/scripts/ledger-du delete mode 100755 contrib/scripts/report delete mode 100755 contrib/scripts/tc delete mode 100755 contrib/scripts/ti delete mode 100755 contrib/scripts/to delete mode 100755 contrib/scripts/trend create mode 100755 contrib/tc create mode 100755 contrib/ti create mode 100755 contrib/to create mode 100755 contrib/trend diff --git a/contrib/README b/contrib/README new file mode 100644 index 00000000..6108afbf --- /dev/null +++ b/contrib/README @@ -0,0 +1,4 @@ +This scripts are provided just to give some ideas. They probably need +to be modified to better suit your environment. Beware! + +John diff --git a/contrib/bal b/contrib/bal new file mode 100755 index 00000000..423e3e41 --- /dev/null +++ b/contrib/bal @@ -0,0 +1,21 @@ +#!/bin/sh + +switch="-c" +limit="-t (/Liabilities/?a<0:Ua>100)&a" + +if [ "$1" = "-C" -o "$1" = "-U" ]; then + switch="$1" + shift +elif [ "$1" = "-b" -o "$1" = "-e" -o "$1" = "-p" ]; then + switch="$1 $2" + shift 2 +fi + +accts="$@" +if [ -z "$accts" ]; then + accts="-Equity -Income -Expenses" +else + limit="" +fi + +ledger -VQ $switch $limit -s -S "-UT" balance $accts diff --git a/contrib/bal-huquq b/contrib/bal-huquq new file mode 100755 index 00000000..fad2854a --- /dev/null +++ b/contrib/bal-huquq @@ -0,0 +1,21 @@ +#!/bin/sh + +switch="-c" +limit="-t (/Liabilities/?(/Huquq/?a/P{2.22AU}<={-1.0}:a<0):Ua>100)&a" + +if [ "$1" = "-C" -o "$1" = "-U" ]; then + switch="$1" + shift +elif [ "$1" = "-b" -o "$1" = "-e" -o "$1" = "-p" ]; then + switch="$1 $2" + shift 2 +fi + +accts="$@" +if [ -z "$accts" ]; then + accts="-Equity -Income -Expenses" +else + limit="" +fi + +ledger -VQ $switch $limit -s -S "-UT" balance $accts diff --git a/contrib/entry b/contrib/entry new file mode 100755 index 00000000..cc030d8e --- /dev/null +++ b/contrib/entry @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ -z "$LEDGER" -o ! -r "$LEDGER" ]; then + echo Please set your LEDGER environment variable. +fi + +line=`wc -l $LEDGER | awk '{print $1}'` + +if ledger entry "$@" > /tmp/entry; then + cat /tmp/entry >> $LEDGER +else + echo "$@" >> $LEDGER +fi +rm /tmp/entry + +vi +$line $LEDGER diff --git a/contrib/getquote.pl b/contrib/getquote.pl new file mode 100755 index 00000000..bed561d6 --- /dev/null +++ b/contrib/getquote.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +$timeout = 60; + +use Finance::Quote; + +$q = Finance::Quote->new; +$q->timeout($timeout); +$q->require_labels(qw/price/); + +%quotes = $q->fetch("nasdaq", $ARGV[0]); +if ($quotes{$ARGV[0], "price"}) { + print "\$", $quotes{$ARGV[0], "price"}, "\n"; +} else { + exit 1; +} diff --git a/contrib/ledger-du b/contrib/ledger-du new file mode 100755 index 00000000..f5d7dd7d --- /dev/null +++ b/contrib/ledger-du @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import string +import sys +import os +import time + +from stat import * +from os.path import * + +def report_file(path): + dir_elems = string.split(dirname(path), os.sep) + if dir_elems[0] == "." or dir_elems[0] == "": + dir_elems = dir_elems[1 :] + account = string.join(dir_elems, ":") + + info = os.stat(path) + print time.strftime("%Y/%m/%d", time.localtime(info[ST_MTIME])), + + print basename(path) + print " ", account, " ", info[ST_SIZE], "b" + print " Equity:Files" + print + +def find_files(path): + entries = os.listdir(path) + for entry in entries: + entry = join(path, entry) + if not islink(entry): + if isdir(entry) and entry != "/proc": + find_files(entry) + else: + report_file(entry) + +args = sys.argv[1:] +if len(args): + paths = args +else: + paths = ["."] + +print """ +C 1.00 Kb = 1024 b +C 1.00 Mb = 1024 Kb +C 1.00 Gb = 1024 Mb +C 1.00 Tb = 1024 Gb +""" + +for path in paths: + find_files(path) diff --git a/contrib/report b/contrib/report new file mode 100755 index 00000000..24418cdc --- /dev/null +++ b/contrib/report @@ -0,0 +1,21 @@ +#!/bin/sh + +# This script facilities plotting of a ledger register report. If you +# use OS/X, and have AquaTerm installed, you will probably want to set +# LEDGER_TERM to "aqua". +# +# Examples of use: +# +# report -j -M reg food # plot monthly food costs +# report -J reg checking # plot checking account balance + +if [ -z "$LEDGER_TERM" ]; then + LEDGER_TERM="x11 persist" +fi + +(cat < /tmp/entry; then - cat /tmp/entry >> $LEDGER -else - echo "$@" >> $LEDGER -fi -rm /tmp/entry - -vi +$line $LEDGER diff --git a/contrib/scripts/getquote b/contrib/scripts/getquote deleted file mode 100755 index bed561d6..00000000 --- a/contrib/scripts/getquote +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/perl - -$timeout = 60; - -use Finance::Quote; - -$q = Finance::Quote->new; -$q->timeout($timeout); -$q->require_labels(qw/price/); - -%quotes = $q->fetch("nasdaq", $ARGV[0]); -if ($quotes{$ARGV[0], "price"}) { - print "\$", $quotes{$ARGV[0], "price"}, "\n"; -} else { - exit 1; -} diff --git a/contrib/scripts/ledger-du b/contrib/scripts/ledger-du deleted file mode 100755 index f5d7dd7d..00000000 --- a/contrib/scripts/ledger-du +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python - -import string -import sys -import os -import time - -from stat import * -from os.path import * - -def report_file(path): - dir_elems = string.split(dirname(path), os.sep) - if dir_elems[0] == "." or dir_elems[0] == "": - dir_elems = dir_elems[1 :] - account = string.join(dir_elems, ":") - - info = os.stat(path) - print time.strftime("%Y/%m/%d", time.localtime(info[ST_MTIME])), - - print basename(path) - print " ", account, " ", info[ST_SIZE], "b" - print " Equity:Files" - print - -def find_files(path): - entries = os.listdir(path) - for entry in entries: - entry = join(path, entry) - if not islink(entry): - if isdir(entry) and entry != "/proc": - find_files(entry) - else: - report_file(entry) - -args = sys.argv[1:] -if len(args): - paths = args -else: - paths = ["."] - -print """ -C 1.00 Kb = 1024 b -C 1.00 Mb = 1024 Kb -C 1.00 Gb = 1024 Mb -C 1.00 Tb = 1024 Gb -""" - -for path in paths: - find_files(path) diff --git a/contrib/scripts/report b/contrib/scripts/report deleted file mode 100755 index 24418cdc..00000000 --- a/contrib/scripts/report +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# This script facilities plotting of a ledger register report. If you -# use OS/X, and have AquaTerm installed, you will probably want to set -# LEDGER_TERM to "aqua". -# -# Examples of use: -# -# report -j -M reg food # plot monthly food costs -# report -J reg checking # plot checking account balance - -if [ -z "$LEDGER_TERM" ]; then - LEDGER_TERM="x11 persist" -fi - -(cat <