make-manuf.py: Fix a shortening error.
Handle cases where we might shorten a name (e.g. "ZAO") down to nothing. Change-Id: I5ecb9592d2ecd8225d0ed459ef16885214af5da4 Reviewed-on: https://code.wireshark.org/review/35584 Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
4d14586385
commit
12550ef794
|
@ -117,10 +117,17 @@ def shorten(manuf):
|
|||
# & isn't needed when Standalone
|
||||
manuf = manuf.replace(" & ", " ")
|
||||
# Remove business types and other general terms ("the", "inc", "plc", etc.)
|
||||
manuf = re.sub('\W(' + general_terms + ')(?= )', '', manuf, flags=re.IGNORECASE)
|
||||
plain_manuf = re.sub('\W(' + general_terms + ')(?= )', '', manuf, flags=re.IGNORECASE)
|
||||
# ...but make sure we don't remove everything.
|
||||
if not all(s == ' ' for s in plain_manuf):
|
||||
manuf = plain_manuf
|
||||
# Remove all spaces
|
||||
manuf = re.sub('\s+', '', manuf)
|
||||
|
||||
if len(manuf) < 1:
|
||||
sys.stderr.write('Manufacturer "{}" shortened to nothing.\n'.format(orig_manuf))
|
||||
sys.exit(1)
|
||||
|
||||
# Truncate names to a reasonable length, say, 8 characters. If
|
||||
# the string contains UTF-8, this may be substantially more than
|
||||
# 8 bytes. It might also be less than 8 visible characters. Plain
|
||||
|
|
Loading…
Reference in New Issue