* [gentoo-commits] gentoo-x86 commit in sci-calculators/units/files: units-2.01_cur.patch
@ 2013-07-06 14:47 Jeroen Roovers (jer)
0 siblings, 0 replies; 2+ messages in thread
From: Jeroen Roovers (jer) @ 2013-07-06 14:47 UTC (permalink / raw
To: gentoo-commits
jer 13/07/06 14:47:55
Added: units-2.01_cur.patch
Log:
Install a patched units_cur (bug #470182).
(Portage version: 2.2.0_alpha186/cvs/Linux x86_64, signed Manifest commit with key A792A613)
Revision Changes Path
1.1 sci-calculators/units/files/units-2.01_cur.patch
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch?rev=1.1&content-type=text/plain
Index: units-2.01_cur.patch
===================================================================
--- a/units-2.01/units_cur
+++ b/units-2.01/units_cur
@@ -1,10 +1,11 @@
-#!/usr/bin/python
+#!/usr/bin/python2
import urllib
import datetime
from xml.dom import minidom
import sys
import re
+import xml.etree.ElementTree as ET
outfile = 'currency.units'
@@ -26,51 +27,54 @@
sys.exit(1)
try:
- data = urllib.urlopen('http://rss.timegenie.com/forex.txt').readlines()
+ data = ET.parse(urllib.urlopen('http://rss.timegenie.com/forex.xml')).findall('data')
except IOError, exc:
sys.stderr.write('Error connecting to currency server. {0}\n'.format(exc))
sys.exit(1)
-if not re.match(r"[A-Z]{3}\|[A-Za-z ]*\|[0-9.]*",data[0]):
- sys.stderr.write('Something wrong with timegenie reply\n')
- sys.exit(1)
-
-splitdata = [x.split('|') for x in data]
-
-codes = [x[0] for x in splitdata]
-names = [x[1].lower().replace(' ','') for x in splitdata]
-values = ['1|' + x[2].rstrip('\n') for x in splitdata]
-
+# <forex>
+# <data>
+# <code>AED</code>
+# <description>United Arab Emirates Dirham</description>
+# <rate>4.8013</rate>
+# </data>
+# </forex>
# print codes here
output.write('# ISO Currency Codes\n\n')
-for x in zip(codes, names):
- output.write(('{0}' + ' '*20 + '{1}\n').format(*x))
-
-usd = codes.index('USD')
-euro = codes.index('EUR')
-usdval = values[usd][2:] # Trim off leading 1|
-
-values = [x+' euro' for x in values]
-
-values[euro] = usdval + ' US$'
-
-del names[usd]
-del values[usd]
-
-# print values here
+for datum in data:
+ code = datum.find('code').text
+ description = datum.find('description').text.lower().replace(' ','')
+ datum.find('description').text = description
+ output.write(code + ' '*20 + description + '\n')
+
+# print rates here
+
+for datum in data:
+ if datum.find('code').text == 'USD':
+ usdval = datum.find('rate').text[2:]
+ datum.remove
now = datetime.datetime.now()
output.write('\n# Currency exchange rates from Time Genie (www.timegenie.com)\n')
output.write('\n!message Currency exchange rates from ' + now.strftime('%Y-%m-%d') + '\n\n')
+maxlen = 0
-maxlen = max(map(len,names))
-names = [x.ljust(maxlen+2) for x in names]
-for x in zip(names, values):
- output.write('{0}{1}\n'.format(*x))
+for datum in data:
+ if len(datum.find('description').text) > maxlen:
+ maxlen = len(datum.find('description').text)
+
+ if datum.find('code').text == 'EUR':
+ euro = datum.find('rate').text
+ datum.find('rate').text = usdval + ' US$'
+
+ else:
+ datum.find('rate').text += ' euro'
+ output.write(datum.find('description').text.ljust(maxlen+2) + '1|' + datum.find('rate').text + '\n')
+# precious metals prices
output.write('\n# Precious metals prices from http://services.packetizer.com/spotprices/\n\n')
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gentoo-commits] gentoo-x86 commit in sci-calculators/units/files: units-2.01_cur.patch
@ 2013-07-06 15:40 Jeroen Roovers (jer)
0 siblings, 0 replies; 2+ messages in thread
From: Jeroen Roovers (jer) @ 2013-07-06 15:40 UTC (permalink / raw
To: gentoo-commits
jer 13/07/06 15:40:41
Modified: units-2.01_cur.patch
Log:
Update patch to remove the proper node from the element tree.
(Portage version: 2.2.0_alpha186/cvs/Linux x86_64, signed Manifest commit with key A792A613)
Revision Changes Path
1.2 sci-calculators/units/files/units-2.01_cur.patch
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch?r1=1.1&r2=1.2
Index: units-2.01_cur.patch
===================================================================
RCS file: /var/cvsroot/gentoo-x86/sci-calculators/units/files/units-2.01_cur.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- units-2.01_cur.patch 6 Jul 2013 14:47:55 -0000 1.1
+++ units-2.01_cur.patch 6 Jul 2013 15:40:41 -0000 1.2
@@ -1,5 +1,5 @@
---- a/units-2.01/units_cur
-+++ b/units-2.01/units_cur
+--- a/units_cur
++++ b/units_cur
@@ -1,10 +1,11 @@
-#!/usr/bin/python
+#!/usr/bin/python2
@@ -71,7 +71,7 @@
+for datum in data:
+ if datum.find('code').text == 'USD':
+ usdval = datum.find('rate').text[2:]
-+ datum.remove
++ data.remove(datum)
now = datetime.datetime.now()
output.write('\n# Currency exchange rates from Time Genie (www.timegenie.com)\n')
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-06 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-06 15:40 [gentoo-commits] gentoo-x86 commit in sci-calculators/units/files: units-2.01_cur.patch Jeroen Roovers (jer)
-- strict thread matches above, loose matches on Subject: below --
2013-07-06 14:47 Jeroen Roovers (jer)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox