Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
10cf2180
Kaydet (Commit)
10cf2180
authored
Nis 17, 2003
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use True in a few more places.
Use isinstance(somestring, basestring) instead of type() as per PEP 8
üst
a6bdf2ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
libshlex.tex
Doc/lib/libshlex.tex
+1
-1
shlex.py
Lib/shlex.py
+5
-7
No files found.
Doc/lib/libshlex.tex
Dosyayı görüntüle @
10cf2180
...
...
@@ -177,7 +177,7 @@ includes just \character{"} by default.
\end{memberdesc}
\begin{memberdesc}
{
whitespace
_
split
}
If
true
, tokens will only be split in whitespaces. This is useful, for
If
\code
{
True
}
, tokens will only be split in whitespaces. This is useful, for
example, for parsing command lines with
\class
{
shlex
}
, getting tokens
in a similar way to shell arguments.
\versionadded
{
2.3
}
...
...
Lib/shlex.py
Dosyayı görüntüle @
10cf2180
...
...
@@ -10,8 +10,6 @@
import
os.path
import
sys
from
types
import
StringTypes
try
:
from
cStringIO
import
StringIO
except
ImportError
:
...
...
@@ -22,7 +20,7 @@ __all__ = ["shlex", "split"]
class
shlex
:
"A lexical analyzer class for simple shell-like syntaxes."
def
__init__
(
self
,
instream
=
None
,
infile
=
None
,
posix
=
False
):
if
type
(
instream
)
in
StringTypes
:
if
isinstance
(
instream
,
basestring
)
:
instream
=
StringIO
(
instream
)
if
instream
is
not
None
:
self
.
instream
=
instream
...
...
@@ -65,7 +63,7 @@ class shlex:
def
push_source
(
self
,
newstream
,
newfile
=
None
):
"Push an input source onto the lexer's input source stack."
if
type
(
newstream
)
in
StringTypes
:
if
isinstance
(
newstream
,
basestring
)
:
newstream
=
StringIO
(
newstream
)
self
.
filestack
.
insert
(
0
,
(
self
.
infile
,
self
.
instream
,
self
.
lineno
))
self
.
infile
=
newfile
...
...
@@ -122,7 +120,7 @@ class shlex:
def
read_token
(
self
):
quoted
=
False
escapedstate
=
' '
while
1
:
while
True
:
nextchar
=
self
.
instream
.
read
(
1
)
if
nextchar
==
'
\n
'
:
self
.
lineno
=
self
.
lineno
+
1
...
...
@@ -252,7 +250,7 @@ class shlex:
if
newfile
[
0
]
==
'"'
:
newfile
=
newfile
[
1
:
-
1
]
# This implements cpp-like semantics for relative-path inclusion.
if
type
(
self
.
infile
)
in
StringTypes
and
not
os
.
path
.
isabs
(
newfile
):
if
isinstance
(
self
.
infile
,
basestring
)
and
not
os
.
path
.
isabs
(
newfile
):
newfile
=
os
.
path
.
join
(
os
.
path
.
dirname
(
self
.
infile
),
newfile
)
return
(
newfile
,
open
(
newfile
,
"r"
))
...
...
@@ -273,7 +271,7 @@ class shlex:
raise
StopIteration
return
token
def
split
(
s
,
posix
=
1
,
spaces
=
1
):
def
split
(
s
,
posix
=
True
,
spaces
=
True
):
lex
=
shlex
(
s
,
posix
=
posix
)
lex
.
whitespace_split
=
spaces
return
list
(
lex
)
...
...
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