<commit_before># Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import copy
import sys

from glanceclient.common import utils
import glanceclient.v1.images


def do_image_list(gc, args):
    """List images."""
    images = gc.images.list()
    columns = ['ID', 'Name', 'Disk Format', 'Container Format',
               'Size', 'Status']
    utils.print_list(images, columns)


def _image_show(image):
    # Flatten image properties dict for display
    info = copy.deepcopy(image._info)
    for (k, v) in info.pop('properties').iteritems():
        info['Property \'%s\'' % k] = v

    utils.print_dict(info)

<commit_msg>Add size filtering to image-list action<commit_after># Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import copy
import sys

from glanceclient.common import utils
import glanceclient.v1.images


@utils.arg('--size-min', metavar='<SIZE>',
           help='Filter images to those with a size greater than this.')
@utils.arg('--size-max', metavar='<SIZE>',
           help='Filter images to those with a size less than this.')
def do_image_list(gc, args):
    """List images."""
    filters = [
        ('size_min', args.size_min),
        ('size_max', args.size_max),
    ]
    filters = dict(filter(lambda f: f[1] is not None, filters))
    images = gc.images.list(filters=filters)
    columns = ['ID', 'Name', 'Disk Format', 'Container Format',
               'Size', 'Status']
    utils.print_list(images, columns)


def _image_show(image):
    # Flatten image properties dict for display
    info = copy.deepcopy(image._info)
    for (k, v) in info.pop('properties').iteritems():
        info['Property \'%s\'' % k] = v

    utils.print_dict(info)


{'fraction_non_alphanumeric': 0.10930888575458392, 'fraction_numerical': 0.006699576868829337, 'mean_word_length': 3.285498489425982, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4193114', 'n_tokens_mistral': 816, 'n_tokens_neox': 805, 'n_words': 310}