예제 #1
0
 def test_nothing_missing(self):
     with capture_output() as out:
         dip.find_missing_nums(self.folder_exclusions[0])
     output = out.getvalue().strip()
     out.close()
     lines = output.split('\n')
     self.assertTrue(lines[0].startswith('No number found: "'))
예제 #2
0
def execute_photos(args: argparse.Namespace) -> int:
    r"""
    Executes the photo processing commands.

    Parameters
    ----------
    args : class argparse.Namespace, with fields:
        .docstrings : bool
        .verbose : bool

    Returns
    -------
    return_code : int
        Return code for whether the command executed cleanly

    Notes
    -----
    #.  Written by David C. Stauffer in December 2020.

    Examples
    --------
    >>> from dstauffman2.commands import execute_photos
    >>> from argparse import Namespace
    >>> args = Namespace(folder='.', long=False, missing=False, pause=False, picasa=False, resize=False, unexpected_ext=False, upper=False)
    >>> execute_photos(args) # doctest: +SKIP

    """
    # alias options
    folder = os.path.abspath(args.folder)
    upper = args.upper
    missing = args.missing
    unexpect = args.unexpected_ext
    picasa = args.picasa
    list_long = args.long
    resize = args.resize
    pause = args.pause

    if upper:
        rename_upper_ext(folder)
    if missing:
        find_missing_nums(folder)
    if list_long:
        find_long_filenames(folder)
    if unexpect:
        find_unexpected_ext(folder)
    if picasa:
        rename_old_picasa_files(folder)
    if resize:
        batch_resize(folder, max_width=1024, max_height=768)
    if pause:
        breakpoint()
예제 #3
0
 def test_ignore_digits(self):
     with capture_output() as out:
         dip.find_missing_nums(self.folder, digit_check=False)
     output = out.getvalue().strip()
     out.close()
     lines = output.split('\n')
     if lines[0][0] == 'O':
         ix0 = 0
         ix1 = 1
     else:
         ix0 = 1
         ix1 = 0
     self.assertTrue(lines[ix0].startswith('Old Picasa file: "'))
     self.assertTrue(lines[ix1].startswith('Weird numbering: "'))
     self.assertTrue(lines[2].startswith('Missing: "'))
     self.assertTrue(lines[2].endswith('": {3, 5}'))
     self.assertFalse(lines[3].startswith('Inconsistent digits: "'))
예제 #4
0
r"""
Copies changes any *.JPG to *.jpg and shows any missing numbers.

Notes
-----
#.  Written by David C. Stauffer in December 2013.
"""

#%% Imports
import dstauffman2.imageproc as dip

#%% Test script
if __name__ == '__main__':
    folder = r'C:\Users\DStauffman\Desktop\Camera'
    dip.rename_upper_ext(folder)
    dip.find_missing_nums(folder)
    #dip.find_unexpected_ext(folder)
    #dip.rename_old_picasa_files(folder)
    #dip.find_long_filenames(folder)