Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
791c7ad0
Commit
791c7ad0
authored
Oct 17, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break ZODB dependency.
parent
e7881acf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
BTrees/utils.py
BTrees/utils.py
+28
-0
No files found.
BTrees/utils.py
0 → 100644
View file @
791c7ad0
# Copied from ZODB/utils.py
from
binascii
import
hexlify
from
struct
import
calcsize
_ADDRESS_MASK
=
256
**
calcsize
(
'P'
)
def
positive_id
(
obj
):
"""Return id(obj) as a non-negative integer."""
result
=
id
(
obj
)
if
result
<
0
:
result
+=
_ADDRESS_MASK
assert
result
>
0
return
result
def
oid_repr
(
oid
):
if
isinstance
(
oid
,
str
)
and
len
(
oid
)
==
8
:
# Convert to hex and strip leading zeroes.
as_hex
=
hexlify
(
oid
).
lstrip
(
'0'
)
# Ensure two characters per input byte.
if
len
(
as_hex
)
&
1
:
as_hex
=
'0'
+
as_hex
elif
as_hex
==
''
:
as_hex
=
'00'
return
'0x'
+
as_hex
else
:
return
repr
(
oid
)
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