Пример #1
0
def test_ik():
    ik = Session.query(cikUIK).filter( cikUIK.region == 'kirov', cikUIK.type_ik == 'ik' ).first()
    if not ik:
        ik = cikUIK( region = 'kirov', type_ik = 'ik', url='http://www.kirov.vybory.izbirkom.ru/ik/' )
        ik.iz_id = 7437000291808
        Session.add(ik)
    vals = ik.parse(recursion=False)
    for (k, v) in vals.items():
        print k, v
Пример #2
0
def test_tik():
    iz_id = 443400194087
    tik = Session.query(cikUIK).filter( cikUIK.type_ik == 'tik', cikUIK.iz_id == iz_id ).first()
    if not tik:
        tik = cikUIK( region = 'kirov', type_ik = 'tik', iz_id = iz_id )
        Session.add(tik)
    tik.url = 'http://www.kirov.vybory.izbirkom.ru/kirov/ik/443400194087'
    vals = tik.parse(recursion=False)
    for (k, v) in vals.items():
        print k, v
Пример #3
0
def test_tik():
    iz_id = 443400194087
    tik = Session.query(cikUIK).filter(cikUIK.type_ik == 'tik',
                                       cikUIK.iz_id == iz_id).first()
    if not tik:
        tik = cikUIK(region='kirov', type_ik='tik', iz_id=iz_id)
        Session.add(tik)
    tik.url = 'http://www.kirov.vybory.izbirkom.ru/kirov/ik/443400194087'
    vals = tik.parse(recursion=False)
    for (k, v) in vals.items():
        print k, v
Пример #4
0
def test_ik():
    ik = Session.query(cikUIK).filter(cikUIK.region == 'kirov',
                                      cikUIK.type_ik == 'ik').first()
    if not ik:
        ik = cikUIK(region='kirov',
                    type_ik='ik',
                    url='http://www.kirov.vybory.izbirkom.ru/ik/')
        ik.iz_id = 7437000291808
        Session.add(ik)
    vals = ik.parse(recursion=False)
    for (k, v) in vals.items():
        print k, v
Пример #5
0
    from cik import Session, Base, init_model, cikUIK, all_regions
    from sqlalchemy import create_engine

    engine = create_engine('sqlite:///%s' % (options.path_db, ))
    init_model(engine)

    if options.regions == 'all':
        down_regions = all_regions
    else:
        down_regions = options.regions.split(',')

    for reg in down_regions:
        if reg not in all_regions: continue

        ik = Session.query(cikUIK).filter(cikUIK.region == reg,
                                          cikUIK.type_ik == 'ik').first()
        if not ik:
            ik = cikUIK(region=reg,
                        type_ik='ik',
                        url='http://www.%s.vybory.izbirkom.ru/ik/' % (reg, ))
            ik.iz_id = -1
            Session.add(ik)

        vals = ik.parse(recursion=True)
        Session.commit()

        if options.with_reserve:
            vals = ik.parse_reserve(recursion=True)
            Session.commit()
Пример #6
0
    "moscow_city", "st-petersburg", "jewish_aut", "nenetsk", "khantu-mansy",
    "chukot", "yamal-nenetsk",
]

if __name__ == '__main__':
    parser = optparse.OptionParser("usage: %prog")
    parser.add_option("-r", "--region", dest="regions",
                      default='all', help=u'какой регион выкачать')
    
    (options, args) = parser.parse_args()

    engine = create_engine('sqlite:///cik.sqlite')
    init_model(engine)

    if options.regions == 'all': 
        down_regions = all_regions
    else:
        down_regions = options.regions.split(',')

    for reg in down_regions:
        if reg not in all_regions: continue
        
        ik = Session.query(cikUIK).filter( cikUIK.region == reg, cikUIK.type_ik == 'ik' ).first()
        if not ik:
            ik = cikUIK( region = reg, type_ik = 'ik', url='http://www.%s.vybory.izbirkom.ru/ik/' % (reg, ) )
            ik.iz_id = -1
            Session.add(ik)
            
        vals = ik.parse(recursion=True)