Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import factory
from publish import config as config_module, publishing
class PublishFactory(factory.Factory):
class Meta:
strategy = factory.BUILD_STRATEGY
class ConfigFactory(PublishFactory):
path = pathlib.Path(__file__).parent / 'configs' / 'basic.toml'
class Meta:
model = config_module.Config
class RepoFactory(PublishFactory):
config = factory.SubFactory(ConfigFactory)
name = factory.Faker('slug')
git_repo_url = factory.Faker('url')
secret = factory.Faker('pystr', min_chars=20, max_chars=20)
class Meta:
model = publishing.GenericRepo
class GithubRepoFactory(RepoFactory):
class Meta:
model = publishing.GithubRepo
def commit(self, path, family):
"""Move to timestamped destination relative workspace"""
date = time.strftime(publish.config.date_format)
workspace_dir = cmds.workspace(rootDirectory=True, query=True)
if not workspace_dir:
# Project has not been set. Files will
# instead end up next to the working file.
workspace_dir = cmds.workspace(dir=True, query=True)
published_dir = os.path.join(workspace_dir,
publish.config.prefix,
family)
commit_dir = os.path.join(published_dir, date)
shutil.copytree(path, commit_dir)
return commit_dir
def commit(self, path, family):
"""Move to timestamped destination relative workspace"""
date = time.strftime(publish.config.date_format)
workspace_dir = cmds.workspace(rootDirectory=True, query=True)
if not workspace_dir:
# Project has not been set. Files will
# instead end up next to the working file.
workspace_dir = cmds.workspace(dir=True, query=True)
published_dir = os.path.join(workspace_dir,
publish.config.prefix,
family)
commit_dir = os.path.join(published_dir, date)
shutil.copytree(path, commit_dir)
return commit_dir
def commit(self, path, family):
"""Move to timestamped destination relative workspace"""
date = time.strftime(publish.config.date_format)
workspace_dir = cmds.workspace(rootDirectory=True, query=True)
if not workspace_dir:
# Project has not been set. Files will
# instead end up next to the working file.
workspace_dir = cmds.workspace(dir=True, query=True)
published_dir = os.path.join(workspace_dir,
publish.config.prefix,
family)
commit_dir = os.path.join(published_dir, date)
shutil.copytree(path, commit_dir)
return commit_dir
def process(self, context):
for objset in cmds.ls("*." + publish.config.identifier,
objectsOnly=True,
type='objectSet'):
instance = publish.domain.Instance(name=objset)
self.log.info("Adding instance: {0}".format(objset))
for node in cmds.sets(objset, query=True):
if cmds.nodeType(node) == 'transform':
descendents = cmds.listRelatives(node,
allDescendents=True)
for descendent in descendents:
instance.add(descendent)
else:
instance.add(node)
attrs = cmds.listAttr(objset, userDefined=True)