Esempio n. 1
0
def print_table(data: List[List[str]] = None,
                title: str = '',
                colored_header: bool = True,
                no_borders: bool = False):
    if data is None:
        return

    # Make header blue
    if colored_header:
        for x in range(len(data[0])):
            data[0][x] = print_utils.color(data[0][x], 'blue')

    table = SingleTable(data)
    table.title = title
    table.inner_row_border = True

    if no_borders:
        table.inner_row_border = False
        table.inner_column_border = False
        table.outer_border = False
        table.inner_footing_row_border = False
        table.inner_heading_row_border = False

    print('')
    print(table.table)
    print('')
Esempio n. 2
0
def list_all():
    print '\n{}ENCODERS{}'.format(logs.bold(logs.purple('>>')),logs.bold(logs.purple('<<')))
    table_data = [['--NAME--', '--ARCH--', '--DESCRIPTION--', '--RANK--']]
    encoders = []
    for enc in os.walk(PATH+'encoders'):
        encoders.append(enc)
    encoders = encoders[0][2]
    cdrs = []
    for enc in encoders:
        if ('init' in enc or '.pyc' in enc):
            pass
        else:
            cdrs.append(enc.replace('.py', ''))
    for encoder in cdrs:
        try:
            encoder = importlib.import_module('encoders.'+encoder).Encoder()
            if encoder.rank == 'unstable':
                rank = logs.red('UNSTABLE')
            if encoder.rank == 'manual':
                rank = logs.yellow('MANUAL')
            elif encoder.rank == 'good':
                rank = logs.green('GOOD')
            elif encoder.rank == 'excellent':
                rank = logs.blue('EXCELLENT')
        except:
            rank = 'N/A'
        table_data.append([encoder.name, encoder.arch, encoder.description, rank])
    table_instance = SingleTable(table_data) 
    table_instance.inner_heading_row_border = True
    table_instance.inner_row_border = False
    table_instance.justify_columns = {0: 'left', 1: 'left', 2: 'left'}
    print table_instance.table

    print '\n{}EGGHUNTERS{}'.format(logs.bold(logs.purple('>>')),logs.bold(logs.purple('<<')))
    table_data = [['--NAME--', '--PLATFORM--', '--SIZE--', '--EGG SIZE--']]
    for egg in eggs:
        table_data.append([egg, eggs[egg][1],'{} bytes'.format(eggs[egg][2]),'{} bytes'.format(eggs[egg][3])])
    table_instance = SingleTable(table_data) 
    table_instance.inner_heading_row_border = True
    table_instance.inner_row_border = False
    table_instance.justify_columns = {0: 'left', 1: 'left', 2: 'left'}
    print table_instance.table

    print '\n{}FORMATS{}'.format(logs.bold(logs.purple('>>')),logs.bold(logs.purple('<<')))
    table_data = [['--FORMAT--', '--DESCRIPTION--']]
    for func in dir(wrappers):
        if "format_"  in func:
            table_data.append([func.replace("format_", ''), eval("wrappers.{}".format(func)).__doc__])
    table_instance = SingleTable(table_data) 
    table_instance.inner_heading_row_border = True
    table_instance.inner_row_border = False
    table_instance.justify_columns = {0: 'left', 1: 'left', 2: 'left'}
    print table_instance.table
Esempio n. 3
0
def main():
    user_inp = str(raw_input('Enter the ip address :  ')).strip()
    ip = IPAddress(str(user_inp))
    
    if ip.version == 4:
        ipaddr = user_inp
    elif ip.version == 6:
        ipaddr = user_inp.replace(":","%3A")    
    else:
        print "Please enter only a valid ipv4 or ipv6 address"
        sys.exit()
    
    tor_result = torproject(ipaddr)
    status,asn,owner,isp,continent,country,city,region = blacklist(ipaddr)
    table_data = [["ASN",asn],
                  ["Owner",owner],
                  ["ISP",isp],
                  ["TorNode",tor_result],
                  ["Blacklist",status],
                  ["City",city],
                  ["Region",region],
                  ["Continent",continent],
                  ["Country",country]]
    table = SingleTable(table_data)    
    table.title = ipaddr
    table.justify_columns = {0: 'center', 1: 'center'}
    table.inner_row_border = True
    print ""
    print table.table                    
Esempio n. 4
0
def stat_bar(cur):
    """ one-liner stat bar """
    # Block : All=X  Ours=Y Oth=Z   |  Allow : All=X Ours=Y Oth=Z
    data = []

    data.append("Blocks Enabled:  All=" +
                str(get(cur, "total_adlist_enabled")))
    data.append("│")
    data.append("Ours=" + str(get(cur, "our_adlist_enabled")))
    # data.append("│")
    # data.append("Other=" + str(get(cur, "other_adlist_enabled")))

    data.append("│")
    data.append("Allows Enabled:  All=" + str(get(cur, "total_allow_enabled")))
    data.append("│")
    data.append("Ours=" + str(get(cur, "our_allow_enabled")))
    # data.append("│")
    # data.append("Other=" + str(get(cur, "other_allow_enabled")))

    table = SingleTable([data])

    table.inner_heading_row_border = False
    table.outer_border = False
    table.inner_row_border = False
    table.inner_column_border = False
    table.padding_left = 2

    print()
    print(color(table.table, bg="#505050", fg="white"))
    print()
Esempio n. 5
0
def printInformation(session):
    """ Prints out Information about all created virtual machines """

    print "\n\n=================[ VIRTUAL MACHINES ]=================\n"

    table_data        = [['VM', 'CLUSTER','TEMPLATE', 'STORAGE DOMAIN', 'MEMORY', 'DISKS', 'INTERFACES']]

    for vm in configFile['vms']:
        hostname        = vm['hostname']
        cluster        = vm['cluster']
        template    = vm['template']
        storageDomain    = vm['storage-domain']
        memory        = vm['memory']
        diskInfo    = ""
        nicInfo        = ""

        for disk in vm['disks']:
            diskSize        = vm['disks'][disk]
            diskInfo    += disk +" (" + str(diskSize) + " GB)\n"

        for nic in vm['interfaces']:
                    network        = vm['interfaces'][nic]
            nicInfo        += network + " (" + nic + ")\n"

        table_data      += [[ hostname, cluster, template, storageDomain, str(memory) + " GB", diskInfo, nicInfo ]]

    table = SingleTable(table_data)
    table.inner_row_border = True
    table.justify_columns = {0: 'center' , 1: 'center', 2: 'center',3 : 'center',
                 4: 'center', 5: 'center', 6 : 'center'}
    print table.table
Esempio n. 6
0
    def show_status(self):
        table_data=[]

        temp=[]
        temp.append('Event')
        for i in range (number_of_players):
            temp.append(self.event[i])
        table_data.append(temp)

        temp1=[]
        temp1.append('Diagnosis')
        for i in range (number_of_players):
            temp1.append(self.diagnosis[i])
        table_data.append(temp1)

        temp2=[]
        temp2.append('Tests')
        for i in range (number_of_players):
            temp2.append(self.tests[i])
        table_data.append(temp2)

        table=SingleTable(table_data)
        table.title=Color('{autored}Node ID:'+self.nodeid+' NodeNum:' +
                          self.nodenum+'{/autored}')
        table.inner_row_border="True"
        print ""
        print table.table
    def get_description(self):
        root, _, scripts = self.walking_in_directory()
        scripts.sort()

        full_description = {}
        for s in scripts:
            with open(root + s) as text:
                head = [next(text) for l in range(2)]
                technique_name = head[0].replace('#TechniqueName: ', '').strip('\n')
                atomic_name = head[1].replace('#AtomicTestName:', '').strip('\n')

                if technique_name not in full_description:
                    full_description[technique_name] = [(atomic_name, s)]
                else:
                    full_description[technique_name].append((atomic_name, s))
        
        description_display = ''
        table_data = []
        for key, values in full_description.items():
            table_data.append([f'\n#{key}', ''])
            
            for ttp_variant in values:
                table_data.append([f'  {ttp_variant[0]}', ttp_variant[1]])
                self.ttp_list.append(ttp_variant[1])

        table = SingleTable(table_data, title='Atomics')
        table.inner_column_border = False
        table.inner_heading_row_border = False
        table.inner_row_border = False
        table.outer_border = False

        description_display += table.table

        return description_display 
Esempio n. 8
0
def add(login, name, email, password):
    user = Users().create(login, name, email, password)
    table = SingleTable(Transform().api_response_to_terminaltables(
        user, include=DEFAULT_DISPLAY_ATTRIBUTES))
    table.inner_row_border = True
    table.title = "List of users"
    click.echo(table.table)
Esempio n. 9
0
def print_inventory(emoji, emoji_you_have, title="Your Inventory"):
    newlist = [emoji[1:], emoji_you_have[1:]]
    table = SingleTable(newlist)
    table.inner_row_border = True
    table.inner_heading_row_border = False
    table.title = title
    print(table.table)
Esempio n. 10
0
def viewSentiments(number):
    twits = getFile()
    table_data = [[
        Color('{cyan}TWEET{/cyan}'),
        Color('{autored}SENTIMENTS{/autored}')
    ]]
    for twit in tqdm(twits.items(),
                     total=number,
                     desc="Analysing sentiments..."):
        sentiment = twit[1]['sentiments']
        sentString = ''
        for item in sentiment:
            sentString += item + '\n'
        sentString = sentString.strip()
        text = '\n'.join(wrap(twit[1]['tweet'], 80))
        table_data.append([
            Color('{cyan}' + text + '{/cyan}'),
            Color('{red}' + sentString + '{/red}')
        ])
    table_instance = SingleTable(table_data,
                                 Color('{green}Sentiment Analysis{/green}'))
    table_instance.inner_heading_row_border = True
    table_instance.inner_row_border = True
    table_instance.justify_columns = {0: 'left', 1: 'left'}
    return table_instance.table
Esempio n. 11
0
def viewRanks(number):
    twits = getFile()
    stopWords = getStopwords()
    words = []
    for twit in tqdm(twits.items(), total=number, desc="Ranking words..."):
        words.extend(word_tokenize(twit[1]['tweet']))
    words = [
        word for word in words
        if word.lower() not in stopWords and re.match(r'\w', word)
    ]
    wordsDict = Counter(words)
    sortedList = sorted(wordsDict.items(), key=lambda x: x[1], reverse=True)
    table_data = [[
        Color('{cyan}WORDS{/cyan}'),
        Color('{autored}RANKS{/autored}')
    ]]
    for word in sortedList:
        table_data.append(
            [Color(word[0]),
             Color('{autored}' + str(word[1]) + '{/autored}')])
    table_instance = SingleTable(table_data,
                                 Color('{green}Word Frequency{/green}'))
    table_instance.inner_heading_row_border = True
    table_instance.inner_row_border = True
    table_instance.justify_columns = {0: 'center', 1: 'center'}
    return table_instance.table
Esempio n. 12
0
def searchPJ(requete='', num=''):
	def testResponse(requete):
		noReponse = soup.find("p", {"class": "wording-no-responses"})
		if noReponse:
			return 1

	page = requete.text #content.decode('utf-8')
	soup = BeautifulSoup(page, "html.parser")
	rep = testResponse(requete)
	if rep == 1:
		print(warning+" Aucun résultat pour votre recherche... o_o'")
		if num != '':
			pass

	TABLE_DATA = [
		('Name', 'Address', 'Phone', 'Line Phone')
	]

	profiles_list = soup.find_all("div", {"class":"zone-bi"})
	for profile in profiles_list:
		nameList = [n.text.strip() for n in profile.find_all("a", {"class": "denomination-links pj-lb pj-link"})][0]
		addressList = [a.text.strip() for a in profile.find_all("a", {"class": "adresse pj-lb pj-link"})][0]
		numList = [n.text.strip().replace(" ","") for n in profile.find_all("strong", {"class": "num"})]
		operator_list = []
		for n in numList:
			p = searchInfoNumero()
			p.search(n)
			operator_list.append(p.phone_type)

		TABLE_DATA.append((nameList, addressList, ", ".join(numList), ", ".join(operator_list)))

	if rep != 1:
		table_instance = SingleTable(TABLE_DATA, " Particulier ")
		table_instance.inner_row_border = True
		print("\n"+table_instance.table)
Esempio n. 13
0
def main():
    db = dbhandler.connect_db_judged(
        "127.0.0.1", "root", "sustcse", "uva_crawler")
    os.system("clear")
    print bcolors.BOLD + bcolors.HEADER + "                  Problem Recomendation system for SourceCode" + bcolors.ENDC + "\n"
    while True:
        p = raw_input("Type user_id or exit : ")
        # os.system("clear")
        print "\n"
        if p == "exit":
            break
        obj = Recommend(db, int(p))
        data = [[bcolors.WARNING+"pid"+bcolors.ENDC,bcolors.WARNING+"Title"+bcolors.ENDC]]
        for p in obj.rec_prob:
            query = "SELECT name FROM problems WHERE pid=" + str(p["pid"])
            pname = dbhandler.parse_db(db, query)
            temp = [p["pid"],pname[0][0]]
            data.append(temp)
        table = SingleTable(data)
        table.inner_row_border = True
        table.justify_columns={1:"center"}
        print bcolors.CYAN + "Recommended problems : " + bcolors.ENDC
        print table.table
        print "\n"
    dbhandler.disconnect_db_judge(db)
Esempio n. 14
0
    def display_board(self):
        self.clear_screen()

        current_round = self.rounds[self.current_round]
        board_data = [sorted(list(current_round.keys()))]

        values = set()
        for category in current_round:
            for val in current_round[category]:
                values.add(val)

        for val in sorted(values):
            row = []
            for key in sorted(current_round.keys()):
                if current_round[key].get(val, {}).get('active', False):
                    row.append('\n' + colored(f'${val:,}', 'yellow') + '\n')
                else:
                    row.append('\n\n')
            board_data.append(row)

        board = SingleTable(board_data, f'Round {self.current_round}')
        board.inner_row_border = True
        board.justify_columns = {k: 'center' for k, idx in enumerate(current_round.keys())}

        self.render_scores()

        print('\n')

        for line in str(board.table).splitlines():
            self.print_centered(line, width=board.table_width)

        self.load_clue(self.prompt_centered('Pick a clue'))
Esempio n. 15
0
def print_agent_table(data: List[List[str]] = None,
                      formatting: List[List[str]] = None,
                      title: str = ''):
    if data is None:
        return

    # Make header blue
    for x in range(len(data[0])):
        data[0][x] = print_utils.color(data[0][x], 'blue')

    for x in range(len(data))[1:]:
        # Add asterisk for high-integrity agents
        if formatting[x][1]:
            data[x][1] = data[x][1] + '*'

        # color agents
        if formatting[x][0]:
            color = 'red'
        elif not formatting[x][0]:
            color = 'green'

        # Set colors for entire row
        for y in range(len(data[x])):
            data[x][y] = print_utils.color(data[x][y], color)

    table = SingleTable(data)
    table.title = title
    table.inner_row_border = True

    print('')
    print(table.table)
    print('')
Esempio n. 16
0
def trace_table(exc, logger='default', note=True, column=5, mode='ascii', level='error', width=40):
    if isinstance(logger, str):
        logger = logging.getLogger(logger)
    tb = traceback.extract_tb(exc.__traceback__, limit=None)
    len_tb = len(tb)
    group_size = len_tb // column
    if len_tb % column != 0:
        group_size += 1
    if note:
        column -= 1
        if column <= 0:
            column = 1
    for index, tb_chunked in enumerate(grouper_it(tb, column)):
        if note:
            data = [
                ['file'], ['func'], ['desc']
            ]
        else:
            data = [[], [], []]

        for i, frame in enumerate(tb_chunked):
            current_filename = frame.filename
            if i == 0:
                last_filename = frame.filename
            else:
                if current_filename == last_filename:
                    current_filename = ''
                else:
                    last_filename = current_filename  # + ':' + frame.lineno
            if len(current_filename) == 0:
                data[0].append(str(frame.lineno))
            else:
                data[0].append('\n'.join(wrap(current_filename + ':' + str(frame.lineno), width)))
            data[1].append(frame.name)
            data[2].append('\n'.join(wrap(frame.line, width)))

        if mode == 'single':
            table = SingleTable(data, str(group_size) + '-' + str(index + 1))
        else:
            table = AsciiTable(data, str(group_size) + '-' + str(index + 1))

        table.outer_border = True
        table.inner_heading_row_border = True
        table.inner_column_border = True
        table.inner_row_border = True

        # max_width = table.column_max_width(1)
        # wrapped_string = '\n'.join(wrap(LONG_STRING, max_width))
        # table.table_data[0][1] = wrapped_string

        if level == 'critical':
            logger.critical('\n' + table.table)
        elif level == 'warning':
            logger.warning('\n' + table.table)
        elif level == 'info':
            logger.info('\n' + table.table)
        elif level == 'debug':
            logger.debug('\n' + table.table)
        else:
            logger.error('\n' + table.table)
Esempio n. 17
0
File: app.py Progetto: guyskk/weirb
 def _print_table(self, table, title, inner_row_border=False):
     if is_terminal():
         table = SingleTable(table, title=title)
     else:
         table = AsciiTable(table, title=title)
     table.inner_row_border = inner_row_border
     print(table.table)
Esempio n. 18
0
def add(name, description):
    workspace = Workspaces().create(name, description)
    table = SingleTable(Transform().api_response_to_terminaltables(
        workspace, include=DEFAULT_DISPLAY_ATTRIBUTES))
    table.inner_row_border = True
    table.title = "List of workspaces"
    click.echo(table.table)
Esempio n. 19
0
def print_table(table_headers,
				table_values,
				table_title='',
				table_view='v'):
	os.system("cls")
	if table_view == 'v':
		table_data = [table_headers]
		for i in range(len(table_values[0])):
			dataline = []
			for j in range(len(table_headers)):
				dataline.append(str(table_values[j][i]))
			table_data.append(dataline)

	elif table_view == 'h':
		table_data = []
		for i in range(len(table_values)):
			table_data.append([table_headers[i]] +
							  list(map(str, table_values[i])))

	table = SingleTable(table_data)
	table.title = table_title
	table.justify_columns = {0: 'left',
							 1: 'left',
							 2: 'left'}
	table.inner_row_border = False
	print(table.table)
Esempio n. 20
0
    def do_w(self, arg):
        'Show watchlist w \nAdd to watchlist w a <symbol> \nRemove from watchlist w r <symbol>'
        parts = arg.split()


        if len(parts) == 2:
            if parts[0] == 'a':
                self.watchlist.append(parts[1].strip())
            if parts[0] == 'r':
                self.watchlist = [r for r in self.watchlist if not r == parts[1].strip()]
            print "Done"
        else:
            watch_t_data=[]
            watch_table = SingleTable(watch_t_data,'Watch List')
            watch_table.inner_row_border = True
            watch_table.justify_columns = {0: 'center', 1: 'center', 2: 'center', 3:'center',4: 'center'}
            watch_t_data.append(["Symbol","Ask Price", "Open", "Today", "%"])

            if len(self.watchlist) > 0:
                raw_data = self.trader.quotes_data(self.watchlist)
                quotes_data = {}
                for quote in raw_data:
                    day_change = float(quote['last_trade_price']) - float(quote['previous_close'])
                    day_change_pct = '{:05.2f}'.format(( day_change / float(quote['previous_close']) ) * 100)
                    watch_t_data.append([
                        quote['symbol'], 
                        '{:05.2f}'.format(float(quote['last_trade_price'])), 
                        '{:05.2f}'.format(float(quote['previous_close'])), 
                        color_data(day_change),
                        color_data(day_change_pct)
                        ])
                print(watch_table.table)
            else:
                print "Watchlist empty!"
Esempio n. 21
0
    def do_o(self, arg):
        'List open orders'
        open_orders = self.trader.get_open_orders()
        if open_orders:
            open_t_data=[]
            open_table = SingleTable(open_t_data,'open List')
            open_table.inner_row_border = True
            open_table.justify_columns = {0: 'center', 1: 'center', 2: 'center', 3:'center',4: 'center'}
            open_t_data.append( ["index", "symbol", "price", "quantity", "type", "id"])

            index = 1
            for order in open_orders:

                if order['trigger'] == 'stop':
                    order_price = order['stop_price']
                    order_type  = "stop loss"
                else:
                    order_price = order['price']
                    order_type  = order['side']+" "+order['type']

                open_t_data.append([
                    index,
                    self.get_symbol(order['instrument']),
                    order_price,
                    int(float(order['quantity'])),
                    order_type,
                    order['id'],
                ])
                index += 1

            print((open_table.table))
        else:
            print("No Open Orders")
Esempio n. 22
0
def print_vending_machine():
    line1 = '   1     2     3   '
    line2 = '                   '
    line3 = '  ^_^ | T-T  | @_@ '
    line4 = '  20  |  60  | 100 '
    line5 = '   4     5     6   '
    line6 = '                   '
    line7 = '  @.@ | *-*  | :P  '
    line8 = '  150 | 200  | 250 '
    line9 = '                   '
    line10 = '       OUTPUT      '
    line11 = '                   '
    line12 = '   _______________ '

    newlist = []
    newlist.append([line1 + "\n" + line2 + "\n" + line3 + "\n" + line4])
    newlist.append([line5 + "\n" + line6 + "\n" + line7 + "\n" + line8])
    newlist.append([line9 + "\n" + line10 + "\n" + line11 + "\n" + line12])
    #print(newlist)

    table = SingleTable(newlist)
    table.inner_row_border = True
    table.inner_heading_row_border = False
    table.title = "Emoji Vending Machine"
    sp.call("clear", shell=True)
    print(table.table)
Esempio n. 23
0
    def do_q(self, arg):
        'Get detailed quote for stock: q <symbol(s)>'

        symbols = re.split('\W+',arg.upper())

        if len(arg) == 0:
            print("Missing symbol(s)")
        else:
            instruments = [self.get_instrument(s)['url'] for s in symbols]
            raw_data = self.trader.get_stock_marketdata(instruments)
            quotes_data = {}
            quote_t_data=[]
            quote_table = SingleTable(quote_t_data,'Quote List')
            quote_table.inner_row_border = True
            quote_table.justify_columns = {0: 'center', 1: 'center', 2: 'center', 3:'center',4: 'center'}
            quote_t_data.append(["Symbol", "Current Price", "Open","Change", "Ask","Bid"])
            for quote in raw_data:
                if not quote:
                    continue
                day_change = float(quote['last_trade_price']) - float(quote['previous_close'])
                day_change_pct = ( day_change / float(quote['previous_close']) ) * 100
                ask_price = '{:05.2f}'.format(float(quote['ask_price']))
                ask_size = quote['ask_size']
                bid_price = '{:05.2f}'.format(float(quote['bid_price']))
                bid_size  = quote['bid_size']
                quote_t_data.append([
                    quote['symbol'],
                    '{:05.2f}'.format(float(quote['last_trade_price'])),
                    '{:05.2f}'.format(float(quote['previous_close'])),
                    color_data(day_change)+' ('+color_data('{:05.2f}'.format(day_change_pct))+'%)',
                    str(ask_price)+' x '+str(ask_size),
                    str(bid_price)+' x '+str(bid_size)
                    ])
            print((quote_table.table))
Esempio n. 24
0
    def print_compare(self, src, dst, a, b, sym):

        from colorclass import Color, Windows

        from terminaltables import SingleTable

        Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

        max_width = 50
        l = [Color('{autocyan}' + self.wrap_text(src, max_width) + '{/autocyan}'),
             sym[0],
             Color('{autocyan}' + self.wrap_text(dst, max_width) + '{/autocyan}')]
        table_data = []
        table_data.append(l)

        for key, value in a.items():
            l = [self.wrap_text(key, max_width), sym[1], ""]
            table_data.append(l)
        for key, value in b.items():
            l = ["", sym[2], self.wrap_text(key, max_width)]
            table_data.append(l)

        table = SingleTable(table_data)
        table.inner_heading_row_border = True
        table.inner_row_border = True
        print(table.table)
Esempio n. 25
0
    def list(self, response):
        """
        Get available sessions

        Usage: list [-h]
        """

        table_data = [
            ["Name", "User", "Address", "Last Checkin"]
        ]

        for guid,session in response.result.items():
            if session['info']:
                try:
                    username = f"{session['info']['Domain']}\\{session['info']['Username']}@{session['info']['Hostname']}"
                    if session['info']['HighIntegrity']:
                        username = f"*{username}"
                except KeyError:
                    username = '******'

                table_data.append([
                    guid,
                    username,
                    session['address'],
                    strftime("h %H m %M s %S", gmtime(session['lastcheckin']))
                ])

        table = SingleTable(table_data, title="Sessions")
        table.inner_row_border = True
        print(table.table)
Esempio n. 26
0
    def print_table(self):
        """
        Uses the `terminaltables` module to pretty-print the timetable. Doesn't
        work Properly on smaller screens, use `print_timetable` function instead.
        """
        rows = []
        headers = [""] + [str(i) for i in range(1, 13)]
        # Used a copy here because work_days is a defaultdict
        work_days_copy = self.work_days.copy()

        for day in Workdays:
            row = [day.name] + [""] * 12
            for cname, slot in work_days_copy[day]:
                msg = f'G{slot.group} {cname} {slot.s_type}'
                msg = '\n'.join(msg.split(' '))
                row[slot.period.start] = f'{msg}'
                if slot.period.start != slot.period.end:
                    row[slot.period.
                        end] = f'Period\n{slot.period.start}\nContinued'
                if slot.instructor:
                    row[slot.period.start] += f'\n{slot.instructor}'

            rows.append(row)
        table_data = [headers] + rows
        table_instance = SingleTable(table_data, "Timetable")
        table_instance.inner_row_border = True
        print(table_instance.table)
Esempio n. 27
0
def print_table(guessed_result):
    newlist = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], guessed_result]
    table = SingleTable(newlist)
    table.inner_row_border = True
    table.inner_heading_row_border = False
    table.title = "Number List"
    # sp.call("clear",shell=True)
    print(table.table)
Esempio n. 28
0
    def _display_list(self, data_list):
        if len(data_list) == 0:
            return 'Nothing in here..'

        table = SingleTable([['\n'.join(textwrap.wrap(x, LINE_WIDTH))]
                             for x in data_list])
        table.inner_row_border = True
        return table.table
Esempio n. 29
0
def add(name, description, git_url):
    project = Projects()
    project = project.create(name, description, git_url)
    table = SingleTable(Transform().api_response_to_terminaltables(
        project, include=DEFAULT_DISPLAY_ATTRIBUTES))
    table.inner_row_border = True
    table.title = "List of projects"
    click.echo(table.table)
Esempio n. 30
0
File: core.py Progetto: azlyth/mcp
    def box(cls, width, height, title=''):
        table_structure = [[' ' * (width - 2)] for x in range(height - 2)]

        table = SingleTable(table_structure, ' {} '.format(title))
        table.inner_row_border = False
        table.inner_heading_row_border = False

        return table.table
Esempio n. 31
0
def print_table(table_data,title=None):

    """Return table string to be printed."""
    table_instance = SingleTable(table_data.tolist(), title)
    table_instance.inner_heading_row_border = False
    table_instance.inner_row_border = True
#    table_instance.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
    print (table_instance.table)
Esempio n. 32
0
 def pprint(self):
     """
     Pretty prints the contents of the box
     """
     table = SingleTable(self.boxes)
     table.inner_heading_row_border = False
     table.inner_row_border = True
     print(table.table)
Esempio n. 33
0
def print_vm_info(summary_vm):
    table_data = []
    table_data.append(['VM Name:', summary_vm.config.name])
    table_data.append(['IP Address:', summary_vm.guest.ipAddress])
    table_data.append(['Annotation:', summary_vm.config.annotation])
    table = SingleTable(table_data)
    table.inner_row_border = True
    print table.table
Esempio n. 34
0
 def table_metrics(self):
     # Returns a printable table of metrics
     data = [[m, self.metrics[m][-1]] for m in self.metrics.keys()]
     table = SingleTable(data, self.experiment.name)
     table.inner_heading_row_border = True
     table.inner_row_border = True
     table.inner_column_border = True
     return table.table
Esempio n. 35
0
def table_server_status():
    """Return table string to be printed."""
    table_data = [
        [Color('Low Space'), Color('{autocyan}Nominal Space{/autocyan}'), Color('Excessive Space')],
        [Color('Low Load'), Color('Nominal Load'), Color('{autored}High Load{/autored}')],
        [Color('{autocyan}Low Free RAM{/autocyan}'), Color('Nominal Free RAM'), Color('High Free RAM')],
    ]
    table_instance = SingleTable(table_data, '192.168.0.105')
    table_instance.inner_heading_row_border = False
    table_instance.inner_row_border = True
    table_instance.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
    return table_instance.table
Esempio n. 36
0
def hinton_diagram(arr, max_arr=None):
    max_arr = arr if max_arr is None else max_arr
    max_val = max(abs(np.max(max_arr)), abs(np.min(max_arr)))
    diagram = [list([hinton_diagram_value(x, max_val) for x in _arr]) for _arr in arr]

    table = SingleTable(diagram)
    table.inner_heading_row_border = False
    table.inner_footing_row_border = False
    table.inner_column_border = False
    table.inner_row_border = False
    table.column_max_width = 1

    return table.table
Esempio n. 37
0
def fancy_table(table_headers, *table_rows):
    """Creates a fancy table string from the given data

    :param table_headers: Iterable contains the table's headers
    :param table_rows: Iterable elements contain the table rows (body)
    :return: Formatted string represents the newly created table
    """
    table_data = [table_headers]
    table_data.extend(table_rows)

    table = SingleTable(table_data=table_data)
    table.inner_row_border = True

    return table.table
Esempio n. 38
0
def _print_deployment_summary(env):
    table_data = [
        ["Project name:", env.project_name],
        ["Target:", env.target_name],
        ["User:"******"Host(s):", "; ".join(env.hosts)],
    ]

    table = SingleTable(table_data)
    table.title = Color('{autoyellow}Deployment configuration{/autoyellow}')
    table.justify_columns = {0: 'left', 1: 'left'}
    table.inner_row_border = False
    table.inner_heading_row_border = False

    _print_table(table)
Esempio n. 39
0
def main():
    user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'
    headers = { 'User-Agent' : user_agent }
    trackingid = raw_input("Please enter the trackingid of your UPS package : ")
    
    url1 = "https://wwwapps.ups.com/WebTracking/processRequest?HTMLVersion=5.0&Requester=NES&AgreeToTermsAndConditions=yes&loc=en_US&"
    url2 = "tracknum={0}".format(trackingid)
    if len(trackingid) < 18:
        print "The tracking id is wrong"
    url = url1 + url2
    city,country,statusdate,localtime,activity = ups(url,headers)
    table_data = [["Tracking ID",trackingid],
                  ["City",city],
                  ["Country",country],
                  ["Status Date",statusdate],
                  ["Status Time",localtime],
                  ["Status",activity]]
    table = SingleTable(table_data)    
    table.title = "UPS Package Status"
    table.justify_columns = {0: 'center', 1: 'center'}
    table.inner_row_border = True
    print ""
    print table.table                    
Esempio n. 40
0
def test_multi_line():
    """Test multi-lined cells."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]
    table = SingleTable(table_data)

    # Test defaults.
    actual = table.table
    expected = (
        '\033(0\x6c\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x77\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6b\033(B\n'

        '\033(0\x78\033(B Show       \033(0\x78\033(B Characters                                                       '
        '                   \033(0\x78\033(B\n'

        '\033(0\x74\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6e\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x75\033(B\n'

        '\033(0\x78\033(B Rugrats    \033(0\x78\033(B Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille,'
        ' Angelica Pickles, \033(0\x78\033(B\n'

        '\033(0\x78\033(B            \033(0\x78\033(B Dil Pickles                                                      '
        '                   \033(0\x78\033(B\n'

        '\033(0\x78\033(B South Park \033(0\x78\033(B Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick       '
        '                   \033(0\x78\033(B\n'

        '\033(0\x6d\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x76\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6a\033(B'
    )
    assert actual == expected

    # Test inner row border.
    table.inner_row_border = True
    actual = table.table
    expected = (
        '\033(0\x6c\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x77\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6b\033(B\n'

        '\033(0\x78\033(B Show       \033(0\x78\033(B Characters                                                       '
        '                   \033(0\x78\033(B\n'

        '\033(0\x74\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6e\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x75\033(B\n'

        '\033(0\x78\033(B Rugrats    \033(0\x78\033(B Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille,'
        ' Angelica Pickles, \033(0\x78\033(B\n'

        '\033(0\x78\033(B            \033(0\x78\033(B Dil Pickles                                                      '
        '                   \033(0\x78\033(B\n'

        '\033(0\x74\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6e\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x75\033(B\n'

        '\033(0\x78\033(B South Park \033(0\x78\033(B Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick       '
        '                   \033(0\x78\033(B\n'

        '\033(0\x6d\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x76\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6a\033(B'
    )
    assert actual == expected

    # Justify right.
    table.justify_columns = {1: 'right'}
    actual = table.table
    expected = (
        '\033(0\x6c\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x77\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6b\033(B\n'

        '\033(0\x78\033(B Show       \033(0\x78\033(B                                                                  '
        '        Characters \033(0\x78\033(B\n'

        '\033(0\x74\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6e\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x75\033(B\n'

        '\033(0\x78\033(B Rugrats    \033(0\x78\033(B Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille,'
        ' Angelica Pickles, \033(0\x78\033(B\n'

        '\033(0\x78\033(B            \033(0\x78\033(B                                                                  '
        '       Dil Pickles \033(0\x78\033(B\n'

        '\033(0\x74\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6e\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x75\033(B\n'

        '\033(0\x78\033(B South Park \033(0\x78\033(B                          Stan Marsh, Kyle Broflovski, '
        'Eric Cartman, Kenny McCormick \033(0\x78\033(B\n'

        '\033(0\x6d\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x76\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71'
        '\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x71\x6a\033(B'
    )
    assert actual == expected
Esempio n. 41
0
from terminaltables import AsciiTable, SingleTable, DoubleTable, GithubFlavoredMarkdownTable

table_data = [["Name", "Size"], ["test1", "512M"], ["test2", "1G"]]

ascii_table = AsciiTable(table_data)
print ascii_table.table

ascii_table.inner_row_border = True
print ascii_table.table

print

single_table = SingleTable(table_data)
print single_table.table

single_table.inner_row_border = True
print single_table.table

single_table.title = "List"
print single_table.table

print

gfw_table = GithubFlavoredMarkdownTable(table_data)
print gfw_table.table


"""
+-------+------+
| Name  | Size |
+-------+------+
def test_multi_line():
    """Test multi-lined cells."""
    table_data = [
        ['Show', 'Characters'],
        ['Rugrats', 'Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles,\nDil Pickles'],
        ['South Park', 'Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick']
    ]
    table = SingleTable(table_data)

    # Test defaults.
    actual = table.table
    expected = (
        u'\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n'

        u'\u2502 Show       \u2502 Characters                                                                          '
        u'\u2502\n'

        u'\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n'

        u'\u2502 Rugrats    \u2502 Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, '
        u'\u2502\n'

        u'\u2502            \u2502 Dil Pickles                                                                         '
        u'\u2502\n'

        u'\u2502 South Park \u2502 Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          '
        u'\u2502\n'

        u'\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518'
    )
    assert actual == expected

    # Test inner row border.
    table.inner_row_border = True
    actual = table.table
    expected = (
        u'\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n'

        u'\u2502 Show       \u2502 Characters                                                                          '
        u'\u2502\n'

        u'\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n'

        u'\u2502 Rugrats    \u2502 Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, '
        u'\u2502\n'

        u'\u2502            \u2502 Dil Pickles                                                                         '
        u'\u2502\n'

        u'\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n'

        u'\u2502 South Park \u2502 Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick                          '
        u'\u2502\n'

        u'\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518'
    )
    assert actual == expected

    # Justify right.
    table.justify_columns = {1: 'right'}
    actual = table.table
    expected = (
        u'\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n'

        u'\u2502 Show       \u2502                                                                          Characters '
        u'\u2502\n'

        u'\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n'

        u'\u2502 Rugrats    \u2502 Tommy Pickles, Chuckie Finster, Phillip DeVille, Lillian DeVille, Angelica Pickles, '
        u'\u2502\n'

        u'\u2502            \u2502                                                                         Dil Pickles '
        u'\u2502\n'

        u'\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n'

        u'\u2502 South Park \u2502                          Stan Marsh, Kyle Broflovski, Eric Cartman, Kenny McCormick '
        u'\u2502\n'

        u'\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
        u'\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518'
    )
    assert actual == expected
Esempio n. 43
0
Windows.enable(auto_colors=True, reset_atexit=True)  # Does nothing if not on Windows.

table_data = [
    [Color('{autobgred}{autogreen}<10ms{/autogreen}{/bgred}'), '192.168.0.100, 192.168.0.101'],
    [Color('{autoyellow}10ms <= 100ms{/autoyellow}'), '192.168.0.102, 192.168.0.103'],
    [Color('{autored}>100ms{/autored}'), '192.168.0.105'],
]
table = SingleTable(table_data)
table.inner_heading_row_border = False
print()
print(table.table)

table.title = '192.168.0.105'
table.justify_columns = {0: 'center', 1: 'center', 2: 'center'}
table.inner_row_border = True
table.table_data = [
    [Color('Low Space'), Color('{autocyan}Nominal Space{/autocyan}'), Color('Excessive Space')],
    [Color('Low Load'), Color('Nominal Load'), Color('{autored}High Load{/autored}')],
    [Color('{autocyan}Low Free RAM{/autocyan}'), Color('Nominal Free RAM'), Color('High Free RAM')],
]
print()
print(table.table)

table.title = None
table.outer_border = False
table.table_data = [['A', 'B'], ['C', 'D']]
print()
print(table.table)

table.outer_border = True
Esempio n. 44
0
def do_it(pp):

	ids = []
	table_data = []
	headers = []
	no_section = []

	for h in pp["columns"]:
		headers.append(str(h))

	table_data.append(headers)

	SOURCEKEY	= pp["columns"].index("SOURCE")
	DESTKEY		= pp["columns"].index("DESTINATION")
	SERVICEKEY	= pp["columns"].index("SERVICE")

	for id in pp["ruleSections"]:
		ids.append(id[1])

	for id in pp["ruleSections"]:
		for rule in pp["rules"]:
			rule = clean_rule(rule)
			if u"Any" in rule[SOURCEKEY] or u"Any" in rule[DESTKEY] or u"Any" in rule[SERVICEKEY] or u"Disabled" in rule[0]:
				if rule[len(rule)-1] == id[1]:
					table_data.append(rule)
					pp["rules"].remove(rule)
				elif rule[len(rule)-1] not in ids:
					if rule not in no_section:
						no_section.append(rule)
						pp["rules"].remove(rule)
				else:
					pass
		if len(table_data) > 1:
			new_table_data = clean_td(table_data)

			ascii = AsciiTable(table_data)
			single = SingleTable(table_data)

			ascii.inner_row_border = True
			single.inner_row_border = True

			a = ascii.table
			s = single.table

			write_output(a, id[0])

			if (verbose):
				print "--- SECTION: %s ---" % id[0]
				print s

			table_data = []
			table_data.append(headers)

	if len(no_section) > 0:
		table_data = []
		headers = []

		for h in pp["columns"]:
			headers.append(str(h))

		table_data.append(headers)

		for rule in no_section:
			table_data.append(rule)

		table_data = clean_td(table_data)

		ascii = AsciiTable(table_data)
		single = SingleTable(table_data)

		single.inner_row_border = True
		ascii.inner_row_border = True

		a = ascii.table
		s = single.table

		write_output(a, "(NO SECTION DEFINED)")
		if (verbose):
			print "--- NO SECTION DEFINED (THESE ARE USUALLY AT THE TOP) ---"
			print s

	n = name + "-myCVT-output.txt"
	print "\033[1;32m[+] Written output to file ./%s\n" % n