Exemplo n.º 1
0
def test_standardise_quotes():

    v = '"the_geom from (select * from road where "name_e"=\'Trans-Canada Highway\' order by gid) as foo using unique gid using srid=3978"'

    q = Quoter(quote='"')
    v2 = q.standardise_quotes(v)
    exp = r'''"the_geom from (select * from road where \"name_e\"='Trans-Canada Highway' order by gid) as foo using unique gid using srid=3978"'''
    assert (v2 == exp)

    q = Quoter(quote="'")
    v2 = q.standardise_quotes(v)
    exp = r"""'the_geom from (select * from road where "name_e"=\'Trans-Canada Highway\' order by gid) as foo using unique gid using srid=3978'"""
    assert (v2 == exp)
Exemplo n.º 2
0
 def __init__(self,
              include_position=False,
              include_comments=False,
              trace_o_incl=None):
     self.quoter = Quoter()
     self.include_position = include_position
     self.include_comments = include_comments
     self.trace_o_incl = trace_o_incl
Exemplo n.º 3
0
def read_mapfile(fn, output_folder):

    mf = mappyfile.load(fn)
    quoter = Quoter()
    includes = []

    for l in (mf["layers"]):
        layer_file = quoter.remove_quotes(l["name"]) + ".txt"
        ofn = os.path.join(output_folder, layer_file)
        mappyfile.write(l, ofn)
        includes.append(quoter.add_quotes(layer_file))

    # now write the mapfile with includes
    ofn = os.path.join(output_folder, "_" + os.path.basename(fn))
    del mf["layers"]

    existing_includes = mf["include"]

    if (len(existing_includes)) > 0:
        mf["include"] += includes
    else:
        mf["include"] = includes

    mappyfile.write(mf, ofn)
Exemplo n.º 4
0
 def __init__(self, include_position=False, include_comments=False):
     self.quoter = Quoter()
     self.include_position = include_position
     self.include_comments = include_comments
Exemplo n.º 5
0
 def __init__(self):
     self.quoter = Quoter()
     self.include_position = False
     self.include_comments = False