How to use the osxphotos.fileutil.FileUtil function in osxphotos

To help you get started, we’ve selected a few osxphotos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RhetTbull / osxphotos / osxphotos / photoinfo / _photoinfo_export.py View on Github external
export_as_hardlink=False,
    overwrite=False,
    increment=True,
    sidecar_json=False,
    sidecar_xmp=False,
    use_photos_export=False,
    timeout=120,
    exiftool=False,
    no_xattr=False,
    use_albums_as_keywords=False,
    use_persons_as_keywords=False,
    keyword_template=None,
    description_template=None,
    update=False,
    export_db=None,
    fileutil=FileUtil,
    dry_run=False,
):
    """ export photo, like export but with update and dry_run options
        dest: must be valid destination path or exception raised 
        filename: (optional): name of exported picture; if not provided, will use current filename 
                    **NOTE**: if provided, user must ensure file extension (suffix) is correct. 
                    For example, if photo is .CR2 file, edited image may be .jpeg.  
                    If you provide an extension different than what the actual file is, 
                    export will print a warning but will export the photo using the 
                    incorrect file extension (unless use_photos_export is true, in which case export will
                    use the extension provided by Photos upon export; in this case, an incorrect extension is
                    silently ignored).
                    e.g. to get the extension of the edited photo, 
                    reference PhotoInfo.path_edited
        edited: (boolean, default=False); if True will export the edited version of the photo 
                (or raise exception if no edited version) 
github RhetTbull / osxphotos / osxphotos / __main__.py View on Github external
)
        click.echo(
            f"You are exporting to {dest}, found {OSXPHOTOS_EXPORT_DB} files in:"
        )
        for other_db in other_db_files:
            click.echo(f"{other_db}")
        click.confirm("Do you want to continue?", abort=True)

    if dry_run:
        export_db = ExportDBInMemory(export_db_path)
        # echo = functools.partial(click.echo, err=True)
        # fileutil = FileUtilNoOp(verbose=echo)
        fileutil = FileUtilNoOp
    else:
        export_db = ExportDB(export_db_path)
        fileutil = FileUtil

    photos = _query(
        db=db,
        keyword=keyword,
        person=person,
        album=album,
        folder=folder,
        uuid=uuid,
        title=title,
        no_title=no_title,
        description=description,
        no_description=no_description,
        ignore_case=ignore_case,
        edited=edited,
        external_edit=external_edit,
        favorite=favorite,
github RhetTbull / osxphotos / osxphotos / fileutil.py View on Github external
def file_sig(cls, f1):
        """ return os.stat signature for file f1 """
        return cls._sig(os.stat(f1))

    @staticmethod
    def _sig(st):
        return (stat.S_IFMT(st.st_mode), st.st_size, st.st_mtime)


class FileUtil(FileUtilMacOS):
    """ Various file utilities """

    pass


class FileUtilNoOp(FileUtil):
    """ No-Op implementation of FileUtil for testing / dry-run mode
        all methods with exception of cmp_sig and file_cmp are no-op
        cmp_sig functions as FileUtil.cmp_sig does
        file_cmp returns mock data
    """

    @staticmethod
    def noop(*args):
        pass

    verbose = noop

    def __new__(cls, verbose=None):
        if verbose:
            if callable(verbose):
                cls.verbose = verbose
github RhetTbull / osxphotos / osxphotos / __main__.py View on Github external
overwrite=None,
    export_edited=None,
    original_name=None,
    export_live=None,
    download_missing=None,
    exiftool=None,
    directory=None,
    filename_template=None,
    no_extended_attributes=None,
    export_raw=None,
    album_keyword=None,
    person_keyword=None,
    keyword_template=None,
    description_template=None,
    export_db=None,
    fileutil=FileUtil,
    dry_run=None,
    edited_suffix="_edited",
):
    """ Helper function for export that does the actual export

    Args:
        photo: PhotoInfo object
        dest: destination path as string
        verbose_: boolean; print verbose output
        export_by_date: boolean; create export folder in form dest/YYYY/MM/DD
        sidecar: list zero, 1 or 2 of ["json","xmp"] of sidecar variety to export
        export_as_hardlink: boolean; hardlink files instead of copying them
        overwrite: boolean; overwrite dest file if it already exists
        original_name: boolean; use original filename instead of current filename
        export_live: boolean; also export live video component if photo is a live photo
                     live video will have same name as photo but with .mov extension