<commit_before>"""
PySAL ShapeFile Reader and Writer based on pure python shapefile module.

Authors:
<NAME> <<EMAIL>>

Not to be used without permission of the authors. 
"""

__author__ = "<NAME>"
__credits__ = "Copyright (c) 2009 <NAME>"

#import pysal
import pysal.core.FileIO #as FileIO
from _pyShpIO import shp_file
import pysal.cg as cg
from warnings import warn
import unittest

STRING_TO_TYPE = {'POLYGON':cg.Polygon,'POINT':cg.Point,'POINTM':cg.Point,'POINTZ':cg.Point,'ARC':cg.Chain}
TYPE_TO_STRING = {cg.Polygon:'POLYGON',cg.Point:'POINT',cg.Chain:'ARC'} #build the reverse map
for key,value in STRING_TO_TYPE.iteritems():
    TYPE_TO_STRING[value] = key

class PurePyShpWrapper(pysal.core.FileIO.FileIO):
    """
    FileIO handeler for ESRI ShapeFiles.

    Attributes:
    FORMATS -- list -- A list of support file extensions.
    MODES -- list -- A list of support file modes.

    Notes:
    This class wraps _pyShpIO's shp_file class with the PySAL FileIO API. shp_file can be used without PySAL.

    Example:
    >>> import tempfile
    >>> f = tempfile.NamedTemporaryFile(suffix='.shp',delete=False); fname = f.name; f.close()
    >>> import pysal
    >>> i = pysal.open('../../examples/10740.shp','r')
    >>> o = pysal.open(fname,'w')
    >>> for shp in i:<commit_msg>removing the delete argument from tempfile.NamedTemporaryFile that was added in python 2.6.<commit_after>"""
PySAL ShapeFile Reader and Writer based on pure python shapefile module.

Authors:
<NAME> <<EMAIL>>

Not to be used without permission of the authors. 
"""

__author__ = "<NAME>"
__credits__ = "Copyright (c) 2009 <NAME>"

#import pysal
import pysal.core.FileIO #as FileIO
from _pyShpIO import shp_file
import pysal.cg as cg
from warnings import warn
import unittest

STRING_TO_TYPE = {'POLYGON':cg.Polygon,'POINT':cg.Point,'POINTM':cg.Point,'POINTZ':cg.Point,'ARC':cg.Chain}
TYPE_TO_STRING = {cg.Polygon:'POLYGON',cg.Point:'POINT',cg.Chain:'ARC'} #build the reverse map
for key,value in STRING_TO_TYPE.iteritems():
    TYPE_TO_STRING[value] = key

class PurePyShpWrapper(pysal.core.FileIO.FileIO):
    """
    FileIO handeler for ESRI ShapeFiles.

    Attributes:
    FORMATS -- list -- A list of support file extensions.
    MODES -- list -- A list of support file modes.

    Notes:
    This class wraps _pyShpIO's shp_file class with the PySAL FileIO API. shp_file can be used without PySAL.

    Example:
    >>> import tempfile
    >>> f = tempfile.NamedTemporaryFile(suffix='.shp'); fname = f.name; f.close()
    >>> import pysal
    >>> i = pysal.open('../../examples/10740.shp','r')
    >>> o = pysal.open(fname,'w')
    >>> for shp in i:
{'fraction_non_alphanumeric': 0.13194706994328922, 'fraction_numerical': 0.007561436672967864, 'mean_word_length': 3.9643527204502815, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, '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': '4013882', 'n_tokens_mistral': 958, 'n_tokens_neox': 904, 'n_words': 260}