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
2e7840fe
Kaydet (Commit)
2e7840fe
authored
Şub 09, 1999
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
The usual.
üst
01b7ced8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
71 deletions
+131
-71
configpa.py
Lib/dos-8x3/configpa.py
+43
-29
posixpat.py
Lib/dos-8x3/posixpat.py
+7
-0
queue.py
Lib/dos-8x3/queue.py
+40
-42
test_ntp.py
Lib/dos-8x3/test_ntp.py
+41
-0
No files found.
Lib/dos-8x3/configpa.py
Dosyayı görüntüle @
2e7840fe
...
...
@@ -24,34 +24,37 @@ ConfigParser -- responsible for for parsing a list of
methods:
__init__(defaults=None) -- create the parser and specify a
dictionary of intrinsic defaults. The
keys must be strings, the values must
be appropriate for
%
()s string
interpolation. Note that `__name__' is
always an intrinsic default; it's value
is the section's name.
__init__(defaults=None)
create the parser and specify a dictionary of intrinsic defaults. The
keys must be strings, the values must be appropriate for
%
()s string
interpolation. Note that `__name__' is always an intrinsic default;
it's value is the section's name.
sections() -- return all the configuration section names, sans DEFAULT
sections()
return all the configuration section names, sans DEFAULT
options(section)
-- return list of configuration options for the named
section
options(section)
return list of configuration options for the named
section
read(*filenames) -- read and parse the list of named configuration files
read(filenames)
read and parse the list of named configuration files
get(section, option, raw=0) -- return a string value for the named
option. All
%
interpolations are
expanded in the return values, based on
the defaults passed into the constructor
and the DEFAULT section.
get(section, option, raw=0, vars=None)
return a string value for the named option. All
%
interpolations are
expanded in the return values, based on the defaults passed into the
constructor and the DEFAULT section. Additional substitutions may be
provided using the `vars' argument, which must be a dictionary whose
contents override any pre-existing defaults.
getint(section, options) -- like get(), but convert value to an integer
getint(section, options)
like get(), but convert value to an integer
getfloat(section, options) -- like get(), but convert value to a float
getfloat(section, options)
like get(), but convert value to a float
getboolean(section, options)
-- like get(), but convert value to
a boolean (currently defined as 0
or
1, only)
getboolean(section, options)
like get(), but convert value to a boolean (currently defined as 0 or
1, only)
"""
import
sys
...
...
@@ -173,12 +176,14 @@ class ConfigParser:
except
IOError
:
pass
def
get
(
self
,
section
,
option
,
raw
=
0
):
def
get
(
self
,
section
,
option
,
raw
=
0
,
vars
=
None
):
"""Get an option value for a given section.
All
%
interpolations are expanded in the return values, based
on the defaults passed into the constructor, unless the optional
argument `raw' is true.
All
%
interpolations are expanded in the return values, based on the
defaults passed into the constructor, unless the optional argument
`raw' is true. Additional substitutions may be provided using the
`vars' argument, which must be a dictionary whose contents overrides
any pre-existing defaults.
The section DEFAULT is special.
"""
...
...
@@ -191,6 +196,9 @@ class ConfigParser:
raise
NoSectionError
(
section
)
d
=
self
.
__defaults
.
copy
()
d
.
update
(
sectdict
)
# Update with the entry specific variables
if
vars
:
d
.
update
(
vars
)
option
=
string
.
lower
(
option
)
try
:
rawval
=
d
[
option
]
...
...
@@ -199,11 +207,17 @@ class ConfigParser:
# do the string interpolation
if
raw
:
return
rawval
try
:
return
rawval
%
d
except
KeyError
,
key
:
raise
InterpolationError
(
key
,
option
,
section
,
rawval
)
value
=
rawval
# Make it a pretty variable name
while
1
:
# Loop through this until it's done
if
not
string
.
find
(
value
,
"
%
("
):
try
:
value
=
value
%
d
except
KeyError
,
key
:
raise
InterpolationError
(
key
,
option
,
section
,
rawval
)
else
:
return
value
def
__get
(
self
,
section
,
conv
,
option
):
return
conv
(
self
.
get
(
section
,
option
))
...
...
Lib/dos-8x3/posixpat.py
Dosyayı görüntüle @
2e7840fe
...
...
@@ -367,3 +367,10 @@ def normpath(path):
if
not
comps
and
not
slashes
:
comps
.
append
(
'.'
)
return
slashes
+
string
.
joinfields
(
comps
,
'/'
)
# Return an absolute path.
def
abspath
(
path
):
if
not
isabs
(
path
):
path
=
join
(
os
.
getcwd
(),
path
)
return
normpath
(
path
)
Lib/dos-8x3/queue.py
Dosyayı görüntüle @
2e7840fe
...
...
@@ -5,9 +5,14 @@
try
:
class
Empty
(
Exception
):
pass
class
Full
(
Exception
):
pass
except
TypeError
:
# string based exceptions
Empty
=
'Queue.Empty'
# Exception raised by get_nowait()
# exception raised by get(block=0)/get_nowait()
Empty
=
'Queue.Empty'
# exception raised by put(block=0)/put_nowait()
Full
=
'Queue.Full'
class
Queue
:
def
__init__
(
self
,
maxsize
):
...
...
@@ -23,32 +28,38 @@ class Queue:
self
.
fsema
=
thread
.
allocate_lock
()
def
qsize
(
self
):
"""Return
s
the approximate size of the queue (not reliable!)."""
"""Return the approximate size of the queue (not reliable!)."""
self
.
mutex
.
acquire
()
n
=
self
.
_qsize
()
self
.
mutex
.
release
()
return
n
def
empty
(
self
):
"""Return
s
1 if the queue is empty, 0 otherwise (not reliable!)."""
"""Return 1 if the queue is empty, 0 otherwise (not reliable!)."""
self
.
mutex
.
acquire
()
n
=
self
.
_empty
()
self
.
mutex
.
release
()
return
n
def
full
(
self
):
"""Return
s
1 if the queue is full, 0 otherwise (not reliable!)."""
"""Return 1 if the queue is full, 0 otherwise (not reliable!)."""
self
.
mutex
.
acquire
()
n
=
self
.
_full
()
self
.
mutex
.
release
()
return
n
def
put
(
self
,
item
):
def
put
(
self
,
item
,
block
=
1
):
"""Put an item into the queue.
If the queue is full, block until a free slot is avaiable.
"""
self
.
fsema
.
acquire
()
If optional arg 'block' is 1 (the default), block if
necessary until a free slot is available. Otherwise (block
is 0), put an item on the queue if a free slot is immediately
available, else raise the Full exception.
"""
if
block
:
self
.
fsema
.
acquire
()
elif
not
self
.
fsema
.
acquire
(
0
):
raise
Full
self
.
mutex
.
acquire
()
was_empty
=
self
.
_empty
()
self
.
_put
(
item
)
...
...
@@ -58,45 +69,27 @@ class Queue:
self
.
fsema
.
release
()
self
.
mutex
.
release
()
def
get
(
self
):
"""
Gets and returns an item from the queue
.
def
put_nowait
(
self
,
item
):
"""
Put an item into the queue without blocking
.
This method blocks if necessary until an item is available.
Only enqueue the item if a free slot is immediately available.
Otherwise raise the Full exception.
"""
self
.
esema
.
acquire
()
self
.
mutex
.
acquire
()
was_full
=
self
.
_full
()
item
=
self
.
_get
()
if
was_full
:
self
.
fsema
.
release
()
if
not
self
.
_empty
():
self
.
esema
.
release
()
self
.
mutex
.
release
()
return
item
return
self
.
put
(
item
,
0
)
# Get an item from the queue if one is immediately available,
# raise Empty if the queue is empty or temporarily unavailable
def
get_nowait
(
self
):
"""Gets and returns an item from the queue.
def
get
(
self
,
block
=
1
):
"""Remove and return an item from the queue.
Only gets an item if one is immediately available, Otherwise
this raises the Empty exception if the queue is empty or
temporarily unavailable.
If optional arg 'block' is 1 (the default), block if
necessary until an item is available. Otherwise (block is 0),
return an item if one is immediately available, else raise the
Empty exception.
"""
locked
=
self
.
esema
.
acquire
(
0
)
self
.
mutex
.
acquire
()
if
self
.
_empty
():
# The queue is empty -- we can't have esema
self
.
mutex
.
release
()
if
block
:
self
.
esema
.
acquire
()
elif
not
self
.
esema
.
acquire
(
0
):
raise
Empty
if
not
locked
:
locked
=
self
.
esema
.
acquire
(
0
)
if
not
locked
:
# Somebody else has esema
# but we have mutex --
# go out of their way
self
.
mutex
.
release
()
raise
Empty
self
.
mutex
.
acquire
()
was_full
=
self
.
_full
()
item
=
self
.
_get
()
if
was_full
:
...
...
@@ -106,8 +99,13 @@ class Queue:
self
.
mutex
.
release
()
return
item
# XXX Need to define put_nowait() as well.
def
get_nowait
(
self
):
"""Remove and return an item from the queue without blocking.
Only get an item if one is immediately available. Otherwise
raise the Empty exception.
"""
return
self
.
get
(
0
)
# Override these methods to implement other queue organizations
# (e.g. stack or priority queue).
...
...
Lib/dos-8x3/test_ntp.py
0 → 100644
Dosyayı görüntüle @
2e7840fe
import
ntpath
import
string
errors
=
0
def
tester
(
fn
,
wantResult
):
fn
=
string
.
replace
(
fn
,
"
\\
"
,
"
\\\\
"
)
gotResult
=
eval
(
fn
)
if
wantResult
!=
gotResult
:
print
"error!"
print
"evaluated: "
+
str
(
fn
)
print
"should be: "
+
str
(
wantResult
)
print
" returned: "
+
str
(
gotResult
)
print
""
global
errors
errors
=
errors
+
1
tester
(
'ntpath.splitdrive("c:
\\
foo
\\
bar")'
,
(
'c:'
,
'
\\
foo
\\
bar'
))
tester
(
'ntpath.splitdrive("
\\\\
conky
\\
mountpoint
\\
foo
\\
bar")'
,
(
'
\\\\
conky
\\
mountpoint'
,
'
\\
foo
\\
bar'
))
tester
(
'ntpath.splitdrive("c:/foo/bar")'
,
(
'c:'
,
'/foo/bar'
))
tester
(
'ntpath.splitdrive("//conky/mountpoint/foo/bar")'
,
(
'//conky/mountpoint'
,
'/foo/bar'
))
tester
(
'ntpath.split("c:
\\
foo
\\
bar")'
,
(
'c:
\\
foo'
,
'bar'
))
tester
(
'ntpath.split("
\\\\
conky
\\
mountpoint
\\
foo
\\
bar")'
,
(
'
\\\\
conky
\\
mountpoint
\\
foo'
,
'bar'
))
tester
(
'ntpath.split("c:
\\
")'
,
(
'c:
\\
'
,
''
))
tester
(
'ntpath.split("
\\\\
conky
\\
mountpoint
\\
")'
,
(
'
\\\\
conky
\\
mountpoint
\\
'
,
''
))
tester
(
'ntpath.split("c:/")'
,
(
'c:/'
,
''
))
tester
(
'ntpath.split("//conky/mountpoint/")'
,
(
'//conky/mountpoint/'
,
''
))
tester
(
'ntpath.isabs("c:
\\
")'
,
1
)
tester
(
'ntpath.isabs("
\\\\
conky
\\
mountpoint
\\
")'
,
1
)
tester
(
'ntpath.isabs("
\\
foo")'
,
1
)
tester
(
'ntpath.isabs("
\\
foo
\\
bar")'
,
1
)
if
errors
:
print
str
(
errors
)
+
" errors."
else
:
print
"No errors. Thank your lucky stars."
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