MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / parse_person

Function parse_person

src/packagedcode/cargo.py:398–429  ·  view source on GitHub ↗

https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional A "person" is an object with an optional "name" or "email" field. A person can be in the form: "author": "Isaac Z. Schlueter " For example: >>> p = parse_person('Barney Rubble <b

(person)

Source from the content-addressed store, hash-verified

396
397
398def parse_person(person):
399 """
400 https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional
401 A "person" is an object with an optional "name" or "email" field.
402
403 A person can be in the form:
404 "author": "Isaac Z. Schlueter <i@izs.me>"
405
406 For example:
407 >>> p = parse_person('Barney Rubble <b@rubble.com>')
408 >>> assert p == ('Barney Rubble', 'b@rubble.com')
409 >>> p = parse_person('Barney Rubble')
410 >>> assert p == ('Barney Rubble', None)
411 >>> p = parse_person('<b@rubble.com>')
412 >>> assert p == (None, 'b@rubble.com')
413 """
414
415 parsed = person_parser(person)
416 if not parsed:
417 name = None
418 parsed = person_parser_no_name(person)
419 else:
420 name = parsed.group('name')
421
422 email = parsed.group('email')
423
424 if name:
425 name = name.strip()
426 if email:
427 email = email.strip('<> ')
428
429 return name, email

Callers 1

get_partiesFunction · 0.70

Calls 1

groupMethod · 0.80

Tested by

no test coverage detected