Skip to content

Instantly share code, notes, and snippets.

View talfco's full-sized avatar

Felix Kuestahler talfco

View GitHub Profile
# 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),
...
@abstractmethod
def _get_active(self,dict):
pass
@abstractmethod
def _get_id(self,dict):
pass
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')
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()
from abc import ABC, abstractmethod
class GovAPI(ABC):
@abstractmethod
def load_government_members(self):
pass
def create_politican_from_govapi_table(self):
self.load_government_members()
df = DataFrame.from_records(self._members)
print(df)
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
/// 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,
@talfco
talfco / tut04-variable-categorization.csv
Last active February 24, 2019 14:35
tut04-variable-categorization
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
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