Skip to content

Commit b3c59d0

Browse files
committed
fix: include mixins and options into the base main code
1 parent 90e0612 commit b3c59d0

File tree

2 files changed

+199
-125
lines changed

2 files changed

+199
-125
lines changed

lib/vsc/utils/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,31 @@
2828
"""
2929
import pkg_resources
3030
pkg_resources.declare_namespace(__name__)
31+
32+
import os
33+
import warnings
34+
from functools import wraps
35+
36+
def _script_name(full_name):
37+
"""Return the script name without .py extension if any. This assumes that the script name does not contain a
38+
dot in case of lacking an extension.
39+
"""
40+
(name, _) = os.path.splitext(full_name)
41+
return os.path.basename(name)
42+
43+
44+
def deprecated_class(message=None):
45+
def decorator(cls):
46+
class Wrapped(cls):
47+
def __init__(self, *args, **kwargs):
48+
warnings.warn(
49+
f"{cls.__name__} is deprecated. {message or ''}",
50+
category=DeprecationWarning,
51+
stacklevel=2,
52+
)
53+
super().__init__(*args, **kwargs)
54+
Wrapped.__name__ = cls.__name__
55+
Wrapped.__doc__ = cls.__doc__
56+
Wrapped.__module__ = cls.__module__
57+
return Wrapped
58+
return decorator

0 commit comments

Comments
 (0)