Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - Pylint issues part one #161

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fido/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def identify_stream(self, stream, filename, extension=True):
elif extension and (len(matches) == 0 or self.current_filesize == 0):
# we can only determine the filename from the STDIN stream
# on Linux, on Windows there is not a (simple) way to do that
if (os.name != "nt"):
if os.name != "nt":
try:
self.current_file = os.readlink("/proc/self/fd/0")
except OSError:
Expand All @@ -470,7 +470,7 @@ def container_type(self, matches):
that we can look inside of (e.g., zip, tar).
@return False, zip, or tar.
"""
for (format_, unused) in matches:
for (format_, _) in matches:
container = format_.find('container')
if container is not None:
return container.text
Expand Down Expand Up @@ -565,7 +565,7 @@ def walk_zip(self, filename, fileobj=None, extension=True):
with zipfile.ZipFile((fileobj if fileobj else filename), 'r') as zipstream:
for item in zipstream.infolist():
if item.file_size == 0:
continue # TODO: Find a better test for isdir
continue # TODO: Find a better test for isdir, Python 3.6 adds is_dir() test to ZipInfo class
t0 = time.clock()
with zipstream.open(item) as f:
item_name = filename + '!' + item.filename
Expand Down Expand Up @@ -624,7 +624,7 @@ def as_good_as_any(self, f1, match_list):
"""
if match_list != []:
f1_puid = self.get_puid(f1)
for (f2, unused) in match_list:
for (f2, _) in match_list:
if f1 == f2:
continue
elif f1_puid in self.puid_has_priority_over_map[self.get_puid(f2)]:
Expand Down Expand Up @@ -736,7 +736,7 @@ def list_files(roots, recurse=False):
if os.path.isfile(root):
yield root
else:
for path, unused, files in os.walk(root):
for path, _, files in os.walk(root):
for f in files:
yield os.path.join(path, f)
if not recurse:
Expand Down
2 changes: 1 addition & 1 deletion fido/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from six import iteritems


class Package(object):
class Package():
"""Base class for container support."""

def _process_puid_map(self, data, puid_map):
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#!/usr/bin/env python
"""Setup installer for Fido."""
# -*- coding: utf-8 -*-

import codecs
import os
import re
import sys

from setuptools import setup


def read(*parts):
"""Read the contents of files in parts and return contents."""
path = os.path.join(os.path.dirname(__file__), *parts)
with codecs.open(path, encoding='utf-8') as fobj:
return fobj.read()


def find_version(*file_paths):
"""Search contents of files in file_paths for version number."""
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
Expand Down
3 changes: 0 additions & 3 deletions tests/test_package.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import os
import zipfile

import pytest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pytest not required for the assert style syntax below, and zipfile for the ZipPackage namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case, only a native Python assert statement is used and here it is running on Travis: https://travis-ci.org/openpreserve/fido/jobs/596043501#L455 This also means that the code is optimised away in some circumstances but its fine for testing.


from fido.package import ZipPackage

Expand Down