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 linting errors #294

Merged
merged 11 commits into from
Aug 19, 2020
2 changes: 1 addition & 1 deletion phys2bids/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

"""Main init for phys2bids package."""
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
2 changes: 1 addition & 1 deletion phys2bids/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class NotThisMethod(Exception):


def register_vcs_handler(vcs, method): # decorator
"""Decorator to mark a method as the handler for a particular VCS."""
"""Mark a method as the handler for a particular VCS."""
def decorate(f):
"""Store f in HANDLERS[vcs][method]."""
if vcs not in HANDLERS:
Expand Down
8 changes: 6 additions & 2 deletions phys2bids/bids.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""BIDS functions for phys2bids package."""
import logging
import os
from csv import reader
Expand Down Expand Up @@ -54,8 +55,8 @@

def bidsify_units(orig_unit):
"""
Read the input unit of measure and use the dictionary of aliases
to bidsify its value.
Read the input unit of measure and use the dictionary of aliases to bidsify its value.

It is possible to make simple conversions.

Parameters
Expand Down Expand Up @@ -180,6 +181,7 @@ def use_heuristic(heur_file, sub, ses, filename, outdir, run='', record_label=''
def participants_file(outdir, yml, sub):
"""
Create participants.tsv file if it does not exist.

If it exists and the subject is missing, then add it.
Otherwise, do nothing.

Expand Down Expand Up @@ -250,6 +252,7 @@ def participants_file(outdir, yml, sub):
def dataset_description_file(outdir):
"""
Create dataset_description.json file if it does not exist.

If it exists, do nothing.

Parameters
Expand All @@ -272,6 +275,7 @@ def dataset_description_file(outdir):
def readme_file(outdir):
"""
Create README file if it does not exist.

If it exists, do nothing.

Parameters
Expand Down
1 change: 1 addition & 0 deletions phys2bids/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init for CLI of phys2bids package."""
21 changes: 12 additions & 9 deletions phys2bids/due.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""
Stub file for a guaranteed safe import of duecredit constructs: if duecredit
is not available.
Stub file for a guaranteed safe import of duecredit constructs: if duecredit is not available.

To use it, place it into your project codebase to be imported, e.g. copy as
cp stub.py /path/tomodule/module/due.py
Note that it might be better to avoid naming it duecredit.py to avoid shadowing
Expand All @@ -14,6 +11,10 @@
Origin: Originally a part of the duecredit
Copyright: 2015-2016 DueCredit developers
License: BSD-2

# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""

from builtins import str
Expand All @@ -22,25 +23,27 @@


class InactiveDueCreditCollector(object):
"""Just a stub at the Collector which would not do anything"""
"""Just a stub at the Collector which would not do anything."""

def _donothing(self, *args, **kwargs):
"""Perform no good and no bad"""
"""Perform no good and no bad."""
pass

def dcite(self, *args, **kwargs):
"""If I could cite I would"""
"""If I could cite I would."""
def nondecorating_decorator(func):
return func
return nondecorating_decorator

cite = load = add = _donothing

def __repr__(self):
"""Return class function."""
return self.__class__.__name__ + '()'


def _donothing_func(*args, **kwargs):
"""Perform no good and no bad"""
"""Perform no good and no bad."""
pass


Expand Down
1 change: 1 addition & 0 deletions phys2bids/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init for interfaces of phys2bids package."""
6 changes: 4 additions & 2 deletions phys2bids/interfaces/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ def read_header_and_channels(filename, chtrig):

def populate_phys_input(filename, chtrig):
"""
Populate object phys_input, extracts header and deduces from it
the format file, afterwards it passes the needed information to
Populate object phys_input.

Extract header and deduce from it the format file,
afterwards pass the needed information to
the corresponding reading function.

Parameters
Expand Down
3 changes: 1 addition & 2 deletions phys2bids/slice4phys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Multi-run slicer for phys2bids package."""

import logging
from copy import deepcopy
Expand Down
37 changes: 27 additions & 10 deletions phys2bids/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-

"""Utilities for phys2bids package."""
import json
import logging
import os
Expand All @@ -14,7 +13,8 @@

def check_input_dir(indir):
"""
Checks that the given indir doesn't have a trailing `/`
Check that the given indir doesn't have a trailing `/`.

Possibly useless if better way to handle this in Python.

Parameters
Expand All @@ -35,7 +35,8 @@ def check_input_dir(indir):

def check_input_ext(filename, ext):
"""
Checks that the given file has the given extension.
Check that the given file has the given extension.

It also treats composite extensions such as `.tsv.gz`,
common in BIDS formats.

Expand Down Expand Up @@ -64,6 +65,7 @@ def check_input_ext(filename, ext):
def check_input_type(filename, indir):
"""
Check which supported type is the filename.

Alternatively, raise an error if file not found or type not supported.

Parameters
Expand Down Expand Up @@ -110,7 +112,7 @@ def check_input_type(filename, indir):

def path_exists_or_make_it(fldr):
"""
Check if folder exists, if not make it
Check if folder exists, if not make it.

Parameters
----------
Expand Down Expand Up @@ -149,7 +151,8 @@ def check_file_exists(filename):

def move_file(oldpath, newpath, ext=''):
"""
Moves file from oldpath to newpath.
Move file from oldpath to newpath.

If file already exists, removes it first.

Parameters
Expand Down Expand Up @@ -178,6 +181,7 @@ def move_file(oldpath, newpath, ext=''):
def copy_file(oldpath, newpath, ext=''):
"""
Copy file from oldpath to newpath.

If file already exists, remove it first.

Parameters
Expand Down Expand Up @@ -207,8 +211,9 @@ def copy_file(oldpath, newpath, ext=''):

def writefile(filename, ext, text):
"""
Produces a textfile of the specified extension `ext`,
containing the given content `text`.
Produce a textfile of the specified extension `ext`.

The textfile containis the given content `text`.

Parameters
----------
Expand All @@ -232,7 +237,7 @@ def writefile(filename, ext, text):

def writejson(filename, data, **kwargs):
"""
Outputs a json file with the given data inside.
Output a json file with the given data inside.

Parameters
----------
Expand All @@ -255,7 +260,8 @@ def writejson(filename, data, **kwargs):


def load_heuristic(heuristic):
""" Loads `heuristic`, returning a callable Python module
"""
Load `heuristic`, returning a callable Python module.

References
----------
Expand Down Expand Up @@ -284,6 +290,17 @@ def load_heuristic(heuristic):


def append_list_as_row(file_name, list_of_elem):
"""
Append list as row.

Parameters
----------
filename: str or path
A string representing a file name or a fullpath
to a file
list_of_elem: list
The list to be appended to the file.
"""
# Open file in append mode
with open(file_name, 'a+', newline='') as write_obj:
# Create a writer object from csv module
Expand Down
2 changes: 1 addition & 1 deletion phys2bids/viz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""Visualization functions for phys2bids package."""
import os
import logging

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ console_scripts =
[flake8]
exclude=
*build/
heuristics
tests
ignore = E126, E402, W503
max-line-length = 99
Expand Down