stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamilad <...@git.apache.org>
Subject [GitHub] stratos pull request: Python CLI PR1
Date Fri, 31 Jul 2015 02:29:57 GMT
Github user chamilad commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/414#discussion_r35942295
  
    --- Diff: components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py ---
    @@ -0,0 +1,69 @@
    +from __future__ import print_function
    +import sys
    +from texttable import *
    +import Configs
    +from Logging import logging
    +
    +
    +class PrintableTree:
    +
    +    def __init__(self, tree_data):
    +        self.tree_data = tree_data
    +        pass
    +
    +    def print_tree(self):
    +        def _print_tree(t, level=0, ups=""):
    +            if isinstance(t, list):
    +                print('|')
    +                for element in t[:-1]:
    +                    print(ups + "+-", end='')
    +                    _print_tree(element, level + 1, ups + "| ")
    +                else:
    +                    print(ups + "+-", end='')
    +                    _print_tree(t[-1], level + 1, ups + "  ")
    +            elif isinstance(t, dict):
    +                print('|')
    +                l = []
    +                for k, v in t.items():
    +                    if isinstance(v, list) or isinstance(v, dict):
    +                        l.extend([k, v])
    +                    else:
    +                        l.extend([str(k) + ":" + str(v)])
    +                t = l
    +                for element in t[:-1]:
    +                    print(ups + "+-", end='')
    +                    _print_tree(element, level + 1, ups + "| ")
    +                else:
    +                    print(ups + "+-", end='')
    +                    _print_tree(t[-1], level + 1, ups + "  ")
    +            else:
    +                print(str(t))
    +        print("_")
    +        _print_tree(self.tree_data)
    +
    +
    +class PrintableTable(Texttable):
    +
    +    def __init__(self):
    +        Texttable.__init__(self)
    +        self.set_deco(Texttable.BORDER | Texttable.HEADER | Texttable.VLINES)
    +
    +    def print_table(self):
    +        print(self.draw())
    +
    +def auth(func):
    +    """Authenticate"""
    +    def auth_inner(self, *args, **kwargs):
    --- End diff --
    
    Why an inner function here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message