def info_squads(self):
     rows = []
     for squad in self.squads[Role.DEFENSE] + self.squads[Role.OFFENSE]:
         rows.append(squad.role.name + " " + str(squad.id) + " : ")
         for unit_type, units in squad.units.items():
             rows.append("  - " + util.name(unit_type) + " : " +
                         str(len(units)))
     return rows
Exemple #2
0
def codes(d, n):
    f = open(str(n) + ".txt", "w")
    for i in range(1, len(d)):
        for j in range(4, len(d[i])):
            if (int(d[i][j]) > n):
                f.write("%d - %s\n" % (i + 1, name(d[i])))
                break
    f.close()
Exemple #3
0
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'upcoming_bills')
        params = {
            'fields':
            ','.join([
                "bill_id", "chamber", "legislative_day", "range", "url",
                "bill", "scheduled_at"
            ]),
            'range__exists':
            'true',
            'order':
            'scheduled_at',
        }

        data = yield from self.get_json(url, params=params, limit=limit)

        ifttt = []

        for upcoming in data['results']:

            timestamp = util.time_to_epoch(upcoming['scheduled_at'])

            display_date = util.readable_date(upcoming['legislative_day'])
            if upcoming['range'] == 'week':
                display_date = "the week of " + display_date

            bill = upcoming.get('bill')

            parts = util.parse_bill_id(upcoming['bill_id'])
            code = util.bill_code(
                parts) if parts else upcoming['bill_id'].strip()

            record = {
                'meta': {
                    'id':
                    '{range}/{legislative_day}/{bill_id}'.format(**upcoming),
                    'timestamp': timestamp,
                },
                'Code': code,
                'Title': util.bill_title(bill) if bill else "(Not yet known)",
                'SponsorName':
                util.name(bill['sponsor']) if bill else "(Not yet known)",
                'LegislativeDate': display_date,
                'Chamber': util.chamber_name(upcoming['chamber']),
                'SourceURL': upcoming['url'],
                'date': upcoming['legislative_day'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
Exemple #4
0
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'bills')
        params = {
            'fields':
            ','.join([
                "bill_id", "bill_type", "number", "history.enacted_at",
                "short_title", "official_title", "sponsor", "urls.congress",
                "urls.opencongress"
            ]),
            'history.enacted':
            'true',
            'order':
            'history.enacted_at',
        }

        if before:
            params['history.enacted_at__lte'] = util.epoch_to_date(before)
            params['order'] = 'history.enacted_at__desc'

        if after:
            params['history.enacted_at__gte'] = util.epoch_to_date(after)
            params['order'] = 'history.enacted_at__asc'

        data = yield from self.get_json(url, params=params, limit=limit)

        ifttt = []

        for bill in data['results']:

            timestamp = util.date_to_epoch(bill['history']['enacted_at'])

            record = {
                'meta': {
                    'id': bill['bill_id'],
                    'timestamp': timestamp,
                },
                'SponsorName': util.name(bill['sponsor']),
                'Code': util.bill_code(bill),
                'Title': util.bill_title(bill),
                'BecameLawOn':
                util.readable_date(bill['history']['enacted_at']),
                'OfficialURL': bill['urls']['congress'],
                'OpenCongressURL': bill['urls']['opencongress'],
                'date': bill['history']['enacted_at'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
Exemple #5
0
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'bills/search')
        params = {
            'fields':
            ','.join([
                "bill_id", "bill_type", "number", "introduced_on",
                "short_title", "official_title", "sponsor", "urls.congress",
                "urls.opencongress"
            ]),
            'query':
            fields.get('query'),
            'order':
            'congress,introduced_on,number',
        }

        data = yield from self.get_json(url, params=params, limit=limit)

        if before:
            params['introduced_on__lte'] = util.epoch_to_date(before)
            params['order'] = 'introduced_on__desc'

        if after:
            params['introduced_on__gte'] = util.epoch_to_date(after)
            params['order'] = 'introduced_on__asc'

        ifttt = []

        for bill in data['results']:

            timestamp = util.date_to_epoch(bill['introduced_on'])

            record = {
                'meta': {
                    'id': bill['bill_id'],
                    'timestamp': timestamp,
                },
                'query': fields.get('query'),
                'sponsor_name': util.name(bill['sponsor']),
                'code': util.bill_code(bill),
                'title': util.bill_title(bill),
                'introduced_on': util.readable_date(bill['introduced_on']),
                'official_url': bill['urls']['congress'],
                'open_congress_url': bill['urls']['opencongress'],
                'date': bill['introduced_on'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'bills/search')
        params = {
            'fields': ','.join(
                ["bill_id", "bill_type", "number", "introduced_on",
                 "short_title", "official_title", "sponsor",
                 "urls.congress", "urls.opencongress"]),
            'query': fields.get('query'),
            'order': 'congress,introduced_on,number',
        }

        data = yield from self.get_json(url, params=params, limit=limit)

        if before:
            params['introduced_on__lte'] = util.epoch_to_date(before)
            params['order'] = 'introduced_on__desc'

        if after:
            params['introduced_on__gte'] = util.epoch_to_date(after)
            params['order'] = 'introduced_on__asc'

        ifttt = []

        for bill in data['results']:

            timestamp = util.date_to_epoch(bill['introduced_on'])

            record = {
                'meta': {
                    'id': bill['bill_id'],
                    'timestamp': timestamp,
                },
                'query': fields.get('query'),
                'sponsor_name': util.name(bill['sponsor']),
                'code': util.bill_code(bill),
                'title': util.bill_title(bill),
                'introduced_on': util.readable_date(bill['introduced_on']),
                'official_url': bill['urls']['congress'],
                'open_congress_url': bill['urls']['opencongress'],
                'date': bill['introduced_on'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'upcoming_bills')
        params = {
            'fields': ','.join(
                ["bill_id", "chamber", "legislative_day",
                 "range", "url", "bill", "scheduled_at"]),
            'range__exists': 'true',
            'order': 'scheduled_at',
        }

        data = yield from self.get_json(url, params=params, limit=limit)

        ifttt = []

        for upcoming in data['results']:

            timestamp = util.time_to_epoch(upcoming['scheduled_at'])

            display_date = util.readable_date(upcoming['legislative_day'])
            if upcoming['range'] == 'week':
                display_date = "the week of " + display_date;

            bill = upcoming.get('bill')

            parts = util.parse_bill_id(upcoming['bill_id'])
            code = util.bill_code(parts) if parts else upcoming['bill_id'].strip()

            record = {
                'meta': {
                    'id': '{range}/{legislative_day}/{bill_id}'.format(**upcoming),
                    'timestamp': timestamp,
                },
                'Code': code,
                'Title': util.bill_title(bill) if bill else "(Not yet known)",
                'SponsorName': util.name(bill['sponsor']) if bill else "(Not yet known)",
                'LegislativeDate': display_date,
                'Chamber': util.chamber_name(upcoming['chamber']),
                'SourceURL': upcoming['url'],
                'date': upcoming['legislative_day'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
    def check(self, fields, before, after, limit):

        url = '{}/{}'.format(SUNLIGHT_URL, 'bills')
        params = {
            'fields': ','.join(
                ["bill_id", "bill_type", "number", "history.enacted_at",
                 "short_title", "official_title", "sponsor",
                 "urls.congress", "urls.opencongress"]),
            'history.enacted': 'true',
            'order': 'history.enacted_at',
        }

        if before:
            params['history.enacted_at__lte'] = util.epoch_to_date(before)
            params['order'] = 'history.enacted_at__desc'

        if after:
            params['history.enacted_at__gte'] = util.epoch_to_date(after)
            params['order'] = 'history.enacted_at__asc'

        data = yield from self.get_json(url, params=params, limit=limit)

        ifttt = []

        for bill in data['results']:

            timestamp = util.date_to_epoch(bill['history']['enacted_at'])

            record = {
                'meta': {
                    'id': bill['bill_id'],
                    'timestamp': timestamp,
                },
                'SponsorName': util.name(bill['sponsor']),
                'Code': util.bill_code(bill),
                'Title': util.bill_title(bill),
                'BecameLawOn': util.readable_date(bill['history']['enacted_at']),
                'OfficialURL': bill['urls']['congress'],
                'OpenCongressURL': bill['urls']['opencongress'],
                'date': bill['history']['enacted_at'],
            }
            ifttt.append(record)

        return util.JSONResponse(ifttt)
Exemple #9
0
 def _str_for_name(self, name):
     assert isinstance(name, Symbol)
     return UT.name(name)._str_value