Skip to content

Commit

Permalink
python-bareos: pylint suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joergsteffens committed Jan 29, 2024
1 parent 2872733 commit b677221
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
17 changes: 13 additions & 4 deletions python-bareos/bareos/util/argparse.py
Expand Up @@ -17,19 +17,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

have_configargparse = False
"""
ArgumentParser wrapper.
Uses configargparse, if available,
otherwise, falls back to argparse.
"""

HAVE_CONFIG_ARG_PARSE_MODULE = False
try:
import configargparse as argparse

have_configargparse = True
HAVE_CONFIG_ARG_PARSE_MODULE = True
except ImportError:
import argparse


class ArgumentParser(argparse.ArgumentParser):
"""ArgumentParser wrapper"""

def __init__(self, *args, **kwargs):
super(ArgumentParser, self).__init__(*args, **kwargs)
if have_configargparse:
super().__init__(*args, **kwargs)
if HAVE_CONFIG_ARG_PARSE_MODULE:
self.add_argument(
"-c", "--config", is_config_file=True, help="Config file path."
)
11 changes: 4 additions & 7 deletions python-bareos/bareos/util/path.py
@@ -1,6 +1,6 @@
# BAREOS - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2015-2021 Bareos GmbH & Co. KG
# Copyright (C) 2015-2024 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand All @@ -21,8 +21,6 @@
Handle file paths.
"""

from copy import copy


class Path(object):
"""
Expand Down Expand Up @@ -55,7 +53,7 @@ def __set_defaults(self):
self.path = None

def set_path(self, path):
if path == None:
if path is None:
self.__set_defaults()
elif isinstance(path, str):
self.path_orig = path
Expand All @@ -76,10 +74,9 @@ def set_path(self, path):
pass

def get(self, index=None):
if index == None:
if index is None:
return self.path
else:
return self.path[index]
return self.path[index]

def shift(self):
"""
Expand Down

0 comments on commit b677221

Please sign in to comment.