forked from Imagelibrary/littlefs
scripts: Adopt __get__ binding for write/writeln methods
This actually binds our custom write/writeln functions as methods to the
file object:
def writeln(self, s=''):
self.write(s)
self.write('\n')
f.writeln = writeln.__get__(f)
This doesn't really gain us anything, but is a bit more correct and may
be safer if other code messes with the file's internals.
This commit is contained in:
@@ -951,11 +951,11 @@ def main_(ring, paths, *,
|
||||
label=False,
|
||||
no_label=False,
|
||||
**args):
|
||||
# give ring an writeln function
|
||||
def writeln(s=''):
|
||||
ring.write(s)
|
||||
ring.write('\n')
|
||||
ring.writeln = writeln
|
||||
# give ring a writeln function
|
||||
def writeln(self, s=''):
|
||||
self.write(s)
|
||||
self.write('\n')
|
||||
ring.writeln = writeln.__get__(ring)
|
||||
|
||||
# figure out what color should be
|
||||
if color == 'auto':
|
||||
|
||||
Reference in New Issue
Block a user