Goes through call stack and finds constructs matching conf.dbmsHandler.*. Returns it or its alias used in 'txt/common-outputs.txt'
(alias=True)
| 2664 | return None, None, None, originalCharset |
| 2665 | |
| 2666 | def getPartRun(alias=True): |
| 2667 | """ |
| 2668 | Goes through call stack and finds constructs matching |
| 2669 | conf.dbmsHandler.*. Returns it or its alias used in 'txt/common-outputs.txt' |
| 2670 | """ |
| 2671 | |
| 2672 | retVal = None |
| 2673 | commonPartsDict = optDict["Enumeration"] |
| 2674 | |
| 2675 | try: |
| 2676 | stack = [item[4][0] if isinstance(item[4], list) else '' for item in inspect.stack()] |
| 2677 | |
| 2678 | # Goes backwards through the stack to find the conf.dbmsHandler method |
| 2679 | # calling this function |
| 2680 | for i in xrange(0, len(stack) - 1): |
| 2681 | for regex in (r"self\.(get[^(]+)\(\)", r"conf\.dbmsHandler\.([^(]+)\(\)"): |
| 2682 | match = re.search(regex, stack[i]) |
| 2683 | |
| 2684 | if match: |
| 2685 | # This is the calling conf.dbmsHandler or self method |
| 2686 | # (e.g. 'getDbms') |
| 2687 | retVal = match.groups()[0] |
| 2688 | break |
| 2689 | |
| 2690 | if retVal is not None: |
| 2691 | break |
| 2692 | |
| 2693 | # Reference: http://coding.derkeiler.com/Archive/Python/comp.lang.python/2004-06/2267.html |
| 2694 | except TypeError: |
| 2695 | pass |
| 2696 | |
| 2697 | # Return the INI tag to consider for common outputs (e.g. 'Databases') |
| 2698 | if alias: |
| 2699 | return commonPartsDict[retVal][1] if isinstance(commonPartsDict.get(retVal), tuple) else retVal |
| 2700 | else: |
| 2701 | return retVal |
| 2702 | |
| 2703 | def longestCommonPrefix(*sequences): |
| 2704 | """ |