Skip to content

Commit

Permalink
Make all names conform to PEP8.
Browse files Browse the repository at this point in the history
Several conversions were done, eg:

  auto_part -> autopart
  autopartition -> autopart
  file_system -> filesystem
  multi_path -> multipath
  boot_loader -> bootloader
  sub_volume -> subvolume
  • Loading branch information
dwlehman committed Oct 28, 2015
1 parent 64e7b0e commit 8f889ab
Show file tree
Hide file tree
Showing 104 changed files with 5,364 additions and 5,367 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -56,7 +56,7 @@ install-requires:
@echo "*** Installing the dependencies required for testing and analysis ***"
dnf install -y $(TEST_DEPENDENCIES)

test: check-requires
test: #check-requires
@echo "*** Running unittests with $(PYTHON) ***"
PYTHONPATH=.:tests/ $(PYTHON) -m unittest discover -v -s tests/ -p '*_test.py'

Expand Down
40 changes: 20 additions & 20 deletions blivet/__init__.py
Expand Up @@ -31,17 +31,17 @@
##
iutil = None
ROOT_PATH = '/'
_storageRoot = ROOT_PATH
_storage_root = ROOT_PATH
_sysroot = ROOT_PATH
shortProductName = 'blivet'
short_product_name = 'blivet'
ERROR_RAISE = 0

class ErrorHandler(object):
def cb(self, exn):
# pylint: disable=unused-argument
return ERROR_RAISE

errorHandler = ErrorHandler()
error_handler = ErrorHandler()

get_bootloader = lambda: None

Expand Down Expand Up @@ -77,7 +77,7 @@ def cb(self, exn):
# initialize the libblockdev library
from gi.repository import GLib
from gi.repository import BlockDev as blockdev
if arch.isS390():
if arch.is_s390():
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390"))
else:
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm"))
Expand All @@ -98,58 +98,58 @@ def enable_installer_mode():
""" Configure the module for use by anaconda (OS installer). """
global iutil
global ROOT_PATH
global _storageRoot
global _storage_root
global _sysroot
global shortProductName
global short_product_name
global get_bootloader
global errorHandler
global error_handler
global ERROR_RAISE

from pyanaconda import iutil # pylint: disable=redefined-outer-name
from pyanaconda.constants import shortProductName # pylint: disable=redefined-outer-name
from pyanaconda.bootloader import get_bootloader # pylint: disable=redefined-outer-name
from pyanaconda.errors import errorHandler # pylint: disable=redefined-outer-name
from pyanaconda.constants import shortProductName as short_product_name # pylint: disable=redefined-outer-name
from pyanaconda.bootloader import getBootloader as get_bootloader # pylint: disable=redefined-outer-name
from pyanaconda.errors import errorHandler as error_handler # pylint: disable=redefined-outer-name
from pyanaconda.errors import ERROR_RAISE # pylint: disable=redefined-outer-name

if hasattr(iutil, 'getTargetPhysicalRoot'):
# For anaconda versions > 21.43
_storageRoot = iutil.getTargetPhysicalRoot() # pylint: disable=no-name-in-module
_storage_root = iutil.getTargetPhysicalRoot() # pylint: disable=no-name-in-module
_sysroot = iutil.getSysroot()
else:
# For prior anaconda versions
from pyanaconda.constants import ROOT_PATH # pylint: disable=redefined-outer-name,no-name-in-module
_storageRoot = _sysroot = ROOT_PATH
_storage_root = _sysroot = ROOT_PATH

from pyanaconda.anaconda_log import program_log_lock
util.program_log_lock = program_log_lock

flags.installer_mode = True

def getSysroot():
def get_sysroot():
"""Returns the path to the target OS installation.
For traditional installations, this is the same as the physical
storage root.
"""
return _sysroot

def getTargetPhysicalRoot():
def get_target_physical_root():
"""Returns the path to the "physical" storage root.
This may be distinct from the sysroot, which could be a
chroot-type subdirectory of the physical root. This is used for
example by all OSTree-based installations.
"""
return _storageRoot
return _storage_root

def setSysroot(storageRoot, sysroot=None):
def set_sysroot(storage_root, sysroot=None):
"""Change the OS root path.
:param storageRoot: The root of physical storage
:param sysroot: An optional chroot subdirectory of storageRoot
:param storage_root: The root of physical storage
:param sysroot: An optional chroot subdirectory of storage_root
"""
global _storageRoot
global _storage_root
global _sysroot
_storageRoot = _sysroot = storageRoot
_storage_root = _sysroot = storage_root
if sysroot is not None:
_sysroot = sysroot

Expand Down
54 changes: 27 additions & 27 deletions blivet/actionlist.py
Expand Up @@ -150,7 +150,7 @@ def sort(self):
actions.append(self._actions[idx])
self._actions = actions

def _preProcess(self, devices=None):
def _pre_process(self, devices=None):
""" Prepare the action queue for execution. """
devices = devices or []
for action in self._actions:
Expand All @@ -159,7 +159,7 @@ def _preProcess(self, devices=None):
log.info("pruning action queue...")
self.prune()

problematic = self._findActiveDevicesOnActionDisks(devices=devices)
problematic = self._find_active_devices_on_action_disks(devices=devices)
if problematic:
if flags.installer_mode:
for device in devices:
Expand All @@ -178,18 +178,18 @@ def _preProcess(self, devices=None):
log.info("resetting parted disks...")
for device in devices:
if device.partitioned:
device.format.resetPartedDisk()
device.format.reset_parted_disk()

if device.originalFormat.type == "disklabel" and \
device.originalFormat != device.format:
device.originalFormat.resetPartedDisk()
if device.original_format.type == "disklabel" and \
device.original_format != device.format:
device.original_format.reset_parted_disk()

# Call preCommitFixup on all devices, including those we're going to
# Call pre_commit_fixup on all devices, including those we're going to
# destroy (these are already removed from the tree)
fixup_devices = devices + [a.device for a in self._actions
if a.isDestroy and a.isDevice]
if a.is_destroy and a.is_device]
for device in fixup_devices:
device.preCommitFixup()
device.pre_commit_fixup()

# setup actions to create any extended partitions we added
#
Expand All @@ -202,7 +202,7 @@ def _preProcess(self, devices=None):
# directly here.
for device in devices:
if isinstance(device, PartitionDevice) and \
device.isExtended and not device.exists and \
device.is_extended and not device.exists and \
not self.find(device=device, action_type="create"):
# don't properly register the action since the device is
# already in the tree
Expand All @@ -217,51 +217,51 @@ def _preProcess(self, devices=None):
log.debug("action: %s", action)

# Remove lvm filters for devices we are operating on
for device in (d for d in devices if d.dependsOn(action.device)):
for device in (d for d in devices if d.depends_on(action.device)):
lvm.lvm_cc_removeFilterRejectRegexp(device.name)

def _postProcess(self, devices=None):
def _post_process(self, devices=None):
""" Clean up relics from action queue execution. """
devices = devices or []
# removal of partitions makes use of originalFormat, so it has to stay
# removal of partitions makes use of original_format, so it has to stay
# up to date in case of multiple passes through this method
for disk in (d for d in devices if d.partitioned):
disk.format.updateOrigPartedDisk()
disk.originalFormat = copy.deepcopy(disk.format)
disk.format.update_orig_parted_disk()
disk.original_format = copy.deepcopy(disk.format)

# now we have to update the parted partitions of all devices so they
# match the parted disks we just updated
for partition in (d for d in devices if isinstance(d, PartitionDevice)):
pdisk = partition.disk.format.partedDisk
partition.partedPartition = pdisk.getPartitionByPath(partition.path)
pdisk = partition.disk.format.parted_disk
partition.parted_partition = pdisk.getPartitionByPath(partition.path)

def _findActiveDevicesOnActionDisks(self, devices=None):
def _find_active_devices_on_action_disks(self, devices=None):
""" Return a list of devices using the disks we plan to change. """
# Find out now if there are active devices using partitions on disks
# whose disklabels we are going to change. If there are, do not proceed.
devices = devices or []
disks = []
for action in self._actions:
disk = None
if action.isFormat and action.format.type == "disklabel":
if action.is_format and action.format.type == "disklabel":
disk = action.device

if disk is not None and disk not in disks:
disks.append(disk)

active = []
for dev in devices:
if dev.status and not dev.isDisk and \
if dev.status and not dev.is_disk and \
not isinstance(dev, PartitionDevice):
active.append(dev)

elif dev.format.status and not dev.isDisk:
elif dev.format.status and not dev.is_disk:
active.append(dev)

devices = [a.name for a in active if any(d in disks for d in a.disks)]
return devices

def process(self, callbacks=None, devices=None, dryRun=None):
def process(self, callbacks=None, devices=None, dry_run=None):
"""
Execute all registered actions.
Expand All @@ -271,11 +271,11 @@ def process(self, callbacks=None, devices=None, dryRun=None):
"""
devices = devices or []
self._preProcess(devices=devices)
self._pre_process(devices=devices)

for action in self._actions[:]:
log.info("executing action: %s", action)
if not dryRun:
if not dry_run:
try:
action.execute(callbacks)
except DiskLabelCommitError:
Expand All @@ -284,17 +284,17 @@ def process(self, callbacks=None, devices=None, dryRun=None):
# include deps no longer in the tree due to pending removal
devs = devices + [a.device for a in self._actions]
for dep in set(devs):
if dep.exists and dep.dependsOn(action.device.disk):
if dep.exists and dep.depends_on(action.device.disk):
dep.teardown(recursive=True)

action.execute(callbacks)

for device in devices:
# make sure we catch any renumbering parted does
if device.exists and isinstance(device, PartitionDevice):
device.updateName()
device.update_name()
device.format.device = device.path

self._completed_actions.append(self._actions.pop(0))

self._postProcess(devices=devices)
self._post_process(devices=devices)

0 comments on commit 8f889ab

Please sign in to comment.