Skip to content

Commit

Permalink
Merge pull request #69 from vsoch/linting-update
Browse files Browse the repository at this point in the history
updating linting
  • Loading branch information
vsoch authored Jan 24, 2024
2 parents 9653d70 + c03f266 commit 9f577db
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 486 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- uses: actions/checkout@v4
- name: Setup black linter
run: conda create --quiet --name black black

- name: Lint python code
run: |
export PATH="/usr/share/miniconda/bin:$PATH"
source activate black
pip install black==23.3.0
black --check scif
12 changes: 0 additions & 12 deletions scif/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Modified from https://github.com/Visual-mov/Colorful-Julia (MIT License)
"""

from scif.version import __version__
13 changes: 6 additions & 7 deletions scif/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
Copyright (C) 2016-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand Down Expand Up @@ -167,8 +167,7 @@ def get_parser():


def get_subparsers(parser):
"""get_subparser will get a dictionary of subparsers, to help with printing help
"""
"""get_subparser will get a dictionary of subparsers, to help with printing help"""

actions = [
action
Expand All @@ -186,16 +185,16 @@ def get_subparsers(parser):


def main():
"""main is the entrypoint to managing or interacting with an scif
organized filesystem.
"""main is the entrypoint to managing or interacting with an scif
organized filesystem.
"""

parser = get_parser()
subparsers = get_subparsers(parser)

def help(return_code=0):
"""print help, including the software version and active client
and exit with return code.
"""print help, including the software version and active client
and exit with return code.
"""
version = scif.__version__

Expand Down
3 changes: 1 addition & 2 deletions scif/client/dump.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -17,7 +17,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

client = ScifRecipe(quiet=True, writable=False)
Expand Down
3 changes: 1 addition & 2 deletions scif/client/execute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -17,7 +17,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

cmd = args.cmd
Expand Down
3 changes: 1 addition & 2 deletions scif/client/help.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -17,7 +17,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

apps = args.app
Expand Down
4 changes: 1 addition & 3 deletions scif/client/inspect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -18,7 +18,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

# Inspect choices, r, e, l, a
Expand Down Expand Up @@ -62,7 +61,6 @@ def main(args, parser, subparser):

result = {}
for app in apps:

inspection = client.inspect(app, attributes)
if len(inspection) > 0:
result[app] = inspection
Expand Down
3 changes: 1 addition & 2 deletions scif/client/install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -16,7 +16,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

apps = args.recipe
Expand Down
4 changes: 1 addition & 3 deletions scif/client/list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -16,7 +16,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

client = ScifRecipe(writable=False, quiet=True)
Expand All @@ -33,7 +32,6 @@ def main(args, parser, subparser):
result.append(app.rjust(10))

if len(result) > 0:

if longlist is True:
header = "[app] [root]"
bot.custom(prefix="SCIF", message=header, color="CYAN")
Expand Down
3 changes: 1 addition & 2 deletions scif/client/preview.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -17,7 +17,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

apps = args.recipe
Expand Down
6 changes: 2 additions & 4 deletions scif/client/pyshell.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -17,7 +17,6 @@


def main(args, parser, subparser):

from scif.defaults import SCIF_SHELL as shell

parsed = parse_input_preferences(args.recipe, quiet=args.quiet)
Expand Down Expand Up @@ -54,8 +53,7 @@ def main(args, parser, subparser):


def ipython(recipe, app=None, quiet=False, writable=True):
"""embed the client with loaded recipe into an ipython session
"""
"""embed the client with loaded recipe into an ipython session"""
from scif.main import ScifRecipe
from IPython import embed

Expand Down
3 changes: 1 addition & 2 deletions scif/client/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2016-2020 Vanessa Sochat.
Copyright (C) 2016-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -16,7 +16,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

cmd = args.cmd
Expand Down
3 changes: 1 addition & 2 deletions scif/client/shell.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -18,7 +18,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

app = args.app
Expand Down
3 changes: 1 addition & 2 deletions scif/client/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2016-2020 Vanessa Sochat.
Copyright (C) 2016-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -16,7 +16,6 @@


def main(args, parser, subparser):

from scif.main import ScifRecipe

cmd = args.cmd
Expand Down
12 changes: 5 additions & 7 deletions scif/client/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand All @@ -21,11 +21,11 @@
def parse_input_preferences(recipe, quiet=False):
"""parse a recipe|app, meaning a list of one or more things that could be
any of the following:
any of the following:
Returns
=======
parsed: a dictionary lookup with keys for app, recipe, and quiet.
Returns
=======
parsed: a dictionary lookup with keys for app, recipe, and quiet.
"""

# if coming from inspect, will be string
Expand All @@ -34,14 +34,12 @@ def parse_input_preferences(recipe, quiet=False):

# First case: recipe and app
if len(recipe) > 1:

app = recipe[1]
recipe = recipe[0]
quiet = True

# Second case, no input or recipe|app
else:

app = None

# If no recipe provided, assume loading base
Expand Down
28 changes: 14 additions & 14 deletions scif/defaults.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand Down Expand Up @@ -31,14 +31,14 @@ def convert2boolean(arg):


def getenv(variable_key, default=None, required=False, silent=True):
""" getenv will attempt to get an environment variable. If the variable
is not found, None is returned.
Paramters
=========
variable_key: the variable name
required: exit with error if not found
silent: Do not print debugging information for variable
"""getenv will attempt to get an environment variable. If the variable
is not found, None is returned.
Paramters
=========
variable_key: the variable name
required: exit with error if not found
silent: Do not print debugging information for variable
"""
variable = os.environ.get(variable_key, default)
if variable is None and required:
Expand All @@ -52,12 +52,12 @@ def getenv(variable_key, default=None, required=False, silent=True):

def getenv_namespace(namespace="SCIF", func=None):
"""return all environment variables in a particular namespace, such as for
SCIF apps using a filter function (func). The function should take first
a key in the environment, and then the namespace variable.
If none provided, uses "starts with" equivalent.
SCIF apps using a filter function (func). The function should take first
a key in the environment, and then the namespace variable.
If none provided, uses "starts with" equivalent.
def func(key, namespace):
return key.startswith(namespace)
def func(key, namespace):
return key.startswith(namespace)
"""
if func is None:
"""does key start with namespace?"""
Expand Down
10 changes: 4 additions & 6 deletions scif/logger/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Copyright (C) 2017-2020 Vanessa Sochat.
Copyright (C) 2017-2024 Vanessa Sochat.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
Expand Down Expand Up @@ -106,8 +106,7 @@ def emitOutput(self, level):
return False

def isEnabledFor(self, messageLevel):
"""check if a messageLevel is enabled to emit a level
"""
"""check if a messageLevel is enabled to emit a level"""
if messageLevel <= self.level:
return True
return False
Expand Down Expand Up @@ -262,16 +261,15 @@ def debug(self, message):
self.emit(DEBUG, message, "DEBUG")

def is_quiet(self):
"""is_quiet returns true if the level is under 1
"""
"""is_quiet returns true if the level is under 1"""
if self.level < 1:
return False
return True

# Terminal ------------------------------------------

def table(self, rows, col_width=2):
"""table will print a table of entries. If the rows is
"""table will print a table of entries. If the rows is
a dictionary, the keys are interpreted as column names. if
not, a numbered list is used.
"""
Expand Down
Loading

0 comments on commit 9f577db

Please sign in to comment.