diff options
author | rsiddharth <s@ricketyspace.net> | 2017-06-04 23:21:31 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2017-06-04 23:21:31 +0000 |
commit | 626ff419f36a8fe7e310346296e61486357b3055 (patch) | |
tree | ad99e3b4b30d81eb461ec9b638bfce04f415047b | |
parent | 45a601c1c9f922c55b36fb6541764659406cd11b (diff) |
mdl_style.py: Add _write_to.
* mdl_style.py (_write_to): New function.
-rw-r--r-- | mdl_style.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mdl_style.py b/mdl_style.py index c90f762..99b63c0 100644 --- a/mdl_style.py +++ b/mdl_style.py @@ -235,6 +235,18 @@ class LinkStyler(object): return md(text) +def _write_to(file_, content): + """Write `content` to `file_`. + + `file_` is expected to be a sub-class of `io.TextIOBase`. + """ + file_.truncate(0) + file_.seek(0) + file_.write(content) + file_.flush() + file_.close() + + def _mdl_stylize(args): ls = LinkStyler(args.link_style) print(ls(args.file), end='') |