Source code for uw.parse.postgres_pgpass

import re

from .delimited import *

[docs]def split_line (line): """Split a line of a .pgpass file into fields. Currently this just splits on ':'. In order to be strictly correct, it should convert escaped ':' and '\\' and split only on non-escaped ':'. See Postgres documentation: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html """ return line.split (':')
postgres_pgpass_spec = ( ('hostname', readString), ('port', readString), ('database', readString), ('username', readString), ('password', readString), )
[docs]def parse_pgpass (infile, loc=Location()): return parseLines (split_line, postgres_pgpass_spec, loc, decomment (readLines (infile)))
if __name__ == "__main__": for line in parse_pgpass (sys.stdin): print(line)