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)
| 396 | |
| 397 | |
| 398 | def 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 |