Skip to content

Commit

Permalink
removed deprecated Asset name in favour of CGAsset
Browse files Browse the repository at this point in the history
renamed `AssetFile` to `CGAssetFile`
  • Loading branch information
chrizzFTD committed May 6, 2019
1 parent ef060c5 commit 16ff89a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 166 deletions.
17 changes: 0 additions & 17 deletions docs/source/Asset.rst

This file was deleted.

17 changes: 0 additions & 17 deletions docs/source/AssetFile.rst

This file was deleted.

17 changes: 17 additions & 0 deletions docs/source/CGAssetFile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CGAssetFile
===========

.. toctree::
:maxdepth: 4

.. container:: toggle

.. container:: header

Inheritance Diagram for grill.names.CGAssetFile

|
.. inheritance-diagram:: grill.names.CGAssetFile

|
.. autoclass:: grill.names.CGAssetFile
3 changes: 1 addition & 2 deletions docs/source/Class List.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ Class List
.. toctree::
:maxdepth: 4

Asset
AssetFile
CGAsset
CGAssetFile
Environment
LifeTR
Primitive
Expand Down
129 changes: 24 additions & 105 deletions grill/names/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from naming import Name, File, Pipe, PipeFile, BaseName
import naming
from grill.tokens import ids


Expand Down Expand Up @@ -33,7 +33,7 @@ def _table_from_id(id_mapping):
return '\n'.join(format_rows)


class Project(Name):
class Project(naming.Name):
"""Inherited by: :class:`grill.names.Environment`
Project Name objects.
Expand All @@ -45,12 +45,6 @@ class Project(Name):
*workarea* Any amount of word characters
========== ==========
=========== ==
**Drops:**
--------------
*base*
==============
Basic use::
>>> from grill.names import Project
Expand All @@ -67,7 +61,6 @@ class Project(Name):
'test_rigging'
"""
config = dict(project='[a-zA-Z0-9]+', workarea='\w+')
drops = 'base',

def __init__(self, *args, sep='_', **kwargs):
super().__init__(*args, sep=sep, **kwargs)
Expand Down Expand Up @@ -111,8 +104,7 @@ def get_path_pattern_list(self):


class Primitive(Environment):
"""Inherited by: :class:`grill.names.Asset`
"""
For primitive names with multiple stages of development.
======= ================
Expand All @@ -139,131 +131,58 @@ class Primitive(Environment):
config = dict(prim='[a-zA-Z0-9]+', stage='[a-z0-9]+')


class Asset(Primitive):
"""Inherited by: :class:`grill.names.AssetFile`
class CGAsset(naming.Name):
"""
Elemental resources that, when composed, generate the entities that bring an idea to a tangible product
through their life cycles (e.g. a character, a film, a videogame).
=========== ============
**Config:**
------------------------
*kind* Any lowercase letter
*group* Accepts 3 characters in the class [a-z0-9]
*area* Any amount of characters in the class [a-zA-Z0-9]
*variant* Any amount of word characters
*partition* Any amount of characters in the class [a-zA-Z0-9]
*layer* Any amount of characters in the class [a-zA-Z0-9]
=========== ============
========== ====
**Compounds:**
---------------
*workarea* kind, group, area
========== ====
Basic use::
>>> from grill.names import Asset
>>> a = Asset()
>>> a.get_name()
'[project]_[workarea]_[prim]_[stage]_[variant]_[partition]_[layer]'
>>> a = Asset.get_default(prim='hero')
>>> a.name
'envcode_kgrparea_hero_stage_original_master_default'
"""
config = dict(kind='[a-z]',
group='[a-z0-9]{3}',
area='[a-z0-9]+',
variant='\w+',
partition='[a-zA-Z0-9]+',
layer='[a-zA-Z0-9]+')
compounds = dict(workarea=('kind', 'group', 'area'))

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._branch = 'pro'
config = {k: v['pattern'] for k, v in ids.CGAsset.items()}
__doc__ += '\n' + _table_from_id(ids.CGAsset) + '\n'

def get_path_pattern_list(self):
pattern = super().get_path_pattern_list()
wa_i = pattern.index('workarea')
new_p = pattern[:wa_i]
new_p.extend(['branch', 'kind', 'group', 'prim', 'area', 'stage'])
new_p.extend(pattern[wa_i + 1:])
new_p.extend(['variant', 'partition', 'layer'])
return new_p
def __init__(self, *args, sep='-', **kwargs):
super().__init__(*args, sep=sep, **kwargs)

@property
def branch(self) -> str:
"""The branch in the production of the project (pro, dev, test, etc)"""
return self._branch

@branch.setter
def branch(self, value):
self._branch = value
def _defaults(self):
return {k: v['default'] for k, v in ids.CGAsset.items()}

@classmethod
def get_default(cls, **kwargs) -> Asset:
"""Get a new Name object with default values and optional field names from **kwargs."""
def get_default(cls, **kwargs) -> CGAsset:
"""Get a new Name object with default values and overrides from **kwargs."""
name = cls()
defaults = dict(name._defaults, **kwargs)
name.name = name.get_name(**defaults)
return name

@property
def _defaults(self):
return dict(project='envcode', workarea='kgrparea', prim='prim', stage='stage', variant='original',
partition='master', layer='default')


class AssetFile(Asset, PipeFile):
"""Versioned files in the pipeline for an asset.
class CGAssetFile(CGAsset, naming.PipeFile):
"""Versioned files in the pipeline for a CGAsset.
Basic use::
>>> from grill.names import AssetFile
>>> a = Asset.get_default()
>>> a.suffix
>>> from grill.names import CGAssetFile
>>> name = CGAssetFile.get_default(version=7)
>>> name.suffix
'ext'
>>> a.suffix = 'abc'
>>> a.path
WindowsPath('code/env/pro/k/grp/prim/area/stage/original/master/default/0/envcode_kgrparea_prim_stage_original_master_default.0.abc')
>>> name.suffix = 'abc'
>>> name.path
WindowsPath('demo/3d/abc/entity/rnd/master/atom/main/all/whole/7/demo-3d-abc-entity-rnd-master-atom-main-all-whole.7.abc')
"""

@property
def _defaults(self):
result = super()._defaults
result.update(version=0, suffix='ext')
result.update(version=1, suffix='ext')
return result

def get_path_pattern_list(self):
pattern = super().get_path_pattern_list()
pattern = super().get_pattern_list()
pattern.append('version')
return pattern


class CGAsset(BaseName):
"""
Elemental resources that, when composed, generate the entities that bring an idea to a tangible product
through their life cycles (e.g. a character, a film, a videogame).
"""
config = {k: v['pattern'] for k, v in ids.CGAsset.items()}
__doc__ += '\n' + _table_from_id(ids.CGAsset) + '\n'

def __init__(self, *args, sep='-', **kwargs):
super().__init__(*args, sep=sep, **kwargs)

@classmethod
def get_default(cls, **kwargs) -> CGAsset:
"""Get a new Name object with default values and overrides from **kwargs."""
name = cls()
defaults = dict({k: v['default'] for k, v in ids.CGAsset.items()}, **kwargs)
name.name = name.get_name(**defaults)
return name


class LifeTR(BaseName):
class LifeTR(naming.Name):
"""Taxonomic Rank used for biological classification.
"""
Expand Down
40 changes: 15 additions & 25 deletions grill/names/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,26 @@ def test_audiovisual(self):
name.name = name.get_name(**_get_primitive_kwargs())
self.assertEqual('tstabc_current_hero_concept', name.name)

def test_asset(self):
name = AssetFile()
name.name = name.get_name(**_get_assetfile_kwargs())
def test_cgasset_file(self):
name = CGAssetFile().get_default()
name.name = name.get_name(area='model')
self.assertEqual(name.workarea, 'schrmodel')
path = Path.joinpath(Path(), 'abc', 'tst', 'pro', 's', 'chr', 'hero', 'model', 'concept', 'original', 'master',
'default', '0', 'tstabc_schrmodel_hero_concept_original_master_default.0.ext')
self.assertEqual(name.area, 'model')
path = Path.joinpath(
Path(),
'demo', '3d', 'abc', 'entity', 'model', 'master', 'atom', 'main', 'all',
'whole', '1', 'demo-3d-abc-entity-model-master-atom-main-all-whole.1.ext'
)
self.assertEqual(Path(path), name.path)
name.sep = '-'
self.assertEqual('-', name.sep)
self.assertEqual('tstabc-schrmodel-hero-concept-original-master-default.0.ext', name.get_name())
name.sep = ':'
self.assertEqual(':', name.sep)
self.assertEqual('demo:3d:abc:entity:model:master:atom:main:all:whole.1.ext', name.get_name())
name.sep = '.'
self.assertEqual(name.sep, '.')
self.assertEqual('tstabc.schrmodel.hero.concept.original.master.default.0.ext', name.get_name())
self.assertEqual('demo.3d.abc.entity.model.master.atom.main.all.whole.1.ext', name.get_name())
name.sep = ' '
name.name = name.get_name(area='rig')
self.assertEqual('schrrig', name.workarea)
self.assertEqual(' ', name.sep)
self.assertEqual('tstabc schrrig hero concept original master default.0.ext', name.get_name())
name.sep = '_'
name.branch = 'dev'
path = Path.joinpath(Path(), 'abc', 'tst', 'dev', 's', 'chr', 'hero', 'rig', 'concept', 'original', 'master',
'default', '0', 'tstabc_schrrig_hero_concept_original_master_default.0.ext')
self.assertEqual(Path(path), name.path)

def test_asset_default(self):
name = Asset.get_default(prim='hero')
self.assertEqual(name.name, 'envcode_kgrparea_hero_stage_original_master_default')
name = AssetFile.get_default()
self.assertEqual(name.name, 'envcode_kgrparea_prim_stage_original_master_default.0.ext')
name.name = name.get_name(area='rig', part='leg', output='skin', branch='dev')
self.assertEqual('rig', name.area)
self.assertEqual('demo 3d abc entity rig dev atom main all leg.skin.1.ext', name.get_name())

def test_cgasset(self):
self.assertEqual(CGAsset().get_name(),
Expand Down

0 comments on commit 16ff89a

Please sign in to comment.