# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/.
import re
class StringVersion(str): """
A string version that can be compared with comparison operators. """
# Pick out numeric and non-numeric parts (a match group for each type).
pat = re.compile(r"(\d+)|([^\d.]+)")
def __init__(self, vstring):
super().__init__()
# We'll use unicode internally. # This check is mainly for python2 strings (which are bytes). if isinstance(vstring, bytes):
vstring = vstring.decode("ascii")
self.vstring = vstring
# Store parts as strings to ease comparisons.
self.version = []
parts = self.pat.findall(vstring) # Pad numeric parts with leading zeros for ordering. for i, obj in enumerate(parts): if obj[0]:
self.version.append(obj[0].zfill(8)) else:
self.version.append(obj[1])
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.