Skip to content

Commit 527e663

Browse files
committed
Add docstrings!
Signed-off-by: Ritiek Malhotra <ritiekmalhotra123@gmail.com>
1 parent 92c4604 commit 527e663

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/packagedcode/cargo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,38 @@ def build_package(package_data):
137137

138138

139139
def party_mapper(party, package, party_type):
140+
"""
141+
Update package parties with party of `party_type` and return package.
142+
https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional
143+
"""
140144
for auth in party:
141145
name, email = parse_person(auth)
142146
package.parties.append(models.Party(
143147
type=models.party_person,
144148
name=name,
145149
role=party_type,
146150
email=email))
151+
147152
return package
148153

149154

150155
def parse_person(person):
156+
"""
157+
https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field-optional
158+
A "person" is an object with an optional "name" or "email" field.
159+
160+
A person can be in the form:
161+
"author": "Isaac Z. Schlueter <i@izs.me>"
162+
163+
For example:
164+
>>> parse_person('Barney Rubble <b@rubble.com>')
165+
('Barney Rubble', u'b@rubble.com')
166+
>>> parse_person('Barney Rubble')
167+
('Barney Rubble', None)
168+
>>> parse_person('<b@rubble.com>')
169+
(None, u'b@rubble.com')
170+
"""
171+
151172
parsed = person_parser(person)
152173
if not parsed:
153174
name = None

0 commit comments

Comments
 (0)