MCPcopy Create free account
hub / github.com/aws/aws-cli / CommandParameters

Class CommandParameters

awscli/customizations/s3/subcommands.py:1735–2049  ·  view source on GitHub ↗

This class is used to do some initial error based on the parameters and arguments passed to the command line.

Source from the content-addressed store, hash-verified

1733# parameters property right now is a dictionary that holds arbitrary
1734# key/value pairs making it difficult to know what is supported.
1735class CommandParameters:
1736 """
1737 This class is used to do some initial error based on the
1738 parameters and arguments passed to the command line.
1739 """
1740
1741 def __init__(
1742 self, cmd, parameters, usage, session=None, parsed_globals=None
1743 ):
1744 """
1745 Stores command name and parameters. Ensures that the ``dir_op`` flag
1746 is true if a certain command is being used.
1747
1748 :param cmd: The name of the command, e.g. "rm".
1749 :param parameters: A dictionary of parameters.
1750 :param usage: A usage string
1751
1752 """
1753 self.cmd = cmd
1754 self.parameters = parameters
1755 self.usage = usage
1756 self._session = session
1757 self._parsed_globals = parsed_globals
1758 if 'dir_op' not in parameters:
1759 self.parameters['dir_op'] = False
1760 if 'follow_symlinks' not in parameters:
1761 self.parameters['follow_symlinks'] = True
1762 if 'source_region' not in parameters:
1763 self.parameters['source_region'] = None
1764 if self.cmd in ['sync', 'mb', 'rb']:
1765 self.parameters['dir_op'] = True
1766 if self.cmd == 'mv':
1767 self.parameters['is_move'] = True
1768 else:
1769 self.parameters['is_move'] = False
1770
1771 def add_paths(self, paths):
1772 """
1773 Reformats the parameters dictionary by including a key and
1774 value for the source and the destination. If a destination is
1775 not used the destination is the same as the source to ensure
1776 the destination always have some value.
1777 """
1778 self.check_path_type(paths)
1779 self._normalize_s3_trailing_slash(paths)
1780 src_path = paths[0]
1781 self.parameters['src'] = src_path
1782 if len(paths) == 2:
1783 self.parameters['dest'] = paths[1]
1784 elif len(paths) == 1:
1785 self.parameters['dest'] = paths[0]
1786 self._validate_streaming_paths()
1787 self._validate_no_overwrite_for_download_streaming()
1788 self._validate_path_args()
1789 self._validate_sse_c_args()
1790 self._validate_not_s3_express_bucket_for_sync()
1791
1792 def _validate_not_s3_express_bucket_for_sync(self):

Calls

no outgoing calls