Commit dba73e30 authored by Morten Brekkevold's avatar Morten Brekkevold

Silently ignore Kind records that appear to be automatically generated or otherwise in error

parent 1f31677b
......@@ -180,7 +180,8 @@ def find_duplicates(names):
def clean_data(kind_data):
kind_devices = [KindDevice.from_json_record(record) for record in kind_data]
kind_devices = [KindDevice.from_json_record(record) for record in kind_data
if not should_silently_ignore(record)]
invalid_names = {device for device in kind_devices
if not device_name_is_okay(device.name)}
......@@ -210,6 +211,18 @@ def device_name_is_okay(name):
return '.' in name and ' ' not in name
def should_silently_ignore(kind_json_record):
"""
Silently ignore Kind records that appear to be automatically generated
or otherwise in error
"""
result = 'fru.pl' in kind_json_record.get('opprettet_av', '')
if result:
LOG.debug("Ignorerer stille %s (%s)",
kind_json_record.get('navn'), kind_json_record.get('id'))
return result
def lookup_addresses(kind_devices):
"""Runs DNS lookups for all collected Kind devices"""
names = {name: kind_device
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment