[Python-modules-commits] [python-django] 01/07: Import python-django_1.9.8.orig.tar.gz
Luke Faraone
lfaraone at moszumanska.debian.org
Tue Jul 19 16:18:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
lfaraone pushed a commit to branch debian/master
in repository python-django.
commit 096e282a00b0722fa2a45e69ee92745f027bf370
Author: Luke Faraone <lfaraone at debian.org>
Date: Tue Jul 19 14:13:27 2016 +0000
Import python-django_1.9.8.orig.tar.gz
---
Django.egg-info/PKG-INFO | 2 +-
Django.egg-info/SOURCES.txt | 6 +-
PKG-INFO | 2 +-
django/__init__.py | 2 +-
django/conf/global_settings.py | 4 +-
django/contrib/admin/options.py | 2 +-
.../static/admin/js/admin/RelatedObjectLookups.js | 2 +-
.../static/admin/js/vendor/xregexp/xregexp.js | 2308 +++++++++
django/contrib/gis/db/backends/base/models.py | 8 +-
django/contrib/gis/db/models/sql/aggregates.py | 10 -
django/contrib/gis/gdal/datasource.py | 2 +-
django/contrib/gis/gdal/envelope.py | 2 +-
django/contrib/gis/gdal/feature.py | 2 +-
django/contrib/gis/gdal/field.py | 2 +-
django/contrib/gis/gdal/geometries.py | 4 +-
django/contrib/gis/gdal/layer.py | 2 +-
django/contrib/gis/maps/google/__init__.py | 2 +-
django/contrib/gis/measure.py | 2 +-
django/core/cache/backends/memcached.py | 2 +-
django/core/files/temp.py | 2 +-
django/core/management/commands/makemessages.py | 2 +-
django/db/backends/oracle/operations.py | 2 +-
django/db/backends/postgresql/schema.py | 6 +
django/http/response.py | 2 +-
django/template/defaulttags.py | 8 +-
django/test/utils.py | 2 +-
django/views/debug.py | 4 +-
docs/faq/admin.txt | 11 +-
docs/howto/custom-model-fields.txt | 28 +
docs/howto/deployment/wsgi/apache-auth.txt | 2 +-
docs/howto/upgrade-version.txt | 39 +-
docs/intro/contributing.txt | 4 +-
docs/intro/reusable-apps.txt | 2 +-
docs/intro/tutorial01.txt | 9 +-
docs/intro/tutorial07.txt | 4 +-
docs/ref/contrib/admin/index.txt | 8 +-
docs/ref/contrib/gis/admin.txt | 2 +-
docs/ref/contrib/gis/install/index.txt | 2 +-
docs/ref/csrf.txt | 4 +-
docs/ref/django-admin.txt | 2 +-
docs/ref/forms/fields.txt | 21 +-
docs/ref/forms/validation.txt | 7 +-
docs/ref/models/conditional-expressions.txt | 5 +-
docs/ref/models/expressions.txt | 16 +
docs/ref/models/meta.txt | 6 +-
docs/ref/request-response.txt | 2 +-
docs/ref/templates/api.txt | 8 +
docs/ref/urlresolvers.txt | 2 +-
docs/releases/1.6.txt | 2 +-
docs/releases/1.7.txt | 8 +-
docs/releases/1.8.14.txt | 25 +
docs/releases/1.8.txt | 9 +-
docs/releases/1.9.8.txt | 28 +
docs/releases/1.9.txt | 9 +-
docs/releases/index.txt | 2 +
docs/topics/auth/default.txt | 8 +-
docs/topics/auth/passwords.txt | 4 +-
docs/topics/class-based-views/generic-display.txt | 2 +-
docs/topics/class-based-views/index.txt | 4 +-
docs/topics/class-based-views/intro.txt | 8 +-
docs/topics/http/file-uploads.txt | 6 +-
docs/topics/http/sessions.txt | 3 +
docs/topics/http/urls.txt | 4 +-
docs/topics/i18n/timezones.txt | 6 +-
docs/topics/i18n/translation.txt | 22 +-
docs/topics/install.txt | 2 +-
docs/topics/logging.txt | 2 +-
docs/topics/serialization.txt | 28 +-
docs/topics/testing/overview.txt | 16 +-
docs/topics/testing/tools.txt | 2 +-
js_tests/qunit/blanket.js | 5430 ++++++++++++++++++++
js_tests/qunit/blanket.min.js | 39 -
js_tests/tests.html | 2 +-
tests/admin_views/models.py | 4 +
tests/admin_views/tests.py | 9 +-
tests/file_storage/tests.py | 8 +
tests/i18n/test_extraction.py | 7 +
.../migrations/0002_create_test_models.py | 5 +-
tests/schema/tests.py | 44 +-
tests/servers/tests.py | 14 +-
tests/template_tests/syntax_tests/test_numpy.py | 14 +-
81 files changed, 8146 insertions(+), 208 deletions(-)
diff --git a/Django.egg-info/PKG-INFO b/Django.egg-info/PKG-INFO
index b02cca7..8007c97 100644
--- a/Django.egg-info/PKG-INFO
+++ b/Django.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: Django
-Version: 1.9.7
+Version: 1.9.8
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: http://www.djangoproject.com/
Author: Django Software Foundation
diff --git a/Django.egg-info/SOURCES.txt b/Django.egg-info/SOURCES.txt
index b020203..5a8d83d 100644
--- a/Django.egg-info/SOURCES.txt
+++ b/Django.egg-info/SOURCES.txt
@@ -766,6 +766,7 @@ django/contrib/admin/static/admin/js/vendor/jquery/LICENSE-JQUERY.txt
django/contrib/admin/static/admin/js/vendor/jquery/jquery.js
django/contrib/admin/static/admin/js/vendor/jquery/jquery.min.js
django/contrib/admin/static/admin/js/vendor/xregexp/LICENSE-XREGEXP.txt
+django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js
django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.min.js
django/contrib/admin/templates/admin/404.html
django/contrib/admin/templates/admin/500.html
@@ -1632,7 +1633,6 @@ django/contrib/gis/db/models/manager.py
django/contrib/gis/db/models/proxy.py
django/contrib/gis/db/models/query.py
django/contrib/gis/db/models/sql/__init__.py
-django/contrib/gis/db/models/sql/aggregates.py
django/contrib/gis/db/models/sql/conversion.py
django/contrib/gis/forms/__init__.py
django/contrib/gis/forms/fields.py
@@ -3455,6 +3455,7 @@ docs/releases/1.8.10.txt
docs/releases/1.8.11.txt
docs/releases/1.8.12.txt
docs/releases/1.8.13.txt
+docs/releases/1.8.14.txt
docs/releases/1.8.2.txt
docs/releases/1.8.3.txt
docs/releases/1.8.4.txt
@@ -3471,6 +3472,7 @@ docs/releases/1.9.4.txt
docs/releases/1.9.5.txt
docs/releases/1.9.6.txt
docs/releases/1.9.7.txt
+docs/releases/1.9.8.txt
docs/releases/1.9.txt
docs/releases/index.txt
docs/releases/security.txt
@@ -3558,7 +3560,7 @@ js_tests/admin/core.test.js
js_tests/admin/inlines.test.js
js_tests/admin/jsi18n-mocks.test.js
js_tests/admin/timeparse.test.js
-js_tests/qunit/blanket.min.js
+js_tests/qunit/blanket.js
js_tests/qunit/grunt-reporter.js
js_tests/qunit/qunit.css
js_tests/qunit/qunit.js
diff --git a/PKG-INFO b/PKG-INFO
index b02cca7..8007c97 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: Django
-Version: 1.9.7
+Version: 1.9.8
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: http://www.djangoproject.com/
Author: Django Software Foundation
diff --git a/django/__init__.py b/django/__init__.py
index cb6deaf..9583467 100644
--- a/django/__init__.py
+++ b/django/__init__.py
@@ -1,6 +1,6 @@
from django.utils.version import get_version
-VERSION = (1, 9, 7, 'final', 0)
+VERSION = (1, 9, 8, 'final', 0)
__version__ = get_version(VERSION)
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index d85e69d..d01ab1c 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -318,12 +318,12 @@ FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB
FILE_UPLOAD_TEMP_DIR = None
# The numeric mode to set newly-uploaded files to. The value should be a mode
-# you'd pass directly to os.chmod; see http://docs.python.org/lib/os-file-dir.html.
+# you'd pass directly to os.chmod; see https://docs.python.org/3/library/os.html#files-and-directories.
FILE_UPLOAD_PERMISSIONS = None
# The numeric mode to assign to newly-created directories, when uploading files.
# The value should be a mode as you'd pass to os.chmod;
-# see http://docs.python.org/lib/os-file-dir.html.
+# see https://docs.python.org/3/library/os.html#files-and-directories.
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
# Python module path where user will place custom format definition.
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 5264005..d97661e 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -572,7 +572,7 @@ class ModelAdmin(BaseModelAdmin):
'actions%s.js' % extra,
'urlify.js',
'prepopulate%s.js' % extra,
- 'vendor/xregexp/xregexp.min.js',
+ 'vendor/xregexp/xregexp%s.js' % extra,
]
return forms.Media(js=[static('admin/js/%s' % url) for url in js])
diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
index 4ac9baa..76cc952 100644
--- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
+++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
@@ -120,7 +120,7 @@
var selects = django.jQuery(selectsSelector);
selects.find('option').each(function() {
if (this.value === objId) {
- this.innerHTML = newRepr;
+ this.textContent = newRepr;
this.value = newId;
}
});
diff --git a/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js b/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js
new file mode 100755
index 0000000..7a4454e
--- /dev/null
+++ b/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js
@@ -0,0 +1,2308 @@
+
+/***** xregexp.js *****/
+
+/*!
+ * XRegExp v2.0.0
+ * (c) 2007-2012 Steven Levithan <http://xregexp.com/>
+ * MIT License
+ */
+
+/**
+ * XRegExp provides augmented, extensible JavaScript regular expressions. You get new syntax,
+ * flags, and methods beyond what browsers support natively. XRegExp is also a regex utility belt
+ * with tools to make your client-side grepping simpler and more powerful, while freeing you from
+ * worrying about pesky cross-browser inconsistencies and the dubious `lastIndex` property. See
+ * XRegExp's documentation (http://xregexp.com/) for more details.
+ * @module xregexp
+ * @requires N/A
+ */
+var XRegExp;
+
+// Avoid running twice; that would reset tokens and could break references to native globals
+XRegExp = XRegExp || (function (undef) {
+ "use strict";
+
+/*--------------------------------------
+ * Private variables
+ *------------------------------------*/
+
+ var self,
+ addToken,
+ add,
+
+// Optional features; can be installed and uninstalled
+ features = {
+ natives: false,
+ extensibility: false
+ },
+
+// Store native methods to use and restore ("native" is an ES3 reserved keyword)
+ nativ = {
+ exec: RegExp.prototype.exec,
+ test: RegExp.prototype.test,
+ match: String.prototype.match,
+ replace: String.prototype.replace,
+ split: String.prototype.split
+ },
+
+// Storage for fixed/extended native methods
+ fixed = {},
+
+// Storage for cached regexes
+ cache = {},
+
+// Storage for addon tokens
+ tokens = [],
+
+// Token scopes
+ defaultScope = "default",
+ classScope = "class",
+
+// Regexes that match native regex syntax
+ nativeTokens = {
+ // Any native multicharacter token in default scope (includes octals, excludes character classes)
+ "default": /^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/,
+ // Any native multicharacter token in character class scope (includes octals)
+ "class": /^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/
+ },
+
+// Any backreference in replacement strings
+ replacementToken = /\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g,
+
+// Any character with a later instance in the string
+ duplicateFlags = /([\s\S])(?=[\s\S]*\1)/g,
+
+// Any greedy/lazy quantifier
+ quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/,
+
+// Check for correct `exec` handling of nonparticipating capturing groups
+ compliantExecNpcg = nativ.exec.call(/()??/, "")[1] === undef,
+
+// Check for flag y support (Firefox 3+)
+ hasNativeY = RegExp.prototype.sticky !== undef,
+
+// Used to kill infinite recursion during XRegExp construction
+ isInsideConstructor = false,
+
+// Storage for known flags, including addon flags
+ registeredFlags = "gim" + (hasNativeY ? "y" : "");
+
+/*--------------------------------------
+ * Private helper functions
+ *------------------------------------*/
+
+/**
+ * Attaches XRegExp.prototype properties and named capture supporting data to a regex object.
+ * @private
+ * @param {RegExp} regex Regex to augment.
+ * @param {Array} captureNames Array with capture names, or null.
+ * @param {Boolean} [isNative] Whether the regex was created by `RegExp` rather than `XRegExp`.
+ * @returns {RegExp} Augmented regex.
+ */
+ function augment(regex, captureNames, isNative) {
+ var p;
+ // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value
+ for (p in self.prototype) {
+ if (self.prototype.hasOwnProperty(p)) {
+ regex[p] = self.prototype[p];
+ }
+ }
+ regex.xregexp = {captureNames: captureNames, isNative: !!isNative};
+ return regex;
+ }
+
+/**
+ * Returns native `RegExp` flags used by a regex object.
+ * @private
+ * @param {RegExp} regex Regex to check.
+ * @returns {String} Native flags in use.
+ */
+ function getNativeFlags(regex) {
+ //return nativ.exec.call(/\/([a-z]*)$/i, String(regex))[1];
+ return (regex.global ? "g" : "") +
+ (regex.ignoreCase ? "i" : "") +
+ (regex.multiline ? "m" : "") +
+ (regex.extended ? "x" : "") + // Proposed for ES6, included in AS3
+ (regex.sticky ? "y" : ""); // Proposed for ES6, included in Firefox 3+
+ }
+
+/**
+ * Copies a regex object while preserving special properties for named capture and augmenting with
+ * `XRegExp.prototype` methods. The copy has a fresh `lastIndex` property (set to zero). Allows
+ * adding and removing flags while copying the regex.
+ * @private
+ * @param {RegExp} regex Regex to copy.
+ * @param {String} [addFlags] Flags to be added while copying the regex.
+ * @param {String} [removeFlags] Flags to be removed while copying the regex.
+ * @returns {RegExp} Copy of the provided regex, possibly with modified flags.
+ */
+ function copy(regex, addFlags, removeFlags) {
+ if (!self.isRegExp(regex)) {
+ throw new TypeError("type RegExp expected");
+ }
+ var flags = nativ.replace.call(getNativeFlags(regex) + (addFlags || ""), duplicateFlags, "");
+ if (removeFlags) {
+ // Would need to escape `removeFlags` if this was public
+ flags = nativ.replace.call(flags, new RegExp("[" + removeFlags + "]+", "g"), "");
+ }
+ if (regex.xregexp && !regex.xregexp.isNative) {
+ // Compiling the current (rather than precompilation) source preserves the effects of nonnative source flags
+ regex = augment(self(regex.source, flags),
+ regex.xregexp.captureNames ? regex.xregexp.captureNames.slice(0) : null);
+ } else {
+ // Augment with `XRegExp.prototype` methods, but use native `RegExp` (avoid searching for special tokens)
+ regex = augment(new RegExp(regex.source, flags), null, true);
+ }
+ return regex;
+ }
+
+/*
+ * Returns the last index at which a given value can be found in an array, or `-1` if it's not
+ * present. The array is searched backwards.
+ * @private
+ * @param {Array} array Array to search.
+ * @param {*} value Value to locate in the array.
+ * @returns {Number} Last zero-based index at which the item is found, or -1.
+ */
+ function lastIndexOf(array, value) {
+ var i = array.length;
+ if (Array.prototype.lastIndexOf) {
+ return array.lastIndexOf(value); // Use the native method if available
+ }
+ while (i--) {
+ if (array[i] === value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+/**
+ * Determines whether an object is of the specified type.
+ * @private
+ * @param {*} value Object to check.
+ * @param {String} type Type to check for, in lowercase.
+ * @returns {Boolean} Whether the object matches the type.
+ */
+ function isType(value, type) {
+ return Object.prototype.toString.call(value).toLowerCase() === "[object " + type + "]";
+ }
+
+/**
+ * Prepares an options object from the given value.
+ * @private
+ * @param {String|Object} value Value to convert to an options object.
+ * @returns {Object} Options object.
+ */
+ function prepareOptions(value) {
+ value = value || {};
+ if (value === "all" || value.all) {
+ value = {natives: true, extensibility: true};
+ } else if (isType(value, "string")) {
+ value = self.forEach(value, /[^\s,]+/, function (m) {
+ this[m] = true;
+ }, {});
+ }
+ return value;
+ }
+
+/**
+ * Runs built-in/custom tokens in reverse insertion order, until a match is found.
+ * @private
+ * @param {String} pattern Original pattern from which an XRegExp object is being built.
+ * @param {Number} pos Position to search for tokens within `pattern`.
+ * @param {Number} scope Current regex scope.
+ * @param {Object} context Context object assigned to token handler functions.
+ * @returns {Object} Object with properties `output` (the substitution string returned by the
+ * successful token handler) and `match` (the token's match array), or null.
+ */
+ function runTokens(pattern, pos, scope, context) {
+ var i = tokens.length,
+ result = null,
+ match,
+ t;
+ // Protect against constructing XRegExps within token handler and trigger functions
+ isInsideConstructor = true;
+ // Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws
+ try {
+ while (i--) { // Run in reverse order
+ t = tokens[i];
+ if ((t.scope === "all" || t.scope === scope) && (!t.trigger || t.trigger.call(context))) {
+ t.pattern.lastIndex = pos;
+ match = fixed.exec.call(t.pattern, pattern); // Fixed `exec` here allows use of named backreferences, etc.
+ if (match && match.index === pos) {
+ result = {
+ output: t.handler.call(context, match, scope),
+ match: match
+ };
+ break;
+ }
+ }
+ }
+ } catch (err) {
+ throw err;
+ } finally {
+ isInsideConstructor = false;
+ }
+ return result;
+ }
+
+/**
+ * Enables or disables XRegExp syntax and flag extensibility.
+ * @private
+ * @param {Boolean} on `true` to enable; `false` to disable.
+ */
+ function setExtensibility(on) {
+ self.addToken = addToken[on ? "on" : "off"];
+ features.extensibility = on;
+ }
+
+/**
+ * Enables or disables native method overrides.
+ * @private
+ * @param {Boolean} on `true` to enable; `false` to disable.
+ */
+ function setNatives(on) {
+ RegExp.prototype.exec = (on ? fixed : nativ).exec;
+ RegExp.prototype.test = (on ? fixed : nativ).test;
+ String.prototype.match = (on ? fixed : nativ).match;
+ String.prototype.replace = (on ? fixed : nativ).replace;
+ String.prototype.split = (on ? fixed : nativ).split;
+ features.natives = on;
+ }
+
+/*--------------------------------------
+ * Constructor
+ *------------------------------------*/
+
+/**
+ * Creates an extended regular expression object for matching text with a pattern. Differs from a
+ * native regular expression in that additional syntax and flags are supported. The returned object
+ * is in fact a native `RegExp` and works with all native methods.
+ * @class XRegExp
+ * @constructor
+ * @param {String|RegExp} pattern Regex pattern string, or an existing `RegExp` object to copy.
+ * @param {String} [flags] Any combination of flags:
+ * <li>`g` - global
+ * <li>`i` - ignore case
+ * <li>`m` - multiline anchors
+ * <li>`n` - explicit capture
+ * <li>`s` - dot matches all (aka singleline)
+ * <li>`x` - free-spacing and line comments (aka extended)
+ * <li>`y` - sticky (Firefox 3+ only)
+ * Flags cannot be provided when constructing one `RegExp` from another.
+ * @returns {RegExp} Extended regular expression object.
+ * @example
+ *
+ * // With named capture and flag x
+ * date = XRegExp('(?<year> [0-9]{4}) -? # year \n\
+ * (?<month> [0-9]{2}) -? # month \n\
+ * (?<day> [0-9]{2}) # day ', 'x');
+ *
+ * // Passing a regex object to copy it. The copy maintains special properties for named capture,
+ * // is augmented with `XRegExp.prototype` methods, and has a fresh `lastIndex` property (set to
+ * // zero). Native regexes are not recompiled using XRegExp syntax.
+ * XRegExp(/regex/);
+ */
+ self = function (pattern, flags) {
+ if (self.isRegExp(pattern)) {
+ if (flags !== undef) {
+ throw new TypeError("can't supply flags when constructing one RegExp from another");
+ }
+ return copy(pattern);
+ }
+ // Tokens become part of the regex construction process, so protect against infinite recursion
+ // when an XRegExp is constructed within a token handler function
+ if (isInsideConstructor) {
+ throw new Error("can't call the XRegExp constructor within token definition functions");
+ }
+
+ var output = [],
+ scope = defaultScope,
+ tokenContext = {
+ hasNamedCapture: false,
+ captureNames: [],
+ hasFlag: function (flag) {
+ return flags.indexOf(flag) > -1;
+ }
+ },
+ pos = 0,
+ tokenResult,
+ match,
+ chr;
+ pattern = pattern === undef ? "" : String(pattern);
+ flags = flags === undef ? "" : String(flags);
+
+ if (nativ.match.call(flags, duplicateFlags)) { // Don't use test/exec because they would update lastIndex
+ throw new SyntaxError("invalid duplicate regular expression flag");
+ }
+ // Strip/apply leading mode modifier with any combination of flags except g or y: (?imnsx)
+ pattern = nativ.replace.call(pattern, /^\(\?([\w$]+)\)/, function ($0, $1) {
+ if (nativ.test.call(/[gy]/, $1)) {
+ throw new SyntaxError("can't use flag g or y in mode modifier");
+ }
+ flags = nativ.replace.call(flags + $1, duplicateFlags, "");
+ return "";
+ });
+ self.forEach(flags, /[\s\S]/, function (m) {
+ if (registeredFlags.indexOf(m[0]) < 0) {
+ throw new SyntaxError("invalid regular expression flag " + m[0]);
+ }
+ });
+
+ while (pos < pattern.length) {
+ // Check for custom tokens at the current position
+ tokenResult = runTokens(pattern, pos, scope, tokenContext);
+ if (tokenResult) {
+ output.push(tokenResult.output);
+ pos += (tokenResult.match[0].length || 1);
+ } else {
+ // Check for native tokens (except character classes) at the current position
+ match = nativ.exec.call(nativeTokens[scope], pattern.slice(pos));
+ if (match) {
+ output.push(match[0]);
+ pos += match[0].length;
+ } else {
+ chr = pattern.charAt(pos);
+ if (chr === "[") {
+ scope = classScope;
+ } else if (chr === "]") {
+ scope = defaultScope;
+ }
+ // Advance position by one character
+ output.push(chr);
+ ++pos;
+ }
+ }
+ }
+
+ return augment(new RegExp(output.join(""), nativ.replace.call(flags, /[^gimy]+/g, "")),
+ tokenContext.hasNamedCapture ? tokenContext.captureNames : null);
+ };
+
+/*--------------------------------------
+ * Public methods/properties
+ *------------------------------------*/
+
+// Installed and uninstalled states for `XRegExp.addToken`
+ addToken = {
+ on: function (regex, handler, options) {
+ options = options || {};
+ if (regex) {
+ tokens.push({
+ pattern: copy(regex, "g" + (hasNativeY ? "y" : "")),
+ handler: handler,
+ scope: options.scope || defaultScope,
+ trigger: options.trigger || null
+ });
+ }
+ // Providing `customFlags` with null `regex` and `handler` allows adding flags that do
+ // nothing, but don't throw an error
+ if (options.customFlags) {
+ registeredFlags = nativ.replace.call(registeredFlags + options.customFlags, duplicateFlags, "");
+ }
+ },
+ off: function () {
+ throw new Error("extensibility must be installed before using addToken");
+ }
+ };
+
+/**
+ * Extends or changes XRegExp syntax and allows custom flags. This is used internally and can be
+ * used to create XRegExp addons. `XRegExp.install('extensibility')` must be run before calling
+ * this function, or an error is thrown. If more than one token can match the same string, the last
+ * added wins.
+ * @memberOf XRegExp
+ * @param {RegExp} regex Regex object that matches the new token.
+ * @param {Function} handler Function that returns a new pattern string (using native regex syntax)
+ * to replace the matched token within all future XRegExp regexes. Has access to persistent
+ * properties of the regex being built, through `this`. Invoked with two arguments:
+ * <li>The match array, with named backreference properties.
+ * <li>The regex scope where the match was found.
+ * @param {Object} [options] Options object with optional properties:
+ * <li>`scope` {String} Scopes where the token applies: 'default', 'class', or 'all'.
+ * <li>`trigger` {Function} Function that returns `true` when the token should be applied; e.g.,
+ * if a flag is set. If `false` is returned, the matched string can be matched by other tokens.
+ * Has access to persistent properties of the regex being built, through `this` (including
+ * function `this.hasFlag`).
+ * <li>`customFlags` {String} Nonnative flags used by the token's handler or trigger functions.
+ * Prevents XRegExp from throwing an invalid flag error when the specified flags are used.
+ * @example
+ *
+ * // Basic usage: Adds \a for ALERT character
+ * XRegExp.addToken(
+ * /\\a/,
+ * function () {return '\\x07';},
+ * {scope: 'all'}
+ * );
+ * XRegExp('\\a[\\a-\\n]+').test('\x07\n\x07'); // -> true
+ */
+ self.addToken = addToken.off;
+
+/**
+ * Caches and returns the result of calling `XRegExp(pattern, flags)`. On any subsequent call with
+ * the same pattern and flag combination, the cached copy is returned.
+ * @memberOf XRegExp
+ * @param {String} pattern Regex pattern string.
+ * @param {String} [flags] Any combination of XRegExp flags.
+ * @returns {RegExp} Cached XRegExp object.
+ * @example
+ *
+ * while (match = XRegExp.cache('.', 'gs').exec(str)) {
+ * // The regex is compiled once only
+ * }
+ */
+ self.cache = function (pattern, flags) {
+ var key = pattern + "/" + (flags || "");
+ return cache[key] || (cache[key] = self(pattern, flags));
+ };
+
+/**
+ * Escapes any regular expression metacharacters, for use when matching literal strings. The result
+ * can safely be used at any point within a regex that uses any flags.
+ * @memberOf XRegExp
+ * @param {String} str String to escape.
+ * @returns {String} String with regex metacharacters escaped.
+ * @example
+ *
+ * XRegExp.escape('Escaped? <.>');
+ * // -> 'Escaped\?\ <\.>'
+ */
+ self.escape = function (str) {
+ return nativ.replace.call(str, /[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ };
+
+/**
+ * Executes a regex search in a specified string. Returns a match array or `null`. If the provided
+ * regex uses named capture, named backreference properties are included on the match array.
+ * Optional `pos` and `sticky` arguments specify the search start position, and whether the match
+ * must start at the specified position only. The `lastIndex` property of the provided regex is not
+ * used, but is updated for compatibility. Also fixes browser bugs compared to the native
+ * `RegExp.prototype.exec` and can be used reliably cross-browser.
+ * @memberOf XRegExp
+ * @param {String} str String to search.
+ * @param {RegExp} regex Regex to search with.
+ * @param {Number} [pos=0] Zero-based index at which to start the search.
+ * @param {Boolean|String} [sticky=false] Whether the match must start at the specified position
+ * only. The string `'sticky'` is accepted as an alternative to `true`.
+ * @returns {Array} Match array with named backreference properties, or null.
+ * @example
+ *
+ * // Basic use, with named backreference
+ * var match = XRegExp.exec('U+2620', XRegExp('U\\+(?<hex>[0-9A-F]{4})'));
+ * match.hex; // -> '2620'
+ *
+ * // With pos and sticky, in a loop
+ * var pos = 2, result = [], match;
+ * while (match = XRegExp.exec('<1><2><3><4>5<6>', /<(\d)>/, pos, 'sticky')) {
+ * result.push(match[1]);
+ * pos = match.index + match[0].length;
+ * }
+ * // result -> ['2', '3', '4']
+ */
+ self.exec = function (str, regex, pos, sticky) {
+ var r2 = copy(regex, "g" + (sticky && hasNativeY ? "y" : ""), (sticky === false ? "y" : "")),
+ match;
+ r2.lastIndex = pos = pos || 0;
+ match = fixed.exec.call(r2, str); // Fixed `exec` required for `lastIndex` fix, etc.
+ if (sticky && match && match.index !== pos) {
+ match = null;
+ }
+ if (regex.global) {
+ regex.lastIndex = match ? r2.lastIndex : 0;
+ }
+ return match;
+ };
+
+/**
+ * Executes a provided function once per regex match.
+ * @memberOf XRegExp
+ * @param {String} str String to search.
+ * @param {RegExp} regex Regex to search with.
+ * @param {Function} callback Function to execute for each match. Invoked with four arguments:
+ * <li>The match array, with named backreference properties.
+ * <li>The zero-based match index.
+ * <li>The string being traversed.
+ * <li>The regex object being used to traverse the string.
+ * @param {*} [context] Object to use as `this` when executing `callback`.
+ * @returns {*} Provided `context` object.
+ * @example
+ *
+ * // Extracts every other digit from a string
+ * XRegExp.forEach('1a2345', /\d/, function (match, i) {
+ * if (i % 2) this.push(+match[0]);
+ * }, []);
+ * // -> [2, 4]
+ */
+ self.forEach = function (str, regex, callback, context) {
+ var pos = 0,
+ i = -1,
+ match;
+ while ((match = self.exec(str, regex, pos))) {
+ callback.call(context, match, ++i, str, regex);
+ pos = match.index + (match[0].length || 1);
+ }
+ return context;
+ };
+
+/**
+ * Copies a regex object and adds flag `g`. The copy maintains special properties for named
+ * capture, is augmented with `XRegExp.prototype` methods, and has a fresh `lastIndex` property
+ * (set to zero). Native regexes are not recompiled using XRegExp syntax.
+ * @memberOf XRegExp
+ * @param {RegExp} regex Regex to globalize.
+ * @returns {RegExp} Copy of the provided regex with flag `g` added.
+ * @example
+ *
+ * var globalCopy = XRegExp.globalize(/regex/);
+ * globalCopy.global; // -> true
+ */
+ self.globalize = function (regex) {
+ return copy(regex, "g");
+ };
+
+/**
+ * Installs optional features according to the specified options.
+ * @memberOf XRegExp
+ * @param {Object|String} options Options object or string.
+ * @example
+ *
+ * // With an options object
+ * XRegExp.install({
+ * // Overrides native regex methods with fixed/extended versions that support named
+ * // backreferences and fix numerous cross-browser bugs
+ * natives: true,
+ *
+ * // Enables extensibility of XRegExp syntax and flags
+ * extensibility: true
+ * });
+ *
+ * // With an options string
+ * XRegExp.install('natives extensibility');
+ *
+ * // Using a shortcut to install all optional features
+ * XRegExp.install('all');
+ */
+ self.install = function (options) {
+ options = prepareOptions(options);
+ if (!features.natives && options.natives) {
+ setNatives(true);
+ }
+ if (!features.extensibility && options.extensibility) {
+ setExtensibility(true);
+ }
+ };
+
+/**
+ * Checks whether an individual optional feature is installed.
+ * @memberOf XRegExp
+ * @param {String} feature Name of the feature to check. One of:
+ * <li>`natives`
+ * <li>`extensibility`
+ * @returns {Boolean} Whether the feature is installed.
+ * @example
+ *
+ * XRegExp.isInstalled('natives');
+ */
+ self.isInstalled = function (feature) {
+ return !!(features[feature]);
+ };
+
+/**
+ * Returns `true` if an object is a regex; `false` if it isn't. This works correctly for regexes
+ * created in another frame, when `instanceof` and `constructor` checks would fail.
+ * @memberOf XRegExp
+ * @param {*} value Object to check.
+ * @returns {Boolean} Whether the object is a `RegExp` object.
+ * @example
+ *
+ * XRegExp.isRegExp('string'); // -> false
+ * XRegExp.isRegExp(/regex/i); // -> true
+ * XRegExp.isRegExp(RegExp('^', 'm')); // -> true
+ * XRegExp.isRegExp(XRegExp('(?s).')); // -> true
+ */
+ self.isRegExp = function (value) {
+ return isType(value, "regexp");
+ };
+
+/**
+ * Retrieves the matches from searching a string using a chain of regexes that successively search
+ * within previous matches. The provided `chain` array can contain regexes and objects with `regex`
+ * and `backref` properties. When a backreference is specified, the named or numbered backreference
+ * is passed forward to the next regex or returned.
+ * @memberOf XRegExp
+ * @param {String} str String to search.
+ * @param {Array} chain Regexes that each search for matches within preceding results.
+ * @returns {Array} Matches by the last regex in the chain, or an empty array.
+ * @example
+ *
+ * // Basic usage; matches numbers within <b> tags
+ * XRegExp.matchChain('1 <b>2</b> 3 <b>4 a 56</b>', [
+ * XRegExp('(?is)<b>.*?</b>'),
+ * /\d+/
+ * ]);
+ * // -> ['2', '4', '56']
+ *
+ * // Passing forward and returning specific backreferences
+ * html = '<a href="http://xregexp.com/api/">XRegExp</a>\
+ * <a href="http://www.google.com/">Google</a>';
+ * XRegExp.matchChain(html, [
+ * {regex: /<a href="([^"]+)">/i, backref: 1},
+ * {regex: XRegExp('(?i)^https?://(?<domain>[^/?#]+)'), backref: 'domain'}
+ * ]);
+ * // -> ['xregexp.com', 'www.google.com']
+ */
+ self.matchChain = function (str, chain) {
+ return (function recurseChain(values, level) {
+ var item = chain[level].regex ? chain[level] : {regex: chain[level]},
+ matches = [],
+ addMatch = function (match) {
+ matches.push(item.backref ? (match[item.backref] || "") : match[0]);
+ },
+ i;
+ for (i = 0; i < values.length; ++i) {
+ self.forEach(values[i], item.regex, addMatch);
+ }
+ return ((level === chain.length - 1) || !matches.length) ?
+ matches :
+ recurseChain(matches, level + 1);
+ }([str], 0));
+ };
+
+/**
+ * Returns a new string with one or all matches of a pattern replaced. The pattern can be a string
+ * or regex, and the replacement can be a string or a function to be called for each match. To
+ * perform a global search and replace, use the optional `scope` argument or include flag `g` if
+ * using a regex. Replacement strings can use `${n}` for named and numbered backreferences.
+ * Replacement functions can use named backreferences via `arguments[0].name`. Also fixes browser
+ * bugs compared to the native `String.prototype.replace` and can be used reliably cross-browser.
+ * @memberOf XRegExp
+ * @param {String} str String to search.
+ * @param {RegExp|String} search Search pattern to be replaced.
+ * @param {String|Function} replacement Replacement string or a function invoked to create it.
+ * Replacement strings can include special replacement syntax:
+ * <li>$$ - Inserts a literal '$'.
+ * <li>$&, $0 - Inserts the matched substring.
+ * <li>$` - Inserts the string that precedes the matched substring (left context).
+ * <li>$' - Inserts the string that follows the matched substring (right context).
+ * <li>$n, $nn - Where n/nn are digits referencing an existent capturing group, inserts
+ * backreference n/nn.
+ * <li>${n} - Where n is a name or any number of digits that reference an existent capturing
+ * group, inserts backreference n.
+ * Replacement functions are invoked with three or more arguments:
+ * <li>The matched substring (corresponds to $& above). Named backreferences are accessible as
+ * properties of this first argument.
+ * <li>0..n arguments, one for each backreference (corresponding to $1, $2, etc. above).
+ * <li>The zero-based index of the match within the total search string.
+ * <li>The total string being searched.
+ * @param {String} [scope='one'] Use 'one' to replace the first match only, or 'all'. If not
+ * explicitly specified and using a regex with flag `g`, `scope` is 'all'.
+ * @returns {String} New string with one or all matches replaced.
+ * @example
+ *
+ * // Regex search, using named backreferences in replacement string
+ * var name = XRegExp('(?<first>\\w+) (?<last>\\w+)');
+ * XRegExp.replace('John Smith', name, '${last}, ${first}');
+ * // -> 'Smith, John'
+ *
+ * // Regex search, using named backreferences in replacement function
+ * XRegExp.replace('John Smith', name, function (match) {
+ * return match.last + ', ' + match.first;
+ * });
+ * // -> 'Smith, John'
+ *
+ * // Global string search/replacement
+ * XRegExp.replace('RegExp builds RegExps', 'RegExp', 'XRegExp', 'all');
+ * // -> 'XRegExp builds XRegExps'
+ */
+ self.replace = function (str, search, replacement, scope) {
+ var isRegex = self.isRegExp(search),
+ search2 = search,
+ result;
+ if (isRegex) {
+ if (scope === undef && search.global) {
+ scope = "all"; // Follow flag g when `scope` isn't explicit
+ }
+ // Note that since a copy is used, `search`'s `lastIndex` isn't updated *during* replacement iterations
+ search2 = copy(search, scope === "all" ? "g" : "", scope === "all" ? "" : "g");
+ } else if (scope === "all") {
+ search2 = new RegExp(self.escape(String(search)), "g");
+ }
+ result = fixed.replace.call(String(str), search2, replacement); // Fixed `replace` required for named backreferences, etc.
+ if (isRegex && search.global) {
+ search.lastIndex = 0; // Fixes IE, Safari bug (last tested IE 9, Safari 5.1)
+ }
+ return result;
+ };
+
+/**
+ * Splits a string into an array of strings using a regex or string separator. Matches of the
+ * separator are not included in the result array. However, if `separator` is a regex that contains
+ * capturing groups, backreferences are spliced into the result each time `separator` is matched.
+ * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
+ * cross-browser.
+ * @memberOf XRegExp
+ * @param {String} str String to split.
+ * @param {RegExp|String} separator Regex or string to use for separating the string.
+ * @param {Number} [limit] Maximum number of items to include in the result array.
+ * @returns {Array} Array of substrings.
+ * @example
+ *
+ * // Basic use
+ * XRegExp.split('a b c', ' ');
+ * // -> ['a', 'b', 'c']
+ *
+ * // With limit
+ * XRegExp.split('a b c', ' ', 2);
+ * // -> ['a', 'b']
+ *
+ * // Backreferences in result array
+ * XRegExp.split('..word1..', /([a-z]+)(\d+)/i);
+ * // -> ['..', 'word', '1', '..']
+ */
+ self.split = function (str, separator, limit) {
+ return fixed.split.call(str, separator, limit);
+ };
+
+/**
+ * Executes a regex search in a specified string. Returns `true` or `false`. Optional `pos` and
+ * `sticky` arguments specify the search start position, and whether the match must start at the
+ * specified position only. The `lastIndex` property of the provided regex is not used, but is
+ * updated for compatibility. Also fixes browser bugs compared to the native
+ * `RegExp.prototype.test` and can be used reliably cross-browser.
+ * @memberOf XRegExp
+ * @param {String} str String to search.
+ * @param {RegExp} regex Regex to search with.
+ * @param {Number} [pos=0] Zero-based index at which to start the search.
+ * @param {Boolean|String} [sticky=false] Whether the match must start at the specified position
+ * only. The string `'sticky'` is accepted as an alternative to `true`.
+ * @returns {Boolean} Whether the regex matched the provided value.
... 8590 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django.git
More information about the Python-modules-commits
mailing list