From: Tomasz Buchert Date: Sat, 29 Aug 2015 20:56:13 +0000 (+0200) Subject: move another function X-Git-Tag: v0.3~5 X-Git-Url: http://git.thekondor.net/?a=commitdiff_plain;h=81f870542f5082c880e8a2879c62d00cee444e38;p=debocker.git move another function --- diff --git a/debocker b/debocker index 641fa74..f93d40c 100755 --- a/debocker +++ b/debocker @@ -4,7 +4,6 @@ import click import re import os -import hashlib from os.path import isdir, join, isfile, abspath, dirname, \ realpath, splitext, relpath from subprocess import check_call, check_output, CalledProcessError, DEVNULL @@ -18,7 +17,8 @@ HERE = realpath(dirname(__file__)) # this is to allow to use it directory from source repository sys.path.append(join(HERE, 'src')) -from debocker.utils import cached_constant, cached_property, tmppath +from debocker.utils import cached_constant, cached_property, tmppath, \ + calculate_md5_and_size __version__ = "0.2" @@ -235,18 +235,6 @@ class Package: with open(filename, 'wb') as output: self.build_docker_tarball_to_fd(output, buildinfo) -def calculate_md5_and_size(path): - md5 = hashlib.md5() - count = 0 - with open(path, 'rb') as f: - while True: - buff = f.read(8192) - if len(buff) == 0: - break - count += len(buff) - md5.update(buff) - return md5.hexdigest(), count - def make_native_bundle(name, version, control, source, buildinfo, output): dsc_name = '{}_{}.dsc'.format(name, version) diff --git a/src/debocker/utils.py b/src/debocker/utils.py index 17afe46..a030976 100644 --- a/src/debocker/utils.py +++ b/src/debocker/utils.py @@ -4,6 +4,7 @@ from tempfile import TemporaryDirectory from datetime import datetime from os.path import join import os +import hashlib def cached_constant(f): cache = [] @@ -42,3 +43,15 @@ def tmppath(name = None, directory = False): if directory: os.mkdir(tmp_path) return tmp_path + +def calculate_md5_and_size(path): + md5 = hashlib.md5() + count = 0 + with open(path, 'rb') as f: + while True: + buff = f.read(8192) + if len(buff) == 0: + break + count += len(buff) + md5.update(buff) + return md5.hexdigest(), count