filter_parser.add_argument(
'-n', metavar='MAX#',
type=int,
- help='''Restrict number of results'''
+ help='''Return first n results'''
+ )
+ filter_parser.add_argument(
+ '-N', metavar='MAX#',
+ type=int,
+ help='''Return last N results'''
)
filter_parser.add_argument(
'-m', metavar='MESSAGEID',
except:
action_parser.error("Invalid maximum count '%s'" % args.get('n'))
+ if args.get('N') is not None:
+ try:
+ filt.add("max_count", 0 - args.get('N'))
+ except:
+ action_parser.error("Invalid maximum count '%s'" % args.get('N'))
+
do_signoff = args.get('signoff')
# grab settings from config files
patches = self.rpc.patch_list({'max_count': 2})
self.assertEqual(len(patches), 2)
self.assertEqual(patches[0]['id'], patch_objs[0].id)
+
+ def testListNegativeMaxCount(self):
+ patch_objs = self._createPatches(5)
+ patches = self.rpc.patch_list({'max_count': -1})
+ self.assertEqual(len(patches), 1)
+ self.assertEqual(patches[0]['id'], patch_objs[-1].id)
Returns:
Version of the API.
"""
- return (1, 1, 0)
+ return (1, 2, 0)
@xmlrpc_method()
if max_count > 0:
return list(map(project_to_dict, projects[:max_count]))
+ elif max_count < 0:
+ return list(map(project_to_dict,
+ projects[len(projects) + max_count:]))
else:
return list(map(project_to_dict, projects))
except Project.DoesNotExist:
if max_count > 0:
return list(map(person_to_dict, people[:max_count]))
+ elif max_count < 0:
+ return list(map(person_to_dict, people[len(people) + max_count:]))
else:
return list(map(person_to_dict, people))
except Person.DoesNotExist:
if max_count > 0:
return list(map(patch_to_dict, patches[:max_count]))
+ elif max_count < 0:
+ return list(map(patch_to_dict,
+ patches[len(patches) + max_count:]))
else:
return list(map(patch_to_dict, patches))
except Patch.DoesNotExist:
if max_count > 0:
return list(map(state_to_dict, states[:max_count]))
+ elif max_count < 0:
+ return list(map(state_to_dict, states[len(states) + max_count:]))
else:
return list(map(state_to_dict, states))
except State.DoesNotExist: