<s> import sys <EOL> import io <EOL> PY2 = ( sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> ) <EOL> if PY2 : <EOL> import unicodecsv , subprocess32 , uritemplate <EOL> unicodecsv . field_size_limit ( sys . maxsize ) <EOL> check_output = subprocess32 . check_output <EOL> CalledProcessError = subprocess32 . CalledProcessError <EOL> csvIO = io . BytesIO <EOL> def csvreader ( file , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if encoding is not None : <EOL> kwargs [ '<STR_LIT>' ] = encoding <EOL> if '<STR_LIT>' in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = str ( kwargs [ '<STR_LIT>' ] ) <EOL> return unicodecsv . reader ( file , ** kwargs ) <EOL> def csvwriter ( file , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if encoding is not None : <EOL> kwargs [ '<STR_LIT>' ] = encoding <EOL> return unicodecsv . writer ( file , ** kwargs ) <EOL> def csvDictReader ( file , encoding = None , delimiter = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if delimiter is not None : <EOL> kwargs [ '<STR_LIT>' ] = delimiter . encode ( '<STR_LIT:ascii>' ) <EOL> if encoding is not None : <EOL> kwargs [ '<STR_LIT>' ] = encoding <EOL> return unicodecsv . DictReader ( file , ** kwargs ) <EOL> def csvDictWriter ( file , fieldnames , encoding = None , delimiter = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if delimiter is not None : <EOL> kwargs [ '<STR_LIT>' ] = delimiter . encode ( '<STR_LIT:ascii>' ) <EOL> if encoding is not None : <EOL> kwargs [ '<STR_LIT>' ] = encoding <EOL> return unicodecsv . DictWriter ( file , fieldnames , ** kwargs ) <EOL> def csvopen ( filename , mode = '<STR_LIT:r>' , encoding = None ) : <EOL> '''<STR_LIT>''' <EOL> return io . FileIO ( filename , mode = mode ) <EOL> def expand_uri ( template , args ) : <EOL> '''<STR_LIT:U+0020>''' <EOL> new_args = { k : v for ( k , v ) in args . items ( ) if not hasattr ( v , '<STR_LIT>' ) } <EOL> new_args . update ( { k : v . encode ( '<STR_LIT:utf8>' ) for ( k , v ) in args . items ( ) if hasattr ( v , '<STR_LIT>' ) } ) <EOL> return uritemplate . expand ( template , new_args ) <EOL> from future import standard_library <EOL> standard_library . install_aliases ( ) <EOL> else : <EOL> import csv , subprocess <EOL> from uritemplate import expand as expand_uri <EOL> standard_library = None <EOL> check_output = subprocess . check_output <EOL> CalledProcessError = subprocess . CalledProcessError <EOL> csvIO = io . StringIO <EOL> def csvreader ( file , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if '<STR_LIT>' in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = str ( kwargs [ '<STR_LIT>' ] ) <EOL> return csv . reader ( file , ** kwargs ) <EOL> def csvwriter ( file , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return csv . writer ( file , ** kwargs ) <EOL> def csvDictReader ( file , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return csv . DictReader ( file , ** kwargs ) <EOL> def csvDictWriter ( file , fieldnames , encoding = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return csv . DictWriter ( file , fieldnames , ** kwargs ) <EOL> def csvopen ( filename , mode = '<STR_LIT:r>' , encoding = None ) : <EOL> '''<STR_LIT>''' <EOL> return io . open ( filename , mode = mode , encoding = encoding ) <EOL> try : <EOL> import cairo <EOL> except ImportError : <EOL> import cairocffi as cairo </s>
