[master 5/6] dd-refactor: new driver_updates.py + tests

wgwoods installerbot-noreply at redhat.com
Wed Jul 8 16:56:24 UTC 2015


In reply to line 215 of dracut/driver_updates.py:

> Why not ```open(filename).readlines()```? Or just ```list(open(filename))```.

To ensure that the returned list doesn't contain newlines, so they match the items passed to `append_line()`:
```python
>>> items = ['one', 'two', 'five']
>>> for i in items: append_line(filename, i)
... 
>>> items == list(open(filename))
False
>>> items == open(filename).readlines()
False
>>> items == open(filename).read().split('\n')
False
>>> items == open(filename).read().splitlines()
True
>>> items == [line.rstrip('\n') for line in open(filename)]
True
```
That last one is a bit clearer about the intent; I'll change that, and add a comment (+ test case).

-- 
To view this comment on github, visit https://github.com/wgwoods/anaconda/commit/d2698c0e08d29b5754db8e7a42e1dfc7bd79e6aa#commitcomment-12066634


More information about the anaconda-patches mailing list