MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Lib/quopri.py:188–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186
187
188def main():
189 import sys
190 import getopt
191 try:
192 opts, args = getopt.getopt(sys.argv[1:], 'td')
193 except getopt.error as msg:
194 sys.stdout = sys.stderr
195 print(msg)
196 print("usage: quopri [-t | -d] [file] ...")
197 print("-t: quote tabs")
198 print("-d: decode; default encode")
199 sys.exit(2)
200 deco = False
201 tabs = False
202 for o, a in opts:
203 if o == '-t': tabs = True
204 if o == '-d': deco = True
205 if tabs and deco:
206 sys.stdout = sys.stderr
207 print("-t and -d are mutually exclusive")
208 sys.exit(2)
209 if not args: args = ['-']
210 sts = 0
211 for file in args:
212 if file == '-':
213 fp = sys.stdin.buffer
214 else:
215 try:
216 fp = open(file, "rb")
217 except OSError as msg:
218 sys.stderr.write("%s: can't open (%s)\n" % (file, msg))
219 sts = 1
220 continue
221 try:
222 if deco:
223 decode(fp, sys.stdout.buffer)
224 else:
225 encode(fp, sys.stdout.buffer, tabs)
226 finally:
227 if file != '-':
228 fp.close()
229 if sts:
230 sys.exit(sts)
231
232
233

Callers 1

quopri.pyFile · 0.70

Calls 6

openFunction · 0.70
decodeFunction · 0.70
encodeFunction · 0.70
exitMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…