MCPcopy Index your code
hub / github.com/rawpython/remi / parse_parametrs

Function parse_parametrs

remi/server.py:314–330  ·  view source on GitHub ↗

Parses the parameters given from POST or websocket reqs expecting the parameters as: "11|par1='asd'|6|par2=1" returns a dict like {par1:'asd',par2:1}

(p)

Source from the content-addressed store, hash-verified

312
313
314def parse_parametrs(p):
315 """
316 Parses the parameters given from POST or websocket reqs
317 expecting the parameters as: "11|par1='asd'|6|par2=1"
318 returns a dict like {par1:'asd',par2:1}
319 """
320 ret = {}
321 while len(p) > 1 and p.count('|') > 0:
322 s = p.split('|')
323 l = int(s[0]) # length of param field
324 if l > 0:
325 p = p[len(s[0]) + 1:]
326 field_name = p.split('|')[0].split('=')[0]
327 field_value = p[len(field_name) + 1:l]
328 p = p[l + 1:]
329 ret[field_name] = field_value
330 return ret
331
332
333# noinspection PyPep8Naming

Callers 1

on_messageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected