summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-split4
-rwxr-xr-xledger-price-db-update.py12
-rwxr-xr-xworth-it18
3 files changed, 19 insertions, 15 deletions
diff --git a/git-split b/git-split
index 6c3398f..3e29b01 100755
--- a/git-split
+++ b/git-split
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
# https://stackoverflow.com/questions/40698651/how-to-split-every-commit-by-file
# Split HEAD commit into multiples with single file in it.
+#
+# If you want to split a single commit during an interactive rebase, use it like this:
+# p Commit to split
+# x git-split
set -e
diff --git a/ledger-price-db-update.py b/ledger-price-db-update.py
index 0a78585..853cfe9 100755
--- a/ledger-price-db-update.py
+++ b/ledger-price-db-update.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
@@ -31,7 +31,7 @@ from codecs import open
CONFIG_FILE = '~/.ledger-commodities'
config = ConfigParser()
-config.readfp(open(os.path.expanduser(CONFIG_FILE), 'r', 'utf-8'))
+config.read_file(open(os.path.expanduser(CONFIG_FILE), 'r', 'utf-8'))
def get_json(url, **kwargs):
@@ -43,7 +43,7 @@ def print_price(symbol, price, base, date=datetime.datetime.now()):
date_str = date.strftime('%Y/%m/%d %H:%M:%S')
if ' ' in symbol:
symbol = '"' + symbol +'"'
- print ('P %s %s %f %s' % (date_str, symbol, price, base)).encode('utf-8')
+ print(('P %s %s %f %s' % (date_str, symbol, price, base)))
def exchange_rates():
@@ -51,12 +51,12 @@ def exchange_rates():
symbols = dict([(symbol.upper(), commodity) for symbol, commodity in config.items('exchange-symbols')])
params = {
"access_key": config.get('fixer', 'access_key'),
- "symbols": ','.join(symbols.keys() + [base,])
+ "symbols": ','.join(list(symbols.keys()) + [base,])
}
rates = get_json(r'http://data.fixer.io/api/latest', params=params)['rates']
base_value = rates[base]
- for symbol, value in rates.items():
+ for symbol, value in list(rates.items()):
if symbol != base:
print_price(symbols[symbol], base_value / value, symbols[base])
@@ -127,7 +127,7 @@ def main():
try:
update()
except Exception as e:
- print >> sys.stderr, 'Oops, update method `%s` failed: %s' % (update, e)
+ print('Oops, update method `%s` failed: %s' % (update, e), file=sys.stderr)
traceback.print_exc()
if __name__ == '__main__':
diff --git a/worth-it b/worth-it
index 64b8f29..35fd276 100755
--- a/worth-it
+++ b/worth-it
@@ -1,16 +1,16 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def read_data():
data = []
while True:
- text = raw_input()
+ text = input()
if text == '':
break
try:
sp = text.split()
- (value, cost) = map(float, sp)
+ (value, cost) = list(map(float, sp))
data.append((cost / value, value, cost, text))
except ValueError:
pass
@@ -18,16 +18,16 @@ def read_data():
def main():
- print 'Enter data table (last line should be empty): value cost'
- print
+ print('Enter data table (last line should be empty): value cost')
+ print()
data = sorted(read_data())
if len(data):
- print '%10s | %10s | %10s' % ("Ratio", "Value", "Cost")
+ print('%10s | %10s | %10s' % ("Ratio", "Value", "Cost"))
for ratio, _, _, orig_value in data:
- print '%10.2f | %10s | %10s' % tuple([ratio, ] + orig_value.split())
- print
- print 'Best choose is %s' % data[0][-1]
+ print('%10.2f | %10s | %10s' % tuple([ratio, ] + orig_value.split()))
+ print()
+ print('Best choose is %s' % data[0][-1])
if __name__ == '__main__':