Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
e93e0c03
Kaydet (Commit)
e93e0c03
authored
Haz 10, 2015
tarafından
Carson Gee
Kaydeden (comit)
Tim Graham
Haz 12, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24963 -- Added File.seekable() on Python 3.
üst
3c593ba7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletion
+27
-1
utils.py
django/core/files/utils.py
+5
-0
file.txt
docs/ref/files/file.txt
+6
-1
1.9.txt
docs/releases/1.9.txt
+3
-0
tests.py
tests/files/tests.py
+13
-0
No files found.
django/core/files/utils.py
Dosyayı görüntüle @
e93e0c03
from
django.utils
import
six
class
FileProxyMixin
(
object
):
"""
A mixin class used to forward file methods to an underlaying file
...
...
@@ -24,6 +27,8 @@ class FileProxyMixin(object):
write
=
property
(
lambda
self
:
self
.
file
.
write
)
writelines
=
property
(
lambda
self
:
self
.
file
.
writelines
)
xreadlines
=
property
(
lambda
self
:
self
.
file
.
xreadlines
)
if
six
.
PY3
:
seekable
=
property
(
lambda
self
:
self
.
file
.
seekable
)
def
__iter__
(
self
):
return
iter
(
self
.
file
)
docs/ref/files/file.txt
Dosyayı görüntüle @
e93e0c03
...
...
@@ -89,7 +89,12 @@ The ``File`` Class
the following attributes and methods of its ``file`` object:
``encoding``, ``fileno``, ``flush``, ``isatty``, ``newlines``,
``read``, ``readinto``, ``readlines``, ``seek``, ``softspace``, ``tell``,
``truncate``, ``writelines``, ``xreadlines``.
``truncate``, ``writelines``, ``xreadlines``. If you are using
Python 3, the ``seekable`` method is also available.
.. versionchanged:: 1.9
The ``seekable`` method was added.
.. currentmodule:: django.core.files.base
...
...
docs/releases/1.9.txt
Dosyayı görüntüle @
e93e0c03
...
...
@@ -200,6 +200,9 @@ File Storage
<django.core.files.storage.Storage.get_valid_name>` is now called when
the :attr:`~django.db.models.FileField.upload_to` is a callable.
* :class:`~django.core.files.File` now has the ``seekable()`` method when using
Python 3.
File Uploads
^^^^^^^^^^^^
...
...
tests/files/tests.py
Dosyayı görüntüle @
e93e0c03
...
...
@@ -120,6 +120,19 @@ class FileTests(unittest.TestCase):
f
=
File
(
StringIO
(
'one
\n
two
\n
three'
))
self
.
assertEqual
(
list
(
f
),
[
'one
\n
'
,
'two
\n
'
,
'three'
])
def
test_seekable
(
self
):
"""
File.seekable() should be available on Python 3.
"""
with
tempfile
.
TemporaryFile
()
as
temp
:
temp
.
write
(
b
"contents
\n
"
)
test_file
=
File
(
temp
,
name
=
"something.txt"
)
if
six
.
PY2
:
self
.
assertFalse
(
hasattr
(
test_file
,
'seekable'
))
if
six
.
PY3
:
self
.
assertTrue
(
hasattr
(
test_file
,
'seekable'
))
self
.
assertTrue
(
test_file
.
seekable
())
class
NoNameFileTestCase
(
unittest
.
TestCase
):
"""
...
...
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