content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
NON_TERMINALS = [ "S", "SBAR", "SQ", "SBARQ", "SINV", "ADJP", "ADVP", "CONJP", "FRAG", "INTJ", "LST", "NAC", "NP", "NX", "PP", "PRN", "QP", "RRC", "UCP", "VP", "WHADJP", "WHAVP", "WHNP", "WHPP", "WHADVP", "X", "ROOT", "NP-TMP", "PRT", ] class Token(object): def __init__(self, word, idx): self.word = word self.idx = idx def __repr__(self): return repr(self.word) class Node(object): def __init__(self): self.root = False self.children = [] self.label = None self.parent = None self.phrase = "" self.terminal = False self.start_idx = 0 self.end_idx = 0 class Sentence(object): def __init__(self, parse_string): self.num_nodes = 0 self.tree = self.get_tree(parse_string) self.sent = self.tree.phrase tokens = {} for idx, tok in enumerate(self.tree.phrase.split(" ")): tokens[idx] = Token(tok, idx) self.tokens = tokens self.num_tokens = len(tokens) def get_tree(self, parse_string): tree = self.contruct_tree_from_parse(parse_string, None) tree = self.reduce_tree(tree) phrase_whole = self.assign_phrases(tree, 0) tree.phrase = phrase_whole tree.start_idx = 0 tree.end_idx = len(phrase_whole.split(" ")) tree.parent_idx = -1 self.assign_ids(tree) return tree def assign_ids(self, tree): tree.idx = self.num_nodes self.num_nodes += 1 for child in tree.children: child.parent_idx = tree.idx self.assign_ids(child) @staticmethod def get_subtrees(parse_txt_partial): parse_txt_partial = parse_txt_partial[1:-1] if "(" in parse_txt_partial: idx_first_lb = parse_txt_partial.index("(") name_const = parse_txt_partial[:idx_first_lb].strip() parse_txt_partial = parse_txt_partial[idx_first_lb:] count = 0 partition_indices = [] for idx in range(len(parse_txt_partial)): if parse_txt_partial[idx] == "(": count += 1 elif parse_txt_partial[idx] == ")": count -= 1 if count == 0: partition_indices.append(idx + 1) partitions = [] part_idx_prev = 0 for i, part_idx in enumerate(partition_indices): partitions.append(parse_txt_partial[part_idx_prev:part_idx]) part_idx_prev = part_idx else: temp = parse_txt_partial.split(" ") name_const = temp[0] partitions = [temp[1]] return name_const, partitions # constructs constituency tree from the parse string @staticmethod def contruct_tree_from_parse(parse_txt, node): if parse_txt.startswith("("): phrase_name, divisions = Sentence.get_subtrees(parse_txt) if node is None: node = Node() node.root = True node.label = phrase_name if phrase_name in NON_TERMINALS: for phrase in divisions: if phrase.strip() == "": continue node_temp = Node() node_temp.parent = node node.children.append( Sentence.contruct_tree_from_parse(phrase, node_temp) ) else: node.terminal = True node.phrase = divisions[0] return node # only used for debugging @staticmethod def print_tree(tree): print(tree.label) print(tree.phrase) print(tree.start_idx) print(tree.end_idx) for child in tree.children: Sentence.print_tree(child) # remove single child nodes @staticmethod def reduce_tree(tree): while len(tree.children) == 1: tree = tree.children[0] children = [] for child in tree.children: child = Sentence.reduce_tree(child) children.append(child) tree.children = children return tree @staticmethod def assign_phrases(tree, phrase_start_idx): if tree.terminal: tree.start_idx = phrase_start_idx tree.end_idx = phrase_start_idx + len( tree.phrase.strip().split(" ") ) return tree.phrase else: phrase = "" phrase_idx_add = 0 for child in tree.children: child_phrase = Sentence.assign_phrases( child, phrase_start_idx + phrase_idx_add ).strip() child.start_idx = phrase_start_idx + phrase_idx_add phrase_idx_add += len(child_phrase.strip().split(" ")) child.end_idx = phrase_start_idx + phrase_idx_add child.phrase = child_phrase phrase += " " + child_phrase phrase = phrase.strip() return phrase
non_terminals = ['S', 'SBAR', 'SQ', 'SBARQ', 'SINV', 'ADJP', 'ADVP', 'CONJP', 'FRAG', 'INTJ', 'LST', 'NAC', 'NP', 'NX', 'PP', 'PRN', 'QP', 'RRC', 'UCP', 'VP', 'WHADJP', 'WHAVP', 'WHNP', 'WHPP', 'WHADVP', 'X', 'ROOT', 'NP-TMP', 'PRT'] class Token(object): def __init__(self, word, idx): self.word = word self.idx = idx def __repr__(self): return repr(self.word) class Node(object): def __init__(self): self.root = False self.children = [] self.label = None self.parent = None self.phrase = '' self.terminal = False self.start_idx = 0 self.end_idx = 0 class Sentence(object): def __init__(self, parse_string): self.num_nodes = 0 self.tree = self.get_tree(parse_string) self.sent = self.tree.phrase tokens = {} for (idx, tok) in enumerate(self.tree.phrase.split(' ')): tokens[idx] = token(tok, idx) self.tokens = tokens self.num_tokens = len(tokens) def get_tree(self, parse_string): tree = self.contruct_tree_from_parse(parse_string, None) tree = self.reduce_tree(tree) phrase_whole = self.assign_phrases(tree, 0) tree.phrase = phrase_whole tree.start_idx = 0 tree.end_idx = len(phrase_whole.split(' ')) tree.parent_idx = -1 self.assign_ids(tree) return tree def assign_ids(self, tree): tree.idx = self.num_nodes self.num_nodes += 1 for child in tree.children: child.parent_idx = tree.idx self.assign_ids(child) @staticmethod def get_subtrees(parse_txt_partial): parse_txt_partial = parse_txt_partial[1:-1] if '(' in parse_txt_partial: idx_first_lb = parse_txt_partial.index('(') name_const = parse_txt_partial[:idx_first_lb].strip() parse_txt_partial = parse_txt_partial[idx_first_lb:] count = 0 partition_indices = [] for idx in range(len(parse_txt_partial)): if parse_txt_partial[idx] == '(': count += 1 elif parse_txt_partial[idx] == ')': count -= 1 if count == 0: partition_indices.append(idx + 1) partitions = [] part_idx_prev = 0 for (i, part_idx) in enumerate(partition_indices): partitions.append(parse_txt_partial[part_idx_prev:part_idx]) part_idx_prev = part_idx else: temp = parse_txt_partial.split(' ') name_const = temp[0] partitions = [temp[1]] return (name_const, partitions) @staticmethod def contruct_tree_from_parse(parse_txt, node): if parse_txt.startswith('('): (phrase_name, divisions) = Sentence.get_subtrees(parse_txt) if node is None: node = node() node.root = True node.label = phrase_name if phrase_name in NON_TERMINALS: for phrase in divisions: if phrase.strip() == '': continue node_temp = node() node_temp.parent = node node.children.append(Sentence.contruct_tree_from_parse(phrase, node_temp)) else: node.terminal = True node.phrase = divisions[0] return node @staticmethod def print_tree(tree): print(tree.label) print(tree.phrase) print(tree.start_idx) print(tree.end_idx) for child in tree.children: Sentence.print_tree(child) @staticmethod def reduce_tree(tree): while len(tree.children) == 1: tree = tree.children[0] children = [] for child in tree.children: child = Sentence.reduce_tree(child) children.append(child) tree.children = children return tree @staticmethod def assign_phrases(tree, phrase_start_idx): if tree.terminal: tree.start_idx = phrase_start_idx tree.end_idx = phrase_start_idx + len(tree.phrase.strip().split(' ')) return tree.phrase else: phrase = '' phrase_idx_add = 0 for child in tree.children: child_phrase = Sentence.assign_phrases(child, phrase_start_idx + phrase_idx_add).strip() child.start_idx = phrase_start_idx + phrase_idx_add phrase_idx_add += len(child_phrase.strip().split(' ')) child.end_idx = phrase_start_idx + phrase_idx_add child.phrase = child_phrase phrase += ' ' + child_phrase phrase = phrase.strip() return phrase
# Problem: # In one cinema hall, the chairs are arranged in rectangular shape in r row and c columns. # There are three types of projections with Tickets at different rates: # -> Premiere - Premiere, at a price of 12.00 BGN. # -> Normal - standard screening, at a price of 7.50 leva. # -> Discount - screening for children, students and students at a reduced price of 5.00 BGN. # Write a program that introduces a screen type, number of rows, and number of columns in the room # numbers) and calculates total ticket revenue in a full room. # Print the result in a format such as the examples below, with 2 decimal places. projections_Type = input() row = int(input()) cow = int(input()) tickets_Price = 0 total_Price = 0 if projections_Type == "Premiere": tickets_Price = 12 elif projections_Type == "Normal": tickets_Price = 7.5 elif projections_Type == "Discount": tickets_Price = 5 total_Price = tickets_Price * (row * cow) print("{0:.2f} leva".format(total_Price))
projections__type = input() row = int(input()) cow = int(input()) tickets__price = 0 total__price = 0 if projections_Type == 'Premiere': tickets__price = 12 elif projections_Type == 'Normal': tickets__price = 7.5 elif projections_Type == 'Discount': tickets__price = 5 total__price = tickets_Price * (row * cow) print('{0:.2f} leva'.format(total_Price))
# Title : TODO # Objective : TODO # Created by: Wenzurk # Created on: 2018/2/19 pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat'] print(pets) while 'cat' in pets: pets.remove('cat') print(pets)
pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat'] print(pets) while 'cat' in pets: pets.remove('cat') print(pets)
class NotInServer(Exception): # The whole point of this is to do nothing def __init__(self): pass class NotWhitelisted(Exception): def __init__(self): pass
class Notinserver(Exception): def __init__(self): pass class Notwhitelisted(Exception): def __init__(self): pass
class Pagination(object): count = None def paginate_queryset(self, request, queryset, handler): raise NotImplementedError def get_paginated_response(self, request, data): raise NotImplementedError
class Pagination(object): count = None def paginate_queryset(self, request, queryset, handler): raise NotImplementedError def get_paginated_response(self, request, data): raise NotImplementedError
# hello world def print_lol(the_list, indent=false, level=0): for each_item in the_list: if isinstance(each_item, list): print_lol(each_item, indent, level+1) else: if indent: for tab_stop in range(level): print("\t", end=' ') print(each_item)
def print_lol(the_list, indent=false, level=0): for each_item in the_list: if isinstance(each_item, list): print_lol(each_item, indent, level + 1) else: if indent: for tab_stop in range(level): print('\t', end=' ') print(each_item)
def read_samplesCSV(spls): # reads in samples.csv file, format: Batch,Lane,Barcode,Sample,Alignments,ProviderName,Patient hdr_check = ['Batch', 'Lane', 'Barcode', 'Sample', 'Alignments', 'ProviderName', 'Patient'] switch = "on" file = open(spls, 'r') list_path = [] list_splID = [] list_providerNames = [] list_refG = [] list_patient = [] for line in file: line = line.strip('\n').split(',') # Test Header. Note: Even when header wrong code continues (w/ warning), but first line not read. if switch == "on": if (line == hdr_check): print("Passed CSV header check") else: Warning("CSV did NOT pass header check! Code continues, but first line ignored") switch = "off" continue # build lists list_path.append(line[0]) list_splID.append(line[3]) list_refG.append(line[4]) list_providerNames.append(line[5]) list_patient.append(line[6]) return [list_path,list_splID,list_refG,list_providerNames,set(list_patient)] # set(list_patient) provides only unique subject IDs def read_samples_caseCSV(spls): # reads in samples_case.csv file, format: Path,Sample,ReferenceGenome,Outgroup hdr_check = ['Path','Sample','ReferenceGenome','Outgroup'] switch = "on" file = open(spls, 'r') list_path = [] list_splID = [] list_refG = [] list_outgroup = [] for line in file: line = line.strip('\n').split(',') # Test Header. Note: Even when header wrong code continues (w/ warning), but first line not read. if switch == "on": if (line == hdr_check): print("Passed CSV header check") else: Warning("CSV did NOT pass header check! Code continues, but first line ignored") switch = "off" continue # build lists list_path.append(line[0]) list_splID.append(line[1]) list_refG.append(line[2]) list_outgroup.append(line[3]) return [list_path,list_splID,list_refG,list_outgroup]
def read_samples_csv(spls): hdr_check = ['Batch', 'Lane', 'Barcode', 'Sample', 'Alignments', 'ProviderName', 'Patient'] switch = 'on' file = open(spls, 'r') list_path = [] list_spl_id = [] list_provider_names = [] list_ref_g = [] list_patient = [] for line in file: line = line.strip('\n').split(',') if switch == 'on': if line == hdr_check: print('Passed CSV header check') else: warning('CSV did NOT pass header check! Code continues, but first line ignored') switch = 'off' continue list_path.append(line[0]) list_splID.append(line[3]) list_refG.append(line[4]) list_providerNames.append(line[5]) list_patient.append(line[6]) return [list_path, list_splID, list_refG, list_providerNames, set(list_patient)] def read_samples_case_csv(spls): hdr_check = ['Path', 'Sample', 'ReferenceGenome', 'Outgroup'] switch = 'on' file = open(spls, 'r') list_path = [] list_spl_id = [] list_ref_g = [] list_outgroup = [] for line in file: line = line.strip('\n').split(',') if switch == 'on': if line == hdr_check: print('Passed CSV header check') else: warning('CSV did NOT pass header check! Code continues, but first line ignored') switch = 'off' continue list_path.append(line[0]) list_splID.append(line[1]) list_refG.append(line[2]) list_outgroup.append(line[3]) return [list_path, list_splID, list_refG, list_outgroup]
while True: n_peer = int(input()) counter = 1 for i in range(2, n_peer): if n_peer%i == 1: print(i, end=' ') counter += 1 print() print(counter)
while True: n_peer = int(input()) counter = 1 for i in range(2, n_peer): if n_peer % i == 1: print(i, end=' ') counter += 1 print() print(counter)
def read_next(*args): for el in args: for i in el: yield i for item in read_next('string', (2,), {'d': 1, 'i': 2, 'c': 3, 't': 4}): print(item, end='')
def read_next(*args): for el in args: for i in el: yield i for item in read_next('string', (2,), {'d': 1, 'i': 2, 'c': 3, 't': 4}): print(item, end='')
califications = { 'anartz': 9.99, 'mikel': 5.01, 'aitor': 1.22, 'maite': 10, 'miren': 7.8, 'olatz': 9.89 } pass_students = [] # Obtener clave, valor elemento a elemento for key, value in califications.items(): if (value >= 5): pass_students.append(key) print("Notas del curso:") print(califications) print("Aprobados:") print(pass_students)
califications = {'anartz': 9.99, 'mikel': 5.01, 'aitor': 1.22, 'maite': 10, 'miren': 7.8, 'olatz': 9.89} pass_students = [] for (key, value) in califications.items(): if value >= 5: pass_students.append(key) print('Notas del curso:') print(califications) print('Aprobados:') print(pass_students)
def qsort(arr): if len(arr) <= 1: return arr pivot = arr.pop() greater, lesser = [], [] for item in arr: if item > pivot: greater.append(item) else: lesser.append(item) return qsort(lesser) + [pivot] + qsort(greater)
def qsort(arr): if len(arr) <= 1: return arr pivot = arr.pop() (greater, lesser) = ([], []) for item in arr: if item > pivot: greater.append(item) else: lesser.append(item) return qsort(lesser) + [pivot] + qsort(greater)
class A(): def load_data(self): return [1,2,3,4,5] def __getitem__(self, item): a = self.load_data() return a[item] class B(A): def load_data(self): return ['a','b','c'] a = B() print(a[1])
class A: def load_data(self): return [1, 2, 3, 4, 5] def __getitem__(self, item): a = self.load_data() return a[item] class B(A): def load_data(self): return ['a', 'b', 'c'] a = b() print(a[1])
class CidrMaskConvert: def cidr_to_mask(self, val): val = int(val) if 1 > val or val > 32: return "Invalid" val = '.'.join([str((0xffffffff << (32 - val) >> i) & 0xff) for i in [24, 16, 8, 0]]) return val def mask_to_cidr(self, val): mask_list = val.split(".") check = IpValidate().ipv4_validation(val) binary = [bin(int(i))[2:].count('1') for i in mask_list] if not check or binary[0] ==3: return 'Invalid' val = sum(binary) if sum(binary) > 0 else 'Invalid' return str(val) class IpValidate: def ipv4_validation(self, val): octets = val.split(".") return len(octets) == 4 and \ all(o.isdigit() and 0 <= int(o) < 256 for o in octets)
class Cidrmaskconvert: def cidr_to_mask(self, val): val = int(val) if 1 > val or val > 32: return 'Invalid' val = '.'.join([str(4294967295 << 32 - val >> i & 255) for i in [24, 16, 8, 0]]) return val def mask_to_cidr(self, val): mask_list = val.split('.') check = ip_validate().ipv4_validation(val) binary = [bin(int(i))[2:].count('1') for i in mask_list] if not check or binary[0] == 3: return 'Invalid' val = sum(binary) if sum(binary) > 0 else 'Invalid' return str(val) class Ipvalidate: def ipv4_validation(self, val): octets = val.split('.') return len(octets) == 4 and all((o.isdigit() and 0 <= int(o) < 256 for o in octets))
# name = input("Enter your name: ") # age = input("Enter your age: ") # print("Hello " + name + "! You are " + age) # create a calculator, be careful the input is a string num1 = input("Enter a number: ") num2 = input("Enter a number: ") # int does not work for decimal numbers result1 = int(num1) + int(num2) result2 = float(num1) + float(num2) result = int(num1) + int(num2) print(result1) print(result2) print(result)
num1 = input('Enter a number: ') num2 = input('Enter a number: ') result1 = int(num1) + int(num2) result2 = float(num1) + float(num2) result = int(num1) + int(num2) print(result1) print(result2) print(result)
class Solution: # @param A : string # @return an integer def solve(self, s): n = len(s) lps = [0]*n i,l = 1,0 while i < n: if s[i]==s[l]: lps[i] = l+1 l+=1 i+=1 elif l > 0: l = lps[l-1] else: i+=1 ans = n for i in range(n): x = i-lps[i] if lps[i]>=x: ans = n-i-1 return ans
class Solution: def solve(self, s): n = len(s) lps = [0] * n (i, l) = (1, 0) while i < n: if s[i] == s[l]: lps[i] = l + 1 l += 1 i += 1 elif l > 0: l = lps[l - 1] else: i += 1 ans = n for i in range(n): x = i - lps[i] if lps[i] >= x: ans = n - i - 1 return ans
# formatting menu = [ ["egg", "bacon"], ["egg", "bacon", "sausage"], ["egg", "spam"], ["egg", "spam", "tomato"], ["egg", "spam", "tomato", "spam", "tomato"], ] for meal in menu: if "spam" in meal: print("Yeah, not there") else: print("{0} has the spam score of {1}" .format(meal, meal.count("spam"))) # challenge: print all the values just not spam for meal in menu: if "spam" in meal: meal.remove("spam") print(meal)
menu = [['egg', 'bacon'], ['egg', 'bacon', 'sausage'], ['egg', 'spam'], ['egg', 'spam', 'tomato'], ['egg', 'spam', 'tomato', 'spam', 'tomato']] for meal in menu: if 'spam' in meal: print('Yeah, not there') else: print('{0} has the spam score of {1}'.format(meal, meal.count('spam'))) for meal in menu: if 'spam' in meal: meal.remove('spam') print(meal)
class Database: ''' A generic database that must implement at least the two methods declared below. The specific implementation of the database is left to Admin, but it can be any typical SQL or other database so long as it can implement a table where the key is a Hashable type and the value is Any type. A database instance is exposed to the origin server (and is only exposed to the origin server) by passing the instance to the Origin constructor. ''' def get(self, key): ''' Translates to a query where the key is the given parameter key. ''' pass def put(self, key, value): ''' Translates to a database insert if the key is not already in the database, or a database update if the key is already in the database. ''' pass
class Database: """ A generic database that must implement at least the two methods declared below. The specific implementation of the database is left to Admin, but it can be any typical SQL or other database so long as it can implement a table where the key is a Hashable type and the value is Any type. A database instance is exposed to the origin server (and is only exposed to the origin server) by passing the instance to the Origin constructor. """ def get(self, key): """ Translates to a query where the key is the given parameter key. """ pass def put(self, key, value): """ Translates to a database insert if the key is not already in the database, or a database update if the key is already in the database. """ pass
# 190. Reverse Bits class Solution: def reverseBits(self, n: int) -> int: bin_num = format(n, 'b') res = '0' * (32-len(bin_num)) + bin_num return int('0b' + res[::-1], 2)
class Solution: def reverse_bits(self, n: int) -> int: bin_num = format(n, 'b') res = '0' * (32 - len(bin_num)) + bin_num return int('0b' + res[::-1], 2)
T = int(input()) a=list(map(int,input().split())) for i in range(0,T): b = input() if(b == '+'): print(a[0]+a[1]) elif(b == '-'): print(a[0]-a[1]) elif(b == '*'): print(a[0]*a[1]) elif(b == '/'): print(a[0]//a[1]) elif(b == '%'): print(a[0]%a[1])
t = int(input()) a = list(map(int, input().split())) for i in range(0, T): b = input() if b == '+': print(a[0] + a[1]) elif b == '-': print(a[0] - a[1]) elif b == '*': print(a[0] * a[1]) elif b == '/': print(a[0] // a[1]) elif b == '%': print(a[0] % a[1])
name = input("whats your name\n") bebe = "october" print(bebe) print("hi") print (name) print("?!") print("tova") # pavtuk smiatam h = 2 c = 2 d = h*2 + c print(d)
name = input('whats your name\n') bebe = 'october' print(bebe) print('hi') print(name) print('?!') print('tova') h = 2 c = 2 d = h * 2 + c print(d)
calories_per_click = dict([(str(index + 1), int(calories)) for index, calories in enumerate(input().split())]) total_calories_burned = sum([calories_per_click[c] for c in input()]) print(total_calories_burned)
calories_per_click = dict([(str(index + 1), int(calories)) for (index, calories) in enumerate(input().split())]) total_calories_burned = sum([calories_per_click[c] for c in input()]) print(total_calories_burned)
# Notation x.y.z: # x: major release # y: minor release / new feature # z: build number / bug maintenance version = '0.5.1'
version = '0.5.1'
class EvaluateConfig: def __init__(self): self.game_num = 100 self.replace_rate = 0.55 self.play_config = PlayConfig() self.play_config.c_puct = 1 self.play_config.change_tau_turn = 0 self.play_config.noise_eps = 0 self.evaluate_latest_first = True class PlayDataConfig: def __init__(self): self.nb_game_in_file = 100 self.max_file_num = 10 self.save_policy_of_tau_1 = True class PlayConfig: def __init__(self): self.simulation_num_per_move = 10 self.share_mtcs_info_in_self_play = True self.reset_mtcs_info_per_game = 10 self.thinking_loop = 1 self.logging_thinking = False self.c_puct = 5 self.noise_eps = 0.25 self.dirichlet_alpha = 0.5 self.dirichlet_noise_only_for_legal_moves = True self.change_tau_turn = 10 self.virtual_loss = 3 self.prediction_queue_size = 16 self.parallel_search_num = 4 self.prediction_worker_sleep_sec = 0.00001 self.wait_for_expanding_sleep_sec = 0.000001 self.resign_threshold = -0.8 self.allowed_resign_turn = 30 self.disable_resignation_rate = 0.1 self.false_positive_threshold = 0.05 self.resign_threshold_delta = 0.01 self.use_newest_next_generation_model = True self.simulation_num_per_move_schedule = [ (300, 8), (500, 20), ] class TrainerConfig: def __init__(self): self.batch_size = 2048 self.min_data_size_to_learn = 100 self.epoch_to_checkpoint = 1 self.start_total_steps = 0 self.save_model_steps = 200 self.lr_schedules = [ (0, 0.01), (100000, 0.001), (200000, 0.0001) ] class ModelConfig: cnn_filter_num = 16 cnn_filter_size = 3 res_layer_num = 1 l2_reg = 1e-4 value_fc_size = 16
class Evaluateconfig: def __init__(self): self.game_num = 100 self.replace_rate = 0.55 self.play_config = play_config() self.play_config.c_puct = 1 self.play_config.change_tau_turn = 0 self.play_config.noise_eps = 0 self.evaluate_latest_first = True class Playdataconfig: def __init__(self): self.nb_game_in_file = 100 self.max_file_num = 10 self.save_policy_of_tau_1 = True class Playconfig: def __init__(self): self.simulation_num_per_move = 10 self.share_mtcs_info_in_self_play = True self.reset_mtcs_info_per_game = 10 self.thinking_loop = 1 self.logging_thinking = False self.c_puct = 5 self.noise_eps = 0.25 self.dirichlet_alpha = 0.5 self.dirichlet_noise_only_for_legal_moves = True self.change_tau_turn = 10 self.virtual_loss = 3 self.prediction_queue_size = 16 self.parallel_search_num = 4 self.prediction_worker_sleep_sec = 1e-05 self.wait_for_expanding_sleep_sec = 1e-06 self.resign_threshold = -0.8 self.allowed_resign_turn = 30 self.disable_resignation_rate = 0.1 self.false_positive_threshold = 0.05 self.resign_threshold_delta = 0.01 self.use_newest_next_generation_model = True self.simulation_num_per_move_schedule = [(300, 8), (500, 20)] class Trainerconfig: def __init__(self): self.batch_size = 2048 self.min_data_size_to_learn = 100 self.epoch_to_checkpoint = 1 self.start_total_steps = 0 self.save_model_steps = 200 self.lr_schedules = [(0, 0.01), (100000, 0.001), (200000, 0.0001)] class Modelconfig: cnn_filter_num = 16 cnn_filter_size = 3 res_layer_num = 1 l2_reg = 0.0001 value_fc_size = 16
class FakeSingleton: def __init__(self, payload): self._payload = payload def instance(self): return self._payload
class Fakesingleton: def __init__(self, payload): self._payload = payload def instance(self): return self._payload
''' What is going on everyone welcome to my if elif else tutorial video. The idea of this is to add yet another layer of logic to the pre-existing if else statement. See with our typical if else statment, the if will be checked for sure, and the else will only run if the if fails... but then what if you want to check multiple ifs? You could just write them all in, though this is somewhat improper. If you actually desire to check every single if statement, then this is fine. There is nothing wrong with writing multiple ifs... if they are necessary to run, otherwise you shouldn't really do this. Instead, you can use what is called the "elif" here in python... which is short for "else if" ''' x = 5 y = 10 z = 22 # first run the default like this, then # change the x > y to x < y... # then change both of these to an == if x > y: print('x is greater than y') elif x < z: print('x is less than z') else: print('if and elif never ran...')
""" What is going on everyone welcome to my if elif else tutorial video. The idea of this is to add yet another layer of logic to the pre-existing if else statement. See with our typical if else statment, the if will be checked for sure, and the else will only run if the if fails... but then what if you want to check multiple ifs? You could just write them all in, though this is somewhat improper. If you actually desire to check every single if statement, then this is fine. There is nothing wrong with writing multiple ifs... if they are necessary to run, otherwise you shouldn't really do this. Instead, you can use what is called the "elif" here in python... which is short for "else if" """ x = 5 y = 10 z = 22 if x > y: print('x is greater than y') elif x < z: print('x is less than z') else: print('if and elif never ran...')
steps = 363 buffer = [0] currentValue = 1 currentPosition = 0 for i in range(1, 2018): currentPosition = (currentPosition+steps)%len(buffer) buffer.insert(currentPosition+1, currentValue) currentValue += 1 currentPosition += 1 print(buffer[(currentPosition+1)%len(buffer)])
steps = 363 buffer = [0] current_value = 1 current_position = 0 for i in range(1, 2018): current_position = (currentPosition + steps) % len(buffer) buffer.insert(currentPosition + 1, currentValue) current_value += 1 current_position += 1 print(buffer[(currentPosition + 1) % len(buffer)])
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education, obj[2]: Occupation, obj[3]: Distance # {"feature": "Coupon", "instances": 51, "metric_value": 0.9931, "depth": 1} if obj[0]>1: # {"feature": "Occupation", "instances": 36, "metric_value": 0.9183, "depth": 2} if obj[2]<=19: # {"feature": "Education", "instances": 33, "metric_value": 0.8454, "depth": 3} if obj[1]<=2: # {"feature": "Distance", "instances": 26, "metric_value": 0.7063, "depth": 4} if obj[3]<=2: return 'True' elif obj[3]>2: return 'True' else: return 'True' elif obj[1]>2: # {"feature": "Distance", "instances": 7, "metric_value": 0.9852, "depth": 4} if obj[3]<=2: return 'True' elif obj[3]>2: return 'False' else: return 'False' else: return 'False' elif obj[2]>19: return 'False' else: return 'False' elif obj[0]<=1: # {"feature": "Occupation", "instances": 15, "metric_value": 0.8366, "depth": 2} if obj[2]<=6: # {"feature": "Education", "instances": 11, "metric_value": 0.9457, "depth": 3} if obj[1]<=3: # {"feature": "Distance", "instances": 10, "metric_value": 0.8813, "depth": 4} if obj[3]<=1: return 'False' elif obj[3]>1: return 'True' else: return 'True' elif obj[1]>3: return 'True' else: return 'True' elif obj[2]>6: return 'False' else: return 'False' else: return 'False'
def find_decision(obj): if obj[0] > 1: if obj[2] <= 19: if obj[1] <= 2: if obj[3] <= 2: return 'True' elif obj[3] > 2: return 'True' else: return 'True' elif obj[1] > 2: if obj[3] <= 2: return 'True' elif obj[3] > 2: return 'False' else: return 'False' else: return 'False' elif obj[2] > 19: return 'False' else: return 'False' elif obj[0] <= 1: if obj[2] <= 6: if obj[1] <= 3: if obj[3] <= 1: return 'False' elif obj[3] > 1: return 'True' else: return 'True' elif obj[1] > 3: return 'True' else: return 'True' elif obj[2] > 6: return 'False' else: return 'False' else: return 'False'
class JSONWriter: def __init__(self, alerts, row_parser): self.alerts = alerts self.row_parser = row_parser def parse_alerts(self, vendor, url,product, webpage_name): collection = list() alerts_list = self.alerts failed_count = 0 skipped_count = 0 for alert in alerts_list: row = self.row_parser.parse( alert, vendor, url,product, webpage_name) if row == "Skipped": skipped_count += 1 break elif row is not None: collection.append(row) else: failed_count += 1 return (collection, failed_count, skipped_count)
class Jsonwriter: def __init__(self, alerts, row_parser): self.alerts = alerts self.row_parser = row_parser def parse_alerts(self, vendor, url, product, webpage_name): collection = list() alerts_list = self.alerts failed_count = 0 skipped_count = 0 for alert in alerts_list: row = self.row_parser.parse(alert, vendor, url, product, webpage_name) if row == 'Skipped': skipped_count += 1 break elif row is not None: collection.append(row) else: failed_count += 1 return (collection, failed_count, skipped_count)
class Partisan_Gauge: def __init__(self): self.cultural_axis = 0 self.economic_axis = 0 self.authoritarian_axis = 0 def set_cultural_axis(self,cultural_axis): self.cultural_axis = cultural_axis def set_cultural_axis(self,cultural_axis): self.cultural_axis = cultural_axis def set_cultural_axis(self,cultural_axis): self.cultural_axis = cultural_axis class DogWhistles: def __init__(self): self.whistles = {} def add_whistle(self, whistle_name, whistle_description, found_on_node): whistle_name = str(whistle_name) whistle_description = str(whistle_description) self.whistles[whistle_name] = whistle_description class ProperNouns: def __init__(self): self.proper_nouns = {} def add_noun(self, noun_name, noun_description, found_on_node): whistle_name = str(noun_name) whistle_description = str(noun_description) self.proper_nouns[noun_name] = noun_description
class Partisan_Gauge: def __init__(self): self.cultural_axis = 0 self.economic_axis = 0 self.authoritarian_axis = 0 def set_cultural_axis(self, cultural_axis): self.cultural_axis = cultural_axis def set_cultural_axis(self, cultural_axis): self.cultural_axis = cultural_axis def set_cultural_axis(self, cultural_axis): self.cultural_axis = cultural_axis class Dogwhistles: def __init__(self): self.whistles = {} def add_whistle(self, whistle_name, whistle_description, found_on_node): whistle_name = str(whistle_name) whistle_description = str(whistle_description) self.whistles[whistle_name] = whistle_description class Propernouns: def __init__(self): self.proper_nouns = {} def add_noun(self, noun_name, noun_description, found_on_node): whistle_name = str(noun_name) whistle_description = str(noun_description) self.proper_nouns[noun_name] = noun_description
# Write your solution for 1.3 here! n = 0 i = 1 while i < 10000: n = n + i i = i + 1 print(i)
n = 0 i = 1 while i < 10000: n = n + i i = i + 1 print(i)
with open('./6/input_a.txt', 'r') as f: input = list(map(int,f.readline().strip().split(','))) fish = list([0,0,0,0,0,0,0,0,0]) for i in range(0,8): fish[i] = sum([1 for a in input if a == i]) def observe(days): for d in range(0,days): newfish = fish[0] for i in range(0,8): fish[i] = fish[i+1] + (newfish if i == 6 else 0) fish[8] = newfish return sum([a for a in fish]) print(f'Part A: after 80 days {observe(80)} lanternfish remaining') print(f'Part B: after 256 days {observe(256-80)} lanternfish remaining')
with open('./6/input_a.txt', 'r') as f: input = list(map(int, f.readline().strip().split(','))) fish = list([0, 0, 0, 0, 0, 0, 0, 0, 0]) for i in range(0, 8): fish[i] = sum([1 for a in input if a == i]) def observe(days): for d in range(0, days): newfish = fish[0] for i in range(0, 8): fish[i] = fish[i + 1] + (newfish if i == 6 else 0) fish[8] = newfish return sum([a for a in fish]) print(f'Part A: after 80 days {observe(80)} lanternfish remaining') print(f'Part B: after 256 days {observe(256 - 80)} lanternfish remaining')
def center_text(*args, sep=' ', end='\n', file=None, flush=False): text='' for arg in args: text += str(arg) + sep left_margin = (80 - len(text)) // 2 print(" " * left_margin, text, end=end, file=file, flush=flush) # calling the function center_text("spams and eggs") center_text(12) center_text("first", "second", 3, 4)
def center_text(*args, sep=' ', end='\n', file=None, flush=False): text = '' for arg in args: text += str(arg) + sep left_margin = (80 - len(text)) // 2 print(' ' * left_margin, text, end=end, file=file, flush=flush) center_text('spams and eggs') center_text(12) center_text('first', 'second', 3, 4)
# ceasar_cypher_encryptor # rotate each letter by k # wrap around alphabet def ceasar_cypher_encryptor(s, k): ciphered = [] overflow_adjust = ord('z') - ord('a') for c in s: new_c = ord(c) + k if new_c > ord('z'): # overflow adjustment new_c = new_c - overflow_adjust ciphered.append(chr(new_c)) return "".join(ciphered) def main(): res = ceasar_cypher_encryptor("abcdefgxyz", 2) print(f'{res}') if __name__ == "__main__": main()
def ceasar_cypher_encryptor(s, k): ciphered = [] overflow_adjust = ord('z') - ord('a') for c in s: new_c = ord(c) + k if new_c > ord('z'): new_c = new_c - overflow_adjust ciphered.append(chr(new_c)) return ''.join(ciphered) def main(): res = ceasar_cypher_encryptor('abcdefgxyz', 2) print(f'{res}') if __name__ == '__main__': main()
# Write a program to read through the mbox-short.txt # and figure out the distribution by hour of the day # for each of the messages. You can pull the hour out # from the 'From ' line by finding the time and then # splitting the string a second time using a colon. # # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 # # Once you have accumulated the counts for each hour, # print out the counts, sorted by hour as shown below. name = input("Enter file:") handle = open(name) hours = {} for line in handle: line = line.strip() if line.find('From ') == 0: hour_sent = line[line.find(':')-2:line.find(':')] # use dict get method to retrieve each hour_sent, or add it # to the dict if it isn't present already (with default value of 0). # Then set the value to value + 1 hours[hour_sent] = hours.get(hour_sent, 0) + 1 tups = hours.items() # get keys/values from hours as list of tuples tups.sort() # sort by keys (first item in each tuple) for tup in tups: print(tup[0], str(tup[1]))
name = input('Enter file:') handle = open(name) hours = {} for line in handle: line = line.strip() if line.find('From ') == 0: hour_sent = line[line.find(':') - 2:line.find(':')] hours[hour_sent] = hours.get(hour_sent, 0) + 1 tups = hours.items() tups.sort() for tup in tups: print(tup[0], str(tup[1]))
def foo(a = 1, b = 2): return a + b price = foo(b = 4) for item in [[1, 2, 3], [4, 5, 6]]: print(item[0]) mylist = [['abc'], ['def', 'ghi']] mylist[-1][-1][-1] def eur_to_usd(euros, rate=0.8): return euros * rate print(eur_to_usd(10)) weight = input("How many kg?") price = weight * 2.5 print(price) x = [len(item) for item in ['abc', 'def', 'ghi']] y = [i * 2 if i > 0 else 0 for i in [1, -2, 10]] def foo(x): return x ** 2 print(foo("Hello")) def foo(a = 1, b = 'John'): return a + b foo()
def foo(a=1, b=2): return a + b price = foo(b=4) for item in [[1, 2, 3], [4, 5, 6]]: print(item[0]) mylist = [['abc'], ['def', 'ghi']] mylist[-1][-1][-1] def eur_to_usd(euros, rate=0.8): return euros * rate print(eur_to_usd(10)) weight = input('How many kg?') price = weight * 2.5 print(price) x = [len(item) for item in ['abc', 'def', 'ghi']] y = [i * 2 if i > 0 else 0 for i in [1, -2, 10]] def foo(x): return x ** 2 print(foo('Hello')) def foo(a=1, b='John'): return a + b foo()
class RawNode(object): def __init__(self, chunk): self.chunk = chunk def render(self, ctx={}): return str(self.chunk)
class Rawnode(object): def __init__(self, chunk): self.chunk = chunk def render(self, ctx={}): return str(self.chunk)
RegionsVariablesMap = { "Zarem": { "Apple": { "Wofost": "Supply of apple zr", "Vensim": "apple zr", "KeyInVensimModel": "apple_zr" }, "Rice": { "Wofost": "supply of rice zr", "Vensim": "rice zr", "KeyInVensimModel": "rice_zr" }, "Citrus": { "Wofost": "Supply of citrus zr", "Vensim": "citrus zr", "KeyInVensimModel": "citrus_zr" }, "Rapeseed": { "Wofost": "Supply of rapeseed zr", "Vensim": "rapeseed zr", "KeyInVensimModel": "rapeseed_zr" } }, "Finesk": { "Tomato": { "Wofost": "supply of tomato", "Vensim": "tomato", "KeyInVensimModel": "tomato" }, "Rapeseed": { "Wofost": "Supply of rapeseed", "Vensim": "rapeseed", "KeyInVensimModel": "rapeseed" }, "Apple": { "Wofost": "Supply of apple", "Vensim": "apple", "KeyInVensimModel": "apple" }, "Citrus": { "Wofost": "Supply of citrus", "Vensim": "citrus", "KeyInVensimModel": "citrus" }, "Grainmaize": { "Wofost": "Supply grainmaize", "Vensim": "grainmaize", "KeyInVensimModel": "grainmaize" }, "Wheat": { "Wofost": "Supply of wheat", "Vensim": "wheat", "KeyInVensimModel": "wheat" }, "Chickpea": { "Wofost": "Supply of chickpea", "Vensim": "chickpea", "KeyInVensimModel": "chickpea" }, "Rice": { "Wofost": "Supply of rice", "Vensim": "rice", "KeyInVensimModel": "rice" } }, "shah R D": { "Rice": { "Wofost": "Supply of Rice Tj", "Vensim": "Rice Tj", "KeyInVensimModel": "Rice_Tj" }, "Apple": { "Wofost": "Supply of apple Tj", "Vensim": "apple Tj", "KeyInVensimModel": "apple_Tj" }, "Citrus": { "Wofost": "Supply of Citrus Tj", "Vensim": "citrs_tj", "KeyInVensimModel": "Citrs_Tj" }, "Tomato": { "Wofost": "Supply of tomato tj", "Vensim": "tomato tj", "KeyInVensimModel": "tomato_Tj" }, "Wheat": { "Wofost": "Supply of wheat Tj", "Vensim": "wheat Tj", "KeyInVensimModel": "wheat_Tj" }, "Rapeseed": { "Wofost": "Supply of rapeseed Tj", "Vensim": "Rapeseed Tj", "KeyInVensimModel": "Rapeseed_Tj" } }, "Tj dd": { "Rice": { "Wofost": "Sup- Rice tjj dd", "Vensim": "rice tjj dd", "KeyInVensimModel": "rice_tjj_dd" }, "Citrus": { "Wofost": "sup-Citrus tjj dd", "Vensim": "citrud tjj dd", "KeyInVensimModel": "citrud_tjj_dd" }, "Apple": { "Wofost": "sup-Apple tjj dd", "Vensim": "apple tjj dd", "KeyInVensimModel": "apple_tjj_dd" }, "Sorgum": { "Wofost": "sup-Sorgum tjdd", "Vensim": "sorgum tjj dd", "KeyInVensimModel": "sorgum_tjj_dd" }, "Wheat": { "Wofost": "sup-Wheat tjj dd", "Vensim": "wheat tjj dd", "KeyInVensimModel": "wheat_tjj_dd" }, "Rapeseed": { "Wofost": "sup-Rapeseed tjdd", "Vensim": "rapeseed tjj dd", "KeyInVensimModel": "rapeseed_tjj_dd" }, "Grainmaize": { "Wofost": "Sup-grainmaize Tjdd", "Vensim": "grain maiz tjj dd", "KeyInVensimModel": "grain_maiz_tjj_dd" }, "Tomato": { "Wofost": "Sup-tomato tjdd", "Vensim": "tomato tjj dd", "KeyInVensimModel": "tomato_tjj_dd" } } } CropNameMaps = { "Apple": "APP301 - TJ.CAB", "Chickpea": "CHICKPEA - TJ.W41", "Citrus": "CIT301 - TJ.CAB", "Grainmaize": "MAIZ - TJ.W41", "Tomato": "POT701-TJ.CAB", "Rice": "RIC501 - TJ.CAB", "Rapeseed": "SOYBEAN - TJ.W41", "Wheat": "WWH101 - TJ.CAB", "Sorgum": "MAIZ - TJ.W41" } MeteoNameMaps = { "Apple": "SAP2.014", "Chickpea": "SCK2.014", "Citrus": "SCT2.014", "Grainmaize": "SMZ2.014", "Tomato": "SPT2.014", "Rice": "SRC2.014", "Rapeseed": "SRP2.014", "rapeseed": "SRP2.014", # added for fixing key error "Wheat": "SWT2.014", "Sorgum": "SMZ2.014" } Coefficient: dict = { "Tomato": { "Finesk": 0.02782949291, "Zarem": 0, "Tj dd": 0.000234943, "shah R D": 0.0000351 }, "Chickpea": { "Finesk": 0.000061, "Zarem": 0, "Tj dd": 0, "shah R D": 0 }, "Rapeseed": { "Finesk": 0.00013, "Zarem": 0.000017, "Tj dd": 0.004354075, "shah R D": 0.000003 }, "Grainmaize": { "Finesk": 0.00001, "Zarem": 0, # 0.000017, "Tj dd": 0.003685, "shah R D": 0 }, "Apple": { "Finesk": 0.02752754991, "Zarem": 0.041570141, "Tj dd": 0.03405931491, "shah R D": 0.005011631 }, "Rice": { "Finesk": 0.019067016, "Zarem": 0.0097329009, "Tj dd": 0.2196073774, "shah R D": 0.0105982088 }, "Wheat": { "Finesk": 0.009012, "Zarem": 0, "Tj dd": 0.017090164, "shah R D": 0.000008 }, "Citrus": { "Finesk": 0.0009526, "Zarem": 0.001605887, "Tj dd": 0.1293910401, "shah R D": 0.00038915 }, "Sorgum": { "Finesk": 0, # 0.00001, "Zarem": 0, # 0.000017, "Tj dd": 0.01708, "shah R D": 0 } } Regions = { "Finesk", "Zarem", "Tj dd", "shah R D" } keys_in_vensim_output = [ '"sup-Wheat tjj dd"', '"sup-Citrus tjj dd"', '"Sup- Rice tjj dd"', '"sup-Apple tjj dd"', '"sup-Sorgum tjdd"', '"Sup-grainmaize Tjdd"', '"Sup-tomato tjdd"', '"sup-Rapeseed tjdd"', "supply of tomato tj", "supply of apple Tj", "supply of Rice Tj", "supply of citrus Tj", "spply of wheat Tj", "supply of rapeseed Tj", "supply of rice zr", "supply of citrus zr", "supply of rapeseed zr", "Supply of apple zr", "supply of wheat", "supply of apple", "supply of tomato", "supply of grainmaize", "supply of chickpea", "supply of rice", "supply of rapeseed", "supply of citrus", ] WeatherContainerRanges = {"LAT": (-90., 90.), "LON": (-180., 180.), "ELEV": (-300, 6000), "IRRAD": (0., 40e30), "TMIN": (-50., 60.), "TMAX": (-50., 60.), "VAP": (0.06, 2000000.3), "RAIN": (0, 25), "E0": (0., 20000000.5), "ES0": (0., 2000000.5), "ET0": (0., 2000000.5), "WIND": (0., 100.), "SNOWDEPTH": (0., 250.), "TEMP": (-50., 60.), "TMINRA": (-50., 60.)} ArgoMap = { "Apple": "apple_calendar.agro", "Chickpea": "chickpea_calendar.agro", "Citrus": "citrus_calendar.agro", "Grainmaize": "grainmaiz_calendar.agro", "Sorgum": "grainmaiz_calendar.agro", "Tomato": "potato_calendar.agro", "Rice": "rice_calendar.agro", "Rapeseed": "rapeseed_calendar.agro", "Wheat": 'wheat_calendar.agro' } SoilMap = { "Soil": "EC11.NEW" }
regions_variables_map = {'Zarem': {'Apple': {'Wofost': 'Supply of apple zr', 'Vensim': 'apple zr', 'KeyInVensimModel': 'apple_zr'}, 'Rice': {'Wofost': 'supply of rice zr', 'Vensim': 'rice zr', 'KeyInVensimModel': 'rice_zr'}, 'Citrus': {'Wofost': 'Supply of citrus zr', 'Vensim': 'citrus zr', 'KeyInVensimModel': 'citrus_zr'}, 'Rapeseed': {'Wofost': 'Supply of rapeseed zr', 'Vensim': 'rapeseed zr', 'KeyInVensimModel': 'rapeseed_zr'}}, 'Finesk': {'Tomato': {'Wofost': 'supply of tomato', 'Vensim': 'tomato', 'KeyInVensimModel': 'tomato'}, 'Rapeseed': {'Wofost': 'Supply of rapeseed', 'Vensim': 'rapeseed', 'KeyInVensimModel': 'rapeseed'}, 'Apple': {'Wofost': 'Supply of apple', 'Vensim': 'apple', 'KeyInVensimModel': 'apple'}, 'Citrus': {'Wofost': 'Supply of citrus', 'Vensim': 'citrus', 'KeyInVensimModel': 'citrus'}, 'Grainmaize': {'Wofost': 'Supply grainmaize', 'Vensim': 'grainmaize', 'KeyInVensimModel': 'grainmaize'}, 'Wheat': {'Wofost': 'Supply of wheat', 'Vensim': 'wheat', 'KeyInVensimModel': 'wheat'}, 'Chickpea': {'Wofost': 'Supply of chickpea', 'Vensim': 'chickpea', 'KeyInVensimModel': 'chickpea'}, 'Rice': {'Wofost': 'Supply of rice', 'Vensim': 'rice', 'KeyInVensimModel': 'rice'}}, 'shah R D': {'Rice': {'Wofost': 'Supply of Rice Tj', 'Vensim': 'Rice Tj', 'KeyInVensimModel': 'Rice_Tj'}, 'Apple': {'Wofost': 'Supply of apple Tj', 'Vensim': 'apple Tj', 'KeyInVensimModel': 'apple_Tj'}, 'Citrus': {'Wofost': 'Supply of Citrus Tj', 'Vensim': 'citrs_tj', 'KeyInVensimModel': 'Citrs_Tj'}, 'Tomato': {'Wofost': 'Supply of tomato tj', 'Vensim': 'tomato tj', 'KeyInVensimModel': 'tomato_Tj'}, 'Wheat': {'Wofost': 'Supply of wheat Tj', 'Vensim': 'wheat Tj', 'KeyInVensimModel': 'wheat_Tj'}, 'Rapeseed': {'Wofost': 'Supply of rapeseed Tj', 'Vensim': 'Rapeseed Tj', 'KeyInVensimModel': 'Rapeseed_Tj'}}, 'Tj dd': {'Rice': {'Wofost': 'Sup- Rice tjj dd', 'Vensim': 'rice tjj dd', 'KeyInVensimModel': 'rice_tjj_dd'}, 'Citrus': {'Wofost': 'sup-Citrus tjj dd', 'Vensim': 'citrud tjj dd', 'KeyInVensimModel': 'citrud_tjj_dd'}, 'Apple': {'Wofost': 'sup-Apple tjj dd', 'Vensim': 'apple tjj dd', 'KeyInVensimModel': 'apple_tjj_dd'}, 'Sorgum': {'Wofost': 'sup-Sorgum tjdd', 'Vensim': 'sorgum tjj dd', 'KeyInVensimModel': 'sorgum_tjj_dd'}, 'Wheat': {'Wofost': 'sup-Wheat tjj dd', 'Vensim': 'wheat tjj dd', 'KeyInVensimModel': 'wheat_tjj_dd'}, 'Rapeseed': {'Wofost': 'sup-Rapeseed tjdd', 'Vensim': 'rapeseed tjj dd', 'KeyInVensimModel': 'rapeseed_tjj_dd'}, 'Grainmaize': {'Wofost': 'Sup-grainmaize Tjdd', 'Vensim': 'grain maiz tjj dd', 'KeyInVensimModel': 'grain_maiz_tjj_dd'}, 'Tomato': {'Wofost': 'Sup-tomato tjdd', 'Vensim': 'tomato tjj dd', 'KeyInVensimModel': 'tomato_tjj_dd'}}} crop_name_maps = {'Apple': 'APP301 - TJ.CAB', 'Chickpea': 'CHICKPEA - TJ.W41', 'Citrus': 'CIT301 - TJ.CAB', 'Grainmaize': 'MAIZ - TJ.W41', 'Tomato': 'POT701-TJ.CAB', 'Rice': 'RIC501 - TJ.CAB', 'Rapeseed': 'SOYBEAN - TJ.W41', 'Wheat': 'WWH101 - TJ.CAB', 'Sorgum': 'MAIZ - TJ.W41'} meteo_name_maps = {'Apple': 'SAP2.014', 'Chickpea': 'SCK2.014', 'Citrus': 'SCT2.014', 'Grainmaize': 'SMZ2.014', 'Tomato': 'SPT2.014', 'Rice': 'SRC2.014', 'Rapeseed': 'SRP2.014', 'rapeseed': 'SRP2.014', 'Wheat': 'SWT2.014', 'Sorgum': 'SMZ2.014'} coefficient: dict = {'Tomato': {'Finesk': 0.02782949291, 'Zarem': 0, 'Tj dd': 0.000234943, 'shah R D': 3.51e-05}, 'Chickpea': {'Finesk': 6.1e-05, 'Zarem': 0, 'Tj dd': 0, 'shah R D': 0}, 'Rapeseed': {'Finesk': 0.00013, 'Zarem': 1.7e-05, 'Tj dd': 0.004354075, 'shah R D': 3e-06}, 'Grainmaize': {'Finesk': 1e-05, 'Zarem': 0, 'Tj dd': 0.003685, 'shah R D': 0}, 'Apple': {'Finesk': 0.02752754991, 'Zarem': 0.041570141, 'Tj dd': 0.03405931491, 'shah R D': 0.005011631}, 'Rice': {'Finesk': 0.019067016, 'Zarem': 0.0097329009, 'Tj dd': 0.2196073774, 'shah R D': 0.0105982088}, 'Wheat': {'Finesk': 0.009012, 'Zarem': 0, 'Tj dd': 0.017090164, 'shah R D': 8e-06}, 'Citrus': {'Finesk': 0.0009526, 'Zarem': 0.001605887, 'Tj dd': 0.1293910401, 'shah R D': 0.00038915}, 'Sorgum': {'Finesk': 0, 'Zarem': 0, 'Tj dd': 0.01708, 'shah R D': 0}} regions = {'Finesk', 'Zarem', 'Tj dd', 'shah R D'} keys_in_vensim_output = ['"sup-Wheat tjj dd"', '"sup-Citrus tjj dd"', '"Sup- Rice tjj dd"', '"sup-Apple tjj dd"', '"sup-Sorgum tjdd"', '"Sup-grainmaize Tjdd"', '"Sup-tomato tjdd"', '"sup-Rapeseed tjdd"', 'supply of tomato tj', 'supply of apple Tj', 'supply of Rice Tj', 'supply of citrus Tj', 'spply of wheat Tj', 'supply of rapeseed Tj', 'supply of rice zr', 'supply of citrus zr', 'supply of rapeseed zr', 'Supply of apple zr', 'supply of wheat', 'supply of apple', 'supply of tomato', 'supply of grainmaize', 'supply of chickpea', 'supply of rice', 'supply of rapeseed', 'supply of citrus'] weather_container_ranges = {'LAT': (-90.0, 90.0), 'LON': (-180.0, 180.0), 'ELEV': (-300, 6000), 'IRRAD': (0.0, 4e+31), 'TMIN': (-50.0, 60.0), 'TMAX': (-50.0, 60.0), 'VAP': (0.06, 2000000.3), 'RAIN': (0, 25), 'E0': (0.0, 20000000.5), 'ES0': (0.0, 2000000.5), 'ET0': (0.0, 2000000.5), 'WIND': (0.0, 100.0), 'SNOWDEPTH': (0.0, 250.0), 'TEMP': (-50.0, 60.0), 'TMINRA': (-50.0, 60.0)} argo_map = {'Apple': 'apple_calendar.agro', 'Chickpea': 'chickpea_calendar.agro', 'Citrus': 'citrus_calendar.agro', 'Grainmaize': 'grainmaiz_calendar.agro', 'Sorgum': 'grainmaiz_calendar.agro', 'Tomato': 'potato_calendar.agro', 'Rice': 'rice_calendar.agro', 'Rapeseed': 'rapeseed_calendar.agro', 'Wheat': 'wheat_calendar.agro'} soil_map = {'Soil': 'EC11.NEW'}
ctx.rule(u'START',u'{PROGRAM}') ctx.rule(u'PROGRAM',u'{STATEMENT}\n{PROGRAM}') ctx.rule(u'PROGRAM',u'') ctx.rule(u'STATEMENT',u';') ctx.rule(u'STATEMENT',u'') ctx.rule(u'STATEMENT',u'break') ctx.rule(u'STATEMENT',u'{VAR} = {EXPR}') ctx.rule(u'STATEMENT',u'local {VARLIST} = {EXPRLIST}') ctx.rule(u'STATEMENT',u'{FUNCTION}') ctx.rule(u'STATEMENT',u'{COROUTINE}') ctx.rule(u'STATEMENT',u'{CONDITIONAL}') ctx.rule(u'STATEMENT',u'{LOOP}') ctx.rule(u'STATEMENT',u'return {EXPRLIST}') ctx.rule(u'STATEMENT',u'goto {LABELNAME}') ctx.rule(u'STATEMENT',u'::{LABELNAME}::') ctx.rule(u'LABELNAME',u'labela') ctx.rule(u'LABELNAME',u'labelb') ctx.rule(u'FUNCTION',u'{FUNCDEF} ({FUNCTION_ARGS}) {PROGRAM}\nend') ctx.rule(u'FUNCDEF',u'function {VAR}.{IDENTIFIER}') ctx.rule(u'FUNCDEF',u'function {VAR}:{IDENTIFIER}') ctx.rule(u'FUNCDEF',u'function {IDENTIFIER}') ctx.rule(u'LAMBDA',u'function ({FUNCTION_ARGS}) {PROGRAM} end') ctx.rule(u'FUNCTION_ARGS',u'') ctx.rule(u'FUNCTION_ARGS',u'{FUNCTION_ARGLIST}') ctx.rule(u'FUNCTION_ARGLIST',u'{VAR}, {FUNCTION_ARGLIST}') ctx.rule(u'FUNCTION_ARGLIST',u'{VAR}') ctx.rule(u'FUNCTION_ARGLIST',u'...') ctx.rule(u'COROUTINE',u'{VAR} = coroutine.create({LAMBDA})') ctx.rule(u'COROUTINE',u'{VAR} = coroutine.wrap({LAMBDA})') ctx.rule(u'COROUTINE',u'coroutine.resume({VAR}, {ARGS})') ctx.rule(u'COROUTINE',u'coroutine.yield({ARGS})') ctx.rule(u'FUNCTIONCALL',u'{IDENTIFIER} {ARGS}') ctx.rule(u'FUNCTIONCALL',u'{EXPR}:{IDENTIFIER} {ARGS}') ctx.rule(u'FUNCTIONCALL',u'{EXPR}.{IDENTIFIER} {ARGS}') ctx.rule(u'ARGS',u'({EXPRLIST})') ctx.rule(u'ARGS',u'{TABLECONSTRUCTOR}') ctx.rule(u'ARGS',u'{LITERALSTRING}') ctx.rule(u'CONDITIONAL',u'if {EXPR} then\n{PROGRAM}\nend') ctx.rule(u'CONDITIONAL',u'if {EXPR} then\n{PROGRAM}\nelse\n{PROGRAM}\nend') ctx.rule(u'LOOP',u'while ({EXPR})\ndo\n{PROGRAM}\nend') ctx.rule(u'LOOP',u'for {VAR}={EXPR}, {EXPR}, {EXPR}\ndo\n{PROGRAM}\nend') ctx.rule(u'LOOP',u'repeat\n{PROGRAM}\nuntil ({EXPR})') ctx.rule(u'EXPRLIST',u'{EXPR}, {EXPRLIST}') ctx.rule(u'EXPRLIST',u'{EXPR}') ctx.rule(u'EXPR',u'(nil)') ctx.rule(u'EXPR',u'(false)') ctx.rule(u'EXPR',u'(true)') ctx.rule(u'EXPR',u'({NUMERAL})') ctx.rule(u'EXPR',u'{LITERALSTRING}') ctx.rule(u'EXPR',u'{TABLECONSTRUCTOR}') ctx.rule(u'EXPR',u'({VAR}[{EXPR}])') ctx.rule(u'EXPR',u'({EXPR}{BINOP}{EXPR})') ctx.rule(u'EXPR',u'({UNOP}{EXPR})') ctx.rule(u'EXPR',u'{LAMBDA}') ctx.rule(u'EXPR',u'{VAR}') ctx.rule(u'EXPR',u'{FUNCTIONCALL}') ctx.rule(u'EXPR',u'({EXPR})') ctx.rule(u'EXPR',u'...') ctx.rule(u'BINOP',u'+') ctx.rule(u'BINOP',u'-') ctx.rule(u'BINOP',u'*') ctx.rule(u'BINOP',u'/') ctx.rule(u'BINOP',u'//') ctx.rule(u'BINOP',u'^') ctx.rule(u'BINOP',u'%') ctx.rule(u'BINOP',u'&') ctx.rule(u'BINOP',u'~') ctx.rule(u'BINOP',u'|') ctx.rule(u'BINOP',u'>>') ctx.rule(u'BINOP',u'<<') ctx.rule(u'BINOP',u' .. ') ctx.rule(u'BINOP',u'<') ctx.rule(u'BINOP',u'<=') ctx.rule(u'BINOP',u'>') ctx.rule(u'BINOP',u'>=') ctx.rule(u'BINOP',u'==') ctx.rule(u'BINOP',u'~=') ctx.rule(u'BINOP',u' and ') ctx.rule(u'BINOP',u' or ') ctx.rule(u'UNOP',u'-') ctx.rule(u'UNOP',u' not ') ctx.rule(u'UNOP',u'#') ctx.rule(u'UNOP',u'~') ctx.rule(u'TABLECONSTRUCTOR',u'\\{{FIELDLIST}\\}') ctx.rule(u'METATABLE',u'{VAR} = setmetatable({VAR}, {TABLECONSTRUCTOR})') ctx.rule(u'FIELDLIST',u'{FIELD},{FIELDLIST}') ctx.rule(u'FIELDLIST',u'{FIELD}') ctx.rule(u'FIELD',u'[{EXPR}]={EXPR}') ctx.rule(u'FIELD',u'{IDENTIFIER}={EXPR}') ctx.rule(u'FIELD',u'{EXPR}') ctx.rule(u'VARLIST',u'{VAR}, {VARLIST}') ctx.rule(u'VARLIST',u'{VAR}') ctx.rule(u'VAR',u'a') ctx.rule(u'VAR',u'b') ctx.rule(u'VAR',u'c') ctx.rule(u'VAR',u'd') ctx.rule(u'VAR',u'e') ctx.rule(u'VAR',u'coroutine') ctx.rule(u'VAR',u'debug') ctx.rule(u'VAR',u'math') ctx.rule(u'VAR',u'io') ctx.rule(u'VAR',u'os') ctx.rule(u'VAR',u'package') ctx.rule(u'VAR',u'string') ctx.rule(u'VAR',u'table') ctx.rule(u'VAR',u'utf8') ctx.rule(u'VAR',u'self') ctx.rule(u'LITERALSTRING',u'"{STRING}"') ctx.rule(u'LITERALSTRING',u'[[{STRING}]]') ctx.rule(u'STRING',u'') ctx.rule(u'STRING',u'{STRCHR}{STRING}') ctx.rule(u'STRCHR',u'\n') ctx.rule(u'STRCHR',u'\r') ctx.rule(u'STRCHR',u' ') ctx.rule(u'STRCHR',u'\t') ctx.rule(u'STRCHR',u'0') ctx.rule(u'STRCHR',u'a') ctx.rule(u'STRCHR',u'/') ctx.rule(u'STRCHR',u'.') ctx.rule(u'STRCHR',u'$') ctx.rule(u'STRCHR',u'{ESCAPESEQUENCE}') ctx.rule(u'ESCAPESEQUENCE',u'\\a') ctx.rule(u'ESCAPESEQUENCE',u'\\b') ctx.rule(u'ESCAPESEQUENCE',u'\\f') ctx.rule(u'ESCAPESEQUENCE',u'\\n') ctx.rule(u'ESCAPESEQUENCE',u'\\r') ctx.rule(u'ESCAPESEQUENCE',u'\\t') ctx.rule(u'ESCAPESEQUENCE',u'\\v') ctx.rule(u'ESCAPESEQUENCE',u'\\z') ctx.rule(u'ESCAPESEQUENCE',u'\n') ctx.rule(u'ESCAPESEQUENCE',u'\\x{HEXADECIMAL}') ctx.rule(u'ESCAPESEQUENCE',u'\\u\\{{HEXADECIMAL}\\}') ctx.rule(u'NUMERAL',u'{DECIMAL}') ctx.rule(u'NUMERAL',u'0x{HEXADECIMAL}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}e{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}e-{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}e{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL',u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}e-{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}p{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}p-{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}p{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL',u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}p-{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'DECIMALDIGITS',u'{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMALDIGITS',u'') ctx.rule(u'HEXDIGITS',u'{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXDIGITS',u'') ctx.rule(u'DECIMALDIGIT',u'0') ctx.rule(u'DECIMALDIGIT',u'1') ctx.rule(u'DECIMALDIGIT',u'2') ctx.rule(u'DECIMALDIGIT',u'3') ctx.rule(u'DECIMALDIGIT',u'4') ctx.rule(u'DECIMALDIGIT',u'5') ctx.rule(u'DECIMALDIGIT',u'6') ctx.rule(u'DECIMALDIGIT',u'7') ctx.rule(u'DECIMALDIGIT',u'8') ctx.rule(u'DECIMALDIGIT',u'9') ctx.rule(u'HEXDIGIT',u'a') ctx.rule(u'HEXDIGIT',u'b') ctx.rule(u'HEXDIGIT',u'c') ctx.rule(u'HEXDIGIT',u'd') ctx.rule(u'HEXDIGIT',u'e') ctx.rule(u'HEXDIGIT',u'f') ctx.rule(u'HEXDIGIT',u'A') ctx.rule(u'HEXDIGIT',u'B') ctx.rule(u'HEXDIGIT',u'C') ctx.rule(u'HEXDIGIT',u'D') ctx.rule(u'HEXDIGIT',u'E') ctx.rule(u'HEXDIGIT',u'F') ctx.rule(u'HEXDIGIT',u'{DECIMALDIGIT}') ctx.rule(u'IDENTIFIER',u'self') ctx.rule(u'IDENTIFIER',u'G') ctx.rule(u'IDENTIFIER',u'_VERSION') ctx.rule(u'IDENTIFIER',u'assert') ctx.rule(u'IDENTIFIER',u'collectgarbage') ctx.rule(u'IDENTIFIER',u'dofile') ctx.rule(u'IDENTIFIER',u'error') ctx.rule(u'IDENTIFIER',u'getmetatable') ctx.rule(u'IDENTIFIER',u'ipairs') ctx.rule(u'IDENTIFIER',u'load') ctx.rule(u'IDENTIFIER',u'loadfile') ctx.rule(u'IDENTIFIER',u'next') ctx.rule(u'IDENTIFIER',u'pairs') ctx.rule(u'IDENTIFIER',u'pcall') ctx.rule(u'IDENTIFIER',u'print') ctx.rule(u'IDENTIFIER',u'rawequal') ctx.rule(u'IDENTIFIER',u'rawget') ctx.rule(u'IDENTIFIER',u'rawlen') ctx.rule(u'IDENTIFIER',u'rawset') ctx.rule(u'IDENTIFIER',u'require') ctx.rule(u'IDENTIFIER',u'select') ctx.rule(u'IDENTIFIER',u'setmetatable') ctx.rule(u'IDENTIFIER',u'tonumber') ctx.rule(u'IDENTIFIER',u'tostring') ctx.rule(u'IDENTIFIER',u'type') ctx.rule(u'IDENTIFIER',u'xpcall') ctx.rule(u'IDENTIFIER',u'coroutine') ctx.rule(u'IDENTIFIER',u'create') ctx.rule(u'IDENTIFIER',u'isyieldable') ctx.rule(u'IDENTIFIER',u'resume') ctx.rule(u'IDENTIFIER',u'running') ctx.rule(u'IDENTIFIER',u'status') ctx.rule(u'IDENTIFIER',u'wrap') ctx.rule(u'IDENTIFIER',u'yield') ctx.rule(u'IDENTIFIER',u'debug') ctx.rule(u'IDENTIFIER',u'debug') ctx.rule(u'IDENTIFIER',u'gethook') ctx.rule(u'IDENTIFIER',u'getinfo') ctx.rule(u'IDENTIFIER',u'getlocal') ctx.rule(u'IDENTIFIER',u'getmetatable') ctx.rule(u'IDENTIFIER',u'getregistry') ctx.rule(u'IDENTIFIER',u'getupvalue') ctx.rule(u'IDENTIFIER',u'getuservalue') ctx.rule(u'IDENTIFIER',u'sethook') ctx.rule(u'IDENTIFIER',u'setlocal') ctx.rule(u'IDENTIFIER',u'setmetatable') ctx.rule(u'IDENTIFIER',u'setupvalue') ctx.rule(u'IDENTIFIER',u'setuservalue') ctx.rule(u'IDENTIFIER',u'traceback') ctx.rule(u'IDENTIFIER',u'upvalueid') ctx.rule(u'IDENTIFIER',u'upvaluejoin') ctx.rule(u'IDENTIFIER',u'io') ctx.rule(u'IDENTIFIER',u'close') ctx.rule(u'IDENTIFIER',u'flush') ctx.rule(u'IDENTIFIER',u'input') ctx.rule(u'IDENTIFIER',u'lines') ctx.rule(u'IDENTIFIER',u'open') ctx.rule(u'IDENTIFIER',u'output') ctx.rule(u'IDENTIFIER',u'popen') ctx.rule(u'IDENTIFIER',u'read') ctx.rule(u'IDENTIFIER',u'stderr') ctx.rule(u'IDENTIFIER',u'stdin') ctx.rule(u'IDENTIFIER',u'stdout') ctx.rule(u'IDENTIFIER',u'tmpfile') ctx.rule(u'IDENTIFIER',u'type') ctx.rule(u'IDENTIFIER',u'write') ctx.rule(u'IDENTIFIER',u'math') ctx.rule(u'IDENTIFIER',u'abs') ctx.rule(u'IDENTIFIER',u'acos') ctx.rule(u'IDENTIFIER',u'asin') ctx.rule(u'IDENTIFIER',u'atan') ctx.rule(u'IDENTIFIER',u'ceil') ctx.rule(u'IDENTIFIER',u'cos') ctx.rule(u'IDENTIFIER',u'deg') ctx.rule(u'IDENTIFIER',u'exp') ctx.rule(u'IDENTIFIER',u'floor') ctx.rule(u'IDENTIFIER',u'fmod') ctx.rule(u'IDENTIFIER',u'huge') ctx.rule(u'IDENTIFIER',u'log') ctx.rule(u'IDENTIFIER',u'max') ctx.rule(u'IDENTIFIER',u'maxinteger') ctx.rule(u'IDENTIFIER',u'min') ctx.rule(u'IDENTIFIER',u'mininteger') ctx.rule(u'IDENTIFIER',u'modf') ctx.rule(u'IDENTIFIER',u'pi') ctx.rule(u'IDENTIFIER',u'rad') ctx.rule(u'IDENTIFIER',u'random') ctx.rule(u'IDENTIFIER',u'randomseed') ctx.rule(u'IDENTIFIER',u'sin') ctx.rule(u'IDENTIFIER',u'sqrt') ctx.rule(u'IDENTIFIER',u'tan') ctx.rule(u'IDENTIFIER',u'tointeger') ctx.rule(u'IDENTIFIER',u'type') ctx.rule(u'IDENTIFIER',u'ult') ctx.rule(u'IDENTIFIER',u'os') ctx.rule(u'IDENTIFIER',u'clock') ctx.rule(u'IDENTIFIER',u'date') ctx.rule(u'IDENTIFIER',u'difftime') ctx.rule(u'IDENTIFIER',u'exit') ctx.rule(u'IDENTIFIER',u'getenv') ctx.rule(u'IDENTIFIER',u'remove') ctx.rule(u'IDENTIFIER',u'rename') ctx.rule(u'IDENTIFIER',u'setlocale') ctx.rule(u'IDENTIFIER',u'time') ctx.rule(u'IDENTIFIER',u'tmpname') ctx.rule(u'IDENTIFIER',u'package') ctx.rule(u'IDENTIFIER',u'config') ctx.rule(u'IDENTIFIER',u'cpath') ctx.rule(u'IDENTIFIER',u'loaded') ctx.rule(u'IDENTIFIER',u'loadlib') ctx.rule(u'IDENTIFIER',u'path') ctx.rule(u'IDENTIFIER',u'preload') ctx.rule(u'IDENTIFIER',u'searchers') ctx.rule(u'IDENTIFIER',u'searchpath') ctx.rule(u'IDENTIFIER',u'string') ctx.rule(u'IDENTIFIER',u'byte') ctx.rule(u'IDENTIFIER',u'char') ctx.rule(u'IDENTIFIER',u'dump') ctx.rule(u'IDENTIFIER',u'find') ctx.rule(u'IDENTIFIER',u'format') ctx.rule(u'IDENTIFIER',u'gmatch') ctx.rule(u'IDENTIFIER',u'gsub') ctx.rule(u'IDENTIFIER',u'len') ctx.rule(u'IDENTIFIER',u'lower') ctx.rule(u'IDENTIFIER',u'match') ctx.rule(u'IDENTIFIER',u'pack') ctx.rule(u'IDENTIFIER',u'packsize') ctx.rule(u'IDENTIFIER',u'rep') ctx.rule(u'IDENTIFIER',u'reverse') ctx.rule(u'IDENTIFIER',u'sub') ctx.rule(u'IDENTIFIER',u'unpack') ctx.rule(u'IDENTIFIER',u'upper') ctx.rule(u'IDENTIFIER',u'table') ctx.rule(u'IDENTIFIER',u'concat') ctx.rule(u'IDENTIFIER',u'insert') ctx.rule(u'IDENTIFIER',u'move') ctx.rule(u'IDENTIFIER',u'pack') ctx.rule(u'IDENTIFIER',u'remove') ctx.rule(u'IDENTIFIER',u'sort') ctx.rule(u'IDENTIFIER',u'unpack') ctx.rule(u'IDENTIFIER',u'utf8') ctx.rule(u'IDENTIFIER',u'char') ctx.rule(u'IDENTIFIER',u'charpattern') ctx.rule(u'IDENTIFIER',u'codepoint') ctx.rule(u'IDENTIFIER',u'codes') ctx.rule(u'IDENTIFIER',u'len') ctx.rule(u'IDENTIFIER',u'offset') ctx.rule(u'IDENTIFIER',u'create') ctx.rule(u'IDENTIFIER',u'isyieldable') ctx.rule(u'IDENTIFIER',u'resume') ctx.rule(u'IDENTIFIER',u'running') ctx.rule(u'IDENTIFIER',u'status') ctx.rule(u'IDENTIFIER',u'wrap') ctx.rule(u'IDENTIFIER',u'yield') ctx.rule(u'IDENTIFIER',u'debug') ctx.rule(u'IDENTIFIER',u'gethook') ctx.rule(u'IDENTIFIER',u'getinfo') ctx.rule(u'IDENTIFIER',u'getlocal') ctx.rule(u'IDENTIFIER',u'getmetatable') ctx.rule(u'IDENTIFIER',u'getregistry') ctx.rule(u'IDENTIFIER',u'getupvalue') ctx.rule(u'IDENTIFIER',u'getuservalue') ctx.rule(u'IDENTIFIER',u'sethook') ctx.rule(u'IDENTIFIER',u'setlocal') ctx.rule(u'IDENTIFIER',u'setmetatable') ctx.rule(u'IDENTIFIER',u'setupvalue') ctx.rule(u'IDENTIFIER',u'setuservalue') ctx.rule(u'IDENTIFIER',u'traceback') ctx.rule(u'IDENTIFIER',u'upvalueid') ctx.rule(u'IDENTIFIER',u'upvaluejoin') ctx.rule(u'IDENTIFIER',u'close') ctx.rule(u'IDENTIFIER',u'flush') ctx.rule(u'IDENTIFIER',u'input') ctx.rule(u'IDENTIFIER',u'lines') ctx.rule(u'IDENTIFIER',u'open') ctx.rule(u'IDENTIFIER',u'output') ctx.rule(u'IDENTIFIER',u'popen') ctx.rule(u'IDENTIFIER',u'read') ctx.rule(u'IDENTIFIER',u'stderr') ctx.rule(u'IDENTIFIER',u'stdin') ctx.rule(u'IDENTIFIER',u'stdout') ctx.rule(u'IDENTIFIER',u'tmpfile') ctx.rule(u'IDENTIFIER',u'type') ctx.rule(u'IDENTIFIER',u'write') ctx.rule(u'IDENTIFIER',u'close') ctx.rule(u'IDENTIFIER',u'flush') ctx.rule(u'IDENTIFIER',u'lines') ctx.rule(u'IDENTIFIER',u'read') ctx.rule(u'IDENTIFIER',u'seek') ctx.rule(u'IDENTIFIER',u'setvbuf') ctx.rule(u'IDENTIFIER',u'write') ctx.rule(u'IDENTIFIER',u'abs') ctx.rule(u'IDENTIFIER',u'acos') ctx.rule(u'IDENTIFIER',u'asin') ctx.rule(u'IDENTIFIER',u'atan') ctx.rule(u'IDENTIFIER',u'ceil') ctx.rule(u'IDENTIFIER',u'cos') ctx.rule(u'IDENTIFIER',u'deg') ctx.rule(u'IDENTIFIER',u'exp') ctx.rule(u'IDENTIFIER',u'floor') ctx.rule(u'IDENTIFIER',u'fmod') ctx.rule(u'IDENTIFIER',u'huge') ctx.rule(u'IDENTIFIER',u'log') ctx.rule(u'IDENTIFIER',u'max') ctx.rule(u'IDENTIFIER',u'maxinteger') ctx.rule(u'IDENTIFIER',u'min') ctx.rule(u'IDENTIFIER',u'mininteger') ctx.rule(u'IDENTIFIER',u'modf') ctx.rule(u'IDENTIFIER',u'pi') ctx.rule(u'IDENTIFIER',u'rad') ctx.rule(u'IDENTIFIER',u'random') ctx.rule(u'IDENTIFIER',u'randomseed') ctx.rule(u'IDENTIFIER',u'sin') ctx.rule(u'IDENTIFIER',u'sqrt') ctx.rule(u'IDENTIFIER',u'tan') ctx.rule(u'IDENTIFIER',u'tointeger') ctx.rule(u'IDENTIFIER',u'type') ctx.rule(u'IDENTIFIER',u'ult') ctx.rule(u'IDENTIFIER',u'clock') ctx.rule(u'IDENTIFIER',u'date') ctx.rule(u'IDENTIFIER',u'difftime') ctx.rule(u'IDENTIFIER',u'exit') ctx.rule(u'IDENTIFIER',u'getenv') ctx.rule(u'IDENTIFIER',u'remove') ctx.rule(u'IDENTIFIER',u'rename') ctx.rule(u'IDENTIFIER',u'setlocale') ctx.rule(u'IDENTIFIER',u'time') ctx.rule(u'IDENTIFIER',u'tmpname') ctx.rule(u'IDENTIFIER',u'config') ctx.rule(u'IDENTIFIER',u'cpath') ctx.rule(u'IDENTIFIER',u'loaded') ctx.rule(u'IDENTIFIER',u'loadlib') ctx.rule(u'IDENTIFIER',u'path') ctx.rule(u'IDENTIFIER',u'preload') ctx.rule(u'IDENTIFIER',u'searchers') ctx.rule(u'IDENTIFIER',u'searchpath') ctx.rule(u'IDENTIFIER',u'byte') ctx.rule(u'IDENTIFIER',u'char') ctx.rule(u'IDENTIFIER',u'dump') ctx.rule(u'IDENTIFIER',u'find') ctx.rule(u'IDENTIFIER',u'format') ctx.rule(u'IDENTIFIER',u'gmatch') ctx.rule(u'IDENTIFIER',u'gsub') ctx.rule(u'IDENTIFIER',u'len') ctx.rule(u'IDENTIFIER',u'lower') ctx.rule(u'IDENTIFIER',u'match') ctx.rule(u'IDENTIFIER',u'pack') ctx.rule(u'IDENTIFIER',u'packsize') ctx.rule(u'IDENTIFIER',u'rep') ctx.rule(u'IDENTIFIER',u'reverse') ctx.rule(u'IDENTIFIER',u'sub') ctx.rule(u'IDENTIFIER',u'unpack') ctx.rule(u'IDENTIFIER',u'upper') ctx.rule(u'IDENTIFIER',u'concat') ctx.rule(u'IDENTIFIER',u'insert') ctx.rule(u'IDENTIFIER',u'move') ctx.rule(u'IDENTIFIER',u'pack') ctx.rule(u'IDENTIFIER',u'remove') ctx.rule(u'IDENTIFIER',u'sort') ctx.rule(u'IDENTIFIER',u'unpack') ctx.rule(u'IDENTIFIER',u'char') ctx.rule(u'IDENTIFIER',u'charpattern') ctx.rule(u'IDENTIFIER',u'codepoint') ctx.rule(u'IDENTIFIER',u'codes') ctx.rule(u'IDENTIFIER',u'len') ctx.rule(u'IDENTIFIER',u'offset') ctx.rule(u'IDENTIFIER',u'__index') ctx.rule(u'IDENTIFIER',u'__newindex') ctx.rule(u'IDENTIFIER',u'__add') ctx.rule(u'IDENTIFIER',u'__sub') ctx.rule(u'IDENTIFIER',u'__mul') ctx.rule(u'IDENTIFIER',u'__div') ctx.rule(u'IDENTIFIER',u'__mod') ctx.rule(u'IDENTIFIER',u'__unm') ctx.rule(u'IDENTIFIER',u'__concat') ctx.rule(u'IDENTIFIER',u'__eq') ctx.rule(u'IDENTIFIER',u'__lt') ctx.rule(u'IDENTIFIER',u'__le') ctx.rule(u'IDENTIFIER',u'__call') ctx.rule(u'IDENTIFIER',u'__tostring')
ctx.rule(u'START', u'{PROGRAM}') ctx.rule(u'PROGRAM', u'{STATEMENT}\n{PROGRAM}') ctx.rule(u'PROGRAM', u'') ctx.rule(u'STATEMENT', u';') ctx.rule(u'STATEMENT', u'') ctx.rule(u'STATEMENT', u'break') ctx.rule(u'STATEMENT', u'{VAR} = {EXPR}') ctx.rule(u'STATEMENT', u'local {VARLIST} = {EXPRLIST}') ctx.rule(u'STATEMENT', u'{FUNCTION}') ctx.rule(u'STATEMENT', u'{COROUTINE}') ctx.rule(u'STATEMENT', u'{CONDITIONAL}') ctx.rule(u'STATEMENT', u'{LOOP}') ctx.rule(u'STATEMENT', u'return {EXPRLIST}') ctx.rule(u'STATEMENT', u'goto {LABELNAME}') ctx.rule(u'STATEMENT', u'::{LABELNAME}::') ctx.rule(u'LABELNAME', u'labela') ctx.rule(u'LABELNAME', u'labelb') ctx.rule(u'FUNCTION', u'{FUNCDEF} ({FUNCTION_ARGS}) {PROGRAM}\nend') ctx.rule(u'FUNCDEF', u'function {VAR}.{IDENTIFIER}') ctx.rule(u'FUNCDEF', u'function {VAR}:{IDENTIFIER}') ctx.rule(u'FUNCDEF', u'function {IDENTIFIER}') ctx.rule(u'LAMBDA', u'function ({FUNCTION_ARGS}) {PROGRAM} end') ctx.rule(u'FUNCTION_ARGS', u'') ctx.rule(u'FUNCTION_ARGS', u'{FUNCTION_ARGLIST}') ctx.rule(u'FUNCTION_ARGLIST', u'{VAR}, {FUNCTION_ARGLIST}') ctx.rule(u'FUNCTION_ARGLIST', u'{VAR}') ctx.rule(u'FUNCTION_ARGLIST', u'...') ctx.rule(u'COROUTINE', u'{VAR} = coroutine.create({LAMBDA})') ctx.rule(u'COROUTINE', u'{VAR} = coroutine.wrap({LAMBDA})') ctx.rule(u'COROUTINE', u'coroutine.resume({VAR}, {ARGS})') ctx.rule(u'COROUTINE', u'coroutine.yield({ARGS})') ctx.rule(u'FUNCTIONCALL', u'{IDENTIFIER} {ARGS}') ctx.rule(u'FUNCTIONCALL', u'{EXPR}:{IDENTIFIER} {ARGS}') ctx.rule(u'FUNCTIONCALL', u'{EXPR}.{IDENTIFIER} {ARGS}') ctx.rule(u'ARGS', u'({EXPRLIST})') ctx.rule(u'ARGS', u'{TABLECONSTRUCTOR}') ctx.rule(u'ARGS', u'{LITERALSTRING}') ctx.rule(u'CONDITIONAL', u'if {EXPR} then\n{PROGRAM}\nend') ctx.rule(u'CONDITIONAL', u'if {EXPR} then\n{PROGRAM}\nelse\n{PROGRAM}\nend') ctx.rule(u'LOOP', u'while ({EXPR})\ndo\n{PROGRAM}\nend') ctx.rule(u'LOOP', u'for {VAR}={EXPR}, {EXPR}, {EXPR}\ndo\n{PROGRAM}\nend') ctx.rule(u'LOOP', u'repeat\n{PROGRAM}\nuntil ({EXPR})') ctx.rule(u'EXPRLIST', u'{EXPR}, {EXPRLIST}') ctx.rule(u'EXPRLIST', u'{EXPR}') ctx.rule(u'EXPR', u'(nil)') ctx.rule(u'EXPR', u'(false)') ctx.rule(u'EXPR', u'(true)') ctx.rule(u'EXPR', u'({NUMERAL})') ctx.rule(u'EXPR', u'{LITERALSTRING}') ctx.rule(u'EXPR', u'{TABLECONSTRUCTOR}') ctx.rule(u'EXPR', u'({VAR}[{EXPR}])') ctx.rule(u'EXPR', u'({EXPR}{BINOP}{EXPR})') ctx.rule(u'EXPR', u'({UNOP}{EXPR})') ctx.rule(u'EXPR', u'{LAMBDA}') ctx.rule(u'EXPR', u'{VAR}') ctx.rule(u'EXPR', u'{FUNCTIONCALL}') ctx.rule(u'EXPR', u'({EXPR})') ctx.rule(u'EXPR', u'...') ctx.rule(u'BINOP', u'+') ctx.rule(u'BINOP', u'-') ctx.rule(u'BINOP', u'*') ctx.rule(u'BINOP', u'/') ctx.rule(u'BINOP', u'//') ctx.rule(u'BINOP', u'^') ctx.rule(u'BINOP', u'%') ctx.rule(u'BINOP', u'&') ctx.rule(u'BINOP', u'~') ctx.rule(u'BINOP', u'|') ctx.rule(u'BINOP', u'>>') ctx.rule(u'BINOP', u'<<') ctx.rule(u'BINOP', u' .. ') ctx.rule(u'BINOP', u'<') ctx.rule(u'BINOP', u'<=') ctx.rule(u'BINOP', u'>') ctx.rule(u'BINOP', u'>=') ctx.rule(u'BINOP', u'==') ctx.rule(u'BINOP', u'~=') ctx.rule(u'BINOP', u' and ') ctx.rule(u'BINOP', u' or ') ctx.rule(u'UNOP', u'-') ctx.rule(u'UNOP', u' not ') ctx.rule(u'UNOP', u'#') ctx.rule(u'UNOP', u'~') ctx.rule(u'TABLECONSTRUCTOR', u'\\{{FIELDLIST}\\}') ctx.rule(u'METATABLE', u'{VAR} = setmetatable({VAR}, {TABLECONSTRUCTOR})') ctx.rule(u'FIELDLIST', u'{FIELD},{FIELDLIST}') ctx.rule(u'FIELDLIST', u'{FIELD}') ctx.rule(u'FIELD', u'[{EXPR}]={EXPR}') ctx.rule(u'FIELD', u'{IDENTIFIER}={EXPR}') ctx.rule(u'FIELD', u'{EXPR}') ctx.rule(u'VARLIST', u'{VAR}, {VARLIST}') ctx.rule(u'VARLIST', u'{VAR}') ctx.rule(u'VAR', u'a') ctx.rule(u'VAR', u'b') ctx.rule(u'VAR', u'c') ctx.rule(u'VAR', u'd') ctx.rule(u'VAR', u'e') ctx.rule(u'VAR', u'coroutine') ctx.rule(u'VAR', u'debug') ctx.rule(u'VAR', u'math') ctx.rule(u'VAR', u'io') ctx.rule(u'VAR', u'os') ctx.rule(u'VAR', u'package') ctx.rule(u'VAR', u'string') ctx.rule(u'VAR', u'table') ctx.rule(u'VAR', u'utf8') ctx.rule(u'VAR', u'self') ctx.rule(u'LITERALSTRING', u'"{STRING}"') ctx.rule(u'LITERALSTRING', u'[[{STRING}]]') ctx.rule(u'STRING', u'') ctx.rule(u'STRING', u'{STRCHR}{STRING}') ctx.rule(u'STRCHR', u'\n') ctx.rule(u'STRCHR', u'\r') ctx.rule(u'STRCHR', u' ') ctx.rule(u'STRCHR', u'\t') ctx.rule(u'STRCHR', u'0') ctx.rule(u'STRCHR', u'a') ctx.rule(u'STRCHR', u'/') ctx.rule(u'STRCHR', u'.') ctx.rule(u'STRCHR', u'$') ctx.rule(u'STRCHR', u'{ESCAPESEQUENCE}') ctx.rule(u'ESCAPESEQUENCE', u'\\a') ctx.rule(u'ESCAPESEQUENCE', u'\\b') ctx.rule(u'ESCAPESEQUENCE', u'\\f') ctx.rule(u'ESCAPESEQUENCE', u'\\n') ctx.rule(u'ESCAPESEQUENCE', u'\\r') ctx.rule(u'ESCAPESEQUENCE', u'\\t') ctx.rule(u'ESCAPESEQUENCE', u'\\v') ctx.rule(u'ESCAPESEQUENCE', u'\\z') ctx.rule(u'ESCAPESEQUENCE', u'\n') ctx.rule(u'ESCAPESEQUENCE', u'\\x{HEXADECIMAL}') ctx.rule(u'ESCAPESEQUENCE', u'\\u\\{{HEXADECIMAL}\\}') ctx.rule(u'NUMERAL', u'{DECIMAL}') ctx.rule(u'NUMERAL', u'0x{HEXADECIMAL}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}e{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}e-{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}e{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMAL', u'{DECIMALDIGIT}{DECIMALDIGITS}.{DECIMALDIGIT}{DECIMALDIGITS}e-{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}p{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}p-{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}p{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXADECIMAL', u'{HEXDIGIT}{HEXDIGITS}.{HEXDIGIT}{HEXDIGITS}p-{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'DECIMALDIGITS', u'{DECIMALDIGIT}{DECIMALDIGITS}') ctx.rule(u'DECIMALDIGITS', u'') ctx.rule(u'HEXDIGITS', u'{HEXDIGIT}{HEXDIGITS}') ctx.rule(u'HEXDIGITS', u'') ctx.rule(u'DECIMALDIGIT', u'0') ctx.rule(u'DECIMALDIGIT', u'1') ctx.rule(u'DECIMALDIGIT', u'2') ctx.rule(u'DECIMALDIGIT', u'3') ctx.rule(u'DECIMALDIGIT', u'4') ctx.rule(u'DECIMALDIGIT', u'5') ctx.rule(u'DECIMALDIGIT', u'6') ctx.rule(u'DECIMALDIGIT', u'7') ctx.rule(u'DECIMALDIGIT', u'8') ctx.rule(u'DECIMALDIGIT', u'9') ctx.rule(u'HEXDIGIT', u'a') ctx.rule(u'HEXDIGIT', u'b') ctx.rule(u'HEXDIGIT', u'c') ctx.rule(u'HEXDIGIT', u'd') ctx.rule(u'HEXDIGIT', u'e') ctx.rule(u'HEXDIGIT', u'f') ctx.rule(u'HEXDIGIT', u'A') ctx.rule(u'HEXDIGIT', u'B') ctx.rule(u'HEXDIGIT', u'C') ctx.rule(u'HEXDIGIT', u'D') ctx.rule(u'HEXDIGIT', u'E') ctx.rule(u'HEXDIGIT', u'F') ctx.rule(u'HEXDIGIT', u'{DECIMALDIGIT}') ctx.rule(u'IDENTIFIER', u'self') ctx.rule(u'IDENTIFIER', u'G') ctx.rule(u'IDENTIFIER', u'_VERSION') ctx.rule(u'IDENTIFIER', u'assert') ctx.rule(u'IDENTIFIER', u'collectgarbage') ctx.rule(u'IDENTIFIER', u'dofile') ctx.rule(u'IDENTIFIER', u'error') ctx.rule(u'IDENTIFIER', u'getmetatable') ctx.rule(u'IDENTIFIER', u'ipairs') ctx.rule(u'IDENTIFIER', u'load') ctx.rule(u'IDENTIFIER', u'loadfile') ctx.rule(u'IDENTIFIER', u'next') ctx.rule(u'IDENTIFIER', u'pairs') ctx.rule(u'IDENTIFIER', u'pcall') ctx.rule(u'IDENTIFIER', u'print') ctx.rule(u'IDENTIFIER', u'rawequal') ctx.rule(u'IDENTIFIER', u'rawget') ctx.rule(u'IDENTIFIER', u'rawlen') ctx.rule(u'IDENTIFIER', u'rawset') ctx.rule(u'IDENTIFIER', u'require') ctx.rule(u'IDENTIFIER', u'select') ctx.rule(u'IDENTIFIER', u'setmetatable') ctx.rule(u'IDENTIFIER', u'tonumber') ctx.rule(u'IDENTIFIER', u'tostring') ctx.rule(u'IDENTIFIER', u'type') ctx.rule(u'IDENTIFIER', u'xpcall') ctx.rule(u'IDENTIFIER', u'coroutine') ctx.rule(u'IDENTIFIER', u'create') ctx.rule(u'IDENTIFIER', u'isyieldable') ctx.rule(u'IDENTIFIER', u'resume') ctx.rule(u'IDENTIFIER', u'running') ctx.rule(u'IDENTIFIER', u'status') ctx.rule(u'IDENTIFIER', u'wrap') ctx.rule(u'IDENTIFIER', u'yield') ctx.rule(u'IDENTIFIER', u'debug') ctx.rule(u'IDENTIFIER', u'debug') ctx.rule(u'IDENTIFIER', u'gethook') ctx.rule(u'IDENTIFIER', u'getinfo') ctx.rule(u'IDENTIFIER', u'getlocal') ctx.rule(u'IDENTIFIER', u'getmetatable') ctx.rule(u'IDENTIFIER', u'getregistry') ctx.rule(u'IDENTIFIER', u'getupvalue') ctx.rule(u'IDENTIFIER', u'getuservalue') ctx.rule(u'IDENTIFIER', u'sethook') ctx.rule(u'IDENTIFIER', u'setlocal') ctx.rule(u'IDENTIFIER', u'setmetatable') ctx.rule(u'IDENTIFIER', u'setupvalue') ctx.rule(u'IDENTIFIER', u'setuservalue') ctx.rule(u'IDENTIFIER', u'traceback') ctx.rule(u'IDENTIFIER', u'upvalueid') ctx.rule(u'IDENTIFIER', u'upvaluejoin') ctx.rule(u'IDENTIFIER', u'io') ctx.rule(u'IDENTIFIER', u'close') ctx.rule(u'IDENTIFIER', u'flush') ctx.rule(u'IDENTIFIER', u'input') ctx.rule(u'IDENTIFIER', u'lines') ctx.rule(u'IDENTIFIER', u'open') ctx.rule(u'IDENTIFIER', u'output') ctx.rule(u'IDENTIFIER', u'popen') ctx.rule(u'IDENTIFIER', u'read') ctx.rule(u'IDENTIFIER', u'stderr') ctx.rule(u'IDENTIFIER', u'stdin') ctx.rule(u'IDENTIFIER', u'stdout') ctx.rule(u'IDENTIFIER', u'tmpfile') ctx.rule(u'IDENTIFIER', u'type') ctx.rule(u'IDENTIFIER', u'write') ctx.rule(u'IDENTIFIER', u'math') ctx.rule(u'IDENTIFIER', u'abs') ctx.rule(u'IDENTIFIER', u'acos') ctx.rule(u'IDENTIFIER', u'asin') ctx.rule(u'IDENTIFIER', u'atan') ctx.rule(u'IDENTIFIER', u'ceil') ctx.rule(u'IDENTIFIER', u'cos') ctx.rule(u'IDENTIFIER', u'deg') ctx.rule(u'IDENTIFIER', u'exp') ctx.rule(u'IDENTIFIER', u'floor') ctx.rule(u'IDENTIFIER', u'fmod') ctx.rule(u'IDENTIFIER', u'huge') ctx.rule(u'IDENTIFIER', u'log') ctx.rule(u'IDENTIFIER', u'max') ctx.rule(u'IDENTIFIER', u'maxinteger') ctx.rule(u'IDENTIFIER', u'min') ctx.rule(u'IDENTIFIER', u'mininteger') ctx.rule(u'IDENTIFIER', u'modf') ctx.rule(u'IDENTIFIER', u'pi') ctx.rule(u'IDENTIFIER', u'rad') ctx.rule(u'IDENTIFIER', u'random') ctx.rule(u'IDENTIFIER', u'randomseed') ctx.rule(u'IDENTIFIER', u'sin') ctx.rule(u'IDENTIFIER', u'sqrt') ctx.rule(u'IDENTIFIER', u'tan') ctx.rule(u'IDENTIFIER', u'tointeger') ctx.rule(u'IDENTIFIER', u'type') ctx.rule(u'IDENTIFIER', u'ult') ctx.rule(u'IDENTIFIER', u'os') ctx.rule(u'IDENTIFIER', u'clock') ctx.rule(u'IDENTIFIER', u'date') ctx.rule(u'IDENTIFIER', u'difftime') ctx.rule(u'IDENTIFIER', u'exit') ctx.rule(u'IDENTIFIER', u'getenv') ctx.rule(u'IDENTIFIER', u'remove') ctx.rule(u'IDENTIFIER', u'rename') ctx.rule(u'IDENTIFIER', u'setlocale') ctx.rule(u'IDENTIFIER', u'time') ctx.rule(u'IDENTIFIER', u'tmpname') ctx.rule(u'IDENTIFIER', u'package') ctx.rule(u'IDENTIFIER', u'config') ctx.rule(u'IDENTIFIER', u'cpath') ctx.rule(u'IDENTIFIER', u'loaded') ctx.rule(u'IDENTIFIER', u'loadlib') ctx.rule(u'IDENTIFIER', u'path') ctx.rule(u'IDENTIFIER', u'preload') ctx.rule(u'IDENTIFIER', u'searchers') ctx.rule(u'IDENTIFIER', u'searchpath') ctx.rule(u'IDENTIFIER', u'string') ctx.rule(u'IDENTIFIER', u'byte') ctx.rule(u'IDENTIFIER', u'char') ctx.rule(u'IDENTIFIER', u'dump') ctx.rule(u'IDENTIFIER', u'find') ctx.rule(u'IDENTIFIER', u'format') ctx.rule(u'IDENTIFIER', u'gmatch') ctx.rule(u'IDENTIFIER', u'gsub') ctx.rule(u'IDENTIFIER', u'len') ctx.rule(u'IDENTIFIER', u'lower') ctx.rule(u'IDENTIFIER', u'match') ctx.rule(u'IDENTIFIER', u'pack') ctx.rule(u'IDENTIFIER', u'packsize') ctx.rule(u'IDENTIFIER', u'rep') ctx.rule(u'IDENTIFIER', u'reverse') ctx.rule(u'IDENTIFIER', u'sub') ctx.rule(u'IDENTIFIER', u'unpack') ctx.rule(u'IDENTIFIER', u'upper') ctx.rule(u'IDENTIFIER', u'table') ctx.rule(u'IDENTIFIER', u'concat') ctx.rule(u'IDENTIFIER', u'insert') ctx.rule(u'IDENTIFIER', u'move') ctx.rule(u'IDENTIFIER', u'pack') ctx.rule(u'IDENTIFIER', u'remove') ctx.rule(u'IDENTIFIER', u'sort') ctx.rule(u'IDENTIFIER', u'unpack') ctx.rule(u'IDENTIFIER', u'utf8') ctx.rule(u'IDENTIFIER', u'char') ctx.rule(u'IDENTIFIER', u'charpattern') ctx.rule(u'IDENTIFIER', u'codepoint') ctx.rule(u'IDENTIFIER', u'codes') ctx.rule(u'IDENTIFIER', u'len') ctx.rule(u'IDENTIFIER', u'offset') ctx.rule(u'IDENTIFIER', u'create') ctx.rule(u'IDENTIFIER', u'isyieldable') ctx.rule(u'IDENTIFIER', u'resume') ctx.rule(u'IDENTIFIER', u'running') ctx.rule(u'IDENTIFIER', u'status') ctx.rule(u'IDENTIFIER', u'wrap') ctx.rule(u'IDENTIFIER', u'yield') ctx.rule(u'IDENTIFIER', u'debug') ctx.rule(u'IDENTIFIER', u'gethook') ctx.rule(u'IDENTIFIER', u'getinfo') ctx.rule(u'IDENTIFIER', u'getlocal') ctx.rule(u'IDENTIFIER', u'getmetatable') ctx.rule(u'IDENTIFIER', u'getregistry') ctx.rule(u'IDENTIFIER', u'getupvalue') ctx.rule(u'IDENTIFIER', u'getuservalue') ctx.rule(u'IDENTIFIER', u'sethook') ctx.rule(u'IDENTIFIER', u'setlocal') ctx.rule(u'IDENTIFIER', u'setmetatable') ctx.rule(u'IDENTIFIER', u'setupvalue') ctx.rule(u'IDENTIFIER', u'setuservalue') ctx.rule(u'IDENTIFIER', u'traceback') ctx.rule(u'IDENTIFIER', u'upvalueid') ctx.rule(u'IDENTIFIER', u'upvaluejoin') ctx.rule(u'IDENTIFIER', u'close') ctx.rule(u'IDENTIFIER', u'flush') ctx.rule(u'IDENTIFIER', u'input') ctx.rule(u'IDENTIFIER', u'lines') ctx.rule(u'IDENTIFIER', u'open') ctx.rule(u'IDENTIFIER', u'output') ctx.rule(u'IDENTIFIER', u'popen') ctx.rule(u'IDENTIFIER', u'read') ctx.rule(u'IDENTIFIER', u'stderr') ctx.rule(u'IDENTIFIER', u'stdin') ctx.rule(u'IDENTIFIER', u'stdout') ctx.rule(u'IDENTIFIER', u'tmpfile') ctx.rule(u'IDENTIFIER', u'type') ctx.rule(u'IDENTIFIER', u'write') ctx.rule(u'IDENTIFIER', u'close') ctx.rule(u'IDENTIFIER', u'flush') ctx.rule(u'IDENTIFIER', u'lines') ctx.rule(u'IDENTIFIER', u'read') ctx.rule(u'IDENTIFIER', u'seek') ctx.rule(u'IDENTIFIER', u'setvbuf') ctx.rule(u'IDENTIFIER', u'write') ctx.rule(u'IDENTIFIER', u'abs') ctx.rule(u'IDENTIFIER', u'acos') ctx.rule(u'IDENTIFIER', u'asin') ctx.rule(u'IDENTIFIER', u'atan') ctx.rule(u'IDENTIFIER', u'ceil') ctx.rule(u'IDENTIFIER', u'cos') ctx.rule(u'IDENTIFIER', u'deg') ctx.rule(u'IDENTIFIER', u'exp') ctx.rule(u'IDENTIFIER', u'floor') ctx.rule(u'IDENTIFIER', u'fmod') ctx.rule(u'IDENTIFIER', u'huge') ctx.rule(u'IDENTIFIER', u'log') ctx.rule(u'IDENTIFIER', u'max') ctx.rule(u'IDENTIFIER', u'maxinteger') ctx.rule(u'IDENTIFIER', u'min') ctx.rule(u'IDENTIFIER', u'mininteger') ctx.rule(u'IDENTIFIER', u'modf') ctx.rule(u'IDENTIFIER', u'pi') ctx.rule(u'IDENTIFIER', u'rad') ctx.rule(u'IDENTIFIER', u'random') ctx.rule(u'IDENTIFIER', u'randomseed') ctx.rule(u'IDENTIFIER', u'sin') ctx.rule(u'IDENTIFIER', u'sqrt') ctx.rule(u'IDENTIFIER', u'tan') ctx.rule(u'IDENTIFIER', u'tointeger') ctx.rule(u'IDENTIFIER', u'type') ctx.rule(u'IDENTIFIER', u'ult') ctx.rule(u'IDENTIFIER', u'clock') ctx.rule(u'IDENTIFIER', u'date') ctx.rule(u'IDENTIFIER', u'difftime') ctx.rule(u'IDENTIFIER', u'exit') ctx.rule(u'IDENTIFIER', u'getenv') ctx.rule(u'IDENTIFIER', u'remove') ctx.rule(u'IDENTIFIER', u'rename') ctx.rule(u'IDENTIFIER', u'setlocale') ctx.rule(u'IDENTIFIER', u'time') ctx.rule(u'IDENTIFIER', u'tmpname') ctx.rule(u'IDENTIFIER', u'config') ctx.rule(u'IDENTIFIER', u'cpath') ctx.rule(u'IDENTIFIER', u'loaded') ctx.rule(u'IDENTIFIER', u'loadlib') ctx.rule(u'IDENTIFIER', u'path') ctx.rule(u'IDENTIFIER', u'preload') ctx.rule(u'IDENTIFIER', u'searchers') ctx.rule(u'IDENTIFIER', u'searchpath') ctx.rule(u'IDENTIFIER', u'byte') ctx.rule(u'IDENTIFIER', u'char') ctx.rule(u'IDENTIFIER', u'dump') ctx.rule(u'IDENTIFIER', u'find') ctx.rule(u'IDENTIFIER', u'format') ctx.rule(u'IDENTIFIER', u'gmatch') ctx.rule(u'IDENTIFIER', u'gsub') ctx.rule(u'IDENTIFIER', u'len') ctx.rule(u'IDENTIFIER', u'lower') ctx.rule(u'IDENTIFIER', u'match') ctx.rule(u'IDENTIFIER', u'pack') ctx.rule(u'IDENTIFIER', u'packsize') ctx.rule(u'IDENTIFIER', u'rep') ctx.rule(u'IDENTIFIER', u'reverse') ctx.rule(u'IDENTIFIER', u'sub') ctx.rule(u'IDENTIFIER', u'unpack') ctx.rule(u'IDENTIFIER', u'upper') ctx.rule(u'IDENTIFIER', u'concat') ctx.rule(u'IDENTIFIER', u'insert') ctx.rule(u'IDENTIFIER', u'move') ctx.rule(u'IDENTIFIER', u'pack') ctx.rule(u'IDENTIFIER', u'remove') ctx.rule(u'IDENTIFIER', u'sort') ctx.rule(u'IDENTIFIER', u'unpack') ctx.rule(u'IDENTIFIER', u'char') ctx.rule(u'IDENTIFIER', u'charpattern') ctx.rule(u'IDENTIFIER', u'codepoint') ctx.rule(u'IDENTIFIER', u'codes') ctx.rule(u'IDENTIFIER', u'len') ctx.rule(u'IDENTIFIER', u'offset') ctx.rule(u'IDENTIFIER', u'__index') ctx.rule(u'IDENTIFIER', u'__newindex') ctx.rule(u'IDENTIFIER', u'__add') ctx.rule(u'IDENTIFIER', u'__sub') ctx.rule(u'IDENTIFIER', u'__mul') ctx.rule(u'IDENTIFIER', u'__div') ctx.rule(u'IDENTIFIER', u'__mod') ctx.rule(u'IDENTIFIER', u'__unm') ctx.rule(u'IDENTIFIER', u'__concat') ctx.rule(u'IDENTIFIER', u'__eq') ctx.rule(u'IDENTIFIER', u'__lt') ctx.rule(u'IDENTIFIER', u'__le') ctx.rule(u'IDENTIFIER', u'__call') ctx.rule(u'IDENTIFIER', u'__tostring')
def detectHashtag(inputs): data = [] for tweet in inputs: hashtag = tweet.entities['hashtags'] for hash in hashtag: if hash['text'].lower() == 'testtweet': data.append(tweet) return data def interact(inputs, api, FILE_NAME): data = detectHashtag(inputs) for i in data[::-1]: api.update_status("Hello @" + i.user.screen_name + ", this is an automated response to your tweet. ", i.id) api.create_favorite(i.id) api.retweet(i.id) store_last_seen(FILE_NAME, i.id) def read_last_seen(FILE_NAME): file_read = open(FILE_NAME, 'r') last_seen_id = int(file_read.read().strip()) file_read.close() return last_seen_id def store_last_seen(FILE_NAME, last_seen_id): file_write = open(FILE_NAME, 'w') file_write.write(str(last_seen_id)) file_write.close()
def detect_hashtag(inputs): data = [] for tweet in inputs: hashtag = tweet.entities['hashtags'] for hash in hashtag: if hash['text'].lower() == 'testtweet': data.append(tweet) return data def interact(inputs, api, FILE_NAME): data = detect_hashtag(inputs) for i in data[::-1]: api.update_status('Hello @' + i.user.screen_name + ', this is an automated response to your tweet. ', i.id) api.create_favorite(i.id) api.retweet(i.id) store_last_seen(FILE_NAME, i.id) def read_last_seen(FILE_NAME): file_read = open(FILE_NAME, 'r') last_seen_id = int(file_read.read().strip()) file_read.close() return last_seen_id def store_last_seen(FILE_NAME, last_seen_id): file_write = open(FILE_NAME, 'w') file_write.write(str(last_seen_id)) file_write.close()
class Element: __slots__ = ('attributes', 'children') name = 'element' def __init__(self, *args, **kwargs): self.attributes = {k.replace('_', '-'): v for k, v in kwargs.items()} self.children = [] for item in args: if type(item) in (list, tuple): self.children.extend(item) elif isinstance(item, dict): self.attributes.update(item) elif isinstance(item, Element): self.children.append(item) else: self.children.append(str(item)) def __str__(self): if self.attributes: opener = '<{} {}>'.format(self.name, ' '.join('{}="{}"'.format(key, value) for key, value in self.attributes.items())) else: opener = '<{}>'.format(self.name) closer = '</{0}>'.format(self.name) descendants = self.descendants if descendants == 0: return opener[:-1] + '/>' elif descendants == 1: return opener + str(self.children[0]) + closer else: return '{}\n{}\n{}'.format( opener, indent_string('\n'.join( str(child) for child in self.children )), closer ) @property def descendants(self): total = 0 for child in self.children: total += 1 if not isinstance(child, str): total += child.descendants return total class Html(Element): name = 'html' def __str__(self): return '<!DOCTYPE html>\n' + super().__str__() class A(Element): name = 'a' class P(Element): name = 'p' class H1(Element): name = 'h1' class H2(Element): name = 'h2' class H3(Element): name = 'h3' class H4(Element): name = 'h4' class H5(Element): name = 'h5' class H6(Element): name = 'h6' class Br(Element): name = 'br' class Tr(Element): name = 'tr' class Th(Element): name = 'th' class Td(Element): name = 'td' class Table(Element): name = 'table' class Head(Element): name = 'head' class Body(Element): name = 'body' class Div(Element): name = 'div' class Span(Element): name = 'span' class Meta(Element): name = 'meta' class Title(Element): name = 'title' class Link(Element): name = 'link' class Script(Element): name = 'script' def indent_string(s, level=1): indent = ' '*level return indent + s.replace('\n', '\n' + indent)
class Element: __slots__ = ('attributes', 'children') name = 'element' def __init__(self, *args, **kwargs): self.attributes = {k.replace('_', '-'): v for (k, v) in kwargs.items()} self.children = [] for item in args: if type(item) in (list, tuple): self.children.extend(item) elif isinstance(item, dict): self.attributes.update(item) elif isinstance(item, Element): self.children.append(item) else: self.children.append(str(item)) def __str__(self): if self.attributes: opener = '<{} {}>'.format(self.name, ' '.join(('{}="{}"'.format(key, value) for (key, value) in self.attributes.items()))) else: opener = '<{}>'.format(self.name) closer = '</{0}>'.format(self.name) descendants = self.descendants if descendants == 0: return opener[:-1] + '/>' elif descendants == 1: return opener + str(self.children[0]) + closer else: return '{}\n{}\n{}'.format(opener, indent_string('\n'.join((str(child) for child in self.children))), closer) @property def descendants(self): total = 0 for child in self.children: total += 1 if not isinstance(child, str): total += child.descendants return total class Html(Element): name = 'html' def __str__(self): return '<!DOCTYPE html>\n' + super().__str__() class A(Element): name = 'a' class P(Element): name = 'p' class H1(Element): name = 'h1' class H2(Element): name = 'h2' class H3(Element): name = 'h3' class H4(Element): name = 'h4' class H5(Element): name = 'h5' class H6(Element): name = 'h6' class Br(Element): name = 'br' class Tr(Element): name = 'tr' class Th(Element): name = 'th' class Td(Element): name = 'td' class Table(Element): name = 'table' class Head(Element): name = 'head' class Body(Element): name = 'body' class Div(Element): name = 'div' class Span(Element): name = 'span' class Meta(Element): name = 'meta' class Title(Element): name = 'title' class Link(Element): name = 'link' class Script(Element): name = 'script' def indent_string(s, level=1): indent = ' ' * level return indent + s.replace('\n', '\n' + indent)
#!/usr/bin/env python # -*- coding: utf-8 -*- ## Copyright Zeta Co., Ltd. ## written by @moeseth based on research by @aye_hnin_khine class MatchedWord(): def __init__(self, word, start): self.word = word self.start = start
class Matchedword: def __init__(self, word, start): self.word = word self.start = start
NPep = int(input()) NLKgH = [] LKgH = [] rank = [] for each in range(NPep): KgH = list(input("The format should be: mass, height ").split(" ")) LKgH.append(KgH[0]) LKgH.append(KgH[1]) NLKgH.append(LKgH) LKgH = [] for each in range(1, len(LKgH)): rank.append(each) for each in range(1, len(rank)-1): if NLKgH[each][0] > NLKgH[each-1][0] and NLKgH[each][1] < NLKgH[each-1][1]: rank[each] = rank[each-1] elif NLKgH[each][0] < NLKgH[each-1][0] and NLKgH[each][1] > NLKgH[each-1][1]: rank[each] = rank[each-1] elif NLKgH[each][0] > NLKgH[each-1][0] and NLKgH[each][1] > NLKgH[each-1][1]: pass for i in rank: print(i)
n_pep = int(input()) nl_kg_h = [] l_kg_h = [] rank = [] for each in range(NPep): kg_h = list(input('The format should be: mass, height ').split(' ')) LKgH.append(KgH[0]) LKgH.append(KgH[1]) NLKgH.append(LKgH) l_kg_h = [] for each in range(1, len(LKgH)): rank.append(each) for each in range(1, len(rank) - 1): if NLKgH[each][0] > NLKgH[each - 1][0] and NLKgH[each][1] < NLKgH[each - 1][1]: rank[each] = rank[each - 1] elif NLKgH[each][0] < NLKgH[each - 1][0] and NLKgH[each][1] > NLKgH[each - 1][1]: rank[each] = rank[each - 1] elif NLKgH[each][0] > NLKgH[each - 1][0] and NLKgH[each][1] > NLKgH[each - 1][1]: pass for i in rank: print(i)
def lower_bound(nums, target): l, r = 0, len(nums) while l < r: mid = (l + r) // 2 if nums[mid] < target: l = mid + 1 else: r = mid return l class Solution: def findMissingRanges(self, nums: List[int], lower: int, upper: int) -> List[str]: l, r = lower_bound(nums, lower), lower_bound(nums, upper) # print(l, r) if lower == upper: if l == len(nums) or (l < len(nums) and nums[l] != lower): return [str(lower)] else: return [] if lower > upper: return [] if r == 0: if len(nums) > 0 and nums[0] == upper: upper -= 1 if lower == upper: return [str(lower)] return ['{}->{}'.format(lower, upper)] if l == len(nums): return ['{}->{}'.format(lower, upper)] ret = [] if nums[l] > lower: _upnum = nums[l] - 1 if lower == _upnum: ret.append(str(lower)) else: ret.append('{}->{}'.format(lower, _upnum)) while l + 1 < r: _lower = nums[l] + 1 _upper = nums[l + 1] - 1 if _lower < _upper: ret.append('{}->{}'.format(_lower, _upper)) elif _lower == _upper: ret.append(str(_lower)) l += 1 if r < len(nums) and upper == nums[r]: upper -= 1 _lower = nums[l] + 1 _upper = upper if _lower < _upper: ret.append('{}->{}'.format(_lower, _upper)) elif _lower == _upper: ret.append(str(_lower)) return ret
def lower_bound(nums, target): (l, r) = (0, len(nums)) while l < r: mid = (l + r) // 2 if nums[mid] < target: l = mid + 1 else: r = mid return l class Solution: def find_missing_ranges(self, nums: List[int], lower: int, upper: int) -> List[str]: (l, r) = (lower_bound(nums, lower), lower_bound(nums, upper)) if lower == upper: if l == len(nums) or (l < len(nums) and nums[l] != lower): return [str(lower)] else: return [] if lower > upper: return [] if r == 0: if len(nums) > 0 and nums[0] == upper: upper -= 1 if lower == upper: return [str(lower)] return ['{}->{}'.format(lower, upper)] if l == len(nums): return ['{}->{}'.format(lower, upper)] ret = [] if nums[l] > lower: _upnum = nums[l] - 1 if lower == _upnum: ret.append(str(lower)) else: ret.append('{}->{}'.format(lower, _upnum)) while l + 1 < r: _lower = nums[l] + 1 _upper = nums[l + 1] - 1 if _lower < _upper: ret.append('{}->{}'.format(_lower, _upper)) elif _lower == _upper: ret.append(str(_lower)) l += 1 if r < len(nums) and upper == nums[r]: upper -= 1 _lower = nums[l] + 1 _upper = upper if _lower < _upper: ret.append('{}->{}'.format(_lower, _upper)) elif _lower == _upper: ret.append(str(_lower)) return ret
number = int(input("Number? ")) factorial = 1 while number > 0: factorial += factorial * (number - 1) number -= 1 print("Factorial: " + str(factorial))
number = int(input('Number? ')) factorial = 1 while number > 0: factorial += factorial * (number - 1) number -= 1 print('Factorial: ' + str(factorial))
## Multiply ## 8 kyu ## https://www.codewars.com//kata/50654ddff44f800200000004 def multiply(a, b): return a * b
def multiply(a, b): return a * b
def get_value_from_node_by_name(node, value_name): tmp_value_name = value_name if value_name == 'Color' and node.type == 'BSDF_PRINCIPLED': tmp_value_name = "Base Color" if tmp_value_name in node.inputs.keys(): if node.inputs[tmp_value_name].type == 'RGBA': r, g, b, a = node.inputs[tmp_value_name].default_value return [r, g, b, a] else: return node.inputs[value_name].default_value
def get_value_from_node_by_name(node, value_name): tmp_value_name = value_name if value_name == 'Color' and node.type == 'BSDF_PRINCIPLED': tmp_value_name = 'Base Color' if tmp_value_name in node.inputs.keys(): if node.inputs[tmp_value_name].type == 'RGBA': (r, g, b, a) = node.inputs[tmp_value_name].default_value return [r, g, b, a] else: return node.inputs[value_name].default_value
class ExamRoom: def __init__(self, n: int): self.occupied = [] self.n = n def seat(self) -> int: if not self.occupied: self.occupied.append(0) return 0 left, right = -self.occupied[0], self.occupied[0] maximum = (right - left) // 2 for start, end in zip(self.occupied, self.occupied[1:] + [2* self.n - 2 - self.occupied[-1]]): if (end - start) // 2 > maximum: left, right = start, end maximum = (right - left) //2 bisect.insort(self.occupied, left + maximum) return left + maximum def leave(self, p: int) -> None: self.occupied.remove(p) # Your ExamRoom object will be instantiated and called as such: # obj = ExamRoom(n) # param_1 = obj.seat() # obj.leave(p)
class Examroom: def __init__(self, n: int): self.occupied = [] self.n = n def seat(self) -> int: if not self.occupied: self.occupied.append(0) return 0 (left, right) = (-self.occupied[0], self.occupied[0]) maximum = (right - left) // 2 for (start, end) in zip(self.occupied, self.occupied[1:] + [2 * self.n - 2 - self.occupied[-1]]): if (end - start) // 2 > maximum: (left, right) = (start, end) maximum = (right - left) // 2 bisect.insort(self.occupied, left + maximum) return left + maximum def leave(self, p: int) -> None: self.occupied.remove(p)
DATA_DIR = './data/' SAVE_DIR = './pts/' DATA_FPATH = 'ml-100k/u.data' DATA_COLS = ['user_id', 'item_id', 'rating', 'timestamp'] POS_THRESH = 3.5 TRAIN_PATH = DATA_DIR + 'train.dat' VALID_PATH = DATA_DIR + 'valid.txt'
data_dir = './data/' save_dir = './pts/' data_fpath = 'ml-100k/u.data' data_cols = ['user_id', 'item_id', 'rating', 'timestamp'] pos_thresh = 3.5 train_path = DATA_DIR + 'train.dat' valid_path = DATA_DIR + 'valid.txt'
class Solution: def minSubArrayLen(self, s: int, nums: list) -> int: # Time Complexity: O(n) # Space Complexity: O(1) # TODO Binary Search O(nlog(n)) if not nums or sum(nums) < s: return 0 min_len = len(nums) current_sum = 0 left = 0 for right in range(len(nums)): current_sum += nums[right] while current_sum >= s: min_len = min(min_len, right - left + 1) current_sum -= nums[left] left += 1 return min_len s = 7; nums = [2,3,1,2,4,3] s = 3; nums = [1,1] sol = Solution() print(sol.minSubArrayLen(s, nums))
class Solution: def min_sub_array_len(self, s: int, nums: list) -> int: if not nums or sum(nums) < s: return 0 min_len = len(nums) current_sum = 0 left = 0 for right in range(len(nums)): current_sum += nums[right] while current_sum >= s: min_len = min(min_len, right - left + 1) current_sum -= nums[left] left += 1 return min_len s = 7 nums = [2, 3, 1, 2, 4, 3] s = 3 nums = [1, 1] sol = solution() print(sol.minSubArrayLen(s, nums))
# Adding an if statement so that the print statements aren't so wrong! # This was not part of the exercise animals = ['Dog', 'Cat', 'Dolphin', 'Wolf', 'Polar bear', 'Penguin'] for animal in animals: if animal == 'Dog' or animal == 'Cat': print(f"A {animal.lower()} would make a great pet!") else: print(f"A {animal.lower()} would NOT make a great pet.") print("You should be careful about what sort of animal you pick as a pet!")
animals = ['Dog', 'Cat', 'Dolphin', 'Wolf', 'Polar bear', 'Penguin'] for animal in animals: if animal == 'Dog' or animal == 'Cat': print(f'A {animal.lower()} would make a great pet!') else: print(f'A {animal.lower()} would NOT make a great pet.') print('You should be careful about what sort of animal you pick as a pet!')
# Fibonacci series class FibonacciSeriesDemo: Instances = 0 def __init__(self): FibonacciSeriesDemo.Instances += 1 def displayFibonacci(self, title, value): first, second = 0, 1 print(f"----- {title}till {value} -----") print(f'FibonacciSeriesDemo.Instances: {self.Instances}') while first < value: print(first) # print(f'----- {first} {second} -----') first, second = second, first+second title = "Fibonacci Series Demo" fibonacci = FibonacciSeriesDemo() fibonacci.displayFibonacci(title, 10) fibonacci.displayFibonacci(title, 20) # first, second = 0, 1 # while first < 10: # print(first) # print(f'----- {first} {second} -----') # first, second = second, first+second
class Fibonacciseriesdemo: instances = 0 def __init__(self): FibonacciSeriesDemo.Instances += 1 def display_fibonacci(self, title, value): (first, second) = (0, 1) print(f'----- {title}till {value} -----') print(f'FibonacciSeriesDemo.Instances: {self.Instances}') while first < value: print(first) (first, second) = (second, first + second) title = 'Fibonacci Series Demo' fibonacci = fibonacci_series_demo() fibonacci.displayFibonacci(title, 10) fibonacci.displayFibonacci(title, 20)
# ---------------------------------------------------------------------------- # CLASSES: nightly # # Test Case: lines.py # # Tests: mesh - 2D lines (unstructured), 3D lines (unstructured) # plots - mesh # # Programmer: Alister Maguire # Date: Tue Mar 17 08:50:32 PDT 2020 # # Modifications: # # Mark C. Miller, Mon Jan 11 10:32:17 PST 2021 # Replace AssertEqual() with TestValueEQ() # ---------------------------------------------------------------------------- def TestMeshPlot(): # # First, let's make sure that 3d lines are read appropriately. # v = GetView3D() v.viewNormal = (0.9, 0.35, -0.88) SetView3D(v) OpenDatabase(data_path("lines_test_data/spring.lines")) AddPlot("Mesh", "Lines", 1, 1) DrawPlots() Query("SpatialExtents") # Check dimensionality. ext_len = len(GetQueryOutputValue()) TestValueEQ("Verifying 3D lines", ext_len, 6) # Check the rendering. Test("mesh_plot_00") DeleteAllPlots() CloseDatabase(data_path("lines_test_data/spring.lines")) # # Next, let's check 2d lines. # OpenDatabase(data_path("lines_test_data/2d.lines")) AddPlot("Mesh", "Lines", 1, 1) DrawPlots() Query("SpatialExtents") # Check dimensionality. ext_len = len(GetQueryOutputValue()) TestValueEQ("Verifying 2D lines", ext_len, 4) # Check the rendering. Test("mesh_plot_01") DeleteAllPlots() CloseDatabase(data_path("lines_test_data/2d.lines")) # # This test makes sure that consecutive points are only # removed from one line at a time. # OpenDatabase(data_path("lines_test_data/consecutive.lines")) AddPlot("Mesh", "Lines", 1, 1) DrawPlots() # Check the rendering. Test("mesh_plot_02") DeleteAllPlots() CloseDatabase(data_path("lines_test_data/consecutive.lines")) def main(): TestMeshPlot() Exit() main()
def test_mesh_plot(): v = get_view3_d() v.viewNormal = (0.9, 0.35, -0.88) set_view3_d(v) open_database(data_path('lines_test_data/spring.lines')) add_plot('Mesh', 'Lines', 1, 1) draw_plots() query('SpatialExtents') ext_len = len(get_query_output_value()) test_value_eq('Verifying 3D lines', ext_len, 6) test('mesh_plot_00') delete_all_plots() close_database(data_path('lines_test_data/spring.lines')) open_database(data_path('lines_test_data/2d.lines')) add_plot('Mesh', 'Lines', 1, 1) draw_plots() query('SpatialExtents') ext_len = len(get_query_output_value()) test_value_eq('Verifying 2D lines', ext_len, 4) test('mesh_plot_01') delete_all_plots() close_database(data_path('lines_test_data/2d.lines')) open_database(data_path('lines_test_data/consecutive.lines')) add_plot('Mesh', 'Lines', 1, 1) draw_plots() test('mesh_plot_02') delete_all_plots() close_database(data_path('lines_test_data/consecutive.lines')) def main(): test_mesh_plot() exit() main()
# author : @akash n=int(input()) a=[] for i in range(n): s=str(input()) a.append(s) b=sorted(a) #print(b) for i in range(n-1): aa=b[i] bb=b[i+1] nn=len(aa) mm=len(bb) if(mm>nn and aa==bb[:nn]): t=b[i] b[i]=b[i+1] b[i+1]=t for i in b: print(i)
n = int(input()) a = [] for i in range(n): s = str(input()) a.append(s) b = sorted(a) for i in range(n - 1): aa = b[i] bb = b[i + 1] nn = len(aa) mm = len(bb) if mm > nn and aa == bb[:nn]: t = b[i] b[i] = b[i + 1] b[i + 1] = t for i in b: print(i)
# https://adventofcode.com/2021/day/8 # load file infile = open('08/input.txt', 'r') lines = infile.readlines() infile.close() # parse input answer = 0 unique_number_of_segments_lengths = [2, 4, 3, 7] for line in lines: line = line.strip() print("line: {}".format(line)) line_parts = line.split(' | ') unique_signal_patterns = line_parts[0].split(' ') four_digit_output_value = line_parts[1].split(' ') for value in four_digit_output_value: output_value_length = len(value) if output_value_length in unique_number_of_segments_lengths: answer += 1 print(answer) # 365 print("OK")
infile = open('08/input.txt', 'r') lines = infile.readlines() infile.close() answer = 0 unique_number_of_segments_lengths = [2, 4, 3, 7] for line in lines: line = line.strip() print('line: {}'.format(line)) line_parts = line.split(' | ') unique_signal_patterns = line_parts[0].split(' ') four_digit_output_value = line_parts[1].split(' ') for value in four_digit_output_value: output_value_length = len(value) if output_value_length in unique_number_of_segments_lengths: answer += 1 print(answer) print('OK')
a=int(input()) b=int(input()) sum=a+b dif=a-b mul=a*b if b==0: print('Error') return div=a//b Exp=a**b print('sum of a and b is:',sum) print('dif of a and b is:',dif) print('mul of a and b is:',mul) print('div of a and b is:',div) print('Exp of a and b is:',Exp)
a = int(input()) b = int(input()) sum = a + b dif = a - b mul = a * b if b == 0: print('Error') return div = a // b exp = a ** b print('sum of a and b is:', sum) print('dif of a and b is:', dif) print('mul of a and b is:', mul) print('div of a and b is:', div) print('Exp of a and b is:', Exp)
#! /usr/bin/env python3 with open('../inputs/input14.txt') as fp: lines = [line.strip() for line in fp.readlines()] polymer, rules = lines[0], lines[2:] # build mappings chr_mappings = {} # character mappings: NN -> H ins_mappings = {} # insertion mappings: NN -> [NH, HN] for rule in rules: [key, val] = rule.split(' -> ') chr_mappings[key] = val ins_mappings[key] = [key[0]+val, val+key[1]] # track individual char counts char_counts = {} for i in range(len(polymer)): char = polymer[i] if not char in char_counts: char_counts[char] = 1 else: char_counts[char] += 1 # track char-pair counts pair_counts = {} for i in range(len(polymer) - 1): pair = polymer[i:i+2] if not pair in pair_counts: pair_counts[pair] = 1 else: pair_counts[pair] += 1 # Iterate one round of insertions, producing new pair_counts & updating char_counts in place def insertion_step(pair_counts): new_pair_counts = pair_counts.copy() for (k1, v1) in pair_counts.items(): # lose all of 1 broken-up pair new_pair_counts[k1] -= v1 # gain 2 new pairs (v1 times) for k2 in ins_mappings[k1]: if not k2 in new_pair_counts: new_pair_counts[k2] = v1 else: new_pair_counts[k2] += v1 # count inserted char (v1 times) char = chr_mappings[k1] if not char in char_counts: char_counts[char] = v1 else: char_counts[char] += v1 return new_pair_counts # Calculate (most frequent minus least frequent) in freqs dict def calc_freq_diff(freqs): freq_vals_order = sorted([v for (k,v) in freqs.items()]) return freq_vals_order[-1] - freq_vals_order[0] # part 1 for n in range(10): pair_counts = insertion_step(pair_counts) print("Part 1:", calc_freq_diff(char_counts)) # 4244 # part 2 for n in range(30): pair_counts = insertion_step(pair_counts) print("Part 2:", calc_freq_diff(char_counts)) # 4807056953866
with open('../inputs/input14.txt') as fp: lines = [line.strip() for line in fp.readlines()] (polymer, rules) = (lines[0], lines[2:]) chr_mappings = {} ins_mappings = {} for rule in rules: [key, val] = rule.split(' -> ') chr_mappings[key] = val ins_mappings[key] = [key[0] + val, val + key[1]] char_counts = {} for i in range(len(polymer)): char = polymer[i] if not char in char_counts: char_counts[char] = 1 else: char_counts[char] += 1 pair_counts = {} for i in range(len(polymer) - 1): pair = polymer[i:i + 2] if not pair in pair_counts: pair_counts[pair] = 1 else: pair_counts[pair] += 1 def insertion_step(pair_counts): new_pair_counts = pair_counts.copy() for (k1, v1) in pair_counts.items(): new_pair_counts[k1] -= v1 for k2 in ins_mappings[k1]: if not k2 in new_pair_counts: new_pair_counts[k2] = v1 else: new_pair_counts[k2] += v1 char = chr_mappings[k1] if not char in char_counts: char_counts[char] = v1 else: char_counts[char] += v1 return new_pair_counts def calc_freq_diff(freqs): freq_vals_order = sorted([v for (k, v) in freqs.items()]) return freq_vals_order[-1] - freq_vals_order[0] for n in range(10): pair_counts = insertion_step(pair_counts) print('Part 1:', calc_freq_diff(char_counts)) for n in range(30): pair_counts = insertion_step(pair_counts) print('Part 2:', calc_freq_diff(char_counts))
def inverno(): dias = list(map(int, input().split())) dia1 = dias[0] dia2 = dias[1] dia3 = dias[2] # 1 - ok if dia1 > dia2 and (dia2 < dia3 or dia2 == dia3): print(':)') # 2 - ok elif dia1 < dia2 and (dia2 > dia3 or dia2 == dia3): print(':(') # 3 - ok elif dia1 < dia2 < dia3 and (dia3-dia2) < (dia2-dia1): print(':(') # 4 - ok elif dia1 < dia2 < dia3 and (dia3-dia2) >= (dia2-dia1): print(':)') # 5 - ok elif dia1 > dia2 > dia3 and (dia1-dia2) > (dia2-dia3): print(':)') # 6 - ok elif dia1 > dia2 > dia3 and (dia2-dia3) >= (dia2-dia1): print(':(') # 7 - ok elif dia1 == dia2: if dia2 < dia3: print(':)') else: print(':(') inverno()
def inverno(): dias = list(map(int, input().split())) dia1 = dias[0] dia2 = dias[1] dia3 = dias[2] if dia1 > dia2 and (dia2 < dia3 or dia2 == dia3): print(':)') elif dia1 < dia2 and (dia2 > dia3 or dia2 == dia3): print(':(') elif dia1 < dia2 < dia3 and dia3 - dia2 < dia2 - dia1: print(':(') elif dia1 < dia2 < dia3 and dia3 - dia2 >= dia2 - dia1: print(':)') elif dia1 > dia2 > dia3 and dia1 - dia2 > dia2 - dia3: print(':)') elif dia1 > dia2 > dia3 and dia2 - dia3 >= dia2 - dia1: print(':(') elif dia1 == dia2: if dia2 < dia3: print(':)') else: print(':(') inverno()
RED = '\033[1;91m' GREEN = '\033[1;92m' YELLOW = '\033[1;93m' BLUE = '\033[1;94m' BROWN = '\033[1;95m' CYAN = '\033[1;96m' WHITE = '\033[1;97m' COL_END = '\033[0m'
red = '\x1b[1;91m' green = '\x1b[1;92m' yellow = '\x1b[1;93m' blue = '\x1b[1;94m' brown = '\x1b[1;95m' cyan = '\x1b[1;96m' white = '\x1b[1;97m' col_end = '\x1b[0m'
''' 6 kyu Your order, please https://www.codewars.com/kata/55c45be3b2079eccff00010f/train/python Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers. Examples "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est" "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople" ''' def order(sentence): return ' '.join([i[1] for i in sorted(zip(filter(str.isdigit, sentence), sentence.split()))])
""" 6 kyu Your order, please https://www.codewars.com/kata/55c45be3b2079eccff00010f/train/python Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers. Examples "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est" "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople" """ def order(sentence): return ' '.join([i[1] for i in sorted(zip(filter(str.isdigit, sentence), sentence.split()))])
def armstrong(num): for x in range(1, num): if x>10: order = len(str(x)) sum = 0 temp = x while temp > 0: digit = temp % 10 sum += digit**order temp //= 10 if x == sum: yield print("T he First Armstrong Nubmer is : ", x) lst=list(armstrong(1000))
def armstrong(num): for x in range(1, num): if x > 10: order = len(str(x)) sum = 0 temp = x while temp > 0: digit = temp % 10 sum += digit ** order temp //= 10 if x == sum: yield print('T he First Armstrong Nubmer is : ', x) lst = list(armstrong(1000))
'''PROGRAM TO CALCULATE WHEN THE USER WILL TURN 100 YEARS OLD''' #Current Year Year = 2020 #Input for name and age Name = input('\nWhat is your name?: ') Age = int(input('How old are you?: ')) #Calculating year of birth YOB = Year-Age #Displaying the output print('\n'+Name,'will be 100 years in the year',YOB + 100,"\n")
"""PROGRAM TO CALCULATE WHEN THE USER WILL TURN 100 YEARS OLD""" year = 2020 name = input('\nWhat is your name?: ') age = int(input('How old are you?: ')) yob = Year - Age print('\n' + Name, 'will be 100 years in the year', YOB + 100, '\n')
''' Config file for CNN model ''' # -- CHANGE PATHS --# # Jamendo JAMENDO_DIR = '../jamendo/' # path to jamendo dataset MEL_JAMENDO_DIR = '../data/schluter_mel_dir/' # path to save computed melgrams of jamendo JAMENDO_LABEL_DIR = '../data/labels/' # path to jamendo dataset label # MedleyDB MDB_VOC_DIR = '/media/bach1/dataset/MedleyDB/' # path to medleyDB vocal containing songs MDB_LABEL_DIR = '../mdb_voc_label/' # vibrato SAW_DIR = '../sawtooth_200/songs/' MEL_SAW_DIR = '../sawtooth_200/schluter_mel_dir/' # -- Audio processing parameters --# SR = 22050 FRAME_LEN = 1024 HOP_LENGTH = 315 CNN_INPUT_SIZE = 115 # 1.6 sec CNN_OVERLAP = 5 # Hopsize of 5 for training, 1 for inference N_MELS = 80 CUTOFF = 8000 # fmax = 8kHz
""" Config file for CNN model """ jamendo_dir = '../jamendo/' mel_jamendo_dir = '../data/schluter_mel_dir/' jamendo_label_dir = '../data/labels/' mdb_voc_dir = '/media/bach1/dataset/MedleyDB/' mdb_label_dir = '../mdb_voc_label/' saw_dir = '../sawtooth_200/songs/' mel_saw_dir = '../sawtooth_200/schluter_mel_dir/' sr = 22050 frame_len = 1024 hop_length = 315 cnn_input_size = 115 cnn_overlap = 5 n_mels = 80 cutoff = 8000
''' Created on Jul 1, 2015 @author: egodolja ''' ''' import unittest from mock import MagicMock from authorizenet import apicontractsv1 #from controller.ARBCancelSubscriptionController import ARBCancelSubscriptionController from tests import apitestbase from authorizenet.apicontrollers import * import test ''' ''' class ARBCancelSubscriptionControllerTest(apitestbase.ApiTestBase): def test_ARBCancelSubscriptionController(self): cancelSubscriptionRequest = apicontractsv1.ARBCancelSubscriptionRequest() cancelSubscriptionRequest.merchantAuthentication = self.merchantAuthentication cancelSubscriptionRequest.refId = 'Sample' cancelSubscriptionRequest.subscriptionId = '2680891' ctrl = ARBCancelSubscriptionController() ctrl.execute = MagicMock(return_value=None) ctrl.execute(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse) ctrl.execute.assert_called_with(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse) ctrl.execute.assert_any_call(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse) ''' ''' class ARBCreateSubscriptionTest(apitestbase.ApiTestBase): def testCreateSubscriptionController(self): createSubscriptionRequest = apicontractsv1.ARBCreateSubscriptionRequest() createSubscriptionRequest.merchantAuthentication = self.merchantAuthentication createSubscriptionRequest.refId = 'Sample' createSubscriptionRequest.subscription = self.subscriptionOne ctrl = ARBCreateSubscriptionController() ctrl.execute = MagicMock(return_value=None) createRequest = ctrl.ARBCreateSubscriptionController(createSubscriptionRequest) ctrl.execute(createRequest, apicontractsv1.ARBCreateSubscriptionResponse) ctrl.execute.assert_called_with(createRequest, apicontractsv1.ARBCreateSubscriptionResponse ) ctrl.execute.assert_any_call(createRequest, apicontractsv1.ARBCreateSubscriptionResponse) class ARBGetSubscriptionStatusTest(object): def testGetSubscriptionStatusController(self): getSubscriptionStatusRequest = apicontractsv1.ARBGetSubscriptionStatusRequest() getSubscriptionStatusRequest.merchantAuthentication = self.merchantAuthentication getSubscriptionStatusRequest.refId = 'Sample' getSubscriptionStatusRequest.subscriptionId = '2680891' ctrl = ARBGetSubscriptionStatusController() ctrl.execute = MagicMock(return_value=None) statusRequest = ctrl.ARBGetSubscriptionStatusController(getSubscriptionStatusRequest) ctrl.execute(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse) ctrl.execute.assert_called_with(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse) ctrl.execute.assert_any_call(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse) '''
""" Created on Jul 1, 2015 @author: egodolja """ '\nimport unittest\n\nfrom mock import MagicMock\nfrom authorizenet import apicontractsv1\n#from controller.ARBCancelSubscriptionController import ARBCancelSubscriptionController\nfrom tests import apitestbase\nfrom authorizenet.apicontrollers import *\nimport test\n' "\nclass ARBCancelSubscriptionControllerTest(apitestbase.ApiTestBase):\n\n def test_ARBCancelSubscriptionController(self):\n cancelSubscriptionRequest = apicontractsv1.ARBCancelSubscriptionRequest()\n cancelSubscriptionRequest.merchantAuthentication = self.merchantAuthentication\n cancelSubscriptionRequest.refId = 'Sample'\n cancelSubscriptionRequest.subscriptionId = '2680891'\n \n ctrl = ARBCancelSubscriptionController()\n\n ctrl.execute = MagicMock(return_value=None)\n\n ctrl.execute(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse)\n \n ctrl.execute.assert_called_with(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse)\n ctrl.execute.assert_any_call(cancelSubscriptionRequest, apicontractsv1.ARBCancelSubscriptionResponse)\n\n" " \nclass ARBCreateSubscriptionTest(apitestbase.ApiTestBase):\n\n def testCreateSubscriptionController(self):\n createSubscriptionRequest = apicontractsv1.ARBCreateSubscriptionRequest()\n createSubscriptionRequest.merchantAuthentication = self.merchantAuthentication\n createSubscriptionRequest.refId = 'Sample'\n createSubscriptionRequest.subscription = self.subscriptionOne\n \n ctrl = ARBCreateSubscriptionController()\n \n ctrl.execute = MagicMock(return_value=None)\n \n createRequest = ctrl.ARBCreateSubscriptionController(createSubscriptionRequest)\n ctrl.execute(createRequest, apicontractsv1.ARBCreateSubscriptionResponse)\n \n ctrl.execute.assert_called_with(createRequest, apicontractsv1.ARBCreateSubscriptionResponse )\n ctrl.execute.assert_any_call(createRequest, apicontractsv1.ARBCreateSubscriptionResponse)\n\nclass ARBGetSubscriptionStatusTest(object):\n \n \n def testGetSubscriptionStatusController(self):\n getSubscriptionStatusRequest = apicontractsv1.ARBGetSubscriptionStatusRequest()\n getSubscriptionStatusRequest.merchantAuthentication = self.merchantAuthentication\n getSubscriptionStatusRequest.refId = 'Sample'\n getSubscriptionStatusRequest.subscriptionId = '2680891'\n \n ctrl = ARBGetSubscriptionStatusController()\n \n ctrl.execute = MagicMock(return_value=None)\n \n statusRequest = ctrl.ARBGetSubscriptionStatusController(getSubscriptionStatusRequest)\n ctrl.execute(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse)\n \n ctrl.execute.assert_called_with(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse)\n ctrl.execute.assert_any_call(statusRequest, apicontractsv1.ARBGetSubscriptionStatusResponse) \n"
def translate(**kwargs): for key, value in kwargs.items(): print(key, ":", value) words = {"mother": "madre", "father": "padre", "grandmother": "abuela", "grandfather": "abuelo"} translate(**words)
def translate(**kwargs): for (key, value) in kwargs.items(): print(key, ':', value) words = {'mother': 'madre', 'father': 'padre', 'grandmother': 'abuela', 'grandfather': 'abuelo'} translate(**words)
# O(n) time | O(1) space class Solution: def minCostToMoveChips(self, position: List[int]) -> int: oddCount = 0 evenCount = 0 for p in position: if p & 1: oddCount += 1 else: evenCount += 1 return min(oddCount, evenCount)
class Solution: def min_cost_to_move_chips(self, position: List[int]) -> int: odd_count = 0 even_count = 0 for p in position: if p & 1: odd_count += 1 else: even_count += 1 return min(oddCount, evenCount)
class GroupHelper: def __init__(self, app): self.app = app def return_to_groups_page(self): wd = self.app.wd wd.find_element_by_link_text("group page").click() def go_to_home(self): wd = self.app.wd wd.find_element_by_link_text("home page").click() def create(self, group): wd = self.app.wd self.open_groups_page() # init group creation wd.find_element_by_name("new").click() # fill form wd.find_element_by_name("group_name").click() wd.find_element_by_name("group_name").clear() wd.find_element_by_name("group_name").send_keys(group.name) wd.find_element_by_name("group_header").click() wd.find_element_by_name("group_header").clear() wd.find_element_by_name("group_header").send_keys(group.header) wd.find_element_by_name("group_footer").click() wd.find_element_by_name("group_footer").clear() wd.find_element_by_name("group_footer").send_keys(group.footer) # submit group creation wd.find_element_by_xpath("//div[@id='content']/form").click() wd.find_element_by_name("submit").click() self.return_to_groups_page() def add_osoba(self, person): wd = self.app.wd wd.find_element_by_link_text("nowy wpis").click() # add_1st_name wd.find_element_by_name("firstname").click() wd.find_element_by_name("firstname").clear() wd.find_element_by_name("firstname").send_keys(person.first_name) # add_middle_name wd.find_element_by_name("middlename").click() wd.find_element_by_name("middlename").clear() wd.find_element_by_name("middlename").send_keys(person.middle) # add_2nd_name wd.find_element_by_name("lastname").click() wd.find_element_by_name("lastname").clear() wd.find_element_by_name("lastname").send_keys(person.last) # add_nick wd.find_element_by_name("nickname").click() wd.find_element_by_name("nickname").clear() wd.find_element_by_name("nickname").send_keys(person.nick) # add_title wd.find_element_by_name("title").click() wd.find_element_by_name("title").clear() wd.find_element_by_name("title").send_keys(person.title) # add_company wd.find_element_by_name("company").click() wd.find_element_by_name("company").clear() wd.find_element_by_name("company").send_keys(person.company) # add_company_address wd.find_element_by_name("address").click() wd.find_element_by_name("address").clear() wd.find_element_by_name("address").send_keys(person.comaddr) # add_private_tel wd.find_element_by_name("home").click() wd.find_element_by_name("home").clear() wd.find_element_by_name("home").send_keys(person.homenr) # add_mobile wd.find_element_by_name("mobile").click() wd.find_element_by_name("mobile").clear() wd.find_element_by_name("mobile").send_keys(person.mobile) # add_work_tel wd.find_element_by_name("work").click() wd.find_element_by_name("work").clear() wd.find_element_by_name("work").send_keys(person.worknr) # add_fax_no wd.find_element_by_name("fax").click() wd.find_element_by_name("fax").clear() wd.find_element_by_name("fax").send_keys(person.faxnr) # add_email1 wd.find_element_by_name("email").click() wd.find_element_by_name("email").clear() wd.find_element_by_name("email").send_keys(person.email_1) # add_email2 wd.find_element_by_name("email2").click() wd.find_element_by_name("email2").clear() wd.find_element_by_name("email2").send_keys(person.email_2) # add_email3 wd.find_element_by_name("email3").click() wd.find_element_by_name("email3").clear() wd.find_element_by_name("email3").send_keys(person.email_3) # add_homepage wd.find_element_by_name("homepage").click() wd.find_element_by_name("homepage").clear() wd.find_element_by_name("homepage").send_keys(person.home_page) # add_birth wd.find_element_by_css_selector("body").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[19]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[19]").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[13]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[13]").click() wd.find_element_by_name("byear").click() wd.find_element_by_name("byear").clear() wd.find_element_by_name("byear").send_keys(person.year_b) # add_anniver= wd.find_element_by_name("theform").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[20]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[20]").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[13]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[13]").click() wd.find_element_by_name("ayear").click() wd.find_element_by_name("ayear").clear() wd.find_element_by_name("ayear").send_keys(person.year_a) wd.find_element_by_name("theform").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[3]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[3]").click() # add_home_add wd.find_element_by_name("address2").click() wd.find_element_by_name("address2").clear() wd.find_element_by_name("address2").send_keys(person.home_add) # add_home_tel wd.find_element_by_name("phone2").click() wd.find_element_by_name("phone2").clear() wd.find_element_by_name("phone2").send_keys(person.home_phone) # add_notes wd.find_element_by_name("notes").click() wd.find_element_by_name("notes").clear() wd.find_element_by_name("notes").send_keys(person.note) # submit_accept wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click() def open_groups_page(self): wd = self.app.wd # open groups page wd.find_element_by_link_text("grupy").click()
class Grouphelper: def __init__(self, app): self.app = app def return_to_groups_page(self): wd = self.app.wd wd.find_element_by_link_text('group page').click() def go_to_home(self): wd = self.app.wd wd.find_element_by_link_text('home page').click() def create(self, group): wd = self.app.wd self.open_groups_page() wd.find_element_by_name('new').click() wd.find_element_by_name('group_name').click() wd.find_element_by_name('group_name').clear() wd.find_element_by_name('group_name').send_keys(group.name) wd.find_element_by_name('group_header').click() wd.find_element_by_name('group_header').clear() wd.find_element_by_name('group_header').send_keys(group.header) wd.find_element_by_name('group_footer').click() wd.find_element_by_name('group_footer').clear() wd.find_element_by_name('group_footer').send_keys(group.footer) wd.find_element_by_xpath("//div[@id='content']/form").click() wd.find_element_by_name('submit').click() self.return_to_groups_page() def add_osoba(self, person): wd = self.app.wd wd.find_element_by_link_text('nowy wpis').click() wd.find_element_by_name('firstname').click() wd.find_element_by_name('firstname').clear() wd.find_element_by_name('firstname').send_keys(person.first_name) wd.find_element_by_name('middlename').click() wd.find_element_by_name('middlename').clear() wd.find_element_by_name('middlename').send_keys(person.middle) wd.find_element_by_name('lastname').click() wd.find_element_by_name('lastname').clear() wd.find_element_by_name('lastname').send_keys(person.last) wd.find_element_by_name('nickname').click() wd.find_element_by_name('nickname').clear() wd.find_element_by_name('nickname').send_keys(person.nick) wd.find_element_by_name('title').click() wd.find_element_by_name('title').clear() wd.find_element_by_name('title').send_keys(person.title) wd.find_element_by_name('company').click() wd.find_element_by_name('company').clear() wd.find_element_by_name('company').send_keys(person.company) wd.find_element_by_name('address').click() wd.find_element_by_name('address').clear() wd.find_element_by_name('address').send_keys(person.comaddr) wd.find_element_by_name('home').click() wd.find_element_by_name('home').clear() wd.find_element_by_name('home').send_keys(person.homenr) wd.find_element_by_name('mobile').click() wd.find_element_by_name('mobile').clear() wd.find_element_by_name('mobile').send_keys(person.mobile) wd.find_element_by_name('work').click() wd.find_element_by_name('work').clear() wd.find_element_by_name('work').send_keys(person.worknr) wd.find_element_by_name('fax').click() wd.find_element_by_name('fax').clear() wd.find_element_by_name('fax').send_keys(person.faxnr) wd.find_element_by_name('email').click() wd.find_element_by_name('email').clear() wd.find_element_by_name('email').send_keys(person.email_1) wd.find_element_by_name('email2').click() wd.find_element_by_name('email2').clear() wd.find_element_by_name('email2').send_keys(person.email_2) wd.find_element_by_name('email3').click() wd.find_element_by_name('email3').clear() wd.find_element_by_name('email3').send_keys(person.email_3) wd.find_element_by_name('homepage').click() wd.find_element_by_name('homepage').clear() wd.find_element_by_name('homepage').send_keys(person.home_page) wd.find_element_by_css_selector('body').click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[19]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[1]//option[19]").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[13]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[2]//option[13]").click() wd.find_element_by_name('byear').click() wd.find_element_by_name('byear').clear() wd.find_element_by_name('byear').send_keys(person.year_b) wd.find_element_by_name('theform').click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[20]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[3]//option[20]").click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[13]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[4]//option[13]").click() wd.find_element_by_name('ayear').click() wd.find_element_by_name('ayear').clear() wd.find_element_by_name('ayear').send_keys(person.year_a) wd.find_element_by_name('theform').click() if not wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[3]").is_selected(): wd.find_element_by_xpath("//div[@id='content']/form/select[5]//option[3]").click() wd.find_element_by_name('address2').click() wd.find_element_by_name('address2').clear() wd.find_element_by_name('address2').send_keys(person.home_add) wd.find_element_by_name('phone2').click() wd.find_element_by_name('phone2').clear() wd.find_element_by_name('phone2').send_keys(person.home_phone) wd.find_element_by_name('notes').click() wd.find_element_by_name('notes').clear() wd.find_element_by_name('notes').send_keys(person.note) wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click() def open_groups_page(self): wd = self.app.wd wd.find_element_by_link_text('grupy').click()
scanners = [] with open('day19/input.txt') as f: lines = f.readlines() for line in lines: line = line.strip() if line == "": continue if line.startswith("---"): scanner = [] scanners.append(scanner) continue scanner.append(list(map(lambda s: int(s), line.split(",")))) def add(p, q): result = p.copy() for i in range(3): result[i] += q[i] return result def sub(p, q): result = p.copy() for i in range(3): result[i] -= q[i] return result def rot(p): x, y, z = p return [ [ x, y, z], [ x, z, y], [ y, x, z], [ y, z, x], [ z, x, y], [ z, y, x], [ x, -y, z], [ x, -z, y], [ y, -x, z], [ y, -z, x], [ z, -x, y], [ z, -y, x], [-x, y, -z], [-x, z, -y], [-y, x, -z], [-y, z, -x], [-z, x, -y], [-z, y, -x], [-x, -y, -z], [-x, -z, -y], [-y, -x, -z], [-y, -z, -x], [-z, -x, -y], [-z, -y, -x] ] def trans(s, r, v): result = [] for p in s: pr = rot(p)[r] result.append(add(pr, v)) return result def count_matches(s1, s2) -> int: n = 0 for p in s1: if p in s2: n += 1 #if n > 1: print(n) return n def match(s1, s2): for p1 in s1: for p2 in s2: p2rotations = rot(p2) for r in range(len(p2rotations)): p2r = p2rotations[r] v = sub(p1, p2r) s2x = trans(s2, r, v) if count_matches(s1, s2x) >= 12: return (r, v) # test # for i in range(len(scanners)-1): # print(i+1, match(scanners[0], scanners[i+1])) beacons = scanners[0].copy() L1 = [0] L2 = list(range(1, len(scanners))) while len(L2) > 0: #for s1 in L1: for s2 in L2: print(s2) # m = match(scanners[s1], scanners[s2]) m = match(beacons, scanners[s2]) if m: print(s2, "*") r, v = m s2x = trans(scanners[s2], r, v) scanners[s2] = s2x for b in s2x: if not b in beacons: beacons.append(b) L1.append(s2) L2.remove(s2) break #if m: break print(len(beacons))
scanners = [] with open('day19/input.txt') as f: lines = f.readlines() for line in lines: line = line.strip() if line == '': continue if line.startswith('---'): scanner = [] scanners.append(scanner) continue scanner.append(list(map(lambda s: int(s), line.split(',')))) def add(p, q): result = p.copy() for i in range(3): result[i] += q[i] return result def sub(p, q): result = p.copy() for i in range(3): result[i] -= q[i] return result def rot(p): (x, y, z) = p return [[x, y, z], [x, z, y], [y, x, z], [y, z, x], [z, x, y], [z, y, x], [x, -y, z], [x, -z, y], [y, -x, z], [y, -z, x], [z, -x, y], [z, -y, x], [-x, y, -z], [-x, z, -y], [-y, x, -z], [-y, z, -x], [-z, x, -y], [-z, y, -x], [-x, -y, -z], [-x, -z, -y], [-y, -x, -z], [-y, -z, -x], [-z, -x, -y], [-z, -y, -x]] def trans(s, r, v): result = [] for p in s: pr = rot(p)[r] result.append(add(pr, v)) return result def count_matches(s1, s2) -> int: n = 0 for p in s1: if p in s2: n += 1 return n def match(s1, s2): for p1 in s1: for p2 in s2: p2rotations = rot(p2) for r in range(len(p2rotations)): p2r = p2rotations[r] v = sub(p1, p2r) s2x = trans(s2, r, v) if count_matches(s1, s2x) >= 12: return (r, v) beacons = scanners[0].copy() l1 = [0] l2 = list(range(1, len(scanners))) while len(L2) > 0: for s2 in L2: print(s2) m = match(beacons, scanners[s2]) if m: print(s2, '*') (r, v) = m s2x = trans(scanners[s2], r, v) scanners[s2] = s2x for b in s2x: if not b in beacons: beacons.append(b) L1.append(s2) L2.remove(s2) break print(len(beacons))
db.session.execute(''' alter table "user" add column created timestamp ''') db.session.execute(''' update "user" set created = '1979-07-07' ''') db.session.execute(''' alter table "user" alter column created set not null ''') db.session.commit()
db.session.execute('\n alter table "user"\n add column created timestamp\n') db.session.execute('\n update "user" set created = \'1979-07-07\'\n') db.session.execute('\n alter table "user" alter column created set not null\n') db.session.commit()
{ "targets": [ { "target_name": "civetkern", "sources": [ "src/lmdb/mdb.c", "src/lmdb/midl.c", "src/util/util.cpp", "src/util/pinyin.cpp", "src/interface.cpp", "src/database.cpp", "src/db_manager.cpp", "src/log.cpp", "src/DBThread.cpp", "src/table/TableTag.cpp", "src/table/TableMeta.cpp", "src/table/TableClass.cpp", "src/RPN.cpp", "src/Condition.cpp", "src/Table.cpp", "src/Expression.cpp", "src/StorageProxy.cpp", "src/upgrader.cpp", "src/civetkern.cpp" ], "include_dirs": [ "include", "src", # "<!(node -e \"require('nan')\")", '<!@(node -p "require(\'node-addon-api\').include")', ], 'cflags_c': [], 'cflags_cc': [ '-std=c++17', '-frtti', '-Wno-pessimizing-move' ], "cflags!": [ '-fno-exceptions' ], "cflags_cc!": [ '-fno-exceptions', '-std=gnu++1y', '-std=gnu++0x' ], 'xcode_settings': { 'CLANG_CXX_LANGUAGE_STANDARD': 'c++17', 'MACOSX_DEPLOYMENT_TARGET': '10.9', 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'GCC_ENABLE_CPP_RTTI': 'YES', 'OTHER_CPLUSPLUSFLAGS': [ '-fexceptions', '-Wall', '-mmacosx-version-min=10.15', '-O3' ] }, 'conditions':[ ['OS=="win"', { 'configurations':{ 'Release': { 'msvs_settings': { 'VCCLCompilerTool': { "ExceptionHandling": 1, 'AdditionalOptions': [ '-std:c++17' ], 'RuntimeTypeInfo': 'true' } } }, 'Debug': { 'msvs_settings': { 'VCCLCompilerTool': { "ExceptionHandling": 1, 'AdditionalOptions': [ '-std:c++17' ], 'RuntimeTypeInfo': 'true' } } } } }], ['OS=="linux"', { }] ] } ] }
{'targets': [{'target_name': 'civetkern', 'sources': ['src/lmdb/mdb.c', 'src/lmdb/midl.c', 'src/util/util.cpp', 'src/util/pinyin.cpp', 'src/interface.cpp', 'src/database.cpp', 'src/db_manager.cpp', 'src/log.cpp', 'src/DBThread.cpp', 'src/table/TableTag.cpp', 'src/table/TableMeta.cpp', 'src/table/TableClass.cpp', 'src/RPN.cpp', 'src/Condition.cpp', 'src/Table.cpp', 'src/Expression.cpp', 'src/StorageProxy.cpp', 'src/upgrader.cpp', 'src/civetkern.cpp'], 'include_dirs': ['include', 'src', '<!@(node -p "require(\'node-addon-api\').include")'], 'cflags_c': [], 'cflags_cc': ['-std=c++17', '-frtti', '-Wno-pessimizing-move'], 'cflags!': ['-fno-exceptions'], 'cflags_cc!': ['-fno-exceptions', '-std=gnu++1y', '-std=gnu++0x'], 'xcode_settings': {'CLANG_CXX_LANGUAGE_STANDARD': 'c++17', 'MACOSX_DEPLOYMENT_TARGET': '10.9', 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'GCC_ENABLE_CPP_RTTI': 'YES', 'OTHER_CPLUSPLUSFLAGS': ['-fexceptions', '-Wall', '-mmacosx-version-min=10.15', '-O3']}, 'conditions': [['OS=="win"', {'configurations': {'Release': {'msvs_settings': {'VCCLCompilerTool': {'ExceptionHandling': 1, 'AdditionalOptions': ['-std:c++17'], 'RuntimeTypeInfo': 'true'}}}, 'Debug': {'msvs_settings': {'VCCLCompilerTool': {'ExceptionHandling': 1, 'AdditionalOptions': ['-std:c++17'], 'RuntimeTypeInfo': 'true'}}}}}], ['OS=="linux"', {}]]}]}
class Solution: def findCenter(self, edges: List[List[int]]) -> int: edgeOne= edges[0][0] edgeTwo = edges[0][1] edgeOneCouner = 0 for i in range(len(edges)): if edgeOne == edges[i][0] or edgeOne == edges[i][1]: edgeOneCouner+=1 return edgeOne if edgeOneCouner == len(edges) else edgeTwo
class Solution: def find_center(self, edges: List[List[int]]) -> int: edge_one = edges[0][0] edge_two = edges[0][1] edge_one_couner = 0 for i in range(len(edges)): if edgeOne == edges[i][0] or edgeOne == edges[i][1]: edge_one_couner += 1 return edgeOne if edgeOneCouner == len(edges) else edgeTwo
d=int(input("Enter d -> ")) e=int(input("Enter e -> ")) b=1 a=0 s=0 k=0 for i in range(max(d,e)): if (((d==0) and (e==1))) or (((d==1) and (e==0))): k=1 print("True") break else: if (((d==a) and (e==b))) or (((d==b) and (e==a))): k=1 print("True") break s=a+b a=b b=s if k==0: print("False")
d = int(input('Enter d -> ')) e = int(input('Enter e -> ')) b = 1 a = 0 s = 0 k = 0 for i in range(max(d, e)): if d == 0 and e == 1 or (d == 1 and e == 0): k = 1 print('True') break else: if d == a and e == b or (d == b and e == a): k = 1 print('True') break s = a + b a = b b = s if k == 0: print('False')
''' Builds a calculator that reads a string and addition and subtraction. Example: Input: '1+3-5+7' Output: 6 ''' def calculator(math_string): return sum([int(item) for item in math_string.replace('-', '+-').split('+')]) def test_calculator(): assert calculator('1+3-5+7') == 6, calculator('1+3-5+7') if __name__ == '__main__': test_calculator()
""" Builds a calculator that reads a string and addition and subtraction. Example: Input: '1+3-5+7' Output: 6 """ def calculator(math_string): return sum([int(item) for item in math_string.replace('-', '+-').split('+')]) def test_calculator(): assert calculator('1+3-5+7') == 6, calculator('1+3-5+7') if __name__ == '__main__': test_calculator()
#Faca um programa que mostre a tabuada de varios numeros, um de cada vez, para cada valor #digitado pelo usuario. O programa sera interrompido quando o numero solicitado for negativo #minha resposta while True: num = int(input('Quer ver a tabuada de qual valor? ')) if num < 0: break print('-'*30) print(f'''{num} x 1 = {num*1} {num} x 2 = {num*2} {num} x 3 = {num*3} {num} x 4 = {num*4} {num} x 5 = {num*5} {num} x 6 = {num*6} {num} x 7 = {num*7} {num} x 8 = {num*8} {num} x 9 = {num*9} {num} x 10 = {num*10}''') print('-'*30) print('PROGRAMA TABUADA ENCERRADO. Volte sempre!') #resposta do Gustavo while True: n = int(input('Quer ver a tabuada de qual valor? ')) print('-'*30) if n < 0: break for c in range(1, 11): print(f'{n} x {c} = {n*c}') print('-'*30) print('PROGRAMA TABUADA ENCERRADO. Volte sempre!')
while True: num = int(input('Quer ver a tabuada de qual valor? ')) if num < 0: break print('-' * 30) print(f'{num} x 1 = {num * 1}\n{num} x 2 = {num * 2}\n{num} x 3 = {num * 3}\n{num} x 4 = {num * 4}\n{num} x 5 = {num * 5}\n{num} x 6 = {num * 6}\n{num} x 7 = {num * 7}\n{num} x 8 = {num * 8}\n{num} x 9 = {num * 9}\n{num} x 10 = {num * 10}') print('-' * 30) print('PROGRAMA TABUADA ENCERRADO. Volte sempre!') while True: n = int(input('Quer ver a tabuada de qual valor? ')) print('-' * 30) if n < 0: break for c in range(1, 11): print(f'{n} x {c} = {n * c}') print('-' * 30) print('PROGRAMA TABUADA ENCERRADO. Volte sempre!')
NUMBER_WORKER = 5 ITEM_DURATION = 60 INPUT_FILE_NAME = 'input.txt' class WorkItem: def __init__(self, name): self.name = name self.dependencies = [] self.completed = False self.completed_at = None def addDependency(self, item): self.dependencies.append(item) def isWorkable(self): if self.completed: return False for p in self.dependencies: if not p.completed: return False return True def startWorking(self, current_time): self.completed_at = current_time + ITEM_DURATION + (ord(self.name) - ord('A')) + 1 def getWorkableItems(work_item_map): result = [] for item in work_item_map.values(): if item.isWorkable(): result.append(item) return result def workOnItemsSequential(work_item_map): instruction = '' while True: work_items = getWorkableItems(work_item_map) if len(work_items) == 0: break item = min(work_items, key = lambda item: item.name) instruction += item.name item.completed = True return instruction def initWorkItemMap(file_name): result = {} with open(file_name) as input_file: for dep_str in input_file: tmp = dep_str.rstrip().split(' ') dep_work_item = result.get(tmp[1], WorkItem(tmp[1])) result[tmp[1]] = dep_work_item work_item = result.get(tmp[7], WorkItem(tmp[7])) result[tmp[7]] = work_item work_item.addDependency(dep_work_item) return result work_item_map = initWorkItemMap(INPUT_FILE_NAME) instruction = workOnItemsSequential(work_item_map) print('Solution to part 1: %s' % (instruction,)) # ------------- def workOnItemsParallel(workers, work_item_map): current_time = 0 in_progress_items = {} while True: # First check if some tasks has been completed remove_items = [] for w, item in in_progress_items.values(): if item.completed_at == current_time: item.completed = True w['busy'] = False remove_items.append(item) for item in remove_items: del in_progress_items[item.name] # Check if we've completed everything work_items = getWorkableItems(work_item_map) if len(work_items) == 0 and len(in_progress_items) == 0: break # If not, assign available tasks to workers for w in workers: if not w['busy'] and len(work_items) > 0: item = min(work_items, key = lambda item: item.name) item.startWorking(current_time) w['busy'] = True in_progress_items[item.name] = (w, item) del work_item_map[item.name] work_items = getWorkableItems(work_item_map) current_time += 1 return current_time work_item_map = initWorkItemMap(INPUT_FILE_NAME) workers = [{'name': i, 'busy': False} for i in range(NUMBER_WORKER)] duration = workOnItemsParallel(workers, work_item_map) print('Solution to part 2: %i' % (duration,))
number_worker = 5 item_duration = 60 input_file_name = 'input.txt' class Workitem: def __init__(self, name): self.name = name self.dependencies = [] self.completed = False self.completed_at = None def add_dependency(self, item): self.dependencies.append(item) def is_workable(self): if self.completed: return False for p in self.dependencies: if not p.completed: return False return True def start_working(self, current_time): self.completed_at = current_time + ITEM_DURATION + (ord(self.name) - ord('A')) + 1 def get_workable_items(work_item_map): result = [] for item in work_item_map.values(): if item.isWorkable(): result.append(item) return result def work_on_items_sequential(work_item_map): instruction = '' while True: work_items = get_workable_items(work_item_map) if len(work_items) == 0: break item = min(work_items, key=lambda item: item.name) instruction += item.name item.completed = True return instruction def init_work_item_map(file_name): result = {} with open(file_name) as input_file: for dep_str in input_file: tmp = dep_str.rstrip().split(' ') dep_work_item = result.get(tmp[1], work_item(tmp[1])) result[tmp[1]] = dep_work_item work_item = result.get(tmp[7], work_item(tmp[7])) result[tmp[7]] = work_item work_item.addDependency(dep_work_item) return result work_item_map = init_work_item_map(INPUT_FILE_NAME) instruction = work_on_items_sequential(work_item_map) print('Solution to part 1: %s' % (instruction,)) def work_on_items_parallel(workers, work_item_map): current_time = 0 in_progress_items = {} while True: remove_items = [] for (w, item) in in_progress_items.values(): if item.completed_at == current_time: item.completed = True w['busy'] = False remove_items.append(item) for item in remove_items: del in_progress_items[item.name] work_items = get_workable_items(work_item_map) if len(work_items) == 0 and len(in_progress_items) == 0: break for w in workers: if not w['busy'] and len(work_items) > 0: item = min(work_items, key=lambda item: item.name) item.startWorking(current_time) w['busy'] = True in_progress_items[item.name] = (w, item) del work_item_map[item.name] work_items = get_workable_items(work_item_map) current_time += 1 return current_time work_item_map = init_work_item_map(INPUT_FILE_NAME) workers = [{'name': i, 'busy': False} for i in range(NUMBER_WORKER)] duration = work_on_items_parallel(workers, work_item_map) print('Solution to part 2: %i' % (duration,))
class IrisError(Exception): pass class IrisDataError(IrisError): pass class IrisStorageError(IrisError): pass
class Iriserror(Exception): pass class Irisdataerror(IrisError): pass class Irisstorageerror(IrisError): pass
def fab(n): if n == 1 or n == 2: return 1 else: return fab(n - 1) + fab(n - 2) if __name__ == '__main__': print(fab(10))
def fab(n): if n == 1 or n == 2: return 1 else: return fab(n - 1) + fab(n - 2) if __name__ == '__main__': print(fab(10))
def f1(): x = 42 def f2(): x = 0 f2() print(x) f1()
def f1(): x = 42 def f2(): x = 0 f2() print(x) f1()
ACTION_ACK = 'ack' ACTION_UNACK = 'unack' ACTION_SHELVE = 'shelve' ACTION_UNSHELVE = 'unshelve' ACTION_OPEN = 'open' ACTION_CLOSE = 'close'
action_ack = 'ack' action_unack = 'unack' action_shelve = 'shelve' action_unshelve = 'unshelve' action_open = 'open' action_close = 'close'
# https://codility.com/programmers/lessons/2-arrays/cyclic_rotation/ def solution(A, K): ''' Rotate an array A to the right by a given number of steps K. ''' N = len(A) if N == 0: return A # After K rotations, the -Kth element becomes first element of list return A[-K:] + A[:N-K] if __name__ == "__main__": cases = [(([3, 8, 9, 7, 6], 3), [9, 7, 6, 3, 8]), (([], 0), []), (([5, -1000], 1), [-1000, 5]) ] for case, expt in cases: res = solution(*case) assert expt == res, (expt, res)
def solution(A, K): """ Rotate an array A to the right by a given number of steps K. """ n = len(A) if N == 0: return A return A[-K:] + A[:N - K] if __name__ == '__main__': cases = [(([3, 8, 9, 7, 6], 3), [9, 7, 6, 3, 8]), (([], 0), []), (([5, -1000], 1), [-1000, 5])] for (case, expt) in cases: res = solution(*case) assert expt == res, (expt, res)
# 23011 - Battle mage 1st job advancement quest sm.setSpeakerID(2151001) if not sm.canHold(1382000): sm.sendSayOkay("Please make some space in your equipment invetory.") sm.dispose() if sm.sendAskYesNo("Would you like to become a Battle Mage?"): sm.completeQuest(parentID) sm.jobAdvance(3200) sm.resetAP(False, 3200) sm.giveItem(1382000, 1) sm.sendSayOkay("Congratulations, you are now a battle mage! I have given you some SP and items to start out with, enjoy!") else: sm.sendSayOkay("Of course, you need more time.") sm.dispose()
sm.setSpeakerID(2151001) if not sm.canHold(1382000): sm.sendSayOkay('Please make some space in your equipment invetory.') sm.dispose() if sm.sendAskYesNo('Would you like to become a Battle Mage?'): sm.completeQuest(parentID) sm.jobAdvance(3200) sm.resetAP(False, 3200) sm.giveItem(1382000, 1) sm.sendSayOkay('Congratulations, you are now a battle mage! I have given you some SP and items to start out with, enjoy!') else: sm.sendSayOkay('Of course, you need more time.') sm.dispose()
n, k = map(int, input().split(' ')) arr = list(map(int, input().split(' '))) print ("0" if max(arr)-k<=0 else max(arr)-k)
(n, k) = map(int, input().split(' ')) arr = list(map(int, input().split(' '))) print('0' if max(arr) - k <= 0 else max(arr) - k)
__i = 0 LOGIN_FAILED_GENERIC = __i; __i += 1 LOGIN_FAILED_BAD_PASSWORD = __i; __i += 1 NIGHTLY_MAINTENANCE = __i; __i += 1 NOT_LOGGED_IN = __i; __i += 1 REQUEST_GENERIC = __i; __i += 1 REQUEST_FATAL = __i; __i += 1 INVALID_ACTION = __i; __i += 1 INVALID_ITEM = __i; __i += 1 INVALID_LOCATION = __i; __i += 1 INVALID_USER = __i; __i += 1 ITEM_NOT_FOUND = __i; __i += 1 SKILL_NOT_FOUND = __i; __i += 1 EFFECT_NOT_FOUND = __i; __i += 1 RECIPE_NOT_FOUND = __i; __i += 1 WRONG_KIND_OF_ITEM = __i; __i += 1 USER_IN_HARDCORE_RONIN = __i; __i += 1 USER_IS_IGNORING = __i; __i += 1 USER_IS_DRUNK = __i; __i += 1 USER_IS_FULL = __i; __i += 1 USER_IS_LOW_LEVEL = __i; __i += 1 USER_IS_WRONG_PROFESSION = __i; __i += 1 USER_NOT_FOUND = __i; __i += 1 NOT_ENOUGH_ADVENTURES = __i; __i += 1 NOT_ENOUGH_MEAT = __i; __i += 1 LIMIT_REACHED = __i; __i += 1 ALREADY_COMPLETED = __i; __i += 1 BOT_REQUEST = __i; __i += 1 class Error(Exception): def __init__(self, msg, code=-1): self.msg = msg self.code = code def __str__(self): return self.msg
__i = 0 login_failed_generic = __i __i += 1 login_failed_bad_password = __i __i += 1 nightly_maintenance = __i __i += 1 not_logged_in = __i __i += 1 request_generic = __i __i += 1 request_fatal = __i __i += 1 invalid_action = __i __i += 1 invalid_item = __i __i += 1 invalid_location = __i __i += 1 invalid_user = __i __i += 1 item_not_found = __i __i += 1 skill_not_found = __i __i += 1 effect_not_found = __i __i += 1 recipe_not_found = __i __i += 1 wrong_kind_of_item = __i __i += 1 user_in_hardcore_ronin = __i __i += 1 user_is_ignoring = __i __i += 1 user_is_drunk = __i __i += 1 user_is_full = __i __i += 1 user_is_low_level = __i __i += 1 user_is_wrong_profession = __i __i += 1 user_not_found = __i __i += 1 not_enough_adventures = __i __i += 1 not_enough_meat = __i __i += 1 limit_reached = __i __i += 1 already_completed = __i __i += 1 bot_request = __i __i += 1 class Error(Exception): def __init__(self, msg, code=-1): self.msg = msg self.code = code def __str__(self): return self.msg
def factorial(n): # base case should be 0. n=1 is wrong. If testcase contains n=0 => dead. if n == 0 : return 1 return n*factorial(n-1) n = int(input("Enter n : ")) print(factorial(n))
def factorial(n): if n == 0: return 1 return n * factorial(n - 1) n = int(input('Enter n : ')) print(factorial(n))
x = 344444444 b0,b1,b2,b3 = [c for c in x.to_bytes(4,"big")] y = b0 << 24 | b1 << 16 | b2 << 8 | b3 << 0 print(b0,b1,b2,b3) print(y)
x = 344444444 (b0, b1, b2, b3) = [c for c in x.to_bytes(4, 'big')] y = b0 << 24 | b1 << 16 | b2 << 8 | b3 << 0 print(b0, b1, b2, b3) print(y)
def newlist(size): list = [] for i in range(size): list.append(i) return list for i in range(5): n = pow(10, i) print("%s: list(%s)" % (i+1, n)) x = newlist(n)
def newlist(size): list = [] for i in range(size): list.append(i) return list for i in range(5): n = pow(10, i) print('%s: list(%s)' % (i + 1, n)) x = newlist(n)
# Given a binary tree, determine if it is a valid binary search tree (BST). # # Assume a BST is defined as follows: # # The left subtree of a node contains only nodes with keys less than the node's key. # The right subtree of a node contains only nodes with keys greater than the node's key. # Both the left and right subtrees must also be binary search trees # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isValidBST(self, root): def helper(node, lower, upper): if not node: return True val = node.val if val <= lower or val >= upper: print("entered 1") return False if not helper(node.right, val, upper): print("entered 2") return False if not helper(node.left, lower, val): print("entered 3") return False return True return helper(root, float("-inf"), float("inf")) node = TreeNode(5) node.left = TreeNode(4) node.right = TreeNode(7) node.right.left = TreeNode(6) node.right.right = TreeNode(8) print(Solution().isValidBST(node))
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def is_valid_bst(self, root): def helper(node, lower, upper): if not node: return True val = node.val if val <= lower or val >= upper: print('entered 1') return False if not helper(node.right, val, upper): print('entered 2') return False if not helper(node.left, lower, val): print('entered 3') return False return True return helper(root, float('-inf'), float('inf')) node = tree_node(5) node.left = tree_node(4) node.right = tree_node(7) node.right.left = tree_node(6) node.right.right = tree_node(8) print(solution().isValidBST(node))
class salaryError(Exception): pass while True: try: #salary = int(input("Enter your Salary")) salary = input("Enter your Salary") if not salary.isdigit(): raise salaryError() print(salary) break #except ValueError: except salaryError: print("Enter a valid Salary amount, try again...") finally: print("Releasing all the resources")
class Salaryerror(Exception): pass while True: try: salary = input('Enter your Salary') if not salary.isdigit(): raise salary_error() print(salary) break except salaryError: print('Enter a valid Salary amount, try again...') finally: print('Releasing all the resources')
x, y = 10, 20 def foo(): nonlocal x,\ y x = 20 y = 10 print(x,y) foo() print(x,y)
(x, y) = (10, 20) def foo(): nonlocal x, y x = 20 y = 10 print(x, y) foo() print(x, y)
#!/usr/bin/env python vcfs = "$vcf".split(" ") with open("vcfList.txt", "w") as fh: for vcf in vcfs: print(vcf, file=fh)
vcfs = '$vcf'.split(' ') with open('vcfList.txt', 'w') as fh: for vcf in vcfs: print(vcf, file=fh)
def grau(valor,v1,v2): for i in range(valor): v1.sort() v2.sort() if v1[i] != v2[i]: return "nao" return "sim" def funcao(alf,num,lista,j,grau): a = lista[1:len(lista)] if alf in a: return grau[j] elif num in a: return grau[j] else: return 0 def repetido(lista): l = [] c = 0 for i in range(len(lista)): if lista[i] not in l: l.append(lista[i]) else: c += 1 return c num = input() num = num.split(' ') num_grafo = list(map(int, num)) if num_grafo[0] != num_grafo[1]: print('nao') else: mtx1 = [[0 for x in range(num_grafo[0])] for y in range(num_grafo[0])] mtx2 = [[0 for x in range(num_grafo[1])] for y in range(num_grafo[1])] vertg1 = [] i = 0 while(i < int(num_grafo[0])): vert = input() vertg1.append(vert) i += 1 vertg2 = [] o = 0 while(o < int(num_grafo[1])): vert = input() vertg2.append(vert) o += 1 vertg1.sort() vertg2.sort() grau_g1 = [] for i in range(len(vertg1)): f = vertg1[i].split(' ') rep = repetido(f) if rep == 1: grau_g1.append(len(f)) else: grau_g1.append(len(f) - 1) grau_g2 = [] for i in range(len(vertg2)): f = vertg2[i].split(' ') rep = repetido(f) if rep == 1: grau_g2.append(len(f)) else: grau_g2.append(len(f) - 1) alf = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] num = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25'] for i in range(num_grafo[0]): for j in range(num_grafo[0]): k = funcao(vertg1[j][0],num[j],vertg1[i],j,grau_g1) mtx1[i][j] = k for i in range(num_grafo[0]): for j in range(num_grafo[0]): k = funcao(vertg2[j][0],num[j],vertg2[i],j,grau_g2) mtx2[i][j] = k for i in range(len(mtx1)): mtx1[i].sort() for i in range(len(mtx2)): mtx2[i].sort() valor = grau(num_grafo[0],grau_g1,grau_g2) if valor == "nao": print("nao") else: contador = 0 for i in range(len(mtx1)): if mtx1[i] not in mtx2: contador += 1 if contador == 0: print("sim") else: print("nao")
def grau(valor, v1, v2): for i in range(valor): v1.sort() v2.sort() if v1[i] != v2[i]: return 'nao' return 'sim' def funcao(alf, num, lista, j, grau): a = lista[1:len(lista)] if alf in a: return grau[j] elif num in a: return grau[j] else: return 0 def repetido(lista): l = [] c = 0 for i in range(len(lista)): if lista[i] not in l: l.append(lista[i]) else: c += 1 return c num = input() num = num.split(' ') num_grafo = list(map(int, num)) if num_grafo[0] != num_grafo[1]: print('nao') else: mtx1 = [[0 for x in range(num_grafo[0])] for y in range(num_grafo[0])] mtx2 = [[0 for x in range(num_grafo[1])] for y in range(num_grafo[1])] vertg1 = [] i = 0 while i < int(num_grafo[0]): vert = input() vertg1.append(vert) i += 1 vertg2 = [] o = 0 while o < int(num_grafo[1]): vert = input() vertg2.append(vert) o += 1 vertg1.sort() vertg2.sort() grau_g1 = [] for i in range(len(vertg1)): f = vertg1[i].split(' ') rep = repetido(f) if rep == 1: grau_g1.append(len(f)) else: grau_g1.append(len(f) - 1) grau_g2 = [] for i in range(len(vertg2)): f = vertg2[i].split(' ') rep = repetido(f) if rep == 1: grau_g2.append(len(f)) else: grau_g2.append(len(f) - 1) alf = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] num = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25'] for i in range(num_grafo[0]): for j in range(num_grafo[0]): k = funcao(vertg1[j][0], num[j], vertg1[i], j, grau_g1) mtx1[i][j] = k for i in range(num_grafo[0]): for j in range(num_grafo[0]): k = funcao(vertg2[j][0], num[j], vertg2[i], j, grau_g2) mtx2[i][j] = k for i in range(len(mtx1)): mtx1[i].sort() for i in range(len(mtx2)): mtx2[i].sort() valor = grau(num_grafo[0], grau_g1, grau_g2) if valor == 'nao': print('nao') else: contador = 0 for i in range(len(mtx1)): if mtx1[i] not in mtx2: contador += 1 if contador == 0: print('sim') else: print('nao')
def moving_zeroes(arr): idx = 0 moved = 0 while idx < len(arr) - moved: if arr[idx] == 0: arr.pop(idx) arr.append(0) moved += 1 else: idx += 1 return arr
def moving_zeroes(arr): idx = 0 moved = 0 while idx < len(arr) - moved: if arr[idx] == 0: arr.pop(idx) arr.append(0) moved += 1 else: idx += 1 return arr
# -*- coding: utf-8 -*- # ============================================================================== # SET THE SCREEN SIZE # # default values: # SCREEN_WIDTH = 1000 # SCREEN_SIZE = 600 # ============================================================================== SCREEN_WIDTH = 1000 SCREEN_HEIGHT = 600 SCREEN_SIZE = (SCREEN_WIDTH, SCREEN_HEIGHT) # ============================================================================== # SET THE BLOCK'S COLOR AND THE COUNTER'S COLOR # # BLOCK's name is not used, but do not set the same name. # You can use your customized color (R, G, B) . # # default values: # LOWER_BLOCK = {'Name': 'Lower', # 'color': BLUE} # UPPER_BLOCK = {'Name': 'upper', # 'color': RED} # COUNT_C = GREEN # LEVEL_C = GREEN # ============================================================================== BLACK = ( 0, 0, 0) WHITE = (255, 255, 255) BLUE = ( 0, 0, 255) GREEN = ( 0, 255, 0) RED = (255, 0, 0) LOWER_BLOCK = {'NAME': 'Lower', 'COLOR': BLUE} UPPER_BLOCK = {'NAME': 'upper', 'COLOR': RED} COUNT_C = GREEN LEVEL_C = GREEN # ============================================================================== # SET THE LEVEL # # B_MIN DISTANCE: the minimum distance between blocks # 'NAME': the name of the level displayed (DO NOT forget ' at each side.) # 'MOVE_X': set the movement distance par frame # 'BLOCK_FREQUENCY': set the block frequency [D, D+U, D+U+None] par frame, where D # is 'DOWN_BLOCK', U is 'UPPER_BLOCK, and None is 'NOT_APPEAR' # LEVEL: list of the LEVELs you use this game # CH_LEVEL: change the level when the counter of passing blocks reaches # that number ((Change LEVEL(i+1) to LEVEL(i+2) when the counter # reaches CH_LEVEL[i])) Be sure that CH_LEVEL[i] <= CH_LEVEL[i+1] for # all i. # ** You can change the number of the LEVELs. ** # # default values: # B_MIN_DISTANCE = 100 # LEVEL1 = {'NAME': 'Level 1', # 'MOVE_X': -3, # 'BLOCK_FREQUENCY': [4, 5, 500]} # LEVEL2 = {'NAME': 'Level 2', # 'MOVE_X': -5, # 'BLOCK_FREQUENCY': [4, 5, 500]} # LEVEL3 = {'NAME': 'Level 3', # 'MOVE_X': -5, # 'BLOCK_FREQUENCY': [16, 20, 500]} # LEVEL4 = {'NAME': 'Level 4', # 'MOVE_X': -8, # 'BLOCK_FREQUENCY': [8, 10, 500]} # LEVEL5 = {'NAME': 'Level 5', # 'MOVE_X': -8, # 'BLOCK_FREQUENCY': [16, 20, 500]} # LEVEL = [LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5] # CH_LEVEL = [10, 30, 50, 80] # ============================================================================== B_MIN_DISTANCE = 100 LEVEL1 = {'NAME': 'Level 1', 'MOVE_X': -3, 'BLOCK_FREQUENCY': [4, 5, 500]} LEVEL2 = {'NAME': 'Level 2', 'MOVE_X': -5, 'BLOCK_FREQUENCY': [4, 5, 500]} LEVEL3 = {'NAME': 'Level 3', 'MOVE_X': -5, 'BLOCK_FREQUENCY': [16, 20, 500]} LEVEL4 = {'NAME': 'Level 4', 'MOVE_X': -8, 'BLOCK_FREQUENCY': [8, 10, 500]} LEVEL5 = {'NAME': 'Level 5', 'MOVE_X': -8, 'BLOCK_FREQUENCY': [16, 20, 500]} LEVEL = [LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5] CH_LEVEL = [10, 30, 50, 80] # ============================================================================== # SET THE MOVEMENT DISTANCE WHEN THE CHARACTER IS JUMPING AND FALLING # # MOVE_UP: when the character jumps up. (a negative number) # MOVE_DOWN: when the character falls down (a positive number) # Changing this params is NOT recommended. # # default values: # MOVE_UP = -SCREEN_HEIGHT // 30 # MOVE_DOWN = SCREEN_HEIGHT // 60 # ============================================================================== MOVE_UP = -SCREEN_HEIGHT // 30 MOVE_DOWN = SCREEN_HEIGHT // 60
screen_width = 1000 screen_height = 600 screen_size = (SCREEN_WIDTH, SCREEN_HEIGHT) black = (0, 0, 0) white = (255, 255, 255) blue = (0, 0, 255) green = (0, 255, 0) red = (255, 0, 0) lower_block = {'NAME': 'Lower', 'COLOR': BLUE} upper_block = {'NAME': 'upper', 'COLOR': RED} count_c = GREEN level_c = GREEN b_min_distance = 100 level1 = {'NAME': 'Level 1', 'MOVE_X': -3, 'BLOCK_FREQUENCY': [4, 5, 500]} level2 = {'NAME': 'Level 2', 'MOVE_X': -5, 'BLOCK_FREQUENCY': [4, 5, 500]} level3 = {'NAME': 'Level 3', 'MOVE_X': -5, 'BLOCK_FREQUENCY': [16, 20, 500]} level4 = {'NAME': 'Level 4', 'MOVE_X': -8, 'BLOCK_FREQUENCY': [8, 10, 500]} level5 = {'NAME': 'Level 5', 'MOVE_X': -8, 'BLOCK_FREQUENCY': [16, 20, 500]} level = [LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5] ch_level = [10, 30, 50, 80] move_up = -SCREEN_HEIGHT // 30 move_down = SCREEN_HEIGHT // 60
# 1MB MAX_DATASET_SIZE = 1048576 MAX_TRAINING_COST = 100
max_dataset_size = 1048576 max_training_cost = 100
# # PySNMP MIB module ALCATEL-IND1-UDLD-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-UDLD-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:20:18 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) # softentIND1Udld, = mibBuilder.importSymbols("ALCATEL-IND1-BASE", "softentIND1Udld") OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance") MibIdentifier, IpAddress, Unsigned32, Gauge32, Integer32, ObjectIdentity, TimeTicks, Bits, iso, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, Counter32, ModuleIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "IpAddress", "Unsigned32", "Gauge32", "Integer32", "ObjectIdentity", "TimeTicks", "Bits", "iso", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "Counter32", "ModuleIdentity") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") alcatelIND1UDLDMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1)) alcatelIND1UDLDMIB.setRevisions(('2007-02-14 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setRevisionsDescriptions(("The UDLD MIB defines a set of UDLD related management objects for ports that support UniDirectional Link Detection (UDLD) Protocol. UDLD as a protocol provides mechanisms to detect and disable unidirectional links caused for instance by mis-wiring of fiber strands, interface malfunctions, media converters' faults, etc. It operates at Layer 2 in conjunction with IEEE 802.3's existing Layer 1 fault detection mechanisms. This MIB comprises proprietary managed objects as well the objects required for conforming to the protocol.",)) if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setLastUpdated('200702140000Z') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setOrganization('Alcatel - Architects Of An Internet World') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setContactInfo('Please consult with Customer Service to insure the most appropriate version of this document is used with the products in question: Alcatel Internetworking, Incorporated (Division 1, Formerly XYLAN Corporation) 26801 West Agoura Road Agoura Hills, CA 91301-5122 United States Of America Telephone: North America +1 800 995 2696 Latin America +1 877 919 9526 Europe +31 23 556 0100 Asia +65 394 7933 All Other +1 818 878 4507 Electronic Mail: support@ind.alcatel.com World Wide Web: http://www.ind.alcatel.com File Transfer Protocol: ftp://ftp.ind.alcatel.com/pub/products/mibs') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setDescription('This module describes an authoritative enterprise-specific Simple Network Management Protocol (SNMP) Management Information Base (MIB): For the Birds Of Prey Product Line UDLD for detection and disabling unidirectional links. The right to make changes in specification and other information contained in this document without prior notice is reserved. No liability shall be assumed for any incidental, indirect, special, or consequential damages whatsoever arising from or related to this document or the information contained herein. Vendors, end-users, and other interested parties are granted non-exclusive license to use this specification in connection with management of the products for which it is intended to be used. Copyright (C) 1995-2002 Alcatel Internetworking, Incorporated ALL RIGHTS RESERVED WORLDWIDE') alcatelIND1UDLDMIBObjects = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBObjects.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBObjects.setDescription('Branch For UDLD Subsystem Managed Objects.') alcatelIND1UDLDMIBConformance = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBConformance.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBConformance.setDescription('Branch for UDLD Module MIB Subsystem Conformance Information.') alcatelIND1UDLDMIBGroups = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBGroups.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBGroups.setDescription('Branch for UDLD Module MIB Subsystem Units of Conformance.') alcatelIND1UDLDMIBCompliances = ObjectIdentity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 2)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliances.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliances.setDescription('Branch for UDLD Module MIB Subsystem Compliance Statements.') alaUdldGlobalStatus = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldGlobalStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalStatus.setDescription('This variable is used to enable or diable UDLD on the switch. The value enable (1) indicates that UDLD should be enabled on the switch. The value disable (2) is used to disable UDLD on the switch. By default, UDLD is disabled on the switch.') alaUdldGlobalClearStats = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("default", 0), ("reset", 1))).clone('default')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldGlobalClearStats.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalClearStats.setDescription('Defines the global clear statistics control for UDLD. The value reset (1) indicates that UDLD should clear all statistic counters related to all ports in the system. By default, this object contains a zero value.') alaUdldGlobalConfigUdldMode = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("normal", 1), ("aggressive", 2))).clone('normal')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldGlobalConfigUdldMode.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldMode.setDescription('Defines the mode of operation of the UDLD protocol on the interface. normal - The UDLD state machines participates normally in UDLD protocol exchanges. The protocol determination at the end of detection process is always based upon information received in UDLD messages. aggressive - UDLD will shut down all port even in case it loses bidirectional connectivity with the neighbor for a defined period of time.') alaUdldGlobalConfigUdldProbeIntervalTimer = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(7, 90)).clone(15)).setUnits('seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldGlobalConfigUdldProbeIntervalTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldProbeIntervalTimer.setDescription('Maximum period of time after which the Probe message is expected from the neighbor. The range supported is 7-90 seconds.') alaUdldGlobalConfigUdldDetectionPeriodTimer = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(4, 15)).clone(8)).setUnits('seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldGlobalConfigUdldDetectionPeriodTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldDetectionPeriodTimer.setDescription('Maximum period of time before which detection of neighbor is expected. If Reply to the Sent Echo message/(s) is not received before, the timer for detection period expires, the link is detected as faulty and the associated port state is marked Undetermined/Shutdown (depending upon the UDLD operation-mode is Normal/Aggressive).') udldPortConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6)) alaUdldPortConfigTable = MibTable((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1), ) if mibBuilder.loadTexts: alaUdldPortConfigTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigTable.setDescription('A table containing UDLD port configuration information.') alaUdldPortConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1), ).setIndexNames((0, "ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigIfIndex")) if mibBuilder.loadTexts: alaUdldPortConfigEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigEntry.setDescription('A UDLD port configuration entry.') alaUdldPortConfigIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: alaUdldPortConfigIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigIfIndex.setDescription('The ifindex of the port on which UDLD is running') alaUdldPortConfigUdldStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldPortConfigUdldStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldStatus.setDescription('This variable is used to enable or diable UDLD on the interface. The value enable (1) indicates that UDLD should be enabled on the interface. The value disable (2) is used to disable UDLD on the interface. By default, UDLD is disabled on the interface.') alaUdldPortConfigUdldMode = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("normal", 1), ("aggressive", 2))).clone('normal')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldPortConfigUdldMode.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldMode.setDescription('Defines the mode of operation of the UDLD protocol on the interface. normal - The UDLD state machines participates normally in UDLD protocol exchanges. The protocol determination at the end of detection process is always based upon information received in UDLD messages. aggressive - UDLD will shut down a port even in case it loses bidirectional connectivity with the neighbor for a defined period of time.') alaUdldPortConfigUdldProbeIntervalTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(7, 90)).clone(15)).setUnits('seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldPortConfigUdldProbeIntervalTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldProbeIntervalTimer.setDescription('Maximum period of time after which the Probe message is expected from the neighbor. The range supported is 7-90 seconds.') alaUdldPortConfigUdldDetectionPeriodTimer = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(4, 15)).clone(8)).setUnits('seconds').setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldPortConfigUdldDetectionPeriodTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldDetectionPeriodTimer.setDescription('Maximum period of time before which detection of neighbor is expected. If Reply to the Sent Echo message/(s) is not received before, the timer for detection period expires, the link is detected as faulty and the associated port state is marked Undetermined/Shutdown (depending upon the UDLD operation-mode is Normal/Aggressive).') alaUdldPortConfigUdldOperationalStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("notapplicable", 0), ("shutdown", 1), ("undetermined", 2), ("bidirectional", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldPortConfigUdldOperationalStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldOperationalStatus.setDescription('The state of the interface as determined by UDLD operation.') udldPortStats = MibIdentifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7)) alaUdldPortStatsTable = MibTable((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1), ) if mibBuilder.loadTexts: alaUdldPortStatsTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsTable.setDescription('A table containing UDLD statistics information.') alaUdldPortStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1), ).setIndexNames((0, "ALCATEL-IND1-UDLD-MIB", "alaUdldPortStatsIfIndex")) if mibBuilder.loadTexts: alaUdldPortStatsEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsEntry.setDescription('A UDLD Statistics entry (per port).') alaUdldPortStatsIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: alaUdldPortStatsIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsIfIndex.setDescription('The ifindex of the port on which UDLD is running') alaUdldNumUDLDNeighbors = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 128))).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldNumUDLDNeighbors.setStatus('current') if mibBuilder.loadTexts: alaUdldNumUDLDNeighbors.setDescription('This object gives the number of neighbors for the interface.') alaUdldPortStatsClear = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("default", 0), ("reset", 1))).clone('default')).setMaxAccess("readwrite") if mibBuilder.loadTexts: alaUdldPortStatsClear.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsClear.setDescription('Reset all statistics parameters corresponding to this port. By default, this objects contains a zero value.') alaUdldPortNumProbeSent = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldPortNumProbeSent.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumProbeSent.setDescription('Number of Probe message sent by a port.') alaUdldPortNumEchoSent = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldPortNumEchoSent.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumEchoSent.setDescription('Number of Echo message sent by a port.') alaUdldPortNumInvalidRcvd = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldPortNumInvalidRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumInvalidRcvd.setDescription('Number of Invalid message received by a port.') alaUdldPortNumFlushRcvd = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 7), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldPortNumFlushRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumFlushRcvd.setDescription('Number of UDLD-Flush message received by a port.') udldPortNeighborStats = MibIdentifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8)) alaUdldPortNeighborStatsTable = MibTable((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1), ) if mibBuilder.loadTexts: alaUdldPortNeighborStatsTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsTable.setDescription("UDLD port's PDU related statistics for a neighbor.") alaUdldPortNeighborStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1), ).setIndexNames((0, "ALCATEL-IND1-UDLD-MIB", "alaUdldPortNeighborStatsIfIndex"), (0, "ALCATEL-IND1-UDLD-MIB", "alaUdldNeighborIfIndex")) if mibBuilder.loadTexts: alaUdldPortNeighborStatsEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsEntry.setDescription('A UDLD Statistics entry (per port, per neighbor).') alaUdldPortNeighborStatsIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: alaUdldPortNeighborStatsIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsIfIndex.setDescription('The ifindex of the port on which UDLD is running') alaUdldNeighborIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 128))) if mibBuilder.loadTexts: alaUdldNeighborIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldNeighborIfIndex.setDescription('The index of the neighbor to which the Statistics belong') alaUdldNeighborName = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldNeighborName.setStatus('current') if mibBuilder.loadTexts: alaUdldNeighborName.setDescription('The name of the neighbor') alaUdldNumHelloRcvd = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldNumHelloRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldNumHelloRcvd.setDescription('This object gives the number of hello messages recieved from the neighbor for this interface.') alaUdldNumEchoRcvd = MibTableColumn((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: alaUdldNumEchoRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldNumEchoRcvd.setDescription('This object gives the number of echo messages received from the neighbor for this interface.') alaUdldPrevState = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("notapplicable", 0), ("shutdown", 1), ("undetermined", 2), ("bidirectional", 3)))).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: alaUdldPrevState.setStatus('current') if mibBuilder.loadTexts: alaUdldPrevState.setDescription('The previous UDLD state of the Port.') alaUdldCurrentState = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("notapplicable", 0), ("shutdown", 1), ("undetermined", 2), ("bidirectional", 3)))).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: alaUdldCurrentState.setStatus('current') if mibBuilder.loadTexts: alaUdldCurrentState.setDescription('The current UDLD state of the Port.') alaUdldPortIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 11), InterfaceIndex()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: alaUdldPortIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortIfIndex.setDescription('The ifindex of the port on which UDLD trap is raised') alaUdldEvents = MibIdentifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 3)) udldStateChange = NotificationType((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 3, 0, 1)).setObjects(("ALCATEL-IND1-UDLD-MIB", "alaUdldPortIfIndex"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPrevState"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldCurrentState")) if mibBuilder.loadTexts: udldStateChange.setStatus('current') if mibBuilder.loadTexts: udldStateChange.setDescription('The UDLD-state of port has changed. Notify the user by raising the Trap. Notify the Management Entity the previous UDLD-state and UDLD-Current.') alcatelIND1UDLDMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 2, 1)).setObjects(("ALCATEL-IND1-UDLD-MIB", "udldPortBaseGroup"), ("ALCATEL-IND1-UDLD-MIB", "udldPortConfigGroup"), ("ALCATEL-IND1-UDLD-MIB", "udldPortStatsGroup"), ("ALCATEL-IND1-UDLD-MIB", "udldPortNeighborStatsGroup"), ("ALCATEL-IND1-UDLD-MIB", "udldPortTrapGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): alcatelIND1UDLDMIBCompliance = alcatelIND1UDLDMIBCompliance.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliance.setDescription('Compliance statement for UDLD.') udldPortBaseGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 1)).setObjects(("ALCATEL-IND1-UDLD-MIB", "alaUdldGlobalStatus"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldGlobalClearStats"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldGlobalConfigUdldMode"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldGlobalConfigUdldProbeIntervalTimer"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldGlobalConfigUdldDetectionPeriodTimer"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPrevState"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldCurrentState"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortIfIndex")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udldPortBaseGroup = udldPortBaseGroup.setStatus('current') if mibBuilder.loadTexts: udldPortBaseGroup.setDescription('Collection of objects for management of UDLD Base Group.') udldPortConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 2)).setObjects(("ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigUdldStatus"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigUdldMode"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigUdldProbeIntervalTimer"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigUdldDetectionPeriodTimer"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortConfigUdldOperationalStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udldPortConfigGroup = udldPortConfigGroup.setStatus('current') if mibBuilder.loadTexts: udldPortConfigGroup.setDescription('Collection of objects for management of UDLD Port Configuration Table.') udldPortStatsGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 3)).setObjects(("ALCATEL-IND1-UDLD-MIB", "alaUdldNumUDLDNeighbors"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortStatsClear"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortNumProbeSent"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortNumEchoSent"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortNumInvalidRcvd"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldPortNumFlushRcvd")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udldPortStatsGroup = udldPortStatsGroup.setStatus('current') if mibBuilder.loadTexts: udldPortStatsGroup.setDescription('Collection of objects for management of UDLD Port Statistics Table.') udldPortNeighborStatsGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 4)).setObjects(("ALCATEL-IND1-UDLD-MIB", "alaUdldNeighborName"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldNumHelloRcvd"), ("ALCATEL-IND1-UDLD-MIB", "alaUdldNumEchoRcvd")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udldPortNeighborStatsGroup = udldPortNeighborStatsGroup.setStatus('current') if mibBuilder.loadTexts: udldPortNeighborStatsGroup.setDescription('Collection of objects for management of UDLD Port Neighbor Statistics Table.') udldPortTrapGroup = NotificationGroup((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 5)).setObjects(("ALCATEL-IND1-UDLD-MIB", "udldStateChange")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udldPortTrapGroup = udldPortTrapGroup.setStatus('current') if mibBuilder.loadTexts: udldPortTrapGroup.setDescription('Collection of objects for UDLD Traps.') mibBuilder.exportSymbols("ALCATEL-IND1-UDLD-MIB", alaUdldPortStatsClear=alaUdldPortStatsClear, alaUdldPortNeighborStatsIfIndex=alaUdldPortNeighborStatsIfIndex, alaUdldPortConfigUdldProbeIntervalTimer=alaUdldPortConfigUdldProbeIntervalTimer, alaUdldPortConfigUdldStatus=alaUdldPortConfigUdldStatus, alaUdldPortConfigTable=alaUdldPortConfigTable, udldPortNeighborStats=udldPortNeighborStats, alaUdldPortNumProbeSent=alaUdldPortNumProbeSent, alaUdldPrevState=alaUdldPrevState, alaUdldPortIfIndex=alaUdldPortIfIndex, udldStateChange=udldStateChange, alaUdldPortConfigUdldDetectionPeriodTimer=alaUdldPortConfigUdldDetectionPeriodTimer, alaUdldPortConfigUdldOperationalStatus=alaUdldPortConfigUdldOperationalStatus, udldPortBaseGroup=udldPortBaseGroup, udldPortStatsGroup=udldPortStatsGroup, alcatelIND1UDLDMIBCompliances=alcatelIND1UDLDMIBCompliances, alaUdldGlobalConfigUdldDetectionPeriodTimer=alaUdldGlobalConfigUdldDetectionPeriodTimer, alaUdldPortNumFlushRcvd=alaUdldPortNumFlushRcvd, alaUdldPortConfigUdldMode=alaUdldPortConfigUdldMode, alaUdldPortNumInvalidRcvd=alaUdldPortNumInvalidRcvd, alaUdldCurrentState=alaUdldCurrentState, alaUdldPortNeighborStatsTable=alaUdldPortNeighborStatsTable, alaUdldGlobalStatus=alaUdldGlobalStatus, alaUdldNumUDLDNeighbors=alaUdldNumUDLDNeighbors, alaUdldPortConfigEntry=alaUdldPortConfigEntry, alaUdldGlobalConfigUdldMode=alaUdldGlobalConfigUdldMode, udldPortConfigGroup=udldPortConfigGroup, alaUdldPortNeighborStatsEntry=alaUdldPortNeighborStatsEntry, udldPortTrapGroup=udldPortTrapGroup, alaUdldPortStatsTable=alaUdldPortStatsTable, alcatelIND1UDLDMIBGroups=alcatelIND1UDLDMIBGroups, alaUdldNumHelloRcvd=alaUdldNumHelloRcvd, alaUdldEvents=alaUdldEvents, alcatelIND1UDLDMIBObjects=alcatelIND1UDLDMIBObjects, udldPortNeighborStatsGroup=udldPortNeighborStatsGroup, alcatelIND1UDLDMIBCompliance=alcatelIND1UDLDMIBCompliance, alaUdldNumEchoRcvd=alaUdldNumEchoRcvd, udldPortConfig=udldPortConfig, alaUdldPortConfigIfIndex=alaUdldPortConfigIfIndex, alaUdldPortStatsEntry=alaUdldPortStatsEntry, alaUdldGlobalClearStats=alaUdldGlobalClearStats, alaUdldGlobalConfigUdldProbeIntervalTimer=alaUdldGlobalConfigUdldProbeIntervalTimer, alcatelIND1UDLDMIB=alcatelIND1UDLDMIB, PYSNMP_MODULE_ID=alcatelIND1UDLDMIB, alaUdldNeighborIfIndex=alaUdldNeighborIfIndex, alcatelIND1UDLDMIBConformance=alcatelIND1UDLDMIBConformance, udldPortStats=udldPortStats, alaUdldPortNumEchoSent=alaUdldPortNumEchoSent, alaUdldNeighborName=alaUdldNeighborName, alaUdldPortStatsIfIndex=alaUdldPortStatsIfIndex)
(softent_ind1_udld,) = mibBuilder.importSymbols('ALCATEL-IND1-BASE', 'softentIND1Udld') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_range_constraint, constraints_intersection, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint') (interface_index,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndex') (snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') (object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance') (mib_identifier, ip_address, unsigned32, gauge32, integer32, object_identity, time_ticks, bits, iso, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, counter32, module_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'IpAddress', 'Unsigned32', 'Gauge32', 'Integer32', 'ObjectIdentity', 'TimeTicks', 'Bits', 'iso', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'Counter32', 'ModuleIdentity') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') alcatel_ind1_udldmib = module_identity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1)) alcatelIND1UDLDMIB.setRevisions(('2007-02-14 00:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setRevisionsDescriptions(("The UDLD MIB defines a set of UDLD related management objects for ports that support UniDirectional Link Detection (UDLD) Protocol. UDLD as a protocol provides mechanisms to detect and disable unidirectional links caused for instance by mis-wiring of fiber strands, interface malfunctions, media converters' faults, etc. It operates at Layer 2 in conjunction with IEEE 802.3's existing Layer 1 fault detection mechanisms. This MIB comprises proprietary managed objects as well the objects required for conforming to the protocol.",)) if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setLastUpdated('200702140000Z') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setOrganization('Alcatel - Architects Of An Internet World') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setContactInfo('Please consult with Customer Service to insure the most appropriate version of this document is used with the products in question: Alcatel Internetworking, Incorporated (Division 1, Formerly XYLAN Corporation) 26801 West Agoura Road Agoura Hills, CA 91301-5122 United States Of America Telephone: North America +1 800 995 2696 Latin America +1 877 919 9526 Europe +31 23 556 0100 Asia +65 394 7933 All Other +1 818 878 4507 Electronic Mail: support@ind.alcatel.com World Wide Web: http://www.ind.alcatel.com File Transfer Protocol: ftp://ftp.ind.alcatel.com/pub/products/mibs') if mibBuilder.loadTexts: alcatelIND1UDLDMIB.setDescription('This module describes an authoritative enterprise-specific Simple Network Management Protocol (SNMP) Management Information Base (MIB): For the Birds Of Prey Product Line UDLD for detection and disabling unidirectional links. The right to make changes in specification and other information contained in this document without prior notice is reserved. No liability shall be assumed for any incidental, indirect, special, or consequential damages whatsoever arising from or related to this document or the information contained herein. Vendors, end-users, and other interested parties are granted non-exclusive license to use this specification in connection with management of the products for which it is intended to be used. Copyright (C) 1995-2002 Alcatel Internetworking, Incorporated ALL RIGHTS RESERVED WORLDWIDE') alcatel_ind1_udldmib_objects = object_identity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBObjects.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBObjects.setDescription('Branch For UDLD Subsystem Managed Objects.') alcatel_ind1_udldmib_conformance = object_identity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBConformance.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBConformance.setDescription('Branch for UDLD Module MIB Subsystem Conformance Information.') alcatel_ind1_udldmib_groups = object_identity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBGroups.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBGroups.setDescription('Branch for UDLD Module MIB Subsystem Units of Conformance.') alcatel_ind1_udldmib_compliances = object_identity((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 2)) if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliances.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliances.setDescription('Branch for UDLD Module MIB Subsystem Compliance Statements.') ala_udld_global_status = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldGlobalStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalStatus.setDescription('This variable is used to enable or diable UDLD on the switch. The value enable (1) indicates that UDLD should be enabled on the switch. The value disable (2) is used to disable UDLD on the switch. By default, UDLD is disabled on the switch.') ala_udld_global_clear_stats = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('default', 0), ('reset', 1))).clone('default')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldGlobalClearStats.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalClearStats.setDescription('Defines the global clear statistics control for UDLD. The value reset (1) indicates that UDLD should clear all statistic counters related to all ports in the system. By default, this object contains a zero value.') ala_udld_global_config_udld_mode = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('normal', 1), ('aggressive', 2))).clone('normal')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldMode.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldMode.setDescription('Defines the mode of operation of the UDLD protocol on the interface. normal - The UDLD state machines participates normally in UDLD protocol exchanges. The protocol determination at the end of detection process is always based upon information received in UDLD messages. aggressive - UDLD will shut down all port even in case it loses bidirectional connectivity with the neighbor for a defined period of time.') ala_udld_global_config_udld_probe_interval_timer = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(7, 90)).clone(15)).setUnits('seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldProbeIntervalTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldProbeIntervalTimer.setDescription('Maximum period of time after which the Probe message is expected from the neighbor. The range supported is 7-90 seconds.') ala_udld_global_config_udld_detection_period_timer = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(4, 15)).clone(8)).setUnits('seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldDetectionPeriodTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldGlobalConfigUdldDetectionPeriodTimer.setDescription('Maximum period of time before which detection of neighbor is expected. If Reply to the Sent Echo message/(s) is not received before, the timer for detection period expires, the link is detected as faulty and the associated port state is marked Undetermined/Shutdown (depending upon the UDLD operation-mode is Normal/Aggressive).') udld_port_config = mib_identifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6)) ala_udld_port_config_table = mib_table((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1)) if mibBuilder.loadTexts: alaUdldPortConfigTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigTable.setDescription('A table containing UDLD port configuration information.') ala_udld_port_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1)).setIndexNames((0, 'ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigIfIndex')) if mibBuilder.loadTexts: alaUdldPortConfigEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigEntry.setDescription('A UDLD port configuration entry.') ala_udld_port_config_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 1), interface_index()) if mibBuilder.loadTexts: alaUdldPortConfigIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigIfIndex.setDescription('The ifindex of the port on which UDLD is running') ala_udld_port_config_udld_status = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldPortConfigUdldStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldStatus.setDescription('This variable is used to enable or diable UDLD on the interface. The value enable (1) indicates that UDLD should be enabled on the interface. The value disable (2) is used to disable UDLD on the interface. By default, UDLD is disabled on the interface.') ala_udld_port_config_udld_mode = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('normal', 1), ('aggressive', 2))).clone('normal')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldPortConfigUdldMode.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldMode.setDescription('Defines the mode of operation of the UDLD protocol on the interface. normal - The UDLD state machines participates normally in UDLD protocol exchanges. The protocol determination at the end of detection process is always based upon information received in UDLD messages. aggressive - UDLD will shut down a port even in case it loses bidirectional connectivity with the neighbor for a defined period of time.') ala_udld_port_config_udld_probe_interval_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(7, 90)).clone(15)).setUnits('seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldPortConfigUdldProbeIntervalTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldProbeIntervalTimer.setDescription('Maximum period of time after which the Probe message is expected from the neighbor. The range supported is 7-90 seconds.') ala_udld_port_config_udld_detection_period_timer = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(4, 15)).clone(8)).setUnits('seconds').setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldPortConfigUdldDetectionPeriodTimer.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldDetectionPeriodTimer.setDescription('Maximum period of time before which detection of neighbor is expected. If Reply to the Sent Echo message/(s) is not received before, the timer for detection period expires, the link is detected as faulty and the associated port state is marked Undetermined/Shutdown (depending upon the UDLD operation-mode is Normal/Aggressive).') ala_udld_port_config_udld_operational_status = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 6, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('notapplicable', 0), ('shutdown', 1), ('undetermined', 2), ('bidirectional', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldPortConfigUdldOperationalStatus.setStatus('current') if mibBuilder.loadTexts: alaUdldPortConfigUdldOperationalStatus.setDescription('The state of the interface as determined by UDLD operation.') udld_port_stats = mib_identifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7)) ala_udld_port_stats_table = mib_table((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1)) if mibBuilder.loadTexts: alaUdldPortStatsTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsTable.setDescription('A table containing UDLD statistics information.') ala_udld_port_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1)).setIndexNames((0, 'ALCATEL-IND1-UDLD-MIB', 'alaUdldPortStatsIfIndex')) if mibBuilder.loadTexts: alaUdldPortStatsEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsEntry.setDescription('A UDLD Statistics entry (per port).') ala_udld_port_stats_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 1), interface_index()) if mibBuilder.loadTexts: alaUdldPortStatsIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsIfIndex.setDescription('The ifindex of the port on which UDLD is running') ala_udld_num_udld_neighbors = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 128))).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldNumUDLDNeighbors.setStatus('current') if mibBuilder.loadTexts: alaUdldNumUDLDNeighbors.setDescription('This object gives the number of neighbors for the interface.') ala_udld_port_stats_clear = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('default', 0), ('reset', 1))).clone('default')).setMaxAccess('readwrite') if mibBuilder.loadTexts: alaUdldPortStatsClear.setStatus('current') if mibBuilder.loadTexts: alaUdldPortStatsClear.setDescription('Reset all statistics parameters corresponding to this port. By default, this objects contains a zero value.') ala_udld_port_num_probe_sent = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldPortNumProbeSent.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumProbeSent.setDescription('Number of Probe message sent by a port.') ala_udld_port_num_echo_sent = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldPortNumEchoSent.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumEchoSent.setDescription('Number of Echo message sent by a port.') ala_udld_port_num_invalid_rcvd = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldPortNumInvalidRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumInvalidRcvd.setDescription('Number of Invalid message received by a port.') ala_udld_port_num_flush_rcvd = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 7, 1, 1, 7), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldPortNumFlushRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNumFlushRcvd.setDescription('Number of UDLD-Flush message received by a port.') udld_port_neighbor_stats = mib_identifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8)) ala_udld_port_neighbor_stats_table = mib_table((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1)) if mibBuilder.loadTexts: alaUdldPortNeighborStatsTable.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsTable.setDescription("UDLD port's PDU related statistics for a neighbor.") ala_udld_port_neighbor_stats_entry = mib_table_row((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1)).setIndexNames((0, 'ALCATEL-IND1-UDLD-MIB', 'alaUdldPortNeighborStatsIfIndex'), (0, 'ALCATEL-IND1-UDLD-MIB', 'alaUdldNeighborIfIndex')) if mibBuilder.loadTexts: alaUdldPortNeighborStatsEntry.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsEntry.setDescription('A UDLD Statistics entry (per port, per neighbor).') ala_udld_port_neighbor_stats_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 1), interface_index()) if mibBuilder.loadTexts: alaUdldPortNeighborStatsIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortNeighborStatsIfIndex.setDescription('The ifindex of the port on which UDLD is running') ala_udld_neighbor_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 128))) if mibBuilder.loadTexts: alaUdldNeighborIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldNeighborIfIndex.setDescription('The index of the neighbor to which the Statistics belong') ala_udld_neighbor_name = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 3), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldNeighborName.setStatus('current') if mibBuilder.loadTexts: alaUdldNeighborName.setDescription('The name of the neighbor') ala_udld_num_hello_rcvd = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldNumHelloRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldNumHelloRcvd.setDescription('This object gives the number of hello messages recieved from the neighbor for this interface.') ala_udld_num_echo_rcvd = mib_table_column((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 8, 1, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: alaUdldNumEchoRcvd.setStatus('current') if mibBuilder.loadTexts: alaUdldNumEchoRcvd.setDescription('This object gives the number of echo messages received from the neighbor for this interface.') ala_udld_prev_state = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('notapplicable', 0), ('shutdown', 1), ('undetermined', 2), ('bidirectional', 3)))).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: alaUdldPrevState.setStatus('current') if mibBuilder.loadTexts: alaUdldPrevState.setDescription('The previous UDLD state of the Port.') ala_udld_current_state = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('notapplicable', 0), ('shutdown', 1), ('undetermined', 2), ('bidirectional', 3)))).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: alaUdldCurrentState.setStatus('current') if mibBuilder.loadTexts: alaUdldCurrentState.setDescription('The current UDLD state of the Port.') ala_udld_port_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 1, 11), interface_index()).setMaxAccess('accessiblefornotify') if mibBuilder.loadTexts: alaUdldPortIfIndex.setStatus('current') if mibBuilder.loadTexts: alaUdldPortIfIndex.setDescription('The ifindex of the port on which UDLD trap is raised') ala_udld_events = mib_identifier((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 3)) udld_state_change = notification_type((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 3, 0, 1)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortIfIndex'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPrevState'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldCurrentState')) if mibBuilder.loadTexts: udldStateChange.setStatus('current') if mibBuilder.loadTexts: udldStateChange.setDescription('The UDLD-state of port has changed. Notify the user by raising the Trap. Notify the Management Entity the previous UDLD-state and UDLD-Current.') alcatel_ind1_udldmib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 2, 1)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'udldPortBaseGroup'), ('ALCATEL-IND1-UDLD-MIB', 'udldPortConfigGroup'), ('ALCATEL-IND1-UDLD-MIB', 'udldPortStatsGroup'), ('ALCATEL-IND1-UDLD-MIB', 'udldPortNeighborStatsGroup'), ('ALCATEL-IND1-UDLD-MIB', 'udldPortTrapGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): alcatel_ind1_udldmib_compliance = alcatelIND1UDLDMIBCompliance.setStatus('current') if mibBuilder.loadTexts: alcatelIND1UDLDMIBCompliance.setDescription('Compliance statement for UDLD.') udld_port_base_group = object_group((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 1)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'alaUdldGlobalStatus'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldGlobalClearStats'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldGlobalConfigUdldMode'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldGlobalConfigUdldProbeIntervalTimer'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldGlobalConfigUdldDetectionPeriodTimer'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPrevState'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldCurrentState'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortIfIndex')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udld_port_base_group = udldPortBaseGroup.setStatus('current') if mibBuilder.loadTexts: udldPortBaseGroup.setDescription('Collection of objects for management of UDLD Base Group.') udld_port_config_group = object_group((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 2)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigUdldStatus'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigUdldMode'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigUdldProbeIntervalTimer'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigUdldDetectionPeriodTimer'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortConfigUdldOperationalStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udld_port_config_group = udldPortConfigGroup.setStatus('current') if mibBuilder.loadTexts: udldPortConfigGroup.setDescription('Collection of objects for management of UDLD Port Configuration Table.') udld_port_stats_group = object_group((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 3)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'alaUdldNumUDLDNeighbors'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortStatsClear'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortNumProbeSent'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortNumEchoSent'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortNumInvalidRcvd'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldPortNumFlushRcvd')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udld_port_stats_group = udldPortStatsGroup.setStatus('current') if mibBuilder.loadTexts: udldPortStatsGroup.setDescription('Collection of objects for management of UDLD Port Statistics Table.') udld_port_neighbor_stats_group = object_group((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 4)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'alaUdldNeighborName'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldNumHelloRcvd'), ('ALCATEL-IND1-UDLD-MIB', 'alaUdldNumEchoRcvd')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udld_port_neighbor_stats_group = udldPortNeighborStatsGroup.setStatus('current') if mibBuilder.loadTexts: udldPortNeighborStatsGroup.setDescription('Collection of objects for management of UDLD Port Neighbor Statistics Table.') udld_port_trap_group = notification_group((1, 3, 6, 1, 4, 1, 6486, 801, 1, 2, 1, 44, 1, 2, 1, 5)).setObjects(('ALCATEL-IND1-UDLD-MIB', 'udldStateChange')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): udld_port_trap_group = udldPortTrapGroup.setStatus('current') if mibBuilder.loadTexts: udldPortTrapGroup.setDescription('Collection of objects for UDLD Traps.') mibBuilder.exportSymbols('ALCATEL-IND1-UDLD-MIB', alaUdldPortStatsClear=alaUdldPortStatsClear, alaUdldPortNeighborStatsIfIndex=alaUdldPortNeighborStatsIfIndex, alaUdldPortConfigUdldProbeIntervalTimer=alaUdldPortConfigUdldProbeIntervalTimer, alaUdldPortConfigUdldStatus=alaUdldPortConfigUdldStatus, alaUdldPortConfigTable=alaUdldPortConfigTable, udldPortNeighborStats=udldPortNeighborStats, alaUdldPortNumProbeSent=alaUdldPortNumProbeSent, alaUdldPrevState=alaUdldPrevState, alaUdldPortIfIndex=alaUdldPortIfIndex, udldStateChange=udldStateChange, alaUdldPortConfigUdldDetectionPeriodTimer=alaUdldPortConfigUdldDetectionPeriodTimer, alaUdldPortConfigUdldOperationalStatus=alaUdldPortConfigUdldOperationalStatus, udldPortBaseGroup=udldPortBaseGroup, udldPortStatsGroup=udldPortStatsGroup, alcatelIND1UDLDMIBCompliances=alcatelIND1UDLDMIBCompliances, alaUdldGlobalConfigUdldDetectionPeriodTimer=alaUdldGlobalConfigUdldDetectionPeriodTimer, alaUdldPortNumFlushRcvd=alaUdldPortNumFlushRcvd, alaUdldPortConfigUdldMode=alaUdldPortConfigUdldMode, alaUdldPortNumInvalidRcvd=alaUdldPortNumInvalidRcvd, alaUdldCurrentState=alaUdldCurrentState, alaUdldPortNeighborStatsTable=alaUdldPortNeighborStatsTable, alaUdldGlobalStatus=alaUdldGlobalStatus, alaUdldNumUDLDNeighbors=alaUdldNumUDLDNeighbors, alaUdldPortConfigEntry=alaUdldPortConfigEntry, alaUdldGlobalConfigUdldMode=alaUdldGlobalConfigUdldMode, udldPortConfigGroup=udldPortConfigGroup, alaUdldPortNeighborStatsEntry=alaUdldPortNeighborStatsEntry, udldPortTrapGroup=udldPortTrapGroup, alaUdldPortStatsTable=alaUdldPortStatsTable, alcatelIND1UDLDMIBGroups=alcatelIND1UDLDMIBGroups, alaUdldNumHelloRcvd=alaUdldNumHelloRcvd, alaUdldEvents=alaUdldEvents, alcatelIND1UDLDMIBObjects=alcatelIND1UDLDMIBObjects, udldPortNeighborStatsGroup=udldPortNeighborStatsGroup, alcatelIND1UDLDMIBCompliance=alcatelIND1UDLDMIBCompliance, alaUdldNumEchoRcvd=alaUdldNumEchoRcvd, udldPortConfig=udldPortConfig, alaUdldPortConfigIfIndex=alaUdldPortConfigIfIndex, alaUdldPortStatsEntry=alaUdldPortStatsEntry, alaUdldGlobalClearStats=alaUdldGlobalClearStats, alaUdldGlobalConfigUdldProbeIntervalTimer=alaUdldGlobalConfigUdldProbeIntervalTimer, alcatelIND1UDLDMIB=alcatelIND1UDLDMIB, PYSNMP_MODULE_ID=alcatelIND1UDLDMIB, alaUdldNeighborIfIndex=alaUdldNeighborIfIndex, alcatelIND1UDLDMIBConformance=alcatelIND1UDLDMIBConformance, udldPortStats=udldPortStats, alaUdldPortNumEchoSent=alaUdldPortNumEchoSent, alaUdldNeighborName=alaUdldNeighborName, alaUdldPortStatsIfIndex=alaUdldPortStatsIfIndex)
# # PySNMP MIB module CISCO-SECURE-SHELL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SECURE-SHELL-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:54:56 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ValueRangeConstraint, ConstraintsIntersection, SingleValueConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueSizeConstraint") ciscoMgmt, = mibBuilder.importSymbols("CISCO-SMI", "ciscoMgmt") InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType") SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ModuleCompliance, NotificationGroup, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup") ModuleIdentity, IpAddress, iso, Integer32, Unsigned32, MibIdentifier, NotificationType, Bits, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, ObjectIdentity, TimeTicks, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "IpAddress", "iso", "Integer32", "Unsigned32", "MibIdentifier", "NotificationType", "Bits", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "ObjectIdentity", "TimeTicks", "Counter32") TextualConvention, RowStatus, TruthValue, DisplayString, TimeStamp = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "RowStatus", "TruthValue", "DisplayString", "TimeStamp") ciscoSecureShellMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 9, 339)) ciscoSecureShellMIB.setRevisions(('2005-06-01 00:00', '2004-04-05 00:00', '2003-09-18 00:00', '2002-10-05 00:00',)) if mibBuilder.loadTexts: ciscoSecureShellMIB.setLastUpdated('200506010000Z') if mibBuilder.loadTexts: ciscoSecureShellMIB.setOrganization('Cisco Systems, Inc.') ciscoSecureShellMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1)) cssConfiguration = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1)) cssSessionInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2)) class CssVersions(TextualConvention, Bits): status = 'current' namedValues = NamedValues(("v1", 0), ("v2", 1)) cssServiceActivation = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 1), TruthValue().clone('false')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cssServiceActivation.setStatus('current') cssKeyTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2), ) if mibBuilder.loadTexts: cssKeyTable.setStatus('current') cssKeyEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1), ).setIndexNames((0, "CISCO-SECURE-SHELL-MIB", "cssKeyIndex")) if mibBuilder.loadTexts: cssKeyEntry.setStatus('current') cssKeyIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("rsa", 1), ("rsa1", 2), ("dsa", 3)))) if mibBuilder.loadTexts: cssKeyIndex.setStatus('current') cssKeyNBits = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(512, 2048))).setMaxAccess("readcreate") if mibBuilder.loadTexts: cssKeyNBits.setStatus('current') cssKeyOverWrite = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 3), TruthValue()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cssKeyOverWrite.setStatus('current') cssKeyLastCreationTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 4), TimeStamp()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssKeyLastCreationTime.setStatus('current') cssKeyRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 5), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: cssKeyRowStatus.setStatus('current') cssKeyString = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: cssKeyString.setStatus('current') cssServiceCapability = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 3), CssVersions()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssServiceCapability.setStatus('current') cssServiceMode = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 4), CssVersions()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cssServiceMode.setStatus('current') cssKeyGenerationStatus = MibScalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inProgress", 1), ("successful", 2), ("failed", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cssKeyGenerationStatus.setStatus('current') cssSessionTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1), ) if mibBuilder.loadTexts: cssSessionTable.setStatus('current') cssSessionEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1), ).setIndexNames((0, "CISCO-SECURE-SHELL-MIB", "cssSessionID")) if mibBuilder.loadTexts: cssSessionEntry.setStatus('current') cssSessionID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 1), Unsigned32()) if mibBuilder.loadTexts: cssSessionID.setStatus('current') cssSessionVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("one", 1), ("two", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionVersion.setStatus('current') cssSessionState = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=NamedValues(("sshSessionVersionOk", 1), ("sshSessionKeysExchanged", 2), ("sshSessionAuthenticated", 3), ("sshSessionOpen", 4), ("sshSessionDisconnecting", 5), ("sshSessionDisconnected", 6), ("sshSessionClosed", 7)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionState.setStatus('current') cssSessionPID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 4), Unsigned32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionPID.setStatus('current') cssSessionUserID = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 5), SnmpAdminString()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionUserID.setStatus('current') cssSessionHostAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 6), InetAddressType()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionHostAddrType.setStatus('current') cssSessionHostAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 7), InetAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: cssSessionHostAddr.setStatus('current') ciscoSecureShellMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2)) ciscoSecureShellMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1)) ciscoSecureShellMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2)) ciscoSecureShellMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 1)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssConfigurationGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoSecureShellMIBCompliance = ciscoSecureShellMIBCompliance.setStatus('deprecated') ciscoSecureShellMIBComplianceRv1 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 2)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssConfigurationGroupRev1")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoSecureShellMIBComplianceRv1 = ciscoSecureShellMIBComplianceRv1.setStatus('deprecated') ciscoSecureShellMIBComplianceRv2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 3)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssConfigurationGroupRev1")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoSecureShellMIBComplianceRv2 = ciscoSecureShellMIBComplianceRv2.setStatus('deprecated') ciscoSecureShellMIBComplianceRv3 = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 4)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssConfigurationGroupRev1"), ("CISCO-SECURE-SHELL-MIB", "cssConfigurationGroupSupp1")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): ciscoSecureShellMIBComplianceRv3 = ciscoSecureShellMIBComplianceRv3.setStatus('current') cssConfigurationGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 1)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssServiceActivation"), ("CISCO-SECURE-SHELL-MIB", "cssKeyNBits"), ("CISCO-SECURE-SHELL-MIB", "cssKeyOverWrite"), ("CISCO-SECURE-SHELL-MIB", "cssKeyLastCreationTime"), ("CISCO-SECURE-SHELL-MIB", "cssKeyRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cssConfigurationGroup = cssConfigurationGroup.setStatus('deprecated') cssConfigurationGroupRev1 = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 2)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssServiceActivation"), ("CISCO-SECURE-SHELL-MIB", "cssKeyNBits"), ("CISCO-SECURE-SHELL-MIB", "cssKeyOverWrite"), ("CISCO-SECURE-SHELL-MIB", "cssKeyLastCreationTime"), ("CISCO-SECURE-SHELL-MIB", "cssKeyString"), ("CISCO-SECURE-SHELL-MIB", "cssKeyRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cssConfigurationGroupRev1 = cssConfigurationGroupRev1.setStatus('current') cssServiceModeCfgGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 3)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssServiceCapability"), ("CISCO-SECURE-SHELL-MIB", "cssServiceMode")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cssServiceModeCfgGroup = cssServiceModeCfgGroup.setStatus('current') cssSessionInfoGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 4)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssSessionVersion"), ("CISCO-SECURE-SHELL-MIB", "cssSessionState"), ("CISCO-SECURE-SHELL-MIB", "cssSessionPID"), ("CISCO-SECURE-SHELL-MIB", "cssSessionUserID"), ("CISCO-SECURE-SHELL-MIB", "cssSessionHostAddrType"), ("CISCO-SECURE-SHELL-MIB", "cssSessionHostAddr")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cssSessionInfoGroup = cssSessionInfoGroup.setStatus('current') cssConfigurationGroupSupp1 = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 5)).setObjects(("CISCO-SECURE-SHELL-MIB", "cssKeyGenerationStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cssConfigurationGroupSupp1 = cssConfigurationGroupSupp1.setStatus('current') mibBuilder.exportSymbols("CISCO-SECURE-SHELL-MIB", cssSessionTable=cssSessionTable, cssSessionInfoGroup=cssSessionInfoGroup, cssKeyIndex=cssKeyIndex, cssSessionPID=cssSessionPID, CssVersions=CssVersions, cssSessionInfo=cssSessionInfo, cssConfigurationGroup=cssConfigurationGroup, cssKeyRowStatus=cssKeyRowStatus, ciscoSecureShellMIB=ciscoSecureShellMIB, cssKeyNBits=cssKeyNBits, cssServiceMode=cssServiceMode, cssConfiguration=cssConfiguration, cssSessionHostAddr=cssSessionHostAddr, cssKeyOverWrite=cssKeyOverWrite, ciscoSecureShellMIBGroups=ciscoSecureShellMIBGroups, ciscoSecureShellMIBCompliances=ciscoSecureShellMIBCompliances, PYSNMP_MODULE_ID=ciscoSecureShellMIB, cssServiceCapability=cssServiceCapability, cssKeyTable=cssKeyTable, cssServiceModeCfgGroup=cssServiceModeCfgGroup, cssSessionVersion=cssSessionVersion, cssServiceActivation=cssServiceActivation, cssConfigurationGroupSupp1=cssConfigurationGroupSupp1, ciscoSecureShellMIBCompliance=ciscoSecureShellMIBCompliance, cssKeyEntry=cssKeyEntry, cssSessionHostAddrType=cssSessionHostAddrType, cssKeyString=cssKeyString, cssKeyLastCreationTime=cssKeyLastCreationTime, ciscoSecureShellMIBObjects=ciscoSecureShellMIBObjects, cssConfigurationGroupRev1=cssConfigurationGroupRev1, cssSessionID=cssSessionID, cssKeyGenerationStatus=cssKeyGenerationStatus, ciscoSecureShellMIBComplianceRv2=ciscoSecureShellMIBComplianceRv2, ciscoSecureShellMIBComplianceRv3=ciscoSecureShellMIBComplianceRv3, cssSessionUserID=cssSessionUserID, cssSessionState=cssSessionState, ciscoSecureShellMIBConformance=ciscoSecureShellMIBConformance, ciscoSecureShellMIBComplianceRv1=ciscoSecureShellMIBComplianceRv1, cssSessionEntry=cssSessionEntry)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ValueRangeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ValueSizeConstraint') (cisco_mgmt,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoMgmt') (inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddress', 'InetAddressType') (snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') (module_compliance, notification_group, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup', 'ObjectGroup') (module_identity, ip_address, iso, integer32, unsigned32, mib_identifier, notification_type, bits, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, object_identity, time_ticks, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'ModuleIdentity', 'IpAddress', 'iso', 'Integer32', 'Unsigned32', 'MibIdentifier', 'NotificationType', 'Bits', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'ObjectIdentity', 'TimeTicks', 'Counter32') (textual_convention, row_status, truth_value, display_string, time_stamp) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'RowStatus', 'TruthValue', 'DisplayString', 'TimeStamp') cisco_secure_shell_mib = module_identity((1, 3, 6, 1, 4, 1, 9, 9, 339)) ciscoSecureShellMIB.setRevisions(('2005-06-01 00:00', '2004-04-05 00:00', '2003-09-18 00:00', '2002-10-05 00:00')) if mibBuilder.loadTexts: ciscoSecureShellMIB.setLastUpdated('200506010000Z') if mibBuilder.loadTexts: ciscoSecureShellMIB.setOrganization('Cisco Systems, Inc.') cisco_secure_shell_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1)) css_configuration = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1)) css_session_info = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2)) class Cssversions(TextualConvention, Bits): status = 'current' named_values = named_values(('v1', 0), ('v2', 1)) css_service_activation = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 1), truth_value().clone('false')).setMaxAccess('readwrite') if mibBuilder.loadTexts: cssServiceActivation.setStatus('current') css_key_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2)) if mibBuilder.loadTexts: cssKeyTable.setStatus('current') css_key_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1)).setIndexNames((0, 'CISCO-SECURE-SHELL-MIB', 'cssKeyIndex')) if mibBuilder.loadTexts: cssKeyEntry.setStatus('current') css_key_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('rsa', 1), ('rsa1', 2), ('dsa', 3)))) if mibBuilder.loadTexts: cssKeyIndex.setStatus('current') css_key_n_bits = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(512, 2048))).setMaxAccess('readcreate') if mibBuilder.loadTexts: cssKeyNBits.setStatus('current') css_key_over_write = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 3), truth_value()).setMaxAccess('readcreate') if mibBuilder.loadTexts: cssKeyOverWrite.setStatus('current') css_key_last_creation_time = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 4), time_stamp()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssKeyLastCreationTime.setStatus('current') css_key_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 5), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: cssKeyRowStatus.setStatus('current') css_key_string = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 2, 1, 6), display_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readonly') if mibBuilder.loadTexts: cssKeyString.setStatus('current') css_service_capability = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 3), css_versions()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssServiceCapability.setStatus('current') css_service_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 4), css_versions()).setMaxAccess('readwrite') if mibBuilder.loadTexts: cssServiceMode.setStatus('current') css_key_generation_status = mib_scalar((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inProgress', 1), ('successful', 2), ('failed', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: cssKeyGenerationStatus.setStatus('current') css_session_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1)) if mibBuilder.loadTexts: cssSessionTable.setStatus('current') css_session_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1)).setIndexNames((0, 'CISCO-SECURE-SHELL-MIB', 'cssSessionID')) if mibBuilder.loadTexts: cssSessionEntry.setStatus('current') css_session_id = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 1), unsigned32()) if mibBuilder.loadTexts: cssSessionID.setStatus('current') css_session_version = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('one', 1), ('two', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionVersion.setStatus('current') css_session_state = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7))).clone(namedValues=named_values(('sshSessionVersionOk', 1), ('sshSessionKeysExchanged', 2), ('sshSessionAuthenticated', 3), ('sshSessionOpen', 4), ('sshSessionDisconnecting', 5), ('sshSessionDisconnected', 6), ('sshSessionClosed', 7)))).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionState.setStatus('current') css_session_pid = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 4), unsigned32()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionPID.setStatus('current') css_session_user_id = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 5), snmp_admin_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionUserID.setStatus('current') css_session_host_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 6), inet_address_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionHostAddrType.setStatus('current') css_session_host_addr = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 339, 1, 2, 1, 1, 7), inet_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: cssSessionHostAddr.setStatus('current') cisco_secure_shell_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2)) cisco_secure_shell_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1)) cisco_secure_shell_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2)) cisco_secure_shell_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 1)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssConfigurationGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_secure_shell_mib_compliance = ciscoSecureShellMIBCompliance.setStatus('deprecated') cisco_secure_shell_mib_compliance_rv1 = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 2)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssConfigurationGroupRev1')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_secure_shell_mib_compliance_rv1 = ciscoSecureShellMIBComplianceRv1.setStatus('deprecated') cisco_secure_shell_mib_compliance_rv2 = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 3)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssConfigurationGroupRev1')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_secure_shell_mib_compliance_rv2 = ciscoSecureShellMIBComplianceRv2.setStatus('deprecated') cisco_secure_shell_mib_compliance_rv3 = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 1, 4)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssConfigurationGroupRev1'), ('CISCO-SECURE-SHELL-MIB', 'cssConfigurationGroupSupp1')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): cisco_secure_shell_mib_compliance_rv3 = ciscoSecureShellMIBComplianceRv3.setStatus('current') css_configuration_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 1)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssServiceActivation'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyNBits'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyOverWrite'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyLastCreationTime'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): css_configuration_group = cssConfigurationGroup.setStatus('deprecated') css_configuration_group_rev1 = object_group((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 2)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssServiceActivation'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyNBits'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyOverWrite'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyLastCreationTime'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyString'), ('CISCO-SECURE-SHELL-MIB', 'cssKeyRowStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): css_configuration_group_rev1 = cssConfigurationGroupRev1.setStatus('current') css_service_mode_cfg_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 3)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssServiceCapability'), ('CISCO-SECURE-SHELL-MIB', 'cssServiceMode')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): css_service_mode_cfg_group = cssServiceModeCfgGroup.setStatus('current') css_session_info_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 4)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssSessionVersion'), ('CISCO-SECURE-SHELL-MIB', 'cssSessionState'), ('CISCO-SECURE-SHELL-MIB', 'cssSessionPID'), ('CISCO-SECURE-SHELL-MIB', 'cssSessionUserID'), ('CISCO-SECURE-SHELL-MIB', 'cssSessionHostAddrType'), ('CISCO-SECURE-SHELL-MIB', 'cssSessionHostAddr')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): css_session_info_group = cssSessionInfoGroup.setStatus('current') css_configuration_group_supp1 = object_group((1, 3, 6, 1, 4, 1, 9, 9, 339, 2, 2, 5)).setObjects(('CISCO-SECURE-SHELL-MIB', 'cssKeyGenerationStatus')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): css_configuration_group_supp1 = cssConfigurationGroupSupp1.setStatus('current') mibBuilder.exportSymbols('CISCO-SECURE-SHELL-MIB', cssSessionTable=cssSessionTable, cssSessionInfoGroup=cssSessionInfoGroup, cssKeyIndex=cssKeyIndex, cssSessionPID=cssSessionPID, CssVersions=CssVersions, cssSessionInfo=cssSessionInfo, cssConfigurationGroup=cssConfigurationGroup, cssKeyRowStatus=cssKeyRowStatus, ciscoSecureShellMIB=ciscoSecureShellMIB, cssKeyNBits=cssKeyNBits, cssServiceMode=cssServiceMode, cssConfiguration=cssConfiguration, cssSessionHostAddr=cssSessionHostAddr, cssKeyOverWrite=cssKeyOverWrite, ciscoSecureShellMIBGroups=ciscoSecureShellMIBGroups, ciscoSecureShellMIBCompliances=ciscoSecureShellMIBCompliances, PYSNMP_MODULE_ID=ciscoSecureShellMIB, cssServiceCapability=cssServiceCapability, cssKeyTable=cssKeyTable, cssServiceModeCfgGroup=cssServiceModeCfgGroup, cssSessionVersion=cssSessionVersion, cssServiceActivation=cssServiceActivation, cssConfigurationGroupSupp1=cssConfigurationGroupSupp1, ciscoSecureShellMIBCompliance=ciscoSecureShellMIBCompliance, cssKeyEntry=cssKeyEntry, cssSessionHostAddrType=cssSessionHostAddrType, cssKeyString=cssKeyString, cssKeyLastCreationTime=cssKeyLastCreationTime, ciscoSecureShellMIBObjects=ciscoSecureShellMIBObjects, cssConfigurationGroupRev1=cssConfigurationGroupRev1, cssSessionID=cssSessionID, cssKeyGenerationStatus=cssKeyGenerationStatus, ciscoSecureShellMIBComplianceRv2=ciscoSecureShellMIBComplianceRv2, ciscoSecureShellMIBComplianceRv3=ciscoSecureShellMIBComplianceRv3, cssSessionUserID=cssSessionUserID, cssSessionState=cssSessionState, ciscoSecureShellMIBConformance=ciscoSecureShellMIBConformance, ciscoSecureShellMIBComplianceRv1=ciscoSecureShellMIBComplianceRv1, cssSessionEntry=cssSessionEntry)
number = int(input("ingrese el numero de filas de su triangulo ")) def print_triangle(number): for i in range(1, number + 1): print(str(i) * i) print_triangle(number)
number = int(input('ingrese el numero de filas de su triangulo ')) def print_triangle(number): for i in range(1, number + 1): print(str(i) * i) print_triangle(number)
def change(n): if (n < 0): return 999 if (n == 0): return 0 best = 999 coins = [200, 100, 50, 20, 10, 5, 2, 1] for x in coins: best = min(best, change(n-x)+1) return best t = 0 n = int(input()) while n != -1: t += n n = int(input()) t %= 60 print(change(t))
def change(n): if n < 0: return 999 if n == 0: return 0 best = 999 coins = [200, 100, 50, 20, 10, 5, 2, 1] for x in coins: best = min(best, change(n - x) + 1) return best t = 0 n = int(input()) while n != -1: t += n n = int(input()) t %= 60 print(change(t))
tb = 0 lr = 0 for i in range(int(input())): n = list(input()) for i in range(len(n)): if int(n[i]) == 0: if i == 0 or i == 1: tb += 1 if i == 2 or i == 3: lr += 1 print(min(tb // 2, lr // 2), tb - min(tb // 2, lr // 2) * 2, lr - min(tb // 2, lr // 2) * 2)
tb = 0 lr = 0 for i in range(int(input())): n = list(input()) for i in range(len(n)): if int(n[i]) == 0: if i == 0 or i == 1: tb += 1 if i == 2 or i == 3: lr += 1 print(min(tb // 2, lr // 2), tb - min(tb // 2, lr // 2) * 2, lr - min(tb // 2, lr // 2) * 2)
#!/usr/bin/python # -*- coding: UTF-8 -*- proxy_web_list = { "http://www.kuaidaili.com/free/inha/", "http://www.kuaidaili.com/free/outha/", "http://ip84.com/dlgn/", "http://ip84.com/gwgn/", "http://www.xicidaili.com/wn/", "http://www.xicidaili.com/nn/", "http://www.ip3366.net/free/?stype=1&page=", "http://www.ip3366.net/free/?stype=3&page=", "http://www.mimiip.com/gngao/", "http://www.mimiip.com/hw/", "http://www.xsdaili.com/index.php?s=/index/mfdl/p/", "http://www.xsdaili.com/index.php?s=/index/mfdl/type/3/p/" } header_pc = { 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11', 'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)' } proxy_web_loop_number = 5 thread_number = 10 db = 'proxylist.db'
proxy_web_list = {'http://www.kuaidaili.com/free/inha/', 'http://www.kuaidaili.com/free/outha/', 'http://ip84.com/dlgn/', 'http://ip84.com/gwgn/', 'http://www.xicidaili.com/wn/', 'http://www.xicidaili.com/nn/', 'http://www.ip3366.net/free/?stype=1&page=', 'http://www.ip3366.net/free/?stype=3&page=', 'http://www.mimiip.com/gngao/', 'http://www.mimiip.com/hw/', 'http://www.xsdaili.com/index.php?s=/index/mfdl/p/', 'http://www.xsdaili.com/index.php?s=/index/mfdl/type/3/p/'} header_pc = {'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11', 'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)'} proxy_web_loop_number = 5 thread_number = 10 db = 'proxylist.db'
REWARDS = { 'star': 1, 'first_quest': 25, 'quest_of_the_day': 5, 'archived_quest': 1, 'personal_share': 3, 'streak_3': 3, 'streak_10': 10, 'streak_100': 100, } ONBOARDING_QUEST_ID = 926 COMMENTS_PER_PAGE = 150 WHITELIST_COMMENTS_PER_PAGE = 100
rewards = {'star': 1, 'first_quest': 25, 'quest_of_the_day': 5, 'archived_quest': 1, 'personal_share': 3, 'streak_3': 3, 'streak_10': 10, 'streak_100': 100} onboarding_quest_id = 926 comments_per_page = 150 whitelist_comments_per_page = 100