Repository: intel/dffml

Issue:
source: file: close does not use WRITEMODE
https://github.com/intel/dffml/blob/78f7ba8de290214919dc45de50800030bbe60f24/dffml/source/file.py#L108

does not use `self.WRITEMODE` (unlike `open`)

change the `"w+"` to be `self.WRITEMODE` and then fix the associated tests

Discussion:
codecov-commenter: # [Codecov](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=h1) Report
> Merging [#862](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=desc) into [master](https://codecov.io/gh/intel/dffml/commit/4d0ca9f32f015bd429e74cf9e1788d3bd0cf25f1?el=desc) will **decrease** coverage by `0.12%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/intel/dffml/pull/862/graphs/tree.svg?width=650&height=150&src=pr&token=B6TSSyBYRi)](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
- Coverage   87.28%   87.16%   -0.13%     
==========================================
  Files         133      133              
  Lines        8119     8116       -3     
  Branches     1312     1312              
==========================================
- Hits         7087     7074      -13     
- Misses        781      789       +8     
- Partials      251      253       +2     
```


| [Impacted Files](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [tests/source/test\_file.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-dGVzdHMvc291cmNlL3Rlc3RfZmlsZS5weQ==) | `100.00% <ø> (ø)` | |
| [dffml/source/file.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-ZGZmbWwvc291cmNlL2ZpbGUucHk=) | `97.87% <100.00%> (ø)` | |
| [dffml/plugins.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-ZGZmbWwvcGx1Z2lucy5weQ==) | `78.72% <0.00%> (-8.52%)` | :arrow_down: |
| [dffml/util/data.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-ZGZmbWwvdXRpbC9kYXRhLnB5) | `74.03% <0.00%> (-2.77%)` | :arrow_down: |
| [tests/util/test\_net.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-dGVzdHMvdXRpbC90ZXN0X25ldC5weQ==) | `98.18% <0.00%> (-1.82%)` | :arrow_down: |
| [dffml/noasync.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-ZGZmbWwvbm9hc3luYy5weQ==) | `78.18% <0.00%> (-1.13%)` | :arrow_down: |
| [dffml/source/df.py](https://codecov.io/gh/intel/dffml/pull/862/diff?src=pr&el=tree#diff-ZGZmbWwvc291cmNlL2RmLnB5) | `77.10% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=footer). Last update [4d0ca9f...db79a64](https://codecov.io/gh/intel/dffml/pull/862?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

pdxjohnny: Thanks @aadarshsingh191198! Can you run `black` on this?

```console
$ pip install black==19.10b0
$ black .
```

Patch:
diff --git a/dffml/source/file.py b/dffml/source/file.py
index a2e312787..e50f21319 100644
--- a/dffml/source/file.py
+++ b/dffml/source/file.py
@@ -105,7 +105,7 @@ class FileSource(BaseSource):
             elif self.config.filename.suffix == ".zip":
                 close = self.zip_closer_helper()
             else:
-                close = open(self.config.filename, "w+", newline="")
+                close = open(self.config.filename, self.WRITEMODE, newline="")
             with close as fd:
                 await self.dump_fd(fd)
 
diff --git a/docs/contributing/style.rst b/docs/contributing/style.rst
index ff0137fa4..16252f98b 100644
--- a/docs/contributing/style.rst
+++ b/docs/contributing/style.rst
@@ -15,7 +15,7 @@ To install black in the environment
 
 .. code-block:: console
 
-    $ pip install black
+    $ pip install black==19.10b0
 
 Run the `black <https://github.com/psf/black>`_ formatter on all Python files.
 


Test patch:
diff --git a/tests/source/test_file.py b/tests/source/test_file.py
index fa7d5918d..b3ef25bbb 100644
--- a/tests/source/test_file.py
+++ b/tests/source/test_file.py
@@ -198,7 +198,7 @@ class TestFileSource(AsyncTestCase):
             async with FakeFileSource(self.config("testfile")):
                 pass
             m_open.assert_called_once_with(
-                pathlib.Path("testfile"), "w+", newline=""
+                pathlib.Path("testfile"), FileSource.WRITEMODE, newline=""
             )
 
     async def test_close_gz(self):