This file is indexed.

/usr/lib/python2.7/dist-packages/PyTango/encoded_attribute.py is in python-pytango 8.1.1-1build3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# ------------------------------------------------------------------------------
# This file is part of PyTango (http://www.tinyurl.com/PyTango)
#
# Copyright 2006-2012 CELLS / ALBA Synchrotron, Bellaterra, Spain
# Copyright 2013-2014 European Synchrotron Radiation Facility, Grenoble, France
#
# Distributed under the terms of the GNU Lesser General Public License,
# either version 3 of the License, or (at your option) any later version.
# See LICENSE.txt for more info.
# ------------------------------------------------------------------------------

"""
This is an internal PyTango module.
"""

__all__ = ["encoded_attribute_init"]

__docformat__ = "restructuredtext"

import collections

from ._PyTango import EncodedAttribute, ExtractAs, _ImageFormat
from ._PyTango import constants

from .utils import is_pure_str, is_seq

if constants.NUMPY_SUPPORT:
    try:
        import numpy
        np = numpy
    except:
        np = None
else:
    np = None

_allowed_extract = ExtractAs.Numpy, ExtractAs.String, ExtractAs.Tuple, \
                   ExtractAs.List

def __EncodedAttribute_encode_jpeg_gray8(self, gray8, width=0, height=0, quality=100.0):
    """Encode a 8 bit grayscale image as JPEG format
    
           :param gray8: an object containning image information
           :type gray8: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if gray8 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 2.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if gray8 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 2.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
           :param quality: Quality of JPEG (0=poor quality 100=max quality) (default is 100.0)
           :type quality: :py:obj:`float`
           
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - gray8 **MUST** be CONTIGUOUS, ALIGNED
               - if gray8.ndims != 2, width and height **MUST** be given and
                 gray8.nbytes **MUST** match width*height
               - if gray8.ndims == 2, gray8.itemsize **MUST** be 1 (typically,
                 gray8.dtype is one of `numpy.dtype.byte`, `numpy.dtype.ubyte`,
                 `numpy.dtype.int8` or `numpy.dtype.uint8`)
    
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               data = numpy.arange(100, dtype=numpy.byte)
               data = numpy.array((data,data,data))
               enc.encode_jpeg_gray8(data)
               attr.set_value(enc)
    """
    self._generic_encode_gray8(gray8, width=width, height=height, quality=quality, format=_ImageFormat.JpegImage)

def __EncodedAttribute_encode_gray8(self, gray8, width=0, height=0):
    """Encode a 8 bit grayscale image (no compression)
    
           :param gray8: an object containning image information
           :type gray8: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if gray8 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 2.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if gray8 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 2.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
           
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - gray8 **MUST** be CONTIGUOUS, ALIGNED
               - if gray8.ndims != 2, width and height **MUST** be given and
                 gray8.nbytes **MUST** match width*height
               - if gray8.ndims == 2, gray8.itemsize **MUST** be 1 (typically,
                 gray8.dtype is one of `numpy.dtype.byte`, `numpy.dtype.ubyte`,
                 `numpy.dtype.int8` or `numpy.dtype.uint8`)
    
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               data = numpy.arange(100, dtype=numpy.byte)
               data = numpy.array((data,data,data))
               enc.encode_gray8(data)
               attr.set_value(enc)
    """
    self._generic_encode_gray8(gray8, width=width, height=height, format=_ImageFormat.RawImage)

def __EncodedAttribute_generic_encode_gray8(self, gray8, width=0, height=0, quality=0, format=_ImageFormat.RawImage):
    """Internal usage only"""
    if not is_seq(gray8):
        raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                        "or bytearray) as first argument")

    is_str = is_pure_str(gray8)
    if is_str:
        if not width or not height:
            raise ValueError("When giving a string as data, you must also "
                             "supply width and height")

    if np and isinstance(gray8, np.ndarray):
        if gray8.ndim != 2:
            if not width or not height:
                raise ValueError("When giving a non 2D numpy array, width and "
                                 "height must be supplied")
            if gray8.nbytes != width * height:
                raise ValueError("numpy array size mismatch")
        else:
            if gray8.itemsize != 1:
                raise TypeError("Expected numpy array with itemsize == 1")
        if gray8.flags.c_contiguous != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")
        if gray8.flags.aligned != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")

    if not is_str and (not width or not height):
        height = len(gray8)
        if height < 1:
            raise IndexError("Expected sequence with at least one row")

        row0 = gray8[0]
        if not is_seq(row0):
            raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                             "bytearray) inside a sequence")
        width = len(row0)

    if format == _ImageFormat.RawImage:
        self._encode_gray8(gray8, width, height)
    elif format == _ImageFormat.JpegImage:
        self._encode_jpeg_gray8(gray8, width, height, quality)

def __EncodedAttribute_encode_gray16(self, gray16, width=0, height=0):
    """Encode a 16 bit grayscale image (no compression)
    
           :param gray16: an object containning image information
           :type gray16: :py:obj:`str` or :py:obj:`buffer` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if gray16 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 2.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if gray16 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 2.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
    
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - gray16 **MUST** be CONTIGUOUS, ALIGNED
               - if gray16.ndims != 2, width and height **MUST** be given and
                 gray16.nbytes/2 **MUST** match width*height
               - if gray16.ndims == 2, gray16.itemsize **MUST** be 2 (typically,
                 gray16.dtype is one of `numpy.dtype.int16`, `numpy.dtype.uint16`,
                 `numpy.dtype.short` or `numpy.dtype.ushort`)
    
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               data = numpy.arange(100, dtype=numpy.int16)
               data = numpy.array((data,data,data))
               enc.encode_gray16(data)
               attr.set_value(enc)
    """
    if not is_seq(gray16):
        raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                        "or bytearray) as first argument")

    is_str = is_pure_str(gray16)
    if is_str:
        if not width or not height:
            raise ValueError("When giving a string as data, you must also "
                             "supply width and height")


    if np and isinstance(gray16, np.ndarray):
        if gray16.ndim != 2:
            if not width or not height:
                raise ValueError("When giving a non 2D numpy array, width and "
                                 "height must be supplied")
            if gray16.nbytes / 2 != width * height:
                raise ValueError("numpy array size mismatch")
        else:
            if gray16.itemsize != 2:
                raise TypeError("Expected numpy array with itemsize == 2")
        if gray16.flags.c_contiguous != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")
        if gray16.flags.aligned != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")

    if not is_str and (not width or not height):
        height = len(gray16)
        if height < 1:
            raise IndexError("Expected sequence with at least one row")

        row0 = gray16[0]
        if not is_seq(row0):
            raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                             "bytearray) inside a sequence")
        width = len(row0)
        if is_pure_str(row0) or type(row0) == bytearray:
            width /= 2

    self._encode_gray16(gray16, width, height)

def __EncodedAttribute_encode_jpeg_rgb24(self, rgb24, width=0, height=0, quality=100.0):
    """Encode a 24 bit rgb color image as JPEG format.
    
           :param rgb24: an object containning image information
           :type rgb24: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if rgb24 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 3.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if rgb24 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 3.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
           :param quality: Quality of JPEG (0=poor quality 100=max quality) (default is 100.0)
           :type quality: :py:obj:`float`
           
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - rgb24 **MUST** be CONTIGUOUS, ALIGNED
               - if rgb24.ndims != 3, width and height **MUST** be given and
                 rgb24.nbytes/3 **MUST** match width*height
               - if rgb24.ndims == 3, rgb24.itemsize **MUST** be 1 (typically,
                 rgb24.dtype is one of `numpy.dtype.byte`, `numpy.dtype.ubyte`,
                 `numpy.dtype.int8` or `numpy.dtype.uint8`) and shape **MUST** be
                 (height, width, 3)
       
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               # create an 'image' where each pixel is R=0x01, G=0x01, B=0x01
               arr = numpy.ones((10,10,3), dtype=numpy.uint8)
               enc.encode_jpeg_rgb24(data)
               attr.set_value(enc)
    """
    self._generic_encode_rgb24(rgb24, width=width, height=height, quality=quality, format=_ImageFormat.JpegImage)

def __EncodedAttribute_encode_rgb24(self, rgb24, width=0, height=0):
    """Encode a 24 bit color image (no compression)
    
           :param rgb24: an object containning image information
           :type rgb24: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if rgb24 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 3.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if rgb24 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 3.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
           
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - rgb24 **MUST** be CONTIGUOUS, ALIGNED
               - if rgb24.ndims != 3, width and height **MUST** be given and
                 rgb24.nbytes/3 **MUST** match width*height
               - if rgb24.ndims == 3, rgb24.itemsize **MUST** be 1 (typically,
                 rgb24.dtype is one of `numpy.dtype.byte`, `numpy.dtype.ubyte`,
                 `numpy.dtype.int8` or `numpy.dtype.uint8`) and shape **MUST** be
                 (height, width, 3)
       
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               # create an 'image' where each pixel is R=0x01, G=0x01, B=0x01
               arr = numpy.ones((10,10,3), dtype=numpy.uint8)
               enc.encode_rgb24(data)
               attr.set_value(enc)
    """
    self._generic_encode_rgb24(rgb24, width=width, height=height, format=_ImageFormat.RawImage)

def __EncodedAttribute_generic_encode_rgb24(self, rgb24, width=0, height=0, quality=0, format=_ImageFormat.RawImage):
    """Internal usage only"""
    if not is_seq(rgb24):
        raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                        "or bytearray) as first argument")

    is_str = is_pure_str(rgb24)
    if is_str:
        if not width or not height:
            raise ValueError("When giving a string as data, you must also "
                             "supply width and height")

    if np and isinstance(rgb24, np.ndarray):
        if rgb24.ndim != 3:
            if not width or not height:
                raise ValueError("When giving a non 2D numpy array, width and "
                                 "height must be supplied")
            if rgb24.nbytes / 3 != width * height:
                raise ValueError("numpy array size mismatch")
        else:
            if rgb24.itemsize != 1:
                raise TypeError("Expected numpy array with itemsize == 1")
        if rgb24.flags.c_contiguous != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")
        if rgb24.flags.aligned != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")

    if not is_str and (not width or not height):
        height = len(rgb24)
        if height < 1:
            raise IndexError("Expected sequence with at least one row")

        row0 = rgb24[0]
        if not is_seq(row0):
            raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                             "bytearray) inside a sequence")
        width = len(row0)
        if is_pure_str(row0) or type(row0) == bytearray:
            width /= 3
    if format == _ImageFormat.RawImage:
        self._encode_rgb24(rgb24, width, height)
    elif format == _ImageFormat.JpegImage:
        self._encode_jpeg_rgb24(rgb24, width, height, quality)

def __EncodedAttribute_encode_jpeg_rgb32(self, rgb32, width=0, height=0, quality=100.0):
    """Encode a 32 bit rgb color image as JPEG format.
    
           :param rgb32: an object containning image information
           :type rgb32: :py:obj:`str` or :class:`numpy.ndarray` or seq< seq<element> >
           :param width: image width. **MUST** be given if rgb32 is a string or
                         if it is a :class:`numpy.ndarray` with ndims != 2.
                         Otherwise it is calculated internally.
           :type width: :py:obj:`int`
           :param height: image height. **MUST** be given if rgb32 is a string
                          or if it is a :class:`numpy.ndarray` with ndims != 2.
                          Otherwise it is calculated internally.
           :type height: :py:obj:`int`
    
       .. note::
           When :class:`numpy.ndarray` is given:
        
               - rgb32 **MUST** be CONTIGUOUS, ALIGNED
               - if rgb32.ndims != 2, width and height **MUST** be given and
                 rgb32.nbytes/4 **MUST** match width*height
               - if rgb32.ndims == 2, rgb32.itemsize **MUST** be 4 (typically,
                 rgb32.dtype is one of `numpy.dtype.int32`, `numpy.dtype.uint32`)
    
       Example::
           
           def read_myattr(self, attr):
               enc = PyTango.EncodedAttribute()
               data = numpy.arange(100, dtype=numpy.int32)
               data = numpy.array((data,data,data))
               enc.encode_jpeg_rgb32(data)
               attr.set_value(enc)
    """
    if not is_seq(rgb32):
        raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
                        "or bytearray) as first argument")

    is_str = is_pure_str(rgb32)
    if is_str:
        if not width or not height:
            raise ValueError("When giving a string as data, you must also "
                             "supply width and height")

    if np and isinstance(rgb32, np.ndarray):
        if rgb32.ndim != 2:
            if not width or not height:
                raise ValueError("When giving a non 2D numpy array, width and "
                                 "height must be supplied")
            if rgb32.nbytes / 4 != width * height:
                raise ValueError("numpy array size mismatch")
        else:
            if rgb32.itemsize != 4:
                raise TypeError("Expected numpy array with itemsize == 4")
        if rgb32.flags.c_contiguous != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")
        if rgb32.flags.aligned != True:
            raise TypeError("Currently, only contiguous, aligned numpy arrays "
                            "are supported")

    if not is_str and (not width or not height):
        height = len(rgb32)
        if height < 1:
            raise IndexError("Expected sequence with at least one row")

        row0 = rgb32[0]
        if not is_seq(row0):
            raise IndexError("Expected sequence (str, numpy.ndarray, list, tuple or "
                             "bytearray) inside a sequence")
        width = len(row0)
        if is_pure_str(row0) or type(row0) == bytearray:
            width /= 4

    self._encode_jpeg_rgb32(rgb32, width, height, quality)


def __EncodedAttribute_decode_gray8(self, da, extract_as=ExtractAs.Numpy):
    """Decode a 8 bits grayscale image (JPEG_GRAY8 or GRAY8) and returns a 8 bits gray scale image.
    
        :param da: :class:`DeviceAttribute` that contains the image
        :type da: :class:`DeviceAttribute`
        :param extract_as: defaults to ExtractAs.Numpy
        :type extract_as: ExtractAs
        :return: the decoded data
        
        - In case String string is choosen as extract method, a tuple is returned:
            width<int>, height<int>, buffer<str>
        - In case Numpy is choosen as extract method, a :class:`numpy.ndarray` is
          returned with ndim=2, shape=(height, width) and dtype=numpy.uint8.
        - In case Tuple or List are choosen, a tuple<tuple<int>> or list<list<int>>
          is returned.
        
       .. warning::
           The PyTango calls that return a :class:`DeviceAttribute` 
           (like :meth:`DeviceProxy.read_attribute` or :meth:`DeviceProxy.command_inout`)
           automatically extract the contents by default. This method requires 
           that the given :class:`DeviceAttribute` is obtained from a 
           call which **DOESN'T** extract the contents. Example::
               
               dev = PyTango.DeviceProxy("a/b/c")
               da = dev.read_attribute("my_attr", extract_as=PyTango.ExtractAs.Nothing)
               enc = PyTango.EncodedAttribute()
               data = enc.decode_gray8(da)
    """
    if hasattr(da, 'value'):
        raise TypeError("DeviceAttribute argument must have been obtained from "
                        "a call which doesn't extract the contents")
    if extract_as not in _allowed_extract:
        raise TypeError("extract_as must be one of Numpy, String, Tuple, List")
    return self._decode_gray8(da, extract_as)

def __EncodedAttribute_decode_gray16(self, da, extract_as=ExtractAs.Numpy):
    """Decode a 16 bits grayscale image (GRAY16) and returns a 16 bits gray scale image.
    
        :param da: :class:`DeviceAttribute` that contains the image
        :type da: :class:`DeviceAttribute`
        :param extract_as: defaults to ExtractAs.Numpy
        :type extract_as: ExtractAs
        :return: the decoded data

        - In case String string is choosen as extract method, a tuple is returned:
            width<int>, height<int>, buffer<str>
        - In case Numpy is choosen as extract method, a :class:`numpy.ndarray` is
          returned with ndim=2, shape=(height, width) and dtype=numpy.uint16.
        - In case Tuple or List are choosen, a tuple<tuple<int>> or list<list<int>>
          is returned.

       .. warning::
           The PyTango calls that return a :class:`DeviceAttribute` 
           (like :meth:`DeviceProxy.read_attribute` or :meth:`DeviceProxy.command_inout`)
           automatically extract the contents by default. This method requires 
           that the given :class:`DeviceAttribute` is obtained from a 
           call which **DOESN'T** extract the contents. Example::
               
               dev = PyTango.DeviceProxy("a/b/c")
               da = dev.read_attribute("my_attr", extract_as=PyTango.ExtractAs.Nothing)
               enc = PyTango.EncodedAttribute()
               data = enc.decode_gray16(da)
    """
    if hasattr(da, 'value'):
        raise TypeError("DeviceAttribute argument must have been obtained from "
                        "a call which doesn't extract the contents")
    if extract_as not in _allowed_extract:
        raise TypeError("extract_as must be one of Numpy, String, Tuple, List")
    return self._decode_gray16(da, extract_as)

def __EncodedAttribute_decode_rgb32(self, da, extract_as=ExtractAs.Numpy):
    """Decode a color image (JPEG_RGB or RGB24) and returns a 32 bits RGB image.
    
        :param da: :class:`DeviceAttribute` that contains the image
        :type da: :class:`DeviceAttribute`
        :param extract_as: defaults to ExtractAs.Numpy
        :type extract_as: ExtractAs
        :return: the decoded data

        - In case String string is choosen as extract method, a tuple is returned:
            width<int>, height<int>, buffer<str>
        - In case Numpy is choosen as extract method, a :class:`numpy.ndarray` is
          returned with ndim=2, shape=(height, width) and dtype=numpy.uint32.
        - In case Tuple or List are choosen, a tuple<tuple<int>> or list<list<int>>
          is returned.
        
       .. warning::
           The PyTango calls that return a :class:`DeviceAttribute` 
           (like :meth:`DeviceProxy.read_attribute` or :meth:`DeviceProxy.command_inout`)
           automatically extract the contents by default. This method requires 
           that the given :class:`DeviceAttribute` is obtained from a 
           call which **DOESN'T** extract the contents. Example::
               
               dev = PyTango.DeviceProxy("a/b/c")
               da = dev.read_attribute("my_attr", extract_as=PyTango.ExtractAs.Nothing)
               enc = PyTango.EncodedAttribute()
               data = enc.decode_rgb32(da)
    """
    if hasattr(da, 'value'):
        raise TypeError("DeviceAttribute argument must have been obtained from "
                        "a call which doesn't extract the contents")
    if extract_as not in _allowed_extract:
        raise TypeError("extract_as must be one of Numpy, String, Tuple, List")
    return self._decode_rgb32(da, extract_as)

def __init_EncodedAttribute():
    EncodedAttribute._generic_encode_gray8 = __EncodedAttribute_generic_encode_gray8
    EncodedAttribute.encode_gray8 = __EncodedAttribute_encode_gray8
    EncodedAttribute.encode_jpeg_gray8 = __EncodedAttribute_encode_jpeg_gray8
    EncodedAttribute.encode_gray16 = __EncodedAttribute_encode_gray16
    EncodedAttribute._generic_encode_rgb24 = __EncodedAttribute_generic_encode_rgb24
    EncodedAttribute.encode_rgb24 = __EncodedAttribute_encode_rgb24
    EncodedAttribute.encode_jpeg_rgb24 = __EncodedAttribute_encode_jpeg_rgb24
    EncodedAttribute.encode_jpeg_rgb32 = __EncodedAttribute_encode_jpeg_rgb32
    EncodedAttribute.decode_gray8 = __EncodedAttribute_decode_gray8
    EncodedAttribute.decode_gray16 = __EncodedAttribute_decode_gray16
    EncodedAttribute.decode_rgb32 = __EncodedAttribute_decode_rgb32

def __doc_EncodedAttribute():
    pass

def encoded_attribute_init(doc=True):
    __init_EncodedAttribute()
    if doc:
        __doc_EncodedAttribute()