-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (49 loc) · 1.91 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
# encoding: utf-8
# code: main
# purpose: build csv of validators and non-validators
from validator import validator
import requests
import pandas as pd
#%% GET LIST OF VALIDATORS
#get users from osm stats, reduce to list of users
usersJSON = requests.get("http://osmstats.redcross.org/users").json()
#%% GET LIST OF USERS' # EDITS, # VALIDATIONS, and EDITOR USED
# list to hold dictionaries for each to be used to make dataframe
usersInfoList = []
for user in usersJSON:
# create validator object for current user, grab edits and stats
user = validator(user['name'],user['id'])
user.userStats()
user.userChangesetsAge()
# use badge pointer here (bit.ly/2nUQfaP) to guess rough # edits made
numVal = [i["level"] for i in user.osmStats['badges'] if i["name"] == "Scrutinizer"]
# TODO: Need to figure out how # are being generated. very crude measure currently
if 3 in numVal:
numVal = 100
elif 2 in numVal:
numVal = 50
elif 1 in numVal:
numVal = 25
else:
numVal = 0
# append validator info of interest usersInfoList
usersInfoList.append({
"user_name": user.name,
"user_id": user.uid,
"build_count_add":user.osmStats['total_building_count_add'],
"build_count_mod":user.osmStats['total_building_count_mod'],
"poi_count_add":user.osmStats['total_poi_count_add'],
"road_km_add":user.osmStats['total_road_km_add'],
"road_km_mod":user.osmStats['total_road_km_mod'],
"waterway_km_add":user.osmStats['total_waterway_count_add'],
"validations": numVal,
"changesets": user.changesets,
"acct_age": user.acctAge,
"mapping_freq": user.userMapFreq(),
"josm_edits": user.osmStats['total_josm_edit_count']
})
print(user.name)
#%% MAKE/WRITE DATAFRAME FROM usersInfoList
validators = pd.DataFrame(usersInfoList)
validators.to_csv('output/validators.csv')