text
stringlengths 1
93.6k
|
|---|
elif confidence_level >= 25:
|
analysis_result += "\nConfidence level: MODERATE (%s%%)" % confidence_level
|
elif confidence_level < 25:
|
analysis_result += "\nConfidence level: LOW (%s%%)" % confidence_level
|
elif confidence_level == 0:
|
analysis_result += "\nConfidence level: VERY LOW (%s%%)" % confidence_level
|
analysis_result += "\n"
|
print(analysis_result)
|
analysis_results += analysis_result
|
return analysis_results
|
def github_search(query, per_page="100", page_num="1"):
|
# Github Search API endpoint for code on Github
|
github_endpoint = "https://api.github.com/search/code?q=\"%s\"&per_page=%s&page=%s&access_token=%s" % (keyword, per_page, page_num, GITHUB_API_TOKEN)
|
# Make the request
|
req = requests.get(github_endpoint)
|
# Save the response in data
|
data = json.loads(req.content)
|
# For each repo name, append it to the global repo list
|
for result in data.get('items'):
|
# Fetch the repo name and add it to the list of repos seen in results
|
repo_name = result['repository']['full_name']
|
repos.append(repo_name)
|
# Return the total number of results and the items
|
return data.get('total_count'), data.get('items')
|
def github_confirmation(repo, confirms):
|
try:
|
# Sleep for 5 seconds to avoid going over the API rate limit
|
time.sleep(5)
|
# Github Search API endpoint, limited to specific repository code
|
github_endpoint = "https://api.github.com/search/code?q=\"%s\"+repo:%s&access_token=%s" % (confirms, repo, GITHUB_API_TOKEN)
|
# Make the request
|
req = requests.get(github_endpoint)
|
# Save the response in data
|
data = json.loads(req.content)
|
result_count = data.get('total_count')
|
# Rate limit has been hit, sleep and try again
|
while result_count == None:
|
print("Rate limit is being hit, sleeping for 10 seconds...")
|
time.sleep(10)
|
result_count = data.get('total_count')
|
# Return total number of successful confirm keyword hits
|
return result_count
|
except Exception as e:
|
return e
|
if __name__ == "__main__":
|
try:
|
# If user supplied a second argument, then perform a search with confirmation keywords
|
if len(sys.argv) == 3:
|
keyword = sys.argv[1]
|
confirm_words = sys.argv[2].split(",")
|
result = main(keyword, confirm_words)
|
# Otherwise, just perform a search with informant keyword
|
else:
|
keyword = sys.argv[1]
|
result = main(keyword)
|
except Exception as e:
|
print(e)
|
# <FILESEP>
|
# -*- coding: utf-8 -*-
|
# ---
|
# jupyter:
|
# jupytext:
|
# formats: ipynb,py:hydrogen
|
# text_representation:
|
# extension: .py
|
# format_name: hydrogen
|
# format_version: '1.3'
|
# jupytext_version: 1.9.1
|
# kernelspec:
|
# display_name: Python 3 (ipykernel)
|
# language: python
|
# name: python3
|
# ---
|
# %% [markdown]
|
# # Day 24 : Historical
|
#
|
# Historical data, historical style or something else.
|
# %%
|
import shutil
|
import zipfile
|
import pygmt
|
import geopandas as gpd
|
import requests
|
# %% [markdown]
|
# ## Download Middle Earth data!
|
#
|
# GIS layers for Middle Earth! Includes a 50m spatial resolution DEM in GeoTIFF
|
# format and various shapefiles of vector features. Retrieved from
|
# https://doi.org/10.21220/rkez-x707 or https://scholarworks.wm.edu/asoer/3
|
#
|
# Inspired by:
|
# - https://twitter.com/pokateo_/status/1458844709116391425
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.