From a27ef7ff6a05a9817b5165e4c3fb643d5d21f532 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 25 Feb 2017 10:25:18 +0200 Subject: Use SHA256 by default; fix pylint warnings/errors --- Makefile | 6 +++--- NEWS | 2 ++ pylint.conf | 1 + summain | 7 ++++--- summainlib/__init__.py | 4 ++-- tests/empty.script | 2 +- tests/manglepaths.script | 2 +- tests/several-files.script | 2 +- tests/xattrs.script | 2 +- 9 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 01d0a98..8731416 100644 --- a/Makefile +++ b/Makefile @@ -23,14 +23,14 @@ summain.1: _summain.so summain.1.in python summain --generate-manpage=summain.1.in > summain.1 check: - python -m CoverageTestRunner + python -m CoverageTestRunner --ignore-missing-from=without-tests rm -f .coverage cmdtest tests - pep8 summain summainlib.py summainlib_tests.py + pep8 summain summainlib summainlib_tests.py if command -v pylint && pylint --version | grep '^pylint [1-9]'; \ then \ PYTHONPATH=. pylint --rcfile=pylint.conf \ - summain summainlib.py summainlib_tests.py; \ + summain summainlib summainlib_tests.py; \ fi clean: diff --git a/NEWS b/NEWS index 7df13e7..5742a1a 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ NEWS file for summain Version 0.22+git, not yet released ---------------------------------- +* Change default checksum to SHA256, from the now-broken SHA1. + Version 0.22, released 2016-10-09 ---------------------------------- diff --git a/pylint.conf b/pylint.conf index bae19df..44a964c 100644 --- a/pylint.conf +++ b/pylint.conf @@ -13,6 +13,7 @@ disable= no-self-use, pointless-statement, protected-access, + redefined-variable-type, star-args, too-few-public-methods, too-many-arguments, diff --git a/summain b/summain index db12eda..863dc5d 100755 --- a/summain +++ b/summain @@ -15,11 +15,12 @@ # along with this program. If not, see . -import cliapp import csv import json import os +import cliapp + import summainlib @@ -123,7 +124,7 @@ class Summain(cliapp.Application): ['checksum', 'c'], 'which checksums to compute: ' 'MD5, SHA1, SHA224, SHA256, SHA384, SHA512; ' - 'use once per checksum type (default is SHA1)') + 'use once per checksum type (default is SHA256)') self.settings.choice( ['output-format', 'f'], ['rfc822', 'csv', 'json'], @@ -145,7 +146,7 @@ class Summain(cliapp.Application): def process_args(self, args): checksums = [x.upper() - for x in self.settings['checksum'] or ['SHA1']] + for x in self.settings['checksum'] or ['SHA256']] fmt = self.new_formatter(checksums, self.find_roots(args)) fmt.write() diff --git a/summainlib/__init__.py b/summainlib/__init__.py index c76e253..8d7a7b8 100644 --- a/summainlib/__init__.py +++ b/summainlib/__init__.py @@ -26,7 +26,7 @@ import urllib import errno try: - import _summain + from summainlib import _summain except ImportError: # We need to import this package when running setup.py, # and for that we don't need _summain. @@ -283,7 +283,7 @@ class FilesystemObject(object): def get_xattrs(self, filename): # pragma: no cover ret = _summain.llistxattr(filename) - if type(ret) is int: + if isinstance(ret, int): # Some file types don't support xattr, e.g. named pipes on FreeBSD: if ret == errno.EOPNOTSUPP: return {} diff --git a/tests/empty.script b/tests/empty.script index 157c8c8..8e9afcf 100755 --- a/tests/empty.script +++ b/tests/empty.script @@ -5,5 +5,5 @@ set -e mkdir -m 0775 "$DATADIR/empty-dir" touch "$DATADIR/empty-dir/empty" chmod 0700 "$DATADIR/empty-dir/empty" -./summain --exclude=mtime --exclude=uid --exclude=username \ +./summain --checksum=sha1 --exclude=mtime --exclude=uid --exclude=username \ --exclude=gid --exclude=group --relative "$DATADIR/empty-dir" diff --git a/tests/manglepaths.script b/tests/manglepaths.script index a377985..d75507a 100755 --- a/tests/manglepaths.script +++ b/tests/manglepaths.script @@ -8,5 +8,5 @@ echo foo > "$DATADIR/files/foo" echo bar > "$DATADIR/files/bar" echo foobar > "$DATADIR/files/foobar" chmod 0666 "$DATADIR/files/"* -./summain --exclude=mtime --exclude=uid --exclude=username \ +./summain --checksum=sha1 --exclude=mtime --exclude=uid --exclude=username \ --exclude=gid --exclude=group --relative --mangle-paths "$DATADIR/files" diff --git a/tests/several-files.script b/tests/several-files.script index 461975d..a15d579 100755 --- a/tests/several-files.script +++ b/tests/several-files.script @@ -8,5 +8,5 @@ echo foo > "$DATADIR/several-files/foo" echo bar > "$DATADIR/several-files/bar" echo foobar > "$DATADIR/several-files/foobar" chmod 0600 "$DATADIR"/several-files/* -./summain --exclude=mtime --exclude=uid --exclude=username \ +./summain --checksum=sha1 --exclude=mtime --exclude=uid --exclude=username \ --exclude=gid --exclude=group --relative "$DATADIR/several-files" diff --git a/tests/xattrs.script b/tests/xattrs.script index 154c236..8b7cb68 100755 --- a/tests/xattrs.script +++ b/tests/xattrs.script @@ -10,7 +10,7 @@ if setfattr -n user.foo -v "$(printf '\177')" "$DATADIR/xattrs/file" 2> /dev/nul then ./summain --exclude=mtime --exclude=uid --exclude=username \ --exclude=gid --exclude=group --exclude=ino --exclude=dev \ - --exclude=nlink --exclude=size --exclude=sha1 \ + --exclude=nlink --exclude=size --exclude=sha1 --exclude=sha256 \ --relative "$DATADIR/xattrs" else # Fake results when xattrs not available. -- cgit v1.2.1