MCPcopy
hub / github.com/psycopg/psycopg / parse_cmdline

Function parse_cmdline

tests/scripts/copytest.py:90–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89
90def parse_cmdline() -> Namespace:
91 parser = ArgumentParser(description=__doc__)
92 parser.add_argument("--dsn", default="", help="database connection string")
93 parser.add_argument(
94 "--async", action="store_true", default=False, help="test async objects"
95 )
96 parser.add_argument(
97 "--nrecs",
98 type=int,
99 default=1000,
100 help="number of records to write [default: %(default)s]",
101 )
102 parser.add_argument(
103 "--nfields",
104 type=int,
105 default=10,
106 help="number of columns to write [default: %(default)s]",
107 )
108 parser.add_argument(
109 "--colsize",
110 type=int,
111 default=10,
112 help="width of each column to write [default: %(default)s]",
113 )
114 parser.add_argument("--writer", help="test alternative writer")
115
116 g = parser.add_mutually_exclusive_group()
117 g.add_argument(
118 "-q",
119 "--quiet",
120 help="Talk less",
121 dest="loglevel",
122 action="store_const",
123 const=logging.WARN,
124 default=logging.INFO,
125 )
126 g.add_argument(
127 "-v",
128 "--verbose",
129 help="Talk more",
130 dest="loglevel",
131 action="store_const",
132 const=logging.DEBUG,
133 default=logging.INFO,
134 )
135
136 if (args := parser.parse_args()).writer:
137 try:
138 getattr(psycopg.copy, args.writer)
139 except AttributeError:
140 parser.error(f"unknown writer: {args.writer!r}")
141
142 return args
143
144
145if __name__ == "__main__":

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected