Changeset 6971
- Timestamp:
- 12/22/07 13:16:39 (1 year ago)
- Files:
-
- django/trunk/django/template/__init__.py (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/template/__init__.py
r6970 r6971 300 300 301 301 def empty_variable(self, token): 302 raise self.error( token, "Empty variable tag")302 raise self.error(token, "Empty variable tag") 303 303 304 304 def empty_block_tag(self, token): 305 raise self.error( token, "Empty block tag")305 raise self.error(token, "Empty block tag") 306 306 307 307 def invalid_block_tag(self, token, command): 308 raise self.error( token, "Invalid block tag: '%s'" % command)308 raise self.error(token, "Invalid block tag: '%s'" % command) 309 309 310 310 def unclosed_block_tag(self, parse_until): … … 335 335 return self.filters[filter_name] 336 336 else: 337 raise TemplateSyntaxError , "Invalid filter: '%s'" % filter_name337 raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name) 338 338 339 339 def lexer_factory(*args, **kwargs): … … 367 367 def top(self): 368 368 "Overload this method to do the actual parsing and return the result." 369 raise NotImplemented 369 raise NotImplementedError() 370 370 371 371 def more(self): … … 376 376 "Undoes the last microparser. Use this for lookahead and backtracking." 377 377 if not len(self.backout): 378 raise TemplateSyntaxError , "back called without some previous parsing"378 raise TemplateSyntaxError("back called without some previous parsing") 379 379 self.pointer = self.backout.pop() 380 380 … … 384 384 i = self.pointer 385 385 if i >= len(subject): 386 raise TemplateSyntaxError , "expected another tag, found end of string: %s" % subject386 raise TemplateSyntaxError("expected another tag, found end of string: %s" % subject) 387 387 p = i 388 388 while i < len(subject) and subject[i] not in (' ', '\t'): … … 400 400 i = self.pointer 401 401 if i >= len(subject): 402 raise TemplateSyntaxError , "Searching for value. Expected another value but found end of string: %s" % subject402 raise TemplateSyntaxError("Searching for value. Expected another value but found end of string: %s" % subject) 403 403 if subject[i] in ('"', "'"): 404 404 p = i … … 407 407 i += 1 408 408 if i >= len(subject): 409 raise TemplateSyntaxError , "Searching for value. Unexpected end of string in column %d: %s" % (i, subject)409 raise TemplateSyntaxError("Searching for value. Unexpected end of string in column %d: %s" % (i, subject)) 410 410 i += 1 411 411 res = subject[p:i] … … 424 424 i += 1 425 425 if i >= len(subject): 426 raise TemplateSyntaxError , "Searching for value. Unexpected end of string in column %d: %s" % (i, subject)426 raise TemplateSyntaxError("Searching for value. Unexpected end of string in column %d: %s" % (i, subject)) 427 427 i += 1 428 428 s = subject[p:i] … … 483 483 start = match.start() 484 484 if upto != start: 485 raise TemplateSyntaxError ,"Could not parse some characters: %s|%s|%s" % \486 (token[:upto], token[upto:start], token[start:]) 485 raise TemplateSyntaxError("Could not parse some characters: %s|%s|%s" % \ 486 (token[:upto], token[upto:start], token[start:])) 487 487 if var == None: 488 488 var, constant, i18n_constant = match.group("var", "constant", "i18n_constant") … … 493 493 upto = match.end() 494 494 if var == None: 495 raise TemplateSyntaxError , "Could not find variable at start of %s" % token495 raise TemplateSyntaxError("Could not find variable at start of %s" % token) 496 496 elif var.find(VARIABLE_ATTRIBUTE_SEPARATOR + '_') > -1 or var[0] == '_': 497 raise TemplateSyntaxError , "Variables and attributes may not begin with underscores: '%s'" % var497 raise TemplateSyntaxError("Variables and attributes may not begin with underscores: '%s'" % var) 498 498 else: 499 499 filter_name = match.group("filter_name") … … 511 511 upto = match.end() 512 512 if upto != len(token): 513 raise TemplateSyntaxError , "Could not parse the remainder: '%s' from '%s'" % (token[upto:], token)513 raise TemplateSyntaxError("Could not parse the remainder: '%s' from '%s'" % (token[upto:], token)) 514 514 self.filters = filters 515 515 self.var = Variable(var) … … 568 568 except IndexError: 569 569 # Not enough 570 raise TemplateSyntaxError , "%s requires %d arguments, %d provided" % (name, len(nondefs), plen)570 raise TemplateSyntaxError("%s requires %d arguments, %d provided" % (name, len(nondefs), plen)) 571 571 572 572 # Defaults can be overridden. … … 577 577 except IndexError: 578 578 # Too many. 579 raise TemplateSyntaxError , "%s requires %d arguments, %d provided" % (name, len(nondefs), plen)579 raise TemplateSyntaxError("%s requires %d arguments, %d provided" % (name, len(nondefs), plen)) 580 580 581 581 return True … … 797 797 else: 798 798 message = "%s takes between %s and %s arguments" % (name, bmin, bmax) 799 raise TemplateSyntaxError , message799 raise TemplateSyntaxError(message) 800 800 return node_class(bits) 801 801 … … 823 823 return compile_function 824 824 else: 825 raise InvalidTemplateLibrary , "Unsupported arguments to Library.tag: (%r, %r)", (name, compile_function)825 raise InvalidTemplateLibrary("Unsupported arguments to Library.tag: (%r, %r)", (name, compile_function)) 826 826 827 827 def tag_function(self,func): … … 847 847 return filter_func 848 848 else: 849 raise InvalidTemplateLibrary , "Unsupported arguments to Library.filter: (%r, %r)", (name, filter_func)849 raise InvalidTemplateLibrary("Unsupported arguments to Library.filter: (%r, %r)", (name, filter_func)) 850 850 851 851 def filter_function(self, func): … … 876 876 params = params[1:] 877 877 else: 878 raise TemplateSyntaxError , "Any tag function decorated with takes_context=True must have a first argument of 'context'"878 raise TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'") 879 879 880 880 class InclusionNode(Node): … … 913 913 mod = __import__(module_name, {}, {}, ['']) 914 914 except ImportError, e: 915 raise InvalidTemplateLibrary , "Could not load template library from %s, %s" % (module_name, e)915 raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)) 916 916 try: 917 917 lib = mod.register 918 918 libraries[module_name] = lib 919 919 except AttributeError: 920 raise InvalidTemplateLibrary , "Template library %s does not have a variable named 'register'" % module_name920 raise InvalidTemplateLibrary("Template library %s does not have a variable named 'register'" % module_name) 921 921 return lib 922 922
