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
e5c12f67
Kaydet (Commit)
e5c12f67
authored
Eyl 01, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23613 -- Removed django.utils.checksums per deprecation timeline.
üst
96317ad8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
67 deletions
+0
-67
checksums.py
django/utils/checksums.py
+0
-34
test_checksums.py
tests/utils_tests/test_checksums.py
+0
-33
No files found.
django/utils/checksums.py
deleted
100644 → 0
Dosyayı görüntüle @
96317ad8
"""
Common checksum routines.
"""
__all__
=
[
'luhn'
]
import
warnings
from
django.utils
import
six
from
django.utils.deprecation
import
RemovedInDjango110Warning
warnings
.
warn
(
"django.utils.checksums will be removed in Django 1.10. The "
"luhn() function is now included in django-localflavor 1.1+."
,
RemovedInDjango110Warning
)
LUHN_ODD_LOOKUP
=
(
0
,
2
,
4
,
6
,
8
,
1
,
3
,
5
,
7
,
9
)
# sum_of_digits(index * 2)
def
luhn
(
candidate
):
"""
Checks a candidate number for validity according to the Luhn
algorithm (used in validation of, for example, credit cards).
Both numeric and string candidates are accepted.
"""
if
not
isinstance
(
candidate
,
six
.
string_types
):
candidate
=
str
(
candidate
)
try
:
evens
=
sum
(
int
(
c
)
for
c
in
candidate
[
-
1
::
-
2
])
odds
=
sum
(
LUHN_ODD_LOOKUP
[
int
(
c
)]
for
c
in
candidate
[
-
2
::
-
2
])
return
((
evens
+
odds
)
%
10
==
0
)
except
ValueError
:
# Raised if an int conversion fails
return
False
tests/utils_tests/test_checksums.py
deleted
100644 → 0
Dosyayı görüntüle @
96317ad8
import
unittest
from
django.test
import
ignore_warnings
from
django.utils.deprecation
import
RemovedInDjango110Warning
class
TestUtilsChecksums
(
unittest
.
TestCase
):
def
check_output
(
self
,
function
,
value
,
output
=
None
):
"""
Check that function(value) equals output. If output is None,
check that function(value) equals value.
"""
if
output
is
None
:
output
=
value
self
.
assertEqual
(
function
(
value
),
output
)
@ignore_warnings
(
category
=
RemovedInDjango110Warning
)
def
test_luhn
(
self
):
from
django.utils
import
checksums
f
=
checksums
.
luhn
items
=
(
(
4111111111111111
,
True
),
(
'4111111111111111'
,
True
),
(
4222222222222
,
True
),
(
378734493671000
,
True
),
(
5424000000000015
,
True
),
(
5555555555554444
,
True
),
(
1008
,
True
),
(
'0000001008'
,
True
),
(
'000000001008'
,
True
),
(
4012888888881881
,
True
),
(
1234567890123456789012345678909
,
True
),
(
4111111111211111
,
False
),
(
42222222222224
,
False
),
(
100
,
False
),
(
'100'
,
False
),
(
'0000100'
,
False
),
(
'abc'
,
False
),
(
None
,
False
),
(
object
(),
False
),
)
for
value
,
output
in
items
:
self
.
check_output
(
f
,
value
,
output
)
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