Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/78623
Change subject: Not all globes may be hardcode, so use the url as a fallback
......................................................................
Not all globes may be hardcode, so use the url as a fallback
This also removes hardcoding a set list of globes, there's no
reason we can't support all of them.
Change-Id: I942d391be8298bf046cd013332ea24687339bb51
---
M pywikibot/__init__.py
1 file changed, 2 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/23/78623/1
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 73947ec..ddd9002 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -125,15 +125,6 @@
self.site = Site().data_repository()
else:
self.site = site
- #Copied from [[mw:Extension:GeoData]]
- if not self.globe in ['earth', 'mercury', 'venus', 'moon',
- 'mars', 'phobos', 'deimos', 'ganymede',
- 'callisto', 'io', 'europa', 'mimas',
- 'enceladus', 'tethys', 'dione',
- 'rhea', 'titan', 'hyperion', 'iapetus',
- 'phoebe', 'miranda', 'ariel', 'umbriel',
- 'titania', 'oberon', 'triton', 'pluto']:
- raise ValueError(u"%s is not a supported globe." % self.globe)
def __repr__(self):
string = 'Coordinate(%s, %s' % (self.lat, self.lon)
@@ -153,7 +144,7 @@
return {'latitude': self.lat,
'longitude': self.lon,
'altitude': self.alt,
- 'globe': self.site.globes()[self.globe],
+ 'globe': self.site.globes().get(self.globe, self.globe),
'precision': self.precision,
}
@@ -166,8 +157,7 @@
globekey = data['globe']
if globekey:
- # FIXME: Should probably use get() with some error handling when
it's an unknown globe
- globe = globes[data['globe']]
+ globe = globes.get(data['globe'], data['globe'])
else:
# Default to earth or should we use None here?
globe = 'earth'
--
To view, visit https://gerrit.wikimedia.org/r/78623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I942d391be8298bf046cd013332ea24687339bb51
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits