Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ML
lib
Binary Storage
Commits
3a87579a
Commit
3a87579a
authored
Jan 29, 2020
by
Zhukov, Alexander P
Browse files
Working on ranges
parent
790db7db
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/read_random.py
View file @
3a87579a
...
...
@@ -15,6 +15,6 @@ from read_storage import BinaryStorage
file
=
BinaryStorage
(
'/data/BinStorage/test.bin'
)
print
(
file
[
0
])
print
(
file
[
0
::
2
])
file
.
close
()
\ No newline at end of file
py/read_storage.py
View file @
3a87579a
...
...
@@ -30,10 +30,21 @@ class BinaryStorage:
def
read
(
self
):
return
BinaryStorage
.
read_record
(
self
.
file
)
def
__getitem__
(
self
,
key
):
def
readAt
(
self
,
key
):
offset
=
self
.
rec_table
[
key
]
self
.
file
.
seek
(
offset
)
return
BinaryStorage
.
read_record
(
self
.
file
)
def
__getitem__
(
self
,
key
):
if
isinstance
(
key
,
slice
):
return
[
self
.
readAt
(
i
)
for
i
in
range
(
key
.
start
,
key
.
stop
,
key
.
step
)]
else
:
return
self
.
readAt
(
key
)
def
__len__
(
self
):
return
len
(
self
.
rec_table
)
...
...
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