From 727c8cc07e0c1b7a8d8ae096e5a19c4d3414c50b Mon Sep 17 00:00:00 2001 From: Pierrick Le Brun Date: Sat, 16 Feb 2013 16:35:50 +0100 Subject: [PATCH] Correct some English strings and some comments syntax. --- src/salix_livetools_library/__init__.py | 3 +-- src/salix_livetools_library/assertPlus.py | 16 +++++++------- src/salix_livetools_library/bootloader.py | 2 +- src/salix_livetools_library/chroot.py | 4 ++-- src/salix_livetools_library/disk.py | 22 +++++++++++-------- src/salix_livetools_library/execute.py | 14 ++++++------ src/salix_livetools_library/freesize.py | 13 +++++++----- src/salix_livetools_library/fs.py | 26 +++++++++++------------ src/salix_livetools_library/fstab.py | 8 +++---- src/salix_livetools_library/kernel.py | 6 +++--- src/salix_livetools_library/keyboard.py | 26 +++++++++++------------ src/salix_livetools_library/language.py | 6 +++--- src/salix_livetools_library/mounting.py | 6 +++--- src/salix_livetools_library/salt.py | 26 +++++++++++------------ src/salix_livetools_library/timezone.py | 20 ++++++++--------- src/salix_livetools_library/user.py | 2 +- 16 files changed, 103 insertions(+), 97 deletions(-) diff --git a/src/salix_livetools_library/__init__.py b/src/salix_livetools_library/__init__.py index 910e210..f56206c 100644 --- a/src/salix_livetools_library/__init__.py +++ b/src/salix_livetools_library/__init__.py @@ -2,8 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Salix Live Installer library for using with either the graphical or ncurses dialogs -in order to help installing Salix. +Salix Live Installer library used by both the GUI and the Ncurses installers. """ from bootloader import * from chroot import * diff --git a/src/salix_livetools_library/assertPlus.py b/src/salix_livetools_library/assertPlus.py index 1efba8e..3308a71 100644 --- a/src/salix_livetools_library/assertPlus.py +++ b/src/salix_livetools_library/assertPlus.py @@ -1,4 +1,4 @@ -#!/bin/evn python +#!/bin/env python # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ @@ -10,23 +10,23 @@ - assertException(exceptionType, function) - assertNoException(function) -to pass a function, you can use lambda expression like: +To pass a function, you can use lambda expression like: assertException(lambda: myfunction()) """ def assertTrue(expression): - "Expect the expression to be true" + """Expect the expression to be true""" assert expression, "'{0}' was expected to be true".format(expression) def assertFalse(expression): - "Expect the expression to be false" + """Expect the expression to be false""" assert (not expression), "'{0}' was expected to be false".format(expression) def assertEquals(expected, expression): - "Expect that the expression equals to the expected value" + """Expect the expression to be equal to the expected value""" assert expression == expected, "'{0}' expected, got '{1}'".format(expected, expression) def assertNotEquals(expected, expression): - "Expect that the expression does not equals to the expected value" + """Expect the expression not to be equal to the expected value""" assert expression != expected, "'{0}' not expected, got '{1}'".format(expected, expression) def assertException(exceptionType, function): - "Expect that the function trigger an exception of type exceptionType" + """Expect the function to trigger an exception with exceptionType type""" triggered = False try: function() @@ -35,7 +35,7 @@ def assertException(exceptionType, function): triggered = True assert triggered, "Exception '{0}' expected with '{1}'".format(exceptionType, function.__doc__) def assertNoException(function): - "Expect that the function does not trigger any exception" + """Expect the function not to trigger any exception""" triggered = False unExpectedE = None try: diff --git a/src/salix_livetools_library/bootloader.py b/src/salix_livetools_library/bootloader.py index b79794c..726e6df 100644 --- a/src/salix_livetools_library/bootloader.py +++ b/src/salix_livetools_library/bootloader.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Launching the boot loader setup tool with some defaults: +Function to launch the boot loader setup tool with some defaults: - runBootsetup """ from execute import * diff --git a/src/salix_livetools_library/chroot.py b/src/salix_livetools_library/chroot.py index d79cf77..5ff4030 100644 --- a/src/salix_livetools_library/chroot.py +++ b/src/salix_livetools_library/chroot.py @@ -10,11 +10,11 @@ def execChroot(path, cmd, shell = False): """ Execute cmd in the chroot defined by path. - pathes in cmd should be relative to the new root. + Paths in cmd should be relative to the new root directory. """ checkRoot() if not path: - raise IOError("You should provide a path to change root.") + raise IOError("You should provide a path to change the root directory.") elif not os.path.isdir(path): raise IOError("'{0}' does not exist or is not a directory.".format(path)) chrootCmd = ['chroot', path] diff --git a/src/salix_livetools_library/disk.py b/src/salix_livetools_library/disk.py index 23af7e9..638c395 100644 --- a/src/salix_livetools_library/disk.py +++ b/src/salix_livetools_library/disk.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Get information of the disks and partitions in the system. -For now it only handles (S/P)ATA disks and partitions. RAID and LVM are not supported. -/proc and /sys should be mounted for getting information +Get information from the system disks and partitions. +For now it only handles (S/P)ATA disks and partitions, RAID and LVM are not supported yet. +/proc and /sys should be mounted to retrieve information. Functions: - getDisks - getDiskInfo @@ -21,7 +21,10 @@ from stat import * def getDisks(): - "Returns the disks devices (without /dev/) connected to the computer. RAID and LVM are not supported yet." + """ + Return the disks devices (without /dev/) connected to the computer. + RAID and LVM are not supported yet. + """ ret = [] for l in open('/proc/partitions', 'r').read().splitlines(): if re.search(r' sd[^0-9]+$', l): @@ -30,8 +33,9 @@ def getDisks(): def getDiskInfo(diskDevice): """ - Returns a dictionary with the model name, size in bytes, size in human and if is removable for the disk device. - diskDevice should no be prefilled with '/dev/' + Return a dictionary with the following disk device's info: + model name, size in bytes, human readable size and whether it is removable or not. + diskDevice should no be prefixed with '/dev/' dictionary key: model, size, sizeHuman, removable """ if S_ISBLK(os.stat('/dev/{0}'.format(diskDevice)).st_mode): @@ -49,7 +53,7 @@ def getDiskInfo(diskDevice): def getPartitions(diskDevice, skipExtended = True, skipSwap = True): """ - Returns partitions following exclusion filters. + Return partitions matching exclusion filters. """ if S_ISBLK(os.stat('/dev/{0}'.format(diskDevice)).st_mode): parts = [p.replace('/sys/block/{0}/'.format(diskDevice), '') for p in glob.glob('/sys/block/{0}/{0}*'.format(diskDevice))] @@ -64,7 +68,7 @@ def getPartitions(diskDevice, skipExtended = True, skipSwap = True): def getSwapPartitions(): """ - Returns partition devices that are of type Linux Swap. + Return partition devices with Linux Swap type. """ ret = [] for diskDevice in getDisks(): @@ -74,7 +78,7 @@ def getSwapPartitions(): def getPartitionInfo(partitionDevice): """ - Returns a dictionary of partion information: + Return a dictionary with the partition information: - fstype - label - size diff --git a/src/salix_livetools_library/execute.py b/src/salix_livetools_library/execute.py index 62e66b5..3f8333c 100644 --- a/src/salix_livetools_library/execute.py +++ b/src/salix_livetools_library/execute.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Module to execute native commands and get their output: +Functions to execute native commands and get their output: - execCall - execCheck - execGetOutput @@ -15,16 +15,16 @@ def execCall(cmd, shell = True, env = {'LANG' : 'en_US'}): """ Execute a command and return the exit code. - The command is executed by default in a /bin/sh shell and using english locale. - The output of the command is not read. With some commands, it hangs if the output is not read when run in a shell. - For this type of command, prefer using execGetOutput even if you don't read the return value or using shell = False. + The command is executed by default in a /bin/sh shell with en_US locale. + The output of the command is not read. With some commands, it may hang if the output is not read when run in a shell. + For this type of command, it is preferable to use execGetOutput even the return value is not read or to use shell = False. """ return subprocess.call(cmd, shell = shell, env = env) def execCheck(cmd, shell = True, env = {'LANG' : 'en_US'}): """ - Execute a command and return 0 if ok or a subprocess.CalledProcessorError exception in case of error. - The command is executed by default in a /bin/sh shell and using english locale. + Execute a command and return 0 if OK or a subprocess.CalledProcessorError exception in case of error. + The command is executed by default in a /bin/sh shell with en_US locale. """ return subprocess.check_call(cmd, shell = shell, env = env) @@ -32,7 +32,7 @@ def execGetOutput(cmd, withError = False, shell = True, env = {'LANG' : 'en_US'} """ Execute a command and return its output in a list, line by line. In case of error, it returns a subprocess.CalledProcessorError exception. - The command is executed by default in a /bin/sh shell and using english locale. + The command is executed by default in a /bin/sh shell with en_US locale. """ stdErr = None if withError: diff --git a/src/salix_livetools_library/freesize.py b/src/salix_livetools_library/freesize.py index 4d20a5d..137a25a 100644 --- a/src/salix_livetools_library/freesize.py +++ b/src/salix_livetools_library/freesize.py @@ -14,7 +14,10 @@ from execute import * def _getMountPoint(device): - "Copied from 'mounting' module to break circular dependancies" + """ + Find the mount point of 'device' or None if not mounted + Copied from 'mounting' module to break circular dependencies + """ mountpoint = None for line in execGetOutput('mount', shell = False): p, _, mp, _ = line.split(' ', 3) # 3 splits max, _ is discarded @@ -26,7 +29,7 @@ def _getMountPoint(device): return mountpoint def getHumanSize(size): - "Returns the human readable format of the size in bytes" + """Return the human readable format of the size in bytes""" units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'] unit = 0 sizeHuman = float(size) @@ -38,7 +41,7 @@ def getHumanSize(size): def getSizes(path): """ Compute the different sizes of the fileystem denoted by path (either a device or a file in filesystem). - Returns the following sizes (in a dictionary): + Return the following sizes (in a dictionary): - size (total size) - free (total free size) - uuFree (free size for unprivileged users) @@ -80,9 +83,9 @@ def getSizes(path): def getUsedSize(path, blocksize = None): """ - Returns the size of the space used by files and folders under 'path'. + Return the size of the space used by files and folders under 'path'. If 'blocksize' is specified, mimic the space that will be used if the blocksize of the underlying filesystem where the one specified. - This could be useful if to be used to transfering files from one directory to another when the target filesystem use another blocksize. + This could be useful if used to transfer files from one directory to another when the target filesystem use another blocksize. Return a tuple with (size, sizeHuman) """ cmd = ['du', '-c', '-s'] diff --git a/src/salix_livetools_library/fs.py b/src/salix_livetools_library/fs.py index a57704d..a05a363 100644 --- a/src/salix_livetools_library/fs.py +++ b/src/salix_livetools_library/fs.py @@ -18,10 +18,10 @@ def getFsType(partitionDevice): """ - Returns the file system type for that partition. - 'partitionDevice' should no be prefilled with '/dev/' if it's a block device. - It can be a full path if the partition is contains in a file. - Returns 'Extended' if the partition is an extended partition and has no filesystem. + Return the file system type for that partition. + 'partitionDevice' should no be prefixed with '/dev/' if it's a block device. + It can be a full path if the partition is contained in a file. + Return 'Extended' if the partition is an extended partition and has no filesystem. """ if os.path.exists('/dev/{0}'.format(partitionDevice)) and S_ISBLK(os.stat('/dev/{0}'.format(partitionDevice)).st_mode): path = '/dev/{0}'.format(partitionDevice) @@ -45,9 +45,9 @@ def getFsType(partitionDevice): def getFsLabel(partitionDevice): """ - Returns the label for that partition (if any). - 'partitionDevice' should no be prefilled with '/dev/' if it's a block device. - It can be a full path if the partition is contains in a file. + Return the label for that partition (if any). + 'partitionDevice' should no be prefixed with '/dev/' if it is a block device. + It can be a full path if the partition is contained in a file. """ if os.path.exists('/dev/{0}'.format(partitionDevice)) and S_ISBLK(os.stat('/dev/{0}'.format(partitionDevice)).st_mode): path = '/dev/{0}'.format(partitionDevice) @@ -69,11 +69,11 @@ def getFsLabel(partitionDevice): def makeFs(partitionDevice, fsType, label=None, force=False, options=None): """ - Creates a filesystem on the device. - 'partitionDevice' should no be prefilled with '/dev/' if it's a block device. + Create a filesystem on the device. + 'partitionDevice' should no be prefixed with '/dev/' if it is a block device. 'fsType' could be ext2, ext3, ext4, xfs, reiserfs, jfs, btrfs, ntfs, fat16, fat32, swap - Use 'force=True' if you want to force creating the filesystem and if 'partitionDevice' is a full path to a file (not a block device). - Use 'options' to force passing these options to the creation process (use a list) + Use 'force=True' if you want to force the creation of the filesystem and if 'partitionDevice' is a full path to a file (not a block device). + Use 'options' to force options on the creation process (use a list) """ if force and os.path.exists(partitionDevice): path = partitionDevice @@ -104,7 +104,7 @@ def makeFs(partitionDevice, fsType, label=None, force=False, options=None): return None # should not append def _makeExtFs(path, version, label, options, force): - "ExtX block size: 4k per default in /etc/mke2fs.conf" + """ExtX block size: 4k per default in /etc/mke2fs.conf""" cmd = ['/sbin/mkfs.ext{0:d}'.format(version)] if not options: options = [] @@ -120,7 +120,7 @@ def _makeExtFs(path, version, label, options, force): return execCall(cmd, shell = False) def _makeXfs(path, label, options, force): - "http://blog.peacon.co.uk/wiki/Creating_and_Tuning_XFS_Partitions" + """http://blog.peacon.co.uk/wiki/Creating_and_Tuning_XFS_Partitions""" cmd = ['/sbin/mkfs.xfs'] if not options: options = ['-f'] # -f is neccessary to have this or you cannot create XFS on a non-empty partition or disk diff --git a/src/salix_livetools_library/fstab.py b/src/salix_livetools_library/fstab.py index ea795d3..5b44c61 100644 --- a/src/salix_livetools_library/fstab.py +++ b/src/salix_livetools_library/fstab.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Used to create fstab entries: +Functions to generate fstab entries: - createFsTab - addFsTabEntry """ @@ -11,7 +11,7 @@ def createFsTab(fstabMountPoint): """ - Creates a etc/fstab empty file + Generate an empty /etc/fstab file """ try: os.mkdir('{0}/etc'.format(fstabMountPoint)) @@ -21,8 +21,8 @@ def createFsTab(fstabMountPoint): def addFsTabEntry(fstabMountPoint, device, mountPoint, fsType = None, options = None, dumpFlag = 0, fsckOrder = 0): """ - Add a line to etc/fstab - If fsType is None, then it will be guessed from the device and the by using blkid + Add a line to /etc/fstab + If fsType is None, then it will be guessed from the device by using blkid If options is None, then it will be guessed from the fsType like this: - 'proc', 'sysfs', 'devpts', 'tmpfs', 'swap' |=> 'defaults' - 'ext2', 'ext3', 'ext4', 'xfs', 'reiserfs', 'btrfs', 'jfs' |=> 'defaults,noatime' diff --git a/src/salix_livetools_library/kernel.py b/src/salix_livetools_library/kernel.py index 38897d6..a88d984 100644 --- a/src/salix_livetools_library/kernel.py +++ b/src/salix_livetools_library/kernel.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Functions for getting kernel parameters: +Functions to retrieve kernel parameters: - hasKernelParam - getKernelParamValue """ @@ -10,7 +10,7 @@ def hasKernelParam(param): """ - Defines if the kernel parameter param has been defined on the kernel command line or not + Define if the kernel parameter param has been defined on the kernel command line or not """ if os.path.exists('/proc/cmdline'): cmdline = open('/proc/cmdline', 'r').read().split() @@ -21,7 +21,7 @@ def hasKernelParam(param): def getKernelParamValue(param): """ - Return the value of the kernel parameter, None if this param has no value and False if this param does not exist + Return the value of the kernel parameter, None if this param has no value and False if this param does not exist. """ if os.path.exists('/proc/cmdline'): cmdline = open('/proc/cmdline', 'r').read().split() diff --git a/src/salix_livetools_library/keyboard.py b/src/salix_livetools_library/keyboard.py index 1cff48c..dc37d37 100644 --- a/src/salix_livetools_library/keyboard.py +++ b/src/salix_livetools_library/keyboard.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Functions to handle keyboard layouts: +Functions to handle keyboard layout: - findCurrentKeymap - listAvailableKeymaps - isNumLockEnabledByDefault @@ -25,8 +25,8 @@ def findCurrentKeymap(mountPoint = None): Find the currently used console keymaps (as loaded by 'loadkeys') by looking in: - /etc/rc.d/rc.keymap, or - in the 'keyb=' kernel parameter - The detected keymap is then check against the first column of one of the files: {0} - Returns None if not found + The detected keymap is then checked against the first column of one of the files: {0} + Return None if not found """.format(' '.join(_keymapsLocation)) if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -62,7 +62,7 @@ def findCurrentKeymap(mountPoint = None): def listAvailableKeymaps(mountPoint = None): """ - Returns a list of couple (keymap, keyboardType). + Return a list of couple (keymap, keyboardType). 'keymap' is a Console keymap as found in /usr/share/kbd/ 'keyboardType' is either 'azerty', 'qwerty', 'qwertz', etc and is there only for information The keymaps are extracted from one of the files: {0} @@ -96,8 +96,8 @@ def listAvailableKeymaps(mountPoint = None): def isNumLockEnabledByDefault(mountPoint = None): """ - Returns True if the num lock is enabled by default. - For this, the execute bit of /etc/rc.d/rc.numlock is checked. + Return True if the num lock is enabled by default. + To do this, the execute bit of /etc/rc.d/rc.numlock is checked. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -107,8 +107,8 @@ def isNumLockEnabledByDefault(mountPoint = None): def isIbusEnabledByDefault(mountPoint = None): """ - Returns True if the IBus is enabled by default. - For this, the execute bit of /usr/bin/ibus-daemon and /etc/profile.d/ibus.sh are checked. + Return True if the IBus is enabled by default. + To do this, the execute bit of /usr/bin/ibus-daemon and /etc/profile.d/ibus.sh are checked. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -119,7 +119,7 @@ def isIbusEnabledByDefault(mountPoint = None): def setDefaultKeymap(keymap, mountPoint = None): """ Fix the configuration in /etc/rc.d/rc.keymap to use the specified 'keymap'. - This use 'keyboardsetup' Salix tool. + This uses 'keyboardsetup' Salix tool. """ checkRoot() if mountPoint and not os.path.isdir(mountPoint): @@ -133,8 +133,8 @@ def setDefaultKeymap(keymap, mountPoint = None): def setNumLockDefault(enabled, mountPoint = None): """ - Fix the configuration for default numlock activated on boot or not. - This use 'keyboardsetup' Salix tool. + Fix the configuration for default numlock to be activated or not on boot. + This uses 'keyboardsetup' Salix tool. """ checkRoot() if mountPoint and not os.path.isdir(mountPoint): @@ -152,7 +152,7 @@ def setNumLockDefault(enabled, mountPoint = None): def setIbusDefault(enabled, mountPoint = None): """ Fix the configuration for default Ibus activated on boot or not. - This use 'keyboardsetup' Salix tool. + This uses 'keyboardsetup' Salix tool. """ checkRoot() if mountPoint and not os.path.isdir(mountPoint): @@ -188,7 +188,7 @@ def setIbusDefault(enabled, mountPoint = None): assertTrue(isNumLockEnabledByDefault()) assertEquals(0, setIbusDefault(True)) assertTrue(isIbusEnabledByDefault()) - # restore actual keybaord parameters + # restore actual keyboard parameters setDefaultKeymap(keymap) setNumLockDefault(numlock) setIbusDefault(ibus) diff --git a/src/salix_livetools_library/language.py b/src/salix_livetools_library/language.py index 1540c6b..c0f9d53 100644 --- a/src/salix_livetools_library/language.py +++ b/src/salix_livetools_library/language.py @@ -18,7 +18,7 @@ def listAvailableLocales(mountPoint = None): """ - Returns a list of couples (name, title) of available utf8 locales on the system under 'mountPoint'. + Return a list of couples (name, title) for available utf8 locales on the system under 'mountPoint'. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -33,14 +33,14 @@ def listAvailableLocales(mountPoint = None): def getCurrentLocale(): """ - Returns the current used locale in the current environment. + Return the current used locale in the current environment. """ lang, enc = locale.getdefaultlocale() return "{0}.{1}".format(lang, enc.lower()) def getDefaultLocale(mountPoint = None): """ - Returns the default locale as defined in /etc/profile.d/lang.c?sh + Return the default locale as defined in /etc/profile.d/lang.c?sh """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) diff --git a/src/salix_livetools_library/mounting.py b/src/salix_livetools_library/mounting.py index 9de4da0..ba31f2b 100644 --- a/src/salix_livetools_library/mounting.py +++ b/src/salix_livetools_library/mounting.py @@ -18,7 +18,7 @@ def getMountPoint(device): """ - Will find the mount point to this 'device' or None if not mounted. + Find the mount point to this 'device' or None if not mounted. """ mountpoint = None path = os.path.abspath(device) @@ -76,8 +76,8 @@ def mountDevice(device, fsType = None, mountPoint = None): def umountDevice(deviceOrPath, tryLazyUmount = True, deleteMountPoint = True): """ - Umount the 'deviceOrPath' which could be a device or a mount point. - If the umount failed, try again with a lazyUmount if 'tryLazyUmount' is True. + Unmount the 'deviceOrPath' which could be a device or a mount point. + If umount failed, try again with a lazyUmount if 'tryLazyUmount' is True. Will delete the mount point if 'deleteMountPoint' is True. Returns False if it fails. """ diff --git a/src/salix_livetools_library/salt.py b/src/salix_livetools_library/salt.py index 9391041..a73ea6d 100644 --- a/src/salix_livetools_library/salt.py +++ b/src/salix_livetools_library/salt.py @@ -21,14 +21,14 @@ def getSaLTVersion(): """ - Returns the SaLT version if run in a SaLT Live environement + Return the SaLT version if run in a SaLT Live environment """ _checkLive() return open('/mnt/salt/salt-version', 'r').read().strip() def isSaLTVersionAtLeast(version): """ - Returns True if the SaLT version is at least 'version'. + Return True if the SaLT version is at least 'version'. """ v = getSaLTVersion() def vercmp(v1, v2): @@ -42,7 +42,7 @@ def _makelist(v): def isSaLTLiveEnv(): """ - Returns True if it is executed in a SaLT Live environment, False otherwise + Return True if it is executed in a SaLT Live environment, False otherwise """ return os.path.isfile('/mnt/salt/salt-version') and os.path.isfile('/mnt/salt/tmp/distro_infos') @@ -52,7 +52,7 @@ def _checkLive(): def isSaLTLiveCloneEnv(): """ - Returns Trus if it is exectued in a SaLT LiveClone environment, False otherwise + Return True if it is executed in a SaLT LiveClone environment, False otherwise """ if not isSaLTLiveEnv(): return False @@ -62,7 +62,7 @@ def isSaLTLiveCloneEnv(): def getSaLTLiveMountPoint(): """ - Returns the SaLT source mount point path. It could be the mountpoint of the optical drive, or the USB stick for example. + Return the SaLT source mount point path. It could be the mount point of the optical drive or the USB stick for example. """ _checkLive() try: @@ -75,8 +75,8 @@ def getSaLTLiveMountPoint(): def getSaLTRootDir(): """ - Returns the SaLT ROOT_DIR, so the name of the directory containing the modules. - This is not a full path but relative to the BASEDIR. + Return the SaLT ROOT_DIR, which is the directory containing SaLT modules. + This is not the full path but a relative path to BASEDIR. """ _checkLive() ret = None @@ -88,8 +88,8 @@ def getSaLTRootDir(): def getSaLTIdentFile(): """ - Returns the SaLT IDENT_FILE, so the name of the file located at the root of a filesystem containing some SaLT information for this Live session. - This is not a full path but relative to the mount point. + Return the SaLT IDENT_FILE, which is the file located at the root of a filesystem containing some SaLT information for this Live session. + This is not the full path but a relative path to the mount point. """ _checkLive() ret = None @@ -101,8 +101,8 @@ def getSaLTIdentFile(): def getSaLTBaseDir(): """ - Returns the SaLT BASEDIR, so the name of the directory containing all files for this Live session. - This is not a full path but relative to the mount point. + Return the SaLT BASEDIR, which is the directory containing all files for this Live session. + This is not a full path but a relative path to the mount point. """ _checkLive() mountpoint = getSaLTLiveMountPoint() @@ -119,7 +119,7 @@ def getSaLTBaseDir(): def listSaLTModules(): """ - Returns a list of modules names for this Live session. + Return the list of SaLT modules for this Live session. """ _checkLive() moduledir = '{0}/{1}/{2}/modules'.format(getSaLTLiveMountPoint(), getSaLTBaseDir(), getSaLTRootDir()) @@ -127,7 +127,7 @@ def listSaLTModules(): def installSaLTModule(moduleName, targetMountPoint): """ - Install the module 'moduleName' of this Live session into the targetMountPoint. + Install the module 'moduleName' from this Live session into the targetMountPoint. """ _checkLive() if not os.path.isdir('/mnt/salt/mnt/{1}'.format(moduleName)): diff --git a/src/salix_livetools_library/timezone.py b/src/salix_livetools_library/timezone.py index d7b6e33..fbda56c 100644 --- a/src/salix_livetools_library/timezone.py +++ b/src/salix_livetools_library/timezone.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # vim: set et ai sta sw=2 ts=2 tw=0: """ -Functions to handle timezones: +Functions to handle time zones: - listTimeZones - listTZContinents - listTZCities @@ -19,7 +19,7 @@ def listTimeZones(mountPoint = None): """ - Returns a dictionnary of time zones, by continent. + Return a dictionary of time zones, by continent. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -32,7 +32,7 @@ def listTimeZones(mountPoint = None): def listTZContinents(mountPoint = None): """ - Returns a sorted list for continents for time zones. + Return a sorted list of continents for time zones. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -42,7 +42,7 @@ def listTZContinents(mountPoint = None): def listTZCities(continent, mountPoint = None): """ - Returns a sorted list of cities for a specific continent time zone. + Return a sorted list of cities for a specific continent's time zone. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -55,7 +55,7 @@ def listTZCities(continent, mountPoint = None): def getDefaultTimeZone(mountPoint = None): """ - Returns the default time zone, by reading the /etc/localtime-copied-from symlink. + Return the default time zone, by reading the /etc/localtime-copied-from symlink. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -68,7 +68,7 @@ def getDefaultTimeZone(mountPoint = None): def setDefaultTimeZone(timezone, mountPoint = None): """ - Sets the default time zone, by copying the correct time zone to /etc/localtime and by setting the /etc/localtime-copied-from symlink. + Set the default time zone, by copying the correct time zone to /etc/localtime and by setting the /etc/localtime-copied-from symlink. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -81,12 +81,12 @@ def setDefaultTimeZone(timezone, mountPoint = None): os.unlink('{0}/etc/localtime-copied-from'.format(mountPoint)) os.symlink('/usr/share/zoneinfo/{0}'.format(timezone), '{0}/etc/localtime-copied-from'.format(mountPoint)) else: - raise Exception('This timezone ({0}) is incorrect.'.format(timezone)) + raise Exception('This time zone: ({0}), is incorrect.'.format(timezone)) def isNTPEnabledByDefault(mountPoint = None): """ - Returns True if the NTP service is enabled by default. - For this, the execute bit of /etc/rc.d/rc.ntpd is checked. + Return True if the NTP service is enabled by default. + To do this, the execute bit of /etc/rc.d/rc.ntpd is checked. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint)) @@ -96,7 +96,7 @@ def isNTPEnabledByDefault(mountPoint = None): def setNTPDefault(enabled, mountPoint = None): """ - Fix the configuration for default NTP service activated on boot or not. + Fix the configuration for the default NTP service to be activated on boot or not. """ checkRoot() if mountPoint and not os.path.isdir(mountPoint): diff --git a/src/salix_livetools_library/user.py b/src/salix_livetools_library/user.py index 3e8a3fa..3b360b9 100644 --- a/src/salix_livetools_library/user.py +++ b/src/salix_livetools_library/user.py @@ -20,7 +20,7 @@ def listRegularSystemUsers(mountPoint = None): """ - Returns a sorted list of regular users, i.e. users with id ≥ 1000. + Return a sorted list of regular users, i.e. users with id ≥ 1000. """ if mountPoint and not os.path.isdir(mountPoint): raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint))