Revision: 11809 http://trac.calendarserver.org//changeset/11809 Author: wsanchez@apple.com Date: 2013-10-11 18:05:34 -0700 (Fri, 11 Oct 2013) Log Message: ----------- New school formatting Modified Paths: -------------- CalendarServer/trunk/twext/who/aggregate.py CalendarServer/trunk/twext/who/directory.py CalendarServer/trunk/twext/who/expression.py CalendarServer/trunk/twext/who/index.py CalendarServer/trunk/twext/who/util.py CalendarServer/trunk/twext/who/xml.py Modified: CalendarServer/trunk/twext/who/aggregate.py =================================================================== --- CalendarServer/trunk/twext/who/aggregate.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/aggregate.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -45,14 +45,16 @@ for service in services: if not IDirectoryService.implementedBy(service.__class__): - raise ValueError("Not a directory service: %s" % (service,)) + raise ValueError( + "Not a directory service: {0}".format(service) + ) for recordType in service.recordTypes(): if recordType in recordTypes: raise DirectoryConfigurationError( "Aggregated services may not vend " - "the same record type: %s" - % (recordType,) + "the same record type: {0}" + .format(recordType) ) recordTypes.add(recordType) Modified: CalendarServer/trunk/twext/who/directory.py =================================================================== --- CalendarServer/trunk/twext/who/directory.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/directory.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -57,9 +57,9 @@ def __repr__(self): - return "<%s %r>" % ( - self.__class__.__name__, - self.realmName, + return ( + "<{self.__class__.__name__} {self.realmName!r}>" + .format(self=self) ) @@ -77,7 +77,7 @@ @type records: L{set} or L{frozenset} """ return fail(QueryNotSupportedError( - "Unknown expression: %s" % (expression,) + "Unknown expression: {0}".format(expression) )) @@ -112,7 +112,7 @@ results |= recordsMatchingExpression else: raise QueryNotSupportedError( - "Unknown operand: %s" % (operand,) + "Unknown operand: {0}".format(operand) ) returnValue(results) @@ -179,28 +179,31 @@ def __init__(self, service, fields): for fieldName in self.requiredFields: if fieldName not in fields or not fields[fieldName]: - raise ValueError("%s field is required." % (fieldName,)) + raise ValueError("{0} field is required.".format(fieldName)) if FieldName.isMultiValue(fieldName): values = fields[fieldName] if len(values) == 0: raise ValueError( - "%s field must have at least one value." % (fieldName,) + "{0} field must have at least one value." + .format(fieldName) ) for value in values: if not value: raise ValueError( - "%s field must not be empty." % (fieldName,) + "{0} field must not be empty.".format(fieldName) ) if ( fields[FieldName.recordType] not in service.recordType.iterconstants() ): - raise ValueError("Record type must be one of %r, not %r." % ( - tuple(service.recordType.iterconstants()), - fields[FieldName.recordType] - )) + raise ValueError( + "Record type must be one of {0!r}, not {1!r}.".format( + tuple(service.recordType.iterconstants()), + fields[FieldName.recordType], + ) + ) # Normalize fields normalizedFields = {} @@ -221,10 +224,12 @@ def __repr__(self): - return "<%s (%s)%s>" % ( - self.__class__.__name__, - describe(self.recordType), - self.shortNames[0], + return ( + "<{self.__class__.__name__} ({recordType}){shortName}>".format( + self=self, + recordType=describe(self.recordType), + shortName=self.shortNames[0], + ) ) Modified: CalendarServer/trunk/twext/who/expression.py =================================================================== --- CalendarServer/trunk/twext/who/expression.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/expression.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -89,12 +89,16 @@ if self.flags is None: flags = "" else: - flags = " (%s)" % (describe(self.flags),) + flags = " ({0})".format(describe(self.flags)) - return "<%s: %r %s %r%s>" % ( - self.__class__.__name__, - describe(self.fieldName), - describe(self.matchType), - describe(self.fieldValue), - flags + return ( + "<{self.__class__.__name__}: {fieldName!r} " + "{matchType} {fieldValue!r}{flags}>" + .format( + self=self, + fieldName=describe(self.fieldName), + matchType=describe(self.matchType), + fieldValue=describe(self.fieldValue), + flags=flags, + ) ) Modified: CalendarServer/trunk/twext/who/index.py =================================================================== --- CalendarServer/trunk/twext/who/index.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/index.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -117,7 +117,7 @@ normalize = lambda x: x.lower() else: raise NotImplementedError( - "Unknown query flag: %s" % (describe(flag),) + "Unknown query flag: {0}".format(describe(flag)) ) return predicate, normalize @@ -156,7 +156,7 @@ ) else: raise NotImplementedError( - "Unknown match type: %s" % (describe(matchType),) + "Unknown match type: {0}".format(describe(matchType)) ) matchingRecords = set() @@ -191,7 +191,7 @@ match = lambda fieldValue: predicate(fieldValue == matchValue) else: raise NotImplementedError( - "Unknown match type: %s" % (describe(matchType),) + "Unknown match type: {0}".format(describe(matchType)) ) result = set() Modified: CalendarServer/trunk/twext/who/util.py =================================================================== --- CalendarServer/trunk/twext/who/util.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/util.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -40,7 +40,7 @@ myConstants = {} for constant in constants: if constant.name in myConstants: - raise ValueError("Name conflict: %r" % (constant.name,)) + raise ValueError("Name conflict: {0}".format(constant.name)) myConstants[constant.name] = constant self._constants = myConstants Modified: CalendarServer/trunk/twext/who/xml.py =================================================================== --- CalendarServer/trunk/twext/who/xml.py 2013-10-12 00:45:10 UTC (rev 11808) +++ CalendarServer/trunk/twext/who/xml.py 2013-10-12 01:05:34 UTC (rev 11809) @@ -144,9 +144,11 @@ else: realmName = repr(realmName) - return "<%s %s>" % ( - self.__class__.__name__, - realmName, + return ( + "<{self.__class__.__name__} {realmName}>".format( + self=self, + realmName=realmName, + ) ) @@ -229,7 +231,7 @@ directoryNode = etree.getroot() if directoryNode.tag != self.element.directory.value: raise ParseError( - "Incorrect root element: %s" % (directoryNode.tag,) + "Incorrect root element: {0}".format(directoryNode.tag) ) realmName = directoryNode.get( @@ -376,7 +378,7 @@ ) else: raise AssertionError( - "Unknown record type: %r" % (value,) + "Unknown record type: {0}".format(value) ) else: @@ -395,7 +397,7 @@ else: raise AssertionError( - "Unknown field name: %r" % (name,) + "Unknown field name: {0!r}".format(name) ) # Walk through the record nodes in the XML tree and apply
participants (1)
-
source_changes@macosforge.org