mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
@@ -234,7 +234,7 @@ class Distance(MeasureBase):
|
||||
'british_yd': 0.914398414616,
|
||||
'clarke_ft': 0.3047972654,
|
||||
'clarke_link': 0.201166195164,
|
||||
'fathom': 1.8288,
|
||||
'fathom': 1.8288,
|
||||
'ft': 0.3048,
|
||||
'german_m': 1.0000135965,
|
||||
'gold_coast_ft': 0.304799710181508,
|
||||
|
||||
@@ -49,7 +49,7 @@ class GeoFeedTest(TestCase):
|
||||
# Incrementing through the feeds.
|
||||
for feed in [feed1, feed2]:
|
||||
# Ensuring the georss namespace was added to the <rss> element.
|
||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||
chan = feed.getElementsByTagName('channel')[0]
|
||||
items = chan.getElementsByTagName('item')
|
||||
self.assertEqual(len(items), City.objects.count())
|
||||
@@ -69,7 +69,7 @@ class GeoFeedTest(TestCase):
|
||||
|
||||
for feed in [feed1, feed2]:
|
||||
# Ensuring the georsss namespace was added to the <feed> element.
|
||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||
self.assertEqual(feed.getAttribute('xmlns:georss'), 'http://www.georss.org/georss')
|
||||
entries = feed.getElementsByTagName('entry')
|
||||
self.assertEqual(len(entries), City.objects.count())
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class RelatedGeoModelTest(TestCase):
|
||||
cities = (
|
||||
('Aurora', 'TX', -97.516111, 33.058333),
|
||||
('Roswell', 'NM', -104.528056, 33.387222),
|
||||
('Kecksburg', 'PA', -79.460734, 40.18476),
|
||||
('Kecksburg', 'PA', -79.460734, 40.18476),
|
||||
)
|
||||
|
||||
for qs in (qs1, qs2, qs3):
|
||||
|
||||
@@ -6,9 +6,11 @@ from django.utils.six.moves.urllib.request import urlopen
|
||||
|
||||
PING_URL = "http://www.google.com/webmasters/tools/ping"
|
||||
|
||||
|
||||
class SitemapNotFound(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def ping_google(sitemap_url=None, ping_url=PING_URL):
|
||||
"""
|
||||
Alerts Google that the sitemap for the current site has been updated.
|
||||
@@ -35,6 +37,7 @@ def ping_google(sitemap_url=None, ping_url=PING_URL):
|
||||
params = urlencode({'sitemap': url})
|
||||
urlopen("%s?%s" % (ping_url, params))
|
||||
|
||||
|
||||
class Sitemap(object):
|
||||
# This limit is defined by Google. See the index documentation at
|
||||
# http://sitemaps.org/protocol.php#index.
|
||||
@@ -94,22 +97,24 @@ class Sitemap(object):
|
||||
(latest_lastmod is None or lastmod > latest_lastmod)):
|
||||
latest_lastmod = lastmod
|
||||
url_info = {
|
||||
'item': item,
|
||||
'location': loc,
|
||||
'lastmod': lastmod,
|
||||
'item': item,
|
||||
'location': loc,
|
||||
'lastmod': lastmod,
|
||||
'changefreq': self.__get('changefreq', item, None),
|
||||
'priority': str(priority if priority is not None else ''),
|
||||
'priority': str(priority if priority is not None else ''),
|
||||
}
|
||||
urls.append(url_info)
|
||||
if all_items_lastmod and latest_lastmod:
|
||||
self.latest_lastmod = latest_lastmod
|
||||
return urls
|
||||
|
||||
|
||||
class FlatPageSitemap(Sitemap):
|
||||
def items(self):
|
||||
current_site = Site.objects.get_current()
|
||||
return current_site.flatpage_set.filter(registration_required=False)
|
||||
|
||||
|
||||
class GenericSitemap(Sitemap):
|
||||
priority = None
|
||||
changefreq = None
|
||||
|
||||
@@ -72,9 +72,9 @@ class Command(BaseCommand):
|
||||
|
||||
self.serialization_formats = serializers.get_public_serializer_formats()
|
||||
self.compression_formats = {
|
||||
None: open,
|
||||
'gz': gzip.GzipFile,
|
||||
'zip': SingleZipReader
|
||||
None: open,
|
||||
'gz': gzip.GzipFile,
|
||||
'zip': SingleZipReader
|
||||
}
|
||||
if has_bz2:
|
||||
self.compression_formats['bz2'] = bz2.BZ2File
|
||||
|
||||
@@ -111,7 +111,7 @@ def get_validation_errors(outfile, app=None):
|
||||
try:
|
||||
max_digits = int(f.max_digits)
|
||||
if max_digits <= 0:
|
||||
e.add(opts, mdigits_msg % f.name)
|
||||
e.add(opts, mdigits_msg % f.name)
|
||||
else:
|
||||
mdigits_ok = True
|
||||
except (ValueError, TypeError):
|
||||
|
||||
@@ -19,6 +19,7 @@ __all__ = ('SelectDateWidget',)
|
||||
|
||||
RE_DATE = re.compile(r'(\d{4})-(\d\d?)-(\d\d?)$')
|
||||
|
||||
|
||||
def _parse_date_fmt():
|
||||
fmt = get_format('DATE_FORMAT')
|
||||
escaped = False
|
||||
@@ -39,6 +40,7 @@ def _parse_date_fmt():
|
||||
#if not self.first_select: self.first_select = 'day'
|
||||
return output
|
||||
|
||||
|
||||
class SelectDateWidget(Widget):
|
||||
"""
|
||||
A Widget that splits date input into three <select> boxes.
|
||||
@@ -90,7 +92,7 @@ class SelectDateWidget(Widget):
|
||||
choices = list(six.iteritems(self.months))
|
||||
month_html = self.create_select(name, self.month_field, value, month_val, choices)
|
||||
choices = [(i, i) for i in range(1, 32)]
|
||||
day_html = self.create_select(name, self.day_field, value, day_val, choices)
|
||||
day_html = self.create_select(name, self.day_field, value, day_val, choices)
|
||||
|
||||
output = []
|
||||
for field in _parse_date_fmt():
|
||||
|
||||
@@ -222,21 +222,21 @@ class RequestFactory(object):
|
||||
# - REMOTE_ADDR: often useful, see #8551.
|
||||
# See http://www.python.org/dev/peps/pep-3333/#environ-variables
|
||||
environ = {
|
||||
'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
|
||||
'PATH_INFO': str('/'),
|
||||
'REMOTE_ADDR': str('127.0.0.1'),
|
||||
'REQUEST_METHOD': str('GET'),
|
||||
'SCRIPT_NAME': str(''),
|
||||
'SERVER_NAME': str('testserver'),
|
||||
'SERVER_PORT': str('80'),
|
||||
'SERVER_PROTOCOL': str('HTTP/1.1'),
|
||||
'wsgi.version': (1, 0),
|
||||
'wsgi.url_scheme': str('http'),
|
||||
'wsgi.input': FakePayload(b''),
|
||||
'wsgi.errors': self.errors,
|
||||
'HTTP_COOKIE': self.cookies.output(header='', sep='; '),
|
||||
'PATH_INFO': str('/'),
|
||||
'REMOTE_ADDR': str('127.0.0.1'),
|
||||
'REQUEST_METHOD': str('GET'),
|
||||
'SCRIPT_NAME': str(''),
|
||||
'SERVER_NAME': str('testserver'),
|
||||
'SERVER_PORT': str('80'),
|
||||
'SERVER_PROTOCOL': str('HTTP/1.1'),
|
||||
'wsgi.version': (1, 0),
|
||||
'wsgi.url_scheme': str('http'),
|
||||
'wsgi.input': FakePayload(b''),
|
||||
'wsgi.errors': self.errors,
|
||||
'wsgi.multiprocess': True,
|
||||
'wsgi.multithread': False,
|
||||
'wsgi.run_once': False,
|
||||
'wsgi.multithread': False,
|
||||
'wsgi.run_once': False,
|
||||
}
|
||||
environ.update(self.defaults)
|
||||
environ.update(request)
|
||||
@@ -327,7 +327,7 @@ class RequestFactory(object):
|
||||
parsed = urlparse(path)
|
||||
data = force_bytes(data, settings.DEFAULT_CHARSET)
|
||||
r = {
|
||||
'PATH_INFO': self._get_path(parsed),
|
||||
'PATH_INFO': self._get_path(parsed),
|
||||
'REQUEST_METHOD': str(method),
|
||||
'SERVER_PORT': str('443') if secure else str('80'),
|
||||
'wsgi.url_scheme': str('https') if secure else str('http'),
|
||||
@@ -335,8 +335,8 @@ class RequestFactory(object):
|
||||
if data:
|
||||
r.update({
|
||||
'CONTENT_LENGTH': len(data),
|
||||
'CONTENT_TYPE': str(content_type),
|
||||
'wsgi.input': FakePayload(data),
|
||||
'CONTENT_TYPE': str(content_type),
|
||||
'wsgi.input': FakePayload(data),
|
||||
})
|
||||
r.update(extra)
|
||||
# If QUERY_STRING is absent or empty, we want to extract it from the URL.
|
||||
|
||||
@@ -23,7 +23,7 @@ from django.utils.translation import deactivate
|
||||
|
||||
|
||||
__all__ = (
|
||||
'Approximate', 'ContextList', 'get_runner', 'override_settings',
|
||||
'Approximate', 'ContextList', 'get_runner', 'override_settings',
|
||||
'requires_tz_support', 'setup_test_environment', 'teardown_test_environment',
|
||||
)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Originally from https://bitbucket.org/ned/jslex
|
||||
import re
|
||||
|
||||
|
||||
class Tok(object):
|
||||
"""
|
||||
A specification for a token class.
|
||||
@@ -15,6 +16,7 @@ class Tok(object):
|
||||
self.regex = regex
|
||||
self.next = next
|
||||
|
||||
|
||||
def literals(choices, prefix="", suffix=""):
|
||||
"""
|
||||
Create a regex from a space-separated list of literal `choices`.
|
||||
@@ -97,49 +99,49 @@ class JsLexer(Lexer):
|
||||
# http://inimino.org/~inimino/blog/javascript_semicolons
|
||||
|
||||
both_before = [
|
||||
Tok("comment", r"/\*(.|\n)*?\*/"),
|
||||
Tok("linecomment", r"//.*?$"),
|
||||
Tok("ws", r"\s+"),
|
||||
Tok("keyword", literals("""
|
||||
break case catch class const continue debugger
|
||||
default delete do else enum export extends
|
||||
finally for function if import in instanceof
|
||||
new return super switch this throw try typeof
|
||||
var void while with
|
||||
""", suffix=r"\b"), next='reg'),
|
||||
Tok("reserved", literals("null true false", suffix=r"\b"), next='div'),
|
||||
Tok("id", r"""
|
||||
([a-zA-Z_$ ]|\\u[0-9a-fA-Z]{4}) # first char
|
||||
([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})* # rest chars
|
||||
""", next='div'),
|
||||
Tok("hnum", r"0[xX][0-9a-fA-F]+", next='div'),
|
||||
Tok("onum", r"0[0-7]+"),
|
||||
Tok("dnum", r"""
|
||||
( (0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||
\. # dot
|
||||
[0-9]* # DecimalDigits-opt
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
|
|
||||
\. # dot
|
||||
[0-9]+ # DecimalDigits
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
|
|
||||
(0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
)
|
||||
""", next='div'),
|
||||
Tok("punct", literals("""
|
||||
>>>= === !== >>> <<= >>= <= >= == != << >> &&
|
||||
|| += -= *= %= &= |= ^=
|
||||
"""), next="reg"),
|
||||
Tok("punct", literals("++ -- ) ]"), next='div'),
|
||||
Tok("punct", literals("{ } ( [ . ; , < > + - * % & | ^ ! ~ ? : ="), next='reg'),
|
||||
Tok("string", r'"([^"\\]|(\\(.|\n)))*?"', next='div'),
|
||||
Tok("string", r"'([^'\\]|(\\(.|\n)))*?'", next='div'),
|
||||
Tok("comment", r"/\*(.|\n)*?\*/"),
|
||||
Tok("linecomment", r"//.*?$"),
|
||||
Tok("ws", r"\s+"),
|
||||
Tok("keyword", literals("""
|
||||
break case catch class const continue debugger
|
||||
default delete do else enum export extends
|
||||
finally for function if import in instanceof
|
||||
new return super switch this throw try typeof
|
||||
var void while with
|
||||
""", suffix=r"\b"), next='reg'),
|
||||
Tok("reserved", literals("null true false", suffix=r"\b"), next='div'),
|
||||
Tok("id", r"""
|
||||
([a-zA-Z_$ ]|\\u[0-9a-fA-Z]{4}) # first char
|
||||
([a-zA-Z_$0-9]|\\u[0-9a-fA-F]{4})* # rest chars
|
||||
""", next='div'),
|
||||
Tok("hnum", r"0[xX][0-9a-fA-F]+", next='div'),
|
||||
Tok("onum", r"0[0-7]+"),
|
||||
Tok("dnum", r"""
|
||||
( (0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||
\. # dot
|
||||
[0-9]* # DecimalDigits-opt
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
|
|
||||
\. # dot
|
||||
[0-9]+ # DecimalDigits
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
|
|
||||
(0|[1-9][0-9]*) # DecimalIntegerLiteral
|
||||
([eE][-+]?[0-9]+)? # ExponentPart-opt
|
||||
)
|
||||
""", next='div'),
|
||||
Tok("punct", literals("""
|
||||
>>>= === !== >>> <<= >>= <= >= == != << >> &&
|
||||
|| += -= *= %= &= |= ^=
|
||||
"""), next="reg"),
|
||||
Tok("punct", literals("++ -- ) ]"), next='div'),
|
||||
Tok("punct", literals("{ } ( [ . ; , < > + - * % & | ^ ! ~ ? : ="), next='reg'),
|
||||
Tok("string", r'"([^"\\]|(\\(.|\n)))*?"', next='div'),
|
||||
Tok("string", r"'([^'\\]|(\\(.|\n)))*?'", next='div'),
|
||||
]
|
||||
|
||||
both_after = [
|
||||
Tok("other", r"."),
|
||||
Tok("other", r"."),
|
||||
]
|
||||
|
||||
states = {
|
||||
|
||||
@@ -11,6 +11,7 @@ background = dict((color_names[x], '4%s' % x) for x in range(8))
|
||||
RESET = '0'
|
||||
opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
|
||||
|
||||
|
||||
def colorize(text='', opts=(), **kwargs):
|
||||
"""
|
||||
Returns your text, enclosed in ANSI graphics codes.
|
||||
@@ -55,6 +56,7 @@ def colorize(text='', opts=(), **kwargs):
|
||||
text = '%s\x1b[%sm' % (text or '', RESET)
|
||||
return '%s%s' % (('\x1b[%sm' % ';'.join(code_list)), text or '')
|
||||
|
||||
|
||||
def make_style(opts=(), **kwargs):
|
||||
"""
|
||||
Returns a function with default parameters for colorize()
|
||||
@@ -73,65 +75,66 @@ LIGHT_PALETTE = 'light'
|
||||
|
||||
PALETTES = {
|
||||
NOCOLOR_PALETTE: {
|
||||
'ERROR': {},
|
||||
'NOTICE': {},
|
||||
'SQL_FIELD': {},
|
||||
'SQL_COLTYPE': {},
|
||||
'SQL_KEYWORD': {},
|
||||
'SQL_TABLE': {},
|
||||
'HTTP_INFO': {},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {},
|
||||
'ERROR': {},
|
||||
'NOTICE': {},
|
||||
'SQL_FIELD': {},
|
||||
'SQL_COLTYPE': {},
|
||||
'SQL_KEYWORD': {},
|
||||
'SQL_TABLE': {},
|
||||
'HTTP_INFO': {},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {},
|
||||
'HTTP_NOT_MODIFIED': {},
|
||||
'HTTP_BAD_REQUEST': {},
|
||||
'HTTP_NOT_FOUND': {},
|
||||
'HTTP_BAD_REQUEST': {},
|
||||
'HTTP_NOT_FOUND': {},
|
||||
'HTTP_SERVER_ERROR': {},
|
||||
'MIGRATE_HEADING': {},
|
||||
'MIGRATE_LABEL': {},
|
||||
'MIGRATE_SUCCESS': {},
|
||||
'MIGRATE_FAILURE': {},
|
||||
'MIGRATE_HEADING': {},
|
||||
'MIGRATE_LABEL': {},
|
||||
'MIGRATE_SUCCESS': {},
|
||||
'MIGRATE_FAILURE': {},
|
||||
},
|
||||
DARK_PALETTE: {
|
||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||
'NOTICE': {'fg': 'red'},
|
||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||
'SQL_COLTYPE': {'fg': 'green'},
|
||||
'SQL_KEYWORD': {'fg': 'yellow'},
|
||||
'SQL_TABLE': {'opts': ('bold',)},
|
||||
'HTTP_INFO': {'opts': ('bold',)},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {'fg': 'green'},
|
||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||
'NOTICE': {'fg': 'red'},
|
||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||
'SQL_COLTYPE': {'fg': 'green'},
|
||||
'SQL_KEYWORD': {'fg': 'yellow'},
|
||||
'SQL_TABLE': {'opts': ('bold',)},
|
||||
'HTTP_INFO': {'opts': ('bold',)},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {'fg': 'green'},
|
||||
'HTTP_NOT_MODIFIED': {'fg': 'cyan'},
|
||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||
'HTTP_NOT_FOUND': {'fg': 'yellow'},
|
||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||
'HTTP_NOT_FOUND': {'fg': 'yellow'},
|
||||
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||
},
|
||||
LIGHT_PALETTE: {
|
||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||
'NOTICE': {'fg': 'red'},
|
||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||
'SQL_COLTYPE': {'fg': 'green'},
|
||||
'SQL_KEYWORD': {'fg': 'blue'},
|
||||
'SQL_TABLE': {'opts': ('bold',)},
|
||||
'HTTP_INFO': {'opts': ('bold',)},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)},
|
||||
'ERROR': {'fg': 'red', 'opts': ('bold',)},
|
||||
'NOTICE': {'fg': 'red'},
|
||||
'SQL_FIELD': {'fg': 'green', 'opts': ('bold',)},
|
||||
'SQL_COLTYPE': {'fg': 'green'},
|
||||
'SQL_KEYWORD': {'fg': 'blue'},
|
||||
'SQL_TABLE': {'opts': ('bold',)},
|
||||
'HTTP_INFO': {'opts': ('bold',)},
|
||||
'HTTP_SUCCESS': {},
|
||||
'HTTP_REDIRECT': {'fg': 'green', 'opts': ('bold',)},
|
||||
'HTTP_NOT_MODIFIED': {'fg': 'green'},
|
||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||
'HTTP_NOT_FOUND': {'fg': 'red'},
|
||||
'HTTP_BAD_REQUEST': {'fg': 'red', 'opts': ('bold',)},
|
||||
'HTTP_NOT_FOUND': {'fg': 'red'},
|
||||
'HTTP_SERVER_ERROR': {'fg': 'magenta', 'opts': ('bold',)},
|
||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||
'MIGRATE_HEADING': {'fg': 'cyan', 'opts': ('bold',)},
|
||||
'MIGRATE_LABEL': {'opts': ('bold',)},
|
||||
'MIGRATE_SUCCESS': {'fg': 'green', 'opts': ('bold',)},
|
||||
'MIGRATE_FAILURE': {'fg': 'red', 'opts': ('bold',)},
|
||||
}
|
||||
}
|
||||
DEFAULT_PALETTE = DARK_PALETTE
|
||||
|
||||
|
||||
def parse_color_setting(config_string):
|
||||
"""Parse a DJANGO_COLORS environment variable to produce the system palette
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.utils import six
|
||||
|
||||
__all__ = [
|
||||
'activate', 'deactivate', 'override', 'deactivate_all',
|
||||
'get_language', 'get_language_from_request',
|
||||
'get_language', 'get_language_from_request',
|
||||
'get_language_info', 'get_language_bidi',
|
||||
'check_for_language', 'to_locale', 'templatize', 'string_concat',
|
||||
'gettext', 'gettext_lazy', 'gettext_noop',
|
||||
|
||||
Reference in New Issue
Block a user