Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse get_global('windows_zone_mapping') to avoid data loss. Fixes #464 #465

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ecederstrand
Copy link

@ecederstrand ecederstrand commented Jan 10, 2017

Reverses get_global('windows_zone_mapping') keys and values and does not filter on territory. This preserves all input data and makes it possible to look up Windows timezone name for any supported timezone, while still supporting the previous functionality with a simple previous_output = {v:k for k, v in get_global('windows_zone_mapping')}.

It also makes 'windows_zone_mapping behave like the other timezone mappings which are indexed by timezone name.

This is backwards incompatible, but I'm not sure how much it matters since get_global('windows_zone_mapping') is technically an undocumented feature (see #463 )

Changes  `get_global('windows_zone_mapping')` to return tuple values. This preserves all input data and makes it possible to easily make a reverse map without losing keys.
Most other maps are also keyed by timezone name, so do the same with win_mapping.
Don't take territory into account when creating the map - the other territories are also valid.
@ecederstrand ecederstrand changed the title Make windows_zone_mappinglossless. Fixes #464 Reverse win_mapping to avoid data loss. Fixes #464 Jan 10, 2017
@codecov-io
Copy link

codecov-io commented Jan 10, 2017

Current coverage is 90.14% (diff: 100%)

Merging #465 into master will not change coverage

@@             master       #465   diff @@
==========================================
  Files            24         24          
  Lines          3979       3979          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           3587       3587          
  Misses          392        392          
  Partials          0          0          

Powered by Codecov. Last update ab56a43...a7c0961

@ecederstrand ecederstrand changed the title Reverse win_mapping to avoid data loss. Fixes #464 Reverse get_global('windows_zone_mapping') to avoid data loss. Fixes #464 Jan 10, 2017
@akx
Copy link
Member

akx commented Aug 18, 2017

Hey and sorry it's taken us ages to get back to this PR. 😞

Anyway I'm thinking we could do better here – what if we import the lossless, detailed mapping as, say, detailed_windows_zone_mapping or similar? The shape could be {(zone, territory): windows_zone, ...}.

Then it's trivial to create windows_zone_mapping during CLDR import time from that data. That'd leave us backward compatible API-wise (even if I don't exactly truly believe too many people are currently using windows_zone_mapping – it's hard to tell since Github's code search just turns up thousands of vendored copies of Babel) so this could be shipped in Babel 2.x.

@ecederstrand
Copy link
Author

This solution is fine with me.

My use case is a Microsoft Exchange client that needs to translate from pytz timezones to Windows timezone names, and I ended up storing a static map with the translations, generated from the CLDR: https://github.com/ecederstrand/exchangelib/blob/master/exchangelib/winzone.py So this is no longer urgent for me, but I promise to use Babel instead when this is solved and hits a release :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants