MCPcopy Create free account
hub / github.com/ActiveState/code / parse_options

Function parse_options

recipes/Python/576551_Simple_Web_Crawler/recipe-576551.py:134–161  ·  view source on GitHub ↗

parse_options() -> opts, args Parse any command-line options given returning both the parsed options and arguments.

()

Source from the content-addressed store, hash-verified

132 print "%d. %s" % (i, url)
133
134def parse_options():
135 """parse_options() -> opts, args
136
137 Parse any command-line options given returning both
138 the parsed options and arguments.
139 """
140
141 parser = optparse.OptionParser(usage=USAGE, version=VERSION)
142
143 parser.add_option("-q", "--quiet",
144 action="store_true", default=False, dest="quiet",
145 help="Enable quiet mode")
146
147 parser.add_option("-l", "--links",
148 action="store_true", default=False, dest="links",
149 help="Get links for specified url only")
150
151 parser.add_option("-d", "--depth",
152 action="store", type="int", default=30, dest="depth",
153 help="Maximum depth to traverse")
154
155 opts, args = parser.parse_args()
156
157 if len(args) < 1:
158 parser.print_help()
159 raise SystemExit, 1
160
161 return opts, args
162
163def main():
164 opts, args = parse_options()

Callers 1

mainFunction · 0.70

Calls 2

print_helpMethod · 0.80
parse_argsMethod · 0.45

Tested by

no test coverage detected