<commit_before>import tempfile

import os

import shutil
from enum import Enum
from fractions import Fraction

from django.utils import timezone

from jinja2 import Environment, PackageLoader
from rq import get_current_job

from osmaxx.conversion._settings import odb_license
from osmaxx.conversion.converters.converter_gis.bootstrap import BootStrapper
from osmaxx.conversion.converters.converter_gis.extract.db_to_format.extract import extract_to
from osmaxx.conversion.converters.utils import zip_folders_relative, recursive_getsize
from osmaxx.conversion_api.formats import FORMAT_DEFINITIONS


def perform_export(*, conversion_format, output_zip_file_path, filename_prefix, out_srs, polyfile_string, detail_level, **__):
    gis = GISConverter(
        conversion_format=conversion_format,
        output_zip_file_path=output_zip_file_path,
        base_file_name=filename_prefix,
        out_srs=out_srs,
        polyfile_string=polyfile_string,
        detail_level=detail_level
    )
    gis.create_gis_export()


QGIS_DISPLAY_SRID = 3857  # Web Mercator


class ScaleLevel(Enum):
    m1 = Fraction(1, 2500)
    m3 = Fraction(1, 10000)
    m4 = Fraction(1, 25000)


class GISConverter:
    def __init__(self, *, conversion_format, output_zip_file_path, base_file_name, out_srs, polyfile_string, detail_level):
        """
        Converts a specified pbf into the specified format.

        Args:
            output_zip_file_path: path to where the zipped result should be stored, directory must already exist
            conversion_format: One of 'fgdb', 'shapefile', 'gpkg', 'spatialite'<commit_msg>reformat source code<commit_after>import tempfile

import os

import shutil
from enum import Enum
from fractions import Fraction

from django.utils import timezone

from jinja2 import Environment, PackageLoader
from rq import get_current_job

from osmaxx.conversion._settings import odb_license
from osmaxx.conversion.converters.converter_gis.bootstrap import BootStrapper
from osmaxx.conversion.converters.converter_gis.extract.db_to_format.extract import extract_to
from osmaxx.conversion.converters.utils import zip_folders_relative, recursive_getsize
from osmaxx.conversion_api.formats import FORMAT_DEFINITIONS


def perform_export(
        *, conversion_format, output_zip_file_path, filename_prefix, out_srs, polyfile_string, detail_level, **__):
    gis = GISConverter(
        conversion_format=conversion_format,
        output_zip_file_path=output_zip_file_path,
        base_file_name=filename_prefix,
        out_srs=out_srs,
        polyfile_string=polyfile_string,
        detail_level=detail_level
    )
    gis.create_gis_export()


QGIS_DISPLAY_SRID = 3857  # Web Mercator


class ScaleLevel(Enum):
    m1 = Fraction(1, 2500)
    m3 = Fraction(1, 10000)
    m4 = Fraction(1, 25000)


class GISConverter:
    def __init__(
            self, *, conversion_format, output_zip_file_path, base_file_name, out_srs, polyfile_string, detail_level):
        """
        Converts a specified pbf into the specified format.

        Args:
            output_zip_file_path: path to where the zipped result should be stored, directory must already exist
            conversion_format: One of 'fgdb', 'shapefile', 'gpkg', 'spatialite'
{'fraction_non_alphanumeric': 0.06221127194333231, 'fraction_numerical': 0.015398829688943641, 'mean_word_length': 4.404326123128119, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6809241', 'n_tokens_mistral': 1068, 'n_tokens_neox': 993, 'n_words': 242}