content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class handshake: def clientside(Socket_Object): """This must be called with the main object from the socket""" pass#Socket_Object.
class Handshake: def clientside(Socket_Object): """This must be called with the main object from the socket""" pass
#!/usr/bin/python3 # Can user retrieve reward after a time cycle? def test_get_reward(multi, base_token, reward_token, alice, issue, chain): amount = 10 ** 10 init_reward_balance = reward_token.balanceOf(alice) base_token.approve(multi, amount, {"from": alice}) multi.stake(amount, {"from": alice}) chain.mine(timedelta=60) earnings = multi.earned(alice, reward_token) assert earnings > 0 multi.getReward({"from": alice}) final_reward_balance = reward_token.balanceOf(alice) assert final_reward_balance - init_reward_balance == earnings # Reward per token over many cycles? def test_multiuser_reward_per_token_paid(multi, reward_token, alice, chain): reward_token._mint_for_testing(alice, 10 ** 18, {"from": alice}) reward_token.approve(multi, 10 ** 18, {"from": alice}) multi.setRewardsDistributor(reward_token, alice, {"from": alice}) multi.stake(10 ** 10, {"from": alice}) for i in range(5): last_val = multi.userRewardPerTokenPaid(alice, reward_token) multi.notifyRewardAmount(reward_token, 10 ** 10, {"from": alice}) chain.mine(timedelta=60) earnings = multi.earned(alice, reward_token) tx = multi.getReward() assert multi.userRewardPerTokenPaid(alice, reward_token) > last_val assert tx.events["RewardPaid"].values()[2] == earnings # User should not be able to withdraw a reward if empty def test_cannot_get_empty_reward(multi, reward_token, alice, chain): init_amount = reward_token.balanceOf(alice) chain.mine(timedelta=60) multi.getReward({"from": alice}) final_amount = reward_token.balanceOf(alice) assert init_amount == final_amount # User should not be able to withdraw a reward if empty def test_no_action_on_empty_reward(multi, reward_token, charlie): tx = multi.getReward({"from": charlie}) assert "RewardPaid" not in tx.events # Call from a user who is staked should receive the correct amount of tokens def test_staked_token_value(multi, reward_token, base_token, alice, charlie, issue, chain): amount = base_token.balanceOf(charlie) reward_init_bal = reward_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) assert base_token.balanceOf(charlie) == 0 assert multi.balanceOf(charlie) == amount chain.mine(timedelta=60) reward_per_token = multi.rewardPerToken(reward_token) earned_calc = reward_per_token * amount // 10 ** 18 assert earned_calc == multi.earned(charlie, reward_token) tx = multi.getReward({"from": charlie}) assert tx.events["RewardPaid"].values()[2] == earned_calc assert reward_token.balanceOf(charlie) - reward_init_bal == earned_calc # User at outset has no earnings def test_fresh_user_no_earnings(multi, reward_token, charlie, issue): assert multi.earned(charlie, reward_token) == 0 # User has no earnings after staking def test_no_earnings_upon_staking(multi, reward_token, base_token, charlie, issue): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) assert multi.earned(charlie, reward_token) == 0 # User has earnings after staking and waiting def test_user_accrues_rewards(multi, reward_token, base_token, charlie, issue, chain): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) chain.mine(timedelta=60) period = ( multi.lastTimeRewardApplicable(reward_token) - multi.rewardData(reward_token)["lastUpdateTime"] ) calc_earn = period * (10 ** 18 / 60) assert calc_earn * 0.99 <= multi.earned(charlie, reward_token) <= calc_earn * 1.01 # User has no earnings after withdrawing def test_no_earnings_post_withdrawal( multi, reward_token, slow_token, base_token, alice, charlie, issue, chain ): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) chain.mine(timedelta=30) assert multi.earned(charlie, reward_token) > 0 multi.getReward({"from": charlie}) multi.withdraw(multi.balanceOf(charlie), {"from": charlie}) chain.mine(timedelta=30) assert multi.earned(charlie, reward_token) == 0 # Call from a user who is staked should receive the correct amount of tokens # Also confirm earnings at various stages def test_staked_tokens_multi_durations( multi, reward_token, slow_token, base_token, alice, charlie, issue, chain ): reward_init_bal = reward_token.balanceOf(charlie) slow_init_bal = slow_token.balanceOf(charlie) amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) for i in range(1): reward_init_bal = reward_token.balanceOf(charlie) slow_init_bal = slow_token.balanceOf(charlie) charlie_paid_reward = multi.userRewardPerTokenPaid(charlie, reward_token) charlie_paid_slow = multi.userRewardPerTokenPaid(charlie, slow_token) chain.mine(timedelta=30) reward_per = multi.rewardPerToken(reward_token) slow_per = multi.rewardPerToken(slow_token) reward_calc = (amount * (reward_per - charlie_paid_reward)) // 10 ** 18 slow_calc = (amount * (slow_per - charlie_paid_slow)) // 10 ** 18 assert reward_calc == multi.earned(charlie, reward_token) assert slow_calc == multi.earned(charlie, slow_token) multi.getReward({"from": charlie}) # Reward may have changed in the second it takes to getReward reward_per_act = multi.rewardPerToken(reward_token) slow_per_act = multi.rewardPerToken(slow_token) reward_calc_act = (amount * (reward_per_act - charlie_paid_reward)) // 10 ** 18 slow_calc_act = (amount * (slow_per_act - charlie_paid_slow)) // 10 ** 18 assert reward_token.balanceOf(charlie) - reward_init_bal == reward_calc_act assert slow_token.balanceOf(charlie) - slow_init_bal == slow_calc_act # A user that has withdrawn should still be able to claim their rewards def test_withdrawn_user_can_claim(multi, slow_token, base_token, alice, charlie, issue, chain): amount = base_token.balanceOf(charlie) reward_init_bal = slow_token.balanceOf(charlie) base_token.approve(multi, amount, {"from": charlie}) multi.stake(amount, {"from": charlie}) # Confirm charlie staked assert base_token.balanceOf(charlie) == 0 assert multi.balanceOf(charlie) == amount chain.mine(timedelta=60) multi.withdraw(amount, {"from": charlie}) # Confirm Charlie withdrew as expected reward_per_token = multi.rewardPerToken(slow_token) earned_calc = reward_per_token * amount // 10 ** 18 assert multi.balanceOf(charlie) == 0 assert reward_per_token > 0 assert earned_calc == multi.earned(charlie, slow_token) # Does Charlie still get rewarded? tx = multi.getReward({"from": charlie}) for e in tx.events["RewardPaid"]: if e["user"] == charlie and e["rewardsToken"] == slow_token: token_log = e assert token_log["reward"] == earned_calc assert slow_token.balanceOf(charlie) - reward_init_bal == earned_calc
def test_get_reward(multi, base_token, reward_token, alice, issue, chain): amount = 10 ** 10 init_reward_balance = reward_token.balanceOf(alice) base_token.approve(multi, amount, {'from': alice}) multi.stake(amount, {'from': alice}) chain.mine(timedelta=60) earnings = multi.earned(alice, reward_token) assert earnings > 0 multi.getReward({'from': alice}) final_reward_balance = reward_token.balanceOf(alice) assert final_reward_balance - init_reward_balance == earnings def test_multiuser_reward_per_token_paid(multi, reward_token, alice, chain): reward_token._mint_for_testing(alice, 10 ** 18, {'from': alice}) reward_token.approve(multi, 10 ** 18, {'from': alice}) multi.setRewardsDistributor(reward_token, alice, {'from': alice}) multi.stake(10 ** 10, {'from': alice}) for i in range(5): last_val = multi.userRewardPerTokenPaid(alice, reward_token) multi.notifyRewardAmount(reward_token, 10 ** 10, {'from': alice}) chain.mine(timedelta=60) earnings = multi.earned(alice, reward_token) tx = multi.getReward() assert multi.userRewardPerTokenPaid(alice, reward_token) > last_val assert tx.events['RewardPaid'].values()[2] == earnings def test_cannot_get_empty_reward(multi, reward_token, alice, chain): init_amount = reward_token.balanceOf(alice) chain.mine(timedelta=60) multi.getReward({'from': alice}) final_amount = reward_token.balanceOf(alice) assert init_amount == final_amount def test_no_action_on_empty_reward(multi, reward_token, charlie): tx = multi.getReward({'from': charlie}) assert 'RewardPaid' not in tx.events def test_staked_token_value(multi, reward_token, base_token, alice, charlie, issue, chain): amount = base_token.balanceOf(charlie) reward_init_bal = reward_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) assert base_token.balanceOf(charlie) == 0 assert multi.balanceOf(charlie) == amount chain.mine(timedelta=60) reward_per_token = multi.rewardPerToken(reward_token) earned_calc = reward_per_token * amount // 10 ** 18 assert earned_calc == multi.earned(charlie, reward_token) tx = multi.getReward({'from': charlie}) assert tx.events['RewardPaid'].values()[2] == earned_calc assert reward_token.balanceOf(charlie) - reward_init_bal == earned_calc def test_fresh_user_no_earnings(multi, reward_token, charlie, issue): assert multi.earned(charlie, reward_token) == 0 def test_no_earnings_upon_staking(multi, reward_token, base_token, charlie, issue): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) assert multi.earned(charlie, reward_token) == 0 def test_user_accrues_rewards(multi, reward_token, base_token, charlie, issue, chain): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) chain.mine(timedelta=60) period = multi.lastTimeRewardApplicable(reward_token) - multi.rewardData(reward_token)['lastUpdateTime'] calc_earn = period * (10 ** 18 / 60) assert calc_earn * 0.99 <= multi.earned(charlie, reward_token) <= calc_earn * 1.01 def test_no_earnings_post_withdrawal(multi, reward_token, slow_token, base_token, alice, charlie, issue, chain): amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) chain.mine(timedelta=30) assert multi.earned(charlie, reward_token) > 0 multi.getReward({'from': charlie}) multi.withdraw(multi.balanceOf(charlie), {'from': charlie}) chain.mine(timedelta=30) assert multi.earned(charlie, reward_token) == 0 def test_staked_tokens_multi_durations(multi, reward_token, slow_token, base_token, alice, charlie, issue, chain): reward_init_bal = reward_token.balanceOf(charlie) slow_init_bal = slow_token.balanceOf(charlie) amount = base_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) for i in range(1): reward_init_bal = reward_token.balanceOf(charlie) slow_init_bal = slow_token.balanceOf(charlie) charlie_paid_reward = multi.userRewardPerTokenPaid(charlie, reward_token) charlie_paid_slow = multi.userRewardPerTokenPaid(charlie, slow_token) chain.mine(timedelta=30) reward_per = multi.rewardPerToken(reward_token) slow_per = multi.rewardPerToken(slow_token) reward_calc = amount * (reward_per - charlie_paid_reward) // 10 ** 18 slow_calc = amount * (slow_per - charlie_paid_slow) // 10 ** 18 assert reward_calc == multi.earned(charlie, reward_token) assert slow_calc == multi.earned(charlie, slow_token) multi.getReward({'from': charlie}) reward_per_act = multi.rewardPerToken(reward_token) slow_per_act = multi.rewardPerToken(slow_token) reward_calc_act = amount * (reward_per_act - charlie_paid_reward) // 10 ** 18 slow_calc_act = amount * (slow_per_act - charlie_paid_slow) // 10 ** 18 assert reward_token.balanceOf(charlie) - reward_init_bal == reward_calc_act assert slow_token.balanceOf(charlie) - slow_init_bal == slow_calc_act def test_withdrawn_user_can_claim(multi, slow_token, base_token, alice, charlie, issue, chain): amount = base_token.balanceOf(charlie) reward_init_bal = slow_token.balanceOf(charlie) base_token.approve(multi, amount, {'from': charlie}) multi.stake(amount, {'from': charlie}) assert base_token.balanceOf(charlie) == 0 assert multi.balanceOf(charlie) == amount chain.mine(timedelta=60) multi.withdraw(amount, {'from': charlie}) reward_per_token = multi.rewardPerToken(slow_token) earned_calc = reward_per_token * amount // 10 ** 18 assert multi.balanceOf(charlie) == 0 assert reward_per_token > 0 assert earned_calc == multi.earned(charlie, slow_token) tx = multi.getReward({'from': charlie}) for e in tx.events['RewardPaid']: if e['user'] == charlie and e['rewardsToken'] == slow_token: token_log = e assert token_log['reward'] == earned_calc assert slow_token.balanceOf(charlie) - reward_init_bal == earned_calc
data = ( 'ddwim', # 0x00 'ddwib', # 0x01 'ddwibs', # 0x02 'ddwis', # 0x03 'ddwiss', # 0x04 'ddwing', # 0x05 'ddwij', # 0x06 'ddwic', # 0x07 'ddwik', # 0x08 'ddwit', # 0x09 'ddwip', # 0x0a 'ddwih', # 0x0b 'ddyu', # 0x0c 'ddyug', # 0x0d 'ddyugg', # 0x0e 'ddyugs', # 0x0f 'ddyun', # 0x10 'ddyunj', # 0x11 'ddyunh', # 0x12 'ddyud', # 0x13 'ddyul', # 0x14 'ddyulg', # 0x15 'ddyulm', # 0x16 'ddyulb', # 0x17 'ddyuls', # 0x18 'ddyult', # 0x19 'ddyulp', # 0x1a 'ddyulh', # 0x1b 'ddyum', # 0x1c 'ddyub', # 0x1d 'ddyubs', # 0x1e 'ddyus', # 0x1f 'ddyuss', # 0x20 'ddyung', # 0x21 'ddyuj', # 0x22 'ddyuc', # 0x23 'ddyuk', # 0x24 'ddyut', # 0x25 'ddyup', # 0x26 'ddyuh', # 0x27 'ddeu', # 0x28 'ddeug', # 0x29 'ddeugg', # 0x2a 'ddeugs', # 0x2b 'ddeun', # 0x2c 'ddeunj', # 0x2d 'ddeunh', # 0x2e 'ddeud', # 0x2f 'ddeul', # 0x30 'ddeulg', # 0x31 'ddeulm', # 0x32 'ddeulb', # 0x33 'ddeuls', # 0x34 'ddeult', # 0x35 'ddeulp', # 0x36 'ddeulh', # 0x37 'ddeum', # 0x38 'ddeub', # 0x39 'ddeubs', # 0x3a 'ddeus', # 0x3b 'ddeuss', # 0x3c 'ddeung', # 0x3d 'ddeuj', # 0x3e 'ddeuc', # 0x3f 'ddeuk', # 0x40 'ddeut', # 0x41 'ddeup', # 0x42 'ddeuh', # 0x43 'ddyi', # 0x44 'ddyig', # 0x45 'ddyigg', # 0x46 'ddyigs', # 0x47 'ddyin', # 0x48 'ddyinj', # 0x49 'ddyinh', # 0x4a 'ddyid', # 0x4b 'ddyil', # 0x4c 'ddyilg', # 0x4d 'ddyilm', # 0x4e 'ddyilb', # 0x4f 'ddyils', # 0x50 'ddyilt', # 0x51 'ddyilp', # 0x52 'ddyilh', # 0x53 'ddyim', # 0x54 'ddyib', # 0x55 'ddyibs', # 0x56 'ddyis', # 0x57 'ddyiss', # 0x58 'ddying', # 0x59 'ddyij', # 0x5a 'ddyic', # 0x5b 'ddyik', # 0x5c 'ddyit', # 0x5d 'ddyip', # 0x5e 'ddyih', # 0x5f 'ddi', # 0x60 'ddig', # 0x61 'ddigg', # 0x62 'ddigs', # 0x63 'ddin', # 0x64 'ddinj', # 0x65 'ddinh', # 0x66 'ddid', # 0x67 'ddil', # 0x68 'ddilg', # 0x69 'ddilm', # 0x6a 'ddilb', # 0x6b 'ddils', # 0x6c 'ddilt', # 0x6d 'ddilp', # 0x6e 'ddilh', # 0x6f 'ddim', # 0x70 'ddib', # 0x71 'ddibs', # 0x72 'ddis', # 0x73 'ddiss', # 0x74 'dding', # 0x75 'ddij', # 0x76 'ddic', # 0x77 'ddik', # 0x78 'ddit', # 0x79 'ddip', # 0x7a 'ddih', # 0x7b 'ra', # 0x7c 'rag', # 0x7d 'ragg', # 0x7e 'rags', # 0x7f 'ran', # 0x80 'ranj', # 0x81 'ranh', # 0x82 'rad', # 0x83 'ral', # 0x84 'ralg', # 0x85 'ralm', # 0x86 'ralb', # 0x87 'rals', # 0x88 'ralt', # 0x89 'ralp', # 0x8a 'ralh', # 0x8b 'ram', # 0x8c 'rab', # 0x8d 'rabs', # 0x8e 'ras', # 0x8f 'rass', # 0x90 'rang', # 0x91 'raj', # 0x92 'rac', # 0x93 'rak', # 0x94 'rat', # 0x95 'rap', # 0x96 'rah', # 0x97 'rae', # 0x98 'raeg', # 0x99 'raegg', # 0x9a 'raegs', # 0x9b 'raen', # 0x9c 'raenj', # 0x9d 'raenh', # 0x9e 'raed', # 0x9f 'rael', # 0xa0 'raelg', # 0xa1 'raelm', # 0xa2 'raelb', # 0xa3 'raels', # 0xa4 'raelt', # 0xa5 'raelp', # 0xa6 'raelh', # 0xa7 'raem', # 0xa8 'raeb', # 0xa9 'raebs', # 0xaa 'raes', # 0xab 'raess', # 0xac 'raeng', # 0xad 'raej', # 0xae 'raec', # 0xaf 'raek', # 0xb0 'raet', # 0xb1 'raep', # 0xb2 'raeh', # 0xb3 'rya', # 0xb4 'ryag', # 0xb5 'ryagg', # 0xb6 'ryags', # 0xb7 'ryan', # 0xb8 'ryanj', # 0xb9 'ryanh', # 0xba 'ryad', # 0xbb 'ryal', # 0xbc 'ryalg', # 0xbd 'ryalm', # 0xbe 'ryalb', # 0xbf 'ryals', # 0xc0 'ryalt', # 0xc1 'ryalp', # 0xc2 'ryalh', # 0xc3 'ryam', # 0xc4 'ryab', # 0xc5 'ryabs', # 0xc6 'ryas', # 0xc7 'ryass', # 0xc8 'ryang', # 0xc9 'ryaj', # 0xca 'ryac', # 0xcb 'ryak', # 0xcc 'ryat', # 0xcd 'ryap', # 0xce 'ryah', # 0xcf 'ryae', # 0xd0 'ryaeg', # 0xd1 'ryaegg', # 0xd2 'ryaegs', # 0xd3 'ryaen', # 0xd4 'ryaenj', # 0xd5 'ryaenh', # 0xd6 'ryaed', # 0xd7 'ryael', # 0xd8 'ryaelg', # 0xd9 'ryaelm', # 0xda 'ryaelb', # 0xdb 'ryaels', # 0xdc 'ryaelt', # 0xdd 'ryaelp', # 0xde 'ryaelh', # 0xdf 'ryaem', # 0xe0 'ryaeb', # 0xe1 'ryaebs', # 0xe2 'ryaes', # 0xe3 'ryaess', # 0xe4 'ryaeng', # 0xe5 'ryaej', # 0xe6 'ryaec', # 0xe7 'ryaek', # 0xe8 'ryaet', # 0xe9 'ryaep', # 0xea 'ryaeh', # 0xeb 'reo', # 0xec 'reog', # 0xed 'reogg', # 0xee 'reogs', # 0xef 'reon', # 0xf0 'reonj', # 0xf1 'reonh', # 0xf2 'reod', # 0xf3 'reol', # 0xf4 'reolg', # 0xf5 'reolm', # 0xf6 'reolb', # 0xf7 'reols', # 0xf8 'reolt', # 0xf9 'reolp', # 0xfa 'reolh', # 0xfb 'reom', # 0xfc 'reob', # 0xfd 'reobs', # 0xfe 'reos', # 0xff )
data = ('ddwim', 'ddwib', 'ddwibs', 'ddwis', 'ddwiss', 'ddwing', 'ddwij', 'ddwic', 'ddwik', 'ddwit', 'ddwip', 'ddwih', 'ddyu', 'ddyug', 'ddyugg', 'ddyugs', 'ddyun', 'ddyunj', 'ddyunh', 'ddyud', 'ddyul', 'ddyulg', 'ddyulm', 'ddyulb', 'ddyuls', 'ddyult', 'ddyulp', 'ddyulh', 'ddyum', 'ddyub', 'ddyubs', 'ddyus', 'ddyuss', 'ddyung', 'ddyuj', 'ddyuc', 'ddyuk', 'ddyut', 'ddyup', 'ddyuh', 'ddeu', 'ddeug', 'ddeugg', 'ddeugs', 'ddeun', 'ddeunj', 'ddeunh', 'ddeud', 'ddeul', 'ddeulg', 'ddeulm', 'ddeulb', 'ddeuls', 'ddeult', 'ddeulp', 'ddeulh', 'ddeum', 'ddeub', 'ddeubs', 'ddeus', 'ddeuss', 'ddeung', 'ddeuj', 'ddeuc', 'ddeuk', 'ddeut', 'ddeup', 'ddeuh', 'ddyi', 'ddyig', 'ddyigg', 'ddyigs', 'ddyin', 'ddyinj', 'ddyinh', 'ddyid', 'ddyil', 'ddyilg', 'ddyilm', 'ddyilb', 'ddyils', 'ddyilt', 'ddyilp', 'ddyilh', 'ddyim', 'ddyib', 'ddyibs', 'ddyis', 'ddyiss', 'ddying', 'ddyij', 'ddyic', 'ddyik', 'ddyit', 'ddyip', 'ddyih', 'ddi', 'ddig', 'ddigg', 'ddigs', 'ddin', 'ddinj', 'ddinh', 'ddid', 'ddil', 'ddilg', 'ddilm', 'ddilb', 'ddils', 'ddilt', 'ddilp', 'ddilh', 'ddim', 'ddib', 'ddibs', 'ddis', 'ddiss', 'dding', 'ddij', 'ddic', 'ddik', 'ddit', 'ddip', 'ddih', 'ra', 'rag', 'ragg', 'rags', 'ran', 'ranj', 'ranh', 'rad', 'ral', 'ralg', 'ralm', 'ralb', 'rals', 'ralt', 'ralp', 'ralh', 'ram', 'rab', 'rabs', 'ras', 'rass', 'rang', 'raj', 'rac', 'rak', 'rat', 'rap', 'rah', 'rae', 'raeg', 'raegg', 'raegs', 'raen', 'raenj', 'raenh', 'raed', 'rael', 'raelg', 'raelm', 'raelb', 'raels', 'raelt', 'raelp', 'raelh', 'raem', 'raeb', 'raebs', 'raes', 'raess', 'raeng', 'raej', 'raec', 'raek', 'raet', 'raep', 'raeh', 'rya', 'ryag', 'ryagg', 'ryags', 'ryan', 'ryanj', 'ryanh', 'ryad', 'ryal', 'ryalg', 'ryalm', 'ryalb', 'ryals', 'ryalt', 'ryalp', 'ryalh', 'ryam', 'ryab', 'ryabs', 'ryas', 'ryass', 'ryang', 'ryaj', 'ryac', 'ryak', 'ryat', 'ryap', 'ryah', 'ryae', 'ryaeg', 'ryaegg', 'ryaegs', 'ryaen', 'ryaenj', 'ryaenh', 'ryaed', 'ryael', 'ryaelg', 'ryaelm', 'ryaelb', 'ryaels', 'ryaelt', 'ryaelp', 'ryaelh', 'ryaem', 'ryaeb', 'ryaebs', 'ryaes', 'ryaess', 'ryaeng', 'ryaej', 'ryaec', 'ryaek', 'ryaet', 'ryaep', 'ryaeh', 'reo', 'reog', 'reogg', 'reogs', 'reon', 'reonj', 'reonh', 'reod', 'reol', 'reolg', 'reolm', 'reolb', 'reols', 'reolt', 'reolp', 'reolh', 'reom', 'reob', 'reobs', 'reos')
"""Static key/seed for keystream generation""" ACP_STATIC_KEY = "5b6faf5d9d5b0e1351f2da1de7e8d673".decode("hex") def generate_acp_keystream(length): """Get key used to encrypt the header key (and some message data?) Args: length (int): length of keystream to generate Returns: String of requested length Note: Keystream repeats every 256 bytes """ key = "" key_idx = 0 while (key_idx < length): key += chr((key_idx + 0x55 & 0xFF) ^ ord(ACP_STATIC_KEY[key_idx % len(ACP_STATIC_KEY)])) key_idx += 1 return key
"""Static key/seed for keystream generation""" acp_static_key = '5b6faf5d9d5b0e1351f2da1de7e8d673'.decode('hex') def generate_acp_keystream(length): """Get key used to encrypt the header key (and some message data?) Args: length (int): length of keystream to generate Returns: String of requested length Note: Keystream repeats every 256 bytes """ key = '' key_idx = 0 while key_idx < length: key += chr(key_idx + 85 & 255 ^ ord(ACP_STATIC_KEY[key_idx % len(ACP_STATIC_KEY)])) key_idx += 1 return key
"""RCON exceptions.""" __all__ = ['InvalidPacketStructure', 'RequestIdMismatch', 'InvalidCredentials'] class InvalidPacketStructure(Exception): """Indicates an invalid packet structure.""" class RequestIdMismatch(Exception): """Indicates that the sent and received request IDs do not match.""" def __init__(self, sent, received): """Sets the sent and received request IDs.""" super().__init__(sent, received) self.sent = sent self.received = received class InvalidCredentials(Exception): """Indicates invalid RCON password."""
"""RCON exceptions.""" __all__ = ['InvalidPacketStructure', 'RequestIdMismatch', 'InvalidCredentials'] class Invalidpacketstructure(Exception): """Indicates an invalid packet structure.""" class Requestidmismatch(Exception): """Indicates that the sent and received request IDs do not match.""" def __init__(self, sent, received): """Sets the sent and received request IDs.""" super().__init__(sent, received) self.sent = sent self.received = received class Invalidcredentials(Exception): """Indicates invalid RCON password."""
def build_mx(n, m): grid = [] for i in range(n): grid.append([' '] * m) return grid def EMPTY_SHAPE(): return [[]] class Shape(object): _name = None grid = EMPTY_SHAPE() rotate_grid = [] def __init__(self, grid): # align each row and column is same n = len(grid) m = max([len(row) for row in grid]) self.grid = build_mx(n, m) for i, row in enumerate(grid): for j, col in enumerate(row): self.grid[i][j] = col self.rotate_grid = [self.grid] @property def name(self): if self._name is None: for row in self.grid: for col in row: if col != ' ': self._name = col return col return self._name def all_shapes(self): visited = {self} yield self for i in range(4): out = Shape(self.rotate(i)) if out not in visited: yield out visited.add(out) h_out = Shape(self.h_mirror()) if h_out not in visited: yield h_out visited.add(h_out) for i in range(4): out = Shape(h_out.rotate(i)) if out not in visited: yield out visited.add(out) v_out = Shape(self.v_mirror()) if v_out not in visited: yield v_out visited.add(v_out) for i in range(4): out = Shape(v_out.rotate(i)) if out not in visited: yield out visited.add(out) return def rotate(self, tim=1): if len(self.grid) == 0: return EMPTY_SHAPE tim = tim % 4 last_grid = self.rotate_grid[-1] for t in range(len(self.rotate_grid), tim+1): n, m = len(last_grid), len(last_grid[0]) new_grid = build_mx(m, n) # swap n and m for i in range(n): for j in range(m): new_grid[m-j-1][i] = last_grid[i][j] self.rotate_grid.append(new_grid) last_grid = new_grid return self.rotate_grid[tim] def v_mirror(self): if len(self.grid) == 0: return [[]] n, m = len(self.grid), len(self.grid[0]) new_grid = build_mx(n, m) for i in range(n): for j in range(m): new_grid[i][j], new_grid[n-i-1][j] = self.grid[n-i-1][j], self.grid[i][j] return new_grid def h_mirror(self): if len(self.grid) == 0: return EMPTY_SHAPE() n, m = len(self.grid), len(self.grid[0]) new_grid = build_mx(n, m) for j in range(m): for i in range(n): new_grid[i][j], new_grid[i][m-j-1] = self.grid[i][m-j-1], self.grid[i][j] return new_grid def __str__(self) -> str: return '\n'.join([''.join(row) for row in self.grid]) def __hash__(self) -> int: return hash(self.__str__()) def __eq__(self, other): if not isinstance(other, type(self)): return NotImplemented return self.__str__() == other.__str__() def __lt__(self, rhs): return self.name < rhs.name class ShapeAO(Shape): def __init__(self): grid = [ 'AA', 'A', 'AA' ] super().__init__(grid) class ShapeG(Shape): def __init__(self): grid = [ 'GGG', 'G', 'G' ] super().__init__(grid) class ShapeI(Shape): def __init__(self): grid = [ 'IIII', ] super().__init__(grid) class ShapeL(Shape): def __init__(self): grid = [ 'LLLL', 'L', ] super().__init__(grid) class Shapel(Shape): def __init__(self): grid = [ 'lll', 'l', ] super().__init__(grid) class ShapeO(Shape): def __init__(self): grid = [ 'O', 'OO', 'OO', ] super().__init__(grid) class ShapeS(Shape): def __init__(self): grid = [ ' SS', 'SS', ] super().__init__(grid) class ShapeSS(Shape): def __init__(self): grid = [ ' DD', 'DDD', ] super().__init__(grid) class ShapeT(Shape): def __init__(self): grid = [ 'TTT', ' T', ' T', ] super().__init__(grid) class ShapeZ(Shape): def __init__(self): grid = [ ' ZZ', ' Z', 'ZZ', ] super().__init__(grid)
def build_mx(n, m): grid = [] for i in range(n): grid.append([' '] * m) return grid def empty_shape(): return [[]] class Shape(object): _name = None grid = empty_shape() rotate_grid = [] def __init__(self, grid): n = len(grid) m = max([len(row) for row in grid]) self.grid = build_mx(n, m) for (i, row) in enumerate(grid): for (j, col) in enumerate(row): self.grid[i][j] = col self.rotate_grid = [self.grid] @property def name(self): if self._name is None: for row in self.grid: for col in row: if col != ' ': self._name = col return col return self._name def all_shapes(self): visited = {self} yield self for i in range(4): out = shape(self.rotate(i)) if out not in visited: yield out visited.add(out) h_out = shape(self.h_mirror()) if h_out not in visited: yield h_out visited.add(h_out) for i in range(4): out = shape(h_out.rotate(i)) if out not in visited: yield out visited.add(out) v_out = shape(self.v_mirror()) if v_out not in visited: yield v_out visited.add(v_out) for i in range(4): out = shape(v_out.rotate(i)) if out not in visited: yield out visited.add(out) return def rotate(self, tim=1): if len(self.grid) == 0: return EMPTY_SHAPE tim = tim % 4 last_grid = self.rotate_grid[-1] for t in range(len(self.rotate_grid), tim + 1): (n, m) = (len(last_grid), len(last_grid[0])) new_grid = build_mx(m, n) for i in range(n): for j in range(m): new_grid[m - j - 1][i] = last_grid[i][j] self.rotate_grid.append(new_grid) last_grid = new_grid return self.rotate_grid[tim] def v_mirror(self): if len(self.grid) == 0: return [[]] (n, m) = (len(self.grid), len(self.grid[0])) new_grid = build_mx(n, m) for i in range(n): for j in range(m): (new_grid[i][j], new_grid[n - i - 1][j]) = (self.grid[n - i - 1][j], self.grid[i][j]) return new_grid def h_mirror(self): if len(self.grid) == 0: return empty_shape() (n, m) = (len(self.grid), len(self.grid[0])) new_grid = build_mx(n, m) for j in range(m): for i in range(n): (new_grid[i][j], new_grid[i][m - j - 1]) = (self.grid[i][m - j - 1], self.grid[i][j]) return new_grid def __str__(self) -> str: return '\n'.join([''.join(row) for row in self.grid]) def __hash__(self) -> int: return hash(self.__str__()) def __eq__(self, other): if not isinstance(other, type(self)): return NotImplemented return self.__str__() == other.__str__() def __lt__(self, rhs): return self.name < rhs.name class Shapeao(Shape): def __init__(self): grid = ['AA', 'A', 'AA'] super().__init__(grid) class Shapeg(Shape): def __init__(self): grid = ['GGG', 'G', 'G'] super().__init__(grid) class Shapei(Shape): def __init__(self): grid = ['IIII'] super().__init__(grid) class Shapel(Shape): def __init__(self): grid = ['LLLL', 'L'] super().__init__(grid) class Shapel(Shape): def __init__(self): grid = ['lll', 'l'] super().__init__(grid) class Shapeo(Shape): def __init__(self): grid = ['O', 'OO', 'OO'] super().__init__(grid) class Shapes(Shape): def __init__(self): grid = [' SS', 'SS'] super().__init__(grid) class Shapess(Shape): def __init__(self): grid = [' DD', 'DDD'] super().__init__(grid) class Shapet(Shape): def __init__(self): grid = ['TTT', ' T', ' T'] super().__init__(grid) class Shapez(Shape): def __init__(self): grid = [' ZZ', ' Z', 'ZZ'] super().__init__(grid)
def cal_average(num): i = 0 for x in num: i += x avg = i / len(num) return avg cal_average([1,2,3,4])
def cal_average(num): i = 0 for x in num: i += x avg = i / len(num) return avg cal_average([1, 2, 3, 4])
#!/use/bin/python3 __author__ = 'yangdd' ''' example 024 ''' a = 2 b =1 total = 0.0 for i in range(1,21): total += a/b a,b=a+b,a print(total)
__author__ = 'yangdd' '\n\texample 024\n' a = 2 b = 1 total = 0.0 for i in range(1, 21): total += a / b (a, b) = (a + b, a) print(total)
# # PySNMP MIB module RFC1285-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RFC1285-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:48:17 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") ObjectIdentity, transmission, Counter32, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, NotificationType, MibIdentifier, TimeTicks, Unsigned32, ModuleIdentity, Counter64, Integer32, Gauge32, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "transmission", "Counter32", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "NotificationType", "MibIdentifier", "TimeTicks", "Unsigned32", "ModuleIdentity", "Counter64", "Integer32", "Gauge32", "Bits") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") fddi = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15)) class FddiTime(Integer32): subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) class FddiResourceId(Integer32): subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 65535) class FddiSMTStationIdType(OctetString): subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(8, 8) fixedLength = 8 class FddiMACLongAddressType(OctetString): subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6) fixedLength = 6 snmpFddiSMT = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 1)) snmpFddiMAC = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 2)) snmpFddiPATH = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 3)) snmpFddiPORT = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 4)) snmpFddiATTACHMENT = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 5)) snmpFddiChipSets = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 6)) snmpFddiSMTNumber = MibScalar((1, 3, 6, 1, 2, 1, 10, 15, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTNumber.setStatus('mandatory') snmpFddiSMTTable = MibTable((1, 3, 6, 1, 2, 1, 10, 15, 1, 2), ) if mibBuilder.loadTexts: snmpFddiSMTTable.setStatus('mandatory') snmpFddiSMTEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1), ).setIndexNames((0, "RFC1285-MIB", "snmpFddiSMTIndex")) if mibBuilder.loadTexts: snmpFddiSMTEntry.setStatus('mandatory') snmpFddiSMTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTIndex.setStatus('mandatory') snmpFddiSMTStationId = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 2), FddiSMTStationIdType()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTStationId.setStatus('mandatory') snmpFddiSMTOpVersionId = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiSMTOpVersionId.setStatus('mandatory') snmpFddiSMTHiVersionId = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTHiVersionId.setStatus('mandatory') snmpFddiSMTLoVersionId = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTLoVersionId.setStatus('mandatory') snmpFddiSMTMACCt = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTMACCt.setStatus('mandatory') snmpFddiSMTNonMasterCt = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTNonMasterCt.setStatus('mandatory') snmpFddiSMTMasterCt = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTMasterCt.setStatus('mandatory') snmpFddiSMTPathsAvailable = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTPathsAvailable.setStatus('mandatory') snmpFddiSMTConfigCapabilities = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 3))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTConfigCapabilities.setStatus('mandatory') snmpFddiSMTConfigPolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 3))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiSMTConfigPolicy.setStatus('mandatory') snmpFddiSMTConnectionPolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiSMTConnectionPolicy.setStatus('mandatory') snmpFddiSMTTNotify = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(2, 30))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiSMTTNotify.setStatus('mandatory') snmpFddiSMTStatusReporting = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTStatusReporting.setStatus('mandatory') snmpFddiSMTECMState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=NamedValues(("ec0", 1), ("ec1", 2), ("ec2", 3), ("ec3", 4), ("ec4", 5), ("ec5", 6), ("ec6", 7), ("ec7", 8)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTECMState.setStatus('mandatory') snmpFddiSMTCFState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("cf0", 1), ("cf1", 2), ("cf2", 3), ("cf3", 4), ("cf4", 5), ("cf5", 6)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTCFState.setStatus('mandatory') snmpFddiSMTHoldState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("not-implemented", 1), ("not-holding", 2), ("holding-prm", 3), ("holding-sec", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTHoldState.setStatus('mandatory') snmpFddiSMTRemoteDisconnectFlag = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiSMTRemoteDisconnectFlag.setStatus('mandatory') snmpFddiSMTStationAction = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("connect", 2), ("disconnect", 3), ("path-Test", 4), ("self-Test", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiSMTStationAction.setStatus('mandatory') snmpFddiMACNumber = MibScalar((1, 3, 6, 1, 2, 1, 10, 15, 2, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACNumber.setStatus('mandatory') snmpFddiMACTable = MibTable((1, 3, 6, 1, 2, 1, 10, 15, 2, 2), ) if mibBuilder.loadTexts: snmpFddiMACTable.setStatus('mandatory') snmpFddiMACEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1), ).setIndexNames((0, "RFC1285-MIB", "snmpFddiMACSMTIndex"), (0, "RFC1285-MIB", "snmpFddiMACIndex")) if mibBuilder.loadTexts: snmpFddiMACEntry.setStatus('mandatory') snmpFddiMACSMTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACSMTIndex.setStatus('mandatory') snmpFddiMACIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACIndex.setStatus('mandatory') snmpFddiMACFrameStatusCapabilities = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1799))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACFrameStatusCapabilities.setStatus('mandatory') snmpFddiMACTMaxGreatestLowerBound = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 4), FddiTime()).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiMACTMaxGreatestLowerBound.setStatus('mandatory') snmpFddiMACTVXGreatestLowerBound = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 5), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACTVXGreatestLowerBound.setStatus('mandatory') snmpFddiMACPathsAvailable = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACPathsAvailable.setStatus('mandatory') snmpFddiMACCurrentPath = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 4, 8, 16))).clone(namedValues=NamedValues(("unknown", 1), ("primary", 2), ("secondary", 4), ("local", 8), ("isolated", 16)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACCurrentPath.setStatus('mandatory') snmpFddiMACUpstreamNbr = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 8), FddiMACLongAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACUpstreamNbr.setStatus('mandatory') snmpFddiMACOldUpstreamNbr = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 9), FddiMACLongAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACOldUpstreamNbr.setStatus('mandatory') snmpFddiMACDupAddrTest = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("pass", 2), ("fail", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACDupAddrTest.setStatus('mandatory') snmpFddiMACPathsRequested = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 11), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiMACPathsRequested.setStatus('mandatory') snmpFddiMACDownstreamPORTType = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("a", 1), ("b", 2), ("s", 3), ("m", 4), ("unknown", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACDownstreamPORTType.setStatus('mandatory') snmpFddiMACSMTAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 13), FddiMACLongAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACSMTAddress.setStatus('mandatory') snmpFddiMACTReq = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 14), FddiTime()).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiMACTReq.setStatus('mandatory') snmpFddiMACTNeg = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 15), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACTNeg.setStatus('mandatory') snmpFddiMACTMax = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 16), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACTMax.setStatus('mandatory') snmpFddiMACTvxValue = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 17), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACTvxValue.setStatus('mandatory') snmpFddiMACTMin = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 18), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACTMin.setStatus('mandatory') snmpFddiMACCurrentFrameStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiMACCurrentFrameStatus.setStatus('mandatory') snmpFddiMACFrameCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 20), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACFrameCts.setStatus('mandatory') snmpFddiMACErrorCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 21), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACErrorCts.setStatus('mandatory') snmpFddiMACLostCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 22), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACLostCts.setStatus('mandatory') snmpFddiMACFrameErrorThreshold = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACFrameErrorThreshold.setStatus('mandatory') snmpFddiMACFrameErrorRatio = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACFrameErrorRatio.setStatus('mandatory') snmpFddiMACRMTState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=NamedValues(("rm0", 1), ("rm1", 2), ("rm2", 3), ("rm3", 4), ("rm4", 5), ("rm5", 6), ("rm6", 7), ("rm7", 8)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACRMTState.setStatus('mandatory') snmpFddiMACDaFlag = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACDaFlag.setStatus('mandatory') snmpFddiMACUnaDaFlag = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 27), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACUnaDaFlag.setStatus('mandatory') snmpFddiMACFrameCondition = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACFrameCondition.setStatus('mandatory') snmpFddiMACChipSet = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 29), ObjectIdentifier()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiMACChipSet.setStatus('mandatory') snmpFddiMACAction = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 30), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("enableLLCService", 2), ("disableLLCService", 3), ("connectMAC", 4), ("disconnectMAC", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiMACAction.setStatus('mandatory') snmpFddiPORTNumber = MibScalar((1, 3, 6, 1, 2, 1, 10, 15, 4, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTNumber.setStatus('mandatory') snmpFddiPORTTable = MibTable((1, 3, 6, 1, 2, 1, 10, 15, 4, 2), ) if mibBuilder.loadTexts: snmpFddiPORTTable.setStatus('mandatory') snmpFddiPORTEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1), ).setIndexNames((0, "RFC1285-MIB", "snmpFddiPORTSMTIndex"), (0, "RFC1285-MIB", "snmpFddiPORTIndex")) if mibBuilder.loadTexts: snmpFddiPORTEntry.setStatus('mandatory') snmpFddiPORTSMTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTSMTIndex.setStatus('mandatory') snmpFddiPORTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTIndex.setStatus('mandatory') snmpFddiPORTPCType = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("a", 1), ("b", 2), ("s", 3), ("m", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTPCType.setStatus('mandatory') snmpFddiPORTPCNeighbor = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("a", 1), ("b", 2), ("s", 3), ("m", 4), ("unknown", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTPCNeighbor.setStatus('mandatory') snmpFddiPORTConnectionPolicies = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTConnectionPolicies.setStatus('mandatory') snmpFddiPORTRemoteMACIndicated = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTRemoteMACIndicated.setStatus('mandatory') snmpFddiPORTCEState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("ce0", 1), ("ce1", 2), ("ce2", 3), ("ce3", 4), ("ce4", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTCEState.setStatus('mandatory') snmpFddiPORTPathsRequested = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 15))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTPathsRequested.setStatus('mandatory') snmpFddiPORTMACPlacement = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 9), FddiResourceId()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTMACPlacement.setStatus('mandatory') snmpFddiPORTAvailablePaths = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTAvailablePaths.setStatus('mandatory') snmpFddiPORTMACLoopTime = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 11), FddiTime()).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTMACLoopTime.setStatus('mandatory') snmpFddiPORTTBMax = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 12), FddiTime()).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTTBMax.setStatus('mandatory') snmpFddiPORTBSFlag = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTBSFlag.setStatus('mandatory') snmpFddiPORTLCTFailCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 14), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTLCTFailCts.setStatus('mandatory') snmpFddiPORTLerEstimate = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(4, 15))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTLerEstimate.setStatus('mandatory') snmpFddiPORTLemRejectCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTLemRejectCts.setStatus('mandatory') snmpFddiPORTLemCts = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTLemCts.setStatus('mandatory') snmpFddiPORTLerCutoff = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(4, 15))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTLerCutoff.setStatus('mandatory') snmpFddiPORTLerAlarm = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(4, 15))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTLerAlarm.setStatus('mandatory') snmpFddiPORTConnectState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("disabled", 1), ("connecting", 2), ("standby", 3), ("active", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTConnectState.setStatus('mandatory') snmpFddiPORTPCMState = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("pc0", 1), ("pc1", 2), ("pc2", 3), ("pc3", 4), ("pc4", 5), ("pc5", 6), ("pc6", 7), ("pc7", 8), ("pc8", 9), ("pc9", 10)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTPCMState.setStatus('mandatory') snmpFddiPORTPCWithhold = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 22), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("m-m", 2), ("other", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTPCWithhold.setStatus('mandatory') snmpFddiPORTLerCondition = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 23), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTLerCondition.setStatus('mandatory') snmpFddiPORTChipSet = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 24), ObjectIdentifier()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiPORTChipSet.setStatus('mandatory') snmpFddiPORTAction = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("other", 1), ("maintPORT", 2), ("enablePORT", 3), ("disablePORT", 4), ("startPORT", 5), ("stopPORT", 6)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiPORTAction.setStatus('mandatory') snmpFddiATTACHMENTNumber = MibScalar((1, 3, 6, 1, 2, 1, 10, 15, 5, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTNumber.setStatus('mandatory') snmpFddiATTACHMENTTable = MibTable((1, 3, 6, 1, 2, 1, 10, 15, 5, 2), ) if mibBuilder.loadTexts: snmpFddiATTACHMENTTable.setStatus('mandatory') snmpFddiATTACHMENTEntry = MibTableRow((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1), ).setIndexNames((0, "RFC1285-MIB", "snmpFddiATTACHMENTSMTIndex"), (0, "RFC1285-MIB", "snmpFddiATTACHMENTIndex")) if mibBuilder.loadTexts: snmpFddiATTACHMENTEntry.setStatus('mandatory') snmpFddiATTACHMENTSMTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTSMTIndex.setStatus('mandatory') snmpFddiATTACHMENTIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTIndex.setStatus('mandatory') snmpFddiATTACHMENTClass = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("single-attachment", 1), ("dual-attachment", 2), ("concentrator", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTClass.setStatus('mandatory') snmpFddiATTACHMENTOpticalBypassPresent = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTOpticalBypassPresent.setStatus('mandatory') snmpFddiATTACHMENTIMaxExpiration = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 5), FddiTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTIMaxExpiration.setStatus('mandatory') snmpFddiATTACHMENTInsertedStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("true", 1), ("false", 2), ("unimplemented", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: snmpFddiATTACHMENTInsertedStatus.setStatus('mandatory') snmpFddiATTACHMENTInsertPolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("true", 1), ("false", 2), ("unimplemented", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: snmpFddiATTACHMENTInsertPolicy.setStatus('mandatory') snmpFddiPHYChipSets = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 1)) snmpFddiMACChipSets = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 2)) snmpFddiPHYMACChipSets = MibIdentifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 3)) mibBuilder.exportSymbols("RFC1285-MIB", snmpFddiMACTvxValue=snmpFddiMACTvxValue, FddiSMTStationIdType=FddiSMTStationIdType, snmpFddiSMTCFState=snmpFddiSMTCFState, snmpFddiSMTNumber=snmpFddiSMTNumber, snmpFddiPORTSMTIndex=snmpFddiPORTSMTIndex, snmpFddiPORTBSFlag=snmpFddiPORTBSFlag, snmpFddiMACAction=snmpFddiMACAction, snmpFddiPATH=snmpFddiPATH, snmpFddiPORTNumber=snmpFddiPORTNumber, snmpFddiMACLostCts=snmpFddiMACLostCts, snmpFddiPORTChipSet=snmpFddiPORTChipSet, snmpFddiPORTPCType=snmpFddiPORTPCType, snmpFddiPORTIndex=snmpFddiPORTIndex, snmpFddiSMTStationId=snmpFddiSMTStationId, snmpFddiPORTLerAlarm=snmpFddiPORTLerAlarm, snmpFddiSMTLoVersionId=snmpFddiSMTLoVersionId, snmpFddiPORTRemoteMACIndicated=snmpFddiPORTRemoteMACIndicated, snmpFddiPORTPathsRequested=snmpFddiPORTPathsRequested, snmpFddiMACFrameCondition=snmpFddiMACFrameCondition, snmpFddiPORTConnectionPolicies=snmpFddiPORTConnectionPolicies, snmpFddiPORTTBMax=snmpFddiPORTTBMax, snmpFddiSMTTable=snmpFddiSMTTable, snmpFddiPORTAvailablePaths=snmpFddiPORTAvailablePaths, fddi=fddi, snmpFddiPORTPCWithhold=snmpFddiPORTPCWithhold, snmpFddiPORTPCMState=snmpFddiPORTPCMState, FddiResourceId=FddiResourceId, snmpFddiPORTLerCondition=snmpFddiPORTLerCondition, snmpFddiSMTIndex=snmpFddiSMTIndex, snmpFddiMACSMTAddress=snmpFddiMACSMTAddress, snmpFddiATTACHMENTInsertPolicy=snmpFddiATTACHMENTInsertPolicy, snmpFddiATTACHMENTSMTIndex=snmpFddiATTACHMENTSMTIndex, snmpFddiMACSMTIndex=snmpFddiMACSMTIndex, snmpFddiMACTMax=snmpFddiMACTMax, snmpFddiPHYMACChipSets=snmpFddiPHYMACChipSets, snmpFddiSMT=snmpFddiSMT, snmpFddiMACTVXGreatestLowerBound=snmpFddiMACTVXGreatestLowerBound, snmpFddiATTACHMENT=snmpFddiATTACHMENT, FddiTime=FddiTime, snmpFddiSMTConnectionPolicy=snmpFddiSMTConnectionPolicy, snmpFddiMACOldUpstreamNbr=snmpFddiMACOldUpstreamNbr, snmpFddiMACUnaDaFlag=snmpFddiMACUnaDaFlag, snmpFddiSMTTNotify=snmpFddiSMTTNotify, FddiMACLongAddressType=FddiMACLongAddressType, snmpFddiMACFrameStatusCapabilities=snmpFddiMACFrameStatusCapabilities, snmpFddiATTACHMENTTable=snmpFddiATTACHMENTTable, snmpFddiSMTEntry=snmpFddiSMTEntry, snmpFddiPORT=snmpFddiPORT, snmpFddiSMTMasterCt=snmpFddiSMTMasterCt, snmpFddiMACUpstreamNbr=snmpFddiMACUpstreamNbr, snmpFddiPORTLerCutoff=snmpFddiPORTLerCutoff, snmpFddiMACCurrentPath=snmpFddiMACCurrentPath, snmpFddiMACErrorCts=snmpFddiMACErrorCts, snmpFddiMACChipSet=snmpFddiMACChipSet, snmpFddiSMTStatusReporting=snmpFddiSMTStatusReporting, snmpFddiMACIndex=snmpFddiMACIndex, snmpFddiATTACHMENTIMaxExpiration=snmpFddiATTACHMENTIMaxExpiration, snmpFddiSMTPathsAvailable=snmpFddiSMTPathsAvailable, snmpFddiATTACHMENTNumber=snmpFddiATTACHMENTNumber, snmpFddiMACRMTState=snmpFddiMACRMTState, snmpFddiPORTAction=snmpFddiPORTAction, snmpFddiMACFrameErrorRatio=snmpFddiMACFrameErrorRatio, snmpFddiSMTConfigCapabilities=snmpFddiSMTConfigCapabilities, snmpFddiPORTConnectState=snmpFddiPORTConnectState, snmpFddiMACDownstreamPORTType=snmpFddiMACDownstreamPORTType, snmpFddiPHYChipSets=snmpFddiPHYChipSets, snmpFddiPORTLemRejectCts=snmpFddiPORTLemRejectCts, snmpFddiSMTOpVersionId=snmpFddiSMTOpVersionId, snmpFddiMACChipSets=snmpFddiMACChipSets, snmpFddiPORTTable=snmpFddiPORTTable, snmpFddiPORTLemCts=snmpFddiPORTLemCts, snmpFddiMACPathsRequested=snmpFddiMACPathsRequested, snmpFddiMACFrameCts=snmpFddiMACFrameCts, snmpFddiSMTECMState=snmpFddiSMTECMState, snmpFddiMACDupAddrTest=snmpFddiMACDupAddrTest, snmpFddiMACTNeg=snmpFddiMACTNeg, snmpFddiMACDaFlag=snmpFddiMACDaFlag, snmpFddiATTACHMENTClass=snmpFddiATTACHMENTClass, snmpFddiMACPathsAvailable=snmpFddiMACPathsAvailable, snmpFddiSMTMACCt=snmpFddiSMTMACCt, snmpFddiATTACHMENTEntry=snmpFddiATTACHMENTEntry, snmpFddiMACTReq=snmpFddiMACTReq, snmpFddiPORTLerEstimate=snmpFddiPORTLerEstimate, snmpFddiMACFrameErrorThreshold=snmpFddiMACFrameErrorThreshold, snmpFddiPORTPCNeighbor=snmpFddiPORTPCNeighbor, snmpFddiMACTMin=snmpFddiMACTMin, snmpFddiMACNumber=snmpFddiMACNumber, snmpFddiPORTLCTFailCts=snmpFddiPORTLCTFailCts, snmpFddiChipSets=snmpFddiChipSets, snmpFddiPORTEntry=snmpFddiPORTEntry, snmpFddiMACTMaxGreatestLowerBound=snmpFddiMACTMaxGreatestLowerBound, snmpFddiMACTable=snmpFddiMACTable, snmpFddiMAC=snmpFddiMAC, snmpFddiSMTNonMasterCt=snmpFddiSMTNonMasterCt, snmpFddiSMTRemoteDisconnectFlag=snmpFddiSMTRemoteDisconnectFlag, snmpFddiPORTMACLoopTime=snmpFddiPORTMACLoopTime, snmpFddiSMTHiVersionId=snmpFddiSMTHiVersionId, snmpFddiSMTHoldState=snmpFddiSMTHoldState, snmpFddiSMTStationAction=snmpFddiSMTStationAction, snmpFddiATTACHMENTOpticalBypassPresent=snmpFddiATTACHMENTOpticalBypassPresent, snmpFddiMACEntry=snmpFddiMACEntry, snmpFddiPORTMACPlacement=snmpFddiPORTMACPlacement, snmpFddiATTACHMENTInsertedStatus=snmpFddiATTACHMENTInsertedStatus, snmpFddiATTACHMENTIndex=snmpFddiATTACHMENTIndex, snmpFddiSMTConfigPolicy=snmpFddiSMTConfigPolicy, snmpFddiPORTCEState=snmpFddiPORTCEState, snmpFddiMACCurrentFrameStatus=snmpFddiMACCurrentFrameStatus)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'ValueSizeConstraint') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (object_identity, transmission, counter32, ip_address, mib_scalar, mib_table, mib_table_row, mib_table_column, iso, notification_type, mib_identifier, time_ticks, unsigned32, module_identity, counter64, integer32, gauge32, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'transmission', 'Counter32', 'IpAddress', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'iso', 'NotificationType', 'MibIdentifier', 'TimeTicks', 'Unsigned32', 'ModuleIdentity', 'Counter64', 'Integer32', 'Gauge32', 'Bits') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') fddi = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15)) class Fdditime(Integer32): subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 2147483647) class Fddiresourceid(Integer32): subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 65535) class Fddismtstationidtype(OctetString): subtype_spec = OctetString.subtypeSpec + value_size_constraint(8, 8) fixed_length = 8 class Fddimaclongaddresstype(OctetString): subtype_spec = OctetString.subtypeSpec + value_size_constraint(6, 6) fixed_length = 6 snmp_fddi_smt = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 1)) snmp_fddi_mac = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 2)) snmp_fddi_path = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 3)) snmp_fddi_port = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 4)) snmp_fddi_attachment = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 5)) snmp_fddi_chip_sets = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 6)) snmp_fddi_smt_number = mib_scalar((1, 3, 6, 1, 2, 1, 10, 15, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTNumber.setStatus('mandatory') snmp_fddi_smt_table = mib_table((1, 3, 6, 1, 2, 1, 10, 15, 1, 2)) if mibBuilder.loadTexts: snmpFddiSMTTable.setStatus('mandatory') snmp_fddi_smt_entry = mib_table_row((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1)).setIndexNames((0, 'RFC1285-MIB', 'snmpFddiSMTIndex')) if mibBuilder.loadTexts: snmpFddiSMTEntry.setStatus('mandatory') snmp_fddi_smt_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTIndex.setStatus('mandatory') snmp_fddi_smt_station_id = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 2), fddi_smt_station_id_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTStationId.setStatus('mandatory') snmp_fddi_smt_op_version_id = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiSMTOpVersionId.setStatus('mandatory') snmp_fddi_smt_hi_version_id = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTHiVersionId.setStatus('mandatory') snmp_fddi_smt_lo_version_id = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTLoVersionId.setStatus('mandatory') snmp_fddi_smtmac_ct = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTMACCt.setStatus('mandatory') snmp_fddi_smt_non_master_ct = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(0, 2))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTNonMasterCt.setStatus('mandatory') snmp_fddi_smt_master_ct = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTMasterCt.setStatus('mandatory') snmp_fddi_smt_paths_available = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTPathsAvailable.setStatus('mandatory') snmp_fddi_smt_config_capabilities = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(0, 3))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTConfigCapabilities.setStatus('mandatory') snmp_fddi_smt_config_policy = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 11), integer32().subtype(subtypeSpec=value_range_constraint(0, 3))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiSMTConfigPolicy.setStatus('mandatory') snmp_fddi_smt_connection_policy = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 12), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiSMTConnectionPolicy.setStatus('mandatory') snmp_fddi_smtt_notify = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 13), integer32().subtype(subtypeSpec=value_range_constraint(2, 30))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiSMTTNotify.setStatus('mandatory') snmp_fddi_smt_status_reporting = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTStatusReporting.setStatus('mandatory') snmp_fddi_smtecm_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 15), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=named_values(('ec0', 1), ('ec1', 2), ('ec2', 3), ('ec3', 4), ('ec4', 5), ('ec5', 6), ('ec6', 7), ('ec7', 8)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTECMState.setStatus('mandatory') snmp_fddi_smtcf_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 16), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('cf0', 1), ('cf1', 2), ('cf2', 3), ('cf3', 4), ('cf4', 5), ('cf5', 6)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTCFState.setStatus('mandatory') snmp_fddi_smt_hold_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 17), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('not-implemented', 1), ('not-holding', 2), ('holding-prm', 3), ('holding-sec', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTHoldState.setStatus('mandatory') snmp_fddi_smt_remote_disconnect_flag = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 18), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiSMTRemoteDisconnectFlag.setStatus('mandatory') snmp_fddi_smt_station_action = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 1, 2, 1, 19), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('connect', 2), ('disconnect', 3), ('path-Test', 4), ('self-Test', 5)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiSMTStationAction.setStatus('mandatory') snmp_fddi_mac_number = mib_scalar((1, 3, 6, 1, 2, 1, 10, 15, 2, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACNumber.setStatus('mandatory') snmp_fddi_mac_table = mib_table((1, 3, 6, 1, 2, 1, 10, 15, 2, 2)) if mibBuilder.loadTexts: snmpFddiMACTable.setStatus('mandatory') snmp_fddi_mac_entry = mib_table_row((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1)).setIndexNames((0, 'RFC1285-MIB', 'snmpFddiMACSMTIndex'), (0, 'RFC1285-MIB', 'snmpFddiMACIndex')) if mibBuilder.loadTexts: snmpFddiMACEntry.setStatus('mandatory') snmp_fddi_macsmt_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACSMTIndex.setStatus('mandatory') snmp_fddi_mac_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACIndex.setStatus('mandatory') snmp_fddi_mac_frame_status_capabilities = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 1799))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACFrameStatusCapabilities.setStatus('mandatory') snmp_fddi_mact_max_greatest_lower_bound = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 4), fddi_time()).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiMACTMaxGreatestLowerBound.setStatus('mandatory') snmp_fddi_mactvx_greatest_lower_bound = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 5), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACTVXGreatestLowerBound.setStatus('mandatory') snmp_fddi_mac_paths_available = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACPathsAvailable.setStatus('mandatory') snmp_fddi_mac_current_path = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 4, 8, 16))).clone(namedValues=named_values(('unknown', 1), ('primary', 2), ('secondary', 4), ('local', 8), ('isolated', 16)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACCurrentPath.setStatus('mandatory') snmp_fddi_mac_upstream_nbr = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 8), fddi_mac_long_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACUpstreamNbr.setStatus('mandatory') snmp_fddi_mac_old_upstream_nbr = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 9), fddi_mac_long_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACOldUpstreamNbr.setStatus('mandatory') snmp_fddi_mac_dup_addr_test = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('none', 1), ('pass', 2), ('fail', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACDupAddrTest.setStatus('mandatory') snmp_fddi_mac_paths_requested = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 11), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiMACPathsRequested.setStatus('mandatory') snmp_fddi_mac_downstream_port_type = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('a', 1), ('b', 2), ('s', 3), ('m', 4), ('unknown', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACDownstreamPORTType.setStatus('mandatory') snmp_fddi_macsmt_address = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 13), fddi_mac_long_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACSMTAddress.setStatus('mandatory') snmp_fddi_mact_req = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 14), fddi_time()).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiMACTReq.setStatus('mandatory') snmp_fddi_mact_neg = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 15), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACTNeg.setStatus('mandatory') snmp_fddi_mact_max = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 16), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACTMax.setStatus('mandatory') snmp_fddi_mac_tvx_value = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 17), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACTvxValue.setStatus('mandatory') snmp_fddi_mact_min = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 18), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACTMin.setStatus('mandatory') snmp_fddi_mac_current_frame_status = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 19), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiMACCurrentFrameStatus.setStatus('mandatory') snmp_fddi_mac_frame_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 20), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACFrameCts.setStatus('mandatory') snmp_fddi_mac_error_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 21), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACErrorCts.setStatus('mandatory') snmp_fddi_mac_lost_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 22), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACLostCts.setStatus('mandatory') snmp_fddi_mac_frame_error_threshold = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 23), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACFrameErrorThreshold.setStatus('mandatory') snmp_fddi_mac_frame_error_ratio = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 24), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACFrameErrorRatio.setStatus('mandatory') snmp_fddi_macrmt_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 25), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8))).clone(namedValues=named_values(('rm0', 1), ('rm1', 2), ('rm2', 3), ('rm3', 4), ('rm4', 5), ('rm5', 6), ('rm6', 7), ('rm7', 8)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACRMTState.setStatus('mandatory') snmp_fddi_mac_da_flag = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 26), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACDaFlag.setStatus('mandatory') snmp_fddi_mac_una_da_flag = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 27), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACUnaDaFlag.setStatus('mandatory') snmp_fddi_mac_frame_condition = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 28), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACFrameCondition.setStatus('mandatory') snmp_fddi_mac_chip_set = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 29), object_identifier()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiMACChipSet.setStatus('mandatory') snmp_fddi_mac_action = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 2, 2, 1, 30), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('enableLLCService', 2), ('disableLLCService', 3), ('connectMAC', 4), ('disconnectMAC', 5)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiMACAction.setStatus('mandatory') snmp_fddi_port_number = mib_scalar((1, 3, 6, 1, 2, 1, 10, 15, 4, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTNumber.setStatus('mandatory') snmp_fddi_port_table = mib_table((1, 3, 6, 1, 2, 1, 10, 15, 4, 2)) if mibBuilder.loadTexts: snmpFddiPORTTable.setStatus('mandatory') snmp_fddi_port_entry = mib_table_row((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1)).setIndexNames((0, 'RFC1285-MIB', 'snmpFddiPORTSMTIndex'), (0, 'RFC1285-MIB', 'snmpFddiPORTIndex')) if mibBuilder.loadTexts: snmpFddiPORTEntry.setStatus('mandatory') snmp_fddi_portsmt_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTSMTIndex.setStatus('mandatory') snmp_fddi_port_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTIndex.setStatus('mandatory') snmp_fddi_portpc_type = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('a', 1), ('b', 2), ('s', 3), ('m', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTPCType.setStatus('mandatory') snmp_fddi_portpc_neighbor = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('a', 1), ('b', 2), ('s', 3), ('m', 4), ('unknown', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTPCNeighbor.setStatus('mandatory') snmp_fddi_port_connection_policies = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTConnectionPolicies.setStatus('mandatory') snmp_fddi_port_remote_mac_indicated = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTRemoteMACIndicated.setStatus('mandatory') snmp_fddi_portce_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('ce0', 1), ('ce1', 2), ('ce2', 3), ('ce3', 4), ('ce4', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTCEState.setStatus('mandatory') snmp_fddi_port_paths_requested = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 15))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTPathsRequested.setStatus('mandatory') snmp_fddi_portmac_placement = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 9), fddi_resource_id()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTMACPlacement.setStatus('mandatory') snmp_fddi_port_available_paths = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTAvailablePaths.setStatus('mandatory') snmp_fddi_portmac_loop_time = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 11), fddi_time()).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTMACLoopTime.setStatus('mandatory') snmp_fddi_porttb_max = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 12), fddi_time()).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTTBMax.setStatus('mandatory') snmp_fddi_portbs_flag = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTBSFlag.setStatus('mandatory') snmp_fddi_portlct_fail_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 14), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTLCTFailCts.setStatus('mandatory') snmp_fddi_port_ler_estimate = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(4, 15))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTLerEstimate.setStatus('mandatory') snmp_fddi_port_lem_reject_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 16), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTLemRejectCts.setStatus('mandatory') snmp_fddi_port_lem_cts = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 17), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTLemCts.setStatus('mandatory') snmp_fddi_port_ler_cutoff = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 18), integer32().subtype(subtypeSpec=value_range_constraint(4, 15))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTLerCutoff.setStatus('mandatory') snmp_fddi_port_ler_alarm = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 19), integer32().subtype(subtypeSpec=value_range_constraint(4, 15))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTLerAlarm.setStatus('mandatory') snmp_fddi_port_connect_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 20), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('disabled', 1), ('connecting', 2), ('standby', 3), ('active', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTConnectState.setStatus('mandatory') snmp_fddi_portpcm_state = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 21), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('pc0', 1), ('pc1', 2), ('pc2', 3), ('pc3', 4), ('pc4', 5), ('pc5', 6), ('pc6', 7), ('pc7', 8), ('pc8', 9), ('pc9', 10)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTPCMState.setStatus('mandatory') snmp_fddi_portpc_withhold = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 22), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('none', 1), ('m-m', 2), ('other', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTPCWithhold.setStatus('mandatory') snmp_fddi_port_ler_condition = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 23), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTLerCondition.setStatus('mandatory') snmp_fddi_port_chip_set = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 24), object_identifier()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiPORTChipSet.setStatus('mandatory') snmp_fddi_port_action = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 4, 2, 1, 25), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('other', 1), ('maintPORT', 2), ('enablePORT', 3), ('disablePORT', 4), ('startPORT', 5), ('stopPORT', 6)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiPORTAction.setStatus('mandatory') snmp_fddi_attachment_number = mib_scalar((1, 3, 6, 1, 2, 1, 10, 15, 5, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTNumber.setStatus('mandatory') snmp_fddi_attachment_table = mib_table((1, 3, 6, 1, 2, 1, 10, 15, 5, 2)) if mibBuilder.loadTexts: snmpFddiATTACHMENTTable.setStatus('mandatory') snmp_fddi_attachment_entry = mib_table_row((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1)).setIndexNames((0, 'RFC1285-MIB', 'snmpFddiATTACHMENTSMTIndex'), (0, 'RFC1285-MIB', 'snmpFddiATTACHMENTIndex')) if mibBuilder.loadTexts: snmpFddiATTACHMENTEntry.setStatus('mandatory') snmp_fddi_attachmentsmt_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTSMTIndex.setStatus('mandatory') snmp_fddi_attachment_index = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTIndex.setStatus('mandatory') snmp_fddi_attachment_class = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('single-attachment', 1), ('dual-attachment', 2), ('concentrator', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTClass.setStatus('mandatory') snmp_fddi_attachment_optical_bypass_present = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTOpticalBypassPresent.setStatus('mandatory') snmp_fddi_attachmenti_max_expiration = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 5), fddi_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTIMaxExpiration.setStatus('mandatory') snmp_fddi_attachment_inserted_status = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('true', 1), ('false', 2), ('unimplemented', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: snmpFddiATTACHMENTInsertedStatus.setStatus('mandatory') snmp_fddi_attachment_insert_policy = mib_table_column((1, 3, 6, 1, 2, 1, 10, 15, 5, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('true', 1), ('false', 2), ('unimplemented', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: snmpFddiATTACHMENTInsertPolicy.setStatus('mandatory') snmp_fddi_phy_chip_sets = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 1)) snmp_fddi_mac_chip_sets = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 2)) snmp_fddi_phymac_chip_sets = mib_identifier((1, 3, 6, 1, 2, 1, 10, 15, 6, 3)) mibBuilder.exportSymbols('RFC1285-MIB', snmpFddiMACTvxValue=snmpFddiMACTvxValue, FddiSMTStationIdType=FddiSMTStationIdType, snmpFddiSMTCFState=snmpFddiSMTCFState, snmpFddiSMTNumber=snmpFddiSMTNumber, snmpFddiPORTSMTIndex=snmpFddiPORTSMTIndex, snmpFddiPORTBSFlag=snmpFddiPORTBSFlag, snmpFddiMACAction=snmpFddiMACAction, snmpFddiPATH=snmpFddiPATH, snmpFddiPORTNumber=snmpFddiPORTNumber, snmpFddiMACLostCts=snmpFddiMACLostCts, snmpFddiPORTChipSet=snmpFddiPORTChipSet, snmpFddiPORTPCType=snmpFddiPORTPCType, snmpFddiPORTIndex=snmpFddiPORTIndex, snmpFddiSMTStationId=snmpFddiSMTStationId, snmpFddiPORTLerAlarm=snmpFddiPORTLerAlarm, snmpFddiSMTLoVersionId=snmpFddiSMTLoVersionId, snmpFddiPORTRemoteMACIndicated=snmpFddiPORTRemoteMACIndicated, snmpFddiPORTPathsRequested=snmpFddiPORTPathsRequested, snmpFddiMACFrameCondition=snmpFddiMACFrameCondition, snmpFddiPORTConnectionPolicies=snmpFddiPORTConnectionPolicies, snmpFddiPORTTBMax=snmpFddiPORTTBMax, snmpFddiSMTTable=snmpFddiSMTTable, snmpFddiPORTAvailablePaths=snmpFddiPORTAvailablePaths, fddi=fddi, snmpFddiPORTPCWithhold=snmpFddiPORTPCWithhold, snmpFddiPORTPCMState=snmpFddiPORTPCMState, FddiResourceId=FddiResourceId, snmpFddiPORTLerCondition=snmpFddiPORTLerCondition, snmpFddiSMTIndex=snmpFddiSMTIndex, snmpFddiMACSMTAddress=snmpFddiMACSMTAddress, snmpFddiATTACHMENTInsertPolicy=snmpFddiATTACHMENTInsertPolicy, snmpFddiATTACHMENTSMTIndex=snmpFddiATTACHMENTSMTIndex, snmpFddiMACSMTIndex=snmpFddiMACSMTIndex, snmpFddiMACTMax=snmpFddiMACTMax, snmpFddiPHYMACChipSets=snmpFddiPHYMACChipSets, snmpFddiSMT=snmpFddiSMT, snmpFddiMACTVXGreatestLowerBound=snmpFddiMACTVXGreatestLowerBound, snmpFddiATTACHMENT=snmpFddiATTACHMENT, FddiTime=FddiTime, snmpFddiSMTConnectionPolicy=snmpFddiSMTConnectionPolicy, snmpFddiMACOldUpstreamNbr=snmpFddiMACOldUpstreamNbr, snmpFddiMACUnaDaFlag=snmpFddiMACUnaDaFlag, snmpFddiSMTTNotify=snmpFddiSMTTNotify, FddiMACLongAddressType=FddiMACLongAddressType, snmpFddiMACFrameStatusCapabilities=snmpFddiMACFrameStatusCapabilities, snmpFddiATTACHMENTTable=snmpFddiATTACHMENTTable, snmpFddiSMTEntry=snmpFddiSMTEntry, snmpFddiPORT=snmpFddiPORT, snmpFddiSMTMasterCt=snmpFddiSMTMasterCt, snmpFddiMACUpstreamNbr=snmpFddiMACUpstreamNbr, snmpFddiPORTLerCutoff=snmpFddiPORTLerCutoff, snmpFddiMACCurrentPath=snmpFddiMACCurrentPath, snmpFddiMACErrorCts=snmpFddiMACErrorCts, snmpFddiMACChipSet=snmpFddiMACChipSet, snmpFddiSMTStatusReporting=snmpFddiSMTStatusReporting, snmpFddiMACIndex=snmpFddiMACIndex, snmpFddiATTACHMENTIMaxExpiration=snmpFddiATTACHMENTIMaxExpiration, snmpFddiSMTPathsAvailable=snmpFddiSMTPathsAvailable, snmpFddiATTACHMENTNumber=snmpFddiATTACHMENTNumber, snmpFddiMACRMTState=snmpFddiMACRMTState, snmpFddiPORTAction=snmpFddiPORTAction, snmpFddiMACFrameErrorRatio=snmpFddiMACFrameErrorRatio, snmpFddiSMTConfigCapabilities=snmpFddiSMTConfigCapabilities, snmpFddiPORTConnectState=snmpFddiPORTConnectState, snmpFddiMACDownstreamPORTType=snmpFddiMACDownstreamPORTType, snmpFddiPHYChipSets=snmpFddiPHYChipSets, snmpFddiPORTLemRejectCts=snmpFddiPORTLemRejectCts, snmpFddiSMTOpVersionId=snmpFddiSMTOpVersionId, snmpFddiMACChipSets=snmpFddiMACChipSets, snmpFddiPORTTable=snmpFddiPORTTable, snmpFddiPORTLemCts=snmpFddiPORTLemCts, snmpFddiMACPathsRequested=snmpFddiMACPathsRequested, snmpFddiMACFrameCts=snmpFddiMACFrameCts, snmpFddiSMTECMState=snmpFddiSMTECMState, snmpFddiMACDupAddrTest=snmpFddiMACDupAddrTest, snmpFddiMACTNeg=snmpFddiMACTNeg, snmpFddiMACDaFlag=snmpFddiMACDaFlag, snmpFddiATTACHMENTClass=snmpFddiATTACHMENTClass, snmpFddiMACPathsAvailable=snmpFddiMACPathsAvailable, snmpFddiSMTMACCt=snmpFddiSMTMACCt, snmpFddiATTACHMENTEntry=snmpFddiATTACHMENTEntry, snmpFddiMACTReq=snmpFddiMACTReq, snmpFddiPORTLerEstimate=snmpFddiPORTLerEstimate, snmpFddiMACFrameErrorThreshold=snmpFddiMACFrameErrorThreshold, snmpFddiPORTPCNeighbor=snmpFddiPORTPCNeighbor, snmpFddiMACTMin=snmpFddiMACTMin, snmpFddiMACNumber=snmpFddiMACNumber, snmpFddiPORTLCTFailCts=snmpFddiPORTLCTFailCts, snmpFddiChipSets=snmpFddiChipSets, snmpFddiPORTEntry=snmpFddiPORTEntry, snmpFddiMACTMaxGreatestLowerBound=snmpFddiMACTMaxGreatestLowerBound, snmpFddiMACTable=snmpFddiMACTable, snmpFddiMAC=snmpFddiMAC, snmpFddiSMTNonMasterCt=snmpFddiSMTNonMasterCt, snmpFddiSMTRemoteDisconnectFlag=snmpFddiSMTRemoteDisconnectFlag, snmpFddiPORTMACLoopTime=snmpFddiPORTMACLoopTime, snmpFddiSMTHiVersionId=snmpFddiSMTHiVersionId, snmpFddiSMTHoldState=snmpFddiSMTHoldState, snmpFddiSMTStationAction=snmpFddiSMTStationAction, snmpFddiATTACHMENTOpticalBypassPresent=snmpFddiATTACHMENTOpticalBypassPresent, snmpFddiMACEntry=snmpFddiMACEntry, snmpFddiPORTMACPlacement=snmpFddiPORTMACPlacement, snmpFddiATTACHMENTInsertedStatus=snmpFddiATTACHMENTInsertedStatus, snmpFddiATTACHMENTIndex=snmpFddiATTACHMENTIndex, snmpFddiSMTConfigPolicy=snmpFddiSMTConfigPolicy, snmpFddiPORTCEState=snmpFddiPORTCEState, snmpFddiMACCurrentFrameStatus=snmpFddiMACCurrentFrameStatus)
grey_image = np.mean(image, axis=-1) print("Shape: {}".format(grey_image.shape)) print("Type: {}".format(grey_image.dtype)) print("image size: {:0.3} MB".format(grey_image.nbytes / 1e6)) print("Min: {}; Max: {}".format(grey_image.min(), grey_image.max())) plt.imshow(grey_image, cmap=plt.cm.Greys_r)
grey_image = np.mean(image, axis=-1) print('Shape: {}'.format(grey_image.shape)) print('Type: {}'.format(grey_image.dtype)) print('image size: {:0.3} MB'.format(grey_image.nbytes / 1000000.0)) print('Min: {}; Max: {}'.format(grey_image.min(), grey_image.max())) plt.imshow(grey_image, cmap=plt.cm.Greys_r)
def start_HotSpot(ssid="Hovercraft",encrypted=False,passd="1234",iface="wlan0"): print("HotSpot %s encrypt %s with Pass %s on Interface %s",ssid,encrypted,passd,iface) def stop_HotSpot(): print("HotSpot stopped")
def start__hot_spot(ssid='Hovercraft', encrypted=False, passd='1234', iface='wlan0'): print('HotSpot %s encrypt %s with Pass %s on Interface %s', ssid, encrypted, passd, iface) def stop__hot_spot(): print('HotSpot stopped')
n = int(input()) left_side = 0 right_side = 0 for i in range(n): num = int(input()) left_side += num for i in range(n): num = int(input()) right_side += num if left_side == right_side: print(f"Yes, sum = {left_side}") else: print(f"No, diff = {abs(left_side - right_side)}")
n = int(input()) left_side = 0 right_side = 0 for i in range(n): num = int(input()) left_side += num for i in range(n): num = int(input()) right_side += num if left_side == right_side: print(f'Yes, sum = {left_side}') else: print(f'No, diff = {abs(left_side - right_side)}')
# # PySNMP MIB module CTRON-PRIORITY-CLASSIFY-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-PRIORITY-CLASSIFY-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:30:31 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ConstraintsIntersection", "SingleValueConstraint") ctPriorityExt, = mibBuilder.importSymbols("CTRON-MIB-NAMES", "ctPriorityExt") NotificationGroup, ObjectGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ObjectGroup", "ModuleCompliance") iso, IpAddress, Counter64, Bits, MibIdentifier, NotificationType, ModuleIdentity, Integer32, ObjectIdentity, Unsigned32, Gauge32, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "IpAddress", "Counter64", "Bits", "MibIdentifier", "NotificationType", "ModuleIdentity", "Integer32", "ObjectIdentity", "Unsigned32", "Gauge32", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks") RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention") ctPriClassify = ModuleIdentity((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6)) if mibBuilder.loadTexts: ctPriClassify.setLastUpdated('200203121855Z') if mibBuilder.loadTexts: ctPriClassify.setOrganization('Cabletron Systems, Inc') if mibBuilder.loadTexts: ctPriClassify.setContactInfo(' Cabletron Systems, Inc. Postal: 35 Industrial Way, P.O. Box 5005 Rochester, NH 03867-0505 Phone: (603) 332-9400 Email: support@cabletron.com Web: http://www.cabletron.com') if mibBuilder.loadTexts: ctPriClassify.setDescription('The Cabletron Priority Classify MIB module for controlling Cabletron specific priority classification criteria based on packet content.') ctPriClassifyObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1)) class CtPriClassifyType(TextualConvention, Integer32): description = 'Each enumerated value represents a unique classification type. Different types have different rules regarding how data is interpreted during classification. These rules are spelled out in the comments preceding each type.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)) namedValues = NamedValues(("etherType", 1), ("llcDsapSsap", 2), ("ipTypeOfService", 3), ("ipProtocolType", 4), ("ipxClassOfService", 5), ("ipxPacketType", 6), ("ipAddressSource", 7), ("ipAddressDestination", 8), ("ipAddressBilateral", 9), ("ipxNetworkSource", 10), ("ipxNetworkDestination", 11), ("ipxNetworkBilateral", 12), ("ipUdpPortSource", 13), ("ipUdpPortDestination", 14), ("ipUdpPortBilateral", 15), ("ipTcpPortSource", 16), ("ipTcpPortDestination", 17), ("ipTcpPortBilateral", 18), ("ipxSocketSource", 19), ("ipxSocketDestination", 20), ("ipxSocketBilateral", 21), ("macAddressSource", 22), ("macAddressDestination", 23), ("macAddressBilateral", 24), ("ipFragments", 25)) class PortList(TextualConvention, OctetString): description = "Each octet within this value specifies a set of eight ports, with the first octet specifying ports 1 through 8, the second octet specifying ports 9 through 16, etc. Within each octet, the most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port. Thus, each port of the bridge is represented by a single bit within the value of this object. If that bit has a value of '1' then that port is included in the set of ports; the port is not included if its bit has a value of '0'." status = 'current' ctPriClassifyStatus = MibScalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: ctPriClassifyStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyStatus.setDescription('Allows the Priority Classification feature to be globally enabled/disabled. A value of disable(2), functionally supersedes the RowStatus of individual entries in the ctPriClassifyTable, but does not change their actual RowStatus value.') ctPriClassifyMaxEntries = MibScalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ctPriClassifyMaxEntries.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyMaxEntries.setDescription('The maximum number of entries allowed in the ctPriClassifyTable.') ctPriClassifyNumEntries = MibScalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 3), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ctPriClassifyNumEntries.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyNumEntries.setDescription('The current number of entries in the ctPriClassifyTable.') ctPriClassifyTable = MibTable((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4), ) if mibBuilder.loadTexts: ctPriClassifyTable.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTable.setDescription('A table containing configuration information for each Priority classification configured into the device by (local or network) management. All entries are permanent and will be restored after the device is reset.') ctPriClassifyEntry = MibTableRow((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1), ).setIndexNames((0, "CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyPriority"), (0, "CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyDataMeaning"), (0, "CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyDataVal"), (0, "CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyDataMask")) if mibBuilder.loadTexts: ctPriClassifyEntry.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyEntry.setDescription('Describes a particular entry of ctPriClassifyTable.') ctPriClassifyPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))) if mibBuilder.loadTexts: ctPriClassifyPriority.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyPriority.setDescription('The priority for this entry. Any packet meeting the classification criteria specified by this conceptual row will be given the priority indicated by this object.') ctPriClassifyDataMeaning = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 2), CtPriClassifyType()) if mibBuilder.loadTexts: ctPriClassifyDataMeaning.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataMeaning.setDescription('The meaning of the ctPriClassifyDataVal leaf for this conceptual row. The ctPriClassifyDataVal specifies a particular value which, when compared to packet data, is used to classify that packet to a particular priority. The part of the packet (if any), to which this data comparison applies, is determined by this object. For example, the value ipAddressBilateral(8) means that the value ctPriClassifyDataVal for this entry is an IP address. It further means that the given IP address will be compared against both source and destination IP address fields in a packet. Such an entry obviously would not not match against any non-IP packets. Additionally, the value of this leaf will impose certain implicit ranges and interpretations of data contained within the ctPriClassifyDataVal leaf for this entry. The specific limitations of each type should be spelled out in the comments for that type.') ctPriClassifyDataVal = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 3), Unsigned32()) if mibBuilder.loadTexts: ctPriClassifyDataVal.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataVal.setDescription('The data value associated with ctPriClassifyDataMeaning. The explicit range of this value is any unsigned 32-bit integer(0..4294967295). This range may vary, however, depending upon the value of ctPriClassifyDataMeaning. Illegal values should not be allowed.') ctPriClassifyDataMask = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 4), Unsigned32()) if mibBuilder.loadTexts: ctPriClassifyDataMask.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataMask.setDescription("This object is the one's complement of a 32-bit mask. This mask is applicable to the data comparison of ctPriClassifyDataVal. The mask is applied to the actual packet data under consideration through a logical bitwise AND operation. This result is then compared to the data. For example, we want to classify according to a bilateral IP address of 134.141.0.0 with a mask of 255.255.240.0. This would be reflected by the following values: ctPriClassifyDataMeaning: ipAddressBilateral(8) ctPriClassifyDataVal: 0x868d0000 ctPriClassifyDataMask: 0x00000fff Again there are contextual implications for this leaf depending upon the value of ctPriClassifyDataMeaning. Not all types will use the mask, and others will impose restrictions. This value should however be a true indication of the masking operation. In other words, data types that don't use a mask should only allow a value of zero, indicating that all data bits are significant in the comparison. The specific restrictions of each type should be spelled out in the comments for that type. Illegal values should not be allowed.") ctPriClassifyIngressList = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 5), PortList().clone(hexValue="0000")).setMaxAccess("readcreate") if mibBuilder.loadTexts: ctPriClassifyIngressList.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyIngressList.setDescription('The set of ports on which this classification rule applies. Classification occurs on ingress. An agent implementation should allow a set operation of this object to create a row if it does not exist.') ctPriClassifyRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 6), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ctPriClassifyRowStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyRowStatus.setDescription("This object provides both control and status for the associated conceptual row in the table. Rows can be created in two ways. createAndGo - The specified row will be created and activated if the instance is allowable. If not, an inconsistentValue exception will be returned and the row will not be created. This provides the most optimal method of creating an active row, but provides the user no explanation if the row cannot be created. createAndWait - The specified row will be created and put in the notInService state if the instance is allowable. A subsequent activation of this row will bring it into the active state. If the instance is not allowable, the row will be created and put in the notReady state. A subsequent activation of this row will fail. Since the inappropriate information is always contained in the indexing leaves, activation will never succeed and the row should be removed by the management station. When a row is in the notReady state, the ctPriClassifyRowInfo may be retrieved to obtain a plain English explanation of why this row cannot be activated. createAndWait is the preferred method for this reason. Both methods described above leave ctPriClassifyIngressList in it's default state, requiring an additional set operation in order to modify it. An even more optimal twist on the createAndWait method is to set the ctPriClassifyIngressList to it's desired value as a method for row creation. This will essentially cause an implicit createAndWait since it too will leave the row in either the notInService or notReady state. This leaves only activation or error analysis as the last step. Any rows left in the notReady or notInService state for more than 5 minutes should be automatically removed by the agent implementation.") ctPriClassifyRowInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 7), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ctPriClassifyRowInfo.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyRowInfo.setDescription("This object provides info about this row in the form of an ASCII string, suitable for display purposes. The intended purpose of this object is to provide an 'agent-specific' explanation as to why the ctPriClassifyRowStatus for this conceptual row is in the 'notReady' state. A management station should read this object and display it to the user in this case. A conceptual row that does not fall into this category may simply return a single NULL, but may also provide any useful info of its choice. A management station may attempt to display such info if it so chooses, but is under no burden to do so.") ctPriClassifyTOSStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: ctPriClassifyTOSStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTOSStatus.setDescription('This object indicates whether an IP Type Of Service (TOS) value, defined by ctPriClassifyTOSValue, should be written into the TOS field of the IP header for any packet matching the classification specified by this conceptual row. This object may be set to enable only for the conceptual rows whose ctPriClassifyDataMeaning and ctPriClassifyDataVal have the following values: ctPriClassifyDataMeaning ctPriClassifyDataVal ------------------------ -------------------- etherType(1) 0x0800 (IP) llcDsapSsap(2) 0x0606 (IP) ipTypeOfService(3) any ipProtocolType(4) any ipAddressSource(7) any ipAddressDestination(8) any ipAddressBilateral(9) any ipUdpPortSource(13) any ipUdpPortDestination(14) any ipUdpPortBilateral(15) any ipTdpPortSource(16) any ipTdpPortDestination(17) any ipTdpPortBilateral(18) any ipFrag(25) not applicable A conceptual row that does not fall into these categories may be set to disable(2) and will return disable(2).') ctPriClassifyTOSValue = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: ctPriClassifyTOSValue.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTOSValue.setDescription('The value to be written into the IP TOS field of the IP header of any packet that matches the classification specified by the conceptual row.') ctPriClassifyAbilityTable = MibTable((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5), ) if mibBuilder.loadTexts: ctPriClassifyAbilityTable.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbilityTable.setDescription('A table containing information for each of the priority classification types. Types for which there is no corresponding row are not supported by this device.') ctPriClassifyAbilityEntry = MibTableRow((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1), ).setIndexNames((0, "CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyAbility")) if mibBuilder.loadTexts: ctPriClassifyAbilityEntry.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbilityEntry.setDescription('Describes a particular entry of ctPriClassifyAbilityTable.') ctPriClassifyAbility = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1, 1), CtPriClassifyType()) if mibBuilder.loadTexts: ctPriClassifyAbility.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbility.setDescription('The priority classification type associated with this entry.') ctPriClassifyPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1, 2), PortList()).setMaxAccess("readonly") if mibBuilder.loadTexts: ctPriClassifyPorts.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyPorts.setDescription('The set of ports on which the classification type specified by ctPriClassifyAbility is supported.') ctPriClassifyTableLastChange = MibScalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 6), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: ctPriClassifyTableLastChange.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTableLastChange.setDescription('Indicates the sysUpTime at which the last change was made to the ctPriClassifyTable.') ctPriClassifyConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2)) ctPriClassifyGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 1)) ctPriClassifyCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 2)) ctPriClassifyBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 1, 1)).setObjects(("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyStatus"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyMaxEntries"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyNumEntries"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyIngressList"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyRowStatus"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyRowInfo"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyTOSStatus"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyTOSValue"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyPorts"), ("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyTableLastChange")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ctPriClassifyBaseGroup = ctPriClassifyBaseGroup.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyBaseGroup.setDescription('A collection of objects providing device level control and status information for Priority classification.') ctPriClassifyCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 2, 1)).setObjects(("CTRON-PRIORITY-CLASSIFY-MIB", "ctPriClassifyBaseGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ctPriClassifyCompliance = ctPriClassifyCompliance.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyCompliance.setDescription('The compliance statement for devices that support Priority classification.') mibBuilder.exportSymbols("CTRON-PRIORITY-CLASSIFY-MIB", ctPriClassifyTOSValue=ctPriClassifyTOSValue, ctPriClassify=ctPriClassify, ctPriClassifyRowStatus=ctPriClassifyRowStatus, ctPriClassifyAbilityTable=ctPriClassifyAbilityTable, PortList=PortList, ctPriClassifyRowInfo=ctPriClassifyRowInfo, ctPriClassifyCompliances=ctPriClassifyCompliances, ctPriClassifyBaseGroup=ctPriClassifyBaseGroup, ctPriClassifyEntry=ctPriClassifyEntry, ctPriClassifyMaxEntries=ctPriClassifyMaxEntries, ctPriClassifyPorts=ctPriClassifyPorts, CtPriClassifyType=CtPriClassifyType, ctPriClassifyStatus=ctPriClassifyStatus, ctPriClassifyTableLastChange=ctPriClassifyTableLastChange, ctPriClassifyDataVal=ctPriClassifyDataVal, ctPriClassifyIngressList=ctPriClassifyIngressList, ctPriClassifyDataMeaning=ctPriClassifyDataMeaning, ctPriClassifyPriority=ctPriClassifyPriority, ctPriClassifyGroups=ctPriClassifyGroups, PYSNMP_MODULE_ID=ctPriClassify, ctPriClassifyDataMask=ctPriClassifyDataMask, ctPriClassifyAbilityEntry=ctPriClassifyAbilityEntry, ctPriClassifyAbility=ctPriClassifyAbility, ctPriClassifyTable=ctPriClassifyTable, ctPriClassifyTOSStatus=ctPriClassifyTOSStatus, ctPriClassifyConformance=ctPriClassifyConformance, ctPriClassifyCompliance=ctPriClassifyCompliance, ctPriClassifyObjects=ctPriClassifyObjects, ctPriClassifyNumEntries=ctPriClassifyNumEntries)
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, constraints_intersection, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'SingleValueConstraint') (ct_priority_ext,) = mibBuilder.importSymbols('CTRON-MIB-NAMES', 'ctPriorityExt') (notification_group, object_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ObjectGroup', 'ModuleCompliance') (iso, ip_address, counter64, bits, mib_identifier, notification_type, module_identity, integer32, object_identity, unsigned32, gauge32, counter32, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks) = mibBuilder.importSymbols('SNMPv2-SMI', 'iso', 'IpAddress', 'Counter64', 'Bits', 'MibIdentifier', 'NotificationType', 'ModuleIdentity', 'Integer32', 'ObjectIdentity', 'Unsigned32', 'Gauge32', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks') (row_status, display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'DisplayString', 'TextualConvention') ct_pri_classify = module_identity((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6)) if mibBuilder.loadTexts: ctPriClassify.setLastUpdated('200203121855Z') if mibBuilder.loadTexts: ctPriClassify.setOrganization('Cabletron Systems, Inc') if mibBuilder.loadTexts: ctPriClassify.setContactInfo(' Cabletron Systems, Inc. Postal: 35 Industrial Way, P.O. Box 5005 Rochester, NH 03867-0505 Phone: (603) 332-9400 Email: support@cabletron.com Web: http://www.cabletron.com') if mibBuilder.loadTexts: ctPriClassify.setDescription('The Cabletron Priority Classify MIB module for controlling Cabletron specific priority classification criteria based on packet content.') ct_pri_classify_objects = mib_identifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1)) class Ctpriclassifytype(TextualConvention, Integer32): description = 'Each enumerated value represents a unique classification type. Different types have different rules regarding how data is interpreted during classification. These rules are spelled out in the comments preceding each type.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)) named_values = named_values(('etherType', 1), ('llcDsapSsap', 2), ('ipTypeOfService', 3), ('ipProtocolType', 4), ('ipxClassOfService', 5), ('ipxPacketType', 6), ('ipAddressSource', 7), ('ipAddressDestination', 8), ('ipAddressBilateral', 9), ('ipxNetworkSource', 10), ('ipxNetworkDestination', 11), ('ipxNetworkBilateral', 12), ('ipUdpPortSource', 13), ('ipUdpPortDestination', 14), ('ipUdpPortBilateral', 15), ('ipTcpPortSource', 16), ('ipTcpPortDestination', 17), ('ipTcpPortBilateral', 18), ('ipxSocketSource', 19), ('ipxSocketDestination', 20), ('ipxSocketBilateral', 21), ('macAddressSource', 22), ('macAddressDestination', 23), ('macAddressBilateral', 24), ('ipFragments', 25)) class Portlist(TextualConvention, OctetString): description = "Each octet within this value specifies a set of eight ports, with the first octet specifying ports 1 through 8, the second octet specifying ports 9 through 16, etc. Within each octet, the most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port. Thus, each port of the bridge is represented by a single bit within the value of this object. If that bit has a value of '1' then that port is included in the set of ports; the port is not included if its bit has a value of '0'." status = 'current' ct_pri_classify_status = mib_scalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: ctPriClassifyStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyStatus.setDescription('Allows the Priority Classification feature to be globally enabled/disabled. A value of disable(2), functionally supersedes the RowStatus of individual entries in the ctPriClassifyTable, but does not change their actual RowStatus value.') ct_pri_classify_max_entries = mib_scalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ctPriClassifyMaxEntries.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyMaxEntries.setDescription('The maximum number of entries allowed in the ctPriClassifyTable.') ct_pri_classify_num_entries = mib_scalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 3), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ctPriClassifyNumEntries.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyNumEntries.setDescription('The current number of entries in the ctPriClassifyTable.') ct_pri_classify_table = mib_table((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4)) if mibBuilder.loadTexts: ctPriClassifyTable.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTable.setDescription('A table containing configuration information for each Priority classification configured into the device by (local or network) management. All entries are permanent and will be restored after the device is reset.') ct_pri_classify_entry = mib_table_row((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1)).setIndexNames((0, 'CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyPriority'), (0, 'CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyDataMeaning'), (0, 'CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyDataVal'), (0, 'CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyDataMask')) if mibBuilder.loadTexts: ctPriClassifyEntry.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyEntry.setDescription('Describes a particular entry of ctPriClassifyTable.') ct_pri_classify_priority = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))) if mibBuilder.loadTexts: ctPriClassifyPriority.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyPriority.setDescription('The priority for this entry. Any packet meeting the classification criteria specified by this conceptual row will be given the priority indicated by this object.') ct_pri_classify_data_meaning = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 2), ct_pri_classify_type()) if mibBuilder.loadTexts: ctPriClassifyDataMeaning.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataMeaning.setDescription('The meaning of the ctPriClassifyDataVal leaf for this conceptual row. The ctPriClassifyDataVal specifies a particular value which, when compared to packet data, is used to classify that packet to a particular priority. The part of the packet (if any), to which this data comparison applies, is determined by this object. For example, the value ipAddressBilateral(8) means that the value ctPriClassifyDataVal for this entry is an IP address. It further means that the given IP address will be compared against both source and destination IP address fields in a packet. Such an entry obviously would not not match against any non-IP packets. Additionally, the value of this leaf will impose certain implicit ranges and interpretations of data contained within the ctPriClassifyDataVal leaf for this entry. The specific limitations of each type should be spelled out in the comments for that type.') ct_pri_classify_data_val = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 3), unsigned32()) if mibBuilder.loadTexts: ctPriClassifyDataVal.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataVal.setDescription('The data value associated with ctPriClassifyDataMeaning. The explicit range of this value is any unsigned 32-bit integer(0..4294967295). This range may vary, however, depending upon the value of ctPriClassifyDataMeaning. Illegal values should not be allowed.') ct_pri_classify_data_mask = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 4), unsigned32()) if mibBuilder.loadTexts: ctPriClassifyDataMask.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyDataMask.setDescription("This object is the one's complement of a 32-bit mask. This mask is applicable to the data comparison of ctPriClassifyDataVal. The mask is applied to the actual packet data under consideration through a logical bitwise AND operation. This result is then compared to the data. For example, we want to classify according to a bilateral IP address of 134.141.0.0 with a mask of 255.255.240.0. This would be reflected by the following values: ctPriClassifyDataMeaning: ipAddressBilateral(8) ctPriClassifyDataVal: 0x868d0000 ctPriClassifyDataMask: 0x00000fff Again there are contextual implications for this leaf depending upon the value of ctPriClassifyDataMeaning. Not all types will use the mask, and others will impose restrictions. This value should however be a true indication of the masking operation. In other words, data types that don't use a mask should only allow a value of zero, indicating that all data bits are significant in the comparison. The specific restrictions of each type should be spelled out in the comments for that type. Illegal values should not be allowed.") ct_pri_classify_ingress_list = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 5), port_list().clone(hexValue='0000')).setMaxAccess('readcreate') if mibBuilder.loadTexts: ctPriClassifyIngressList.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyIngressList.setDescription('The set of ports on which this classification rule applies. Classification occurs on ingress. An agent implementation should allow a set operation of this object to create a row if it does not exist.') ct_pri_classify_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 6), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ctPriClassifyRowStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyRowStatus.setDescription("This object provides both control and status for the associated conceptual row in the table. Rows can be created in two ways. createAndGo - The specified row will be created and activated if the instance is allowable. If not, an inconsistentValue exception will be returned and the row will not be created. This provides the most optimal method of creating an active row, but provides the user no explanation if the row cannot be created. createAndWait - The specified row will be created and put in the notInService state if the instance is allowable. A subsequent activation of this row will bring it into the active state. If the instance is not allowable, the row will be created and put in the notReady state. A subsequent activation of this row will fail. Since the inappropriate information is always contained in the indexing leaves, activation will never succeed and the row should be removed by the management station. When a row is in the notReady state, the ctPriClassifyRowInfo may be retrieved to obtain a plain English explanation of why this row cannot be activated. createAndWait is the preferred method for this reason. Both methods described above leave ctPriClassifyIngressList in it's default state, requiring an additional set operation in order to modify it. An even more optimal twist on the createAndWait method is to set the ctPriClassifyIngressList to it's desired value as a method for row creation. This will essentially cause an implicit createAndWait since it too will leave the row in either the notInService or notReady state. This leaves only activation or error analysis as the last step. Any rows left in the notReady or notInService state for more than 5 minutes should be automatically removed by the agent implementation.") ct_pri_classify_row_info = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 7), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ctPriClassifyRowInfo.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyRowInfo.setDescription("This object provides info about this row in the form of an ASCII string, suitable for display purposes. The intended purpose of this object is to provide an 'agent-specific' explanation as to why the ctPriClassifyRowStatus for this conceptual row is in the 'notReady' state. A management station should read this object and display it to the user in this case. A conceptual row that does not fall into this category may simply return a single NULL, but may also provide any useful info of its choice. A management station may attempt to display such info if it so chooses, but is under no burden to do so.") ct_pri_classify_tos_status = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: ctPriClassifyTOSStatus.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTOSStatus.setDescription('This object indicates whether an IP Type Of Service (TOS) value, defined by ctPriClassifyTOSValue, should be written into the TOS field of the IP header for any packet matching the classification specified by this conceptual row. This object may be set to enable only for the conceptual rows whose ctPriClassifyDataMeaning and ctPriClassifyDataVal have the following values: ctPriClassifyDataMeaning ctPriClassifyDataVal ------------------------ -------------------- etherType(1) 0x0800 (IP) llcDsapSsap(2) 0x0606 (IP) ipTypeOfService(3) any ipProtocolType(4) any ipAddressSource(7) any ipAddressDestination(8) any ipAddressBilateral(9) any ipUdpPortSource(13) any ipUdpPortDestination(14) any ipUdpPortBilateral(15) any ipTdpPortSource(16) any ipTdpPortDestination(17) any ipTdpPortBilateral(18) any ipFrag(25) not applicable A conceptual row that does not fall into these categories may be set to disable(2) and will return disable(2).') ct_pri_classify_tos_value = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 4, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: ctPriClassifyTOSValue.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTOSValue.setDescription('The value to be written into the IP TOS field of the IP header of any packet that matches the classification specified by the conceptual row.') ct_pri_classify_ability_table = mib_table((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5)) if mibBuilder.loadTexts: ctPriClassifyAbilityTable.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbilityTable.setDescription('A table containing information for each of the priority classification types. Types for which there is no corresponding row are not supported by this device.') ct_pri_classify_ability_entry = mib_table_row((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1)).setIndexNames((0, 'CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyAbility')) if mibBuilder.loadTexts: ctPriClassifyAbilityEntry.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbilityEntry.setDescription('Describes a particular entry of ctPriClassifyAbilityTable.') ct_pri_classify_ability = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1, 1), ct_pri_classify_type()) if mibBuilder.loadTexts: ctPriClassifyAbility.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyAbility.setDescription('The priority classification type associated with this entry.') ct_pri_classify_ports = mib_table_column((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 5, 1, 2), port_list()).setMaxAccess('readonly') if mibBuilder.loadTexts: ctPriClassifyPorts.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyPorts.setDescription('The set of ports on which the classification type specified by ctPriClassifyAbility is supported.') ct_pri_classify_table_last_change = mib_scalar((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 1, 6), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: ctPriClassifyTableLastChange.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyTableLastChange.setDescription('Indicates the sysUpTime at which the last change was made to the ctPriClassifyTable.') ct_pri_classify_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2)) ct_pri_classify_groups = mib_identifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 1)) ct_pri_classify_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 2)) ct_pri_classify_base_group = object_group((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 1, 1)).setObjects(('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyStatus'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyMaxEntries'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyNumEntries'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyIngressList'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyRowStatus'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyRowInfo'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyTOSStatus'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyTOSValue'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyPorts'), ('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyTableLastChange')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ct_pri_classify_base_group = ctPriClassifyBaseGroup.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyBaseGroup.setDescription('A collection of objects providing device level control and status information for Priority classification.') ct_pri_classify_compliance = module_compliance((1, 3, 6, 1, 4, 1, 52, 4, 1, 2, 14, 6, 2, 2, 1)).setObjects(('CTRON-PRIORITY-CLASSIFY-MIB', 'ctPriClassifyBaseGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ct_pri_classify_compliance = ctPriClassifyCompliance.setStatus('current') if mibBuilder.loadTexts: ctPriClassifyCompliance.setDescription('The compliance statement for devices that support Priority classification.') mibBuilder.exportSymbols('CTRON-PRIORITY-CLASSIFY-MIB', ctPriClassifyTOSValue=ctPriClassifyTOSValue, ctPriClassify=ctPriClassify, ctPriClassifyRowStatus=ctPriClassifyRowStatus, ctPriClassifyAbilityTable=ctPriClassifyAbilityTable, PortList=PortList, ctPriClassifyRowInfo=ctPriClassifyRowInfo, ctPriClassifyCompliances=ctPriClassifyCompliances, ctPriClassifyBaseGroup=ctPriClassifyBaseGroup, ctPriClassifyEntry=ctPriClassifyEntry, ctPriClassifyMaxEntries=ctPriClassifyMaxEntries, ctPriClassifyPorts=ctPriClassifyPorts, CtPriClassifyType=CtPriClassifyType, ctPriClassifyStatus=ctPriClassifyStatus, ctPriClassifyTableLastChange=ctPriClassifyTableLastChange, ctPriClassifyDataVal=ctPriClassifyDataVal, ctPriClassifyIngressList=ctPriClassifyIngressList, ctPriClassifyDataMeaning=ctPriClassifyDataMeaning, ctPriClassifyPriority=ctPriClassifyPriority, ctPriClassifyGroups=ctPriClassifyGroups, PYSNMP_MODULE_ID=ctPriClassify, ctPriClassifyDataMask=ctPriClassifyDataMask, ctPriClassifyAbilityEntry=ctPriClassifyAbilityEntry, ctPriClassifyAbility=ctPriClassifyAbility, ctPriClassifyTable=ctPriClassifyTable, ctPriClassifyTOSStatus=ctPriClassifyTOSStatus, ctPriClassifyConformance=ctPriClassifyConformance, ctPriClassifyCompliance=ctPriClassifyCompliance, ctPriClassifyObjects=ctPriClassifyObjects, ctPriClassifyNumEntries=ctPriClassifyNumEntries)
DESCRIPTION = "switch to a different module" def autocomplete(shell, line, text, state): # todo: make this show shorter paths at a time # should never go this big... if len(line.split()) > 2 and line.split()[0] != "set": return None options = [x + " " for x in shell.plugins if x.startswith(text)] try: return options[state] except: return None def help(shell): pass def execute(shell, cmd): splitted = cmd.split() if len(splitted) > 1: module = splitted[1] if module not in shell.plugins: shell.print_error("No module named %s" % (module)) return shell.previous = shell.state shell.state = module
description = 'switch to a different module' def autocomplete(shell, line, text, state): if len(line.split()) > 2 and line.split()[0] != 'set': return None options = [x + ' ' for x in shell.plugins if x.startswith(text)] try: return options[state] except: return None def help(shell): pass def execute(shell, cmd): splitted = cmd.split() if len(splitted) > 1: module = splitted[1] if module not in shell.plugins: shell.print_error('No module named %s' % module) return shell.previous = shell.state shell.state = module
# test builtin issubclass class A: pass print(issubclass(A, A)) print(issubclass(A, (A,))) try: issubclass(A, 1) except TypeError: print('TypeError') try: issubclass('a', 1) except TypeError: print('TypeError')
class A: pass print(issubclass(A, A)) print(issubclass(A, (A,))) try: issubclass(A, 1) except TypeError: print('TypeError') try: issubclass('a', 1) except TypeError: print('TypeError')
def install(job): prefab = job.service.executor.prefab # For now we download FS from there. when we have proper VM image it will be installed already if not prefab.core.command_check('fs'): prefab.core.dir_ensure('$BINDIR') prefab.core.file_download('https://stor.jumpscale.org/public/fs', '$BINDIR/fs') prefab.core.file_attribs('$BINDIR/fs', '0550') def start(job): prefab = job.service.executor.prefab service = job.service actor = service.aysrepo.actorGet(name=service.model.dbobj.actorName) prefab.core.dir_ensure('$JSCFGDIR/fs/flists') for flist in actor.model.dbobj.flists: args = {} args['flist_path'] = prefab.core.replace('$JSCFGDIR/fs/flists/%s' % flist.name) prefab.core.file_write(args['flist_path'], flist.content) args['mountpoint'] = flist.mountpoint args['mode'] = flist.mode.__str__().upper() args['namespace'] = flist.namespace args['store_url'] = flist.storeUrl prefab.core.dir_ensure(args['mountpoint']) config = """ [[mount]] path="{mountpoint}" flist="{flist_path}" backend="main" mode = "{mode}" trim_base = true [backend.main] path="/storage/fs_backend" stor="stor1" namespace="{namespace}" upload=false encrypted=false # encrypted=true # user_rsa="user.rsa" # store_rsa="store.rsa" aydostor_push_cron="@every 1m" cleanup_cron="@every 1m" cleanup_older_than=1 #in hours [aydostor.stor1] addr="{store_url}" """.format(**args) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist.name) prefab.core.file_write(config_path, config) pm = prefab.processmanager.get('tmux') cmd = '$BINDIR/fs -config %s' % config_path pm.ensure("fs_%s" % flist.name, cmd=cmd, env={}, path='$JSCFGDIR/fs', descr='G8OS FS') def stop(job): prefab = job.service.executor.prefab service = job.service actor = service.aysrepo.actorGet(name=service.model.dbobj.actorName) for flist in actor.model.dbobj.flists: config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist.name) flist_config = prefab.core.file_read(config_path) flist_config = j.data.serializer.toml.loads(flist_config) pm = prefab.processmanager.get('tmux') pm.stop('fs_%s' % flist.name) for mount in flist_config['mount']: cmd = 'umount -fl %s' % mount['path'] prefab.core.run(cmd) def processChange(job): service = job.service category = job.model.args.get('changeCategory', None) if category == 'config': service.runAction('stop') service.runAction('start') def start_flist(job): args = job.model.args prefab = job.service.executor.prefab prefab.core.dir_ensure('$JSCFGDIR/fs/flists') flist_content = j.sal.fs.fileGetContents(args['flist']) flist_name = j.sal.fs.getBaseName(args['flist']) args['flist_path'] = prefab.core.replace('$JSCFGDIR/fs/flists/%s' % flist_name) prefab.core.file_write(args['flist_path'], flist_content) prefab.core.dir_ensure(args['mount_path']) config = """ [[mount]] path="{mount_path}" flist="{flist_path}" backend="main" mode = "{mode}" trim_base = true [backend.main] path="/storage/fs_backend" stor="stor1" namespace="{namespace}" upload=false encrypted=false # encrypted=true # user_rsa="user.rsa" # store_rsa="store.rsa" aydostor_push_cron="@every 1m" cleanup_cron="@every 1m" cleanup_older_than=1 #in hours [aydostor.stor1] addr="{store_addr}" """.format(**args) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist_name) prefab.core.file_write(config_path, config) pm = prefab.processmanager.get('tmux') cmd = '$BINDIR/fs -config %s' % config_path pm.ensure("fs_%s" % flist_name, cmd=cmd, env={}, path='$JSCFGDIR/fs', descr='G8OS FS') def stop_flist(job): prefab = job.service.executor.prefab args = job.model.args flist_name = j.sal.fs.getBaseName(args['flist']) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist_name) flist_config = prefab.core.file_read(config_path) flist_config = j.data.serializer.toml.loads(flist_config) pm = prefab.processmanager.get('tmux') pm.stop('fs_%s' % flist_name) for mount in flist_config['mount']: cmd = 'umount -fl %s' % mount['path'] prefab.core.run(cmd)
def install(job): prefab = job.service.executor.prefab if not prefab.core.command_check('fs'): prefab.core.dir_ensure('$BINDIR') prefab.core.file_download('https://stor.jumpscale.org/public/fs', '$BINDIR/fs') prefab.core.file_attribs('$BINDIR/fs', '0550') def start(job): prefab = job.service.executor.prefab service = job.service actor = service.aysrepo.actorGet(name=service.model.dbobj.actorName) prefab.core.dir_ensure('$JSCFGDIR/fs/flists') for flist in actor.model.dbobj.flists: args = {} args['flist_path'] = prefab.core.replace('$JSCFGDIR/fs/flists/%s' % flist.name) prefab.core.file_write(args['flist_path'], flist.content) args['mountpoint'] = flist.mountpoint args['mode'] = flist.mode.__str__().upper() args['namespace'] = flist.namespace args['store_url'] = flist.storeUrl prefab.core.dir_ensure(args['mountpoint']) config = '\n [[mount]]\n path="{mountpoint}"\n flist="{flist_path}"\n backend="main"\n mode = "{mode}"\n trim_base = true\n\n [backend.main]\n path="/storage/fs_backend"\n stor="stor1"\n namespace="{namespace}"\n\n upload=false\n encrypted=false\n # encrypted=true\n # user_rsa="user.rsa"\n # store_rsa="store.rsa"\n\n aydostor_push_cron="@every 1m"\n cleanup_cron="@every 1m"\n cleanup_older_than=1 #in hours\n\n [aydostor.stor1]\n addr="{store_url}"\n '.format(**args) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist.name) prefab.core.file_write(config_path, config) pm = prefab.processmanager.get('tmux') cmd = '$BINDIR/fs -config %s' % config_path pm.ensure('fs_%s' % flist.name, cmd=cmd, env={}, path='$JSCFGDIR/fs', descr='G8OS FS') def stop(job): prefab = job.service.executor.prefab service = job.service actor = service.aysrepo.actorGet(name=service.model.dbobj.actorName) for flist in actor.model.dbobj.flists: config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist.name) flist_config = prefab.core.file_read(config_path) flist_config = j.data.serializer.toml.loads(flist_config) pm = prefab.processmanager.get('tmux') pm.stop('fs_%s' % flist.name) for mount in flist_config['mount']: cmd = 'umount -fl %s' % mount['path'] prefab.core.run(cmd) def process_change(job): service = job.service category = job.model.args.get('changeCategory', None) if category == 'config': service.runAction('stop') service.runAction('start') def start_flist(job): args = job.model.args prefab = job.service.executor.prefab prefab.core.dir_ensure('$JSCFGDIR/fs/flists') flist_content = j.sal.fs.fileGetContents(args['flist']) flist_name = j.sal.fs.getBaseName(args['flist']) args['flist_path'] = prefab.core.replace('$JSCFGDIR/fs/flists/%s' % flist_name) prefab.core.file_write(args['flist_path'], flist_content) prefab.core.dir_ensure(args['mount_path']) config = '\n [[mount]]\n path="{mount_path}"\n flist="{flist_path}"\n backend="main"\n mode = "{mode}"\n trim_base = true\n\n [backend.main]\n path="/storage/fs_backend"\n stor="stor1"\n namespace="{namespace}"\n\n upload=false\n encrypted=false\n # encrypted=true\n # user_rsa="user.rsa"\n # store_rsa="store.rsa"\n\n aydostor_push_cron="@every 1m"\n cleanup_cron="@every 1m"\n cleanup_older_than=1 #in hours\n\n [aydostor.stor1]\n addr="{store_addr}"\n '.format(**args) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist_name) prefab.core.file_write(config_path, config) pm = prefab.processmanager.get('tmux') cmd = '$BINDIR/fs -config %s' % config_path pm.ensure('fs_%s' % flist_name, cmd=cmd, env={}, path='$JSCFGDIR/fs', descr='G8OS FS') def stop_flist(job): prefab = job.service.executor.prefab args = job.model.args flist_name = j.sal.fs.getBaseName(args['flist']) config_path = prefab.core.replace('$JSCFGDIR/fs/%s.toml' % flist_name) flist_config = prefab.core.file_read(config_path) flist_config = j.data.serializer.toml.loads(flist_config) pm = prefab.processmanager.get('tmux') pm.stop('fs_%s' % flist_name) for mount in flist_config['mount']: cmd = 'umount -fl %s' % mount['path'] prefab.core.run(cmd)
# Gianna-Carina Gruen # 05/23/2016 # Homework 1 # 1. Prompt the user for their year of birth, and tell them (approximately): year_of_birth = input ("Hello! I'm not interested in your name, but I would like to know your age. In what year were you born?") # Additionally, if someone gives you a year in the future, try asking them again (assume they'll do it right the second time) if int(year_of_birth) >=2016: year_of_birth = input ("I seriously doubt that - you get another chance. Tell me the truth this time. In what year where you born?") # 2. How old they are age = 2016 - int(year_of_birth) print ("So you are roughly", age, "years old.") # 3. How many times their heart has beaten #human heartbeat: 70bpm; source: https://answers.yahoo.com/question/index?qid=20070907185006AAo85XE human_heartbeat_since = age * 365 * 70 * 60 * 24 print ("Since you were born your heart has beaten roughly", human_heartbeat_since, "times. Plus one, two, three...") # 4. How many times a blue whale's heart has beaten #bluewhale heartbeat: 9 bpm; source: http://www.whalefacts.org/blue-whale-heart/ whale_heartbeat_since = age * 365 * 9 * 60 * 24 print ("In the same time, a blue whale's heart has beaten approximately", whale_heartbeat_since, "times." ) # 5. How many times a rabbit's heart has beaten #rabbit heartbeat: 205 bpm; source: http://www.cardio-research.com/quick-facts/animals rabbit_heartbeat_since = age * 365 * 205 * 60 * 24 # 6. If the answer to (5) is more than a billion, say "XXX billion" instead of the very long raw number if rabbit_heartbeat_since >= 1000000000: print ("Whereas a rabbit's heart has beaten roughly", rabbit_heartbeat_since/1000000000, "billion times.") #no idea how to round the number. Tried round ( x [, n]) and I assume it doesn't work because rabbit_heartbeat_since/1000000000 is not a number. Changing it into an integer didn't help either. Defining it as a new variable neither. So, gave up on rounding it for now. # 7. How old they are in Venus years # One year = one surrounding of the sun. For Venus to surround the sun once, it takes 225 Earth days; source: http://spaceplace.nasa.gov/all-about-venus/en/ # To translate into code: How many times did Venus surround the sun since you were born? # Approach: 1) Calculate the number of days passed since birth 2) divide them by 225 age_on_venus = age * 365 / 225 print ("Measured in Venus years, you are", age_on_venus, "years old.") # 8. How old they are in Neptune years # A year on Neptune equals 164.8 Earth years; source: https://pds.jpl.nasa.gov/planets/special/neptune.htm age_on_neptune = age * 164.8 print ("Measured in Neptune years, you are", age_on_neptune, "years old.") # 9. Whether they are the same age as you, older or younger if int(year_of_birth) == 1987: print("And it might surprise you, but we were both born in the same year!") # 10. If older or younger, how many years difference elif int(year_of_birth) > 1987: print ("You are", int(year_of_birth)-1987, "years younger than me.") else: print ("You are", 1987-int(year_of_birth), "years older than me.") # 11. If they were born in an even or odd year # Approach: If year_of_birth divided by 2 results in an integer number, the year is even if int(year_of_birth) % 2 == 0: print ("You might have noticed, but in case not: you were born in an even year.") else: print ("You might have noticed, but in case not: you were born in an odd year.") # 12. How many times the Pittsburgh Steelers have won the Superbowl since their birth. #Pittsburgh Steelers won in 1975, 1976, 1979, 1980, 2006, 2009; source: http://www.steelers.com/history/superbowl.html if int(year_of_birth) <= 1975: print ("And did you know that the Pittsburgh Steelers won six Superbowls since you were born?!") elif int(year_of_birth) >= 1976 and int(year_of_birth) < 1979: print ("And did you know that the Pittsburgh Steelers won five Superbowls since you were born?!") elif int(year_of_birth) == 1979: print ("And did you know that the Pittsburgh Steelers won four Superbowls since you were born?!") elif int(year_of_birth) == 1980: print ("And did you know that the Pittsburgh Steelers won three Superbowls since you were born?!") elif int(year_of_birth) >= 1981 and int(year_of_birth) <= 2006: print ("And did you know that the Pittsburgh Steelers won two Superbowls since you were born?!") elif int(year_of_birth) > 2006 and int(year_of_birth) <= 2009: print ("And did you know that the Pittsburgh Steelers won one Superbowl since you were born?!") elif int(year_of_birth) > 2009: print ("And did you know that the Pittsburgh Steelers haven't won one single Superbowl since you were born?!") # 13. Which US President was in office when they were born (FDR onward) # actually I guess there's probably a more elegant way to solve Task 12 and this one, however I haven't yet figured the right way to google it... # Franklin D. Roosevelt 1933 - 1945 # Harry S. Truman 1945 - 1953 # Dwight D. Eisenhower 1953 - 1961 # John F. Kennedy 1961 - 1963 # Lydon B. Johnson 1963 - 1969 # Richard Nixon 1969 - 1974 # Gerald Ford 1974 - 1977 # Jimmy Carter 1977- 1981 # Ronald Reagan 1981 - 1989 # George Bush 1989 - 1993 # Bill Clinton 1993 - 2001 # George W. Bush 2001 - 2009 # Barack Obama 2009 - 2016 if int(year_of_birth) >= 1933 and int(year_of_birth) < 1945: print ("At the end, we're getting official: When you were born, President Franklin D. Roosevelt governed the US from the Oval Office") elif int(year_of_birth) == 1945: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Frankling D. Roosevelt was followed by President Harry S. Truman.") elif int(year_of_birth) > 1945 and int(year_of_birth) < 1953: print ("At the end, we're getting official: When you were born, President Harry S. Truman governed the US from the Oval Office.") elif int(year_of_birth) == 1953: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Harry S. Truman was followed by President Dwight D. Eisenhower.") elif int(year_of_birth) > 1953 and int(year_of_birth) < 1961: print ("At the end, we're getting official: When you were born, President Dwight D. Eisenhower governed the US from the Oval Office.") elif int(year_of_birth) == 1961: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Dwight D. Eisenhower was followed by President John F. Kennedy.") elif int(year_of_birth) > 1961 and int(year_of_birth) < 1963: print ("At the end, we're getting official: When you were born, President John F. Kennedy governed the US from the Oval Office.") elif int(year_of_birth) == 1963: print ("At the end, we're getting official: The year you were born, there were elections in the US. President John F. Kennedy was followed by President Lydon B. Johnson.") elif int(year_of_birth) > 1963 and int(year_of_birth) < 1969: print ("At the end, we're getting official: When you were born, President Lydon B. Johnson governed the US from the Oval Office.") elif int(year_of_birth) == 1969: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Lydon B. Johnson was followed by President Richard Nixon.") elif int(year_of_birth) > 1969 and int(year_of_birth) < 1974: print ("At the end, we're getting official: When you were born, President Richard Nixon governed the US from the Oval Office.") elif int(year_of_birth) == 1974: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Richard Nixon was followed by President Gerald Ford.") elif int(year_of_birth) > 1974 and int(year_of_birth) < 1977: print ("At the end, we're getting official: When you were born, President Gerald Ford governed the US from the Oval Office.") elif int(year_of_birth) == 1977: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Gerald Ford was followed by President Jimmy Carter.") elif int(year_of_birth) > 1977 and int(year_of_birth) < 1981: print ("At the end, we're getting official: When you were born, President Jimmy Carter governed the US from the Oval Office.") elif int(year_of_birth) == 1981: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Jimmy Carter was followed by President Ronald Reagan.") elif int(year_of_birth) > 1981 and int(year_of_birth) < 1989: print ("At the end, we're getting official: When you were born, President Ronald Reagan governed the US from the Oval Office.") elif int(year_of_birth) == 1989: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Ronald Reagan was followed by President George Bush.") elif int(year_of_birth) > 1989 and int(year_of_birth) < 1993: print ("At the end, we're getting official: When you were born, President George Bush governed the US from the Oval Office.") elif int(year_of_birth) == 1993: print ("At the end, we're getting official: The year you were born, there were elections in the US. President George Bush was followed by President Bill Clinton.") elif int(year_of_birth) > 1993 and int(year_of_birth) < 2001: print ("At the end, we're getting official: When you were born, President Bill Clinton governed the US from the Oval Office.") elif int(year_of_birth) == 2001: print ("At the end, we're getting official: The year you were born, there were elections in the US. President Bill Clinton was followed by President George W. Bush.") elif int(year_of_birth) > 2001 and int(year_of_birth) < 2009: print ("At the end, we're getting official: When you were born, President George W. Bush governed the US from the Oval Office.") elif int(year_of_birth) == 2009: print ("At the end, we're getting official: The year you were born, there were elections in the US. President George W. Bush was followed by President Barack Obama.") elif int(year_of_birth) > 2009: print ("At the end, we're getting official: When you were born, President Barack Obama governed the US from the Oval Office.")
year_of_birth = input("Hello! I'm not interested in your name, but I would like to know your age. In what year were you born?") if int(year_of_birth) >= 2016: year_of_birth = input('I seriously doubt that - you get another chance. Tell me the truth this time. In what year where you born?') age = 2016 - int(year_of_birth) print('So you are roughly', age, 'years old.') human_heartbeat_since = age * 365 * 70 * 60 * 24 print('Since you were born your heart has beaten roughly', human_heartbeat_since, 'times. Plus one, two, three...') whale_heartbeat_since = age * 365 * 9 * 60 * 24 print("In the same time, a blue whale's heart has beaten approximately", whale_heartbeat_since, 'times.') rabbit_heartbeat_since = age * 365 * 205 * 60 * 24 if rabbit_heartbeat_since >= 1000000000: print("Whereas a rabbit's heart has beaten roughly", rabbit_heartbeat_since / 1000000000, 'billion times.') age_on_venus = age * 365 / 225 print('Measured in Venus years, you are', age_on_venus, 'years old.') age_on_neptune = age * 164.8 print('Measured in Neptune years, you are', age_on_neptune, 'years old.') if int(year_of_birth) == 1987: print('And it might surprise you, but we were both born in the same year!') elif int(year_of_birth) > 1987: print('You are', int(year_of_birth) - 1987, 'years younger than me.') else: print('You are', 1987 - int(year_of_birth), 'years older than me.') if int(year_of_birth) % 2 == 0: print('You might have noticed, but in case not: you were born in an even year.') else: print('You might have noticed, but in case not: you were born in an odd year.') if int(year_of_birth) <= 1975: print('And did you know that the Pittsburgh Steelers won six Superbowls since you were born?!') elif int(year_of_birth) >= 1976 and int(year_of_birth) < 1979: print('And did you know that the Pittsburgh Steelers won five Superbowls since you were born?!') elif int(year_of_birth) == 1979: print('And did you know that the Pittsburgh Steelers won four Superbowls since you were born?!') elif int(year_of_birth) == 1980: print('And did you know that the Pittsburgh Steelers won three Superbowls since you were born?!') elif int(year_of_birth) >= 1981 and int(year_of_birth) <= 2006: print('And did you know that the Pittsburgh Steelers won two Superbowls since you were born?!') elif int(year_of_birth) > 2006 and int(year_of_birth) <= 2009: print('And did you know that the Pittsburgh Steelers won one Superbowl since you were born?!') elif int(year_of_birth) > 2009: print("And did you know that the Pittsburgh Steelers haven't won one single Superbowl since you were born?!") if int(year_of_birth) >= 1933 and int(year_of_birth) < 1945: print("At the end, we're getting official: When you were born, President Franklin D. Roosevelt governed the US from the Oval Office") elif int(year_of_birth) == 1945: print("At the end, we're getting official: The year you were born, there were elections in the US. President Frankling D. Roosevelt was followed by President Harry S. Truman.") elif int(year_of_birth) > 1945 and int(year_of_birth) < 1953: print("At the end, we're getting official: When you were born, President Harry S. Truman governed the US from the Oval Office.") elif int(year_of_birth) == 1953: print("At the end, we're getting official: The year you were born, there were elections in the US. President Harry S. Truman was followed by President Dwight D. Eisenhower.") elif int(year_of_birth) > 1953 and int(year_of_birth) < 1961: print("At the end, we're getting official: When you were born, President Dwight D. Eisenhower governed the US from the Oval Office.") elif int(year_of_birth) == 1961: print("At the end, we're getting official: The year you were born, there were elections in the US. President Dwight D. Eisenhower was followed by President John F. Kennedy.") elif int(year_of_birth) > 1961 and int(year_of_birth) < 1963: print("At the end, we're getting official: When you were born, President John F. Kennedy governed the US from the Oval Office.") elif int(year_of_birth) == 1963: print("At the end, we're getting official: The year you were born, there were elections in the US. President John F. Kennedy was followed by President Lydon B. Johnson.") elif int(year_of_birth) > 1963 and int(year_of_birth) < 1969: print("At the end, we're getting official: When you were born, President Lydon B. Johnson governed the US from the Oval Office.") elif int(year_of_birth) == 1969: print("At the end, we're getting official: The year you were born, there were elections in the US. President Lydon B. Johnson was followed by President Richard Nixon.") elif int(year_of_birth) > 1969 and int(year_of_birth) < 1974: print("At the end, we're getting official: When you were born, President Richard Nixon governed the US from the Oval Office.") elif int(year_of_birth) == 1974: print("At the end, we're getting official: The year you were born, there were elections in the US. President Richard Nixon was followed by President Gerald Ford.") elif int(year_of_birth) > 1974 and int(year_of_birth) < 1977: print("At the end, we're getting official: When you were born, President Gerald Ford governed the US from the Oval Office.") elif int(year_of_birth) == 1977: print("At the end, we're getting official: The year you were born, there were elections in the US. President Gerald Ford was followed by President Jimmy Carter.") elif int(year_of_birth) > 1977 and int(year_of_birth) < 1981: print("At the end, we're getting official: When you were born, President Jimmy Carter governed the US from the Oval Office.") elif int(year_of_birth) == 1981: print("At the end, we're getting official: The year you were born, there were elections in the US. President Jimmy Carter was followed by President Ronald Reagan.") elif int(year_of_birth) > 1981 and int(year_of_birth) < 1989: print("At the end, we're getting official: When you were born, President Ronald Reagan governed the US from the Oval Office.") elif int(year_of_birth) == 1989: print("At the end, we're getting official: The year you were born, there were elections in the US. President Ronald Reagan was followed by President George Bush.") elif int(year_of_birth) > 1989 and int(year_of_birth) < 1993: print("At the end, we're getting official: When you were born, President George Bush governed the US from the Oval Office.") elif int(year_of_birth) == 1993: print("At the end, we're getting official: The year you were born, there were elections in the US. President George Bush was followed by President Bill Clinton.") elif int(year_of_birth) > 1993 and int(year_of_birth) < 2001: print("At the end, we're getting official: When you were born, President Bill Clinton governed the US from the Oval Office.") elif int(year_of_birth) == 2001: print("At the end, we're getting official: The year you were born, there were elections in the US. President Bill Clinton was followed by President George W. Bush.") elif int(year_of_birth) > 2001 and int(year_of_birth) < 2009: print("At the end, we're getting official: When you were born, President George W. Bush governed the US from the Oval Office.") elif int(year_of_birth) == 2009: print("At the end, we're getting official: The year you were born, there were elections in the US. President George W. Bush was followed by President Barack Obama.") elif int(year_of_birth) > 2009: print("At the end, we're getting official: When you were born, President Barack Obama governed the US from the Oval Office.")
class Solution: def removePalindromeSub(self, s: str) -> int: # exception if s == '': return 0 elif s == s[::-1]: return 1 else: return 2
class Solution: def remove_palindrome_sub(self, s: str) -> int: if s == '': return 0 elif s == s[::-1]: return 1 else: return 2
#!/usr/bin/env python # coding=utf-8 class startURL: xinfangURL = [ 'http://cs.ganji.com/fang12/o1/', 'http://cs.ganji.com/fang12/o2/', 'http://cs.ganji.com/fang12/o3/', 'http://cs.ganji.com/fang12/o4/', 'http://cs.ganji.com/fang12/o5/', 'http://cs.ganji.com/fang12/o6/', 'http://cs.ganji.com/fang12/o7/', 'http://cs.ganji.com/fang12/o8/', 'http://cs.ganji.com/fang12/o9/', 'http://cs.ganji.com/fang12/o10/', 'http://cs.ganji.com/fang12/o11/', 'http://cs.ganji.com/fang12/o12/', 'http://cs.ganji.com/fang12/o13/', 'http://cs.ganji.com/fang12/o14/', 'http://cs.ganji.com/fang12/o15/', 'http://cs.ganji.com/fang12/o16/', 'http://cs.ganji.com/fang12/o17/', 'http://cs.ganji.com/fang12/o18/', 'http://cs.ganji.com/fang12/o19/', 'http://cs.ganji.com/fang12/o20/', 'http://cs.ganji.com/fang12/o21/', 'http://cs.ganji.com/fang12/o22/', 'http://cs.ganji.com/fang12/o23/', 'http://cs.ganji.com/fang12/o24/', 'http://cs.ganji.com/fang12/o25/', 'http://cs.ganji.com/fang12/o26/', 'http://cs.ganji.com/fang12/o27/', 'http://cs.ganji.com/fang12/o28/', 'http://cs.ganji.com/fang12/o29/', 'http://cs.ganji.com/fang12/o30/', 'http://cs.ganji.com/fang12/o31/', 'http://cs.ganji.com/fang12/o32/', 'http://cs.ganji.com/fang12/o33/', 'http://cs.ganji.com/fang12/o34/', 'http://cs.ganji.com/fang12/o35/', 'http://cs.ganji.com/fang12/o36/', 'http://cs.ganji.com/fang12/o37/', 'http://cs.ganji.com/fang12/o38/', 'http://cs.ganji.com/fang12/o39/', 'http://cs.ganji.com/fang12/o40/', 'http://cs.ganji.com/fang12/o41/', 'http://cs.ganji.com/fang12/o42/', 'http://cs.ganji.com/fang12/o43/', 'http://cs.ganji.com/fang12/o44/', 'http://cs.ganji.com/fang12/o45/', 'http://cs.ganji.com/fang12/o46/', 'http://cs.ganji.com/fang12/o47/', 'http://cs.ganji.com/fang12/o48/', 'http://cs.ganji.com/fang12/o49/', 'http://cs.ganji.com/fang12/o50/', 'http://cs.ganji.com/fang12/o51/', 'http://cs.ganji.com/fang12/o52/', 'http://cs.ganji.com/fang12/o53/', 'http://cs.ganji.com/fang12/o54/', 'http://cs.ganji.com/fang12/o55/', 'http://cs.ganji.com/fang12/o56/', 'http://cs.ganji.com/fang12/o57/', 'http://cs.ganji.com/fang12/o58/', 'http://cs.ganji.com/fang12/o59/', 'http://cs.ganji.com/fang12/o60/', 'http://cs.ganji.com/fang12/o61/', 'http://cs.ganji.com/fang12/o62/', 'http://cs.ganji.com/fang12/o63/', 'http://cs.ganji.com/fang12/o64/', 'http://cs.ganji.com/fang12/o65/', 'http://cs.ganji.com/fang12/o66/', 'http://cs.ganji.com/fang12/o67/', 'http://cs.ganji.com/fang12/o68/', 'http://cs.ganji.com/fang12/o69/', 'http://cs.ganji.com/fang12/o70/' ] ershoufangURL = [ 'http://cs.ganji.com/fang5/o1/', 'http://cs.ganji.com/fang5/o2/', 'http://cs.ganji.com/fang5/o3/', 'http://cs.ganji.com/fang5/o4/', 'http://cs.ganji.com/fang5/o5/', 'http://cs.ganji.com/fang5/o6/', 'http://cs.ganji.com/fang5/o7/', 'http://cs.ganji.com/fang5/o8/', 'http://cs.ganji.com/fang5/o9/', 'http://cs.ganji.com/fang5/o10/', 'http://cs.ganji.com/fang5/o11/', 'http://cs.ganji.com/fang5/o12/', 'http://cs.ganji.com/fang5/o13/', 'http://cs.ganji.com/fang5/o14/', 'http://cs.ganji.com/fang5/o15/', 'http://cs.ganji.com/fang5/o16/', 'http://cs.ganji.com/fang5/o17/', 'http://cs.ganji.com/fang5/o18/', 'http://cs.ganji.com/fang5/o19/', 'http://cs.ganji.com/fang5/o20/', 'http://cs.ganji.com/fang5/o21/', 'http://cs.ganji.com/fang5/o22/', 'http://cs.ganji.com/fang5/o23/', 'http://cs.ganji.com/fang5/o24/', 'http://cs.ganji.com/fang5/o25/', 'http://cs.ganji.com/fang5/o26/', 'http://cs.ganji.com/fang5/o27/', 'http://cs.ganji.com/fang5/o28/', 'http://cs.ganji.com/fang5/o29/', 'http://cs.ganji.com/fang5/o30/', 'http://cs.ganji.com/fang5/o31/', 'http://cs.ganji.com/fang5/o32/', 'http://cs.ganji.com/fang5/o33/', 'http://cs.ganji.com/fang5/o34/', 'http://cs.ganji.com/fang5/o35/', 'http://cs.ganji.com/fang5/o36/', 'http://cs.ganji.com/fang5/o37/', 'http://cs.ganji.com/fang5/o38/', 'http://cs.ganji.com/fang5/o39/', 'http://cs.ganji.com/fang5/o40/', 'http://cs.ganji.com/fang5/o41/', 'http://cs.ganji.com/fang5/o42/', 'http://cs.ganji.com/fang5/o43/', 'http://cs.ganji.com/fang5/o44/', 'http://cs.ganji.com/fang5/o45/', 'http://cs.ganji.com/fang5/o46/', 'http://cs.ganji.com/fang5/o47/', 'http://cs.ganji.com/fang5/o48/', 'http://cs.ganji.com/fang5/o49/', 'http://cs.ganji.com/fang5/o50/', 'http://cs.ganji.com/fang5/o51/', 'http://cs.ganji.com/fang5/o52/', 'http://cs.ganji.com/fang5/o53/', 'http://cs.ganji.com/fang5/o54/', 'http://cs.ganji.com/fang5/o55/', 'http://cs.ganji.com/fang5/o56/', 'http://cs.ganji.com/fang5/o57/', 'http://cs.ganji.com/fang5/o58/', 'http://cs.ganji.com/fang5/o59/', 'http://cs.ganji.com/fang5/o60/', 'http://cs.ganji.com/fang5/o61/', 'http://cs.ganji.com/fang5/o62/', 'http://cs.ganji.com/fang5/o63/', 'http://cs.ganji.com/fang5/o64/', 'http://cs.ganji.com/fang5/o65/', 'http://cs.ganji.com/fang5/o66/', 'http://cs.ganji.com/fang5/o67/', 'http://cs.ganji.com/fang5/o68/', 'http://cs.ganji.com/fang5/o69/', 'http://cs.ganji.com/fang5/o70/' ] zufangURL = [ 'http://cs.ganji.com/fang1/o1/', 'http://cs.ganji.com/fang1/o2/', 'http://cs.ganji.com/fang1/o3/', 'http://cs.ganji.com/fang1/o4/', 'http://cs.ganji.com/fang1/o5/', 'http://cs.ganji.com/fang1/o6/', 'http://cs.ganji.com/fang1/o7/', 'http://cs.ganji.com/fang1/o8/', 'http://cs.ganji.com/fang1/o9/', 'http://cs.ganji.com/fang1/o10/', 'http://cs.ganji.com/fang1/o11/', 'http://cs.ganji.com/fang1/o12/', 'http://cs.ganji.com/fang1/o13/', 'http://cs.ganji.com/fang1/o14/', 'http://cs.ganji.com/fang1/o15/', 'http://cs.ganji.com/fang1/o16/', 'http://cs.ganji.com/fang1/o17/', 'http://cs.ganji.com/fang1/o18/', 'http://cs.ganji.com/fang1/o19/', 'http://cs.ganji.com/fang1/o20/', 'http://cs.ganji.com/fang1/o21/', 'http://cs.ganji.com/fang1/o22/', 'http://cs.ganji.com/fang1/o23/', 'http://cs.ganji.com/fang1/o24/', 'http://cs.ganji.com/fang1/o25/', 'http://cs.ganji.com/fang1/o26/', 'http://cs.ganji.com/fang1/o27/', 'http://cs.ganji.com/fang1/o28/', 'http://cs.ganji.com/fang1/o29/', 'http://cs.ganji.com/fang1/o30/', 'http://cs.ganji.com/fang1/o31/', 'http://cs.ganji.com/fang1/o32/', 'http://cs.ganji.com/fang1/o33/', 'http://cs.ganji.com/fang1/o34/', 'http://cs.ganji.com/fang1/o35/', 'http://cs.ganji.com/fang1/o36/', 'http://cs.ganji.com/fang1/o37/', 'http://cs.ganji.com/fang1/o38/', 'http://cs.ganji.com/fang1/o39/', 'http://cs.ganji.com/fang1/o40/', 'http://cs.ganji.com/fang1/o41/', 'http://cs.ganji.com/fang1/o42/', 'http://cs.ganji.com/fang1/o43/', 'http://cs.ganji.com/fang1/o44/', 'http://cs.ganji.com/fang1/o45/', 'http://cs.ganji.com/fang1/o46/', 'http://cs.ganji.com/fang1/o47/', 'http://cs.ganji.com/fang1/o48/', 'http://cs.ganji.com/fang1/o49/', 'http://cs.ganji.com/fang1/o50/', 'http://cs.ganji.com/fang1/o51/', 'http://cs.ganji.com/fang1/o52/', 'http://cs.ganji.com/fang1/o53/', 'http://cs.ganji.com/fang1/o54/', 'http://cs.ganji.com/fang1/o55/', 'http://cs.ganji.com/fang1/o56/', 'http://cs.ganji.com/fang1/o57/', 'http://cs.ganji.com/fang1/o58/', 'http://cs.ganji.com/fang1/o59/', 'http://cs.ganji.com/fang1/o60/', 'http://cs.ganji.com/fang1/o61/', 'http://cs.ganji.com/fang1/o62/', 'http://cs.ganji.com/fang1/o63/', 'http://cs.ganji.com/fang1/o64/', 'http://cs.ganji.com/fang1/o65/', 'http://cs.ganji.com/fang1/o66/', 'http://cs.ganji.com/fang1/o67/', 'http://cs.ganji.com/fang1/o68/', 'http://cs.ganji.com/fang1/o69/', 'http://cs.ganji.com/fang1/o70/' ]
class Starturl: xinfang_url = ['http://cs.ganji.com/fang12/o1/', 'http://cs.ganji.com/fang12/o2/', 'http://cs.ganji.com/fang12/o3/', 'http://cs.ganji.com/fang12/o4/', 'http://cs.ganji.com/fang12/o5/', 'http://cs.ganji.com/fang12/o6/', 'http://cs.ganji.com/fang12/o7/', 'http://cs.ganji.com/fang12/o8/', 'http://cs.ganji.com/fang12/o9/', 'http://cs.ganji.com/fang12/o10/', 'http://cs.ganji.com/fang12/o11/', 'http://cs.ganji.com/fang12/o12/', 'http://cs.ganji.com/fang12/o13/', 'http://cs.ganji.com/fang12/o14/', 'http://cs.ganji.com/fang12/o15/', 'http://cs.ganji.com/fang12/o16/', 'http://cs.ganji.com/fang12/o17/', 'http://cs.ganji.com/fang12/o18/', 'http://cs.ganji.com/fang12/o19/', 'http://cs.ganji.com/fang12/o20/', 'http://cs.ganji.com/fang12/o21/', 'http://cs.ganji.com/fang12/o22/', 'http://cs.ganji.com/fang12/o23/', 'http://cs.ganji.com/fang12/o24/', 'http://cs.ganji.com/fang12/o25/', 'http://cs.ganji.com/fang12/o26/', 'http://cs.ganji.com/fang12/o27/', 'http://cs.ganji.com/fang12/o28/', 'http://cs.ganji.com/fang12/o29/', 'http://cs.ganji.com/fang12/o30/', 'http://cs.ganji.com/fang12/o31/', 'http://cs.ganji.com/fang12/o32/', 'http://cs.ganji.com/fang12/o33/', 'http://cs.ganji.com/fang12/o34/', 'http://cs.ganji.com/fang12/o35/', 'http://cs.ganji.com/fang12/o36/', 'http://cs.ganji.com/fang12/o37/', 'http://cs.ganji.com/fang12/o38/', 'http://cs.ganji.com/fang12/o39/', 'http://cs.ganji.com/fang12/o40/', 'http://cs.ganji.com/fang12/o41/', 'http://cs.ganji.com/fang12/o42/', 'http://cs.ganji.com/fang12/o43/', 'http://cs.ganji.com/fang12/o44/', 'http://cs.ganji.com/fang12/o45/', 'http://cs.ganji.com/fang12/o46/', 'http://cs.ganji.com/fang12/o47/', 'http://cs.ganji.com/fang12/o48/', 'http://cs.ganji.com/fang12/o49/', 'http://cs.ganji.com/fang12/o50/', 'http://cs.ganji.com/fang12/o51/', 'http://cs.ganji.com/fang12/o52/', 'http://cs.ganji.com/fang12/o53/', 'http://cs.ganji.com/fang12/o54/', 'http://cs.ganji.com/fang12/o55/', 'http://cs.ganji.com/fang12/o56/', 'http://cs.ganji.com/fang12/o57/', 'http://cs.ganji.com/fang12/o58/', 'http://cs.ganji.com/fang12/o59/', 'http://cs.ganji.com/fang12/o60/', 'http://cs.ganji.com/fang12/o61/', 'http://cs.ganji.com/fang12/o62/', 'http://cs.ganji.com/fang12/o63/', 'http://cs.ganji.com/fang12/o64/', 'http://cs.ganji.com/fang12/o65/', 'http://cs.ganji.com/fang12/o66/', 'http://cs.ganji.com/fang12/o67/', 'http://cs.ganji.com/fang12/o68/', 'http://cs.ganji.com/fang12/o69/', 'http://cs.ganji.com/fang12/o70/'] ershoufang_url = ['http://cs.ganji.com/fang5/o1/', 'http://cs.ganji.com/fang5/o2/', 'http://cs.ganji.com/fang5/o3/', 'http://cs.ganji.com/fang5/o4/', 'http://cs.ganji.com/fang5/o5/', 'http://cs.ganji.com/fang5/o6/', 'http://cs.ganji.com/fang5/o7/', 'http://cs.ganji.com/fang5/o8/', 'http://cs.ganji.com/fang5/o9/', 'http://cs.ganji.com/fang5/o10/', 'http://cs.ganji.com/fang5/o11/', 'http://cs.ganji.com/fang5/o12/', 'http://cs.ganji.com/fang5/o13/', 'http://cs.ganji.com/fang5/o14/', 'http://cs.ganji.com/fang5/o15/', 'http://cs.ganji.com/fang5/o16/', 'http://cs.ganji.com/fang5/o17/', 'http://cs.ganji.com/fang5/o18/', 'http://cs.ganji.com/fang5/o19/', 'http://cs.ganji.com/fang5/o20/', 'http://cs.ganji.com/fang5/o21/', 'http://cs.ganji.com/fang5/o22/', 'http://cs.ganji.com/fang5/o23/', 'http://cs.ganji.com/fang5/o24/', 'http://cs.ganji.com/fang5/o25/', 'http://cs.ganji.com/fang5/o26/', 'http://cs.ganji.com/fang5/o27/', 'http://cs.ganji.com/fang5/o28/', 'http://cs.ganji.com/fang5/o29/', 'http://cs.ganji.com/fang5/o30/', 'http://cs.ganji.com/fang5/o31/', 'http://cs.ganji.com/fang5/o32/', 'http://cs.ganji.com/fang5/o33/', 'http://cs.ganji.com/fang5/o34/', 'http://cs.ganji.com/fang5/o35/', 'http://cs.ganji.com/fang5/o36/', 'http://cs.ganji.com/fang5/o37/', 'http://cs.ganji.com/fang5/o38/', 'http://cs.ganji.com/fang5/o39/', 'http://cs.ganji.com/fang5/o40/', 'http://cs.ganji.com/fang5/o41/', 'http://cs.ganji.com/fang5/o42/', 'http://cs.ganji.com/fang5/o43/', 'http://cs.ganji.com/fang5/o44/', 'http://cs.ganji.com/fang5/o45/', 'http://cs.ganji.com/fang5/o46/', 'http://cs.ganji.com/fang5/o47/', 'http://cs.ganji.com/fang5/o48/', 'http://cs.ganji.com/fang5/o49/', 'http://cs.ganji.com/fang5/o50/', 'http://cs.ganji.com/fang5/o51/', 'http://cs.ganji.com/fang5/o52/', 'http://cs.ganji.com/fang5/o53/', 'http://cs.ganji.com/fang5/o54/', 'http://cs.ganji.com/fang5/o55/', 'http://cs.ganji.com/fang5/o56/', 'http://cs.ganji.com/fang5/o57/', 'http://cs.ganji.com/fang5/o58/', 'http://cs.ganji.com/fang5/o59/', 'http://cs.ganji.com/fang5/o60/', 'http://cs.ganji.com/fang5/o61/', 'http://cs.ganji.com/fang5/o62/', 'http://cs.ganji.com/fang5/o63/', 'http://cs.ganji.com/fang5/o64/', 'http://cs.ganji.com/fang5/o65/', 'http://cs.ganji.com/fang5/o66/', 'http://cs.ganji.com/fang5/o67/', 'http://cs.ganji.com/fang5/o68/', 'http://cs.ganji.com/fang5/o69/', 'http://cs.ganji.com/fang5/o70/'] zufang_url = ['http://cs.ganji.com/fang1/o1/', 'http://cs.ganji.com/fang1/o2/', 'http://cs.ganji.com/fang1/o3/', 'http://cs.ganji.com/fang1/o4/', 'http://cs.ganji.com/fang1/o5/', 'http://cs.ganji.com/fang1/o6/', 'http://cs.ganji.com/fang1/o7/', 'http://cs.ganji.com/fang1/o8/', 'http://cs.ganji.com/fang1/o9/', 'http://cs.ganji.com/fang1/o10/', 'http://cs.ganji.com/fang1/o11/', 'http://cs.ganji.com/fang1/o12/', 'http://cs.ganji.com/fang1/o13/', 'http://cs.ganji.com/fang1/o14/', 'http://cs.ganji.com/fang1/o15/', 'http://cs.ganji.com/fang1/o16/', 'http://cs.ganji.com/fang1/o17/', 'http://cs.ganji.com/fang1/o18/', 'http://cs.ganji.com/fang1/o19/', 'http://cs.ganji.com/fang1/o20/', 'http://cs.ganji.com/fang1/o21/', 'http://cs.ganji.com/fang1/o22/', 'http://cs.ganji.com/fang1/o23/', 'http://cs.ganji.com/fang1/o24/', 'http://cs.ganji.com/fang1/o25/', 'http://cs.ganji.com/fang1/o26/', 'http://cs.ganji.com/fang1/o27/', 'http://cs.ganji.com/fang1/o28/', 'http://cs.ganji.com/fang1/o29/', 'http://cs.ganji.com/fang1/o30/', 'http://cs.ganji.com/fang1/o31/', 'http://cs.ganji.com/fang1/o32/', 'http://cs.ganji.com/fang1/o33/', 'http://cs.ganji.com/fang1/o34/', 'http://cs.ganji.com/fang1/o35/', 'http://cs.ganji.com/fang1/o36/', 'http://cs.ganji.com/fang1/o37/', 'http://cs.ganji.com/fang1/o38/', 'http://cs.ganji.com/fang1/o39/', 'http://cs.ganji.com/fang1/o40/', 'http://cs.ganji.com/fang1/o41/', 'http://cs.ganji.com/fang1/o42/', 'http://cs.ganji.com/fang1/o43/', 'http://cs.ganji.com/fang1/o44/', 'http://cs.ganji.com/fang1/o45/', 'http://cs.ganji.com/fang1/o46/', 'http://cs.ganji.com/fang1/o47/', 'http://cs.ganji.com/fang1/o48/', 'http://cs.ganji.com/fang1/o49/', 'http://cs.ganji.com/fang1/o50/', 'http://cs.ganji.com/fang1/o51/', 'http://cs.ganji.com/fang1/o52/', 'http://cs.ganji.com/fang1/o53/', 'http://cs.ganji.com/fang1/o54/', 'http://cs.ganji.com/fang1/o55/', 'http://cs.ganji.com/fang1/o56/', 'http://cs.ganji.com/fang1/o57/', 'http://cs.ganji.com/fang1/o58/', 'http://cs.ganji.com/fang1/o59/', 'http://cs.ganji.com/fang1/o60/', 'http://cs.ganji.com/fang1/o61/', 'http://cs.ganji.com/fang1/o62/', 'http://cs.ganji.com/fang1/o63/', 'http://cs.ganji.com/fang1/o64/', 'http://cs.ganji.com/fang1/o65/', 'http://cs.ganji.com/fang1/o66/', 'http://cs.ganji.com/fang1/o67/', 'http://cs.ganji.com/fang1/o68/', 'http://cs.ganji.com/fang1/o69/', 'http://cs.ganji.com/fang1/o70/']
# File: hackerone_consts.py # Copyright (c) 2020-2021 Splunk Inc. # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) # # Constants for actions ACTION_ID_GET_ALL = 'get_reports' ACTION_ID_GET_UPDATED = 'get_updated_reports' ACTION_ID_GET_ONE = 'get_report' ACTION_ID_UPDATE = 'update_id' ACTION_ID_UNASSIGN = 'unassign' ACTION_ID_ON_POLL = 'on_poll' ACTION_ID_TEST = 'test_asset_connectivity' ACTION_ID_GET_BOUNTY_BALANCE = 'get_bounty_balance' ACTION_ID_GET_BILLING_TRANSACTIONS = 'get_billing_transactions' # Constants for error messages ERR_CODE_MSG = "Error code unavailable" ERR_MSG_UNAVAILABLE = "Error message unavailable. Please check the asset configuration and|or action parameters" PARSE_ERR_MSG = "Unable to parse the error message. Please check the asset configuration and|or action parameters" TYPE_ERR_MSG = "Error occurred while connecting to the HackerOne Server. Please check the asset configuration and|or the action parameters" INT_VALIDATION_ERR_MSG = "Please provide a valid integer value in the {}" NEG_INT_VALIDATION_ERR_MSG = "Please provide a valid non-negative integer value in the {}" # Constants for params RANGE_KEY = "'range' action parameter" CONTAINER_COUNT_KEY = "'container_count' action parameter"
action_id_get_all = 'get_reports' action_id_get_updated = 'get_updated_reports' action_id_get_one = 'get_report' action_id_update = 'update_id' action_id_unassign = 'unassign' action_id_on_poll = 'on_poll' action_id_test = 'test_asset_connectivity' action_id_get_bounty_balance = 'get_bounty_balance' action_id_get_billing_transactions = 'get_billing_transactions' err_code_msg = 'Error code unavailable' err_msg_unavailable = 'Error message unavailable. Please check the asset configuration and|or action parameters' parse_err_msg = 'Unable to parse the error message. Please check the asset configuration and|or action parameters' type_err_msg = 'Error occurred while connecting to the HackerOne Server. Please check the asset configuration and|or the action parameters' int_validation_err_msg = 'Please provide a valid integer value in the {}' neg_int_validation_err_msg = 'Please provide a valid non-negative integer value in the {}' range_key = "'range' action parameter" container_count_key = "'container_count' action parameter"
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ pre_n_th = n_th = tail = head i = 0 if head.next is None: return None while n > 1: tail = tail.next n -= 1 while tail.next is not None: tail = tail.next n_th = n_th.next if i > 0: pre_n_th = pre_n_th.next i += 1 if n_th == pre_n_th: return head.next else: pre_n_th.next = n_th.next return head def removeNthFromEnd2(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ fast = slow = head for _ in range(n): fast = fast.next if not fast: return head.next while fast.next: fast = fast.next slow = slow.next slow.next = slow.next.next return head
class Listnode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def remove_nth_from_end(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ pre_n_th = n_th = tail = head i = 0 if head.next is None: return None while n > 1: tail = tail.next n -= 1 while tail.next is not None: tail = tail.next n_th = n_th.next if i > 0: pre_n_th = pre_n_th.next i += 1 if n_th == pre_n_th: return head.next else: pre_n_th.next = n_th.next return head def remove_nth_from_end2(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ fast = slow = head for _ in range(n): fast = fast.next if not fast: return head.next while fast.next: fast = fast.next slow = slow.next slow.next = slow.next.next return head
# -*- coding: utf-8 -*- # Author: Daniel Yang <daniel.yj.yang@gmail.com> # # License: BSD-3-Clause __version__ = "0.0.6" __license__ = "BSD-3-Clause License"
__version__ = '0.0.6' __license__ = 'BSD-3-Clause License'
##n=int(input("enter a number:")) ##i=1 ## ##count=0 ##while(i<n): ## if(n%i==0): ## count=count+1 ## ## i=i+1 ##if(count<=2): ## print("prime") ##else: ## print("not") i=2 j=2 while(i<=10): while(j<i): if(i%j==0): break; else: print(i) j+=1 i+=1
i = 2 j = 2 while i <= 10: while j < i: if i % j == 0: break else: print(i) j += 1 i += 1
for m in range(1,1000): for n in range(m+1,1000): c=1000-m-n if c**2==(m**2+n**2): print('The individual numbers a,b,c respectively are',m,n,c,'the product of abc is',m*n*c)
for m in range(1, 1000): for n in range(m + 1, 1000): c = 1000 - m - n if c ** 2 == m ** 2 + n ** 2: print('The individual numbers a,b,c respectively are', m, n, c, 'the product of abc is', m * n * c)
{ 'target_defaults': { 'includes': ['../common-mk/common.gypi'], 'variables': { 'deps': [ 'protobuf', ], }, }, 'targets': [ { 'target_name': 'media_perception_protos', 'type': 'static_library', 'variables': { 'proto_in_dir': 'proto/', 'proto_out_dir': 'include/media_perception', }, 'sources': [ '<(proto_in_dir)/device_management.proto', '<(proto_in_dir)/pipeline.proto', ], 'includes': ['../common-mk/protoc.gypi'], }, { 'target_name': 'media_perception_mojo_bindings', 'type': 'static_library', 'sources': [ 'mojom/color_space.mojom', 'mojom/constants.mojom', 'mojom/device.mojom', 'mojom/device_factory.mojom', 'mojom/device_management.mojom', 'mojom/geometry.mojom', 'mojom/image_capture.mojom', 'mojom/mailbox.mojom', 'mojom/mailbox_holder.mojom', 'mojom/media_perception.mojom', 'mojom/media_perception_service.mojom', 'mojom/pipeline.mojom', 'mojom/producer.mojom', 'mojom/receiver.mojom', 'mojom/scoped_access_permission.mojom', 'mojom/shared_memory.mojom', 'mojom/sync_token.mojom', 'mojom/time.mojom', 'mojom/values.mojom', 'mojom/video_capture_types.mojom', 'mojom/virtual_device.mojom', ], 'includes': ['../common-mk/mojom_bindings_generator.gypi'], }, { 'target_name': 'media_perception_service_lib', 'type': 'static_library', 'variables': { 'exported_deps': [ 'libchrome-<(libbase_ver)', 'libbrillo-<(libbase_ver)', 'libmojo-<(libbase_ver)', ], 'deps': ['<@(exported_deps)'], }, 'dependencies': [ 'media_perception_mojo_bindings', 'media_perception_protos', ], 'all_dependent_settings': { 'variables': { 'deps': [ '<@(exported_deps)', ], }, }, 'sources': [ 'cras_client_impl.cc', 'media_perception_controller_impl.cc', 'media_perception_impl.cc', 'media_perception_service_impl.cc', 'mojo_connector.cc', 'producer_impl.cc', 'proto_mojom_conversion.cc', 'receiver_impl.cc', 'shared_memory_provider.cc', 'video_capture_service_client_impl.cc', ], 'direct_dependent_settings': { 'cflags': [ '<!@(<(pkg-config) --cflags libcras)', '<!@(<(pkg-config) --cflags dbus-1)', ], }, 'link_settings': { 'ldflags': [ '<!@(<(pkg-config) --libs-only-L --libs-only-other libcras)', '<!@(<(pkg-config) --libs-only-L --libs-only-other dbus-1)', ], 'libraries': [ '<!@(<(pkg-config) --libs-only-l libcras)', '<!@(<(pkg-config) --libs-only-l dbus-1)', ], }, }, { 'target_name': 'rtanalytics_main', 'type': 'executable', 'dependencies': [ 'media_perception_service_lib', ], 'sources': ['main.cc'], 'link_settings': { 'ldflags': [ '-L .', ], 'libraries': [ '-lrtanalytics -ldl', ], }, }, ], 'conditions': [ ['USE_test == 1', { 'targets': [ { 'target_name': 'media_perception_service_test', 'type': 'executable', 'includes': ['../common-mk/common_test.gypi'], 'dependencies': ['media_perception_service_lib'], 'sources': [ '../common-mk/testrunner.cc', 'proto_mojom_conversion_test.cc', ], }, ], }], ], }
{'target_defaults': {'includes': ['../common-mk/common.gypi'], 'variables': {'deps': ['protobuf']}}, 'targets': [{'target_name': 'media_perception_protos', 'type': 'static_library', 'variables': {'proto_in_dir': 'proto/', 'proto_out_dir': 'include/media_perception'}, 'sources': ['<(proto_in_dir)/device_management.proto', '<(proto_in_dir)/pipeline.proto'], 'includes': ['../common-mk/protoc.gypi']}, {'target_name': 'media_perception_mojo_bindings', 'type': 'static_library', 'sources': ['mojom/color_space.mojom', 'mojom/constants.mojom', 'mojom/device.mojom', 'mojom/device_factory.mojom', 'mojom/device_management.mojom', 'mojom/geometry.mojom', 'mojom/image_capture.mojom', 'mojom/mailbox.mojom', 'mojom/mailbox_holder.mojom', 'mojom/media_perception.mojom', 'mojom/media_perception_service.mojom', 'mojom/pipeline.mojom', 'mojom/producer.mojom', 'mojom/receiver.mojom', 'mojom/scoped_access_permission.mojom', 'mojom/shared_memory.mojom', 'mojom/sync_token.mojom', 'mojom/time.mojom', 'mojom/values.mojom', 'mojom/video_capture_types.mojom', 'mojom/virtual_device.mojom'], 'includes': ['../common-mk/mojom_bindings_generator.gypi']}, {'target_name': 'media_perception_service_lib', 'type': 'static_library', 'variables': {'exported_deps': ['libchrome-<(libbase_ver)', 'libbrillo-<(libbase_ver)', 'libmojo-<(libbase_ver)'], 'deps': ['<@(exported_deps)']}, 'dependencies': ['media_perception_mojo_bindings', 'media_perception_protos'], 'all_dependent_settings': {'variables': {'deps': ['<@(exported_deps)']}}, 'sources': ['cras_client_impl.cc', 'media_perception_controller_impl.cc', 'media_perception_impl.cc', 'media_perception_service_impl.cc', 'mojo_connector.cc', 'producer_impl.cc', 'proto_mojom_conversion.cc', 'receiver_impl.cc', 'shared_memory_provider.cc', 'video_capture_service_client_impl.cc'], 'direct_dependent_settings': {'cflags': ['<!@(<(pkg-config) --cflags libcras)', '<!@(<(pkg-config) --cflags dbus-1)']}, 'link_settings': {'ldflags': ['<!@(<(pkg-config) --libs-only-L --libs-only-other libcras)', '<!@(<(pkg-config) --libs-only-L --libs-only-other dbus-1)'], 'libraries': ['<!@(<(pkg-config) --libs-only-l libcras)', '<!@(<(pkg-config) --libs-only-l dbus-1)']}}, {'target_name': 'rtanalytics_main', 'type': 'executable', 'dependencies': ['media_perception_service_lib'], 'sources': ['main.cc'], 'link_settings': {'ldflags': ['-L .'], 'libraries': ['-lrtanalytics -ldl']}}], 'conditions': [['USE_test == 1', {'targets': [{'target_name': 'media_perception_service_test', 'type': 'executable', 'includes': ['../common-mk/common_test.gypi'], 'dependencies': ['media_perception_service_lib'], 'sources': ['../common-mk/testrunner.cc', 'proto_mojom_conversion_test.cc']}]}]]}
class Solution: def canReach(self, arr: List[int], start: int) -> bool: # bastardized version of DFS # if we are out of bounds return false # else check to left and right # same idea as sinking islands where we remove visited for current recurse left, right = 0, len(arr) def dfs(i): if (i < left or i >= right or arr[i] < 0): return False if arr[i] == 0: return True arr[i] = -arr[i] poss1 = dfs(i - arr[i]) poss2 = dfs(i + arr[i]) arr[i] = -arr[i] return poss1 or poss2 return dfs(start)
class Solution: def can_reach(self, arr: List[int], start: int) -> bool: (left, right) = (0, len(arr)) def dfs(i): if i < left or i >= right or arr[i] < 0: return False if arr[i] == 0: return True arr[i] = -arr[i] poss1 = dfs(i - arr[i]) poss2 = dfs(i + arr[i]) arr[i] = -arr[i] return poss1 or poss2 return dfs(start)
class Queue: def __init__(self, maxsize): self.__max_size = maxsize self.__elements = [None] * self.__max_size self.__rear = -1 self.__front = 0 def getMaxSize(self): return self.__max_size def isFull(self): return self.__rear == self.__max_size def isEmpty(self): if self.__rear == -1 or self.__front == self.__max_size: return True else: return False def enqueue(self, data): if self.isFull(): print('Queue is full') else: self.__rear += 1 self.__elements[self.__rear] = data def dequeue(self): if self.isEmpty(): print('Queue is empty.') else: data = self.__elements[self.__front] self.__front += 1 return data def display(self): if not self.isEmpty(): for i in range(self.__front, (self.__rear + 1)): print(self.__elements[i]) else: print('Empty queue.') def __str__(self): msg = [] index = self.__front while index <= self.__rear: msg.append(str(self.__elements[index])) index += 1 msg = ' '.join(msg) msg = f'Queue data (from front to rear) : {msg}' return msg if __name__ == '__main__': queue = Queue(5) queue.enqueue('A') queue.enqueue('B') queue.enqueue('C') queue.enqueue('D') queue.enqueue('E') print(queue) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) queue.display()
class Queue: def __init__(self, maxsize): self.__max_size = maxsize self.__elements = [None] * self.__max_size self.__rear = -1 self.__front = 0 def get_max_size(self): return self.__max_size def is_full(self): return self.__rear == self.__max_size def is_empty(self): if self.__rear == -1 or self.__front == self.__max_size: return True else: return False def enqueue(self, data): if self.isFull(): print('Queue is full') else: self.__rear += 1 self.__elements[self.__rear] = data def dequeue(self): if self.isEmpty(): print('Queue is empty.') else: data = self.__elements[self.__front] self.__front += 1 return data def display(self): if not self.isEmpty(): for i in range(self.__front, self.__rear + 1): print(self.__elements[i]) else: print('Empty queue.') def __str__(self): msg = [] index = self.__front while index <= self.__rear: msg.append(str(self.__elements[index])) index += 1 msg = ' '.join(msg) msg = f'Queue data (from front to rear) : {msg}' return msg if __name__ == '__main__': queue = queue(5) queue.enqueue('A') queue.enqueue('B') queue.enqueue('C') queue.enqueue('D') queue.enqueue('E') print(queue) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) print('Dequeued: ', queue.dequeue()) queue.display()
def HammingDistance(p, q): mm = [p[i] != q[i] for i in range(len(p))] return sum(mm) # def ImmediateNeighbors(Pattern): # Neighborhood = [Pattern] # for i in range(len(Pattern)): # nuc = Pattern[i] # for nuc2 in ['A', 'C', 'G', 'T']: # if nuc != nuc2: # pat = list(Pattern) # pat[i] = nuc2 # Neighborhood.append(''.join(pat)) # return Neighborhood def Neighbors(Pattern, d): if d == 0: return Pattern if len(Pattern) == 1: return ['A', 'C', 'G', 'T'] Neighborhood = set() SuffixNeighbors = Neighbors(Pattern[1:], d) for Text in SuffixNeighbors: if HammingDistance(Pattern[1:], Text) < d: for nuc in ['A', 'C', 'G', 'T']: Neighborhood.add(nuc + Text) else: Neighborhood.add(Pattern[0] + Text) return Neighborhood def FrequentWordsWithMismatches(Text, k, d): pattern_dict = {} max_val = -1 for i in range(len(Text) - k + 1): Pattern = Text[i:i+k] Neighborhood = Neighbors(Pattern, d) for ApproximatePattern in Neighborhood: if ApproximatePattern in pattern_dict.keys(): pattern_dict[ApproximatePattern] += 1 if pattern_dict[ApproximatePattern] > max_val: max_val = pattern_dict[ApproximatePattern] else: pattern_dict[ApproximatePattern] = 1 if pattern_dict[ApproximatePattern] > max_val: max_val = pattern_dict[ApproximatePattern] FrequentPatterns = [] for key, value in pattern_dict.iteritems(): if value == max_val: FrequentPatterns.append(key) return FrequentPatterns FrequentWordsWithMismatches('ATA', 3, 1) FrequentWordsWithMismatches('GTAAGATGTGCACTGATGTAAGTAAGTAACACTGACGGACGGATGTGGATGTAACACTCACTGTGGACGGATGTGGTAAGACGGTAAGTGCACTGATGACGGTGGTGGATGATGATGTGGATGACGCACTCACTGTAAGTGGATCACTGACGGATGTAAGACGGTGGATGTAAGATGTGGATGATGATGACGCACTGTAAGACGGTAAGTAAGTAAGACGGTGGTGGTGGTAAGACGGTAACACTCACTGTGCACTGACGGATGTAACACTGATCACTCACTGATGTGGTGGTAAGACGGTAAGATGTAAGACGCACTGTGCACTGTAAGATGACGGACGGTGGATCACTGATGACGGTAACACTCACTGACGGTAA', 6, 2)
def hamming_distance(p, q): mm = [p[i] != q[i] for i in range(len(p))] return sum(mm) def neighbors(Pattern, d): if d == 0: return Pattern if len(Pattern) == 1: return ['A', 'C', 'G', 'T'] neighborhood = set() suffix_neighbors = neighbors(Pattern[1:], d) for text in SuffixNeighbors: if hamming_distance(Pattern[1:], Text) < d: for nuc in ['A', 'C', 'G', 'T']: Neighborhood.add(nuc + Text) else: Neighborhood.add(Pattern[0] + Text) return Neighborhood def frequent_words_with_mismatches(Text, k, d): pattern_dict = {} max_val = -1 for i in range(len(Text) - k + 1): pattern = Text[i:i + k] neighborhood = neighbors(Pattern, d) for approximate_pattern in Neighborhood: if ApproximatePattern in pattern_dict.keys(): pattern_dict[ApproximatePattern] += 1 if pattern_dict[ApproximatePattern] > max_val: max_val = pattern_dict[ApproximatePattern] else: pattern_dict[ApproximatePattern] = 1 if pattern_dict[ApproximatePattern] > max_val: max_val = pattern_dict[ApproximatePattern] frequent_patterns = [] for (key, value) in pattern_dict.iteritems(): if value == max_val: FrequentPatterns.append(key) return FrequentPatterns frequent_words_with_mismatches('ATA', 3, 1) frequent_words_with_mismatches('GTAAGATGTGCACTGATGTAAGTAAGTAACACTGACGGACGGATGTGGATGTAACACTCACTGTGGACGGATGTGGTAAGACGGTAAGTGCACTGATGACGGTGGTGGATGATGATGTGGATGACGCACTCACTGTAAGTGGATCACTGACGGATGTAAGACGGTGGATGTAAGATGTGGATGATGATGACGCACTGTAAGACGGTAAGTAAGTAAGACGGTGGTGGTGGTAAGACGGTAACACTCACTGTGCACTGACGGATGTAACACTGATCACTCACTGATGTGGTGGTAAGACGGTAAGATGTAAGACGCACTGTGCACTGTAAGATGACGGACGGTGGATCACTGATGACGGTAACACTCACTGACGGTAA', 6, 2)
''' Description: Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Example 1: Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 Output: 32 Example 2: Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10 Output: 23 Note: The number of nodes in the tree is at most 10000. The final answer is guaranteed to be less than 2^31. ''' # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def helper(self, node, arr): # in-order traversal if node: self.helper( node.left, arr ) arr.append( node.val ) self.helper( node.right, arr ) def rangeSumBST(self, root: TreeNode, L: int, R: int) -> int: arr = [] self.helper(root, arr) index_of_L, index_of_R = arr.index(L), arr.index(R) return sum( arr[index_of_L : index_of_R+1] ) # n : the number of node in given binary search tree ## Time Complexity: O( n ) # # The overhead in time is to traversal the binary search tree within range, which is of O( n ) ## Space Complexity: O( n ) # # The overhead in space is the call stack for recursion and array, arr, which are both of O( n ) def test_bench(): root = TreeNode( 10 ) root.left = TreeNode( 5 ) root.right = TreeNode( 15 ) root.left.left = TreeNode( 3 ) root.left.right = TreeNode( 7 ) root.right.left = None root.right.right = TreeNode( 18 ) L, R = 7, 15 print( Solution().rangeSumBST(root, L, R) ) return if __name__ == '__main__': test_bench()
""" Description: Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Example 1: Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 Output: 32 Example 2: Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10 Output: 23 Note: The number of nodes in the tree is at most 10000. The final answer is guaranteed to be less than 2^31. """ class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def helper(self, node, arr): if node: self.helper(node.left, arr) arr.append(node.val) self.helper(node.right, arr) def range_sum_bst(self, root: TreeNode, L: int, R: int) -> int: arr = [] self.helper(root, arr) (index_of_l, index_of_r) = (arr.index(L), arr.index(R)) return sum(arr[index_of_L:index_of_R + 1]) def test_bench(): root = tree_node(10) root.left = tree_node(5) root.right = tree_node(15) root.left.left = tree_node(3) root.left.right = tree_node(7) root.right.left = None root.right.right = tree_node(18) (l, r) = (7, 15) print(solution().rangeSumBST(root, L, R)) return if __name__ == '__main__': test_bench()
""" This is a modelmanager settings file. Import or define your settings variables, functions or classes below. For example: ``` # will only be available here import pandas as example_module from pandas.some_module import some_function as _pandas_function # will be available as project.example_variable example_variable = 123 # will be available as project.example_function() def example_function(project, d=1): dd = d + 2 return dd # will be initialised and available as project.example (lower cased!) class Example: example_variable = 456 def __init__(self, project): self.project = project return ``` """
""" This is a modelmanager settings file. Import or define your settings variables, functions or classes below. For example: ``` # will only be available here import pandas as example_module from pandas.some_module import some_function as _pandas_function # will be available as project.example_variable example_variable = 123 # will be available as project.example_function() def example_function(project, d=1): dd = d + 2 return dd # will be initialised and available as project.example (lower cased!) class Example: example_variable = 456 def __init__(self, project): self.project = project return ``` """
""" Given array of integers lengths, create an array of arrays output such that output[i] consists of lengths[i] elements and output[i][j] = j. Example For lengths = [1, 2, 0, 4], the output should be create2DArray(lengths) = [[0], [0, 1], [], [0, 1, 2, 3]] """ def create2DArray(lengths): return [range(i) for i in lengths]
""" Given array of integers lengths, create an array of arrays output such that output[i] consists of lengths[i] elements and output[i][j] = j. Example For lengths = [1, 2, 0, 4], the output should be create2DArray(lengths) = [[0], [0, 1], [], [0, 1, 2, 3]] """ def create2_d_array(lengths): return [range(i) for i in lengths]
# model settings model = dict( type='Classification', pretrained=None, backbone=dict( type='MobileNetV3', arch='large', out_indices=(16,), # x-1: stage-x norm_cfg=dict(type='BN', eps=0.001, momentum=0.01), ), head=dict( type='ClsHead', loss=dict(type='CrossEntropyLoss', loss_weight=1.0), with_avg_pool=True, in_channels=960, num_classes=1000) )
model = dict(type='Classification', pretrained=None, backbone=dict(type='MobileNetV3', arch='large', out_indices=(16,), norm_cfg=dict(type='BN', eps=0.001, momentum=0.01)), head=dict(type='ClsHead', loss=dict(type='CrossEntropyLoss', loss_weight=1.0), with_avg_pool=True, in_channels=960, num_classes=1000))
""" API for yt.frontends.gamer """
""" API for yt.frontends.gamer """
# Generate permutations with a space def permutation_with_space_helper(input_val, output_val): if len(input_val) == 0: # Base condition to get a final output once the input string is empty final.append(output_val) return # Store the first element of the string and make decisions on it temp = input_val[0] # Recursively calling the fnc including the temp in the output permutation_with_space_helper(input_val[1:], output_val + temp) # Recursively calling the fnc including the temp and "_" in the output permutation_with_space_helper(input_val[1:], output_val + "_" + temp) def permutation_with_space(input_val): output_val = "" # Calling the helper function for i in range(len(input_val)): permutation_with_space_helper(input_val[:i] + input_val[i+1:], input_val[i]) final = [] permutation_with_space('abc') print(final)
def permutation_with_space_helper(input_val, output_val): if len(input_val) == 0: final.append(output_val) return temp = input_val[0] permutation_with_space_helper(input_val[1:], output_val + temp) permutation_with_space_helper(input_val[1:], output_val + '_' + temp) def permutation_with_space(input_val): output_val = '' for i in range(len(input_val)): permutation_with_space_helper(input_val[:i] + input_val[i + 1:], input_val[i]) final = [] permutation_with_space('abc') print(final)
"""Skeleton for 'itertools' stdlib module.""" class islice(object): def __init__(self, iterable, start, stop=None, step=None): """ :type iterable: collections.Iterable[T] :type start: numbers.Integral :type stop: numbers.Integral | None :type step: numbers.Integral | None :rtype: itertools.islice[T] """ pass
"""Skeleton for 'itertools' stdlib module.""" class Islice(object): def __init__(self, iterable, start, stop=None, step=None): """ :type iterable: collections.Iterable[T] :type start: numbers.Integral :type stop: numbers.Integral | None :type step: numbers.Integral | None :rtype: itertools.islice[T] """ pass
EXAMPLE_DOCS = [ # Collection stored as "docs" { '_data': 'one two', '_type': 'http://sharejs.org/types/textv1', '_v': 8, '_m': { 'mtime': 1415654366808, 'ctime': 1415654358668 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { '_data': 'XXX', '_type': 'http://sharejs.org/types/textv1', '_v': 4, '_m': { 'mtime': 1415654385628, 'ctime': 1415654381131 }, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a' } ] EXAMPLE_OPS = [ # Collection stored as "docs_ops" { 'op': None, 'v': 0, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 1, 'create': { 'type': 'http://sharejs.org/types/textv1', 'data': None }, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654358667 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v0', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 'o' ], 'v': 1, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 2, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654363751 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v1', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 1, 'n' ], 'v': 2, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 3, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654363838 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v2', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 2, 'e' ], 'v': 3, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 4, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654364007 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v3', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 3, ' ' ], 'v': 4, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 5, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654366367 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v4', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 4, 't' ], 'v': 5, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 6, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654366542 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v5', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 5, 'w' ], 'v': 6, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 7, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654366678 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v6', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': [ 6, 'o' ], 'v': 7, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 8, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654366808 }, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v7', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118' }, { 'op': None, 'v': 0, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 1, 'create': { 'type': 'http://sharejs.org/types/textv1', 'data': None }, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654381130 }, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v0', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a' }, { 'op': [ 'X' ], 'v': 1, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 2, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654384929 }, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v1', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a' }, { 'op': [ 1, 'X' ], 'v': 2, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 3, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654385266 }, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v2', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a' }, { 'op': [ 2, 'X' ], 'v': 3, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 4, 'preValidate': None, 'validate': None, 'm': { 'ts': 1415654385626 }, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v3', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a' } ] EXAMPLE_DOCS_6 = { '_id': '9a247ce9-b219-5f7d-b2c8-ef31661b38d7', 'data': { 'v': 20, 'meta': { 'mtime': 1413229471447.0, 'ctime': 1413229471447.0, }, 'snapshot': 'one two three four! ', 'type': 'text', } }
example_docs = [{'_data': 'one two', '_type': 'http://sharejs.org/types/textv1', '_v': 8, '_m': {'mtime': 1415654366808, 'ctime': 1415654358668}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'_data': 'XXX', '_type': 'http://sharejs.org/types/textv1', '_v': 4, '_m': {'mtime': 1415654385628, 'ctime': 1415654381131}, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a'}] example_ops = [{'op': None, 'v': 0, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 1, 'create': {'type': 'http://sharejs.org/types/textv1', 'data': None}, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654358667}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v0', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': ['o'], 'v': 1, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 2, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654363751}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v1', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [1, 'n'], 'v': 2, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 3, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654363838}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v2', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [2, 'e'], 'v': 3, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 4, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654364007}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v3', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [3, ' '], 'v': 4, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 5, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654366367}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v4', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [4, 't'], 'v': 5, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 6, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654366542}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v5', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [5, 'w'], 'v': 6, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 7, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654366678}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v6', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': [6, 'o'], 'v': 7, 'src': '94ae709f9736c24d821301de2dfc71df', 'seq': 8, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654366808}, '_id': '26aabd89-541b-5c02-9e6a-ad332ba43118 v7', 'name': '26aabd89-541b-5c02-9e6a-ad332ba43118'}, {'op': None, 'v': 0, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 1, 'create': {'type': 'http://sharejs.org/types/textv1', 'data': None}, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654381130}, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v0', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a'}, {'op': ['X'], 'v': 1, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 2, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654384929}, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v1', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a'}, {'op': [1, 'X'], 'v': 2, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 3, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654385266}, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v2', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a'}, {'op': [2, 'X'], 'v': 3, 'src': '166028c1b14818475eec6fab9720af7b', 'seq': 4, 'preValidate': None, 'validate': None, 'm': {'ts': 1415654385626}, '_id': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a v3', 'name': '9a68120a-d3c5-5ba6-b399-fe39e8f2028a'}] example_docs_6 = {'_id': '9a247ce9-b219-5f7d-b2c8-ef31661b38d7', 'data': {'v': 20, 'meta': {'mtime': 1413229471447.0, 'ctime': 1413229471447.0}, 'snapshot': 'one two three four! ', 'type': 'text'}}
def insert_line(file, text, after=None, before=None, past=None, once=True): with open(file) as f: lines = iter(f.readlines()) with open(file, 'w') as f: if past: for line in lines: f.write(line) if re.match(past, line): break for line in lines: if before and re.match(before, line): f.write(text + '\n') if once: f.write(line) break f.write(line) if after and re.match(after, line): f.write(text + '\n') if once: break for line in lines: f.write(line)
def insert_line(file, text, after=None, before=None, past=None, once=True): with open(file) as f: lines = iter(f.readlines()) with open(file, 'w') as f: if past: for line in lines: f.write(line) if re.match(past, line): break for line in lines: if before and re.match(before, line): f.write(text + '\n') if once: f.write(line) break f.write(line) if after and re.match(after, line): f.write(text + '\n') if once: break for line in lines: f.write(line)
count = int(input()) tux = [" _~_ ", " (o o) ", " / V \ ", "/( _ )\\ ", " ^^ ^^ "] for i in tux: print(i * count)
count = int(input()) tux = [' _~_ ', ' (o o) ', ' / V \\ ', '/( _ )\\ ', ' ^^ ^^ '] for i in tux: print(i * count)
class Node(): ''' The DiNode class is specifically designed for altering path search. - Active and passive out nodes, for easily iteratively find new nodes in path. - Marks for easy look up edges already visited (earlier Schlaufen) / nodes in path-creation already visited - The edge-marks have the Schlaufen number saved, such that later a reconstruction of the Schlaufen found is possible ''' def __init__(self, id, degree, totalnodes): self.id = id self.degree = degree self.passive_outnodes = set(range(totalnodes)) self.passive_outnodes.remove(id) self.passive_outnodes_removed_selfloop_crossarrow = 1 # for graph correctness check self.outnodes = set() # marks self.active_visited = False self.passive_visited = False # marked edges self.active_marked = {} # dictionary outarrows as key, number of schlaufe as Value self.passive_marked = {} def add_outedge(self, out_node): self.outnodes.add(out_node) def add_passive_outedge(self, out_node): self.passive_outnodes.add(out_node) def del_outedge(self, out_node): if not (out_node in self.outnodes): raise ValueError('outnode subtraction error') else: self.outnodes.remove(out_node) def del_passive_outedge(self, out_node): if not (out_node in self.passive_outnodes): raise ValueError('outnode subtraction error') else: self.passive_outnodes.remove(out_node)
class Node: """ The DiNode class is specifically designed for altering path search. - Active and passive out nodes, for easily iteratively find new nodes in path. - Marks for easy look up edges already visited (earlier Schlaufen) / nodes in path-creation already visited - The edge-marks have the Schlaufen number saved, such that later a reconstruction of the Schlaufen found is possible """ def __init__(self, id, degree, totalnodes): self.id = id self.degree = degree self.passive_outnodes = set(range(totalnodes)) self.passive_outnodes.remove(id) self.passive_outnodes_removed_selfloop_crossarrow = 1 self.outnodes = set() self.active_visited = False self.passive_visited = False self.active_marked = {} self.passive_marked = {} def add_outedge(self, out_node): self.outnodes.add(out_node) def add_passive_outedge(self, out_node): self.passive_outnodes.add(out_node) def del_outedge(self, out_node): if not out_node in self.outnodes: raise value_error('outnode subtraction error') else: self.outnodes.remove(out_node) def del_passive_outedge(self, out_node): if not out_node in self.passive_outnodes: raise value_error('outnode subtraction error') else: self.passive_outnodes.remove(out_node)
class Point2D: def __init__(self,x,y): self.x = x self.y = y def __eq__(self, value): return self.x == value.x and self.y == value.y def __hash__(self): return hash((self.x,self.y))
class Point2D: def __init__(self, x, y): self.x = x self.y = y def __eq__(self, value): return self.x == value.x and self.y == value.y def __hash__(self): return hash((self.x, self.y))
""" This is pure Python implementation of linear search algorithm For doctests run following command: python3 -m doctest -v linear_search.py For manual testing run: python3 linear_search.py """ def linear_search(sequence: list, target: int) -> int: """A pure Python implementation of a linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param target: item value to search :return: index of found item or None if item is not found Examples: >>> linear_search([0, 5, 7, 10, 15], 0) 0 >>> linear_search([0, 5, 7, 10, 15], 15) 4 >>> linear_search([0, 5, 7, 10, 15], 5) 1 >>> linear_search([0, 5, 7, 10, 15], 6) -1 """ for index, item in enumerate(sequence): if item == target: return index return -1 def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int: """ A pure Python implementation of a recursive linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param low: Lower bound of the array :param high: Higher bound of the array :param target: The element to be found :return: Index of the key or -1 if key not found Examples: >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 0) 0 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 700) 4 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 30) 1 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, -6) -1 """ if not (0 <= high < len(sequence) and 0 <= low < len(sequence)): raise Exception("Invalid upper or lower bound!") if high < low: return -1 if sequence[low] == target: return low if sequence[high] == target: return high return rec_linear_search(sequence, low + 1, high - 1, target) if __name__ == "__main__": user_input = input("Enter numbers separated by comma:\n").strip() sequence = [int(item.strip()) for item in user_input.split(",")] target = int(input("Enter a single number to be found in the list:\n").strip()) result = linear_search(sequence, target) if result != -1: print(f"linear_search({sequence}, {target}) = {result}") else: print(f"{target} was not found in {sequence}")
""" This is pure Python implementation of linear search algorithm For doctests run following command: python3 -m doctest -v linear_search.py For manual testing run: python3 linear_search.py """ def linear_search(sequence: list, target: int) -> int: """A pure Python implementation of a linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param target: item value to search :return: index of found item or None if item is not found Examples: >>> linear_search([0, 5, 7, 10, 15], 0) 0 >>> linear_search([0, 5, 7, 10, 15], 15) 4 >>> linear_search([0, 5, 7, 10, 15], 5) 1 >>> linear_search([0, 5, 7, 10, 15], 6) -1 """ for (index, item) in enumerate(sequence): if item == target: return index return -1 def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int: """ A pure Python implementation of a recursive linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param low: Lower bound of the array :param high: Higher bound of the array :param target: The element to be found :return: Index of the key or -1 if key not found Examples: >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 0) 0 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 700) 4 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 30) 1 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, -6) -1 """ if not (0 <= high < len(sequence) and 0 <= low < len(sequence)): raise exception('Invalid upper or lower bound!') if high < low: return -1 if sequence[low] == target: return low if sequence[high] == target: return high return rec_linear_search(sequence, low + 1, high - 1, target) if __name__ == '__main__': user_input = input('Enter numbers separated by comma:\n').strip() sequence = [int(item.strip()) for item in user_input.split(',')] target = int(input('Enter a single number to be found in the list:\n').strip()) result = linear_search(sequence, target) if result != -1: print(f'linear_search({sequence}, {target}) = {result}') else: print(f'{target} was not found in {sequence}')
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeTwoLists(self, a, b): if a is None: return b if b is None: return a if a.val > b.val: a, b = b, a result = a result_head = result a = a.next while a is not None or b is not None: a_val = a.val if a is not None else math.inf b_val = b.val if b is not None else math.inf if a_val < b_val: result.next = a a = a.next else: result.next = b b = b.next result = result.next return result_head
class Solution: def merge_two_lists(self, a, b): if a is None: return b if b is None: return a if a.val > b.val: (a, b) = (b, a) result = a result_head = result a = a.next while a is not None or b is not None: a_val = a.val if a is not None else math.inf b_val = b.val if b is not None else math.inf if a_val < b_val: result.next = a a = a.next else: result.next = b b = b.next result = result.next return result_head
""" package information : Core package Author: Shanmugathas Vigneswaran email: shanmugathas.vigneswaran@outlook.fr Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) Licence: https://creativecommons.org/licenses/by-nc/4.0/ UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND ONLY TO THE EXTENT OF ANY RIGHTS HELD IN THE LICENSED WORK BY THE LICENSOR. THE LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MARKETABILITY, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. """ __all__ = ["controller", "uv_helpers"]
""" package information : Core package Author: Shanmugathas Vigneswaran email: shanmugathas.vigneswaran@outlook.fr Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) Licence: https://creativecommons.org/licenses/by-nc/4.0/ UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND ONLY TO THE EXTENT OF ANY RIGHTS HELD IN THE LICENSED WORK BY THE LICENSOR. THE LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MARKETABILITY, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. """ __all__ = ['controller', 'uv_helpers']
# DEFAULT_ASSET_URL="https://totogoto.com/assets/python_project/images/" DEFAULT_ASSET_URL="https://cdn.jsdelivr.net/gh/totogoto/assets/" DEFAULT_OBJECTS = [ "1", "2", "3", "4", "5", "apple_goal", "apple", "around3_sol", "banana_goal", "banana", "beeper_goal", "box_goal", "box", "bricks", "bridge", "carrot_goal", "carrot", "daisy_goal", "daisy", "dandelion_goal", "dandelion", "desert", "east_goal", "east_grid", "east", "external_link", "favicon", "fence_double", "fence_left", "fence_right", "fence_vertical", "fire1", "fire2", "fire", "flame1", "flame2", "flame3", "flame4", "flame5", "flame6", "fromage", "grass_bottom_left", "grass_bottom_right", "grass", "grass_top_left", "grass_top_right", "gravel", "green_home_tile", "highlight", "house", "hurdles", "ice", "leaf_goal", "leaf", "logs", "magnifying_no", "magnifying_yes", "mailto", "mort", "mud", "north", "not_ok", "ok", "open_program", "orange_goal", "orange", "ouch", "pale_grass", "pause", "plain_e", "plain_n", "plain_s", "plain_w", "play", "poison", "racing_flag", "racing_flag_small", "rat_e", "rat_n", "rat_s", "rat_w", "reeborg_judkis", "reload", "resize", "reverse_step", "save_program", "scorpion", "seed", "simple_path", "sp_e", "sp_n", "sp_s", "sp_w", "square_goal", "square", "stalactite2", "stalactite", "star_goal", "star", "step", "stop", "strawberry_goal", "strawberry", "student", "teleport", "tile_colour", "token_goal", "token", "transparent_tile", "triangle_goal", "triangle", "tulip_goal", "tulip", "water2", "water3", "water4", "water5", "water6", "water_bucket", "water", "east_arrow", "north_arrow", "west_arrow", "south_arrow", "envelope", "envelope-30", "envelope-sprite", "speech_bubble", "robot-yellow" ] DEFAULT_TILE_MAP = {tile: "{}{}.png".format(DEFAULT_ASSET_URL, tile) for tile in DEFAULT_OBJECTS }
default_asset_url = 'https://cdn.jsdelivr.net/gh/totogoto/assets/' default_objects = ['1', '2', '3', '4', '5', 'apple_goal', 'apple', 'around3_sol', 'banana_goal', 'banana', 'beeper_goal', 'box_goal', 'box', 'bricks', 'bridge', 'carrot_goal', 'carrot', 'daisy_goal', 'daisy', 'dandelion_goal', 'dandelion', 'desert', 'east_goal', 'east_grid', 'east', 'external_link', 'favicon', 'fence_double', 'fence_left', 'fence_right', 'fence_vertical', 'fire1', 'fire2', 'fire', 'flame1', 'flame2', 'flame3', 'flame4', 'flame5', 'flame6', 'fromage', 'grass_bottom_left', 'grass_bottom_right', 'grass', 'grass_top_left', 'grass_top_right', 'gravel', 'green_home_tile', 'highlight', 'house', 'hurdles', 'ice', 'leaf_goal', 'leaf', 'logs', 'magnifying_no', 'magnifying_yes', 'mailto', 'mort', 'mud', 'north', 'not_ok', 'ok', 'open_program', 'orange_goal', 'orange', 'ouch', 'pale_grass', 'pause', 'plain_e', 'plain_n', 'plain_s', 'plain_w', 'play', 'poison', 'racing_flag', 'racing_flag_small', 'rat_e', 'rat_n', 'rat_s', 'rat_w', 'reeborg_judkis', 'reload', 'resize', 'reverse_step', 'save_program', 'scorpion', 'seed', 'simple_path', 'sp_e', 'sp_n', 'sp_s', 'sp_w', 'square_goal', 'square', 'stalactite2', 'stalactite', 'star_goal', 'star', 'step', 'stop', 'strawberry_goal', 'strawberry', 'student', 'teleport', 'tile_colour', 'token_goal', 'token', 'transparent_tile', 'triangle_goal', 'triangle', 'tulip_goal', 'tulip', 'water2', 'water3', 'water4', 'water5', 'water6', 'water_bucket', 'water', 'east_arrow', 'north_arrow', 'west_arrow', 'south_arrow', 'envelope', 'envelope-30', 'envelope-sprite', 'speech_bubble', 'robot-yellow'] default_tile_map = {tile: '{}{}.png'.format(DEFAULT_ASSET_URL, tile) for tile in DEFAULT_OBJECTS}
def main(): with open('test.txt','rt') as infile: test2 = infile.read() test1 ='This is a test of the emergency text system' print(test1 == test2) if __name__ == '__main__': main()
def main(): with open('test.txt', 'rt') as infile: test2 = infile.read() test1 = 'This is a test of the emergency text system' print(test1 == test2) if __name__ == '__main__': main()
# Enter your code here. Read input from STDIN. Print output to STDOUT testCases = int(input()) for i in range(testCases): word = input() for j in range(len(word)): if j%2 == 0: print(word[j], end='') print(" ", end="") for j in range(len(word)): if j%2 !=0 : print(word[j], end='') print('')
test_cases = int(input()) for i in range(testCases): word = input() for j in range(len(word)): if j % 2 == 0: print(word[j], end='') print(' ', end='') for j in range(len(word)): if j % 2 != 0: print(word[j], end='') print('')
# # gambit # # This file contains the information to make the mesh for a subset of the original point data set. # # # The original data sets are in csv format and are for 6519 observation points. # 1. `Grav_MeasEs.csv` contains the cartesian coordinates of the observation points (m). # 2. `Grav_gz.csv` contains the Bouger corrected gravity measurements ( micro m/s^2). # 3. `Grav_acc.csv` cotains the measurement accuracy (micro m/s^2). # big_gravity_data_file = "Grav_gz.csv" big_acc_data_file = "Grav_acc.csv" big_obsPts_file = "Grav_MeasEs.csv" # # The inversion code has a measurement scale factor so it is not absolutely necessary # to have the same units for the gravity measurments. The scale factor conversts the # measurements to m/s^2. It is assumed that the spatial measurements are in m. # # The size of the data sets can be reduced. The new arrays contain the first element and # then in steps of "pick" . # pick = 4 # # The new small data file names # gravity_data_file = "Grav_small_gz.csv" accuracy_data_file = "Grav_small_acc.csv" obsPts_file = "Grav_small_MeasEs.csv" # # Element size at observation points depends on the distance to its nearest neighbour. # To make the ground variable mesh, the minimum nearest neighbour distance is computed for each observation point # and recorded in the file minDist_file = "Grav_small_minDist.csv" # # # GMSH mesh making parameters # # A bound for the maximum nearest neighbour distance. This value will be used to compute element size for any point # that has no nearest neighbour closer. maxDist = 5000 # # For each observatio point, element length is, in general # nearest neighbour distance / spacing0 # # For nearest neighbour distance < mindist1, element length is, # nearest neighbour distance / spacing1 # # For nearest neighbour distance < mindist1, element length is, # nearest neighbour distance / spacing2 # mindist1 = 500 mindist2 = 100 spacing0 = 4 spacing1 = 3 spacing2 = 2 # # The core area is 1.01*span of observation points in the x and y directions. # Ground level is at 0m and is horizontal. There is a core ground region and core air region. groundLevel = 0 coreDepth = - 20000 coreAir = 10000 # # mesh sizes vary. # Mesh size at the top of the core air region MCtop = 5000 # Mesh size at the bottom of the core ground region MCbase = 5000 # mesh size at the core ground region. This is probably over ruled by the mesh size of the observation points. MCground = 5000 # # The buffer region has different element lengths. # Mesh size at the tob of the buffer in the air MBtop = 20000 # Mesh size at the edge of the buffer region at ground level MBbase = 20000 # Mesh size at the base of the buffer region. MBground = 10000 # Name for the geo file. geo_name = "smallPointMesh.geo"
big_gravity_data_file = 'Grav_gz.csv' big_acc_data_file = 'Grav_acc.csv' big_obs_pts_file = 'Grav_MeasEs.csv' pick = 4 gravity_data_file = 'Grav_small_gz.csv' accuracy_data_file = 'Grav_small_acc.csv' obs_pts_file = 'Grav_small_MeasEs.csv' min_dist_file = 'Grav_small_minDist.csv' max_dist = 5000 mindist1 = 500 mindist2 = 100 spacing0 = 4 spacing1 = 3 spacing2 = 2 ground_level = 0 core_depth = -20000 core_air = 10000 m_ctop = 5000 m_cbase = 5000 m_cground = 5000 m_btop = 20000 m_bbase = 20000 m_bground = 10000 geo_name = 'smallPointMesh.geo'
""" 148. Sort List Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 """ class Solution: def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: return head def merge(l1, l2): dummy = ListNode(0) cur = dummy while l1 and l2: if l1.val < l2.val: cur.next = l1 l1 = l1.next else: cur.next = l2 l2 = l2.next cur = cur.next if l1: cur.next = l1 else: cur.next = l2 return dummy.next slow = head fast = head while fast.next and fast.next.next: fast = fast.next.next slow = slow.next r = slow.next slow.next = None return merge(self.sortList(head),self.sortList(r)) class Solution(object): def merge(self, h1, h2): dummy = tail = ListNode(None) while h1 and h2: if h1.val < h2.val: tail.next, tail, h1 = h1, h1, h1.next else: tail.next, tail, h2 = h2, h2, h2.next tail.next = h1 or h2 return dummy.next def sortList(self, head): if not head or not head.next: return head pre, slow, fast = None, head, head while fast and fast.next: pre, slow, fast = slow, slow.next, fast.next.next pre.next = None return self.merge(*map(self.sortList, (head, slow)))
""" 148. Sort List Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 """ class Solution: def sort_list(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: return head def merge(l1, l2): dummy = list_node(0) cur = dummy while l1 and l2: if l1.val < l2.val: cur.next = l1 l1 = l1.next else: cur.next = l2 l2 = l2.next cur = cur.next if l1: cur.next = l1 else: cur.next = l2 return dummy.next slow = head fast = head while fast.next and fast.next.next: fast = fast.next.next slow = slow.next r = slow.next slow.next = None return merge(self.sortList(head), self.sortList(r)) class Solution(object): def merge(self, h1, h2): dummy = tail = list_node(None) while h1 and h2: if h1.val < h2.val: (tail.next, tail, h1) = (h1, h1, h1.next) else: (tail.next, tail, h2) = (h2, h2, h2.next) tail.next = h1 or h2 return dummy.next def sort_list(self, head): if not head or not head.next: return head (pre, slow, fast) = (None, head, head) while fast and fast.next: (pre, slow, fast) = (slow, slow.next, fast.next.next) pre.next = None return self.merge(*map(self.sortList, (head, slow)))
i = 1 while i < 6: print(i) if i == 3: break i += 1 i = 1 while i < 6: print(i) if i == 3: continue i += 1 fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": continue print(x)
i = 1 while i < 6: print(i) if i == 3: break i += 1 i = 1 while i < 6: print(i) if i == 3: continue i += 1 fruits = ['apple', 'banana', 'cherry'] for x in fruits: print(x) if x == 'banana': break fruits = ['apple', 'banana', 'cherry'] for x in fruits: if x == 'banana': continue print(x)
def config(): return None def watch(): return None
def config(): return None def watch(): return None
""" This file contains all of the display functions for model management """ def display_init_model_root(root): """display function for creating new model folder""" print("Created model directory at %s" % (root)) def display_init_model_db(db_root): """display function for initializing the model db""" print("Created model database at %s" % (db_root)) def display_imported_model(name): """display function for importing a model""" print("Model %s imported successfully" % (name))
""" This file contains all of the display functions for model management """ def display_init_model_root(root): """display function for creating new model folder""" print('Created model directory at %s' % root) def display_init_model_db(db_root): """display function for initializing the model db""" print('Created model database at %s' % db_root) def display_imported_model(name): """display function for importing a model""" print('Model %s imported successfully' % name)
"""Class implementation for type name interface. """ class TypeNameInterface: _type_name: str @property def type_name(self) -> str: """ Get this instance expression's type name. Returns ------- type_name : str This instance expression's type name. """ return self._type_name
"""Class implementation for type name interface. """ class Typenameinterface: _type_name: str @property def type_name(self) -> str: """ Get this instance expression's type name. Returns ------- type_name : str This instance expression's type name. """ return self._type_name
def transposition(key, order, order_name): new_key = "" for pos in order: new_key += key[pos-1] print("Permuted "+ order_name +" = "+ new_key) return new_key def P10(key): P10_order = [3, 5, 2, 7, 4, 10, 1, 9, 8, 6] P10_key = transposition(key, P10_order, "P10") return P10_key def P8(LS1_key): P8_order = [6, 3, 7, 4, 8, 5, 10, 9] P8_key = transposition(LS1_key, P8_order, "P8") return P8_key def LS1(P10_key): P10_key_left = P10_key[:5] P10_key_right = P10_key[5:] LS1_key_left = P10_key_left[1:5] + P10_key_left[0] LS1_key_right = P10_key_right[1:5] + P10_key_right[0] LS1_key = LS1_key_left+LS1_key_right #print("LS-1 = " + LS1_key) return LS1_key def IP(LS1_key): IP_order = [2, 6, 3, 1, 4, 8, 5, 7] IP_key = transposition(LS1_key, IP_order, "IP") return IP_key def IP_inv(LS1_key): IP_inv_order = [4, 1, 3, 5, 7, 2, 8, 6] IP_inv_key = transposition(LS1_key, IP_inv_order, "IP-1") return IP_inv_key def key_gen(key): LS1_key = LS1(P10(key)) key_1 = P8(LS1_key) key_2 = P8(LS1(LS1_key)) #print("Key-1:"+ key_1 +"\nKey-2:"+ key_2) return (key_1,key_2) def encrypt_plain(plain_text): enc = IP(plain_text) dec = IP_inv(enc) #print("ENC:"+ enc +"\nDEC:"+ dec) return(enc, dec) def f_key(enc_plain, SK): L = enc_plain[:4] R = enc_plain[4:] F = F_func(R, SK) #print(L) #print(R) f = A_xor_B(L, SK) + R #print(f) return f def F_func(R, SK): EP_order = [4, 1, 2, 3, 2, 3, 4, 1] EP_key = transposition(R, EP_order, "EP") P = A_xor_B(EP_key, SK) P4 = s_box(P) return P4 def A_xor_B(A,B): bit_xor = "" for i in range(len(A)): bit_xor += str ( int(A[i]) ^ int(B[i]) ) #print(bit_xor) return bit_xor def s_box(P): P0 = P[:4] P1 = P[4:] S0_order = [[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]] S1_order = [[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]] P4_order = [2, 4, 3, 1] S0 = sbox_calc(P0, S0_order) S1 = sbox_calc(P1, S1_order) P4 = transposition( S0+S1, P4_order, "P4" ) #print(P4) return P4 def sbox_calc(P, S): row = int( (P[0] + P[3]) , 2 ) col = int( (P[1] + P[2]) , 2 ) s_val = bin(S[row][col])[2:].zfill(2) return(s_val) def SW(key): key_new = key[:4] + key[4:] #print(key_new) return key_new option = input("\n1. Encode\n2. Decode\nEnter your option:") key = input("Enter the key:") inp = input("Enter the text:") key_1, key_2 = key_gen(key) #enc_plain, dec_plain = encrypt_plain(plain_text) if option == '1': print() IP_1 = IP(inp) fk_1 = f_key(IP_1, key_1) switch = SW(fk_1) fk_2 = f_key(switch, key_2) IP_2 = IP_inv(fk_2) print("\nEncoded = " + IP_2) else: print() plain_text = inp IP_1 = IP(plain_text) fk_2 = f_key(IP_1, key_2) switch = SW(fk_2) fk_1 = f_key(switch, key_1) IP_2 = IP_inv(fk_1) print("\nDecoded = " + IP_2) # 1010000010 # 10111101
def transposition(key, order, order_name): new_key = '' for pos in order: new_key += key[pos - 1] print('Permuted ' + order_name + ' = ' + new_key) return new_key def p10(key): p10_order = [3, 5, 2, 7, 4, 10, 1, 9, 8, 6] p10_key = transposition(key, P10_order, 'P10') return P10_key def p8(LS1_key): p8_order = [6, 3, 7, 4, 8, 5, 10, 9] p8_key = transposition(LS1_key, P8_order, 'P8') return P8_key def ls1(P10_key): p10_key_left = P10_key[:5] p10_key_right = P10_key[5:] ls1_key_left = P10_key_left[1:5] + P10_key_left[0] ls1_key_right = P10_key_right[1:5] + P10_key_right[0] ls1_key = LS1_key_left + LS1_key_right return LS1_key def ip(LS1_key): ip_order = [2, 6, 3, 1, 4, 8, 5, 7] ip_key = transposition(LS1_key, IP_order, 'IP') return IP_key def ip_inv(LS1_key): ip_inv_order = [4, 1, 3, 5, 7, 2, 8, 6] ip_inv_key = transposition(LS1_key, IP_inv_order, 'IP-1') return IP_inv_key def key_gen(key): ls1_key = ls1(p10(key)) key_1 = p8(LS1_key) key_2 = p8(ls1(LS1_key)) return (key_1, key_2) def encrypt_plain(plain_text): enc = ip(plain_text) dec = ip_inv(enc) return (enc, dec) def f_key(enc_plain, SK): l = enc_plain[:4] r = enc_plain[4:] f = f_func(R, SK) f = a_xor_b(L, SK) + R return f def f_func(R, SK): ep_order = [4, 1, 2, 3, 2, 3, 4, 1] ep_key = transposition(R, EP_order, 'EP') p = a_xor_b(EP_key, SK) p4 = s_box(P) return P4 def a_xor_b(A, B): bit_xor = '' for i in range(len(A)): bit_xor += str(int(A[i]) ^ int(B[i])) return bit_xor def s_box(P): p0 = P[:4] p1 = P[4:] s0_order = [[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]] s1_order = [[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]] p4_order = [2, 4, 3, 1] s0 = sbox_calc(P0, S0_order) s1 = sbox_calc(P1, S1_order) p4 = transposition(S0 + S1, P4_order, 'P4') return P4 def sbox_calc(P, S): row = int(P[0] + P[3], 2) col = int(P[1] + P[2], 2) s_val = bin(S[row][col])[2:].zfill(2) return s_val def sw(key): key_new = key[:4] + key[4:] return key_new option = input('\n1. Encode\n2. Decode\nEnter your option:') key = input('Enter the key:') inp = input('Enter the text:') (key_1, key_2) = key_gen(key) if option == '1': print() ip_1 = ip(inp) fk_1 = f_key(IP_1, key_1) switch = sw(fk_1) fk_2 = f_key(switch, key_2) ip_2 = ip_inv(fk_2) print('\nEncoded = ' + IP_2) else: print() plain_text = inp ip_1 = ip(plain_text) fk_2 = f_key(IP_1, key_2) switch = sw(fk_2) fk_1 = f_key(switch, key_1) ip_2 = ip_inv(fk_1) print('\nDecoded = ' + IP_2)
""" Add a counter at a iterable and return the this counter . """ # teste fruits = ["apple", "pineapple", "lemon", "watermelon", "grapes"] enumerate_list = enumerate(fruits) # print(list(enumerate_list)) for index, element in enumerate_list: filename = f"file{index}.jpg" print(filename)
""" Add a counter at a iterable and return the this counter . """ fruits = ['apple', 'pineapple', 'lemon', 'watermelon', 'grapes'] enumerate_list = enumerate(fruits) for (index, element) in enumerate_list: filename = f'file{index}.jpg' print(filename)
class laptop: brand=[] year=[] ram=[] def __init__(self,brand,year,ram,cost): self.brand.append(brand) self.year.append(year) self.ram.append(ram) self.cost.append(cost)
class Laptop: brand = [] year = [] ram = [] def __init__(self, brand, year, ram, cost): self.brand.append(brand) self.year.append(year) self.ram.append(ram) self.cost.append(cost)
"""uVoyeur Application Bus""" class PublishFailures(Exception): delimiter = '\n' def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) self._exceptions = list() def capture_exception(self): self._exceptions.append(sys.exc_info()[1]) def get_instances(self): return self._exceptions[:] def __str__(self): exception_strings = map(repr, self.get_instances()) return self.delimiter.join(exception_strings) __repr__ = __str__ def __bool__(self): return bool(self._exceptions) __nonzero__ = __bool__ class Bus(object): def __init__(self): self.listeners = dict( [(channel, set()) for channel in ('main')]) print("Bus() initialized.") def subscribe(self, channel, callback): if channel not in self.listeners: self.listeners[channel] = set() self.listeners[channel].add(callback) def unsubscribe(self, channel, callback): listeners = self.listeners.get(channel) if listeners and callback in listeners: listeners.discard(callback) def publish(self, channel, *args, **kwargs): """Return the output of all subscribers in an array.""" if channel not in self.listeners: return [] exc = PublishFailures() output = [] listeners = self.listeners.get(channel) for listener in listeners: try: output.append(listener(*args, **kwargs)) except KeyboardInterrupt: raise except SystemExit: # If there were previous (non SystemExit) errors, make sure exit code in non-zero e = sys.exc_info()[1] if exc and e.code == 0: e.code = 1 # propigate SystemExit raise except: exc.capture_exception() # and continue publishing if exc: raise exc return output ## Local Variables: ## mode: python ## End:
"""uVoyeur Application Bus""" class Publishfailures(Exception): delimiter = '\n' def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **kwargs) self._exceptions = list() def capture_exception(self): self._exceptions.append(sys.exc_info()[1]) def get_instances(self): return self._exceptions[:] def __str__(self): exception_strings = map(repr, self.get_instances()) return self.delimiter.join(exception_strings) __repr__ = __str__ def __bool__(self): return bool(self._exceptions) __nonzero__ = __bool__ class Bus(object): def __init__(self): self.listeners = dict([(channel, set()) for channel in 'main']) print('Bus() initialized.') def subscribe(self, channel, callback): if channel not in self.listeners: self.listeners[channel] = set() self.listeners[channel].add(callback) def unsubscribe(self, channel, callback): listeners = self.listeners.get(channel) if listeners and callback in listeners: listeners.discard(callback) def publish(self, channel, *args, **kwargs): """Return the output of all subscribers in an array.""" if channel not in self.listeners: return [] exc = publish_failures() output = [] listeners = self.listeners.get(channel) for listener in listeners: try: output.append(listener(*args, **kwargs)) except KeyboardInterrupt: raise except SystemExit: e = sys.exc_info()[1] if exc and e.code == 0: e.code = 1 raise except: exc.capture_exception() if exc: raise exc return output
dataset_type = 'TextDetDataset' data_root = 'data/synthtext' train = dict( type=dataset_type, ann_file=f'{data_root}/instances_training.lmdb', loader=dict( type='AnnFileLoader', repeat=1, file_format='lmdb', parser=dict( type='LineJsonParser', keys=['file_name', 'height', 'width', 'annotations'])), img_prefix=f'{data_root}/imgs', pipeline=None) train_list = [train] test_list = [train]
dataset_type = 'TextDetDataset' data_root = 'data/synthtext' train = dict(type=dataset_type, ann_file=f'{data_root}/instances_training.lmdb', loader=dict(type='AnnFileLoader', repeat=1, file_format='lmdb', parser=dict(type='LineJsonParser', keys=['file_name', 'height', 'width', 'annotations'])), img_prefix=f'{data_root}/imgs', pipeline=None) train_list = [train] test_list = [train]
class Solution: def judgeSquareSum(self, c: int) -> bool: left = 0 right = int(c ** 0.5) while left <= right: cur = left ** 2 + right ** 2 if cur < c: left += 1 elif cur > c: right -= 1 else: return True return False
class Solution: def judge_square_sum(self, c: int) -> bool: left = 0 right = int(c ** 0.5) while left <= right: cur = left ** 2 + right ** 2 if cur < c: left += 1 elif cur > c: right -= 1 else: return True return False
#!/usr/bin/env python3 def score_word(word): score = 0 for letter in word: # add code here pass return score
def score_word(word): score = 0 for letter in word: pass return score
""" Advent of Code 2021: Day 02 Part 1 tldr: Find two dimensional ending position """ input_file = "input.solution" totals = { "forward": 0, "down": 0, "up": 0, } with open(input_file, "r") as file: for line in file: direction, magnitude = line.split() totals[direction] += int(magnitude) result = (totals["down"] - totals["up"]) * totals["forward"] print(result)
""" Advent of Code 2021: Day 02 Part 1 tldr: Find two dimensional ending position """ input_file = 'input.solution' totals = {'forward': 0, 'down': 0, 'up': 0} with open(input_file, 'r') as file: for line in file: (direction, magnitude) = line.split() totals[direction] += int(magnitude) result = (totals['down'] - totals['up']) * totals['forward'] print(result)
#!/bin/python3 # https://www.hackerrank.com/challenges/alphabet-rangoli/problem #ll=limitting letter #sl=starting letter #df=deduction factor #cd=character difference #rl=resulting letter while True: ll=ord(input("Enter the limitting letter in the pattern:> ")) sl=65 if ll in range(65,91) else (97 if ll in range(97,123) else None) if sl: break print("Enter a valid input.") print("See the alphabet pattern:>\n") for df in range(sl-ll,ll-sl+1): for cd in range(sl-ll,ll-sl+1): rl=sl+abs(cd)+abs(df) if(cd==ll-sl): print(chr(rl) if rl<=ll else '-') else: print(chr(rl) if rl<=ll else '-',end="-")
while True: ll = ord(input('Enter the limitting letter in the pattern:> ')) sl = 65 if ll in range(65, 91) else 97 if ll in range(97, 123) else None if sl: break print('Enter a valid input.') print('See the alphabet pattern:>\n') for df in range(sl - ll, ll - sl + 1): for cd in range(sl - ll, ll - sl + 1): rl = sl + abs(cd) + abs(df) if cd == ll - sl: print(chr(rl) if rl <= ll else '-') else: print(chr(rl) if rl <= ll else '-', end='-')
# initialize step_end step_end = 25 with plt.xkcd(): # initialize the figure plt.figure() # loop for step_end steps for step in range(step_end): t = step * dt i = i_mean * (1 + np.sin((t * 2 * np.pi) / 0.01)) plt.plot(t, i, 'ko') plt.title('Synaptic Input $I(t)$') plt.xlabel('time (s)') plt.ylabel(r'$I$ (A)') plt.show()
step_end = 25 with plt.xkcd(): plt.figure() for step in range(step_end): t = step * dt i = i_mean * (1 + np.sin(t * 2 * np.pi / 0.01)) plt.plot(t, i, 'ko') plt.title('Synaptic Input $I(t)$') plt.xlabel('time (s)') plt.ylabel('$I$ (A)') plt.show()
S = list(map(str, input())) for i in range(len(S)): if S[i] == '6': S[i] = '9' elif S[i] == '9': S[i] = '6' S = reversed(S) print("".join(S))
s = list(map(str, input())) for i in range(len(S)): if S[i] == '6': S[i] = '9' elif S[i] == '9': S[i] = '6' s = reversed(S) print(''.join(S))
global_variable = "global_variable" print(global_variable + " printed at the module level.") class GeoPoint(): class_attribute = "class_attribute" print(class_attribute + " printed at the class level.") def __init__(self): global global_variable print(global_variable + " printed at the method level.") print(GeoPoint.class_attribute + " printed at the method level.") print(class_attribute + " printed at the method level without class.") self.instance_variable = "self.instance_variable" print(self.instance_variable + " printed at the method level.") method_local_variable = "method_local_variable" print(method_local_variable + " printed at the method level.") def another_method(self): # No access to method_local_variable here print(method_local_variable + " printed within another method.")
global_variable = 'global_variable' print(global_variable + ' printed at the module level.') class Geopoint: class_attribute = 'class_attribute' print(class_attribute + ' printed at the class level.') def __init__(self): global global_variable print(global_variable + ' printed at the method level.') print(GeoPoint.class_attribute + ' printed at the method level.') print(class_attribute + ' printed at the method level without class.') self.instance_variable = 'self.instance_variable' print(self.instance_variable + ' printed at the method level.') method_local_variable = 'method_local_variable' print(method_local_variable + ' printed at the method level.') def another_method(self): print(method_local_variable + ' printed within another method.')
#!/usr/bin/env python3 #!/usr/bin/python str1 = 'test1' if str1 == 'test1' or str1 == 'test2': print('1 or 2') elif str1 == 'test3' or str1 == 'test4': print("3 or 4") else: print("else") str1 = '' if str1: print(("'%s' is True" % str1)) else: print(("'%s' is False" % str1)) str1 = ' ' if str1: print(("'%s' is True" % str1)) else: print(("'%s' is False" % str1))
str1 = 'test1' if str1 == 'test1' or str1 == 'test2': print('1 or 2') elif str1 == 'test3' or str1 == 'test4': print('3 or 4') else: print('else') str1 = '' if str1: print("'%s' is True" % str1) else: print("'%s' is False" % str1) str1 = ' ' if str1: print("'%s' is True" % str1) else: print("'%s' is False" % str1)
"""This module handles numbers""" class NAN(ValueError): def __init__(self, value): super().__init__(f"NAN: {value}") def _eval(value, kind, default=None): try: return kind(value) except (ValueError, TypeError): # if default is None: # raise NAN(value) if isinstance(value, (str, type(None))): return default try: return len(value) except TypeError: raise NAN(value) as_int = lambda x: _eval(x, int) as_float = lambda x: _eval(x, float) inty = lambda x: _eval(x, int, x) floaty = lambda x: _eval(x, float, x)
"""This module handles numbers""" class Nan(ValueError): def __init__(self, value): super().__init__(f'NAN: {value}') def _eval(value, kind, default=None): try: return kind(value) except (ValueError, TypeError): if isinstance(value, (str, type(None))): return default try: return len(value) except TypeError: raise nan(value) as_int = lambda x: _eval(x, int) as_float = lambda x: _eval(x, float) inty = lambda x: _eval(x, int, x) floaty = lambda x: _eval(x, float, x)
# Python Class 1 # variable <-- Left # = <-- Assign # data = int, String, char, boolean, float name = "McGill University" age = 10 is_good = False height = 5.6 print("Name is :" + name) print("Age is :" + str(age)) print("He is good :" +str(is_good))
name = 'McGill University' age = 10 is_good = False height = 5.6 print('Name is :' + name) print('Age is :' + str(age)) print('He is good :' + str(is_good))
# -*- coding: utf-8 -*- """Utility exception classes.""" # Part of Clockwork MUD Server (https://github.com/whutch/cwmud) # :copyright: (c) 2008 - 2017 Will Hutcheson # :license: MIT (https://github.com/whutch/cwmud/blob/master/LICENSE.txt) class AlreadyExists(Exception): """Exception for adding an item to a collection it is already in.""" def __init__(self, key, old, new=None): self.key = key self.old = old self.new = new class ServerShutdown(Exception): """Exception to signal that the server should be shutdown.""" def __init__(self, forced=True): self.forced = forced class ServerReboot(Exception): """Exception to signal that the server should be rebooted.""" class ServerReload(Exception): """Exception to signal that the server should be reloaded.""" def __init__(self, new_pid=None): self.new_pid = new_pid
"""Utility exception classes.""" class Alreadyexists(Exception): """Exception for adding an item to a collection it is already in.""" def __init__(self, key, old, new=None): self.key = key self.old = old self.new = new class Servershutdown(Exception): """Exception to signal that the server should be shutdown.""" def __init__(self, forced=True): self.forced = forced class Serverreboot(Exception): """Exception to signal that the server should be rebooted.""" class Serverreload(Exception): """Exception to signal that the server should be reloaded.""" def __init__(self, new_pid=None): self.new_pid = new_pid
e,f,c = map(int,input().split()) bottle = (e+f)//c get = (e+f)%c + bottle while 1: if get < c: break bottle += get//c get = get//c + get%c print(bottle)
(e, f, c) = map(int, input().split()) bottle = (e + f) // c get = (e + f) % c + bottle while 1: if get < c: break bottle += get // c get = get // c + get % c print(bottle)
TESTING = True HOST = "127.0.0.1" PORT = 8000
testing = True host = '127.0.0.1' port = 8000
def to_star(word): vowels = ['a', 'e' ,'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] for char in vowels: word = word.replace(char,"*") return word word = input("Enter a word: ") print(to_star(word))
def to_star(word): vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] for char in vowels: word = word.replace(char, '*') return word word = input('Enter a word: ') print(to_star(word))
""" Constants for 'skills' table """ table_ = "skillsScores" timestamp = "timestamp" team_num = "teamNum" skills_type = "type" skills_type_driving = 1 skills_type_programming = 2 red_balls = "redBalls" blue_balls = "blueBalls" owned_goals = "ownedGoals" score = "score" stop_time = "stopTime" referee = "referee" create_ = "CREATE TABLE IF NOT EXISTS " + table_ + " ( " \ + timestamp + " INTEGER NOT NULL, " \ + team_num + " TEXT NOT NULL, " \ + skills_type + " INTEGER NOT NULL, " \ + red_balls + " INTEGER NOT NULL, " \ + blue_balls + " INTEGER NOT NULL, " \ + owned_goals + " TEXT NOT NULL, " \ + score + " INTEGER NOT NULL, " \ + stop_time + " INTEGER NOT NULL, " \ + referee + " TEXT NOT NULL " \ + ");"
""" Constants for 'skills' table """ table_ = 'skillsScores' timestamp = 'timestamp' team_num = 'teamNum' skills_type = 'type' skills_type_driving = 1 skills_type_programming = 2 red_balls = 'redBalls' blue_balls = 'blueBalls' owned_goals = 'ownedGoals' score = 'score' stop_time = 'stopTime' referee = 'referee' create_ = 'CREATE TABLE IF NOT EXISTS ' + table_ + ' ( ' + timestamp + ' INTEGER NOT NULL, ' + team_num + ' TEXT NOT NULL, ' + skills_type + ' INTEGER NOT NULL, ' + red_balls + ' INTEGER NOT NULL, ' + blue_balls + ' INTEGER NOT NULL, ' + owned_goals + ' TEXT NOT NULL, ' + score + ' INTEGER NOT NULL, ' + stop_time + ' INTEGER NOT NULL, ' + referee + ' TEXT NOT NULL ' + ');'
""" To create a cli command add a new file appended by the command for example: if I want to create a command called test: - I will create a file cmd_test - create a function cli and run my command To run command on cli: with docker: docker-compose exec your-image yourapp your-command without docker: - export FLASK_APP='/path/to/flask/app' - flask run your command To view optional parameter - docker: doc """
""" To create a cli command add a new file appended by the command for example: if I want to create a command called test: - I will create a file cmd_test - create a function cli and run my command To run command on cli: with docker: docker-compose exec your-image yourapp your-command without docker: - export FLASK_APP='/path/to/flask/app' - flask run your command To view optional parameter - docker: doc """
print ("Welcome to the mad lib generator. Please follow along and type your input to each statement or question.") print ("Name an object") obj1 = input() print ("Name the plural of your previous object") obj3 = input() print ("Name a different plural object") obj2 = input() print ("Name a color") color1 = input() print ("What is the weather today?") weather = input() print ("Name an adjective ending in 'ly'") adj1 = input() print ("Name a feeling (present tense)") feeling = input() print ("Name an adjective ending in 'ly'") adj2 = input() print ("Name a verb (past tense)") verb1 = input() print ("Name a color") color2 = input() print ("Name an adjective") adj3 = input() print ("Name a quality or a person or thing") quality1 = input() print ("Name a quality or a person or thing") quality2 = input() #Print Song Title print ("\t*O Christmas Tree Mad Lib*") #Verse 1 print ("\n O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("How lovely are your %s!" %obj2) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("How lovely are your %s!" %obj2) print ("Not only %s in summer's heat," %color1) print ("But also winter's snow and %s" %weather) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("How lovely are your %s!" %obj2) # Verse 2 print ("\n O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("Of all the %s most %s;" %(obj3, adj1)) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("Of all the %s most %s;" %(obj3, adj1)) print ("Each year you bring to us %s" %feeling) print ("With %s shinning Christmas light!" %adj2) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("Of all the %s most %s." %(obj1, adj1)) # Verse 3 print ("\n O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("We %s from all your beauty;" %verb1) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("We %s from all your beauty;" %verb1) print ("Your bright %s leaves with %s cheer," %(color2, adj3)) print ("Give %s and %s throughout the year." %(quality1, quality2)) print ("O Christmas %s," %obj1 ) print ("O Christmas %s," %obj1 ) print ("We %s from all your beauty;" %verb1) print ("\nHappy Holidays! And congratulations on making a new song: 'O Christmas %s!'" %obj1 )
print('Welcome to the mad lib generator. Please follow along and type your input to each statement or question.') print('Name an object') obj1 = input() print('Name the plural of your previous object') obj3 = input() print('Name a different plural object') obj2 = input() print('Name a color') color1 = input() print('What is the weather today?') weather = input() print("Name an adjective ending in 'ly'") adj1 = input() print('Name a feeling (present tense)') feeling = input() print("Name an adjective ending in 'ly'") adj2 = input() print('Name a verb (past tense)') verb1 = input() print('Name a color') color2 = input() print('Name an adjective') adj3 = input() print('Name a quality or a person or thing') quality1 = input() print('Name a quality or a person or thing') quality2 = input() print('\t*O Christmas Tree Mad Lib*') print('\n O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('How lovely are your %s!' % obj2) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('How lovely are your %s!' % obj2) print("Not only %s in summer's heat," % color1) print("But also winter's snow and %s" % weather) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('How lovely are your %s!' % obj2) print('\n O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('Of all the %s most %s;' % (obj3, adj1)) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('Of all the %s most %s;' % (obj3, adj1)) print('Each year you bring to us %s' % feeling) print('With %s shinning Christmas light!' % adj2) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('Of all the %s most %s.' % (obj1, adj1)) print('\n O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('We %s from all your beauty;' % verb1) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('We %s from all your beauty;' % verb1) print('Your bright %s leaves with %s cheer,' % (color2, adj3)) print('Give %s and %s throughout the year.' % (quality1, quality2)) print('O Christmas %s,' % obj1) print('O Christmas %s,' % obj1) print('We %s from all your beauty;' % verb1) print("\nHappy Holidays! And congratulations on making a new song: 'O Christmas %s!'" % obj1)
students = { "ivan": 5.50, "alex": 3.50, "maria": 5.50, "georgy": 5.50, } for k,v in students.items(): if v > 4.50: print( "{} - {}".format(k, v) )
students = {'ivan': 5.5, 'alex': 3.5, 'maria': 5.5, 'georgy': 5.5} for (k, v) in students.items(): if v > 4.5: print('{} - {}'.format(k, v))
#!/usr/bin/python # pylint: disable=W0223 """ Utilities for formatting html pages """ def wrap(headr, data): """ Input: headr -- text of html field data -- text to be wrapped. Returns a corresponding portion of an html file. """ return '<%s>%s</%s>' % (headr, data, headr) def fmt_table(tbl_info): """ Format a table. tbl_info is a list of lists. Each list in tbl_info is a line of fields. Wrap the fields in td html blocks and the lines in tr html blocks """ output = [] for tline in tbl_info: local_line = '' for field in tline: local_line += wrap('td', field) output.append(wrap('tr', local_line)) return '\n'.join(output) def make_header(header): """ header is a list of text fields. Return a string representing the html text for a table header. """ retv = '' for field in header: retv += wrap('th', field) return wrap('tr', retv) class OutputInterface(object): """ Output html file. """ def __init__(self, template): self.out_data = '' self.filename = '' with open(template, 'r') as inputstr: self.template = inputstr.read() def build_page(self, filename, title, headerl, table_data): """ Construct the html file based on the values of the other three parameters. """ header = make_header(headerl) self.out_data = self.template % title self.out_data += header self.out_data += table_data self.out_data += '\n</table></div></body></html>\n' self.filename = filename def output(self): """ This routine writes out the data constructed by build_page. """ with open(self.filename, 'w') as ofile: ofile.write(self.out_data) def inject(self, edits): """ Add some text into the html data. Edits is a list of paired entries consisting of text to add and text to insert this text in front of. """ for fix_text in edits: indx = self.out_data.find(fix_text[1]) firstp = self.out_data[0:indx] secondp = self.out_data[indx:] self.out_data = firstp + fix_text[0] + secondp def get_template(self): """ Return saved template value """ return self.template
""" Utilities for formatting html pages """ def wrap(headr, data): """ Input: headr -- text of html field data -- text to be wrapped. Returns a corresponding portion of an html file. """ return '<%s>%s</%s>' % (headr, data, headr) def fmt_table(tbl_info): """ Format a table. tbl_info is a list of lists. Each list in tbl_info is a line of fields. Wrap the fields in td html blocks and the lines in tr html blocks """ output = [] for tline in tbl_info: local_line = '' for field in tline: local_line += wrap('td', field) output.append(wrap('tr', local_line)) return '\n'.join(output) def make_header(header): """ header is a list of text fields. Return a string representing the html text for a table header. """ retv = '' for field in header: retv += wrap('th', field) return wrap('tr', retv) class Outputinterface(object): """ Output html file. """ def __init__(self, template): self.out_data = '' self.filename = '' with open(template, 'r') as inputstr: self.template = inputstr.read() def build_page(self, filename, title, headerl, table_data): """ Construct the html file based on the values of the other three parameters. """ header = make_header(headerl) self.out_data = self.template % title self.out_data += header self.out_data += table_data self.out_data += '\n</table></div></body></html>\n' self.filename = filename def output(self): """ This routine writes out the data constructed by build_page. """ with open(self.filename, 'w') as ofile: ofile.write(self.out_data) def inject(self, edits): """ Add some text into the html data. Edits is a list of paired entries consisting of text to add and text to insert this text in front of. """ for fix_text in edits: indx = self.out_data.find(fix_text[1]) firstp = self.out_data[0:indx] secondp = self.out_data[indx:] self.out_data = firstp + fix_text[0] + secondp def get_template(self): """ Return saved template value """ return self.template
# This script will track two lists through a 3-D printing process # Source code/inspiration/software # Python Crash Course by Eric Matthews, Chapter 8, example 8+ # Made with Mu 1.0.3 in October 2021 # Start with a list of unprinted_designs to be 3-D printed unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron'] for unprinted_design in unprinted_designs: print("The following model will be printed: " + unprinted_design) completed_models =[] print("\n ") # Track unprinted_designs as they are 3-D printed while unprinted_designs: current_design = unprinted_designs.pop() # Track model in the 3-D print process print("Printing model: " + current_design) completed_models.append(current_design) # Generate a list of printed designs print("\nThe following models have been printed:") for completed_model in completed_models: print(completed_model)
unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron'] for unprinted_design in unprinted_designs: print('The following model will be printed: ' + unprinted_design) completed_models = [] print('\n ') while unprinted_designs: current_design = unprinted_designs.pop() print('Printing model: ' + current_design) completed_models.append(current_design) print('\nThe following models have been printed:') for completed_model in completed_models: print(completed_model)
# from typing import Counter # counter={} words=input().split(" ") counter ={ x:words.count(x) for x in set(words)} print('max: ', max(counter)) print('min: ', min(counter)) # a = input().split() # d = {} # for x in a: # try: # d[x] += 1 # except: # d[x] = 1 # print('max: ', max(d)) # print('min: ', min(d)) # words = input().split() # counter={} # for word in set(words): # counter[word] = words.count(word) # print(word) # print('max: ', max(counter)) # print('min: ', min(counter))
words = input().split(' ') counter = {x: words.count(x) for x in set(words)} print('max: ', max(counter)) print('min: ', min(counter))
# This file is part of the Extra-P software (http://www.scalasca.org/software/extra-p) # # Copyright (c) 2020, Technical University of Darmstadt, Germany # # This software may be modified and distributed under the terms of a BSD-style license. # See the LICENSE file in the base directory for details. class RecoverableError(RuntimeError): def __init__(self, *args: object) -> None: super().__init__(*args) class FileFormatError(RecoverableError): NAME = 'File Format Error' def __init__(self, *args: object) -> None: super().__init__(*args) class InvalidExperimentError(RecoverableError): NAME = 'Invalid Experiment Error' def __init__(self, *args: object) -> None: super().__init__(*args) class CancelProcessError(RecoverableError): NAME = 'Canceled Process' def __init__(self, *args: object) -> None: super().__init__(*args)
class Recoverableerror(RuntimeError): def __init__(self, *args: object) -> None: super().__init__(*args) class Fileformaterror(RecoverableError): name = 'File Format Error' def __init__(self, *args: object) -> None: super().__init__(*args) class Invalidexperimenterror(RecoverableError): name = 'Invalid Experiment Error' def __init__(self, *args: object) -> None: super().__init__(*args) class Cancelprocesserror(RecoverableError): name = 'Canceled Process' def __init__(self, *args: object) -> None: super().__init__(*args)
""" Examples will be published soon ... """
""" Examples will be published soon ... """
def greet(first_name, last_name): print(f"Hi {first_name} {last_name}") greet("Tom", "Hill")
def greet(first_name, last_name): print(f'Hi {first_name} {last_name}') greet('Tom', 'Hill')
""" This script takes two input strings and compare them to check if they are anagrams or not. """ def mysort(s): #function that splits the letters d=sorted(s) s=''.join(d) return s s1=input("enter first word ") n1=mysort(s1) #function invocation /calling the function s2=input("enter second word ") n2=mysort(s2) if n1.lower()==n2.lower(): print(s1," and ",s2," are anagrams") else: print(s1," and ",s2," are not anagrams")
""" This script takes two input strings and compare them to check if they are anagrams or not. """ def mysort(s): d = sorted(s) s = ''.join(d) return s s1 = input('enter first word ') n1 = mysort(s1) s2 = input('enter second word ') n2 = mysort(s2) if n1.lower() == n2.lower(): print(s1, ' and ', s2, ' are anagrams') else: print(s1, ' and ', s2, ' are not anagrams')
# Copyright (c) 2022, INRIA # Copyright (c) 2022, University of Lille # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class CPUTopology: """ This class stores the necessary information about the CPU topology. """ def __init__(self, tdp, freq_bclk, ratio_min, ratio_base, ratio_max): """ Create a new CPU topology object. :param tdp: TDP of the CPU in Watt :param freq_bclk: Base clock in MHz :param ratio_min: Maximum efficiency ratio :param ratio_base: Base frequency ratio :param ratio_max: Maximum frequency ratio (with Turbo-Boost) """ self.tdp = tdp self.freq_bclk = freq_bclk self.ratio_min = ratio_min self.ratio_base = ratio_base self.ratio_max = ratio_max def get_min_frequency(self): """ Compute and return the CPU max efficiency frequency. :return: The CPU max efficiency frequency in MHz """ return self.freq_bclk * self.ratio_min def get_base_frequency(self): """ Compute and return the CPU base frequency. :return: The CPU base frequency in MHz """ return self.freq_bclk * self.ratio_base def get_max_frequency(self): """ Compute and return the CPU maximum frequency. (Turbo-Boost included) :return: The CPU maximum frequency in MHz """ return self.freq_bclk * self.ratio_max def get_supported_frequencies(self): """ Compute the supported frequencies for this CPU. :return: A list of supported frequencies in MHz """ return list(range(self.get_min_frequency(), self.get_max_frequency() + 1, self.freq_bclk))
class Cputopology: """ This class stores the necessary information about the CPU topology. """ def __init__(self, tdp, freq_bclk, ratio_min, ratio_base, ratio_max): """ Create a new CPU topology object. :param tdp: TDP of the CPU in Watt :param freq_bclk: Base clock in MHz :param ratio_min: Maximum efficiency ratio :param ratio_base: Base frequency ratio :param ratio_max: Maximum frequency ratio (with Turbo-Boost) """ self.tdp = tdp self.freq_bclk = freq_bclk self.ratio_min = ratio_min self.ratio_base = ratio_base self.ratio_max = ratio_max def get_min_frequency(self): """ Compute and return the CPU max efficiency frequency. :return: The CPU max efficiency frequency in MHz """ return self.freq_bclk * self.ratio_min def get_base_frequency(self): """ Compute and return the CPU base frequency. :return: The CPU base frequency in MHz """ return self.freq_bclk * self.ratio_base def get_max_frequency(self): """ Compute and return the CPU maximum frequency. (Turbo-Boost included) :return: The CPU maximum frequency in MHz """ return self.freq_bclk * self.ratio_max def get_supported_frequencies(self): """ Compute the supported frequencies for this CPU. :return: A list of supported frequencies in MHz """ return list(range(self.get_min_frequency(), self.get_max_frequency() + 1, self.freq_bclk))
print() print("--- Math ---") print(1+1) print(1*3) print(1/2) print(3**2) print(4%2) print(4%2 == 0) print(type(1)) print(type(1.0))
print() print('--- Math ---') print(1 + 1) print(1 * 3) print(1 / 2) print(3 ** 2) print(4 % 2) print(4 % 2 == 0) print(type(1)) print(type(1.0))
directions = [(-1,0), (0,1), (1,0), (0,-1), (0,0)] dirs = ["North", "East", "South", "West", "Stay"] def add(a, b): return tuple(map(lambda a, b: a + b, a, b)) def sub(a,b): return tuple(map(lambda a, b: a - b, a, b)) def manhattan_dist(a, b): return abs(a[0]-b[0]) + abs(a[1]-b[1]) def direction_to_cmd(p): return dirs[directions.index((p[0],p[1]))] def cmd_to_direction(c): return directions[dirs.index(c)]
directions = [(-1, 0), (0, 1), (1, 0), (0, -1), (0, 0)] dirs = ['North', 'East', 'South', 'West', 'Stay'] def add(a, b): return tuple(map(lambda a, b: a + b, a, b)) def sub(a, b): return tuple(map(lambda a, b: a - b, a, b)) def manhattan_dist(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) def direction_to_cmd(p): return dirs[directions.index((p[0], p[1]))] def cmd_to_direction(c): return directions[dirs.index(c)]
def even_fibo(): a =1 b = 1 even_sum = 0 c =0 while(c<= 4000000): c = a + b a = b b = c if(c %2 == 0): even_sum = c + even_sum print(even_sum) if __name__ == "__main__": print("Project Euler Problem 1") even_fibo()
def even_fibo(): a = 1 b = 1 even_sum = 0 c = 0 while c <= 4000000: c = a + b a = b b = c if c % 2 == 0: even_sum = c + even_sum print(even_sum) if __name__ == '__main__': print('Project Euler Problem 1') even_fibo()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 24 16:18:39 2018 @author: pamelaanderson """ def clean_ad_ev_table(df): """ This function cleans the adverse event reporting data- correcting for drug labeling information using CMS database as the 'truth' to correct to """ df['drug_generic_name'] = df['drug_generic_name'].str.lower() df['drug_brand_name'] = df['drug_brand_name'].str.lower() # Fix generics names drug_gen_series = df['drug_generic_name'] drug_gen_series = drug_gen_series.str.replace('hydrochloride', 'hci') drug_gen_series = drug_gen_series.str.replace('acetaminophen', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetaminophen and codeine phosphate', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetaminophen with codeine and codeine phosphate', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetazolamide sodium', 'acetazolamide') drug_gen_series = drug_gen_series.str.replace('acyclovir sodium', 'acyclovir') drug_gen_series = drug_gen_series.str.replace('albuterol', 'albuterol sulfate') drug_gen_series = drug_gen_series.str.replace('alfuzosin', 'alfuzosin hci') drug_gen_series = drug_gen_series.str.replace('betaxolol', 'betaxolol hci') drug_gen_series = drug_gen_series.str.replace('carbidopa and levodopa', 'carbidopa\levodopa') drug_gen_series = drug_gen_series.str.replace('estradiol,', 'estradiol') drug_gen_series = drug_gen_series.str.replace('levetiracetam injection', 'levetiracetam') drug_gen_series = drug_gen_series.str.replace('lisinopril and hydrochlorothiazide', 'lisinopril/hydrochlorothiazide') drug_gen_series = drug_gen_series.str.replace('pantoprazole', '') drug_gen_series = drug_gen_series.str.replace('raloxifene', 'raloxifene hci') drug_gen_series[(df['drug_generic_name'] == 'metoprolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'metoprolol succinate' drug_gen_series[(df['drug_generic_name'] == 'montelukast') & (df['drug_manuf_name'] != 'Merck Sharp & Dohme Corp.')] = 'montelukast sodium' drug_gen_series[(df['drug_generic_name'] == 'pantoprazole') & (df['drug_manuf_name'] == 'Camber Pharmaceuticals, Inc.')] = 'pantoprazole sodium' drug_gen_series[(df['drug_generic_name'] == 'sertraline') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'sertraline hci' # Fix brands names drug_brand_series = df['drug_brand_name'] drug_brand_series = drug_brand_series.replace('fluoxetine', 'fluoxetine hci') drug_brand_series = drug_brand_series.replace('hydrochloride', 'hci') drug_brand_series = drug_brand_series.replace('tylenol regular strength', 'Tylenol-Codeine No.3') drug_brand_series = drug_brand_series.replace('tylenol with codeine', 'Tylenol-Codeine No.3') drug_brand_series = drug_brand_series.str.replace('albuterol', 'albuterol sulfate') drug_brand_series = drug_brand_series.str.replace('alfuzosin hydrochloride', 'alfuzosin hci er') drug_brand_series = drug_brand_series.str.replace('aloprim', 'allopurinol') drug_brand_series = drug_brand_series.str.replace('amlodipine besylate 10 mg', 'amlodipine besylate') drug_brand_series[(df['drug_generic_name'] == 'atenolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'atenolol' drug_brand_series = drug_brand_series.str.replace('betaxolol', 'betaxolol hci') drug_brand_series[(df['drug_generic_name'] == 'casodex') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'bicalutamide' drug_brand_series = drug_brand_series.str.replace('brimonidine', 'brimonidine tartrate') drug_brand_series[(df['drug_generic_name'] == 'candesartan cilexetil') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'candesartan cilexetil' drug_brand_series[(df['drug_generic_name'] == 'carbamazepine') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'carbamazepine' drug_brand_series = drug_brand_series.str.replace('carisoprodol immediate release', 'carisoprodol') drug_brand_series = drug_brand_series.str.replace('celecoxib 50 mg', 'celecoxib') drug_brand_series = drug_brand_series.str.replace('cipro hc', 'cipro') drug_brand_series[(df['drug_generic_name'] == 'clopidogrel bisulfate') & (df['drug_manuf_name'] != 'Bristol-Myers Squibb/Sanofi Pharmaceuticals Partnership')] = 'clopidogrel bisulfate' drug_brand_series = drug_brand_series.str.replace('diltiazem hci extended release', 'diltiazem hci') drug_brand_series = drug_brand_series.str.replace('diltiazem hci extended release', 'diltiazem hci') drug_brand_series = drug_brand_series.str.replace('duloxetine delayed-release', 'duloxetine hci') drug_brand_series[(df['drug_generic_name'] == 'enoxaparin sodium') & (df['drug_manuf_name'] != 'sanofi-aventis U.S. LLC')] = 'enoxaparin sodium' drug_brand_series[(df['drug_generic_name'] == 'exemestane') & (df['drug_manuf_name'] != 'Pharmacia and Upjohn Company LLC')] = 'exemestane' drug_brand_series = drug_brand_series.str.replace('fentanyl - novaplus', 'fentanyl') drug_brand_series[(df['drug_generic_name'] == 'furosemide') & (df['drug_manuf_name'] != 'Sanofi-Aventis U.S. LLC')] = 'furosemide' drug_brand_series = drug_brand_series.str.replace('gabapentin kit', 'gabapentin') drug_brand_series = drug_brand_series.str.replace('gentamicin', 'gentamicin sulfate') drug_brand_series[(df['drug_generic_name'] == 'glimepiride') & (df['drug_manuf_name'] != 'Sanofi-Aventis U.S. LLC')] = 'glimepiride' drug_brand_series[(df['drug_generic_name'] == 'irbesartan') & (df['drug_manuf_name'] != 'sanofi-aventis U.S. LLC')] = 'irbesartan' drug_brand_series[(df['drug_generic_name'] == 'lamotrigine') & (df['drug_manuf_name'] != 'GlaxoSmithKline LLC')] = 'lamotrigine' drug_brand_series = drug_brand_series.str.replace('health mart lansoprazole', 'lansoprazole') drug_brand_series= drug_brand_series.str.replace('levetiracetam levetiracetam', 'levetiracetam') drug_brand_series[(df['drug_generic_name'] == 'levofloxacin') & (df['drug_manuf_name'] != 'Janssen Pharmaceuticals, Inc.')] = 'levofloxacin' drug_brand_series[(df['drug_generic_name'] == 'lisinopril') & (df['drug_manuf_name'] != 'Merck Sharp & Dohme Corp.')] = 'lisinopril' drug_brand_series = drug_brand_series.str.replace('acetaminophen and codeine', 'Acetaminophen-Codeine') drug_brand_series[(df['drug_generic_name'] == 'acyclovir sodium') & (df['drug_manuf_name'] != 'Prestium Pharma, Inc.')] = 'acyclovir' drug_brand_series[(df['drug_generic_name'] == 'lisinopril') & (df['drug_manuf_name'] != 'LUPIN LIMITED')] = 'lisinopril' drug_brand_series[(df['drug_generic_name'] == 'lisinopril/hydrochlorothiazide') & (df['drug_manuf_name'] != 'Almatica Pharma Inc.')] = 'lisinopril/hydrochlorothiazide' drug_brand_series[(df['drug_generic_name'] == 'azacitidine') & (df['drug_manuf_name'] != 'Celgene Corporation')] = 'azacitidine' drug_brand_series = drug_brand_series.str.replace('methotrexate', 'methotrexate sodium') drug_brand_series = drug_brand_series.str.replace('montelukast sodium chewable', 'montelukast sodium') drug_brand_series = drug_brand_series.str.replace('nevirapine extended release', 'nevirapine') drug_brand_series = drug_brand_series.str.replace('raloxifene', 'raloxifene hci') drug_brand_series = drug_brand_series.str.replace('being well heartburn relief', 'ranitidine hci') drug_brand_series = drug_brand_series.str.replace('acid reducer', 'ranitidine hci') drug_brand_series[(df['drug_generic_name'] == 'meloxicam') & (df['drug_manuf_name'] != 'Boehringer Ingelheim Pharmaceuticals Inc.')] = 'meloxicam' drug_brand_series[(df['drug_generic_name'] == 'memantine') & (df['drug_manuf_name'] != 'Allergan, Inc.')] = 'memantine' drug_brand_series[(df['drug_generic_name'] == 'metaxalone') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'metaxalone' drug_brand_series[(df['drug_generic_name'] == 'metoprolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'metoprolol succinate' drug_brand_series[(df['drug_generic_name'] == 'modafinil') & (df['drug_manuf_name'] != 'Cephalon, Inc.')] = 'modafinil' drug_brand_series[(df['drug_generic_name'] == 'nateglinide') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'nateglinide' drug_brand_series[(df['drug_generic_name'] == 'nitroglycerin') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'nitroglycerin' drug_brand_series[(df['drug_generic_name'] == 'oxcarbazepine') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'oxcarbazepine' drug_brand_series[(df['drug_generic_name'] == 'oxycodone hci') & (df['drug_manuf_name'] != 'Mallinckrodt ARD Inc.')] = 'oxycodone hci' drug_brand_series[(df['drug_generic_name'] == 'paclitaxel') & (df['drug_manuf_name'] != 'Celgene Corporation')] = 'paclitaxel' drug_brand_series[(df['drug_generic_name'] == 'pantoprazole sodium') & (df['drug_manuf_name'] != 'Wyeth Pharmaceuticals LLC, a subsidiary of Pfizer Inc.')] = 'pantoprazole sodium' drug_brand_series[(df['drug_generic_name'] == 'phenytoin') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'phenytoin' drug_brand_series[(df['drug_generic_name'] == 'ranitidine hci') & (df['drug_manuf_name'] != 'GlaxoSmithKline Consumer Healthcare Holdings (US) LLC')] = 'ranitidine hci' drug_brand_series[(df['drug_generic_name'] == 'sertraline') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'sertraline hci' df['drug_generic_name_re'] = drug_gen_series df['drug_brand_name_re'] = drug_brand_series return df
""" Created on Mon Sep 24 16:18:39 2018 @author: pamelaanderson """ def clean_ad_ev_table(df): """ This function cleans the adverse event reporting data- correcting for drug labeling information using CMS database as the 'truth' to correct to """ df['drug_generic_name'] = df['drug_generic_name'].str.lower() df['drug_brand_name'] = df['drug_brand_name'].str.lower() drug_gen_series = df['drug_generic_name'] drug_gen_series = drug_gen_series.str.replace('hydrochloride', 'hci') drug_gen_series = drug_gen_series.str.replace('acetaminophen', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetaminophen and codeine phosphate', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetaminophen with codeine and codeine phosphate', 'acetaminophen with codeine') drug_gen_series = drug_gen_series.str.replace('acetazolamide sodium', 'acetazolamide') drug_gen_series = drug_gen_series.str.replace('acyclovir sodium', 'acyclovir') drug_gen_series = drug_gen_series.str.replace('albuterol', 'albuterol sulfate') drug_gen_series = drug_gen_series.str.replace('alfuzosin', 'alfuzosin hci') drug_gen_series = drug_gen_series.str.replace('betaxolol', 'betaxolol hci') drug_gen_series = drug_gen_series.str.replace('carbidopa and levodopa', 'carbidopa\\levodopa') drug_gen_series = drug_gen_series.str.replace('estradiol,', 'estradiol') drug_gen_series = drug_gen_series.str.replace('levetiracetam injection', 'levetiracetam') drug_gen_series = drug_gen_series.str.replace('lisinopril and hydrochlorothiazide', 'lisinopril/hydrochlorothiazide') drug_gen_series = drug_gen_series.str.replace('pantoprazole', '') drug_gen_series = drug_gen_series.str.replace('raloxifene', 'raloxifene hci') drug_gen_series[(df['drug_generic_name'] == 'metoprolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'metoprolol succinate' drug_gen_series[(df['drug_generic_name'] == 'montelukast') & (df['drug_manuf_name'] != 'Merck Sharp & Dohme Corp.')] = 'montelukast sodium' drug_gen_series[(df['drug_generic_name'] == 'pantoprazole') & (df['drug_manuf_name'] == 'Camber Pharmaceuticals, Inc.')] = 'pantoprazole sodium' drug_gen_series[(df['drug_generic_name'] == 'sertraline') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'sertraline hci' drug_brand_series = df['drug_brand_name'] drug_brand_series = drug_brand_series.replace('fluoxetine', 'fluoxetine hci') drug_brand_series = drug_brand_series.replace('hydrochloride', 'hci') drug_brand_series = drug_brand_series.replace('tylenol regular strength', 'Tylenol-Codeine No.3') drug_brand_series = drug_brand_series.replace('tylenol with codeine', 'Tylenol-Codeine No.3') drug_brand_series = drug_brand_series.str.replace('albuterol', 'albuterol sulfate') drug_brand_series = drug_brand_series.str.replace('alfuzosin hydrochloride', 'alfuzosin hci er') drug_brand_series = drug_brand_series.str.replace('aloprim', 'allopurinol') drug_brand_series = drug_brand_series.str.replace('amlodipine besylate 10 mg', 'amlodipine besylate') drug_brand_series[(df['drug_generic_name'] == 'atenolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'atenolol' drug_brand_series = drug_brand_series.str.replace('betaxolol', 'betaxolol hci') drug_brand_series[(df['drug_generic_name'] == 'casodex') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'bicalutamide' drug_brand_series = drug_brand_series.str.replace('brimonidine', 'brimonidine tartrate') drug_brand_series[(df['drug_generic_name'] == 'candesartan cilexetil') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'candesartan cilexetil' drug_brand_series[(df['drug_generic_name'] == 'carbamazepine') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'carbamazepine' drug_brand_series = drug_brand_series.str.replace('carisoprodol immediate release', 'carisoprodol') drug_brand_series = drug_brand_series.str.replace('celecoxib 50 mg', 'celecoxib') drug_brand_series = drug_brand_series.str.replace('cipro hc', 'cipro') drug_brand_series[(df['drug_generic_name'] == 'clopidogrel bisulfate') & (df['drug_manuf_name'] != 'Bristol-Myers Squibb/Sanofi Pharmaceuticals Partnership')] = 'clopidogrel bisulfate' drug_brand_series = drug_brand_series.str.replace('diltiazem hci extended release', 'diltiazem hci') drug_brand_series = drug_brand_series.str.replace('diltiazem hci extended release', 'diltiazem hci') drug_brand_series = drug_brand_series.str.replace('duloxetine delayed-release', 'duloxetine hci') drug_brand_series[(df['drug_generic_name'] == 'enoxaparin sodium') & (df['drug_manuf_name'] != 'sanofi-aventis U.S. LLC')] = 'enoxaparin sodium' drug_brand_series[(df['drug_generic_name'] == 'exemestane') & (df['drug_manuf_name'] != 'Pharmacia and Upjohn Company LLC')] = 'exemestane' drug_brand_series = drug_brand_series.str.replace('fentanyl - novaplus', 'fentanyl') drug_brand_series[(df['drug_generic_name'] == 'furosemide') & (df['drug_manuf_name'] != 'Sanofi-Aventis U.S. LLC')] = 'furosemide' drug_brand_series = drug_brand_series.str.replace('gabapentin kit', 'gabapentin') drug_brand_series = drug_brand_series.str.replace('gentamicin', 'gentamicin sulfate') drug_brand_series[(df['drug_generic_name'] == 'glimepiride') & (df['drug_manuf_name'] != 'Sanofi-Aventis U.S. LLC')] = 'glimepiride' drug_brand_series[(df['drug_generic_name'] == 'irbesartan') & (df['drug_manuf_name'] != 'sanofi-aventis U.S. LLC')] = 'irbesartan' drug_brand_series[(df['drug_generic_name'] == 'lamotrigine') & (df['drug_manuf_name'] != 'GlaxoSmithKline LLC')] = 'lamotrigine' drug_brand_series = drug_brand_series.str.replace('health mart lansoprazole', 'lansoprazole') drug_brand_series = drug_brand_series.str.replace('levetiracetam levetiracetam', 'levetiracetam') drug_brand_series[(df['drug_generic_name'] == 'levofloxacin') & (df['drug_manuf_name'] != 'Janssen Pharmaceuticals, Inc.')] = 'levofloxacin' drug_brand_series[(df['drug_generic_name'] == 'lisinopril') & (df['drug_manuf_name'] != 'Merck Sharp & Dohme Corp.')] = 'lisinopril' drug_brand_series = drug_brand_series.str.replace('acetaminophen and codeine', 'Acetaminophen-Codeine') drug_brand_series[(df['drug_generic_name'] == 'acyclovir sodium') & (df['drug_manuf_name'] != 'Prestium Pharma, Inc.')] = 'acyclovir' drug_brand_series[(df['drug_generic_name'] == 'lisinopril') & (df['drug_manuf_name'] != 'LUPIN LIMITED')] = 'lisinopril' drug_brand_series[(df['drug_generic_name'] == 'lisinopril/hydrochlorothiazide') & (df['drug_manuf_name'] != 'Almatica Pharma Inc.')] = 'lisinopril/hydrochlorothiazide' drug_brand_series[(df['drug_generic_name'] == 'azacitidine') & (df['drug_manuf_name'] != 'Celgene Corporation')] = 'azacitidine' drug_brand_series = drug_brand_series.str.replace('methotrexate', 'methotrexate sodium') drug_brand_series = drug_brand_series.str.replace('montelukast sodium chewable', 'montelukast sodium') drug_brand_series = drug_brand_series.str.replace('nevirapine extended release', 'nevirapine') drug_brand_series = drug_brand_series.str.replace('raloxifene', 'raloxifene hci') drug_brand_series = drug_brand_series.str.replace('being well heartburn relief', 'ranitidine hci') drug_brand_series = drug_brand_series.str.replace('acid reducer', 'ranitidine hci') drug_brand_series[(df['drug_generic_name'] == 'meloxicam') & (df['drug_manuf_name'] != 'Boehringer Ingelheim Pharmaceuticals Inc.')] = 'meloxicam' drug_brand_series[(df['drug_generic_name'] == 'memantine') & (df['drug_manuf_name'] != 'Allergan, Inc.')] = 'memantine' drug_brand_series[(df['drug_generic_name'] == 'metaxalone') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'metaxalone' drug_brand_series[(df['drug_generic_name'] == 'metoprolol') & (df['drug_manuf_name'] != 'AstraZeneca Pharmaceuticals LP')] = 'metoprolol succinate' drug_brand_series[(df['drug_generic_name'] == 'modafinil') & (df['drug_manuf_name'] != 'Cephalon, Inc.')] = 'modafinil' drug_brand_series[(df['drug_generic_name'] == 'nateglinide') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'nateglinide' drug_brand_series[(df['drug_generic_name'] == 'nitroglycerin') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'nitroglycerin' drug_brand_series[(df['drug_generic_name'] == 'oxcarbazepine') & (df['drug_manuf_name'] != 'Novartis Pharmaceuticals Corporation')] = 'oxcarbazepine' drug_brand_series[(df['drug_generic_name'] == 'oxycodone hci') & (df['drug_manuf_name'] != 'Mallinckrodt ARD Inc.')] = 'oxycodone hci' drug_brand_series[(df['drug_generic_name'] == 'paclitaxel') & (df['drug_manuf_name'] != 'Celgene Corporation')] = 'paclitaxel' drug_brand_series[(df['drug_generic_name'] == 'pantoprazole sodium') & (df['drug_manuf_name'] != 'Wyeth Pharmaceuticals LLC, a subsidiary of Pfizer Inc.')] = 'pantoprazole sodium' drug_brand_series[(df['drug_generic_name'] == 'phenytoin') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'phenytoin' drug_brand_series[(df['drug_generic_name'] == 'ranitidine hci') & (df['drug_manuf_name'] != 'GlaxoSmithKline Consumer Healthcare Holdings (US) LLC')] = 'ranitidine hci' drug_brand_series[(df['drug_generic_name'] == 'sertraline') & (df['drug_manuf_name'] != 'Pfizer Laboratories Div Pfizer Inc')] = 'sertraline hci' df['drug_generic_name_re'] = drug_gen_series df['drug_brand_name_re'] = drug_brand_series return df
MULTI_ERRORS_HTTP_RESPONSE = { "errors": [ { "code": 403, "message": "access denied, authorization failed" }, { "code": 401, "message": "test error #1" }, { "code": 402, "message": "test error #2" } ], "meta": { "powered_by": "crowdstrike-api-gateway", "query_time": 0.000654734, "trace_id": "39f1573c-7a51-4b1a-abaa-92d29f704afd" } } NO_ERRORS_HTTP_RESPONSE = { "errors": [], "meta": { "powered_by": "crowdstrike-api-gateway", "query_time": 0.000654734, "trace_id": "39f1573c-7a51-4b1a-abaa-92d29f704afd" } }
multi_errors_http_response = {'errors': [{'code': 403, 'message': 'access denied, authorization failed'}, {'code': 401, 'message': 'test error #1'}, {'code': 402, 'message': 'test error #2'}], 'meta': {'powered_by': 'crowdstrike-api-gateway', 'query_time': 0.000654734, 'trace_id': '39f1573c-7a51-4b1a-abaa-92d29f704afd'}} no_errors_http_response = {'errors': [], 'meta': {'powered_by': 'crowdstrike-api-gateway', 'query_time': 0.000654734, 'trace_id': '39f1573c-7a51-4b1a-abaa-92d29f704afd'}}
name = 'shell_proc' version = '1.1.1' description = 'Continuous shell process' url = 'https://github.com/justengel/shell_proc' author = 'Justin Engel' author_email = 'jtengel08@gmail.com'
name = 'shell_proc' version = '1.1.1' description = 'Continuous shell process' url = 'https://github.com/justengel/shell_proc' author = 'Justin Engel' author_email = 'jtengel08@gmail.com'
def open_input(): with open("input.txt") as fd: array = fd.read().splitlines() array = list(map(int, array)) return array def part_one(array): lenght = len(array) increased = 0 for i in range(0, lenght - 1): if array[i] < array[i + 1]: increased += 1 print("part one:", increased) def part_two(array): lenght = len(array) increased = 0 for i in range(0, lenght - 3): sum1 = array[i] + array[i + 1] + array[i + 2] sum2 = array[i + 1] + array[i + 2] + array[i + 3] if sum1 < sum2: increased += 1 print("part two:", increased) if (__name__ == "__main__"): array = open_input() part_one(array) part_two(array)
def open_input(): with open('input.txt') as fd: array = fd.read().splitlines() array = list(map(int, array)) return array def part_one(array): lenght = len(array) increased = 0 for i in range(0, lenght - 1): if array[i] < array[i + 1]: increased += 1 print('part one:', increased) def part_two(array): lenght = len(array) increased = 0 for i in range(0, lenght - 3): sum1 = array[i] + array[i + 1] + array[i + 2] sum2 = array[i + 1] + array[i + 2] + array[i + 3] if sum1 < sum2: increased += 1 print('part two:', increased) if __name__ == '__main__': array = open_input() part_one(array) part_two(array)
# =========================================================================== # dictionary.py ----------------------------------------------------------- # =========================================================================== # function ---------------------------------------------------------------- # --------------------------------------------------------------------------- def update_dict(a, b): # @todo[comment]: if a and b and isinstance(a, dict): a.update(b) return a # function ---------------------------------------------------------------- # --------------------------------------------------------------------------- def get_dict_element(dict_list, field, query): # @todo[comment]: for item in dict_list: if item[field] == query: return item return dict() # function ---------------------------------------------------------------- # --------------------------------------------------------------------------- def get_dict_elements(dict_list, field, query, update=False): # @todo[comment]: if not isinstance(field, list) and isinstance(query, list): field = [field] * len(query) result = list() if not update else dict() if isinstance(field, list) and isinstance(query, list): for field_item, query_item in zip(field, query): item = get_dict_element(dict_list, field_item, query_item) if item: if not update: result.append(item) else: result.update(item) return result
def update_dict(a, b): if a and b and isinstance(a, dict): a.update(b) return a def get_dict_element(dict_list, field, query): for item in dict_list: if item[field] == query: return item return dict() def get_dict_elements(dict_list, field, query, update=False): if not isinstance(field, list) and isinstance(query, list): field = [field] * len(query) result = list() if not update else dict() if isinstance(field, list) and isinstance(query, list): for (field_item, query_item) in zip(field, query): item = get_dict_element(dict_list, field_item, query_item) if item: if not update: result.append(item) else: result.update(item) return result
# selectionsort() method def selectionSort(arr): arraySize = len(arr) for i in range(arraySize): min = i for j in range(i+1, arraySize): if arr[j] < arr[min]: min = j #swap values arr[i], arr[min] = arr[min], arr[i] # method to print an array def printList(arr): for i in range(len(arr)): print(arr[i],end=" ") print("\n") # driver method if __name__ == '__main__': arr = [3,4,1,7,6,2,8] print ("Given array: ", end="\n") printList(arr) selectionSort(arr) print("Sorted array: ", end="\n") printList(arr)
def selection_sort(arr): array_size = len(arr) for i in range(arraySize): min = i for j in range(i + 1, arraySize): if arr[j] < arr[min]: min = j (arr[i], arr[min]) = (arr[min], arr[i]) def print_list(arr): for i in range(len(arr)): print(arr[i], end=' ') print('\n') if __name__ == '__main__': arr = [3, 4, 1, 7, 6, 2, 8] print('Given array: ', end='\n') print_list(arr) selection_sort(arr) print('Sorted array: ', end='\n') print_list(arr)
# -*- coding: utf-8 -*- """Exceptions used in this module""" class CoincError(Exception): """Base Class used to declare other errors for Coinc Extends: Exception """ pass class ConfigError(CoincError): """Raised when there are invalid value filled in Configuration Sheet Extends: CoincError """ pass class QueryError(CoincError): """Raised when invalid query were given Extends: CoincError """ pass class AppIDError(CoincError): """Raised when App ID can not be used Extends: CoincError """ pass class ApiError(CoincError): """Raised when API is unreachable or return bad response Extends: CoincError """ pass class UnknownPythonError(CoincError): """Raised when Python runtime version can not be correctly detacted Extends: CoincError """ pass
"""Exceptions used in this module""" class Coincerror(Exception): """Base Class used to declare other errors for Coinc Extends: Exception """ pass class Configerror(CoincError): """Raised when there are invalid value filled in Configuration Sheet Extends: CoincError """ pass class Queryerror(CoincError): """Raised when invalid query were given Extends: CoincError """ pass class Appiderror(CoincError): """Raised when App ID can not be used Extends: CoincError """ pass class Apierror(CoincError): """Raised when API is unreachable or return bad response Extends: CoincError """ pass class Unknownpythonerror(CoincError): """Raised when Python runtime version can not be correctly detacted Extends: CoincError """ pass
logo = ''' ______ __ __ _ __ __ / ____/__ __ ___ _____ _____ / /_ / /_ ___ / | / /__ __ ____ ___ / /_ ___ _____ / / __ / / / // _ \ / ___// ___/ / __// __ \ / _ \ / |/ // / / // __ `__ \ / __ \ / _ \ / ___/ / /_/ // /_/ // __/(__ )(__ ) / /_ / / / // __/ / /| // /_/ // / / / / // /_/ // __// / \____/ \__,_/ \___//____//____/ \__//_/ /_/ \___/ /_/ |_/ \__,_//_/ /_/ /_//_.___/ \___//_/ '''
logo = '\n ______ __ __ _ __ __ \n / ____/__ __ ___ _____ _____ / /_ / /_ ___ / | / /__ __ ____ ___ / /_ ___ _____\n / / __ / / / // _ \\ / ___// ___/ / __// __ \\ / _ \\ / |/ // / / // __ `__ \\ / __ \\ / _ \\ / ___/\n/ /_/ // /_/ // __/(__ )(__ ) / /_ / / / // __/ / /| // /_/ // / / / / // /_/ // __// / \n\\____/ \\__,_/ \\___//____//____/ \\__//_/ /_/ \\___/ /_/ |_/ \\__,_//_/ /_/ /_//_.___/ \\___//_/ \n'
class AzureBlobUrlModel(object): def __init__(self, storage_name, container_name, blob_name): """ :param storage_name: (str) Azure storage name :param container_name: (str) Azure container name :param blob_name: (str) Azure Blob name """ self.storage_name = storage_name self.container_name = container_name self.blob_name = blob_name
class Azurebloburlmodel(object): def __init__(self, storage_name, container_name, blob_name): """ :param storage_name: (str) Azure storage name :param container_name: (str) Azure container name :param blob_name: (str) Azure Blob name """ self.storage_name = storage_name self.container_name = container_name self.blob_name = blob_name
'''https://leetcode.com/problems/symmetric-tree/''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isMirror(self, left, right): if left is None and right is None: return True if left is None or right is None: return False if left.val==right.val: return self.isMirror(left.left, right.right) and self.isMirror(left.right, right.left) else: return False def isSymmetric(self, root: TreeNode) -> bool: if not root: return True return self.isMirror(root.left, root.right)
"""https://leetcode.com/problems/symmetric-tree/""" class Solution: def is_mirror(self, left, right): if left is None and right is None: return True if left is None or right is None: return False if left.val == right.val: return self.isMirror(left.left, right.right) and self.isMirror(left.right, right.left) else: return False def is_symmetric(self, root: TreeNode) -> bool: if not root: return True return self.isMirror(root.left, root.right)
def convert_to_bool(string): """ Converts string to bool :param string: String :str string: str :return: True or False """ if isinstance(string, bool): return string return string in ['true', 'True', '1']
def convert_to_bool(string): """ Converts string to bool :param string: String :str string: str :return: True or False """ if isinstance(string, bool): return string return string in ['true', 'True', '1']
# -*- coding: utf-8 -*- """ Created on Mon Jul 27 10:49:39 2020 @author: Arthur Donizeti Rodrigues Dias """ class Category: def __init__(self, categories): self.ledger=[] self.categories = categories self.listaDeposito=[] self.listaRetirada=[] self.total_entrada = 0 self.total_saida = 0 def __str__(self): x = self.categories.center(30,"*")+'\n' n = 0; lista_v = [] for i in self.ledger: for k, v in self.ledger[n].items(): lista_v.append(v) n+=1 n = 1 for i in self.ledger: y = str(lista_v[n]) x = x + y[0:23].ljust(23)+str(format(lista_v[n-1], '.2f')).rjust(7)+'\n' n += 2 x = x + 'Total: '+str(format(self.get_balance(), '.2f')) return x def deposit(self, quantia,description=""): dic ={'amount': quantia, 'description' : description} self.total_entrada += quantia self.listaDeposito.append(quantia) self.listaDeposito.append(description) self.ledger.append(dic) def withdraw(self, quantia,description=""): try: if self.total_entrada>quantia: self.total_saida += quantia dic ={'amount': -quantia, 'description' : description} self.listaRetirada.append(quantia) self.listaRetirada.append(description) self.ledger.append(dic) return True else: return False except: return False def get_balance(self): return self.total_entrada - self.total_saida def transfer(self,quantia, beneficiario): if quantia <= self.total_entrada: x = f'Transfer to {beneficiario.categories}' self.withdraw(quantia,x) beneficiario.deposit(quantia, f'Transfer from {self.categories}' ) return True else: return False def check_funds(self, quantia): if quantia <= self.get_balance() : return True else : return False def create_spend_chart(teste): soma = 0.0 cont = 10 tamanho = 0 lista = [] lista_porcentagem = [] for i in teste: x = i.categories if tamanho < len(x): tamanho = len(x) soma += i.total_saida lista.append(x) for i in teste: lista_porcentagem.append((i.total_saida/soma)*10) x = 'Percentage spent by category\n' while cont >=0: x += f'{cont*10}|'.rjust(4) for i in lista_porcentagem: if i > cont: x += ' o ' else: x += ' ' x = x+' \n' cont -= 1 x += ('--'*len(lista)).rjust(7+len(lista))+'----\n' aux =0 while tamanho > 0: x += " "*4 for i in lista: if len(i)>aux: x += ' '+i[aux]+' ' else: x += ' ' if tamanho == 1: x += " " else: x = x+' \n' aux +=1 tamanho -= 1 return(x)
""" Created on Mon Jul 27 10:49:39 2020 @author: Arthur Donizeti Rodrigues Dias """ class Category: def __init__(self, categories): self.ledger = [] self.categories = categories self.listaDeposito = [] self.listaRetirada = [] self.total_entrada = 0 self.total_saida = 0 def __str__(self): x = self.categories.center(30, '*') + '\n' n = 0 lista_v = [] for i in self.ledger: for (k, v) in self.ledger[n].items(): lista_v.append(v) n += 1 n = 1 for i in self.ledger: y = str(lista_v[n]) x = x + y[0:23].ljust(23) + str(format(lista_v[n - 1], '.2f')).rjust(7) + '\n' n += 2 x = x + 'Total: ' + str(format(self.get_balance(), '.2f')) return x def deposit(self, quantia, description=''): dic = {'amount': quantia, 'description': description} self.total_entrada += quantia self.listaDeposito.append(quantia) self.listaDeposito.append(description) self.ledger.append(dic) def withdraw(self, quantia, description=''): try: if self.total_entrada > quantia: self.total_saida += quantia dic = {'amount': -quantia, 'description': description} self.listaRetirada.append(quantia) self.listaRetirada.append(description) self.ledger.append(dic) return True else: return False except: return False def get_balance(self): return self.total_entrada - self.total_saida def transfer(self, quantia, beneficiario): if quantia <= self.total_entrada: x = f'Transfer to {beneficiario.categories}' self.withdraw(quantia, x) beneficiario.deposit(quantia, f'Transfer from {self.categories}') return True else: return False def check_funds(self, quantia): if quantia <= self.get_balance(): return True else: return False def create_spend_chart(teste): soma = 0.0 cont = 10 tamanho = 0 lista = [] lista_porcentagem = [] for i in teste: x = i.categories if tamanho < len(x): tamanho = len(x) soma += i.total_saida lista.append(x) for i in teste: lista_porcentagem.append(i.total_saida / soma * 10) x = 'Percentage spent by category\n' while cont >= 0: x += f'{cont * 10}|'.rjust(4) for i in lista_porcentagem: if i > cont: x += ' o ' else: x += ' ' x = x + ' \n' cont -= 1 x += ('--' * len(lista)).rjust(7 + len(lista)) + '----\n' aux = 0 while tamanho > 0: x += ' ' * 4 for i in lista: if len(i) > aux: x += ' ' + i[aux] + ' ' else: x += ' ' if tamanho == 1: x += ' ' else: x = x + ' \n' aux += 1 tamanho -= 1 return x
def defaults(): return dict( actor='mlp', ac_kwargs={ 'pi': {'hidden_sizes': (64, 64), 'activation': 'tanh'}, 'val': {'hidden_sizes': (64, 64), 'activation': 'tanh'} }, adv_estimation_method='gae', epochs=300, # 9.8M steps gamma=0.99, lam_c=0.95, steps_per_epoch=64 * 1000, # default: 64k target_kl=0.0001, use_exploration_noise_anneal=True ) def locomotion(): """Default hyper-parameters for Bullet's locomotion environments.""" params = defaults() params['epochs'] = 312 params['max_ep_len'] = 1000 params['steps_per_epoch'] = 32 * 1000 params['vf_lr'] = 3e-4 # default choice is Adam return params # Hack to circumvent kwarg errors with the official PyBullet Envs def gym_locomotion_envs(): params = locomotion() return params def gym_manipulator_envs(): """Default hyper-parameters for Bullet's manipulation environments.""" params = defaults() params['epochs'] = 312 params['max_ep_len'] = 150 params['steps_per_epoch'] = 32 * 1000 params['vf_lr'] = 3e-4 # default choice is Adam return params
def defaults(): return dict(actor='mlp', ac_kwargs={'pi': {'hidden_sizes': (64, 64), 'activation': 'tanh'}, 'val': {'hidden_sizes': (64, 64), 'activation': 'tanh'}}, adv_estimation_method='gae', epochs=300, gamma=0.99, lam_c=0.95, steps_per_epoch=64 * 1000, target_kl=0.0001, use_exploration_noise_anneal=True) def locomotion(): """Default hyper-parameters for Bullet's locomotion environments.""" params = defaults() params['epochs'] = 312 params['max_ep_len'] = 1000 params['steps_per_epoch'] = 32 * 1000 params['vf_lr'] = 0.0003 return params def gym_locomotion_envs(): params = locomotion() return params def gym_manipulator_envs(): """Default hyper-parameters for Bullet's manipulation environments.""" params = defaults() params['epochs'] = 312 params['max_ep_len'] = 150 params['steps_per_epoch'] = 32 * 1000 params['vf_lr'] = 0.0003 return params
class INestedContainer(IContainer,IDisposable): """ Provides functionality for nested containers,which logically contain zero or more other components and are owned by a parent component. """ def __enter__(self,*args): """ __enter__(self: IDisposable) -> object Provides the implementation of __enter__ for objects which implement IDisposable. """ pass def __exit__(self,*args): """ __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) Provides the implementation of __exit__ for objects which implement IDisposable. """ pass def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass Owner=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the owning component for the nested container. Get: Owner(self: INestedContainer) -> IComponent """
class Inestedcontainer(IContainer, IDisposable): """ Provides functionality for nested containers,which logically contain zero or more other components and are owned by a parent component. """ def __enter__(self, *args): """ __enter__(self: IDisposable) -> object Provides the implementation of __enter__ for objects which implement IDisposable. """ pass def __exit__(self, *args): """ __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) Provides the implementation of __exit__ for objects which implement IDisposable. """ pass def __init__(self, *args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass owner = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the owning component for the nested container.\n\n\n\nGet: Owner(self: INestedContainer) -> IComponent\n\n\n\n'