Pro_Pack : ImportExport

ProPack importexport module manages files and sourcecontrol

>>> # import statement for the module via the r9pro decompiler
>>> from Red9.pro_pack import r9pro
>>> r9pro.r9import('r9ie')
>>> import r9ie

Main Classes

P4_sourceControl([path]) Perforce format reference:
r9File([path]) Red9 file handler system, bound to OS calls directly by inheritance from pm.util.path which then exposes all OS calls directly to the class instance.
getNewNodes(fn)

decorator function to get new nodes after a method has been run this decorator sets an attr call _new nodes in the object instance where all new created nodes are store as a list

checkPlugin(pluginName)
checkFile(fileName, ext)
class MayaFile(filePath=None)

Bases: Red9.pro_pack.browser.actions.FileBaseActions

saveMa()
saveMb()
open(*args, **kws)
importFile(*args, **kws)
reference(*args, **kws)
class Fbx

Bases: object

base class to handlin FBX file import and export

importFbx(fileName=None, preset=None)

import fbx with the base fbximport preset from motionbuilder

Parameters:
  • fileName – fbx file to import
  • preset – if given use this preset rather than the internal preset of Red9

Note

the presets must be in the “Red9pro_packcoreFBX_presetsimport” folder to be loaded

exportFbx(fileName=None, selection=False, preset=None)

export selected data to fbx

Parameters:
  • fileName – fbx file to export too
  • selection – bool, export the selected nodes or the scene
  • preset – if given use this preset rather than the internal preset of Red9

Note

the presets must be in the “Red9pro_packcoreFBX_presetsexport” folder to be loaded

updateFbx(fileName=None)

import an fbx via the ‘update’ option, if nodes are found in the scene their anim data will be updated

Parameters:fileName – fbx file to import
addFbx(fileName=None)

import using the ‘add’ only method, all data will be imported as new

Parameters:fileName – fbx file to import
getTakeInfo(fileName=None, index=1)

get take info from the fbx data internals

class Atom

Bases: object

class P4_sourceControl(path='')

Bases: object

Perforce format reference:

Note

This accepts either the file pointer or depot folder path if you want to act on multiple files at once. Ideally folder depot path needs to end in ... to denote that we’re walking into that path

if you want to clamp to a given format in a folder you can pass the depot path as ‘//depot/path/to/stuff/...ma’ for example

TODO: decouple this from Maya so it can be using in native Python (MoBu support etc)

path_iswildcard()

check if our given path var is a dir or a single file object, ie endsWith ‘...’ or ‘*’

<<<<<<< HEAD
info()
=======
info
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e

get the general Perforce session info

username
<<<<<<< HEAD

return the current userName from P4 info keys

=======
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
clientroot
<<<<<<< HEAD

return the clientRoot from P4 info keys

=======
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
clientname
<<<<<<< HEAD

return the clientName from P4 info keys

revision()

return the current revision that you have in your workspace

=======
revision
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
exists
<<<<<<< HEAD

simple bool, is the file path already in P4? Checked via a simple fstat call

=======

simple bool, is the file path already in P4? Checked via fstat

>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
exists_local
<<<<<<< HEAD

os check if the file exists locally. Issue is that P4 can say you have the file in your workspace but you may have deleted it locally

=======

os check if the file exists locally

>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
fstat

get all fstat info for the fileobject, returned as a dict

fstat_dir(filetype=None, recursive=True)

where the path bound in the object is just that, a depot folder path rather than a file pointer.

Parameters:
  • filetype – if you want to clamp the fstat to a given file extension
  • recursive – append ‘...’ to the search to make it recursive folder
is_head()
<<<<<<< HEAD

return True if you have the head revision in your workspace, this DOESN’T check if it exists locally however

=======

return true is the file is already at the head version

>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
<<<<<<< HEAD have_rev(rev=None)

return the revision you have locally in your workspace, if this returns nothing then the file does not exist in your workspace yet and return False

Parameters:rev – if given we check the version you have against this revision and return a bool
head_revision()

head revision number of the fileobject in Perforce

have_head()

The file you have is the Head revision AND exists locally. The issue with P4 is that you can get the fstat to return that you have the head file in your workspace, but you may have deleted the local file. This validates both cases.

client_file()

local ‘client’ path to the fileobject

depot_file()

local ‘depotFile’ path to the fileobject

client_parentfolder()

return the stripped back parent folder on the client side

depot_parentfolder()
======= have_rev()

return the revision you have locally in your workspace, if this returns nothing then the file does not exist in your workspace yet and return False

head_revision

head revision number of the fileobject

client_file

local ‘client’ path to the fileobject

depot_file

local ‘depotFile’ path to the fileobject

client_parentfolder

return the stripped back parent folder on the client side

depot_parentfolder
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e

return the stripped back parent folder on the depot side

<<<<<<< HEAD sync(force=False, exists=True)

sync the file to headRevision of this fileobject

Parameters:
  • force – use the force flag when syncing
  • exists – ensure that the file exists in the local if not set force
======= sync(force=False)

sync the file to headRevision of this fileobject

>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
checkout(changelist=None, force=True)

checkout the fileobject in P4

Parameters:
  • changelist – if given use this changelist else use the default
  • <<<<<<< HEAD
  • force – if the file is NOT in your workspace, sync it before checkout, this also verifies that you haven’t deleted the local version of that file
  • =======
  • force – if the file is NOT in your workspace, sync it before checkout
  • >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e
checkin()

Not Implemented for safety

revert()

revert this fileobject

revert_unchanged(changelist)
get_revision(revision)

get a specific revision of this fileobject

Parameters:revision – revision to get
create_changelist(text)

make a fresh changelist with the text given

Parameters:text – text to use in the changelist description
get_changelist_info(changelist)

get the details back on a given changelist for this fileobject

Parameters:changelist – changelist to get the info from if given
add(changelist=None)

add this fileobject into Perforce

Parameters:changelist – changelist to add the data to if given
delete(changelist=None)

mark the fileobject for delete from P4

Parameters:changelist – changelist to delete the data from if given
revert_all(changelist)

revert all changes in a given changelist

Parameters:changelist – changelist to revert
push_file(changelist=None)

This is a wrap over checkout and add, if the file already exists in P4 then we check it out, if it’s a new file that doesn’t exist then we mark it for add

Parameters:changelist – changelist to add the fileobject to if given
class r9File(path=None)

Bases: pymel.util.path.path

Red9 file handler system, bound to OS calls directly by inheritance from pm.util.path which then exposes all OS calls directly to the class instance.

This also binds Perforce to the class is Perforce was found on your system, exposing and binding all perforce commands directly to this file object

>>> from Red9.pro_pack import r9pro
>>> r9pro.r9import('r9ie')
>>> import r9ie
>>> 
>>> myfile=r9ie.r9File(myfilepath)
>>> myfile.sourcecontrol.fstat
>>> 
>>> # bescause we bind os we can also directly run os/path calls
>>> myfile.exists()
>>> myfile.splitext()

Note

when dealing with P4 the P4_SourceControl class is bound to self as self.sourcecontrol, exposing all the calls directly.

Parameters:path – Only takes one args and that’s the filepath to convert to a file object
explore()

open up the native OS directory to explore

formatPath()

take the given path and format it for Maya path ‘/’

open_osNative()

open the file in the native OS application

open_mayafile()

open maya file files.i n batch mode opens in current maya session, not in batch mode it prompt a message box to choose between open in current session or in a new maya session

joinpath(first, *others)

override of joint path to always return a Maya format path not an os path (‘/’ not ‘’)

force_makedirs()

for the internal path ensure that the folder structure exists if not create it

copy_makedirs(dest)

copy a file to a folder and if that folder, or folder structure does not exist, recursively create it with makedirs before the file copy

Parameters:dest – destination path to copy the data too

Note

the dest can be either a folder or a full path, if it’s just a folder the file will be copied with the same name, if it’s a full path then the file copy will rename the file accordingly

makedirs uses id:0755 in folder creation

copy_to_sourcecontrol(dest, changelist=None, ignore_deleted=True)

This is a wrap over the sourcecontrol/Perforce handler, designed to allow you, in one go, to push a file into the repository.

Parameters:
  • src – source file path
  • dest – destination filepath
  • changelist – optional changelist to add it too
  • changelist_txt – text for the changelist

ignore_deleted: if the file was previously marked for delete or deleted ignore it

It will:
  • locally create all folder structures as required
  • sync the dest file if it exists in the repository and isn’t in your workspace
  • check the dest file out
  • copy the src file to the given dest path
  • if the file is not in the repository it will mark it for add