Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
24315238
Commit
24315238
authored
Apr 17, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- use Tue/False for booleans
- some very minor cleanups
parent
dbd6503e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
Lib/shlex.py
Lib/shlex.py
+8
-9
No files found.
Lib/shlex.py
View file @
24315238
...
...
@@ -21,7 +21,7 @@ __all__ = ["shlex", "split"]
class
shlex
:
"A lexical analyzer class for simple shell-like syntaxes."
def
__init__
(
self
,
instream
=
None
,
infile
=
None
,
posix
=
0
):
def
__init__
(
self
,
instream
=
None
,
infile
=
None
,
posix
=
False
):
if
type
(
instream
)
in
StringTypes
:
instream
=
StringIO
(
instream
)
if
instream
is
not
None
:
...
...
@@ -42,7 +42,7 @@ class shlex:
self
.
wordchars
+=
(
''
''
)
self
.
whitespace
=
'
\
t
\
r
\
n
'
self
.
whitespace_split
=
0
self
.
whitespace_split
=
False
self
.
quotes
=
'
\
'
"'
self
.
escape
=
'
\
\
'
self
.
escapedquotes
=
'"'
...
...
@@ -61,7 +61,7 @@ class shlex:
"Push a token onto the stack popped by the get_token method"
if
self
.
debug
>=
1
:
print
"shlex: pushing token "
+
`tok`
self
.
pushback
=
[
tok
]
+
self
.
pushback
self
.
pushback
.
insert
(
0
,
tok
)
def
push_source
(
self
,
newstream
,
newfile
=
None
):
"Push an input source onto the lexer's input source stack."
...
...
@@ -90,8 +90,7 @@ class shlex:
def
get_token
(
self
):
"Get a token from the input stream (or from stack if it's nonempty)"
if
self
.
pushback
:
tok
=
self
.
pushback
[
0
]
self
.
pushback
=
self
.
pushback
[
1
:]
tok
=
self
.
pushback
.
pop
(
0
)
if
self
.
debug
>=
1
:
print
"shlex: popping token "
+
`tok`
return
tok
...
...
@@ -107,7 +106,7 @@ class shlex:
raw
=
self
.
get_token
()
# Maybe we got EOF instead?
while
raw
==
self
.
eof
:
if
len
(
self
.
filestack
)
==
0
:
if
not
self
.
filestack
:
return
self
.
eof
else
:
self
.
pop_source
()
...
...
@@ -121,7 +120,7 @@ class shlex:
return
raw
def
read_token
(
self
):
quoted
=
0
quoted
=
False
escapedstate
=
' '
while
1
:
nextchar
=
self
.
instream
.
read
(
1
)
...
...
@@ -167,7 +166,7 @@ class shlex:
else
:
continue
elif
self
.
state
in
self
.
quotes
:
quoted
=
1
quoted
=
True
if
not
nextchar
:
# end of file
if
self
.
debug
>=
2
:
print
"shlex: I see EOF in quotes state"
...
...
@@ -229,7 +228,7 @@ class shlex:
or
self
.
whitespace_split
:
self
.
token
=
self
.
token
+
nextchar
else
:
self
.
pushback
=
[
nextchar
]
+
self
.
pushback
self
.
pushback
.
insert
(
0
,
nextchar
)
if
self
.
debug
>=
2
:
print
"shlex: I see punctuation in word state"
self
.
state
=
' '
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment