To Do list for improving code idioms #################################### To Do ===== * Remove use of global variables. * dput.dput:debug * Ensure all files explicitly opened are closed correctly. * Encapsulate application state in a class. * dput.dput.PackageUploadApplication * dput.dcut.CommandUploadApplication * Use standard OS exit status values. * dput.helper.dputhelper.EXIT_STATUS_SUCCESS → os.EX_OK * dput.helper.dputhelper.EXIT_STATUS_FAILURE → * os.EX_USAGE (“the command was used incorrectly”) * os.EX_NOINPUT (“an input file did not exist or was not readable”) * os.EX_UNAVAILABLE (”a required service is unavailable”) * os.EX_SOFTWARE (“an internal software error was detected”) * os.EX_OSERR (“an operating system error was detected”) * os.EX_OSFILE (“some system file did not exist, could not be opened, or had some other kind of error”) * os.EX_CANTCREAT (“a user specified output file could not be created”) * os.EX_IOERR (“an error occurred while doing I/O on some file”) * os.EX_TEMPFAIL (“a temporary failure occurred. This indicates something that may not really be an error”) * os.EX_PROTOCOL (“a protocol exchange was illegal, invalid, or not understood”) * os.EX_NOPERM (“there were insufficient permissions to perform the operation (but not intended for file system problems)” * os.EX_CONFIG (“some kind of configuration error occurred”) * Use idiomatic ‘configparser’ processing. * Migrate to ‘ConfigParser.read’ method. * Use ‘argparse’ for command-line parsing. * Remove usage of ‘getopt’. * Use ‘logging’ module throughout for all messages. * Remove usage of ‘sys.std{out,err}.write’ for debug-level messages. * Remove usage of ‘sys.std{out,err}.write’ for informational messages. * Remove usage of ‘sys.std{out,err}.write’ for warning message. * Remove usage of ‘sys.std{out,err}.write’ for error messages. * Remove usage of ‘sys.std{out,err}.write’ for critical error messages. * Migrate use of ‘os.path’ → ‘pathlib’ for filesystem path functionality. * dput/configfile.py * dput/dcut.py * dput/dput.py * dput/helper/dputhelper.py * dput/methods/ftp.py * dput/methods/http.py * dput/methods/local.py * dput/methods/rsync.py * dput/methods/scp.py * setup.py * test/helper.py * test/test_changesfile.py * test/test_configfile.py * test/test_dcut.py * test/test_dput.py * test/test_dput_main.py * test/test_methods.py * Generate text output content each in an explicit generator function. * dcut:write_commands * dput:create_upload_file * Write text output files from a passed-in iterable for text lines. * dcut:write_commands * dput:create_upload_file * Replace `dputhelper.FileWithProgress` with a robust third-party implementation of a progress display. * Possible candidate: ‘python3-progress’ * Possible candidate: ‘python3-ttystatus’ * Possible candidate: ‘python3-rich’ * Possible candidate: ‘python3-tqdm’ Done ==== * Remove use of global variables. * dput.dcut.progname * dput.dcut.version * dput.dcut.USAGE * dput.dput.dput_version * dput.dput.files_to_remove * dput.dput.files_to_upload * dput.dput.USAGE * dput.dput.config_file * dput.dput.config * dput.dput.check_only * dput.dput.dinstall * dput.dput.delay_upload * dput.dput.unsigned_upload * dput.dput.simulate * dput.dput.upload_methods * Use ‘subprocess’ API for all subprocess interaction. * Remove usage of ‘os.popen3’. * Migrate ‘os.system’ → ‘subprocess.call’. * Migrate ‘os.waitpid’ → ‘subprocess.check_call’. * Migrate ‘os.popen’ → ‘subprocess.Popen’. * Migrate ‘os.spawnv’ → ‘subprocess.check_call’. * Use ‘sys.stdout.write’ for all normal output. * Remove usage of ‘print’ for normal output. * Use ‘str.format’ for all string formatting and interpolation. * Remove usage of ‘%’ formatting operator. * Reduce ‘if __name__ == '__main__'’ block to minimum. * Install top-level programs using Setuptools ‘entry_points’ feature. * Use idiomatic ‘configparser’ processing. * Use ‘ConfigParser.default_section’ instance attribute instead of hard-coded 'DEFAULT' name. .. Local variables: coding: utf-8 mode: text mode: rst End: vim: fileencoding=utf-8 filetype=rst :