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
1bc82f89
Kaydet (Commit)
1bc82f89
authored
Ara 05, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed deprecated method arguments from the shelve module.
üst
7cf9ce24
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
34 deletions
+25
-34
libshelve.tex
Doc/lib/libshelve.tex
+8
-10
shelve.py
Lib/shelve.py
+7
-16
test_shelve.py
Lib/test/test_shelve.py
+8
-8
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libshelve.tex
Dosyayı görüntüle @
1bc82f89
...
...
@@ -13,7 +13,7 @@ instances, recursive data types, and objects containing lots of shared
sub-objects. The keys are ordinary strings.
\refstmodindex
{
pickle
}
\begin{funcdesc}
{
open
}{
filename
\optional
{
,flag='c'
\optional
{
,protocol=
\code
{
None
}
\optional
{
,writeback=
\code
{
False
}
\optional
{
,binary=
\code
{
None
}}
}}}}
\begin{funcdesc}
{
open
}{
filename
\optional
{
,flag='c'
\optional
{
,protocol=
\code
{
None
}
\optional
{
,writeback=
\code
{
False
}}}}}
Open a persistent dictionary. The filename specified is the base filename
for the underlying database. As a side-effect, an extension may be added to
the filename and more than one file may be created. By default, the
...
...
@@ -24,8 +24,7 @@ parameter of \function{anydbm.open}.
By default, version 0 pickles are used to serialize values.
The version of the pickle protocol can be specified with the
\var
{
protocol
}
parameter.
\versionchanged
[The
\var
{
protocol
}
parameter was added. The
\var
{
binary
}
parameter is deprecated
and provided for backwards compatibility only]
{
2.3
}
parameter was added]
{
2.3
}
By default, mutations to persistent-dictionary mutable entries are not
automatically written back. If the optional
\var
{
writeback
}
parameter
...
...
@@ -76,7 +75,7 @@ requires knowledge about the database implementation used.
\end{itemize}
\begin{classdesc}
{
Shelf
}{
dict
\optional
{
, protocol=None
\optional
{
, writeback=False
\optional
{
, binary=None
}
}}}
\begin{classdesc}
{
Shelf
}{
dict
\optional
{
, protocol=None
\optional
{
, writeback=False
}}}
A subclass of
\class
{
UserDict.DictMixin
}
which stores pickled values in the
\var
{
dict
}
object.
...
...
@@ -84,8 +83,7 @@ By default, version 0 pickles are used to serialize values. The
version of the pickle protocol can be specified with the
\var
{
protocol
}
parameter. See the
\module
{
pickle
}
documentation for a
discussion of the pickle protocols.
\versionchanged
[The
\var
{
protocol
}
parameter was added. The
\var
{
binary
}
parameter is deprecated and
provided for backwards compatibility only]
{
2.3
}
parameter was added]
{
2.3
}
If the
\var
{
writeback
}
parameter is
\code
{
True
}
, the object will hold a
cache of all entries accessed and write them back to the
\var
{
dict
}
at
...
...
@@ -93,7 +91,7 @@ sync and close times. This allows natural operations on mutable entries,
but can consume much more memory and make sync and close take a long time.
\end{classdesc}
\begin{classdesc}
{
BsdDbShelf
}{
dict
\optional
{
, protocol=None
\optional
{
, writeback=False
\optional
{
, binary=None
}
}}}
\begin{classdesc}
{
BsdDbShelf
}{
dict
\optional
{
, protocol=None
\optional
{
, writeback=False
}}}
A subclass of
\class
{
Shelf
}
which exposes
\method
{
first
}
,
\method
{
next
}
,
\method
{
previous
}
,
\method
{
last
}
and
...
...
@@ -102,19 +100,19 @@ but not in other database modules. The \var{dict} object passed to
the constructor must support those methods. This is generally
accomplished by calling one of
\function
{
bsddb.hashopen
}
,
\function
{
bsddb.btopen
}
or
\function
{
bsddb.rnopen
}
. The optional
\var
{
protocol
}
,
\var
{
writeback
}
, and
\var
{
binary
}
parameters have the
\var
{
protocol
}
and
\var
{
writeback
}
parameters have the
same interpretation as for the
\class
{
Shelf
}
class.
\end{classdesc}
\begin{classdesc}
{
DbfilenameShelf
}{
filename
\optional
{
, flag='c'
\optional
{
, protocol=None
\optional
{
, writeback=False
\optional
{
, binary=None
}
}}}}
\begin{classdesc}
{
DbfilenameShelf
}{
filename
\optional
{
, flag='c'
\optional
{
, protocol=None
\optional
{
, writeback=False
}}}}
A subclass of
\class
{
Shelf
}
which accepts a
\var
{
filename
}
instead of
a dict-like object. The underlying file will be opened using
{}
\function
{
anydbm.open
}
. By default, the file will be created and
opened for both read and write. The optional
\var
{
flag
}
parameter has
the same interpretation as for the
\function
{
open
}
function. The
optional
\var
{
protocol
}
,
\var
{
writeback
}
, and
\var
{
binary
}
parameters
optional
\var
{
protocol
}
and
\var
{
writeback
}
parameters
have the same interpretation as for the
\class
{
Shelf
}
class.
\end{classdesc}
...
...
Lib/shelve.py
Dosyayı görüntüle @
1bc82f89
...
...
@@ -80,14 +80,8 @@ class Shelf(UserDict.DictMixin):
See the module's __doc__ string for an overview of the interface.
"""
def
__init__
(
self
,
dict
,
protocol
=
None
,
writeback
=
False
,
binary
=
None
):
def
__init__
(
self
,
dict
,
protocol
=
None
,
writeback
=
False
):
self
.
dict
=
dict
if
protocol
is
not
None
and
binary
is
not
None
:
raise
ValueError
,
"can't specify both 'protocol' and 'binary'"
if
binary
is
not
None
:
warnings
.
warn
(
"The 'binary' argument to Shelf() is deprecated"
,
PendingDeprecationWarning
)
protocol
=
int
(
binary
)
if
protocol
is
None
:
protocol
=
0
self
.
_protocol
=
protocol
...
...
@@ -171,8 +165,8 @@ class BsdDbShelf(Shelf):
See the module's __doc__ string for an overview of the interface.
"""
def
__init__
(
self
,
dict
,
protocol
=
None
,
writeback
=
False
,
binary
=
None
):
Shelf
.
__init__
(
self
,
dict
,
protocol
,
writeback
,
binary
)
def
__init__
(
self
,
dict
,
protocol
=
None
,
writeback
=
False
):
Shelf
.
__init__
(
self
,
dict
,
protocol
,
writeback
)
def
set_location
(
self
,
key
):
(
key
,
value
)
=
self
.
dict
.
set_location
(
key
)
...
...
@@ -207,12 +201,12 @@ class DbfilenameShelf(Shelf):
See the module's __doc__ string for an overview of the interface.
"""
def
__init__
(
self
,
filename
,
flag
=
'c'
,
protocol
=
None
,
writeback
=
False
,
binary
=
None
):
def
__init__
(
self
,
filename
,
flag
=
'c'
,
protocol
=
None
,
writeback
=
False
):
import
anydbm
Shelf
.
__init__
(
self
,
anydbm
.
open
(
filename
,
flag
),
protocol
,
writeback
,
binary
)
Shelf
.
__init__
(
self
,
anydbm
.
open
(
filename
,
flag
),
protocol
,
writeback
)
def
open
(
filename
,
flag
=
'c'
,
protocol
=
None
,
writeback
=
False
,
binary
=
None
):
def
open
(
filename
,
flag
=
'c'
,
protocol
=
None
,
writeback
=
False
):
"""Open a persistent dictionary for reading and writing.
The filename parameter is the base filename for the underlying
...
...
@@ -222,10 +216,7 @@ def open(filename, flag='c', protocol=None, writeback=False, binary=None):
anydbm.open(). The optional protocol parameter specifies the
version of the pickle protocol (0, 1, or 2).
The optional binary parameter is deprecated and may be set to True
to force the use of binary pickles for serializing data values.
See the module's __doc__ string for an overview of the interface.
"""
return
DbfilenameShelf
(
filename
,
flag
,
protocol
,
writeback
,
binary
)
return
DbfilenameShelf
(
filename
,
flag
,
protocol
,
writeback
)
Lib/test/test_shelve.py
Dosyayı görüntüle @
1bc82f89
...
...
@@ -10,7 +10,7 @@ class TestCase(unittest.TestCase):
def
test_ascii_file_shelf
(
self
):
try
:
s
=
shelve
.
open
(
self
.
fn
,
binary
=
False
)
s
=
shelve
.
open
(
self
.
fn
,
protocol
=
0
)
s
[
'key1'
]
=
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
s
[
'key1'
],
(
1
,
2
,
3
,
4
))
s
.
close
()
...
...
@@ -20,7 +20,7 @@ class TestCase(unittest.TestCase):
def
test_binary_file_shelf
(
self
):
try
:
s
=
shelve
.
open
(
self
.
fn
,
binary
=
True
)
s
=
shelve
.
open
(
self
.
fn
,
protocol
=
1
)
s
[
'key1'
]
=
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
s
[
'key1'
],
(
1
,
2
,
3
,
4
))
s
.
close
()
...
...
@@ -40,12 +40,12 @@ class TestCase(unittest.TestCase):
def
test_in_memory_shelf
(
self
):
d1
=
{}
s
=
shelve
.
Shelf
(
d1
,
binary
=
False
)
s
=
shelve
.
Shelf
(
d1
,
protocol
=
0
)
s
[
'key1'
]
=
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
s
[
'key1'
],
(
1
,
2
,
3
,
4
))
s
.
close
()
d2
=
{}
s
=
shelve
.
Shelf
(
d2
,
binary
=
True
)
s
=
shelve
.
Shelf
(
d2
,
protocol
=
1
)
s
[
'key1'
]
=
(
1
,
2
,
3
,
4
)
self
.
assertEqual
(
s
[
'key1'
],
(
1
,
2
,
3
,
4
))
s
.
close
()
...
...
@@ -102,19 +102,19 @@ class TestShelveBase(mapping_tests.BasicTestMappingProtocol):
os
.
unlink
(
f
)
class
TestAsciiFileShelve
(
TestShelveBase
):
_args
=
{
'
binary'
:
False
}
_args
=
{
'
protocol'
:
0
}
_in_mem
=
False
class
TestBinaryFileShelve
(
TestShelveBase
):
_args
=
{
'
binary'
:
True
}
_args
=
{
'
protocol'
:
1
}
_in_mem
=
False
class
TestProto2FileShelve
(
TestShelveBase
):
_args
=
{
'protocol'
:
2
}
_in_mem
=
False
class
TestAsciiMemShelve
(
TestShelveBase
):
_args
=
{
'
binary'
:
False
}
_args
=
{
'
protocol'
:
0
}
_in_mem
=
True
class
TestBinaryMemShelve
(
TestShelveBase
):
_args
=
{
'
binary'
:
True
}
_args
=
{
'
protocol'
:
1
}
_in_mem
=
True
class
TestProto2MemShelve
(
TestShelveBase
):
_args
=
{
'protocol'
:
2
}
...
...
Misc/NEWS
Dosyayı görüntüle @
1bc82f89
...
...
@@ -21,6 +21,8 @@ Extension Modules
Library
-------
- the shelve module no longer uses the deprecated binary parameter.
- the pstats module no longer uses the deprecated ignore() method.
- the filecmp module no longer uses the deprecated use_statcache argument.
...
...
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