예제 #1
0
def _subs_table(subs):

    sub_id = "Id"
    product_ver = "Product version"
    locked = "Locked"

    output = Output()
    output.vertical_padding = 0
    output.vertical_separator = None
    output.table_header_separator = '-'
    output.header_names = [
        sub_id,
        product_ver,
        locked,
    ]

    output.set_header_alignment({
        sub_id: "right",
    })

    for sub in sorted(subs, key=lambda s: s.spec):

        output.add_item(
            {
                sub_id: str(sub.id).zfill(5),
                product_ver: sub.product_version_spec,
                locked: sub.locked,
            },
            color_all=Style.bright,
        )

    output.dump(output_format='table')
예제 #2
0
파일: list.py 프로젝트: chippey/dpa-pipe
def _subs_table(subs):

    sub_id = "Id"
    product_ver = "Product version" 
    locked = "Locked"

    output = Output()
    output.vertical_padding = 0
    output.vertical_separator = None
    output.table_header_separator = '-'
    output.header_names = [
        sub_id,
        product_ver,
        locked,
    ]

    output.set_header_alignment({
        sub_id: "right",
    })

    for sub in sorted(subs, key=lambda s: s.spec):

        output.add_item(
            {
                sub_id: str(sub.id).zfill(5),
                product_ver: sub.product_version_spec,
                locked: sub.locked,
            },
            color_all=Style.bright,
        )

    output.dump(output_format='table')
예제 #3
0
파일: edit.py 프로젝트: chippey/dpa-pipe
    def _sub_table(self, subs, title="Subscriptions"):

        sub_id = "Sub. ID"
        product = "Product"
        subscriber = "Subscriber"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator="-"
        output.header_names = [
            sub_id,
            product,
            subscriber,
        ]

        output.set_header_alignment({
            sub_id: "right"
        })

        for sub in sorted(subs, key=lambda s: s.spec):
            
            output.add_item(
                {
                    sub_id: str(sub.id).zfill(5),
                    product: sub.product_version_spec,
                    subscriber: sub.ptask_version_spec,
                }
            )

        output.dump(output_format="table")

        print ""
예제 #4
0
    def _sub_table(self, subs, title="Subscriptions"):

        sub_id = "Sub. ID"
        product = "Product"
        subscriber = "Subscriber"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator = "-"
        output.header_names = [
            sub_id,
            product,
            subscriber,
        ]

        output.set_header_alignment({sub_id: "right"})

        for sub in sorted(subs, key=lambda s: s.spec):

            output.add_item({
                sub_id: str(sub.id).zfill(5),
                product: sub.product_version_spec,
                subscriber: sub.ptask_version_spec,
            })

        output.dump(output_format="table")

        print ""
예제 #5
0
파일: info.py 프로젝트: liudger/dpa-pipe
    def _info_versions(self):

        self._versions = self.product.versions

        if len(self._versions) == 0:
            print "Found no versions for product!\n"
            return

        number = "Ver"
        published = "P"
        deprecated = "D"
        note = "Release note"
        reps = "Reps"
        creator = "Creator"
        created = "Created"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator = "-"
        output.header_names = [published, number, note, reps, creator, created]

        output.set_header_alignment({number: "right", published: "right"})

        for version in sorted(self._versions, key=lambda v: v.number):

            is_official = version.number == self.product.official_version_number
            is_published = version.published
            is_deprecated = version.deprecated

            style = Style.dim
            if is_official or is_published:
                style = Style.normal

            output.add_item(
                {
                    number: version.number_padded,
                    note: version.release_note,
                    published: _published(is_published, is_official),
                    reps: _representations(version),
                    creator: version.creator_username,
                    created: _datetime_format(version.created),
                },
                colors={
                    published: _published_color(is_published, is_official, is_deprecated),
                    number: _published_color(is_published, is_official, is_deprecated),
                    note: style,
                    reps: style,
                    creator: style,
                    created: style,
                },
            )

        output.dump(output_format="table")

        print ""
예제 #6
0
    def verify(self):

        product = "Product"
        source = "From"
        current = "Old"
        new = "New"
        note = "Note"

        output = Output()
        output.title = "Subscriptions to update:"
        output.header_names = [
            source,
            product,
            current,
            new,
            note,
        ]

        output.set_header_alignment({
            current: "right",
            new: "right",
        })

        updates = False

        for sub in sorted(self._subs, key=lambda s: s.spec):
            
            update_map = self._update_map[sub.id]
            cur_ver = update_map['old']
            cur_product = cur_ver.product
            new_ver = update_map['new']
            update_note = update_map['note']

            if new_ver:
                updates = True
                new_ver_disp = new_ver.number_padded
            else:
                new_ver_disp = "----"

            output.add_item(
                {
                    source: cur_product.ptask.spec,
                    product: cur_product.name_spec,
                    current: cur_ver.number_padded,
                    new: new_ver_disp,
                    note: update_note,
                },
            )
            
        output.dump(output_format='table')

        if not updates:
            raise ActionAborted("Nothing to update.")

        if not Output.prompt_yes_no(Style.bright + "Update" + Style.reset):
            raise ActionAborted("User chose not to proceed.")
예제 #7
0
파일: list.py 프로젝트: josh-t/dpa-pipe
    def execute(self):

        products = _get_products(self.wild_spec)

        if len(products) == 0:
            print '\nFound 0 products matching: "{s}"\n'.\
                format(s=self.wild_spec)
            return

        name = "Name"
        category = "Category"
        description = "Description"
        official = "Official"
        spec = "Spec"

        output = Output()
        output.vertical_separator = None
        output.table_cell_separator = '  '
        output.table_header_separator = '-'
        output.header_names = [
            name,
            category,
            description,
            official,
            spec,
        ]

        output.set_header_alignment({
            official: "right" 
        })

        if len(products) == 1:
            output.title = "{s}: 1 match".format(s=self.wild_spec)
        else:
            output.title = "{s}: {n} matches".format(
                s=self.wild_spec, n=len(products))

        for product in sorted(products, key=lambda p: p.name + p.category + p.ptask_spec):
            if self._official_only and not product.official_version_number:
                continue

            output.add_item(
                {
                    name: product.name,
                    category: product.category,
                    description: product.description,
                    official: _official(product),
                    spec: product.spec,
                },
                colors={
                    spec: Style.bright,
                }
            )
            
        output.dump(output_format='table')
예제 #8
0
파일: info.py 프로젝트: chippey/dpa-pipe
    def _ptask_versions_info(self):

        version_number = "Version"
        description = "Description"
        created = "Created"
        creator = "Creator"
        location = "Location"
        parent = "Source"
        
        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator = '-'
        output.header_names = [
            version_number,
            description,
            created,
            creator,
            location,
            parent,
        ]

        output.set_header_alignment({
            version_number: "right",
            parent: "right",
        })

        for version in sorted(self.ptask.versions, key=lambda v: v.number):

            parent_num = version.parent_spec


            if parent_num:
                (parent_ptask_spec, parent_ver) = parent_num.split("@")
                if parent_ptask_spec == self.ptask.spec:
                    parent_num = parent_ver

            output.add_item(
                {
                    version_number: version.number_padded,
                    description: version.description,
                    created: version.created.strftime("%Y/%m/%d %H:%M:%S"),
                    creator: version.creator_username,
                    location: version.location_code,
                    parent: parent_num,
                },
                colors={
                    version_number: Style.bright,
                }
            )

        output.dump(output_format='table')

        print ""
예제 #9
0
    def execute(self):

        products = _get_products(self.wild_spec)

        if len(products) == 0:
            print '\nFound 0 products matching: "{s}"\n'.\
                format(s=self.wild_spec)
            return

        name = "Name"
        category = "Category"
        description = "Description"
        official = "Official"
        spec = "Spec"

        output = Output()
        output.vertical_separator = None
        output.table_cell_separator = '  '
        output.table_header_separator = '-'
        output.header_names = [
            name,
            category,
            description,
            official,
            spec,
        ]

        output.set_header_alignment({official: "right"})

        if len(products) == 1:
            output.title = "{s}: 1 match".format(s=self.wild_spec)
        else:
            output.title = "{s}: {n} matches".format(s=self.wild_spec,
                                                     n=len(products))

        for product in sorted(
                products, key=lambda p: p.name + p.category + p.ptask_spec):
            if self._official_only and not product.official_version_number:
                continue

            output.add_item(
                {
                    name: product.name,
                    category: product.category,
                    description: product.description,
                    official: _official(product),
                    spec: product.spec,
                },
                colors={
                    spec: Style.bright,
                })

        output.dump(output_format='table')
예제 #10
0
파일: info.py 프로젝트: liudger/dpa-pipe
    def _ptask_versions_info(self):

        version_number = "Version"
        description = "Description"
        created = "Created"
        creator = "Creator"
        location = "Location"
        parent = "Source"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator = '-'
        output.header_names = [
            version_number,
            description,
            created,
            creator,
            location,
            parent,
        ]

        output.set_header_alignment({
            version_number: "right",
            parent: "right",
        })

        for version in sorted(self.ptask.versions, key=lambda v: v.number):

            parent_num = version.parent_spec

            if parent_num:
                (parent_ptask_spec, parent_ver) = parent_num.split("@")
                if parent_ptask_spec == self.ptask.spec:
                    parent_num = parent_ver

            output.add_item(
                {
                    version_number: version.number_padded,
                    description: version.description,
                    created: version.created.strftime("%Y/%m/%d %H:%M:%S"),
                    creator: version.creator_username,
                    location: version.location_code,
                    parent: parent_num,
                },
                colors={
                    version_number: Style.bright,
                })

        output.dump(output_format='table')

        print ""
예제 #11
0
파일: update.py 프로젝트: josh-t/dpa-pipe
    def _version_table(self, versions, title='Versions'):

        number = title
        note = "Release note"
        reps = "Reps"
        creator = "Creator"
        created = "Created"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator="-"
        output.header_names = [
            number,
            note,
            reps,
            creator,
            created,
        ]

        output.set_header_alignment({
            number: "right",
        })

        output.set_header_colors({
            number: Style.bright,
        })

        for version in sorted(versions, key=lambda v: v.number):

            output.add_item(
                {
                    number: version.number_padded,
                    note: version.release_note,
                    reps: _representations(version),
                    creator: version.creator_username,
                    created: _datetime_format(version.created),
                },
            )

        output.dump(output_format='table')

        print ""
예제 #12
0
    def _version_table(self, versions, title='Versions'):

        number = title
        note = "Release note"
        reps = "Reps"
        creator = "Creator"
        created = "Created"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator="-"
        output.header_names = [
            number,
            note,
            reps,
            creator,
            created,
        ]

        output.set_header_alignment({
            number: "right",
        })

        output.set_header_colors({
            number: Style.bright,
        })

        for version in sorted(versions, key=lambda v: v.number):

            output.add_item(
                {
                    number: version.number_padded,
                    note: version.release_note,
                    reps: _representations(version),
                    creator: version.creator_username,
                    created: _datetime_format(version.created),
                },
            )

        output.dump(output_format='table')

        print ""
예제 #13
0
파일: info.py 프로젝트: liudger/dpa-pipe
    def _info_versions(self):

        self._versions = self.product.versions

        if len(self._versions) == 0:
            print "Found no versions for product!\n"
            return

        number = "Ver"
        published = "P"
        deprecated = "D"
        note = "Release note"
        reps = "Reps"
        creator = "Creator"
        created = "Created"

        output = Output()
        output.vertical_padding = 0
        output.vertical_separator = None
        output.table_header_separator = "-"
        output.header_names = [
            published,
            number,
            note,
            reps,
            creator,
            created,
        ]

        output.set_header_alignment({
            number: "right",
            published: "right",
        })

        for version in sorted(self._versions, key=lambda v: v.number):

            is_official = version.number == self.product.official_version_number
            is_published = version.published
            is_deprecated = version.deprecated

            style = Style.dim
            if is_official or is_published:
                style = Style.normal

            output.add_item(
                {
                    number: version.number_padded,
                    note: version.release_note,
                    published: _published(is_published, is_official),
                    reps: _representations(version),
                    creator: version.creator_username,
                    created: _datetime_format(version.created),
                },
                colors={
                    published:
                    _published_color(is_published, is_official, is_deprecated),
                    number:
                    _published_color(is_published, is_official, is_deprecated),
                    note:
                    style,
                    reps:
                    style,
                    creator:
                    style,
                    created:
                    style,
                })

        output.dump(output_format='table')

        print ""
예제 #14
0
파일: action.py 프로젝트: chippey/dpa-pipe
    def _print_ptask_stats(self):

        total_ptasks = 0
        total_vers = 0
        total_subs = 0
        total_products = 0
        total_product_vers = 0

        type_name = "Type"
        type_total = "Count"
        type_vers = "Versions"
        type_ver_avg = "Vers/PTask"
        type_products = "Products"
        type_prod_avg = "Prods/PTask"
        type_product_vers = "ProductVers"
        type_product_vers_avg1 = "ProductVer/PTaskVer"
        type_product_vers_avg2= "ProductVer/Product"
        type_subs = "Subs"
        type_subs_avg = "Subs/Ver"

        type_out = Output()
        type_out.title = "PTask Totals for : {pt} (by type)".format(
            pt=self._ptask.spec)

        type_out.header_names = [
            type_name,
            type_total,
            type_vers,
            type_ver_avg,
            type_products,
            type_prod_avg,
            type_product_vers,
            type_product_vers_avg1,
            type_product_vers_avg2,
            type_subs, 
            type_subs_avg
        ]

        type_out.set_header_alignment(
            {
                type_name: "right",
                type_total: "right",
                type_vers: "right",
                type_ver_avg: "right",
                type_products: "right",
                type_prod_avg: "right",
                type_product_vers: "right",
                type_product_vers_avg1: "right",
                type_product_vers_avg2: "right",
                type_subs: "right",
                type_subs_avg: "right",
            })

        for (ptask_type, ptask_type_count) in \
            sorted(self._data.ptasks.iteritems()):

            total_ptasks += ptask_type_count

            if ptask_type in self._data.ptask_versions:
                ver_count = self._data.ptask_versions[ptask_type]
                total_vers += ver_count
            else:
                ver_count = 0

            if ptask_type in self._data.ptask_products:
                product_count = self._data.ptask_products[ptask_type]
                total_products += product_count
            else:
                product_count = 0

            if ptask_type in self._data.ptask_product_versions:
                product_ver_count = self._data.ptask_product_versions[ptask_type]
                total_product_vers += product_ver_count
            else:
                product_ver_count = 0

            if ptask_type in self._data.ptask_subscriptions:
                subs_count = self._data.ptask_subscriptions[ptask_type]
                total_subs += subs_count
            else:
                subs_count = 0

            if ptask_type_count:
                type_ver_avg_val = \
                    '%.2f' % (ver_count / float(ptask_type_count))
                type_prod_avg_val = \
                    '%.2f' % (product_count / float(ptask_type_count))
            else:
                type_ver_avg_val = "?"
                type_prod_avg_val = "?"

            if ver_count:
                type_product_vers_avg1_val = \
                    "%.2f" % (product_ver_count / float(ver_count))
                type_subs_avg_val = \
                    '%.2f' % (subs_count / float(ver_count))
            else:
                type_product_vers_avg1_val = "?"
                type_subs_avg_val = "?"

            if product_count:
                type_product_vers_avg2_val = \
                    "%.2f" % (product_ver_count / float(product_count))
            else:
                type_product_vers_avg2_val = "?"

            type_out.add_item(
                {
                    type_name: ptask_type,
                    type_total: ptask_type_count,
                    type_vers: ver_count,
                    type_ver_avg: type_ver_avg_val,
                    type_products: product_count,
                    type_prod_avg: type_prod_avg_val,
                    type_product_vers: product_ver_count,
                    type_product_vers_avg1: type_product_vers_avg1_val, 
                    type_product_vers_avg2: type_product_vers_avg2_val,
                    type_subs: subs_count,
                    type_subs_avg: type_subs_avg_val,
                },
                color_all=Style.bright,
            )

        count = 'PTasks'
        versions = 'Versions'
        products = 'Products'
        product_vers = "ProductVers"
        subs = 'Subs'

        totals_out = Output()
        totals_out.title = "PTask Totals for : {pt}".format(pt=self._ptask.spec)
        totals_out.header_names = [
            count,
            versions,
            subs,
            products,
            product_vers,
        ]

        totals_out.set_header_alignment(
            {
                count: "right",
                versions: "right",
                products: "right",
                product_vers: "right",
                subs: "right",
            })
        totals_out.add_item(
            {
                count: total_ptasks,
                versions: total_vers,
                products: total_products,
                product_vers: total_product_vers,
                subs: total_subs,
            },
            color_all=Style.bright,
        )
        
        totals_out.dump(output_format='table')
        type_out.dump(output_format='table')
예제 #15
0
    def _print_ptask_stats(self):

        total_ptasks = 0
        total_vers = 0
        total_subs = 0
        total_products = 0
        total_product_vers = 0

        type_name = "Type"
        type_total = "Count"
        type_vers = "Versions"
        type_ver_avg = "Vers/PTask"
        type_products = "Products"
        type_prod_avg = "Prods/PTask"
        type_product_vers = "ProductVers"
        type_product_vers_avg1 = "ProductVer/PTaskVer"
        type_product_vers_avg2 = "ProductVer/Product"
        type_subs = "Subs"
        type_subs_avg = "Subs/Ver"

        type_out = Output()
        type_out.title = "PTask Totals for : {pt} (by type)".format(
            pt=self._ptask.spec)

        type_out.header_names = [
            type_name, type_total, type_vers, type_ver_avg, type_products,
            type_prod_avg, type_product_vers, type_product_vers_avg1,
            type_product_vers_avg2, type_subs, type_subs_avg
        ]

        type_out.set_header_alignment({
            type_name: "right",
            type_total: "right",
            type_vers: "right",
            type_ver_avg: "right",
            type_products: "right",
            type_prod_avg: "right",
            type_product_vers: "right",
            type_product_vers_avg1: "right",
            type_product_vers_avg2: "right",
            type_subs: "right",
            type_subs_avg: "right",
        })

        for (ptask_type, ptask_type_count) in \
            sorted(self._data.ptasks.iteritems()):

            total_ptasks += ptask_type_count

            if ptask_type in self._data.ptask_versions:
                ver_count = self._data.ptask_versions[ptask_type]
                total_vers += ver_count
            else:
                ver_count = 0

            if ptask_type in self._data.ptask_products:
                product_count = self._data.ptask_products[ptask_type]
                total_products += product_count
            else:
                product_count = 0

            if ptask_type in self._data.ptask_product_versions:
                product_ver_count = self._data.ptask_product_versions[
                    ptask_type]
                total_product_vers += product_ver_count
            else:
                product_ver_count = 0

            if ptask_type in self._data.ptask_subscriptions:
                subs_count = self._data.ptask_subscriptions[ptask_type]
                total_subs += subs_count
            else:
                subs_count = 0

            if ptask_type_count:
                type_ver_avg_val = \
                    '%.2f' % (ver_count / float(ptask_type_count))
                type_prod_avg_val = \
                    '%.2f' % (product_count / float(ptask_type_count))
            else:
                type_ver_avg_val = "?"
                type_prod_avg_val = "?"

            if ver_count:
                type_product_vers_avg1_val = \
                    "%.2f" % (product_ver_count / float(ver_count))
                type_subs_avg_val = \
                    '%.2f' % (subs_count / float(ver_count))
            else:
                type_product_vers_avg1_val = "?"
                type_subs_avg_val = "?"

            if product_count:
                type_product_vers_avg2_val = \
                    "%.2f" % (product_ver_count / float(product_count))
            else:
                type_product_vers_avg2_val = "?"

            type_out.add_item(
                {
                    type_name: ptask_type,
                    type_total: ptask_type_count,
                    type_vers: ver_count,
                    type_ver_avg: type_ver_avg_val,
                    type_products: product_count,
                    type_prod_avg: type_prod_avg_val,
                    type_product_vers: product_ver_count,
                    type_product_vers_avg1: type_product_vers_avg1_val,
                    type_product_vers_avg2: type_product_vers_avg2_val,
                    type_subs: subs_count,
                    type_subs_avg: type_subs_avg_val,
                },
                color_all=Style.bright,
            )

        count = 'PTasks'
        versions = 'Versions'
        products = 'Products'
        product_vers = "ProductVers"
        subs = 'Subs'

        totals_out = Output()
        totals_out.title = "PTask Totals for : {pt}".format(
            pt=self._ptask.spec)
        totals_out.header_names = [
            count,
            versions,
            subs,
            products,
            product_vers,
        ]

        totals_out.set_header_alignment({
            count: "right",
            versions: "right",
            products: "right",
            product_vers: "right",
            subs: "right",
        })
        totals_out.add_item(
            {
                count: total_ptasks,
                versions: total_vers,
                products: total_products,
                product_vers: total_product_vers,
                subs: total_subs,
            },
            color_all=Style.bright,
        )

        totals_out.dump(output_format='table')
        type_out.dump(output_format='table')
예제 #16
0
    def _print_product_stats(self):

        total_products = 0
        total_versions = 0
        total_reprs = 0
        total_files = 0

        # category
        # products
        # versions
        # representations
        # files

        cat_name = "Category"
        cat_products = "Products"
        cat_vers = "Versions"
        cat_reprs = "Representatiosn"
        cat_files = "Files"

        cat_out = Output()
        cat_out.title = "Product Totals for : {pt} (by category)".format(
            pt=self._ptask.spec)

        cat_out.header_names = [
            cat_name,
            cat_products,
            cat_vers,
            cat_reprs,
            cat_files,
        ]

        cat_out.set_header_alignment({
            cat_name: "right",
            cat_products: "right",
            cat_vers: "right",
            cat_reprs: "right",
            cat_files: "right",
        })

        for (category,
             category_count) in sorted(self._data.products.iteritems()):

            total_products += category_count

            if category in self._data.product_versions:
                ver_count = self._data.product_versions[category]
                total_versions += ver_count
            else:
                ver_count = 0

            if category in self._data.product_representations:
                repr_count = self._data.product_representations[category]
                total_reprs += repr_count
            else:
                repr_count = 0

            if category in self._data.product_repr_files:
                file_count = self._data.product_repr_files[category]
                total_files += file_count
            else:
                file_count = 0

            cat_out.add_item(
                {
                    cat_name: category,
                    cat_products: category_count,
                    cat_vers: ver_count,
                    cat_reprs: repr_count,
                    cat_files: file_count,
                },
                color_all=Style.bright,
            )

        count = 'Products'
        vers = 'Versions'
        reprs = 'Representations'
        files = 'Files'
        vers_product = "Vers/Product"
        reprs_version = "Reprs/Vers"
        files_repr = "Files/Repr"

        totals_out = Output()
        totals_out.title = "Product Totals for : {pt}".format(
            pt=self._ptask.spec)
        totals_out.header_names = [
            count,
            vers,
            reprs,
            files,
            vers_product,
            reprs_version,
            files_repr,
        ]

        totals_out.set_header_alignment({
            count: "right",
            vers: "right",
            reprs: "right",
            files: "right",
            vers_product: "right",
            reprs_version: "right",
            files_repr: "right",
        })

        if total_products:
            vers_product_val = \
                "%.2f" % (total_versions / float(total_products))
        else:
            vers_product_val = "?"

        if total_versions:
            reprs_version_val = \
                "%.2f" % (total_reprs / float(total_versions))
        else:
            reprs_version_val = "?"

        if total_reprs:
            files_repr_val = \
                "%.2f" % (total_files / float(total_reprs))
        else:
            files_repr_val = "?"

        totals_out.add_item(
            {
                count: total_products,
                vers: total_versions,
                reprs: total_reprs,
                files: total_files,
                vers_product: vers_product_val,
                reprs_version: reprs_version_val,
                files_repr: files_repr_val,
            },
            color_all=Style.bright,
        )

        totals_out.dump(output_format='table')

        file_type_hdr = 'Type'
        count = 'Count'

        types_out = Output()
        types_out.title = "Product Totals for : {pt} (by type)".format(
            pt=self._ptask.spec)

        types_out.header_names = [
            file_type_hdr,
            count,
        ]

        types_out.set_header_alignment({
            file_type_hdr: "right",
            count: "right",
        })

        for (file_type, file_type_count) in \
            sorted(self._data.product_repr_files_by_type.iteritems()):

            types_out.add_item(
                {
                    file_type_hdr: file_type,
                    count: file_type_count,
                },
                color_all=Style.bright,
            )

        cat_out.dump(output_format='table')
        types_out.dump(output_format='table')
예제 #17
0
파일: action.py 프로젝트: chippey/dpa-pipe
    def _print_product_stats(self):

        total_products = 0
        total_versions = 0
        total_reprs = 0
        total_files = 0

            # category
            # products
            # versions
            # representations
            # files

        cat_name = "Category"
        cat_products = "Products"
        cat_vers = "Versions"
        cat_reprs = "Representatiosn"
        cat_files = "Files"

        cat_out = Output()
        cat_out.title = "Product Totals for : {pt} (by category)".format(
            pt=self._ptask.spec)

        cat_out.header_names = [
            cat_name,
            cat_products,
            cat_vers,
            cat_reprs,
            cat_files,
        ]

        cat_out.set_header_alignment(
            {
                cat_name: "right",
                cat_products: "right",
                cat_vers: "right",
                cat_reprs: "right",
                cat_files: "right",
            })

        for (category, category_count) in sorted(self._data.products.iteritems()):

            total_products += category_count

            if category in self._data.product_versions:
                ver_count = self._data.product_versions[category]
                total_versions += ver_count
            else:
                ver_count = 0

            if category in self._data.product_representations:
                repr_count = self._data.product_representations[category]
                total_reprs += repr_count
            else:
                repr_count = 0

            if category in self._data.product_repr_files:
                file_count = self._data.product_repr_files[category] 
                total_files += file_count
            else:
                file_count = 0

            cat_out.add_item(
                {
                    cat_name: category,
                    cat_products: category_count,
                    cat_vers: ver_count,
                    cat_reprs: repr_count,
                    cat_files: file_count,
                },
                color_all=Style.bright,
            )
             
        count = 'Products'
        vers = 'Versions'
        reprs = 'Representations'
        files = 'Files'
        vers_product = "Vers/Product"
        reprs_version = "Reprs/Vers"
        files_repr = "Files/Repr"

        totals_out = Output()
        totals_out.title = "Product Totals for : {pt}".format(pt=self._ptask.spec)
        totals_out.header_names = [
            count,
            vers,
            reprs,
            files,
            vers_product,
            reprs_version,
            files_repr,
        ]

        totals_out.set_header_alignment(
            {
                count: "right",
                vers: "right",
                reprs: "right",
                files: "right",
                vers_product: "right",
                reprs_version: "right",
                files_repr: "right",
            }
        )

        if total_products:
            vers_product_val = \
                "%.2f" % (total_versions / float(total_products))
        else:
            vers_product_val = "?"

        if total_versions:
            reprs_version_val = \
                "%.2f" % (total_reprs / float(total_versions))
        else:
            reprs_version_val = "?"

        if total_reprs:
            files_repr_val = \
                "%.2f" % (total_files / float(total_reprs))
        else:
            files_repr_val = "?"

        totals_out.add_item(
            {
                count: total_products,
                vers: total_versions,
                reprs: total_reprs,
                files: total_files,
                vers_product: vers_product_val,
                reprs_version: reprs_version_val,
                files_repr: files_repr_val,
            },
            color_all=Style.bright,
        )
        
        totals_out.dump(output_format='table')

        file_type_hdr = 'Type'
        count = 'Count'

        types_out = Output()
        types_out.title = "Product Totals for : {pt} (by type)".format(
            pt=self._ptask.spec)

        types_out.header_names = [
            file_type_hdr,
            count,
        ]

        types_out.set_header_alignment(
            {
                file_type_hdr: "right",
                count: "right",
            }
        )

        for (file_type, file_type_count) in \
            sorted(self._data.product_repr_files_by_type.iteritems()):

            types_out.add_item(
                {
                    file_type_hdr: file_type,
                    count: file_type_count,
                },
                color_all=Style.bright,
            )

        cat_out.dump(output_format='table')
        types_out.dump(output_format='table')