diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 07:34:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 07:50:21 +0000 |
commit | fe534d5229de5e83dccdfa3e4ba3c1b29bd38a71 (patch) | |
tree | b6c5cd613e258116b1f732732c78f87b3d5f6e50 /pytzdata/commands/zones.py | |
parent | Initial commit. (diff) | |
download | pytzdata-fe534d5229de5e83dccdfa3e4ba3c1b29bd38a71.tar.xz pytzdata-fe534d5229de5e83dccdfa3e4ba3c1b29bd38a71.zip |
Adding upstream version 2020.1+dfsg.upstream/2010.1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pytzdata/commands/zones.py')
-rw-r--r-- | pytzdata/commands/zones.py | 36 |
1 files changed, 36 insertions, 0 deletions
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 <comment>{}</> timezones'.format(len(zones))) |