Ticket #7020: lists-to-tuples.diff
File lists-to-tuples.diff, 4.3 KB (added by , 17 years ago) |
---|
-
django/oldforms/__init__.py
953 953 if match is not None: 954 954 import re 955 955 match_re = re.compile(match) 956 choices = not is_required and BLANK_CHOICE_DASH[:] or []956 choices = not is_required and [BLANK_CHOICE_DASH] or [] 957 957 if recursive: 958 958 for root, dirs, files in os.walk(path): 959 959 for f in files: -
django/db/models/fields/__init__.py
28 28 HORIZONTAL, VERTICAL = 1, 2 29 29 30 30 # The values to use for "blank" in SelectFields. Will be appended to the start of most "choices" lists. 31 BLANK_CHOICE_DASH = [("", "---------")]32 BLANK_CHOICE_NONE = [("", "None")]31 BLANK_CHOICE_DASH = ("", "---------") 32 BLANK_CHOICE_NONE = ("", "None") 33 33 34 34 # prepares a value for use in a LIKE query 35 35 prep_for_like_query = lambda x: smart_unicode(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_") … … 345 345 val = None 346 346 return val 347 347 348 def get_choices(self, include_blank=True, blank_choice= BLANK_CHOICE_DASH):348 def get_choices(self, include_blank=True, blank_choice=[BLANK_CHOICE_DASH]): 349 349 "Returns a list of tuples used as SelectField choices for this field." 350 350 first_choice = include_blank and blank_choice or [] 351 351 if self.choices: … … 359 359 360 360 def get_choices_default(self): 361 361 if self.radio_admin: 362 return self.get_choices(include_blank=self.blank, blank_choice= BLANK_CHOICE_NONE)362 return self.get_choices(include_blank=self.blank, blank_choice=[BLANK_CHOICE_NONE]) 363 363 else: 364 364 return self.get_choices() 365 365 -
django/utils/_decimal.py
370 370 """ 371 371 372 372 # List of public traps and flags 373 _signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded,374 Underflow, InvalidOperation, Subnormal ]373 _signals = (Clamped, DivisionByZero, Inexact, Overflow, Rounded, 374 Underflow, InvalidOperation, Subnormal) 375 375 376 376 # Map conditions (per the spec) to signals 377 377 _condition_map = {ConversionSyntax:InvalidOperation, … … 2164 2164 2165 2165 2166 2166 # get rounding method function: 2167 rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')] 2168 for name in rounding_functions: 2167 for name in Decimal.__dict__.iterkeys(): 2168 if not name.startswith('_round_'): 2169 continue 2169 2170 #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. 2170 2171 globalname = name[1:].upper() 2171 2172 val = globals()[globalname] 2172 2173 Decimal._pick_rounding_function[val] = name 2173 2174 2174 del name, val, globalname , rounding_functions2175 del name, val, globalname 2175 2176 2176 2177 class Context(object): 2177 2178 """Contains the context for a Decimal instance. -
django/utils/html.py
9 9 from django.utils.http import urlquote 10 10 11 11 # Configuration for urlize() function. 12 LEADING_PUNCTUATION = ['(', '<', '<']13 TRAILING_PUNCTUATION = ['.', ',', ')', '>', '\n', '>']12 LEADING_PUNCTUATION = ('(', '<', '<') 13 TRAILING_PUNCTUATION = ('.', ',', ')', '>', '\n', '>') 14 14 15 15 # List of possible strings used for bullets in bulleted lists. 16 DOTS = ['·', '*', '\xe2\x80\xa2', '•', '•', '•']16 DOTS = ('·', '*', '\xe2\x80\xa2', '•', '•', '•') 17 17 18 18 unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)') 19 19 word_split_re = re.compile(r'(\s+)') -
django/utils/simplejson/decoder.py
183 183 return values, end 184 184 pattern(r'\[')(JSONArray) 185 185 186 ANYTHING = [186 ANYTHING = ( 187 187 JSONObject, 188 188 JSONArray, 189 189 JSONString, 190 190 JSONConstant, 191 191 JSONNumber, 192 ] 192 ) 193 193 194 194 JSONScanner = Scanner(ANYTHING) 195 195