Changeset 9626


Ignore:
Timestamp:
Aug 30, 2011, 6:24:00 PM (13 years ago)
Author:
rick
Message:

strip replaces all characters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/management/commands/import_datafile.py

    r9625 r9626  
    3737
    3838# Prefix/Suffix removal
    39 valid_prefix = ['DroidStumbler-', 'Kismet-']
     39valid_prefixes = ['DroidStumbler-', 'Kismet-','ScanResult-']
    4040def strip_prefix(filename):
    41   for suffix in valid_suffixes:
    42     filename = filename.rstrip(suffix)
     41  for prefix in valid_prefixes:
     42    if filename.startswith(prefix):
     43      filename = filename[len(prefix):]
    4344  return filename
    4445valid_suffixes = ['.gz', '.gpsxml', '.netxml', '.csv', '.ns1']
    4546def strip_suffix(filename):
    4647  for suffix in valid_suffixes:
    47     filename = filename.rstrip(suffix)
     48    if filename.endswith(suffix):
     49      filename = filename[:-len(suffix)]
    4850  return filename
    4951def strip_file(filename):
     
    170172           return datetime.datetime.strptime(datestr,'%Y%m%d-%H-%M-%S-1')
    171173        except ValueError:
    172           raise CommandError("Invalid date '%s'" % options['datum'])
     174          raise CommandError("Invalid date '%s'" % datestr)
    173175      if options['datum'] == None:
    174176         datestr = strip_file(os.path.basename(filename))
Note: See TracChangeset for help on using the changeset viewer.