File: __init__.py

package info (click to toggle)
paraview 5.4.1+dfsg4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 218,616 kB
  • sloc: cpp: 2,331,508; ansic: 322,365; python: 111,051; xml: 79,203; tcl: 47,013; yacc: 4,877; java: 4,438; perl: 3,238; sh: 2,920; lex: 1,908; f90: 748; makefile: 273; pascal: 228; objc: 83; fortran: 31
file content (159 lines) | stat: -rw-r--r-- 5,318 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
r"""
The paraview package provides modules used to script ParaView. Generally, users
should import the modules of interest directly e.g.::

  from paraview.simple import *

However, one may want to import paraview package before importing any of the
ParaView modules to force backwards compatibility to an older version::

  # To run scripts written for ParaView 4.0 in newer versions, you can use the
  # following.
  import paraview
  paraview.compatibility.major = 4
  paraview.compatibility.minor = 0

  # Now, import the modules of interest.
  from paraview.simple import *
"""

import sys
sys.path.append('/usr/lib/python2.7/dist-packages/paraview')


#==============================================================================
#
#  Program:   ParaView
#  Module:    __init__.py
#
#  Copyright (c) Kitware, Inc.
#  All rights reserved.
#  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
#
#     This software is distributed WITHOUT ANY WARRANTY; without even
#     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#     PURPOSE.  See the above copyright notice for more information.
#
#==============================================================================

class _version(object):
    def __init__(self, major, minor):
      self.major = major
      self.minor = minor
    def GetVersion(self):
        """Return version as a float. Will return None is no version is
        specified."""
        if self.minor != None and self.major != None:
            version = float(self.minor)
            while version >= 1.0:
                version = version / 10.0
            version += float(self.major)
            return version
        return None
    def __lt__(self, other):
        """This will always return False if compatibility is not being forced
        to a particular version."""
        myversion = self.GetVersion()
        if not myversion:
            return False
        else:
            return myversion < other
    def __le__(self, other):
        """This will always return False if compatibility is not forced to a
        particular version."""
        myversion = self.GetVersion()
        if not myversion:
            return False
        else:
            return myversion <= other
    def __eq__(self, other):
        raise RuntimeError("Equal operation not supported.")
    def __ne__(self, other):
        raise RuntimeError("NotEqual operation not supported.")
    def __gt__(self, other):
        """This will always return True if compatibility is not being forced to
        a particular version"""
        myversion = self.GetVersion()
        if not myversion:
            return True
        else:
            return myversion > other
    def __ge__(self, other):
        """This will always return True if compatibility is not being forced to
        a particular version"""
        myversion = self.GetVersion()
        if not myversion:
            return True
        else:
            return myversion >= other
    def __repr__(self):
        myversion = self.GetVersion()
        if not myversion:
          return "(none)"
        return str(myversion)

class compatibility:
    """Class used to check version number and compatibility. Users should only
    set the compatibility explicitly to force backwards compatibility to and
    older versions.
    """
    minor = None
    major = None

    def GetVersion(cls):
        return _version(cls.major, cls.minor)
    GetVersion = classmethod(GetVersion)

# This is reimplemented in vtkSMCoreUtilities::SanitizeName(). Keep both
# implementations consistent.
def make_name_valid(name):
    """Make a string into a valid Python variable name."""
    if not name:
        return None
    import string
    valid_chars = "_%s%s" % (string.ascii_letters, string.digits)
    name = str().join([c for c in name if c in valid_chars])
    if name and not name[0].isalpha():
        name = 'a' + name
    return name

class options:
    """Values set here have any effect, only when importing the paraview module
       in python interpretor directly i.e. not through pvpython or pvbatch. In
       that case, one should use command line arguments for the two
       executables"""

    """When True, act as pvbatch. Default behaviour is to act like pvpython"""
    batch = False

    """When True, acts like pvbatch --symmetric. Requires that batch is set to
    True to have any effect."""
    symmetric = False

    """When True, `paraview.print_debug_info()` will result in printing the
    debug messages to stdout. Default is False, hence all debug messages will be
    suppressed."""
    print_debug_messages = False

    """When True, This mean the current process is a satelite and should not try to
    connect or do anything else."""
    satelite = False

def print_warning(text):
   """Print text"""
   print(text)

def print_error(text):
   """Print text"""
   print(text)

def print_debug_info(text):
   """Print text"""
   if options.print_debug_messages:
       print(text)

"""This variable is set whenever Python is initialized within a ParaView
Qt-based application. Modules within the 'paraview' package often use this to
taylor their behaviour based on whether the Python environment is embedded
within an application or not."""
fromGUI = False