Created
June 30, 2012 21:58
-
-
Save ShadowKyogre/3025686 to your computer and use it in GitHub Desktop.
Improved portability for openastro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -aur openastro.org_1.1.25.orig/openastro.py openastro.org_1.1.25.modified/openastro.py | |
--- openastro.org_1.1.25.orig/openastro.py 2011-09-28 00:17:43 -0700 | |
+++ openastro.org_1.1.25.modified/openastro.py 2012-06-30 14:54:31 -0700 | |
@@ -19,7 +19,7 @@ | |
#basics | |
import math, sys, os.path, datetime, socket, gettext, codecs, webbrowser | |
- | |
+import tempfile | |
#copyfile | |
from shutil import copyfile | |
@@ -50,7 +50,7 @@ | |
#directories | |
DATADIR=os.path.join(sys.prefix,'share','openastro.org') | |
-TMPDIR='/tmp' | |
+TMPDIR=tempfile.gettempdir() | |
#Translations | |
LANGUAGES_LABEL={ | |
@@ -78,10 +78,15 @@ | |
} | |
+local_trans = os.path.join(sys.path[0],'locale') | |
+sys_trans = os.path.join(DATADIR,'locale') | |
if LOCAL: | |
- TDomain = './locale' | |
+ TDomain = local_trans | |
else: | |
- TDomain = os.path.join(DATADIR,'locale') | |
+ if os.path.exists(sys_trans): | |
+ TDomain = sys_trans | |
+ else: | |
+ TDomain = local_trans | |
LANGUAGES=LANGUAGES_LABEL.keys() | |
TRANSLATION={} | |
diff -aur openastro.org_1.1.25.orig/openastromod/swiss.py openastro.org_1.1.25.modified/openastromod/swiss.py | |
--- openastro.org_1.1.25.orig/openastromod/swiss.py 2011-09-28 00:17:43 -0700 | |
+++ openastro.org_1.1.25.modified/openastromod/swiss.py 2012-06-30 00:30:05 -0700 | |
@@ -32,7 +32,7 @@ | |
class ephData: | |
def __init__(self,year,month,day,hour,geolon,geolat,altitude,planets,zodiac,openastrocfg,houses_override=None): | |
#ephemeris path (default "/usr/share/swisseph:/usr/local/share/swisseph") | |
- swe.set_ephe_path(ephe_path) | |
+ #swe.set_ephe_path(ephe_path) | |
#basic location | |
self.jul_day_UT=swe.julday(year,month,day,hour) | |
diff -aur openastro.org_1.1.25.orig/openastromod/zonetab.py openastro.org_1.1.25.modified/openastromod/zonetab.py | |
--- openastro.org_1.1.25.orig/openastromod/zonetab.py 2011-09-28 00:17:43 -0700 | |
+++ openastro.org_1.1.25.modified/openastromod/zonetab.py 2012-06-30 14:49:35 -0700 | |
@@ -9,6 +9,15 @@ | |
import re, struct, math | |
from datetime import datetime | |
from dateutil.tz import tzfile | |
+from dateutil import zoneinfo | |
+from os import path | |
+import sys | |
+ | |
+def get_zonetab(p): | |
+ if path.exists(p): | |
+ return p | |
+ else: | |
+ return path.join(sys.path[0],'zone.tab') | |
def nearest_tz(lat, lon, zones): | |
""" | |
@@ -46,7 +55,7 @@ | |
* (math.sin(dlong / 2))**2 | |
return 2 * math.asin(min(1, math.sqrt(a))) | |
-def timezones(zonetab="/usr/share/zoneinfo/zone.tab", | |
+def timezones(zonetab=get_zonetab("/usr/share/zoneinfo/zone.tab"), | |
exclude=[]): | |
"""iterate over timezones in zone.tab; yield (country, (lat, lon), name) | |
@@ -66,16 +75,14 @@ | |
yield country, latlong(coords), tz | |
-def stdtime(tz, year, month, day, hour, min, sec , | |
- zoneinfo="/usr/share/zoneinfo" | |
- ): | |
+def stdtime(tz, year, month, day, hour, min, sec): | |
"""Use /usr/share/zoneinfo to interpret a time in a timezone. | |
>>> stdtime("America/Chicago", "2007-04-02T21:53:27") | |
'2007-04-02T21:53:27-05:00' | |
""" | |
return datetime(year, month, day, hour, min, sec, | |
- tzinfo=tzfile("%s/%s" % (zoneinfo, tz)) | |
+ tzinfo=zoneinfo.gettz("%s" % (tz)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment