content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def master_plan(): yield from bps.mvr(giantxy.x,x_range/2) yield from bps.mvr(giantxy.y,y_range/2) for _ in range(6): yield from bps.mvr(giantxy.x,-x_range) yield from bps.mvr(giantxy.y,-1) yield from bps.mvr(giantxy.x,+x_range) yield from bps.mvr(giantxy.y,-1) yield from bps.mvr(giantxy.x,-x_range) yield from bps.mvr(giantxy.y,-1) yield from bps.mvr(giantxy.x,+x_range) yield from bps.mvr(giantxy.x,-x_range/2) yield from bps.mvr(giantxy.y,y_range/2)
def master_plan(): yield from bps.mvr(giantxy.x, x_range / 2) yield from bps.mvr(giantxy.y, y_range / 2) for _ in range(6): yield from bps.mvr(giantxy.x, -x_range) yield from bps.mvr(giantxy.y, -1) yield from bps.mvr(giantxy.x, +x_range) yield from bps.mvr(giantxy.y, -1) yield from bps.mvr(giantxy.x, -x_range) yield from bps.mvr(giantxy.y, -1) yield from bps.mvr(giantxy.x, +x_range) yield from bps.mvr(giantxy.x, -x_range / 2) yield from bps.mvr(giantxy.y, y_range / 2)
number =int(raw_input("enter number:")) word =str(raw_input("enter word:")) if number == 0 or number > 1: print ("%s %ss." % (number,word)) else: print("%s %s." % (number,word)) if word[-3:] == "ife": print( word[:-3] + "ives") elif word[-2:] == "sh": print(word[:-2] + "shes" ) elif word[-2:] == "ch": print(word[:-2] + "ches") elif word[-2:] == "us": print(word[:-2] + "i") elif word[-2:] == "ay": print(word[:-2] + "ays") elif word[-2:] == "oy": print(word[:-2] + "oys") elif word[-2:] == "ey": print(word[:-2] + "eys") elif word[-2:] == "uy": print(word[:-2] + "uys") elif word[-1:] == "y": print(word[:-1] + "ies") else: print(word + "s")
number = int(raw_input('enter number:')) word = str(raw_input('enter word:')) if number == 0 or number > 1: print('%s %ss.' % (number, word)) else: print('%s %s.' % (number, word)) if word[-3:] == 'ife': print(word[:-3] + 'ives') elif word[-2:] == 'sh': print(word[:-2] + 'shes') elif word[-2:] == 'ch': print(word[:-2] + 'ches') elif word[-2:] == 'us': print(word[:-2] + 'i') elif word[-2:] == 'ay': print(word[:-2] + 'ays') elif word[-2:] == 'oy': print(word[:-2] + 'oys') elif word[-2:] == 'ey': print(word[:-2] + 'eys') elif word[-2:] == 'uy': print(word[:-2] + 'uys') elif word[-1:] == 'y': print(word[:-1] + 'ies') else: print(word + 's')
FIELDS_EN = { 'title': lambda **kwargs: ' renamed project from "{from}" to "{to}"'.format(**kwargs), 'short': lambda **kwargs: ' changed short name of project from "{from}" to "{to}"'.format(**kwargs), 'description': lambda **kwargs: ' changed description of project from "{from}" to "{to}"'.format(**kwargs), 'creator': lambda **kwargs: ' changed creator of project from "@{from}" to "@{to}"'.format(**kwargs), 'telegramChannel': lambda **kwargs: ' changed Telegram channel setting from "{from}" to "{to}"'.format(**kwargs), 'slackChannel': lambda **kwargs: ' changed Slack channel setting from "{from}" to "{to}"'.format(**kwargs), }
fields_en = {'title': lambda **kwargs: ' renamed project from "{from}" to "{to}"'.format(**kwargs), 'short': lambda **kwargs: ' changed short name of project from "{from}" to "{to}"'.format(**kwargs), 'description': lambda **kwargs: ' changed description of project from "{from}" to "{to}"'.format(**kwargs), 'creator': lambda **kwargs: ' changed creator of project from "@{from}" to "@{to}"'.format(**kwargs), 'telegramChannel': lambda **kwargs: ' changed Telegram channel setting from "{from}" to "{to}"'.format(**kwargs), 'slackChannel': lambda **kwargs: ' changed Slack channel setting from "{from}" to "{to}"'.format(**kwargs)}
# -*- coding: utf-8 -*- class PeekableGenerator(object): def __init__(self, generator): self.__generator = generator self.__element = None self.__isset = False self.__more = False try: self.__element = generator.next() self.__more = True self.__isset = True except StopIteration: pass def hasMore(self): return self.__more or self.__isset def peek(self): if not self.hasMore(): assert "Shouldn't happen" raise StopIteration return self.__element def next(self): if not self.hasMore(): assert "Shouldn't happen" raise StopIteration self.__more == self.__isset element = self.__element self.__isset = False try: self.__element = self.__generator.next() self.__isset = True except StopIteration: self.__isset = False return element
class Peekablegenerator(object): def __init__(self, generator): self.__generator = generator self.__element = None self.__isset = False self.__more = False try: self.__element = generator.next() self.__more = True self.__isset = True except StopIteration: pass def has_more(self): return self.__more or self.__isset def peek(self): if not self.hasMore(): assert "Shouldn't happen" raise StopIteration return self.__element def next(self): if not self.hasMore(): assert "Shouldn't happen" raise StopIteration self.__more == self.__isset element = self.__element self.__isset = False try: self.__element = self.__generator.next() self.__isset = True except StopIteration: self.__isset = False return element
def get_member_guaranteed(ctx, lookup): if len(ctx.message.mentions) > 0: return ctx.message.mentions[0] if lookup.isdigit(): result = ctx.guild.get_member(int(lookup)) if result: return result if "#" in lookup: result = ctx.guild.get_member_named(lookup) if result: return result for member in ctx.guild.members: if member.display_name.lower() == lookup.lower(): return member return None def get_member_guaranteed_custom_guild(ctx, guild, lookup): if len(ctx.message.mentions) > 0: return ctx.message.mentions[0] if lookup.isdigit(): result = guild.get_member(int(lookup)) if result: return result if "#" in lookup: result = guild.get_member_named(lookup) if result: return result for member in guild.members: if member.display_name.lower() == lookup.lower(): return member return None
def get_member_guaranteed(ctx, lookup): if len(ctx.message.mentions) > 0: return ctx.message.mentions[0] if lookup.isdigit(): result = ctx.guild.get_member(int(lookup)) if result: return result if '#' in lookup: result = ctx.guild.get_member_named(lookup) if result: return result for member in ctx.guild.members: if member.display_name.lower() == lookup.lower(): return member return None def get_member_guaranteed_custom_guild(ctx, guild, lookup): if len(ctx.message.mentions) > 0: return ctx.message.mentions[0] if lookup.isdigit(): result = guild.get_member(int(lookup)) if result: return result if '#' in lookup: result = guild.get_member_named(lookup) if result: return result for member in guild.members: if member.display_name.lower() == lookup.lower(): return member return None
class Solution: def isIsomorphic(self, s: str, t: str) -> bool: if len(s) != len(t): return False s_t_dic = {} t_s_dic = {} n = len(s) for i in range(n): if (s[i] not in s_t_dic) and (t[i] not in t_s_dic): s_t_dic[s[i]] = t[i] t_s_dic[t[i]] = s[i] elif s_t_dic.get(s[i]) != t[i] or t_s_dic.get(t[i]) != s[i]: return False return True s = Solution() print(s.isIsomorphic("egg", "add")) print(s.isIsomorphic("foo", "bar")) print(s.isIsomorphic("paper", "title"))
class Solution: def is_isomorphic(self, s: str, t: str) -> bool: if len(s) != len(t): return False s_t_dic = {} t_s_dic = {} n = len(s) for i in range(n): if s[i] not in s_t_dic and t[i] not in t_s_dic: s_t_dic[s[i]] = t[i] t_s_dic[t[i]] = s[i] elif s_t_dic.get(s[i]) != t[i] or t_s_dic.get(t[i]) != s[i]: return False return True s = solution() print(s.isIsomorphic('egg', 'add')) print(s.isIsomorphic('foo', 'bar')) print(s.isIsomorphic('paper', 'title'))
class RandomListNode(): def __init__(self, x: int): self.label = x self.next = None self.random = None class Solution(): def copy_random_list(self, root: RandomListNode) -> RandomListNode: head = None if root is not None: pointers = {} new_root = RandomListNode(root.label) pointers[id(root)] = new_root head = new_root while (root is not None and (root.next is not None or root.random is not None)): if root.next is not None: if id(root.next) not in pointers: new_root.next = RandomListNode(root.next.label) pointers[id(root.next)] = new_root.next else: new_root.next = pointers[id(root.next)] if root.random is not None: if id(root.random) not in pointers: new_root.random = RandomListNode(root.random.label) pointers[id(root.random)] = new_root.random else: new_root.random = pointers[id(root.random)] root = root.next new_root = new_root.next return head
class Randomlistnode: def __init__(self, x: int): self.label = x self.next = None self.random = None class Solution: def copy_random_list(self, root: RandomListNode) -> RandomListNode: head = None if root is not None: pointers = {} new_root = random_list_node(root.label) pointers[id(root)] = new_root head = new_root while root is not None and (root.next is not None or root.random is not None): if root.next is not None: if id(root.next) not in pointers: new_root.next = random_list_node(root.next.label) pointers[id(root.next)] = new_root.next else: new_root.next = pointers[id(root.next)] if root.random is not None: if id(root.random) not in pointers: new_root.random = random_list_node(root.random.label) pointers[id(root.random)] = new_root.random else: new_root.random = pointers[id(root.random)] root = root.next new_root = new_root.next return head
# Copyright 2016 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # These devices are ina3221 (3-channels/i2c address) devices inas = [('0x40:0', 'pp3300_edp_dx', 3.30, 0.020, 'rem', True), #R367 ('0x40:1', 'pp3300_a', 3.30, 0.002, 'rem', True), #R422 ('0x40:2', 'pp1800_a', 1.80, 0.020, 'rem', True), #R416 # ('0x41:0', 'pp1240_a', 1.24, 0.020, 'rem', True), #R417 ('0x41:1', 'pp1800_dram_u', 1.80, 0.020, 'rem', True), #R403 ('0x41:2', 'pp1050_s', 1.05, 0.010, 'rem', True), #R412 # ('0x42:0', 'pp3300_pd_a', 3.30, 0.100, 'rem', True), #R384 ('0x42:1', 'pp3300_wlan_dx', 3.30, 0.020, 'rem', True), #R389 ('0x42:2', 'pp3300_soc_a', 3.30, 0.020, 'rem', True), #R383 # ('0x43:0', 'pp1100_vddq', 1.10, 0.002, 'rem', True), #R425 ('0x43:1', 'pp3300_ec', 3.30, 2.200, 'rem', True), #R415 ('0x43:2', 'pp5000_a', 5.00, 0.002, 'rem', True), #R421 ]
inas = [('0x40:0', 'pp3300_edp_dx', 3.3, 0.02, 'rem', True), ('0x40:1', 'pp3300_a', 3.3, 0.002, 'rem', True), ('0x40:2', 'pp1800_a', 1.8, 0.02, 'rem', True), ('0x41:0', 'pp1240_a', 1.24, 0.02, 'rem', True), ('0x41:1', 'pp1800_dram_u', 1.8, 0.02, 'rem', True), ('0x41:2', 'pp1050_s', 1.05, 0.01, 'rem', True), ('0x42:0', 'pp3300_pd_a', 3.3, 0.1, 'rem', True), ('0x42:1', 'pp3300_wlan_dx', 3.3, 0.02, 'rem', True), ('0x42:2', 'pp3300_soc_a', 3.3, 0.02, 'rem', True), ('0x43:0', 'pp1100_vddq', 1.1, 0.002, 'rem', True), ('0x43:1', 'pp3300_ec', 3.3, 2.2, 'rem', True), ('0x43:2', 'pp5000_a', 5.0, 0.002, 'rem', True)]
n = int(input()) lst = [] for _ in range(n): a, b = [int(i) for i in input().split()] lst.append((a,b)) lst.sort(key = lambda x: x[1]) index = 0 coordinates = [] while index < n: curr = lst[index] while index < n-1 and curr[1]>=lst[index+1][0]: index += 1 coordinates.append(curr[1]) index += 1 print(len(coordinates)) print(' '.join([str(i) for i in coordinates]))
n = int(input()) lst = [] for _ in range(n): (a, b) = [int(i) for i in input().split()] lst.append((a, b)) lst.sort(key=lambda x: x[1]) index = 0 coordinates = [] while index < n: curr = lst[index] while index < n - 1 and curr[1] >= lst[index + 1][0]: index += 1 coordinates.append(curr[1]) index += 1 print(len(coordinates)) print(' '.join([str(i) for i in coordinates]))
# -*- coding: utf-8 -*- class Solution: def numDifferentIntegers(self, word: str) -> int: result = set() number = None for char in word: if char.isdigit() and number is None: number = int(char) elif char.isdigit() and number is not None: number = 10 * number + int(char) elif number is not None: result.add(number) number = None if number is not None: result.add(number) number = None return len(result) if __name__ == '__main__': solution = Solution() assert 3 == solution.numDifferentIntegers('a123bc34d8ef34') assert 2 == solution.numDifferentIntegers('leet1234code234') assert 1 == solution.numDifferentIntegers('a1b01c001')
class Solution: def num_different_integers(self, word: str) -> int: result = set() number = None for char in word: if char.isdigit() and number is None: number = int(char) elif char.isdigit() and number is not None: number = 10 * number + int(char) elif number is not None: result.add(number) number = None if number is not None: result.add(number) number = None return len(result) if __name__ == '__main__': solution = solution() assert 3 == solution.numDifferentIntegers('a123bc34d8ef34') assert 2 == solution.numDifferentIntegers('leet1234code234') assert 1 == solution.numDifferentIntegers('a1b01c001')
def fibo(n): return n if n <= 1 else (fibo(n-1) + fibo(n-2)) nums = [1,2,3,4,5,6] [fibo(x) for x in nums] # [1, 1, 2 ,3 ,5, 8] [y for x in nums if (y:= fibo(x)) % 2 == 0] # [2, 8]
def fibo(n): return n if n <= 1 else fibo(n - 1) + fibo(n - 2) nums = [1, 2, 3, 4, 5, 6] [fibo(x) for x in nums] [y for x in nums if (y := fibo(x)) % 2 == 0]
BUTTON_LEFT = 0 BUTTON_MIDDLE = 1 BUTTON_RIGHT = 2
button_left = 0 button_middle = 1 button_right = 2
def main(): file_log = open("hostapd.log",'r').read() address = file_log.find("AP-STA-CONNECTED") mac = set() while address >= 0: mac.add(file_log[address+17:address+34]) address=file_log.find("AP-STA-CONNECTED",address+1) for addr in mac: print(addr) # For the sake of not using global variables if __name__ == "__main__": main()
def main(): file_log = open('hostapd.log', 'r').read() address = file_log.find('AP-STA-CONNECTED') mac = set() while address >= 0: mac.add(file_log[address + 17:address + 34]) address = file_log.find('AP-STA-CONNECTED', address + 1) for addr in mac: print(addr) if __name__ == '__main__': main()
COURSE = "Python for Everybody" def which_course_is_this(): print("The course is:", COURSE)
course = 'Python for Everybody' def which_course_is_this(): print('The course is:', COURSE)
DATASOURCE_NAME = "Coderepos" GITHUB_DATASOURCE_NAME = "github"
datasource_name = 'Coderepos' github_datasource_name = 'github'
def readDataIntoMatrix(fileName): f = open(fileName, 'r') i = 0 data = [] for line in f.readlines(): j = 0 row = [] values = line.split() for value in values: row.append(int(value)) j += 1 data.append(row) i += 1 return data
def read_data_into_matrix(fileName): f = open(fileName, 'r') i = 0 data = [] for line in f.readlines(): j = 0 row = [] values = line.split() for value in values: row.append(int(value)) j += 1 data.append(row) i += 1 return data
# -*- coding: UTF-8 -*- logger.info("Loading 2 objects to table invoicing_tariff...") # fields: id, designation, number_of_events, min_asset, max_asset loader.save(create_invoicing_tariff(1,['By presence', 'Pro Anwesenheit', 'By presence'],1,None,None)) loader.save(create_invoicing_tariff(2,['Maximum 10', 'Maximum 10', 'Maximum 10'],1,None,10)) loader.flush_deferred_objects()
logger.info('Loading 2 objects to table invoicing_tariff...') loader.save(create_invoicing_tariff(1, ['By presence', 'Pro Anwesenheit', 'By presence'], 1, None, None)) loader.save(create_invoicing_tariff(2, ['Maximum 10', 'Maximum 10', 'Maximum 10'], 1, None, 10)) loader.flush_deferred_objects()
#!/usr/bin/env python3 # Write a program that computes the GC% of a DNA sequence # Format the output for 2 decimal places # Use all three formatting methods print('Method 1: printf()') seq = 'ACAGAGCCAGCAGATATACAGCAGATACTAT' # feel free to change gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print ('%.2f' % (gc_count / len(seq))) print('-----') print('Method 2: str.format()') gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print ('{:.2f}'.format (gc_count / len(seq))) print('------') print('Method 3: f-strings') gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print (f'{gc_count / len(seq):.2f}') print('------') print('Korfs method') gc_count = 0 for c in seq: if c == 'G' or c == 'C': gc_count += 1 print(f'{gc_count / len(seq):.2f}') ''' 0.42 0.42 0.42 '''
print('Method 1: printf()') seq = 'ACAGAGCCAGCAGATATACAGCAGATACTAT' gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print('%.2f' % (gc_count / len(seq))) print('-----') print('Method 2: str.format()') gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print('{:.2f}'.format(gc_count / len(seq))) print('------') print('Method 3: f-strings') gc_count = 0 for i in range(0, len(seq)): if seq[i] == 'G' or seq[i] == 'C': gc_count += 1 print(f'{gc_count / len(seq):.2f}') print('------') print('Korfs method') gc_count = 0 for c in seq: if c == 'G' or c == 'C': gc_count += 1 print(f'{gc_count / len(seq):.2f}') '\n0.42\n0.42\n0.42\n'
''' solve amazing problem: Given a 2D array of mines, replace the question mark with the number of mines that immediately surround it. This includes the diagonals, meaning it is possible for it to be surrounded by 8 mines maximum. The key is as follows: An empty space: "-" A mine: "#" Number showing number of mines surrounding it: "?" sample: (["-","#","-"], ["-","?","-"], ["-","-","-"]) (["-","#","#"], ["?","#",""], ["#","?","-"]) output: [["-","#","-"], ["-","1","-"], ["-","-","-"]] [["-","#","#"], ["3","#",""], ["#","2","-"]] ''' tupli1 = (["-","#","-"], ["-","?","-"], ["-","-","-"]) tupli2 = (["-","#","-"], ["#","-","?"], ["#","#","-"]) tupli3 = (["-","#","#"], ["?","#",""], ["#","?","-"]) tupli4 = (["-","?","#"], ["?","#","?"], ["#","?","-"]) tupli5 = (["#","?","#"], ["#","#","?"], ["#","?","-"]) tupli6 = (["#","#","#"], ["#","?","#"], ["#","#","#"]) tupli7 = (["#","#","#"], ["#","#","#"], ["#","?","#"]) tupli8 = (["#","#","#"], ["#","#","?"], ["#","#","#"]) print() result = [[],[],[]] count = 0 liicount = [] def solveProblem(tp): global count, liicount for i in tp: if '?' in i: if tp[0][0] == '?': if tp[0][1] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 liicount.append(count) if tp[0][1] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 liicount.append(count) if tp[0][2] == '?': count = 0 if tp[0][1] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 liicount.append(count) # ========================================= 1 if tp[1][0] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][1] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) if tp[1][1] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][1] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][1] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) if tp[1][2] == '?': count = 0 if tp[0][1] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][1] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) # ========================================= 2 if tp[2][0] == '?': count = 0 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) if tp[2][1] == '?': count = 0 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) if tp[2][2] == '?': count = 0 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) def numOfQuest(numq): o = 0 for i in numq: for g in i: if g == '?': o += 1 else: pass return o liicount = [liicount[i] for i in range(numOfQuest(numq=tp))] def replace_questionMark(tup): solveProblem(tup) y = 0 m = 0 for u in tup: for a in u: if a == '?': result[y].append(a.replace('?', str(liicount[m]))) m += 1 else: result[y].append(a) y += 1 return result if __name__ == '__main__': #print(replace_questionMark(tup=tupli1)) #print(replace_questionMark(tup=tupli2)) #print(replace_questionMark(tup=tupli3)) #print(replace_questionMark(tup=tupli4)) #print(replace_questionMark(tup=tupli5)) #print(replace_questionMark(tup=tupli6)) #print(replace_questionMark(tup=tupli7)) print(replace_questionMark(tup=tupli8))
""" solve amazing problem: Given a 2D array of mines, replace the question mark with the number of mines that immediately surround it. This includes the diagonals, meaning it is possible for it to be surrounded by 8 mines maximum. The key is as follows: An empty space: "-" A mine: "#" Number showing number of mines surrounding it: "?" sample: (["-","#","-"], ["-","?","-"], ["-","-","-"]) (["-","#","#"], ["?","#",""], ["#","?","-"]) output: [["-","#","-"], ["-","1","-"], ["-","-","-"]] [["-","#","#"], ["3","#",""], ["#","2","-"]] """ tupli1 = (['-', '#', '-'], ['-', '?', '-'], ['-', '-', '-']) tupli2 = (['-', '#', '-'], ['#', '-', '?'], ['#', '#', '-']) tupli3 = (['-', '#', '#'], ['?', '#', ''], ['#', '?', '-']) tupli4 = (['-', '?', '#'], ['?', '#', '?'], ['#', '?', '-']) tupli5 = (['#', '?', '#'], ['#', '#', '?'], ['#', '?', '-']) tupli6 = (['#', '#', '#'], ['#', '?', '#'], ['#', '#', '#']) tupli7 = (['#', '#', '#'], ['#', '#', '#'], ['#', '?', '#']) tupli8 = (['#', '#', '#'], ['#', '#', '?'], ['#', '#', '#']) print() result = [[], [], []] count = 0 liicount = [] def solve_problem(tp): global count, liicount for i in tp: if '?' in i: if tp[0][0] == '?': if tp[0][1] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 liicount.append(count) if tp[0][1] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 liicount.append(count) if tp[0][2] == '?': count = 0 if tp[0][1] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 liicount.append(count) if tp[1][0] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][1] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) if tp[1][1] == '?': count = 0 if tp[0][0] == '#': count += 1 if tp[0][1] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][0] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][1] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) if tp[1][2] == '?': count = 0 if tp[0][1] == '#': count += 1 if tp[0][2] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][1] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) if tp[2][0] == '?': count = 0 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) if tp[2][1] == '?': count = 0 if tp[1][0] == '#': count += 1 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][0] == '#': count += 1 if tp[2][2] == '#': count += 1 liicount.append(count) if tp[2][2] == '?': count = 0 if tp[1][1] == '#': count += 1 if tp[1][2] == '#': count += 1 if tp[2][1] == '#': count += 1 liicount.append(count) def num_of_quest(numq): o = 0 for i in numq: for g in i: if g == '?': o += 1 else: pass return o liicount = [liicount[i] for i in range(num_of_quest(numq=tp))] def replace_question_mark(tup): solve_problem(tup) y = 0 m = 0 for u in tup: for a in u: if a == '?': result[y].append(a.replace('?', str(liicount[m]))) m += 1 else: result[y].append(a) y += 1 return result if __name__ == '__main__': print(replace_question_mark(tup=tupli8))
#when many condition fullfil use all. subs = 1000 likes = 400 comments = 500 condition = [subs>150,likes>150,comments>50] if all(condition): print('Great Content')
subs = 1000 likes = 400 comments = 500 condition = [subs > 150, likes > 150, comments > 50] if all(condition): print('Great Content')
def write_to(filename:str,text:str): with open(f'{filename}.txt','w') as file1: file1.write(text) write_to('players','zarinaemirbaizak')
def write_to(filename: str, text: str): with open(f'{filename}.txt', 'w') as file1: file1.write(text) write_to('players', 'zarinaemirbaizak')
def main(): # input S = input() N, M = map(int, input().split()) # compute # output print(S[:N-1] + S[M-1] + S[N:M-1] + S[N-1] + S[M:]) if __name__ == '__main__': main()
def main(): s = input() (n, m) = map(int, input().split()) print(S[:N - 1] + S[M - 1] + S[N:M - 1] + S[N - 1] + S[M:]) if __name__ == '__main__': main()
class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a { True } forbids /b { True }''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False # nothing to do if self._state == 3: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a { True } forbids /b { True } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a { (data > 0) } forbids /b { (data < 0) }''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if (msg.data < 0): self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False # nothing to do if self._state == 3: if (msg.data > 0): self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a { (data > 0) } forbids /b { (data < 0) } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if (msg.data < 0): self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.data > 0): self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: if (msg.data > 0): self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: (/a1 { (data > 0) } or /a2 { (data < 0) }) forbids /b { True } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a1': self.on_msg__a1, '/a2': self.on_msg__a2, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.data > 0): self._pool.append(MsgRecord('/a1', stamp, msg)) return True if self._state == 3: if (msg.data > 0): self._pool.append(MsgRecord('/a1', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__a2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.data < 0): self._pool.append(MsgRecord('/a2', stamp, msg)) return True if self._state == 3: if (msg.data < 0): self._pool.append(MsgRecord('/a2', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a { True } forbids (/b1 { (data > 0) } or /b2 { (data < 0) }) within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b2': self.on_msg__b2, '/a': self.on_msg__a, '/b1': self.on_msg__b1, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if (msg.data < 0): self.witness.append(rec) self.witness.append(MsgRecord('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if (msg.data > 0): self.witness.append(rec) self.witness.append(MsgRecord('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''after /p { True }: /a { True } forbids /b { True } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, '/p': self.on_msg__p, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: self.witness.append(MsgRecord('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''after /p { phi }: /a { (data > 0) } forbids /b { (data < 0) } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, '/p': self.on_msg__p, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if (msg.data < 0): self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.data > 0): self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: if (msg.data > 0): self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: if msg.phi: self.witness.append(MsgRecord('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''until /q { True }: /a { phi } forbids /b { psi } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/q': self.on_msg__q, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.psi: self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(MsgRecord('/q', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True if self._state == 3: self._pool.clear() self.witness.append(MsgRecord('/q', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.phi: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: if msg.phi: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''until /b { True }: /a { True } forbids /b { True } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(MsgRecord('/b', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True if self._state == 3: self._pool.clear() self.witness.append(MsgRecord('/b', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''until /a { True }: /a { True } forbids /b { True } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(MsgRecord('/a', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: self._pool.clear() self.witness.append(MsgRecord('/a', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''after /p { phi } until /q { psi }: /a { alpha } forbids /b { beta }''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/a': self.on_msg__a, '/b': self.on_msg__b, '/q': self.on_msg__q, '/p': self.on_msg__p, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False # nothing to do if self._state == 3: if msg.alpha: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.beta: self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 1: if msg.phi: self.witness.append(MsgRecord('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''after /p { phi } until /q { psi }: /a { alpha } forbids /b { beta } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/a': self.on_msg__a, '/b': self.on_msg__b, '/q': self.on_msg__q, '/p': self.on_msg__p, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.alpha: self._pool.append(MsgRecord('/a', stamp, msg)) return True if self._state == 3: if msg.alpha: self._pool.append(MsgRecord('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.beta: self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: if msg.phi: self.witness.append(MsgRecord('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a as A { True } forbids /b { (x < @A.x) }''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_A = rec.msg if (msg.x < v_A.x): self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): # this method is only needed to ensure Python 2.7 compatibility if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i-1].timestamp: try: self._pool.insert(i, rec) # Python >= 3.5 except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a as A { (x > 0) } forbids /b { (x < @A.x) } within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b': self.on_msg__b, '/a': self.on_msg__a, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_A = rec.msg if (msg.x < v_A.x): self.witness.append(rec) self.witness.append(MsgRecord('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.x > 0): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: if (msg.x > 0): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): # this method is only needed to ensure Python 2.7 compatibility if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i-1].timestamp: try: self._pool.insert(i, rec) # Python >= 3.5 except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''globally: /a as A { (x > 0) } forbids (/b1 { (x < @A.x) } or /b2 { (y < @A.y) }) within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b2': self.on_msg__b2, '/a': self.on_msg__a, '/b1': self.on_msg__b1, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_A = rec.msg if (msg.y < v_A.y): self.witness.append(rec) self.witness.append(MsgRecord('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if (msg.x > 0): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: if (msg.x > 0): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_A = rec.msg if (msg.x < v_A.x): self.witness.append(rec) self.witness.append(MsgRecord('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): # this method is only needed to ensure Python 2.7 compatibility if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i-1].timestamp: try: self._pool.insert(i, rec) # Python >= 3.5 except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class PropertyMonitor(object): __slots__ = ( '_lock', # concurrency control '_state', # currently active state '_pool', # MsgRecord deque to hold temporary records 'witness', # MsgRecord list of observed events 'on_enter_scope', # callback upon entering the scope 'on_exit_scope', # callback upon exiting the scope 'on_violation', # callback upon verdict of False 'on_success', # callback upon verdict of True 'time_launch', # when was the monitor launched 'time_shutdown', # when was the monitor shutdown 'time_state', # when did the last state transition occur 'cb_map', # mapping of topic names to callback functions ) PROP_ID = 'None' PROP_TITLE = '''None''' PROP_DESC = '''None''' HPL_PROPERTY = r'''after /p as P { True } until /q { (x > @P.x) }: /a as A { (x = @P.x) } forbids (/b1 { (x < (@A.x + @P.x)) } or /b2 { (x in {@P.x, @A.x}) }) within 0.1s''' def __init__(self): self._lock = Lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = { '/b1': self.on_msg__b1, '/b2': self.on_msg__b2, '/a': self.on_msg__a, '/q': self.on_msg__q, '/p': self.on_msg__p, } @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise RuntimeError('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise RuntimeError('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' assert len(self.witness) >= 1, 'missing activator event' v_P = self.witness[0].msg for rec in self._pool: v_A = rec.msg if (msg.x < (v_A.x + v_P.x)): self.witness.append(rec) self.witness.append(MsgRecord('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' assert len(self.witness) >= 1, 'missing activator event' v_P = self.witness[0].msg for rec in self._pool: v_A = rec.msg if (msg.x in (v_P.x, v_A.x)): self.witness.append(rec) self.witness.append(MsgRecord('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self.witness) >= 1, 'missing activator' v_P = self.witness[0].msg if (msg.x == v_P.x): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: assert len(self.witness) >= 1, 'missing activator' v_P = self.witness[0].msg if (msg.x == v_P.x): rec = MsgRecord('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self.witness) >= 1, 'missing activator event' v_P = self.witness[0].msg if (msg.x > v_P.x): self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: assert len(self.witness) >= 1, 'missing activator event' v_P = self.witness[0].msg if (msg.x > v_P.x): self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and (stamp - self._pool[0].timestamp) >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: self.witness.append(MsgRecord('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): # this method is only needed to ensure Python 2.7 compatibility if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i-1].timestamp: try: self._pool.insert(i, rec) # Python >= 3.5 except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass
class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a { True } forbids /b { True }' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False if self._state == 3: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a { True } forbids /b { True } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a { (data > 0) } forbids /b { (data < 0) }' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.data < 0: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False if self._state == 3: if msg.data > 0: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a { (data > 0) } forbids /b { (data < 0) } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.data < 0: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.data > 0: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: if msg.data > 0: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: (/a1 { (data > 0) } or /a2 { (data < 0) }) forbids /b { True } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a1': self.on_msg__a1, '/a2': self.on_msg__a2} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.data > 0: self._pool.append(msg_record('/a1', stamp, msg)) return True if self._state == 3: if msg.data > 0: self._pool.append(msg_record('/a1', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__a2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.data < 0: self._pool.append(msg_record('/a2', stamp, msg)) return True if self._state == 3: if msg.data < 0: self._pool.append(msg_record('/a2', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a { True } forbids (/b1 { (data > 0) } or /b2 { (data < 0) }) within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b2': self.on_msg__b2, '/a': self.on_msg__a, '/b1': self.on_msg__b1} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.data < 0: self.witness.append(rec) self.witness.append(msg_record('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.data > 0: self.witness.append(rec) self.witness.append(msg_record('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'after /p { True }: /a { True } forbids /b { True } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a, '/p': self.on_msg__p} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: self.witness.append(msg_record('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'after /p { phi }: /a { (data > 0) } forbids /b { (data < 0) } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a, '/p': self.on_msg__p} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.data < 0: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.data > 0: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: if msg.data > 0: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: if msg.phi: self.witness.append(msg_record('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'until /q { True }: /a { phi } forbids /b { psi } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/q': self.on_msg__q, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.psi: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(msg_record('/q', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True if self._state == 3: self._pool.clear() self.witness.append(msg_record('/q', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.phi: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: if msg.phi: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'until /b { True }: /a { True } forbids /b { True } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(msg_record('/b', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True if self._state == 3: self._pool.clear() self.witness.append(msg_record('/b', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'until /a { True }: /a { True } forbids /b { True } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: self._pool.clear() self.witness.append(msg_record('/a', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: self._pool.clear() self.witness.append(msg_record('/a', stamp, msg)) self._state = -1 self.time_state = stamp self.on_exit_scope(stamp) self.on_success(stamp, self.witness) return True self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'after /p { phi } until /q { psi }: /a { alpha } forbids /b { beta }' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/a': self.on_msg__a, '/b': self.on_msg__b, '/q': self.on_msg__q, '/p': self.on_msg__p} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: return False if self._state == 3: if msg.alpha: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.beta: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 1: if msg.phi: self.witness.append(msg_record('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'after /p { phi } until /q { psi }: /a { alpha } forbids /b { beta } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/a': self.on_msg__a, '/b': self.on_msg__b, '/q': self.on_msg__q, '/p': self.on_msg__p} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.alpha: self._pool.append(msg_record('/a', stamp, msg)) return True if self._state == 3: if msg.alpha: self._pool.append(msg_record('/a', stamp, msg)) self._state = 2 self.time_state = stamp return True return False def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' rec = self._pool[0] if msg.beta: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: if msg.psi: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: if msg.phi: self.witness.append(msg_record('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque((), 1) self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a as A { True } forbids /b { (x < @A.x) }' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_a = rec.msg if msg.x < v_A.x: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i - 1].timestamp: try: self._pool.insert(i, rec) except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a as A { (x > 0) } forbids /b { (x < @A.x) } within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b': self.on_msg__b, '/a': self.on_msg__a} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_a = rec.msg if msg.x < v_A.x: self.witness.append(rec) self.witness.append(msg_record('/b', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.x > 0: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: if msg.x > 0: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i - 1].timestamp: try: self._pool.insert(i, rec) except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'globally: /a as A { (x > 0) } forbids (/b1 { (x < @A.x) } or /b2 { (y < @A.y) }) within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b2': self.on_msg__b2, '/a': self.on_msg__a, '/b1': self.on_msg__b1} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_a = rec.msg if msg.y < v_A.y: self.witness.append(rec) self.witness.append(msg_record('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: if msg.x > 0: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: if msg.x > 0: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' for rec in self._pool: v_a = rec.msg if msg.x < v_A.x: self.witness.append(rec) self.witness.append(msg_record('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i - 1].timestamp: try: self._pool.insert(i, rec) except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass class Propertymonitor(object): __slots__ = ('_lock', '_state', '_pool', 'witness', 'on_enter_scope', 'on_exit_scope', 'on_violation', 'on_success', 'time_launch', 'time_shutdown', 'time_state', 'cb_map') prop_id = 'None' prop_title = 'None' prop_desc = 'None' hpl_property = 'after /p as P { True } until /q { (x > @P.x) }: /a as A { (x = @P.x) } forbids (/b1 { (x < (@A.x + @P.x)) } or /b2 { (x in {@P.x, @A.x}) }) within 0.1s' def __init__(self): self._lock = lock() self._reset() self.on_enter_scope = self._noop self.on_exit_scope = self._noop self.on_violation = self._noop self.on_success = self._noop self._state = 0 self.cb_map = {'/b1': self.on_msg__b1, '/b2': self.on_msg__b2, '/a': self.on_msg__a, '/q': self.on_msg__q, '/p': self.on_msg__p} @property def verdict(self): with self._lock: if self._state == -1: return True if self._state == -2: return False return None def on_launch(self, stamp): with self._lock: if self._state != 0: raise runtime_error('monitor is already turned on') self._reset() self.time_launch = stamp self._state = 1 self.time_state = stamp return True def on_shutdown(self, stamp): with self._lock: if self._state == 0: raise runtime_error('monitor is already turned off') self.time_shutdown = stamp self._state = 0 self.time_state = stamp return True def on_timer(self, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp return True def on_msg__b1(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' assert len(self.witness) >= 1, 'missing activator event' v_p = self.witness[0].msg for rec in self._pool: v_a = rec.msg if msg.x < v_A.x + v_P.x: self.witness.append(rec) self.witness.append(msg_record('/b1', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__b2(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' assert len(self.witness) >= 1, 'missing activator event' v_p = self.witness[0].msg for rec in self._pool: v_a = rec.msg if msg.x in (v_P.x, v_A.x): self.witness.append(rec) self.witness.append(msg_record('/b2', stamp, msg)) self._pool.clear() self._state = -2 self.time_state = stamp self.on_violation(stamp, self.witness) return True return False def on_msg__a(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self.witness) >= 1, 'missing activator' v_p = self.witness[0].msg if msg.x == v_P.x: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) return True if self._state == 3: assert len(self.witness) >= 1, 'missing activator' v_p = self.witness[0].msg if msg.x == v_P.x: rec = msg_record('/a', stamp, msg) self._pool_insert(rec) self._state = 2 self.time_state = stamp return True return False def on_msg__q(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 2: assert len(self.witness) >= 1, 'missing activator event' v_p = self.witness[0].msg if msg.x > v_P.x: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True if self._state == 3: assert len(self.witness) >= 1, 'missing activator event' v_p = self.witness[0].msg if msg.x > v_P.x: self._pool.clear() self.witness = [] self._state = 1 self.time_state = stamp self.on_exit_scope(stamp) return True return False def on_msg__p(self, msg, stamp): with self._lock: if self._state == 2: assert len(self._pool) >= 1, 'missing trigger event' while self._pool and stamp - self._pool[0].timestamp >= 0.1: self._pool.popleft() if not self._pool: self._state = 3 self.time_state = stamp if self._state == 1: self.witness.append(msg_record('/p', stamp, msg)) self._state = 3 self.time_state = stamp self.on_enter_scope(stamp) return True return False def _reset(self): self.witness = [] self._pool = deque() self.time_launch = -1 self.time_shutdown = -1 self.time_state = -1 def _pool_insert(self, rec): if not self._pool: return self._pool.append(rec) stamp = rec.timestamp if len(self._pool) == 1: if stamp >= self._pool[0].timestamp: return self._pool.append(rec) return self._pool.appendleft(rec) for i in range(len(self._pool), 0, -1): if stamp >= self._pool[i - 1].timestamp: try: self._pool.insert(i, rec) except AttributeError as e: tmp = [self._pool.pop() for j in range(i, len(self._pool))] self._pool.append(rec) self._pool.extend(reversed(tmp)) break else: self._pool.appendleft(rec) def _noop(self, *args): pass
le = 0 notas = 0 while le != 2: n = float(input()) if 0 <= n <= 10: notas = notas+n le += 1 else: print('nota invalida') print('media = {:.2f}'.format((notas/2)))
le = 0 notas = 0 while le != 2: n = float(input()) if 0 <= n <= 10: notas = notas + n le += 1 else: print('nota invalida') print('media = {:.2f}'.format(notas / 2))
def ipaddr(interface=None): ''' Returns the IP address for a given interface CLI Example:: salt '*' network.ipaddr eth0 ''' iflist = interfaces() out = None if interface: data = iflist.get(interface) or dict() if data.get('inet'): return data.get('inet')[0]['address'] if data.get('inet6'): return data.get('inet6')[0]['address'] return out out = dict() for iface, data in iflist.items(): if data.get('inet'): out[iface] = data.get('inet')[0]['address'] continue if data.get('inet6'): out[iface] = data.get('inet6')[0]['address'] continue return out def netmask(interface): ''' Returns the netmask for a given interface CLI Example:: salt '*' network.netmask eth0 ''' out = list() data = interfaces().get(interface) if data.get('inet'): for addrinfo in data.get('inet'): if addrinfo.get('netmask'): out.append(addrinfo['netmask']) if data.get('inet6'): # TODO: This should return the prefix for the address pass return out or None def hwaddr(interface): ''' Returns the hwaddr for a given interface CLI Example:: salt '*' network.hwaddr eth0 ''' data = interfaces().get(interface) or {} return data.get('hwaddr') def up(interface): ''' Returns True if interface is up, otherwise returns False CLI Example:: salt '*' network.up eth0 ''' data = interfaces().get(interface) or {} return data.get('up')
def ipaddr(interface=None): """ Returns the IP address for a given interface CLI Example:: salt '*' network.ipaddr eth0 """ iflist = interfaces() out = None if interface: data = iflist.get(interface) or dict() if data.get('inet'): return data.get('inet')[0]['address'] if data.get('inet6'): return data.get('inet6')[0]['address'] return out out = dict() for (iface, data) in iflist.items(): if data.get('inet'): out[iface] = data.get('inet')[0]['address'] continue if data.get('inet6'): out[iface] = data.get('inet6')[0]['address'] continue return out def netmask(interface): """ Returns the netmask for a given interface CLI Example:: salt '*' network.netmask eth0 """ out = list() data = interfaces().get(interface) if data.get('inet'): for addrinfo in data.get('inet'): if addrinfo.get('netmask'): out.append(addrinfo['netmask']) if data.get('inet6'): pass return out or None def hwaddr(interface): """ Returns the hwaddr for a given interface CLI Example:: salt '*' network.hwaddr eth0 """ data = interfaces().get(interface) or {} return data.get('hwaddr') def up(interface): """ Returns True if interface is up, otherwise returns False CLI Example:: salt '*' network.up eth0 """ data = interfaces().get(interface) or {} return data.get('up')
def generate(env, **kw): if not kw.get('depsOnly',0): env.Tool('addLibrary', library=['astro'], package = 'astro') if env['PLATFORM'] == 'win32'and env.get('CONTAINERNAME','')=='GlastRelease': env.Tool('findPkgPath', package = 'astro') env.Tool('facilitiesLib') env.Tool('tipLib') env.Tool('addLibrary', library=env['clhepLibs']) env.Tool('addLibrary', library=env['cfitsioLibs']) # EAC, add wcslib and healpix as externals env.Tool('addLibrary', library=env['wcslibs']) env.Tool('addLibrary', library=env['healpixlibs']) def exists(env): return 1
def generate(env, **kw): if not kw.get('depsOnly', 0): env.Tool('addLibrary', library=['astro'], package='astro') if env['PLATFORM'] == 'win32' and env.get('CONTAINERNAME', '') == 'GlastRelease': env.Tool('findPkgPath', package='astro') env.Tool('facilitiesLib') env.Tool('tipLib') env.Tool('addLibrary', library=env['clhepLibs']) env.Tool('addLibrary', library=env['cfitsioLibs']) env.Tool('addLibrary', library=env['wcslibs']) env.Tool('addLibrary', library=env['healpixlibs']) def exists(env): return 1
def cvt(s): if isinstance(s, str): return unicode(s) return s class GWTCanvasImplDefault: def createElement(self): e = DOM.createElement("CANVAS") try: # This results occasionally in an error: # AttributeError: XPCOM component '<unknown>' has no attribute 'MozGetIPCContext' self.setCanvasContext(e.MozGetIPCContext(u'2d')) except AttributeError: # In which case this seems to work: self.setCanvasContext(e.getContext('2d')) return e
def cvt(s): if isinstance(s, str): return unicode(s) return s class Gwtcanvasimpldefault: def create_element(self): e = DOM.createElement('CANVAS') try: self.setCanvasContext(e.MozGetIPCContext(u'2d')) except AttributeError: self.setCanvasContext(e.getContext('2d')) return e
# DSAME prob #40 class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def get_josephus_pos(): q = p = Node() n = int(input("Enter no of players: ")) m = int(input("Enter which player needs to be eliminated each time:")) # create cll containing all players p.data = 1 p.next = Node() for i in range(2, n): p.next = Node() p = p.next p.data = i p.next = q for count in range (n, 1, -1): for i in range(0, m-1): p = p.next p.next = p.next.next print("Last player standing is {}".format(p.data)) if __name__ == '__main__': get_josephus_pos()
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next def get_josephus_pos(): q = p = node() n = int(input('Enter no of players: ')) m = int(input('Enter which player needs to be eliminated each time:')) p.data = 1 p.next = node() for i in range(2, n): p.next = node() p = p.next p.data = i p.next = q for count in range(n, 1, -1): for i in range(0, m - 1): p = p.next p.next = p.next.next print('Last player standing is {}'.format(p.data)) if __name__ == '__main__': get_josephus_pos()
a=float(input()) b=float(input()) if a<b: print(a) else: print(b)
a = float(input()) b = float(input()) if a < b: print(a) else: print(b)
def grammar(): return [ 'progStructure', 'name', 'body', 'instruction', 'moreInstruction', 'functionCall', 'parameter', 'moreParameter', 'parameterType' ] def progStructure(self): self.name() self.match( ('reserved_word', 'INICIO') ) self.body() self.match( ('reserved_word', 'FIN') ) def name(self): self.match( ('reserved_word', 'PROGRAMA') ) self.match( 'id' ) def body(self): self.instruction() self.moreInstruction() def instruction(self): self.functionCall() def moreInstruction(self): if( self.token['type'] == 'function' ): self.body() def functionCall(self): func_call = {} self.logger.info('function') func_call['type'] = self.token['type'] func_call['name'] = self.token['lexeme'] self.match('function') self.match('parentesis_a') func_call['parameters'] = self.parameter() self.match('parentesis_c') self.semantic.analyze(func_call) def parameter(self): parameters = [] parameters.append( self.parameterType() ) if(self.token['type'] == 'coma'): self.match('coma') parameters.extend( self.moreParameter() ) print(parameters) return parameters def moreParameter(self): if( self.token['type'] in ['entero', 'cadena', 'id'] ): return self.parameter() def parameterType(self): value = (self.token['type'], self.token['lexeme']) self.match( ['entero', 'cadena', 'id'] ) return value
def grammar(): return ['progStructure', 'name', 'body', 'instruction', 'moreInstruction', 'functionCall', 'parameter', 'moreParameter', 'parameterType'] def prog_structure(self): self.name() self.match(('reserved_word', 'INICIO')) self.body() self.match(('reserved_word', 'FIN')) def name(self): self.match(('reserved_word', 'PROGRAMA')) self.match('id') def body(self): self.instruction() self.moreInstruction() def instruction(self): self.functionCall() def more_instruction(self): if self.token['type'] == 'function': self.body() def function_call(self): func_call = {} self.logger.info('function') func_call['type'] = self.token['type'] func_call['name'] = self.token['lexeme'] self.match('function') self.match('parentesis_a') func_call['parameters'] = self.parameter() self.match('parentesis_c') self.semantic.analyze(func_call) def parameter(self): parameters = [] parameters.append(self.parameterType()) if self.token['type'] == 'coma': self.match('coma') parameters.extend(self.moreParameter()) print(parameters) return parameters def more_parameter(self): if self.token['type'] in ['entero', 'cadena', 'id']: return self.parameter() def parameter_type(self): value = (self.token['type'], self.token['lexeme']) self.match(['entero', 'cadena', 'id']) return value
n,m=map(int,input().split()) l1=list(map(int,input().split())) minindex=l1.index(min(l1)) l2=list(map(int,input().split())) maxindex=l2.index(max(l2)) for i in range(0,m): print(minindex,i) for j in range(0,minindex): print(j,maxindex) for j in range(minindex+1,n): print(j,maxindex)
(n, m) = map(int, input().split()) l1 = list(map(int, input().split())) minindex = l1.index(min(l1)) l2 = list(map(int, input().split())) maxindex = l2.index(max(l2)) for i in range(0, m): print(minindex, i) for j in range(0, minindex): print(j, maxindex) for j in range(minindex + 1, n): print(j, maxindex)
class TempSensor: __sensor_path = '/sys/bus/w1/devices/28-00000652b8e4/w1_slave' def __init__(self): self.__recent_values = [] def read(self): data = self.__read_sensor_file() temp_value = self.__parse_sensor_data(data) fahrenheit_value = self.__convert_to_fahrenheit(temp_value) self.__recent_values.append(fahrenheit_value) while len(self.__recent_values) > 5: self.__recent_values.pop(0) return sum(self.__recent_values) / float(len(self.__recent_values)) def __read_sensor_file(self): f = open(TempSensor.__sensor_path,'r') contents = f.read() f.close() return contents def __parse_sensor_data(self, data): return int(data.split('t=')[-1])/1000 def __convert_to_fahrenheit(self, celsius): return (celsius * 1.8) + 32
class Tempsensor: __sensor_path = '/sys/bus/w1/devices/28-00000652b8e4/w1_slave' def __init__(self): self.__recent_values = [] def read(self): data = self.__read_sensor_file() temp_value = self.__parse_sensor_data(data) fahrenheit_value = self.__convert_to_fahrenheit(temp_value) self.__recent_values.append(fahrenheit_value) while len(self.__recent_values) > 5: self.__recent_values.pop(0) return sum(self.__recent_values) / float(len(self.__recent_values)) def __read_sensor_file(self): f = open(TempSensor.__sensor_path, 'r') contents = f.read() f.close() return contents def __parse_sensor_data(self, data): return int(data.split('t=')[-1]) / 1000 def __convert_to_fahrenheit(self, celsius): return celsius * 1.8 + 32
#Question 14 power = int(input('Enter power:')) number = 2**power print('Two last digits:', number%100)
power = int(input('Enter power:')) number = 2 ** power print('Two last digits:', number % 100)
def distance(strand_a, strand_b): if len(strand_a) != len(strand_b): raise ValueError('strands are not of equal length') count = 0 for i in range(len(strand_a)): if strand_a[i] != strand_b[i]: count += 1 return count
def distance(strand_a, strand_b): if len(strand_a) != len(strand_b): raise value_error('strands are not of equal length') count = 0 for i in range(len(strand_a)): if strand_a[i] != strand_b[i]: count += 1 return count
# 367. Valid Perfect Square class Solution: # Binary Search def isPerfectSquare(self, num: int) -> bool: if num < 2: return True left, right = 2, num // 2 while left <= right: mid = left + (right - left) // 2 sqr = mid ** 2 if sqr == num: return True elif sqr < num: left = mid + 1 else: right = mid - 1 return False
class Solution: def is_perfect_square(self, num: int) -> bool: if num < 2: return True (left, right) = (2, num // 2) while left <= right: mid = left + (right - left) // 2 sqr = mid ** 2 if sqr == num: return True elif sqr < num: left = mid + 1 else: right = mid - 1 return False
class BuySellEnum: BUY_SELL_UNSET = 0 BUY = 1 SELL = 2
class Buysellenum: buy_sell_unset = 0 buy = 1 sell = 2
STATS = [ { "num_node_expansions": 653, "plan_length": 167, "search_time": 0.49, "total_time": 0.49 }, { "num_node_expansions": 978, "plan_length": 167, "search_time": 0.72, "total_time": 0.72 }, { "num_node_expansions": 1087, "plan_length": 194, "search_time": 17.44, "total_time": 17.44 }, { "num_node_expansions": 923, "plan_length": 198, "search_time": 14.63, "total_time": 14.63 }, { "num_node_expansions": 667, "plan_length": 142, "search_time": 14.3, "total_time": 14.3 }, { "num_node_expansions": 581, "plan_length": 156, "search_time": 13.29, "total_time": 13.29 }, { "num_node_expansions": 505, "plan_length": 134, "search_time": 3.04, "total_time": 3.04 }, { "num_node_expansions": 953, "plan_length": 165, "search_time": 6.84, "total_time": 6.84 }, { "num_node_expansions": 792, "plan_length": 163, "search_time": 0.45, "total_time": 0.45 }, { "num_node_expansions": 554, "plan_length": 160, "search_time": 0.44, "total_time": 0.44 }, { "num_node_expansions": 706, "plan_length": 156, "search_time": 4.71, "total_time": 4.71 }, { "num_node_expansions": 620, "plan_length": 138, "search_time": 3.2, "total_time": 3.2 }, { "num_node_expansions": 661, "plan_length": 169, "search_time": 0.41, "total_time": 0.41 }, { "num_node_expansions": 774, "plan_length": 178, "search_time": 0.66, "total_time": 0.66 }, { "num_node_expansions": 615, "plan_length": 171, "search_time": 0.76, "total_time": 0.76 }, { "num_node_expansions": 516, "plan_length": 134, "search_time": 0.93, "total_time": 0.93 }, { "num_node_expansions": 1077, "plan_length": 221, "search_time": 0.9, "total_time": 0.9 }, { "num_node_expansions": 1029, "plan_length": 213, "search_time": 0.93, "total_time": 0.93 }, { "num_node_expansions": 753, "plan_length": 173, "search_time": 0.71, "total_time": 0.71 }, { "num_node_expansions": 814, "plan_length": 210, "search_time": 0.66, "total_time": 0.66 }, { "num_node_expansions": 569, "plan_length": 134, "search_time": 4.8, "total_time": 4.8 }, { "num_node_expansions": 899, "plan_length": 176, "search_time": 6.19, "total_time": 6.19 }, { "num_node_expansions": 531, "plan_length": 144, "search_time": 3.85, "total_time": 3.85 }, { "num_node_expansions": 631, "plan_length": 164, "search_time": 4.22, "total_time": 4.22 }, { "num_node_expansions": 479, "plan_length": 138, "search_time": 0.11, "total_time": 0.11 }, { "num_node_expansions": 941, "plan_length": 148, "search_time": 0.21, "total_time": 0.21 }, { "num_node_expansions": 1023, "plan_length": 197, "search_time": 9.89, "total_time": 9.89 }, { "num_node_expansions": 1152, "plan_length": 196, "search_time": 12.89, "total_time": 12.89 }, { "num_node_expansions": 629, "plan_length": 147, "search_time": 3.24, "total_time": 3.24 }, { "num_node_expansions": 697, "plan_length": 160, "search_time": 2.33, "total_time": 2.33 }, { "num_node_expansions": 646, "plan_length": 158, "search_time": 3.94, "total_time": 3.94 }, { "num_node_expansions": 741, "plan_length": 152, "search_time": 4.03, "total_time": 4.03 }, { "num_node_expansions": 486, "plan_length": 136, "search_time": 1.99, "total_time": 1.99 }, { "num_node_expansions": 602, "plan_length": 146, "search_time": 3.41, "total_time": 3.41 }, { "num_node_expansions": 774, "plan_length": 186, "search_time": 1.47, "total_time": 1.47 }, { "num_node_expansions": 1512, "plan_length": 209, "search_time": 3.74, "total_time": 3.74 }, { "num_node_expansions": 791, "plan_length": 180, "search_time": 14.14, "total_time": 14.14 }, { "num_node_expansions": 1019, "plan_length": 211, "search_time": 21.35, "total_time": 21.35 }, { "num_node_expansions": 450, "plan_length": 133, "search_time": 1.76, "total_time": 1.76 }, { "num_node_expansions": 526, "plan_length": 135, "search_time": 1.98, "total_time": 1.98 }, { "num_node_expansions": 1329, "plan_length": 182, "search_time": 6.8, "total_time": 6.8 }, { "num_node_expansions": 655, "plan_length": 134, "search_time": 3.31, "total_time": 3.31 }, { "num_node_expansions": 636, "plan_length": 159, "search_time": 5.99, "total_time": 5.99 }, { "num_node_expansions": 1403, "plan_length": 196, "search_time": 13.75, "total_time": 13.75 }, { "num_node_expansions": 664, "plan_length": 175, "search_time": 3.62, "total_time": 3.62 }, { "num_node_expansions": 760, "plan_length": 150, "search_time": 5.2, "total_time": 5.2 }, { "num_node_expansions": 593, "plan_length": 163, "search_time": 8.61, "total_time": 8.61 }, { "num_node_expansions": 1043, "plan_length": 179, "search_time": 16.05, "total_time": 16.05 }, { "num_node_expansions": 390, "plan_length": 103, "search_time": 0.33, "total_time": 0.33 }, { "num_node_expansions": 419, "plan_length": 120, "search_time": 0.35, "total_time": 0.35 }, { "num_node_expansions": 606, "plan_length": 160, "search_time": 15.03, "total_time": 15.03 }, { "num_node_expansions": 525, "plan_length": 146, "search_time": 0.2, "total_time": 0.2 }, { "num_node_expansions": 522, "plan_length": 147, "search_time": 0.22, "total_time": 0.22 }, { "num_node_expansions": 652, "plan_length": 165, "search_time": 10.35, "total_time": 10.35 }, { "num_node_expansions": 1188, "plan_length": 178, "search_time": 13.19, "total_time": 13.19 }, { "num_node_expansions": 450, "plan_length": 136, "search_time": 1.56, "total_time": 1.56 }, { "num_node_expansions": 1179, "plan_length": 209, "search_time": 3.46, "total_time": 3.46 }, { "num_node_expansions": 834, "plan_length": 204, "search_time": 20.33, "total_time": 20.33 }, { "num_node_expansions": 1133, "plan_length": 187, "search_time": 12.76, "total_time": 12.76 }, { "num_node_expansions": 777, "plan_length": 181, "search_time": 8.97, "total_time": 8.97 }, { "num_node_expansions": 591, "plan_length": 136, "search_time": 1.58, "total_time": 1.58 }, { "num_node_expansions": 580, "plan_length": 143, "search_time": 1.56, "total_time": 1.56 }, { "num_node_expansions": 977, "plan_length": 173, "search_time": 5.94, "total_time": 5.94 }, { "num_node_expansions": 694, "plan_length": 167, "search_time": 5.26, "total_time": 5.26 }, { "num_node_expansions": 861, "plan_length": 188, "search_time": 1.15, "total_time": 1.15 }, { "num_node_expansions": 790, "plan_length": 160, "search_time": 0.81, "total_time": 0.81 }, { "num_node_expansions": 841, "plan_length": 188, "search_time": 4.87, "total_time": 4.87 }, { "num_node_expansions": 436, "plan_length": 128, "search_time": 1.77, "total_time": 1.77 }, { "num_node_expansions": 550, "plan_length": 127, "search_time": 0.03, "total_time": 0.03 }, { "num_node_expansions": 434, "plan_length": 134, "search_time": 0.03, "total_time": 0.03 }, { "num_node_expansions": 990, "plan_length": 191, "search_time": 26.16, "total_time": 26.16 }, { "num_node_expansions": 987, "plan_length": 248, "search_time": 27.03, "total_time": 27.03 }, { "num_node_expansions": 958, "plan_length": 195, "search_time": 6.81, "total_time": 6.81 }, { "num_node_expansions": 658, "plan_length": 174, "search_time": 4.83, "total_time": 4.83 }, { "num_node_expansions": 370, "plan_length": 126, "search_time": 0.06, "total_time": 0.06 }, { "num_node_expansions": 440, "plan_length": 119, "search_time": 0.06, "total_time": 0.06 }, { "num_node_expansions": 648, "plan_length": 168, "search_time": 7.05, "total_time": 7.05 }, { "num_node_expansions": 832, "plan_length": 178, "search_time": 9.96, "total_time": 9.96 }, { "num_node_expansions": 355, "plan_length": 116, "search_time": 0.6, "total_time": 0.6 }, { "num_node_expansions": 495, "plan_length": 123, "search_time": 0.73, "total_time": 0.73 }, { "num_node_expansions": 612, "plan_length": 148, "search_time": 2.91, "total_time": 2.91 }, { "num_node_expansions": 1067, "plan_length": 174, "search_time": 4.37, "total_time": 4.37 }, { "num_node_expansions": 821, "plan_length": 185, "search_time": 2.51, "total_time": 2.51 }, { "num_node_expansions": 625, "plan_length": 153, "search_time": 2.22, "total_time": 2.22 }, { "num_node_expansions": 304, "plan_length": 99, "search_time": 0.15, "total_time": 0.15 }, { "num_node_expansions": 477, "plan_length": 133, "search_time": 0.41, "total_time": 0.41 }, { "num_node_expansions": 651, "plan_length": 160, "search_time": 0.19, "total_time": 0.19 }, { "num_node_expansions": 594, "plan_length": 147, "search_time": 0.17, "total_time": 0.17 }, { "num_node_expansions": 524, "plan_length": 134, "search_time": 5.8, "total_time": 5.8 }, { "num_node_expansions": 400, "plan_length": 127, "search_time": 5.23, "total_time": 5.23 }, { "num_node_expansions": 825, "plan_length": 185, "search_time": 5.71, "total_time": 5.71 }, { "num_node_expansions": 613, "plan_length": 156, "search_time": 4.13, "total_time": 4.13 }, { "num_node_expansions": 427, "plan_length": 121, "search_time": 0.08, "total_time": 0.08 }, { "num_node_expansions": 362, "plan_length": 116, "search_time": 0.07, "total_time": 0.07 }, { "num_node_expansions": 459, "plan_length": 119, "search_time": 0.6, "total_time": 0.6 }, { "num_node_expansions": 501, "plan_length": 132, "search_time": 0.72, "total_time": 0.72 }, { "num_node_expansions": 697, "plan_length": 156, "search_time": 2.94, "total_time": 2.94 }, { "num_node_expansions": 1024, "plan_length": 162, "search_time": 6.43, "total_time": 6.43 }, { "num_node_expansions": 501, "plan_length": 122, "search_time": 4.23, "total_time": 4.23 }, { "num_node_expansions": 577, "plan_length": 126, "search_time": 4.8, "total_time": 4.8 }, { "num_node_expansions": 633, "plan_length": 152, "search_time": 15.85, "total_time": 15.85 }, { "num_node_expansions": 833, "plan_length": 186, "search_time": 20.61, "total_time": 20.61 }, { "num_node_expansions": 996, "plan_length": 183, "search_time": 3.53, "total_time": 3.53 }, { "num_node_expansions": 1246, "plan_length": 206, "search_time": 4.34, "total_time": 4.34 }, { "num_node_expansions": 466, "plan_length": 137, "search_time": 1.19, "total_time": 1.19 }, { "num_node_expansions": 530, "plan_length": 142, "search_time": 1.5, "total_time": 1.5 }, { "num_node_expansions": 923, "plan_length": 189, "search_time": 13.9, "total_time": 13.9 }, { "num_node_expansions": 799, "plan_length": 167, "search_time": 11.96, "total_time": 11.96 }, { "num_node_expansions": 651, "plan_length": 173, "search_time": 0.82, "total_time": 0.82 }, { "num_node_expansions": 590, "plan_length": 159, "search_time": 0.56, "total_time": 0.56 }, { "num_node_expansions": 542, "plan_length": 155, "search_time": 0.06, "total_time": 0.06 }, { "num_node_expansions": 418, "plan_length": 130, "search_time": 0.05, "total_time": 0.05 }, { "num_node_expansions": 881, "plan_length": 182, "search_time": 7.23, "total_time": 7.23 }, { "num_node_expansions": 1256, "plan_length": 205, "search_time": 11.35, "total_time": 11.35 }, { "num_node_expansions": 612, "plan_length": 146, "search_time": 1.83, "total_time": 1.83 }, { "num_node_expansions": 567, "plan_length": 145, "search_time": 2.49, "total_time": 2.49 }, { "num_node_expansions": 655, "plan_length": 152, "search_time": 6.73, "total_time": 6.73 }, { "num_node_expansions": 499, "plan_length": 133, "search_time": 4.83, "total_time": 4.83 }, { "num_node_expansions": 500, "plan_length": 137, "search_time": 0.24, "total_time": 0.24 }, { "num_node_expansions": 869, "plan_length": 156, "search_time": 0.35, "total_time": 0.35 }, { "num_node_expansions": 522, "plan_length": 161, "search_time": 0.05, "total_time": 0.05 }, { "num_node_expansions": 712, "plan_length": 181, "search_time": 0.07, "total_time": 0.07 }, { "num_node_expansions": 708, "plan_length": 142, "search_time": 3.52, "total_time": 3.52 }, { "num_node_expansions": 642, "plan_length": 163, "search_time": 3.84, "total_time": 3.84 }, { "num_node_expansions": 426, "plan_length": 134, "search_time": 0.11, "total_time": 0.11 }, { "num_node_expansions": 471, "plan_length": 129, "search_time": 0.12, "total_time": 0.12 }, { "num_node_expansions": 520, "plan_length": 135, "search_time": 1.06, "total_time": 1.06 }, { "num_node_expansions": 666, "plan_length": 144, "search_time": 1.74, "total_time": 1.74 }, { "num_node_expansions": 563, "plan_length": 159, "search_time": 1.27, "total_time": 1.27 }, { "num_node_expansions": 566, "plan_length": 162, "search_time": 1.71, "total_time": 1.71 }, { "num_node_expansions": 1356, "plan_length": 212, "search_time": 24.23, "total_time": 24.23 }, { "num_node_expansions": 836, "plan_length": 203, "search_time": 15.08, "total_time": 15.08 }, { "num_node_expansions": 604, "plan_length": 145, "search_time": 0.9, "total_time": 0.9 }, { "num_node_expansions": 506, "plan_length": 124, "search_time": 0.75, "total_time": 0.75 }, { "num_node_expansions": 851, "plan_length": 203, "search_time": 0.89, "total_time": 0.89 }, { "num_node_expansions": 603, "plan_length": 166, "search_time": 0.67, "total_time": 0.67 }, { "num_node_expansions": 497, "plan_length": 118, "search_time": 0.25, "total_time": 0.25 }, { "num_node_expansions": 590, "plan_length": 117, "search_time": 0.23, "total_time": 0.23 }, { "num_node_expansions": 409, "plan_length": 129, "search_time": 0.07, "total_time": 0.07 }, { "num_node_expansions": 669, "plan_length": 165, "search_time": 0.11, "total_time": 0.11 }, { "num_node_expansions": 786, "plan_length": 161, "search_time": 15.63, "total_time": 15.63 }, { "num_node_expansions": 474, "plan_length": 144, "search_time": 11.44, "total_time": 11.44 }, { "num_node_expansions": 579, "plan_length": 165, "search_time": 0.76, "total_time": 0.76 }, { "num_node_expansions": 620, "plan_length": 160, "search_time": 0.71, "total_time": 0.71 }, { "num_node_expansions": 1523, "plan_length": 221, "search_time": 26.01, "total_time": 26.01 }, { "num_node_expansions": 961, "plan_length": 207, "search_time": 15.01, "total_time": 15.01 }, { "num_node_expansions": 444, "plan_length": 127, "search_time": 3.52, "total_time": 3.52 }, { "num_node_expansions": 464, "plan_length": 127, "search_time": 4.44, "total_time": 4.44 }, { "num_node_expansions": 773, "plan_length": 194, "search_time": 0.8, "total_time": 0.8 }, { "num_node_expansions": 676, "plan_length": 161, "search_time": 0.86, "total_time": 0.86 }, { "num_node_expansions": 414, "plan_length": 127, "search_time": 0.43, "total_time": 0.43 }, { "num_node_expansions": 623, "plan_length": 165, "search_time": 0.47, "total_time": 0.47 }, { "num_node_expansions": 703, "plan_length": 163, "search_time": 0.89, "total_time": 0.89 }, { "num_node_expansions": 785, "plan_length": 176, "search_time": 0.99, "total_time": 0.99 }, { "num_node_expansions": 986, "plan_length": 167, "search_time": 13.69, "total_time": 13.69 }, { "num_node_expansions": 955, "plan_length": 205, "search_time": 12.42, "total_time": 12.42 }, { "num_node_expansions": 417, "plan_length": 118, "search_time": 0.05, "total_time": 0.05 }, { "num_node_expansions": 521, "plan_length": 141, "search_time": 0.07, "total_time": 0.07 }, { "num_node_expansions": 815, "plan_length": 182, "search_time": 23.26, "total_time": 23.26 } ] num_timeouts = 13 num_timeouts = 0 num_problems = 172
stats = [{'num_node_expansions': 653, 'plan_length': 167, 'search_time': 0.49, 'total_time': 0.49}, {'num_node_expansions': 978, 'plan_length': 167, 'search_time': 0.72, 'total_time': 0.72}, {'num_node_expansions': 1087, 'plan_length': 194, 'search_time': 17.44, 'total_time': 17.44}, {'num_node_expansions': 923, 'plan_length': 198, 'search_time': 14.63, 'total_time': 14.63}, {'num_node_expansions': 667, 'plan_length': 142, 'search_time': 14.3, 'total_time': 14.3}, {'num_node_expansions': 581, 'plan_length': 156, 'search_time': 13.29, 'total_time': 13.29}, {'num_node_expansions': 505, 'plan_length': 134, 'search_time': 3.04, 'total_time': 3.04}, {'num_node_expansions': 953, 'plan_length': 165, 'search_time': 6.84, 'total_time': 6.84}, {'num_node_expansions': 792, 'plan_length': 163, 'search_time': 0.45, 'total_time': 0.45}, {'num_node_expansions': 554, 'plan_length': 160, 'search_time': 0.44, 'total_time': 0.44}, {'num_node_expansions': 706, 'plan_length': 156, 'search_time': 4.71, 'total_time': 4.71}, {'num_node_expansions': 620, 'plan_length': 138, 'search_time': 3.2, 'total_time': 3.2}, {'num_node_expansions': 661, 'plan_length': 169, 'search_time': 0.41, 'total_time': 0.41}, {'num_node_expansions': 774, 'plan_length': 178, 'search_time': 0.66, 'total_time': 0.66}, {'num_node_expansions': 615, 'plan_length': 171, 'search_time': 0.76, 'total_time': 0.76}, {'num_node_expansions': 516, 'plan_length': 134, 'search_time': 0.93, 'total_time': 0.93}, {'num_node_expansions': 1077, 'plan_length': 221, 'search_time': 0.9, 'total_time': 0.9}, {'num_node_expansions': 1029, 'plan_length': 213, 'search_time': 0.93, 'total_time': 0.93}, {'num_node_expansions': 753, 'plan_length': 173, 'search_time': 0.71, 'total_time': 0.71}, {'num_node_expansions': 814, 'plan_length': 210, 'search_time': 0.66, 'total_time': 0.66}, {'num_node_expansions': 569, 'plan_length': 134, 'search_time': 4.8, 'total_time': 4.8}, {'num_node_expansions': 899, 'plan_length': 176, 'search_time': 6.19, 'total_time': 6.19}, {'num_node_expansions': 531, 'plan_length': 144, 'search_time': 3.85, 'total_time': 3.85}, {'num_node_expansions': 631, 'plan_length': 164, 'search_time': 4.22, 'total_time': 4.22}, {'num_node_expansions': 479, 'plan_length': 138, 'search_time': 0.11, 'total_time': 0.11}, {'num_node_expansions': 941, 'plan_length': 148, 'search_time': 0.21, 'total_time': 0.21}, {'num_node_expansions': 1023, 'plan_length': 197, 'search_time': 9.89, 'total_time': 9.89}, {'num_node_expansions': 1152, 'plan_length': 196, 'search_time': 12.89, 'total_time': 12.89}, {'num_node_expansions': 629, 'plan_length': 147, 'search_time': 3.24, 'total_time': 3.24}, {'num_node_expansions': 697, 'plan_length': 160, 'search_time': 2.33, 'total_time': 2.33}, {'num_node_expansions': 646, 'plan_length': 158, 'search_time': 3.94, 'total_time': 3.94}, {'num_node_expansions': 741, 'plan_length': 152, 'search_time': 4.03, 'total_time': 4.03}, {'num_node_expansions': 486, 'plan_length': 136, 'search_time': 1.99, 'total_time': 1.99}, {'num_node_expansions': 602, 'plan_length': 146, 'search_time': 3.41, 'total_time': 3.41}, {'num_node_expansions': 774, 'plan_length': 186, 'search_time': 1.47, 'total_time': 1.47}, {'num_node_expansions': 1512, 'plan_length': 209, 'search_time': 3.74, 'total_time': 3.74}, {'num_node_expansions': 791, 'plan_length': 180, 'search_time': 14.14, 'total_time': 14.14}, {'num_node_expansions': 1019, 'plan_length': 211, 'search_time': 21.35, 'total_time': 21.35}, {'num_node_expansions': 450, 'plan_length': 133, 'search_time': 1.76, 'total_time': 1.76}, {'num_node_expansions': 526, 'plan_length': 135, 'search_time': 1.98, 'total_time': 1.98}, {'num_node_expansions': 1329, 'plan_length': 182, 'search_time': 6.8, 'total_time': 6.8}, {'num_node_expansions': 655, 'plan_length': 134, 'search_time': 3.31, 'total_time': 3.31}, {'num_node_expansions': 636, 'plan_length': 159, 'search_time': 5.99, 'total_time': 5.99}, {'num_node_expansions': 1403, 'plan_length': 196, 'search_time': 13.75, 'total_time': 13.75}, {'num_node_expansions': 664, 'plan_length': 175, 'search_time': 3.62, 'total_time': 3.62}, {'num_node_expansions': 760, 'plan_length': 150, 'search_time': 5.2, 'total_time': 5.2}, {'num_node_expansions': 593, 'plan_length': 163, 'search_time': 8.61, 'total_time': 8.61}, {'num_node_expansions': 1043, 'plan_length': 179, 'search_time': 16.05, 'total_time': 16.05}, {'num_node_expansions': 390, 'plan_length': 103, 'search_time': 0.33, 'total_time': 0.33}, {'num_node_expansions': 419, 'plan_length': 120, 'search_time': 0.35, 'total_time': 0.35}, {'num_node_expansions': 606, 'plan_length': 160, 'search_time': 15.03, 'total_time': 15.03}, {'num_node_expansions': 525, 'plan_length': 146, 'search_time': 0.2, 'total_time': 0.2}, {'num_node_expansions': 522, 'plan_length': 147, 'search_time': 0.22, 'total_time': 0.22}, {'num_node_expansions': 652, 'plan_length': 165, 'search_time': 10.35, 'total_time': 10.35}, {'num_node_expansions': 1188, 'plan_length': 178, 'search_time': 13.19, 'total_time': 13.19}, {'num_node_expansions': 450, 'plan_length': 136, 'search_time': 1.56, 'total_time': 1.56}, {'num_node_expansions': 1179, 'plan_length': 209, 'search_time': 3.46, 'total_time': 3.46}, {'num_node_expansions': 834, 'plan_length': 204, 'search_time': 20.33, 'total_time': 20.33}, {'num_node_expansions': 1133, 'plan_length': 187, 'search_time': 12.76, 'total_time': 12.76}, {'num_node_expansions': 777, 'plan_length': 181, 'search_time': 8.97, 'total_time': 8.97}, {'num_node_expansions': 591, 'plan_length': 136, 'search_time': 1.58, 'total_time': 1.58}, {'num_node_expansions': 580, 'plan_length': 143, 'search_time': 1.56, 'total_time': 1.56}, {'num_node_expansions': 977, 'plan_length': 173, 'search_time': 5.94, 'total_time': 5.94}, {'num_node_expansions': 694, 'plan_length': 167, 'search_time': 5.26, 'total_time': 5.26}, {'num_node_expansions': 861, 'plan_length': 188, 'search_time': 1.15, 'total_time': 1.15}, {'num_node_expansions': 790, 'plan_length': 160, 'search_time': 0.81, 'total_time': 0.81}, {'num_node_expansions': 841, 'plan_length': 188, 'search_time': 4.87, 'total_time': 4.87}, {'num_node_expansions': 436, 'plan_length': 128, 'search_time': 1.77, 'total_time': 1.77}, {'num_node_expansions': 550, 'plan_length': 127, 'search_time': 0.03, 'total_time': 0.03}, {'num_node_expansions': 434, 'plan_length': 134, 'search_time': 0.03, 'total_time': 0.03}, {'num_node_expansions': 990, 'plan_length': 191, 'search_time': 26.16, 'total_time': 26.16}, {'num_node_expansions': 987, 'plan_length': 248, 'search_time': 27.03, 'total_time': 27.03}, {'num_node_expansions': 958, 'plan_length': 195, 'search_time': 6.81, 'total_time': 6.81}, {'num_node_expansions': 658, 'plan_length': 174, 'search_time': 4.83, 'total_time': 4.83}, {'num_node_expansions': 370, 'plan_length': 126, 'search_time': 0.06, 'total_time': 0.06}, {'num_node_expansions': 440, 'plan_length': 119, 'search_time': 0.06, 'total_time': 0.06}, {'num_node_expansions': 648, 'plan_length': 168, 'search_time': 7.05, 'total_time': 7.05}, {'num_node_expansions': 832, 'plan_length': 178, 'search_time': 9.96, 'total_time': 9.96}, {'num_node_expansions': 355, 'plan_length': 116, 'search_time': 0.6, 'total_time': 0.6}, {'num_node_expansions': 495, 'plan_length': 123, 'search_time': 0.73, 'total_time': 0.73}, {'num_node_expansions': 612, 'plan_length': 148, 'search_time': 2.91, 'total_time': 2.91}, {'num_node_expansions': 1067, 'plan_length': 174, 'search_time': 4.37, 'total_time': 4.37}, {'num_node_expansions': 821, 'plan_length': 185, 'search_time': 2.51, 'total_time': 2.51}, {'num_node_expansions': 625, 'plan_length': 153, 'search_time': 2.22, 'total_time': 2.22}, {'num_node_expansions': 304, 'plan_length': 99, 'search_time': 0.15, 'total_time': 0.15}, {'num_node_expansions': 477, 'plan_length': 133, 'search_time': 0.41, 'total_time': 0.41}, {'num_node_expansions': 651, 'plan_length': 160, 'search_time': 0.19, 'total_time': 0.19}, {'num_node_expansions': 594, 'plan_length': 147, 'search_time': 0.17, 'total_time': 0.17}, {'num_node_expansions': 524, 'plan_length': 134, 'search_time': 5.8, 'total_time': 5.8}, {'num_node_expansions': 400, 'plan_length': 127, 'search_time': 5.23, 'total_time': 5.23}, {'num_node_expansions': 825, 'plan_length': 185, 'search_time': 5.71, 'total_time': 5.71}, {'num_node_expansions': 613, 'plan_length': 156, 'search_time': 4.13, 'total_time': 4.13}, {'num_node_expansions': 427, 'plan_length': 121, 'search_time': 0.08, 'total_time': 0.08}, {'num_node_expansions': 362, 'plan_length': 116, 'search_time': 0.07, 'total_time': 0.07}, {'num_node_expansions': 459, 'plan_length': 119, 'search_time': 0.6, 'total_time': 0.6}, {'num_node_expansions': 501, 'plan_length': 132, 'search_time': 0.72, 'total_time': 0.72}, {'num_node_expansions': 697, 'plan_length': 156, 'search_time': 2.94, 'total_time': 2.94}, {'num_node_expansions': 1024, 'plan_length': 162, 'search_time': 6.43, 'total_time': 6.43}, {'num_node_expansions': 501, 'plan_length': 122, 'search_time': 4.23, 'total_time': 4.23}, {'num_node_expansions': 577, 'plan_length': 126, 'search_time': 4.8, 'total_time': 4.8}, {'num_node_expansions': 633, 'plan_length': 152, 'search_time': 15.85, 'total_time': 15.85}, {'num_node_expansions': 833, 'plan_length': 186, 'search_time': 20.61, 'total_time': 20.61}, {'num_node_expansions': 996, 'plan_length': 183, 'search_time': 3.53, 'total_time': 3.53}, {'num_node_expansions': 1246, 'plan_length': 206, 'search_time': 4.34, 'total_time': 4.34}, {'num_node_expansions': 466, 'plan_length': 137, 'search_time': 1.19, 'total_time': 1.19}, {'num_node_expansions': 530, 'plan_length': 142, 'search_time': 1.5, 'total_time': 1.5}, {'num_node_expansions': 923, 'plan_length': 189, 'search_time': 13.9, 'total_time': 13.9}, {'num_node_expansions': 799, 'plan_length': 167, 'search_time': 11.96, 'total_time': 11.96}, {'num_node_expansions': 651, 'plan_length': 173, 'search_time': 0.82, 'total_time': 0.82}, {'num_node_expansions': 590, 'plan_length': 159, 'search_time': 0.56, 'total_time': 0.56}, {'num_node_expansions': 542, 'plan_length': 155, 'search_time': 0.06, 'total_time': 0.06}, {'num_node_expansions': 418, 'plan_length': 130, 'search_time': 0.05, 'total_time': 0.05}, {'num_node_expansions': 881, 'plan_length': 182, 'search_time': 7.23, 'total_time': 7.23}, {'num_node_expansions': 1256, 'plan_length': 205, 'search_time': 11.35, 'total_time': 11.35}, {'num_node_expansions': 612, 'plan_length': 146, 'search_time': 1.83, 'total_time': 1.83}, {'num_node_expansions': 567, 'plan_length': 145, 'search_time': 2.49, 'total_time': 2.49}, {'num_node_expansions': 655, 'plan_length': 152, 'search_time': 6.73, 'total_time': 6.73}, {'num_node_expansions': 499, 'plan_length': 133, 'search_time': 4.83, 'total_time': 4.83}, {'num_node_expansions': 500, 'plan_length': 137, 'search_time': 0.24, 'total_time': 0.24}, {'num_node_expansions': 869, 'plan_length': 156, 'search_time': 0.35, 'total_time': 0.35}, {'num_node_expansions': 522, 'plan_length': 161, 'search_time': 0.05, 'total_time': 0.05}, {'num_node_expansions': 712, 'plan_length': 181, 'search_time': 0.07, 'total_time': 0.07}, {'num_node_expansions': 708, 'plan_length': 142, 'search_time': 3.52, 'total_time': 3.52}, {'num_node_expansions': 642, 'plan_length': 163, 'search_time': 3.84, 'total_time': 3.84}, {'num_node_expansions': 426, 'plan_length': 134, 'search_time': 0.11, 'total_time': 0.11}, {'num_node_expansions': 471, 'plan_length': 129, 'search_time': 0.12, 'total_time': 0.12}, {'num_node_expansions': 520, 'plan_length': 135, 'search_time': 1.06, 'total_time': 1.06}, {'num_node_expansions': 666, 'plan_length': 144, 'search_time': 1.74, 'total_time': 1.74}, {'num_node_expansions': 563, 'plan_length': 159, 'search_time': 1.27, 'total_time': 1.27}, {'num_node_expansions': 566, 'plan_length': 162, 'search_time': 1.71, 'total_time': 1.71}, {'num_node_expansions': 1356, 'plan_length': 212, 'search_time': 24.23, 'total_time': 24.23}, {'num_node_expansions': 836, 'plan_length': 203, 'search_time': 15.08, 'total_time': 15.08}, {'num_node_expansions': 604, 'plan_length': 145, 'search_time': 0.9, 'total_time': 0.9}, {'num_node_expansions': 506, 'plan_length': 124, 'search_time': 0.75, 'total_time': 0.75}, {'num_node_expansions': 851, 'plan_length': 203, 'search_time': 0.89, 'total_time': 0.89}, {'num_node_expansions': 603, 'plan_length': 166, 'search_time': 0.67, 'total_time': 0.67}, {'num_node_expansions': 497, 'plan_length': 118, 'search_time': 0.25, 'total_time': 0.25}, {'num_node_expansions': 590, 'plan_length': 117, 'search_time': 0.23, 'total_time': 0.23}, {'num_node_expansions': 409, 'plan_length': 129, 'search_time': 0.07, 'total_time': 0.07}, {'num_node_expansions': 669, 'plan_length': 165, 'search_time': 0.11, 'total_time': 0.11}, {'num_node_expansions': 786, 'plan_length': 161, 'search_time': 15.63, 'total_time': 15.63}, {'num_node_expansions': 474, 'plan_length': 144, 'search_time': 11.44, 'total_time': 11.44}, {'num_node_expansions': 579, 'plan_length': 165, 'search_time': 0.76, 'total_time': 0.76}, {'num_node_expansions': 620, 'plan_length': 160, 'search_time': 0.71, 'total_time': 0.71}, {'num_node_expansions': 1523, 'plan_length': 221, 'search_time': 26.01, 'total_time': 26.01}, {'num_node_expansions': 961, 'plan_length': 207, 'search_time': 15.01, 'total_time': 15.01}, {'num_node_expansions': 444, 'plan_length': 127, 'search_time': 3.52, 'total_time': 3.52}, {'num_node_expansions': 464, 'plan_length': 127, 'search_time': 4.44, 'total_time': 4.44}, {'num_node_expansions': 773, 'plan_length': 194, 'search_time': 0.8, 'total_time': 0.8}, {'num_node_expansions': 676, 'plan_length': 161, 'search_time': 0.86, 'total_time': 0.86}, {'num_node_expansions': 414, 'plan_length': 127, 'search_time': 0.43, 'total_time': 0.43}, {'num_node_expansions': 623, 'plan_length': 165, 'search_time': 0.47, 'total_time': 0.47}, {'num_node_expansions': 703, 'plan_length': 163, 'search_time': 0.89, 'total_time': 0.89}, {'num_node_expansions': 785, 'plan_length': 176, 'search_time': 0.99, 'total_time': 0.99}, {'num_node_expansions': 986, 'plan_length': 167, 'search_time': 13.69, 'total_time': 13.69}, {'num_node_expansions': 955, 'plan_length': 205, 'search_time': 12.42, 'total_time': 12.42}, {'num_node_expansions': 417, 'plan_length': 118, 'search_time': 0.05, 'total_time': 0.05}, {'num_node_expansions': 521, 'plan_length': 141, 'search_time': 0.07, 'total_time': 0.07}, {'num_node_expansions': 815, 'plan_length': 182, 'search_time': 23.26, 'total_time': 23.26}] num_timeouts = 13 num_timeouts = 0 num_problems = 172
# List dog_names = ["tom", "sean", "sally", "mark"] print(type(dog_names)) print(dog_names) # Adding Item On Last Position dog_names.append("sam") print(dog_names) # Adding Item On First Position dog_names.insert(0, "bruz") print(dog_names) # Delete Items del(dog_names[0]) print(dog_names) # Length Of List print('Length Of List: ',len(dog_names))
dog_names = ['tom', 'sean', 'sally', 'mark'] print(type(dog_names)) print(dog_names) dog_names.append('sam') print(dog_names) dog_names.insert(0, 'bruz') print(dog_names) del dog_names[0] print(dog_names) print('Length Of List: ', len(dog_names))
class BTNode: def __init__(self, data = -1, left = None, right = None): self.data = data self.left = left self.right = right class BTree: def __init__(self): self.root = None self.found = False def is_empty(self): return self.root is None def build(self, vals): self.root = BTNode(int(vals.pop(0))) queue = [self.root] while len(queue) != 0: node = queue.pop(0) if len(vals) != 0: val = vals.pop(0) if val != "None": node.left = BTNode(int(val)) queue.append(node.left) if len(vals) != 0: val = vals.pop(0) if val != "None": node.right = BTNode(int(val)) queue.append(node.right) def find(self, num): self.dfs(self.root, 0, num) if self.found: print("True") else: print("False") def dfs(self, node, val, num): val += node.data if val == num: self.found = True if node.left: self.dfs(node.left, val, num) if node.right: self.dfs(node.right, val, num) def main(): n = int(input()) s = input().split() tree = BTree() tree.build(s) tree.find(n) main()
class Btnode: def __init__(self, data=-1, left=None, right=None): self.data = data self.left = left self.right = right class Btree: def __init__(self): self.root = None self.found = False def is_empty(self): return self.root is None def build(self, vals): self.root = bt_node(int(vals.pop(0))) queue = [self.root] while len(queue) != 0: node = queue.pop(0) if len(vals) != 0: val = vals.pop(0) if val != 'None': node.left = bt_node(int(val)) queue.append(node.left) if len(vals) != 0: val = vals.pop(0) if val != 'None': node.right = bt_node(int(val)) queue.append(node.right) def find(self, num): self.dfs(self.root, 0, num) if self.found: print('True') else: print('False') def dfs(self, node, val, num): val += node.data if val == num: self.found = True if node.left: self.dfs(node.left, val, num) if node.right: self.dfs(node.right, val, num) def main(): n = int(input()) s = input().split() tree = b_tree() tree.build(s) tree.find(n) main()
# -- Project information ----------------------------------------------------- project = "Test" copyright = "Test" author = "Test" # -- General configuration --------------------------------------------------- master_doc = "index" # -- Options for HTML output ------------------------------------------------- html_theme = "pydata_sphinx_theme"
project = 'Test' copyright = 'Test' author = 'Test' master_doc = 'index' html_theme = 'pydata_sphinx_theme'
# Reads the UA list from the file "ua_list.txt" # Refer this site for list of UAs: https://developers.whatismybrowser.com/useragents/explore/ ua_file = open("ua_list.txt", "r") lines = ua_file.readlines() ua_list = [] for line in lines: line_cleaned = line.replace("\n","").lower() ua_list.append(line_cleaned) ua_list.sort() ua_list = list(dict.fromkeys(ua_list)) ua_list_count = len(ua_list) print(ua_list) print("Identified ",ua_list_count," UAs in the file.") ua_file.close() # Write the sorted list back to the file "ua_list.txt" ua_file_sorted = open("ua_list.txt", "w") for ua in ua_list: ua_line = ua + "\n" ua_file_sorted.write(ua_line) ua_file_sorted.close # Generate Cloudflare configuration in the string "ua_list_cf" # Using Cloudflare case insensitive matching lower() ua_list_cf = "" i = 0 for ua in ua_list: if (i < ua_list_count - 1): cf_single_rule = "(lower(http.user_agent) contains \"" + ua + "\") or " else: cf_single_rule = "(lower(http.user_agent) contains \"" + ua + "\")" ua_list_cf = ua_list_cf + cf_single_rule i += 1 # Write Cloudflare configuration to the file "ua_list_cf.txt" ua_file_cf = open("ua_list_cf.txt", "w") ua_file_cf.write(ua_list_cf) ua_file_cf.close print("Cloudflare firewall rules generated in the file 'ua_list_cf.txt'") # Generate nginx configuration in the string "ua_list_nginx" # Using nginx case insensitive matching ua_list_nginx = "if ($http_user_agent ~* (" i = 0 for ua in ua_list: ua_escaped = ua.replace(" ","\ ") if (i < ua_list_count - 1): nginx_single_rule = ua_escaped + "|" else: nginx_single_rule = ua_escaped i += 1 ua_list_nginx = ua_list_nginx + nginx_single_rule ua_list_nginx = ua_list_nginx + ")) {\n return 403;\n}" # Write nginx configuration to the file "ua_list_nginx.conf" ua_file_nginx = open("ua_list_nginx.conf", "w") ua_file_nginx.write(ua_list_nginx) ua_file_nginx.close print("Nginx file generated in the file 'ua_list_nginx.conf', please insert this into your Nginx configuration within server{} block")
ua_file = open('ua_list.txt', 'r') lines = ua_file.readlines() ua_list = [] for line in lines: line_cleaned = line.replace('\n', '').lower() ua_list.append(line_cleaned) ua_list.sort() ua_list = list(dict.fromkeys(ua_list)) ua_list_count = len(ua_list) print(ua_list) print('Identified ', ua_list_count, ' UAs in the file.') ua_file.close() ua_file_sorted = open('ua_list.txt', 'w') for ua in ua_list: ua_line = ua + '\n' ua_file_sorted.write(ua_line) ua_file_sorted.close ua_list_cf = '' i = 0 for ua in ua_list: if i < ua_list_count - 1: cf_single_rule = '(lower(http.user_agent) contains "' + ua + '") or ' else: cf_single_rule = '(lower(http.user_agent) contains "' + ua + '")' ua_list_cf = ua_list_cf + cf_single_rule i += 1 ua_file_cf = open('ua_list_cf.txt', 'w') ua_file_cf.write(ua_list_cf) ua_file_cf.close print("Cloudflare firewall rules generated in the file 'ua_list_cf.txt'") ua_list_nginx = 'if ($http_user_agent ~* (' i = 0 for ua in ua_list: ua_escaped = ua.replace(' ', '\\ ') if i < ua_list_count - 1: nginx_single_rule = ua_escaped + '|' else: nginx_single_rule = ua_escaped i += 1 ua_list_nginx = ua_list_nginx + nginx_single_rule ua_list_nginx = ua_list_nginx + ')) {\n return 403;\n}' ua_file_nginx = open('ua_list_nginx.conf', 'w') ua_file_nginx.write(ua_list_nginx) ua_file_nginx.close print("Nginx file generated in the file 'ua_list_nginx.conf', please insert this into your Nginx configuration within server{} block")
# greatest of three def greatest(a,b,c): return max(a,b,c) print(greatest(2,4,3))
def greatest(a, b, c): return max(a, b, c) print(greatest(2, 4, 3))
def LCSBackTrack(v, w): v = '-' + v w = '-' + w S = [[0 for i in range(len(w))] for j in range(len(v))] Backtrack = [[0 for i in range(len(w))] for j in range(len(v))] for i in range(1, len(v)): for j in range(1, len(w)): tmp = S[i - 1][j - 1] + (1 if v[i] == w[j] else 0) S[i][j] = max([S[i - 1][j], S[i][j - 1], tmp]) if S[i][j] == S[i - 1][j]: Backtrack[i][j] = 1 elif S[i][j] == S[i][j - 1]: Backtrack[i][j] = 2 else: Backtrack[i][j] = 4 LCS = [] while i > 0 and j > 0: if Backtrack[i][j] == 4: LCS.append(v[i]) i -= 1 j -= 1 elif Backtrack[i][j] == 2: j -= 1 else: i -= 1 return Backtrack # def OutputLCS(Backtrack, V, i, j): # # print(str(i) + ' ' + str(j)) # if i == 0 or j == 0: # return V[i] # if Backtrack[i][j] == 1: # return OutputLCS(Backtrack, V, i - 1, j) # elif Backtrack[i][j] == 2: # return OutputLCS(Backtrack, V, i, j - 1) # else: # return OutputLCS(Backtrack, V, i - 1, j - 1) + V[i] def OutputLCS(Backtrack, V, i, j): LCS = [] while i > 0 and j > 0: if Backtrack[i][j] == 4: LCS.append(V[i]) i -= 1 j -= 1 elif Backtrack[i][j] == 2: j -= 1 else: i -= 1 return LCS if __name__ == "__main__": v = input().rstrip() w = input().rstrip() Backtrack = LCSBackTrack(v, w) i = len(Backtrack) - 1 j = len(Backtrack[0]) - 1 res = OutputLCS(Backtrack, v, i, j) print(''.join(res[::-1]))
def lcs_back_track(v, w): v = '-' + v w = '-' + w s = [[0 for i in range(len(w))] for j in range(len(v))] backtrack = [[0 for i in range(len(w))] for j in range(len(v))] for i in range(1, len(v)): for j in range(1, len(w)): tmp = S[i - 1][j - 1] + (1 if v[i] == w[j] else 0) S[i][j] = max([S[i - 1][j], S[i][j - 1], tmp]) if S[i][j] == S[i - 1][j]: Backtrack[i][j] = 1 elif S[i][j] == S[i][j - 1]: Backtrack[i][j] = 2 else: Backtrack[i][j] = 4 lcs = [] while i > 0 and j > 0: if Backtrack[i][j] == 4: LCS.append(v[i]) i -= 1 j -= 1 elif Backtrack[i][j] == 2: j -= 1 else: i -= 1 return Backtrack def output_lcs(Backtrack, V, i, j): lcs = [] while i > 0 and j > 0: if Backtrack[i][j] == 4: LCS.append(V[i]) i -= 1 j -= 1 elif Backtrack[i][j] == 2: j -= 1 else: i -= 1 return LCS if __name__ == '__main__': v = input().rstrip() w = input().rstrip() backtrack = lcs_back_track(v, w) i = len(Backtrack) - 1 j = len(Backtrack[0]) - 1 res = output_lcs(Backtrack, v, i, j) print(''.join(res[::-1]))
{ "targets": [ { "target_name": "boost-parameter", "type": "none", "include_dirs": [ "1.57.0/parameter-boost-1.57.0/include" ], "all_dependent_settings": { "include_dirs": [ "1.57.0/parameter-boost-1.57.0/include" ] }, "dependencies": [ "../boost-config/boost-config.gyp:*", "../boost-detail/boost-detail.gyp:*", "../boost-optional/boost-optional.gyp:*", "../boost-core/boost-core.gyp:*", "../boost-preprocessor/boost-preprocessor.gyp:*", "../boost-mpl/boost-mpl.gyp:*" #"../boost-python/boost-python.gyp:*" ] }, { "target_name": "boost-parameter_test_deduced", "type": "executable", "test": {}, "sources": [ "1.57.0/parameter-boost-1.57.0/test/deduced.cpp" ], "dependencies": [ "boost-parameter" ], # this disables building the example on iOS "conditions": [ ["OS=='iOS'", { "type": "none" } ] ] }, { "target_name": "boost-parameter_tutorial", "type": "executable", "test": {}, "sources": [ "1.57.0/parameter-boost-1.57.0/test/tutorial.cpp" ], "dependencies": [ "boost-parameter"], # this disables building the example on iOS "conditions": [ ["OS=='iOS'", { "type": "none" } ] ] } ] }
{'targets': [{'target_name': 'boost-parameter', 'type': 'none', 'include_dirs': ['1.57.0/parameter-boost-1.57.0/include'], 'all_dependent_settings': {'include_dirs': ['1.57.0/parameter-boost-1.57.0/include']}, 'dependencies': ['../boost-config/boost-config.gyp:*', '../boost-detail/boost-detail.gyp:*', '../boost-optional/boost-optional.gyp:*', '../boost-core/boost-core.gyp:*', '../boost-preprocessor/boost-preprocessor.gyp:*', '../boost-mpl/boost-mpl.gyp:*']}, {'target_name': 'boost-parameter_test_deduced', 'type': 'executable', 'test': {}, 'sources': ['1.57.0/parameter-boost-1.57.0/test/deduced.cpp'], 'dependencies': ['boost-parameter'], 'conditions': [["OS=='iOS'", {'type': 'none'}]]}, {'target_name': 'boost-parameter_tutorial', 'type': 'executable', 'test': {}, 'sources': ['1.57.0/parameter-boost-1.57.0/test/tutorial.cpp'], 'dependencies': ['boost-parameter'], 'conditions': [["OS=='iOS'", {'type': 'none'}]]}]}
class AbstractBatchifier(object): def filter(self, games): return games def apply(self, games): return games
class Abstractbatchifier(object): def filter(self, games): return games def apply(self, games): return games
#coding:utf-8 ''' filename:clsmethod.py learn class method ''' class Message: msg = 'Python is a smart language.' def get_msg(self): print('self :',self) print('attrs of class(Message.msg):',Message.msg) print('use type(self).msg:',type(self).msg) cls = type(self) print('[cls = type(self)] cls:',cls) print('attrs of class(cls.msg):',cls.msg) @classmethod def get_cls_msg(cls): print('cls :',cls) print('attrs of class(cls.msg):',cls.msg) mess = Message() mess.get_msg() print('-'*50) mess.get_cls_msg()
""" filename:clsmethod.py learn class method """ class Message: msg = 'Python is a smart language.' def get_msg(self): print('self :', self) print('attrs of class(Message.msg):', Message.msg) print('use type(self).msg:', type(self).msg) cls = type(self) print('[cls = type(self)] cls:', cls) print('attrs of class(cls.msg):', cls.msg) @classmethod def get_cls_msg(cls): print('cls :', cls) print('attrs of class(cls.msg):', cls.msg) mess = message() mess.get_msg() print('-' * 50) mess.get_cls_msg()
class Solution: def findNumbers(self, nums: List[int]) -> int: if len(nums) == 0: return 0 return len(list(filter(lambda x:len(str(x))%2==0,nums)))
class Solution: def find_numbers(self, nums: List[int]) -> int: if len(nums) == 0: return 0 return len(list(filter(lambda x: len(str(x)) % 2 == 0, nums)))
# 231 - Power Of Two (Easy) # https://leetcode.com/problems/power-of-two/submissions/ class Solution: def isPowerOfTwo(self, n: int) -> bool: return n and (n & (n-1)) == 0
class Solution: def is_power_of_two(self, n: int) -> bool: return n and n & n - 1 == 0
# Some sites give IR codes in this weird pronto format # Cut off the preamble and footer and find which value represents a 1 in the spacing code = "0000 0016 0000 0016 0000 0016 0000 003F 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 003F 0000 0016 0000 003F 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000" print(int(''.join(list(map(lambda x: "1" if x == '003F' else "0", code.split(' ')[1::2]))), 2))
code = '0000 0016 0000 0016 0000 0016 0000 003F 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 0016 0000 003F 0000 0016 0000 003F 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000 003F 0000 0016 0000 0016 0000 003F 0000 003F 0000 0016 0000' print(int(''.join(list(map(lambda x: '1' if x == '003F' else '0', code.split(' ')[1::2]))), 2))
# ---------------------------------------------------------------------------- # This software is in the public domain, furnished "as is", without technical # support, and with no warranty, express or implied, as to its usefulness for # any purpose. # # iscSendSampleDef # # Author: mathewson # ---------------------------------------------------------------------------- ## # This is an absolute override file, indicating that a higher priority version # of the file will completely replace a lower priority version of the file. ## # The configuration interval file is an optional capability of ifpnetCDF. # It can be used to select certain grids to be placed in the ifpnetCDF # output file, rather than all grids in the inventory. For example, you can # choose to only include 3-hrly temperature grids out to 24 hours, then # 6-hrly temperature grids out to 72 hours, and then no temperature grids # past 72 hours. You can control this capability on a per weather element # basis. The definition determines a set of explicit times. If there # is a grid that contains that explicit time, then the grid is included in # the output. # The configuration interval file is a python file and must reside in the # ifpServer's TEXT/Utility directory. You can create the file through the # use of the GFE, with the GFE->Define Text Products menu, or by using # a conventional text editor and the ifpServerText utility. # This is the default for ifpnetCDF with regard to its use with ISC traffic. # The data is sent from -24h to the future in 1 hour intervals. HR=3600 SampleDef = {} SampleDef['default'] = ( [0*HR], #first tuple is basetimes [ #2nd tuple is list of offset from basetime, interval (-24*HR, 1*HR), #start at basetime, take every hour ])
hr = 3600 sample_def = {} SampleDef['default'] = ([0 * HR], [(-24 * HR, 1 * HR)])
#Write a program (using functions!) that asks the user for a long string containing multiple words. # Print back to the user the same string, except with the words in backwards order. For example, say I type the string: # My name is Michele #Then I would see the string: # Michele is name My #shown back to me. def reverse(strng: str): list = strng.split(' ') list.reverse() return list print(reverse("My name is Michele"))
def reverse(strng: str): list = strng.split(' ') list.reverse() return list print(reverse('My name is Michele'))
def strategy(history, memory): if memory is None or 1 == memory: return 0, 0 else: return 1, 1
def strategy(history, memory): if memory is None or 1 == memory: return (0, 0) else: return (1, 1)
with open("promote.in") as input_file: input_lst = [[*map(int, line.split())] for line in input_file] promotions = [ promotion[1] - promotion[0] for promotion in input_lst ] output = [] for promotion in promotions[::-1]: output.append(sum([])) with open("promote.out", "w") as output_file: for promotion in promotions: print(promotion, file=output_file) # print(input_lst)
with open('promote.in') as input_file: input_lst = [[*map(int, line.split())] for line in input_file] promotions = [promotion[1] - promotion[0] for promotion in input_lst] output = [] for promotion in promotions[::-1]: output.append(sum([])) with open('promote.out', 'w') as output_file: for promotion in promotions: print(promotion, file=output_file)
sample_text = ''' The textwrap module can be used to format text for output in situations where pretty-printing is desired. It offers programmatic functionality similar to the paragraph wrapping or filling features found in many text editors. '''
sample_text = '\n The textwrap module can be used to format text for output in\n situations where pretty-printing is desired. It offers\n programmatic functionality similar to the paragraph wrapping\n or filling features found in many text editors.\n '
# Write your solutions for 1.5 here! class Superheros: def __init__(self, name, superpower, strength): self.name = name self.superpower = superpower self.strength = strength def hero (self): print(self.name) print(self.strength) def save_civilian (self, work): if work > self.strength: print("Superhero is not strong enough! :(") else: self.strength = self.strength - work superman = Superheros("Super Man", "strong", 8) hero(superman) save_civilian(superman, 9) hero(superman)
class Superheros: def __init__(self, name, superpower, strength): self.name = name self.superpower = superpower self.strength = strength def hero(self): print(self.name) print(self.strength) def save_civilian(self, work): if work > self.strength: print('Superhero is not strong enough! :(') else: self.strength = self.strength - work superman = superheros('Super Man', 'strong', 8) hero(superman) save_civilian(superman, 9) hero(superman)
# Copyright (c) 2011 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'targets': [ { 'target_name': 'prefix_header', 'type': 'static_library', 'sources': [ 'file.c', ], 'xcode_settings': { 'GCC_PREFIX_HEADER': 'header.h', }, }, { 'target_name': 'precompiled_prefix_header', 'type': 'shared_library', 'mac_bundle': 1, 'sources': [ 'file.c', ], 'xcode_settings': { 'GCC_PREFIX_HEADER': 'header.h', 'GCC_PRECOMPILE_PREFIX_HEADER': 'YES', }, }, ], }
{'targets': [{'target_name': 'prefix_header', 'type': 'static_library', 'sources': ['file.c'], 'xcode_settings': {'GCC_PREFIX_HEADER': 'header.h'}}, {'target_name': 'precompiled_prefix_header', 'type': 'shared_library', 'mac_bundle': 1, 'sources': ['file.c'], 'xcode_settings': {'GCC_PREFIX_HEADER': 'header.h', 'GCC_PRECOMPILE_PREFIX_HEADER': 'YES'}}]}
#FACTORIAL OF A NUMBER a = input("Enter number1") a=int(a) factorial=1 if a==1: print('Factorial is 1') elif a<1: print('Please enter a valid number') else: for i in range(1, a+1): factorial *= i print(f'The factorial is {factorial}')
a = input('Enter number1') a = int(a) factorial = 1 if a == 1: print('Factorial is 1') elif a < 1: print('Please enter a valid number') else: for i in range(1, a + 1): factorial *= i print(f'The factorial is {factorial}')
# -*- coding: utf-8 -*- class Job: def __init__(self, job_id, name, status, start_date, end_date, source_records, processed_records, price): self.id = job_id self.name = name self.status = status self.start_date = start_date self.end_date = end_date self.source_records = source_records self.processed_records = processed_records self.price = price def __repr__(self): return str(vars(self)) class JobReport: def __new__(cls, *args, **kwargs): if 'code' in kwargs: return None return super().__new__(cls) def __init__(self, quality_issues, quality_names, results): self.quality_issues = quality_issues self.quality_names = quality_names self.results = results def __repr__(self): return str(vars(self)) class JobConfig: def __init__(self, name): self.name = name self._input_format = { "field_separator": ",", "text_delimiter": "\"", "code_page": "utf-8" } self._input_columns = {} self._extend = { "teryt": 0, "gus": 0, "geocode": 0, "building_info": 0, "diagnostic": 0, "area_characteristic": 0 } self._module_std = { "address": 0, "names": 0, "contact": 0, "id_numbers": 0 } self._client = { "name": "", "mode": "" } self._deduplication = { "on": 0, "incremental": 0 } def input_format(self, field_separator=",", text_delimiter="\"", code_page="utf-8"): self._input_format["field_separator"] = field_separator self._input_format["text_delimiter"] = text_delimiter self._input_format["code_page"] = code_page def input_column(self, idx, name, function): self._input_columns[idx] = {"no": idx, "name": name, "function": function} def extend(self, teryt=False, gus=False, geocode=False, building_info=False, diagnostic=False, area_characteristic=False): self._extend["teryt"] = self.__boolean_to_num(teryt) self._extend["gus"] = self.__boolean_to_num(gus) self._extend["geocode"] = self.__boolean_to_num(geocode) self._extend["building_info"] = self.__boolean_to_num(building_info) self._extend["diagnostic"] = self.__boolean_to_num(diagnostic) self._extend["area_characteristic"] = \ self.__boolean_to_num(area_characteristic) def module_std(self, address = False, names = False, contact = False, id_numbers = False): self._module_std["address"] = self.__boolean_to_num(address) self._module_std["names"] = self.__boolean_to_num(names) self._module_std["contact"] = self.__boolean_to_num(contact) self._module_std["id_numbers"] = self.__boolean_to_num(id_numbers) def deduplication(self, on = False, incremental = False): self._deduplication["on"] = self.__boolean_to_num(on) self._deduplication["incremental"] = self.__boolean_to_num(incremental) def client(self, name, mode): self._client["name"] = name self._client["mode"] = mode @staticmethod def __boolean_to_num(value): return 1 if value else 0 def data(self): return { "job_name": self.name, "input_format": self._input_format, "input_columns": list(self._input_columns.values()), "extend": self._extend, "module_std": self._module_std, "deduplication": self._deduplication, "client": self._client }
class Job: def __init__(self, job_id, name, status, start_date, end_date, source_records, processed_records, price): self.id = job_id self.name = name self.status = status self.start_date = start_date self.end_date = end_date self.source_records = source_records self.processed_records = processed_records self.price = price def __repr__(self): return str(vars(self)) class Jobreport: def __new__(cls, *args, **kwargs): if 'code' in kwargs: return None return super().__new__(cls) def __init__(self, quality_issues, quality_names, results): self.quality_issues = quality_issues self.quality_names = quality_names self.results = results def __repr__(self): return str(vars(self)) class Jobconfig: def __init__(self, name): self.name = name self._input_format = {'field_separator': ',', 'text_delimiter': '"', 'code_page': 'utf-8'} self._input_columns = {} self._extend = {'teryt': 0, 'gus': 0, 'geocode': 0, 'building_info': 0, 'diagnostic': 0, 'area_characteristic': 0} self._module_std = {'address': 0, 'names': 0, 'contact': 0, 'id_numbers': 0} self._client = {'name': '', 'mode': ''} self._deduplication = {'on': 0, 'incremental': 0} def input_format(self, field_separator=',', text_delimiter='"', code_page='utf-8'): self._input_format['field_separator'] = field_separator self._input_format['text_delimiter'] = text_delimiter self._input_format['code_page'] = code_page def input_column(self, idx, name, function): self._input_columns[idx] = {'no': idx, 'name': name, 'function': function} def extend(self, teryt=False, gus=False, geocode=False, building_info=False, diagnostic=False, area_characteristic=False): self._extend['teryt'] = self.__boolean_to_num(teryt) self._extend['gus'] = self.__boolean_to_num(gus) self._extend['geocode'] = self.__boolean_to_num(geocode) self._extend['building_info'] = self.__boolean_to_num(building_info) self._extend['diagnostic'] = self.__boolean_to_num(diagnostic) self._extend['area_characteristic'] = self.__boolean_to_num(area_characteristic) def module_std(self, address=False, names=False, contact=False, id_numbers=False): self._module_std['address'] = self.__boolean_to_num(address) self._module_std['names'] = self.__boolean_to_num(names) self._module_std['contact'] = self.__boolean_to_num(contact) self._module_std['id_numbers'] = self.__boolean_to_num(id_numbers) def deduplication(self, on=False, incremental=False): self._deduplication['on'] = self.__boolean_to_num(on) self._deduplication['incremental'] = self.__boolean_to_num(incremental) def client(self, name, mode): self._client['name'] = name self._client['mode'] = mode @staticmethod def __boolean_to_num(value): return 1 if value else 0 def data(self): return {'job_name': self.name, 'input_format': self._input_format, 'input_columns': list(self._input_columns.values()), 'extend': self._extend, 'module_std': self._module_std, 'deduplication': self._deduplication, 'client': self._client}
def median(iterable): items = sorted(iterable) if len(items) == 0: raise ValueError("median() arg is an empty series") median_index = (len(items) - 1) // 2 if len(items) % 2 != 0: return items[median_index] return (items[median_index] + items[median_index + 1]) / 2 print(median([5, 2, 1, 4, 3])) def main(): try: median([]) except ValueError as e: print("Payload", e.args) main()
def median(iterable): items = sorted(iterable) if len(items) == 0: raise value_error('median() arg is an empty series') median_index = (len(items) - 1) // 2 if len(items) % 2 != 0: return items[median_index] return (items[median_index] + items[median_index + 1]) / 2 print(median([5, 2, 1, 4, 3])) def main(): try: median([]) except ValueError as e: print('Payload', e.args) main()
def get(): return int(input()) def get_num(): return get() def get_line(): return get_num() print(get_line())
def get(): return int(input()) def get_num(): return get() def get_line(): return get_num() print(get_line())
# ### Problem 1 # ``` # # Start with this List # list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7] # ``` # Example Input/Output if the user enters the number 9: # ``` # The User entered 9 # 1 2 7 are smaller than 9 # 12 24 34 10 are larger than 9 # ``` # Ask the user to enter a number. userInput = int(input("Enter a number ")) # Using the provided list of numbers, use a for loop to iterate the array and # print out all the values that are smaller than the user input and print out # all the values that are larger than the number entered by the user. list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7] for x in list_of_many_numbers: # print out all the values that are smaller than the user input if (userInput > x): print('the value that is smaller than the user input ', x) # print out all the values that are larger than the number entered by the user if (userInput < x): print('the value that is greater than the user input ', x)
user_input = int(input('Enter a number ')) list_of_many_numbers = [12, 24, 1, 34, 10, 2, 7] for x in list_of_many_numbers: if userInput > x: print('the value that is smaller than the user input ', x) if userInput < x: print('the value that is greater than the user input ', x)
class Scheduler(object): def __init__(self, env, cpu_list=[], task_list=[]): self.env = env self.cpu_list = cpu_list self.task_list = [] self._lock = False self.overhead = 0 def run(self): pass def on_activate(self, job): pass def on_terminated(self, job): pass def schedule(self, cpu): raise NotImplementedError("You need to everride the schedule method!") def add_task(self, task): self.task_list.append(task) def add_processor(self, cpu): self.cpu_list.append(cpu)
class Scheduler(object): def __init__(self, env, cpu_list=[], task_list=[]): self.env = env self.cpu_list = cpu_list self.task_list = [] self._lock = False self.overhead = 0 def run(self): pass def on_activate(self, job): pass def on_terminated(self, job): pass def schedule(self, cpu): raise not_implemented_error('You need to everride the schedule method!') def add_task(self, task): self.task_list.append(task) def add_processor(self, cpu): self.cpu_list.append(cpu)
# test 0 # correct answer # [0] num_topics, num_themes = 1, 1 lst = [0] with open('input.txt', 'w') as f: f.write("{} {}\n".format(num_topics, num_themes)) for l in lst: f.write(str(l) + '\n')
(num_topics, num_themes) = (1, 1) lst = [0] with open('input.txt', 'w') as f: f.write('{} {}\n'.format(num_topics, num_themes)) for l in lst: f.write(str(l) + '\n')
class Stack(): def __init__(self): self.items = [] def push(self, item): return self.items.append(item) def pop(self): return self.items.pop() def IsEmpty(self): return self.items == [] def length(self): return len(self.items) def peek(self): return self.items[len(self.items) - 1] s = Stack() s.IsEmpty() s.push(10) s.length() s.push(20) s.push(30) s.length() s.peek() s.pop() s.IsEmpty() s.pop() s.pop() s.IsEmpty()
class Stack: def __init__(self): self.items = [] def push(self, item): return self.items.append(item) def pop(self): return self.items.pop() def is_empty(self): return self.items == [] def length(self): return len(self.items) def peek(self): return self.items[len(self.items) - 1] s = stack() s.IsEmpty() s.push(10) s.length() s.push(20) s.push(30) s.length() s.peek() s.pop() s.IsEmpty() s.pop() s.pop() s.IsEmpty()
# User input percentage = float(input("Enter your marks: ")) # Program operation & Computer output if (percentage >= 90): print("Your grade is A1 !") elif (percentage >= 80): print("Your grade is A !") elif (percentage >= 70): print("Your grade is B1 !") elif (percentage >= 60): print("Your grade is B !") elif (percentage >= 50): print("Your grade is C, try better next time!") elif (percentage >= 33): print("Your grade is D, try better next time!") else: print("Your grade is E, try better next time!")
percentage = float(input('Enter your marks: ')) if percentage >= 90: print('Your grade is A1 !') elif percentage >= 80: print('Your grade is A !') elif percentage >= 70: print('Your grade is B1 !') elif percentage >= 60: print('Your grade is B !') elif percentage >= 50: print('Your grade is C, try better next time!') elif percentage >= 33: print('Your grade is D, try better next time!') else: print('Your grade is E, try better next time!')
#!/usr/bin/env python # -*- coding:utf-8 -*- def q_s(v): if len(v) <=1: return v left, right = 0, len(v) - 1 item = v[int((left+right))/2] left_value = [i for i in v if i < item] right_value = [i for i in v if i > item] return q_s(left_value) + [item] + q_s(right_value) if __name__ == "__main__": v = [1, 2, 4, 3, 6, 7, 8, 5, 9] q_v = q_s(v) print(q_v)
def q_s(v): if len(v) <= 1: return v (left, right) = (0, len(v) - 1) item = v[int(left + right) / 2] left_value = [i for i in v if i < item] right_value = [i for i in v if i > item] return q_s(left_value) + [item] + q_s(right_value) if __name__ == '__main__': v = [1, 2, 4, 3, 6, 7, 8, 5, 9] q_v = q_s(v) print(q_v)
# # PySNMP MIB module WWP-LEOS-OAM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WWP-LEOS-OAM-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:31:22 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") ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") iso, Counter64, MibIdentifier, TimeTicks, Gauge32, Integer32, ObjectIdentity, ModuleIdentity, Unsigned32, Counter32, NotificationType, IpAddress, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "Counter64", "MibIdentifier", "TimeTicks", "Gauge32", "Integer32", "ObjectIdentity", "ModuleIdentity", "Unsigned32", "Counter32", "NotificationType", "IpAddress", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") DisplayString, TimeStamp, TextualConvention, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TimeStamp", "TextualConvention", "TruthValue") wwpLeosEtherPortOperStatus, wwpLeosEtherPortDesc = mibBuilder.importSymbols("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus", "wwpLeosEtherPortDesc") wwpModulesLeos, = mibBuilder.importSymbols("WWP-SMI", "wwpModulesLeos") wwpLeosOamMibModule = ModuleIdentity((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400)) wwpLeosOamMibModule.setRevisions(('2008-01-03 00:00',)) if mibBuilder.loadTexts: wwpLeosOamMibModule.setLastUpdated('200801030000Z') if mibBuilder.loadTexts: wwpLeosOamMibModule.setOrganization('Ciena, Inc') wwpLeosOamMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1)) wwpLeosOamConf = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1)) wwpLeosOamGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 1)) wwpLeosOamCompls = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 2)) wwpLeosOamObjs = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2)) wwpLeosOamTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1), ) if mibBuilder.loadTexts: wwpLeosOamTable.setStatus('current') wwpLeosOamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamPort")) if mibBuilder.loadTexts: wwpLeosOamEntry.setStatus('current') wwpLeosOamAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("disabled", 1), ("enabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamAdminState.setStatus('current') wwpLeosOamOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=NamedValues(("disabled", 1), ("linkfault", 2), ("passiveWait", 3), ("activeSendLocal", 4), ("sendLocalAndRemote", 5), ("sendLocalAndRemoteOk", 6), ("oamPeeringLocallyRejected", 7), ("oamPeeringRemotelyRejected", 8), ("operational", 9)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamOperStatus.setStatus('current') wwpLeosOamMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("passive", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamMode.setStatus('current') wwpLeosMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 4), Integer32()).setUnits('bytes').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosMaxOamPduSize.setStatus('current') wwpLeosOamConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 5), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamConfigRevision.setStatus('current') wwpLeosOamFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 6), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamFunctionsSupported.setStatus('current') wwpLeosOamPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPort.setStatus('current') wwpLeosOamPduTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 1000))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamPduTimer.setStatus('current') wwpLeosOamLinkLostTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(500, 5000))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamLinkLostTimer.setStatus('current') wwpLeosOamPeerStatusNotifyState = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamPeerStatusNotifyState.setStatus('current') wwpLeosOamPeerTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2), ) if mibBuilder.loadTexts: wwpLeosOamPeerTable.setStatus('current') wwpLeosOamPeerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLocalPort")) if mibBuilder.loadTexts: wwpLeosOamPeerEntry.setStatus('current') wwpLeosOamPeerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerStatus.setStatus('current') wwpLeosOamPeerMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 2), OctetString().subtype(subtypeSpec=ValueSizeConstraint(6, 6)).setFixedLength(6)).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerMacAddress.setStatus('current') wwpLeosOamPeerVendorOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 3), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerVendorOui.setStatus('current') wwpLeosOamPeerVendorInfo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 4), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerVendorInfo.setStatus('current') wwpLeosOamPeerMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("active", 1), ("passive", 2), ("unknown", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerMode.setStatus('current') wwpLeosOamPeerMaxOamPduSize = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 6), Integer32()).setUnits('bytes').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerMaxOamPduSize.setStatus('current') wwpLeosOamPeerConfigRevision = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 7), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerConfigRevision.setStatus('current') wwpLeosOamPeerFunctionsSupported = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 8), Bits().clone(namedValues=NamedValues(("unidirectionalSupport", 0), ("loopbackSupport", 1), ("eventSupport", 2), ("variableSupport", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamPeerFunctionsSupported.setStatus('current') wwpLeosOamLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamLocalPort.setStatus('current') wwpLeosOamLoopbackTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3), ) if mibBuilder.loadTexts: wwpLeosOamLoopbackTable.setStatus('current') wwpLeosOamLoopbackEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamLoopbackPort")) if mibBuilder.loadTexts: wwpLeosOamLoopbackEntry.setStatus('current') wwpLeosOamLoopbackCommand = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("noLoopback", 1), ("startRemoteLoopback", 2), ("stopRemoteLoopback", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamLoopbackCommand.setStatus('current') wwpLeosOamLoopbackStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("noLoopback", 1), ("initiatingLoopback", 2), ("remoteLoopback", 3), ("terminatingLoopback", 4), ("localLoopback", 5), ("unknown", 6)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamLoopbackStatus.setStatus('current') wwpLeosOamLoopbackIgnoreRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ignore", 1), ("process", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamLoopbackIgnoreRx.setStatus('current') wwpLeosOamLoopbackPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamLoopbackPort.setStatus('current') wwpLeosOamStatsTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4), ) if mibBuilder.loadTexts: wwpLeosOamStatsTable.setStatus('current') wwpLeosOamStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamStatsPort")) if mibBuilder.loadTexts: wwpLeosOamStatsEntry.setStatus('current') wwpLeosOamInformationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 1), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamInformationTx.setStatus('current') wwpLeosOamInformationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 2), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamInformationRx.setStatus('current') wwpLeosOamUniqueEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 3), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationTx.setStatus('current') wwpLeosOamUniqueEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 4), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationRx.setStatus('current') wwpLeosOamLoopbackControlTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 5), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamLoopbackControlTx.setStatus('current') wwpLeosOamLoopbackControlRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 6), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamLoopbackControlRx.setStatus('current') wwpLeosOamVariableRequestTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 7), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamVariableRequestTx.setStatus('current') wwpLeosOamVariableRequestRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 8), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamVariableRequestRx.setStatus('current') wwpLeosOamVariableResponseTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 9), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamVariableResponseTx.setStatus('current') wwpLeosOamVariableResponseRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 10), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamVariableResponseRx.setStatus('current') wwpLeosOamOrgSpecificTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 11), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamOrgSpecificTx.setStatus('current') wwpLeosOamOrgSpecificRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 12), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamOrgSpecificRx.setStatus('current') wwpLeosOamUnsupportedCodesTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 13), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesTx.setStatus('current') wwpLeosOamUnsupportedCodesRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 14), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesRx.setStatus('current') wwpLeosOamframesLostDueToOam = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 15), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamframesLostDueToOam.setStatus('current') wwpLeosOamStatsPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamStatsPort.setStatus('current') wwpLeosOamDuplicateEventNotificationTx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 17), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationTx.setStatus('current') wwpLeosOamDuplicateEventNotificationRx = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 18), Counter32()).setUnits('frames').setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationRx.setStatus('current') wwpLeosOamSystemEnableDisable = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamSystemEnableDisable.setStatus('current') wwpLeosOamEventConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6), ) if mibBuilder.loadTexts: wwpLeosOamEventConfigTable.setStatus('current') wwpLeosOamEventConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventPort")) if mibBuilder.loadTexts: wwpLeosOamEventConfigEntry.setStatus('current') wwpLeosOamEventPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventPort.setStatus('current') wwpLeosOamErrFramePeriodWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(14880, 8928000))).setUnits('frames').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodWindow.setStatus('current') wwpLeosOamErrFramePeriodThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodThreshold.setStatus('current') wwpLeosOamErrFramePeriodEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodEvNotifEnable.setStatus('current') wwpLeosOamErrFrameWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(10, 600))).setUnits('tenths of a second').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameWindow.setStatus('current') wwpLeosOamErrFrameThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 6), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967293))).setUnits('frames').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameThreshold.setStatus('current') wwpLeosOamErrFrameEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameEvNotifEnable.setStatus('current') wwpLeosOamErrFrameSecsSummaryWindow = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 9000))).setUnits('tenths of a second').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryWindow.setStatus('current') wwpLeosOamErrFrameSecsSummaryThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('errored frame seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryThreshold.setStatus('current') wwpLeosOamErrFrameSecsEvNotifEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsEvNotifEnable.setStatus('current') wwpLeosOamDyingGaspEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamDyingGaspEnable.setStatus('current') wwpLeosOamCriticalEventEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamCriticalEventEnable.setStatus('current') wwpLeosOamEventLogTable = MibTable((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7), ) if mibBuilder.loadTexts: wwpLeosOamEventLogTable.setStatus('current') wwpLeosOamEventLogEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1), ).setIndexNames((0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), (0, "WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogIndex")) if mibBuilder.loadTexts: wwpLeosOamEventLogEntry.setStatus('current') wwpLeosOamEventLogPort = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogPort.setStatus('current') wwpLeosOamEventLogIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 2), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogIndex.setStatus('current') wwpLeosOamEventLogTimestamp = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 3), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogTimestamp.setStatus('current') wwpLeosOamEventLogOui = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(3, 3)).setFixedLength(3)).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogOui.setStatus('current') wwpLeosOamEventLogType = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 5), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogType.setStatus('current') wwpLeosOamEventLogLocation = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("local", 1), ("remote", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogLocation.setStatus('current') wwpLeosOamEventLogWindowHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 7), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogWindowHi.setStatus('current') wwpLeosOamEventLogWindowLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 8), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogWindowLo.setStatus('current') wwpLeosOamEventLogThresholdHi = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 9), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdHi.setStatus('current') wwpLeosOamEventLogThresholdLo = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 10), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdLo.setStatus('current') wwpLeosOamEventLogValue = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 11), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogValue.setStatus('current') wwpLeosOamEventLogRunningTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 12), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogRunningTotal.setStatus('current') wwpLeosOamEventLogEventTotal = MibTableColumn((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 13), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: wwpLeosOamEventLogEventTotal.setStatus('current') wwpLeosOamGlobal = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8)) wwpLeosOamStatsClear = MibScalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8, 1), TruthValue()).setMaxAccess("readwrite") if mibBuilder.loadTexts: wwpLeosOamStatsClear.setStatus('current') wwpLeosOamNotifMIBNotificationPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3)) wwpLeosOamNotifMIBNotification = MibIdentifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0)) wwpLeosOamLinkEventTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 1)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogPort"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogType"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamEventLogLocation")) if mibBuilder.loadTexts: wwpLeosOamLinkEventTrap.setStatus('current') wwpLeosOamLinkLostTimerActiveTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 2)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress")) if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerActiveTrap.setStatus('current') wwpLeosOamLinkLostTimerExpiredTrap = NotificationType((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 3)).setObjects(("WWP-LEOS-OAM-MIB", "wwpLeosOamPort"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortDesc"), ("WWP-LEOS-PORT-MIB", "wwpLeosEtherPortOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamOperStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerStatus"), ("WWP-LEOS-OAM-MIB", "wwpLeosOamPeerMacAddress")) if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerExpiredTrap.setStatus('current') mibBuilder.exportSymbols("WWP-LEOS-OAM-MIB", wwpLeosOamErrFrameSecsSummaryWindow=wwpLeosOamErrFrameSecsSummaryWindow, wwpLeosOamLoopbackIgnoreRx=wwpLeosOamLoopbackIgnoreRx, wwpLeosOamEventLogEntry=wwpLeosOamEventLogEntry, wwpLeosOamEventLogWindowHi=wwpLeosOamEventLogWindowHi, wwpLeosOamInformationRx=wwpLeosOamInformationRx, wwpLeosOamMode=wwpLeosOamMode, wwpLeosOamPort=wwpLeosOamPort, wwpLeosOamVariableRequestRx=wwpLeosOamVariableRequestRx, wwpLeosOamSystemEnableDisable=wwpLeosOamSystemEnableDisable, wwpLeosOamErrFramePeriodWindow=wwpLeosOamErrFramePeriodWindow, wwpLeosOamErrFramePeriodEvNotifEnable=wwpLeosOamErrFramePeriodEvNotifEnable, wwpLeosOamEventLogTable=wwpLeosOamEventLogTable, wwpLeosOamLinkLostTimerActiveTrap=wwpLeosOamLinkLostTimerActiveTrap, wwpLeosOamEventPort=wwpLeosOamEventPort, wwpLeosOamEventLogWindowLo=wwpLeosOamEventLogWindowLo, wwpLeosOamLoopbackControlTx=wwpLeosOamLoopbackControlTx, wwpLeosOamStatsClear=wwpLeosOamStatsClear, wwpLeosOamLoopbackCommand=wwpLeosOamLoopbackCommand, wwpLeosOamPeerMode=wwpLeosOamPeerMode, wwpLeosOamEventLogTimestamp=wwpLeosOamEventLogTimestamp, wwpLeosOamEventConfigEntry=wwpLeosOamEventConfigEntry, wwpLeosOamErrFrameThreshold=wwpLeosOamErrFrameThreshold, wwpLeosOamEventLogType=wwpLeosOamEventLogType, wwpLeosOamLoopbackControlRx=wwpLeosOamLoopbackControlRx, wwpLeosOamCriticalEventEnable=wwpLeosOamCriticalEventEnable, wwpLeosOamAdminState=wwpLeosOamAdminState, wwpLeosOamPeerFunctionsSupported=wwpLeosOamPeerFunctionsSupported, wwpLeosOamPeerMacAddress=wwpLeosOamPeerMacAddress, wwpLeosOamNotifMIBNotificationPrefix=wwpLeosOamNotifMIBNotificationPrefix, wwpLeosOamLinkEventTrap=wwpLeosOamLinkEventTrap, wwpLeosOamPeerStatusNotifyState=wwpLeosOamPeerStatusNotifyState, wwpLeosOamEventLogIndex=wwpLeosOamEventLogIndex, wwpLeosOamErrFrameWindow=wwpLeosOamErrFrameWindow, wwpLeosOamLinkLostTimerExpiredTrap=wwpLeosOamLinkLostTimerExpiredTrap, wwpLeosOamUnsupportedCodesTx=wwpLeosOamUnsupportedCodesTx, wwpLeosOamPeerVendorOui=wwpLeosOamPeerVendorOui, wwpLeosOamEventLogEventTotal=wwpLeosOamEventLogEventTotal, wwpLeosOamPeerVendorInfo=wwpLeosOamPeerVendorInfo, wwpLeosOamVariableRequestTx=wwpLeosOamVariableRequestTx, wwpLeosOamframesLostDueToOam=wwpLeosOamframesLostDueToOam, wwpLeosOamLocalPort=wwpLeosOamLocalPort, wwpLeosOamFunctionsSupported=wwpLeosOamFunctionsSupported, wwpLeosOamUniqueEventNotificationTx=wwpLeosOamUniqueEventNotificationTx, wwpLeosOamConf=wwpLeosOamConf, wwpLeosOamGroups=wwpLeosOamGroups, wwpLeosOamPeerEntry=wwpLeosOamPeerEntry, wwpLeosOamErrFrameSecsSummaryThreshold=wwpLeosOamErrFrameSecsSummaryThreshold, wwpLeosOamObjs=wwpLeosOamObjs, wwpLeosOamErrFrameEvNotifEnable=wwpLeosOamErrFrameEvNotifEnable, wwpLeosOamLoopbackTable=wwpLeosOamLoopbackTable, wwpLeosOamErrFrameSecsEvNotifEnable=wwpLeosOamErrFrameSecsEvNotifEnable, wwpLeosOamPeerStatus=wwpLeosOamPeerStatus, wwpLeosOamCompls=wwpLeosOamCompls, wwpLeosOamNotifMIBNotification=wwpLeosOamNotifMIBNotification, wwpLeosOamPeerTable=wwpLeosOamPeerTable, wwpLeosOamEventLogOui=wwpLeosOamEventLogOui, wwpLeosOamPeerConfigRevision=wwpLeosOamPeerConfigRevision, wwpLeosOamLinkLostTimer=wwpLeosOamLinkLostTimer, wwpLeosOamPeerMaxOamPduSize=wwpLeosOamPeerMaxOamPduSize, wwpLeosOamErrFramePeriodThreshold=wwpLeosOamErrFramePeriodThreshold, wwpLeosOamDuplicateEventNotificationRx=wwpLeosOamDuplicateEventNotificationRx, wwpLeosOamGlobal=wwpLeosOamGlobal, wwpLeosOamDyingGaspEnable=wwpLeosOamDyingGaspEnable, wwpLeosOamStatsEntry=wwpLeosOamStatsEntry, wwpLeosOamDuplicateEventNotificationTx=wwpLeosOamDuplicateEventNotificationTx, wwpLeosOamConfigRevision=wwpLeosOamConfigRevision, wwpLeosOamLoopbackStatus=wwpLeosOamLoopbackStatus, wwpLeosOamOrgSpecificRx=wwpLeosOamOrgSpecificRx, wwpLeosOamEventLogRunningTotal=wwpLeosOamEventLogRunningTotal, wwpLeosOamMIB=wwpLeosOamMIB, wwpLeosOamStatsTable=wwpLeosOamStatsTable, wwpLeosOamOperStatus=wwpLeosOamOperStatus, wwpLeosOamInformationTx=wwpLeosOamInformationTx, wwpLeosOamEventLogLocation=wwpLeosOamEventLogLocation, wwpLeosOamVariableResponseTx=wwpLeosOamVariableResponseTx, wwpLeosOamEventConfigTable=wwpLeosOamEventConfigTable, wwpLeosOamLoopbackPort=wwpLeosOamLoopbackPort, wwpLeosOamEventLogThresholdLo=wwpLeosOamEventLogThresholdLo, wwpLeosOamTable=wwpLeosOamTable, wwpLeosOamLoopbackEntry=wwpLeosOamLoopbackEntry, wwpLeosOamMibModule=wwpLeosOamMibModule, wwpLeosOamOrgSpecificTx=wwpLeosOamOrgSpecificTx, wwpLeosOamStatsPort=wwpLeosOamStatsPort, wwpLeosOamVariableResponseRx=wwpLeosOamVariableResponseRx, wwpLeosOamUnsupportedCodesRx=wwpLeosOamUnsupportedCodesRx, wwpLeosMaxOamPduSize=wwpLeosMaxOamPduSize, wwpLeosOamEventLogValue=wwpLeosOamEventLogValue, wwpLeosOamEventLogPort=wwpLeosOamEventLogPort, wwpLeosOamEventLogThresholdHi=wwpLeosOamEventLogThresholdHi, wwpLeosOamPduTimer=wwpLeosOamPduTimer, wwpLeosOamUniqueEventNotificationRx=wwpLeosOamUniqueEventNotificationRx, wwpLeosOamEntry=wwpLeosOamEntry, PYSNMP_MODULE_ID=wwpLeosOamMibModule)
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint') (notification_group, module_compliance, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance', 'ObjectGroup') (iso, counter64, mib_identifier, time_ticks, gauge32, integer32, object_identity, module_identity, unsigned32, counter32, notification_type, ip_address, bits, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'iso', 'Counter64', 'MibIdentifier', 'TimeTicks', 'Gauge32', 'Integer32', 'ObjectIdentity', 'ModuleIdentity', 'Unsigned32', 'Counter32', 'NotificationType', 'IpAddress', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn') (display_string, time_stamp, textual_convention, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TimeStamp', 'TextualConvention', 'TruthValue') (wwp_leos_ether_port_oper_status, wwp_leos_ether_port_desc) = mibBuilder.importSymbols('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus', 'wwpLeosEtherPortDesc') (wwp_modules_leos,) = mibBuilder.importSymbols('WWP-SMI', 'wwpModulesLeos') wwp_leos_oam_mib_module = module_identity((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400)) wwpLeosOamMibModule.setRevisions(('2008-01-03 00:00',)) if mibBuilder.loadTexts: wwpLeosOamMibModule.setLastUpdated('200801030000Z') if mibBuilder.loadTexts: wwpLeosOamMibModule.setOrganization('Ciena, Inc') wwp_leos_oam_mib = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1)) wwp_leos_oam_conf = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1)) wwp_leos_oam_groups = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 1)) wwp_leos_oam_compls = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 1, 2)) wwp_leos_oam_objs = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2)) wwp_leos_oam_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1)) if mibBuilder.loadTexts: wwpLeosOamTable.setStatus('current') wwp_leos_oam_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamPort')) if mibBuilder.loadTexts: wwpLeosOamEntry.setStatus('current') wwp_leos_oam_admin_state = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('disabled', 1), ('enabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamAdminState.setStatus('current') wwp_leos_oam_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=named_values(('disabled', 1), ('linkfault', 2), ('passiveWait', 3), ('activeSendLocal', 4), ('sendLocalAndRemote', 5), ('sendLocalAndRemoteOk', 6), ('oamPeeringLocallyRejected', 7), ('oamPeeringRemotelyRejected', 8), ('operational', 9)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamOperStatus.setStatus('current') wwp_leos_oam_mode = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('passive', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamMode.setStatus('current') wwp_leos_max_oam_pdu_size = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 4), integer32()).setUnits('bytes').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosMaxOamPduSize.setStatus('current') wwp_leos_oam_config_revision = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 5), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamConfigRevision.setStatus('current') wwp_leos_oam_functions_supported = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 6), bits().clone(namedValues=named_values(('unidirectionalSupport', 0), ('loopbackSupport', 1), ('eventSupport', 2), ('variableSupport', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamFunctionsSupported.setStatus('current') wwp_leos_oam_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPort.setStatus('current') wwp_leos_oam_pdu_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(100, 1000))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamPduTimer.setStatus('current') wwp_leos_oam_link_lost_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(500, 5000))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamLinkLostTimer.setStatus('current') wwp_leos_oam_peer_status_notify_state = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('on', 1), ('off', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamPeerStatusNotifyState.setStatus('current') wwp_leos_oam_peer_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2)) if mibBuilder.loadTexts: wwpLeosOamPeerTable.setStatus('current') wwp_leos_oam_peer_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamLocalPort')) if mibBuilder.loadTexts: wwpLeosOamPeerEntry.setStatus('current') wwp_leos_oam_peer_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerStatus.setStatus('current') wwp_leos_oam_peer_mac_address = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 2), octet_string().subtype(subtypeSpec=value_size_constraint(6, 6)).setFixedLength(6)).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerMacAddress.setStatus('current') wwp_leos_oam_peer_vendor_oui = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 3), octet_string().subtype(subtypeSpec=value_size_constraint(3, 3)).setFixedLength(3)).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerVendorOui.setStatus('current') wwp_leos_oam_peer_vendor_info = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 4), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerVendorInfo.setStatus('current') wwp_leos_oam_peer_mode = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('active', 1), ('passive', 2), ('unknown', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerMode.setStatus('current') wwp_leos_oam_peer_max_oam_pdu_size = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 6), integer32()).setUnits('bytes').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerMaxOamPduSize.setStatus('current') wwp_leos_oam_peer_config_revision = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 7), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerConfigRevision.setStatus('current') wwp_leos_oam_peer_functions_supported = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 8), bits().clone(namedValues=named_values(('unidirectionalSupport', 0), ('loopbackSupport', 1), ('eventSupport', 2), ('variableSupport', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamPeerFunctionsSupported.setStatus('current') wwp_leos_oam_local_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 2, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamLocalPort.setStatus('current') wwp_leos_oam_loopback_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3)) if mibBuilder.loadTexts: wwpLeosOamLoopbackTable.setStatus('current') wwp_leos_oam_loopback_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamLoopbackPort')) if mibBuilder.loadTexts: wwpLeosOamLoopbackEntry.setStatus('current') wwp_leos_oam_loopback_command = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('noLoopback', 1), ('startRemoteLoopback', 2), ('stopRemoteLoopback', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamLoopbackCommand.setStatus('current') wwp_leos_oam_loopback_status = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('noLoopback', 1), ('initiatingLoopback', 2), ('remoteLoopback', 3), ('terminatingLoopback', 4), ('localLoopback', 5), ('unknown', 6)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamLoopbackStatus.setStatus('current') wwp_leos_oam_loopback_ignore_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('ignore', 1), ('process', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamLoopbackIgnoreRx.setStatus('current') wwp_leos_oam_loopback_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 3, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamLoopbackPort.setStatus('current') wwp_leos_oam_stats_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4)) if mibBuilder.loadTexts: wwpLeosOamStatsTable.setStatus('current') wwp_leos_oam_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamStatsPort')) if mibBuilder.loadTexts: wwpLeosOamStatsEntry.setStatus('current') wwp_leos_oam_information_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 1), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamInformationTx.setStatus('current') wwp_leos_oam_information_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 2), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamInformationRx.setStatus('current') wwp_leos_oam_unique_event_notification_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 3), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationTx.setStatus('current') wwp_leos_oam_unique_event_notification_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 4), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamUniqueEventNotificationRx.setStatus('current') wwp_leos_oam_loopback_control_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 5), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamLoopbackControlTx.setStatus('current') wwp_leos_oam_loopback_control_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 6), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamLoopbackControlRx.setStatus('current') wwp_leos_oam_variable_request_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 7), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamVariableRequestTx.setStatus('current') wwp_leos_oam_variable_request_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 8), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamVariableRequestRx.setStatus('current') wwp_leos_oam_variable_response_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 9), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamVariableResponseTx.setStatus('current') wwp_leos_oam_variable_response_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 10), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamVariableResponseRx.setStatus('current') wwp_leos_oam_org_specific_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 11), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamOrgSpecificTx.setStatus('current') wwp_leos_oam_org_specific_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 12), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamOrgSpecificRx.setStatus('current') wwp_leos_oam_unsupported_codes_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 13), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesTx.setStatus('current') wwp_leos_oam_unsupported_codes_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 14), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamUnsupportedCodesRx.setStatus('current') wwp_leos_oamframes_lost_due_to_oam = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 15), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamframesLostDueToOam.setStatus('current') wwp_leos_oam_stats_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 16), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamStatsPort.setStatus('current') wwp_leos_oam_duplicate_event_notification_tx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 17), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationTx.setStatus('current') wwp_leos_oam_duplicate_event_notification_rx = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 4, 1, 18), counter32()).setUnits('frames').setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamDuplicateEventNotificationRx.setStatus('current') wwp_leos_oam_system_enable_disable = mib_scalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamSystemEnableDisable.setStatus('current') wwp_leos_oam_event_config_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6)) if mibBuilder.loadTexts: wwpLeosOamEventConfigTable.setStatus('current') wwp_leos_oam_event_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventPort')) if mibBuilder.loadTexts: wwpLeosOamEventConfigEntry.setStatus('current') wwp_leos_oam_event_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventPort.setStatus('current') wwp_leos_oam_err_frame_period_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(14880, 8928000))).setUnits('frames').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodWindow.setStatus('current') wwp_leos_oam_err_frame_period_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967293))).setUnits('frames').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodThreshold.setStatus('current') wwp_leos_oam_err_frame_period_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFramePeriodEvNotifEnable.setStatus('current') wwp_leos_oam_err_frame_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(10, 600))).setUnits('tenths of a second').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameWindow.setStatus('current') wwp_leos_oam_err_frame_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 6), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967293))).setUnits('frames').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameThreshold.setStatus('current') wwp_leos_oam_err_frame_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameEvNotifEnable.setStatus('current') wwp_leos_oam_err_frame_secs_summary_window = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(100, 9000))).setUnits('tenths of a second').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryWindow.setStatus('current') wwp_leos_oam_err_frame_secs_summary_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setUnits('errored frame seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsSummaryThreshold.setStatus('current') wwp_leos_oam_err_frame_secs_ev_notif_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamErrFrameSecsEvNotifEnable.setStatus('current') wwp_leos_oam_dying_gasp_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamDyingGaspEnable.setStatus('current') wwp_leos_oam_critical_event_enable = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 6, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamCriticalEventEnable.setStatus('current') wwp_leos_oam_event_log_table = mib_table((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7)) if mibBuilder.loadTexts: wwpLeosOamEventLogTable.setStatus('current') wwp_leos_oam_event_log_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1)).setIndexNames((0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogPort'), (0, 'WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogIndex')) if mibBuilder.loadTexts: wwpLeosOamEventLogEntry.setStatus('current') wwp_leos_oam_event_log_port = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogPort.setStatus('current') wwp_leos_oam_event_log_index = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 2), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogIndex.setStatus('current') wwp_leos_oam_event_log_timestamp = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 3), time_stamp()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogTimestamp.setStatus('current') wwp_leos_oam_event_log_oui = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 4), octet_string().subtype(subtypeSpec=value_size_constraint(3, 3)).setFixedLength(3)).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogOui.setStatus('current') wwp_leos_oam_event_log_type = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 5), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogType.setStatus('current') wwp_leos_oam_event_log_location = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('local', 1), ('remote', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogLocation.setStatus('current') wwp_leos_oam_event_log_window_hi = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 7), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogWindowHi.setStatus('current') wwp_leos_oam_event_log_window_lo = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 8), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogWindowLo.setStatus('current') wwp_leos_oam_event_log_threshold_hi = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 9), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdHi.setStatus('current') wwp_leos_oam_event_log_threshold_lo = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 10), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogThresholdLo.setStatus('current') wwp_leos_oam_event_log_value = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 11), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogValue.setStatus('current') wwp_leos_oam_event_log_running_total = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 12), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogRunningTotal.setStatus('current') wwp_leos_oam_event_log_event_total = mib_table_column((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 7, 1, 13), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: wwpLeosOamEventLogEventTotal.setStatus('current') wwp_leos_oam_global = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8)) wwp_leos_oam_stats_clear = mib_scalar((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 2, 8, 1), truth_value()).setMaxAccess('readwrite') if mibBuilder.loadTexts: wwpLeosOamStatsClear.setStatus('current') wwp_leos_oam_notif_mib_notification_prefix = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3)) wwp_leos_oam_notif_mib_notification = mib_identifier((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0)) wwp_leos_oam_link_event_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 1)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogPort'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogType'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamEventLogLocation')) if mibBuilder.loadTexts: wwpLeosOamLinkEventTrap.setStatus('current') wwp_leos_oam_link_lost_timer_active_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 2)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamPort'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortDesc'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerMacAddress')) if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerActiveTrap.setStatus('current') wwp_leos_oam_link_lost_timer_expired_trap = notification_type((1, 3, 6, 1, 4, 1, 6141, 2, 60, 400, 1, 3, 0, 3)).setObjects(('WWP-LEOS-OAM-MIB', 'wwpLeosOamPort'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortDesc'), ('WWP-LEOS-PORT-MIB', 'wwpLeosEtherPortOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamOperStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerStatus'), ('WWP-LEOS-OAM-MIB', 'wwpLeosOamPeerMacAddress')) if mibBuilder.loadTexts: wwpLeosOamLinkLostTimerExpiredTrap.setStatus('current') mibBuilder.exportSymbols('WWP-LEOS-OAM-MIB', wwpLeosOamErrFrameSecsSummaryWindow=wwpLeosOamErrFrameSecsSummaryWindow, wwpLeosOamLoopbackIgnoreRx=wwpLeosOamLoopbackIgnoreRx, wwpLeosOamEventLogEntry=wwpLeosOamEventLogEntry, wwpLeosOamEventLogWindowHi=wwpLeosOamEventLogWindowHi, wwpLeosOamInformationRx=wwpLeosOamInformationRx, wwpLeosOamMode=wwpLeosOamMode, wwpLeosOamPort=wwpLeosOamPort, wwpLeosOamVariableRequestRx=wwpLeosOamVariableRequestRx, wwpLeosOamSystemEnableDisable=wwpLeosOamSystemEnableDisable, wwpLeosOamErrFramePeriodWindow=wwpLeosOamErrFramePeriodWindow, wwpLeosOamErrFramePeriodEvNotifEnable=wwpLeosOamErrFramePeriodEvNotifEnable, wwpLeosOamEventLogTable=wwpLeosOamEventLogTable, wwpLeosOamLinkLostTimerActiveTrap=wwpLeosOamLinkLostTimerActiveTrap, wwpLeosOamEventPort=wwpLeosOamEventPort, wwpLeosOamEventLogWindowLo=wwpLeosOamEventLogWindowLo, wwpLeosOamLoopbackControlTx=wwpLeosOamLoopbackControlTx, wwpLeosOamStatsClear=wwpLeosOamStatsClear, wwpLeosOamLoopbackCommand=wwpLeosOamLoopbackCommand, wwpLeosOamPeerMode=wwpLeosOamPeerMode, wwpLeosOamEventLogTimestamp=wwpLeosOamEventLogTimestamp, wwpLeosOamEventConfigEntry=wwpLeosOamEventConfigEntry, wwpLeosOamErrFrameThreshold=wwpLeosOamErrFrameThreshold, wwpLeosOamEventLogType=wwpLeosOamEventLogType, wwpLeosOamLoopbackControlRx=wwpLeosOamLoopbackControlRx, wwpLeosOamCriticalEventEnable=wwpLeosOamCriticalEventEnable, wwpLeosOamAdminState=wwpLeosOamAdminState, wwpLeosOamPeerFunctionsSupported=wwpLeosOamPeerFunctionsSupported, wwpLeosOamPeerMacAddress=wwpLeosOamPeerMacAddress, wwpLeosOamNotifMIBNotificationPrefix=wwpLeosOamNotifMIBNotificationPrefix, wwpLeosOamLinkEventTrap=wwpLeosOamLinkEventTrap, wwpLeosOamPeerStatusNotifyState=wwpLeosOamPeerStatusNotifyState, wwpLeosOamEventLogIndex=wwpLeosOamEventLogIndex, wwpLeosOamErrFrameWindow=wwpLeosOamErrFrameWindow, wwpLeosOamLinkLostTimerExpiredTrap=wwpLeosOamLinkLostTimerExpiredTrap, wwpLeosOamUnsupportedCodesTx=wwpLeosOamUnsupportedCodesTx, wwpLeosOamPeerVendorOui=wwpLeosOamPeerVendorOui, wwpLeosOamEventLogEventTotal=wwpLeosOamEventLogEventTotal, wwpLeosOamPeerVendorInfo=wwpLeosOamPeerVendorInfo, wwpLeosOamVariableRequestTx=wwpLeosOamVariableRequestTx, wwpLeosOamframesLostDueToOam=wwpLeosOamframesLostDueToOam, wwpLeosOamLocalPort=wwpLeosOamLocalPort, wwpLeosOamFunctionsSupported=wwpLeosOamFunctionsSupported, wwpLeosOamUniqueEventNotificationTx=wwpLeosOamUniqueEventNotificationTx, wwpLeosOamConf=wwpLeosOamConf, wwpLeosOamGroups=wwpLeosOamGroups, wwpLeosOamPeerEntry=wwpLeosOamPeerEntry, wwpLeosOamErrFrameSecsSummaryThreshold=wwpLeosOamErrFrameSecsSummaryThreshold, wwpLeosOamObjs=wwpLeosOamObjs, wwpLeosOamErrFrameEvNotifEnable=wwpLeosOamErrFrameEvNotifEnable, wwpLeosOamLoopbackTable=wwpLeosOamLoopbackTable, wwpLeosOamErrFrameSecsEvNotifEnable=wwpLeosOamErrFrameSecsEvNotifEnable, wwpLeosOamPeerStatus=wwpLeosOamPeerStatus, wwpLeosOamCompls=wwpLeosOamCompls, wwpLeosOamNotifMIBNotification=wwpLeosOamNotifMIBNotification, wwpLeosOamPeerTable=wwpLeosOamPeerTable, wwpLeosOamEventLogOui=wwpLeosOamEventLogOui, wwpLeosOamPeerConfigRevision=wwpLeosOamPeerConfigRevision, wwpLeosOamLinkLostTimer=wwpLeosOamLinkLostTimer, wwpLeosOamPeerMaxOamPduSize=wwpLeosOamPeerMaxOamPduSize, wwpLeosOamErrFramePeriodThreshold=wwpLeosOamErrFramePeriodThreshold, wwpLeosOamDuplicateEventNotificationRx=wwpLeosOamDuplicateEventNotificationRx, wwpLeosOamGlobal=wwpLeosOamGlobal, wwpLeosOamDyingGaspEnable=wwpLeosOamDyingGaspEnable, wwpLeosOamStatsEntry=wwpLeosOamStatsEntry, wwpLeosOamDuplicateEventNotificationTx=wwpLeosOamDuplicateEventNotificationTx, wwpLeosOamConfigRevision=wwpLeosOamConfigRevision, wwpLeosOamLoopbackStatus=wwpLeosOamLoopbackStatus, wwpLeosOamOrgSpecificRx=wwpLeosOamOrgSpecificRx, wwpLeosOamEventLogRunningTotal=wwpLeosOamEventLogRunningTotal, wwpLeosOamMIB=wwpLeosOamMIB, wwpLeosOamStatsTable=wwpLeosOamStatsTable, wwpLeosOamOperStatus=wwpLeosOamOperStatus, wwpLeosOamInformationTx=wwpLeosOamInformationTx, wwpLeosOamEventLogLocation=wwpLeosOamEventLogLocation, wwpLeosOamVariableResponseTx=wwpLeosOamVariableResponseTx, wwpLeosOamEventConfigTable=wwpLeosOamEventConfigTable, wwpLeosOamLoopbackPort=wwpLeosOamLoopbackPort, wwpLeosOamEventLogThresholdLo=wwpLeosOamEventLogThresholdLo, wwpLeosOamTable=wwpLeosOamTable, wwpLeosOamLoopbackEntry=wwpLeosOamLoopbackEntry, wwpLeosOamMibModule=wwpLeosOamMibModule, wwpLeosOamOrgSpecificTx=wwpLeosOamOrgSpecificTx, wwpLeosOamStatsPort=wwpLeosOamStatsPort, wwpLeosOamVariableResponseRx=wwpLeosOamVariableResponseRx, wwpLeosOamUnsupportedCodesRx=wwpLeosOamUnsupportedCodesRx, wwpLeosMaxOamPduSize=wwpLeosMaxOamPduSize, wwpLeosOamEventLogValue=wwpLeosOamEventLogValue, wwpLeosOamEventLogPort=wwpLeosOamEventLogPort, wwpLeosOamEventLogThresholdHi=wwpLeosOamEventLogThresholdHi, wwpLeosOamPduTimer=wwpLeosOamPduTimer, wwpLeosOamUniqueEventNotificationRx=wwpLeosOamUniqueEventNotificationRx, wwpLeosOamEntry=wwpLeosOamEntry, PYSNMP_MODULE_ID=wwpLeosOamMibModule)
# https://leetcode.com/problems/longest-palindromic-subsequence/ class Solution: def longestPalindromeSubseq(self, s: str) -> int: dp = [[0 for _ in range(len(s))] for _ in range(len(s))] for row in range(len(s)): for col in range(len(s)): # Find len of longest common subsequence of s and reversed(s). if s[row] == s[-1 - col]: diagonal_top_left = ( dp[row - 1][col - 1] if row > 0 and col > 0 else 0) dp[row][col] = diagonal_top_left + 1 else: top = dp[row - 1][col] if row > 0 else 0 left = dp[row][col - 1] if col > 0 else 0 dp[row][col] = max(top, left) return dp[-1][-1]
class Solution: def longest_palindrome_subseq(self, s: str) -> int: dp = [[0 for _ in range(len(s))] for _ in range(len(s))] for row in range(len(s)): for col in range(len(s)): if s[row] == s[-1 - col]: diagonal_top_left = dp[row - 1][col - 1] if row > 0 and col > 0 else 0 dp[row][col] = diagonal_top_left + 1 else: top = dp[row - 1][col] if row > 0 else 0 left = dp[row][col - 1] if col > 0 else 0 dp[row][col] = max(top, left) return dp[-1][-1]
# -- Project information ----------------------------------------------------- project = "PyData Tests" copyright = "2020, Pydata community" author = "Pydata community" master_doc = "index" # -- General configuration --------------------------------------------------- html_theme = "pydata_sphinx_theme" html_copy_source = True html_sourcelink_suffix = ""
project = 'PyData Tests' copyright = '2020, Pydata community' author = 'Pydata community' master_doc = 'index' html_theme = 'pydata_sphinx_theme' html_copy_source = True html_sourcelink_suffix = ''
test = { 'name': 'q5g', 'points': 1, 'suites': [ { 'cases': [ { 'code': ">>> 'result_q5g' in globals()\n" 'True', 'hidden': False, 'locked': False}, { 'code': '>>> ' 'result_q5g.to_string(index=False) ' '== ' 'df_usa.fillna(value=0).head().to_string(index=False)\n' 'True', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
test = {'name': 'q5g', 'points': 1, 'suites': [{'cases': [{'code': ">>> 'result_q5g' in globals()\nTrue", 'hidden': False, 'locked': False}, {'code': '>>> result_q5g.to_string(index=False) == df_usa.fillna(value=0).head().to_string(index=False)\nTrue', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
# ======================== # Information # ======================== # Direct Link: https://www.hackerrank.com/challenges/s10-poisson-distribution-2/problem # Difficulty: Easy # Max Score: 30 # Language: Python # ======================== # Solution # ======================== AVERAGE_X, AVERAGE_Y = [float(num) for num in input().split(" ")] # Cost COST_X = 160 + 40*(AVERAGE_X + AVERAGE_X**2) COST_Y = 128 + 40*(AVERAGE_Y + AVERAGE_Y**2) print(round(COST_X, 3)) print(round(COST_Y, 3))
(average_x, average_y) = [float(num) for num in input().split(' ')] cost_x = 160 + 40 * (AVERAGE_X + AVERAGE_X ** 2) cost_y = 128 + 40 * (AVERAGE_Y + AVERAGE_Y ** 2) print(round(COST_X, 3)) print(round(COST_Y, 3))
def cap_11(packet): # your code here try: if packet["RTMPT"]["string"] == '_result': packet["RTMPT"]["string"] = '_123456' print("cambiado") return packet except: print("fallo") return None
def cap_11(packet): try: if packet['RTMPT']['string'] == '_result': packet['RTMPT']['string'] = '_123456' print('cambiado') return packet except: print('fallo') return None
''' Hardcoded string input no filtering sink: check if a file exists ''' class Class_351: def __init__(self, param): self.var_351 = param def get_var_351(self): return self.var_351
""" Hardcoded string input no filtering sink: check if a file exists """ class Class_351: def __init__(self, param): self.var_351 = param def get_var_351(self): return self.var_351
inv_count = 0 def sorter(l_res , r_res): global inv_count i = 0 r = 0 results = [] while i < len(l_res) and r < len(r_res): if l_res[i] > r_res[r]: results.append(r_res[r]) inv_count += len(l_res) - i r += 1 else: results.append(l_res[i]) i += 1 while i < len(l_res): results.append(l_res[i]) i += 1 while r < len(r_res): results.append(r_res[r]) r += 1 return results def divider(arr): if len(arr) == 1: return arr mid = len(arr)//2 l_arr = arr[0:mid] r_arr = arr[mid:] l_res = divider(l_arr) r_res = divider(r_arr) arr = sorter(l_res, r_res) return arr A = [6, 5, 2, 1, 5, 6] res = divider(A) print(inv_count) # # def brute_force(arr): # arr = A # lent = len(arr) # inv_c = 0 # for i in range(lent): # for j in range(i+1, lent): # if arr[i] > arr[j]: # inv_c += 1 # return inv_c % (10**7 + 7) # # # A = [1, 2, 3, 4, 5, 6] # res = brute_force(A) # print(res)
inv_count = 0 def sorter(l_res, r_res): global inv_count i = 0 r = 0 results = [] while i < len(l_res) and r < len(r_res): if l_res[i] > r_res[r]: results.append(r_res[r]) inv_count += len(l_res) - i r += 1 else: results.append(l_res[i]) i += 1 while i < len(l_res): results.append(l_res[i]) i += 1 while r < len(r_res): results.append(r_res[r]) r += 1 return results def divider(arr): if len(arr) == 1: return arr mid = len(arr) // 2 l_arr = arr[0:mid] r_arr = arr[mid:] l_res = divider(l_arr) r_res = divider(r_arr) arr = sorter(l_res, r_res) return arr a = [6, 5, 2, 1, 5, 6] res = divider(A) print(inv_count)
# # @lc app=leetcode.cn id=133 lang=python3 # # [133] clone-graph # None # @lc code=end
None
def add_node(v): if v in graph: print(v,"already present") else: graph[v]=[] def add_edge(v1,v2): if v1 not in graph: print(v1," not present in graph") elif v2 not in graph: print(v2,"not present in graph") else: graph[v1].append(v2) graph[v2].append(v1) def delete_edge(v1,v2): if v1 not in graph: print(v1,"not present in graph") elif v2 not in graph: print(v2,"not present in graph") else: if v2 in graph[v1]: graph[v1].remove(v2) graph[v2].remove(v1) graph={} add_node('A') add_node('B') add_node('C') add_node('D') add_edge('A','D') add_edge('A','C') add_edge('C','D') add_edge('C','E') delete_edge('C','D') #Op=>> {'A': ['D', 'C'], 'B': [], 'C': ['A'], 'D': ['A']} print(graph)
def add_node(v): if v in graph: print(v, 'already present') else: graph[v] = [] def add_edge(v1, v2): if v1 not in graph: print(v1, ' not present in graph') elif v2 not in graph: print(v2, 'not present in graph') else: graph[v1].append(v2) graph[v2].append(v1) def delete_edge(v1, v2): if v1 not in graph: print(v1, 'not present in graph') elif v2 not in graph: print(v2, 'not present in graph') elif v2 in graph[v1]: graph[v1].remove(v2) graph[v2].remove(v1) graph = {} add_node('A') add_node('B') add_node('C') add_node('D') add_edge('A', 'D') add_edge('A', 'C') add_edge('C', 'D') add_edge('C', 'E') delete_edge('C', 'D') print(graph)
# ================================================================ def total_packet_size_bytes (s): return (s ['packet_len'] + s ['num_credits'] + s ['channel_id'] + s ['payload']) def this_packet_size_bytes (s, n): return (s ['packet_len'] + s ['num_credits'] + s ['channel_id'] + n) # ================================================================ # Substitution function to expand a template into code. # 'template' is a list of strings # Each string represents a line of text, # and may contain '@FOO' variables to be substituted. # 'substs' is list of (@FOO, string) substitutions. # Returns a string which concatenates the lines and substitutes the vars. def subst (template, substs): s = "\n".join (template) for (var, val) in substs: s = s.replace (var, val) return s # ================================================================
def total_packet_size_bytes(s): return s['packet_len'] + s['num_credits'] + s['channel_id'] + s['payload'] def this_packet_size_bytes(s, n): return s['packet_len'] + s['num_credits'] + s['channel_id'] + n def subst(template, substs): s = '\n'.join(template) for (var, val) in substs: s = s.replace(var, val) return s
class S(str): # Symbol class: the only important difference between S and str is that S has a __substitute__ method # Note that S('a') == 'a' is True. This lets us use strings as shorthand in certain places. def __str__(self): return "S('" + super(S, self).__str__() + "')" def __repr__(self): return "S(" + super(S, self).__repr__() + ")" def __substitute__(self, values): return values[self] def identity(x): return x class TransSymbol(object): # A Symbol or SymbolicAddress with a transformation applied # TODO: reverse transformation currently not applied during match. Use it. def __init__(self, symbol, forward=identity, reverse=identity): # Can either pass a single dict, or a pair of functions self._symbol = symbol self._map = None if type(forward) == dict: reverse = {v:k for k,v in forward.items()} # TODO: add option to fail on map miss self._forward_func = lambda k: forward.get(k, None) self._reverse = lambda k: reverse.get(k, None) self._map = forward else: self._forward_func = forward self._reverse = reverse # Note that there is no corresponding wrapper for _reverse. This is a minor hack, and I haven't decided what behavior # I actually want here. def _forward(self, inner): try: return self._forward_func(inner) except TypeError: # Hit if either forward function is None, or forward function receives None but doesn't handle it. Both ok. # TODO: figure out what I actually want the default behavior to be return inner except AttributeError: # Same story return inner # TODO: proper equality & hashing for TransSymbols. def __str__(self): return 'Trans(' + str(self._symbol) + ')' def __repr__(self): if self._map: return 'Trans(' + self._symbol.__repr__() + ', ' + self._map.__repr__() + ')' return 'Trans(' + self._symbol.__repr__() + ')' class Nullable(object): # A simple wrapper class to mark part of a template as optional, i.e. match is allowed to fail. def __init__(self, contents): self.contents = contents
class S(str): def __str__(self): return "S('" + super(S, self).__str__() + "')" def __repr__(self): return 'S(' + super(S, self).__repr__() + ')' def __substitute__(self, values): return values[self] def identity(x): return x class Transsymbol(object): def __init__(self, symbol, forward=identity, reverse=identity): self._symbol = symbol self._map = None if type(forward) == dict: reverse = {v: k for (k, v) in forward.items()} self._forward_func = lambda k: forward.get(k, None) self._reverse = lambda k: reverse.get(k, None) self._map = forward else: self._forward_func = forward self._reverse = reverse def _forward(self, inner): try: return self._forward_func(inner) except TypeError: return inner except AttributeError: return inner def __str__(self): return 'Trans(' + str(self._symbol) + ')' def __repr__(self): if self._map: return 'Trans(' + self._symbol.__repr__() + ', ' + self._map.__repr__() + ')' return 'Trans(' + self._symbol.__repr__() + ')' class Nullable(object): def __init__(self, contents): self.contents = contents
class SwampyException(Exception): pass class ExWelcomeTimeout(SwampyException): pass class ExAbort(SwampyException): pass class ExInvocationError(SwampyException): pass
class Swampyexception(Exception): pass class Exwelcometimeout(SwampyException): pass class Exabort(SwampyException): pass class Exinvocationerror(SwampyException): pass
#!/usr/bin/python3 def new_in_list(my_list, idx, element): new_list = my_list[:] if idx >= 0 and idx < len(my_list): new_list[idx] = element return new_list
def new_in_list(my_list, idx, element): new_list = my_list[:] if idx >= 0 and idx < len(my_list): new_list[idx] = element return new_list
def main(type): x = 0 print(type) if type=="wl": #a while loop while (x <5): print(x) x = x + 1 elif type=="fl": #a for loop for x in range(5,10): print(x) elif type=="cl": #a for loop over a collection days = ["Mon", "Tue", "Wed", "Thurs", "Fri", "Sat", "Sun"] for d in days: print(d) elif type=="en": # enumerate() function to get index directions = ["East", "West", "North", "South", "SouthWest", "NorthEast", "NorthWest"] for i, d in enumerate(directions): print (i,d) else: print("Invalid loop type specified") if __name__ == "__main__": main('wl')
def main(type): x = 0 print(type) if type == 'wl': while x < 5: print(x) x = x + 1 elif type == 'fl': for x in range(5, 10): print(x) elif type == 'cl': days = ['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'] for d in days: print(d) elif type == 'en': directions = ['East', 'West', 'North', 'South', 'SouthWest', 'NorthEast', 'NorthWest'] for (i, d) in enumerate(directions): print(i, d) else: print('Invalid loop type specified') if __name__ == '__main__': main('wl')
# Constants in FlexRay spec cdCycleMax = 16000 cCycleCountMax = 63 cStaticSlotIDMax = 1023 cSlotIDMax = 2047 cPayloadLengthMax = 127 cSamplesPerBit = 8 cSyncFrameIDCountMax = 15 cMicroPerMacroNomMin = 40 cdMinMTNom = 1 cdMaxMTNom = 6 cdFES = 2 cdFSS = 1 cChannelIdleDelimiter = 11 cClockDeviationMax = 0.0015 cStrobeOffset = 5 cVotingSamples = 5 cVotingDelay = (cVotingSamples - 1) / 2 cdBSS = 2 cdWakeupSymbolTxIdle = 18 cdWakeupSymbolTxLow = 6 cdCAS = 30 cMicroPerMacroMin = 20 cdMaxOffsetCalculation = 1350 cdMaxRateCalculation = 1500 SIZEOF_UINT16 = 2 SIZEOF_PACKET_HEADER = SIZEOF_UINT16 * 2 PACKET_TYPE_START_DRIVER = 0 PACKET_TYPE_FLEXRAY_FRAME = 1 PACKET_TYPE_HEALTH = 2 PACKET_TYPE_FLEXRAY_JOINED_CLUSTER = 3 PACKET_TYPE_FLEXRAY_JOIN_CLUSTER_FAILED = 4 PACKET_TYPE_FLEXRAY_DISCONNECTED_FROM_CLUSTER = 5 PACKET_TYPE_FLEXRAY_FATAL_ERROR = 6 PACKET_TYPE_MONIOR_SLOTS = 7 # MPC5748g registers bits FR_PIFR0_TBVA_IF_U16 = 0x0008 FR_PIFR0_TBVB_IF_U16 = 0x0010 FR_PIFR0_LTXA_IF_U16 = 0x0020 FR_PIFR0_LTXB_IF_U16 = 0x0040 FR_PIER0_CCL_IF_U16 = 0x0200 FR_PIFR0_MOC_IF_U16 = 0x0400 FR_PIFR0_MRC_IF_U16 = 0x0800 FR_PIFR0_FATL_IF_U16 = 0x8000 FR_PIFR0_INTL_IF_U16 = 0x4000 FR_PIFR0_ILCF_IF_U16 = 0x2000 FR_PIFR0_CSA_IF_U16 = 0x1000 FR_PIER0_TI2_IE_U16 = 0x0004 FR_PIER0_TI1_IE_U16 = 0x0002 FR_PSR0_ERRMODE_MASK_U16 = 0xC000 FR_PSR0_SLOTMODE_MASK_U16 = 0x3000 FR_PSR0_PROTSTATE_MASK_U16 = 0x0700 FR_PSR0_STARTUP_MASK_U16 = 0x00F0 FR_PSR0_WUP_MASK_U16 = 0x0007 FR_PSR0_SLOTMODE_SINGLE_U16 = 0x0000 FR_PSR0_SLOTMODE_ALL_PENDING_U16 = 0x1000 FR_PSR0_SLOTMODE_ALL_U16 = 0x2000 FR_PSR0_ERRMODE_ACTIVE_U16 = 0x0000 FR_PSR0_ERRMODE_PASSIVE_U16 = 0x4000 FR_PSR0_ERRMODE_COMM_HALT_U16 = 0x8000 FR_PSR0_PROTSTATE_DEFAULT_CONFIG_U16 = 0x0000 FR_PSR0_PROTSTATE_CONFIG_U16 = 0x0100 FR_PSR0_PROTSTATE_WAKEUP_U16 = 0x0200 FR_PSR0_PROTSTATE_READY_U16 = 0x0300 FR_PSR0_PROTSTATE_NORMAL_PASSIVE_U16 = 0x0400 FR_PSR0_PROTSTATE_NORMAL_ACTIVE_U16 = 0x0500 FR_PSR0_PROTSTATE_HALT_U16 = 0x0600 FR_PSR0_PROTSTATE_STARTUP_U16 = 0x0700 FR_PSR0_STARTUP_CCR_U16 = 0x0020 FR_PSR0_STARTUP_CL_U16 = 0x0030 FR_PSR0_STARTUP_ICOC_U16 = 0x0040 FR_PSR0_STARTUP_IL_U16 = 0x0050 FR_PSR0_STARTUP_IS_U16 = 0x0070 FR_PSR0_STARTUP_CCC_U16 = 0x00A0 FR_PSR0_STARTUP_ICLC_U16 = 0x00D0 FR_PSR0_STARTUP_CG_U16 = 0x00E0 FR_PSR0_STARTUP_CJ_U16 = 0x00F0 FR_PSR1_CPN_U16 = 0x0080 FR_PSR1_HHR_U16 = 0x0040 FR_PSR1_FRZ_U16 = 0x0020 FR_PSR2_NBVB_MASK_U16 = 0x8000 FR_PSR2_NSEB_MASK_U16 = 0x4000 FR_PSR2_STCB_MASK_U16 = 0x2000 FR_PSR2_SBVB_MASK_U16 = 0x1000 FR_PSR2_SSEB_MASK_U16 = 0x0800 FR_PSR2_MTB_MASK_U16 = 0x0400 FR_PSR2_NBVA_MASK_U16 = 0x0200 FR_PSR2_NSEA_MASK_U16 = 0x0100 FR_PSR2_STCA_MASK_U16 = 0x0080 FR_PSR2_SBVA_MASK_U16 = 0x0040 FR_PSR2_SSEA_MASK_U16 = 0x0020 FR_PSR2_MTA_MASK_U16 = 0x0010 FR_PSR2_CKCORFCNT_MASK_U16 = 0x000F FR_PSR3_ABVB_U16 = 0x1000 FR_PSR3_AACB_U16 = 0x0800 FR_PSR3_ACEB_U16 = 0x0400 FR_PSR3_ASEB_U16 = 0x0200 FR_PSR3_AVFB_U16 = 0x0100 FR_PSR3_ABVA_U16 = 0x0010 FR_PSR3_AACA_U16 = 0x0008 FR_PSR3_ACEA_U16 = 0x0004 FR_PSR3_ASEA_U16 = 0x0002 FR_PSR3_AVFA_U16 = 0x0001 FR_SSR_VFB = 0x8000 FR_SSR_SYB = 0x4000 FR_SSR_NFB = 0x2000 FR_SSR_SUB = 0x1000 FR_SSR_SEB = 0x0800 FR_SSR_CEB = 0x0400 FR_SSR_BVB = 0x0200 FR_SSR_TCB = 0x0100 FR_SSR_VFA = 0x0080 FR_SSR_SYA = 0x0040 FR_SSR_NFA = 0x0020 FR_SSR_SUA = 0x0010 FR_SSR_SEA = 0x0008 FR_SSR_CEA = 0x0004 FR_SSR_BVA = 0x0002 FR_SSR_TCA = 0x0001
cd_cycle_max = 16000 c_cycle_count_max = 63 c_static_slot_id_max = 1023 c_slot_id_max = 2047 c_payload_length_max = 127 c_samples_per_bit = 8 c_sync_frame_id_count_max = 15 c_micro_per_macro_nom_min = 40 cd_min_mt_nom = 1 cd_max_mt_nom = 6 cd_fes = 2 cd_fss = 1 c_channel_idle_delimiter = 11 c_clock_deviation_max = 0.0015 c_strobe_offset = 5 c_voting_samples = 5 c_voting_delay = (cVotingSamples - 1) / 2 cd_bss = 2 cd_wakeup_symbol_tx_idle = 18 cd_wakeup_symbol_tx_low = 6 cd_cas = 30 c_micro_per_macro_min = 20 cd_max_offset_calculation = 1350 cd_max_rate_calculation = 1500 sizeof_uint16 = 2 sizeof_packet_header = SIZEOF_UINT16 * 2 packet_type_start_driver = 0 packet_type_flexray_frame = 1 packet_type_health = 2 packet_type_flexray_joined_cluster = 3 packet_type_flexray_join_cluster_failed = 4 packet_type_flexray_disconnected_from_cluster = 5 packet_type_flexray_fatal_error = 6 packet_type_monior_slots = 7 fr_pifr0_tbva_if_u16 = 8 fr_pifr0_tbvb_if_u16 = 16 fr_pifr0_ltxa_if_u16 = 32 fr_pifr0_ltxb_if_u16 = 64 fr_pier0_ccl_if_u16 = 512 fr_pifr0_moc_if_u16 = 1024 fr_pifr0_mrc_if_u16 = 2048 fr_pifr0_fatl_if_u16 = 32768 fr_pifr0_intl_if_u16 = 16384 fr_pifr0_ilcf_if_u16 = 8192 fr_pifr0_csa_if_u16 = 4096 fr_pier0_ti2_ie_u16 = 4 fr_pier0_ti1_ie_u16 = 2 fr_psr0_errmode_mask_u16 = 49152 fr_psr0_slotmode_mask_u16 = 12288 fr_psr0_protstate_mask_u16 = 1792 fr_psr0_startup_mask_u16 = 240 fr_psr0_wup_mask_u16 = 7 fr_psr0_slotmode_single_u16 = 0 fr_psr0_slotmode_all_pending_u16 = 4096 fr_psr0_slotmode_all_u16 = 8192 fr_psr0_errmode_active_u16 = 0 fr_psr0_errmode_passive_u16 = 16384 fr_psr0_errmode_comm_halt_u16 = 32768 fr_psr0_protstate_default_config_u16 = 0 fr_psr0_protstate_config_u16 = 256 fr_psr0_protstate_wakeup_u16 = 512 fr_psr0_protstate_ready_u16 = 768 fr_psr0_protstate_normal_passive_u16 = 1024 fr_psr0_protstate_normal_active_u16 = 1280 fr_psr0_protstate_halt_u16 = 1536 fr_psr0_protstate_startup_u16 = 1792 fr_psr0_startup_ccr_u16 = 32 fr_psr0_startup_cl_u16 = 48 fr_psr0_startup_icoc_u16 = 64 fr_psr0_startup_il_u16 = 80 fr_psr0_startup_is_u16 = 112 fr_psr0_startup_ccc_u16 = 160 fr_psr0_startup_iclc_u16 = 208 fr_psr0_startup_cg_u16 = 224 fr_psr0_startup_cj_u16 = 240 fr_psr1_cpn_u16 = 128 fr_psr1_hhr_u16 = 64 fr_psr1_frz_u16 = 32 fr_psr2_nbvb_mask_u16 = 32768 fr_psr2_nseb_mask_u16 = 16384 fr_psr2_stcb_mask_u16 = 8192 fr_psr2_sbvb_mask_u16 = 4096 fr_psr2_sseb_mask_u16 = 2048 fr_psr2_mtb_mask_u16 = 1024 fr_psr2_nbva_mask_u16 = 512 fr_psr2_nsea_mask_u16 = 256 fr_psr2_stca_mask_u16 = 128 fr_psr2_sbva_mask_u16 = 64 fr_psr2_ssea_mask_u16 = 32 fr_psr2_mta_mask_u16 = 16 fr_psr2_ckcorfcnt_mask_u16 = 15 fr_psr3_abvb_u16 = 4096 fr_psr3_aacb_u16 = 2048 fr_psr3_aceb_u16 = 1024 fr_psr3_aseb_u16 = 512 fr_psr3_avfb_u16 = 256 fr_psr3_abva_u16 = 16 fr_psr3_aaca_u16 = 8 fr_psr3_acea_u16 = 4 fr_psr3_asea_u16 = 2 fr_psr3_avfa_u16 = 1 fr_ssr_vfb = 32768 fr_ssr_syb = 16384 fr_ssr_nfb = 8192 fr_ssr_sub = 4096 fr_ssr_seb = 2048 fr_ssr_ceb = 1024 fr_ssr_bvb = 512 fr_ssr_tcb = 256 fr_ssr_vfa = 128 fr_ssr_sya = 64 fr_ssr_nfa = 32 fr_ssr_sua = 16 fr_ssr_sea = 8 fr_ssr_cea = 4 fr_ssr_bva = 2 fr_ssr_tca = 1
class Triple: def __init__(self, subject, predicate, object): self.subject = subject self.predicate = predicate self.object = object
class Triple: def __init__(self, subject, predicate, object): self.subject = subject self.predicate = predicate self.object = object
def main(): return 0 if __name__ == "__main__": for case in range(1, int(input()) + 1): print(f"Case #{case}:", main())
def main(): return 0 if __name__ == '__main__': for case in range(1, int(input()) + 1): print(f'Case #{case}:', main())
file = open('input.txt', 'r') Lines = file.readlines() count = 0 # Strips the newline character for line in Lines: line_parts = line.strip().split(' ') rule_part = line_parts[0].split('-') min_rule = int(rule_part[0]) max_rule = int(rule_part[1]) password = line_parts[2] char = line_parts[1][0] char_count = password.count(char) if max_rule >= char_count >= min_rule: count += 1 print(count)
file = open('input.txt', 'r') lines = file.readlines() count = 0 for line in Lines: line_parts = line.strip().split(' ') rule_part = line_parts[0].split('-') min_rule = int(rule_part[0]) max_rule = int(rule_part[1]) password = line_parts[2] char = line_parts[1][0] char_count = password.count(char) if max_rule >= char_count >= min_rule: count += 1 print(count)
# Roman numeral/Decimal converter # Roman to decimal conversion table RomanValue = { 'I' : 1, 'V' : 5, 'X' : 10, 'L' : 50, 'C' : 100, 'D' : 500, 'M' : 1000 } def RomanValueList (RomanNumber): number = [] for i in RomanNumber: number.append(RomanValue[i]) return number # Convert Roman number string to list of decimal conversion values def ToDecimal (number): # Expects a list from RomanValueList() answer = number[-1] # Start with the rightmost digit for i in range(len(number)-1,0,-1): # Digits offered in reverse right = i left = i-1 if left < 0: # Don't overrun the beginning of the list break # This should never happen anyway. else: # Process every pair of roman digits with a simple rule. if number[left] < number[right]: answer -= number[left] else: answer += number[left] return answer # Decimal to Roman conversion table ones = { 0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX' } tens = { 0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC' } huns = { 0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8: 'DCCC', 9: 'CM' } thous = { 0: '', 1: 'M', 2: 'MM', 3: 'MMM' } # Convert decimal int to Roman number string def ToRoman (x): # Expects an int 1 to 3999 one = x//1 % 10 # separate the place values ten = x//10 % 10 hun = x//100 % 10 thou = x//1000 % 10 return thous[thou] + huns[hun] + tens[ten] + ones[one] # Main code starts here # accepts improper Roman numbers such as IVMX. # may give unexpected conversions for improper Roman numbers. # IVMX converts to 1004. 1004 should be MIV in modern standard notation. # Does not accept 0, or over large or fractional decimal numbers. stop = False while not stop: baddata = False while not baddata: number = '' while number == '': number = input ("Enter number to convert: ") number = number.upper() # Anything other than decimal digits, decimal point, or Roman digits is rejected. decimal = Roman = True for i in number: if i not in {'0','1','2','3','4','5','6','7','8','9'}: decimal = False if i not in {'I','V','X','L','C','D','M'}: # 2 Sets of acceptable chars. Roman = False if not decimal and not Roman: # Neither type entered. if number == 'Q': stop = True # Trying to end the prog here. break # Breaks baddata loop. else: print ("Decimal (1 to 3999) or Roman numbers only, please.") continue # Get another input. Continues baddata loop. else: # Process the number input if decimal: if (int(number) < 1) or (int(number) > 3999): print ("Decimal (1 to 3999) or Roman numbers only, please.") continue answer = ToRoman(int(number)) elif Roman: answer = ToDecimal(RomanValueList (number)) print (number, " converts to ", answer) # Main code stops here
roman_value = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} def roman_value_list(RomanNumber): number = [] for i in RomanNumber: number.append(RomanValue[i]) return number def to_decimal(number): answer = number[-1] for i in range(len(number) - 1, 0, -1): right = i left = i - 1 if left < 0: break elif number[left] < number[right]: answer -= number[left] else: answer += number[left] return answer ones = {0: '', 1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 6: 'VI', 7: 'VII', 8: 'VIII', 9: 'IX'} tens = {0: '', 1: 'X', 2: 'XX', 3: 'XXX', 4: 'XL', 5: 'L', 6: 'LX', 7: 'LXX', 8: 'LXXX', 9: 'XC'} huns = {0: '', 1: 'C', 2: 'CC', 3: 'CCC', 4: 'CD', 5: 'D', 6: 'DC', 7: 'DCC', 8: 'DCCC', 9: 'CM'} thous = {0: '', 1: 'M', 2: 'MM', 3: 'MMM'} def to_roman(x): one = x // 1 % 10 ten = x // 10 % 10 hun = x // 100 % 10 thou = x // 1000 % 10 return thous[thou] + huns[hun] + tens[ten] + ones[one] stop = False while not stop: baddata = False while not baddata: number = '' while number == '': number = input('Enter number to convert: ') number = number.upper() decimal = roman = True for i in number: if i not in {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}: decimal = False if i not in {'I', 'V', 'X', 'L', 'C', 'D', 'M'}: roman = False if not decimal and (not Roman): if number == 'Q': stop = True break else: print('Decimal (1 to 3999) or Roman numbers only, please.') continue elif decimal: if int(number) < 1 or int(number) > 3999: print('Decimal (1 to 3999) or Roman numbers only, please.') continue answer = to_roman(int(number)) elif Roman: answer = to_decimal(roman_value_list(number)) print(number, ' converts to ', answer)
# Python Program To Handle Multiple Exceptions def avg(list): tot = 0 for x in list: tot += x avg = tot/len(list) return tot, avg # Call The avg() And Pass A List try: t, a = avg([1,2,3,4,5,'a']) # Here Give Empty List And try print('Total = {}, Average = {}'.format(t, a)) except TypeError: print('Type Error, Please Provide Numbers.') except ZeroDivisionError: print('ZeroDivisionError, Please Do Not Give Empty List. ')
def avg(list): tot = 0 for x in list: tot += x avg = tot / len(list) return (tot, avg) try: (t, a) = avg([1, 2, 3, 4, 5, 'a']) print('Total = {}, Average = {}'.format(t, a)) except TypeError: print('Type Error, Please Provide Numbers.') except ZeroDivisionError: print('ZeroDivisionError, Please Do Not Give Empty List. ')
def dataset(): pass def model(): pass def loss(): pass def opt(): pass
def dataset(): pass def model(): pass def loss(): pass def opt(): pass
class Response: def __init__(self, message=None, data=None): self.message = message self.data = data def build(self): return { "message": self.message, "data": self.data }
class Response: def __init__(self, message=None, data=None): self.message = message self.data = data def build(self): return {'message': self.message, 'data': self.data}
def main(): double_letters = 0 triple_letters = 0 input_file = open('input', 'r') for line in input_file: double_letters_found = False triple_letters_found = False characters = set(line.replace('\n', '')) for character in characters: if not double_letters_found and (line.count(character) == 2): double_letters += 1 double_letters_found = True elif not triple_letters_found and (line.count(character) == 3): triple_letters += 1 triple_letters_found = True if double_letters_found and triple_letters_found: break checksum = double_letters * triple_letters print(checksum) if __name__ == "__main__": main()
def main(): double_letters = 0 triple_letters = 0 input_file = open('input', 'r') for line in input_file: double_letters_found = False triple_letters_found = False characters = set(line.replace('\n', '')) for character in characters: if not double_letters_found and line.count(character) == 2: double_letters += 1 double_letters_found = True elif not triple_letters_found and line.count(character) == 3: triple_letters += 1 triple_letters_found = True if double_letters_found and triple_letters_found: break checksum = double_letters * triple_letters print(checksum) if __name__ == '__main__': main()
coordinates_E0E1E1 = ((129, 120), (129, 122), (129, 124), (130, 124), (131, 124), (132, 124), (133, 124), (134, 124), (135, 124), (136, 123), (136, 132), (137, 119), (137, 123), (138, 119), (138, 122), (139, 120), (139, 122), (140, 121), (140, 123), (141, 121), (141, 126), (142, 113), (142, 115), (142, 121), (142, 123), (143, 112), (143, 116), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 124), (144, 113), (144, 114), (144, 115), (144, 121), (144, 122), (144, 124), (145, 110), (145, 113), (145, 114), (145, 115), (145, 116), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 133), (146, 111), (146, 113), (146, 114), (146, 115), (146, 116), (146, 117), (146, 118), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 129), (146, 130), (146, 131), (146, 133), (147, 112), (147, 114), (147, 115), (147, 116), (147, 117), (147, 118), (147, 120), (147, 127), (147, 131), (147, 132), (148, 113), (148, 115), (148, 116), (148, 117), (148, 118), (148, 119), (148, 121), (148, 127), (148, 129), (149, 114), (149, 117), (149, 118), (149, 119), (149, 120), (149, 122), (149, 128), (150, 115), (150, 116), (150, 119), (150, 120), (150, 121), (150, 124), (150, 125), (150, 127), (151, 117), (151, 122), (151, 126), (152, 120), (152, 123), (152, 125), (153, 125), (154, 123), (154, 125), (155, 124), (155, 125), ) coordinates_E1E1E1 = ((99, 118), (100, 118), (101, 118), (101, 119), (102, 118), (102, 119), (102, 126), (102, 128), (102, 134), (103, 117), (103, 119), (103, 126), (103, 129), (103, 130), (103, 131), (103, 132), (103, 133), (103, 135), (104, 117), (104, 120), (104, 127), (104, 130), (104, 135), (105, 118), (105, 120), (105, 128), (105, 130), (105, 135), (106, 119), (106, 121), (106, 128), (106, 131), (106, 134), (107, 120), (107, 121), (107, 127), (107, 131), (108, 122), (108, 124), (108, 125), (108, 128), (108, 130), (109, 123), (109, 126), (110, 112), (110, 125), (111, 111), (111, 125), (112, 110), (113, 125), (113, 126), (114, 120), (114, 124), (114, 126), (115, 125), (115, 127), (116, 128), (117, 128), ) coordinates_016400 = ((126, 134), (127, 134), (127, 136), (128, 134), (128, 137), (129, 134), (129, 137), (130, 134), (130, 136), (130, 138), (131, 133), (131, 134), (131, 136), (131, 138), (132, 133), (132, 135), (132, 136), (132, 138), (133, 134), (133, 136), (133, 137), (133, 139), (134, 134), (134, 136), (134, 137), (134, 138), (134, 141), (135, 134), (135, 136), (135, 137), (135, 138), (135, 140), (136, 135), (136, 137), (136, 138), (136, 140), (137, 140), (138, 132), (138, 134), (138, 135), (138, 136), (138, 137), (139, 133), (139, 139), (139, 140), (140, 131), (141, 130), (142, 128), (142, 129), ) coordinates_006400 = ((105, 133), (109, 132), (110, 135), (110, 136), (110, 137), (110, 138), (110, 139), (110, 140), (110, 142), (111, 133), (111, 142), (112, 134), (112, 139), (112, 140), (112, 142), (113, 137), (113, 138), (113, 139), (113, 140), (113, 141), (113, 143), (114, 139), (114, 142), (115, 138), (115, 139), (116, 138), (116, 141), (117, 138), (117, 140), (118, 138), (118, 139), (119, 137), (119, 138), ) coordinates_6395ED = ((125, 131), (126, 129), (126, 131), (127, 128), (127, 132), (128, 127), (128, 129), (128, 130), (128, 132), (129, 126), (129, 128), (129, 129), (129, 130), (129, 132), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 132), (131, 126), (131, 128), (131, 129), (131, 131), (132, 126), (132, 128), (132, 129), (132, 131), (133, 126), (133, 128), (133, 129), (133, 131), (134, 126), (134, 128), (134, 129), (134, 131), (135, 126), (135, 128), (135, 130), (136, 126), (136, 128), (136, 130), (137, 125), (137, 130), (138, 124), (138, 127), (138, 129), (139, 125), ) coordinates_00FFFE = ((140, 137), (141, 137), (141, 139), (142, 137), (142, 141), (143, 138), (143, 142), (144, 138), (144, 140), (144, 142), (145, 138), (145, 140), (145, 142), (146, 138), (146, 142), (147, 139), ) coordinates_F98072 = ((124, 114), (124, 116), (124, 117), (124, 118), (124, 119), (124, 120), (124, 121), (125, 113), (125, 122), (125, 123), (125, 124), (125, 125), (125, 127), (126, 112), (126, 114), (126, 115), (126, 116), (127, 112), (127, 114), (127, 115), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 125), (128, 112), (128, 114), (129, 111), (129, 113), (129, 115), (130, 111), (130, 114), (131, 111), (131, 113), (132, 112), (133, 104), (133, 106), (133, 107), (133, 108), (133, 109), (134, 106), (134, 108), (134, 109), ) coordinates_97FB98 = ((140, 135), (141, 133), (141, 135), (142, 132), (142, 135), (143, 126), (143, 127), (143, 130), (143, 131), (143, 132), (143, 133), (143, 135), (144, 126), (144, 128), (144, 129), (144, 130), (144, 135), (145, 135), (145, 136), (146, 136), (147, 135), (147, 137), (148, 134), (148, 136), (148, 138), (149, 131), (149, 133), (149, 135), (149, 137), (149, 138), (150, 130), (150, 134), (150, 136), (151, 131), (151, 133), (151, 135), (152, 131), (152, 133), (152, 135), (153, 131), (153, 133), (153, 135), (154, 131), (154, 133), (154, 135), (154, 136), (155, 131), (155, 132), (155, 133), (155, 134), (155, 136), (156, 131), (156, 133), (156, 134), (156, 137), (157, 131), (157, 136), (158, 131), (158, 133), (158, 134), ) coordinates_6495ED = ((110, 128), (110, 130), (111, 127), (111, 131), (112, 128), (112, 131), (113, 128), (113, 130), (114, 129), (114, 131), (114, 134), (115, 129), (115, 131), (115, 132), (115, 133), (115, 136), (116, 130), (116, 132), (116, 133), (116, 134), (116, 136), (117, 130), (117, 132), (117, 133), (117, 134), (117, 136), (118, 131), (118, 133), (118, 135), (119, 132), (119, 135), (120, 133), (120, 135), ) coordinates_FA8072 = ((111, 113), (112, 113), (112, 115), (113, 111), (113, 117), (114, 109), (114, 113), (114, 114), (114, 115), (114, 118), (115, 108), (115, 111), (115, 112), (115, 113), (115, 114), (115, 115), (115, 116), (115, 118), (116, 107), (116, 109), (116, 110), (116, 111), (116, 112), (116, 113), (116, 114), (116, 115), (116, 116), (116, 117), (116, 118), (116, 119), (117, 106), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 121), (117, 122), (117, 123), (117, 125), (118, 106), (118, 108), (118, 109), (118, 110), (118, 111), (118, 112), (118, 115), (118, 116), (118, 117), (118, 118), (118, 119), (118, 126), (119, 113), (119, 114), (119, 119), (119, 120), (119, 121), (119, 122), (119, 123), (119, 124), (119, 125), (119, 129), (120, 116), (120, 117), (120, 118), (120, 123), (120, 124), (120, 125), (120, 126), (120, 130), (121, 119), (121, 120), (121, 121), (121, 122), (121, 123), (121, 131), (122, 124), (122, 125), (122, 126), (122, 127), (122, 128), (122, 130), ) coordinates_98FB98 = ((88, 135), (89, 134), (89, 136), (90, 133), (90, 136), (91, 132), (91, 134), (91, 135), (91, 137), (92, 131), (92, 133), (92, 134), (92, 135), (92, 136), (92, 141), (93, 131), (93, 133), (93, 134), (93, 135), (93, 136), (93, 137), (93, 139), (93, 140), (93, 142), (94, 130), (94, 132), (94, 133), (94, 134), (94, 135), (94, 136), (94, 137), (94, 138), (94, 143), (95, 130), (95, 132), (95, 133), (95, 136), (95, 137), (95, 138), (95, 139), (95, 140), (95, 141), (95, 143), (96, 131), (96, 133), (96, 134), (96, 135), (96, 136), (96, 137), (96, 138), (96, 139), (96, 140), (96, 141), (96, 143), (97, 131), (97, 133), (97, 136), (97, 138), (97, 139), (97, 140), (97, 141), (97, 143), (98, 132), (98, 133), (98, 136), (98, 138), (98, 139), (98, 140), (98, 141), (98, 143), (99, 132), (99, 135), (99, 136), (99, 137), (99, 138), (99, 139), (99, 140), (99, 141), (99, 143), (100, 133), (100, 137), (100, 138), (100, 139), (100, 140), (100, 141), (100, 143), (101, 136), (101, 138), (101, 139), (101, 140), (101, 141), (101, 143), (102, 137), (102, 139), (102, 140), (102, 142), (103, 137), (103, 139), (103, 140), (103, 142), (104, 137), (104, 138), (104, 139), (104, 140), (104, 142), (105, 137), (105, 139), (105, 140), (105, 142), (106, 137), (106, 139), (106, 140), (106, 142), (107, 136), (107, 142), (108, 135), (108, 137), (108, 138), (108, 139), (108, 140), (108, 142), ) coordinates_FEC0CB = ((130, 117), (130, 119), (131, 115), (131, 121), (132, 114), (132, 117), (132, 118), (132, 119), (132, 122), (133, 113), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 122), (134, 111), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 122), (135, 104), (135, 110), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 119), (135, 120), (136, 104), (136, 106), (136, 107), (136, 108), (136, 109), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (137, 104), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 117), (138, 105), (138, 108), (138, 109), (138, 110), (138, 111), (138, 112), (138, 113), (138, 114), (138, 115), (138, 117), (139, 109), (139, 111), (139, 117), (140, 109), (140, 111), (140, 113), (140, 114), (140, 115), (140, 118), (141, 109), (141, 111), (141, 117), (141, 119), (142, 109), (142, 111), (143, 109), (143, 110), (144, 109), (145, 108), (147, 109), (148, 109), (148, 110), (148, 125), (149, 111), (150, 110), (151, 111), (151, 114), (152, 113), (152, 115), (152, 128), (152, 129), (153, 115), (153, 117), (153, 118), (153, 129), (154, 118), (154, 120), (154, 127), (154, 129), (155, 120), (155, 121), (155, 127), (155, 129), (156, 121), (156, 122), (156, 126), (156, 127), (156, 129), (157, 122), (157, 124), (157, 125), (157, 127), (157, 129), (158, 123), (158, 126), (158, 129), (159, 124), (159, 127), (160, 126), ) coordinates_333287 = ((88, 125), (88, 127), (89, 124), (89, 128), (90, 123), (90, 125), (90, 126), (90, 127), (90, 129), (91, 123), (91, 125), (91, 126), (91, 127), (91, 129), (92, 124), (92, 126), (92, 127), (92, 129), (93, 124), (93, 126), (93, 128), (94, 124), (94, 126), (94, 128), (95, 125), (95, 128), (96, 126), (96, 128), ) coordinates_FFC0CB = ((92, 115), (92, 116), (92, 117), (92, 119), (93, 112), (93, 114), (93, 120), (94, 111), (94, 115), (94, 116), (94, 117), (94, 118), (94, 119), (94, 121), (95, 110), (95, 112), (95, 113), (95, 114), (95, 115), (95, 116), (95, 117), (95, 118), (95, 119), (95, 121), (96, 109), (96, 111), (96, 112), (96, 113), (96, 114), (96, 115), (96, 116), (96, 117), (96, 120), (97, 109), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97, 116), (97, 118), (97, 120), (97, 121), (97, 124), (98, 108), (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98, 116), (98, 117), (98, 120), (98, 122), (98, 126), (98, 127), (98, 129), (99, 108), (99, 110), (99, 111), (99, 112), (99, 113), (99, 114), (99, 116), (99, 120), (99, 122), (99, 123), (99, 124), (99, 126), (99, 130), (100, 108), (100, 110), (100, 111), (100, 112), (100, 113), (100, 114), (100, 116), (100, 121), (100, 124), (100, 127), (100, 129), (100, 131), (101, 108), (101, 110), (101, 111), (101, 112), (101, 113), (101, 114), (101, 116), (101, 121), (101, 123), (101, 130), (101, 132), (102, 108), (102, 111), (102, 112), (102, 113), (102, 115), (102, 121), (102, 123), (103, 109), (103, 110), (103, 112), (103, 113), (103, 115), (103, 122), (103, 124), (104, 110), (104, 112), (104, 113), (104, 115), (104, 122), (104, 125), (105, 110), (105, 112), (105, 113), (105, 114), (105, 116), (105, 122), (105, 125), (106, 110), (106, 112), (106, 113), (106, 114), (106, 116), (106, 123), (106, 125), (107, 108), (107, 110), (107, 114), (107, 115), (107, 117), (108, 106), (108, 112), (108, 115), (108, 116), (108, 119), (109, 108), (109, 110), (109, 114), (109, 117), (109, 120), (110, 106), (110, 109), (110, 115), (110, 119), (110, 122), (111, 106), (111, 108), (111, 117), (111, 123), (112, 107), (112, 108), (112, 119), (112, 123), (113, 107), (113, 121), (113, 122), (115, 105), )
coordinates_e0_e1_e1 = ((129, 120), (129, 122), (129, 124), (130, 124), (131, 124), (132, 124), (133, 124), (134, 124), (135, 124), (136, 123), (136, 132), (137, 119), (137, 123), (138, 119), (138, 122), (139, 120), (139, 122), (140, 121), (140, 123), (141, 121), (141, 126), (142, 113), (142, 115), (142, 121), (142, 123), (143, 112), (143, 116), (143, 117), (143, 118), (143, 119), (143, 120), (143, 121), (143, 122), (143, 124), (144, 113), (144, 114), (144, 115), (144, 121), (144, 122), (144, 124), (145, 110), (145, 113), (145, 114), (145, 115), (145, 116), (145, 117), (145, 118), (145, 119), (145, 120), (145, 121), (145, 133), (146, 111), (146, 113), (146, 114), (146, 115), (146, 116), (146, 117), (146, 118), (146, 119), (146, 120), (146, 121), (146, 122), (146, 123), (146, 124), (146, 125), (146, 126), (146, 127), (146, 128), (146, 129), (146, 130), (146, 131), (146, 133), (147, 112), (147, 114), (147, 115), (147, 116), (147, 117), (147, 118), (147, 120), (147, 127), (147, 131), (147, 132), (148, 113), (148, 115), (148, 116), (148, 117), (148, 118), (148, 119), (148, 121), (148, 127), (148, 129), (149, 114), (149, 117), (149, 118), (149, 119), (149, 120), (149, 122), (149, 128), (150, 115), (150, 116), (150, 119), (150, 120), (150, 121), (150, 124), (150, 125), (150, 127), (151, 117), (151, 122), (151, 126), (152, 120), (152, 123), (152, 125), (153, 125), (154, 123), (154, 125), (155, 124), (155, 125)) coordinates_e1_e1_e1 = ((99, 118), (100, 118), (101, 118), (101, 119), (102, 118), (102, 119), (102, 126), (102, 128), (102, 134), (103, 117), (103, 119), (103, 126), (103, 129), (103, 130), (103, 131), (103, 132), (103, 133), (103, 135), (104, 117), (104, 120), (104, 127), (104, 130), (104, 135), (105, 118), (105, 120), (105, 128), (105, 130), (105, 135), (106, 119), (106, 121), (106, 128), (106, 131), (106, 134), (107, 120), (107, 121), (107, 127), (107, 131), (108, 122), (108, 124), (108, 125), (108, 128), (108, 130), (109, 123), (109, 126), (110, 112), (110, 125), (111, 111), (111, 125), (112, 110), (113, 125), (113, 126), (114, 120), (114, 124), (114, 126), (115, 125), (115, 127), (116, 128), (117, 128)) coordinates_016400 = ((126, 134), (127, 134), (127, 136), (128, 134), (128, 137), (129, 134), (129, 137), (130, 134), (130, 136), (130, 138), (131, 133), (131, 134), (131, 136), (131, 138), (132, 133), (132, 135), (132, 136), (132, 138), (133, 134), (133, 136), (133, 137), (133, 139), (134, 134), (134, 136), (134, 137), (134, 138), (134, 141), (135, 134), (135, 136), (135, 137), (135, 138), (135, 140), (136, 135), (136, 137), (136, 138), (136, 140), (137, 140), (138, 132), (138, 134), (138, 135), (138, 136), (138, 137), (139, 133), (139, 139), (139, 140), (140, 131), (141, 130), (142, 128), (142, 129)) coordinates_006400 = ((105, 133), (109, 132), (110, 135), (110, 136), (110, 137), (110, 138), (110, 139), (110, 140), (110, 142), (111, 133), (111, 142), (112, 134), (112, 139), (112, 140), (112, 142), (113, 137), (113, 138), (113, 139), (113, 140), (113, 141), (113, 143), (114, 139), (114, 142), (115, 138), (115, 139), (116, 138), (116, 141), (117, 138), (117, 140), (118, 138), (118, 139), (119, 137), (119, 138)) coordinates_6395_ed = ((125, 131), (126, 129), (126, 131), (127, 128), (127, 132), (128, 127), (128, 129), (128, 130), (128, 132), (129, 126), (129, 128), (129, 129), (129, 130), (129, 132), (130, 126), (130, 127), (130, 128), (130, 129), (130, 130), (130, 132), (131, 126), (131, 128), (131, 129), (131, 131), (132, 126), (132, 128), (132, 129), (132, 131), (133, 126), (133, 128), (133, 129), (133, 131), (134, 126), (134, 128), (134, 129), (134, 131), (135, 126), (135, 128), (135, 130), (136, 126), (136, 128), (136, 130), (137, 125), (137, 130), (138, 124), (138, 127), (138, 129), (139, 125)) coordinates_00_fffe = ((140, 137), (141, 137), (141, 139), (142, 137), (142, 141), (143, 138), (143, 142), (144, 138), (144, 140), (144, 142), (145, 138), (145, 140), (145, 142), (146, 138), (146, 142), (147, 139)) coordinates_f98072 = ((124, 114), (124, 116), (124, 117), (124, 118), (124, 119), (124, 120), (124, 121), (125, 113), (125, 122), (125, 123), (125, 124), (125, 125), (125, 127), (126, 112), (126, 114), (126, 115), (126, 116), (127, 112), (127, 114), (127, 115), (127, 118), (127, 119), (127, 120), (127, 121), (127, 122), (127, 123), (127, 125), (128, 112), (128, 114), (129, 111), (129, 113), (129, 115), (130, 111), (130, 114), (131, 111), (131, 113), (132, 112), (133, 104), (133, 106), (133, 107), (133, 108), (133, 109), (134, 106), (134, 108), (134, 109)) coordinates_97_fb98 = ((140, 135), (141, 133), (141, 135), (142, 132), (142, 135), (143, 126), (143, 127), (143, 130), (143, 131), (143, 132), (143, 133), (143, 135), (144, 126), (144, 128), (144, 129), (144, 130), (144, 135), (145, 135), (145, 136), (146, 136), (147, 135), (147, 137), (148, 134), (148, 136), (148, 138), (149, 131), (149, 133), (149, 135), (149, 137), (149, 138), (150, 130), (150, 134), (150, 136), (151, 131), (151, 133), (151, 135), (152, 131), (152, 133), (152, 135), (153, 131), (153, 133), (153, 135), (154, 131), (154, 133), (154, 135), (154, 136), (155, 131), (155, 132), (155, 133), (155, 134), (155, 136), (156, 131), (156, 133), (156, 134), (156, 137), (157, 131), (157, 136), (158, 131), (158, 133), (158, 134)) coordinates_6495_ed = ((110, 128), (110, 130), (111, 127), (111, 131), (112, 128), (112, 131), (113, 128), (113, 130), (114, 129), (114, 131), (114, 134), (115, 129), (115, 131), (115, 132), (115, 133), (115, 136), (116, 130), (116, 132), (116, 133), (116, 134), (116, 136), (117, 130), (117, 132), (117, 133), (117, 134), (117, 136), (118, 131), (118, 133), (118, 135), (119, 132), (119, 135), (120, 133), (120, 135)) coordinates_fa8072 = ((111, 113), (112, 113), (112, 115), (113, 111), (113, 117), (114, 109), (114, 113), (114, 114), (114, 115), (114, 118), (115, 108), (115, 111), (115, 112), (115, 113), (115, 114), (115, 115), (115, 116), (115, 118), (116, 107), (116, 109), (116, 110), (116, 111), (116, 112), (116, 113), (116, 114), (116, 115), (116, 116), (116, 117), (116, 118), (116, 119), (117, 106), (117, 113), (117, 114), (117, 115), (117, 116), (117, 117), (117, 118), (117, 121), (117, 122), (117, 123), (117, 125), (118, 106), (118, 108), (118, 109), (118, 110), (118, 111), (118, 112), (118, 115), (118, 116), (118, 117), (118, 118), (118, 119), (118, 126), (119, 113), (119, 114), (119, 119), (119, 120), (119, 121), (119, 122), (119, 123), (119, 124), (119, 125), (119, 129), (120, 116), (120, 117), (120, 118), (120, 123), (120, 124), (120, 125), (120, 126), (120, 130), (121, 119), (121, 120), (121, 121), (121, 122), (121, 123), (121, 131), (122, 124), (122, 125), (122, 126), (122, 127), (122, 128), (122, 130)) coordinates_98_fb98 = ((88, 135), (89, 134), (89, 136), (90, 133), (90, 136), (91, 132), (91, 134), (91, 135), (91, 137), (92, 131), (92, 133), (92, 134), (92, 135), (92, 136), (92, 141), (93, 131), (93, 133), (93, 134), (93, 135), (93, 136), (93, 137), (93, 139), (93, 140), (93, 142), (94, 130), (94, 132), (94, 133), (94, 134), (94, 135), (94, 136), (94, 137), (94, 138), (94, 143), (95, 130), (95, 132), (95, 133), (95, 136), (95, 137), (95, 138), (95, 139), (95, 140), (95, 141), (95, 143), (96, 131), (96, 133), (96, 134), (96, 135), (96, 136), (96, 137), (96, 138), (96, 139), (96, 140), (96, 141), (96, 143), (97, 131), (97, 133), (97, 136), (97, 138), (97, 139), (97, 140), (97, 141), (97, 143), (98, 132), (98, 133), (98, 136), (98, 138), (98, 139), (98, 140), (98, 141), (98, 143), (99, 132), (99, 135), (99, 136), (99, 137), (99, 138), (99, 139), (99, 140), (99, 141), (99, 143), (100, 133), (100, 137), (100, 138), (100, 139), (100, 140), (100, 141), (100, 143), (101, 136), (101, 138), (101, 139), (101, 140), (101, 141), (101, 143), (102, 137), (102, 139), (102, 140), (102, 142), (103, 137), (103, 139), (103, 140), (103, 142), (104, 137), (104, 138), (104, 139), (104, 140), (104, 142), (105, 137), (105, 139), (105, 140), (105, 142), (106, 137), (106, 139), (106, 140), (106, 142), (107, 136), (107, 142), (108, 135), (108, 137), (108, 138), (108, 139), (108, 140), (108, 142)) coordinates_fec0_cb = ((130, 117), (130, 119), (131, 115), (131, 121), (132, 114), (132, 117), (132, 118), (132, 119), (132, 122), (133, 113), (133, 116), (133, 117), (133, 118), (133, 119), (133, 120), (133, 122), (134, 111), (134, 114), (134, 115), (134, 116), (134, 117), (134, 118), (134, 122), (135, 104), (135, 110), (135, 113), (135, 114), (135, 115), (135, 116), (135, 117), (135, 119), (135, 120), (136, 104), (136, 106), (136, 107), (136, 108), (136, 109), (136, 111), (136, 112), (136, 113), (136, 114), (136, 115), (136, 116), (136, 117), (137, 104), (137, 110), (137, 111), (137, 112), (137, 113), (137, 114), (137, 115), (137, 117), (138, 105), (138, 108), (138, 109), (138, 110), (138, 111), (138, 112), (138, 113), (138, 114), (138, 115), (138, 117), (139, 109), (139, 111), (139, 117), (140, 109), (140, 111), (140, 113), (140, 114), (140, 115), (140, 118), (141, 109), (141, 111), (141, 117), (141, 119), (142, 109), (142, 111), (143, 109), (143, 110), (144, 109), (145, 108), (147, 109), (148, 109), (148, 110), (148, 125), (149, 111), (150, 110), (151, 111), (151, 114), (152, 113), (152, 115), (152, 128), (152, 129), (153, 115), (153, 117), (153, 118), (153, 129), (154, 118), (154, 120), (154, 127), (154, 129), (155, 120), (155, 121), (155, 127), (155, 129), (156, 121), (156, 122), (156, 126), (156, 127), (156, 129), (157, 122), (157, 124), (157, 125), (157, 127), (157, 129), (158, 123), (158, 126), (158, 129), (159, 124), (159, 127), (160, 126)) coordinates_333287 = ((88, 125), (88, 127), (89, 124), (89, 128), (90, 123), (90, 125), (90, 126), (90, 127), (90, 129), (91, 123), (91, 125), (91, 126), (91, 127), (91, 129), (92, 124), (92, 126), (92, 127), (92, 129), (93, 124), (93, 126), (93, 128), (94, 124), (94, 126), (94, 128), (95, 125), (95, 128), (96, 126), (96, 128)) coordinates_ffc0_cb = ((92, 115), (92, 116), (92, 117), (92, 119), (93, 112), (93, 114), (93, 120), (94, 111), (94, 115), (94, 116), (94, 117), (94, 118), (94, 119), (94, 121), (95, 110), (95, 112), (95, 113), (95, 114), (95, 115), (95, 116), (95, 117), (95, 118), (95, 119), (95, 121), (96, 109), (96, 111), (96, 112), (96, 113), (96, 114), (96, 115), (96, 116), (96, 117), (96, 120), (97, 109), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97, 116), (97, 118), (97, 120), (97, 121), (97, 124), (98, 108), (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98, 116), (98, 117), (98, 120), (98, 122), (98, 126), (98, 127), (98, 129), (99, 108), (99, 110), (99, 111), (99, 112), (99, 113), (99, 114), (99, 116), (99, 120), (99, 122), (99, 123), (99, 124), (99, 126), (99, 130), (100, 108), (100, 110), (100, 111), (100, 112), (100, 113), (100, 114), (100, 116), (100, 121), (100, 124), (100, 127), (100, 129), (100, 131), (101, 108), (101, 110), (101, 111), (101, 112), (101, 113), (101, 114), (101, 116), (101, 121), (101, 123), (101, 130), (101, 132), (102, 108), (102, 111), (102, 112), (102, 113), (102, 115), (102, 121), (102, 123), (103, 109), (103, 110), (103, 112), (103, 113), (103, 115), (103, 122), (103, 124), (104, 110), (104, 112), (104, 113), (104, 115), (104, 122), (104, 125), (105, 110), (105, 112), (105, 113), (105, 114), (105, 116), (105, 122), (105, 125), (106, 110), (106, 112), (106, 113), (106, 114), (106, 116), (106, 123), (106, 125), (107, 108), (107, 110), (107, 114), (107, 115), (107, 117), (108, 106), (108, 112), (108, 115), (108, 116), (108, 119), (109, 108), (109, 110), (109, 114), (109, 117), (109, 120), (110, 106), (110, 109), (110, 115), (110, 119), (110, 122), (111, 106), (111, 108), (111, 117), (111, 123), (112, 107), (112, 108), (112, 119), (112, 123), (113, 107), (113, 121), (113, 122), (115, 105))
num = int(input('digite um numero pra daber sua tabuada: ')) for rep in range(0, 11): print('{} x {:2} = {}'.format(rep, num, num*rep))
num = int(input('digite um numero pra daber sua tabuada: ')) for rep in range(0, 11): print('{} x {:2} = {}'.format(rep, num, num * rep))
class Solution: def bstFromPreorder(self, preorder: List[int]) -> TreeNode: if len(preorder)==0: return None tn=TreeNode(preorder[0]) l=[] r=[] for i in preorder: if i<preorder[0]: l.append(i) elif i>preorder[0]: r.append(i) tn.left=self.bstFromPreorder(l) tn.right=self.bstFromPreorder(r) return tn
class Solution: def bst_from_preorder(self, preorder: List[int]) -> TreeNode: if len(preorder) == 0: return None tn = tree_node(preorder[0]) l = [] r = [] for i in preorder: if i < preorder[0]: l.append(i) elif i > preorder[0]: r.append(i) tn.left = self.bstFromPreorder(l) tn.right = self.bstFromPreorder(r) return tn
n = int(input('digite um numero de 1 a 9999: ')) u = n % 10 d = n // 10 % 10 c = n // 100 % 10 m = n // 1000 % 10 print('A unidade', u) print('A dezena', d) print('A centena', c) print('A milhar', m)
n = int(input('digite um numero de 1 a 9999: ')) u = n % 10 d = n // 10 % 10 c = n // 100 % 10 m = n // 1000 % 10 print('A unidade', u) print('A dezena', d) print('A centena', c) print('A milhar', m)
def stair(n): if n == 0 or n == 1: return 1 elif n == 2: return 2 elif n == 3: return 4 else: return stair(n-3) + stair(n-2) + stair(n-1) n = int(input()) print(stair(n))
def stair(n): if n == 0 or n == 1: return 1 elif n == 2: return 2 elif n == 3: return 4 else: return stair(n - 3) + stair(n - 2) + stair(n - 1) n = int(input()) print(stair(n))
# # PySNMP MIB module CADANT-CMTS-EXPORTIMPORT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CADANT-CMTS-EXPORTIMPORT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:27:10 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, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion") trapSeverity, trapCounter = mibBuilder.importSymbols("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity", "trapCounter") cadExperimental, = mibBuilder.importSymbols("CADANT-PRODUCTS-MIB", "cadExperimental") InterfaceIndexOrZero, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Integer32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Counter64, iso, TimeTicks, Gauge32, ObjectIdentity, IpAddress, Bits, MibIdentifier, Counter32, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Counter64", "iso", "TimeTicks", "Gauge32", "ObjectIdentity", "IpAddress", "Bits", "MibIdentifier", "Counter32", "NotificationType") TextualConvention, DisplayString, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "TruthValue") cadExportImportMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1)) cadExportImportMib.setRevisions(('2001-03-09 00:00', '2004-02-13 00:00', '2004-02-16 00:00',)) if mibBuilder.loadTexts: cadExportImportMib.setLastUpdated('200402160000Z') if mibBuilder.loadTexts: cadExportImportMib.setOrganization('Arris International Inc.') class ExportImportAction(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4)) namedValues = NamedValues(("noop", 0), ("export", 1), ("import", 2), ("pCmCertExport", 3), ("caCertExport", 4)) class ExportResult(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5)) namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNameTooLong", 2), ("invalidCharactersInFilename", 3), ("fileSystemFull", 4), ("otherError", 5)) class ImportResult(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4)) namedValues = NamedValues(("unknown", 0), ("success", 1), ("fileNotFound", 2), ("fileDecodingError", 3), ("otherError", 4)) cadCmtsExportImportGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1)) cadCmtsExportImportFilename = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 1), DisplayString().clone('update:/export.txt')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportFilename.setStatus('current') cadCmtsExportImportAction = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 2), ExportImportAction().clone('noop')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportAction.setStatus('current') cadCmtsExportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 3), ExportResult().clone('unknown')).setMaxAccess("readonly") if mibBuilder.loadTexts: cadCmtsExportResult.setStatus('current') cadCmtsImportResult = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 4), ImportResult().clone('unknown')).setMaxAccess("readonly") if mibBuilder.loadTexts: cadCmtsImportResult.setStatus('current') cadCmtsExportImportWithLineNums = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 5), TruthValue().clone('false')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportWithLineNums.setStatus('current') cadCmtsExportImportWithDefaults = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 6), TruthValue().clone('false')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportWithDefaults.setStatus('current') cadCmtsExportImportNested = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 7), TruthValue().clone('true')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportNested.setStatus('current') cadCmtsExportImportWithCertificates = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 8), TruthValue().clone('true')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportWithCertificates.setStatus('current') cadCmtsExportImportIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 9), InterfaceIndexOrZero()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cadCmtsExportImportIfIndex.setStatus('current') cadCmtsExportImportTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0)) cadCmtsExportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 1)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsExportResult")) if mibBuilder.loadTexts: cadCmtsExportNotification.setStatus('current') cadCmtsImportNotification = NotificationType((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 2)).setObjects(("CADANT-CMTS-EQUIPMENT-MIB", "trapCounter"), ("CADANT-CMTS-EQUIPMENT-MIB", "trapSeverity"), ("CADANT-CMTS-EXPORTIMPORT-MIB", "cadCmtsImportResult")) if mibBuilder.loadTexts: cadCmtsImportNotification.setStatus('current') mibBuilder.exportSymbols("CADANT-CMTS-EXPORTIMPORT-MIB", cadCmtsExportImportNested=cadCmtsExportImportNested, cadCmtsExportImportWithDefaults=cadCmtsExportImportWithDefaults, ImportResult=ImportResult, cadCmtsExportImportWithCertificates=cadCmtsExportImportWithCertificates, ExportResult=ExportResult, cadCmtsImportNotification=cadCmtsImportNotification, cadExportImportMib=cadExportImportMib, cadCmtsExportImportIfIndex=cadCmtsExportImportIfIndex, PYSNMP_MODULE_ID=cadExportImportMib, cadCmtsExportImportTraps=cadCmtsExportImportTraps, cadCmtsExportNotification=cadCmtsExportNotification, cadCmtsExportImportFilename=cadCmtsExportImportFilename, cadCmtsExportResult=cadCmtsExportResult, cadCmtsExportImportAction=cadCmtsExportImportAction, cadCmtsImportResult=cadCmtsImportResult, ExportImportAction=ExportImportAction, cadCmtsExportImportGroup=cadCmtsExportImportGroup, cadCmtsExportImportWithLineNums=cadCmtsExportImportWithLineNums)
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion') (trap_severity, trap_counter) = mibBuilder.importSymbols('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity', 'trapCounter') (cad_experimental,) = mibBuilder.importSymbols('CADANT-PRODUCTS-MIB', 'cadExperimental') (interface_index_or_zero,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (integer32, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, counter64, iso, time_ticks, gauge32, object_identity, ip_address, bits, mib_identifier, counter32, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'Counter64', 'iso', 'TimeTicks', 'Gauge32', 'ObjectIdentity', 'IpAddress', 'Bits', 'MibIdentifier', 'Counter32', 'NotificationType') (textual_convention, display_string, truth_value) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString', 'TruthValue') cad_export_import_mib = module_identity((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1)) cadExportImportMib.setRevisions(('2001-03-09 00:00', '2004-02-13 00:00', '2004-02-16 00:00')) if mibBuilder.loadTexts: cadExportImportMib.setLastUpdated('200402160000Z') if mibBuilder.loadTexts: cadExportImportMib.setOrganization('Arris International Inc.') class Exportimportaction(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4)) named_values = named_values(('noop', 0), ('export', 1), ('import', 2), ('pCmCertExport', 3), ('caCertExport', 4)) class Exportresult(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4, 5)) named_values = named_values(('unknown', 0), ('success', 1), ('fileNameTooLong', 2), ('invalidCharactersInFilename', 3), ('fileSystemFull', 4), ('otherError', 5)) class Importresult(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(0, 1, 2, 3, 4)) named_values = named_values(('unknown', 0), ('success', 1), ('fileNotFound', 2), ('fileDecodingError', 3), ('otherError', 4)) cad_cmts_export_import_group = mib_identifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1)) cad_cmts_export_import_filename = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 1), display_string().clone('update:/export.txt')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportFilename.setStatus('current') cad_cmts_export_import_action = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 2), export_import_action().clone('noop')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportAction.setStatus('current') cad_cmts_export_result = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 3), export_result().clone('unknown')).setMaxAccess('readonly') if mibBuilder.loadTexts: cadCmtsExportResult.setStatus('current') cad_cmts_import_result = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 4), import_result().clone('unknown')).setMaxAccess('readonly') if mibBuilder.loadTexts: cadCmtsImportResult.setStatus('current') cad_cmts_export_import_with_line_nums = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 5), truth_value().clone('false')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportWithLineNums.setStatus('current') cad_cmts_export_import_with_defaults = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 6), truth_value().clone('false')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportWithDefaults.setStatus('current') cad_cmts_export_import_nested = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 7), truth_value().clone('true')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportNested.setStatus('current') cad_cmts_export_import_with_certificates = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 8), truth_value().clone('true')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportWithCertificates.setStatus('current') cad_cmts_export_import_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 1, 9), interface_index_or_zero()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cadCmtsExportImportIfIndex.setStatus('current') cad_cmts_export_import_traps = mib_identifier((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0)) cad_cmts_export_notification = notification_type((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 1)).setObjects(('CADANT-CMTS-EQUIPMENT-MIB', 'trapCounter'), ('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity'), ('CADANT-CMTS-EXPORTIMPORT-MIB', 'cadCmtsExportResult')) if mibBuilder.loadTexts: cadCmtsExportNotification.setStatus('current') cad_cmts_import_notification = notification_type((1, 3, 6, 1, 4, 1, 4998, 1, 1, 100, 1, 0, 2)).setObjects(('CADANT-CMTS-EQUIPMENT-MIB', 'trapCounter'), ('CADANT-CMTS-EQUIPMENT-MIB', 'trapSeverity'), ('CADANT-CMTS-EXPORTIMPORT-MIB', 'cadCmtsImportResult')) if mibBuilder.loadTexts: cadCmtsImportNotification.setStatus('current') mibBuilder.exportSymbols('CADANT-CMTS-EXPORTIMPORT-MIB', cadCmtsExportImportNested=cadCmtsExportImportNested, cadCmtsExportImportWithDefaults=cadCmtsExportImportWithDefaults, ImportResult=ImportResult, cadCmtsExportImportWithCertificates=cadCmtsExportImportWithCertificates, ExportResult=ExportResult, cadCmtsImportNotification=cadCmtsImportNotification, cadExportImportMib=cadExportImportMib, cadCmtsExportImportIfIndex=cadCmtsExportImportIfIndex, PYSNMP_MODULE_ID=cadExportImportMib, cadCmtsExportImportTraps=cadCmtsExportImportTraps, cadCmtsExportNotification=cadCmtsExportNotification, cadCmtsExportImportFilename=cadCmtsExportImportFilename, cadCmtsExportResult=cadCmtsExportResult, cadCmtsExportImportAction=cadCmtsExportImportAction, cadCmtsImportResult=cadCmtsImportResult, ExportImportAction=ExportImportAction, cadCmtsExportImportGroup=cadCmtsExportImportGroup, cadCmtsExportImportWithLineNums=cadCmtsExportImportWithLineNums)
#!/home/jepoy/anaconda3/bin/python ## at terminal which python #simple fibonacci series # the sum of two elements defines the next set a, b = 0, 1 while b < 1000: print(b, end = ' ', flush = True) a, b = b, a + b print() # line ending
(a, b) = (0, 1) while b < 1000: print(b, end=' ', flush=True) (a, b) = (b, a + b) print()
def create(type): switcher = { "L": LPiece(), "O": OPiece(), "I": IPiece(), "J": JPiece(), "S": SPiece(), "T": TPiece(), "Z": ZPiece() } return switcher.get(type.upper()) class Piece: def __init__(self): self._rotateIndex = 0 self._rotations = [] def turnLeft(self, times=1): if self._rotateIndex > times-1: self._rotateIndex -= times return True return False def turnRight(self, times=1): if self._rotateIndex < len(self._rotations) - times: self._rotateIndex += times return True return False def rotateCount(self): return self._rotateIndex def positions(self): return self._rotations[self._rotateIndex] def appendRotation(self, rotation): self._rotations.append(rotation) class LPiece(Piece): def __init__(self): Piece.__init__(self) # rotations ordered by their rotation to the right self._rotations.append([[2, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [1, 1], [1, 2], [2, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [0, 2]]) self._rotations.append([[0, 0], [1, 0], [1, 1], [1, 2]]) class OPiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 0], [1, 0], [0, 1], [1, 1]]) class IPiece(Piece): def __init__(self): Piece.__init__(self) # rotations ordered by their rotation to the right self._rotations.append([[0, 1], [1, 1], [2, 1], [3, 1]]) self._rotations.append([[2, 0], [2, 1], [2, 2], [2, 3]]) # self._rotations.append([[0, 2], [1, 2], [2, 2], [3, 2]]) # self._rotations.append([[1, 0], [1, 1], [1, 2], [1, 3]]) class JPiece(Piece): def __init__(self): Piece.__init__(self) # rotations ordered by their rotation to the right self._rotations.append([[0, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [2, 0], [1, 1], [1, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [2, 2]]) self._rotations.append([[1, 0], [1, 1], [0, 2], [1, 2]]) class SPiece(Piece): def __init__(self): Piece.__init__(self) # rotations ordered by their rotation to the right self._rotations.append([[1, 0], [2, 0], [0, 1], [1, 1]]) self._rotations.append([[1, 0], [1, 1], [2, 1], [2, 2]]) # self._rotations.append([[1, 1], [2, 1], [0, 2], [1, 2]]) # self._rotations.append([[0, 0], [0, 1], [1, 1], [1, 2]]) class TPiece(Piece): def __init__(self): Piece.__init__(self) # rotations ordered by their rotation to the right self._rotations.append([[1, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [1, 1], [2, 1], [1, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [1, 2]]) self._rotations.append([[1, 0], [0, 1], [1, 1], [1, 2]]) class ZPiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 0], [1, 0], [1, 1], [2, 1]]) self._rotations.append([[2, 0], [1, 1], [2, 1], [1, 2]]) # self._rotations.append([[0, 1], [1, 1], [1, 2], [2, 2]]) # self._rotations.append([[1, 0], [0, 1], [1, 1], [0, 2]])
def create(type): switcher = {'L': l_piece(), 'O': o_piece(), 'I': i_piece(), 'J': j_piece(), 'S': s_piece(), 'T': t_piece(), 'Z': z_piece()} return switcher.get(type.upper()) class Piece: def __init__(self): self._rotateIndex = 0 self._rotations = [] def turn_left(self, times=1): if self._rotateIndex > times - 1: self._rotateIndex -= times return True return False def turn_right(self, times=1): if self._rotateIndex < len(self._rotations) - times: self._rotateIndex += times return True return False def rotate_count(self): return self._rotateIndex def positions(self): return self._rotations[self._rotateIndex] def append_rotation(self, rotation): self._rotations.append(rotation) class Lpiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[2, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [1, 1], [1, 2], [2, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [0, 2]]) self._rotations.append([[0, 0], [1, 0], [1, 1], [1, 2]]) class Opiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 0], [1, 0], [0, 1], [1, 1]]) class Ipiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 1], [1, 1], [2, 1], [3, 1]]) self._rotations.append([[2, 0], [2, 1], [2, 2], [2, 3]]) class Jpiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [2, 0], [1, 1], [1, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [2, 2]]) self._rotations.append([[1, 0], [1, 1], [0, 2], [1, 2]]) class Spiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[1, 0], [2, 0], [0, 1], [1, 1]]) self._rotations.append([[1, 0], [1, 1], [2, 1], [2, 2]]) class Tpiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[1, 0], [0, 1], [1, 1], [2, 1]]) self._rotations.append([[1, 0], [1, 1], [2, 1], [1, 2]]) self._rotations.append([[0, 1], [1, 1], [2, 1], [1, 2]]) self._rotations.append([[1, 0], [0, 1], [1, 1], [1, 2]]) class Zpiece(Piece): def __init__(self): Piece.__init__(self) self._rotations.append([[0, 0], [1, 0], [1, 1], [2, 1]]) self._rotations.append([[2, 0], [1, 1], [2, 1], [1, 2]])
class HelperBase: def __init__(self, app): self.app = app def type(self, locator, text): wd = self.app.wd if text is not None: wd.find_element_by_name(locator).click() wd.find_element_by_name(locator).clear() wd.find_element_by_name(locator).send_keys(text) def is_valid(self): wd = self.app.wd try: wd.current_url return True except: return False
class Helperbase: def __init__(self, app): self.app = app def type(self, locator, text): wd = self.app.wd if text is not None: wd.find_element_by_name(locator).click() wd.find_element_by_name(locator).clear() wd.find_element_by_name(locator).send_keys(text) def is_valid(self): wd = self.app.wd try: wd.current_url return True except: return False
#!/usr/bin/python3 print("Hello World") x=4 y="ok,google" z=[4,77,x,y] print(y) print(z) print(x,y)
print('Hello World') x = 4 y = 'ok,google' z = [4, 77, x, y] print(y) print(z) print(x, y)