[jhbuild/pre-3-cleanup] Remove hashlib import fallback
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/pre-3-cleanup] Remove hashlib import fallback
- Date: Sat, 21 Sep 2019 21:59:47 +0000 (UTC)
commit ebc85f20436c8d09c02884bf71f1fa7df897f063
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sat Sep 21 22:23:37 2019 +0200
Remove hashlib import fallback
hashlib exists since 2.5
jhbuild/modtypes/autotools.py | 5 +----
jhbuild/modtypes/tarball.py | 7 +------
jhbuild/modtypes/testmodule.py | 6 +-----
jhbuild/utils/packagedb.py | 6 +-----
jhbuild/versioncontrol/cvs.py | 6 +-----
jhbuild/versioncontrol/darcs.py | 6 +-----
jhbuild/versioncontrol/tarball.py | 7 ++-----
scripts/mk-tarball-moduleset.py | 4 ++--
8 files changed, 10 insertions(+), 37 deletions(-)
---
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index b3490697..4159ca7f 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -22,10 +22,7 @@ __metaclass__ = type
import os
import stat
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
+import hashlib
from jhbuild.errors import FatalError, CommandError
from jhbuild.modtypes import \
diff --git a/jhbuild/modtypes/tarball.py b/jhbuild/modtypes/tarball.py
index 40d32b47..04fd97bb 100644
--- a/jhbuild/modtypes/tarball.py
+++ b/jhbuild/modtypes/tarball.py
@@ -21,11 +21,6 @@ __metaclass__ = type
import logging
-try:
- import hashlib
-except ImportError:
- hashlib = None
-
from jhbuild.modtypes import register_module_type, get_dependencies, find_first_child_node_content
def parse_tarball(node, config, uri, repositories, default_repo):
@@ -69,7 +64,7 @@ def parse_tarball(node, config, uri, repositories, default_repo):
'module': name, 'size': childnode.getAttribute('size')})
if childnode.hasAttribute('md5sum'):
source_hash = 'md5:' + childnode.getAttribute('md5sum')
- if childnode.hasAttribute('hash') and hashlib:
+ if childnode.hasAttribute('hash'):
source_hash = childnode.getAttribute('hash')
elif childnode.nodeName == 'patches':
for patch in childnode.childNodes:
diff --git a/jhbuild/modtypes/testmodule.py b/jhbuild/modtypes/testmodule.py
index 31d9351c..2b012add 100644
--- a/jhbuild/modtypes/testmodule.py
+++ b/jhbuild/modtypes/testmodule.py
@@ -20,11 +20,7 @@
__metaclass__ = type
import os, time, signal, subprocess, random, tempfile
-
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
+import hashlib
from jhbuild.errors import CommandError, BuildStateError
from jhbuild.modtypes import \
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index c7b34c3c..6927ef17 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -21,11 +21,7 @@ import os
import time
import logging
import errno
-
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
+import hashlib
import xml.etree.ElementTree as ET
diff --git a/jhbuild/versioncontrol/cvs.py b/jhbuild/versioncontrol/cvs.py
index bb545c5b..3193b8d8 100644
--- a/jhbuild/versioncontrol/cvs.py
+++ b/jhbuild/versioncontrol/cvs.py
@@ -25,11 +25,7 @@ __metaclass__ = type
import sys
import os
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
-
+import hashlib
import git
from jhbuild.errors import BuildStateError, CommandError
diff --git a/jhbuild/versioncontrol/darcs.py b/jhbuild/versioncontrol/darcs.py
index 4650c238..711dc2bc 100644
--- a/jhbuild/versioncontrol/darcs.py
+++ b/jhbuild/versioncontrol/darcs.py
@@ -22,11 +22,7 @@ __metaclass__ = type
import os
import urlparse
-
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
+import hashlib
from jhbuild.errors import FatalError, CommandError
from jhbuild.versioncontrol import Repository, Branch, register_repo_type
diff --git a/jhbuild/versioncontrol/tarball.py b/jhbuild/versioncontrol/tarball.py
index 516ca1d8..cfce6a75 100644
--- a/jhbuild/versioncontrol/tarball.py
+++ b/jhbuild/versioncontrol/tarball.py
@@ -21,10 +21,7 @@ __all__ = []
__metaclass__ = type
import os
-try:
- import hashlib
-except ImportError:
- import md5 as hashlib
+import hashlib
import urlparse
import urllib2
import logging
@@ -77,7 +74,7 @@ class TarballRepository(Repository):
checkoutdir = checkoutdir.replace('${version}', version)
if size is not None:
size = int(size)
- if md5sum and (not hash or hashlib.__name__ == 'md5'):
+ if md5sum and not hash:
hash = 'md5:' + md5sum
if rename_tarball is not None:
rename_tarball = rename_tarball.replace('${name}', name).replace('${version}', version)
diff --git a/scripts/mk-tarball-moduleset.py b/scripts/mk-tarball-moduleset.py
index 5bf60bd6..2a7e9af5 100755
--- a/scripts/mk-tarball-moduleset.py
+++ b/scripts/mk-tarball-moduleset.py
@@ -6,7 +6,7 @@ import sys
import os
import stat
import re
-import md5
+import hashlib
import getopt
import urlparse
import ConfigParser
@@ -90,7 +90,7 @@ class SourceRepo:
info = os.stat(os.path.join(self.sourcedir, filename))
source_node.setAttribute('size', str(info[stat.ST_SIZE]))
- sum = md5.new()
+ sum = hashlib.new("md5")
fp = open(os.path.join(self.sourcedir, filename), 'rb')
data = fp.read(4096)
while data:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]