auslib.util

auslib.util.cache

class auslib.util.cache.MaybeCacher

Bases: object

MaybeCacher is a very simple wrapper to work around the fact that we have two consumers of the auslib library (admin app, non-admin app) that require cache different things. Most notably, the non-admin app caches blobs and blob versions, while the admin app only caches blobs (because blob versions can change frequently). This class is intended to be instantiated as a global object, and then have caches created by consumers through calls to make_cache. Consumers that make changes (ie: the admin app) generally also set make_copies to True to get the cache to copy values on get/put to avoid the possibility of accidental cache pollution. For performance reasons, this should be disabled when not necessary.

If the cache given to get/put/clear/invalidate doesn’t exist, these methods are essentially no-ops. In a world where bug 1109295 is fixed, we might only need to handle the caching case.

clear(name=None)
get(name, key, value_getter=None)

Returns the value of the specified key from the named cache. If value_getter is provided and no cache is found, or no value is found for the key, the return value of value_getter will be returned instead.

invalidate(name, key)
make_cache(name, maxsize, timeout)
make_copies
put(name, key, value)
reset()

auslib.util.comparison

auslib.util.comparison.get_op(pattern)
auslib.util.comparison.has_operator(value)
auslib.util.comparison.int_compare(value, compstr)

Do a int comparison of a bare int with another, which may carry a comparison operator.

eg int_compare(1, ‘>2’) is False
auslib.util.comparison.string_compare(value, compstr)

Do a string comparison of a bare string with another, which may carry a comparison operator.

eg string_compare(‘a’, ‘>b’) is False
auslib.util.comparison.strip_operator(value)
auslib.util.comparison.version_compare(value, compstr)

Do a version comparison between a string (representing a version), with another which may carry a comparison operator. A true version comparison is done.

eg version_compare(‘1.1’, ‘>1.0’) is True

auslib.util.thirdparty

auslib.util.thirdparty.extendsyspath()

auslib.util.timestamp

auslib.util.timestamp.getMillisecondTimestamp()

auslib.util.versions

class auslib.util.versions.AncientMozillaVersion(vstring=None)

Bases: distutils.version.StrictVersion

A version class that is slightly less restrictive than StrictVersion. Instead of just allowing “a” or “b” as prerelease tags, it allows any alpha. This allows us to support the once-shipped “3.6.3plugin1” and similar versions. It also supports versions w.x.y.z by transmuting to w.x.z, which is useful for versions like 1.5.0.x and 2.0.0.y

version_re = <_sre.SRE_Pattern object>
class auslib.util.versions.ModernMozillaVersion(vstring=None)

Bases: distutils.version.StrictVersion

A version class that is slightly less restrictive than StrictVersion. Instead of just allowing “a” or “b” as prerelease tags, it allows any alpha. This allows us to support the once-shipped “3.6.3plugin1” and similar versions.

version_re = <_sre.SRE_Pattern object>
auslib.util.versions.MozillaVersion(version)
class auslib.util.versions.PostModernMozillaVersion(vstring=None)

Bases: distutils.version.StrictVersion

A version class that supports Firefox versions 5.0 and up, which may have “a1” but not “b2” tags in them

version_re = <_sre.SRE_Pattern object>
auslib.util.versions.decrement_version(version)

Decrements a version to its ‘previous’ version by subtracting one from its last part. If the last part is 0, it is changed to 99, and the second last part is subtracted by one. This is repeated until subtraction happens or we run out of parts.

auslib.util.versions.get_version_parts(version)
auslib.util.versions.increment_version(version)

Increments a version to its ‘next’ version by adding one to the last part of the version.