def dict_to_cli_options(params): for k, v in params.items(): # Omit boolean options set to false or None, but preserve options with an empty # string argument. if v is not False and v is not None: # we need special handling for 'with' since it is a reserved # keyword in Python, so we call it 'decospecs' in click args if k == 'decospecs': k = 'with' k = k.replace('_', '-') if not isinstance(v, tuple): v = [v] for value in v: yield '--%s' % k if not isinstance(value, bool): value = to_unicode(value) # Of the value starts with $, assume the caller wants shell variable # expansion to happen, so we pass it as is. # NOTE: We strip '\' to allow for various backends to use escaped # shell variables as well. if value.lstrip("\\").startswith("$"): yield value else: # Otherwise, assume it is a literal value and quote it safely yield _quote(value)
def quote(command): """Extension of the standard shutil.quote that handles both strings and lists of strings. This mirrors how the subprocess package can handle commands as both a standalone string or list of strings. >>> quote('/Applications/App Store.app') "'/Applications/App Store.app'" >>> quote(['rm', '-rf', '~/Documents/My Homework']) "rm -rf '~/Documents/My Homework'" """ if isinstance(command, (str, )): return _quote(command) if isinstance(command, collections.Iterable): return ' '.join([_quote(arg) for arg in _normalize_args(command)]) raise ValueError('Invalid command type: {}'.format(type(command).__name__))
<section> Defines a section in the document <summary> Defines a visible heading for a <details> element <time> Defines a date/time <wbr> Defines a possible line-break Form elements, delete as added: <datalist> Defines pre-defined options for input controls <keygen> Defines a key-pair generator field (for forms) <output> Defines the result of a calculation """ from __future__ import division, absolute_import, print_function from pipes import quote as _quote import sys as _sys print('executing document/__init__.py, name, sys.argv:') print(__name__) print(' '.join(_quote(s) for s in _sys.argv)) #__all__ = ['A', 'Abbr', 'Address', 'Anchor', 'Area', 'Article', # 'Aside', 'Audio', 'Author', 'Base', 'Blockquote', 'Body', # 'Br', 'Canvas', 'Circle', 'Code', 'Comment', 'Datalist', # 'Description', 'Details', 'Document', 'Elem', 'ElemContainer', # 'EmailLink', 'Embed', 'Footer', 'Form', 'H1', 'H2', 'H3', 'H4', # 'H5', 'H6', 'Head', 'Header', 'HyperLink', 'Image', 'Img', 'Input', # 'KBD', 'Keywords', 'LI', 'LineBreak', 'Link', 'ListItem', 'Map', # 'Meta', 'Nav', 'OL', 'Option', 'OrderedList', 'P', 'Paragraph', # 'Q', 'QuoteInline', 'Robots', 'SVG', 'Samp', 'Script', 'Section', # 'Source', 'TextOnly', 'Title', 'Track', 'UL', 'UnorderedList', # 'Var', 'Video', 'writeout'] def _indent(html, space=' '):