Skip to content

Commit

Permalink
Improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed Aug 27, 2024
1 parent 804cdcb commit db09d8d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions osmcha/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class InvalidChangesetError(Exception):


def get_user_details(user_id):
"""Get information about number of changesets, blocks and mapping days of a
user, using both the OSM API and the Mapbox comments APIself.
"""Get information about the number of changesets, blocks and mapping days
of a user, using the OSM API.
"""
reasons = []
try:
Expand Down Expand Up @@ -240,7 +240,7 @@ def get_area(self, geojson):
)

def filter(self):
"""Filter the changesets that intersects with the geojson geometry."""
"""Filter the changesets that intersect with the geojson geometry."""
self.content = [
ch
for ch in self.xml
Expand All @@ -249,15 +249,15 @@ def filter(self):


class Analyse(object):
"""Analyse a changeset and define if it is suspect."""
"""Analyse a changeset and evaluate if it is suspect."""

def __init__(self, changeset, create_threshold=200, modify_threshold=200,
delete_threshold=30, percentage=0.7, top_threshold=1000,
suspect_words=WORDS['common'] + WORDS['sources'],
illegal_sources=WORDS['sources'], excluded_words=WORDS['exclude']):
if type(changeset) in [int, str]:
self.set_fields(changeset_info(get_metadata(changeset)))
elif type(changeset) == dict:
elif type(changeset) is dict:
self.set_fields(changeset)
else:
raise InvalidChangesetError(
Expand All @@ -275,7 +275,7 @@ def __init__(self, changeset, create_threshold=200, modify_threshold=200,
self.suspect_words = suspect_words

def set_fields(self, changeset):
"""Set the fields of this class with the metadata of the analysed
"""Set the class attributes with the metadata of the analysed
changeset.
"""
self.id = int(changeset.get('id'))
Expand Down Expand Up @@ -321,7 +321,7 @@ def label_suspicious(self, reason):
self.is_suspect = True

def full_analysis(self):
"""Execute the count and verify_words methods."""
"""Execute the count and verify methods."""
self.count()
self.verify_words()
self.verify_user()
Expand All @@ -337,8 +337,9 @@ def verify_warning_tags(self):
self.label_suspicious(item)

def verify_user(self):
"""Verify if the changeset was made by a inexperienced mapper (anyone
with less than 5 edits) or by a user that was blocked more than once.
"""Verify if the changeset was created by a inexperienced mapper
(anyone with less than 5 edits) or by a user that was blocked more
than once.
"""
user_reasons = get_user_details(self.uid)
[self.label_suspicious(reason) for reason in user_reasons]
Expand Down

0 comments on commit db09d8d

Please sign in to comment.