Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
92b7dc6d
Commit
92b7dc6d
authored
1 year ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
docs fix
Change-Id: Ie8979237f2c191ce066fa1892030cb1daecd07db
parent
d8af4afe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/files.py
+12
-21
12 additions, 21 deletions
satella/files.py
with
12 additions
and
21 deletions
satella/files.py
+
12
−
21
View file @
92b7dc6d
...
@@ -392,14 +392,6 @@ def close_file_after(fun):
...
@@ -392,14 +392,6 @@ def close_file_after(fun):
return
inner
return
inner
def
open_file
(
fun
):
@wraps
(
fun
)
def
inner
(
self
,
*
args
,
**
kwargs
):
return
fun
(
self
,
self
.
_open_file
(),
*
args
,
**
kwargs
)
return
inner
class
AutoflushFile
(
Proxy
[
io
.
FileIO
]):
class
AutoflushFile
(
Proxy
[
io
.
FileIO
]):
"""
"""
A file that is supposed to be closed after each write command issued.
A file that is supposed to be closed after each write command issued.
...
@@ -444,8 +436,7 @@ class AutoflushFile(Proxy[io.FileIO]):
...
@@ -444,8 +436,7 @@ class AutoflushFile(Proxy[io.FileIO]):
@is_closed_getter
@is_closed_getter
@close_file_after
@close_file_after
@open_file
def
seek
(
self
,
offset
:
int
,
whence
:
int
=
os
.
SEEK_SET
)
->
int
:
def
seek
(
self
,
fle
:
AutoflushFile
,
offset
:
int
,
whence
:
int
=
os
.
SEEK_SET
)
->
int
:
"""
"""
Seek to a provided position within the file
Seek to a provided position within the file
...
@@ -454,19 +445,20 @@ class AutoflushFile(Proxy[io.FileIO]):
...
@@ -454,19 +445,20 @@ class AutoflushFile(Proxy[io.FileIO]):
:return: current pointer
:return: current pointer
"""
"""
fle
=
self
.
_open_file
()
v
=
fle
.
seek
(
offset
,
whence
)
v
=
fle
.
seek
(
offset
,
whence
)
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
return
v
return
v
@is_closed_getter
@is_closed_getter
@close_file_after
@close_file_after
@open_file
def
read
(
self
,
*
args
,
**
kwargs
)
->
tp
.
Union
[
str
,
bytes
]:
def
read
(
self
,
fle
:
AutoflushFile
,
*
args
,
**
kwargs
)
->
tp
.
Union
[
str
,
bytes
]:
"""
"""
Read a file, returning the read-in data
Read a file, returning the read-in data
:return: data readed
:return: data readed
"""
"""
fle
=
self
.
_open_file
()
p
=
fle
.
read
(
*
args
,
**
kwargs
)
p
=
fle
.
read
(
*
args
,
**
kwargs
)
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
return
p
return
p
...
@@ -476,10 +468,10 @@ class AutoflushFile(Proxy[io.FileIO]):
...
@@ -476,10 +468,10 @@ class AutoflushFile(Proxy[io.FileIO]):
@is_closed_getter
@is_closed_getter
@close_file_after
@close_file_after
@open_file
def
readall
(
self
)
->
tp
.
Union
[
str
,
bytes
]:
def
readall
(
self
,
fle
)
->
tp
.
Union
[
str
,
bytes
]:
"""
Read all contents into the file
"""
"""
Read all contents into the file
"""
return
file
.
readall
()
fle
=
self
.
_open_file
()
return
fle
.
readall
()
def
_open_file
(
self
)
->
io
.
FileIO
:
def
_open_file
(
self
)
->
io
.
FileIO
:
file
=
self
.
_get_file
()
file
=
self
.
_get_file
()
...
@@ -499,7 +491,6 @@ class AutoflushFile(Proxy[io.FileIO]):
...
@@ -499,7 +491,6 @@ class AutoflushFile(Proxy[io.FileIO]):
self
.
__dict__
[
'
_Proxy__obj
'
]
=
None
self
.
__dict__
[
'
_Proxy__obj
'
]
=
None
@is_closed_getter
@is_closed_getter
@open_file
@close_file_after
@close_file_after
def
close
(
self
,
fle
)
->
None
:
# pylint: disable=unused-argument
def
close
(
self
,
fle
)
->
None
:
# pylint: disable=unused-argument
"""
"""
...
@@ -509,22 +500,22 @@ class AutoflushFile(Proxy[io.FileIO]):
...
@@ -509,22 +500,22 @@ class AutoflushFile(Proxy[io.FileIO]):
@is_closed_getter
@is_closed_getter
@close_file_after
@close_file_after
@open_file
def
write
(
self
,
*
args
,
**
kwargs
)
->
int
:
def
write
(
self
,
fle
,
*
args
,
**
kwargs
)
->
int
:
"""
"""
Write a particular value to the file, close it afterwards.
Write a particular value to the file, close it afterwards.
:return: amount of bytes written
:return: amount of bytes written
"""
"""
fle
=
self
.
_open_file
()
val
=
fle
.
write
(
*
args
,
**
kwargs
)
val
=
fle
.
write
(
*
args
,
**
kwargs
)
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
return
val
return
val
@is_closed_getter
@is_closed_getter
@close_file_after
@close_file_after
@open_file
def
truncate
(
self
,
_size
:
tp
.
Optional
[
int
]
=
None
)
->
int
:
def
truncate
(
self
,
fle
,
__size
:
tp
.
Optional
[
int
]
=
None
)
->
int
:
"""
Truncate file to __size starting bytes
"""
"""
Truncate file to __size starting bytes
"""
v
=
fle
.
truncate
(
__size
)
fle
=
self
.
_open_file
()
v
=
fle
.
truncate
(
_size
)
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
self
.
__dict__
[
'
pointer
'
]
=
fle
.
tell
()
return
v
return
v
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment