From 0e4577ea8ac0ea99e2c44164e2e81182d1ec4d07 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 7 Jul 2018 19:07:30 -0700 Subject: import order and break long lines --- examples/plugin_pmount.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index f7e1bd3c..3079b5a3 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -15,8 +15,8 @@ from __future__ import (absolute_import, division, print_function) -import ranger.api import subprocess +import ranger.api MOUNT_KEY = 'm' UMOUNT_KEY = 'M' @@ -27,13 +27,15 @@ def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) diskcmd = "lsblk -lno NAME | grep -w 'sd[a-z]' | sed 's/sd//'" - disks = subprocess.check_output(diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') + disks = subprocess.check_output( + diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') for disk in disks: partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) try: - numparts = int(subprocess.check_output(partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) + numparts = int(subprocess.check_output( + partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) except ValueError: numparts = 0 @@ -43,19 +45,21 @@ def hook_init(fm): disk, key=MOUNT_KEY)) fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{0}".format( disk, key=UMOUNT_KEY)) - + elif numparts == 1: # only one partition, mount the partition - fm.execute_console("map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( - disk, key=MOUNT_KEY)) + fm.execute_console( + "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( + disk, key=MOUNT_KEY)) fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( disk, key=UMOUNT_KEY)) else: # use range start 1, /dev/sd{device}0 doesn't exist for part in range(1, numparts + 1): - fm.execute_console("map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( - disk, part, key=MOUNT_KEY)) + fm.execute_console( + "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY)) fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( disk, part, key=UMOUNT_KEY)) -- cgit 1.4.1-2-gfad0