<commit_before>import types
import textwrap
from docopt import docopt
import inspect
import sys
import importlib
from cmd3.shell import command
import cloudmesh
from pprint import pprint
from cloudmesh.util.logger import LOGGER


log = LOGGER(__file__)

class cm_shell_list:

    """opt_example class"""

    def activate_cm_shell_list(self):
        pass

    @command
    def do_list(self, args, arguments):
        """
        Usage:
               list flavors [CLOUD...] 
               list servers [CLOUD...]
               list images [CLOUD...]
               list [CLOUD...]
                              
        Arguments:
        
                CLOUD    the name of the cloud
                
        Options:

           -v       verbose mode

        """
        mesh = cloudmesh.mesh()
        #log.info(args)

        #log.info(arguments)
        all = False
        if len(arguments["CLOUD"]) == 0:
            print "get all active clouds"
            all = True
            clouds = ['a', 'b']
        else:
            clouds = arguments['CLOUD']

#        print clouds
        #pprint(mesh.clouds)
        #a=9/0
        #print"-----------------------------------"
        #pprint(mesh.clouds["jedi"])
        if arguments["flavors"] or all:
             #log.info ("count flavors")
             for cloud in clouds:
                 #print "cloud: flavors", cloud, None
                 mesh.refresh(names=[cloud], types=['flavor'])
                 #print mesh.clouds[cloud]
                 #pprint(mesh.clouds[cloud])
                 flavors = mesh.clouds[cloud]['flavor']
                 pprint(flavors)

        if arguments["servers"] or all:
            log.info ("count servers")
            for cloud in clouds:
                print "cloud: servers", cloud, None

        if arguments["images"] or all:
            log.info ("list images")
            for cloud in clouds:
                print "cloud: images", cloud, None




    @command
    def do_count(self, args, arguments):
        """
        Usage: 
               count flavors [CLOUD...]
               count servers [CLOUD...]
               count images [CLOUD...]
               count [CLOUD...]
               
        Arguments:
        
                CLOUD    the name of the cloud
        
        Options:

           -v       verbose mode

        """
        log.info(args)

        log.info(arguments)

        if len(arguments["CLOUD"]) == 0:
            print "get all active clouds"
            all = True
            clouds = ['a', 'b']
        else:
            clouds = arguments['CLOUD']<commit_msg>cm tool for imsges ad servers now gives json<commit_after>import types
import textwrap
from docopt import docopt
import inspect
import sys
import importlib
from cmd3.shell import command
import cloudmesh
from pprint import pprint
from cloudmesh.util.logger import LOGGER


log = LOGGER(__file__)

class cm_shell_list:

    """opt_example class"""

    def activate_cm_shell_list(self):
        pass

    @command
    def do_list(self, args, arguments):
        """
        Usage:
               list flavors [CLOUD...] 
               list servers [CLOUD...]
               list images [CLOUD...]
               list [CLOUD...]
                              
        Arguments:
        
                CLOUD    the name of the cloud
                
        Options:

           -v       verbose mode

        """
        mesh = cloudmesh.mesh()
        #log.info(args)
        #pprint(arguments)
        #log.info(arguments)
        all = False
        if len(arguments["CLOUD"]) == 0:
            print "get all active clouds"
            all = True
            clouds = ['a', 'b']
        else:
            clouds = arguments['CLOUD']

        if arguments["flavors"] or all:
             for cloud in clouds:
                 mesh.refresh(names=[cloud], types=['flavor'])
                 flavors = mesh.clouds[cloud]['flavor']
                 pprint(flavors)

        if arguments["servers"] or all:
#            log.info ("count servers")
            for cloud in clouds:
                 mesh.refresh(names=[cloud], types=['server'])
                 servers = mesh.clouds[cloud]['server']
                 pprint(servers)

        if arguments["images"] or all:
            #log.info ("list images")
            for cloud in clouds:
                 mesh.refresh(names=[cloud], types=['image'])
                 images = mesh.clouds[cloud]['image']
                 pprint(images)



    @command
    def do_count(self, args, arguments):
        """
        Usage: 
               count flavors [CLOUD...]
               count servers [CLOUD...]
               count images [CLOUD...]
               count [CLOUD...]
               
        Arguments:
        
                CLOUD    the name of the cloud
        
        Options:

           -v       verbose mode

        """
        log.info(args)

        log.info(arguments)

        if len(arguments["CLOUD"]) == 0:
            print "get all active clouds"
            all = True
            clouds = ['a', 'b']
        else:
            clouds = arguments['CLOUD']
{'fraction_non_alphanumeric': 0.10848049679798176, 'fraction_numerical': 0.0015524936929943722, 'mean_word_length': 1.3029490616621984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '345390', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1339, 'n_words': 381}