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
# This method will add a normalized person | |
# record to our members array | |
def _add_person_record(self, dict): | |
person = { | |
'id': self._get_id(dict), | |
'active': self._get_active(dict), | |
'lastName': self._get_last_name(dict), | |
'firstName': self._get_first_name(dict), | |
'middleName':self._get_middle_name(dict), | |
'gender': self._get_gender(dict), |
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
... | |
@abstractmethod | |
def _get_active(self,dict): | |
pass | |
@abstractmethod | |
def _get_id(self,dict): | |
pass |
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
class GovAPI_CH(GovAPI): | |
def __init__(self, cfg): | |
self.__cfg = cfg | |
def _get_active(self,dict): | |
return dict.get('active') | |
def _get_id(self,dict): | |
return dict.get('id') |
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
def load_government_members(self): | |
page_number=1 | |
url = self.__cfg['govAPIUrl'] | |
politician_res = self.__cfg['govAPICouncillorsRes'] | |
par = self.__cfg['govAPIParams'] | |
while True: | |
par[0]['pageNumber'] = str(page_number) | |
headers = requests.utils.default_headers() | |
headers.update({ 'User-Agent': 'Mozilla/5.0'}) | |
politicians = requests.get(url+politician_res, params=par[0], headers=headers).json() |
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 abc import ABC, abstractmethod | |
class GovAPI(ABC): | |
@abstractmethod | |
def load_government_members(self): | |
pass |
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
def create_politican_from_govapi_table(self): | |
self.load_government_members() | |
df = DataFrame.from_records(self._members) | |
print(df) |
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 govAPI_CH import GovAPI_CH | |
class GovAPIFactory: | |
@classmethod | |
def create_country_gov_api(cls, country_code,cfg): | |
if country_code == "CH": | |
return GovAPI_CH(cfg) | |
return None |
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
/// Check a given transaction for validity. This doesn't execute any | |
/// side-effects; it merely checks whether the transaction would panic if it were included or not. | |
/// | |
/// Changes made to the storage should be discarded. | |
pub fn validate_transaction(uxt: Block::Extrinsic) -> TransactionValidity { | |
let encoded_len = uxt.encode().len(); | |
let xt = match uxt.check(&Default::default()) { | |
// Checks out. Carry on. | |
Ok(xt) => xt, |
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
data set | variable name | cat.nominal | cat.ordinal | num.discrete | num.continous | |
---|---|---|---|---|---|---|
twitter.api | ScreenName | x (unique) | ||||
twitter.api | Name | x | ||||
twitter.api | Description | |||||
twitter.api | FollowersCount | x | ||||
twitter.api | FriendsCount | x | ||||
twitter.api | Party | x | ||||
gov.api | id | x (unique) | ||||
gov.api | firstName.middleName.lastName | x | ||||
gov.api | birthDate | x |
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
Twitter Account Name | Remark | Resolution | |
---|---|---|---|
Dr. Bastien Girod | Title prefix | Remove Title | |
Jean Chr. Schwaab | Middle Name Abbreviation | Expand Middle Name | |
Kathy Riklin Zürich | City postfix | Remove City |