Bug 1646431 - Fix type error in mach file-info bugzilla-component r=nalexander

The `key` function to the `sort` call here was janky, so this produced an error if you tried to invoke this command on a path that doesn't have an owner (`TypeError: '<' not supported between instances of 'TypedTuple' and 'NoneType'`).

Differential Revision: https://phabricator.services.mozilla.com/D80043
This commit is contained in:
Ricky Stewart 2020-06-17 17:16:06 +00:00
parent 3bda67deab
commit 40da5b0814

View File

@ -128,16 +128,15 @@ class MozbuildFileCommands(MachCommandBase):
json.dump(data, sys.stdout, sort_keys=True, indent=2)
return
elif fmt == 'plain':
data = sorted(components.items(),
key=lambda x: (x is None, x))
for component, files in data:
if component:
s = '%s :: %s' % (component.product, component.component)
else:
s = 'UNKNOWN'
print(s)
for f in sorted(files):
comp_to_file = sorted(
('UNKNOWN' if component is None
else '%s :: %s' % (component.product, component.component),
sorted(files))
for component, files in components.items()
)
for component, files in comp_to_file:
print(component)
for f in files:
print(' %s' % f)
else:
print('unhandled output format: %s' % fmt)