""" Returns the final number used in a list of objects with names of the form WhateverFileName_### """ # Copyright © 2004 Saugus.net, Inc. # All Rights Reserved. # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. from string import rfind finalNum=0 for objectID in context.objectIds(): finalUnderscore=rfind(objectID,'_') if finalUnderscore!=-1: try: theNum=int(objectID[finalUnderscore+1:]) if theNum>finalNum: finalNum=theNum except (ValueError,TypeError): pass return finalNum