python-hosts icon indicating copy to clipboard operation
python-hosts copied to clipboard

hosts.add with an entries list containing the same host twice should fail

Open paulbusse opened this issue 1 year ago • 2 comments

Running the following program

from python_hosts import Hosts, HostsEntry

host = HostsEntry(
    entry_type='ipv4',
    address='10.10.10.10',
    names=['samsung', 'samsung.local'],
)
entries = []
entries.append(host)
entries.append(host)

hosts = Hosts('testhosts')
hosts.add(entries, force=True)
hosts.write()

gives this content in testhosts

10.10.10.10	samsung samsung.local
10.10.10.10	samsung samsung.local

I would expect the entry to be present only once.

Thanks for the module. Saved me a lot of time.

paulbusse avatar Sep 09 '24 12:09 paulbusse