Changeset 752 for trunk


Ignore:
Timestamp:
Jan 11, 2013, 12:55:59 AM (7 years ago)
Author:
Dominic Hargreaves
Message:

compare only against undeleted count when checking for suspiciously low numbers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/generic-python-import/generic_importer.py

    r736 r752  
    214214                count = len(spcs.keys())
    215215                deleted_count = len([a for a in spcs.values() if a['deleted']])
     216                undeleted_count = count - deleted_count
    216217
    217218                # And for interest, grab the raw deleted count
     
    223224
    224225                print "There are currently %d distinct entries in the database from the %s." % (count, self.source_name)
    225                 print " Of these, %d are live, and %d are deleted" % (count-deleted_count, deleted_count)
     226                print " Of these, %d are live, and %d are deleted" % (undeleted_count, deleted_count)
    226227                print " There are also %d raw deleted entries (may include duplicates)" % (raw_deleted_count)
    227228                print "The new import contains %d entries" % len(postcodes)
     
    229230                # Only prompt if it's a big difference
    230231                if self.confirm_update:
    231                         if (count == 0 or len(postcodes) == 0 or
    232                                         len(postcodes) < count or (len(postcodes)-count) > 50):
     232                        if (undeleted_count == 0 or len(postcodes) == 0 or
     233                                        len(postcodes) < undeleted_count or (len(postcodes)-undeleted_count) > 50):
    233234                                print "Are you sure you wish to run an import?"
    234235                                confirm = raw_input("")
     
    243244                else:
    244245                        # Don't trash everything even with --no-confirm
    245                         if len(postcodes) == 0 or abs(len(postcodes)-count) > 100:
     246                        if len(postcodes) == 0 or abs(len(postcodes)-undeleted_count) > 100:
    246247                                raise Exception("Postcode count too different, not running (re-run without --no-confirm to allow")
    247248
Note: See TracChangeset for help on using the changeset viewer.