diff --git a/.travis.yml b/.travis.yml index 699af3f..aa503ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,12 @@ python: - "3.6" - "3.7" install: - - pip install requests - - pip install python-dateutil - pip install coveralls pycodestyle pep257 restructuredtext_lint testfixtures - python setup.py install script: - python setup.py test - - pycodestyle --ignore=E501,W503 resync tests bin/resync bin/resync-explorer - - pep257 resync tests bin/resync bin/resync-explorer + - pycodestyle --ignore=E501,W503 resync tests resync.py resync-explorer.py + - pep257 resync tests resync.py resync-explorer.py - rst-lint README - coverage run --source=resync setup.py test after_success: diff --git a/resync-explorer.py b/resync-explorer.py index d030dab..8dfdd0b 100755 --- a/resync-explorer.py +++ b/resync-explorer.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -""" -resync-explorer: The ResourceSync explorer +"""resync-explorer: The ResourceSync explorer. -Copyright 2012-2017 Simeon Warner +Copyright 2012-2020 Simeon Warner Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -29,7 +28,7 @@ DEFAULT_LOGFILE = 'resync-explorer.log' def main(): - + """Main function to implement command line script.""" if (sys.version_info < (2, 7)): sys.exit("This program requires python version 2.7 or later") diff --git a/resync.py b/resync.py index e941370..ef7d636 100755 --- a/resync.py +++ b/resync.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -""" -resync: The ResourceSync command line client +"""resync: The ResourceSync command line client. -Copyright 2012-2017 Simeon Warner +Copyright 2012-2020 Simeon Warner Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,7 +27,7 @@ DEFAULT_LOGFILE = 'resync-client.log' def main(): - + """Main function to implement command line script.""" if (sys.version_info < (2, 7)): sys.exit("This program requires python version 2.7 or later") diff --git a/resync/client.py b/resync/client.py index 5cc526a..9000292 100644 --- a/resync/client.py +++ b/resync/client.py @@ -395,8 +395,8 @@ class Client(object): if (not change_list_uri): uauth_sm = UrlAuthority(self.sitemap) for resource in src_change_list: - if (not uauth_cs.has_authority_over(resource.uri) and - (change_list_uri or not uauth_sm.has_authority_over(resource.uri))): + if (not uauth_cs.has_authority_over(resource.uri) + and (change_list_uri or not uauth_sm.has_authority_over(resource.uri))): raise ClientFatalError( "Aborting as change list (%s) mentions resource at a location it does not have authority over (%s), override with --noauth" % (change_list, resource.uri)) @@ -586,8 +586,8 @@ class Client(object): """ num_deleted = 0 uri = resource.uri - if (resource.timestamp is not None and - resource.timestamp > self.last_timestamp): + if (resource.timestamp is not None + and resource.timestamp > self.last_timestamp): self.last_timestamp = resource.timestamp if (allow_deletion): if (self.dryrun): diff --git a/resync/dump.py b/resync/dump.py index 2679061..0405718 100644 --- a/resync/dump.py +++ b/resync/dump.py @@ -96,7 +96,7 @@ class Dump(object): # without this installed try: from warc import WARCFile, WARCHeader, WARCRecord - except: + except ImportError: raise DumpError("Failed to load WARC library") wf = WARCFile(dumpfile, mode="w", compress=self.compress) # Add all files in the resources @@ -175,8 +175,7 @@ class Dump(object): manifest.add(resource) manifest_size += resource.length manifest_files += 1 - if (manifest_size >= self.max_size or - manifest_files >= self.max_files): + if (manifest_size >= self.max_size or manifest_files >= self.max_files): yield(manifest) # Need to start a new manifest manifest = self.manifest_class() diff --git a/resync/explorer.py b/resync/explorer.py index a83e799..2ad9fea 100644 --- a/resync/explorer.py +++ b/resync/explorer.py @@ -288,8 +288,7 @@ class Explorer(Client): 'lastmod', 'content-type', 'etag']: if header in response.headers: check_str = '' - if (check_headers is not None and - header in check_headers): + if (check_headers is not None and header in check_headers): if (response.headers[header] == check_headers[header]): check_str = ' MATCHES EXPECTED VALUE' else: diff --git a/resync/list_base_with_index.py b/resync/list_base_with_index.py index 61b32ed..5b19bf3 100644 --- a/resync/list_base_with_index.py +++ b/resync/list_base_with_index.py @@ -150,8 +150,8 @@ class ListBaseWithIndex(ListBase): else: # The individual sitemaps should be at a URL (scheme/server/path) # that the sitemapindex URL can speak authoritatively about - if (self.check_url_authority and - not UrlAuthority(sitemapindex_uri).has_authority_over(sitemap_uri)): + if (self.check_url_authority + and not UrlAuthority(sitemapindex_uri).has_authority_over(sitemap_uri)): raise ListBaseIndexError( "The sitemapindex (%s) refers to sitemap at a location it does not have authority over (%s)" % (sitemapindex_uri, sitemap_uri)) @@ -187,8 +187,8 @@ class ListBaseWithIndex(ListBase): In the case that no len() is available for self.resources then then self.count must be set beforehand to avoid an exception. """ - if (self.max_sitemap_entries is None or - len(self) <= self.max_sitemap_entries): + if (self.max_sitemap_entries is None + or len(self) <= self.max_sitemap_entries): return(False) return(int(math.ceil(len(self) / float(self.max_sitemap_entries)))) @@ -409,7 +409,7 @@ class ListBaseWithIndex(ListBase): Test is to see whether have either an explicit file: URI or whether there is no scheme name. """ - return(re.match('file:', uri) or not re.match('\w{3,4}:', uri)) + return(re.match(r'file:', uri) or not re.match(r'\w{3,4}:', uri)) class ListBaseIndexError(Exception):