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
93cdd07e
Kaydet (Commit)
93cdd07e
authored
Kas 22, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Kas 23, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used bytes.hex() and bytes.fromhex() to simplify.
üst
3f237c1a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
23 deletions
+11
-23
geometries.py
django/contrib/gis/gdal/geometries.py
+2
-2
schema.py
django/db/backends/oracle/schema.py
+1
-3
schema.py
django/db/backends/sqlite3/schema.py
+2
-8
test_geom.py
tests/gis_tests/gdal_tests/test_geom.py
+1
-2
test_geos.py
tests/gis_tests/geos_tests/test_geos.py
+3
-3
test_crypto.py
tests/utils_tests/test_crypto.py
+2
-5
No files found.
django/contrib/gis/gdal/geometries.py
Dosyayı görüntüle @
93cdd07e
...
...
@@ -39,7 +39,7 @@
True True
"""
import
sys
from
binascii
import
a2b_hex
,
b2a_hex
from
binascii
import
b2a_hex
from
ctypes
import
byref
,
c_char_p
,
c_double
,
c_ubyte
,
c_void_p
,
string_at
from
django.contrib.gis.gdal.base
import
GDALBase
...
...
@@ -67,7 +67,7 @@ class OGRGeometry(GDALBase):
# If HEX, unpack input to a binary buffer.
if
str_instance
and
hex_regex
.
match
(
geom_input
):
geom_input
=
memoryview
(
a2b_hex
(
geom_input
.
upper
()
.
encode
()
))
geom_input
=
memoryview
(
bytes
.
fromhex
(
geom_input
))
str_instance
=
False
# Constructing the geometry,
...
...
django/db/backends/oracle/schema.py
Dosyayı görüntüle @
93cdd07e
import
binascii
import
copy
import
datetime
import
re
from
django.db.backends.base.schema
import
BaseDatabaseSchemaEditor
from
django.db.utils
import
DatabaseError
from
django.utils.encoding
import
force_text
class
DatabaseSchemaEditor
(
BaseDatabaseSchemaEditor
):
...
...
@@ -25,7 +23,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
elif
isinstance
(
value
,
str
):
return
"'
%
s'"
%
value
.
replace
(
"
\'
"
,
"
\'\'
"
)
elif
isinstance
(
value
,
(
bytes
,
bytearray
,
memoryview
)):
return
"'
%
s'"
%
force_text
(
binascii
.
hexlify
(
value
)
)
return
"'
%
s'"
%
value
.
hex
(
)
elif
isinstance
(
value
,
bool
):
return
"1"
if
value
else
"0"
else
:
...
...
django/db/backends/sqlite3/schema.py
Dosyayı görüntüle @
93cdd07e
import
codecs
import
contextlib
import
copy
from
decimal
import
Decimal
...
...
@@ -49,13 +48,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
elif
isinstance
(
value
,
(
bytes
,
bytearray
,
memoryview
)):
# Bytes are only allowed for BLOB fields, encoded as string
# literals containing hexadecimal data and preceded by a single "X"
# character:
# value = b'\x01\x02' => value_hex = b'0102' => return X'0102'
value
=
bytes
(
value
)
hex_encoder
=
codecs
.
getencoder
(
'hex_codec'
)
value_hex
,
_length
=
hex_encoder
(
value
)
# Use 'ascii' encoding for b'01' => '01', no need to use force_text here.
return
"X'
%
s'"
%
value_hex
.
decode
(
'ascii'
)
# character.
return
"X'
%
s'"
%
value
.
hex
()
else
:
raise
ValueError
(
"Cannot quote parameter value
%
r of type
%
s"
%
(
value
,
type
(
value
)))
...
...
tests/gis_tests/gdal_tests/test_geom.py
Dosyayı görüntüle @
93cdd07e
import
json
import
pickle
from
binascii
import
b2a_hex
from
django.contrib.gis.gdal
import
(
CoordTransform
,
GDALException
,
OGRGeometry
,
OGRGeomType
,
SpatialReference
,
...
...
@@ -100,7 +99,7 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
for
g
in
self
.
geometries
.
hex_wkt
:
geom1
=
OGRGeometry
(
g
.
wkt
)
wkb
=
geom1
.
wkb
self
.
assertEqual
(
b2a_hex
(
wkb
)
.
upper
(),
g
.
hex
.
encode
()
)
self
.
assertEqual
(
wkb
.
hex
()
.
upper
(),
g
.
hex
)
# Constructing w/WKB.
geom2
=
OGRGeometry
(
wkb
)
self
.
assertEqual
(
geom1
,
geom2
)
...
...
tests/gis_tests/geos_tests/test_geos.py
Dosyayı görüntüle @
93cdd07e
...
...
@@ -2,7 +2,7 @@ import ctypes
import
json
import
pickle
import
random
from
binascii
import
a2b_hex
,
b2a_hex
from
binascii
import
a2b_hex
from
io
import
BytesIO
from
unittest
import
mock
...
...
@@ -102,7 +102,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
for
g
in
self
.
geometries
.
hex_wkt
:
geom
=
fromstr
(
g
.
wkt
)
wkb
=
geom
.
wkb
self
.
assertEqual
(
b2a_hex
(
wkb
)
.
decode
()
.
upper
(),
g
.
hex
)
self
.
assertEqual
(
wkb
.
hex
()
.
upper
(),
g
.
hex
)
def
test_create_hex
(
self
):
"Testing creation from HEX."
...
...
@@ -115,7 +115,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def
test_create_wkb
(
self
):
"Testing creation from WKB."
for
g
in
self
.
geometries
.
hex_wkt
:
wkb
=
memoryview
(
a2b_hex
(
g
.
hex
.
encode
()
))
wkb
=
memoryview
(
bytes
.
fromhex
(
g
.
hex
))
geom_h
=
GEOSGeometry
(
wkb
)
# we need to do this so decimal places get normalized
geom_t
=
fromstr
(
g
.
wkt
)
...
...
tests/utils_tests/test_crypto.py
Dosyayı görüntüle @
93cdd07e
import
binascii
import
hashlib
import
unittest
...
...
@@ -132,14 +131,12 @@ class TestUtilsCryptoPBKDF2(unittest.TestCase):
def
test_public_vectors
(
self
):
for
vector
in
self
.
rfc_vectors
:
result
=
pbkdf2
(
**
vector
[
'args'
])
self
.
assertEqual
(
binascii
.
hexlify
(
result
)
.
decode
(
'ascii'
),
vector
[
'result'
])
self
.
assertEqual
(
result
.
hex
(),
vector
[
'result'
])
def
test_regression_vectors
(
self
):
for
vector
in
self
.
regression_vectors
:
result
=
pbkdf2
(
**
vector
[
'args'
])
self
.
assertEqual
(
binascii
.
hexlify
(
result
)
.
decode
(
'ascii'
),
vector
[
'result'
])
self
.
assertEqual
(
result
.
hex
(),
vector
[
'result'
])
def
test_default_hmac_alg
(
self
):
kwargs
=
{
'password'
:
b
'password'
,
'salt'
:
b
'salt'
,
'iterations'
:
1
,
'dklen'
:
20
}
...
...
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