content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
#!python3.6 #encoding: utf-8 # https://teratail.com/questions/52151 class Deco: def __init__(self): self.value = 'value' def deco(func): def wrapper(self, *args, **kwargs): print('----- start -----') print('self.value =', self.value) # AttributeError: 'C' object has no attribute 'value' ret = func(self, *args, **kwargs) print('----- end -----') return ret return wrapper class C: @Deco.deco def test(self, *args, **kwargs): for a in args: print(a) for k,v in kwargs.items(): print(k, v) return 'RETURN' print(C().test(1, 'a', key1='value1'))
class Deco: def __init__(self): self.value = 'value' def deco(func): def wrapper(self, *args, **kwargs): print('----- start -----') print('self.value =', self.value) ret = func(self, *args, **kwargs) print('----- end -----') return ret return wrapper class C: @Deco.deco def test(self, *args, **kwargs): for a in args: print(a) for (k, v) in kwargs.items(): print(k, v) return 'RETURN' print(c().test(1, 'a', key1='value1'))
expected_output = { "Mgmt-intf": { "address_family": { "ipv4 unicast": { "flags": "0x0", "table_id": "0x1", "vrf_label": {"allocation_mode": "per-prefix"}, } }, "cli_format": "New", "flags": "0x1808", "interface": {"GigabitEthernet1": {"vrf": "Mgmt-intf"}}, "interfaces": ["GigabitEthernet1"], "support_af": "multiple address-families", "vrf_id": 1, }, "VRF1": { "address_family": { "ipv4 unicast": { "flags": "0x0", "table_id": "0x2", "vrf_label": { "allocation_mode": "per-prefix", "distribution_protocol": "LDP", }, } }, "cli_format": "New", "flags": "0x180C", "interface": { "GigabitEthernet2.390": {"vrf": "VRF1"}, "GigabitEthernet2.410": {"vrf": "VRF1"}, "GigabitEthernet2.415": {"vrf": "VRF1"}, "GigabitEthernet2.420": {"vrf": "VRF1"}, "GigabitEthernet3.390": {"vrf": "VRF1"}, "GigabitEthernet3.410": {"vrf": "VRF1"}, "GigabitEthernet3.415": {"vrf": "VRF1"}, "GigabitEthernet3.420": {"vrf": "VRF1"}, "Loopback300": {"vrf": "VRF1"}, "Tunnel1": {"vrf": "VRF1"}, "Tunnel3": {"vrf": "VRF1"}, "Tunnel4": {"vrf": "VRF1"}, "Tunnel6": {"vrf": "VRF1"}, "Tunnel8": {"vrf": "VRF1"}, }, "interfaces": [ "Tunnel1", "Loopback300", "GigabitEthernet2.390", "GigabitEthernet2.410", "GigabitEthernet2.415", "GigabitEthernet2.420", "GigabitEthernet3.390", "GigabitEthernet3.410", "GigabitEthernet3.415", "GigabitEthernet3.420", "Tunnel3", "Tunnel4", "Tunnel6", "Tunnel8", ], "route_distinguisher": "65000:1", "support_af": "multiple address-families", "vrf_id": 2, }, }
expected_output = {'Mgmt-intf': {'address_family': {'ipv4 unicast': {'flags': '0x0', 'table_id': '0x1', 'vrf_label': {'allocation_mode': 'per-prefix'}}}, 'cli_format': 'New', 'flags': '0x1808', 'interface': {'GigabitEthernet1': {'vrf': 'Mgmt-intf'}}, 'interfaces': ['GigabitEthernet1'], 'support_af': 'multiple address-families', 'vrf_id': 1}, 'VRF1': {'address_family': {'ipv4 unicast': {'flags': '0x0', 'table_id': '0x2', 'vrf_label': {'allocation_mode': 'per-prefix', 'distribution_protocol': 'LDP'}}}, 'cli_format': 'New', 'flags': '0x180C', 'interface': {'GigabitEthernet2.390': {'vrf': 'VRF1'}, 'GigabitEthernet2.410': {'vrf': 'VRF1'}, 'GigabitEthernet2.415': {'vrf': 'VRF1'}, 'GigabitEthernet2.420': {'vrf': 'VRF1'}, 'GigabitEthernet3.390': {'vrf': 'VRF1'}, 'GigabitEthernet3.410': {'vrf': 'VRF1'}, 'GigabitEthernet3.415': {'vrf': 'VRF1'}, 'GigabitEthernet3.420': {'vrf': 'VRF1'}, 'Loopback300': {'vrf': 'VRF1'}, 'Tunnel1': {'vrf': 'VRF1'}, 'Tunnel3': {'vrf': 'VRF1'}, 'Tunnel4': {'vrf': 'VRF1'}, 'Tunnel6': {'vrf': 'VRF1'}, 'Tunnel8': {'vrf': 'VRF1'}}, 'interfaces': ['Tunnel1', 'Loopback300', 'GigabitEthernet2.390', 'GigabitEthernet2.410', 'GigabitEthernet2.415', 'GigabitEthernet2.420', 'GigabitEthernet3.390', 'GigabitEthernet3.410', 'GigabitEthernet3.415', 'GigabitEthernet3.420', 'Tunnel3', 'Tunnel4', 'Tunnel6', 'Tunnel8'], 'route_distinguisher': '65000:1', 'support_af': 'multiple address-families', 'vrf_id': 2}}
class Solution: def longestDupSubstring(self, s: str) -> str: kMod = int(1e9) + 7 bestStart = -1 l = 1 r = len(s) def val(c: str) -> int: return ord(c) - ord('a') # k := length of hashed substring def getStart(k: int) -> Optional[int]: maxPow = pow(26, k - 1, kMod) hashedToStart = defaultdict(list) h = 0 # compute hash value of s[:k] for i in range(k): h = (h * 26 + val(s[i])) % kMod hashedToStart[h].append(0) # compute rolling hash by Rabin Karp for i in range(k, len(s)): startIndex = i - k + 1 h = (h - maxPow * val(s[i - k])) % kMod h = (h * 26 + val(s[i])) % kMod if h in hashedToStart: currSub = s[startIndex:startIndex + k] for start in hashedToStart[h]: if s[start:start + k] == currSub: return startIndex hashedToStart[h].append(startIndex) while l < r: m = (l + r) // 2 start: Optional[int] = getStart(m) if start: bestStart = start l = m + 1 else: r = m if bestStart == -1: return '' if getStart(l): return s[bestStart:bestStart + l] return s[bestStart:bestStart + l - 1]
class Solution: def longest_dup_substring(self, s: str) -> str: k_mod = int(1000000000.0) + 7 best_start = -1 l = 1 r = len(s) def val(c: str) -> int: return ord(c) - ord('a') def get_start(k: int) -> Optional[int]: max_pow = pow(26, k - 1, kMod) hashed_to_start = defaultdict(list) h = 0 for i in range(k): h = (h * 26 + val(s[i])) % kMod hashedToStart[h].append(0) for i in range(k, len(s)): start_index = i - k + 1 h = (h - maxPow * val(s[i - k])) % kMod h = (h * 26 + val(s[i])) % kMod if h in hashedToStart: curr_sub = s[startIndex:startIndex + k] for start in hashedToStart[h]: if s[start:start + k] == currSub: return startIndex hashedToStart[h].append(startIndex) while l < r: m = (l + r) // 2 start: Optional[int] = get_start(m) if start: best_start = start l = m + 1 else: r = m if bestStart == -1: return '' if get_start(l): return s[bestStart:bestStart + l] return s[bestStart:bestStart + l - 1]
# parsetab.py # This file is automatically generated. Do not edit. # pylint: disable=W,C,R _tabversion = '3.10' _lr_method = 'LALR' _lr_signature = "rightASSIGNrightNOTnonassocLESSEQ<=left+-left*/rightISVOIDleft~left@left.ASSIGN CASE CLASS COMMENT ELSE ESAC FALSE FI ID IF IN INHERITS INT ISVOID LESSEQ LET LOOP NEW NOT OF POOL RET STRING THEN TRUE TYPE WHILEprogram : class_listclass_list : class ';' class_list\n | class ';'class : CLASS TYPE INHERITS TYPE '{' feature_list '}'\n | CLASS TYPE '{' feature_list '}'feature_list : attribute ';' feature_list\n | method ';' feature_list\n | emptyattribute : ID ':' TYPE ASSIGN expression\n | ID ':' TYPE method : ID '(' params_list ')' ':' TYPE '{' expression '}'params_list : param ',' params_list\n | paramparams_list : emptyparam : ID ':' TYPEexpression_list : expression ';' expression_list\n | expression ';' expression : ID ASSIGN expressionexpression : IF expression THEN expression ELSE expression FIexpression : WHILE expression LOOP expression POOLexpression : '{' expression_list '}'expression : LET let_list IN expressionlet_list : let_single ',' let_list\n | let_singlelet_single : ID ':' TYPE ASSIGN expression\n | ID ':' TYPEexpression : CASE expression OF case_list ESACcase_list : case_single case_list\n | case_singlecase_single : ID ':' TYPE RET expression ';'expression : expression '@' TYPE '.' ID '(' args_list ')'\n | expression '.' ID '(' args_list ')'\n | ID '(' args_list ')'args_list : expression ',' args_list\n | expressionargs_list : emptyexpression : NEW TYPEexpression : ISVOID expressionexpression : NOT expressionexpression : '~' expressionexpression : expression '+' expressionexpression : expression '-' expressionexpression : expression '/' expressionexpression : expression '*' expressionexpression : expression '<' expressionexpression : expression LESSEQ expressionexpression : expression '=' expressionexpression : '(' expression ')'expression : STRINGexpression : IDexpression : TRUEexpression : FALSEexpression : INTempty : " _lr_action_items = {'CLASS':([0,5,],[4,4,]),'$end':([1,2,5,7,],[0,-1,-3,-2,]),';':([3,12,13,17,25,30,35,36,47,48,49,50,68,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,120,122,125,127,132,134,135,],[5,18,19,-5,-10,-4,-50,-9,-49,-51,-52,-53,95,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-20,-27,-11,-32,-19,-31,136,]),'TYPE':([4,8,20,32,43,52,56,98,124,],[6,10,25,51,74,78,83,111,130,]),'INHERITS':([6,],[8,]),'{':([6,10,31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,78,92,93,95,96,101,103,105,119,121,126,133,],[9,16,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,101,39,39,39,39,39,39,39,39,39,39,39,]),'ID':([9,16,18,19,21,31,34,37,38,39,40,41,42,44,45,46,54,55,57,58,59,60,61,62,63,64,92,93,95,96,97,99,101,103,104,105,113,119,121,126,133,136,],[15,15,15,15,26,35,26,35,35,35,71,35,35,35,35,35,35,35,84,35,35,35,35,35,35,35,35,35,35,35,71,114,35,35,117,35,114,35,35,35,35,-30,]),'}':([9,11,14,16,18,19,22,23,24,35,47,48,49,50,67,74,75,76,77,79,85,86,87,88,89,90,91,94,95,100,102,108,109,115,120,122,127,132,134,],[-54,17,-8,-54,-54,-54,30,-6,-7,-50,-49,-51,-52,-53,94,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-17,-48,-33,-16,-22,125,-20,-27,-32,-19,-31,]),':':([15,26,33,71,114,],[20,32,52,98,124,]),'(':([15,31,35,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,84,92,93,95,96,101,103,105,117,119,121,126,133,],[21,42,55,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,105,42,42,42,42,42,42,42,126,42,42,42,42,]),')':([21,27,28,29,34,35,47,48,49,50,51,53,55,73,74,75,76,77,79,80,81,82,85,86,87,88,89,90,91,94,100,102,103,105,109,116,118,120,122,126,127,131,132,134,],[-54,33,-13,-14,-54,-50,-49,-51,-52,-53,-15,-12,-54,100,-37,-38,-39,-40,-18,102,-35,-36,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-54,-54,-22,-34,127,-20,-27,-54,-32,134,-19,-31,]),'ASSIGN':([25,35,111,],[31,54,121,]),',':([28,35,47,48,49,50,51,70,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,109,111,120,122,127,129,132,134,],[34,-50,-49,-51,-52,-53,-15,97,-37,-38,-39,-40,-18,103,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-26,-20,-27,-32,-25,-19,-31,]),'IF':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,]),'WHILE':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,]),'LET':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,]),'CASE':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,]),'NEW':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,]),'ISVOID':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,]),'NOT':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,]),'~':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,]),'STRING':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,]),'TRUE':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,]),'FALSE':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,]),'INT':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,]),'@':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,56,-49,-51,-52,-53,56,56,56,56,56,-37,56,56,56,56,56,56,56,56,56,56,56,56,-21,-48,-33,56,56,56,56,-20,-27,-32,56,56,-19,-31,56,]),'.':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,83,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,57,-49,-51,-52,-53,57,57,57,57,57,-37,57,57,57,57,57,104,57,57,57,57,57,57,57,-21,-48,-33,57,57,57,57,-20,-27,-32,57,57,-19,-31,57,]),'+':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,58,-49,-51,-52,-53,58,58,58,58,58,-37,-38,58,-40,58,58,-41,-42,-43,-44,58,58,58,-21,-48,-33,58,58,58,58,-20,-27,-32,58,58,-19,-31,58,]),'-':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,59,-49,-51,-52,-53,59,59,59,59,59,-37,-38,59,-40,59,59,-41,-42,-43,-44,59,59,59,-21,-48,-33,59,59,59,59,-20,-27,-32,59,59,-19,-31,59,]),'/':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,60,-49,-51,-52,-53,60,60,60,60,60,-37,-38,60,-40,60,60,60,60,-43,-44,60,60,60,-21,-48,-33,60,60,60,60,-20,-27,-32,60,60,-19,-31,60,]),'*':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,61,-49,-51,-52,-53,61,61,61,61,61,-37,-38,61,-40,61,61,61,61,-43,-44,61,61,61,-21,-48,-33,61,61,61,61,-20,-27,-32,61,61,-19,-31,61,]),'<':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,62,-49,-51,-52,-53,62,62,62,62,62,-37,-38,62,-40,62,62,-41,-42,-43,-44,None,None,None,-21,-48,-33,62,62,62,62,-20,-27,-32,62,62,-19,-31,62,]),'LESSEQ':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,63,-49,-51,-52,-53,63,63,63,63,63,-37,-38,63,-40,63,63,-41,-42,-43,-44,None,None,None,-21,-48,-33,63,63,63,63,-20,-27,-32,63,63,-19,-31,63,]),'=':([35,36,47,48,49,50,65,66,68,72,73,74,75,76,77,79,81,85,86,87,88,89,90,91,94,100,102,106,107,109,115,120,122,127,128,129,132,134,135,],[-50,64,-49,-51,-52,-53,64,64,64,64,64,-37,-38,64,-40,64,64,-41,-42,-43,-44,None,None,None,-21,-48,-33,64,64,64,64,-20,-27,-32,64,64,-19,-31,64,]),'THEN':([35,47,48,49,50,65,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,120,122,127,132,134,],[-50,-49,-51,-52,-53,92,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-20,-27,-32,-19,-31,]),'LOOP':([35,47,48,49,50,66,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,120,122,127,132,134,],[-50,-49,-51,-52,-53,93,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-20,-27,-32,-19,-31,]),'OF':([35,47,48,49,50,72,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,120,122,127,132,134,],[-50,-49,-51,-52,-53,99,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-20,-27,-32,-19,-31,]),'ELSE':([35,47,48,49,50,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,106,109,120,122,127,132,134,],[-50,-49,-51,-52,-53,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,119,-22,-20,-27,-32,-19,-31,]),'POOL':([35,47,48,49,50,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,107,109,120,122,127,132,134,],[-50,-49,-51,-52,-53,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,120,-22,-20,-27,-32,-19,-31,]),'FI':([35,47,48,49,50,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,120,122,127,128,132,134,],[-50,-49,-51,-52,-53,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-20,-27,-32,132,-19,-31,]),'IN':([35,47,48,49,50,69,70,74,75,76,77,79,85,86,87,88,89,90,91,94,100,102,109,110,111,120,122,127,129,132,134,],[-50,-49,-51,-52,-53,96,-24,-37,-38,-39,-40,-18,-41,-42,-43,-44,-45,-46,-47,-21,-48,-33,-22,-23,-26,-20,-27,-32,-25,-19,-31,]),'ESAC':([112,113,123,136,],[122,-29,-28,-30,]),'RET':([130,],[133,]),} _lr_action = {} for _k, _v in _lr_action_items.items(): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'program':([0,],[1,]),'class_list':([0,5,],[2,7,]),'class':([0,5,],[3,3,]),'feature_list':([9,16,18,19,],[11,22,23,24,]),'attribute':([9,16,18,19,],[12,12,12,12,]),'method':([9,16,18,19,],[13,13,13,13,]),'empty':([9,16,18,19,21,34,55,103,105,126,],[14,14,14,14,29,29,82,82,82,82,]),'params_list':([21,34,],[27,53,]),'param':([21,34,],[28,28,]),'expression':([31,37,38,39,41,42,44,45,46,54,55,58,59,60,61,62,63,64,92,93,95,96,101,103,105,119,121,126,133,],[36,65,66,68,72,73,75,76,77,79,81,85,86,87,88,89,90,91,106,107,68,109,115,81,81,128,129,81,135,]),'expression_list':([39,95,],[67,108,]),'let_list':([40,97,],[69,110,]),'let_single':([40,97,],[70,70,]),'args_list':([55,103,105,126,],[80,116,118,131,]),'case_list':([99,113,],[112,123,]),'case_single':([99,113,],[113,113,]),} _lr_goto = {} for _k, _v in _lr_goto_items.items(): for _x, _y in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [ ("S' -> program","S'",1,None,None,None), ('program -> class_list','program',1,'p_program','parsing_rules.py',13), ('class_list -> class ; class_list','class_list',3,'p_class_list','parsing_rules.py',18), ('class_list -> class ;','class_list',2,'p_class_list','parsing_rules.py',19), ('class -> CLASS TYPE INHERITS TYPE { feature_list }','class',7,'p_class','parsing_rules.py',27), ('class -> CLASS TYPE { feature_list }','class',5,'p_class','parsing_rules.py',28), ('feature_list -> attribute ; feature_list','feature_list',3,'p_feature_list','parsing_rules.py',39), ('feature_list -> method ; feature_list','feature_list',3,'p_feature_list','parsing_rules.py',40), ('feature_list -> empty','feature_list',1,'p_feature_list','parsing_rules.py',41), ('attribute -> ID : TYPE ASSIGN expression','attribute',5,'p_attribute','parsing_rules.py',49), ('attribute -> ID : TYPE','attribute',3,'p_attribute','parsing_rules.py',50), ('method -> ID ( params_list ) : TYPE { expression }','method',9,'p_method','parsing_rules.py',60), ('params_list -> param , params_list','params_list',3,'p_params_list','parsing_rules.py',66), ('params_list -> param','params_list',1,'p_params_list','parsing_rules.py',67), ('params_list -> empty','params_list',1,'p_params_list_empty','parsing_rules.py',74), ('param -> ID : TYPE','param',3,'p_param','parsing_rules.py',79), ('expression_list -> expression ; expression_list','expression_list',3,'p_expression_list','parsing_rules.py',86), ('expression_list -> expression ;','expression_list',2,'p_expression_list','parsing_rules.py',87), ('expression -> ID ASSIGN expression','expression',3,'p_expression_assigment','parsing_rules.py',95), ('expression -> IF expression THEN expression ELSE expression FI','expression',7,'p_expression_if_then_else','parsing_rules.py',102), ('expression -> WHILE expression LOOP expression POOL','expression',5,'p_expression_while','parsing_rules.py',109), ('expression -> { expression_list }','expression',3,'p_expression_block','parsing_rules.py',116), ('expression -> LET let_list IN expression','expression',4,'p_expression_let_in','parsing_rules.py',123), ('let_list -> let_single , let_list','let_list',3,'p_let_list','parsing_rules.py',130), ('let_list -> let_single','let_list',1,'p_let_list','parsing_rules.py',131), ('let_single -> ID : TYPE ASSIGN expression','let_single',5,'p_let_single','parsing_rules.py',139), ('let_single -> ID : TYPE','let_single',3,'p_let_single','parsing_rules.py',140), ('expression -> CASE expression OF case_list ESAC','expression',5,'p_expression_case','parsing_rules.py',150), ('case_list -> case_single case_list','case_list',2,'p_case_list','parsing_rules.py',157), ('case_list -> case_single','case_list',1,'p_case_list','parsing_rules.py',158), ('case_single -> ID : TYPE RET expression ;','case_single',6,'p_case_single','parsing_rules.py',166), ('expression -> expression @ TYPE . ID ( args_list )','expression',8,'p_expression_dispatch','parsing_rules.py',174), ('expression -> expression . ID ( args_list )','expression',6,'p_expression_dispatch','parsing_rules.py',175), ('expression -> ID ( args_list )','expression',4,'p_expression_dispatch','parsing_rules.py',176), ('args_list -> expression , args_list','args_list',3,'p_args_list','parsing_rules.py',192), ('args_list -> expression','args_list',1,'p_args_list','parsing_rules.py',193), ('args_list -> empty','args_list',1,'p_args_list_empty','parsing_rules.py',201), ('expression -> NEW TYPE','expression',2,'p_expression_instatiate','parsing_rules.py',205), ('expression -> ISVOID expression','expression',2,'p_expression_isvoid','parsing_rules.py',212), ('expression -> NOT expression','expression',2,'p_expression_not','parsing_rules.py',218), ('expression -> ~ expression','expression',2,'p_expression_complement','parsing_rules.py',225), ('expression -> expression + expression','expression',3,'p_expression_plus','parsing_rules.py',232), ('expression -> expression - expression','expression',3,'p_expression_minus','parsing_rules.py',239), ('expression -> expression / expression','expression',3,'p_expression_div','parsing_rules.py',246), ('expression -> expression * expression','expression',3,'p_expression_star','parsing_rules.py',252), ('expression -> expression < expression','expression',3,'p_expression_less','parsing_rules.py',258), ('expression -> expression LESSEQ expression','expression',3,'p_expression_lesseq','parsing_rules.py',264), ('expression -> expression = expression','expression',3,'p_expression_equals','parsing_rules.py',270), ('expression -> ( expression )','expression',3,'p_expression_parentheses','parsing_rules.py',276), ('expression -> STRING','expression',1,'p_expression_string','parsing_rules.py',283), ('expression -> ID','expression',1,'p_expression_variable','parsing_rules.py',290), ('expression -> TRUE','expression',1,'p_expression_true','parsing_rules.py',297), ('expression -> FALSE','expression',1,'p_expression_false','parsing_rules.py',304), ('expression -> INT','expression',1,'p_expression_int','parsing_rules.py',311), ('empty -> <empty>','empty',0,'p_empty','parsing_rules.py',318), ]
_tabversion = '3.10' _lr_method = 'LALR' _lr_signature = "rightASSIGNrightNOTnonassocLESSEQ<=left+-left*/rightISVOIDleft~left@left.ASSIGN CASE CLASS COMMENT ELSE ESAC FALSE FI ID IF IN INHERITS INT ISVOID LESSEQ LET LOOP NEW NOT OF POOL RET STRING THEN TRUE TYPE WHILEprogram : class_listclass_list : class ';' class_list\n | class ';'class : CLASS TYPE INHERITS TYPE '{' feature_list '}'\n | CLASS TYPE '{' feature_list '}'feature_list : attribute ';' feature_list\n | method ';' feature_list\n | emptyattribute : ID ':' TYPE ASSIGN expression\n | ID ':' TYPE method : ID '(' params_list ')' ':' TYPE '{' expression '}'params_list : param ',' params_list\n | paramparams_list : emptyparam : ID ':' TYPEexpression_list : expression ';' expression_list\n | expression ';' expression : ID ASSIGN expressionexpression : IF expression THEN expression ELSE expression FIexpression : WHILE expression LOOP expression POOLexpression : '{' expression_list '}'expression : LET let_list IN expressionlet_list : let_single ',' let_list\n | let_singlelet_single : ID ':' TYPE ASSIGN expression\n | ID ':' TYPEexpression : CASE expression OF case_list ESACcase_list : case_single case_list\n | case_singlecase_single : ID ':' TYPE RET expression ';'expression : expression '@' TYPE '.' ID '(' args_list ')'\n | expression '.' ID '(' args_list ')'\n | ID '(' args_list ')'args_list : expression ',' args_list\n | expressionargs_list : emptyexpression : NEW TYPEexpression : ISVOID expressionexpression : NOT expressionexpression : '~' expressionexpression : expression '+' expressionexpression : expression '-' expressionexpression : expression '/' expressionexpression : expression '*' expressionexpression : expression '<' expressionexpression : expression LESSEQ expressionexpression : expression '=' expressionexpression : '(' expression ')'expression : STRINGexpression : IDexpression : TRUEexpression : FALSEexpression : INTempty : " _lr_action_items = {'CLASS': ([0, 5], [4, 4]), '$end': ([1, 2, 5, 7], [0, -1, -3, -2]), ';': ([3, 12, 13, 17, 25, 30, 35, 36, 47, 48, 49, 50, 68, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 120, 122, 125, 127, 132, 134, 135], [5, 18, 19, -5, -10, -4, -50, -9, -49, -51, -52, -53, 95, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -20, -27, -11, -32, -19, -31, 136]), 'TYPE': ([4, 8, 20, 32, 43, 52, 56, 98, 124], [6, 10, 25, 51, 74, 78, 83, 111, 130]), 'INHERITS': ([6], [8]), '{': ([6, 10, 31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 78, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [9, 16, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 101, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39]), 'ID': ([9, 16, 18, 19, 21, 31, 34, 37, 38, 39, 40, 41, 42, 44, 45, 46, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 97, 99, 101, 103, 104, 105, 113, 119, 121, 126, 133, 136], [15, 15, 15, 15, 26, 35, 26, 35, 35, 35, 71, 35, 35, 35, 35, 35, 35, 35, 84, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 71, 114, 35, 35, 117, 35, 114, 35, 35, 35, 35, -30]), '}': ([9, 11, 14, 16, 18, 19, 22, 23, 24, 35, 47, 48, 49, 50, 67, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 95, 100, 102, 108, 109, 115, 120, 122, 127, 132, 134], [-54, 17, -8, -54, -54, -54, 30, -6, -7, -50, -49, -51, -52, -53, 94, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -17, -48, -33, -16, -22, 125, -20, -27, -32, -19, -31]), ':': ([15, 26, 33, 71, 114], [20, 32, 52, 98, 124]), '(': ([15, 31, 35, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 84, 92, 93, 95, 96, 101, 103, 105, 117, 119, 121, 126, 133], [21, 42, 55, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 105, 42, 42, 42, 42, 42, 42, 42, 126, 42, 42, 42, 42]), ')': ([21, 27, 28, 29, 34, 35, 47, 48, 49, 50, 51, 53, 55, 73, 74, 75, 76, 77, 79, 80, 81, 82, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 103, 105, 109, 116, 118, 120, 122, 126, 127, 131, 132, 134], [-54, 33, -13, -14, -54, -50, -49, -51, -52, -53, -15, -12, -54, 100, -37, -38, -39, -40, -18, 102, -35, -36, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -54, -54, -22, -34, 127, -20, -27, -54, -32, 134, -19, -31]), 'ASSIGN': ([25, 35, 111], [31, 54, 121]), ',': ([28, 35, 47, 48, 49, 50, 51, 70, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 111, 120, 122, 127, 129, 132, 134], [34, -50, -49, -51, -52, -53, -15, 97, -37, -38, -39, -40, -18, 103, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -26, -20, -27, -32, -25, -19, -31]), 'IF': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37]), 'WHILE': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38]), 'LET': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40]), 'CASE': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41]), 'NEW': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43]), 'ISVOID': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44]), 'NOT': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]), '~': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46]), 'STRING': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47]), 'TRUE': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), 'FALSE': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49]), 'INT': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]), '@': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 56, -49, -51, -52, -53, 56, 56, 56, 56, 56, -37, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, -21, -48, -33, 56, 56, 56, 56, -20, -27, -32, 56, 56, -19, -31, 56]), '.': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 83, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 57, -49, -51, -52, -53, 57, 57, 57, 57, 57, -37, 57, 57, 57, 57, 57, 104, 57, 57, 57, 57, 57, 57, 57, -21, -48, -33, 57, 57, 57, 57, -20, -27, -32, 57, 57, -19, -31, 57]), '+': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 58, -49, -51, -52, -53, 58, 58, 58, 58, 58, -37, -38, 58, -40, 58, 58, -41, -42, -43, -44, 58, 58, 58, -21, -48, -33, 58, 58, 58, 58, -20, -27, -32, 58, 58, -19, -31, 58]), '-': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 59, -49, -51, -52, -53, 59, 59, 59, 59, 59, -37, -38, 59, -40, 59, 59, -41, -42, -43, -44, 59, 59, 59, -21, -48, -33, 59, 59, 59, 59, -20, -27, -32, 59, 59, -19, -31, 59]), '/': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 60, -49, -51, -52, -53, 60, 60, 60, 60, 60, -37, -38, 60, -40, 60, 60, 60, 60, -43, -44, 60, 60, 60, -21, -48, -33, 60, 60, 60, 60, -20, -27, -32, 60, 60, -19, -31, 60]), '*': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 61, -49, -51, -52, -53, 61, 61, 61, 61, 61, -37, -38, 61, -40, 61, 61, 61, 61, -43, -44, 61, 61, 61, -21, -48, -33, 61, 61, 61, 61, -20, -27, -32, 61, 61, -19, -31, 61]), '<': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 62, -49, -51, -52, -53, 62, 62, 62, 62, 62, -37, -38, 62, -40, 62, 62, -41, -42, -43, -44, None, None, None, -21, -48, -33, 62, 62, 62, 62, -20, -27, -32, 62, 62, -19, -31, 62]), 'LESSEQ': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 63, -49, -51, -52, -53, 63, 63, 63, 63, 63, -37, -38, 63, -40, 63, 63, -41, -42, -43, -44, None, None, None, -21, -48, -33, 63, 63, 63, 63, -20, -27, -32, 63, 63, -19, -31, 63]), '=': ([35, 36, 47, 48, 49, 50, 65, 66, 68, 72, 73, 74, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 107, 109, 115, 120, 122, 127, 128, 129, 132, 134, 135], [-50, 64, -49, -51, -52, -53, 64, 64, 64, 64, 64, -37, -38, 64, -40, 64, 64, -41, -42, -43, -44, None, None, None, -21, -48, -33, 64, 64, 64, 64, -20, -27, -32, 64, 64, -19, -31, 64]), 'THEN': ([35, 47, 48, 49, 50, 65, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 120, 122, 127, 132, 134], [-50, -49, -51, -52, -53, 92, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -20, -27, -32, -19, -31]), 'LOOP': ([35, 47, 48, 49, 50, 66, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 120, 122, 127, 132, 134], [-50, -49, -51, -52, -53, 93, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -20, -27, -32, -19, -31]), 'OF': ([35, 47, 48, 49, 50, 72, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 120, 122, 127, 132, 134], [-50, -49, -51, -52, -53, 99, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -20, -27, -32, -19, -31]), 'ELSE': ([35, 47, 48, 49, 50, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 106, 109, 120, 122, 127, 132, 134], [-50, -49, -51, -52, -53, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, 119, -22, -20, -27, -32, -19, -31]), 'POOL': ([35, 47, 48, 49, 50, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 107, 109, 120, 122, 127, 132, 134], [-50, -49, -51, -52, -53, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, 120, -22, -20, -27, -32, -19, -31]), 'FI': ([35, 47, 48, 49, 50, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 120, 122, 127, 128, 132, 134], [-50, -49, -51, -52, -53, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -20, -27, -32, 132, -19, -31]), 'IN': ([35, 47, 48, 49, 50, 69, 70, 74, 75, 76, 77, 79, 85, 86, 87, 88, 89, 90, 91, 94, 100, 102, 109, 110, 111, 120, 122, 127, 129, 132, 134], [-50, -49, -51, -52, -53, 96, -24, -37, -38, -39, -40, -18, -41, -42, -43, -44, -45, -46, -47, -21, -48, -33, -22, -23, -26, -20, -27, -32, -25, -19, -31]), 'ESAC': ([112, 113, 123, 136], [122, -29, -28, -30]), 'RET': ([130], [133])} _lr_action = {} for (_k, _v) in _lr_action_items.items(): for (_x, _y) in zip(_v[0], _v[1]): if not _x in _lr_action: _lr_action[_x] = {} _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'program': ([0], [1]), 'class_list': ([0, 5], [2, 7]), 'class': ([0, 5], [3, 3]), 'feature_list': ([9, 16, 18, 19], [11, 22, 23, 24]), 'attribute': ([9, 16, 18, 19], [12, 12, 12, 12]), 'method': ([9, 16, 18, 19], [13, 13, 13, 13]), 'empty': ([9, 16, 18, 19, 21, 34, 55, 103, 105, 126], [14, 14, 14, 14, 29, 29, 82, 82, 82, 82]), 'params_list': ([21, 34], [27, 53]), 'param': ([21, 34], [28, 28]), 'expression': ([31, 37, 38, 39, 41, 42, 44, 45, 46, 54, 55, 58, 59, 60, 61, 62, 63, 64, 92, 93, 95, 96, 101, 103, 105, 119, 121, 126, 133], [36, 65, 66, 68, 72, 73, 75, 76, 77, 79, 81, 85, 86, 87, 88, 89, 90, 91, 106, 107, 68, 109, 115, 81, 81, 128, 129, 81, 135]), 'expression_list': ([39, 95], [67, 108]), 'let_list': ([40, 97], [69, 110]), 'let_single': ([40, 97], [70, 70]), 'args_list': ([55, 103, 105, 126], [80, 116, 118, 131]), 'case_list': ([99, 113], [112, 123]), 'case_single': ([99, 113], [113, 113])} _lr_goto = {} for (_k, _v) in _lr_goto_items.items(): for (_x, _y) in zip(_v[0], _v[1]): if not _x in _lr_goto: _lr_goto[_x] = {} _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [("S' -> program", "S'", 1, None, None, None), ('program -> class_list', 'program', 1, 'p_program', 'parsing_rules.py', 13), ('class_list -> class ; class_list', 'class_list', 3, 'p_class_list', 'parsing_rules.py', 18), ('class_list -> class ;', 'class_list', 2, 'p_class_list', 'parsing_rules.py', 19), ('class -> CLASS TYPE INHERITS TYPE { feature_list }', 'class', 7, 'p_class', 'parsing_rules.py', 27), ('class -> CLASS TYPE { feature_list }', 'class', 5, 'p_class', 'parsing_rules.py', 28), ('feature_list -> attribute ; feature_list', 'feature_list', 3, 'p_feature_list', 'parsing_rules.py', 39), ('feature_list -> method ; feature_list', 'feature_list', 3, 'p_feature_list', 'parsing_rules.py', 40), ('feature_list -> empty', 'feature_list', 1, 'p_feature_list', 'parsing_rules.py', 41), ('attribute -> ID : TYPE ASSIGN expression', 'attribute', 5, 'p_attribute', 'parsing_rules.py', 49), ('attribute -> ID : TYPE', 'attribute', 3, 'p_attribute', 'parsing_rules.py', 50), ('method -> ID ( params_list ) : TYPE { expression }', 'method', 9, 'p_method', 'parsing_rules.py', 60), ('params_list -> param , params_list', 'params_list', 3, 'p_params_list', 'parsing_rules.py', 66), ('params_list -> param', 'params_list', 1, 'p_params_list', 'parsing_rules.py', 67), ('params_list -> empty', 'params_list', 1, 'p_params_list_empty', 'parsing_rules.py', 74), ('param -> ID : TYPE', 'param', 3, 'p_param', 'parsing_rules.py', 79), ('expression_list -> expression ; expression_list', 'expression_list', 3, 'p_expression_list', 'parsing_rules.py', 86), ('expression_list -> expression ;', 'expression_list', 2, 'p_expression_list', 'parsing_rules.py', 87), ('expression -> ID ASSIGN expression', 'expression', 3, 'p_expression_assigment', 'parsing_rules.py', 95), ('expression -> IF expression THEN expression ELSE expression FI', 'expression', 7, 'p_expression_if_then_else', 'parsing_rules.py', 102), ('expression -> WHILE expression LOOP expression POOL', 'expression', 5, 'p_expression_while', 'parsing_rules.py', 109), ('expression -> { expression_list }', 'expression', 3, 'p_expression_block', 'parsing_rules.py', 116), ('expression -> LET let_list IN expression', 'expression', 4, 'p_expression_let_in', 'parsing_rules.py', 123), ('let_list -> let_single , let_list', 'let_list', 3, 'p_let_list', 'parsing_rules.py', 130), ('let_list -> let_single', 'let_list', 1, 'p_let_list', 'parsing_rules.py', 131), ('let_single -> ID : TYPE ASSIGN expression', 'let_single', 5, 'p_let_single', 'parsing_rules.py', 139), ('let_single -> ID : TYPE', 'let_single', 3, 'p_let_single', 'parsing_rules.py', 140), ('expression -> CASE expression OF case_list ESAC', 'expression', 5, 'p_expression_case', 'parsing_rules.py', 150), ('case_list -> case_single case_list', 'case_list', 2, 'p_case_list', 'parsing_rules.py', 157), ('case_list -> case_single', 'case_list', 1, 'p_case_list', 'parsing_rules.py', 158), ('case_single -> ID : TYPE RET expression ;', 'case_single', 6, 'p_case_single', 'parsing_rules.py', 166), ('expression -> expression @ TYPE . ID ( args_list )', 'expression', 8, 'p_expression_dispatch', 'parsing_rules.py', 174), ('expression -> expression . ID ( args_list )', 'expression', 6, 'p_expression_dispatch', 'parsing_rules.py', 175), ('expression -> ID ( args_list )', 'expression', 4, 'p_expression_dispatch', 'parsing_rules.py', 176), ('args_list -> expression , args_list', 'args_list', 3, 'p_args_list', 'parsing_rules.py', 192), ('args_list -> expression', 'args_list', 1, 'p_args_list', 'parsing_rules.py', 193), ('args_list -> empty', 'args_list', 1, 'p_args_list_empty', 'parsing_rules.py', 201), ('expression -> NEW TYPE', 'expression', 2, 'p_expression_instatiate', 'parsing_rules.py', 205), ('expression -> ISVOID expression', 'expression', 2, 'p_expression_isvoid', 'parsing_rules.py', 212), ('expression -> NOT expression', 'expression', 2, 'p_expression_not', 'parsing_rules.py', 218), ('expression -> ~ expression', 'expression', 2, 'p_expression_complement', 'parsing_rules.py', 225), ('expression -> expression + expression', 'expression', 3, 'p_expression_plus', 'parsing_rules.py', 232), ('expression -> expression - expression', 'expression', 3, 'p_expression_minus', 'parsing_rules.py', 239), ('expression -> expression / expression', 'expression', 3, 'p_expression_div', 'parsing_rules.py', 246), ('expression -> expression * expression', 'expression', 3, 'p_expression_star', 'parsing_rules.py', 252), ('expression -> expression < expression', 'expression', 3, 'p_expression_less', 'parsing_rules.py', 258), ('expression -> expression LESSEQ expression', 'expression', 3, 'p_expression_lesseq', 'parsing_rules.py', 264), ('expression -> expression = expression', 'expression', 3, 'p_expression_equals', 'parsing_rules.py', 270), ('expression -> ( expression )', 'expression', 3, 'p_expression_parentheses', 'parsing_rules.py', 276), ('expression -> STRING', 'expression', 1, 'p_expression_string', 'parsing_rules.py', 283), ('expression -> ID', 'expression', 1, 'p_expression_variable', 'parsing_rules.py', 290), ('expression -> TRUE', 'expression', 1, 'p_expression_true', 'parsing_rules.py', 297), ('expression -> FALSE', 'expression', 1, 'p_expression_false', 'parsing_rules.py', 304), ('expression -> INT', 'expression', 1, 'p_expression_int', 'parsing_rules.py', 311), ('empty -> <empty>', 'empty', 0, 'p_empty', 'parsing_rules.py', 318)]
# # PySNMP MIB module EXTRAHOP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EXTRAHOP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:53:00 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) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint") ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") Integer32, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, IpAddress, Counter64, enterprises, MibIdentifier, NotificationType, Gauge32, Unsigned32, TimeTicks, ObjectIdentity, ModuleIdentity, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "IpAddress", "Counter64", "enterprises", "MibIdentifier", "NotificationType", "Gauge32", "Unsigned32", "TimeTicks", "ObjectIdentity", "ModuleIdentity", "Counter32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") extrahop = ModuleIdentity((1, 3, 6, 1, 4, 1, 32015)) extrahop.setRevisions(('2015-05-08 00:00',)) if mibBuilder.loadTexts: extrahop.setLastUpdated('201505080000Z') if mibBuilder.loadTexts: extrahop.setOrganization('ExtraHop Networks') extrahopInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 0)) extrahopInfoVersionString = MibScalar((1, 3, 6, 1, 4, 1, 32015, 0, 0), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopInfoVersionString.setStatus('current') extrahopInfoVersionMajor = MibScalar((1, 3, 6, 1, 4, 1, 32015, 0, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopInfoVersionMajor.setStatus('current') extrahopInfoVersionMinor = MibScalar((1, 3, 6, 1, 4, 1, 32015, 0, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopInfoVersionMinor.setStatus('current') extrahopInfoVersionBranchRelease = MibScalar((1, 3, 6, 1, 4, 1, 32015, 0, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopInfoVersionBranchRelease.setStatus('current') extrahopInfoVersionRevision = MibScalar((1, 3, 6, 1, 4, 1, 32015, 0, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopInfoVersionRevision.setStatus('current') extrahopAlert = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 1)) extrahopTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 2)) extrahopObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 4)) extrahopObjectGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 32015, 4, 1)).setObjects(("EXTRAHOP-MIB", "extrahopAlertName"), ("EXTRAHOP-MIB", "extrahopAlertComment"), ("EXTRAHOP-MIB", "extrahopAlertObjectType"), ("EXTRAHOP-MIB", "extrahopAlertObjectName"), ("EXTRAHOP-MIB", "extrahopAlertExpr"), ("EXTRAHOP-MIB", "extrahopAlertValue"), ("EXTRAHOP-MIB", "extrahopAlertTime"), ("EXTRAHOP-MIB", "extrahopAlertObjectId"), ("EXTRAHOP-MIB", "extrahopAlertObjectStrId"), ("EXTRAHOP-MIB", "extrahopAlertObjectMACAddr"), ("EXTRAHOP-MIB", "extrahopAlertObjectIPAddr"), ("EXTRAHOP-MIB", "extrahopAlertObjectTags"), ("EXTRAHOP-MIB", "extrahopAlertObjectURL"), ("EXTRAHOP-MIB", "extrahopAlertStatName"), ("EXTRAHOP-MIB", "extrahopAlertStatFieldName"), ("EXTRAHOP-MIB", "extrahopAlertSeverity"), ("EXTRAHOP-MIB", "extrahopStatsPktsSinceBoot"), ("EXTRAHOP-MIB", "extrahopStatsBytesSinceBoot"), ("EXTRAHOP-MIB", "extrahopStorageAlertRole"), ("EXTRAHOP-MIB", "extrahopStorageAlertDevice"), ("EXTRAHOP-MIB", "extrahopStorageAlertStatus"), ("EXTRAHOP-MIB", "extrahopStorageAlertDetails"), ("EXTRAHOP-MIB", "extrahopStorageAlertSeverity"), ("EXTRAHOP-MIB", "extrahopStorageAlertMachine")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): extrahopObjectGroup = extrahopObjectGroup.setStatus('current') extrahopNotificationGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 32015, 4, 2)).setObjects(("EXTRAHOP-MIB", "extrahopAlertTrap"), ("EXTRAHOP-MIB", "extrahopStorageAlertTrap")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): extrahopNotificationGroup = extrahopNotificationGroup.setStatus('current') extrahopAlertTrap = NotificationType((1, 3, 6, 1, 4, 1, 32015, 2, 1)).setObjects(("EXTRAHOP-MIB", "extrahopAlertName"), ("EXTRAHOP-MIB", "extrahopAlertComment"), ("EXTRAHOP-MIB", "extrahopAlertObjectType"), ("EXTRAHOP-MIB", "extrahopAlertObjectName"), ("EXTRAHOP-MIB", "extrahopAlertExpr"), ("EXTRAHOP-MIB", "extrahopAlertValue"), ("EXTRAHOP-MIB", "extrahopAlertTime"), ("EXTRAHOP-MIB", "extrahopAlertObjectId"), ("EXTRAHOP-MIB", "extrahopAlertObjectStrId"), ("EXTRAHOP-MIB", "extrahopAlertObjectMACAddr"), ("EXTRAHOP-MIB", "extrahopAlertObjectIPAddr"), ("EXTRAHOP-MIB", "extrahopAlertObjectTags"), ("EXTRAHOP-MIB", "extrahopAlertObjectURL"), ("EXTRAHOP-MIB", "extrahopAlertStatName"), ("EXTRAHOP-MIB", "extrahopAlertStatFieldName"), ("EXTRAHOP-MIB", "extrahopAlertSeverity")) if mibBuilder.loadTexts: extrahopAlertTrap.setStatus('current') extrahopAlertName = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertName.setStatus('current') extrahopAlertComment = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertComment.setStatus('current') extrahopAlertObjectType = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectType.setStatus('current') extrahopAlertObjectName = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectName.setStatus('current') extrahopAlertExpr = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertExpr.setStatus('current') extrahopAlertValue = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertValue.setStatus('current') extrahopAlertTime = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 7), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertTime.setStatus('current') extrahopAlertObjectId = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 8), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectId.setStatus('current') extrahopAlertObjectStrId = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 9), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectStrId.setStatus('current') extrahopAlertObjectMACAddr = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectMACAddr.setStatus('current') extrahopAlertObjectIPAddr = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 11), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectIPAddr.setStatus('current') extrahopAlertObjectTags = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 12), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectTags.setStatus('current') extrahopAlertObjectURL = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 13), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertObjectURL.setStatus('current') extrahopAlertStatName = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 14), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertStatName.setStatus('current') extrahopAlertStatFieldName = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 15), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertStatFieldName.setStatus('current') extrahopAlertSeverity = MibScalar((1, 3, 6, 1, 4, 1, 32015, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("emergency", 0), ("alert", 1), ("critical", 2), ("error", 3), ("warning", 4), ("notice", 5), ("info", 6), ("debug", 7)))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopAlertSeverity.setStatus('current') extrahopStats = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 3)) extrahopStatsPktsSinceBoot = MibScalar((1, 3, 6, 1, 4, 1, 32015, 3, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStatsPktsSinceBoot.setStatus('current') extrahopStatsBytesSinceBoot = MibScalar((1, 3, 6, 1, 4, 1, 32015, 3, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStatsBytesSinceBoot.setStatus('current') extrahopStorageAlert = MibIdentifier((1, 3, 6, 1, 4, 1, 32015, 5)) extrahopStorageAlertTrap = NotificationType((1, 3, 6, 1, 4, 1, 32015, 2, 2)).setObjects(("EXTRAHOP-MIB", "extrahopStorageAlertRole"), ("EXTRAHOP-MIB", "extrahopStorageAlertDevice"), ("EXTRAHOP-MIB", "extrahopStorageAlertStatus"), ("EXTRAHOP-MIB", "extrahopStorageAlertDetails"), ("EXTRAHOP-MIB", "extrahopStorageAlertSeverity"), ("EXTRAHOP-MIB", "extrahopStorageAlertMachine")) if mibBuilder.loadTexts: extrahopStorageAlertTrap.setStatus('current') extrahopStorageAlertRole = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertRole.setStatus('current') extrahopStorageAlertDevice = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertDevice.setStatus('current') extrahopStorageAlertStatus = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertStatus.setStatus('current') extrahopStorageAlertDetails = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertDetails.setStatus('current') extrahopStorageAlertSeverity = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("emergency", 0), ("alert", 1), ("critical", 2), ("error", 3), ("warning", 4), ("notice", 5), ("info", 6), ("debug", 7)))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertSeverity.setStatus('current') extrahopStorageAlertMachine = MibScalar((1, 3, 6, 1, 4, 1, 32015, 5, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: extrahopStorageAlertMachine.setStatus('current') mibBuilder.exportSymbols("EXTRAHOP-MIB", extrahop=extrahop, extrahopAlertComment=extrahopAlertComment, extrahopAlertExpr=extrahopAlertExpr, extrahopStorageAlertDevice=extrahopStorageAlertDevice, extrahopStatsBytesSinceBoot=extrahopStatsBytesSinceBoot, extrahopAlertObjectTags=extrahopAlertObjectTags, extrahopAlert=extrahopAlert, extrahopStorageAlertStatus=extrahopStorageAlertStatus, extrahopAlertStatFieldName=extrahopAlertStatFieldName, extrahopStorageAlertMachine=extrahopStorageAlertMachine, extrahopStorageAlertTrap=extrahopStorageAlertTrap, extrahopAlertStatName=extrahopAlertStatName, extrahopStats=extrahopStats, extrahopStorageAlertRole=extrahopStorageAlertRole, extrahopStorageAlertDetails=extrahopStorageAlertDetails, extrahopObjectGroup=extrahopObjectGroup, extrahopInfoVersionRevision=extrahopInfoVersionRevision, extrahopAlertSeverity=extrahopAlertSeverity, extrahopAlertObjectStrId=extrahopAlertObjectStrId, extrahopTraps=extrahopTraps, extrahopStatsPktsSinceBoot=extrahopStatsPktsSinceBoot, PYSNMP_MODULE_ID=extrahop, extrahopAlertTime=extrahopAlertTime, extrahopInfoVersionString=extrahopInfoVersionString, extrahopObjects=extrahopObjects, extrahopAlertObjectName=extrahopAlertObjectName, extrahopAlertObjectURL=extrahopAlertObjectURL, extrahopNotificationGroup=extrahopNotificationGroup, extrahopAlertObjectId=extrahopAlertObjectId, extrahopAlertObjectIPAddr=extrahopAlertObjectIPAddr, extrahopInfoVersionMinor=extrahopInfoVersionMinor, extrahopStorageAlert=extrahopStorageAlert, extrahopAlertValue=extrahopAlertValue, extrahopAlertTrap=extrahopAlertTrap, extrahopInfo=extrahopInfo, extrahopInfoVersionMajor=extrahopInfoVersionMajor, extrahopAlertObjectType=extrahopAlertObjectType, extrahopStorageAlertSeverity=extrahopStorageAlertSeverity, extrahopAlertName=extrahopAlertName, extrahopInfoVersionBranchRelease=extrahopInfoVersionBranchRelease, extrahopAlertObjectMACAddr=extrahopAlertObjectMACAddr)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint') (module_compliance, object_group, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'ObjectGroup', 'NotificationGroup') (integer32, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, bits, ip_address, counter64, enterprises, mib_identifier, notification_type, gauge32, unsigned32, time_ticks, object_identity, module_identity, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Bits', 'IpAddress', 'Counter64', 'enterprises', 'MibIdentifier', 'NotificationType', 'Gauge32', 'Unsigned32', 'TimeTicks', 'ObjectIdentity', 'ModuleIdentity', 'Counter32') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') extrahop = module_identity((1, 3, 6, 1, 4, 1, 32015)) extrahop.setRevisions(('2015-05-08 00:00',)) if mibBuilder.loadTexts: extrahop.setLastUpdated('201505080000Z') if mibBuilder.loadTexts: extrahop.setOrganization('ExtraHop Networks') extrahop_info = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 0)) extrahop_info_version_string = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 0, 0), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopInfoVersionString.setStatus('current') extrahop_info_version_major = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 0, 1), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopInfoVersionMajor.setStatus('current') extrahop_info_version_minor = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 0, 2), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopInfoVersionMinor.setStatus('current') extrahop_info_version_branch_release = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 0, 3), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopInfoVersionBranchRelease.setStatus('current') extrahop_info_version_revision = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 0, 4), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopInfoVersionRevision.setStatus('current') extrahop_alert = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 1)) extrahop_traps = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 2)) extrahop_objects = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 4)) extrahop_object_group = object_group((1, 3, 6, 1, 4, 1, 32015, 4, 1)).setObjects(('EXTRAHOP-MIB', 'extrahopAlertName'), ('EXTRAHOP-MIB', 'extrahopAlertComment'), ('EXTRAHOP-MIB', 'extrahopAlertObjectType'), ('EXTRAHOP-MIB', 'extrahopAlertObjectName'), ('EXTRAHOP-MIB', 'extrahopAlertExpr'), ('EXTRAHOP-MIB', 'extrahopAlertValue'), ('EXTRAHOP-MIB', 'extrahopAlertTime'), ('EXTRAHOP-MIB', 'extrahopAlertObjectId'), ('EXTRAHOP-MIB', 'extrahopAlertObjectStrId'), ('EXTRAHOP-MIB', 'extrahopAlertObjectMACAddr'), ('EXTRAHOP-MIB', 'extrahopAlertObjectIPAddr'), ('EXTRAHOP-MIB', 'extrahopAlertObjectTags'), ('EXTRAHOP-MIB', 'extrahopAlertObjectURL'), ('EXTRAHOP-MIB', 'extrahopAlertStatName'), ('EXTRAHOP-MIB', 'extrahopAlertStatFieldName'), ('EXTRAHOP-MIB', 'extrahopAlertSeverity'), ('EXTRAHOP-MIB', 'extrahopStatsPktsSinceBoot'), ('EXTRAHOP-MIB', 'extrahopStatsBytesSinceBoot'), ('EXTRAHOP-MIB', 'extrahopStorageAlertRole'), ('EXTRAHOP-MIB', 'extrahopStorageAlertDevice'), ('EXTRAHOP-MIB', 'extrahopStorageAlertStatus'), ('EXTRAHOP-MIB', 'extrahopStorageAlertDetails'), ('EXTRAHOP-MIB', 'extrahopStorageAlertSeverity'), ('EXTRAHOP-MIB', 'extrahopStorageAlertMachine')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): extrahop_object_group = extrahopObjectGroup.setStatus('current') extrahop_notification_group = notification_group((1, 3, 6, 1, 4, 1, 32015, 4, 2)).setObjects(('EXTRAHOP-MIB', 'extrahopAlertTrap'), ('EXTRAHOP-MIB', 'extrahopStorageAlertTrap')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): extrahop_notification_group = extrahopNotificationGroup.setStatus('current') extrahop_alert_trap = notification_type((1, 3, 6, 1, 4, 1, 32015, 2, 1)).setObjects(('EXTRAHOP-MIB', 'extrahopAlertName'), ('EXTRAHOP-MIB', 'extrahopAlertComment'), ('EXTRAHOP-MIB', 'extrahopAlertObjectType'), ('EXTRAHOP-MIB', 'extrahopAlertObjectName'), ('EXTRAHOP-MIB', 'extrahopAlertExpr'), ('EXTRAHOP-MIB', 'extrahopAlertValue'), ('EXTRAHOP-MIB', 'extrahopAlertTime'), ('EXTRAHOP-MIB', 'extrahopAlertObjectId'), ('EXTRAHOP-MIB', 'extrahopAlertObjectStrId'), ('EXTRAHOP-MIB', 'extrahopAlertObjectMACAddr'), ('EXTRAHOP-MIB', 'extrahopAlertObjectIPAddr'), ('EXTRAHOP-MIB', 'extrahopAlertObjectTags'), ('EXTRAHOP-MIB', 'extrahopAlertObjectURL'), ('EXTRAHOP-MIB', 'extrahopAlertStatName'), ('EXTRAHOP-MIB', 'extrahopAlertStatFieldName'), ('EXTRAHOP-MIB', 'extrahopAlertSeverity')) if mibBuilder.loadTexts: extrahopAlertTrap.setStatus('current') extrahop_alert_name = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 1), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertName.setStatus('current') extrahop_alert_comment = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertComment.setStatus('current') extrahop_alert_object_type = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 3), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectType.setStatus('current') extrahop_alert_object_name = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectName.setStatus('current') extrahop_alert_expr = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 5), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertExpr.setStatus('current') extrahop_alert_value = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 6), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertValue.setStatus('current') extrahop_alert_time = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 7), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertTime.setStatus('current') extrahop_alert_object_id = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 8), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectId.setStatus('current') extrahop_alert_object_str_id = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 9), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectStrId.setStatus('current') extrahop_alert_object_mac_addr = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 10), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectMACAddr.setStatus('current') extrahop_alert_object_ip_addr = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 11), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectIPAddr.setStatus('current') extrahop_alert_object_tags = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 12), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectTags.setStatus('current') extrahop_alert_object_url = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 13), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertObjectURL.setStatus('current') extrahop_alert_stat_name = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 14), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertStatName.setStatus('current') extrahop_alert_stat_field_name = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 15), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertStatFieldName.setStatus('current') extrahop_alert_severity = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 1, 16), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('emergency', 0), ('alert', 1), ('critical', 2), ('error', 3), ('warning', 4), ('notice', 5), ('info', 6), ('debug', 7)))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopAlertSeverity.setStatus('current') extrahop_stats = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 3)) extrahop_stats_pkts_since_boot = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 3, 1), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStatsPktsSinceBoot.setStatus('current') extrahop_stats_bytes_since_boot = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 3, 2), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStatsBytesSinceBoot.setStatus('current') extrahop_storage_alert = mib_identifier((1, 3, 6, 1, 4, 1, 32015, 5)) extrahop_storage_alert_trap = notification_type((1, 3, 6, 1, 4, 1, 32015, 2, 2)).setObjects(('EXTRAHOP-MIB', 'extrahopStorageAlertRole'), ('EXTRAHOP-MIB', 'extrahopStorageAlertDevice'), ('EXTRAHOP-MIB', 'extrahopStorageAlertStatus'), ('EXTRAHOP-MIB', 'extrahopStorageAlertDetails'), ('EXTRAHOP-MIB', 'extrahopStorageAlertSeverity'), ('EXTRAHOP-MIB', 'extrahopStorageAlertMachine')) if mibBuilder.loadTexts: extrahopStorageAlertTrap.setStatus('current') extrahop_storage_alert_role = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 1), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertRole.setStatus('current') extrahop_storage_alert_device = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertDevice.setStatus('current') extrahop_storage_alert_status = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 3), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertStatus.setStatus('current') extrahop_storage_alert_details = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertDetails.setStatus('current') extrahop_storage_alert_severity = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('emergency', 0), ('alert', 1), ('critical', 2), ('error', 3), ('warning', 4), ('notice', 5), ('info', 6), ('debug', 7)))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertSeverity.setStatus('current') extrahop_storage_alert_machine = mib_scalar((1, 3, 6, 1, 4, 1, 32015, 5, 6), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: extrahopStorageAlertMachine.setStatus('current') mibBuilder.exportSymbols('EXTRAHOP-MIB', extrahop=extrahop, extrahopAlertComment=extrahopAlertComment, extrahopAlertExpr=extrahopAlertExpr, extrahopStorageAlertDevice=extrahopStorageAlertDevice, extrahopStatsBytesSinceBoot=extrahopStatsBytesSinceBoot, extrahopAlertObjectTags=extrahopAlertObjectTags, extrahopAlert=extrahopAlert, extrahopStorageAlertStatus=extrahopStorageAlertStatus, extrahopAlertStatFieldName=extrahopAlertStatFieldName, extrahopStorageAlertMachine=extrahopStorageAlertMachine, extrahopStorageAlertTrap=extrahopStorageAlertTrap, extrahopAlertStatName=extrahopAlertStatName, extrahopStats=extrahopStats, extrahopStorageAlertRole=extrahopStorageAlertRole, extrahopStorageAlertDetails=extrahopStorageAlertDetails, extrahopObjectGroup=extrahopObjectGroup, extrahopInfoVersionRevision=extrahopInfoVersionRevision, extrahopAlertSeverity=extrahopAlertSeverity, extrahopAlertObjectStrId=extrahopAlertObjectStrId, extrahopTraps=extrahopTraps, extrahopStatsPktsSinceBoot=extrahopStatsPktsSinceBoot, PYSNMP_MODULE_ID=extrahop, extrahopAlertTime=extrahopAlertTime, extrahopInfoVersionString=extrahopInfoVersionString, extrahopObjects=extrahopObjects, extrahopAlertObjectName=extrahopAlertObjectName, extrahopAlertObjectURL=extrahopAlertObjectURL, extrahopNotificationGroup=extrahopNotificationGroup, extrahopAlertObjectId=extrahopAlertObjectId, extrahopAlertObjectIPAddr=extrahopAlertObjectIPAddr, extrahopInfoVersionMinor=extrahopInfoVersionMinor, extrahopStorageAlert=extrahopStorageAlert, extrahopAlertValue=extrahopAlertValue, extrahopAlertTrap=extrahopAlertTrap, extrahopInfo=extrahopInfo, extrahopInfoVersionMajor=extrahopInfoVersionMajor, extrahopAlertObjectType=extrahopAlertObjectType, extrahopStorageAlertSeverity=extrahopStorageAlertSeverity, extrahopAlertName=extrahopAlertName, extrahopInfoVersionBranchRelease=extrahopInfoVersionBranchRelease, extrahopAlertObjectMACAddr=extrahopAlertObjectMACAddr)
# ============================================================================== # ARSC (A Relatively Simple Computer) License # ============================================================================== # # ARSC is distributed under the following BSD-style license: # # Copyright (c) 2016-2017 Dzanan Bajgoric # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # 2. 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. # # 3. The name of the author may not be used to endorse or promote products derived from # this product without specific prior written permission from the author. # # 4. Products derived from this product may not be called "ARSC" nor may "ARSC" appear # in their names without specific prior written permission from the author. # # THIS PRODUCT IS PROVIDED ``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 AUTHOR 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 PRODUCT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # PART OF THE ARSC ASSEMBLER # # Provides the traditional symbol table functionality class SymbolTable: def __init__(self): self.symbols = dict() def add_entry(self, symbol, addr): if symbol in self.symbols: raise KeyError('Symbol "%s" already exists' % symbol) try: self.symbols[symbol] = int(addr) except ValueError: raise ValueError('Address "%s" must be an integer' % addr) def contains(self, symbol): return (symbol in self.symbols) def get_address(self, symbol): if symbol not in self.symbols: raise KeyError('Symbol "%s" not in the symbol table' % symbol) return self.symbols[symbol] def __str__(self): pretty_str = '{\n' for key in sorted(self.symbols, key=self.symbols.get): pretty_str += '\t%s: %s\n' % (key, self.symbols[key]) pretty_str += '}' return pretty_str
class Symboltable: def __init__(self): self.symbols = dict() def add_entry(self, symbol, addr): if symbol in self.symbols: raise key_error('Symbol "%s" already exists' % symbol) try: self.symbols[symbol] = int(addr) except ValueError: raise value_error('Address "%s" must be an integer' % addr) def contains(self, symbol): return symbol in self.symbols def get_address(self, symbol): if symbol not in self.symbols: raise key_error('Symbol "%s" not in the symbol table' % symbol) return self.symbols[symbol] def __str__(self): pretty_str = '{\n' for key in sorted(self.symbols, key=self.symbols.get): pretty_str += '\t%s: %s\n' % (key, self.symbols[key]) pretty_str += '}' return pretty_str
def SymbolToFromAtomicNumber(ATOM): atoms = [ [1,"H"],[2,"He"],[3,"Li"],[4,"Be"],[5,"B"],[6,"C"],[7,"N"],[8,"O"],[9,"F"],[10,"Ne"], \ [11,"Na"],[12,"Mg"],[13,"Al"],[14,"Si"],[15,"P"],[16,"S"],[17,"Cl"],[18,"Ar"],[19,"K"],[20,"Ca"], \ [21,"Sc"],[22,"Ti"],[23,"V"],[24,"Cr"],[25,"Mn"],[26,"Fe"],[27,"Co"],[28,"Ni"],[29,"Cu"],[30,"Zn"], \ [31,"Ga"],[32,"Ge"],[33,"As"],[34,"Se"],[35,"Br"],[36,"Kr"],[37,"Rb"],[38,"Sr"],[39,"Y"],[40,"Zr"], \ [41,"Nb"],[42,"Mo"],[43,"Tc"],[44,"Ru"],[45,"Rh"],[46,"Pd"],[47,"Ag"],[48,"Cd"],[49,"In"],[50,"Sn"], \ [51,"Sb"],[52,"Te"],[53,"I"],[54,"Xe"],[55,"Cs"],[56,"Ba"],[57,"La"],[58,"Ce"],[59,"Pr"],[60,"Nd"], \ [61,"Pm"],[62,"Sm"],[63,"Eu"],[64,"Gd"],[65,"Tb"],[66,"Dy"],[67,"Ho"],[68,"Er"],[69,"Tm"],[70,"Yb"], \ [71,"Lu"],[72,"Hf"],[73,"Ta"],[74,"W"],[75,"Re"],[76,"Os"],[77,"Ir"],[78,"Pt"],[79,"Au"],[80,"Hg"], \ [81,"Tl"],[82,"Pb"],[83,"Bi"],[84,"Po"],[85,"At"],[86,"Rn"],[87,"Fr"],[88,"Ra"],[89,"Ac"],[90,"Th"], \ [91,"Pa"],[92,"U"],[93,"Np"],[94,"Pu"],[95,"Am"],[96,"Cm"],[97,"Bk"],[98,"Cf"],[99,"Es"],[100,"Fm"], \ [101,"Md"],[102,"No"],[103,"Lr"],[104,"Rf"],[105,"Db"],[106,"Sg"],[107,"Bh"] ] if isinstance(ATOM,int): for a in atoms: if a[0] == ATOM: return a[1] for a in atoms: if a[1] == ATOM: return int(a[0]) raise Exception("Why are you here?")
def symbol_to_from_atomic_number(ATOM): atoms = [[1, 'H'], [2, 'He'], [3, 'Li'], [4, 'Be'], [5, 'B'], [6, 'C'], [7, 'N'], [8, 'O'], [9, 'F'], [10, 'Ne'], [11, 'Na'], [12, 'Mg'], [13, 'Al'], [14, 'Si'], [15, 'P'], [16, 'S'], [17, 'Cl'], [18, 'Ar'], [19, 'K'], [20, 'Ca'], [21, 'Sc'], [22, 'Ti'], [23, 'V'], [24, 'Cr'], [25, 'Mn'], [26, 'Fe'], [27, 'Co'], [28, 'Ni'], [29, 'Cu'], [30, 'Zn'], [31, 'Ga'], [32, 'Ge'], [33, 'As'], [34, 'Se'], [35, 'Br'], [36, 'Kr'], [37, 'Rb'], [38, 'Sr'], [39, 'Y'], [40, 'Zr'], [41, 'Nb'], [42, 'Mo'], [43, 'Tc'], [44, 'Ru'], [45, 'Rh'], [46, 'Pd'], [47, 'Ag'], [48, 'Cd'], [49, 'In'], [50, 'Sn'], [51, 'Sb'], [52, 'Te'], [53, 'I'], [54, 'Xe'], [55, 'Cs'], [56, 'Ba'], [57, 'La'], [58, 'Ce'], [59, 'Pr'], [60, 'Nd'], [61, 'Pm'], [62, 'Sm'], [63, 'Eu'], [64, 'Gd'], [65, 'Tb'], [66, 'Dy'], [67, 'Ho'], [68, 'Er'], [69, 'Tm'], [70, 'Yb'], [71, 'Lu'], [72, 'Hf'], [73, 'Ta'], [74, 'W'], [75, 'Re'], [76, 'Os'], [77, 'Ir'], [78, 'Pt'], [79, 'Au'], [80, 'Hg'], [81, 'Tl'], [82, 'Pb'], [83, 'Bi'], [84, 'Po'], [85, 'At'], [86, 'Rn'], [87, 'Fr'], [88, 'Ra'], [89, 'Ac'], [90, 'Th'], [91, 'Pa'], [92, 'U'], [93, 'Np'], [94, 'Pu'], [95, 'Am'], [96, 'Cm'], [97, 'Bk'], [98, 'Cf'], [99, 'Es'], [100, 'Fm'], [101, 'Md'], [102, 'No'], [103, 'Lr'], [104, 'Rf'], [105, 'Db'], [106, 'Sg'], [107, 'Bh']] if isinstance(ATOM, int): for a in atoms: if a[0] == ATOM: return a[1] for a in atoms: if a[1] == ATOM: return int(a[0]) raise exception('Why are you here?')
#!/usr/bin/python3 list = ["Binwalk","bulk-extractor","Capstone","chntpw","Cuckoo", "dc3dd","ddrescue","DFF","diStorm3","Dumpzilla","extundelete", "Foremost","Galleta","Guymager","iPhone Backup Analyzer","p0f", "pdf-parser","pdfid","pdgmail","peepdf","RegRipper","Volatility","Xplico"]
list = ['Binwalk', 'bulk-extractor', 'Capstone', 'chntpw', 'Cuckoo', 'dc3dd', 'ddrescue', 'DFF', 'diStorm3', 'Dumpzilla', 'extundelete', 'Foremost', 'Galleta', 'Guymager', 'iPhone Backup Analyzer', 'p0f', 'pdf-parser', 'pdfid', 'pdgmail', 'peepdf', 'RegRipper', 'Volatility', 'Xplico']
# # PySNMP MIB module CISCOSB-STACK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-STACK-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:23:37 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) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection") MacAddress, = mibBuilder.importSymbols("BRIDGE-MIB", "MacAddress") switch001, = mibBuilder.importSymbols("CISCOSB-MIB", "switch001") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Counter32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, Gauge32, Counter64, MibIdentifier, TimeTicks, ModuleIdentity, ObjectIdentity, Unsigned32, NotificationType, iso, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "Gauge32", "Counter64", "MibIdentifier", "TimeTicks", "ModuleIdentity", "ObjectIdentity", "Unsigned32", "NotificationType", "iso", "Integer32") TruthValue, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "DisplayString", "TextualConvention") rlStack = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107)) rlStack.setRevisions(('2005-04-14 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: rlStack.setRevisionsDescriptions(('Initial revision.',)) if mibBuilder.loadTexts: rlStack.setLastUpdated('200504140000Z') if mibBuilder.loadTexts: rlStack.setOrganization('Cisco Small Business') if mibBuilder.loadTexts: rlStack.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>') if mibBuilder.loadTexts: rlStack.setDescription('The private MIB module definition for stack.') class StackMode(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5)) namedValues = NamedValues(("standalone", 1), ("native", 2), ("basic-hybrid", 3), ("advanced-hybrid", 4), ("advanced-hybrid-XG", 5)) class PortsPair(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5)) namedValues = NamedValues(("pair-s1s2", 1), ("pair-s3s4", 2), ("pair-s1s25G", 3), ("pair-s1s2Xg", 4), ("pair-lionXg", 5)) class HybridStackPortSpeed(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5)) namedValues = NamedValues(("port-speed-1G", 1), ("port-speed-5G", 2), ("port-speed-10G", 3), ("port-speed-auto", 4), ("port-speed-down", 5)) class HybridStackDeviceMode(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("mode-L2", 1), ("mode-L3", 2)) rlStackActiveUnitIdTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1), ) if mibBuilder.loadTexts: rlStackActiveUnitIdTable.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdTable.setDescription(' The table listing the active unit id of the requested unit.') rlStackActiveUnitIdEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1), ).setIndexNames((0, "CISCOSB-STACK-MIB", "rlStackCurrentUnitId")) if mibBuilder.loadTexts: rlStackActiveUnitIdEntry.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdEntry.setDescription(' An entry in the rlStackActiveUnitIdTable.') rlStackCurrentUnitId = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: rlStackCurrentUnitId.setStatus('current') if mibBuilder.loadTexts: rlStackCurrentUnitId.setDescription('The unit number device, which is the active unit id') rlStackActiveUnitIdAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackActiveUnitIdAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdAfterReset.setDescription('Indicates the unit id that will be after reset.') rlStackUnitModeAfterReset = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("standalone", 1), ("stack", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackUnitModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackUnitModeAfterReset.setDescription('set unit type that will be after reset, standalone or stack.') rlStackUnitMode = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("standalone", 1), ("stack", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackUnitMode.setStatus('current') if mibBuilder.loadTexts: rlStackUnitMode.setDescription('show unit type standalone or stack.') rlStackUnitMacAddressAfterReset = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 4), MacAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setReference('IEEE 802.1D-1990: Sections 6.4.1.1.3 and 3.12.5') if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setDescription('The MAC address used by this bridge after rest.') rlStackHybridTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5), ) if mibBuilder.loadTexts: rlStackHybridTable.setStatus('current') if mibBuilder.loadTexts: rlStackHybridTable.setDescription(' The table listing information required for hybrid stack.') rlStackHybridEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1), ).setIndexNames((0, "CISCOSB-STACK-MIB", "rlStackHybridUnitId")) if mibBuilder.loadTexts: rlStackHybridEntry.setStatus('current') if mibBuilder.loadTexts: rlStackHybridEntry.setDescription(' An entry in the rlStackActiveUnitIdTable.') rlStackHybridUnitId = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 8))) if mibBuilder.loadTexts: rlStackHybridUnitId.setStatus('current') if mibBuilder.loadTexts: rlStackHybridUnitId.setDescription('The unit number device, which is the active unit id') rlStackHybridStackMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 2), StackMode()).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridStackMode.setStatus('current') if mibBuilder.loadTexts: rlStackHybridStackMode.setDescription('Indicates the unit stack mode.') rlStackHybridPortsPair = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 3), PortsPair()).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridPortsPair.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortsPair.setDescription('Indicates the PortsPair.') rlStackHybridPortNo1speed = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 4), HybridStackPortSpeed()).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridPortNo1speed.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo1speed.setDescription('Indicates the rlStackHybridPortNo1speed.') rlStackHybridPortNo2speed = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 5), HybridStackPortSpeed()).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridPortNo2speed.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo2speed.setDescription('Indicates the rlStackHybridPortNo2speed.') rlStackHybridUnitIdAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 8))).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridUnitIdAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridUnitIdAfterReset.setDescription('Indicates the unit id that will be after reset.') rlStackHybridStackModeAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 7), StackMode()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridStackModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridStackModeAfterReset.setDescription('Indicates the unit stack mode that will be after reset.') rlStackHybridPortsPairAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 8), PortsPair()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridPortsPairAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortsPairAfterReset.setDescription('Indicates the PortsPair that will be after reset.') rlStackHybridPortNo1speedAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 9), HybridStackPortSpeed()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridPortNo1speedAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo1speedAfterReset.setDescription('Indicates the HybridStackPortSpeed that will be after reset.') rlStackHybridPortNo2speedAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 10), HybridStackPortSpeed()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridPortNo2speedAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo2speedAfterReset.setDescription('Indicates the HybridStackPortSpeed that will be after reset.') rlStackHybridDeleteStartupAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 11), TruthValue()).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridDeleteStartupAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridDeleteStartupAfterReset.setDescription('Indicates whether the startup configuration is deleted after reset.') rlStackHybridDeviceModeAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 12), HybridStackDeviceMode()).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridDeviceModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridDeviceModeAfterReset.setDescription('Indicates Device mode (Layer2 or Layer3) after reset.') rlStackHybridXgPortNo1Num = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridXgPortNo1Num.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo1Num.setDescription('Indicates the 1st stack cascade active port number.') rlStackHybridXgPortNo1NumAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridXgPortNo1NumAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo1NumAfterReset.setDescription('Indicates the 1st stack cascade port number that will be after reset.') rlStackHybridXgPortNo2Num = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readonly") if mibBuilder.loadTexts: rlStackHybridXgPortNo2Num.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo2Num.setDescription('Indicates the 2nd stack cascade active port number.') rlStackHybridXgPortNo2NumAfterReset = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: rlStackHybridXgPortNo2NumAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo2NumAfterReset.setDescription('Indicates the 2nd stack cascade port number that will be after reset.') mibBuilder.exportSymbols("CISCOSB-STACK-MIB", rlStackHybridPortNo1speed=rlStackHybridPortNo1speed, rlStackUnitMode=rlStackUnitMode, rlStackHybridStackModeAfterReset=rlStackHybridStackModeAfterReset, rlStackActiveUnitIdTable=rlStackActiveUnitIdTable, rlStackHybridPortNo1speedAfterReset=rlStackHybridPortNo1speedAfterReset, rlStackHybridDeviceModeAfterReset=rlStackHybridDeviceModeAfterReset, rlStack=rlStack, PortsPair=PortsPair, rlStackHybridPortNo2speed=rlStackHybridPortNo2speed, rlStackHybridXgPortNo1NumAfterReset=rlStackHybridXgPortNo1NumAfterReset, rlStackActiveUnitIdAfterReset=rlStackActiveUnitIdAfterReset, rlStackHybridTable=rlStackHybridTable, rlStackHybridUnitId=rlStackHybridUnitId, rlStackHybridPortsPairAfterReset=rlStackHybridPortsPairAfterReset, rlStackHybridEntry=rlStackHybridEntry, rlStackHybridXgPortNo2NumAfterReset=rlStackHybridXgPortNo2NumAfterReset, rlStackHybridStackMode=rlStackHybridStackMode, rlStackHybridPortNo2speedAfterReset=rlStackHybridPortNo2speedAfterReset, HybridStackDeviceMode=HybridStackDeviceMode, rlStackUnitModeAfterReset=rlStackUnitModeAfterReset, PYSNMP_MODULE_ID=rlStack, HybridStackPortSpeed=HybridStackPortSpeed, rlStackHybridDeleteStartupAfterReset=rlStackHybridDeleteStartupAfterReset, rlStackHybridXgPortNo2Num=rlStackHybridXgPortNo2Num, rlStackCurrentUnitId=rlStackCurrentUnitId, rlStackActiveUnitIdEntry=rlStackActiveUnitIdEntry, rlStackHybridPortsPair=rlStackHybridPortsPair, rlStackHybridXgPortNo1Num=rlStackHybridXgPortNo1Num, rlStackHybridUnitIdAfterReset=rlStackHybridUnitIdAfterReset, rlStackUnitMacAddressAfterReset=rlStackUnitMacAddressAfterReset, StackMode=StackMode)
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, single_value_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection') (mac_address,) = mibBuilder.importSymbols('BRIDGE-MIB', 'MacAddress') (switch001,) = mibBuilder.importSymbols('CISCOSB-MIB', 'switch001') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (counter32, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, gauge32, counter64, mib_identifier, time_ticks, module_identity, object_identity, unsigned32, notification_type, iso, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'Gauge32', 'Counter64', 'MibIdentifier', 'TimeTicks', 'ModuleIdentity', 'ObjectIdentity', 'Unsigned32', 'NotificationType', 'iso', 'Integer32') (truth_value, display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'TruthValue', 'DisplayString', 'TextualConvention') rl_stack = module_identity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107)) rlStack.setRevisions(('2005-04-14 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: rlStack.setRevisionsDescriptions(('Initial revision.',)) if mibBuilder.loadTexts: rlStack.setLastUpdated('200504140000Z') if mibBuilder.loadTexts: rlStack.setOrganization('Cisco Small Business') if mibBuilder.loadTexts: rlStack.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>') if mibBuilder.loadTexts: rlStack.setDescription('The private MIB module definition for stack.') class Stackmode(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5)) named_values = named_values(('standalone', 1), ('native', 2), ('basic-hybrid', 3), ('advanced-hybrid', 4), ('advanced-hybrid-XG', 5)) class Portspair(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5)) named_values = named_values(('pair-s1s2', 1), ('pair-s3s4', 2), ('pair-s1s25G', 3), ('pair-s1s2Xg', 4), ('pair-lionXg', 5)) class Hybridstackportspeed(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5)) named_values = named_values(('port-speed-1G', 1), ('port-speed-5G', 2), ('port-speed-10G', 3), ('port-speed-auto', 4), ('port-speed-down', 5)) class Hybridstackdevicemode(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2)) named_values = named_values(('mode-L2', 1), ('mode-L3', 2)) rl_stack_active_unit_id_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1)) if mibBuilder.loadTexts: rlStackActiveUnitIdTable.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdTable.setDescription(' The table listing the active unit id of the requested unit.') rl_stack_active_unit_id_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1)).setIndexNames((0, 'CISCOSB-STACK-MIB', 'rlStackCurrentUnitId')) if mibBuilder.loadTexts: rlStackActiveUnitIdEntry.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdEntry.setDescription(' An entry in the rlStackActiveUnitIdTable.') rl_stack_current_unit_id = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1, 1), integer32()) if mibBuilder.loadTexts: rlStackCurrentUnitId.setStatus('current') if mibBuilder.loadTexts: rlStackCurrentUnitId.setDescription('The unit number device, which is the active unit id') rl_stack_active_unit_id_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 1, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackActiveUnitIdAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackActiveUnitIdAfterReset.setDescription('Indicates the unit id that will be after reset.') rl_stack_unit_mode_after_reset = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('standalone', 1), ('stack', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackUnitModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackUnitModeAfterReset.setDescription('set unit type that will be after reset, standalone or stack.') rl_stack_unit_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('standalone', 1), ('stack', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackUnitMode.setStatus('current') if mibBuilder.loadTexts: rlStackUnitMode.setDescription('show unit type standalone or stack.') rl_stack_unit_mac_address_after_reset = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 4), mac_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setReference('IEEE 802.1D-1990: Sections 6.4.1.1.3 and 3.12.5') if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackUnitMacAddressAfterReset.setDescription('The MAC address used by this bridge after rest.') rl_stack_hybrid_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5)) if mibBuilder.loadTexts: rlStackHybridTable.setStatus('current') if mibBuilder.loadTexts: rlStackHybridTable.setDescription(' The table listing information required for hybrid stack.') rl_stack_hybrid_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1)).setIndexNames((0, 'CISCOSB-STACK-MIB', 'rlStackHybridUnitId')) if mibBuilder.loadTexts: rlStackHybridEntry.setStatus('current') if mibBuilder.loadTexts: rlStackHybridEntry.setDescription(' An entry in the rlStackActiveUnitIdTable.') rl_stack_hybrid_unit_id = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 8))) if mibBuilder.loadTexts: rlStackHybridUnitId.setStatus('current') if mibBuilder.loadTexts: rlStackHybridUnitId.setDescription('The unit number device, which is the active unit id') rl_stack_hybrid_stack_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 2), stack_mode()).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridStackMode.setStatus('current') if mibBuilder.loadTexts: rlStackHybridStackMode.setDescription('Indicates the unit stack mode.') rl_stack_hybrid_ports_pair = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 3), ports_pair()).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridPortsPair.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortsPair.setDescription('Indicates the PortsPair.') rl_stack_hybrid_port_no1speed = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 4), hybrid_stack_port_speed()).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridPortNo1speed.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo1speed.setDescription('Indicates the rlStackHybridPortNo1speed.') rl_stack_hybrid_port_no2speed = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 5), hybrid_stack_port_speed()).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridPortNo2speed.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo2speed.setDescription('Indicates the rlStackHybridPortNo2speed.') rl_stack_hybrid_unit_id_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 8))).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridUnitIdAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridUnitIdAfterReset.setDescription('Indicates the unit id that will be after reset.') rl_stack_hybrid_stack_mode_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 7), stack_mode()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridStackModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridStackModeAfterReset.setDescription('Indicates the unit stack mode that will be after reset.') rl_stack_hybrid_ports_pair_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 8), ports_pair()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridPortsPairAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortsPairAfterReset.setDescription('Indicates the PortsPair that will be after reset.') rl_stack_hybrid_port_no1speed_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 9), hybrid_stack_port_speed()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridPortNo1speedAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo1speedAfterReset.setDescription('Indicates the HybridStackPortSpeed that will be after reset.') rl_stack_hybrid_port_no2speed_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 10), hybrid_stack_port_speed()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridPortNo2speedAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridPortNo2speedAfterReset.setDescription('Indicates the HybridStackPortSpeed that will be after reset.') rl_stack_hybrid_delete_startup_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 11), truth_value()).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridDeleteStartupAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridDeleteStartupAfterReset.setDescription('Indicates whether the startup configuration is deleted after reset.') rl_stack_hybrid_device_mode_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 12), hybrid_stack_device_mode()).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridDeviceModeAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridDeviceModeAfterReset.setDescription('Indicates Device mode (Layer2 or Layer3) after reset.') rl_stack_hybrid_xg_port_no1_num = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 13), integer32().subtype(subtypeSpec=value_range_constraint(1, 16))).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridXgPortNo1Num.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo1Num.setDescription('Indicates the 1st stack cascade active port number.') rl_stack_hybrid_xg_port_no1_num_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 14), integer32().subtype(subtypeSpec=value_range_constraint(1, 16))).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridXgPortNo1NumAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo1NumAfterReset.setDescription('Indicates the 1st stack cascade port number that will be after reset.') rl_stack_hybrid_xg_port_no2_num = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(1, 16))).setMaxAccess('readonly') if mibBuilder.loadTexts: rlStackHybridXgPortNo2Num.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo2Num.setDescription('Indicates the 2nd stack cascade active port number.') rl_stack_hybrid_xg_port_no2_num_after_reset = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 107, 5, 1, 16), integer32().subtype(subtypeSpec=value_range_constraint(1, 16))).setMaxAccess('readwrite') if mibBuilder.loadTexts: rlStackHybridXgPortNo2NumAfterReset.setStatus('current') if mibBuilder.loadTexts: rlStackHybridXgPortNo2NumAfterReset.setDescription('Indicates the 2nd stack cascade port number that will be after reset.') mibBuilder.exportSymbols('CISCOSB-STACK-MIB', rlStackHybridPortNo1speed=rlStackHybridPortNo1speed, rlStackUnitMode=rlStackUnitMode, rlStackHybridStackModeAfterReset=rlStackHybridStackModeAfterReset, rlStackActiveUnitIdTable=rlStackActiveUnitIdTable, rlStackHybridPortNo1speedAfterReset=rlStackHybridPortNo1speedAfterReset, rlStackHybridDeviceModeAfterReset=rlStackHybridDeviceModeAfterReset, rlStack=rlStack, PortsPair=PortsPair, rlStackHybridPortNo2speed=rlStackHybridPortNo2speed, rlStackHybridXgPortNo1NumAfterReset=rlStackHybridXgPortNo1NumAfterReset, rlStackActiveUnitIdAfterReset=rlStackActiveUnitIdAfterReset, rlStackHybridTable=rlStackHybridTable, rlStackHybridUnitId=rlStackHybridUnitId, rlStackHybridPortsPairAfterReset=rlStackHybridPortsPairAfterReset, rlStackHybridEntry=rlStackHybridEntry, rlStackHybridXgPortNo2NumAfterReset=rlStackHybridXgPortNo2NumAfterReset, rlStackHybridStackMode=rlStackHybridStackMode, rlStackHybridPortNo2speedAfterReset=rlStackHybridPortNo2speedAfterReset, HybridStackDeviceMode=HybridStackDeviceMode, rlStackUnitModeAfterReset=rlStackUnitModeAfterReset, PYSNMP_MODULE_ID=rlStack, HybridStackPortSpeed=HybridStackPortSpeed, rlStackHybridDeleteStartupAfterReset=rlStackHybridDeleteStartupAfterReset, rlStackHybridXgPortNo2Num=rlStackHybridXgPortNo2Num, rlStackCurrentUnitId=rlStackCurrentUnitId, rlStackActiveUnitIdEntry=rlStackActiveUnitIdEntry, rlStackHybridPortsPair=rlStackHybridPortsPair, rlStackHybridXgPortNo1Num=rlStackHybridXgPortNo1Num, rlStackHybridUnitIdAfterReset=rlStackHybridUnitIdAfterReset, rlStackUnitMacAddressAfterReset=rlStackUnitMacAddressAfterReset, StackMode=StackMode)
def config_fgsm(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' fgsm_params = {yname: adv_ys, 'eps': 0.3, 'clip_min': 0., 'clip_max': 1.} return fgsm_params def config_bim(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' bim_params = {yname: adv_ys, 'eps': 0.3, 'eps_iter': 0.01, 'nb_iter': 100, 'clip_min': 0., 'clip_max': 1.} return bim_params def config_mim(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' mim_params = {yname: adv_ys, 'eps': 0.1, 'eps_iter': 0.01, 'nb_iter': 100, 'decay_factor': 0.7, 'clip_min': 0., 'clip_max': 1.} return mim_params def config_jsma(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' jsma_params = {yname: adv_ys, 'theta': 1., 'gamma': 0.1, 'clip_min': 0., 'clip_max': 1.} return jsma_params def config_vat(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' vat_params = {yname: adv_ys, 'eps': 2.0, 'xi': 1e-6, 'num_iterations': 10, 'clip_min': 0., 'clip_max': 1.} return vat_params def config_cw(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' cw_params = {yname: adv_ys, 'max_iterations': 10000, 'binary_search_steps': 9, 'abort_early': True, 'confidence': 0., 'learning_rate': 1e-2, 'initial_const': 1e-3, 'clip_min': 0., 'clip_max': 1.} return cw_params def config_elastic(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' elastic_params = {yname: adv_ys, 'beta': 1e-3, 'confidence': 0., 'learning_rate': 1e-2, 'binary_search_steps': 9, 'max_iterations': 1000, 'abort_early': False, 'initial_const': 1e-3, 'clip_min': 0., 'clip_max': 1.} return elastic_params def config_deepfool(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' deepfool_params = {yname: adv_ys, 'nb_candidate': 10, 'overshoot': 0.02, 'max_iter': 50, 'clip_min': 0., 'clip_max': 1.} return deepfool_params def config_madry(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' madry_params = {yname: adv_ys, 'eps': 0.3, 'eps_iter': 0.01, 'nb_iter': 40, 'clip_min': 0., 'clip_max': 1., 'rand_init': False} return madry_params
def config_fgsm(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' fgsm_params = {yname: adv_ys, 'eps': 0.3, 'clip_min': 0.0, 'clip_max': 1.0} return fgsm_params def config_bim(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' bim_params = {yname: adv_ys, 'eps': 0.3, 'eps_iter': 0.01, 'nb_iter': 100, 'clip_min': 0.0, 'clip_max': 1.0} return bim_params def config_mim(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' mim_params = {yname: adv_ys, 'eps': 0.1, 'eps_iter': 0.01, 'nb_iter': 100, 'decay_factor': 0.7, 'clip_min': 0.0, 'clip_max': 1.0} return mim_params def config_jsma(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' jsma_params = {yname: adv_ys, 'theta': 1.0, 'gamma': 0.1, 'clip_min': 0.0, 'clip_max': 1.0} return jsma_params def config_vat(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' vat_params = {yname: adv_ys, 'eps': 2.0, 'xi': 1e-06, 'num_iterations': 10, 'clip_min': 0.0, 'clip_max': 1.0} return vat_params def config_cw(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' cw_params = {yname: adv_ys, 'max_iterations': 10000, 'binary_search_steps': 9, 'abort_early': True, 'confidence': 0.0, 'learning_rate': 0.01, 'initial_const': 0.001, 'clip_min': 0.0, 'clip_max': 1.0} return cw_params def config_elastic(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' elastic_params = {yname: adv_ys, 'beta': 0.001, 'confidence': 0.0, 'learning_rate': 0.01, 'binary_search_steps': 9, 'max_iterations': 1000, 'abort_early': False, 'initial_const': 0.001, 'clip_min': 0.0, 'clip_max': 1.0} return elastic_params def config_deepfool(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' deepfool_params = {yname: adv_ys, 'nb_candidate': 10, 'overshoot': 0.02, 'max_iter': 50, 'clip_min': 0.0, 'clip_max': 1.0} return deepfool_params def config_madry(targeted, adv_ys): if targeted: yname = 'y_target' else: yname = 'y' madry_params = {yname: adv_ys, 'eps': 0.3, 'eps_iter': 0.01, 'nb_iter': 40, 'clip_min': 0.0, 'clip_max': 1.0, 'rand_init': False} return madry_params
n = int(input()) for i in range(1,n+1): if ((n % i) == 0): print(i,end=" ")
n = int(input()) for i in range(1, n + 1): if n % i == 0: print(i, end=' ')
_base_ = [ '../_base_/models/faster_rcnn_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py' ] # model setting model = dict( backbone=dict( init_cfg=None ), roi_head=dict( bbox_head=dict( num_classes=1 ) ) ) # data sets setting dataset_type = 'CocoDataset' classes = ('target',) data_root = '../data/rockets/' img_norm_cfg = dict( mean=[96, 96, 96], std=[18.5, 18.5, 18.5] ) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', flip_ratio=0.5), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), ] test_pipeline = [ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1333, 800), flip=False, transforms=[ dict(type='Resize', keep_ratio=True), dict(type='RandomFlip'), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']), ]) ] data = dict( samples_per_gpu=1, workers_per_gpu=1, train=dict( type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=train_pipeline, classes=classes ), val=dict( type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=test_pipeline, classes=classes ), test=dict( type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=test_pipeline, classes=classes ) ) # schedule setting optimizer = dict(lr=0.01) lr_config = dict(step=[16, 22]) runner = dict(max_epochs=24) evaluation = dict(interval=1, metric='bbox') # default runtime setting checkpoint_config = dict(interval=5) log_config = dict(interval=100) load_from = None work_dir = '../workdirs/faster_rcnn_r50_fpn_2x_rockets'
_base_ = ['../_base_/models/faster_rcnn_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py'] model = dict(backbone=dict(init_cfg=None), roi_head=dict(bbox_head=dict(num_classes=1))) dataset_type = 'CocoDataset' classes = ('target',) data_root = '../data/rockets/' img_norm_cfg = dict(mean=[96, 96, 96], std=[18.5, 18.5, 18.5]) train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', flip_ratio=0.5), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])] test_pipeline = [dict(type='LoadImageFromFile'), dict(type='MultiScaleFlipAug', img_scale=(1333, 800), flip=False, transforms=[dict(type='Resize', keep_ratio=True), dict(type='RandomFlip'), dict(type='Normalize', **img_norm_cfg), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img'])])] data = dict(samples_per_gpu=1, workers_per_gpu=1, train=dict(type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=train_pipeline, classes=classes), val=dict(type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=test_pipeline, classes=classes), test=dict(type=dataset_type, ann_file=data_root + 'train_2022.json', img_prefix=data_root + 'train_2022/', pipeline=test_pipeline, classes=classes)) optimizer = dict(lr=0.01) lr_config = dict(step=[16, 22]) runner = dict(max_epochs=24) evaluation = dict(interval=1, metric='bbox') checkpoint_config = dict(interval=5) log_config = dict(interval=100) load_from = None work_dir = '../workdirs/faster_rcnn_r50_fpn_2x_rockets'
# 24. Swap Nodes in Pairs # Runtime: 24 ms, faster than 96.60% of Python3 online submissions for Swap Nodes in Pairs. # Memory Usage: 14 MB, less than 92.32% of Python3 online submissions for Swap Nodes in Pairs. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: # Recursive Approach def swapPairs(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head else: head.val, head.next.val = head.next.val, head.val self.swapPairs(head.next.next) return head
class Solution: def swap_pairs(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head else: (head.val, head.next.val) = (head.next.val, head.val) self.swapPairs(head.next.next) return head
''' Created on 11 Apr 2020 @author: dkr85djo ''' class md: MAXCARDS = 106 class MDColourSet: def __init__(self, value, names, hexcolour=b'#000000'): self.value = value self.names = names self.hexcolour = hexcolour def size(self): return len(self.names) class MDCard: # ABSTRACT def __init__(self, value, titleid, cardid=0, ctype=0): self.value = value # monetary value: may be index or literal (direct) self.title = titleid # descriptive text: index self.cardid = cardid # explicit index, direct, implicit, set by drawpile generator self.cardtype = ctype # card type: implicit, set by derived constructors class MDMoneyCard(MDCard): def __init__(self, value, titleid, inctype=4, colourset=None): MDCard.__init__(self, value, titleid, ctype=inctype) self.cardtype = inctype self.colourset = colourset class MDPropertyCard(MDCard): def __init__(self, value, titleid, colourset=None, inctype=0): MDCard.__init__(self, value, titleid, ctype=inctype) self.colourset = colourset # if non wild card, 1 element self.cardtype = inctype + min(len(colourset) - 1, 1) # targetall = True => whichtarget=all # targetall = False => whichtarget=$var (one of which is 'self') class MDActionCard(MDCard): def __init__(self, value, titleid, colourset=None, targetall=False, inctype=2): MDCard.__init__(self, value, titleid, ctype=inctype) self.targetall = targetall self.colourset = colourset self.cardtype = inctype + min(len(colourset) - 1, 1) class MDCardCollection: def __init__(self, ownerid, ispublic=False): self.ownerid = ownerid self.ispublic = ispublic self.cards = [] def generate(self, cardset): for i in range(len(cardset)): newcardobject = cardset[i] newcardobject.cardid = i # need to generate cardid here self.cards.append(newcardobject) # we are agnostic to the type of card def length(self): # FIXME: We should just use len() return (len(self.cards)) def remove(self, index): return self.cards.pop(index) def add(self, cardobject): self.cards.append(cardobject)
""" Created on 11 Apr 2020 @author: dkr85djo """ class Md: maxcards = 106 class Mdcolourset: def __init__(self, value, names, hexcolour=b'#000000'): self.value = value self.names = names self.hexcolour = hexcolour def size(self): return len(self.names) class Mdcard: def __init__(self, value, titleid, cardid=0, ctype=0): self.value = value self.title = titleid self.cardid = cardid self.cardtype = ctype class Mdmoneycard(MDCard): def __init__(self, value, titleid, inctype=4, colourset=None): MDCard.__init__(self, value, titleid, ctype=inctype) self.cardtype = inctype self.colourset = colourset class Mdpropertycard(MDCard): def __init__(self, value, titleid, colourset=None, inctype=0): MDCard.__init__(self, value, titleid, ctype=inctype) self.colourset = colourset self.cardtype = inctype + min(len(colourset) - 1, 1) class Mdactioncard(MDCard): def __init__(self, value, titleid, colourset=None, targetall=False, inctype=2): MDCard.__init__(self, value, titleid, ctype=inctype) self.targetall = targetall self.colourset = colourset self.cardtype = inctype + min(len(colourset) - 1, 1) class Mdcardcollection: def __init__(self, ownerid, ispublic=False): self.ownerid = ownerid self.ispublic = ispublic self.cards = [] def generate(self, cardset): for i in range(len(cardset)): newcardobject = cardset[i] newcardobject.cardid = i self.cards.append(newcardobject) def length(self): return len(self.cards) def remove(self, index): return self.cards.pop(index) def add(self, cardobject): self.cards.append(cardobject)
class Stack: Top = -1 def __init__(self,size): self.stack = [0 for i in range(size)] def push(self, value): if (Stack.Top!=len(self.stack)-1): Stack.Top += 1 self.stack[Stack.Top] = value else: print("Overflow: Stack is Full") def pop(self): if (Stack.Top == -1): print("Underflow: Stack is Empty") else: Stack.Top -= 1 def peek(self): if (Stack.Top == -1): print("Underflow: Stack is Empty") else: return (self.stack[Stack.Top]) def traverse(self): if (Stack.Top == -1): print("Underflow: Stack is Empty") else: for i in range(Stack.Top,-1,-1): print(self.stack[i], end = " ") def is_Full(self): if (Stack.Top == len(self.stack)-1): return True else: return False def is_Empty(self): if (Stack.Top == -1): return True else: return False # Driver Code data = Stack(5) data.traverse() data.push(5) data.push(36) data.push(43) data.traverse() data.push(33) data.traverse() print(data.peek()) data.pop() data.traverse() print(data.is_Empty()) print(data.is_Full())
class Stack: top = -1 def __init__(self, size): self.stack = [0 for i in range(size)] def push(self, value): if Stack.Top != len(self.stack) - 1: Stack.Top += 1 self.stack[Stack.Top] = value else: print('Overflow: Stack is Full') def pop(self): if Stack.Top == -1: print('Underflow: Stack is Empty') else: Stack.Top -= 1 def peek(self): if Stack.Top == -1: print('Underflow: Stack is Empty') else: return self.stack[Stack.Top] def traverse(self): if Stack.Top == -1: print('Underflow: Stack is Empty') else: for i in range(Stack.Top, -1, -1): print(self.stack[i], end=' ') def is__full(self): if Stack.Top == len(self.stack) - 1: return True else: return False def is__empty(self): if Stack.Top == -1: return True else: return False data = stack(5) data.traverse() data.push(5) data.push(36) data.push(43) data.traverse() data.push(33) data.traverse() print(data.peek()) data.pop() data.traverse() print(data.is_Empty()) print(data.is_Full())
BASIC_PLUGINS = [ { "name": "kubejobs", "source": "", "component": "manager", "plugin_source": "", "module": "kubejobs" }, { "name": "kubejobs", "source": "", "component": "controller", "plugin_source": "", "module": "kubejobs" }, { "name": "kubejobs", "source": "", "component": "monitor", "plugin_source": "", "module": "kubejobs" }, { "name": "k8s-grafana", "source": "", "component": "visualizer", "plugin_source": "", "module": "k8s-grafana" }, ] def check_basic_plugins(db): ''' This function checks if the basic plugins (kubejobs) are registered into the database. ''' installed_plugins = db.get_all() for basic in BASIC_PLUGINS: name = basic.get('name') source = basic.get('source') component = basic.get('component') plugin_source = basic.get('plugin_source') module = basic.get('module') is_installed = False for installed in installed_plugins: if installed.name == name and \ installed.component == component: is_installed = True if not is_installed: db.put(plugin_name=name, source=source, plugin_source=plugin_source, component=component, plugin_module=module)
basic_plugins = [{'name': 'kubejobs', 'source': '', 'component': 'manager', 'plugin_source': '', 'module': 'kubejobs'}, {'name': 'kubejobs', 'source': '', 'component': 'controller', 'plugin_source': '', 'module': 'kubejobs'}, {'name': 'kubejobs', 'source': '', 'component': 'monitor', 'plugin_source': '', 'module': 'kubejobs'}, {'name': 'k8s-grafana', 'source': '', 'component': 'visualizer', 'plugin_source': '', 'module': 'k8s-grafana'}] def check_basic_plugins(db): """ This function checks if the basic plugins (kubejobs) are registered into the database. """ installed_plugins = db.get_all() for basic in BASIC_PLUGINS: name = basic.get('name') source = basic.get('source') component = basic.get('component') plugin_source = basic.get('plugin_source') module = basic.get('module') is_installed = False for installed in installed_plugins: if installed.name == name and installed.component == component: is_installed = True if not is_installed: db.put(plugin_name=name, source=source, plugin_source=plugin_source, component=component, plugin_module=module)
refTable = [{'desc': 'Freedom of Movement', 'templates': ['free'], 'weight': 1.0}, {'desc': 'Visa not Required', 'templates': ['yes', 'yes '], 'weight': 0.9}, {'desc': 'Visa on Arrival', 'templates': ['Optional', 'yes-no'], 'weight': 0.7}, {'desc': 'Electronic Visa', 'templates': ['yes2'], 'weight': 0.5}, {'desc': 'Visa is required', 'templates': ['no', 'no ', 'n/a'], 'weight': 0.4}, {'desc': 'Travel not Allowed', 'templates': ['black', 'BLACK'], 'weight': 0.0}]
ref_table = [{'desc': 'Freedom of Movement', 'templates': ['free'], 'weight': 1.0}, {'desc': 'Visa not Required', 'templates': ['yes', 'yes '], 'weight': 0.9}, {'desc': 'Visa on Arrival', 'templates': ['Optional', 'yes-no'], 'weight': 0.7}, {'desc': 'Electronic Visa', 'templates': ['yes2'], 'weight': 0.5}, {'desc': 'Visa is required', 'templates': ['no', 'no ', 'n/a'], 'weight': 0.4}, {'desc': 'Travel not Allowed', 'templates': ['black', 'BLACK'], 'weight': 0.0}]
# builtins stub used in boolean-related test cases. class object: def __init__(self) -> None: pass class type: pass class bool: pass class int: pass
class Object: def __init__(self) -> None: pass class Type: pass class Bool: pass class Int: pass
{ '%Y-%m-%d':'%Y-%m-%d', '%Y-%m-%d %H:%M:%S':'%Y-%m-%d %H:%M:%S', '%s rows deleted':'%s records cancellati', '%s rows updated':'*** %s records modificati', 'Hello World':'Salve Mondo', 'Invalid Query':'Query invalida', 'Sure you want to delete this object?':'Sicuro che vuoi cancellare questo oggetto?', 'Welcome to web2py':'Ciao da wek2py', 'click here for online examples':'clicca per vedere gli esempi', 'click here for the administrative interface':'clicca per l\'interfaccia administrativa', 'data uploaded':'dati caricati', 'db':'db', 'design':'progetta', 'done!':'fatto!', 'invalid request':'richiesta invalida!', 'new record inserted':'nuovo record inserito', 'record does not exist':'il record non esiste', 'state':'stato', 'unable to parse csv file':'non so leggere questo csv file' }
{'%Y-%m-%d': '%Y-%m-%d', '%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S', '%s rows deleted': '%s records cancellati', '%s rows updated': '*** %s records modificati', 'Hello World': 'Salve Mondo', 'Invalid Query': 'Query invalida', 'Sure you want to delete this object?': 'Sicuro che vuoi cancellare questo oggetto?', 'Welcome to web2py': 'Ciao da wek2py', 'click here for online examples': 'clicca per vedere gli esempi', 'click here for the administrative interface': "clicca per l'interfaccia administrativa", 'data uploaded': 'dati caricati', 'db': 'db', 'design': 'progetta', 'done!': 'fatto!', 'invalid request': 'richiesta invalida!', 'new record inserted': 'nuovo record inserito', 'record does not exist': 'il record non esiste', 'state': 'stato', 'unable to parse csv file': 'non so leggere questo csv file'}
def clean_split(text, delim=','): text = text.strip() return map(lambda o: o.strip(), text.split(delim)) def read_notes(file): notes = {} for line in file: split = clean_split(line, ',')[:-1] if split[-1] == '': continue notes[(split[0], int(split[1]))] = float(split[2]) return notes # Map notes to frequencies notes = read_notes(open('notes.txt')) # Map frequencies to note tuples inv_notes = {v: k for k, v in notes.items()} if __name__ == '__main__': path = 'notes.txt' with open(path) as f: read_notes(f)
def clean_split(text, delim=','): text = text.strip() return map(lambda o: o.strip(), text.split(delim)) def read_notes(file): notes = {} for line in file: split = clean_split(line, ',')[:-1] if split[-1] == '': continue notes[split[0], int(split[1])] = float(split[2]) return notes notes = read_notes(open('notes.txt')) inv_notes = {v: k for (k, v) in notes.items()} if __name__ == '__main__': path = 'notes.txt' with open(path) as f: read_notes(f)
# Game Objects class Space(object): def __init__(self,name): self.name = name def get_name(self): return self.name class Property(Space): set_houses = { "Violet":2, "Light blue":3, "Purple":3, "Orange":3, "Red":3, "Yellow":3, "Green":3, "Blue":2 } def __init__(self, name, color, price, rent, one_house_rent, two_house_rent, three_house_rent, four_house_rent, hotel_rent, house_cost): super(Property,self).__init__(name) self.price = price self.color = color self.house_count = 0 #5 means hotel self.rents = {0:rent, 1:one_house_rent, 2:two_house_rent, 3:three_house_rent, 4:four_house_rent, 5:hotel_rent} self.house_cost = house_cost def get_house_cost(self): return self.house_cost def info(self): information = [ self.name+" is a "+self.color+" property that costs "+str(self.price)+".", "It currently has "+str(self.house_count)+" houses.", "With no houses rent is "+str(self.rents[0])+".", "With 1 house rent is "+str(self.rents[1])+".", "With 2 houses rent is "+str(self.rents[2])+".", "With 3 houses rent is "+str(self.rents[3])+".", "With 4 houses rent is "+str(self.rents[4])+".", "With a hotel rent is "+str(self.rents[5])+".", "A house costs "+str(self.house_cost)+" to build." ] return " ".join(information) class Railroad(Space): def __init__(self,name): super(Railroad, self).__init__(name) self.price = 200 self.rents = {1:25, 2:50, 3:100, 4:200} def info(self): information = [ self.name+" is a railroad that costs "+str(self.price)+".", "If a player has one railroad only the rent is "+str(self.rents[1])+".", "If a player has two railroads the rent is "+str(self.rents[2])+".", "If a player has three railroads only the rent is "+str(self.rents[3])+".", "If a player has four railroads only the rent is "+str(self.rents[4])+"." ] return " ".join(information) class Utility(Space): def __init__(self,name): super(Utility,self).__init__(name) self.price = 150 self.rents = {1:"4 *", 2:"10 *"} def info(self): return self.name+" is a utility that costs "+str(self.price)+". If you have " +\ "one utility rent is four times the amount the player rolled on the dice or "+\ "if you have two utilities the rent is ten times!" board_spaces = [ Space("GO"), Property("Mediterranean Ave.","Violet",60,2,10,30,90,160,250,50), Space("Community Card"), Property("Baltic Ave.","Violet",60,4,20,60,180,320,450,50), Space("Income Tax"), Railroad("Reading Railroad"), Property("Oriental Ave.","Light blue",100,6,30,90,270,400,550,50), Space("Chance Card"), Property("Vermont Ave.","Light blue",100,6,30,90,270,400,550,50), Property("Conneticut Ave.","Light blue",120,8,40,100,300,450,600,50), Space("Jail"), Property("St. Charles Pl.","Purple",140,10,50,150,450,625,750,100), Utility("Electric Company"), Property("States Ave.","Purple",140,10,50,150,450,625,750,100), Property("Virginia Ave.","Purple",160,12,60,180,500,700,900,100), Railroad("Pennsylvania Railroad"), Property("St. James Pl.","Orange",180,14,70,200,550,750,950,100), Space("Community Card"), Property("Tennessee Ave.","Orange",180,14,70,200,550,750,950,100), Property("New York Ave.","Orange",200,16,80,220,600,800,1000,100), Space("Free Parking"), Property("Kentucky Ave.","Red",220,18,90,250,700,875,1050,150), Space("Chance Card"), Property("Indiana Ave.","Red",220,18,90,250,700,875,1050,150), Property("Illinois Ave.","Red",240,20,100,300,750,925,1100,150), Railroad("B. & O. Railroad"), Property("Atlantic Ave.","Yellow",260,22,110,330,800,975,1150,150), Property("Ventnor Ave.","Yellow",260,22,110,330,800,975,1150,150), Utility("Water Works"), Property("Marvin Gardens","Yellow",280,24,120,360,850,1025,1200,150), Space("Go to Jail"), Property("Pacific Ave.","Green",300,26,130,390,900,1100,1275,200), Property("No. Carolina Ave.","Green",300,26,130,390,900,1100,1275,200), Space("Community Card"), Property("Pennsylvania Ave.","Green",320,28,150,450,1000,1200,1400,200), Railroad("Short Line Railroad"), Space("Chance Card"), Property("Park Place","Blue",350,35,175,500,1100,1300,1500,200), Space("Luxury Tax"), Property("Boardwalk","Blue",400,50,200,600,1400,1700,2000,200) ] #chance_methods = [pay_all,reading_rail,move_to,go,railroad,get_outta_jail,jail,earn,fine,repairs,util,move_back_three] #in the following decks, the second value of the dictionaries in the array must be an iterable and not an int, #hence why you will see things like (50,) so that python keeps it as a tuple chance_deck = [ {"You have been elected chairman of the board, pay each player $50":[0,(50,)]}, {"Take a ride on the reading, if you pass GO collect $200":[1,()]}, {"Take a walk on the board walk, advance token to board walk":[2,(board_spaces[39],)]}, {"Advance to go, collect $200":[3,()]}, {"Advance token to the nearest Railroad and pay owner Twice the Rental owed. If Railroad is unowned you may buy it from the bank":[4,()]}, {"Advance token to the nearest Railroad and pay owner Twice the Rental owed. If Railroad is unowned you may buy it from the bank":[4,()]}, {"Get out of jail free. This card may be kept until needed or sold":[5,()]}, {"Go directly to jail. Do not pass Go, do not collect $200":[6,()]}, {"Bank pays you dividend of $50":[7,(50,)]}, {"Advance to Illinois Ave":[2,(board_spaces[24],)]}, {"Pay poor tax of $15":[8,(15,)]}, {"Make general repairs on all your property. For each house pay $25, for each hotel $100":[9,(25,100)]}, {"Advance to St. Charles Place. If you pass Go, collect $200":[2,(board_spaces[11],)]}, {"Your building and loan matures. Collect $150":[7,(150,)]}, {"Advance token to nearest utility. If Unowned you may buy it from the bank. If owned throw dice and pay owner ten times the amount thrown.":[10,()]}, {"Go back 3 spaces":[11,()]} ] #cc methods = [earn,get_outta_jail,collect,go,jail,repairs,fine] community_deck = [ {"Get out of jail free.":[1,()]}, {"From sale of stock, you get $45":[0,(45,)]}, {"Grand opera opening. Collect $50 from every player for opening night seats":[2,(50,)]}, {"Advance to Go, collect $200":[3,()]}, {"Xmas fund matures, collect $100":[0,(100,)]}, {"Go directly to jail. Do not pass Go. Do not collect $200":[4,()]}, {"Life insurance matures, collect $200":[0,(200,)]}, {"You are assessed for street repairs. $40 per house, $115 per hotel":[5,(40,115)]}, {"Pay hospital $100":[6,(100,)]}, {"Income tax refund, collect $20":[0,(20,)]}, {"Doctor's fee, pay $50":[6,(50,)]}, {"You inherit $100":[0,(100,)]}, {"Pay school tax of $150":[6,(150,)]}, {"Receive for services $25":[0,(25,)]}, {"Bank error in your favor, collect $200":[0,(200,)]}, {"You have won second prize in a beauty contest, collect $10":[0,(10,)]} ]
class Space(object): def __init__(self, name): self.name = name def get_name(self): return self.name class Property(Space): set_houses = {'Violet': 2, 'Light blue': 3, 'Purple': 3, 'Orange': 3, 'Red': 3, 'Yellow': 3, 'Green': 3, 'Blue': 2} def __init__(self, name, color, price, rent, one_house_rent, two_house_rent, three_house_rent, four_house_rent, hotel_rent, house_cost): super(Property, self).__init__(name) self.price = price self.color = color self.house_count = 0 self.rents = {0: rent, 1: one_house_rent, 2: two_house_rent, 3: three_house_rent, 4: four_house_rent, 5: hotel_rent} self.house_cost = house_cost def get_house_cost(self): return self.house_cost def info(self): information = [self.name + ' is a ' + self.color + ' property that costs ' + str(self.price) + '.', 'It currently has ' + str(self.house_count) + ' houses.', 'With no houses rent is ' + str(self.rents[0]) + '.', 'With 1 house rent is ' + str(self.rents[1]) + '.', 'With 2 houses rent is ' + str(self.rents[2]) + '.', 'With 3 houses rent is ' + str(self.rents[3]) + '.', 'With 4 houses rent is ' + str(self.rents[4]) + '.', 'With a hotel rent is ' + str(self.rents[5]) + '.', 'A house costs ' + str(self.house_cost) + ' to build.'] return ' '.join(information) class Railroad(Space): def __init__(self, name): super(Railroad, self).__init__(name) self.price = 200 self.rents = {1: 25, 2: 50, 3: 100, 4: 200} def info(self): information = [self.name + ' is a railroad that costs ' + str(self.price) + '.', 'If a player has one railroad only the rent is ' + str(self.rents[1]) + '.', 'If a player has two railroads the rent is ' + str(self.rents[2]) + '.', 'If a player has three railroads only the rent is ' + str(self.rents[3]) + '.', 'If a player has four railroads only the rent is ' + str(self.rents[4]) + '.'] return ' '.join(information) class Utility(Space): def __init__(self, name): super(Utility, self).__init__(name) self.price = 150 self.rents = {1: '4 *', 2: '10 *'} def info(self): return self.name + ' is a utility that costs ' + str(self.price) + '. If you have ' + 'one utility rent is four times the amount the player rolled on the dice or ' + 'if you have two utilities the rent is ten times!' board_spaces = [space('GO'), property('Mediterranean Ave.', 'Violet', 60, 2, 10, 30, 90, 160, 250, 50), space('Community Card'), property('Baltic Ave.', 'Violet', 60, 4, 20, 60, 180, 320, 450, 50), space('Income Tax'), railroad('Reading Railroad'), property('Oriental Ave.', 'Light blue', 100, 6, 30, 90, 270, 400, 550, 50), space('Chance Card'), property('Vermont Ave.', 'Light blue', 100, 6, 30, 90, 270, 400, 550, 50), property('Conneticut Ave.', 'Light blue', 120, 8, 40, 100, 300, 450, 600, 50), space('Jail'), property('St. Charles Pl.', 'Purple', 140, 10, 50, 150, 450, 625, 750, 100), utility('Electric Company'), property('States Ave.', 'Purple', 140, 10, 50, 150, 450, 625, 750, 100), property('Virginia Ave.', 'Purple', 160, 12, 60, 180, 500, 700, 900, 100), railroad('Pennsylvania Railroad'), property('St. James Pl.', 'Orange', 180, 14, 70, 200, 550, 750, 950, 100), space('Community Card'), property('Tennessee Ave.', 'Orange', 180, 14, 70, 200, 550, 750, 950, 100), property('New York Ave.', 'Orange', 200, 16, 80, 220, 600, 800, 1000, 100), space('Free Parking'), property('Kentucky Ave.', 'Red', 220, 18, 90, 250, 700, 875, 1050, 150), space('Chance Card'), property('Indiana Ave.', 'Red', 220, 18, 90, 250, 700, 875, 1050, 150), property('Illinois Ave.', 'Red', 240, 20, 100, 300, 750, 925, 1100, 150), railroad('B. & O. Railroad'), property('Atlantic Ave.', 'Yellow', 260, 22, 110, 330, 800, 975, 1150, 150), property('Ventnor Ave.', 'Yellow', 260, 22, 110, 330, 800, 975, 1150, 150), utility('Water Works'), property('Marvin Gardens', 'Yellow', 280, 24, 120, 360, 850, 1025, 1200, 150), space('Go to Jail'), property('Pacific Ave.', 'Green', 300, 26, 130, 390, 900, 1100, 1275, 200), property('No. Carolina Ave.', 'Green', 300, 26, 130, 390, 900, 1100, 1275, 200), space('Community Card'), property('Pennsylvania Ave.', 'Green', 320, 28, 150, 450, 1000, 1200, 1400, 200), railroad('Short Line Railroad'), space('Chance Card'), property('Park Place', 'Blue', 350, 35, 175, 500, 1100, 1300, 1500, 200), space('Luxury Tax'), property('Boardwalk', 'Blue', 400, 50, 200, 600, 1400, 1700, 2000, 200)] chance_deck = [{'You have been elected chairman of the board, pay each player $50': [0, (50,)]}, {'Take a ride on the reading, if you pass GO collect $200': [1, ()]}, {'Take a walk on the board walk, advance token to board walk': [2, (board_spaces[39],)]}, {'Advance to go, collect $200': [3, ()]}, {'Advance token to the nearest Railroad and pay owner Twice the Rental owed. If Railroad is unowned you may buy it from the bank': [4, ()]}, {'Advance token to the nearest Railroad and pay owner Twice the Rental owed. If Railroad is unowned you may buy it from the bank': [4, ()]}, {'Get out of jail free. This card may be kept until needed or sold': [5, ()]}, {'Go directly to jail. Do not pass Go, do not collect $200': [6, ()]}, {'Bank pays you dividend of $50': [7, (50,)]}, {'Advance to Illinois Ave': [2, (board_spaces[24],)]}, {'Pay poor tax of $15': [8, (15,)]}, {'Make general repairs on all your property. For each house pay $25, for each hotel $100': [9, (25, 100)]}, {'Advance to St. Charles Place. If you pass Go, collect $200': [2, (board_spaces[11],)]}, {'Your building and loan matures. Collect $150': [7, (150,)]}, {'Advance token to nearest utility. If Unowned you may buy it from the bank. If owned throw dice and pay owner ten times the amount thrown.': [10, ()]}, {'Go back 3 spaces': [11, ()]}] community_deck = [{'Get out of jail free.': [1, ()]}, {'From sale of stock, you get $45': [0, (45,)]}, {'Grand opera opening. Collect $50 from every player for opening night seats': [2, (50,)]}, {'Advance to Go, collect $200': [3, ()]}, {'Xmas fund matures, collect $100': [0, (100,)]}, {'Go directly to jail. Do not pass Go. Do not collect $200': [4, ()]}, {'Life insurance matures, collect $200': [0, (200,)]}, {'You are assessed for street repairs. $40 per house, $115 per hotel': [5, (40, 115)]}, {'Pay hospital $100': [6, (100,)]}, {'Income tax refund, collect $20': [0, (20,)]}, {"Doctor's fee, pay $50": [6, (50,)]}, {'You inherit $100': [0, (100,)]}, {'Pay school tax of $150': [6, (150,)]}, {'Receive for services $25': [0, (25,)]}, {'Bank error in your favor, collect $200': [0, (200,)]}, {'You have won second prize in a beauty contest, collect $10': [0, (10,)]}]
class Hourly: def __init__(self, temp, feels_like, pressure, humidity, wind_speed, date, city, weather): self.temp=temp; self.feels_like=feels_like; self.pressure=pressure; self.humidity=humidity; self.wind_speed=wind_speed; self.date=date; self.city=city; self.weather=weather;
class Hourly: def __init__(self, temp, feels_like, pressure, humidity, wind_speed, date, city, weather): self.temp = temp self.feels_like = feels_like self.pressure = pressure self.humidity = humidity self.wind_speed = wind_speed self.date = date self.city = city self.weather = weather
class InvalidQNameError(RuntimeError): def __init__(self, qname): message = "Invalid qname: " + qname super(InvalidQNameError, self).__init__(message)
class Invalidqnameerror(RuntimeError): def __init__(self, qname): message = 'Invalid qname: ' + qname super(InvalidQNameError, self).__init__(message)
# selection sort algorithm # time complexity O(n^2) # space complexity O(1) def selectionsort(list, comp): for x in range(len(list)): curr = x for y in range(x, len(list)): if (comp(list[curr], list[y]) > 0): curr = y swap = list[x] list[x] = list[curr] list[curr] = swap return list
def selectionsort(list, comp): for x in range(len(list)): curr = x for y in range(x, len(list)): if comp(list[curr], list[y]) > 0: curr = y swap = list[x] list[x] = list[curr] list[curr] = swap return list
# Represents a single space within the board. class Tile(): # Initializes the tile. # By default, each tile is a wall until a board is built def __init__(self): self.isWall = True # Renders the object character in this tile def render(self): if self.isWall == True: return '0'; # Represents the game board for the PC to explore class Board(): # Initializes the board with a rectangle of Tiles # # @width - the number of tiles wide the board is # @height - the number of tiles tall the board is def __init__(self, width, height): self.width = width # width of the max play area self.height = height # height of the max play area self.board = []; # collection of all tiles that make up the board # Loop through each row & column to initialize the tile for y in range(0, self.height): row = []; for x in range(0, self.width): tile = Tile(); row.append(tile); self.board.append(row); # Renders each tile in the board def render(self): for y in range(0, self.height): row = ''; for x in range(0, self.width): row += self.board[y][x].render(); print(row)
class Tile: def __init__(self): self.isWall = True def render(self): if self.isWall == True: return '0' class Board: def __init__(self, width, height): self.width = width self.height = height self.board = [] for y in range(0, self.height): row = [] for x in range(0, self.width): tile = tile() row.append(tile) self.board.append(row) def render(self): for y in range(0, self.height): row = '' for x in range(0, self.width): row += self.board[y][x].render() print(row)
__title__ = 'dtanys' __description__ = 'Python structured data parser.' __url__ = 'https://github.com/luxuncang/dtanys' __version__ = '1.0.5' __author__ = 'ShengXin Lu' __author_email__ = 'luxuncang@qq.com' __license__ = 'MIT' __copyright__ = 'Copyright 2021 ShengXin Lu'
__title__ = 'dtanys' __description__ = 'Python structured data parser.' __url__ = 'https://github.com/luxuncang/dtanys' __version__ = '1.0.5' __author__ = 'ShengXin Lu' __author_email__ = 'luxuncang@qq.com' __license__ = 'MIT' __copyright__ = 'Copyright 2021 ShengXin Lu'
class Clock: def __init__(self, hour, minute): self.total: int = hour * 60 + minute # in minutes def __repr__(self): hour, minute = (self.total // 60) % 24, self.total % 60 return '{:02d}:{:02d}'.format(hour, minute) def __eq__(self, other): return repr(self) == repr(other) def __add__(self, minutes: int): self.total += minutes return self def __sub__(self, minutes: int): self.total -= minutes return self
class Clock: def __init__(self, hour, minute): self.total: int = hour * 60 + minute def __repr__(self): (hour, minute) = (self.total // 60 % 24, self.total % 60) return '{:02d}:{:02d}'.format(hour, minute) def __eq__(self, other): return repr(self) == repr(other) def __add__(self, minutes: int): self.total += minutes return self def __sub__(self, minutes: int): self.total -= minutes return self
file=open("circulations.txt") data=[] date=int(input()) for line in file: [book,member,due]=line.strip().split() if date>int(due): data.append([book,member,due]) i=0 while i<len(data)-1: j=0 while j<len(data)-1: if int(data[j][2])>int(data[j+1][2]): data[j], data[j+1] = data[j+1], data[j] j+=1 i+=1 if len(data)>0: for d in data: print(" ".join(d)) else: print("Not Found") file.close
file = open('circulations.txt') data = [] date = int(input()) for line in file: [book, member, due] = line.strip().split() if date > int(due): data.append([book, member, due]) i = 0 while i < len(data) - 1: j = 0 while j < len(data) - 1: if int(data[j][2]) > int(data[j + 1][2]): (data[j], data[j + 1]) = (data[j + 1], data[j]) j += 1 i += 1 if len(data) > 0: for d in data: print(' '.join(d)) else: print('Not Found') file.close
BASE_URL = "https://api.stlouisfed.org" SERIES_ENDPOINT = "fred/series/observations" SERIES = ["GDPC1", "UMCSENT", "UNRATE"] FILE_TYPE = "json"
base_url = 'https://api.stlouisfed.org' series_endpoint = 'fred/series/observations' series = ['GDPC1', 'UMCSENT', 'UNRATE'] file_type = 'json'
f90 = {} cxx = {} cc = {} is_arch_valid = 1 flags_arch = '-g -pg -O3 -Wall' # -lpthread: not needed? # -rdynamic: required for backtraces balancer = 'RotateLB' flags_prec_single = '-fdefault-real-4 -fdefault-double-8' flags_prec_double = '-fdefault-real-8 -fdefault-double-8' flags_cxx_charm = '-balancer ' + balancer flags_link_charm = '-rdynamic -module ' + balancer cc = 'gcc' f90 = 'gfortran' libpath_fortran = '' libs_fortran = ['gfortran'] home = os.environ['HOME'] charm_path = home + '/Charm/charm' papi_path = '/usr/local' hdf5_path = '/usr'
f90 = {} cxx = {} cc = {} is_arch_valid = 1 flags_arch = '-g -pg -O3 -Wall' balancer = 'RotateLB' flags_prec_single = '-fdefault-real-4 -fdefault-double-8' flags_prec_double = '-fdefault-real-8 -fdefault-double-8' flags_cxx_charm = '-balancer ' + balancer flags_link_charm = '-rdynamic -module ' + balancer cc = 'gcc' f90 = 'gfortran' libpath_fortran = '' libs_fortran = ['gfortran'] home = os.environ['HOME'] charm_path = home + '/Charm/charm' papi_path = '/usr/local' hdf5_path = '/usr'
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def removeZeroSumSublists(self, head: ListNode) -> ListNode: ptr = ListNode(-1) ptr.next = head current = head head = ptr while head: s = 0 while current: s += current.val if s == 0: head.next = current.next current = current.next head = head.next if head: current = head.next return ptr.next
class Listnode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def remove_zero_sum_sublists(self, head: ListNode) -> ListNode: ptr = list_node(-1) ptr.next = head current = head head = ptr while head: s = 0 while current: s += current.val if s == 0: head.next = current.next current = current.next head = head.next if head: current = head.next return ptr.next
add_library('opencv_processing') src = loadImage("test.jpg") size(src.width, src.height, P2D) opencv = OpenCV(this, src) opencv.findCannyEdges(20, 75) canny = opencv.getSnapshot() opencv.loadImage(src) opencv.findScharrEdges(OpenCV.HORIZONTAL) scharr = opencv.getSnapshot() opencv.loadImage(src) opencv.findSobelEdges(1, 0) sobel = opencv.getSnapshot() with pushMatrix(): scale(0.5) image(src, 0, 0) image(canny, src.width, 0) image(scharr, 0, src.height) image(sobel, src.width, src.height) text("Source", 10, 25) text("Canny", src.width / 2 + 10, 25) text("Scharr", 10, src.height / 2 + 25) text("Sobel", src.width / 2 + 10, src.height / 2 + 25)
add_library('opencv_processing') src = load_image('test.jpg') size(src.width, src.height, P2D) opencv = open_cv(this, src) opencv.findCannyEdges(20, 75) canny = opencv.getSnapshot() opencv.loadImage(src) opencv.findScharrEdges(OpenCV.HORIZONTAL) scharr = opencv.getSnapshot() opencv.loadImage(src) opencv.findSobelEdges(1, 0) sobel = opencv.getSnapshot() with push_matrix(): scale(0.5) image(src, 0, 0) image(canny, src.width, 0) image(scharr, 0, src.height) image(sobel, src.width, src.height) text('Source', 10, 25) text('Canny', src.width / 2 + 10, 25) text('Scharr', 10, src.height / 2 + 25) text('Sobel', src.width / 2 + 10, src.height / 2 + 25)
# # PySNMP MIB module RAPID-HA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RAPID-HA-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:51:59 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, ConstraintsIntersection, SingleValueConstraint, ValueSizeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsUnion") rapidstream, = mibBuilder.importSymbols("RAPID-MIB", "rapidstream") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") MibIdentifier, Bits, Integer32, Unsigned32, NotificationType, enterprises, Counter64, iso, Counter32, ModuleIdentity, TimeTicks, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "Bits", "Integer32", "Unsigned32", "NotificationType", "enterprises", "Counter64", "iso", "Counter32", "ModuleIdentity", "TimeTicks", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Gauge32") DateAndTime, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "DateAndTime", "TextualConvention", "DisplayString") rsInfoModule = ModuleIdentity((1, 3, 6, 1, 4, 1, 4355, 6)) rsInfoModule.setRevisions(('2002-11-01 12:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: rsInfoModule.setRevisionsDescriptions(('Initial revision.',)) if mibBuilder.loadTexts: rsInfoModule.setLastUpdated('0211011200Z') if mibBuilder.loadTexts: rsInfoModule.setOrganization('WatchGuard Technologies, Inc.') if mibBuilder.loadTexts: rsInfoModule.setContactInfo(' Ella Yu WatchGuard Technologies, Inc. 1841 Zanker Road San Jose, CA 95112 USA 408-519-4888 ella.yu@watchguard.com ') if mibBuilder.loadTexts: rsInfoModule.setDescription('The MIB module describes general information of RapidStream system. Mainly, the information obtained from this MIB is used by rsInfoSystemMIB, rsClientMIB, rsSystemStatisticsMIB, rsIpsecTunnelMIB, rsHAMIB.') rsHAMIB = ObjectIdentity((1, 3, 6, 1, 4, 1, 4355, 6, 6)) if mibBuilder.loadTexts: rsHAMIB.setStatus('current') if mibBuilder.loadTexts: rsHAMIB.setDescription('This is the base object identifier for all HA related branches.') rsHALocal = ObjectIdentity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1)) if mibBuilder.loadTexts: rsHALocal.setStatus('current') if mibBuilder.loadTexts: rsHALocal.setDescription('This is the base object identifier for all objects which are belong to local appliance.') rsHAPeer = ObjectIdentity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2)) if mibBuilder.loadTexts: rsHAPeer.setStatus('current') if mibBuilder.loadTexts: rsHAPeer.setDescription('This is the base object identifier for all objects which are belong to peer appliance.') rsHAStatus = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=NamedValues(("disabled", 0), ("unknown", 1), ("as-primary-active", 2), ("as-secondary-active", 3), ("aa-primary-ative", 4), ("aa-secondary-active", 5), ("aa-primary-takeover", 6), ("aa-secondary-takeover", 7), ("standby", 8), ("admin", 9), ("failed", 10), ("unavailable", 11)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAStatus.setStatus('current') if mibBuilder.loadTexts: rsHAStatus.setDescription("Indicates current status of local appliance. disabled: The local appliance of HA system is not enabled. unknown: The local appliance of HA system is in initialization as-primary-active: The local appliance that is the primary appliance of HA/AS system is in active mode. This status is also called MASTER in some systems. as-secondary-active: The local appliance that is the secondary appliance of HA/AS system is in active mode. This status is also called BACKUP in some systems. aa-primary-ative: The local appliance that is the primary appliance of HA/AA system is in active mode. aa-secondary-active: The local appliance that is the secondary appliance of HA/AA system is in active mode. aa-primary-takeover: The local appliance that is the primary appliance of HA/AA system has taken over the peer's duty. aa-secondary-takeover: The local appliance of the secondary appliance of HA/AA system has taken over the peer's duty. standby: The local appliance of HA/AS system is in standby mode. admin: The local appliance of HA system detects an mismatched configuration and waits for system administrator to reslove the conflict. failed: The local appliance of the HA system is down due to forced failover or other reasons. unavailable: It's reported when local appliance of HA system is unabled to get status information. ") rsHAPeerStatus = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))).clone(namedValues=NamedValues(("unavailable", 0), ("active", 1), ("standby", 2), ("admin", 3), ("failed", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerStatus.setStatus('current') if mibBuilder.loadTexts: rsHAPeerStatus.setDescription("Indicates current status of peer appliance. unavailable: It's reported when peer appliance of HA system is unabled to get status information. active: The peer applicance of HA system is in active mode. standby: The peer applicance of HA system is in standby mode. admin: The peer applicance of HA system dectects an mismatched configuration and waits for system administrator to reslove the conflict. failed: The peer appliance of HA system is down due to forced failover or other reasons. ") rsHALastDBSyncTime = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 3), DateAndTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHALastDBSyncTime.setStatus('current') if mibBuilder.loadTexts: rsHALastDBSyncTime.setDescription('The last DB synchronized time of local appliance.') rsHAError = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))).clone(namedValues=NamedValues(("no-error", 0), ("mismatched-ha-id", 1), ("mismatched-software", 2), ("mismatched-database", 3), ("mismatched-hardware", 4), ("forced-fail", 5), ("invalid-ha-role", 6), ("link-down", 7), ("lost-mia-heartbeat", 8), ("mia-not-responding", 9), ("admin-command-failed", 10), ("detect-ha-error", 11), ("unavailable", 12), ("hotsync-failed", 13), ("config-sync-failed", 14)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAError.setStatus('current') if mibBuilder.loadTexts: rsHAError.setDescription('Reports the current error that occurred in local appliance .') rsHAPeerError = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))).clone(namedValues=NamedValues(("no-error", 0), ("mismatched-ha-id", 1), ("mismatched-software", 2), ("mismatched-database", 3), ("mismatched-hardware", 4), ("forced-fail", 5), ("invalid-ha-role", 6), ("link-down", 7), ("lost-mia-heartbeat", 8), ("mia-not-responding", 9), ("admin-command-failed", 10), ("detect-ha-error", 11), ("unavailable", 12), ("hotsync-failed", 13), ("config-sync-failed", 14)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerError.setStatus('current') if mibBuilder.loadTexts: rsHAPeerError.setDescription('Reports the current error that occurred in peer appliance.') rsHAPeerSerialNumber = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 1), OctetString()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSerialNumber.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSerialNumber.setDescription('The serial number of peer appliance.') rsHAPeerLastDBSyncTime = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 2), DateAndTime()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerLastDBSyncTime.setStatus('current') if mibBuilder.loadTexts: rsHAPeerLastDBSyncTime.setDescription('The last DB synchronized time of peer appliance.') rsHAPeerDevice = ObjectIdentity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3)) if mibBuilder.loadTexts: rsHAPeerDevice.setStatus('current') if mibBuilder.loadTexts: rsHAPeerDevice.setDescription('This is the base object for parameters and configuration data of devices in this entity.') rsHAPeerCounters = ObjectIdentity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4)) if mibBuilder.loadTexts: rsHAPeerCounters.setStatus('current') if mibBuilder.loadTexts: rsHAPeerCounters.setDescription('This is the base object for parameters and configuration data of devices in this entity.') rsHAPeerIfNumber = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 1), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerIfNumber.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfNumber.setDescription('The number of RapidCard installed in this entity.') rsHAPeerIfTable = MibTable((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2), ) if mibBuilder.loadTexts: rsHAPeerIfTable.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfTable.setDescription('A list of RapidCard entries. The number of entries is given by the value of rsHAPeerDeviceNumber.') rsHAPeerIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1), ).setIndexNames((0, "RAPID-HA-MIB", "rsHAPeerIfIndex")) if mibBuilder.loadTexts: rsHAPeerIfEntry.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfEntry.setDescription('A RapidCard entry containing objects for a particular RapidCard.') rsHAPeerIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 1), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerIfIndex.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfIndex.setDescription('The unique value for each interface.') rsHAPeerIfIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 4), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerIfIpAddr.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfIpAddr.setDescription('The ip address of the interface.') rsHAPeerIfLinkStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("down", 0), ("up", 1), ("other", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerIfLinkStatus.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfLinkStatus.setDescription('The current state of the interface.') rsHAPeerSystemCpuUtil = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 1), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil.setDescription('The CPU utilization of the peer system in last 5 seconds.') rsHAPeerSystemTotalSendBytes = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemTotalSendBytes.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendBytes.setDescription('The total number of bytes sent since peer system is up.') rsHAPeerSystemTotalRecvBytes = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvBytes.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvBytes.setDescription('The total number of bytes received since peer system is up.') rsHAPeerSystemTotalSendPackets = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemTotalSendPackets.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendPackets.setDescription('The total number of packets sent since peer system is up.') rsHAPeerSystemTotalRecvPackets = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 5), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvPackets.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvPackets.setDescription('The total number of packets received since peer system is up.') rsHAPeerSystemStreamReqTotal = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 6), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemStreamReqTotal.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqTotal.setDescription('The total number of the connection requests since system is up.') rsHAPeerSystemStreamReqDrop = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 7), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemStreamReqDrop.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqDrop.setDescription('The total number of the connection requests being dropped since system is up.') rsHAPeerSystemCurrIpsecTunnels = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 8), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemCurrIpsecTunnels.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCurrIpsecTunnels.setDescription('The number of ipsec tunnels in the peer system currently.') rsHAPeerSystemCpuUtil1 = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 9), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil1.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil1.setDescription('The CPU utilization of the peer system in last 1 minute.') rsHAPeerSystemCpuUtil5 = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 10), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil5.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil5.setDescription('The CPU utilization of the peer system in last 5 minutes.') rsHAPeerSystemCpuUtil15 = MibScalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 11), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil15.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil15.setDescription('The CPU utilization of the peer system in last 15 minutes.') mibBuilder.exportSymbols("RAPID-HA-MIB", rsHAPeerIfNumber=rsHAPeerIfNumber, rsHALocal=rsHALocal, rsHAPeerIfIndex=rsHAPeerIfIndex, rsHAError=rsHAError, rsHAPeerLastDBSyncTime=rsHAPeerLastDBSyncTime, rsInfoModule=rsInfoModule, rsHALastDBSyncTime=rsHALastDBSyncTime, rsHAPeerDevice=rsHAPeerDevice, rsHAPeerSystemStreamReqTotal=rsHAPeerSystemStreamReqTotal, rsHAPeerSystemCpuUtil1=rsHAPeerSystemCpuUtil1, rsHAPeerSystemCpuUtil5=rsHAPeerSystemCpuUtil5, rsHAPeerSystemCpuUtil=rsHAPeerSystemCpuUtil, rsHAPeerStatus=rsHAPeerStatus, rsHAPeer=rsHAPeer, rsHAPeerSystemCurrIpsecTunnels=rsHAPeerSystemCurrIpsecTunnels, rsHAMIB=rsHAMIB, rsHAPeerSystemTotalSendBytes=rsHAPeerSystemTotalSendBytes, rsHAPeerCounters=rsHAPeerCounters, rsHAPeerIfIpAddr=rsHAPeerIfIpAddr, rsHAPeerIfEntry=rsHAPeerIfEntry, rsHAStatus=rsHAStatus, rsHAPeerError=rsHAPeerError, rsHAPeerIfLinkStatus=rsHAPeerIfLinkStatus, PYSNMP_MODULE_ID=rsInfoModule, rsHAPeerSystemCpuUtil15=rsHAPeerSystemCpuUtil15, rsHAPeerSystemTotalRecvBytes=rsHAPeerSystemTotalRecvBytes, rsHAPeerSystemStreamReqDrop=rsHAPeerSystemStreamReqDrop, rsHAPeerSerialNumber=rsHAPeerSerialNumber, rsHAPeerSystemTotalSendPackets=rsHAPeerSystemTotalSendPackets, rsHAPeerSystemTotalRecvPackets=rsHAPeerSystemTotalRecvPackets, rsHAPeerIfTable=rsHAPeerIfTable)
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsUnion') (rapidstream,) = mibBuilder.importSymbols('RAPID-MIB', 'rapidstream') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (mib_identifier, bits, integer32, unsigned32, notification_type, enterprises, counter64, iso, counter32, module_identity, time_ticks, ip_address, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'Bits', 'Integer32', 'Unsigned32', 'NotificationType', 'enterprises', 'Counter64', 'iso', 'Counter32', 'ModuleIdentity', 'TimeTicks', 'IpAddress', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'Gauge32') (date_and_time, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'DateAndTime', 'TextualConvention', 'DisplayString') rs_info_module = module_identity((1, 3, 6, 1, 4, 1, 4355, 6)) rsInfoModule.setRevisions(('2002-11-01 12:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: rsInfoModule.setRevisionsDescriptions(('Initial revision.',)) if mibBuilder.loadTexts: rsInfoModule.setLastUpdated('0211011200Z') if mibBuilder.loadTexts: rsInfoModule.setOrganization('WatchGuard Technologies, Inc.') if mibBuilder.loadTexts: rsInfoModule.setContactInfo(' Ella Yu WatchGuard Technologies, Inc. 1841 Zanker Road San Jose, CA 95112 USA 408-519-4888 ella.yu@watchguard.com ') if mibBuilder.loadTexts: rsInfoModule.setDescription('The MIB module describes general information of RapidStream system. Mainly, the information obtained from this MIB is used by rsInfoSystemMIB, rsClientMIB, rsSystemStatisticsMIB, rsIpsecTunnelMIB, rsHAMIB.') rs_hamib = object_identity((1, 3, 6, 1, 4, 1, 4355, 6, 6)) if mibBuilder.loadTexts: rsHAMIB.setStatus('current') if mibBuilder.loadTexts: rsHAMIB.setDescription('This is the base object identifier for all HA related branches.') rs_ha_local = object_identity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1)) if mibBuilder.loadTexts: rsHALocal.setStatus('current') if mibBuilder.loadTexts: rsHALocal.setDescription('This is the base object identifier for all objects which are belong to local appliance.') rs_ha_peer = object_identity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2)) if mibBuilder.loadTexts: rsHAPeer.setStatus('current') if mibBuilder.loadTexts: rsHAPeer.setDescription('This is the base object identifier for all objects which are belong to peer appliance.') rs_ha_status = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))).clone(namedValues=named_values(('disabled', 0), ('unknown', 1), ('as-primary-active', 2), ('as-secondary-active', 3), ('aa-primary-ative', 4), ('aa-secondary-active', 5), ('aa-primary-takeover', 6), ('aa-secondary-takeover', 7), ('standby', 8), ('admin', 9), ('failed', 10), ('unavailable', 11)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAStatus.setStatus('current') if mibBuilder.loadTexts: rsHAStatus.setDescription("Indicates current status of local appliance. disabled: The local appliance of HA system is not enabled. unknown: The local appliance of HA system is in initialization as-primary-active: The local appliance that is the primary appliance of HA/AS system is in active mode. This status is also called MASTER in some systems. as-secondary-active: The local appliance that is the secondary appliance of HA/AS system is in active mode. This status is also called BACKUP in some systems. aa-primary-ative: The local appliance that is the primary appliance of HA/AA system is in active mode. aa-secondary-active: The local appliance that is the secondary appliance of HA/AA system is in active mode. aa-primary-takeover: The local appliance that is the primary appliance of HA/AA system has taken over the peer's duty. aa-secondary-takeover: The local appliance of the secondary appliance of HA/AA system has taken over the peer's duty. standby: The local appliance of HA/AS system is in standby mode. admin: The local appliance of HA system detects an mismatched configuration and waits for system administrator to reslove the conflict. failed: The local appliance of the HA system is down due to forced failover or other reasons. unavailable: It's reported when local appliance of HA system is unabled to get status information. ") rs_ha_peer_status = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4))).clone(namedValues=named_values(('unavailable', 0), ('active', 1), ('standby', 2), ('admin', 3), ('failed', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerStatus.setStatus('current') if mibBuilder.loadTexts: rsHAPeerStatus.setDescription("Indicates current status of peer appliance. unavailable: It's reported when peer appliance of HA system is unabled to get status information. active: The peer applicance of HA system is in active mode. standby: The peer applicance of HA system is in standby mode. admin: The peer applicance of HA system dectects an mismatched configuration and waits for system administrator to reslove the conflict. failed: The peer appliance of HA system is down due to forced failover or other reasons. ") rs_ha_last_db_sync_time = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 3), date_and_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHALastDBSyncTime.setStatus('current') if mibBuilder.loadTexts: rsHALastDBSyncTime.setDescription('The last DB synchronized time of local appliance.') rs_ha_error = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))).clone(namedValues=named_values(('no-error', 0), ('mismatched-ha-id', 1), ('mismatched-software', 2), ('mismatched-database', 3), ('mismatched-hardware', 4), ('forced-fail', 5), ('invalid-ha-role', 6), ('link-down', 7), ('lost-mia-heartbeat', 8), ('mia-not-responding', 9), ('admin-command-failed', 10), ('detect-ha-error', 11), ('unavailable', 12), ('hotsync-failed', 13), ('config-sync-failed', 14)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAError.setStatus('current') if mibBuilder.loadTexts: rsHAError.setDescription('Reports the current error that occurred in local appliance .') rs_ha_peer_error = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))).clone(namedValues=named_values(('no-error', 0), ('mismatched-ha-id', 1), ('mismatched-software', 2), ('mismatched-database', 3), ('mismatched-hardware', 4), ('forced-fail', 5), ('invalid-ha-role', 6), ('link-down', 7), ('lost-mia-heartbeat', 8), ('mia-not-responding', 9), ('admin-command-failed', 10), ('detect-ha-error', 11), ('unavailable', 12), ('hotsync-failed', 13), ('config-sync-failed', 14)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerError.setStatus('current') if mibBuilder.loadTexts: rsHAPeerError.setDescription('Reports the current error that occurred in peer appliance.') rs_ha_peer_serial_number = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 1), octet_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSerialNumber.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSerialNumber.setDescription('The serial number of peer appliance.') rs_ha_peer_last_db_sync_time = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 2), date_and_time()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerLastDBSyncTime.setStatus('current') if mibBuilder.loadTexts: rsHAPeerLastDBSyncTime.setDescription('The last DB synchronized time of peer appliance.') rs_ha_peer_device = object_identity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3)) if mibBuilder.loadTexts: rsHAPeerDevice.setStatus('current') if mibBuilder.loadTexts: rsHAPeerDevice.setDescription('This is the base object for parameters and configuration data of devices in this entity.') rs_ha_peer_counters = object_identity((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4)) if mibBuilder.loadTexts: rsHAPeerCounters.setStatus('current') if mibBuilder.loadTexts: rsHAPeerCounters.setDescription('This is the base object for parameters and configuration data of devices in this entity.') rs_ha_peer_if_number = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 1), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerIfNumber.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfNumber.setDescription('The number of RapidCard installed in this entity.') rs_ha_peer_if_table = mib_table((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2)) if mibBuilder.loadTexts: rsHAPeerIfTable.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfTable.setDescription('A list of RapidCard entries. The number of entries is given by the value of rsHAPeerDeviceNumber.') rs_ha_peer_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1)).setIndexNames((0, 'RAPID-HA-MIB', 'rsHAPeerIfIndex')) if mibBuilder.loadTexts: rsHAPeerIfEntry.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfEntry.setDescription('A RapidCard entry containing objects for a particular RapidCard.') rs_ha_peer_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 1), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerIfIndex.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfIndex.setDescription('The unique value for each interface.') rs_ha_peer_if_ip_addr = mib_table_column((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 4), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerIfIpAddr.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfIpAddr.setDescription('The ip address of the interface.') rs_ha_peer_if_link_status = mib_table_column((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 3, 2, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2))).clone(namedValues=named_values(('down', 0), ('up', 1), ('other', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerIfLinkStatus.setStatus('current') if mibBuilder.loadTexts: rsHAPeerIfLinkStatus.setDescription('The current state of the interface.') rs_ha_peer_system_cpu_util = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 1), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil.setDescription('The CPU utilization of the peer system in last 5 seconds.') rs_ha_peer_system_total_send_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 2), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendBytes.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendBytes.setDescription('The total number of bytes sent since peer system is up.') rs_ha_peer_system_total_recv_bytes = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 3), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvBytes.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvBytes.setDescription('The total number of bytes received since peer system is up.') rs_ha_peer_system_total_send_packets = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 4), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendPackets.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalSendPackets.setDescription('The total number of packets sent since peer system is up.') rs_ha_peer_system_total_recv_packets = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 5), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvPackets.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemTotalRecvPackets.setDescription('The total number of packets received since peer system is up.') rs_ha_peer_system_stream_req_total = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 6), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqTotal.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqTotal.setDescription('The total number of the connection requests since system is up.') rs_ha_peer_system_stream_req_drop = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 7), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqDrop.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemStreamReqDrop.setDescription('The total number of the connection requests being dropped since system is up.') rs_ha_peer_system_curr_ipsec_tunnels = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 8), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemCurrIpsecTunnels.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCurrIpsecTunnels.setDescription('The number of ipsec tunnels in the peer system currently.') rs_ha_peer_system_cpu_util1 = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 9), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil1.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil1.setDescription('The CPU utilization of the peer system in last 1 minute.') rs_ha_peer_system_cpu_util5 = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 10), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil5.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil5.setDescription('The CPU utilization of the peer system in last 5 minutes.') rs_ha_peer_system_cpu_util15 = mib_scalar((1, 3, 6, 1, 4, 1, 4355, 6, 6, 2, 4, 11), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil15.setStatus('current') if mibBuilder.loadTexts: rsHAPeerSystemCpuUtil15.setDescription('The CPU utilization of the peer system in last 15 minutes.') mibBuilder.exportSymbols('RAPID-HA-MIB', rsHAPeerIfNumber=rsHAPeerIfNumber, rsHALocal=rsHALocal, rsHAPeerIfIndex=rsHAPeerIfIndex, rsHAError=rsHAError, rsHAPeerLastDBSyncTime=rsHAPeerLastDBSyncTime, rsInfoModule=rsInfoModule, rsHALastDBSyncTime=rsHALastDBSyncTime, rsHAPeerDevice=rsHAPeerDevice, rsHAPeerSystemStreamReqTotal=rsHAPeerSystemStreamReqTotal, rsHAPeerSystemCpuUtil1=rsHAPeerSystemCpuUtil1, rsHAPeerSystemCpuUtil5=rsHAPeerSystemCpuUtil5, rsHAPeerSystemCpuUtil=rsHAPeerSystemCpuUtil, rsHAPeerStatus=rsHAPeerStatus, rsHAPeer=rsHAPeer, rsHAPeerSystemCurrIpsecTunnels=rsHAPeerSystemCurrIpsecTunnels, rsHAMIB=rsHAMIB, rsHAPeerSystemTotalSendBytes=rsHAPeerSystemTotalSendBytes, rsHAPeerCounters=rsHAPeerCounters, rsHAPeerIfIpAddr=rsHAPeerIfIpAddr, rsHAPeerIfEntry=rsHAPeerIfEntry, rsHAStatus=rsHAStatus, rsHAPeerError=rsHAPeerError, rsHAPeerIfLinkStatus=rsHAPeerIfLinkStatus, PYSNMP_MODULE_ID=rsInfoModule, rsHAPeerSystemCpuUtil15=rsHAPeerSystemCpuUtil15, rsHAPeerSystemTotalRecvBytes=rsHAPeerSystemTotalRecvBytes, rsHAPeerSystemStreamReqDrop=rsHAPeerSystemStreamReqDrop, rsHAPeerSerialNumber=rsHAPeerSerialNumber, rsHAPeerSystemTotalSendPackets=rsHAPeerSystemTotalSendPackets, rsHAPeerSystemTotalRecvPackets=rsHAPeerSystemTotalRecvPackets, rsHAPeerIfTable=rsHAPeerIfTable)
filt_dict = { 'db': [['Emissions', '(Kyoto Gases|co2)$', '(|Energy and Industrial Processes|AFOLU)$', '', '(world|r5.*)'], ['Policy cost', '(Additional Total Energy System Cost|consumption Loss|gdp Loss)', '', '', '(world|r5.*)'], ['Price', 'Carbon', '$', '', '(world|r5.*)'], ], }
filt_dict = {'db': [['Emissions', '(Kyoto Gases|co2)$', '(|Energy and Industrial Processes|AFOLU)$', '', '(world|r5.*)'], ['Policy cost', '(Additional Total Energy System Cost|consumption Loss|gdp Loss)', '', '', '(world|r5.*)'], ['Price', 'Carbon', '$', '', '(world|r5.*)']]}
# https://leetcode.com/problems/insert-interval/ # Given a set of non-overlapping intervals, insert a new interval into the # intervals (merge if necessary). # You may assume that the intervals were initially sorted according to their start # times. ################################################################################ # loop over intervals -> merge with newIntercal if overlap # append to ans if no overlap class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: if not intervals: return [newInterval] ans = [] inserted = False for interval in intervals: if interval[1] < newInterval[0]: # no overlap ans.append(interval) elif interval[0] > newInterval[1]: # no overlap if not inserted: ans.append(newInterval) inserted = True ans.append(interval) else: # overlap, merge intervals newInterval[0] = min(newInterval[0], interval[0]) newInterval[1] = max(newInterval[1], interval[1]) if not inserted: ans.append(newInterval) return ans
class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: if not intervals: return [newInterval] ans = [] inserted = False for interval in intervals: if interval[1] < newInterval[0]: ans.append(interval) elif interval[0] > newInterval[1]: if not inserted: ans.append(newInterval) inserted = True ans.append(interval) else: newInterval[0] = min(newInterval[0], interval[0]) newInterval[1] = max(newInterval[1], interval[1]) if not inserted: ans.append(newInterval) return ans
#!/usr/bin/env python3 def merge(L1, L2): L3 = L1+L2 for j in range(len(L3)): for i in range(0, len(L3)-j-1): if L3[i]> L3[i+1]: L3[i],L3[i+1] = L3[i+1] , L3[i] return (L3) def main(): print((merge([1,2,3],[1,6,7]))) pass if __name__ == "__main__": main()
def merge(L1, L2): l3 = L1 + L2 for j in range(len(L3)): for i in range(0, len(L3) - j - 1): if L3[i] > L3[i + 1]: (L3[i], L3[i + 1]) = (L3[i + 1], L3[i]) return L3 def main(): print(merge([1, 2, 3], [1, 6, 7])) pass if __name__ == '__main__': main()
class ControllerBase: @staticmethod def base(): return True
class Controllerbase: @staticmethod def base(): return True
''' You are given an array of length n which only contains the elements 0,1 and 2. You are supposed to sort the array in ascending order without the use of any sorting algorithms. Minimize time complexity. Input Format: The first line of input contains the value of n i.e. size of array. The next line contains n space separated integers, each representing an element of the array (0/1/2) Output Format: Print the sorted array as n space separated integers. Constraints: All array elements and n are within integer value limits. Example input: 8 1 0 2 1 2 1 0 0 Example output: [0, 0, 0, 1, 1, 1, 2, 2] Explanation: There are 3 zeroes, 3 ones and 2 twos. Sorted array is printed as space separated integers. ********************************************************************************************************************* ''' #Solution presented here has a time complexity of O(n) and uses a dictionary def arraySort(n, array): mappings = {0:0, 1:0, 2:0} for element in array: count = mappings.get(element) count = count+1 mappings.update({element:count}) arrayIndex = 0 count = mappings.get(0) for i in range(0, count): array[arrayIndex]=0 arrayIndex = arrayIndex+1 count = mappings.get(1) for i in range(0, count): array[arrayIndex]=1 arrayIndex = arrayIndex+1 count = mappings.get(2) for i in range(0, count): array[arrayIndex]=2 arrayIndex = arrayIndex+1 return array #Take input and call the function n = int(input()) array = [int(item) for item in input().split(' ')] array = arraySort(n, array) print(array)
""" You are given an array of length n which only contains the elements 0,1 and 2. You are supposed to sort the array in ascending order without the use of any sorting algorithms. Minimize time complexity. Input Format: The first line of input contains the value of n i.e. size of array. The next line contains n space separated integers, each representing an element of the array (0/1/2) Output Format: Print the sorted array as n space separated integers. Constraints: All array elements and n are within integer value limits. Example input: 8 1 0 2 1 2 1 0 0 Example output: [0, 0, 0, 1, 1, 1, 2, 2] Explanation: There are 3 zeroes, 3 ones and 2 twos. Sorted array is printed as space separated integers. ********************************************************************************************************************* """ def array_sort(n, array): mappings = {0: 0, 1: 0, 2: 0} for element in array: count = mappings.get(element) count = count + 1 mappings.update({element: count}) array_index = 0 count = mappings.get(0) for i in range(0, count): array[arrayIndex] = 0 array_index = arrayIndex + 1 count = mappings.get(1) for i in range(0, count): array[arrayIndex] = 1 array_index = arrayIndex + 1 count = mappings.get(2) for i in range(0, count): array[arrayIndex] = 2 array_index = arrayIndex + 1 return array n = int(input()) array = [int(item) for item in input().split(' ')] array = array_sort(n, array) print(array)
class BlocoMemoria: palavra: list endBlock: int atualizado: bool custo: int cacheHit: int ultimoUso: int def __init__(self): self.endBlock = -1 self.atualizado = False self.custo = 0 self.cacheHit = 0 ultimoUso: 2**31-1
class Blocomemoria: palavra: list end_block: int atualizado: bool custo: int cache_hit: int ultimo_uso: int def __init__(self): self.endBlock = -1 self.atualizado = False self.custo = 0 self.cacheHit = 0 ultimo_uso: 2 ** 31 - 1
AzToolchainInfo = provider( doc = "Azure toolchain rule parameters", fields = [ "az_tool_path", "az_tool_target", "azure_extension_dir", "az_extensions_installed", "jq_tool_path", ], ) AzConfigInfo = provider( fields = [ "debug", "global_args", "subscription", "verbose" ], )
az_toolchain_info = provider(doc='Azure toolchain rule parameters', fields=['az_tool_path', 'az_tool_target', 'azure_extension_dir', 'az_extensions_installed', 'jq_tool_path']) az_config_info = provider(fields=['debug', 'global_args', 'subscription', 'verbose'])
# Copyright 2018- The Pixie Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 def _fetch_licenses_impl(ctx): args = ctx.actions.args() args.add("--github_token", ctx.file.oauth_token) args.add("--modules", ctx.file.src) if ctx.attr.use_pkg_dev_go: args.add("--try_pkg_dev_go") if ctx.attr.disallow_missing: args.add("--fatal_if_missing") args.add("--json_manual_input", ctx.file.manual_licenses) args.add("--json_output", ctx.outputs.out_found) args.add("--json_missing_output", ctx.outputs.out_missing) ctx.actions.run( executable = ctx.file.fetch_tool, inputs = [ctx.file.src, ctx.file.oauth_token, ctx.file.manual_licenses], outputs = [ctx.outputs.out_found, ctx.outputs.out_missing], arguments = [args], progress_message = "Fetching licenses %s" % ctx.outputs.out_found, ) fetch_licenses = rule( implementation = _fetch_licenses_impl, attrs = dict({ "disallow_missing": attr.bool(), "fetch_tool": attr.label(mandatory = True, allow_single_file = True), "manual_licenses": attr.label(mandatory = True, allow_single_file = True), "oauth_token": attr.label(mandatory = True, allow_single_file = True), "out_found": attr.output(mandatory = True), "out_missing": attr.output(), "src": attr.label(mandatory = True, allow_single_file = True), "use_pkg_dev_go": attr.bool(), }), )
def _fetch_licenses_impl(ctx): args = ctx.actions.args() args.add('--github_token', ctx.file.oauth_token) args.add('--modules', ctx.file.src) if ctx.attr.use_pkg_dev_go: args.add('--try_pkg_dev_go') if ctx.attr.disallow_missing: args.add('--fatal_if_missing') args.add('--json_manual_input', ctx.file.manual_licenses) args.add('--json_output', ctx.outputs.out_found) args.add('--json_missing_output', ctx.outputs.out_missing) ctx.actions.run(executable=ctx.file.fetch_tool, inputs=[ctx.file.src, ctx.file.oauth_token, ctx.file.manual_licenses], outputs=[ctx.outputs.out_found, ctx.outputs.out_missing], arguments=[args], progress_message='Fetching licenses %s' % ctx.outputs.out_found) fetch_licenses = rule(implementation=_fetch_licenses_impl, attrs=dict({'disallow_missing': attr.bool(), 'fetch_tool': attr.label(mandatory=True, allow_single_file=True), 'manual_licenses': attr.label(mandatory=True, allow_single_file=True), 'oauth_token': attr.label(mandatory=True, allow_single_file=True), 'out_found': attr.output(mandatory=True), 'out_missing': attr.output(), 'src': attr.label(mandatory=True, allow_single_file=True), 'use_pkg_dev_go': attr.bool()}))
package(default_visibility = [ "//visibility:public" ]) load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "net_import_library", "core_import_library") net_import_library( name = "net45", src = "lib/netstandard1.0/System.Threading.Tasks.Extensions.dll", ) core_import_library( name = "netcore", src = "lib/netstandard2.0/System.Threading.Tasks.Extensions.dll" )
package(default_visibility=['//visibility:public']) load('@io_bazel_rules_dotnet//dotnet:defs.bzl', 'net_import_library', 'core_import_library') net_import_library(name='net45', src='lib/netstandard1.0/System.Threading.Tasks.Extensions.dll') core_import_library(name='netcore', src='lib/netstandard2.0/System.Threading.Tasks.Extensions.dll')
class Solution: def repeatedStringMatch(self, A: str, B: str) -> int: if B in A: return 0 counter = 1 repeatedA = A while len(repeatedA) < len(B)*2: repeatedA += A if B in repeatedA: return counter counter += 1 return -1 a = 'abc' b = 'abcs' if find('c', a): print('yes') else: print('no') # print(not a.index('s'))
class Solution: def repeated_string_match(self, A: str, B: str) -> int: if B in A: return 0 counter = 1 repeated_a = A while len(repeatedA) < len(B) * 2: repeated_a += A if B in repeatedA: return counter counter += 1 return -1 a = 'abc' b = 'abcs' if find('c', a): print('yes') else: print('no')
WIDTH = 50 HEIGHT = 10 MAX_WIDTH = WIDTH - 2 MAX_HEIGHT = HEIGHT - 2
width = 50 height = 10 max_width = WIDTH - 2 max_height = HEIGHT - 2
# coding: utf-8 class CorpusInterface(object): def load_corpus(self, corpus): pass def read_corpus(self, filename): pass class Corpus(object): def load_corpus(self, corpus): raise NotImplementedError() def read_corpus(self, filename): raise NotImplementedError()
class Corpusinterface(object): def load_corpus(self, corpus): pass def read_corpus(self, filename): pass class Corpus(object): def load_corpus(self, corpus): raise not_implemented_error() def read_corpus(self, filename): raise not_implemented_error()
x = int(input()) for i in range(1, 11): resultado = i * x print("{} x {} = {}".format(i, x, resultado))
x = int(input()) for i in range(1, 11): resultado = i * x print('{} x {} = {}'.format(i, x, resultado))
patches = [ # Rename AWS::Lightsail::Instance.Disk to AWS::Lightsail::Instance.DiskProperty { "op": "move", "from": "/PropertyTypes/AWS::Lightsail::Instance.Disk", "path": "/PropertyTypes/AWS::Lightsail::Instance.DiskProperty", }, { "op": "replace", "path": "/PropertyTypes/AWS::Lightsail::Instance.Hardware/Properties/Disks/ItemType", "value": "DiskProperty", }, # Remove Location and State attribute properties { "op": "remove", "path": "/PropertyTypes/AWS::Lightsail::Instance.Location", }, { "op": "remove", "path": "/PropertyTypes/AWS::Lightsail::Instance.State", }, ]
patches = [{'op': 'move', 'from': '/PropertyTypes/AWS::Lightsail::Instance.Disk', 'path': '/PropertyTypes/AWS::Lightsail::Instance.DiskProperty'}, {'op': 'replace', 'path': '/PropertyTypes/AWS::Lightsail::Instance.Hardware/Properties/Disks/ItemType', 'value': 'DiskProperty'}, {'op': 'remove', 'path': '/PropertyTypes/AWS::Lightsail::Instance.Location'}, {'op': 'remove', 'path': '/PropertyTypes/AWS::Lightsail::Instance.State'}]
maximum = float("-inf") def max_path_sum(root): helper(root) return maximum def helper(root): if not root: return 0 left = helper(root.left) right = helper(root.right) maximum = max(maximum, left+right+root.val) return root.val + max(left, right)
maximum = float('-inf') def max_path_sum(root): helper(root) return maximum def helper(root): if not root: return 0 left = helper(root.left) right = helper(root.right) maximum = max(maximum, left + right + root.val) return root.val + max(left, right)
fruit = input() size_set = input() count_sets = float(input()) price_set = 0 if fruit == 'Watermelon': if size_set == 'small': price_set = count_sets * 56 * 2 elif size_set == 'big': price_set = count_sets * 28.7 * 5 elif fruit == 'Mango': if size_set == 'small': price_set = count_sets * 36.66 * 2 elif size_set == 'big': price_set = count_sets * 19.60 * 5 elif fruit == 'Pineapple': if size_set == 'small': price_set = count_sets * 42.1 * 2 elif size_set == 'big': price_set = count_sets * 24.8 * 5 elif fruit == 'Raspberry': if size_set == 'small': price_set = count_sets * 20 * 2 elif size_set == 'big': price_set = count_sets * 15.2 * 5 if 400 <= price_set <= 1000: price_set = price_set * 0.85 elif price_set > 1000: price_set = price_set * 0.5 print(f'{price_set:.2f} lv.')
fruit = input() size_set = input() count_sets = float(input()) price_set = 0 if fruit == 'Watermelon': if size_set == 'small': price_set = count_sets * 56 * 2 elif size_set == 'big': price_set = count_sets * 28.7 * 5 elif fruit == 'Mango': if size_set == 'small': price_set = count_sets * 36.66 * 2 elif size_set == 'big': price_set = count_sets * 19.6 * 5 elif fruit == 'Pineapple': if size_set == 'small': price_set = count_sets * 42.1 * 2 elif size_set == 'big': price_set = count_sets * 24.8 * 5 elif fruit == 'Raspberry': if size_set == 'small': price_set = count_sets * 20 * 2 elif size_set == 'big': price_set = count_sets * 15.2 * 5 if 400 <= price_set <= 1000: price_set = price_set * 0.85 elif price_set > 1000: price_set = price_set * 0.5 print(f'{price_set:.2f} lv.')
def test_socfaker_timestamp_in_the_past(socfaker_fixture): assert socfaker_fixture.timestamp.in_the_past() def test_socfaker_timestamp_in_the_future(socfaker_fixture): assert socfaker_fixture.timestamp.in_the_future() def test_socfaker_timestamp_current(socfaker_fixture): assert socfaker_fixture.timestamp.current def test_socfaker_timestamp_date_string(socfaker_fixture): assert socfaker_fixture.timestamp.date_string
def test_socfaker_timestamp_in_the_past(socfaker_fixture): assert socfaker_fixture.timestamp.in_the_past() def test_socfaker_timestamp_in_the_future(socfaker_fixture): assert socfaker_fixture.timestamp.in_the_future() def test_socfaker_timestamp_current(socfaker_fixture): assert socfaker_fixture.timestamp.current def test_socfaker_timestamp_date_string(socfaker_fixture): assert socfaker_fixture.timestamp.date_string
releases = [ { "ocid": "A", "id": "1", "date": "2014-01-01", "tag": ["tender"], "tender": { "items": [ { "id": "1", "description": "Item 1", "quantity": 1 }, { "id": "2", "description": "Item 2", "quantity": 1 } ] } }, { "ocid": "A", "id": "2", "date": "2014-01-02", "tag": ["tender"], "tender": { "items": [ { "id": "1", "description": "Item 1", "quantity": 2 }, { "id": "3", "description": "Item 3", "quantity": 1 } ] } } ] compiledRelease = { "ocid": "A", "id": "2", "date": "2014-01-02", "tag": ["compiled"], "tender": { "items": [ { "id": "1", "description": "Item 1", "quantity": 2 }, { "id": "2", "description": "Item 2", "quantity": 1 }, { "id": "3", "description": "Item 3", "quantity": 1 } ] } } versionedRelease = { "ocid": "A", "tender": { "items": [ { "id": "1", "description": [ { "value": "Item 1", "releaseDate": "2014-01-01", "releaseTag": ["tender"], "releaseID": "1" } ], "quantity": [ { "value": 1, "releaseDate": "2014-01-01", "releaseTag": ["tender"], "releaseID": "1" }, { "value": 2, "releaseDate": "2014-01-02", "releaseTag": ["tender"], "releaseID": "2" } ] }, { "id": "2", "description": [ { "value": "Item 2", "releaseDate": "2014-01-01", "releaseTag": ["tender"], "releaseID": "1" } ], "quantity": [ { "value": 1, "releaseDate": "2014-01-01", "releaseTag": ["tender"], "releaseID": "1" }, ] }, { "id": "3", "description": [ { "value": "Item 3", "releaseDate": "2014-01-02", "releaseTag": ["tender"], "releaseID": "2" } ], "quantity": [ { "value": 1, "releaseDate": "2014-01-02", "releaseTag": ["tender"], "releaseID": "2" }, ] } ] } }
releases = [{'ocid': 'A', 'id': '1', 'date': '2014-01-01', 'tag': ['tender'], 'tender': {'items': [{'id': '1', 'description': 'Item 1', 'quantity': 1}, {'id': '2', 'description': 'Item 2', 'quantity': 1}]}}, {'ocid': 'A', 'id': '2', 'date': '2014-01-02', 'tag': ['tender'], 'tender': {'items': [{'id': '1', 'description': 'Item 1', 'quantity': 2}, {'id': '3', 'description': 'Item 3', 'quantity': 1}]}}] compiled_release = {'ocid': 'A', 'id': '2', 'date': '2014-01-02', 'tag': ['compiled'], 'tender': {'items': [{'id': '1', 'description': 'Item 1', 'quantity': 2}, {'id': '2', 'description': 'Item 2', 'quantity': 1}, {'id': '3', 'description': 'Item 3', 'quantity': 1}]}} versioned_release = {'ocid': 'A', 'tender': {'items': [{'id': '1', 'description': [{'value': 'Item 1', 'releaseDate': '2014-01-01', 'releaseTag': ['tender'], 'releaseID': '1'}], 'quantity': [{'value': 1, 'releaseDate': '2014-01-01', 'releaseTag': ['tender'], 'releaseID': '1'}, {'value': 2, 'releaseDate': '2014-01-02', 'releaseTag': ['tender'], 'releaseID': '2'}]}, {'id': '2', 'description': [{'value': 'Item 2', 'releaseDate': '2014-01-01', 'releaseTag': ['tender'], 'releaseID': '1'}], 'quantity': [{'value': 1, 'releaseDate': '2014-01-01', 'releaseTag': ['tender'], 'releaseID': '1'}]}, {'id': '3', 'description': [{'value': 'Item 3', 'releaseDate': '2014-01-02', 'releaseTag': ['tender'], 'releaseID': '2'}], 'quantity': [{'value': 1, 'releaseDate': '2014-01-02', 'releaseTag': ['tender'], 'releaseID': '2'}]}]}}
__title__ = "PyMatting" __version__ = "1.1.3" __author__ = "The PyMatting Developers" __email__ = "pymatting@gmail.com" __license__ = "MIT" __uri__ = "https://pymatting.github.io" __summary__ = "Python package for alpha matting."
__title__ = 'PyMatting' __version__ = '1.1.3' __author__ = 'The PyMatting Developers' __email__ = 'pymatting@gmail.com' __license__ = 'MIT' __uri__ = 'https://pymatting.github.io' __summary__ = 'Python package for alpha matting.'
class Matrix: def __init__(self, mat): l_size = len(mat[0]) for line in mat: if l_size != len(line): raise ValueError('invalid matrix sizes') self._raw = mat @property def raw(self): return self._raw @property def trace(self): if self.size[0] == self.size[1]: return sum([ self[i][j] for j in range(self.size[0]) for i in range(self.size[1]) ]) else: print('nb lines != nb columns') @property def size(self): return self._raw.__len__(), self._raw[0].__len__() def __str__(self): s = "\n" for l in self._raw: s +='| ' for c in l: s += '{:6.2f} '.format( round(float(c), 3)) s += '|\n' return s def __call__(self, index): return self.col(self, index) @classmethod def col(cls, matrix, index, raw = False): col = [ line[index] for line in matrix._raw ] if raw: return col else: return Vector(col) def transpose(self): return Matrix([ self.col(self, i, True) for i in range(self.size[1]) ]) def __setitem__(self, key, item): if not type(item).__name__ == 'list' or len(item) != self.size[0]: print('invalid assignement') else: self._raw[key] = item def __getitem__(self, key): return Vector(self._raw[key], transpose = True) def __add__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[0] == other.size[0] and self.size[1] == other.size[1]: return Matrix([ [ self._raw[i][j] + other._raw[i][j] for j in range(self.size[1])] for i in range(self.size[0])]) else: try: return Matrix([ [ self._raw[i][j] + other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot add') def __sub__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[0] == other.size[0] and self.size[1] == other.size[1]: return Matrix([ [ self._raw[i][j] - other._raw[i][j] for j in range(self.size[1])] for i in range(self.size[0])]) else: try: return Matrix([ [ self._raw[i][j] - other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot substract') def __mul__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[1] == other.size[0]: # nb c == nb l res = [] for i in range(self.size[0]): res += [[]] for j in range(other.size[1]): res[i] += [sum([m*n for m,n in zip(self._raw[i], self.col(other, j, True))])] return Matrix(res) else: try: return Matrix([ [ self[i][j] * other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot substract') @classmethod def gen(cls, l, c, fill = 0): mat = [[fill for j in range(c)] for i in range(l)] return Matrix(mat) class Vector(Matrix): def __init__(self, vect, transpose = False): self.transposed = transpose super().__init__([vect] if transpose else [ [elem] for elem in vect ] ) @property def raw(self): if self.transposed: return self._raw[0] else: return self.col(self, 0, True) @property def gravity(self): return sum(self.raw) / len(self.raw) def __setitem__(self, key, item): if self.transposed: self._raw[0][key] = item else: self._raw[key][0] = item def __getitem__(self, key): if self.transposed: if type(self._raw[0][key]).__name__ == 'list': return Vector(self._raw[0][key]) else: return self._raw[0][key] else: if type(self._raw[key][0]).__name__ == 'list': return Vector(self._raw[key][0]) else: return self._raw[key][0] @classmethod def gen(cls, l, fill = 0): mat = super().gen(l, 1, fill) return mat(0) # ================================================================== # m = [[1,2,3],[4,5,6],[7,8,9]] # mt = Matrix(m) # print(mt) # print(mt.transpose()) # print(mt.trace) # print(mt.size) # mt2 = mt.transpose() # mt3 = Matrix.gen(3,3,9) # print(mt3) # print(mt2 + mt,mt2 - mt, mt2 * mt)
class Matrix: def __init__(self, mat): l_size = len(mat[0]) for line in mat: if l_size != len(line): raise value_error('invalid matrix sizes') self._raw = mat @property def raw(self): return self._raw @property def trace(self): if self.size[0] == self.size[1]: return sum([self[i][j] for j in range(self.size[0]) for i in range(self.size[1])]) else: print('nb lines != nb columns') @property def size(self): return (self._raw.__len__(), self._raw[0].__len__()) def __str__(self): s = '\n' for l in self._raw: s += '| ' for c in l: s += '{:6.2f} '.format(round(float(c), 3)) s += '|\n' return s def __call__(self, index): return self.col(self, index) @classmethod def col(cls, matrix, index, raw=False): col = [line[index] for line in matrix._raw] if raw: return col else: return vector(col) def transpose(self): return matrix([self.col(self, i, True) for i in range(self.size[1])]) def __setitem__(self, key, item): if not type(item).__name__ == 'list' or len(item) != self.size[0]: print('invalid assignement') else: self._raw[key] = item def __getitem__(self, key): return vector(self._raw[key], transpose=True) def __add__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[0] == other.size[0] and self.size[1] == other.size[1]: return matrix([[self._raw[i][j] + other._raw[i][j] for j in range(self.size[1])] for i in range(self.size[0])]) else: try: return matrix([[self._raw[i][j] + other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot add') def __sub__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[0] == other.size[0] and self.size[1] == other.size[1]: return matrix([[self._raw[i][j] - other._raw[i][j] for j in range(self.size[1])] for i in range(self.size[0])]) else: try: return matrix([[self._raw[i][j] - other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot substract') def __mul__(self, other): if type(other).__name__ == 'Matrix' or type(other).__name__ == 'Vector': if self.size[1] == other.size[0]: res = [] for i in range(self.size[0]): res += [[]] for j in range(other.size[1]): res[i] += [sum([m * n for (m, n) in zip(self._raw[i], self.col(other, j, True))])] return matrix(res) else: try: return matrix([[self[i][j] * other for j in range(self.size[1])] for i in range(self.size[0])]) except: print('cannot substract') @classmethod def gen(cls, l, c, fill=0): mat = [[fill for j in range(c)] for i in range(l)] return matrix(mat) class Vector(Matrix): def __init__(self, vect, transpose=False): self.transposed = transpose super().__init__([vect] if transpose else [[elem] for elem in vect]) @property def raw(self): if self.transposed: return self._raw[0] else: return self.col(self, 0, True) @property def gravity(self): return sum(self.raw) / len(self.raw) def __setitem__(self, key, item): if self.transposed: self._raw[0][key] = item else: self._raw[key][0] = item def __getitem__(self, key): if self.transposed: if type(self._raw[0][key]).__name__ == 'list': return vector(self._raw[0][key]) else: return self._raw[0][key] elif type(self._raw[key][0]).__name__ == 'list': return vector(self._raw[key][0]) else: return self._raw[key][0] @classmethod def gen(cls, l, fill=0): mat = super().gen(l, 1, fill) return mat(0)
# todo remove in next major release as we no longer support django < 3.2 anyway. Note this would make dj-stripe unuseable for djang0 < 3.2 # for django < 3.2 default_app_config = "djstripe.apps.DjstripeAppConfig"
default_app_config = 'djstripe.apps.DjstripeAppConfig'
with open("mynewtextfile.txt","w+") as f: f.writelines("\nOtus we are learning python\nOtus we are learning python\nOtus we are learning python") f.seek(0) print(f.readlines()) print("Is readable:", f.readable()) print("Is writeable:", f.writable()) print("File no:", f.fileno()) print("Is connected to tty-like device:", f.isatty()) f.truncate(20) f.flush() f.seek(0) print(f.readline()) print(f.readline()) print(f.readline()) print(f.readline()) print(f.readline()) f.close()
with open('mynewtextfile.txt', 'w+') as f: f.writelines('\nOtus we are learning python\nOtus we are learning python\nOtus we are learning python') f.seek(0) print(f.readlines()) print('Is readable:', f.readable()) print('Is writeable:', f.writable()) print('File no:', f.fileno()) print('Is connected to tty-like device:', f.isatty()) f.truncate(20) f.flush() f.seek(0) print(f.readline()) print(f.readline()) print(f.readline()) print(f.readline()) print(f.readline()) f.close()
class Solution: def traverse(self, node: TreeNode, deep: int): if node is None: return deep deep += 1 if node.left is None: return self.traverse(node.right, deep) elif node.right is None: return self.traverse(node.left, deep) else: left_deep = self.traverse(node.left, deep) right_deep = self.traverse(node.right, deep) return min(left_deep, right_deep) def XXX(self, root: TreeNode) -> int: return self.traverse(root, 0)
class Solution: def traverse(self, node: TreeNode, deep: int): if node is None: return deep deep += 1 if node.left is None: return self.traverse(node.right, deep) elif node.right is None: return self.traverse(node.left, deep) else: left_deep = self.traverse(node.left, deep) right_deep = self.traverse(node.right, deep) return min(left_deep, right_deep) def xxx(self, root: TreeNode) -> int: return self.traverse(root, 0)
def rotation_saxs(t = 1): #sample = ['Hopper2_AGIB_AuPd_top', 'Hopper2_AGIB_AuPd_mid', 'Hopper2_AGIB_AuPd_bot'] #Change filename sample = ['AGIB3N_1top', 'AGIB3N_1mid', 'AGIB3N_1cen'] #Change filename #y_list = [-6.06, -6.04, -6.02] #hexapod is in mm #y_list = [-10320, -10300, -10280] #SmarAct is um y_list = [4760, 4810, 4860]#, 5210] #SmarAct is um assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' # Detectors, motors: #dets = [pil1M, rayonix, pil300KW] dets = [pil1M, pil300KW] prs_range = [-90, 90, 91] waxs_range = [0, 26, 5] #step of 6.5 degrees det_exposure_time(t,t) #pil_pos_x = [-0.4997, -0.4997 + 4.3, -0.4997 + 4.3, -0.4997] #pil_pos_y = [-59.9987, -59.9987, -59.9987 + 4.3, -59.9987] #waxs_po = np.linspace(20.95, 2.95, 4) for sam, y in zip(sample, y_list): #yield from bps.mv(stage.y, y) #hexapod yield from bps.mv(piezo.y, y) #SmarAct name_fmt = '{sam}' sample_name = name_fmt.format(sam=sam) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.grid_scan(dets, prs, *prs_range, waxs, *waxs_range, 1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.3, 0.3) def rotation_saxs_fast(t = 1): sample = ['AGIB3DR_2fast_top', 'AGIB3DR_2fast_mid', 'AGIB3DR_2fast_cen'] #Change filename y_list = [5150, 5230, 5310] #SmarAct is um assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' # Detectors, motors: dets = [pil1M, pil300KW] prs_range = np.linspace(-90, 90, 91) waxs_range = np.linspace(0, 26, 5) det_exposure_time(t,t) for sam, y in zip(sample, y_list): yield from bps.mv(piezo.y, y) for wa in waxs_range: yield from bps.mv(waxs, wa) for pr in prs_range: yield from bps.mv(prs, pr) name_fmt = '{sam}_wa{waxs}deg_{prs}deg' sample_name = name_fmt.format(sam=sam, waxs='%2.1f'%wa, prs='%3.3d'%pr) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets, num=1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.3, 0.3) def rotation_saxs_att(t = 1): #attenuated WAXS, so SAXS recorded separately first #sample = ['Disc3_AuPd_top-3', 'Disc3_AuPd_mid-3', 'Disc3_AuPd_bot-3'] #Change filename sample = ['Hopper1_AGIB_AuPd_top','Hopper1_AGIB_AuPd_mid', 'Hopper1_AGIB_AuPd_bot'] #Change filename #y_list = [-6.06, -6.04, -6.02] #hexapod is in mm #y_list = [-10320, -10300, -10280] #SmarAct is um y_list = [-9540, -9520, -9500] #SmarAct is um assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' # Detectors, motors: #dets = [pil1M, rayonix, pil300KW] dets0 = [pil1M] dets = [pil300KW] det_exposure_time(t,t) pil_pos_x = [-0.4997, -0.4997 + 4.3, -0.4997 + 4.3, -0.4997] pil_pos_y = [-59.9987, -59.9987, -59.9987 + 4.3, -59.9987] waxs_po = np.linspace(20.95, 2.95, 4) for sam, y in zip(sample, y_list): #yield from bps.mv(stage.y, y) #hexapod yield from bps.mv(piezo.y, y) #SmarAct yield from bps.mv(waxs, 70) for angle in range(-90, 91, 1): yield from bps.mv(prs, angle) name_fmt = '{sam}_phi{angle}deg' sample_name = name_fmt.format(sam=sam, angle=angle) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets0, num = 1) yield from bps.mv(att1_5, 'Insert') yield from bps.sleep(1) yield from bps.mv(att1_6, 'Insert') yield from bps.sleep(1) for sam, y in zip(sample, y_list): #yield from bps.mv(stage.y, y) #hexapod yield from bps.mv(piezo.y, y) #SmarAct for i, waxs_pos in enumerate(waxs_po): yield from bps.mv(waxs, waxs_pos) yield from bps.mv(pil1m_pos.x, pil_pos_x[i]) yield from bps.mv(pil1m_pos.y, pil_pos_y[i]) for angle in range(-90, 91, 1): yield from bps.mv(prs, angle) name_fmt = '{sam}_phi{angle}deg_{waxs_pos}deg' sample_name = name_fmt.format(sam=sam, angle=angle, waxs_pos = waxs_pos) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets, num = 1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.5, 0.5) yield from bps.mv(att1_5, 'Retract') yield from bps.sleep(1) yield from bps.mv(att1_6, 'Retract') yield from bps.sleep(1) yield from bps.mv(pil1m_pos.x, -0.4997) yield from bps.mv(pil1m_pos.y, -59.9987)
def rotation_saxs(t=1): sample = ['AGIB3N_1top', 'AGIB3N_1mid', 'AGIB3N_1cen'] y_list = [4760, 4810, 4860] assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' dets = [pil1M, pil300KW] prs_range = [-90, 90, 91] waxs_range = [0, 26, 5] det_exposure_time(t, t) for (sam, y) in zip(sample, y_list): yield from bps.mv(piezo.y, y) name_fmt = '{sam}' sample_name = name_fmt.format(sam=sam) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.grid_scan(dets, prs, *prs_range, waxs, *waxs_range, 1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.3, 0.3) def rotation_saxs_fast(t=1): sample = ['AGIB3DR_2fast_top', 'AGIB3DR_2fast_mid', 'AGIB3DR_2fast_cen'] y_list = [5150, 5230, 5310] assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' dets = [pil1M, pil300KW] prs_range = np.linspace(-90, 90, 91) waxs_range = np.linspace(0, 26, 5) det_exposure_time(t, t) for (sam, y) in zip(sample, y_list): yield from bps.mv(piezo.y, y) for wa in waxs_range: yield from bps.mv(waxs, wa) for pr in prs_range: yield from bps.mv(prs, pr) name_fmt = '{sam}_wa{waxs}deg_{prs}deg' sample_name = name_fmt.format(sam=sam, waxs='%2.1f' % wa, prs='%3.3d' % pr) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets, num=1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.3, 0.3) def rotation_saxs_att(t=1): sample = ['Hopper1_AGIB_AuPd_top', 'Hopper1_AGIB_AuPd_mid', 'Hopper1_AGIB_AuPd_bot'] y_list = [-9540, -9520, -9500] assert len(y_list) == len(sample), f'Number of X coordinates ({len(x_list)}) is different from number of samples ({len(samples)})' dets0 = [pil1M] dets = [pil300KW] det_exposure_time(t, t) pil_pos_x = [-0.4997, -0.4997 + 4.3, -0.4997 + 4.3, -0.4997] pil_pos_y = [-59.9987, -59.9987, -59.9987 + 4.3, -59.9987] waxs_po = np.linspace(20.95, 2.95, 4) for (sam, y) in zip(sample, y_list): yield from bps.mv(piezo.y, y) yield from bps.mv(waxs, 70) for angle in range(-90, 91, 1): yield from bps.mv(prs, angle) name_fmt = '{sam}_phi{angle}deg' sample_name = name_fmt.format(sam=sam, angle=angle) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets0, num=1) yield from bps.mv(att1_5, 'Insert') yield from bps.sleep(1) yield from bps.mv(att1_6, 'Insert') yield from bps.sleep(1) for (sam, y) in zip(sample, y_list): yield from bps.mv(piezo.y, y) for (i, waxs_pos) in enumerate(waxs_po): yield from bps.mv(waxs, waxs_pos) yield from bps.mv(pil1m_pos.x, pil_pos_x[i]) yield from bps.mv(pil1m_pos.y, pil_pos_y[i]) for angle in range(-90, 91, 1): yield from bps.mv(prs, angle) name_fmt = '{sam}_phi{angle}deg_{waxs_pos}deg' sample_name = name_fmt.format(sam=sam, angle=angle, waxs_pos=waxs_pos) sample_id(user_name='MK', sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') yield from bp.count(dets, num=1) sample_id(user_name='test', sample_name='test') det_exposure_time(0.5, 0.5) yield from bps.mv(att1_5, 'Retract') yield from bps.sleep(1) yield from bps.mv(att1_6, 'Retract') yield from bps.sleep(1) yield from bps.mv(pil1m_pos.x, -0.4997) yield from bps.mv(pil1m_pos.y, -59.9987)
def factory(classToInstantiate): def f(*arg): def g(): return classToInstantiate(*arg) return g return f
def factory(classToInstantiate): def f(*arg): def g(): return class_to_instantiate(*arg) return g return f
class EmailBuilder: def __init__(self): self.message = {} def set_from_email(self, email): self.message['from'] = email return self def set_receiver_email(self, email): self.message['receiver'] = email def set_cc_emails(self, emails): self.message['cc'] = emails return self def set_attachaments(self, attachments): self.message['attachments'] = attachments return self def set_subject(self, subject): self.message['subject'] = subject return self def set_msg(self, message): self.message['message'] = message return self def set_priority(self, priority): self.message['priority'] = priority return self def build(self): return self.message
class Emailbuilder: def __init__(self): self.message = {} def set_from_email(self, email): self.message['from'] = email return self def set_receiver_email(self, email): self.message['receiver'] = email def set_cc_emails(self, emails): self.message['cc'] = emails return self def set_attachaments(self, attachments): self.message['attachments'] = attachments return self def set_subject(self, subject): self.message['subject'] = subject return self def set_msg(self, message): self.message['message'] = message return self def set_priority(self, priority): self.message['priority'] = priority return self def build(self): return self.message
# -*- coding: utf-8 -*- # Copyright 2018 ICON Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. TEST_REQUEST_TRANSFER_ICX = { "jsonrpc": "2.0", "method": "icx_sendTransaction", "id": 1234, "params": { "version": "0x3", "from": "hxbe258ceb872e08851f1f59694dac2558708ece11", "to": "hx5bfdb090f43a808005ffc27c25b213145e80b7cd", "value": "0xde0b6b3a7640000", "stepLimit": "0x12345", "timestamp": "0x563a6cf330136", "nid": "0x3f", "nonce": "0x1", "signature": "VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=" } } TEST_REQUEST_SCORE_FUNCTION_CALL = { "jsonrpc": "2.0", "method": "icx_sendTransaction", "id": 1234, "params": { "version": "0x3", "from": "hxbe258ceb872e08851f1f59694dac2558708ece11", "to": "cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32", "stepLimit": "0x12345", "timestamp": "0x563a6cf330136", "nid": "0x3f", "nonce": "0x1", "signature": "VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=", "dataType": "call", "data": { "method": "transfer", "params": { "to": "hxab2d8215eab14bc6bdd8bfb2c8151257032ecd8b", "value": "0x1" } } } } TEST_REQUEST_SCORE_ISNTALL = { "jsonrpc": "2.0", "method": "icx_sendTransaction", "id": 1234, "params": { "version": "0x3", "from": "hxbe258ceb872e08851f1f59694dac2558708ece11", "to": "cx0000000000000000000000000000000000000000", "stepLimit": "0x12345", "timestamp": "0x563a6cf330136", "nid": "0x3f", "nonce": "0x1", "signature": "VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=", "dataType": "deploy", "data": { "contentType": "application/zip", "content": "0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...", "params": { "name": "ABCToken", "symbol": "abc", "decimals": "0x12" } } } } TEST_REQUEST_SCORE_UPDATE = { "jsonrpc": "2.0", "method": "icx_sendTransaction", "id": 1234, "params": { "version": "0x3", "from": "hxbe258ceb872e08851f1f59694dac2558708ece11", "to": "cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32", "stepLimit": "0x12345", "timestamp": "0x563a6cf330136", "nid": "0x3f", "nonce": "0x1", "signature": "VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=", "dataType": "deploy", "data": { "contentType": "application/zip", "content": "0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...", "params": { "amount": "0x1234" } } } } TEST_REQUEST_SEND_MESSAGE = { "jsonrpc": "2.0", "method": "icx_sendTransaction", "id": 1234, "params": { "version": "0x3", "from": "hxbe258ceb872e08851f1f59694dac2558708ece11", "to": "hxbe258ceb872e08851f1f59694dac2558708ece11", "stepLimit": "0x12345", "timestamp": "0x563a6cf330136", "nid": "0x3f", "nonce": "0x1", "signature": "VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=", "dataType": "message", "data": "0x4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c2071756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e69736920757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e2044756973206175746520697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c697420657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e204578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c2073756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e" } }
test_request_transfer_icx = {'jsonrpc': '2.0', 'method': 'icx_sendTransaction', 'id': 1234, 'params': {'version': '0x3', 'from': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'to': 'hx5bfdb090f43a808005ffc27c25b213145e80b7cd', 'value': '0xde0b6b3a7640000', 'stepLimit': '0x12345', 'timestamp': '0x563a6cf330136', 'nid': '0x3f', 'nonce': '0x1', 'signature': 'VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA='}} test_request_score_function_call = {'jsonrpc': '2.0', 'method': 'icx_sendTransaction', 'id': 1234, 'params': {'version': '0x3', 'from': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'to': 'cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32', 'stepLimit': '0x12345', 'timestamp': '0x563a6cf330136', 'nid': '0x3f', 'nonce': '0x1', 'signature': 'VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=', 'dataType': 'call', 'data': {'method': 'transfer', 'params': {'to': 'hxab2d8215eab14bc6bdd8bfb2c8151257032ecd8b', 'value': '0x1'}}}} test_request_score_isntall = {'jsonrpc': '2.0', 'method': 'icx_sendTransaction', 'id': 1234, 'params': {'version': '0x3', 'from': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'to': 'cx0000000000000000000000000000000000000000', 'stepLimit': '0x12345', 'timestamp': '0x563a6cf330136', 'nid': '0x3f', 'nonce': '0x1', 'signature': 'VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=', 'dataType': 'deploy', 'data': {'contentType': 'application/zip', 'content': '0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...', 'params': {'name': 'ABCToken', 'symbol': 'abc', 'decimals': '0x12'}}}} test_request_score_update = {'jsonrpc': '2.0', 'method': 'icx_sendTransaction', 'id': 1234, 'params': {'version': '0x3', 'from': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'to': 'cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32', 'stepLimit': '0x12345', 'timestamp': '0x563a6cf330136', 'nid': '0x3f', 'nonce': '0x1', 'signature': 'VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=', 'dataType': 'deploy', 'data': {'contentType': 'application/zip', 'content': '0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...', 'params': {'amount': '0x1234'}}}} test_request_send_message = {'jsonrpc': '2.0', 'method': 'icx_sendTransaction', 'id': 1234, 'params': {'version': '0x3', 'from': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'to': 'hxbe258ceb872e08851f1f59694dac2558708ece11', 'stepLimit': '0x12345', 'timestamp': '0x563a6cf330136', 'nid': '0x3f', 'nonce': '0x1', 'signature': 'VAia7YZ2Ji6igKWzjR2YsGa2m53nKPrfK7uXYW78QLE+ATehAVZPC40szvAiA6NEU5gCYB4c4qaQzqDh2ugcHgA=', 'dataType': 'message', 'data': '0x4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c2071756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e69736920757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e2044756973206175746520697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c697420657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e204578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c2073756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e'}}
#! /usr/bin/env python3 def main(): try: name = input('\nHello! What is your name? ') if name: print(f'\nWell, {name}, it is nice to meet you!\n') except: print('\n\nSorry. Something went wrong, please try again.\n') if __name__ == '__main__': main()
def main(): try: name = input('\nHello! What is your name? ') if name: print(f'\nWell, {name}, it is nice to meet you!\n') except: print('\n\nSorry. Something went wrong, please try again.\n') if __name__ == '__main__': main()
meta_pickups={ 'aux_domains': lambda r, common, data: { 'pos': r['head_pos'], 'head': r['head'], 'head_word': r['head_word'], **common, **data}, 'root_domains': lambda r, common, data: {'pos': r['upos'], 'rel': r['rel'], **common, **data}, 'verb_domains': lambda r, common, data: {'pos': r['upos'], 'rel': r['rel'], **common, **data}, 'predicate': lambda r, common, data: { 'pos': r['pos'], 'rel': r['rel'], 'segments':r['segments'] if 'segments' in r else [], **common, **data}, 'subj_domains': lambda r, common, data: { 'pos': r['head_pos'], 'head': r['head'], 'head_word': r['head_word'], **common, **data}, } def build_meta(r, data): # from sagas.conf.conf import cf type_name = r['type'] common = {'lemma': r['lemma'], 'word': r['word'], 'index': r['index'], 'stems': r['stems'], 'domain_type': type_name, } # if 'engine' not in data: # data['engine']=cf.engine(data['lang']) if type_name in meta_pickups: return meta_pickups[type_name](r, common, data) else: return {'rel': r['rel'], **common, **data}
meta_pickups = {'aux_domains': lambda r, common, data: {'pos': r['head_pos'], 'head': r['head'], 'head_word': r['head_word'], **common, **data}, 'root_domains': lambda r, common, data: {'pos': r['upos'], 'rel': r['rel'], **common, **data}, 'verb_domains': lambda r, common, data: {'pos': r['upos'], 'rel': r['rel'], **common, **data}, 'predicate': lambda r, common, data: {'pos': r['pos'], 'rel': r['rel'], 'segments': r['segments'] if 'segments' in r else [], **common, **data}, 'subj_domains': lambda r, common, data: {'pos': r['head_pos'], 'head': r['head'], 'head_word': r['head_word'], **common, **data}} def build_meta(r, data): type_name = r['type'] common = {'lemma': r['lemma'], 'word': r['word'], 'index': r['index'], 'stems': r['stems'], 'domain_type': type_name} if type_name in meta_pickups: return meta_pickups[type_name](r, common, data) else: return {'rel': r['rel'], **common, **data}
# # PySNMP MIB module CISCO-WAN-BBIF-ATM-CONN-STAT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-BBIF-ATM-CONN-STAT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:03:57 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) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion") bbChanCntGrp, = mibBuilder.importSymbols("BASIS-MIB", "bbChanCntGrp") ciscoWan, = mibBuilder.importSymbols("CISCOWAN-SMI", "ciscoWan") ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") MibIdentifier, Counter64, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, Counter32, NotificationType, Unsigned32, TimeTicks, Gauge32, ObjectIdentity, Bits, ModuleIdentity, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "Counter64", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "Counter32", "NotificationType", "Unsigned32", "TimeTicks", "Gauge32", "ObjectIdentity", "Bits", "ModuleIdentity", "Integer32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") ciscoWanBbifAtmConnStatMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 351, 150, 36)) ciscoWanBbifAtmConnStatMIB.setRevisions(('2002-10-18 00:00',)) if mibBuilder.loadTexts: ciscoWanBbifAtmConnStatMIB.setLastUpdated('200210180000Z') if mibBuilder.loadTexts: ciscoWanBbifAtmConnStatMIB.setOrganization('Cisco Systems, Inc.') bbChanCntGrpTable = MibTable((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1), ) if mibBuilder.loadTexts: bbChanCntGrpTable.setStatus('current') bbChanCntGrpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1), ).setIndexNames((0, "CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanCntNum")) if mibBuilder.loadTexts: bbChanCntGrpEntry.setStatus('current') bbChanCntNum = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(16, 4111))).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanCntNum.setStatus('current') bbChanRcvClp0Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanRcvClp0Cells.setStatus('current') bbChanRcvClp1Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanRcvClp1Cells.setStatus('current') bbChanNonConformCellsAtGcra1Policer = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanNonConformCellsAtGcra1Policer.setStatus('current') bbChanNonConformCellsAtGcra2Policer = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanNonConformCellsAtGcra2Policer.setStatus('current') bbChanRcvEOFCells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanRcvEOFCells.setStatus('current') bbChanDscdClp0Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanDscdClp0Cells.setStatus('current') bbChanDscdClp1Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 8), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanDscdClp1Cells.setStatus('current') bbChanRcvCellsSent = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 9), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanRcvCellsSent.setStatus('current') bbChanXmtClp0Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 10), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanXmtClp0Cells.setStatus('current') bbChanXmtClp1Cells = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 11), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanXmtClp1Cells.setStatus('current') bbChanDscdClpZeroCellsToPort = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 12), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanDscdClpZeroCellsToPort.setStatus('current') bbChanDscdClpOneCellsToPort = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 13), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: bbChanDscdClpOneCellsToPort.setStatus('current') bbChanCntClrButton = MibTableColumn((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("noAction", 1), ("resetCounters", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: bbChanCntClrButton.setStatus('current') cwbAtmConnStatMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2)) cwbAtmConnStatMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 1)) cwbAtmConnStatMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 2)) cwbAtmConnStatCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 2, 1)).setObjects(("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "cwbAtmConnStatsGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cwbAtmConnStatCompliance = cwbAtmConnStatCompliance.setStatus('current') cwbAtmConnStatsGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 1, 1)).setObjects(("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanCntNum"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanRcvClp0Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanRcvClp1Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanNonConformCellsAtGcra1Policer"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanNonConformCellsAtGcra2Policer"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanRcvEOFCells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanDscdClp0Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanDscdClp1Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanRcvCellsSent"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanXmtClp0Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanXmtClp1Cells"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanDscdClpZeroCellsToPort"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanDscdClpOneCellsToPort"), ("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", "bbChanCntClrButton")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cwbAtmConnStatsGroup = cwbAtmConnStatsGroup.setStatus('current') mibBuilder.exportSymbols("CISCO-WAN-BBIF-ATM-CONN-STAT-MIB", bbChanRcvCellsSent=bbChanRcvCellsSent, bbChanRcvClp1Cells=bbChanRcvClp1Cells, bbChanDscdClp0Cells=bbChanDscdClp0Cells, PYSNMP_MODULE_ID=ciscoWanBbifAtmConnStatMIB, bbChanDscdClpOneCellsToPort=bbChanDscdClpOneCellsToPort, bbChanNonConformCellsAtGcra1Policer=bbChanNonConformCellsAtGcra1Policer, cwbAtmConnStatMIBCompliances=cwbAtmConnStatMIBCompliances, bbChanXmtClp1Cells=bbChanXmtClp1Cells, cwbAtmConnStatMIBGroups=cwbAtmConnStatMIBGroups, bbChanRcvEOFCells=bbChanRcvEOFCells, bbChanRcvClp0Cells=bbChanRcvClp0Cells, cwbAtmConnStatsGroup=cwbAtmConnStatsGroup, cwbAtmConnStatMIBConformance=cwbAtmConnStatMIBConformance, bbChanCntClrButton=bbChanCntClrButton, bbChanXmtClp0Cells=bbChanXmtClp0Cells, bbChanCntNum=bbChanCntNum, bbChanDscdClpZeroCellsToPort=bbChanDscdClpZeroCellsToPort, bbChanDscdClp1Cells=bbChanDscdClp1Cells, bbChanCntGrpTable=bbChanCntGrpTable, ciscoWanBbifAtmConnStatMIB=ciscoWanBbifAtmConnStatMIB, bbChanCntGrpEntry=bbChanCntGrpEntry, cwbAtmConnStatCompliance=cwbAtmConnStatCompliance, bbChanNonConformCellsAtGcra2Policer=bbChanNonConformCellsAtGcra2Policer)
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion') (bb_chan_cnt_grp,) = mibBuilder.importSymbols('BASIS-MIB', 'bbChanCntGrp') (cisco_wan,) = mibBuilder.importSymbols('CISCOWAN-SMI', 'ciscoWan') (module_compliance, object_group, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'ObjectGroup', 'NotificationGroup') (mib_identifier, counter64, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, counter32, notification_type, unsigned32, time_ticks, gauge32, object_identity, bits, module_identity, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'Counter64', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'Counter32', 'NotificationType', 'Unsigned32', 'TimeTicks', 'Gauge32', 'ObjectIdentity', 'Bits', 'ModuleIdentity', 'Integer32') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') cisco_wan_bbif_atm_conn_stat_mib = module_identity((1, 3, 6, 1, 4, 1, 351, 150, 36)) ciscoWanBbifAtmConnStatMIB.setRevisions(('2002-10-18 00:00',)) if mibBuilder.loadTexts: ciscoWanBbifAtmConnStatMIB.setLastUpdated('200210180000Z') if mibBuilder.loadTexts: ciscoWanBbifAtmConnStatMIB.setOrganization('Cisco Systems, Inc.') bb_chan_cnt_grp_table = mib_table((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1)) if mibBuilder.loadTexts: bbChanCntGrpTable.setStatus('current') bb_chan_cnt_grp_entry = mib_table_row((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1)).setIndexNames((0, 'CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanCntNum')) if mibBuilder.loadTexts: bbChanCntGrpEntry.setStatus('current') bb_chan_cnt_num = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(16, 4111))).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanCntNum.setStatus('current') bb_chan_rcv_clp0_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 2), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanRcvClp0Cells.setStatus('current') bb_chan_rcv_clp1_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 3), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanRcvClp1Cells.setStatus('current') bb_chan_non_conform_cells_at_gcra1_policer = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanNonConformCellsAtGcra1Policer.setStatus('current') bb_chan_non_conform_cells_at_gcra2_policer = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanNonConformCellsAtGcra2Policer.setStatus('current') bb_chan_rcv_eof_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanRcvEOFCells.setStatus('current') bb_chan_dscd_clp0_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 7), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanDscdClp0Cells.setStatus('current') bb_chan_dscd_clp1_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 8), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanDscdClp1Cells.setStatus('current') bb_chan_rcv_cells_sent = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 9), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanRcvCellsSent.setStatus('current') bb_chan_xmt_clp0_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 10), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanXmtClp0Cells.setStatus('current') bb_chan_xmt_clp1_cells = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 11), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanXmtClp1Cells.setStatus('current') bb_chan_dscd_clp_zero_cells_to_port = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 12), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanDscdClpZeroCellsToPort.setStatus('current') bb_chan_dscd_clp_one_cells_to_port = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 13), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: bbChanDscdClpOneCellsToPort.setStatus('current') bb_chan_cnt_clr_button = mib_table_column((1, 3, 6, 1, 4, 1, 351, 110, 5, 2, 7, 3, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('noAction', 1), ('resetCounters', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: bbChanCntClrButton.setStatus('current') cwb_atm_conn_stat_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2)) cwb_atm_conn_stat_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 1)) cwb_atm_conn_stat_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 2)) cwb_atm_conn_stat_compliance = module_compliance((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 2, 1)).setObjects(('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'cwbAtmConnStatsGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cwb_atm_conn_stat_compliance = cwbAtmConnStatCompliance.setStatus('current') cwb_atm_conn_stats_group = object_group((1, 3, 6, 1, 4, 1, 351, 150, 36, 2, 1, 1)).setObjects(('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanCntNum'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanRcvClp0Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanRcvClp1Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanNonConformCellsAtGcra1Policer'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanNonConformCellsAtGcra2Policer'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanRcvEOFCells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanDscdClp0Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanDscdClp1Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanRcvCellsSent'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanXmtClp0Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanXmtClp1Cells'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanDscdClpZeroCellsToPort'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanDscdClpOneCellsToPort'), ('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', 'bbChanCntClrButton')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cwb_atm_conn_stats_group = cwbAtmConnStatsGroup.setStatus('current') mibBuilder.exportSymbols('CISCO-WAN-BBIF-ATM-CONN-STAT-MIB', bbChanRcvCellsSent=bbChanRcvCellsSent, bbChanRcvClp1Cells=bbChanRcvClp1Cells, bbChanDscdClp0Cells=bbChanDscdClp0Cells, PYSNMP_MODULE_ID=ciscoWanBbifAtmConnStatMIB, bbChanDscdClpOneCellsToPort=bbChanDscdClpOneCellsToPort, bbChanNonConformCellsAtGcra1Policer=bbChanNonConformCellsAtGcra1Policer, cwbAtmConnStatMIBCompliances=cwbAtmConnStatMIBCompliances, bbChanXmtClp1Cells=bbChanXmtClp1Cells, cwbAtmConnStatMIBGroups=cwbAtmConnStatMIBGroups, bbChanRcvEOFCells=bbChanRcvEOFCells, bbChanRcvClp0Cells=bbChanRcvClp0Cells, cwbAtmConnStatsGroup=cwbAtmConnStatsGroup, cwbAtmConnStatMIBConformance=cwbAtmConnStatMIBConformance, bbChanCntClrButton=bbChanCntClrButton, bbChanXmtClp0Cells=bbChanXmtClp0Cells, bbChanCntNum=bbChanCntNum, bbChanDscdClpZeroCellsToPort=bbChanDscdClpZeroCellsToPort, bbChanDscdClp1Cells=bbChanDscdClp1Cells, bbChanCntGrpTable=bbChanCntGrpTable, ciscoWanBbifAtmConnStatMIB=ciscoWanBbifAtmConnStatMIB, bbChanCntGrpEntry=bbChanCntGrpEntry, cwbAtmConnStatCompliance=cwbAtmConnStatCompliance, bbChanNonConformCellsAtGcra2Policer=bbChanNonConformCellsAtGcra2Policer)
things = ['a', 'b', 'c', 'd'] print(things) print(things[1]) things[1] = 'z' print(things[1]) print(things) things = ['a', 'b', 'c', 'd'] print("=" * 50) stuff = {'name' : 'Jinkyu', 'age' : 40, 'height' : 6 * 12 + 2} print(stuff) print(stuff['name']) print(stuff['age']) print(stuff['height']) stuff['city'] = "SF" print(stuff['city']) stuff[1] = "Wow" stuff[2] = "Neato" print(stuff) print(stuff[1]) print(stuff[2]) del stuff['city'] del stuff[1] del stuff[2] print(stuff)
things = ['a', 'b', 'c', 'd'] print(things) print(things[1]) things[1] = 'z' print(things[1]) print(things) things = ['a', 'b', 'c', 'd'] print('=' * 50) stuff = {'name': 'Jinkyu', 'age': 40, 'height': 6 * 12 + 2} print(stuff) print(stuff['name']) print(stuff['age']) print(stuff['height']) stuff['city'] = 'SF' print(stuff['city']) stuff[1] = 'Wow' stuff[2] = 'Neato' print(stuff) print(stuff[1]) print(stuff[2]) del stuff['city'] del stuff[1] del stuff[2] print(stuff)
# https://leetcode.com/problems/surface-area-of-3d-shapes class Solution: def surfaceArea(self, grid): N = len(grid) ans = 0 for i in range(N): for j in range(N): if grid[i][j] == 0: continue height = grid[i][j] ans += 2 for h in range(1, height + 1): adj = [[i + 1, j], [i - 1, j], [i, j + 1], [i, j - 1]] for a, b in adj: if a < 0 or N <= a or b < 0 or N <= b: ans += 1 else: if h <= grid[a][b]: ans += 0 else: ans += 1 return ans
class Solution: def surface_area(self, grid): n = len(grid) ans = 0 for i in range(N): for j in range(N): if grid[i][j] == 0: continue height = grid[i][j] ans += 2 for h in range(1, height + 1): adj = [[i + 1, j], [i - 1, j], [i, j + 1], [i, j - 1]] for (a, b) in adj: if a < 0 or N <= a or b < 0 or (N <= b): ans += 1 elif h <= grid[a][b]: ans += 0 else: ans += 1 return ans
tempo = int(input()) velocida_media = int(input()) gasto_carro = 12 distancia = velocida_media * tempo print(f'{distancia / 12:.3f}')
tempo = int(input()) velocida_media = int(input()) gasto_carro = 12 distancia = velocida_media * tempo print(f'{distancia / 12:.3f}')
rows, cols = [int(n) for n in input().split(", ")] matrix = [] for _ in range(rows): matrix.append([int(n) for n in input().split(" ")]) for j in range(cols): total = 0 for row in matrix: total += row[j] print(total)
(rows, cols) = [int(n) for n in input().split(', ')] matrix = [] for _ in range(rows): matrix.append([int(n) for n in input().split(' ')]) for j in range(cols): total = 0 for row in matrix: total += row[j] print(total)
# Available methods METHODS = { # Dummy for HF "hf": ["hf"], "ricc2": ["rimp2", "rimp3", "rimp4", "ricc2"], # Hardcoded XC-functionals that can be selected from the dft submenu # of define. "dft_hardcoded": [ # Hardcoded in V7.3 "s-vwn", "s-vwn_Gaussian", "pwlda", "b-lyp", "b-vwn", "b-p", "pbe", "tpss", "bh-lyp", "b3-lyp", "b3-lyp_Gaussian", "pbe0", "tpssh", "pw6b95", "m06", "m06-l", "m06-2x", "lhf", "oep", "b97-d", "pbeh-3c", "b97-3c", "lh07t-svwn", "lh07s-svwn", "lh12ct-ssirpw92", "lh12ct-ssifpw92", "lh14t-calpbe", # Hardcoded in V7.4 "cam-b3lyp", # B2PLYP his is not easily supported right now as we would need an # additional MP2 calculation from rimp2/ricc2. # "b2-plyp", ], # Shorctus for XC functionals in V7.4 using LibXC "dft_libxc": [ "wb97", "wb97x", "sogga11", "sogga-11x", "mn12-l", "mn12-sx", "mn15", "mn15-l", "m06-libxc", "cam-b3lyp-libxc", "hse06-libxc", ], } # Available keywords KEYWORDS = { # Resolution of identity "ri": ["rijk", "ri", "marij"], # Dispersion correction "dsp": ["d3", "d3bj"], }
methods = {'hf': ['hf'], 'ricc2': ['rimp2', 'rimp3', 'rimp4', 'ricc2'], 'dft_hardcoded': ['s-vwn', 's-vwn_Gaussian', 'pwlda', 'b-lyp', 'b-vwn', 'b-p', 'pbe', 'tpss', 'bh-lyp', 'b3-lyp', 'b3-lyp_Gaussian', 'pbe0', 'tpssh', 'pw6b95', 'm06', 'm06-l', 'm06-2x', 'lhf', 'oep', 'b97-d', 'pbeh-3c', 'b97-3c', 'lh07t-svwn', 'lh07s-svwn', 'lh12ct-ssirpw92', 'lh12ct-ssifpw92', 'lh14t-calpbe', 'cam-b3lyp'], 'dft_libxc': ['wb97', 'wb97x', 'sogga11', 'sogga-11x', 'mn12-l', 'mn12-sx', 'mn15', 'mn15-l', 'm06-libxc', 'cam-b3lyp-libxc', 'hse06-libxc']} keywords = {'ri': ['rijk', 'ri', 'marij'], 'dsp': ['d3', 'd3bj']}
class Config: ''' General configuration parent class ''' NEWS_API_BASE_URL ='https://newsapi.org/v2/sources?apiKey={}' ARTICLE_API_BASE_URL = 'https://newsapi.org/v2/everything?sources={}&apiKey={}' class ProdConfig(Config): ''' Production configuration child class Args: Config: The parent configuration class with general configuration settings ''' pass class DevConfig(Config): ''' Development configuration child class Args: Config: The parent configuration class with general configuration settings ''' DEBUG = True
class Config: """ General configuration parent class """ news_api_base_url = 'https://newsapi.org/v2/sources?apiKey={}' article_api_base_url = 'https://newsapi.org/v2/everything?sources={}&apiKey={}' class Prodconfig(Config): """ Production configuration child class Args: Config: The parent configuration class with general configuration settings """ pass class Devconfig(Config): """ Development configuration child class Args: Config: The parent configuration class with general configuration settings """ debug = True
def main() -> None: K, X = map(int, input().split()) assert 1 <= K <= 100 assert 1 <= X <= 10**5 if __name__ == '__main__': main()
def main() -> None: (k, x) = map(int, input().split()) assert 1 <= K <= 100 assert 1 <= X <= 10 ** 5 if __name__ == '__main__': main()
# -*- coding: utf-8 -*- description = "Setup for the LakeShore 340 temperature controller" group = "optional" includes = ["alias_T"] tango_base = "tango://phys.kws3.frm2:10000/kws3" tango_ls340 = tango_base + "/ls340" devices = dict( T_ls340 = device("nicos.devices.entangle.TemperatureController", description = "Temperature regulation", tangodevice = tango_ls340 + "/t_control1", pollinterval = 2, maxage = 5, abslimits = (0, 300), precision = 0.01, ), ls340_heaterrange = device("nicos.devices.entangle.DigitalOutput", description = "Temperature regulation", tangodevice = tango_ls340 + "/t_range1", unit = '', fmtstr = '%d', ), T_ls340_A = device("nicos.devices.entangle.Sensor", description = "Sensor A", tangodevice = tango_ls340 + "/t_sensor1", pollinterval = 2, maxage = 5, ), T_ls340_B = device("nicos.devices.entangle.Sensor", description = "Sensor B", tangodevice = tango_ls340 + "/t_sensor2", pollinterval = 2, maxage = 5, ), T_ls340_C = device("nicos.devices.entangle.Sensor", description = "Sensor C", tangodevice = tango_ls340 + "/t_sensor3", pollinterval = 2, maxage = 5, ), T_ls340_D = device("nicos.devices.entangle.Sensor", description = "Sensor D", tangodevice = tango_ls340 + "/t_sensor4", pollinterval = 2, maxage = 5, ), ) alias_config = { "T": { "T_%s" % setupname: 100 }, "Ts": { "T_%s_A" % setupname: 110, "T_%s_B" % setupname: 100, "T_%s_C" % setupname: 90, "T_%s_D" % setupname: 80, "T_%s" % setupname: 120, }, }
description = 'Setup for the LakeShore 340 temperature controller' group = 'optional' includes = ['alias_T'] tango_base = 'tango://phys.kws3.frm2:10000/kws3' tango_ls340 = tango_base + '/ls340' devices = dict(T_ls340=device('nicos.devices.entangle.TemperatureController', description='Temperature regulation', tangodevice=tango_ls340 + '/t_control1', pollinterval=2, maxage=5, abslimits=(0, 300), precision=0.01), ls340_heaterrange=device('nicos.devices.entangle.DigitalOutput', description='Temperature regulation', tangodevice=tango_ls340 + '/t_range1', unit='', fmtstr='%d'), T_ls340_A=device('nicos.devices.entangle.Sensor', description='Sensor A', tangodevice=tango_ls340 + '/t_sensor1', pollinterval=2, maxage=5), T_ls340_B=device('nicos.devices.entangle.Sensor', description='Sensor B', tangodevice=tango_ls340 + '/t_sensor2', pollinterval=2, maxage=5), T_ls340_C=device('nicos.devices.entangle.Sensor', description='Sensor C', tangodevice=tango_ls340 + '/t_sensor3', pollinterval=2, maxage=5), T_ls340_D=device('nicos.devices.entangle.Sensor', description='Sensor D', tangodevice=tango_ls340 + '/t_sensor4', pollinterval=2, maxage=5)) alias_config = {'T': {'T_%s' % setupname: 100}, 'Ts': {'T_%s_A' % setupname: 110, 'T_%s_B' % setupname: 100, 'T_%s_C' % setupname: 90, 'T_%s_D' % setupname: 80, 'T_%s' % setupname: 120}}
def response(status, message, data, status_code=200): return { "status": status, "message": message, "data": data, }, status_code
def response(status, message, data, status_code=200): return ({'status': status, 'message': message, 'data': data}, status_code)
x = 0 for n in range(10): x = x + 1 assert x == 10
x = 0 for n in range(10): x = x + 1 assert x == 10
#Queue.py #20 Oct 2017 #Written By Amin Dehghan #DS & Algorithms With Python class Queue: def __init__(self): self.items=[] self.fronIdx=0 def __compress(self): newlst=[] for i in range(self.frontIdx,len(self.items)): newlst.append(self.items[i]) self.items=newlst self.frontIdx=0 def dequeue(self): if self.isEmpty(): raise RuntimeError("Attempt to dequeue an empty queue") if self.froniIdx*2< len(self.items): self.__compress() item=self.items[self.frontIdx] self.frontIdx+=1 return item def enqueue(self,val): self.items.append(val) def front(self): if self.isEmpty(): raise RuntimeError("Attempt to access front of empty queue") return self.items[frontIdx] def isEmpty(self): return len(self.items)==frontIdx
class Queue: def __init__(self): self.items = [] self.fronIdx = 0 def __compress(self): newlst = [] for i in range(self.frontIdx, len(self.items)): newlst.append(self.items[i]) self.items = newlst self.frontIdx = 0 def dequeue(self): if self.isEmpty(): raise runtime_error('Attempt to dequeue an empty queue') if self.froniIdx * 2 < len(self.items): self.__compress() item = self.items[self.frontIdx] self.frontIdx += 1 return item def enqueue(self, val): self.items.append(val) def front(self): if self.isEmpty(): raise runtime_error('Attempt to access front of empty queue') return self.items[frontIdx] def is_empty(self): return len(self.items) == frontIdx
patches = [ { "op": "move", "from": "/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/ItemType", "path": "/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/PrimitiveItemType", }, { "op": "replace", "path": "/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/PrimitiveItemType", "value": "String", }, { "op": "move", "from": "/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/ItemType", "path": "/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/PrimitiveItemType", }, { "op": "replace", "path": "/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/PrimitiveItemType", "value": "String", }, ]
patches = [{'op': 'move', 'from': '/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/ItemType', 'path': '/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/PrimitiveItemType'}, {'op': 'replace', 'path': '/ResourceTypes/AWS::Transfer::Server/Properties/Protocols/PrimitiveItemType', 'value': 'String'}, {'op': 'move', 'from': '/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/ItemType', 'path': '/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/PrimitiveItemType'}, {'op': 'replace', 'path': '/ResourceTypes/AWS::Transfer::User/Properties/SshPublicKeys/PrimitiveItemType', 'value': 'String'}]
def foo(x): if x == 0: return 1 elif x % 2 == 0: return 2 * x * foo(x - 2) else: return (x -3) * x * foo(x + 1) print(foo(4))
def foo(x): if x == 0: return 1 elif x % 2 == 0: return 2 * x * foo(x - 2) else: return (x - 3) * x * foo(x + 1) print(foo(4))
def diff(n, mid) : if (n > (mid * mid * mid)) : return (n - (mid * mid * mid)) else : return ((mid * mid * mid) - n) # Returns cube root of a no n def cubicRoot(n) : # Set start and end for binary # search start = 0 end = n # Set precision e = 0.0000001 while (True) : mid = (start + end) / 2 error = diff(n, mid) # If error is less than e # then mid is our answer # so return mid if (error <= e) : return mid # If mid*mid*mid is greater # than n set end = mid if ((mid * mid * mid) > n) : end = mid # If mid*mid*mid is less # than n set start = mid else : start = mid # Driver code n = 3 print("Cubic root of", n, "is", round(cubicRoot(n),6))
def diff(n, mid): if n > mid * mid * mid: return n - mid * mid * mid else: return mid * mid * mid - n def cubic_root(n): start = 0 end = n e = 1e-07 while True: mid = (start + end) / 2 error = diff(n, mid) if error <= e: return mid if mid * mid * mid > n: end = mid else: start = mid n = 3 print('Cubic root of', n, 'is', round(cubic_root(n), 6))
# Base Parameters assets = asset_list('FX') # Trading Parameters horizon = 'H1' pair = 0 # Mass Imports my_data = mass_import(pair, horizon) # Parameters long_ema = 26 short_ema = 12 signal_ema = 9 def ma(Data, lookback, close, where): Data = adder(Data, 1) for i in range(len(Data)): try: Data[i, where] = (Data[i - lookback + 1:i + 1, close].mean()) except IndexError: pass # Cleaning Data = jump(Data, lookback) return Data def ema(Data, alpha, lookback, what, where): alpha = alpha / (lookback + 1.0) beta = 1 - alpha # First value is a simple SMA Data = ma(Data, lookback, what, where) # Calculating first EMA Data[lookback + 1, where] = (Data[lookback + 1, what] * alpha) + (Data[lookback, where] * beta) # Calculating the rest of EMA for i in range(lookback + 2, len(Data)): try: Data[i, where] = (Data[i, what] * alpha) + (Data[i - 1, where] * beta) except IndexError: pass return Data def macd(Data, what, long_ema, short_ema, signal_ema, where): Data = adder(Data, 1) Data = ema(Data, 2, long_ema, what, where) Data = ema(Data, 2, short_ema, what, where + 1) Data[:, where + 2] = Data[:, where + 1] - Data[:, where] Data = jump(Data, long_ema) Data = ema(Data, 2, signal_ema, where + 2, where + 3) Data = deleter(Data, where, 2) Data = jump(Data, signal_ema) return Data def indicator_plot_double_macd(Data, MACD_line, MACD_signal, window = 250): fig, ax = plt.subplots(2, figsize = (8, 5)) Chosen = Data[-window:, ] for i in range(len(Chosen)): ax[0].vlines(x = i, ymin = Chosen[i, 2], ymax = Chosen[i, 1], color = 'black', linewidth = 1) ax[0].grid() for i in range(len(Chosen)): if Chosen[i, MACD_line] > 0: ax[1].vlines(x = i, ymin = 0, ymax = Chosen[i, MACD_line], color = 'green', linewidth = 1) if Chosen[i, MACD_line] < 0: ax[1].vlines(x = i, ymin = Chosen[i, MACD_line], ymax = 0, color = 'red', linewidth = 1) if Chosen[i, MACD_line] == 0: ax[1].vlines(x = i, ymin = Chosen[i, MACD_line], ymax = 0, color = 'black', linewidth = 1) ax[1].grid() ax[1].axhline(y = 0, color = 'black', linewidth = 0.5, linestyle = '--') ax[1].plot(Data[-window:, MACD_signal], color = 'blue', linewidth = 0.75, linestyle = 'dashed') my_data = macd(my_data, 3, 26, 12, 9, 4) indicator_plot_double_macd(my_data, 4, 5, window = 250)
assets = asset_list('FX') horizon = 'H1' pair = 0 my_data = mass_import(pair, horizon) long_ema = 26 short_ema = 12 signal_ema = 9 def ma(Data, lookback, close, where): data = adder(Data, 1) for i in range(len(Data)): try: Data[i, where] = Data[i - lookback + 1:i + 1, close].mean() except IndexError: pass data = jump(Data, lookback) return Data def ema(Data, alpha, lookback, what, where): alpha = alpha / (lookback + 1.0) beta = 1 - alpha data = ma(Data, lookback, what, where) Data[lookback + 1, where] = Data[lookback + 1, what] * alpha + Data[lookback, where] * beta for i in range(lookback + 2, len(Data)): try: Data[i, where] = Data[i, what] * alpha + Data[i - 1, where] * beta except IndexError: pass return Data def macd(Data, what, long_ema, short_ema, signal_ema, where): data = adder(Data, 1) data = ema(Data, 2, long_ema, what, where) data = ema(Data, 2, short_ema, what, where + 1) Data[:, where + 2] = Data[:, where + 1] - Data[:, where] data = jump(Data, long_ema) data = ema(Data, 2, signal_ema, where + 2, where + 3) data = deleter(Data, where, 2) data = jump(Data, signal_ema) return Data def indicator_plot_double_macd(Data, MACD_line, MACD_signal, window=250): (fig, ax) = plt.subplots(2, figsize=(8, 5)) chosen = Data[-window:,] for i in range(len(Chosen)): ax[0].vlines(x=i, ymin=Chosen[i, 2], ymax=Chosen[i, 1], color='black', linewidth=1) ax[0].grid() for i in range(len(Chosen)): if Chosen[i, MACD_line] > 0: ax[1].vlines(x=i, ymin=0, ymax=Chosen[i, MACD_line], color='green', linewidth=1) if Chosen[i, MACD_line] < 0: ax[1].vlines(x=i, ymin=Chosen[i, MACD_line], ymax=0, color='red', linewidth=1) if Chosen[i, MACD_line] == 0: ax[1].vlines(x=i, ymin=Chosen[i, MACD_line], ymax=0, color='black', linewidth=1) ax[1].grid() ax[1].axhline(y=0, color='black', linewidth=0.5, linestyle='--') ax[1].plot(Data[-window:, MACD_signal], color='blue', linewidth=0.75, linestyle='dashed') my_data = macd(my_data, 3, 26, 12, 9, 4) indicator_plot_double_macd(my_data, 4, 5, window=250)
x = 'heLLo world' print("Swap the case: " + x.swapcase()) print("Set all cast to upper: " + x.upper()) print("Set all cast to lower: " + x.lower()) print("Set all cast to lower aggresivly: " + x.casefold()) print("Set every word\'s first letter to upper: " + x.title()) print("Set the first word\'s first letter to upper in a sentence: " + x.capitalize()) x = x.split() y = '--'.join(x) print(y)
x = 'heLLo world' print('Swap the case: ' + x.swapcase()) print('Set all cast to upper: ' + x.upper()) print('Set all cast to lower: ' + x.lower()) print('Set all cast to lower aggresivly: ' + x.casefold()) print("Set every word's first letter to upper: " + x.title()) print("Set the first word's first letter to upper in a sentence: " + x.capitalize()) x = x.split() y = '--'.join(x) print(y)
''' constants for the project ''' TRAIN_LOSS = 0 TRAIN_ACCURACY = 1 VAL_LOSS = 2 VAL_ACCURACY = 3
""" constants for the project """ train_loss = 0 train_accuracy = 1 val_loss = 2 val_accuracy = 3
# -*- coding: utf-8 -*- STATSD_ENABLED = False STATSD_HOST = "localhost" STATSD_PORT = 8125 STATSD_LOG_PERIODIC = True STATSD_LOG_EVERY = 5 STATSD_HANDLER = "scrapy_statsd_extension.handlers.StatsdBase" STATSD_PREFIX = "scrapy" STATSD_LOG_ONLY = [] STATSD_TAGGING = False STATSD_TAGS = {"spider_name": True} STATSD_IGNORE = []
statsd_enabled = False statsd_host = 'localhost' statsd_port = 8125 statsd_log_periodic = True statsd_log_every = 5 statsd_handler = 'scrapy_statsd_extension.handlers.StatsdBase' statsd_prefix = 'scrapy' statsd_log_only = [] statsd_tagging = False statsd_tags = {'spider_name': True} statsd_ignore = []
N, r = map(int, input().split()) for i in range(N): R = int(input()) if R>=r: print('Good boi') else: print('Bad boi')
(n, r) = map(int, input().split()) for i in range(N): r = int(input()) if R >= r: print('Good boi') else: print('Bad boi')
# WRITE YOUR SOLUTION HERE: class Employee: def __init__(self, name: str): self.name = name self.subordinates = [] def add_subordinate(self, employee: 'Employee'): self.subordinates.append(employee) def count_subordinates(employee: Employee): count = len(employee.subordinates) if len(employee.subordinates) != 0: for sub_employee in employee.subordinates: count += count_subordinates(sub_employee) return count if __name__ == "__main__": t1 = Employee("Sally") t2 = Employee("Eric") t3 = Employee("Matthew") t4 = Employee("Emily") t5 = Employee("Adele") t6 = Employee("Claire") t1.add_subordinate(t4) t1.add_subordinate(t6) t4.add_subordinate(t2) t4.add_subordinate(t3) t4.add_subordinate(t5) print(count_subordinates(t1)) print(count_subordinates(t4)) print(count_subordinates(t5))
class Employee: def __init__(self, name: str): self.name = name self.subordinates = [] def add_subordinate(self, employee: 'Employee'): self.subordinates.append(employee) def count_subordinates(employee: Employee): count = len(employee.subordinates) if len(employee.subordinates) != 0: for sub_employee in employee.subordinates: count += count_subordinates(sub_employee) return count if __name__ == '__main__': t1 = employee('Sally') t2 = employee('Eric') t3 = employee('Matthew') t4 = employee('Emily') t5 = employee('Adele') t6 = employee('Claire') t1.add_subordinate(t4) t1.add_subordinate(t6) t4.add_subordinate(t2) t4.add_subordinate(t3) t4.add_subordinate(t5) print(count_subordinates(t1)) print(count_subordinates(t4)) print(count_subordinates(t5))
#!/usr/bin/env python3 def palindrome(x): return str(x) == str(x)[::-1] def number_palindrome(n, base): if base == 2: binary = bin(n)[2:] return palindrome(binary) if base == 10: return palindrome(n) return False def double_base_palindrome(x): return number_palindrome(x, 10) and number_palindrome(x, 2) def sum_double_palindrome_numbers_below(limit): return sum((x for x in range(1, limit) if double_base_palindrome(x))) def solve(): return sum_double_palindrome_numbers_below(1000000) if __name__ == '__main__': result = solve() print(result)
def palindrome(x): return str(x) == str(x)[::-1] def number_palindrome(n, base): if base == 2: binary = bin(n)[2:] return palindrome(binary) if base == 10: return palindrome(n) return False def double_base_palindrome(x): return number_palindrome(x, 10) and number_palindrome(x, 2) def sum_double_palindrome_numbers_below(limit): return sum((x for x in range(1, limit) if double_base_palindrome(x))) def solve(): return sum_double_palindrome_numbers_below(1000000) if __name__ == '__main__': result = solve() print(result)
#for request headers headers = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Max-Age': '3600', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0' }
headers = {'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Access-Control-Allow-Headers': 'Content-Type', 'Access-Control-Max-Age': '3600', 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'}
# Create an array for the points of the line line_points = [ {"x":5, "y":5}, {"x":70, "y":70}, {"x":120, "y":10}, {"x":180, "y":60}, {"x":240, "y":10}] # Create style style_line = lv.style_t() style_line.init() style_line.set_line_width(8) style_line.set_line_color(lv.palette_main(lv.PALETTE.BLUE)) style_line.set_line_rounded(True) # Create a line and apply the new style line1 = lv.line(lv.scr_act()) line1.set_points(line_points, 5) # Set the points line1.add_style(style_line, 0) line1.center()
line_points = [{'x': 5, 'y': 5}, {'x': 70, 'y': 70}, {'x': 120, 'y': 10}, {'x': 180, 'y': 60}, {'x': 240, 'y': 10}] style_line = lv.style_t() style_line.init() style_line.set_line_width(8) style_line.set_line_color(lv.palette_main(lv.PALETTE.BLUE)) style_line.set_line_rounded(True) line1 = lv.line(lv.scr_act()) line1.set_points(line_points, 5) line1.add_style(style_line, 0) line1.center()
# In case it's not obvious, a list comprehension produces a list, but # it doesn't have to be given a list to iterate over. # # You can use a list comprehension with any iterable type, so we'll # write a comprehension to convert dimensions from inches to centimetres. # # Our dimensions will be represented by a tuple, for the length, width and height. # # There are 2.54 centimetres to 1 inch. inch_measurement = (3, 8, 20) cm_measurement = [x * 2.54 for x in inch_measurement] print(cm_measurement) # Once you've got the correct values, change the code to produce a tuple, rather than a list. cm_measurement = [(x, x * 2.54) for x in inch_measurement] print(cm_measurement) cm_measurement = tuple(x * 2.54 for x in inch_measurement) print(cm_measurement)
inch_measurement = (3, 8, 20) cm_measurement = [x * 2.54 for x in inch_measurement] print(cm_measurement) cm_measurement = [(x, x * 2.54) for x in inch_measurement] print(cm_measurement) cm_measurement = tuple((x * 2.54 for x in inch_measurement)) print(cm_measurement)
r=s=t=1 #--- I1 print(r + s + t) r=s=t='1' #--- I2 print(r + s + t)
r = s = t = 1 print(r + s + t) r = s = t = '1' print(r + s + t)
_base_ = '../../base.py' # model settings model = dict( type='Classification', pretrained=None, backbone=dict( type='ResNet', depth=50, out_indices=[4], # 4: stage-4 norm_cfg=dict(type='BN')), head=dict( type='ClsHead', with_avg_pool=True, in_channels=2048, num_classes=10)) # dataset settings data_source_cfg = dict(type='Cifar10', root='/root/data/zq/data/cifar/') dataset_type = 'ClassificationDataset' img_norm_cfg = dict(mean=[0.4914, 0.4822, 0.4465], std=[0.2023, 0.1994, 0.201]) train_pipeline = [ dict(type='RandomCrop', size=32, padding=4), dict(type='RandomHorizontalFlip'), dict(type='ToTensor'), dict(type='Normalize', **img_norm_cfg), ] test_pipeline = [ dict(type='ToTensor'), dict(type='Normalize', **img_norm_cfg), ] data = dict( imgs_per_gpu=128, workers_per_gpu=2, train=dict( type=dataset_type, data_source=dict(split='train', **data_source_cfg), pipeline=train_pipeline), val=dict( type=dataset_type, data_source=dict(split='test', **data_source_cfg), pipeline=test_pipeline), test=dict( type=dataset_type, data_source=dict(split='test', **data_source_cfg), pipeline=test_pipeline)) # additional hooks custom_hooks = [ dict( type='ValidateHook', dataset=data['val'], initial=True, interval=10, imgs_per_gpu=128, workers_per_gpu=8, eval_param=dict(topk=(1, 5))) ] # optimizer optimizer = dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.0005) # learning policy lr_config = dict(policy='step', step=[150, 250]) checkpoint_config = dict(interval=50) # runtime settings total_epochs = 350
_base_ = '../../base.py' model = dict(type='Classification', pretrained=None, backbone=dict(type='ResNet', depth=50, out_indices=[4], norm_cfg=dict(type='BN')), head=dict(type='ClsHead', with_avg_pool=True, in_channels=2048, num_classes=10)) data_source_cfg = dict(type='Cifar10', root='/root/data/zq/data/cifar/') dataset_type = 'ClassificationDataset' img_norm_cfg = dict(mean=[0.4914, 0.4822, 0.4465], std=[0.2023, 0.1994, 0.201]) train_pipeline = [dict(type='RandomCrop', size=32, padding=4), dict(type='RandomHorizontalFlip'), dict(type='ToTensor'), dict(type='Normalize', **img_norm_cfg)] test_pipeline = [dict(type='ToTensor'), dict(type='Normalize', **img_norm_cfg)] data = dict(imgs_per_gpu=128, workers_per_gpu=2, train=dict(type=dataset_type, data_source=dict(split='train', **data_source_cfg), pipeline=train_pipeline), val=dict(type=dataset_type, data_source=dict(split='test', **data_source_cfg), pipeline=test_pipeline), test=dict(type=dataset_type, data_source=dict(split='test', **data_source_cfg), pipeline=test_pipeline)) custom_hooks = [dict(type='ValidateHook', dataset=data['val'], initial=True, interval=10, imgs_per_gpu=128, workers_per_gpu=8, eval_param=dict(topk=(1, 5)))] optimizer = dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.0005) lr_config = dict(policy='step', step=[150, 250]) checkpoint_config = dict(interval=50) total_epochs = 350
class BruteForceProtectionException(Exception): pass class BruteForceProtectionBanException(BruteForceProtectionException): pass class BruteForceProtectionCaptchaException(BruteForceProtectionException): pass
class Bruteforceprotectionexception(Exception): pass class Bruteforceprotectionbanexception(BruteForceProtectionException): pass class Bruteforceprotectioncaptchaexception(BruteForceProtectionException): pass
model = Model() i1 = Input("input", "TENSOR_FLOAT32", "{1, 2, 2, 1}") axis = Parameter("axis", "TENSOR_INT32", "{1}", [2]) keepDims = False output = Output("output", "TENSOR_FLOAT32", "{1, 2, 1}") model = model.Operation("REDUCE_MIN", i1, axis, keepDims).To(output) # Example 1. Input in operand 0, input0 = {i1: # input 0 [2.0, 1.0, 3.0, 4.0]} output0 = {output: # output 0 [1.0, 3.0]} # Instantiate an example Example((input0, output0))
model = model() i1 = input('input', 'TENSOR_FLOAT32', '{1, 2, 2, 1}') axis = parameter('axis', 'TENSOR_INT32', '{1}', [2]) keep_dims = False output = output('output', 'TENSOR_FLOAT32', '{1, 2, 1}') model = model.Operation('REDUCE_MIN', i1, axis, keepDims).To(output) input0 = {i1: [2.0, 1.0, 3.0, 4.0]} output0 = {output: [1.0, 3.0]} example((input0, output0))
# https://leetcode.com/problems/subrectangle-queries class SubrectangleQueries: def __init__(self, rectangle): self.rectangle = rectangle def updateSubrectangle(self, row1, col1, row2, col2, newValue): for row in range(row1, row2 + 1): for col in range(col1, col2 + 1): self.rectangle[row][col] = newValue def getValue(self, row, col): return self.rectangle[row][col]
class Subrectanglequeries: def __init__(self, rectangle): self.rectangle = rectangle def update_subrectangle(self, row1, col1, row2, col2, newValue): for row in range(row1, row2 + 1): for col in range(col1, col2 + 1): self.rectangle[row][col] = newValue def get_value(self, row, col): return self.rectangle[row][col]
entries = [ { "env-title": "atari-alien", "env-variant": "No-op start", "score": 6482.10, }, { "env-title": "atari-amidar", "env-variant": "No-op start", "score": 833, }, { "env-title": "atari-assault", "env-variant": "No-op start", "score": 11013.50, }, { "env-title": "atari-asterix", "env-variant": "No-op start", "score": 36238.50, }, { "env-title": "atari-asteroids", "env-variant": "No-op start", "score": 2780.40, }, { "env-title": "atari-atlantis", "env-variant": "No-op start", "score": 308258, }, { "env-title": "atari-bank-heist", "env-variant": "No-op start", "score": 988.70, }, { "env-title": "atari-battle-zone", "env-variant": "No-op start", "score": 61220, }, { "env-title": "atari-beam-rider", "env-variant": "No-op start", "score": 8566.50, }, { "env-title": "atari-berzerk", "env-variant": "No-op start", "score": 1641.40, }, { "env-title": "atari-bowling", "env-variant": "No-op start", "score": 75.40, }, { "env-title": "atari-boxing", "env-variant": "No-op start", "score": 99.40, }, { "env-title": "atari-breakout", "env-variant": "No-op start", "score": 518.40, }, { "env-title": "atari-centipede", "env-variant": "No-op start", "score": 3402.80, }, { "env-title": "atari-chopper-command", "env-variant": "No-op start", "score": 37568, }, { "env-title": "atari-crazy-climber", "env-variant": "No-op start", "score": 194347, }, { "env-title": "atari-defender", "env-variant": "No-op start", "score": 113128, }, { "env-title": "atari-demon-attack", "env-variant": "No-op start", "score": 100189, }, { "env-title": "atari-double-dunk", "env-variant": "No-op start", "score": 11.40, }, { "env-title": "atari-enduro", "env-variant": "No-op start", "score": 2230.10, }, { "env-title": "atari-fishing-derby", "env-variant": "No-op start", "score": 23.20, }, { "env-title": "atari-freeway", "env-variant": "No-op start", "score": 31.40, }, { "env-title": "atari-frostbite", "env-variant": "No-op start", "score": 8042.10, }, { "env-title": "atari-gopher", "env-variant": "No-op start", "score": 69135.10, }, { "env-title": "atari-gravitar", "env-variant": "No-op start", "score": 1073.80, }, { "env-title": "atari-hero", "env-variant": "No-op start", "score": 35542.20, }, { "env-title": "atari-ice-hockey", "env-variant": "No-op start", "score": 3.40, }, { "env-title": "atari-jamesbond", "env-variant": "No-op start", "score": 7869.20, }, { "env-title": "atari-kangaroo", "env-variant": "No-op start", "score": 10484.50, }, { "env-title": "atari-krull", "env-variant": "No-op start", "score": 9930.80, }, { "env-title": "atari-kung-fu-master", "env-variant": "No-op start", "score": 59799.50, }, { "env-title": "atari-montezuma-revenge", "env-variant": "No-op start", "score": 2643.50, }, { "env-title": "atari-ms-pacman", "env-variant": "No-op start", "score": 2724.30, }, { "env-title": "atari-name-this-game", "env-variant": "No-op start", "score": 9907.20, }, { "env-title": "atari-phoenix", "env-variant": "No-op start", "score": 40092.20, }, { "env-title": "atari-pitfall", "env-variant": "No-op start", "score": -3.50, }, { "env-title": "atari-pong", "env-variant": "No-op start", "score": 20.70, }, { "env-title": "atari-private-eye", "env-variant": "No-op start", "score": 15177.10, }, { "env-title": "atari-qbert", "env-variant": "No-op start", "score": 22956.50, }, { "env-title": "atari-riverraid", "env-variant": "No-op start", "score": 16608.30, }, { "env-title": "atari-road-runner", "env-variant": "No-op start", "score": 71168, }, { "env-title": "atari-robotank", "env-variant": "No-op start", "score": 68.50, }, { "env-title": "atari-seaquest", "env-variant": "No-op start", "score": 8425.80, }, { "env-title": "atari-skiing", "env-variant": "No-op start", "score": -10753.40, }, { "env-title": "atari-solaris", "env-variant": "No-op start", "score": 2760, }, { "env-title": "atari-space-invaders", "env-variant": "No-op start", "score": 2448.60, }, { "env-title": "atari-star-gunner", "env-variant": "No-op start", "score": 70038, }, { "env-title": "atari-surround", "env-variant": "No-op start", "score": 6.70, }, { "env-title": "atari-tennis", "env-variant": "No-op start", "score": 23.30, }, { "env-title": "atari-time-pilot", "env-variant": "No-op start", "score": 19401, }, { "env-title": "atari-tutankham", "env-variant": "No-op start", "score": 272.60, }, { "env-title": "atari-up-n-down", "env-variant": "No-op start", "score": 64354.20, }, { "env-title": "atari-venture", "env-variant": "No-op start", "score": 1597.50, }, { "env-title": "atari-video-pinball", "env-variant": "No-op start", "score": 469366, }, { "env-title": "atari-wizard-of-wor", "env-variant": "No-op start", "score": 13170.50, }, { "env-title": "atari-yars-revenge", "env-variant": "No-op start", "score": 102760, }, { "env-title": "atari-zaxxon", "env-variant": "No-op start", "score": 25215.50, }, ]
entries = [{'env-title': 'atari-alien', 'env-variant': 'No-op start', 'score': 6482.1}, {'env-title': 'atari-amidar', 'env-variant': 'No-op start', 'score': 833}, {'env-title': 'atari-assault', 'env-variant': 'No-op start', 'score': 11013.5}, {'env-title': 'atari-asterix', 'env-variant': 'No-op start', 'score': 36238.5}, {'env-title': 'atari-asteroids', 'env-variant': 'No-op start', 'score': 2780.4}, {'env-title': 'atari-atlantis', 'env-variant': 'No-op start', 'score': 308258}, {'env-title': 'atari-bank-heist', 'env-variant': 'No-op start', 'score': 988.7}, {'env-title': 'atari-battle-zone', 'env-variant': 'No-op start', 'score': 61220}, {'env-title': 'atari-beam-rider', 'env-variant': 'No-op start', 'score': 8566.5}, {'env-title': 'atari-berzerk', 'env-variant': 'No-op start', 'score': 1641.4}, {'env-title': 'atari-bowling', 'env-variant': 'No-op start', 'score': 75.4}, {'env-title': 'atari-boxing', 'env-variant': 'No-op start', 'score': 99.4}, {'env-title': 'atari-breakout', 'env-variant': 'No-op start', 'score': 518.4}, {'env-title': 'atari-centipede', 'env-variant': 'No-op start', 'score': 3402.8}, {'env-title': 'atari-chopper-command', 'env-variant': 'No-op start', 'score': 37568}, {'env-title': 'atari-crazy-climber', 'env-variant': 'No-op start', 'score': 194347}, {'env-title': 'atari-defender', 'env-variant': 'No-op start', 'score': 113128}, {'env-title': 'atari-demon-attack', 'env-variant': 'No-op start', 'score': 100189}, {'env-title': 'atari-double-dunk', 'env-variant': 'No-op start', 'score': 11.4}, {'env-title': 'atari-enduro', 'env-variant': 'No-op start', 'score': 2230.1}, {'env-title': 'atari-fishing-derby', 'env-variant': 'No-op start', 'score': 23.2}, {'env-title': 'atari-freeway', 'env-variant': 'No-op start', 'score': 31.4}, {'env-title': 'atari-frostbite', 'env-variant': 'No-op start', 'score': 8042.1}, {'env-title': 'atari-gopher', 'env-variant': 'No-op start', 'score': 69135.1}, {'env-title': 'atari-gravitar', 'env-variant': 'No-op start', 'score': 1073.8}, {'env-title': 'atari-hero', 'env-variant': 'No-op start', 'score': 35542.2}, {'env-title': 'atari-ice-hockey', 'env-variant': 'No-op start', 'score': 3.4}, {'env-title': 'atari-jamesbond', 'env-variant': 'No-op start', 'score': 7869.2}, {'env-title': 'atari-kangaroo', 'env-variant': 'No-op start', 'score': 10484.5}, {'env-title': 'atari-krull', 'env-variant': 'No-op start', 'score': 9930.8}, {'env-title': 'atari-kung-fu-master', 'env-variant': 'No-op start', 'score': 59799.5}, {'env-title': 'atari-montezuma-revenge', 'env-variant': 'No-op start', 'score': 2643.5}, {'env-title': 'atari-ms-pacman', 'env-variant': 'No-op start', 'score': 2724.3}, {'env-title': 'atari-name-this-game', 'env-variant': 'No-op start', 'score': 9907.2}, {'env-title': 'atari-phoenix', 'env-variant': 'No-op start', 'score': 40092.2}, {'env-title': 'atari-pitfall', 'env-variant': 'No-op start', 'score': -3.5}, {'env-title': 'atari-pong', 'env-variant': 'No-op start', 'score': 20.7}, {'env-title': 'atari-private-eye', 'env-variant': 'No-op start', 'score': 15177.1}, {'env-title': 'atari-qbert', 'env-variant': 'No-op start', 'score': 22956.5}, {'env-title': 'atari-riverraid', 'env-variant': 'No-op start', 'score': 16608.3}, {'env-title': 'atari-road-runner', 'env-variant': 'No-op start', 'score': 71168}, {'env-title': 'atari-robotank', 'env-variant': 'No-op start', 'score': 68.5}, {'env-title': 'atari-seaquest', 'env-variant': 'No-op start', 'score': 8425.8}, {'env-title': 'atari-skiing', 'env-variant': 'No-op start', 'score': -10753.4}, {'env-title': 'atari-solaris', 'env-variant': 'No-op start', 'score': 2760}, {'env-title': 'atari-space-invaders', 'env-variant': 'No-op start', 'score': 2448.6}, {'env-title': 'atari-star-gunner', 'env-variant': 'No-op start', 'score': 70038}, {'env-title': 'atari-surround', 'env-variant': 'No-op start', 'score': 6.7}, {'env-title': 'atari-tennis', 'env-variant': 'No-op start', 'score': 23.3}, {'env-title': 'atari-time-pilot', 'env-variant': 'No-op start', 'score': 19401}, {'env-title': 'atari-tutankham', 'env-variant': 'No-op start', 'score': 272.6}, {'env-title': 'atari-up-n-down', 'env-variant': 'No-op start', 'score': 64354.2}, {'env-title': 'atari-venture', 'env-variant': 'No-op start', 'score': 1597.5}, {'env-title': 'atari-video-pinball', 'env-variant': 'No-op start', 'score': 469366}, {'env-title': 'atari-wizard-of-wor', 'env-variant': 'No-op start', 'score': 13170.5}, {'env-title': 'atari-yars-revenge', 'env-variant': 'No-op start', 'score': 102760}, {'env-title': 'atari-zaxxon', 'env-variant': 'No-op start', 'score': 25215.5}]
class BaseViewTemplate(): def get_template(self): if self.request.user.is_authenticated: template = "core/base.html" else: template = "core/base-nav.html" return template
class Baseviewtemplate: def get_template(self): if self.request.user.is_authenticated: template = 'core/base.html' else: template = 'core/base-nav.html' return template
{ "roadMapId" : "2", "mapIds" : { "1" : { "parameter" : [ "-l" ], "code" : "import json\ndef eventHandler(event, context, callback):\n\tjsonString = json.dumps(event)\n\tprint(jsonString)\n\tif event[\"present\"] == \"person\":\n\t\tprint(\"OK\")\n\telse:\n\t\tprint(\"None\")", "deviceId" : "deviceId1", "serverId" : "serverId1", "brokerId" : "brokerId1" } } }
{'roadMapId': '2', 'mapIds': {'1': {'parameter': ['-l'], 'code': 'import json\ndef eventHandler(event, context, callback):\n\tjsonString = json.dumps(event)\n\tprint(jsonString)\n\tif event["present"] == "person":\n\t\tprint("OK")\n\telse:\n\t\tprint("None")', 'deviceId': 'deviceId1', 'serverId': 'serverId1', 'brokerId': 'brokerId1'}}}
# program to converte API text file to markdown for wiki. all_apis = [] with open("stepspy_api.txt","rt") as fid_api: api = [] line = fid_api.readline().strip() api.append(line) while True: line = fid_api.readline() if len(line)==0: if len(api) != 0: all_apis.append(tuple(api)) break else: line = line.strip() if not line.startswith("API "): api.append(line) else: all_apis.append(tuple(api)) api = [] api.append(line) with open("stepspy_api.md","wt") as fid_md: for api in all_apis: current_cat = "count" for line in api: if line.startswith("API "): #fid_md.write("# "+line+": ") fid_md.write("# ") current_cat = "format" continue if current_cat == "format": api_name = line.strip("Format:").strip() api_name = api_name[:api_name.find("(")] fid_md.write(api_name+"\n") fid_md.write(line+" \n") current_cat = "description" continue if current_cat == "description": fid_md.write(line+" \n") if line.startswith("Args:"): current_cat = "args" continue if current_cat == "args": if not line.startswith("Rets:"): fid_md.write("> "+line+" \n") else: fid_md.write("\n"+line+" \n") current_cat = "rets" continue if current_cat == "rets": if not line.startswith("Example:") and not line.startswith("Tips:"): fid_md.write("> "+line+" \n") else: fid_md.write("\n"+line+" \n") if line.startswith("Tips:"): current_cat = "tips" else: fid_md.write("```python\n") current_cat = "example" continue if current_cat == "tips": if not line.startswith("Example:"): fid_md.write("> "+line+" \n") else: fid_md.write("\n"+line+" \n") fid_md.write("```python\n") current_cat = "example" continue if current_cat == "example": if len(line)!=0: fid_md.write(line+" \n") continue if current_cat == "example": fid_md.write("```\n\n") else: fid_md.write("\n\n")
all_apis = [] with open('stepspy_api.txt', 'rt') as fid_api: api = [] line = fid_api.readline().strip() api.append(line) while True: line = fid_api.readline() if len(line) == 0: if len(api) != 0: all_apis.append(tuple(api)) break else: line = line.strip() if not line.startswith('API '): api.append(line) else: all_apis.append(tuple(api)) api = [] api.append(line) with open('stepspy_api.md', 'wt') as fid_md: for api in all_apis: current_cat = 'count' for line in api: if line.startswith('API '): fid_md.write('# ') current_cat = 'format' continue if current_cat == 'format': api_name = line.strip('Format:').strip() api_name = api_name[:api_name.find('(')] fid_md.write(api_name + '\n') fid_md.write(line + ' \n') current_cat = 'description' continue if current_cat == 'description': fid_md.write(line + ' \n') if line.startswith('Args:'): current_cat = 'args' continue if current_cat == 'args': if not line.startswith('Rets:'): fid_md.write('> ' + line + ' \n') else: fid_md.write('\n' + line + ' \n') current_cat = 'rets' continue if current_cat == 'rets': if not line.startswith('Example:') and (not line.startswith('Tips:')): fid_md.write('> ' + line + ' \n') else: fid_md.write('\n' + line + ' \n') if line.startswith('Tips:'): current_cat = 'tips' else: fid_md.write('```python\n') current_cat = 'example' continue if current_cat == 'tips': if not line.startswith('Example:'): fid_md.write('> ' + line + ' \n') else: fid_md.write('\n' + line + ' \n') fid_md.write('```python\n') current_cat = 'example' continue if current_cat == 'example': if len(line) != 0: fid_md.write(line + ' \n') continue if current_cat == 'example': fid_md.write('```\n\n') else: fid_md.write('\n\n')
type_input = input() symbol = input() def int_type(num): number = int(num) result = number * 2 print(result) def real_type(num): number = float(num) result = number * 1.5 print(f"{result:.2f}") def string_type(text): string = "$" + text + "$" print(string) if type_input == "int": int_type(symbol) elif type_input == "real": real_type(symbol) else: string_type(symbol)
type_input = input() symbol = input() def int_type(num): number = int(num) result = number * 2 print(result) def real_type(num): number = float(num) result = number * 1.5 print(f'{result:.2f}') def string_type(text): string = '$' + text + '$' print(string) if type_input == 'int': int_type(symbol) elif type_input == 'real': real_type(symbol) else: string_type(symbol)
class Wrapper: "Wrapper to disable commit in sqla" def __init__(self, obj): self.obj = obj def __getattr__(self, attr): if attr in ["commit", "rollback"]: return lambda *args, **kwargs: None obj = getattr(self.obj, attr) if attr not in ["cursor", "execute"]: return obj if attr == "cursor": return type(self)(obj) return self.wrapper(obj) def wrapper(self, obj): "Implement if you need to make your customized wrapper" return obj def __call__(self, *args, **kwargs): self.obj = self.obj(*args, **kwargs) return self
class Wrapper: """Wrapper to disable commit in sqla""" def __init__(self, obj): self.obj = obj def __getattr__(self, attr): if attr in ['commit', 'rollback']: return lambda *args, **kwargs: None obj = getattr(self.obj, attr) if attr not in ['cursor', 'execute']: return obj if attr == 'cursor': return type(self)(obj) return self.wrapper(obj) def wrapper(self, obj): """Implement if you need to make your customized wrapper""" return obj def __call__(self, *args, **kwargs): self.obj = self.obj(*args, **kwargs) return self
class Solution: def findAndReplacePattern(self, words: List[str], pattern: str) -> List[str]: result = [] if not words or not pattern: return result for word in words: mapping = {} isMapped = True for i, c in enumerate(word): p = pattern[i] if p in mapping and mapping[p] != c: isMapped = False break mapping[p] = c values = mapping.values() if len(values) != len(set(values)): isMapped = False if isMapped: result.append(word) return result
class Solution: def find_and_replace_pattern(self, words: List[str], pattern: str) -> List[str]: result = [] if not words or not pattern: return result for word in words: mapping = {} is_mapped = True for (i, c) in enumerate(word): p = pattern[i] if p in mapping and mapping[p] != c: is_mapped = False break mapping[p] = c values = mapping.values() if len(values) != len(set(values)): is_mapped = False if isMapped: result.append(word) return result
CONSUMER_KEY = 'WVQrIJcorH11hQoP6mHKvXIZJ' CONSUMER_SECRET = 'Ui3V1dEsa5owJnhu3nLNyqdz2hFf6HmvICPObiShmkzBszKnah' ACCESS_TOKEN = '218405160-0iabe9XqpwAJ4z4BYsaXwH3ydKpFZhnzj5xpHxpI' ACCESS_SECRET = 'PdPNfcgkc5x7TO54cxVjGOjSrqY2jbcaayV46ys9IkLj3'
consumer_key = 'WVQrIJcorH11hQoP6mHKvXIZJ' consumer_secret = 'Ui3V1dEsa5owJnhu3nLNyqdz2hFf6HmvICPObiShmkzBszKnah' access_token = '218405160-0iabe9XqpwAJ4z4BYsaXwH3ydKpFZhnzj5xpHxpI' access_secret = 'PdPNfcgkc5x7TO54cxVjGOjSrqY2jbcaayV46ys9IkLj3'