Overhauled v2 plugin attaching

This commit is contained in:
jtc42 2019-11-19 19:19:54 +00:00
parent b8f6193f7b
commit 3c096e9b53
6 changed files with 167 additions and 135 deletions

View file

@ -1,3 +1,4 @@
import re
import copy
import operator
from collections import abc
@ -5,6 +6,14 @@ from functools import reduce
from contextlib import contextmanager
def camel_to_snake(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
def camel_to_spine(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1-\2', s1).lower()
@contextmanager
def set_properties(obj, **kwargs):
"""A context manager to set, then reset, certain properties of an object.