Institution for developing agency
This commit is contained in:
parent
a4f98a6492
commit
54c42f0a82
2 changed files with 41 additions and 6 deletions
|
@ -201,6 +201,8 @@ def mapDeployment(entry):
|
||||||
global args
|
global args
|
||||||
city = mapCity(entry)
|
city = mapCity(entry)
|
||||||
mapInstitution(entry)
|
mapInstitution(entry)
|
||||||
|
if entry['Vendor'] and len(entry['Vendor'].strip()) > 0:
|
||||||
|
mapDeveloperInstitution(entry['Vendor'])
|
||||||
tech = mapTechnology(entry)
|
tech = mapTechnology(entry)
|
||||||
return {
|
return {
|
||||||
'title': f"{entry['Vendor']} {entry['Technology']} used by {entry['Agency']}".replace(' '," ").strip(),
|
'title': f"{entry['Vendor']} {entry['Technology']} used by {entry['Agency']}".replace(' '," ").strip(),
|
||||||
|
@ -295,6 +297,23 @@ def mapInstitution(entry):
|
||||||
else:
|
else:
|
||||||
institutions[entry['Agency']] = info
|
institutions[entry['Agency']] = info
|
||||||
|
|
||||||
|
def mapDeveloperInstitution(title):
|
||||||
|
|
||||||
|
if title in institutions:
|
||||||
|
return
|
||||||
|
|
||||||
|
institutions[title] = {
|
||||||
|
'title': title,
|
||||||
|
'@type': 'Institution',
|
||||||
|
'properties': {
|
||||||
|
},
|
||||||
|
"additionalProperties": {
|
||||||
|
"Needs content": "Yes",
|
||||||
|
'CiteRef': args.citeref,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def mapCity(entry):
|
def mapCity(entry):
|
||||||
title = f"{entry['City']} ({entry['State']})"
|
title = f"{entry['City']} ({entry['State']})"
|
||||||
if title not in cities:
|
if title not in cities:
|
||||||
|
@ -310,7 +329,7 @@ def mapCity(entry):
|
||||||
}
|
}
|
||||||
|
|
||||||
if not args.skip_geolocation:
|
if not args.skip_geolocation:
|
||||||
location_response = geocoder.geocode(title + " USA")
|
location_response = geocoder.geocode(f"{entry['City']}, {entry['State']}, USA")
|
||||||
sleep(1) # free tier of location geocode requires 1 sec delay
|
sleep(1) # free tier of location geocode requires 1 sec delay
|
||||||
if location_response:
|
if location_response:
|
||||||
location = location_response.raw
|
location = location_response.raw
|
||||||
|
@ -419,7 +438,7 @@ if __name__ == "__main__":
|
||||||
parsedData=[]
|
parsedData=[]
|
||||||
with open(args.csv, newline='') as csvfile:
|
with open(args.csv, newline='') as csvfile:
|
||||||
csvreader = csv.DictReader(csvfile, delimiter=',')
|
csvreader = csv.DictReader(csvfile, delimiter=',')
|
||||||
for row in csvreader:
|
for row in tqdm.tqdm(csvreader):
|
||||||
data = mapEntry(row)
|
data = mapEntry(row)
|
||||||
if data is None:
|
if data is None:
|
||||||
continue
|
continue
|
||||||
|
@ -433,10 +452,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
for i, data in enumerate(parsedData):
|
for i, data in enumerate(parsedData):
|
||||||
page = renderPage(data)
|
page = renderPage(data)
|
||||||
# if data['@type'] == "Institution":
|
# if data['@type'] == 'City': #only for city as to update coordinates
|
||||||
# print(data['title'])
|
|
||||||
# print(page)
|
|
||||||
# break
|
|
||||||
saveIfNotExists(data, page, session, token)
|
saveIfNotExists(data, page, session, token)
|
||||||
|
|
||||||
# if i > 5:
|
# if i > 5:
|
||||||
|
|
19
fix_blockquote.py
Normal file
19
fix_blockquote.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import re, os
|
||||||
|
|
||||||
|
regex = r"(?<=(?<=>).)( \[\[CiteRef::atlasofsurveillance2022\]\]<\/blockquote>\n\n<blockquote>)"
|
||||||
|
|
||||||
|
files = [f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('.mw')]
|
||||||
|
|
||||||
|
for f in files:
|
||||||
|
with open(f, 'r') as fp:
|
||||||
|
contents = fp.read()
|
||||||
|
|
||||||
|
# You can manually specify the number of replacements by changing the 4th argument
|
||||||
|
result = re.sub(regex, "", contents, 0, re.MULTILINE)
|
||||||
|
if contents != result:
|
||||||
|
print (f)
|
||||||
|
with open(f, 'w') as fp:
|
||||||
|
fp.write(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue