HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/pytzdata/commands/zones.py
# -*- 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)))