3N/A# The contents of this file are subject to the terms of the 3N/A# Common Development and Distribution License (the "License"). 3N/A# You may not use this file except in compliance with the License. 3N/A# See the License for the specific language governing permissions 3N/A# and limitations under the License. 3N/A# When distributing Covered Code, include this CDDL HEADER in each 3N/A# If applicable, add the following below this CDDL HEADER, with the 3N/A# fields enclosed by brackets "[]" replaced with your own identifying 3N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3158N/A# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. 933N/A """Base exception class for all version errors.""" 933N/A """Used to indicate that the specified DotSequence is not valid.""" 3N/A """A DotSequence is the typical "x.y.z" string used in software 3N/A versioning. We define the "major release" value and the "minor release" 3N/A value as the first two numbers in the sequence.""" 1698N/A # We employ the Flyweight design pattern for dotsequences, since they 1698N/A # are used immutably, are highly repetitive (0.5.11 over and over) and, 1698N/A # for what they contain, are relatively expensive memory-wise. 526N/A # Do this first; if the string is zero chars or non-numeric 526N/A # chars, this will throw. 1698N/A # Was I already initialized? See __new__ above. 30N/A """Return true if self is a "subsequence" of other, meaning that 30N/A other and self have identical components, up to the length of 30N/A self's sequence.""" 416N/A """ Test if DotSequences have the same major number """ 416N/A """ Test if DotSequences have the same major and minor num """ 852N/A """A subclass of DotSequence with (much) weaker rules about its format. 852N/A This is intended to accept user input with wildcard characters.""" 2224N/A # We employ the Flyweight design pattern for dotsequences, since they 2224N/A # are used immutably, are highly repetitive (0.5.11 over and over) and, 2224N/A # for what they contain, are relatively expensive memory-wise. 852N/A # Do this first; if the string is zero chars or non-numeric 852N/A # chars (other than "*"), an exception will be raised. 1537N/A """Return true if self is a "subsequence" of other, meaning that 1537N/A other and self have identical components, up to the length of 1537N/A self's sequence or self or other is '*'.""" 1537N/A """Test if DotSequences have the same major number, or major 1537N/A """ Test if DotSequences have the same major and minor num.""" 933N/A """Used to indicate that the specified version string is not valid.""" 59N/A """Version format is release[,build_release]-branch:datetime, which we 416N/A decompose into three DotSequences and a date string. Time 59N/A representation is in the ISO8601-compliant form "YYYYMMDDTHHMMSSZ", 59N/A referring to the UTC time associated with the version. The release and 59N/A branch DotSequences are interpreted normally, where v1 < v2 implies that 59N/A v2 is a later release or branch. The build_release DotSequence records 2958N/A the system on which the package binaries were constructed.""" 3N/A # XXX If illegally formatted, raise exception. 526N/A # Locate and extract the time, branch, and build strings, 526N/A # if specified. Error checking happens in the second half of 526N/A # the routine. In the event that a given part of the input is 526N/A # signalled but empty (for example: '0.3-' or '0.3-3.0:', 526N/A # we'll produce an empty (but not None) string for that portion. 526N/A # Locate and extract the time string, if specified. 526N/A # Locate and extract the branch string, if specified. 526N/A # Locate and extract the build string, if specified. 526N/A # Error checking and conversion from strings to objects 416N/A # In 99% of the cases in which we use date and time, it's solely 416N/A # for comparison. Since the ISO date string lexicographically 416N/A # collates in date order, we just hold onto the string- 416N/A # converting it to anything else is expensive. 2690N/A """Returns the serialized state of this object in a format 2690N/A that that can be easily stored using JSON, pickle, etc.""" 2690N/A """Allocate a new object using previously serialized state 2690N/A obtained via getstate().""" 175N/A """Returns True if 'self' comes before 'other', and vice versa. 175N/A If exactly one of the release values of the versions is None, 175N/A then that version is less than the other. The same applies to 175N/A the branch and timestamp components. 175N/A """Returns True if 'self' comes after 'other', and vice versa. 175N/A If exactly one of the release values of the versions is None, 175N/A then that version is less than the other. The same applies to 175N/A the branch and timestamp components. 526N/A # If a timestamp is present, it's enough to hash on, and is 526N/A # nicely unique. If not, use release and branch, which are 30N/A """Evaluate true if self is a successor version to other. 30N/A The loosest constraint is CONSTRAINT_NONE (None is treated 30N/A equivalently, which is a simple test for self > other. As we 30N/A proceed through the policies we get stricter, depending on the 30N/A selected constraint. 175N/A Slightly less loose is CONSTRAINT_AUTO. In this case, if any of 175N/A the release, branch, or timestamp components is None, it acts as 175N/A a "don't care" value -- a versioned component always succeeds 30N/A For CONSTRAINT_RELEASE, self is a successor to other if all of 30N/A the components of other's release match, and there are later 59N/A components of self's version. The branch and datetime 30N/A components are ignored. 30N/A For CONSTRAINT_RELEASE_MAJOR and CONSTRAINT_RELEASE_MINOR, other 30N/A is effectively truncated to [other[0]] and [other[0], other[1]] 30N/A prior to being treated as for CONSTRAINT_RELEASE. 30N/A Similarly for CONSTRAINT_BRANCH, the release fields of other and 30N/A self are expected to be identical, and then the branches are 30N/A compared as releases were for the CONSTRAINT_RELEASE* policies. 2199N/A """Takes an assumed valid version string and splits it into 1537N/A its components as a tuple of the form ((release, build_release, 1537N/A branch, timestr), short_ver).""" 1537N/A # Locate and extract the time string. 1537N/A # Locate and extract the branch string. 1537N/A # Locate and extract the build string. 852N/A """An alternative for Version with (much) weaker rules about its format. 852N/A This is intended to accept user input with globbing characters.""" 2224N/A # Treat special "latest" syntax as equivalent to '*' for 2224N/A # version comparison purposes. 852N/A # Error checking and conversion from strings to objects 852N/A # Every component of the version (after the first) is 852N/A # optional, if not provided, assume "*" (wildcard). 852N/A # Store the re-constructed input value for use as a string 852N/A # representation of this object. 852N/A """Returns True if 'self' comes before 'other', and vice versa. 852N/A If exactly one of the release values of the versions is None or 852N/A "*", then that version is less than the other. The same applies 852N/A to the branch and timestamp components. 852N/A """Returns True if 'self' comes after 'other', and vice versa. 852N/A If exactly one of the release values of the versions is None or 852N/A "*", then that version is less than the other. The same applies 852N/A to the branch and timestamp components. 852N/A # If a timestamp is present, it's enough to hash on, and is 852N/A # nicely unique. If not, use release and branch, which are