示例#1
0
    def test_next_version(self, exists, glob, mock_open):
        """Retrieve the next version to publish."""
        asset = Asset('TestProject', 'AssetName', 'AssetKind')

        # No version exists yet
        self.assertEqual(0, len(asset.versions))

        self.assertEqual(Paths.asset_published(project=asset.project.name,
                                               name=asset.name,
                                               kind=asset.kind,
                                               version='{0:0>{padding}}'.format(1, padding=config.padding),
                                               ext=config.maya_ext),
                         asset.next_version.path)

        # Next Version is 12th Version
        exists.return_value = True
        glob.return_value = [Paths.asset_published(project=asset.project.name,
                                                   name=asset.name, kind=asset.kind,
                                                   version='{0:0>{padding}}'.format(i, padding=config.padding),
                                                   ext=config.maya_ext) for i in range(1, 12)]
        self.assertEqual(Paths.asset_published(project=asset.project.name,
                                               name=asset.name,
                                               kind=asset.kind,
                                               version='{0:0>{padding}}'.format(12, padding=config.padding),
                                               ext=config.maya_ext),
                         asset.next_version.path)
示例#2
0
    def test_get(self):
        """Get various paths."""
        regex = re.compile(r'\{(.*?)\}')
        for name, pattern in config.patterns.items():
            kwargs = {p: 'REPLACED' for p in regex.findall(pattern) if 'version' not in p}
            kwargs['version'] = 1
            path = getattr(Paths, name)(**kwargs)
            self.assertTrue(path.startswith(config.root))
            self.assertGreaterEqual(path.count('REPLACED'), len(kwargs.keys())-1)
        # end for

        with self.assertRaises(AttributeError):
            Paths.does_not_exist(var='a')
示例#3
0
 def workfiles(self):
     """All work files of this Asset."""
     path = Paths.step(project=self.project.name,
                       name=self.name,
                       kind=self.kind,
                       step='work')
     if not os.path.exists(path):
         return list()
     else:
         pattern = Paths.asset_work(project=self.project.name,
                                    name=self.name,
                                    kind=self.kind,
                                    version='*',
                                    ext=config.maya_ext)
         return [AssetFile(f) for f in sorted(glob.glob(pattern))]
示例#4
0
    def test_asset_file(self, exists, mock_open):
        """AssetFile contains the path, notes and path to the notes."""
        path = Paths.asset_published(project='TestProject',
                                     name='AssetName',
                                     kind='AssetKind',
                                     version='{0:0>{padding}}'.format(12, padding=config.padding),
                                     ext=config.maya_ext)
        notes_file = Paths.notes(path=os.path.dirname(path),
                                      filename=os.path.basename(path))

        af = AssetFile(path)
        self.assertEqual(path, af.path)
        self.assertEqual('Some Notes', af.notes)
        self.assertEqual(notes_file, af.notes_file)
        self.assertIn(path, str(af))
        self.assertIn('Some Notes', str(af))
示例#5
0
def main(project):
    py_path = Paths.program(project=project, program=project)
    ProjectCreator.create_path(py_path)
    with open(os.path.join(py_path, '__init__.py'), 'w'):
        pass
    with open(os.path.join(py_path, '{}.py'.format(project)), 'w'):
        pass

    tests = Paths.program(project=project, program='tests')
    ProjectCreator.create_path(tests)
    with open(os.path.join(tests, '__init__.py'), 'w'):
        pass

    with open(os.path.join(Paths.project(project=project), 'requirements.txt'),
              'w'):
        pass
示例#6
0
 def all_projects():
     """Find all available projects."""
     projects = list()
     for name in os.listdir(config.root):
         if os.path.exists(Paths.project_config(project=name)):
             projects.append(Project(name))
         # end if
     # end for
     return projects
示例#7
0
 def next_version(self):
     """The next publish file of this Asset."""
     next_version = '{0:0>{padding}}'.format(len(self.versions) + 1,
                                             padding=config.padding)
     return AssetFile(
         Paths.asset_published(project=self.project.name,
                               name=self.name,
                               kind=self.kind,
                               version=next_version,
                               ext=config.maya_ext))
示例#8
0
 def latest_version(self):
     """The latest_version published file of this Asset."""
     filepath = Paths.asset_latest(project=self.project.name,
                                   name=self.name,
                                   kind=self.kind,
                                   ext=config.maya_ext)
     if not os.path.exists(filepath):
         return AssetFile(filepath)
     else:
         return AssetFile(filepath)
示例#9
0
 def __init__(self, path):
     """Retrieve the notes corresponding to this file."""
     super(AssetFile, self).__init__()
     self.path = path
     self.notes = ''
     self.notes_file = Paths.notes(path=os.path.dirname(path),
                                   filename=os.path.basename(path))
     # Get the notes from file if possible
     if os.path.exists(self.notes_file):
         with open(self.notes_file, 'r') as notes:
             self.notes = notes.read()
示例#10
0
    def test_versions(self, exists, glob, mock_open):
        """Retrieve all published versions."""
        asset = Asset('TestProject', 'AssetName', 'AssetKind')

        self.assertEqual(0, len(asset.versions))

        # 12 Versions exist
        exists.return_value = True
        glob.return_value = [Paths.asset_published(project=asset.project.name,
                                                   name=asset.name, kind=asset.kind,
                                                   version='{0:0>{padding}}'.format(i, padding=config.padding),
                                                   ext=config.maya_ext) for i in range(1, 13)]
        self.assertEqual(12, len(asset.versions))
示例#11
0
    def create(name, description='', template='base'):
        """Create a new Project on disc."""
        if template not in ProjectCreator.templates():
            raise Exception('Invalid project template.')
        # end if
        path = Paths.project(project=name)
        if not os.path.exists(path):
            os.makedirs(path)
        else:
            raise Exception('Project already exists.')
        # end if

        # The config file
        data = dict(description=description, template=template)
        with open(Paths.project_config(project=name), 'w') as cfg:
            json.dump(data, cfg, indent=4)
        # end with

        # Create the other bootstrap folders, based on the given template
        template = importlib.import_module(
            'project_templates.{0}'.format(template))
        template.main(name)
        return True
示例#12
0
    def __init__(self, name):
        """Initialize the Project by the given name.

        Add the information from the config file, if possible.
        Args:
            name (str): The (unique) name of the project
        """
        super(Project, self).__init__()
        self.name = name
        self.description = ''
        self.template = ''

        project_config = Paths.project_config(project=name)
        if os.path.exists(project_config):
            with open(project_config, 'r') as cfg:
                for attr, value in json.load(cfg).items():
                    setattr(self, attr, value)
示例#13
0
 def update_path(self, text):
     """Update the path display."""
     self.path_lbl.setText(Paths.project(project=text))
示例#14
0
def main(project):
    base.main(project)

    maya = Paths.maya(project=project)
    ProjectCreator.create_path(maya)

    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='cache'))
    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='data'))
    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='images'))
    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='renderData'))
    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='scenes'))
    ProjectCreator.create_path(
        Paths.maya_subfolder(project=project, folder='sourceimages'))

    with open(os.path.join(maya, 'workspace.mel'), 'w') as workspace:
        workspace.write("""
workspace -fr "fluidCache" "cache/nCache/fluid";
workspace -fr "JT_DC" "data";
workspace -fr "images" "images";
workspace -fr "CATIAV4_DC" "data";
workspace -fr "offlineEdit" "scenes/edits";
workspace -fr "STEP_DC" "data";
workspace -fr "furShadowMap" "renderData/fur/furShadowMap";
workspace -fr "SPF_DCE" "data";
workspace -fr "scripts" "scripts";
workspace -fr "CATIAV5_DC" "data";
workspace -fr "DAE_FBX" "data";
workspace -fr "shaders" "renderData/shaders";
workspace -fr "furFiles" "renderData/fur/furFiles";
workspace -fr "OBJ" "data";
workspace -fr "FBX export" "data";
workspace -fr "furEqualMap" "renderData/fur/furEqualMap";
workspace -fr "Autodesk Packet File" "data";
workspace -fr "DAE_FBX export" "data";
workspace -fr "SPF_DC" "data";
workspace -fr "movie" "movies";
workspace -fr "DXF_DCE" "data";
workspace -fr "move" "data";
workspace -fr "mayaAscii" "scenes";
workspace -fr "autoSave" "autosave";
workspace -fr "sound" "sound";
workspace -fr "mayaBinary" "scenes";
workspace -fr "ZPR_DCE" "data";
workspace -fr "STL_DCE" "data";
workspace -fr "iprImages" "renderData/iprImages";
workspace -fr "studioImport" "data";
workspace -fr "FBX" "data";
workspace -fr "DXF_DC" "data";
workspace -fr "UG_DCE" "data";
workspace -fr "renderData" "renderData";
workspace -fr "fileCache" "cache/nCache";
workspace -fr "eps" "data";
workspace -fr "3dPaintTextures" "sourceimages/3dPaintTextures";
workspace -fr "mel" "scripts";
workspace -fr "translatorData" "data";
workspace -fr "particles" "cache/particles";
workspace -fr "IV_DC" "data";
workspace -fr "scene" "scenes";
workspace -fr "DWG_DCE" "data";
workspace -fr "sourceImages" "sourceimages";
workspace -fr "clips" "clips";
workspace -fr "furImages" "renderData/fur/furImages";
workspace -fr "PTC_DC" "data";
workspace -fr "STL_DC" "data";
workspace -fr "IPT_DC" "data";
workspace -fr "CSB_DC" "data";
workspace -fr "SW_DC" "data";
workspace -fr "depth" "renderData/depth";
workspace -fr "audio" "sound";
workspace -fr "DWG_DC" "data";
workspace -fr "bifrostCache" "cache/bifrost";
workspace -fr "IGES_DCE" "data";
workspace -fr "Alembic" "data";
workspace -fr "illustrator" "data";
workspace -fr "diskCache" "data";
workspace -fr "UG_DC" "data";
workspace -fr "templates" "assets";
workspace -fr "OBJexport" "data";
workspace -fr "furAttrMap" "renderData/fur/furAttrMap";
workspace -fr "IGES_DC" "data";
                        """)
示例#15
0
 def test_version_padding(self):
     """Make the padding dynamic."""
     config.patterns['test'] = '{version:0>{padding}}'
     config.padding = 4
     self.assertTrue(Paths.test(padding=4, version=1).endswith('0001'))
示例#16
0
def main(project):
    ProjectCreator.create_path(Paths.unsorted(project=project))