<commit_before>#!/usr/bin/env python

"""
Converts VFR file into desired GIS format supported by OGR library.

Requires GDAL/OGR library version 1.11 or later.

One of options must be given:
       --file
       --date and --ftype

Usage: vfr2ogr.py [-f] [-o] [--file=/path/to/vfr/filename] [--date=YYYYMMDD] [--type=ST_ABCD|OB_000000_ABCD] [--format=<output format>] [--dsn=<OGR datasource>] [--layer=layer1,layer2,...]

       -f         List supported output formats
       -e         Extended layer list statistics 
       -o         Overwrite existing files
       --file     Path to xml.gz file
       --date     Date in format 'YYYYMMDD'
       --type     Type of request in format XY_ABCD, eg. 'ST_UKSH' or 'OB_000000_ABCD'
       --format   Output format
       --dsn      Output OGR datasource
       --layer    Import only selected layers separated by comma (if not given all layers are processed)
"""

import sys
from getopt import GetoptError

from vfr2ogr.ogr import check_ogr, open_file, list_layers, convert_vfr
from vfr2ogr.utils import fatal, message, parse_xml_gz, compare_list
from vfr2ogr.parse import parse_cmd

# print usage
def usage():
    print __doc__

def main():
    # check requirements
    check_ogr()

    # parse cmd arguments
    options = { 'format' : None, 'dsn' : None, 'overwrite' : False, 'extended' : False,
                'layer' : []}
    try:
        filename = parse_cmd(sys.argv, "hfeo", ["help", "overwrite", "extended",
                                               "file=", "date=", "type=",
                                               "format=", "dsn=", "layer="], options)
    except GetoptError, e:
        usage()
        fatal(e)

    # open input file by GML driver
    ids = open_file(filename)
    
    if options['format'] is None:
        # list available layers and exit
        layer_list = list_layers(ids, options['extended'])
        if options['extended']:
            compare_list(layer_list, parse_xml_gz(filename))
    else:
        if options['dsn'] is None:<commit_msg>new option layer (fix vfr2ogr)<commit_after>#!/usr/bin/env python

"""
Converts VFR file into desired GIS format supported by OGR library.

Requires GDAL/OGR library version 1.11 or later.

One of options must be given:
       --file
       --date and --ftype

Usage: vfr2ogr.py [-f] [-o] [--file=/path/to/vfr/filename] [--date=YYYYMMDD] [--type=ST_ABCD|OB_000000_ABCD] [--layer=layer1,layer2,...] [--format=<output format>] [--dsn=<OGR datasource>] 

       -f         List supported output formats
       -e         Extended layer list statistics 
       -o         Overwrite existing files
       --file     Path to xml.gz file
       --date     Date in format 'YYYYMMDD'
       --type     Type of request in format XY_ABCD, eg. 'ST_UKSH' or 'OB_000000_ABCD'
       --layer    Import only selected layers separated by comma (if not given all layers are processed)
       --format   Output format
       --dsn      Output OGR datasource
"""

import sys
from getopt import GetoptError

from vfr2ogr.ogr import check_ogr, open_file, list_layers, convert_vfr
from vfr2ogr.utils import fatal, message, parse_xml_gz, compare_list
from vfr2ogr.parse import parse_cmd

# print usage
def usage():
    print __doc__

def main():
    # check requirements
    check_ogr()

    # parse cmd arguments
    options = { 'format' : None, 'dsn' : None, 'overwrite' : False, 'extended' : False,
                'layer' : []}
    try:
        filename = parse_cmd(sys.argv, "hfeo", ["help", "overwrite", "extended",
                                               "file=", "date=", "type=", "layer=",
                                               "format=", "dsn="], options)
    except GetoptError, e:
        usage()
        fatal(e)

    # open input file by GML driver
    ids = open_file(filename)
    
    if options['format'] is None:
        # list available layers and exit
        layer_list = list_layers(ids, options['extended'])
        if options['extended']:
            compare_list(layer_list, parse_xml_gz(filename))
    else:
        if options['dsn'] is None:
{'fraction_non_alphanumeric': 0.11306042884990253, 'fraction_numerical': 0.010477582846003898, 'mean_word_length': 2.242496050552923, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6143576', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1226, 'n_words': 393}