MCPcopy Index your code
hub / github.com/httpie/cli / serialize

Method serialize

httpie/cli/options.py:113–165  ·  view source on GitHub ↗
(self, *, isolation_mode: bool = False)

Source from the content-addressed store, hash-verified

111 self.configuration['help'] = f'\n{short_help}\n\n'
112
113 def serialize(self, *, isolation_mode: bool = False) -> Dict[str, Any]:
114 configuration = self.configuration.copy()
115
116 # Unpack the dynamically computed choices, since we
117 # will need to store the actual values somewhere.
118 action = configuration.pop('action', None)
119 short_help = configuration.pop('short_help', None)
120 nested_options = configuration.pop('nested_options', None)
121
122 if action == 'lazy_choices':
123 choices = LazyChoices(
124 self.aliases,
125 **{'dest': None, **configuration},
126 isolation_mode=isolation_mode
127 )
128 configuration['choices'] = list(choices.load())
129 configuration['help'] = choices.help
130
131 result = {}
132 if self.aliases:
133 result['options'] = self.aliases.copy()
134 else:
135 result['options'] = [configuration['metavar']]
136 result['is_positional'] = True
137
138 qualifiers = JSON_QUALIFIER_TO_OPTIONS[configuration.get('nargs', Qualifiers.SUPPRESS)]
139 result.update(qualifiers)
140
141 description = configuration.get('help')
142 if description and description is not Qualifiers.SUPPRESS:
143 result['short_description'] = short_help
144 result['description'] = description
145
146 if nested_options:
147 result['nested_options'] = nested_options
148
149 python_type = configuration.get('type')
150 if python_type is not None:
151 if hasattr(python_type, '__name__'):
152 type_name = python_type.__name__
153 else:
154 type_name = type(python_type).__name__
155
156 result['python_type_name'] = type_name
157
158 result.update({
159 key: value
160 for key, value in configuration.items()
161 if key in JSON_DIRECT_MIRROR_OPTIONS
162 if value is not Qualifiers.SUPPRESS
163 })
164
165 return result
166
167 @property
168 def is_positional(self):

Callers

nothing calls this directly

Calls 5

loadMethod · 0.95
LazyChoicesClass · 0.90
getMethod · 0.80
updateMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected