From fe534d5229de5e83dccdfa3e4ba3c1b29bd38a71 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Feb 2021 08:34:39 +0100 Subject: Adding upstream version 2020.1+dfsg. Signed-off-by: Daniel Baumann --- pytzdata/commands/zones.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pytzdata/commands/zones.py (limited to 'pytzdata/commands/zones.py') diff --git a/pytzdata/commands/zones.py b/pytzdata/commands/zones.py new file mode 100644 index 0000000..ef3e33a --- /dev/null +++ b/pytzdata/commands/zones.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +import os +import pprint +import pytzdata + +from cleo import Command + + +class ZonesCommand(Command): + """ + Dumps available timezones to the _timezone.py file. + + zones:dump + """ + + TEMPLATE = """# -*- coding: utf-8 -*- + +timezones = {} +""" + + def handle(self): + zones = pytzdata.get_timezones() + + tz_file = os.path.join( + os.path.dirname(__file__), + '..', + '_timezones.py' + ) + + with open(tz_file, 'w') as fd: + fd.write( + self.TEMPLATE.format(pprint.pformat(zones)) + ) + + self.info('Dumped {} timezones'.format(len(zones))) -- cgit v1.2.3