88from prettytable import PrettyTable
99import requests
1010import os
11+ from .savemeps import save_meps
1112
1213url = 'http://www.votewatch.eu/actions.php?euro_parlamentar_id={}&form_category=get_mep_acte&sEcho=1&iColumns=6&sColumns=&iDisplayStart=0&iDisplayLength={}&mDataProp_0=mysql_data&mDataProp_1=act_nume_full&mDataProp_2=euro_vot_valoare_special_vote_page&mDataProp_3=euro_vot_rol_euro_grup.rol_af&mDataProp_4=euro_domeniu_nume&mDataProp_5=euro_vot_valoare_text&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&iSortingCols=1&iSortCol_0=0&sSortDir_0=desc&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true&_=1486840527483'
1314
@@ -44,8 +45,7 @@ def get_meps(country=None):
4445 t .add_row ([country .title ()])
4546 print (t )
4647 else :
47- import savemeps
48- savemeps .save_meps ()
48+ save_meps ()
4949 get_meps (country )
5050
5151class EUvotes (object ):
@@ -70,7 +70,6 @@ def __init__(self, mep_id, limit=50):
7070 """When launching initialization use given data
7171 to retrieve all interesting info from Votewatch.eu
7272 automatically.
73-
7473 """
7574 self .mep_id = abs (mep_id )
7675 self .limit = abs (limit )
@@ -85,9 +84,14 @@ def __str__(self):
8584
8685 def _mep_name (self , mep_id ):
8786 """Get searched MEP name"""
88- with open (os .path .expanduser ("~/.meps" ), 'rb' ) as f :
89- meps = pickle .load (f )
90- return meps [abs (mep_id ) - 1 ][1 ]
87+ meps_path = os .path .expanduser ("~/.meps" )
88+ if os .path .isfile (meps_path ):
89+ with open (os .path .expanduser (meps_path ), 'rb' ) as f :
90+ meps = pickle .load (f )
91+ return meps [abs (mep_id ) - 1 ][1 ]
92+ else :
93+ save_meps ()
94+ self ._mep_name (mep_id )
9195
9296 def _get_votes (self , mep_id , limit ):
9397 """Get last `limit` votes for requested MEP"""
0 commit comments