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

Function parse_listing

tests/utils/plugins_cli.py:131–163  ·  view source on GitHub ↗
(lines: List[str])

Source from the content-addressed store, hash-verified

129
130
131def parse_listing(lines: List[str]) -> Dict[str, Any]:
132 plugins = {}
133 current_plugin = None
134
135 def parse_entry_point(line: str) -> Tuple[str, str]:
136 entry_point, raw_group = line.strip().split()
137 return entry_point, raw_group[1:-1]
138
139 def parse_plugin(line: str) -> Tuple[str, str]:
140 plugin, raw_version = line.strip().split()
141 return plugin, raw_version[1:-1]
142
143 for line in lines:
144 if not line.strip():
145 continue
146
147 if line[0].isspace():
148 # <indent> $entry_point ($group)
149 assert current_plugin is not None
150 entry_point, group = parse_entry_point(line)
151 plugins[current_plugin]['entry_points'].append({
152 'name': entry_point,
153 'group': group
154 })
155 else:
156 # $plugin ($version)
157 current_plugin, version = parse_plugin(line)
158 plugins[current_plugin] = {
159 'version': version,
160 'entry_points': []
161 }
162
163 return plugins
164
165
166@pytest.fixture(scope='function')

Callers 5

test_plugins_listingFunction · 0.90
test_plugins_upgradeFunction · 0.90
test_broken_pluginsFunction · 0.90

Calls 2

parse_entry_pointFunction · 0.85
parse_pluginFunction · 0.85

Tested by 5

test_plugins_listingFunction · 0.72
test_plugins_upgradeFunction · 0.72
test_broken_pluginsFunction · 0.72