Only compile the version string regex once on module import.
* MOVE the compiled regex for matching the GnuPG binary's version to a module-level variable in `gnupg._util`.fix/44-verbose-arg
parent
7dc3b66de4
commit
eb25ef2b91
|
@ -70,6 +70,9 @@ _conf = os.path.join(os.path.join(_user, '.config'), 'python-gnupg')
|
||||||
## Logger is disabled by default
|
## Logger is disabled by default
|
||||||
log = _logger.create_logger(0)
|
log = _logger.create_logger(0)
|
||||||
|
|
||||||
|
#: Compiled regex for determining a GnuPG binary's version:
|
||||||
|
_VERSION_STRING_REGEX = re.compile('(\d)*(\.)*(\d)*(\.)*(\d)*')
|
||||||
|
|
||||||
|
|
||||||
def find_encodings(enc=None, system=False):
|
def find_encodings(enc=None, system=False):
|
||||||
"""Find functions for encoding translations for a specific codec.
|
"""Find functions for encoding translations for a specific codec.
|
||||||
|
@ -436,8 +439,7 @@ def _match_version_string(version):
|
||||||
|
|
||||||
:param str version: A version string in the form x.x.x
|
:param str version: A version string in the form x.x.x
|
||||||
"""
|
"""
|
||||||
regex = re.compile('(\d)*(\.)*(\d)*(\.)*(\d)*')
|
matched = _VERSION_STRING_REGEX.match(version)
|
||||||
matched = regex.match(version)
|
|
||||||
g = matched.groups()
|
g = matched.groups()
|
||||||
major, minor, micro = int(g[0]), int(g[2]), int(g[4])
|
major, minor, micro = int(g[0]), int(g[2]), int(g[4])
|
||||||
return (major, minor, micro)
|
return (major, minor, micro)
|
||||||
|
|
Loading…
Reference in New Issue