aboutsummaryrefslogtreecommitdiffstats
path: root/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters')
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/__init__.py0
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/base.py75
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/commaseparated.py63
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/json_format.py53
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/shell.py65
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/table.py203
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/value.py44
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/yaml_format.py45
8 files changed, 0 insertions, 548 deletions
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/__init__.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/__init__.py
+++ /dev/null
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/base.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/base.py
deleted file mode 100644
index 920cb32..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/base.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# 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.
-
-"""Base classes for formatters.
-"""
-
-import abc
-
-import six
-
-
-@six.add_metaclass(abc.ABCMeta)
-class Formatter(object):
-
- @abc.abstractmethod
- def add_argument_group(self, parser):
- """Add any options to the argument parser.
-
- Should use our own argument group.
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class ListFormatter(Formatter):
- """Base class for formatters that know how to deal with multiple objects.
- """
-
- @abc.abstractmethod
- def emit_list(self, column_names, data, stdout, parsed_args):
- """Format and print the list from the iterable data source.
-
- Data values can be primitive types like ints and strings, or
- can be an instance of a :class:`FormattableColumn` for
- situations where the value is complex, and may need to be
- handled differently for human readable output vs. machine
- readable output.
-
- :param column_names: names of the columns
- :param data: iterable data source, one tuple per object
- with values in order of column names
- :param stdout: output stream where data should be written
- :param parsed_args: argparse namespace from our local options
-
- """
-
-
-@six.add_metaclass(abc.ABCMeta)
-class SingleFormatter(Formatter):
- """Base class for formatters that work with single objects.
- """
-
- @abc.abstractmethod
- def emit_one(self, column_names, data, stdout, parsed_args):
- """Format and print the values associated with the single object.
-
- Data values can be primitive types like ints and strings, or
- can be an instance of a :class:`FormattableColumn` for
- situations where the value is complex, and may need to be
- handled differently for human readable output vs. machine
- readable output.
-
- :param column_names: names of the columns
- :param data: iterable data source with values in order of column names
- :param stdout: output stream where data should be written
- :param parsed_args: argparse namespace from our local options
- """
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/commaseparated.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/commaseparated.py
deleted file mode 100644
index 46a7bc5..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/commaseparated.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# 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.
-
-"""Output formatters using csv format.
-"""
-
-import os
-import sys
-
-from .base import ListFormatter
-from cliff import columns
-
-import six
-
-if sys.version_info[0] == 3:
- import csv
-else:
- import unicodecsv as csv
-
-
-class CSVLister(ListFormatter):
-
- QUOTE_MODES = {
- 'all': csv.QUOTE_ALL,
- 'minimal': csv.QUOTE_MINIMAL,
- 'nonnumeric': csv.QUOTE_NONNUMERIC,
- 'none': csv.QUOTE_NONE,
- }
-
- def add_argument_group(self, parser):
- group = parser.add_argument_group('CSV Formatter')
- group.add_argument(
- '--quote',
- choices=sorted(self.QUOTE_MODES.keys()),
- dest='quote_mode',
- default='nonnumeric',
- help='when to include quotes, defaults to nonnumeric',
- )
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- writer = csv.writer(stdout,
- quoting=self.QUOTE_MODES[parsed_args.quote_mode],
- lineterminator=os.linesep,
- escapechar='\\',
- )
- writer.writerow(column_names)
- for row in data:
- writer.writerow(
- [(six.text_type(c.machine_readable())
- if isinstance(c, columns.FormattableColumn)
- else c)
- for c in row]
- )
- return
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/json_format.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/json_format.py
deleted file mode 100644
index 2af5260..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/json_format.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# 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.
-
-"""Output formatters for JSON.
-"""
-
-import json
-
-from . import base
-from cliff import columns
-
-
-class JSONFormatter(base.ListFormatter, base.SingleFormatter):
-
- def add_argument_group(self, parser):
- group = parser.add_argument_group(title='json formatter')
- group.add_argument(
- '--noindent',
- action='store_true',
- dest='noindent',
- help='whether to disable indenting the JSON'
- )
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- items = []
- for item in data:
- items.append(
- {n: (i.machine_readable()
- if isinstance(i, columns.FormattableColumn)
- else i)
- for n, i in zip(column_names, item)}
- )
- indent = None if parsed_args.noindent else 2
- json.dump(items, stdout, indent=indent)
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- one = {
- n: (i.machine_readable()
- if isinstance(i, columns.FormattableColumn)
- else i)
- for n, i in zip(column_names, data)
- }
- indent = None if parsed_args.noindent else 2
- json.dump(one, stdout, indent=indent)
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/shell.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/shell.py
deleted file mode 100644
index 6e7bae9..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/shell.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# 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.
-
-"""Output formatters using shell syntax.
-"""
-
-from . import base
-from cliff import columns
-
-import argparse
-import six
-
-
-class ShellFormatter(base.SingleFormatter):
-
- def add_argument_group(self, parser):
- group = parser.add_argument_group(
- title='shell formatter',
- description='a format a UNIX shell can parse (variable="value")',
- )
- group.add_argument(
- '--variable',
- action='append',
- default=[],
- dest='variables',
- metavar='VARIABLE',
- help=argparse.SUPPRESS,
- )
- group.add_argument(
- '--prefix',
- action='store',
- default='',
- dest='prefix',
- help='add a prefix to all variable names',
- )
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- variable_names = [c.lower().replace(' ', '_')
- for c in column_names
- ]
- desired_columns = parsed_args.variables
- for name, value in zip(variable_names, data):
- if name in desired_columns or not desired_columns:
- value = (six.text_type(value.machine_readable())
- if isinstance(value, columns.FormattableColumn)
- else value)
- if isinstance(value, six.string_types):
- value = value.replace('"', '\\"')
- if isinstance(name, six.string_types):
- # Colons and dashes may appear as a resource property but
- # are invalid to use in a shell, replace them with an
- # underscore.
- name = name.replace(':', '_')
- name = name.replace('-', '_')
- stdout.write('%s%s="%s"\n' % (parsed_args.prefix, name, value))
- return
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/table.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/table.py
deleted file mode 100644
index df4616b..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/table.py
+++ /dev/null
@@ -1,203 +0,0 @@
-# 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.
-
-"""Output formatters using prettytable.
-"""
-
-import prettytable
-import six
-import os
-
-from cliff import utils
-from . import base
-from cliff import columns
-
-
-def _format_row(row):
- new_row = []
- for r in row:
- if isinstance(r, columns.FormattableColumn):
- r = r.human_readable()
- if isinstance(r, six.string_types):
- r = r.replace('\r\n', '\n').replace('\r', ' ')
- new_row.append(r)
- return new_row
-
-
-class TableFormatter(base.ListFormatter, base.SingleFormatter):
-
- ALIGNMENTS = {
- int: 'r',
- str: 'l',
- float: 'r',
- }
- try:
- ALIGNMENTS[unicode] = 'l'
- except NameError:
- pass
-
- def add_argument_group(self, parser):
- group = parser.add_argument_group('table formatter')
- group.add_argument(
- '--max-width',
- metavar='<integer>',
- default=int(os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)),
- type=int,
- help=('Maximum display width, <1 to disable. You can also '
- 'use the CLIFF_MAX_TERM_WIDTH environment variable, '
- 'but the parameter takes precedence.'),
- )
- group.add_argument(
- '--print-empty',
- action='store_true',
- help='Print empty table if there is no data to show.',
- )
-
- def add_rows(self, table, column_names, data):
- # Figure out the types of the columns in the
- # first row and set the alignment of the
- # output accordingly.
- data_iter = iter(data)
- try:
- first_row = next(data_iter)
- except StopIteration:
- pass
- else:
- for value, name in zip(first_row, column_names):
- alignment = self.ALIGNMENTS.get(type(value), 'l')
- table.align[name] = alignment
- # Now iterate over the data and add the rows.
- table.add_row(_format_row(first_row))
- for row in data_iter:
- table.add_row(_format_row(row))
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- x = prettytable.PrettyTable(
- column_names,
- print_empty=parsed_args.print_empty,
- )
- x.padding_width = 1
-
- # Add rows if data is provided
- if data:
- self.add_rows(x, column_names, data)
-
- # Choose a reasonable min_width to better handle many columns on a
- # narrow console. The table will overflow the console width in
- # preference to wrapping columns smaller than 8 characters.
- min_width = 8
- self._assign_max_widths(
- stdout, x, int(parsed_args.max_width), min_width)
-
- formatted = x.get_string()
- stdout.write(formatted)
- stdout.write('\n')
- return
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- x = prettytable.PrettyTable(field_names=('Field', 'Value'),
- print_empty=False)
- x.padding_width = 1
- # Align all columns left because the values are
- # not all the same type.
- x.align['Field'] = 'l'
- x.align['Value'] = 'l'
- for name, value in zip(column_names, data):
- x.add_row(_format_row((name, value)))
-
- # Choose a reasonable min_width to better handle a narrow
- # console. The table will overflow the console width in preference
- # to wrapping columns smaller than 16 characters in an attempt to keep
- # the Field column readable.
- min_width = 16
- self._assign_max_widths(
- stdout, x, int(parsed_args.max_width), min_width)
-
- formatted = x.get_string()
- stdout.write(formatted)
- stdout.write('\n')
- return
-
- @staticmethod
- def _field_widths(field_names, first_line):
-
- # use the first line +----+-------+ to infer column widths
- # accounting for padding and dividers
- widths = [max(0, len(i) - 2) for i in first_line.split('+')[1:-1]]
- return dict(zip(field_names, widths))
-
- @staticmethod
- def _width_info(term_width, field_count):
- # remove padding and dividers for width available to actual content
- usable_total_width = max(0, term_width - 1 - 3 * field_count)
-
- # calculate width per column if all columns were equal
- if field_count == 0:
- optimal_width = 0
- else:
- optimal_width = max(0, usable_total_width // field_count)
-
- return usable_total_width, optimal_width
-
- @staticmethod
- def _build_shrink_fields(usable_total_width, optimal_width,
- field_widths, field_names):
- shrink_fields = []
- shrink_remaining = usable_total_width
- for field in field_names:
- w = field_widths[field]
- if w <= optimal_width:
- # leave alone columns which are smaller than the optimal width
- shrink_remaining -= w
- else:
- shrink_fields.append(field)
-
- return shrink_fields, shrink_remaining
-
- @staticmethod
- def _assign_max_widths(stdout, x, max_width, min_width=0):
- if min_width:
- x.min_width = min_width
-
- if max_width > 0:
- term_width = max_width
- else:
- term_width = utils.terminal_width(stdout)
- if not term_width:
- # not a tty, so do not set any max widths
- return
- field_count = len(x.field_names)
-
- try:
- first_line = x.get_string().splitlines()[0]
- if len(first_line) <= term_width:
- return
- except IndexError:
- return
-
- usable_total_width, optimal_width = TableFormatter._width_info(
- term_width, field_count)
-
- field_widths = TableFormatter._field_widths(x.field_names, first_line)
-
- shrink_fields, shrink_remaining = TableFormatter._build_shrink_fields(
- usable_total_width, optimal_width, field_widths, x.field_names)
-
- shrink_to = shrink_remaining // len(shrink_fields)
- # make all shrinkable fields size shrink_to apart from the last one
- for field in shrink_fields[:-1]:
- x.max_width[field] = max(min_width, shrink_to)
- shrink_remaining -= shrink_to
-
- # give the last shrinkable column shrink_to plus any remaining
- field = shrink_fields[-1]
- x.max_width[field] = max(min_width, shrink_remaining)
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/value.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/value.py
deleted file mode 100644
index 24125c0..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/value.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# 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.
-
-"""Output formatters values only
-"""
-
-import six
-
-from . import base
-from cliff import columns
-
-
-class ValueFormatter(base.ListFormatter, base.SingleFormatter):
-
- def add_argument_group(self, parser):
- pass
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- for row in data:
- stdout.write(
- ' '.join(
- six.text_type(c.machine_readable()
- if isinstance(c, columns.FormattableColumn)
- else c)
- for c in row) + u'\n')
- return
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- for value in data:
- stdout.write('%s\n' % six.text_type(
- value.machine_readable()
- if isinstance(value, columns.FormattableColumn)
- else value)
- )
- return
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/yaml_format.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/yaml_format.py
deleted file mode 100644
index 8b1e64d..0000000
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/cliff-2.4.0-py2.7.egg/cliff/formatters/yaml_format.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# 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.
-
-"""Output formatters using PyYAML.
-"""
-
-import yaml
-
-from . import base
-from cliff import columns
-
-
-class YAMLFormatter(base.ListFormatter, base.SingleFormatter):
-
- def add_argument_group(self, parser):
- pass
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- items = []
- for item in data:
- items.append(
- {n: (i.machine_readable()
- if isinstance(i, columns.FormattableColumn)
- else i)
- for n, i in zip(column_names, item)}
- )
- yaml.safe_dump(items, stream=stdout, default_flow_style=False)
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- for key, value in zip(column_names, data):
- dict_data = {
- key: (value.machine_readable()
- if isinstance(value, columns.FormattableColumn)
- else value)
- }
- yaml.safe_dump(dict_data, stream=stdout, default_flow_style=False)