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
#!/bin/bash | |
set -e | |
usage="$(basename "$0") [-h] [-i PROJECT] [-v VM] [-p PYTHON] [-d NOTEBOOKS] | |
Make a user provide SSH key and jupyter notebooks (in roles/bootstrap/files/notebooks) to each user listed in var/common.yml | |
where: | |
-h show this help text | |
-i google cloud project id | |
-v name of instance/virtual machine | |
-p python path |
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
""" | |
Download the latest wiki dump files for a language, | |
If from_date is passed, the latest before that date is downloaded | |
""" | |
import requests | |
from datetime import datetime | |
from datetime import timedelta | |
from string import Template | |
from tqdm import tqdm |
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
from collections import defaultdict | |
from pprint import pprint | |
from django.db.models.query import QuerySet | |
def parse_annotated_query_set(qs: QuerySet, nest_level: int = 1) -> dict: | |
""" | |
This function parses annotated query sets and returns a nested dictionary. | |
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
import re | |
CURRENCY_LIST = {"£": "pounds", "$": "dollars", "€": "euros"} | |
CURRENCY_PATTERN = fr"((?:[{''.join(CURRENCY_LIST.keys())}]+\d*)(?:\,*\d+)(?:\.\d+)?(?i:[km])*)|(\d+(?:\,*\d+)(?:\.\d+)?(?i:[km])*(?:[{''.join(CURRENCY_LIST.keys())}]+))|((?:[{''.join(CURRENCY_LIST.keys())}]+))" | |
def _currency_to_text(text: str) -> str: | |
clean = ( | |
lambda x: x.lower() | |
.replace(",", "") |