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

Method __init__

Lib/shlex.py:17–64  ·  view source on GitHub ↗
(self, instream=None, infile=None, posix=False,
                 punctuation_chars=False)

Source from the content-addressed store, hash-verified

15class shlex:
16 "A lexical analyzer class for simple shell-like syntaxes."
17 def __init__(self, instream=None, infile=None, posix=False,
18 punctuation_chars=False):
19 from collections import deque # deferred import for performance
20
21 if isinstance(instream, str):
22 instream = StringIO(instream)
23 if instream is not None:
24 self.instream = instream
25 self.infile = infile
26 else:
27 self.instream = sys.stdin
28 self.infile = None
29 self.posix = posix
30 if posix:
31 self.eof = None
32 else:
33 self.eof = ''
34 self.commenters = '#'
35 self.wordchars = ('abcdfeghijklmnopqrstuvwxyz'
36 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_')
37 if self.posix:
38 self.wordchars += ('ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
39 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ')
40 self.whitespace = ' \t\r\n'
41 self.whitespace_split = False
42 self.quotes = '\'"'
43 self.escape = '\\'
44 self.escapedquotes = '"'
45 self.state = ' '
46 self.pushback = deque()
47 self.lineno = 1
48 self.debug = 0
49 self.token = ''
50 self.filestack = deque()
51 self.source = None
52 if not punctuation_chars:
53 punctuation_chars = ''
54 elif punctuation_chars is True:
55 punctuation_chars = '();<>|&'
56 self._punctuation_chars = punctuation_chars
57 if punctuation_chars:
58 # _pushback_chars is a push back queue used by lookahead logic
59 self._pushback_chars = deque()
60 # these chars added because allowed in file names, args, wildcards
61 self.wordchars += '~-./*?='
62 #remove any punctuation chars from wordchars
63 t = self.wordchars.maketrans(dict.fromkeys(punctuation_chars))
64 self.wordchars = self.wordchars.translate(t)
65
66 @property
67 def punctuation_chars(self):

Callers

nothing calls this directly

Calls 4

StringIOClass · 0.90
maketransMethod · 0.80
fromkeysMethod · 0.45
translateMethod · 0.45

Tested by

no test coverage detected