Created
June 30, 2015 19:43
-
-
Save WesleyE/857bd944472a714da5c7 to your computer and use it in GitHub Desktop.
Hiero move exporter, moves files between folders instead of coping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The MIT License (MIT) | |
Copyright (c) 2014 Wesley Elfring | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE.""" | |
import os.path | |
import os | |
import sys | |
import shutil | |
import math | |
import PySide.QtCore | |
import PySide.QtGui | |
import hiero.core | |
import hiero.ui | |
class MoveExporter(hiero.exporters.FnFrameExporter.FrameExporter): | |
def __init__( self, initDict ): | |
"""Initialize""" | |
hiero.exporters.FnFrameExporter.FrameExporter.__init__( self, initDict ) | |
if self.nothingToDo(): | |
return | |
def doFrame(self, src, dst): | |
hiero.core.log.info( "MoveExporter:" ) | |
hiero.core.log.info( " - source: " + str(src) ) | |
hiero.core.log.info( " - destination: " + str(dst) ) | |
# Find the base destination directory, if it doesn't exist create it | |
dstdir = os.path.dirname(dst) | |
if not os.path.exists(dstdir): | |
hiero.core.log.info( "make dirs:" + dstdir ) | |
os.makedirs(dstdir) | |
# Move file including the permission bits, last access time, last modification time, and flags | |
try: | |
shutil.move(src, dst) | |
except shutil.Error, e: | |
# Dont need to report this as an error | |
if e.message.endswith("are the same file"): | |
pass | |
else: | |
self.setError("Unable to move file. %s" % e.message) | |
def taskStep(self): | |
# If this is a single file (eg r3d or mov) then we don't need to do the whole step every frame. | |
ret = hiero.exporters.FnFrameExporter.FrameExporter.taskStep(self) | |
return ret and not self._singleFile | |
class MovePreset(hiero.core.TaskPresetBase): | |
def __init__(self, name, properties): | |
hiero.core.TaskPresetBase.__init__(self, MoveExporter, name) | |
# Update preset with loaded data | |
self.properties().update(properties) | |
def supportedItems(self): | |
return hiero.core.TaskPresetBase.kTrackItem | hiero.core.TaskPresetBase.kClip | |
hiero.core.taskRegistry.registerTask(MovePreset, MoveExporter) | |
class MoveExporterUI(hiero.ui.TaskUIBase): | |
def __init__(self, preset): | |
"""Initialize""" | |
hiero.ui.TaskUIBase.__init__(self, MoveExporter, preset, "Move Exporter") | |
hiero.ui.taskUIRegistry.registerTaskUI(MovePreset, MoveExporterUI) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment