Skip to content

Commit

Permalink
Docstring refactoring: use quotes instead of apostrophe (oamg#616)
Browse files Browse the repository at this point in the history
In case of docstring, quotes should be used always, officialy.
Replace apostrophes by quotes in case of docstrings.
  • Loading branch information
pirat89 committed Nov 10, 2020
1 parent 9ac2b80 commit 1cb2458
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


def detect_config_error(conf_file):
'''
"""
Check grub configuration for syntax error in GRUB_CMDLINE_LINUX value.
:return: Function returns True if error was detected, otherwise False.
'''
"""
with open(conf_file, 'r') as f:
config = f.read()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@


class MultipathConfCheck(Actor):
'''
"""
Checks whether the multipath configuration can be updated to RHEL-8.
Specifically, it checks if the path_checker/checker option is set to
something other than tur in the defaults section. If so, non-trivial
changes may be required in the multipath.conf file, and it is not
possible to auto-update it.
'''
"""

name = 'multipath_conf_check'
consumes = (MultipathConfFacts,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@


class MultipathConfRead(Actor):
'''
"""
Reads multipath configuration files (multipath.conf, and any files in
the multipath config directory) and extracts the necessary information
'''
"""

name = 'multipath_conf_read'
consumes = (InstalledRedHatSignedRPM,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


class MultipathConfUpdate(Actor):
'''
"""
Modifies multipath configuration files on the target RHEL-8 system so that
they will run properly. This is done in three ways
1. commenting out lines for options that no longer exist, or whose value
is no longer current in RHEL-8
2. Migrating any options in an devices section with all_devs to an
overrides setions
3. Rename options that have changed names
'''
"""

name = 'multipath_conf_update'
consumes = (MultipathConfFacts,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def parse_pci_device(block):
''' Parse one block from lspci output describing one PCI device '''
""" Parse one block from lspci output describing one PCI device """
device = {
'Slot': '',
'Class': '',
Expand Down Expand Up @@ -50,17 +50,17 @@ def parse_pci_device(block):


def parse_pci_devices(output):
''' Parse lspci output and return a list of PCI devices '''
""" Parse lspci output and return a list of PCI devices """
return [parse_pci_device(block) for block in output.split('\n\n')[:-1]]


def produce_pci_devices(producer, devices):
''' Produce a Leapp message with all PCI devices '''
""" Produce a Leapp message with all PCI devices """
producer(PCIDevices(devices=devices))


def scan_pci_devices(producer):
''' Scan system PCI Devices '''
""" Scan system PCI Devices """
output = run(['lspci', '-vmmk'], checked=False)['stdout']
devices = parse_pci_devices(output)
produce_pci_devices(producer, devices)
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@


class SELinuxApplyCustom(Actor):
'''
"""
Re-apply SELinux customizations from RHEL-7 installation
Re-apply SELinux policy customizations (custom policy modules and changes
introduced by semanage). Any changes (due to incompatiblity with RHEL-8
SELinux policy) are reported to user.
'''
"""
name = 'selinuxapplycustom'
consumes = (SELinuxCustom, SELinuxModules)
produces = ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@


class SELinuxContentScanner(Actor):
'''
"""
Scan the system for any SELinux customizations
Find SELinux policy customizations (custom policy modules and changes
introduced by semanage) and save them in SELinuxModules and SELinuxCustom
models. Customizations that are incompatible with SELinux policy on RHEL-8
are removed.
'''
"""

name = 'selinuxcontentscanner'
consumes = (SELinuxFacts,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@


def check_module(name):
'''
"""
Check if given module contains one of removed types and comment out corresponding lines.
The function expects a text file "$name" containing cil policy
to be present in the current directory.
Returns a list of invalid lines.
'''
"""
try:
removed = run(['grep', '-w', '-E', "|".join(REMOVED_TYPES_), name], split=True)
# Add ";" at the beginning of invalid lines (comment them out)
Expand All @@ -49,11 +49,11 @@ def check_module(name):


def list_selinux_modules():
'''
"""
Produce list of SELinux policy modules
Returns list of tuples (name,priority)
'''
"""
try:
semodule = run(['semodule', '-lfull'], split=True)
except CalledProcessError:
Expand All @@ -75,7 +75,7 @@ def list_selinux_modules():


def get_selinux_modules():
'''
"""
Read all custom SELinux policy modules from the system
Returns 3-tuple (modules, retain_rpms, install_rpms)
Expand All @@ -84,7 +84,7 @@ def get_selinux_modules():
during the upgrade and "install_rpms" is a list of RPMs
that should be installed during the upgrade
'''
"""

modules = list_selinux_modules()
semodule_list = []
Expand Down Expand Up @@ -172,15 +172,15 @@ def get_selinux_modules():


def get_selinux_customizations():
'''
"""
Extract local SELinux customizations introduced by semanage command
Returns tuple (semanage_valid, semanage_removed)
where "semanage_valid" is a list of semanage commands
which should be safe to re-apply on RHEL 8 system
and "semanage_removed" is a list of commands that
will no longer be valid after system upgrade
'''
"""

semanage_removed = []
semanage_valid = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@


class SELinuxPrepare(Actor):
'''
"""
Remove selinux policy customizations before updating selinux-policy* packages
RHEL-7 policy customizations could cause policy package upgrade to fail and therefore
need to be removed. Customizations introduced by semanage are removed first,
followed by custom policy modules gathered by SELinuxContentScanner.
'''
"""

name = 'selinuxprepare'
consumes = (SELinuxCustom, SELinuxModules)
Expand Down
4 changes: 2 additions & 2 deletions repos/system_upgrade/el7toel8/actors/sssdcheck/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@


class SSSDCheck(Actor):
'''
"""
Check SSSD configuration for changes in RHEL8 and report them.
These changes are:
- id_provider=local is no longer supported and will be ignored
- ldap_groups_use_matching_rule_in_chain was removed and will be ignored
- ldap_initgroups_use_matching_rule_in_chain was removed and will be ignored
- ldap_sudo_include_regexp changed default from true to false
'''
"""

name = 'sssd_check'
consumes = (SSSDConfig,)
Expand Down
4 changes: 2 additions & 2 deletions repos/system_upgrade/el7toel8/actors/sssdfacts/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@


class SSSDFacts(Actor):
'''
"""
Check SSSD configuration for changes in RHEL8 and report them in model.
These changes are:
- id_provider=local is no longer supported and will be ignored
- ldap_groups_use_matching_rule_in_chain was removed and will be ignored
- ldap_initgroups_use_matching_rule_in_chain was removed and will be ignored
- ldap_sudo_include_regexp changed default from true to false
'''
"""

name = 'sssd_facts'
consumes = ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@


def aslist(f):
''' Decorator used to convert generator to list '''
""" Decorator used to convert generator to list """
@functools.wraps(f)
def inner(*args, **kwargs):
return list(f(*args, **kwargs))
return inner


def anyendswith(value, ends):
''' Check if `value` ends with one of the possible `ends` '''
""" Check if `value` ends with one of the possible `ends` """
for end in ends:
if value.endswith(end):
return True
return False


def anyhasprefix(value, prefixes):
''' Check if `value` starts with on of the possible `prefixes` '''
""" Check if `value` starts with on of the possible `prefixes` """
for p in prefixes:
if value.startswith(p):
return True
Expand All @@ -51,7 +51,7 @@ def _get_system_users():


def get_system_users_status():
''' Get a list of users from `/etc/passwd` '''
""" Get a list of users from `/etc/passwd` """
return UsersFacts(users=_get_system_users())


Expand All @@ -66,7 +66,7 @@ def _get_system_groups():


def get_system_groups_status():
''' Get a list of groups from `/etc/groups` '''
""" Get a list of groups from `/etc/groups` """
return GroupsFacts(groups=_get_system_groups())


Expand Down Expand Up @@ -127,7 +127,7 @@ def _get_active_kernel_modules(logger):


def get_active_kernel_modules_status(logger):
''' Get a list of active kernel modules '''
""" Get a list of active kernel modules """
return ActiveKernelModulesFacts(kernel_modules=_get_active_kernel_modules(logger))


Expand Down Expand Up @@ -157,7 +157,7 @@ def _get_sysctls():


def get_sysctls_status():
r''' Get a list of stable `sysctls` variables
r""" Get a list of stable `sysctls` variables
Note that some variables are inherently unstable and we need to blacklist
them:
Expand All @@ -166,17 +166,17 @@ def get_sysctls_status():
| grep -E '^\+[a-z]'\
| cut -d' ' -f1\
| cut -d+ -f2
'''
"""
return SysctlVariablesFacts(sysctl_variables=_get_sysctls())


def get_repositories_status():
''' Get a basic information about YUM repositories installed in the system '''
""" Get a basic information about YUM repositories installed in the system """
return RepositoriesFacts(repositories=repofileutils.get_parsed_repofiles())


def get_selinux_status():
''' Get SELinux status information '''
""" Get SELinux status information """
# will be None if something went wrong or contain SELinuxFacts otherwise
res = None
try:
Expand Down Expand Up @@ -209,7 +209,7 @@ def get_selinux_status():


def get_firewalls_status():
''' Get firewalld status information '''
""" Get firewalld status information """
logger = logging.getLogger('get_firewalld_status')

def _get_firewall_status(service_name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


class TcpWrappersConfigRead(Actor):
'''
"""
Parse tcp_wrappers configuration files /etc/hosts.{allow,deny}.
'''
"""

name = 'tcp_wrappers_config_read'
consumes = ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def update_kernel_config(path):
''' Update DEFAULTKERNEL entry at provided config file '''
""" Update DEFAULTKERNEL entry at provided config file """
run(['/bin/sed',
'-i',
's/^DEFAULTKERNEL=kernel$/DEFAULTKERNEL=kernel-core/g',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


class VsftpdConfigRead(Actor):
'''
"""
Reads vsftpd configuration files (/etc/vsftpd/*.conf) and extracts necessary information.
'''
"""

name = 'vsftpd_config_read'
consumes = (InstalledRedHatSignedRPM,)
Expand Down
4 changes: 2 additions & 2 deletions repos/system_upgrade/el7toel8/files/rhel_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def set_argparser(parser):
parser.add_argument('filename')

def _process_packages(self, pkg_set, op):
'''
"""
Adds list of packages for given operation to the transaction
'''
"""
pkgs_notfound = []

for pkg_spec in pkg_set:
Expand Down
4 changes: 2 additions & 2 deletions repos/system_upgrade/el7toel8/libraries/tcpwrappersutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _daemon_list_matches_daemon(daemon_list, daemon, recursion_depth):


def config_applies_to_daemon(facts, daemon):
'''
"""
Returns True if the specified tcp_wrappers configuration applies to the specified daemon.
Otherwise returns False.
Expand All @@ -75,7 +75,7 @@ def config_applies_to_daemon(facts, daemon):
:param facts: A TcpWrappersFacts representation of the tcp_wrappers configuration
:param daemon: The daemon name
'''
"""
for daemon_list in facts.daemon_lists:
value = [item.lower() for item in daemon_list.value]
if _daemon_list_matches_daemon(value, daemon, 0):
Expand Down

0 comments on commit 1cb2458

Please sign in to comment.