Skip to content

Commit e056a8c

Browse files
committed
Warn for deprecation of the var() and vars() methods
1) We do not want multiple entry points (e.g. methods) doing the same thing. 2) vars is a reserved methode in python; we should not use it 3) The longer names are preferred, abbreviations are sometimes criptic These methods will definitively be removed in the next major release.
1 parent bf3a562 commit e056a8c

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

pygccxml/declarations/scopedef.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""Defines :class:`scopedef_t` class"""
77

88
import time
9+
import warnings
910
from . import algorithm
1011
from . import templates
1112
from . import declaration
@@ -519,7 +520,22 @@ def variable(
519520
header_file=header_file,
520521
recursive=recursive)
521522
)
522-
var = variable # small alias
523+
524+
def var(self,
525+
name=None,
526+
function=None,
527+
type=None,
528+
header_dir=None,
529+
header_file=None,
530+
recursive=None):
531+
532+
warnings.warn(
533+
"The var() method is deprecated. \n" +
534+
"Please use the variable() method instead.",
535+
DeprecationWarning)
536+
537+
return self.variable(
538+
name, function, type, header_dir, header_file, recursive)
523539

524540
def variables(
525541
self,
@@ -544,7 +560,25 @@ def variables(
544560
recursive=recursive,
545561
allow_empty=allow_empty)
546562
)
547-
vars = variables # small alias
563+
564+
def vars(
565+
self,
566+
name=None,
567+
function=None,
568+
type=None,
569+
header_dir=None,
570+
header_file=None,
571+
recursive=None,
572+
allow_empty=None):
573+
574+
warnings.warn(
575+
"The vars() method is deprecated. \n" +
576+
"Please use the variables() method instead.",
577+
DeprecationWarning)
578+
579+
return self.variables(
580+
name, function, type, header_dir,
581+
header_file, recursive, allow_empty)
548582

549583
def calldef(
550584
self,

0 commit comments

Comments
 (0)