-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jackson-upgrade
- Loading branch information
Showing
298 changed files
with
1,446 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ metadata-ingestion/generated/** | |
|
||
# docs | ||
docs/generated/ | ||
docs-website/versioned_docs/ | ||
tmp* | ||
temp/** | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import tarfile | ||
import urllib.request | ||
import json | ||
|
||
repo_url = "https://api.github.com/repos/datahub-project/static-assets" | ||
|
||
|
||
def download_file(url, destination): | ||
with urllib.request.urlopen(url) as response: | ||
with open(destination, "wb") as f: | ||
while True: | ||
chunk = response.read(8192) | ||
if not chunk: | ||
break | ||
f.write(chunk) | ||
|
||
|
||
def fetch_tar_urls(repo_url, folder_path): | ||
api_url = f"{repo_url}/contents/{folder_path}" | ||
response = urllib.request.urlopen(api_url) | ||
data = response.read().decode('utf-8') | ||
tar_urls = [ | ||
file["download_url"] for file in json.loads(data) if file["name"].endswith(".tar.gz") | ||
] | ||
print(tar_urls) | ||
return tar_urls | ||
|
||
|
||
def main(): | ||
folder_path = "versioned_docs" | ||
destination_dir = "versioned_docs" | ||
if not os.path.exists(destination_dir): | ||
os.makedirs(destination_dir) | ||
|
||
tar_urls = fetch_tar_urls(repo_url, folder_path) | ||
|
||
for url in tar_urls: | ||
filename = os.path.basename(url) | ||
destination_path = os.path.join(destination_dir, filename) | ||
|
||
version = '.'.join(filename.split('.')[:3]) | ||
extracted_path = os.path.join(destination_dir, version) | ||
print("extracted_path", extracted_path) | ||
if os.path.exists(extracted_path): | ||
print(f"{extracted_path} already exists, skipping downloads") | ||
continue | ||
try: | ||
download_file(url, destination_path) | ||
print(f"Downloaded {filename} to {destination_dir}") | ||
with tarfile.open(destination_path, "r:gz") as tar: | ||
tar.extractall() | ||
os.remove(destination_path) | ||
except urllib.error.URLError as e: | ||
print(f"Error while downloading {filename}: {e}") | ||
continue | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.