Last active
January 30, 2017 16:28
-
-
Save Lawouach/c888885e2efbb2aa629da23d2abef831 to your computer and use it in GitHub Desktop.
Suffixes Python class name with Rug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from typing import Dict, Any | |
__all__ = ["editor"] | |
def edit(project: Any, params: Dict[str, str]) -> Dict[str, str]: | |
""" | |
Update each class name of a project with a new suffix. | |
""" | |
eng = project.context().pathExpressionEngine() | |
res = eng.evaluate(project, "/*//PythonRawFile()//classdef()/NAME") | |
for match in res.matches(): | |
match.update(match.value() + params['class_suffix']) | |
return {"status":"OK", "message": "Suffix added to all your classes"} | |
editor = { | |
"tags": ["python"], | |
"name": "SuffixClassName", | |
"description": "Suffixes Python class names", | |
"parameters": [ | |
{ | |
"required": True, | |
"description": "the suffix value", | |
"displayName": "Suffix to append", | |
"displayable": True, | |
"validInput": "the suffix value", | |
"pattern": "^[\\w]*$", | |
"minLength": 1, | |
"name": "class_suffix" | |
} | |
], | |
"edit": edit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment