upoints.tzdata.Zones

Package upoints :: Module tzdata :: Class Zones |
[hide private]
[frames] | no frames]

# Class Zones

    object --+
             |
          list --+
                 |
      point.Points --+
                     |
                    Zones

Class for representing a group of Zone objects

Since: 0.6.0

Instance Methods | [hide private]
new list |
__init__(self, zone_file=None) Initialise a new Zones object |
`list` |
import_locations(self, zone_file) Parse zoneinfo zone description data files |
`list` |
dump_zone_file(self) Generate a zoneinfo compatible zone description table |
Inherited from `point.Points`: `__repr__`, `bearing`, `destination`, `distance`, `final_bearing`, `forward`, `inverse`, `midpoint`, `range`, `sun_events`, `sunrise`, `sunset`, `to_grid_locator` Inherited from `list`: `__add__`, `__contains__`, `__delitem__`, `__delslice__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__iadd__`, `__imul__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__mul__`, `__ne__`, `__new__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `append`, `count`, `extend`, `index`, `insert`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, zone_file=None) (Constructor) |
Initialise a new Zones object Parameters: `points` - Point objects to wrap `parse` - Whether to attempt import of `points` `units` - Unit type to be used for distances when parsing string locations Returns: new list Overrides: object.__init__

### import_locations(self, zone_file) |
Parse zoneinfo zone description data files import_locations() returns a list of Zone objects. It expects data files in one of the following formats:
    AN  +1211-06900     America/Curacao
    AO  -0848+01314     Africa/Luanda
    AQ  -7750+16636     Antarctica/McMurdo      McMurdo Station, Ross Island
Files containing the data in this format can be found in `zone.tab` file that is normally found in `/usr/share/zoneinfo` on UNIX-like systems, or from the standard distribution site. When processed by import_locations() a `list` object of the following style will be returned:
    [Zone(None, None, "AN", "America/Curacao", None),
     Zone(None, None, "AO", "Africa/Luanda", None),
     Zone(None, None, "AO", "Antartica/McMurdo",
          ["McMurdo Station", "Ross Island"])]
    >>> zones = Zones(open("timezones"))
    >>> for value in sorted(zones,
    ...                     key=lambda x: x.zone):
    ...     print(value)
    Africa/Luanda (AO: 08°48'00"S, 013°14'00"E)
    America/Curacao (AN: 12°11'00"N, 069°00'00"W)
    Antarctica/McMurdo (AQ: 77°50'00"S, 166°36'00"E also McMurdo Station,
    Ross Island)
Parameters: `zone_file` (`file`, `list` or `str`) - zone.tab data to read Returns: `list` Locations as Zone objects Raises: `FileFormatError` - Unknown file format Overrides: point.Points.import_locations

### dump_zone_file(self) |
Generate a zoneinfo compatible zone description table
    >>> zones = Zones(open("timezones"))
    >>> Zones.dump_zone_file(zones)
    ['AN\t+121100-0690000\tAmerica/Curacao',
     'AO\t-084800+0131400\tAfrica/Luanda',
     'AQ\t-775000+1663600\tAntarctica/McMurdo\tMcMurdo Station, Ross Island']
Returns: `list` zoneinfo descriptions