Exemplo n.º 1
0
def print_names():
    data = get_names("https://apidata.mos.ru/v1/datasets/2009/rows")
    result = '''
	<table>
		<tr>
			<th>Имя</th>
			<th>Год</th>
			<th>Месяц</th>
			<th>Количество</th>
		</tr>
	'''
    if data:
        for name in data:
            result += '<tr>'
            result += '<td>{}</td>'.format(name['Cells']['Name'])
            result += '<td>{}</td>'.format(name['Cells']['Year'])
            result += '<td>{}</td>'.format(name['Cells']['Month'])
            result += '<td>{}</td>'.format(name['Cells']['NumberOfPersons'])
            result += '</tr>\n'

    result += '''
			</table>
	'''

    return result
Exemplo n.º 2
0
def cross_reference():
    from names import names as get_names
    from itertools import chain
    names = chain(*get_names().values())
    name_to_canonical = dict(
        (name['Name'], name['Canonical'])
        for name in names
    )
    scrapings = scrape()
    table = sorted(
        (
            canonical,
            ('1' if canonical else ''), # mapped
            ('1' if canonical else ''), # mapable
            " / ".join(names),
            '', # description
            'Tolkien Gateway', # source
            link
        )
        for link, names in inverse_reference(scrapings).items()
        for canonical in set(
            name_to_canonical[name]
            for name in names
            if name in name_to_canonical
        ) or ['']
    )
    return table
Exemplo n.º 3
0
def year_born(years_born):
    data = get_names("https://apidata.mos.ru/v1/datasets/2009/rows")
    years_id = [name for name in data if name['Cells']['Year'] == years_born]

    result = '''
	<table>
		<tr>
			<th>Имя</th>
			<th>Год</th>
			<th>Месяц</th>
			<th>Количество</th>
		</tr>
	'''
    if years_id:
        for name in years_id:
            result += '<tr>'
            result += '<td>{}</td>'.format(name['Cells']['Name'])
            result += '<td>{}</td>'.format(name['Cells']['Year'])
            result += '<td>{}</td>'.format(name['Cells']['Month'])
            result += '<td>{}</td>'.format(name['Cells']['NumberOfPersons'])
            result += '</tr>\n'

    result += '''
			</table>
		'''

    return 'Дети одного года %s' % result
Exemplo n.º 4
0
def print_names():
    year = int(request.args.get('year'))

    data = get_names("https://apidata.mos.ru/v1/datasets/2009/rows")

    years_born = [name for name in data if name['Cells']['Year'] == year]

    result = '''
	<table>
		<tr>
			<th>Имя</th>
			<th>Год</th>
			<th>Месяц</th>
			<th>Количество</th>
		</tr>
	'''

    for name in years_born:
        result += '<tr>'
        result += '<td>{}</td>'.format(name['Cells']['Name'])
        result += '<td>{}</td>'.format(name['Cells']['Year'])
        result += '<td>{}</td>'.format(name['Cells']['Month'])
        result += '<td>{}</td>'.format(name['Cells']['NumberOfPersons'])
        result += '</tr>\n'

    result += '''
			</table>
	'''

    return result
Exemplo n.º 5
0
def display_names():
    print("this happens")
    arg = request.args.get("names")
    if not arg:
        names = ["Petter", "Hans", "Per", "William", "Håkon"]
    else:
        names = arg.split(",")
    names = [s.strip() for s in names]
    names = [s[0].upper() + s[1:] for s in names]
    print(names)
    fig = get_names(names=names)
    return render_template("names.html", fig=fig)
Exemplo n.º 6
0
def main():
    names_list = names.get_names()
    for i in range(0, int(sys.argv[1])):
        _tipo = sys.argv[2]
        _dep = sys.argv[3]
        _dir = sys.argv[4]
        payload = {
            'nombre': names_list[i],
            'apellido': names_list[i + 1],
            'tipo': _tipo,
            'departamento': _dep,
            'direccion': _dir,
            'estado': 'activa',
            'estuche': '',
            'telefonos': [make_tel()]
        }

        r = requests.post(url, data=payload)
        print(r.text)
Exemplo n.º 7
0
def names_page():
    try:
        year = int(request.args.get('year'))
    except:
        year = 0

    api_key = "c35d4b418b278a6174df2aa7b38566cb"
    names_list = get_names(
        "http://api.data.mos.ru/v1/datasets/2009/rows?api_key={key}".format(
            key=api_key))

    table_content = """
        <tr> 
            <th>Имя</th>
            <th>Год</th>
            <th>Месяц</th>
            <th>Количество</th>
        </tr>
     """

    for name_dict in names_list:
        if year != 0 and name_dict['Cells'].get('Year') != year:
            continue
        name_data = name_dict['Cells']
        table_content += """
        <tr> 
            <td>{name}</td>
            <td>{year}</td>
            <td>{month}</td>
            <td>{number}</td>
        </tr>
        """.format(name=name_data.get('Name'),
                   year=name_data.get('Year'),
                   month=name_data.get('Month'),
                   number=name_data.get('NumberOfPersons'))
    table_content = '''
    <table cellspacing="2" border="1" cellpadding="5">
        {content}
    </table></br> 
    <a href="/">Вернуться на главную</a>'''.format(content=table_content)

    return table_content
Exemplo n.º 8
0
def kids_names():
    url = "http://api.data.mos.ru/v1/datasets/2009/rows?api_key=%s" % _api_key
    names = get_names(url)
    years = ['2015', '2016', '2017']
    year = int(request.args.get('year')) if request.args.get('year') in years else ''
    result = "<table><tr><th>№</th><th>Имя</th><th>Кол-во человек</th><th>Год</th><th>Месяц</th></tr>"
    cnt = 1
    for user in names:
        name = user['Cells']['Name']
        num = user['Cells']['NumberOfPersons']
        #year = user['Cells']['Year']
        month = user['Cells']['Month']
        if year == '':
            result += "<tr align=center><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (cnt, name, num, user['Cells']['Year'], month)
            cnt += 1
        elif year == user['Cells']['Year']:
            result += "<tr align=center><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (cnt, name, num, year, month)
            cnt += 1
    result += "</table>"
    return result
Exemplo n.º 9
0
SCALE = 2.0
SIZE = 16000
PRECISION = 7

try:
    import json
except ImportError:
    try:
        from django.utils import simplejson as json
    except ImportError:
        import simplejson as json
from regions import regions2 as get_regions

from names import names as get_names

names = get_names()

regions = sorted(get_regions().values(), key=lambda region: -min(region.height, region.width))


def quad(regions, prefix, x, y, width, height, depth=0):
    if depth > DEPTH:
        return
    _width, _height = width / SCALE, height / SCALE
    _region = type("region", (), {"x": x, "y": y, "width": width, "height": height})
    _regions = sorted((region for region in regions if intersect(_region, region)), key=keyator(_region))
    yield prefix, list(r.name for r in _regions[:5])

    for _y in range(2):
        for _x in range(2):
            for r in quad(