3
3
This module provides the Base Property class.
4
4
"""
5
5
import uuid
6
+ import warnings
6
7
7
8
from . import base
8
9
from . import dtypes
12
13
from .util import format_cardinality
13
14
14
15
16
+ MSG_VALUE_DEPRECATION = "The attribute 'value' is deprecated and will be removed, " \
17
+ "use 'values' instead."
18
+
19
+
15
20
def odml_tuple_import (t_count , new_value ):
16
21
"""
17
22
Checks via a heuristic if the values in a string fit the general
@@ -131,6 +136,8 @@ def __init__(self, name=None, values=None, parent=None, unit=None,
131
136
self ._values = []
132
137
self .values = values
133
138
if not values and (value or isinstance (value , (bool , int ))):
139
+ # Using stacklevel=2 to avoid file name and code line in the message output.
140
+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
134
141
self .values = value
135
142
136
143
self .parent = parent
@@ -285,7 +292,9 @@ def value(self):
285
292
"""
286
293
Deprecated alias of 'values'. Will be removed with the next minor release.
287
294
"""
288
- print ("The attribute 'value' is deprecated. Please use 'values' instead." )
295
+ # Using stacklevel=2 to avoid file name and code line in the message output.
296
+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
297
+
289
298
return self .values
290
299
291
300
@value .setter
@@ -295,7 +304,8 @@ def value(self, new_value):
295
304
296
305
:param new_value: a single value or list of values.
297
306
"""
298
- print ("The attribute 'value' is deprecated. Please use 'values' instead." )
307
+ # Using stacklevel=2 to avoid file name and code line in the message output.
308
+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
299
309
self .values = new_value
300
310
301
311
def value_str (self , index = 0 ):
0 commit comments