diff --git a/rattail/files.py b/rattail/files.py index e5406f0f5f9513e6820ccd8bd242e2b0c548d6fd..717bf0f0da5f234040555d568ea2d3f244a070c2 100644 --- a/rattail/files.py +++ b/rattail/files.py @@ -184,25 +184,23 @@ def overwriting_move(src, dst): shutil.move(src, dst) -def minimal_move(src, dst): +def move_lpt(src, dst): """ - Move a source file to a destination path, in as few operations as possible. + "Move" a source file to a LPT port, on Windows only. This is an experimental function which will hopefully provide a more reliable way to send a print job directly to a parallel port (e.g. 'LPT1') on Windows systems. The function body was copied from :func:`python:shutil.move()` and "gutted" as much as was practical. - Note that one difference from ``shutil.move()`` is that in this function, - the ``dst`` parameter is always assumed to be a directory(-like) path, and - never a "file" path. There also is no check for the final destination's - existence, etc. + Note that this function's signature differs from ``shutil.move()`` in that + the ``dst`` parameter is always assumed to be a LPT port, e.g. ``'LPT1'``, + and never a "file" path. """ - real_dst = os.path.join(dst, shutil._basename(src)) try: - os.rename(src, real_dst) + os.rename(src, dst) except OSError: - shutil.copyfile(src, real_dst) + shutil.copyfile(src, dst) os.unlink(src)