forked from hatashiro/ClassHierarchy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
29 lines (24 loc) · 808 Bytes
/
helpers.py
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
# -*- encoding: utf-8 -*-
import re
from functools import wraps
def hierarchy_base_decorator(f):
@wraps(f)
def wrapper(self, edit, **args):
view = self.view
if not args.get('no_symbol'):
symbol = args.get('symbol')
if not symbol:
region = view.sel()[0]
if region.begin() == region.end():
region = view.word(region)
symbol = view.substr(region)
else:
symbol = None
window = args.get('window')
if not window:
window = None
return f(self, edit, view, symbol, window)
return wrapper
def to_underscore(camelcase):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camelcase)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()