File: DataSetAttr.py

package info (click to toggle)
pyvtk 0.4.74-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 284 kB
  • ctags: 354
  • sloc: python: 2,073; makefile: 71; sh: 1
file content (55 lines) | stat: -rw-r--r-- 1,618 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""
DataSetAttr
"""
"""

Copyright 2001 Pearu Peterson all rights reserved,
Pearu Peterson <pearu@ioc.ee>          
Permission to use, modify, and distribute this software is given under the
terms of the LGPL.  See http://www.fsf.org

NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
$Revision: 1.2 $
$Date: 2001-05-31 17:48:54 $
Pearu Peterson
"""

__version__ = "$Id: DataSetAttr.py,v 1.2 2001-05-31 17:48:54 pearu Exp $"

import common

class DataSetAttr(common.Common):
    """Abstract class for VTK data."""
    counters = {}
    default_value = 0
    def _get_default_name(self):
        n = self.__class__.__name__
        try:
            self.counters[n] += 1
        except KeyError:
            self.counters[n] = 0
        return self.__class__.__name__+str(self.counters[n])
    def _get_name(self,name):
        if name is None:
            name = self._get_default_name()
            self.warning('Using name=%s'%(`name`))
            return name
        if common.is_string(name):
            name = name.strip().replace(' ','_')
            if name:
                return name
        raise ValueError,'name=%s must be non-empty string'%(`name`)
    def _get_lookup_table(self,name):
        if name is None:
            name = 'default'
            self.warning('Using lookup_table=%s'%(`name`))
            return name
        if common.is_string(name):
            name = name.strip().replace(' ','_')
            if name:
                return name
        raise ValueError,'lookup_table=%s must be nonempty string'%(`name`)

if __name__ == "__main__":
    pass