content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
""" 3047 : ABC URL : https://www.acmicpc.net/problem/3047 Input : 1 5 3 ABC Output : 1 3 5 """ a = list(sorted(map(int, input().split()))) order = input() b = [] for o in order: b.append(a[ord(o) - ord('A')]) print(' '.join(str(c) for c in b))
""" 3047 : ABC URL : https://www.acmicpc.net/problem/3047 Input : 1 5 3 ABC Output : 1 3 5 """ a = list(sorted(map(int, input().split()))) order = input() b = [] for o in order: b.append(a[ord(o) - ord('A')]) print(' '.join((str(c) for c in b)))
class Solution: def checkSubarraySum(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ sums = [0] s = 0 for num in nums: s += num sums.append(s) for i in range(len(sums)): for j in range(i + 2, len(sums)): r = (sums[j] - sums[i]) if k != 0 and r % k == 0 or k == 0 and r == 0: return True return False if __name__ == "__main__": print(Solution().checkSubarraySum([23, 2, 4, 6, 7], 6)) print(Solution().checkSubarraySum([23, 4, 2, 6, 7], 6)) print(Solution().checkSubarraySum([0, 0], 0))
class Solution: def check_subarray_sum(self, nums, k): """ :type nums: List[int] :type k: int :rtype: bool """ sums = [0] s = 0 for num in nums: s += num sums.append(s) for i in range(len(sums)): for j in range(i + 2, len(sums)): r = sums[j] - sums[i] if k != 0 and r % k == 0 or (k == 0 and r == 0): return True return False if __name__ == '__main__': print(solution().checkSubarraySum([23, 2, 4, 6, 7], 6)) print(solution().checkSubarraySum([23, 4, 2, 6, 7], 6)) print(solution().checkSubarraySum([0, 0], 0))
'''Defines data and parameters in an easily resuable format.''' # Common sequence alphabets. ALPHABETS = { 'dna': 'ATGCNatgcn-', 'rna': 'AUGCNaugcn', 'peptide': 'ACDEFGHIKLMNPQRSTVWYXacdefghiklmnpqrstvwyx'} COMPLEMENTS = { 'dna': {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 't', 't': 'a', 'g': 'c', 'c': 'g', 'n': 'n', '-': '-'}, 'rna': {'A': 'U', 'U': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 'u', 'u': 'a', 'g': 'c', 'c': 'g', 'n': 'n'}} # The standard codon table. CODON_TABLE = { 'A': ['GCG', 'GCA', 'GCU', 'GCC'], 'R': ['AGG', 'AGA', 'CGG', 'CGA', 'CGU', 'CGC'], 'N': ['AAU', 'AAC'], 'D': ['GAU', 'GAC'], 'C': ['UGU', 'UGC'], '*': ['UGA', 'UAG', 'UAA'], 'Q': ['CAG', 'CAA'], 'E': ['GAG', 'GAA'], 'G': ['GGG', 'GGA', 'GGU', 'GGC'], 'H': ['CAU', 'CAC'], 'I': ['AUA', 'AUU', 'AUC'], 'L': ['UUG', 'UUA', 'CUG', 'CUA', 'CUU', 'CUC'], 'K': ['AAG', 'AAA'], 'M': ['AUG'], 'F': ['UUU', 'UUC'], 'P': ['CCG', 'CCA', 'CCU', 'CCC'], 'S': ['AGU', 'AGC', 'UCG', 'UCA', 'UCU', 'UCC'], 'T': ['ACG', 'ACA', 'ACU', 'ACC'], 'W': ['UGG'], 'Y': ['UAU', 'UAC'], 'V': ['GUG', 'GUA', 'GUU', 'GUC']} # Saccharomyces cerevisiae # source: http://www.kazusa.or.jp/codon/ # (which cites GenBank, i.e. yeast genome project CDS database) CODON_FREQ = { 'sc': { 'GCG': 0.109972396541529, 'GCA': 0.288596474496094, 'GCU': 0.377014739102356, 'GCC': 0.224416389860021, 'AGG': 0.208564104515562, 'AGA': 0.481137590939125, 'CGG': 0.0392677130215486, 'CGA': 0.0676728924436203, 'CGU': 0.144572019635586, 'CGC': 0.0587856794445578, 'AAU': 0.589705127199784, 'AAC': 0.410294872800217, 'GAU': 0.65037901553924, 'GAC': 0.34962098446076, 'UGU': 0.629812614586062, 'UGC': 0.370187385413938, 'UGA': 0.303094329334787, 'UAG': 0.225736095965104, 'UAA': 0.471169574700109, 'CAG': 0.307418833439535, 'CAA': 0.692581166560465, 'GAG': 0.296739610207218, 'GAA': 0.703260389792782, 'GGG': 0.119057918187951, 'GGA': 0.215422869017838, 'GGU': 0.472217600813099, 'GGC': 0.193301611981112, 'CAU': 0.636710255236351, 'CAC': 0.363289744763649, 'AUA': 0.273331091899568, 'AUU': 0.462925823433014, 'AUC': 0.263743084667417, 'UUG': 0.286319859527146, 'UUA': 0.275534472444779, 'CUG': 0.110440170850593, 'CUA': 0.141277445174148, 'CUU': 0.129115062940288, 'CUC': 0.0573129890630467, 'AAG': 0.423936637198697, 'AAA': 0.576063362801303, 'AUG': 1, 'UUU': 0.586126603840976, 'UUC': 0.413873396159024, 'CCG': 0.120626895854398, 'CCA': 0.417143753704543, 'CCU': 0.307740315888567, 'CCC': 0.154489034552491, 'AGU': 0.159245398699046, 'AGC': 0.109749229743856, 'UCG': 0.0963590866114069, 'UCA': 0.210157220085731, 'UCU': 0.264456618519558, 'UCC': 0.160032446340401, 'ACG': 0.135583991997041, 'ACA': 0.302413913478422, 'ACU': 0.345237040780705, 'ACC': 0.216765053743832, 'UGG': 1, 'UAU': 0.559573963633711, 'UAC': 0.440426036366289, 'GUG': 0.190897642582249, 'GUA': 0.208783185960798, 'GUU': 0.391481704636128, 'GUC': 0.208837466820824}} # Codon usage organized by organism, then amino acid CODON_FREQ_BY_AA = { 'sc': { 'A': {'GCG': 0.109972396541529, 'GCA': 0.288596474496094, 'GCU': 0.377014739102356, 'GCC': 0.224416389860021}, 'R': {'AGG': 0.208564104515562, 'AGA': 0.481137590939125, 'CGG': 0.0392677130215486, 'CGA': 0.0676728924436203, 'CGU': 0.144572019635586, 'CGC': 0.0587856794445578}, 'N': {'AAU': 0.589705127199784, 'AAC': 0.410294872800217}, 'D': {'GAU': 0.65037901553924, 'GAC': 0.34962098446076}, 'C': {'UGU': 0.629812614586062, 'UGC': 0.370187385413938}, '*': {'UGA': 0.303094329334787, 'UAG': 0.225736095965104, 'UAA': 0.471169574700109}, 'Q': {'CAG': 0.307418833439535, 'CAA': 0.692581166560465}, 'E': {'GAG': 0.296739610207218, 'GAA': 0.703260389792782}, 'G': {'GGG': 0.119057918187951, 'GGA': 0.215422869017838, 'GGU': 0.472217600813099, 'GGC': 0.193301611981112}, 'H': {'CAU': 0.636710255236351, 'CAC': 0.363289744763649}, 'I': {'AUA': 0.273331091899568, 'AUU': 0.462925823433014, 'AUC': 0.263743084667417}, 'L': {'UUG': 0.286319859527146, 'UUA': 0.275534472444779, 'CUG': 0.110440170850593, 'CUA': 0.141277445174148, 'CUU': 0.129115062940288, 'CUC': 0.0573129890630467}, 'K': {'AAG': 0.423936637198697, 'AAA': 0.576063362801303}, 'M': {'AUG': 1}, 'F': {'UUU': 0.586126603840976, 'UUC': 0.413873396159024}, 'P': {'CCG': 0.120626895854398, 'CCA': 0.417143753704543, 'CCU': 0.307740315888567, 'CCC': 0.154489034552491}, 'S': {'AGU': 0.159245398699046, 'AGC': 0.109749229743856, 'UCG': 0.0963590866114069, 'UCA': 0.210157220085731, 'UCU': 0.264456618519558, 'UCC': 0.160032446340401}, 'T': {'ACG': 0.135583991997041, 'ACA': 0.302413913478422, 'ACU': 0.345237040780705, 'ACC': 0.216765053743832}, 'W': {'UGG': 1}, 'Y': {'UAU': 0.559573963633711, 'UAC': 0.440426036366289}, 'V': {'GUG': 0.190897642582249, 'GUA': 0.208783185960798, 'GUU': 0.391481704636128, 'GUC': 0.208837466820824}}} # Complete list of codons. CODONS = {'AAA': 'K', 'AAC': 'N', 'AAG': 'K', 'AAU': 'N', 'ACA': 'T', 'ACC': 'T', 'ACG': 'T', 'ACU': 'T', 'AGA': 'R', 'AGC': 'S', 'AGG': 'R', 'AGU': 'S', 'AUA': 'I', 'AUC': 'I', 'AUG': 'M', 'AUU': 'I', 'CAA': 'Q', 'CAC': 'H', 'CAG': 'Q', 'CAU': 'H', 'CCA': 'P', 'CCC': 'P', 'CCG': 'P', 'CCU': 'P', 'CGA': 'R', 'CGC': 'R', 'CGG': 'R', 'CGU': 'R', 'CUA': 'L', 'CUC': 'L', 'CUG': 'L', 'CUU': 'L', 'GAA': 'E', 'GAC': 'D', 'GAG': 'E', 'GAU': 'D', 'GCA': 'A', 'GCC': 'A', 'GCG': 'A', 'GCU': 'A', 'GGA': 'G', 'GGC': 'G', 'GGG': 'G', 'GGU': 'G', 'GUA': 'V', 'GUC': 'V', 'GUG': 'V', 'GUU': 'V', 'UAA': '*', 'UAC': 'Y', 'UAG': '*', 'UAU': 'Y', 'UCA': 'S', 'UCC': 'S', 'UCG': 'S', 'UCU': 'S', 'UGA': '*', 'UGC': 'C', 'UGG': 'W', 'UGU': 'C', 'UUA': 'L', 'UUC': 'F', 'UUG': 'L', 'UUU': 'F'}
"""Defines data and parameters in an easily resuable format.""" alphabets = {'dna': 'ATGCNatgcn-', 'rna': 'AUGCNaugcn', 'peptide': 'ACDEFGHIKLMNPQRSTVWYXacdefghiklmnpqrstvwyx'} complements = {'dna': {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 't', 't': 'a', 'g': 'c', 'c': 'g', 'n': 'n', '-': '-'}, 'rna': {'A': 'U', 'U': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 'u', 'u': 'a', 'g': 'c', 'c': 'g', 'n': 'n'}} codon_table = {'A': ['GCG', 'GCA', 'GCU', 'GCC'], 'R': ['AGG', 'AGA', 'CGG', 'CGA', 'CGU', 'CGC'], 'N': ['AAU', 'AAC'], 'D': ['GAU', 'GAC'], 'C': ['UGU', 'UGC'], '*': ['UGA', 'UAG', 'UAA'], 'Q': ['CAG', 'CAA'], 'E': ['GAG', 'GAA'], 'G': ['GGG', 'GGA', 'GGU', 'GGC'], 'H': ['CAU', 'CAC'], 'I': ['AUA', 'AUU', 'AUC'], 'L': ['UUG', 'UUA', 'CUG', 'CUA', 'CUU', 'CUC'], 'K': ['AAG', 'AAA'], 'M': ['AUG'], 'F': ['UUU', 'UUC'], 'P': ['CCG', 'CCA', 'CCU', 'CCC'], 'S': ['AGU', 'AGC', 'UCG', 'UCA', 'UCU', 'UCC'], 'T': ['ACG', 'ACA', 'ACU', 'ACC'], 'W': ['UGG'], 'Y': ['UAU', 'UAC'], 'V': ['GUG', 'GUA', 'GUU', 'GUC']} codon_freq = {'sc': {'GCG': 0.109972396541529, 'GCA': 0.288596474496094, 'GCU': 0.377014739102356, 'GCC': 0.224416389860021, 'AGG': 0.208564104515562, 'AGA': 0.481137590939125, 'CGG': 0.0392677130215486, 'CGA': 0.0676728924436203, 'CGU': 0.144572019635586, 'CGC': 0.0587856794445578, 'AAU': 0.589705127199784, 'AAC': 0.410294872800217, 'GAU': 0.65037901553924, 'GAC': 0.34962098446076, 'UGU': 0.629812614586062, 'UGC': 0.370187385413938, 'UGA': 0.303094329334787, 'UAG': 0.225736095965104, 'UAA': 0.471169574700109, 'CAG': 0.307418833439535, 'CAA': 0.692581166560465, 'GAG': 0.296739610207218, 'GAA': 0.703260389792782, 'GGG': 0.119057918187951, 'GGA': 0.215422869017838, 'GGU': 0.472217600813099, 'GGC': 0.193301611981112, 'CAU': 0.636710255236351, 'CAC': 0.363289744763649, 'AUA': 0.273331091899568, 'AUU': 0.462925823433014, 'AUC': 0.263743084667417, 'UUG': 0.286319859527146, 'UUA': 0.275534472444779, 'CUG': 0.110440170850593, 'CUA': 0.141277445174148, 'CUU': 0.129115062940288, 'CUC': 0.0573129890630467, 'AAG': 0.423936637198697, 'AAA': 0.576063362801303, 'AUG': 1, 'UUU': 0.586126603840976, 'UUC': 0.413873396159024, 'CCG': 0.120626895854398, 'CCA': 0.417143753704543, 'CCU': 0.307740315888567, 'CCC': 0.154489034552491, 'AGU': 0.159245398699046, 'AGC': 0.109749229743856, 'UCG': 0.0963590866114069, 'UCA': 0.210157220085731, 'UCU': 0.264456618519558, 'UCC': 0.160032446340401, 'ACG': 0.135583991997041, 'ACA': 0.302413913478422, 'ACU': 0.345237040780705, 'ACC': 0.216765053743832, 'UGG': 1, 'UAU': 0.559573963633711, 'UAC': 0.440426036366289, 'GUG': 0.190897642582249, 'GUA': 0.208783185960798, 'GUU': 0.391481704636128, 'GUC': 0.208837466820824}} codon_freq_by_aa = {'sc': {'A': {'GCG': 0.109972396541529, 'GCA': 0.288596474496094, 'GCU': 0.377014739102356, 'GCC': 0.224416389860021}, 'R': {'AGG': 0.208564104515562, 'AGA': 0.481137590939125, 'CGG': 0.0392677130215486, 'CGA': 0.0676728924436203, 'CGU': 0.144572019635586, 'CGC': 0.0587856794445578}, 'N': {'AAU': 0.589705127199784, 'AAC': 0.410294872800217}, 'D': {'GAU': 0.65037901553924, 'GAC': 0.34962098446076}, 'C': {'UGU': 0.629812614586062, 'UGC': 0.370187385413938}, '*': {'UGA': 0.303094329334787, 'UAG': 0.225736095965104, 'UAA': 0.471169574700109}, 'Q': {'CAG': 0.307418833439535, 'CAA': 0.692581166560465}, 'E': {'GAG': 0.296739610207218, 'GAA': 0.703260389792782}, 'G': {'GGG': 0.119057918187951, 'GGA': 0.215422869017838, 'GGU': 0.472217600813099, 'GGC': 0.193301611981112}, 'H': {'CAU': 0.636710255236351, 'CAC': 0.363289744763649}, 'I': {'AUA': 0.273331091899568, 'AUU': 0.462925823433014, 'AUC': 0.263743084667417}, 'L': {'UUG': 0.286319859527146, 'UUA': 0.275534472444779, 'CUG': 0.110440170850593, 'CUA': 0.141277445174148, 'CUU': 0.129115062940288, 'CUC': 0.0573129890630467}, 'K': {'AAG': 0.423936637198697, 'AAA': 0.576063362801303}, 'M': {'AUG': 1}, 'F': {'UUU': 0.586126603840976, 'UUC': 0.413873396159024}, 'P': {'CCG': 0.120626895854398, 'CCA': 0.417143753704543, 'CCU': 0.307740315888567, 'CCC': 0.154489034552491}, 'S': {'AGU': 0.159245398699046, 'AGC': 0.109749229743856, 'UCG': 0.0963590866114069, 'UCA': 0.210157220085731, 'UCU': 0.264456618519558, 'UCC': 0.160032446340401}, 'T': {'ACG': 0.135583991997041, 'ACA': 0.302413913478422, 'ACU': 0.345237040780705, 'ACC': 0.216765053743832}, 'W': {'UGG': 1}, 'Y': {'UAU': 0.559573963633711, 'UAC': 0.440426036366289}, 'V': {'GUG': 0.190897642582249, 'GUA': 0.208783185960798, 'GUU': 0.391481704636128, 'GUC': 0.208837466820824}}} codons = {'AAA': 'K', 'AAC': 'N', 'AAG': 'K', 'AAU': 'N', 'ACA': 'T', 'ACC': 'T', 'ACG': 'T', 'ACU': 'T', 'AGA': 'R', 'AGC': 'S', 'AGG': 'R', 'AGU': 'S', 'AUA': 'I', 'AUC': 'I', 'AUG': 'M', 'AUU': 'I', 'CAA': 'Q', 'CAC': 'H', 'CAG': 'Q', 'CAU': 'H', 'CCA': 'P', 'CCC': 'P', 'CCG': 'P', 'CCU': 'P', 'CGA': 'R', 'CGC': 'R', 'CGG': 'R', 'CGU': 'R', 'CUA': 'L', 'CUC': 'L', 'CUG': 'L', 'CUU': 'L', 'GAA': 'E', 'GAC': 'D', 'GAG': 'E', 'GAU': 'D', 'GCA': 'A', 'GCC': 'A', 'GCG': 'A', 'GCU': 'A', 'GGA': 'G', 'GGC': 'G', 'GGG': 'G', 'GGU': 'G', 'GUA': 'V', 'GUC': 'V', 'GUG': 'V', 'GUU': 'V', 'UAA': '*', 'UAC': 'Y', 'UAG': '*', 'UAU': 'Y', 'UCA': 'S', 'UCC': 'S', 'UCG': 'S', 'UCU': 'S', 'UGA': '*', 'UGC': 'C', 'UGG': 'W', 'UGU': 'C', 'UUA': 'L', 'UUC': 'F', 'UUG': 'L', 'UUU': 'F'}
# Created by MechAviv # White Heaven Sun Damage Skin | (2433828) if sm.addDamageSkin(2433828): sm.chat("'White Heaven Sun Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
if sm.addDamageSkin(2433828): sm.chat("'White Heaven Sun Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
def expose(board, x, y): if not board[y][x].flagged: board[y][x].exposed = True #debug print(x, y, sep='\t') if x == 0 or x == len(board[0]) - 1 or y == 0 or y == len(board) - 1 or board[y][x].mine: return 0 if board[y][x].neighbours == 0: if board[y-1][x-1].exposed is False: expose(board, x-1, y-1) if board[y-1][x].exposed is False: expose(board, x, y-1) if board[y-1][x+1].exposed is False: expose(board, x+1, y-1) if board[y][x-1].exposed is False: expose(board, x-1, y) if board[y][x+1].exposed is False: expose(board, x+1, y) if board[y+1][x-1].exposed is False: expose(board, x-1, y+1) if board[y+1][x].exposed is False: expose(board, x, y+1) if board[y+1][x+1].exposed is False: expose(board, x+1, y+1) return 0
def expose(board, x, y): if not board[y][x].flagged: board[y][x].exposed = True if x == 0 or x == len(board[0]) - 1 or y == 0 or (y == len(board) - 1) or board[y][x].mine: return 0 if board[y][x].neighbours == 0: if board[y - 1][x - 1].exposed is False: expose(board, x - 1, y - 1) if board[y - 1][x].exposed is False: expose(board, x, y - 1) if board[y - 1][x + 1].exposed is False: expose(board, x + 1, y - 1) if board[y][x - 1].exposed is False: expose(board, x - 1, y) if board[y][x + 1].exposed is False: expose(board, x + 1, y) if board[y + 1][x - 1].exposed is False: expose(board, x - 1, y + 1) if board[y + 1][x].exposed is False: expose(board, x, y + 1) if board[y + 1][x + 1].exposed is False: expose(board, x + 1, y + 1) return 0
number = 5 numbers = [1,2,3,4,5] # if statement if number == 5: print(number) if len(numbers) == 5: print(numbers[3]) if number in numbers: # if 3 in [1,2,3,4,5] print("3 is here") # elif and else statement if number == 3: print("is 3") elif number == 5: print("is 5") else: print("not 3 & 5")
number = 5 numbers = [1, 2, 3, 4, 5] if number == 5: print(number) if len(numbers) == 5: print(numbers[3]) if number in numbers: print('3 is here') if number == 3: print('is 3') elif number == 5: print('is 5') else: print('not 3 & 5')
memo = { 0: 0, 1: 1, 2: 1, } def fib(n): if n in memo: return memo[n] val = fib(n-1) + fib(n-2) memo[n] = val return val print(fib(35))
memo = {0: 0, 1: 1, 2: 1} def fib(n): if n in memo: return memo[n] val = fib(n - 1) + fib(n - 2) memo[n] = val return val print(fib(35))
class Screen(object): """ Represents a display device or multiple display devices on a single system. """ def Equals(self,obj): """ Equals(self: Screen,obj: object) -> bool Gets or sets a value indicating whether the specified object is equal to this Screen. obj: The object to compare to this System.Windows.Forms.Screen. Returns: true if the specified object is equal to this System.Windows.Forms.Screen; otherwise,false. """ pass @staticmethod def FromControl(control): """ FromControl(control: Control) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the specified control. control: A System.Windows.Forms.Control for which to retrieve a System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the specified control. In multiple display environments where no display contains the control,the display closest to the specified control is returned. """ pass @staticmethod def FromHandle(hwnd): """ FromHandle(hwnd: IntPtr) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the object referred to by the specified handle. hwnd: The window handle for which to retrieve the System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the object. In multiple display environments where no display contains any portion of the specified window,the display closest to the object is returned. """ pass @staticmethod def FromPoint(point): """ FromPoint(point: Point) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the specified point. point: A System.Drawing.Point that specifies the location for which to retrieve a System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the point. In multiple display environments where no display contains the point,the display closest to the specified point is returned. """ pass @staticmethod def FromRectangle(rect): """ FromRectangle(rect: Rectangle) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the rectangle. rect: A System.Drawing.Rectangle that specifies the area for which to retrieve the display. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the specified rectangle. In multiple display environments where no display contains the rectangle,the display closest to the rectangle is returned. """ pass @staticmethod def GetBounds(*__args): """ GetBounds(ctl: Control) -> Rectangle Retrieves the bounds of the display that contains the largest portion of the specified control. ctl: The System.Windows.Forms.Control for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified control. In multiple display environments where no display contains the specified control,the display closest to the control is returned. GetBounds(rect: Rectangle) -> Rectangle Retrieves the bounds of the display that contains the largest portion of the specified rectangle. rect: A System.Drawing.Rectangle that specifies the area for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified rectangle. In multiple display environments where no monitor contains the specified rectangle, the monitor closest to the rectangle is returned. GetBounds(pt: Point) -> Rectangle Retrieves the bounds of the display that contains the specified point. pt: A System.Drawing.Point that specifies the coordinates for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified point. In multiple display environments where no display contains the specified point,the display closest to the point is returned. """ pass def GetHashCode(self): """ GetHashCode(self: Screen) -> int Computes and retrieves a hash code for an object. Returns: A hash code for an object. """ pass @staticmethod def GetWorkingArea(*__args): """ GetWorkingArea(ctl: Control) -> Rectangle Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. ctl: The System.Windows.Forms.Control for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified control,the display closest to the control is returned. GetWorkingArea(rect: Rectangle) -> Rectangle Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. rect: The System.Drawing.Rectangle that specifies the area for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified rectangle,the display closest to the rectangle is returned. GetWorkingArea(pt: Point) -> Rectangle Retrieves the working area closest to the specified point. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. pt: A System.Drawing.Point that specifies the coordinates for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified point,the display closest to the point is returned. """ pass def ToString(self): """ ToString(self: Screen) -> str Retrieves a string representing this object. Returns: A string representation of the object. """ pass def __eq__(self,*args): """ x.__eq__(y) <==> x==y """ pass def __ne__(self,*args): pass BitsPerPixel=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the number of bits of memory,associated with one pixel of data. Get: BitsPerPixel(self: Screen) -> int """ Bounds=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the bounds of the display. Get: Bounds(self: Screen) -> Rectangle """ DeviceName=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the device name associated with a display. Get: DeviceName(self: Screen) -> str """ Primary=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets a value indicating whether a particular display is the primary device. Get: Primary(self: Screen) -> bool """ WorkingArea=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the working area of the display. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. Get: WorkingArea(self: Screen) -> Rectangle """ AllScreens=None PrimaryScreen=None
class Screen(object): """ Represents a display device or multiple display devices on a single system. """ def equals(self, obj): """ Equals(self: Screen,obj: object) -> bool Gets or sets a value indicating whether the specified object is equal to this Screen. obj: The object to compare to this System.Windows.Forms.Screen. Returns: true if the specified object is equal to this System.Windows.Forms.Screen; otherwise,false. """ pass @staticmethod def from_control(control): """ FromControl(control: Control) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the specified control. control: A System.Windows.Forms.Control for which to retrieve a System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the specified control. In multiple display environments where no display contains the control,the display closest to the specified control is returned. """ pass @staticmethod def from_handle(hwnd): """ FromHandle(hwnd: IntPtr) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the object referred to by the specified handle. hwnd: The window handle for which to retrieve the System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the object. In multiple display environments where no display contains any portion of the specified window,the display closest to the object is returned. """ pass @staticmethod def from_point(point): """ FromPoint(point: Point) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the specified point. point: A System.Drawing.Point that specifies the location for which to retrieve a System.Windows.Forms.Screen. Returns: A System.Windows.Forms.Screen for the display that contains the point. In multiple display environments where no display contains the point,the display closest to the specified point is returned. """ pass @staticmethod def from_rectangle(rect): """ FromRectangle(rect: Rectangle) -> Screen Retrieves a System.Windows.Forms.Screen for the display that contains the largest portion of the rectangle. rect: A System.Drawing.Rectangle that specifies the area for which to retrieve the display. Returns: A System.Windows.Forms.Screen for the display that contains the largest region of the specified rectangle. In multiple display environments where no display contains the rectangle,the display closest to the rectangle is returned. """ pass @staticmethod def get_bounds(*__args): """ GetBounds(ctl: Control) -> Rectangle Retrieves the bounds of the display that contains the largest portion of the specified control. ctl: The System.Windows.Forms.Control for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified control. In multiple display environments where no display contains the specified control,the display closest to the control is returned. GetBounds(rect: Rectangle) -> Rectangle Retrieves the bounds of the display that contains the largest portion of the specified rectangle. rect: A System.Drawing.Rectangle that specifies the area for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified rectangle. In multiple display environments where no monitor contains the specified rectangle, the monitor closest to the rectangle is returned. GetBounds(pt: Point) -> Rectangle Retrieves the bounds of the display that contains the specified point. pt: A System.Drawing.Point that specifies the coordinates for which to retrieve the display bounds. Returns: A System.Drawing.Rectangle that specifies the bounds of the display that contains the specified point. In multiple display environments where no display contains the specified point,the display closest to the point is returned. """ pass def get_hash_code(self): """ GetHashCode(self: Screen) -> int Computes and retrieves a hash code for an object. Returns: A hash code for an object. """ pass @staticmethod def get_working_area(*__args): """ GetWorkingArea(ctl: Control) -> Rectangle Retrieves the working area for the display that contains the largest region of the specified control. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. ctl: The System.Windows.Forms.Control for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified control,the display closest to the control is returned. GetWorkingArea(rect: Rectangle) -> Rectangle Retrieves the working area for the display that contains the largest portion of the specified rectangle. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. rect: The System.Drawing.Rectangle that specifies the area for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified rectangle,the display closest to the rectangle is returned. GetWorkingArea(pt: Point) -> Rectangle Retrieves the working area closest to the specified point. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars. pt: A System.Drawing.Point that specifies the coordinates for which to retrieve the working area. Returns: A System.Drawing.Rectangle that specifies the working area. In multiple display environments where no display contains the specified point,the display closest to the point is returned. """ pass def to_string(self): """ ToString(self: Screen) -> str Retrieves a string representing this object. Returns: A string representation of the object. """ pass def __eq__(self, *args): """ x.__eq__(y) <==> x==y """ pass def __ne__(self, *args): pass bits_per_pixel = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the number of bits of memory,associated with one pixel of data.\n\n\n\nGet: BitsPerPixel(self: Screen) -> int\n\n\n\n' bounds = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the bounds of the display.\n\n\n\nGet: Bounds(self: Screen) -> Rectangle\n\n\n\n' device_name = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the device name associated with a display.\n\n\n\nGet: DeviceName(self: Screen) -> str\n\n\n\n' primary = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets a value indicating whether a particular display is the primary device.\n\n\n\nGet: Primary(self: Screen) -> bool\n\n\n\n' working_area = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the working area of the display. The working area is the desktop area of the display,excluding taskbars,docked windows,and docked tool bars.\n\n\n\nGet: WorkingArea(self: Screen) -> Rectangle\n\n\n\n' all_screens = None primary_screen = None
# coding: utf-8 __version__ = '0.12.0'
__version__ = '0.12.0'
# -*- coding: utf-8 -*- # Caching # https://docs.djangoproject.com/en/3.2/topics/cache/ CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', }, 'staticfiles': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake', } }
caches = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake'}, 'staticfiles': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake'}}
x, a, b = map(int, input().split()) if b <= a: print('delicious') elif b - a <= x: print('safe') else: print('dangerous')
(x, a, b) = map(int, input().split()) if b <= a: print('delicious') elif b - a <= x: print('safe') else: print('dangerous')
class EvaluatorTestCases: expressions = [ ("1 2 + 2.5 * 2 5 SUM", 14.5, float, 3), ("1 2 3 SUM 4 5 SUM 6 7 SUM", sum(range(8)), int, 3), ("1 2 3 SUM 4 5 SUM 6 7 SUM 8.5 *", sum(range(8)) * 8.5, float, 4), ] not_ok = [ """ void test(){ int a; int b; a = int; b = int; int a /* scope violation*/ } """, """ void test(){ int a; int b; { int a; int b; { int c; int a; int q; int q; } } } """, """void a(){ }; void a(){ }""", """int i; i = str""", """int b; int b;""" ] ok = [ """ void test(){ int a; int b; a = int; b = int; } """, """ void test(){ int a; int b; a = int; b = int; { int a; int b; { int d; int e; } } } """, """str i; i = str""", """int b; int c;""" ]
class Evaluatortestcases: expressions = [('1 2 + 2.5 * 2 5 SUM', 14.5, float, 3), ('1 2 3 SUM 4 5 SUM 6 7 SUM', sum(range(8)), int, 3), ('1 2 3 SUM 4 5 SUM 6 7 SUM 8.5 *', sum(range(8)) * 8.5, float, 4)] not_ok = ['\n void test(){\n int a; int b; a = int; b = int; int a /* scope violation*/\n }\n ', '\n void test(){\n int a; int b; {\n int a; int b; {\n int c; int a;\n int q; int q;\n }\n }\n }\n ', 'void a(){ }; void a(){ }', 'int i; i = str', 'int b; int b;'] ok = ['\n void test(){\n int a; int b; a = int; b = int;\n }\n ', '\n void test(){\n int a; int b; a = int; b = int; {\n int a; int b; {\n int d; int e;\n }\n }\n }\n ', 'str i; i = str', 'int b; int c;']
class Args(object): def __init__(self): self.seed = 0 self.experiment = None self.network = None self.approach = None self.parameter = [] self.taskcla = None self.comment = None self.log_dir = None global args args = Args()
class Args(object): def __init__(self): self.seed = 0 self.experiment = None self.network = None self.approach = None self.parameter = [] self.taskcla = None self.comment = None self.log_dir = None global args args = args()
list1=[12,-7,5,64,-14] for num in list1: if num>=0: print(num,end=" ") list2=[12,14,-95,3] for num in list2: if num>=0: print(num,end=" ")
list1 = [12, -7, 5, 64, -14] for num in list1: if num >= 0: print(num, end=' ') list2 = [12, 14, -95, 3] for num in list2: if num >= 0: print(num, end=' ')
#Three character NHGIS codes to postal abbreviations state_codes = { '530':'WA', '100':'DE', '110':'DC', '550':'WI', '540':'WV', '150':'HI', '120':'FL', '560':'WY', '720':'PR', '340':'NJ', '350':'NM', '480':'TX', '220':'LA', '370':'NC', '380':'ND', '310':'NE', '470':'TN', '360':'NY', '420':'PA', '020':'AK', '320':'NV', '330':'NH', '510':'VA', '080':'CO', '060':'CA', '010':'AL', '050':'AR', '500':'VT', '170':'IL', '130':'GA', '180':'IN', '190':'IA', '250':'MA', '040':'AZ', '160':'ID', '090':'CT', '230':'ME', '240':'MD', '400':'OK', '390':'OH', '490':'UT', '290':'MO', '270':'MN', '260':'MI', '440':'RI', '200':'KS', '300':'MT', '280':'MS', '450':'SC', '210':'KY', '410':'OR', '460':'SD', '720':'PR' }
state_codes = {'530': 'WA', '100': 'DE', '110': 'DC', '550': 'WI', '540': 'WV', '150': 'HI', '120': 'FL', '560': 'WY', '720': 'PR', '340': 'NJ', '350': 'NM', '480': 'TX', '220': 'LA', '370': 'NC', '380': 'ND', '310': 'NE', '470': 'TN', '360': 'NY', '420': 'PA', '020': 'AK', '320': 'NV', '330': 'NH', '510': 'VA', '080': 'CO', '060': 'CA', '010': 'AL', '050': 'AR', '500': 'VT', '170': 'IL', '130': 'GA', '180': 'IN', '190': 'IA', '250': 'MA', '040': 'AZ', '160': 'ID', '090': 'CT', '230': 'ME', '240': 'MD', '400': 'OK', '390': 'OH', '490': 'UT', '290': 'MO', '270': 'MN', '260': 'MI', '440': 'RI', '200': 'KS', '300': 'MT', '280': 'MS', '450': 'SC', '210': 'KY', '410': 'OR', '460': 'SD', '720': 'PR'}
def uniquePaths(m: int, n: int) -> int: dp = [[0 for _ in range(m)] for _ in range(n)] for i in range(m): dp[0][i] = 1 for j in range(n): dp[j][0] = 1 for i in range(1, n): for j in range(1, m): dp[i][j] = dp[i - 1][j] + dp[i][j - 1] return dp[-1][-1] if __name__ == "__main__": print(uniquePaths(3, 7)) print(uniquePaths(3, 2)) print(uniquePaths(7, 3)) print(uniquePaths(3, 3))
def unique_paths(m: int, n: int) -> int: dp = [[0 for _ in range(m)] for _ in range(n)] for i in range(m): dp[0][i] = 1 for j in range(n): dp[j][0] = 1 for i in range(1, n): for j in range(1, m): dp[i][j] = dp[i - 1][j] + dp[i][j - 1] return dp[-1][-1] if __name__ == '__main__': print(unique_paths(3, 7)) print(unique_paths(3, 2)) print(unique_paths(7, 3)) print(unique_paths(3, 3))
if __name__ == "__main__": base_path = "/data4/dheeraj/hashtag/all/Twitter/" f_tweets = open(base_path + "train_post.txt", "r") f_tags = open(base_path + "train_tag.txt", "r") tweets = f_tweets.readlines() tags = f_tags.readlines() f_tags.close() f_tweets.close() tweets = tweets[:100] tags = tags[:100] final_tweets = [] final_tags = [] for i, tag in enumerate(tags): all_tags = tag.split(';') for t in all_tags: final_tweets.append(tweets[i]) final_tags.append(t.strip()) for i, tweet in enumerate(final_tweets): tag = final_tags[i] with open(base_path + "data/" + str(i) + ".txt", "w") as f: f.write(tweet.strip()) f.write("\n") f.write(tag.strip())
if __name__ == '__main__': base_path = '/data4/dheeraj/hashtag/all/Twitter/' f_tweets = open(base_path + 'train_post.txt', 'r') f_tags = open(base_path + 'train_tag.txt', 'r') tweets = f_tweets.readlines() tags = f_tags.readlines() f_tags.close() f_tweets.close() tweets = tweets[:100] tags = tags[:100] final_tweets = [] final_tags = [] for (i, tag) in enumerate(tags): all_tags = tag.split(';') for t in all_tags: final_tweets.append(tweets[i]) final_tags.append(t.strip()) for (i, tweet) in enumerate(final_tweets): tag = final_tags[i] with open(base_path + 'data/' + str(i) + '.txt', 'w') as f: f.write(tweet.strip()) f.write('\n') f.write(tag.strip())
# -*- coding: utf-8 -*- """Bandit directory containing multi-armed bandit implementations of BLA policies in python. **Files in this package** * :mod:`moe.bandit.bla.bla`: :class:`~moe.bandit.bla.bla.BLA` object for allocating bandit arms and choosing the winning arm based on BLA policy. """
"""Bandit directory containing multi-armed bandit implementations of BLA policies in python. **Files in this package** * :mod:`moe.bandit.bla.bla`: :class:`~moe.bandit.bla.bla.BLA` object for allocating bandit arms and choosing the winning arm based on BLA policy. """
# # PySNMP MIB module IPMROUTE-STD-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/IPMROUTE-STD-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:18:06 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52) # ( OctetString, Integer, ObjectIdentifier, ) = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") ( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ( ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection") ( IANAipMRouteProtocol, IANAipRouteProtocol, ) = mibBuilder.importSymbols("IANA-RTPROTO-MIB", "IANAipMRouteProtocol", "IANAipRouteProtocol") ( InterfaceIndexOrZero, InterfaceIndex, ) = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero", "InterfaceIndex") ( SnmpAdminString, ) = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString") ( ObjectGroup, ModuleCompliance, NotificationGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") ( mib_2, TimeTicks, ModuleIdentity, Integer32, Counter32, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Unsigned32, MibIdentifier, Gauge32, Counter64, Bits, NotificationType, IpAddress, ) = mibBuilder.importSymbols("SNMPv2-SMI", "mib-2", "TimeTicks", "ModuleIdentity", "Integer32", "Counter32", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Unsigned32", "MibIdentifier", "Gauge32", "Counter64", "Bits", "NotificationType", "IpAddress") ( RowStatus, DisplayString, TruthValue, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TruthValue", "TextualConvention") ipMRouteStdMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 83)).setRevisions(("2000-09-22 00:00",)) if mibBuilder.loadTexts: ipMRouteStdMIB.setLastUpdated('200009220000Z') if mibBuilder.loadTexts: ipMRouteStdMIB.setOrganization('IETF IDMR Working Group') if mibBuilder.loadTexts: ipMRouteStdMIB.setContactInfo(' Dave Thaler\n Microsoft Corporation\n One Microsoft Way\n Redmond, WA 98052-6399\n US\n\n Phone: +1 425 703 8835\n EMail: dthaler@microsoft.com') if mibBuilder.loadTexts: ipMRouteStdMIB.setDescription('The MIB module for management of IP Multicast routing, but\n independent of the specific multicast routing protocol in\n use.') class LanguageTag(OctetString, TextualConvention): displayHint = '100a' subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(1,100) ipMRouteMIBObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 83, 1)) ipMRoute = MibIdentifier((1, 3, 6, 1, 2, 1, 83, 1, 1)) ipMRouteEnable = MibScalar((1, 3, 6, 1, 2, 1, 83, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2,))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2),))).setMaxAccess("readwrite") if mibBuilder.loadTexts: ipMRouteEnable.setDescription('The enabled status of IP Multicast routing on this router.') ipMRouteEntryCount = MibScalar((1, 3, 6, 1, 2, 1, 83, 1, 1, 7), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteEntryCount.setDescription('The number of rows in the ipMRouteTable. This can be used\n to monitor the multicast routing table size.') ipMRouteTable = MibTable((1, 3, 6, 1, 2, 1, 83, 1, 1, 2), ) if mibBuilder.loadTexts: ipMRouteTable.setDescription('The (conceptual) table containing multicast routing\n information for IP datagrams sent by particular sources to\n the IP multicast groups known to this router.') ipMRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1), ).setIndexNames((0, "IPMROUTE-STD-MIB", "ipMRouteGroup"), (0, "IPMROUTE-STD-MIB", "ipMRouteSource"), (0, "IPMROUTE-STD-MIB", "ipMRouteSourceMask")) if mibBuilder.loadTexts: ipMRouteEntry.setDescription('An entry (conceptual row) containing the multicast routing\n information for IP datagrams from a particular source and\n addressed to a particular IP multicast group address.\n Discontinuities in counters in this entry can be detected by\n observing the value of ipMRouteUpTime.') ipMRouteGroup = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 1), IpAddress()) if mibBuilder.loadTexts: ipMRouteGroup.setDescription('The IP multicast group address for which this entry\n contains multicast routing information.') ipMRouteSource = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 2), IpAddress()) if mibBuilder.loadTexts: ipMRouteSource.setDescription('The network address which when combined with the\n corresponding value of ipMRouteSourceMask identifies the\n sources for which this entry contains multicast routing\n information.') ipMRouteSourceMask = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 3), IpAddress()) if mibBuilder.loadTexts: ipMRouteSourceMask.setDescription('The network mask which when combined with the corresponding\n value of ipMRouteSource identifies the sources for which\n this entry contains multicast routing information.') ipMRouteUpstreamNeighbor = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 4), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteUpstreamNeighbor.setDescription('The address of the upstream neighbor (e.g., RPF neighbor)\n from which IP datagrams from these sources to this multicast\n address are received, or 0.0.0.0 if the upstream neighbor is\n unknown (e.g., in CBT).') ipMRouteInIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 5), InterfaceIndexOrZero()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInIfIndex.setDescription('The value of ifIndex for the interface on which IP\n datagrams sent by these sources to this multicast address\n are received. A value of 0 indicates that datagrams are not\n subject to an incoming interface check, but may be accepted\n on multiple interfaces (e.g., in CBT).') ipMRouteUpTime = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 6), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteUpTime.setDescription('The time since the multicast routing information\n represented by this entry was learned by the router.') ipMRouteExpiryTime = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 7), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteExpiryTime.setDescription('The minimum amount of time remaining before this entry will\n be aged out. The value 0 indicates that the entry is not\n subject to aging.') ipMRoutePkts = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 8), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRoutePkts.setDescription('The number of packets which this router has received from\n these sources and addressed to this multicast group\n address.') ipMRouteDifferentInIfPackets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 9), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteDifferentInIfPackets.setDescription('The number of packets which this router has received from\n these sources and addressed to this multicast group address,\n which were dropped because they were not received on the\n interface indicated by ipMRouteInIfIndex. Packets which are\n not subject to an incoming interface check (e.g., using CBT)\n are not counted.') ipMRouteOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 10), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteOctets.setDescription('The number of octets contained in IP datagrams which were\n received from these sources and addressed to this multicast\n group address, and which were forwarded by this router.') ipMRouteProtocol = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 11), IANAipMRouteProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteProtocol.setDescription('The multicast routing protocol via which this multicast\n forwarding entry was learned.') ipMRouteRtProto = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 12), IANAipRouteProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteRtProto.setDescription('The routing mechanism via which the route used to find the\n upstream or parent interface for this multicast forwarding\n entry was learned. Inclusion of values for routing\n protocols is not intended to imply that those protocols need\n be supported.') ipMRouteRtAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 13), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteRtAddress.setDescription('The address portion of the route used to find the upstream\n or parent interface for this multicast forwarding entry.') ipMRouteRtMask = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 14), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteRtMask.setDescription('The mask associated with the route used to find the upstream\n or parent interface for this multicast forwarding entry.') ipMRouteRtType = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2,))).clone(namedValues=NamedValues(("unicast", 1), ("multicast", 2),))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteRtType.setDescription('The reason the given route was placed in the (logical)\n multicast Routing Information Base (RIB). A value of\n unicast means that the route would normally be placed only\n in the unicast RIB, but was placed in the multicast RIB\n (instead or in addition) due to local configuration, such as\n when running PIM over RIP. A value of multicast means that\n\n\n\n\n\n the route was explicitly added to the multicast RIB by the\n routing protocol, such as DVMRP or Multiprotocol BGP.') ipMRouteHCOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 16), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteHCOctets.setDescription('The number of octets contained in IP datagrams which were\n received from these sources and addressed to this multicast\n group address, and which were forwarded by this router.\n This object is a 64-bit version of ipMRouteOctets.') ipMRouteNextHopTable = MibTable((1, 3, 6, 1, 2, 1, 83, 1, 1, 3), ) if mibBuilder.loadTexts: ipMRouteNextHopTable.setDescription('The (conceptual) table containing information on the next-\n hops on outgoing interfaces for routing IP multicast\n datagrams. Each entry is one of a list of next-hops on\n outgoing interfaces for particular sources sending to a\n particular multicast group address.') ipMRouteNextHopEntry = MibTableRow((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1), ).setIndexNames((0, "IPMROUTE-STD-MIB", "ipMRouteNextHopGroup"), (0, "IPMROUTE-STD-MIB", "ipMRouteNextHopSource"), (0, "IPMROUTE-STD-MIB", "ipMRouteNextHopSourceMask"), (0, "IPMROUTE-STD-MIB", "ipMRouteNextHopIfIndex"), (0, "IPMROUTE-STD-MIB", "ipMRouteNextHopAddress")) if mibBuilder.loadTexts: ipMRouteNextHopEntry.setDescription('An entry (conceptual row) in the list of next-hops on\n outgoing interfaces to which IP multicast datagrams from\n particular sources to a IP multicast group address are\n routed. Discontinuities in counters in this entry can be\n detected by observing the value of ipMRouteUpTime.') ipMRouteNextHopGroup = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 1), IpAddress()) if mibBuilder.loadTexts: ipMRouteNextHopGroup.setDescription('The IP multicast group for which this entry specifies a\n next-hop on an outgoing interface.') ipMRouteNextHopSource = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 2), IpAddress()) if mibBuilder.loadTexts: ipMRouteNextHopSource.setDescription('The network address which when combined with the\n corresponding value of ipMRouteNextHopSourceMask identifies\n the sources for which this entry specifies a next-hop on an\n outgoing interface.') ipMRouteNextHopSourceMask = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 3), IpAddress()) if mibBuilder.loadTexts: ipMRouteNextHopSourceMask.setDescription('The network mask which when combined with the corresponding\n value of ipMRouteNextHopSource identifies the sources for\n which this entry specifies a next-hop on an outgoing\n interface.') ipMRouteNextHopIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 4), InterfaceIndex()) if mibBuilder.loadTexts: ipMRouteNextHopIfIndex.setDescription('The ifIndex value of the interface for the outgoing\n interface for this next-hop.') ipMRouteNextHopAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 5), IpAddress()) if mibBuilder.loadTexts: ipMRouteNextHopAddress.setDescription('The address of the next-hop specific to this entry. For\n most interfaces, this is identical to ipMRouteNextHopGroup.\n NBMA interfaces, however, may have multiple next-hop\n addresses out a single outgoing interface.') ipMRouteNextHopState = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2,))).clone(namedValues=NamedValues(("pruned", 1), ("forwarding", 2),))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopState.setDescription("An indication of whether the outgoing interface and next-\n hop represented by this entry is currently being used to\n forward IP datagrams. The value 'forwarding' indicates it\n is currently being used; the value 'pruned' indicates it is\n not.") ipMRouteNextHopUpTime = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 7), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopUpTime.setDescription('The time since the multicast routing information\n represented by this entry was learned by the router.') ipMRouteNextHopExpiryTime = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 8), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopExpiryTime.setDescription('The minimum amount of time remaining before this entry will\n be aged out. If ipMRouteNextHopState is pruned(1), the\n remaining time until the prune expires and the state reverts\n to forwarding(2). Otherwise, the remaining time until this\n entry is removed from the table. The time remaining may be\n copied from ipMRouteExpiryTime if the protocol in use for\n this entry does not specify next-hop timers. The value 0\n\n\n\n\n\n indicates that the entry is not subject to aging.') ipMRouteNextHopClosestMemberHops = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 9), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopClosestMemberHops.setDescription('The minimum number of hops between this router and any\n member of this IP multicast group reached via this next-hop\n on this outgoing interface. Any IP multicast datagrams for\n the group which have a TTL less than this number of hops\n will not be forwarded to this next-hop.') ipMRouteNextHopProtocol = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 10), IANAipMRouteProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopProtocol.setDescription('The routing mechanism via which this next-hop was learned.') ipMRouteNextHopPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 11), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteNextHopPkts.setDescription('The number of packets which have been forwarded using this\n route.') ipMRouteInterfaceTable = MibTable((1, 3, 6, 1, 2, 1, 83, 1, 1, 4), ) if mibBuilder.loadTexts: ipMRouteInterfaceTable.setDescription('The (conceptual) table containing multicast routing\n information specific to interfaces.') ipMRouteInterfaceEntry = MibTableRow((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1), ).setIndexNames((0, "IPMROUTE-STD-MIB", "ipMRouteInterfaceIfIndex")) if mibBuilder.loadTexts: ipMRouteInterfaceEntry.setDescription('An entry (conceptual row) containing the multicast routing\n information for a particular interface.') ipMRouteInterfaceIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: ipMRouteInterfaceIfIndex.setDescription('The ifIndex value of the interface for which this entry\n contains information.') ipMRouteInterfaceTtl = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: ipMRouteInterfaceTtl.setDescription('The datagram TTL threshold for the interface. Any IP\n multicast datagrams with a TTL less than this threshold will\n not be forwarded out the interface. The default value of 0\n means all multicast packets are forwarded out the\n interface.') ipMRouteInterfaceProtocol = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 3), IANAipMRouteProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInterfaceProtocol.setDescription('The routing protocol running on this interface.') ipMRouteInterfaceRateLimit = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 4), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: ipMRouteInterfaceRateLimit.setDescription('The rate-limit, in kilobits per second, of forwarded\n multicast traffic on the interface. A rate-limit of 0\n indicates that no rate limiting is done.') ipMRouteInterfaceInMcastOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInterfaceInMcastOctets.setDescription('The number of octets of multicast packets that have arrived\n on the interface, including framing characters. This object\n is similar to ifInOctets in the Interfaces MIB, except that\n only multicast packets are counted.') ipMRouteInterfaceOutMcastOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInterfaceOutMcastOctets.setDescription('The number of octets of multicast packets that have been\n sent on the interface.') ipMRouteInterfaceHCInMcastOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 7), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInterfaceHCInMcastOctets.setDescription('The number of octets of multicast packets that have arrived\n on the interface, including framing characters. This object\n is a 64-bit version of ipMRouteInterfaceInMcastOctets. It\n is similar to ifHCInOctets in the Interfaces MIB, except\n that only multicast packets are counted.') ipMRouteInterfaceHCOutMcastOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 8), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipMRouteInterfaceHCOutMcastOctets.setDescription('The number of octets of multicast packets that have been\n\n\n\n\n\n sent on the interface. This object is a 64-bit version of\n ipMRouteInterfaceOutMcastOctets.') ipMRouteBoundaryTable = MibTable((1, 3, 6, 1, 2, 1, 83, 1, 1, 5), ) if mibBuilder.loadTexts: ipMRouteBoundaryTable.setDescription("The (conceptual) table listing the router's scoped\n multicast address boundaries.") ipMRouteBoundaryEntry = MibTableRow((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1), ).setIndexNames((0, "IPMROUTE-STD-MIB", "ipMRouteBoundaryIfIndex"), (0, "IPMROUTE-STD-MIB", "ipMRouteBoundaryAddress"), (0, "IPMROUTE-STD-MIB", "ipMRouteBoundaryAddressMask")) if mibBuilder.loadTexts: ipMRouteBoundaryEntry.setDescription('An entry (conceptual row) in the ipMRouteBoundaryTable\n representing a scoped boundary.') ipMRouteBoundaryIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: ipMRouteBoundaryIfIndex.setDescription('The IfIndex value for the interface to which this boundary\n applies. Packets with a destination address in the\n associated address/mask range will not be forwarded out this\n interface.') ipMRouteBoundaryAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 2), IpAddress()) if mibBuilder.loadTexts: ipMRouteBoundaryAddress.setDescription('The group address which when combined with the\n corresponding value of ipMRouteBoundaryAddressMask\n identifies the group range for which the scoped boundary\n exists. Scoped addresses must come from the range 239.x.x.x\n as specified in RFC 2365.') ipMRouteBoundaryAddressMask = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 3), IpAddress()) if mibBuilder.loadTexts: ipMRouteBoundaryAddressMask.setDescription('The group address mask which when combined with the\n corresponding value of ipMRouteBoundaryAddress identifies\n the group range for which the scoped boundary exists.') ipMRouteBoundaryStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipMRouteBoundaryStatus.setDescription('The status of this row, by which new entries may be\n created, or old entries deleted from this table.') ipMRouteScopeNameTable = MibTable((1, 3, 6, 1, 2, 1, 83, 1, 1, 6), ) if mibBuilder.loadTexts: ipMRouteScopeNameTable.setDescription('The (conceptual) table listing the multicast scope names.') ipMRouteScopeNameEntry = MibTableRow((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1), ).setIndexNames((0, "IPMROUTE-STD-MIB", "ipMRouteScopeNameAddress"), (0, "IPMROUTE-STD-MIB", "ipMRouteScopeNameAddressMask"), (1, "IPMROUTE-STD-MIB", "ipMRouteScopeNameLanguage")) if mibBuilder.loadTexts: ipMRouteScopeNameEntry.setDescription('An entry (conceptual row) in the ipMRouteScopeNameTable\n representing a multicast scope name.') ipMRouteScopeNameAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 1), IpAddress()) if mibBuilder.loadTexts: ipMRouteScopeNameAddress.setDescription('The group address which when combined with the\n corresponding value of ipMRouteScopeNameAddressMask\n identifies the group range associated with the multicast\n scope. Scoped addresses must come from the range\n 239.x.x.x.') ipMRouteScopeNameAddressMask = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 2), IpAddress()) if mibBuilder.loadTexts: ipMRouteScopeNameAddressMask.setDescription('The group address mask which when combined with the\n corresponding value of ipMRouteScopeNameAddress identifies\n the group range associated with the multicast scope.') ipMRouteScopeNameLanguage = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 3), LanguageTag()) if mibBuilder.loadTexts: ipMRouteScopeNameLanguage.setDescription('The RFC 1766-style language tag associated with the scope\n name.') ipMRouteScopeNameString = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 4), SnmpAdminString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipMRouteScopeNameString.setDescription('The textual name associated with the multicast scope. The\n value of this object should be suitable for displaying to\n end-users, such as when allocating a multicast address in\n this scope. When no name is specified, the default value of\n this object should be the string 239.x.x.x/y with x and y\n replaced appropriately to describe the address and mask\n length associated with the scope.') ipMRouteScopeNameDefault = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 5), TruthValue().clone('false')).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipMRouteScopeNameDefault.setDescription('If true, indicates a preference that the name in the\n following language should be used by applications if no name\n is available in a desired language.') ipMRouteScopeNameStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 6), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipMRouteScopeNameStatus.setDescription('The status of this row, by which new entries may be\n created, or old entries deleted from this table.') ipMRouteMIBConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 83, 2)) ipMRouteMIBCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 83, 2, 1)) ipMRouteMIBGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 83, 2, 2)) ipMRouteMIBCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 83, 2, 1, 1)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteMIBBasicGroup"), ("IPMROUTE-STD-MIB", "ipMRouteMIBRouteGroup"), ("IPMROUTE-STD-MIB", "ipMRouteMIBBoundaryGroup"), ("IPMROUTE-STD-MIB", "ipMRouteMIBHCInterfaceGroup"),)) if mibBuilder.loadTexts: ipMRouteMIBCompliance.setDescription('The compliance statement for the IP Multicast MIB.') ipMRouteMIBBasicGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 1)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteEnable"), ("IPMROUTE-STD-MIB", "ipMRouteEntryCount"), ("IPMROUTE-STD-MIB", "ipMRouteUpstreamNeighbor"), ("IPMROUTE-STD-MIB", "ipMRouteInIfIndex"), ("IPMROUTE-STD-MIB", "ipMRouteUpTime"), ("IPMROUTE-STD-MIB", "ipMRouteExpiryTime"), ("IPMROUTE-STD-MIB", "ipMRouteNextHopState"), ("IPMROUTE-STD-MIB", "ipMRouteNextHopUpTime"), ("IPMROUTE-STD-MIB", "ipMRouteNextHopExpiryTime"), ("IPMROUTE-STD-MIB", "ipMRouteNextHopProtocol"), ("IPMROUTE-STD-MIB", "ipMRouteNextHopPkts"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceTtl"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceProtocol"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceRateLimit"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceInMcastOctets"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceOutMcastOctets"), ("IPMROUTE-STD-MIB", "ipMRouteProtocol"),)) if mibBuilder.loadTexts: ipMRouteMIBBasicGroup.setDescription('A collection of objects to support basic management of IP\n Multicast routing.') ipMRouteMIBHopCountGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 2)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteNextHopClosestMemberHops"),)) if mibBuilder.loadTexts: ipMRouteMIBHopCountGroup.setDescription('A collection of objects to support management of the use of\n hop counts in IP Multicast routing.') ipMRouteMIBBoundaryGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 3)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteBoundaryStatus"), ("IPMROUTE-STD-MIB", "ipMRouteScopeNameString"), ("IPMROUTE-STD-MIB", "ipMRouteScopeNameDefault"), ("IPMROUTE-STD-MIB", "ipMRouteScopeNameStatus"),)) if mibBuilder.loadTexts: ipMRouteMIBBoundaryGroup.setDescription('A collection of objects to support management of scoped\n multicast address boundaries.') ipMRouteMIBPktsOutGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 4)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteNextHopPkts"),)) if mibBuilder.loadTexts: ipMRouteMIBPktsOutGroup.setDescription('A collection of objects to support management of packet\n counters for each outgoing interface entry of a route.') ipMRouteMIBHCInterfaceGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 5)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteInterfaceHCInMcastOctets"), ("IPMROUTE-STD-MIB", "ipMRouteInterfaceHCOutMcastOctets"), ("IPMROUTE-STD-MIB", "ipMRouteHCOctets"),)) if mibBuilder.loadTexts: ipMRouteMIBHCInterfaceGroup.setDescription('A collection of objects providing information specific to\n high speed (greater than 20,000,000 bits/second) network\n interfaces.') ipMRouteMIBRouteGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 6)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRouteRtProto"), ("IPMROUTE-STD-MIB", "ipMRouteRtAddress"), ("IPMROUTE-STD-MIB", "ipMRouteRtMask"), ("IPMROUTE-STD-MIB", "ipMRouteRtType"),)) if mibBuilder.loadTexts: ipMRouteMIBRouteGroup.setDescription('A collection of objects providing information on the\n relationship between multicast routing information, and the\n IP Forwarding Table.') ipMRouteMIBPktsGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 83, 2, 2, 7)).setObjects(*(("IPMROUTE-STD-MIB", "ipMRoutePkts"), ("IPMROUTE-STD-MIB", "ipMRouteDifferentInIfPackets"), ("IPMROUTE-STD-MIB", "ipMRouteOctets"),)) if mibBuilder.loadTexts: ipMRouteMIBPktsGroup.setDescription('A collection of objects to support management of packet\n counters for each forwarding entry.') mibBuilder.exportSymbols("IPMROUTE-STD-MIB", ipMRouteMIBConformance=ipMRouteMIBConformance, ipMRouteMIBPktsGroup=ipMRouteMIBPktsGroup, ipMRouteEntryCount=ipMRouteEntryCount, LanguageTag=LanguageTag, ipMRouteHCOctets=ipMRouteHCOctets, ipMRouteNextHopUpTime=ipMRouteNextHopUpTime, ipMRouteScopeNameTable=ipMRouteScopeNameTable, ipMRouteMIBBasicGroup=ipMRouteMIBBasicGroup, ipMRoutePkts=ipMRoutePkts, ipMRouteNextHopSource=ipMRouteNextHopSource, ipMRouteInterfaceRateLimit=ipMRouteInterfaceRateLimit, ipMRouteScopeNameDefault=ipMRouteScopeNameDefault, ipMRouteNextHopClosestMemberHops=ipMRouteNextHopClosestMemberHops, ipMRouteScopeNameAddress=ipMRouteScopeNameAddress, ipMRouteRtProto=ipMRouteRtProto, ipMRouteNextHopProtocol=ipMRouteNextHopProtocol, ipMRouteTable=ipMRouteTable, ipMRouteNextHopExpiryTime=ipMRouteNextHopExpiryTime, ipMRouteRtType=ipMRouteRtType, ipMRouteScopeNameEntry=ipMRouteScopeNameEntry, ipMRouteRtAddress=ipMRouteRtAddress, ipMRouteScopeNameString=ipMRouteScopeNameString, ipMRouteInterfaceProtocol=ipMRouteInterfaceProtocol, ipMRouteMIBCompliances=ipMRouteMIBCompliances, ipMRouteBoundaryTable=ipMRouteBoundaryTable, ipMRouteScopeNameStatus=ipMRouteScopeNameStatus, ipMRouteGroup=ipMRouteGroup, ipMRouteNextHopTable=ipMRouteNextHopTable, ipMRouteSource=ipMRouteSource, ipMRouteMIBHopCountGroup=ipMRouteMIBHopCountGroup, ipMRouteEntry=ipMRouteEntry, PYSNMP_MODULE_ID=ipMRouteStdMIB, ipMRouteExpiryTime=ipMRouteExpiryTime, ipMRouteBoundaryAddress=ipMRouteBoundaryAddress, ipMRouteMIBPktsOutGroup=ipMRouteMIBPktsOutGroup, ipMRouteSourceMask=ipMRouteSourceMask, ipMRouteNextHopSourceMask=ipMRouteNextHopSourceMask, ipMRouteInIfIndex=ipMRouteInIfIndex, ipMRouteScopeNameLanguage=ipMRouteScopeNameLanguage, ipMRouteOctets=ipMRouteOctets, ipMRouteNextHopPkts=ipMRouteNextHopPkts, ipMRouteNextHopAddress=ipMRouteNextHopAddress, ipMRouteNextHopState=ipMRouteNextHopState, ipMRouteMIBRouteGroup=ipMRouteMIBRouteGroup, ipMRouteBoundaryAddressMask=ipMRouteBoundaryAddressMask, ipMRouteRtMask=ipMRouteRtMask, ipMRouteInterfaceInMcastOctets=ipMRouteInterfaceInMcastOctets, ipMRouteBoundaryIfIndex=ipMRouteBoundaryIfIndex, ipMRouteProtocol=ipMRouteProtocol, ipMRouteNextHopIfIndex=ipMRouteNextHopIfIndex, ipMRouteMIBHCInterfaceGroup=ipMRouteMIBHCInterfaceGroup, ipMRouteDifferentInIfPackets=ipMRouteDifferentInIfPackets, ipMRouteInterfaceHCInMcastOctets=ipMRouteInterfaceHCInMcastOctets, ipMRouteNextHopEntry=ipMRouteNextHopEntry, ipMRouteInterfaceHCOutMcastOctets=ipMRouteInterfaceHCOutMcastOctets, ipMRouteBoundaryStatus=ipMRouteBoundaryStatus, ipMRouteEnable=ipMRouteEnable, ipMRouteMIBCompliance=ipMRouteMIBCompliance, ipMRouteInterfaceOutMcastOctets=ipMRouteInterfaceOutMcastOctets, ipMRouteNextHopGroup=ipMRouteNextHopGroup, ipMRouteInterfaceIfIndex=ipMRouteInterfaceIfIndex, ipMRouteInterfaceEntry=ipMRouteInterfaceEntry, ipMRouteStdMIB=ipMRouteStdMIB, ipMRouteInterfaceTable=ipMRouteInterfaceTable, ipMRouteUpstreamNeighbor=ipMRouteUpstreamNeighbor, ipMRouteUpTime=ipMRouteUpTime, ipMRouteScopeNameAddressMask=ipMRouteScopeNameAddressMask, ipMRoute=ipMRoute, ipMRouteInterfaceTtl=ipMRouteInterfaceTtl, ipMRouteMIBBoundaryGroup=ipMRouteMIBBoundaryGroup, ipMRouteMIBObjects=ipMRouteMIBObjects, ipMRouteBoundaryEntry=ipMRouteBoundaryEntry, ipMRouteMIBGroups=ipMRouteMIBGroups)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, single_value_constraint, constraints_union, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ConstraintsIntersection') (ian_aip_m_route_protocol, ian_aip_route_protocol) = mibBuilder.importSymbols('IANA-RTPROTO-MIB', 'IANAipMRouteProtocol', 'IANAipRouteProtocol') (interface_index_or_zero, interface_index) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero', 'InterfaceIndex') (snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') (object_group, module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'ModuleCompliance', 'NotificationGroup') (mib_2, time_ticks, module_identity, integer32, counter32, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, unsigned32, mib_identifier, gauge32, counter64, bits, notification_type, ip_address) = mibBuilder.importSymbols('SNMPv2-SMI', 'mib-2', 'TimeTicks', 'ModuleIdentity', 'Integer32', 'Counter32', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'Unsigned32', 'MibIdentifier', 'Gauge32', 'Counter64', 'Bits', 'NotificationType', 'IpAddress') (row_status, display_string, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'DisplayString', 'TruthValue', 'TextualConvention') ip_m_route_std_mib = module_identity((1, 3, 6, 1, 2, 1, 83)).setRevisions(('2000-09-22 00:00',)) if mibBuilder.loadTexts: ipMRouteStdMIB.setLastUpdated('200009220000Z') if mibBuilder.loadTexts: ipMRouteStdMIB.setOrganization('IETF IDMR Working Group') if mibBuilder.loadTexts: ipMRouteStdMIB.setContactInfo(' Dave Thaler\n Microsoft Corporation\n One Microsoft Way\n Redmond, WA 98052-6399\n US\n\n Phone: +1 425 703 8835\n EMail: dthaler@microsoft.com') if mibBuilder.loadTexts: ipMRouteStdMIB.setDescription('The MIB module for management of IP Multicast routing, but\n independent of the specific multicast routing protocol in\n use.') class Languagetag(OctetString, TextualConvention): display_hint = '100a' subtype_spec = OctetString.subtypeSpec + value_size_constraint(1, 100) ip_m_route_mib_objects = mib_identifier((1, 3, 6, 1, 2, 1, 83, 1)) ip_m_route = mib_identifier((1, 3, 6, 1, 2, 1, 83, 1, 1)) ip_m_route_enable = mib_scalar((1, 3, 6, 1, 2, 1, 83, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: ipMRouteEnable.setDescription('The enabled status of IP Multicast routing on this router.') ip_m_route_entry_count = mib_scalar((1, 3, 6, 1, 2, 1, 83, 1, 1, 7), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteEntryCount.setDescription('The number of rows in the ipMRouteTable. This can be used\n to monitor the multicast routing table size.') ip_m_route_table = mib_table((1, 3, 6, 1, 2, 1, 83, 1, 1, 2)) if mibBuilder.loadTexts: ipMRouteTable.setDescription('The (conceptual) table containing multicast routing\n information for IP datagrams sent by particular sources to\n the IP multicast groups known to this router.') ip_m_route_entry = mib_table_row((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1)).setIndexNames((0, 'IPMROUTE-STD-MIB', 'ipMRouteGroup'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteSource'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteSourceMask')) if mibBuilder.loadTexts: ipMRouteEntry.setDescription('An entry (conceptual row) containing the multicast routing\n information for IP datagrams from a particular source and\n addressed to a particular IP multicast group address.\n Discontinuities in counters in this entry can be detected by\n observing the value of ipMRouteUpTime.') ip_m_route_group = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 1), ip_address()) if mibBuilder.loadTexts: ipMRouteGroup.setDescription('The IP multicast group address for which this entry\n contains multicast routing information.') ip_m_route_source = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 2), ip_address()) if mibBuilder.loadTexts: ipMRouteSource.setDescription('The network address which when combined with the\n corresponding value of ipMRouteSourceMask identifies the\n sources for which this entry contains multicast routing\n information.') ip_m_route_source_mask = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 3), ip_address()) if mibBuilder.loadTexts: ipMRouteSourceMask.setDescription('The network mask which when combined with the corresponding\n value of ipMRouteSource identifies the sources for which\n this entry contains multicast routing information.') ip_m_route_upstream_neighbor = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 4), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteUpstreamNeighbor.setDescription('The address of the upstream neighbor (e.g., RPF neighbor)\n from which IP datagrams from these sources to this multicast\n address are received, or 0.0.0.0 if the upstream neighbor is\n unknown (e.g., in CBT).') ip_m_route_in_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 5), interface_index_or_zero()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInIfIndex.setDescription('The value of ifIndex for the interface on which IP\n datagrams sent by these sources to this multicast address\n are received. A value of 0 indicates that datagrams are not\n subject to an incoming interface check, but may be accepted\n on multiple interfaces (e.g., in CBT).') ip_m_route_up_time = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 6), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteUpTime.setDescription('The time since the multicast routing information\n represented by this entry was learned by the router.') ip_m_route_expiry_time = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 7), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteExpiryTime.setDescription('The minimum amount of time remaining before this entry will\n be aged out. The value 0 indicates that the entry is not\n subject to aging.') ip_m_route_pkts = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 8), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRoutePkts.setDescription('The number of packets which this router has received from\n these sources and addressed to this multicast group\n address.') ip_m_route_different_in_if_packets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 9), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteDifferentInIfPackets.setDescription('The number of packets which this router has received from\n these sources and addressed to this multicast group address,\n which were dropped because they were not received on the\n interface indicated by ipMRouteInIfIndex. Packets which are\n not subject to an incoming interface check (e.g., using CBT)\n are not counted.') ip_m_route_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 10), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteOctets.setDescription('The number of octets contained in IP datagrams which were\n received from these sources and addressed to this multicast\n group address, and which were forwarded by this router.') ip_m_route_protocol = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 11), ian_aip_m_route_protocol()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteProtocol.setDescription('The multicast routing protocol via which this multicast\n forwarding entry was learned.') ip_m_route_rt_proto = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 12), ian_aip_route_protocol()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteRtProto.setDescription('The routing mechanism via which the route used to find the\n upstream or parent interface for this multicast forwarding\n entry was learned. Inclusion of values for routing\n protocols is not intended to imply that those protocols need\n be supported.') ip_m_route_rt_address = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 13), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteRtAddress.setDescription('The address portion of the route used to find the upstream\n or parent interface for this multicast forwarding entry.') ip_m_route_rt_mask = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 14), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteRtMask.setDescription('The mask associated with the route used to find the upstream\n or parent interface for this multicast forwarding entry.') ip_m_route_rt_type = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 15), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('unicast', 1), ('multicast', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteRtType.setDescription('The reason the given route was placed in the (logical)\n multicast Routing Information Base (RIB). A value of\n unicast means that the route would normally be placed only\n in the unicast RIB, but was placed in the multicast RIB\n (instead or in addition) due to local configuration, such as\n when running PIM over RIP. A value of multicast means that\n\n\n\n\n\n the route was explicitly added to the multicast RIB by the\n routing protocol, such as DVMRP or Multiprotocol BGP.') ip_m_route_hc_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 2, 1, 16), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteHCOctets.setDescription('The number of octets contained in IP datagrams which were\n received from these sources and addressed to this multicast\n group address, and which were forwarded by this router.\n This object is a 64-bit version of ipMRouteOctets.') ip_m_route_next_hop_table = mib_table((1, 3, 6, 1, 2, 1, 83, 1, 1, 3)) if mibBuilder.loadTexts: ipMRouteNextHopTable.setDescription('The (conceptual) table containing information on the next-\n hops on outgoing interfaces for routing IP multicast\n datagrams. Each entry is one of a list of next-hops on\n outgoing interfaces for particular sources sending to a\n particular multicast group address.') ip_m_route_next_hop_entry = mib_table_row((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1)).setIndexNames((0, 'IPMROUTE-STD-MIB', 'ipMRouteNextHopGroup'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteNextHopSource'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteNextHopSourceMask'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteNextHopIfIndex'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteNextHopAddress')) if mibBuilder.loadTexts: ipMRouteNextHopEntry.setDescription('An entry (conceptual row) in the list of next-hops on\n outgoing interfaces to which IP multicast datagrams from\n particular sources to a IP multicast group address are\n routed. Discontinuities in counters in this entry can be\n detected by observing the value of ipMRouteUpTime.') ip_m_route_next_hop_group = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 1), ip_address()) if mibBuilder.loadTexts: ipMRouteNextHopGroup.setDescription('The IP multicast group for which this entry specifies a\n next-hop on an outgoing interface.') ip_m_route_next_hop_source = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 2), ip_address()) if mibBuilder.loadTexts: ipMRouteNextHopSource.setDescription('The network address which when combined with the\n corresponding value of ipMRouteNextHopSourceMask identifies\n the sources for which this entry specifies a next-hop on an\n outgoing interface.') ip_m_route_next_hop_source_mask = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 3), ip_address()) if mibBuilder.loadTexts: ipMRouteNextHopSourceMask.setDescription('The network mask which when combined with the corresponding\n value of ipMRouteNextHopSource identifies the sources for\n which this entry specifies a next-hop on an outgoing\n interface.') ip_m_route_next_hop_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 4), interface_index()) if mibBuilder.loadTexts: ipMRouteNextHopIfIndex.setDescription('The ifIndex value of the interface for the outgoing\n interface for this next-hop.') ip_m_route_next_hop_address = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 5), ip_address()) if mibBuilder.loadTexts: ipMRouteNextHopAddress.setDescription('The address of the next-hop specific to this entry. For\n most interfaces, this is identical to ipMRouteNextHopGroup.\n NBMA interfaces, however, may have multiple next-hop\n addresses out a single outgoing interface.') ip_m_route_next_hop_state = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('pruned', 1), ('forwarding', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopState.setDescription("An indication of whether the outgoing interface and next-\n hop represented by this entry is currently being used to\n forward IP datagrams. The value 'forwarding' indicates it\n is currently being used; the value 'pruned' indicates it is\n not.") ip_m_route_next_hop_up_time = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 7), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopUpTime.setDescription('The time since the multicast routing information\n represented by this entry was learned by the router.') ip_m_route_next_hop_expiry_time = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 8), time_ticks()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopExpiryTime.setDescription('The minimum amount of time remaining before this entry will\n be aged out. If ipMRouteNextHopState is pruned(1), the\n remaining time until the prune expires and the state reverts\n to forwarding(2). Otherwise, the remaining time until this\n entry is removed from the table. The time remaining may be\n copied from ipMRouteExpiryTime if the protocol in use for\n this entry does not specify next-hop timers. The value 0\n\n\n\n\n\n indicates that the entry is not subject to aging.') ip_m_route_next_hop_closest_member_hops = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 9), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopClosestMemberHops.setDescription('The minimum number of hops between this router and any\n member of this IP multicast group reached via this next-hop\n on this outgoing interface. Any IP multicast datagrams for\n the group which have a TTL less than this number of hops\n will not be forwarded to this next-hop.') ip_m_route_next_hop_protocol = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 10), ian_aip_m_route_protocol()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopProtocol.setDescription('The routing mechanism via which this next-hop was learned.') ip_m_route_next_hop_pkts = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 3, 1, 11), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteNextHopPkts.setDescription('The number of packets which have been forwarded using this\n route.') ip_m_route_interface_table = mib_table((1, 3, 6, 1, 2, 1, 83, 1, 1, 4)) if mibBuilder.loadTexts: ipMRouteInterfaceTable.setDescription('The (conceptual) table containing multicast routing\n information specific to interfaces.') ip_m_route_interface_entry = mib_table_row((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1)).setIndexNames((0, 'IPMROUTE-STD-MIB', 'ipMRouteInterfaceIfIndex')) if mibBuilder.loadTexts: ipMRouteInterfaceEntry.setDescription('An entry (conceptual row) containing the multicast routing\n information for a particular interface.') ip_m_route_interface_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 1), interface_index()) if mibBuilder.loadTexts: ipMRouteInterfaceIfIndex.setDescription('The ifIndex value of the interface for which this entry\n contains information.') ip_m_route_interface_ttl = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite') if mibBuilder.loadTexts: ipMRouteInterfaceTtl.setDescription('The datagram TTL threshold for the interface. Any IP\n multicast datagrams with a TTL less than this threshold will\n not be forwarded out the interface. The default value of 0\n means all multicast packets are forwarded out the\n interface.') ip_m_route_interface_protocol = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 3), ian_aip_m_route_protocol()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInterfaceProtocol.setDescription('The routing protocol running on this interface.') ip_m_route_interface_rate_limit = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 4), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: ipMRouteInterfaceRateLimit.setDescription('The rate-limit, in kilobits per second, of forwarded\n multicast traffic on the interface. A rate-limit of 0\n indicates that no rate limiting is done.') ip_m_route_interface_in_mcast_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInterfaceInMcastOctets.setDescription('The number of octets of multicast packets that have arrived\n on the interface, including framing characters. This object\n is similar to ifInOctets in the Interfaces MIB, except that\n only multicast packets are counted.') ip_m_route_interface_out_mcast_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 6), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInterfaceOutMcastOctets.setDescription('The number of octets of multicast packets that have been\n sent on the interface.') ip_m_route_interface_hc_in_mcast_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 7), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInterfaceHCInMcastOctets.setDescription('The number of octets of multicast packets that have arrived\n on the interface, including framing characters. This object\n is a 64-bit version of ipMRouteInterfaceInMcastOctets. It\n is similar to ifHCInOctets in the Interfaces MIB, except\n that only multicast packets are counted.') ip_m_route_interface_hc_out_mcast_octets = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 4, 1, 8), counter64()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipMRouteInterfaceHCOutMcastOctets.setDescription('The number of octets of multicast packets that have been\n\n\n\n\n\n sent on the interface. This object is a 64-bit version of\n ipMRouteInterfaceOutMcastOctets.') ip_m_route_boundary_table = mib_table((1, 3, 6, 1, 2, 1, 83, 1, 1, 5)) if mibBuilder.loadTexts: ipMRouteBoundaryTable.setDescription("The (conceptual) table listing the router's scoped\n multicast address boundaries.") ip_m_route_boundary_entry = mib_table_row((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1)).setIndexNames((0, 'IPMROUTE-STD-MIB', 'ipMRouteBoundaryIfIndex'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteBoundaryAddress'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteBoundaryAddressMask')) if mibBuilder.loadTexts: ipMRouteBoundaryEntry.setDescription('An entry (conceptual row) in the ipMRouteBoundaryTable\n representing a scoped boundary.') ip_m_route_boundary_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 1), interface_index()) if mibBuilder.loadTexts: ipMRouteBoundaryIfIndex.setDescription('The IfIndex value for the interface to which this boundary\n applies. Packets with a destination address in the\n associated address/mask range will not be forwarded out this\n interface.') ip_m_route_boundary_address = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 2), ip_address()) if mibBuilder.loadTexts: ipMRouteBoundaryAddress.setDescription('The group address which when combined with the\n corresponding value of ipMRouteBoundaryAddressMask\n identifies the group range for which the scoped boundary\n exists. Scoped addresses must come from the range 239.x.x.x\n as specified in RFC 2365.') ip_m_route_boundary_address_mask = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 3), ip_address()) if mibBuilder.loadTexts: ipMRouteBoundaryAddressMask.setDescription('The group address mask which when combined with the\n corresponding value of ipMRouteBoundaryAddress identifies\n the group range for which the scoped boundary exists.') ip_m_route_boundary_status = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 5, 1, 4), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipMRouteBoundaryStatus.setDescription('The status of this row, by which new entries may be\n created, or old entries deleted from this table.') ip_m_route_scope_name_table = mib_table((1, 3, 6, 1, 2, 1, 83, 1, 1, 6)) if mibBuilder.loadTexts: ipMRouteScopeNameTable.setDescription('The (conceptual) table listing the multicast scope names.') ip_m_route_scope_name_entry = mib_table_row((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1)).setIndexNames((0, 'IPMROUTE-STD-MIB', 'ipMRouteScopeNameAddress'), (0, 'IPMROUTE-STD-MIB', 'ipMRouteScopeNameAddressMask'), (1, 'IPMROUTE-STD-MIB', 'ipMRouteScopeNameLanguage')) if mibBuilder.loadTexts: ipMRouteScopeNameEntry.setDescription('An entry (conceptual row) in the ipMRouteScopeNameTable\n representing a multicast scope name.') ip_m_route_scope_name_address = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 1), ip_address()) if mibBuilder.loadTexts: ipMRouteScopeNameAddress.setDescription('The group address which when combined with the\n corresponding value of ipMRouteScopeNameAddressMask\n identifies the group range associated with the multicast\n scope. Scoped addresses must come from the range\n 239.x.x.x.') ip_m_route_scope_name_address_mask = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 2), ip_address()) if mibBuilder.loadTexts: ipMRouteScopeNameAddressMask.setDescription('The group address mask which when combined with the\n corresponding value of ipMRouteScopeNameAddress identifies\n the group range associated with the multicast scope.') ip_m_route_scope_name_language = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 3), language_tag()) if mibBuilder.loadTexts: ipMRouteScopeNameLanguage.setDescription('The RFC 1766-style language tag associated with the scope\n name.') ip_m_route_scope_name_string = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 4), snmp_admin_string()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipMRouteScopeNameString.setDescription('The textual name associated with the multicast scope. The\n value of this object should be suitable for displaying to\n end-users, such as when allocating a multicast address in\n this scope. When no name is specified, the default value of\n this object should be the string 239.x.x.x/y with x and y\n replaced appropriately to describe the address and mask\n length associated with the scope.') ip_m_route_scope_name_default = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 5), truth_value().clone('false')).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipMRouteScopeNameDefault.setDescription('If true, indicates a preference that the name in the\n following language should be used by applications if no name\n is available in a desired language.') ip_m_route_scope_name_status = mib_table_column((1, 3, 6, 1, 2, 1, 83, 1, 1, 6, 1, 6), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipMRouteScopeNameStatus.setDescription('The status of this row, by which new entries may be\n created, or old entries deleted from this table.') ip_m_route_mib_conformance = mib_identifier((1, 3, 6, 1, 2, 1, 83, 2)) ip_m_route_mib_compliances = mib_identifier((1, 3, 6, 1, 2, 1, 83, 2, 1)) ip_m_route_mib_groups = mib_identifier((1, 3, 6, 1, 2, 1, 83, 2, 2)) ip_m_route_mib_compliance = module_compliance((1, 3, 6, 1, 2, 1, 83, 2, 1, 1)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteMIBBasicGroup'), ('IPMROUTE-STD-MIB', 'ipMRouteMIBRouteGroup'), ('IPMROUTE-STD-MIB', 'ipMRouteMIBBoundaryGroup'), ('IPMROUTE-STD-MIB', 'ipMRouteMIBHCInterfaceGroup'))) if mibBuilder.loadTexts: ipMRouteMIBCompliance.setDescription('The compliance statement for the IP Multicast MIB.') ip_m_route_mib_basic_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 1)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteEnable'), ('IPMROUTE-STD-MIB', 'ipMRouteEntryCount'), ('IPMROUTE-STD-MIB', 'ipMRouteUpstreamNeighbor'), ('IPMROUTE-STD-MIB', 'ipMRouteInIfIndex'), ('IPMROUTE-STD-MIB', 'ipMRouteUpTime'), ('IPMROUTE-STD-MIB', 'ipMRouteExpiryTime'), ('IPMROUTE-STD-MIB', 'ipMRouteNextHopState'), ('IPMROUTE-STD-MIB', 'ipMRouteNextHopUpTime'), ('IPMROUTE-STD-MIB', 'ipMRouteNextHopExpiryTime'), ('IPMROUTE-STD-MIB', 'ipMRouteNextHopProtocol'), ('IPMROUTE-STD-MIB', 'ipMRouteNextHopPkts'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceTtl'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceProtocol'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceRateLimit'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceInMcastOctets'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceOutMcastOctets'), ('IPMROUTE-STD-MIB', 'ipMRouteProtocol'))) if mibBuilder.loadTexts: ipMRouteMIBBasicGroup.setDescription('A collection of objects to support basic management of IP\n Multicast routing.') ip_m_route_mib_hop_count_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 2)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteNextHopClosestMemberHops'),)) if mibBuilder.loadTexts: ipMRouteMIBHopCountGroup.setDescription('A collection of objects to support management of the use of\n hop counts in IP Multicast routing.') ip_m_route_mib_boundary_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 3)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteBoundaryStatus'), ('IPMROUTE-STD-MIB', 'ipMRouteScopeNameString'), ('IPMROUTE-STD-MIB', 'ipMRouteScopeNameDefault'), ('IPMROUTE-STD-MIB', 'ipMRouteScopeNameStatus'))) if mibBuilder.loadTexts: ipMRouteMIBBoundaryGroup.setDescription('A collection of objects to support management of scoped\n multicast address boundaries.') ip_m_route_mib_pkts_out_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 4)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteNextHopPkts'),)) if mibBuilder.loadTexts: ipMRouteMIBPktsOutGroup.setDescription('A collection of objects to support management of packet\n counters for each outgoing interface entry of a route.') ip_m_route_mibhc_interface_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 5)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteInterfaceHCInMcastOctets'), ('IPMROUTE-STD-MIB', 'ipMRouteInterfaceHCOutMcastOctets'), ('IPMROUTE-STD-MIB', 'ipMRouteHCOctets'))) if mibBuilder.loadTexts: ipMRouteMIBHCInterfaceGroup.setDescription('A collection of objects providing information specific to\n high speed (greater than 20,000,000 bits/second) network\n interfaces.') ip_m_route_mib_route_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 6)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRouteRtProto'), ('IPMROUTE-STD-MIB', 'ipMRouteRtAddress'), ('IPMROUTE-STD-MIB', 'ipMRouteRtMask'), ('IPMROUTE-STD-MIB', 'ipMRouteRtType'))) if mibBuilder.loadTexts: ipMRouteMIBRouteGroup.setDescription('A collection of objects providing information on the\n relationship between multicast routing information, and the\n IP Forwarding Table.') ip_m_route_mib_pkts_group = object_group((1, 3, 6, 1, 2, 1, 83, 2, 2, 7)).setObjects(*(('IPMROUTE-STD-MIB', 'ipMRoutePkts'), ('IPMROUTE-STD-MIB', 'ipMRouteDifferentInIfPackets'), ('IPMROUTE-STD-MIB', 'ipMRouteOctets'))) if mibBuilder.loadTexts: ipMRouteMIBPktsGroup.setDescription('A collection of objects to support management of packet\n counters for each forwarding entry.') mibBuilder.exportSymbols('IPMROUTE-STD-MIB', ipMRouteMIBConformance=ipMRouteMIBConformance, ipMRouteMIBPktsGroup=ipMRouteMIBPktsGroup, ipMRouteEntryCount=ipMRouteEntryCount, LanguageTag=LanguageTag, ipMRouteHCOctets=ipMRouteHCOctets, ipMRouteNextHopUpTime=ipMRouteNextHopUpTime, ipMRouteScopeNameTable=ipMRouteScopeNameTable, ipMRouteMIBBasicGroup=ipMRouteMIBBasicGroup, ipMRoutePkts=ipMRoutePkts, ipMRouteNextHopSource=ipMRouteNextHopSource, ipMRouteInterfaceRateLimit=ipMRouteInterfaceRateLimit, ipMRouteScopeNameDefault=ipMRouteScopeNameDefault, ipMRouteNextHopClosestMemberHops=ipMRouteNextHopClosestMemberHops, ipMRouteScopeNameAddress=ipMRouteScopeNameAddress, ipMRouteRtProto=ipMRouteRtProto, ipMRouteNextHopProtocol=ipMRouteNextHopProtocol, ipMRouteTable=ipMRouteTable, ipMRouteNextHopExpiryTime=ipMRouteNextHopExpiryTime, ipMRouteRtType=ipMRouteRtType, ipMRouteScopeNameEntry=ipMRouteScopeNameEntry, ipMRouteRtAddress=ipMRouteRtAddress, ipMRouteScopeNameString=ipMRouteScopeNameString, ipMRouteInterfaceProtocol=ipMRouteInterfaceProtocol, ipMRouteMIBCompliances=ipMRouteMIBCompliances, ipMRouteBoundaryTable=ipMRouteBoundaryTable, ipMRouteScopeNameStatus=ipMRouteScopeNameStatus, ipMRouteGroup=ipMRouteGroup, ipMRouteNextHopTable=ipMRouteNextHopTable, ipMRouteSource=ipMRouteSource, ipMRouteMIBHopCountGroup=ipMRouteMIBHopCountGroup, ipMRouteEntry=ipMRouteEntry, PYSNMP_MODULE_ID=ipMRouteStdMIB, ipMRouteExpiryTime=ipMRouteExpiryTime, ipMRouteBoundaryAddress=ipMRouteBoundaryAddress, ipMRouteMIBPktsOutGroup=ipMRouteMIBPktsOutGroup, ipMRouteSourceMask=ipMRouteSourceMask, ipMRouteNextHopSourceMask=ipMRouteNextHopSourceMask, ipMRouteInIfIndex=ipMRouteInIfIndex, ipMRouteScopeNameLanguage=ipMRouteScopeNameLanguage, ipMRouteOctets=ipMRouteOctets, ipMRouteNextHopPkts=ipMRouteNextHopPkts, ipMRouteNextHopAddress=ipMRouteNextHopAddress, ipMRouteNextHopState=ipMRouteNextHopState, ipMRouteMIBRouteGroup=ipMRouteMIBRouteGroup, ipMRouteBoundaryAddressMask=ipMRouteBoundaryAddressMask, ipMRouteRtMask=ipMRouteRtMask, ipMRouteInterfaceInMcastOctets=ipMRouteInterfaceInMcastOctets, ipMRouteBoundaryIfIndex=ipMRouteBoundaryIfIndex, ipMRouteProtocol=ipMRouteProtocol, ipMRouteNextHopIfIndex=ipMRouteNextHopIfIndex, ipMRouteMIBHCInterfaceGroup=ipMRouteMIBHCInterfaceGroup, ipMRouteDifferentInIfPackets=ipMRouteDifferentInIfPackets, ipMRouteInterfaceHCInMcastOctets=ipMRouteInterfaceHCInMcastOctets, ipMRouteNextHopEntry=ipMRouteNextHopEntry, ipMRouteInterfaceHCOutMcastOctets=ipMRouteInterfaceHCOutMcastOctets, ipMRouteBoundaryStatus=ipMRouteBoundaryStatus, ipMRouteEnable=ipMRouteEnable, ipMRouteMIBCompliance=ipMRouteMIBCompliance, ipMRouteInterfaceOutMcastOctets=ipMRouteInterfaceOutMcastOctets, ipMRouteNextHopGroup=ipMRouteNextHopGroup, ipMRouteInterfaceIfIndex=ipMRouteInterfaceIfIndex, ipMRouteInterfaceEntry=ipMRouteInterfaceEntry, ipMRouteStdMIB=ipMRouteStdMIB, ipMRouteInterfaceTable=ipMRouteInterfaceTable, ipMRouteUpstreamNeighbor=ipMRouteUpstreamNeighbor, ipMRouteUpTime=ipMRouteUpTime, ipMRouteScopeNameAddressMask=ipMRouteScopeNameAddressMask, ipMRoute=ipMRoute, ipMRouteInterfaceTtl=ipMRouteInterfaceTtl, ipMRouteMIBBoundaryGroup=ipMRouteMIBBoundaryGroup, ipMRouteMIBObjects=ipMRouteMIBObjects, ipMRouteBoundaryEntry=ipMRouteBoundaryEntry, ipMRouteMIBGroups=ipMRouteMIBGroups)
class Solution: def wordPattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ words = str.split(' ') if len(pattern) != len(words) or len(set(pattern)) != len(set(words)): return False d = dict() for index, value in enumerate(pattern): if value not in d: d[value] = words[index] else: if d[value] != words[index]: return False return True
class Solution: def word_pattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ words = str.split(' ') if len(pattern) != len(words) or len(set(pattern)) != len(set(words)): return False d = dict() for (index, value) in enumerate(pattern): if value not in d: d[value] = words[index] elif d[value] != words[index]: return False return True
# Problem 4: Dutch National Flag Problem def sort_zero_one_two(input_list): # We define 4 variables for the low, middle, high, and temporary values lo_end = 0 hi_end = len(input_list) - 1 mid = 0 tmp = None if len(input_list) <= 0 or input_list[mid] < 0: return "The list is either empty or invalid." while (mid <= hi_end): if input_list[mid] == 0: tmp = input_list[lo_end] input_list[lo_end] = input_list[mid] input_list[mid] = tmp lo_end += 1 mid += 1 elif input_list[mid] == 1: mid += 1 else: tmp = input_list[mid] input_list[mid] = input_list[hi_end] input_list[hi_end] = tmp hi_end -= 1 return input_list # Run some tests def test_function(test_case): sorted_array = sort_zero_one_two(test_case) print(sorted_array) if sorted_array == sorted(test_case): print("Pass") else: print("Fail") test_function([0, 0, 2, 2, 2, 1, 1, 1, 2, 0, 2]) test_function([2, 1, 2, 0, 0, 2, 1, 0, 1, 0, 0, 2, 2, 2, 1, 2, 0, 0, 0, 2, 1, 0, 2, 0, 0, 1]) test_function([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) test_function([1, 0, 2, 0, 1, 0, 2, 1, 0, 2, 2]) test_function([]) test_function([-1])
def sort_zero_one_two(input_list): lo_end = 0 hi_end = len(input_list) - 1 mid = 0 tmp = None if len(input_list) <= 0 or input_list[mid] < 0: return 'The list is either empty or invalid.' while mid <= hi_end: if input_list[mid] == 0: tmp = input_list[lo_end] input_list[lo_end] = input_list[mid] input_list[mid] = tmp lo_end += 1 mid += 1 elif input_list[mid] == 1: mid += 1 else: tmp = input_list[mid] input_list[mid] = input_list[hi_end] input_list[hi_end] = tmp hi_end -= 1 return input_list def test_function(test_case): sorted_array = sort_zero_one_two(test_case) print(sorted_array) if sorted_array == sorted(test_case): print('Pass') else: print('Fail') test_function([0, 0, 2, 2, 2, 1, 1, 1, 2, 0, 2]) test_function([2, 1, 2, 0, 0, 2, 1, 0, 1, 0, 0, 2, 2, 2, 1, 2, 0, 0, 0, 2, 1, 0, 2, 0, 0, 1]) test_function([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) test_function([1, 0, 2, 0, 1, 0, 2, 1, 0, 2, 2]) test_function([]) test_function([-1])
# -*- coding: utf-8 -*- """ equip.visitors.blocks ~~~~~~~~~~~~~~~~~~~~~ Callback the visit basic blocks in the program. :copyright: (c) 2014 by Romain Gaucher (@rgaucher) :license: Apache 2, see LICENSE for more details. """ class BlockVisitor(object): """ A basic block visitor. It first receives the control-flow graph, and then the ``visit`` method is called with all basic blocks in the CFG. The blocks are not passed to the ``visit`` method with a particular order. """ def __init__(self): self._control_flow = None @property def control_flow(self): return self._control_flow @control_flow.setter def control_flow(self, value): self._control_flow = value def new_control_flow(self): pass def visit(self, block): pass
""" equip.visitors.blocks ~~~~~~~~~~~~~~~~~~~~~ Callback the visit basic blocks in the program. :copyright: (c) 2014 by Romain Gaucher (@rgaucher) :license: Apache 2, see LICENSE for more details. """ class Blockvisitor(object): """ A basic block visitor. It first receives the control-flow graph, and then the ``visit`` method is called with all basic blocks in the CFG. The blocks are not passed to the ``visit`` method with a particular order. """ def __init__(self): self._control_flow = None @property def control_flow(self): return self._control_flow @control_flow.setter def control_flow(self, value): self._control_flow = value def new_control_flow(self): pass def visit(self, block): pass
# coding=utf-8 BTC_BASED_COINS = { 'PIVX': { 'ip': '', 'port': 3000, 'url': '' } } ETHEREUM_BASED_COINS = ['ETH', 'BNB', 'SENT'] ADDRESS = ''.lower() PRIVATE_KEY = '' FEE_PERCENTAGE = 0.01 TOKENS = [ { 'address': ADDRESS, 'decimals': 18, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png', 'name': 'Ethereum', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=SENT', 'symbol': 'ETH', 'coin_type': 'erc20' }, { 'address': '0xb8c77482e45f1f44de1745f52c74426c631bdd52', 'decimals': 18, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png', 'name': 'Binance Coin', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/binance-coin/?convert=SENT', 'symbol': 'BNB', 'coin_type': 'erc20' }, { 'address': None, 'decimals': 0, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1169.png', 'name': 'PIVX', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/pivx/?convert=SENT', 'symbol': 'PIVX', 'coin_type': 'btc_fork' }, { 'address': '0xa44e5137293e855b1b7bc7e2c6f8cd796ffcb037', 'decimals': 8, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/2643.png', 'name': 'SENTinel', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/sentinel/?convert=SENT', 'symbol': 'SENT', 'coin_type': 'erc20' } ]
btc_based_coins = {'PIVX': {'ip': '', 'port': 3000, 'url': ''}} ethereum_based_coins = ['ETH', 'BNB', 'SENT'] address = ''.lower() private_key = '' fee_percentage = 0.01 tokens = [{'address': ADDRESS, 'decimals': 18, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png', 'name': 'Ethereum', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=SENT', 'symbol': 'ETH', 'coin_type': 'erc20'}, {'address': '0xb8c77482e45f1f44de1745f52c74426c631bdd52', 'decimals': 18, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png', 'name': 'Binance Coin', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/binance-coin/?convert=SENT', 'symbol': 'BNB', 'coin_type': 'erc20'}, {'address': None, 'decimals': 0, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1169.png', 'name': 'PIVX', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/pivx/?convert=SENT', 'symbol': 'PIVX', 'coin_type': 'btc_fork'}, {'address': '0xa44e5137293e855b1b7bc7e2c6f8cd796ffcb037', 'decimals': 8, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/2643.png', 'name': 'SENTinel', 'price_url': 'https://api.coinmarketcap.com/v1/ticker/sentinel/?convert=SENT', 'symbol': 'SENT', 'coin_type': 'erc20'}]
def get_poisoned_worker_ids_from_log(log_path): # Unchanged from original work """ :param log_path: string """ with open(log_path, "r") as f: file_lines = [line.strip() for line in f.readlines() if "Poisoning data for workers:" in line] workers = file_lines[0].split("[")[1].split("]")[0] workers_list = workers.split(", ") return [int(worker) for worker in workers_list] def get_worker_num_from_model_file_name(model_file_name): # Unchanged from original work """ :param model_file_name: string """ return int(model_file_name.split("_")[1]) def get_epoch_num_from_model_file_name(model_file_name): # Unchanged from original work """ :param model_file_name: string """ return int(model_file_name.split("_")[2].split(".")[0]) def get_suffix_from_model_file_name(model_file_name): # Unchanged from original work """ :param model_file_name: string """ return model_file_name.split("_")[3].split(".")[0] def get_model_files_for_worker(model_files, worker_id): # Unchanged from original work """ :param model_files: list[string] :param worker_id: int """ worker_model_files = [] for model in model_files: worker_num = get_worker_num_from_model_file_name(model) if worker_num == worker_id: worker_model_files.append(model) return worker_model_files def get_model_files_for_epoch(model_files, epoch_num): # Unchanged from original work """ :param model_files: list[string] :param epoch_num: int """ epoch_model_files = [] for model in model_files: model_epoch_num = get_epoch_num_from_model_file_name(model) if model_epoch_num == epoch_num: epoch_model_files.append(model) return epoch_model_files def get_model_files_for_suffix(model_files, suffix): """ :param model_files: list[string] :param suffix: string """ suffix_only_model_files = [] for model in model_files: model_suffix = get_suffix_from_model_file_name(model) if model_suffix == suffix: suffix_only_model_files.append(model) return suffix_only_model_files
def get_poisoned_worker_ids_from_log(log_path): """ :param log_path: string """ with open(log_path, 'r') as f: file_lines = [line.strip() for line in f.readlines() if 'Poisoning data for workers:' in line] workers = file_lines[0].split('[')[1].split(']')[0] workers_list = workers.split(', ') return [int(worker) for worker in workers_list] def get_worker_num_from_model_file_name(model_file_name): """ :param model_file_name: string """ return int(model_file_name.split('_')[1]) def get_epoch_num_from_model_file_name(model_file_name): """ :param model_file_name: string """ return int(model_file_name.split('_')[2].split('.')[0]) def get_suffix_from_model_file_name(model_file_name): """ :param model_file_name: string """ return model_file_name.split('_')[3].split('.')[0] def get_model_files_for_worker(model_files, worker_id): """ :param model_files: list[string] :param worker_id: int """ worker_model_files = [] for model in model_files: worker_num = get_worker_num_from_model_file_name(model) if worker_num == worker_id: worker_model_files.append(model) return worker_model_files def get_model_files_for_epoch(model_files, epoch_num): """ :param model_files: list[string] :param epoch_num: int """ epoch_model_files = [] for model in model_files: model_epoch_num = get_epoch_num_from_model_file_name(model) if model_epoch_num == epoch_num: epoch_model_files.append(model) return epoch_model_files def get_model_files_for_suffix(model_files, suffix): """ :param model_files: list[string] :param suffix: string """ suffix_only_model_files = [] for model in model_files: model_suffix = get_suffix_from_model_file_name(model) if model_suffix == suffix: suffix_only_model_files.append(model) return suffix_only_model_files
# It must be here to retrieve this information from the dummy core_universal_identifier = 'd9d94986-ea14-11e0-bd1d-00216a5807c8' core_universal_identifier_human = 'Consumer' db_database = "WebLabTests" weblab_db_username = 'weblab' weblab_db_password = 'weblab' debug_mode = True ######################### # General configuration # ######################### server_hostaddress = 'weblab.deusto.es' server_admin = 'weblab@deusto.es' ################################ # Admin Notifier configuration # ################################ mail_notification_enabled = False ########################## # Sessions configuration # ########################## session_mysql_username = 'weblab' session_mysql_password = 'weblab' session_locker_mysql_username = session_mysql_username session_locker_mysql_password = session_mysql_password
core_universal_identifier = 'd9d94986-ea14-11e0-bd1d-00216a5807c8' core_universal_identifier_human = 'Consumer' db_database = 'WebLabTests' weblab_db_username = 'weblab' weblab_db_password = 'weblab' debug_mode = True server_hostaddress = 'weblab.deusto.es' server_admin = 'weblab@deusto.es' mail_notification_enabled = False session_mysql_username = 'weblab' session_mysql_password = 'weblab' session_locker_mysql_username = session_mysql_username session_locker_mysql_password = session_mysql_password
__author__ = "Shaban Hassan [shaban00]" """ Regiser all routes for flask socket io """ # SOCKET_EVENTS = [ # { # "event": "connect", # "func": "connect", # "namespace": "namespace" # } # ] SOCKET_EVENTS = []
__author__ = 'Shaban Hassan [shaban00]' ' Regiser all routes for flask socket io ' socket_events = []
if __name__ == '__main__': n, m = list(map(int, input().split(" "))) arr = list(map(int, input().split(" "))) set_a = set(map(int, input().split(" "))) set_b = set(map(int, input().split(' '))) print(sum([1 if e in set_a else -1 if e in set_b else 0 for e in arr]))
if __name__ == '__main__': (n, m) = list(map(int, input().split(' '))) arr = list(map(int, input().split(' '))) set_a = set(map(int, input().split(' '))) set_b = set(map(int, input().split(' '))) print(sum([1 if e in set_a else -1 if e in set_b else 0 for e in arr]))
""" You are given an m x n 2D image matrix (List of Lists) where each integer represents a pixel. Flip it in-place along its horizontal axis. Example: Input image : 1 1 0 0 Modified to : 0 0 1 1 """ def flip_horizontal_axis(matrix): """ Returns a list of lists in reverse order. :param matrix: list of lists :return: list of lists reversed """ matrix.reverse()
""" You are given an m x n 2D image matrix (List of Lists) where each integer represents a pixel. Flip it in-place along its horizontal axis. Example: Input image : 1 1 0 0 Modified to : 0 0 1 1 """ def flip_horizontal_axis(matrix): """ Returns a list of lists in reverse order. :param matrix: list of lists :return: list of lists reversed """ matrix.reverse()
# Given a binary tree, find a minimum path sum from root to a leaf. # For example, the minimum path in this tree is [10, 5, 1, -1], which has sum 15. # 10 # / \ # 5 5 # \ \ # 2 1 # / # -1 class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def min_path(node): path_values = [] def search_path(node, path=0): path += node.value if node.left is None and node.right is None: path_values.append(path) return if node.left: search_path(node.left, path) if node.right: search_path(node.right, path) search_path(node) return min(path_values) if __name__ == "__main__": tree = Node(10, Node(5, right=Node(2)), Node(5, right=Node(1, Node(-1)))) print(min_path(tree))
class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def min_path(node): path_values = [] def search_path(node, path=0): path += node.value if node.left is None and node.right is None: path_values.append(path) return if node.left: search_path(node.left, path) if node.right: search_path(node.right, path) search_path(node) return min(path_values) if __name__ == '__main__': tree = node(10, node(5, right=node(2)), node(5, right=node(1, node(-1)))) print(min_path(tree))
expected_output = { "interface": { "GigabitEthernet3.90": { "interface": "GigabitEthernet3.90", "neighbors": { "FE80::5C00:40FF:FEFF:209": { "age": "22", "ip": "FE80::5C00:40FF:FEFF:209", "link_layer_address": "5e00.40ff.0209", "neighbor_state": "STALE", } }, } } }
expected_output = {'interface': {'GigabitEthernet3.90': {'interface': 'GigabitEthernet3.90', 'neighbors': {'FE80::5C00:40FF:FEFF:209': {'age': '22', 'ip': 'FE80::5C00:40FF:FEFF:209', 'link_layer_address': '5e00.40ff.0209', 'neighbor_state': 'STALE'}}}}}
class Solution: def rob(self, nums: List[int]) -> int: dp = [num for num in nums] for i in range(2, len(nums)): dp[i] += max(dp[:i-1]) return max(dp)
class Solution: def rob(self, nums: List[int]) -> int: dp = [num for num in nums] for i in range(2, len(nums)): dp[i] += max(dp[:i - 1]) return max(dp)
print("Statements") print("Statement does something, while expression is something") 2*2 # this is an expression, it will not do anything if not using interactive interpreter. print(2*2) #this is an statement, it does print x=3 #this is also an statement, it has no values to print out, but x is already assigned.
print('Statements') print('Statement does something, while expression is something') 2 * 2 print(2 * 2) x = 3
# This problem was recently asked by Google: # Given a sorted list, create a height balanced binary search tree, # meaning the height differences of each node can only differ by at most 1. class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def __str__(self): answer = str(self.value) if self.left: answer += str(self.left) if self.right: answer += str(self.right) return answer def create_height_balanced_bst(nums): # Fill this in. if not nums: return None mid = int((len(nums)) / 2) root = Node(nums[mid]) root.left = create_height_balanced_bst(nums[:mid]) root.right = create_height_balanced_bst(nums[mid + 1 :]) return root tree = create_height_balanced_bst([1, 2, 3, 4, 5, 6, 7, 8]) print(tree) # 53214768 # (pre-order traversal) # 5 # / \ # 3 7 # / \ / \ # 2 4 6 8 # / # 1
class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def __str__(self): answer = str(self.value) if self.left: answer += str(self.left) if self.right: answer += str(self.right) return answer def create_height_balanced_bst(nums): if not nums: return None mid = int(len(nums) / 2) root = node(nums[mid]) root.left = create_height_balanced_bst(nums[:mid]) root.right = create_height_balanced_bst(nums[mid + 1:]) return root tree = create_height_balanced_bst([1, 2, 3, 4, 5, 6, 7, 8]) print(tree)
# Copyright 2021 PaddleFSL Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. __all__ = ['count_model_params'] def count_model_params(model): """ Calculate the number of parameters of the model. Args: model(paddle.nn.Layer): model to be counted. Returns: None. """ print(model) param_size = {} cnt = 0 for name, p in model.named_parameters(): k = name.split('.')[0] if k not in param_size: param_size[k] = 0 p_cnt = 1 # for j in p.size(): for j in p.shape: p_cnt *= j param_size[k] += p_cnt cnt += p_cnt for k, v in param_size.items(): print(f"Number of parameters for {k} = {round(v / 1024, 2)} k") print(f"Total parameters of model = {round(cnt / 1024, 2)} k")
__all__ = ['count_model_params'] def count_model_params(model): """ Calculate the number of parameters of the model. Args: model(paddle.nn.Layer): model to be counted. Returns: None. """ print(model) param_size = {} cnt = 0 for (name, p) in model.named_parameters(): k = name.split('.')[0] if k not in param_size: param_size[k] = 0 p_cnt = 1 for j in p.shape: p_cnt *= j param_size[k] += p_cnt cnt += p_cnt for (k, v) in param_size.items(): print(f'Number of parameters for {k} = {round(v / 1024, 2)} k') print(f'Total parameters of model = {round(cnt / 1024, 2)} k')
#--------------------------------------------------------------------------------------------------- # Tiparoj #--------------------------------------------------------------------------------------------------- c.fonts.completion.category = "bold 8pt monospace" c.fonts.completion.entry = "8pt monospace" c.fonts.debug_console = "8pt monospace" c.fonts.downloads = "8pt monospace" c.fonts.hints = "bold 8pt monospace" c.fonts.keyhint = "8pt monospace" c.fonts.messages.error = "8pt monospace" c.fonts.messages.info = "8pt monospace" c.fonts.messages.warning = "8pt monospace" c.fonts.prompts = "8pt sans-serif" c.fonts.statusbar = "8pt monospace" c.fonts.tabs.selected = "8pt sans-serif" c.fonts.tabs.unselected = "8pt sans-serif" c.fonts.default_family = "Monospace, DejaVu Sans Mono"
c.fonts.completion.category = 'bold 8pt monospace' c.fonts.completion.entry = '8pt monospace' c.fonts.debug_console = '8pt monospace' c.fonts.downloads = '8pt monospace' c.fonts.hints = 'bold 8pt monospace' c.fonts.keyhint = '8pt monospace' c.fonts.messages.error = '8pt monospace' c.fonts.messages.info = '8pt monospace' c.fonts.messages.warning = '8pt monospace' c.fonts.prompts = '8pt sans-serif' c.fonts.statusbar = '8pt monospace' c.fonts.tabs.selected = '8pt sans-serif' c.fonts.tabs.unselected = '8pt sans-serif' c.fonts.default_family = 'Monospace, DejaVu Sans Mono'
class Account: """An account has a balance and a holder. >>> a = Account('John') >>> a.holder 'John' >>> a.deposit(100) 100 >>> a.withdraw(90) 10 >>> a.withdraw(90) 'Insufficient funds' >>> a.balance 10 >>> a.interest 0.02 """ interest = 0.02 # A class attribute def __init__(self, account_holder): self.holder = account_holder self.balance = 0 def deposit(self, amount): """Add amount to balance.""" self.balance = self.balance + amount return self.balance def withdraw(self, amount): """Subtract amount from balance if funds are available.""" if amount > self.balance: return 'Insufficient funds' self.balance = self.balance - amount return self.balance class CheckingAccount(Account): """A bank account that charges for withdrawals. >>> ch = CheckingAccount('Jack') >>> ch.balance = 20 >>> ch.withdraw(5) 14 >>> ch.interest 0.01 """ withdraw_fee = 1 interest = 0.01 def withdraw(self, amount): return Account.withdraw(self, amount + self.withdraw_fee) # Alternatively: return super().withdraw(amount + self.withdraw_fee) class Bank: """A bank has accounts and pays interest. >>> bank = Bank() >>> john = bank.open_account('John', 10) >>> jack = bank.open_account('Jack', 5, CheckingAccount) >>> jack.interest 0.01 >>> john.interest = 0.06 >>> bank.pay_interest() >>> john.balance 10.6 >>> jack.balance 5.05 """ def __init__(self): self.accounts = [] def open_account(self, holder, amount, account_type=Account): """Open an account_type for holder and deposit amount.""" account = account_type(holder) account.deposit(amount) self.accounts.append(account) return account def pay_interest(self): """Pay interest to all accounts.""" for account in self.accounts: account.deposit(account.balance * account.interest) # Inheritance Example class A: z = -1 def f(self, x): return B(x-1) class B(A): n = 4 def __init__(self, y): if y: self.z = self.f(y) else: self.z = C(y+1) class C(B): def f(self, x): return x def WWPD(): """What would Python Display? >>> a = A() >>> b = B(1) >>> b.n = 5 >>> C(2).n 4 >>> C(2).z 2 >>> a.z == C.z True >>> a.z == b.z False >>> b.z.z.z 1 """ # Multiple Inheritance class SavingsAccount(Account): """A bank account that charges for deposits.""" deposit_fee = 2 def deposit(self, amount): return Account.deposit(self, amount - self.deposit_fee) class AsSeenOnTVAccount(CheckingAccount, SavingsAccount): """A bank account that charges for everything.""" def __init__(self, account_holder): self.holder = account_holder self.balance = 1 # A free dollar! supers = [c.__name__ for c in AsSeenOnTVAccount.mro()]
class Account: """An account has a balance and a holder. >>> a = Account('John') >>> a.holder 'John' >>> a.deposit(100) 100 >>> a.withdraw(90) 10 >>> a.withdraw(90) 'Insufficient funds' >>> a.balance 10 >>> a.interest 0.02 """ interest = 0.02 def __init__(self, account_holder): self.holder = account_holder self.balance = 0 def deposit(self, amount): """Add amount to balance.""" self.balance = self.balance + amount return self.balance def withdraw(self, amount): """Subtract amount from balance if funds are available.""" if amount > self.balance: return 'Insufficient funds' self.balance = self.balance - amount return self.balance class Checkingaccount(Account): """A bank account that charges for withdrawals. >>> ch = CheckingAccount('Jack') >>> ch.balance = 20 >>> ch.withdraw(5) 14 >>> ch.interest 0.01 """ withdraw_fee = 1 interest = 0.01 def withdraw(self, amount): return Account.withdraw(self, amount + self.withdraw_fee) return super().withdraw(amount + self.withdraw_fee) class Bank: """A bank has accounts and pays interest. >>> bank = Bank() >>> john = bank.open_account('John', 10) >>> jack = bank.open_account('Jack', 5, CheckingAccount) >>> jack.interest 0.01 >>> john.interest = 0.06 >>> bank.pay_interest() >>> john.balance 10.6 >>> jack.balance 5.05 """ def __init__(self): self.accounts = [] def open_account(self, holder, amount, account_type=Account): """Open an account_type for holder and deposit amount.""" account = account_type(holder) account.deposit(amount) self.accounts.append(account) return account def pay_interest(self): """Pay interest to all accounts.""" for account in self.accounts: account.deposit(account.balance * account.interest) class A: z = -1 def f(self, x): return b(x - 1) class B(A): n = 4 def __init__(self, y): if y: self.z = self.f(y) else: self.z = c(y + 1) class C(B): def f(self, x): return x def wwpd(): """What would Python Display? >>> a = A() >>> b = B(1) >>> b.n = 5 >>> C(2).n 4 >>> C(2).z 2 >>> a.z == C.z True >>> a.z == b.z False >>> b.z.z.z 1 """ class Savingsaccount(Account): """A bank account that charges for deposits.""" deposit_fee = 2 def deposit(self, amount): return Account.deposit(self, amount - self.deposit_fee) class Asseenontvaccount(CheckingAccount, SavingsAccount): """A bank account that charges for everything.""" def __init__(self, account_holder): self.holder = account_holder self.balance = 1 supers = [c.__name__ for c in AsSeenOnTVAccount.mro()]
_base_ = 'ranksort_cascade_rcnn_r50_fpn_1x_coco.py' model = dict(roi_head=dict(stage_loss_weights=[1, 0.50, 0.25]))
_base_ = 'ranksort_cascade_rcnn_r50_fpn_1x_coco.py' model = dict(roi_head=dict(stage_loss_weights=[1, 0.5, 0.25]))
{ "targets": [ { "target_name": "pcap_binding", 'win_delay_load_hook': 'true', "sources": [ "npcap_binding.cpp","npcap_session.cpp"], "include_dirs": ["npcap/Include","<!@(node -p \"require('node-addon-api').include\")"], "libraries": [ "<(module_root_dir)/npcap/Lib/x64/Packet.lib", "<(module_root_dir)/npcap/Lib/x64/wpcap.lib", "Ws2_32.lib" ], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS','NAPI_EXPERIMENTAL'], 'target_conditions': [ ['_win_delay_load_hook=="true"', { # If the addon specifies `'win_delay_load_hook': 'true'` in its # binding.gyp, link a delay-load hook into the DLL. This hook ensures # that the addon will work regardless of whether the node/iojs binary # is named node.exe, iojs.exe, or something else. 'conditions': [ [ 'OS=="win"', { 'defines': [ 'HOST_BINARY=\"<(node_host_binary)<(EXECUTABLE_SUFFIX)\"', ], 'sources': [ '<(node_gyp_dir)/src/win_delay_load_hook.cc', ], 'msvs_settings': { 'VCLinkerTool': { 'DelayLoadDLLs': [ '<(node_host_binary)<(EXECUTABLE_SUFFIX)','wpcap.dll' ], # Don't print a linker warning when no imports from either .exe # are used. 'AdditionalOptions': [ '/ignore:4199' ], }, }, }], ], }], ], } ] }
{'targets': [{'target_name': 'pcap_binding', 'win_delay_load_hook': 'true', 'sources': ['npcap_binding.cpp', 'npcap_session.cpp'], 'include_dirs': ['npcap/Include', '<!@(node -p "require(\'node-addon-api\').include")'], 'libraries': ['<(module_root_dir)/npcap/Lib/x64/Packet.lib', '<(module_root_dir)/npcap/Lib/x64/wpcap.lib', 'Ws2_32.lib'], 'defines': ['NAPI_DISABLE_CPP_EXCEPTIONS', 'NAPI_EXPERIMENTAL'], 'target_conditions': [['_win_delay_load_hook=="true"', {'conditions': [['OS=="win"', {'defines': ['HOST_BINARY="<(node_host_binary)<(EXECUTABLE_SUFFIX)"'], 'sources': ['<(node_gyp_dir)/src/win_delay_load_hook.cc'], 'msvs_settings': {'VCLinkerTool': {'DelayLoadDLLs': ['<(node_host_binary)<(EXECUTABLE_SUFFIX)', 'wpcap.dll'], 'AdditionalOptions': ['/ignore:4199']}}}]]}]]}]}
class Config(object): # game setting row_size = 6 column_size = 6 piece_in_line = 4 black_first = True max_num_round = 36 # mcts temperature = 1.0 playout_times = 100 # num of simulations for each move c_puct = 5. # data num_games_per_generation = 10 batch_size = 32 # mini-batch size for training buffer_size = 10000 data_buffer_size = 10000 # train epoch_per_dataset = 5 # num of train_steps for each update max_epochs = 1000 # learning_rate = 1e-3 # lr_multiplier = 1.0 # adaptively adjust the learning rate based on KL # saved model saved_dir = 'saved' def __init__(self, **kwargs): for k, v in kwargs: self.__setattr__(k, v)
class Config(object): row_size = 6 column_size = 6 piece_in_line = 4 black_first = True max_num_round = 36 temperature = 1.0 playout_times = 100 c_puct = 5.0 num_games_per_generation = 10 batch_size = 32 buffer_size = 10000 data_buffer_size = 10000 epoch_per_dataset = 5 max_epochs = 1000 saved_dir = 'saved' def __init__(self, **kwargs): for (k, v) in kwargs: self.__setattr__(k, v)
class TooLarge(Exception): """The input was too long.""" def __init__(self): super(TooLarge, self).__init__("That number was too large.") class ImproperFormat(Exception): """Invalid Format was given.""" def __init__(self): super(ImproperFormat, self).__init__("An Invalid Format was given.") class NoTimeZone(Exception): """No Timezone was found.""" def __init__(self): super(NoTimeZone, self).__init__("The user did not have a timezone.")
class Toolarge(Exception): """The input was too long.""" def __init__(self): super(TooLarge, self).__init__('That number was too large.') class Improperformat(Exception): """Invalid Format was given.""" def __init__(self): super(ImproperFormat, self).__init__('An Invalid Format was given.') class Notimezone(Exception): """No Timezone was found.""" def __init__(self): super(NoTimeZone, self).__init__('The user did not have a timezone.')
""" Description Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Please implement encode and decode Example Example1 Input: ["lint","code","love","you"] Output: ["lint","code","love","you"] Explanation: One possible encode method is: "lint:;code:;love:;you" Example2 Input: ["we", "say", ":", "yes"] Output: ["we", "say", ":", "yes"] Explanation: One possible encode method is: "we:;say:;:::;yes" """ class Solution: def encode(self, strs): res = "" for s in strs: # encode the strings to one string by adding the length of the string and # before the string res += str(len(s)) + '#' + s return res def decode(self, str): # set i to be initially 0 res, i = [], 0 # while i is less than the length of the str while i < len(str): # we set j to be the current value of i j = i # while the char at j is not # while str[j] != '#': j += 1 # get lenth on the string length = int(str[i:j]) # we start at j+1 since we know the next character from # is where our string starts # we end at j+length+1 since we now have the total length of the string, we add 1 since we start at j+1 res.append(str[j+1: j+length+1]) # we reset i to be the start of the next word i = j+length+1 return res soln = Solution() print(soln.encode(['my', 'dad', 'is', 'coming'])) # output - 2#my3#dad2#is6#coming print(soln.decode('2#my3#dad2#is6#coming'))
""" Description Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Please implement encode and decode Example Example1 Input: ["lint","code","love","you"] Output: ["lint","code","love","you"] Explanation: One possible encode method is: "lint:;code:;love:;you" Example2 Input: ["we", "say", ":", "yes"] Output: ["we", "say", ":", "yes"] Explanation: One possible encode method is: "we:;say:;:::;yes" """ class Solution: def encode(self, strs): res = '' for s in strs: res += str(len(s)) + '#' + s return res def decode(self, str): (res, i) = ([], 0) while i < len(str): j = i while str[j] != '#': j += 1 length = int(str[i:j]) res.append(str[j + 1:j + length + 1]) i = j + length + 1 return res soln = solution() print(soln.encode(['my', 'dad', 'is', 'coming'])) print(soln.decode('2#my3#dad2#is6#coming'))
# Demonstrate how to use dictionary comprehensions def main(): # define a list of temperature values ctemps = [0, 12, 34, 100] # Use a comprehension to build a dictionary tempDict = {t: (t * 9/5) + 32 for t in ctemps if t < 100} print(tempDict) print(tempDict[12]) # Merge two dictionaries with a comprehension team1 = {"Jones": 24, "Jameson": 18, "Smith": 58, "Burns": 7} team2 = {"White": 12, "Macke": 88, "Perce": 4} newTeam = {k: v for team in (team1, team2) for k, v in team.items()} print(newTeam) if __name__ == "__main__": main()
def main(): ctemps = [0, 12, 34, 100] temp_dict = {t: t * 9 / 5 + 32 for t in ctemps if t < 100} print(tempDict) print(tempDict[12]) team1 = {'Jones': 24, 'Jameson': 18, 'Smith': 58, 'Burns': 7} team2 = {'White': 12, 'Macke': 88, 'Perce': 4} new_team = {k: v for team in (team1, team2) for (k, v) in team.items()} print(newTeam) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- """Collection of exceptions raised by requests-toolbelt.""" class StreamingError(Exception): """Used in :mod:`requests_toolbelt.downloadutils.stream`.""" pass class VersionMismatchError(Exception): """Used to indicate a version mismatch in the version of requests required. The feature in use requires a newer version of Requests to function appropriately but the version installed is not sufficient. """ pass class RequestsVersionTooOld(Warning): """Used to indicate that the Requests version is too old. If the version of Requests is too old to support a feature, we will issue this warning to the user. """ pass class IgnoringGAECertificateValidation(Warning): """Used to indicate that given GAE validation behavior will be ignored. If the user has tried to specify certificate validation when using the insecure AppEngine adapter, it will be ignored (certificate validation will remain off), so we will issue this warning to the user. In :class:`requests_toolbelt.adapters.appengine.InsecureAppEngineAdapter`. """ pass
"""Collection of exceptions raised by requests-toolbelt.""" class Streamingerror(Exception): """Used in :mod:`requests_toolbelt.downloadutils.stream`.""" pass class Versionmismatcherror(Exception): """Used to indicate a version mismatch in the version of requests required. The feature in use requires a newer version of Requests to function appropriately but the version installed is not sufficient. """ pass class Requestsversiontooold(Warning): """Used to indicate that the Requests version is too old. If the version of Requests is too old to support a feature, we will issue this warning to the user. """ pass class Ignoringgaecertificatevalidation(Warning): """Used to indicate that given GAE validation behavior will be ignored. If the user has tried to specify certificate validation when using the insecure AppEngine adapter, it will be ignored (certificate validation will remain off), so we will issue this warning to the user. In :class:`requests_toolbelt.adapters.appengine.InsecureAppEngineAdapter`. """ pass
class Config(): def __init__(self): self.type = "a2c" self.gamma = 0.99 self.learning_rate = 0.001 self.entropy_beta = 0.01 self.batch_size = 128
class Config: def __init__(self): self.type = 'a2c' self.gamma = 0.99 self.learning_rate = 0.001 self.entropy_beta = 0.01 self.batch_size = 128
width = const(7) height = const(12) data = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\x10\x10\x00\x00\x10\x00\x00\x00\x00lHH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x14(|(|(PP\x00\x00\x00\x108@@8Hp\x10\x10\x00\x00\x00 P \x0cp\x08\x14\x08\x00\x00\x00\x00\x00\x00\x18 TH4\x00\x00\x00\x00\x10\x10\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x08\x08\x10\x10\x10\x10\x10\x10\x08\x08\x00\x00 \x10\x10\x10\x10\x10\x10 \x00\x00\x10|\x10((\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\xfe\x10\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x100 \x00\x00\x00\x00\x00\x00|\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0000\x00\x00\x00\x00\x04\x04\x08\x08\x10\x10 @\x00\x00\x008DDDDDD8\x00\x00\x00\x000\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x008D\x04\x08\x10 D|\x00\x00\x00\x008D\x04\x18\x04\x04D8\x00\x00\x00\x00\x0c\x14\x14$D~\x04\x0e\x00\x00\x00\x00< 8\x04\x04D8\x00\x00\x00\x00\x1c @xDDD8\x00\x00\x00\x00|D\x04\x08\x08\x08\x10\x10\x00\x00\x00\x008DD8DDD8\x00\x00\x00\x008DDD<\x04\x08p\x00\x00\x00\x00\x00\x0000\x00\x0000\x00\x00\x00\x00\x00\x00\x18\x18\x00\x00\x180 \x00\x00\x00\x00\x0c\x10`\x80`\x10\x0c\x00\x00\x00\x00\x00\x00\x00|\x00|\x00\x00\x00\x00\x00\x00\x00\xc0 \x18\x04\x18 \xc0\x00\x00\x00\x00\x00\x18$\x04\x08\x10\x000\x00\x00\x008DDLTTL@D8\x00\x00\x000\x10(((|D\xee\x00\x00\x00\x00\xf8DDxDDD\xf8\x00\x00\x00\x00<D@@@@D8\x00\x00\x00\x00\xf0HDDDDH\xf0\x00\x00\x00\x00\xfcDPpP@D\xfc\x00\x00\x00\x00~"(8( p\x00\x00\x00\x00<D@@NDD8\x00\x00\x00\x00\xeeDD|DDD\xee\x00\x00\x00\x00|\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x00<\x08\x08\x08HHH0\x00\x00\x00\x00\xeeDHPpHD\xe6\x00\x00\x00\x00p $$|\x00\x00\x00\x00\xeellTTDD\xee\x00\x00\x00\x00\xeeddTTTL\xec\x00\x00\x00\x008DDDDDD8\x00\x00\x00\x00x$$$8 p\x00\x00\x00\x008DDDDDD8\x1c\x00\x00\x00\xf8DDDxHD\xe2\x00\x00\x00\x004L@8\x04\x04dX\x00\x00\x00\x00\xfe\x92\x10\x10\x10\x10\x108\x00\x00\x00\x00\xeeDDDDDD8\x00\x00\x00\x00\xeeDD(((\x10\x10\x00\x00\x00\x00\xeeDDTTTT(\x00\x00\x00\x00\xc6D(\x10\x10(D\xc6\x00\x00\x00\x00\xeeD((\x10\x10\x108\x00\x00\x00\x00|D\x08\x10\x10 D|\x00\x00\x00\x008 8\x00\x00@ \x10\x10\x08\x08\x08\x00\x00\x008\x08\x08\x08\x08\x08\x08\x08\x088\x00\x00\x10\x10(D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x008D<DD>\x00\x00\x00\x00\xc0@XdDDD\xf8\x00\x00\x00\x00\x00\x00<D@@D8\x00\x00\x00\x00\x0c\x044LDDD>\x00\x00\x00\x00\x00\x008D|@@<\x00\x00\x00\x00\x1c | |\x00\x00\x00\x00\x00\x006LDDD<\x048\x00\x00\xc0@XdDDD\xee\x00\x00\x00\x00\x10\x00p\x10\x10\x10\x10|\x00\x00\x00\x00\x10\x00x\x08\x08\x08\x08\x08\x08p\x00\x00\xc0@\\HpPH\xdc\x00\x00\x00\x000\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x00\x00\x00\xe8TTTT\xfe\x00\x00\x00\x00\x00\x00\xd8dDDD\xee\x00\x00\x00\x00\x00\x008DDDD8\x00\x00\x00\x00\x00\x00\xd8dDDDx@\xe0\x00\x00\x00\x006LDDD<\x04\x0e\x00\x00\x00\x00l0 |\x00\x00\x00\x00\x00\x00<D8\x04Dx\x00\x00\x00\x00\x00 | "\x1c\x00\x00\x00\x00\x00\x00\xccDDDL6\x00\x00\x00\x00\x00\x00\xeeDD((\x10\x00\x00\x00\x00\x00\x00\xeeDTTT(\x00\x00\x00\x00\x00\x00\xccH00H\xcc\x00\x00\x00\x00\x00\x00\xeeD$(\x18\x10\x10x\x00\x00\x00\x00|H\x10 D|\x00\x00\x00\x00\x08\x10\x10\x10\x10 \x10\x10\x10\x08\x00\x00\x10\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00 \x10\x10\x10\x10\x08\x10\x10\x10 \x00\x00\x00\x00\x00\x00$X\x00\x00\x00\x00\x00'
width = const(7) height = const(12) data = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\x10\x10\x00\x00\x10\x00\x00\x00\x00lHH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x14(|(|(PP\x00\x00\x00\x108@@8Hp\x10\x10\x00\x00\x00 P \x0cp\x08\x14\x08\x00\x00\x00\x00\x00\x00\x18 TH4\x00\x00\x00\x00\x10\x10\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x08\x08\x10\x10\x10\x10\x10\x10\x08\x08\x00\x00 \x10\x10\x10\x10\x10\x10 \x00\x00\x10|\x10((\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\xfe\x10\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x100 \x00\x00\x00\x00\x00\x00|\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0000\x00\x00\x00\x00\x04\x04\x08\x08\x10\x10 @\x00\x00\x008DDDDDD8\x00\x00\x00\x000\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x008D\x04\x08\x10 D|\x00\x00\x00\x008D\x04\x18\x04\x04D8\x00\x00\x00\x00\x0c\x14\x14$D~\x04\x0e\x00\x00\x00\x00< 8\x04\x04D8\x00\x00\x00\x00\x1c @xDDD8\x00\x00\x00\x00|D\x04\x08\x08\x08\x10\x10\x00\x00\x00\x008DD8DDD8\x00\x00\x00\x008DDD<\x04\x08p\x00\x00\x00\x00\x00\x0000\x00\x0000\x00\x00\x00\x00\x00\x00\x18\x18\x00\x00\x180 \x00\x00\x00\x00\x0c\x10`\x80`\x10\x0c\x00\x00\x00\x00\x00\x00\x00|\x00|\x00\x00\x00\x00\x00\x00\x00\xc0 \x18\x04\x18 \xc0\x00\x00\x00\x00\x00\x18$\x04\x08\x10\x000\x00\x00\x008DDLTTL@D8\x00\x00\x000\x10(((|D\xee\x00\x00\x00\x00\xf8DDxDDD\xf8\x00\x00\x00\x00<D@@@@D8\x00\x00\x00\x00\xf0HDDDDH\xf0\x00\x00\x00\x00\xfcDPpP@D\xfc\x00\x00\x00\x00~"(8( p\x00\x00\x00\x00<D@@NDD8\x00\x00\x00\x00\xeeDD|DDD\xee\x00\x00\x00\x00|\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x00<\x08\x08\x08HHH0\x00\x00\x00\x00\xeeDHPpHD\xe6\x00\x00\x00\x00p $$|\x00\x00\x00\x00\xeellTTDD\xee\x00\x00\x00\x00\xeeddTTTL\xec\x00\x00\x00\x008DDDDDD8\x00\x00\x00\x00x$$$8 p\x00\x00\x00\x008DDDDDD8\x1c\x00\x00\x00\xf8DDDxHD\xe2\x00\x00\x00\x004L@8\x04\x04dX\x00\x00\x00\x00\xfe\x92\x10\x10\x10\x10\x108\x00\x00\x00\x00\xeeDDDDDD8\x00\x00\x00\x00\xeeDD(((\x10\x10\x00\x00\x00\x00\xeeDDTTTT(\x00\x00\x00\x00\xc6D(\x10\x10(D\xc6\x00\x00\x00\x00\xeeD((\x10\x10\x108\x00\x00\x00\x00|D\x08\x10\x10 D|\x00\x00\x00\x008 8\x00\x00@ \x10\x10\x08\x08\x08\x00\x00\x008\x08\x08\x08\x08\x08\x08\x08\x088\x00\x00\x10\x10(D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\x00\x10\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x008D<DD>\x00\x00\x00\x00\xc0@XdDDD\xf8\x00\x00\x00\x00\x00\x00<D@@D8\x00\x00\x00\x00\x0c\x044LDDD>\x00\x00\x00\x00\x00\x008D|@@<\x00\x00\x00\x00\x1c | |\x00\x00\x00\x00\x00\x006LDDD<\x048\x00\x00\xc0@XdDDD\xee\x00\x00\x00\x00\x10\x00p\x10\x10\x10\x10|\x00\x00\x00\x00\x10\x00x\x08\x08\x08\x08\x08\x08p\x00\x00\xc0@\\HpPH\xdc\x00\x00\x00\x000\x10\x10\x10\x10\x10\x10|\x00\x00\x00\x00\x00\x00\xe8TTTT\xfe\x00\x00\x00\x00\x00\x00\xd8dDDD\xee\x00\x00\x00\x00\x00\x008DDDD8\x00\x00\x00\x00\x00\x00\xd8dDDDx@\xe0\x00\x00\x00\x006LDDD<\x04\x0e\x00\x00\x00\x00l0 |\x00\x00\x00\x00\x00\x00<D8\x04Dx\x00\x00\x00\x00\x00 | "\x1c\x00\x00\x00\x00\x00\x00\xccDDDL6\x00\x00\x00\x00\x00\x00\xeeDD((\x10\x00\x00\x00\x00\x00\x00\xeeDTTT(\x00\x00\x00\x00\x00\x00\xccH00H\xcc\x00\x00\x00\x00\x00\x00\xeeD$(\x18\x10\x10x\x00\x00\x00\x00|H\x10 D|\x00\x00\x00\x00\x08\x10\x10\x10\x10 \x10\x10\x10\x08\x00\x00\x10\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00 \x10\x10\x10\x10\x08\x10\x10\x10 \x00\x00\x00\x00\x00\x00$X\x00\x00\x00\x00\x00'
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def binaryTreePaths(self, root: TreeNode) -> List[str]: if not root: return [] result = [] if root.left or root.right: for path in self.binaryTreePaths(root.left): result.append(str(root.val) + "->" + path) for path in self.binaryTreePaths(root.right): result.append(str(root.val) + "->" + path) return result else: return [str(root.val)]
class Solution: def binary_tree_paths(self, root: TreeNode) -> List[str]: if not root: return [] result = [] if root.left or root.right: for path in self.binaryTreePaths(root.left): result.append(str(root.val) + '->' + path) for path in self.binaryTreePaths(root.right): result.append(str(root.val) + '->' + path) return result else: return [str(root.val)]
class Solution(object): def countComponents(self, n, edges): """ :type n: int :type edges: List[List[int]] :rtype: int """ V = [[] for _ in range(n)] for e in edges: V[e[0]].append(e[1]) V[e[1]].append(e[0]) visited = [False for _ in range(n)] cnt = 0 for v in range(n): if not visited[v]: cnt += 1 self.dfs(V, v, visited) return cnt def dfs(self, V, v, visited): visited[v] = True for nbr in V[v]: if not visited[nbr]: self.dfs(V, nbr, visited)
class Solution(object): def count_components(self, n, edges): """ :type n: int :type edges: List[List[int]] :rtype: int """ v = [[] for _ in range(n)] for e in edges: V[e[0]].append(e[1]) V[e[1]].append(e[0]) visited = [False for _ in range(n)] cnt = 0 for v in range(n): if not visited[v]: cnt += 1 self.dfs(V, v, visited) return cnt def dfs(self, V, v, visited): visited[v] = True for nbr in V[v]: if not visited[nbr]: self.dfs(V, nbr, visited)
class Solution: def calculate(self, s: str) -> int: inner, outer, result, opt = 0, 0, 0, '+' for c in s+'+': if c == ' ': continue if c.isdigit(): inner = 10*inner + int(c) continue if opt == '+': result += outer outer = inner elif opt == '-': result += outer outer = -inner elif opt == '*': outer = outer*inner elif opt == '/': outer = int(outer/inner) inner, opt = 0, c return result + outer
class Solution: def calculate(self, s: str) -> int: (inner, outer, result, opt) = (0, 0, 0, '+') for c in s + '+': if c == ' ': continue if c.isdigit(): inner = 10 * inner + int(c) continue if opt == '+': result += outer outer = inner elif opt == '-': result += outer outer = -inner elif opt == '*': outer = outer * inner elif opt == '/': outer = int(outer / inner) (inner, opt) = (0, c) return result + outer
client_id="You need to fill this" client_secret="You need to fill this" user_agent="You need to fill this" username="You need to fill this" password="You need to fill this"
client_id = 'You need to fill this' client_secret = 'You need to fill this' user_agent = 'You need to fill this' username = 'You need to fill this' password = 'You need to fill this'
targets = [int(target) for target in input().split()] command = input().split() while "End" not in command: index = int(command[1]) if "Shoot" in command: power = int(command[2]) if 0 <= index < len(targets): targets[index] -= power if targets[index] <= 0: targets.pop(index) elif "Add" in command: value = int(command[2]) if 0 <= index < len(targets): targets.insert(index, value) else: print("Invalid placement!") elif "Strike" in command: radius = int(command[2]) if (index - radius) >= 0 and (index + radius) < len(targets): for _ in range(radius): targets.pop(index+1) targets.pop(index) for _ in range(radius): targets.pop(index-1) else: print("Strike missed!") command = input().split() targets = [str(target) for target in targets] print("|".join(targets))
targets = [int(target) for target in input().split()] command = input().split() while 'End' not in command: index = int(command[1]) if 'Shoot' in command: power = int(command[2]) if 0 <= index < len(targets): targets[index] -= power if targets[index] <= 0: targets.pop(index) elif 'Add' in command: value = int(command[2]) if 0 <= index < len(targets): targets.insert(index, value) else: print('Invalid placement!') elif 'Strike' in command: radius = int(command[2]) if index - radius >= 0 and index + radius < len(targets): for _ in range(radius): targets.pop(index + 1) targets.pop(index) for _ in range(radius): targets.pop(index - 1) else: print('Strike missed!') command = input().split() targets = [str(target) for target in targets] print('|'.join(targets))
class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] def add_group(self, group): self.groups.append(group) def add_user(self, user): self.users.append(user) def get_groups(self): return self.groups def get_users(self): return self.users def get_name(self): return self.name def is_user_in_group(user, group): if user in group.users: return True if len(group.groups) == 0: return False else: for sub_group in group.groups: flag = is_user_in_group(user, sub_group) if flag: return True return False #%% Testing official # Testing preparation parent = Group("parent") child = Group("child") sub_child = Group("subchild") sub_child_user = "sub_child_user" sub_child.add_user(sub_child_user) child.add_group(sub_child) parent.add_group(child) # Normal Cases: print('Normal Cases:') print(is_user_in_group(user='parent_user', group=parent)) # False print(is_user_in_group(user='child_user', group=parent)) # False print(is_user_in_group(user='sub_child_user', group=parent), '\n') # True # Edge Cases: print('Edge Cases:') print(is_user_in_group(user='', group=parent)) # False print(is_user_in_group(user='', group=child)) # False
class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] def add_group(self, group): self.groups.append(group) def add_user(self, user): self.users.append(user) def get_groups(self): return self.groups def get_users(self): return self.users def get_name(self): return self.name def is_user_in_group(user, group): if user in group.users: return True if len(group.groups) == 0: return False else: for sub_group in group.groups: flag = is_user_in_group(user, sub_group) if flag: return True return False parent = group('parent') child = group('child') sub_child = group('subchild') sub_child_user = 'sub_child_user' sub_child.add_user(sub_child_user) child.add_group(sub_child) parent.add_group(child) print('Normal Cases:') print(is_user_in_group(user='parent_user', group=parent)) print(is_user_in_group(user='child_user', group=parent)) print(is_user_in_group(user='sub_child_user', group=parent), '\n') print('Edge Cases:') print(is_user_in_group(user='', group=parent)) print(is_user_in_group(user='', group=child))
letter="Sai Teja"; for i in letter: print(i);
letter = 'Sai Teja' for i in letter: print(i)
class Club: total = 140 start_address = 751472 size = 88 max_name_size = 48 max_tla_size = 3 def __init__(self, option_file, idx): self.option_file = option_file self.idx = idx self.set_addresses() self.set_name() self.set_tla() def set_addresses(self): """ Set the following club addresses: - Name - TLA - Name edited """ self.name_address = self.start_address + (self.idx * self.size) self.tla_address = self.start_address + 49 + (self.idx * self.size) self.name_edited_address = ( self.start_address + (self.idx * self.size) + 56 ) def set_name(self): """ Set club name from relevant OF data bytes. """ name_byte_array = self.option_file.data[ self.name_address : self.name_address + (self.max_name_size + 1) ] self.name = name_byte_array.partition(b"\0")[0].decode() def set_tla(self): """ Set club tla from relevant OF data bytes. """ tla_byte_array = self.option_file.data[ self.tla_address : self.tla_address + (self.max_tla_size + 1) ] self.tla = tla_byte_array.partition(b"\0")[0].decode() def update_name(self, name): """ Update club name with the supplied value. """ new_name = name[: self.max_name_size] club_name_bytes = [0] * (self.max_name_size + 1) new_name_bytes = str.encode(new_name) club_name_bytes[: len(new_name_bytes)] = new_name_bytes for i, byte in enumerate(club_name_bytes): self.option_file.data[self.name_address + i] = byte self.set_name_edited() self.name = new_name def update_tla(self, tla): """ Update club TLA with the supplied value. """ new_tla = tla[:3].upper() club_tla_bytes = [0] * (self.max_tla_size + 1) new_tla_bytes = str.encode(new_tla) club_tla_bytes[: len(new_tla_bytes)] = new_tla_bytes for i, byte in enumerate(club_tla_bytes): self.option_file.data[self.tla_address + i] = byte self.set_name_edited() self.tla = new_tla def set_name_edited(self): """ Set club name as being edited. """ self.option_file.data[self.name_edited_address] = 1
class Club: total = 140 start_address = 751472 size = 88 max_name_size = 48 max_tla_size = 3 def __init__(self, option_file, idx): self.option_file = option_file self.idx = idx self.set_addresses() self.set_name() self.set_tla() def set_addresses(self): """ Set the following club addresses: - Name - TLA - Name edited """ self.name_address = self.start_address + self.idx * self.size self.tla_address = self.start_address + 49 + self.idx * self.size self.name_edited_address = self.start_address + self.idx * self.size + 56 def set_name(self): """ Set club name from relevant OF data bytes. """ name_byte_array = self.option_file.data[self.name_address:self.name_address + (self.max_name_size + 1)] self.name = name_byte_array.partition(b'\x00')[0].decode() def set_tla(self): """ Set club tla from relevant OF data bytes. """ tla_byte_array = self.option_file.data[self.tla_address:self.tla_address + (self.max_tla_size + 1)] self.tla = tla_byte_array.partition(b'\x00')[0].decode() def update_name(self, name): """ Update club name with the supplied value. """ new_name = name[:self.max_name_size] club_name_bytes = [0] * (self.max_name_size + 1) new_name_bytes = str.encode(new_name) club_name_bytes[:len(new_name_bytes)] = new_name_bytes for (i, byte) in enumerate(club_name_bytes): self.option_file.data[self.name_address + i] = byte self.set_name_edited() self.name = new_name def update_tla(self, tla): """ Update club TLA with the supplied value. """ new_tla = tla[:3].upper() club_tla_bytes = [0] * (self.max_tla_size + 1) new_tla_bytes = str.encode(new_tla) club_tla_bytes[:len(new_tla_bytes)] = new_tla_bytes for (i, byte) in enumerate(club_tla_bytes): self.option_file.data[self.tla_address + i] = byte self.set_name_edited() self.tla = new_tla def set_name_edited(self): """ Set club name as being edited. """ self.option_file.data[self.name_edited_address] = 1
def add_one(num): return (-(~num)) print(add_one(3)) print(add_one(99))
def add_one(num): return -~num print(add_one(3)) print(add_one(99))
# Global constants that will be used all along the program # Port paths ODRIVE_USB_PORT_PATH = "" REHASTIM_USB_PORT_PATH = "" USB_DRIVE_PORT_PATH = ""
odrive_usb_port_path = '' rehastim_usb_port_path = '' usb_drive_port_path = ''
#!/usr/bin/env python3 class Solution: def xorOperation(self, n: int, start: int) -> int: res = start for i in range(1,n): res^=start+2*i return res ## Intuition: # # - As per the requirements of the problem, we don't need to return the array itself. # - So, we can free up any space that would have been otherwise allocated to the array # - And instead work with the elements of the array generated each iteration # without storing them in a temporary location # ## Time Complexity: # # O(n) # - We need to iterate through n elements to get our result # ## Space Complexity: # # O(1) # - Memory assigned does not depends upon the size of the list/array n, rather the value of the res variable
class Solution: def xor_operation(self, n: int, start: int) -> int: res = start for i in range(1, n): res ^= start + 2 * i return res
# dude, this is a comment # some more hello def dude(): yes awesome; # Here we have a comment def realy_awesome(): # hi there in_more same_level def one_liner(): first; second # both inside one_liner back_down last_statement # dude, this is a comment # some more hello if 1: yes awesome; # Here we have a comment if ('hello'): # hi there in_more same_level if ['dude', 'dudess'].horsie(): first; second # both inside one_liner 1 back_down last_statement hello = 1.1(20); # subscription a[1] = b[2]; # simple slicing c[1:1] = d[2:2]; # simple slicing e[1:1, 2:2] = f[3:3, 4:4];
hello def dude(): yes awesome def realy_awesome(): in_more same_level def one_liner(): first second back_down last_statement hello if 1: yes awesome if 'hello': in_more same_level if ['dude', 'dudess'].horsie(): first second 1 back_down last_statement hello = 1.1(20) a[1] = b[2] c[1:1] = d[2:2] e[1:1, 2:2] = f[3:3, 4:4]
# https://open.kattis.com/problems/oddgnome n = int(input()) for _ in range(n): gnomes = list(map(int, input().split()))[1:] for i in range(1, len(gnomes) - 1): if gnomes[i + 1] > gnomes[i - 1]: if gnomes[i] < gnomes[i - 1] and gnomes[i] < gnomes[i + 1]: print(i + 1) break if gnomes[i] > gnomes[i - 1] and gnomes[i] > gnomes[i + 1]: print(i + 1) break
n = int(input()) for _ in range(n): gnomes = list(map(int, input().split()))[1:] for i in range(1, len(gnomes) - 1): if gnomes[i + 1] > gnomes[i - 1]: if gnomes[i] < gnomes[i - 1] and gnomes[i] < gnomes[i + 1]: print(i + 1) break if gnomes[i] > gnomes[i - 1] and gnomes[i] > gnomes[i + 1]: print(i + 1) break
''' ## Questions ### 23. [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. **Example:** ``` Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 ''' ## Solutions # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: length = len(lists) a = [] for i in lists: temp_head = i while temp_head: a.append(temp_head.val) temp_head = temp_head.next a.sort() l = ListNode(None) head = l i = 0 j = len(a) while i < j: new_node = ListNode(a[i]) l.next = new_node l = l.next i += 1 l = head.next return l # Runtime: 100 ms # Memory Usage: 18 MB
""" ## Questions ### 23. [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. **Example:** ``` Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 """ class Solution: def merge_k_lists(self, lists: List[ListNode]) -> ListNode: length = len(lists) a = [] for i in lists: temp_head = i while temp_head: a.append(temp_head.val) temp_head = temp_head.next a.sort() l = list_node(None) head = l i = 0 j = len(a) while i < j: new_node = list_node(a[i]) l.next = new_node l = l.next i += 1 l = head.next return l
# Palace Oasis (2103000) | Ariant Castle (260000300) ariantCulture = 3900 if sm.hasQuest(ariantCulture): sm.setQRValue(ariantCulture, "5", False) sm.sendSayOkay("You used two hands to drink the clean water of the Oasis. " "Delicious! It quenched your thirst right on the spot.")
ariant_culture = 3900 if sm.hasQuest(ariantCulture): sm.setQRValue(ariantCulture, '5', False) sm.sendSayOkay('You used two hands to drink the clean water of the Oasis. Delicious! It quenched your thirst right on the spot.')
class Dino: @staticmethod def exe1(): print("al carajo 1") def exe2(self): print("al carajo 2") class Car(Dino): wheels = 0 def __init__(self, color, x, func): self.color = color self.f = func Car.wheels = x while (True): print("yey") Dino.exe1() din = Dino() din.exe2() f = lambda x: x+1 #print(f(2)) print(Car.wheels) car = Car("red", 5, f) print(Car.wheels) print(car.color) print(car.f(50))
class Dino: @staticmethod def exe1(): print('al carajo 1') def exe2(self): print('al carajo 2') class Car(Dino): wheels = 0 def __init__(self, color, x, func): self.color = color self.f = func Car.wheels = x while True: print('yey') Dino.exe1() din = dino() din.exe2() f = lambda x: x + 1 print(Car.wheels) car = car('red', 5, f) print(Car.wheels) print(car.color) print(car.f(50))
#!/usr/bin/python # # Copyright 2007 Google Inc. All Rights Reserved. """CSS Lexical Grammar rules. CSS lexical grammar from http://www.w3.org/TR/CSS21/grammar.html """ __author__ = ['elsigh@google.com (Lindsey Simon)', 'msamuel@google.com (Mike Samuel)'] # public symbols __all__ = [ "NEWLINE", "HEX", "NON_ASCII", "UNICODE", "ESCAPE", "NMSTART", "NMCHAR", "STRING1", "STRING2", "IDENT", "NAME", "HASH", "NUM", "STRING", "URL", "SPACE", "WHITESPACE", "COMMENT", "QUANTITY", "PUNC" ] # The comments below are mostly copied verbatim from the grammar. # "@import" {return IMPORT_SYM;} # "@page" {return PAGE_SYM;} # "@media" {return MEDIA_SYM;} # "@charset" {return CHARSET_SYM;} KEYWORD = r'(?:\@(?:import|page|media|charset))' # nl \n|\r\n|\r|\f ; a newline NEWLINE = r'\n|\r\n|\r|\f' # h [0-9a-f] ; a hexadecimal digit HEX = r'[0-9a-f]' # nonascii [\200-\377] NON_ASCII = r'[\200-\377]' # unicode \\{h}{1,6}(\r\n|[ \t\r\n\f])? UNICODE = r'(?:(?:\\' + HEX + r'{1,6})(?:\r\n|[ \t\r\n\f])?)' # escape {unicode}|\\[^\r\n\f0-9a-f] ESCAPE = r'(?:' + UNICODE + r'|\\[^\r\n\f0-9a-f])' # nmstart [_a-z]|{nonascii}|{escape} NMSTART = r'(?:[_a-z]|' + NON_ASCII + r'|' + ESCAPE + r')' # nmchar [_a-z0-9-]|{nonascii}|{escape} NMCHAR = r'(?:[_a-z0-9-]|' + NON_ASCII + r'|' + ESCAPE + r')' # ident -?{nmstart}{nmchar}* IDENT = r'-?' + NMSTART + NMCHAR + '*' # name {nmchar}+ NAME = NMCHAR + r'+' # hash HASH = r'#' + NAME # string1 \"([^\n\r\f\\"]|\\{nl}|{escape})*\" ; "string" STRING1 = r'"(?:[^\"\\]|\\.)*"' # string2 \'([^\n\r\f\\']|\\{nl}|{escape})*\' ; 'string' STRING2 = r"'(?:[^\'\\]|\\.)*'" # string {string1}|{string2} STRING = '(?:' + STRING1 + r'|' + STRING2 + ')' # num [0-9]+|[0-9]*"."[0-9]+ NUM = r'(?:[0-9]*\.[0-9]+|[0-9]+)' # s [ \t\r\n\f] SPACE = r'[ \t\r\n\f]' # w {s}* WHITESPACE = '(?:' + SPACE + r'*)' # url special chars URL_SPECIAL_CHARS = r'[!#$%&*-~]' # url chars ({url_special_chars}|{nonascii}|{escape})* URL_CHARS = r'(?:%s|%s|%s)*' % (URL_SPECIAL_CHARS, NON_ASCII, ESCAPE) # url URL = r'url\(%s(%s|%s)%s\)' % (WHITESPACE, STRING, URL_CHARS, WHITESPACE) # comments # see http://www.w3.org/TR/CSS21/grammar.html COMMENT = r'/\*[^*]*\*+([^/*][^*]*\*+)*/' # {E}{M} {return EMS;} # {E}{X} {return EXS;} # {P}{X} {return LENGTH;} # {C}{M} {return LENGTH;} # {M}{M} {return LENGTH;} # {I}{N} {return LENGTH;} # {P}{T} {return LENGTH;} # {P}{C} {return LENGTH;} # {D}{E}{G} {return ANGLE;} # {R}{A}{D} {return ANGLE;} # {G}{R}{A}{D} {return ANGLE;} # {M}{S} {return TIME;} # {S} {return TIME;} # {H}{Z} {return FREQ;} # {K}{H}{Z} {return FREQ;} # % {return PERCENTAGE;} UNIT = r'(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)' # {num}{UNIT|IDENT} {return NUMBER;} QUANTITY = '%s(?:%s%s|%s)?' % (NUM, WHITESPACE, UNIT, IDENT) # "<!--" {return CDO;} # "-->" {return CDC;} # "~=" {return INCLUDES;} # "|=" {return DASHMATCH;} # {w}"{" {return LBRACE;} # {w}"+" {return PLUS;} # {w}">" {return GREATER;} # {w}"," {return COMMA;} PUNC = r'<!--|-->|~=|\|=|[\{\+>,:;]'
"""CSS Lexical Grammar rules. CSS lexical grammar from http://www.w3.org/TR/CSS21/grammar.html """ __author__ = ['elsigh@google.com (Lindsey Simon)', 'msamuel@google.com (Mike Samuel)'] __all__ = ['NEWLINE', 'HEX', 'NON_ASCII', 'UNICODE', 'ESCAPE', 'NMSTART', 'NMCHAR', 'STRING1', 'STRING2', 'IDENT', 'NAME', 'HASH', 'NUM', 'STRING', 'URL', 'SPACE', 'WHITESPACE', 'COMMENT', 'QUANTITY', 'PUNC'] keyword = '(?:\\@(?:import|page|media|charset))' newline = '\\n|\\r\\n|\\r|\\f' hex = '[0-9a-f]' non_ascii = '[\\200-\\377]' unicode = '(?:(?:\\\\' + HEX + '{1,6})(?:\\r\\n|[ \\t\\r\\n\\f])?)' escape = '(?:' + UNICODE + '|\\\\[^\\r\\n\\f0-9a-f])' nmstart = '(?:[_a-z]|' + NON_ASCII + '|' + ESCAPE + ')' nmchar = '(?:[_a-z0-9-]|' + NON_ASCII + '|' + ESCAPE + ')' ident = '-?' + NMSTART + NMCHAR + '*' name = NMCHAR + '+' hash = '#' + NAME string1 = '"(?:[^\\"\\\\]|\\\\.)*"' string2 = "'(?:[^\\'\\\\]|\\\\.)*'" string = '(?:' + STRING1 + '|' + STRING2 + ')' num = '(?:[0-9]*\\.[0-9]+|[0-9]+)' space = '[ \\t\\r\\n\\f]' whitespace = '(?:' + SPACE + '*)' url_special_chars = '[!#$%&*-~]' url_chars = '(?:%s|%s|%s)*' % (URL_SPECIAL_CHARS, NON_ASCII, ESCAPE) url = 'url\\(%s(%s|%s)%s\\)' % (WHITESPACE, STRING, URL_CHARS, WHITESPACE) comment = '/\\*[^*]*\\*+([^/*][^*]*\\*+)*/' unit = '(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)' quantity = '%s(?:%s%s|%s)?' % (NUM, WHITESPACE, UNIT, IDENT) punc = '<!--|-->|~=|\\|=|[\\{\\+>,:;]'
# Copyright (c) 2018 - 2020 Institute for High Voltage Technology and Institute for High Voltage Equipment and Grids, Digitalization and Power Economics # RWTH Aachen University # Contact: Thomas Offergeld (t.offergeld@iaew.rwth-aachen.de) # # # This module is part of CIMPyORM. # # # CIMPyORM is licensed under the BSD-3-Clause license. # For further information see LICENSE in the project's root directory. # def test_parse_meta(acquire_db, dummy_source): _, session = acquire_db assert dummy_source.tree assert dummy_source.nsmap == {'cim': 'http://iec.ch/TC57/2013/CIM-schema-cim16#', 'entsoe': 'http://entsoe.eu/CIM/SchemaExtension/3/1#', 'md': 'http://iec.ch/TC57/61970-552/ModelDescription/1#', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'} assert dummy_source.cim_version == "16"
def test_parse_meta(acquire_db, dummy_source): (_, session) = acquire_db assert dummy_source.tree assert dummy_source.nsmap == {'cim': 'http://iec.ch/TC57/2013/CIM-schema-cim16#', 'entsoe': 'http://entsoe.eu/CIM/SchemaExtension/3/1#', 'md': 'http://iec.ch/TC57/61970-552/ModelDescription/1#', 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'} assert dummy_source.cim_version == '16'
""" Backported error classes for twisted. """ __docformat__ = 'epytext en' class VerifyError(Exception): """Could not verify something that was supposed to be signed. """ class PeerVerifyError(VerifyError): """The peer rejected our verify error. """ class CertificateError(Exception): """ We did not find a certificate where we expected to find one. """
""" Backported error classes for twisted. """ __docformat__ = 'epytext en' class Verifyerror(Exception): """Could not verify something that was supposed to be signed. """ class Peerverifyerror(VerifyError): """The peer rejected our verify error. """ class Certificateerror(Exception): """ We did not find a certificate where we expected to find one. """
with open('inputs/input24.txt') as fin: raw = fin.read() def parse(raw): x = [x for x in raw.splitlines()] return x a = parse(raw) def part_1(data): dictionary = {} for a in data: e = a.count('ne') + a.count('se') w = a.count('nw') + a.count('sw') x = e + 2 * (a.count('e') - e) - (w + 2 * (a.count('w') - w)) y = a.count('n') - a.count('s') if (x, y) in dictionary: dictionary[(x, y)] = not dictionary[(x, y)] else: dictionary[(x, y)] = True return dictionary, sum(dictionary.values()) def part_2(data): result = {} print(data.items()) for x in range(10): for i in data.items(): count = 0 x = i[0] y = i[1] if data.get((x + 2, y)): if data.get((x + 2, y)) == 1: count += 1 else: result[(x + 2, y)] = -1 if data.get((x - 2, y)): if data.get((x - 2, y)) == 1: count += 1 else: result[(x - 2, y)] = -1 if data.get((x + 1, y + 1)): if data.get((x + 1, y + 1)) == 1: count += 1 else: result[(x + 1, y + 1)] = -1 if data.get((x - 1, y + 1)): if data.get((x - 1, y + 1)) == 1: count += 1 else: result[(x - 1, y + 1)] = -1 if data.get((x + 1, y - 1)): if data.get((x + 1, y - 1)) == 1: count += 1 else: result[(x + 1, y - 1)] = -1 if data.get((x - 1, y - 1)): if data.get((x - 1, y - 1)) == 1: count += 1 else: result[(x - 1, y - 1)] = -1 if data[i] == 1 and (count == 0 or count > 2): result[i] = -1 elif data[i] == -1 and count == 2: result[i] = 1 else: result[i] = data[i] data = result return list(result.values()) # print(a) print(part_1(a)[1]) print(part_2(part_1(a)[0]))
with open('inputs/input24.txt') as fin: raw = fin.read() def parse(raw): x = [x for x in raw.splitlines()] return x a = parse(raw) def part_1(data): dictionary = {} for a in data: e = a.count('ne') + a.count('se') w = a.count('nw') + a.count('sw') x = e + 2 * (a.count('e') - e) - (w + 2 * (a.count('w') - w)) y = a.count('n') - a.count('s') if (x, y) in dictionary: dictionary[x, y] = not dictionary[x, y] else: dictionary[x, y] = True return (dictionary, sum(dictionary.values())) def part_2(data): result = {} print(data.items()) for x in range(10): for i in data.items(): count = 0 x = i[0] y = i[1] if data.get((x + 2, y)): if data.get((x + 2, y)) == 1: count += 1 else: result[x + 2, y] = -1 if data.get((x - 2, y)): if data.get((x - 2, y)) == 1: count += 1 else: result[x - 2, y] = -1 if data.get((x + 1, y + 1)): if data.get((x + 1, y + 1)) == 1: count += 1 else: result[x + 1, y + 1] = -1 if data.get((x - 1, y + 1)): if data.get((x - 1, y + 1)) == 1: count += 1 else: result[x - 1, y + 1] = -1 if data.get((x + 1, y - 1)): if data.get((x + 1, y - 1)) == 1: count += 1 else: result[x + 1, y - 1] = -1 if data.get((x - 1, y - 1)): if data.get((x - 1, y - 1)) == 1: count += 1 else: result[x - 1, y - 1] = -1 if data[i] == 1 and (count == 0 or count > 2): result[i] = -1 elif data[i] == -1 and count == 2: result[i] = 1 else: result[i] = data[i] data = result return list(result.values()) print(part_1(a)[1]) print(part_2(part_1(a)[0]))
num = int(input('Digite um numero: ')) tot = 0 for c in range(1, num +1): if num% c == 0 : print('\033[33m', end='') tot += 1 else: print('\033[31m',end=' ') print('{}'.format(c) , end=' ') print('\n\033[mO numero {} foi divisivel {} vezes'.format(num, tot)) if tot == 2: print('E por isso ele e Primo') else: print('E por isso ele nao e Primo .')
num = int(input('Digite um numero: ')) tot = 0 for c in range(1, num + 1): if num % c == 0: print('\x1b[33m', end='') tot += 1 else: print('\x1b[31m', end=' ') print('{}'.format(c), end=' ') print('\n\x1b[mO numero {} foi divisivel {} vezes'.format(num, tot)) if tot == 2: print('E por isso ele e Primo') else: print('E por isso ele nao e Primo .')
__version__ = '0.3.7' __title__ = 'iam-docker-run' __description__ = 'Run Docker containers within the context of an AWS IAM Role, and other development workflow helpers.' __url__ = 'https://github.com/billtrust/iam-docker-run' __author__ = 'Doug Kerwin' __author_email__ = 'dwkerwin@gmail.com' __license__ = 'MIT' __keywords__ = ['aws', 'iam', 'iam-role', 'docker']
__version__ = '0.3.7' __title__ = 'iam-docker-run' __description__ = 'Run Docker containers within the context of an AWS IAM Role, and other development workflow helpers.' __url__ = 'https://github.com/billtrust/iam-docker-run' __author__ = 'Doug Kerwin' __author_email__ = 'dwkerwin@gmail.com' __license__ = 'MIT' __keywords__ = ['aws', 'iam', 'iam-role', 'docker']
#!/bin/python3 # # Copyright (c) 2019 Paulo Vital # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # def fibonacci(n): if (n == 0) or (n == 1): yield 1 yield (fibonacci(n-1) + fibonacci(n-2)) # int main(int argc, char#*argv) # { # int i, limit; # # if (argc < 2) { # printf("Type a limit number: "); # scanf("%d", &limit); # } else { # limit = atoi(argv[1]); # } # # printf("The Fibonacci sequence for %d is: ", limit); # # for (i = 0; i < limit; i++) # printf ("%d ", fibonacci(i)); # # printf("\n"); # # return 0; # } if __name__ == '__main__': end = input("Type a limit number: ") print("The Fibonacci sequence for {0} is: ".format(end), list(fibonacci(int(end))))
def fibonacci(n): if n == 0 or n == 1: yield 1 yield (fibonacci(n - 1) + fibonacci(n - 2)) if __name__ == '__main__': end = input('Type a limit number: ') print('The Fibonacci sequence for {0} is: '.format(end), list(fibonacci(int(end))))
""" Module: 'uasyncio.event' on esp32 1.13.0-103 """ # MCU: (sysname='esp32', nodename='esp32', release='1.13.0', version='v1.13-103-gb137d064e on 2020-10-09', machine='ESP32 module (spiram) with ESP32') # Stubber: 1.3.4 class Event: '' def clear(): pass def is_set(): pass def set(): pass wait = None core = None
""" Module: 'uasyncio.event' on esp32 1.13.0-103 """ class Event: """""" def clear(): pass def is_set(): pass def set(): pass wait = None core = None
NumbersBelow19 = ["One", "Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Ninteen"] multiplesOf10 = ["Twenty" , "Thirty" , "Fourty" , "Fifty" , "Sixty" , "Seventy" ,"Eighty" , "Ninety"] singleDigits = ["One", "Two","Three","Four","Five","Six","Seven","Eight","Nine"] def doHigh(anumber): if anumber < 20: result = NumbersBelow19[anumber-1] else: aPart = int(anumber / 10) bPart = anumber % 10 if bPart == 0: result = multiplesOf10[aPart - 2] else: result = "%s-%s"%(multiplesOf10[aPart - 2], singleDigits[bPart - 1] ) return result numberToBeConverted = int(input('Enter number: ')) print(doHigh(numberToBeConverted))
numbers_below19 = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Ninteen'] multiples_of10 = ['Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'] single_digits = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] def do_high(anumber): if anumber < 20: result = NumbersBelow19[anumber - 1] else: a_part = int(anumber / 10) b_part = anumber % 10 if bPart == 0: result = multiplesOf10[aPart - 2] else: result = '%s-%s' % (multiplesOf10[aPart - 2], singleDigits[bPart - 1]) return result number_to_be_converted = int(input('Enter number: ')) print(do_high(numberToBeConverted))
num = int(input()) first = [] second = [] for i in range(num): line = input().split(' ') name = line[0] t1 = float(line[1]) t2 = float(line[2]) first.append([name, t1]) second.append([name, t2]) first.sort(key=lambda x: x[1]) second.sort(key=lambda x: x[1]) total_time = 0 squad_list_of_lists = [] for i in first: name = i[0] squad = [] time = 0 for j in second: if len(squad) < 3: if j[0] != name: squad.append(j[0]) time += j[1] else: break squad.insert(0, name) time += i[1] squad_list_of_lists.append([squad, time]) squad_list_of_lists.sort(key=lambda x: x[1]) print(squad_list_of_lists[0][1]) for runner in squad_list_of_lists[0][0]: print(runner)
num = int(input()) first = [] second = [] for i in range(num): line = input().split(' ') name = line[0] t1 = float(line[1]) t2 = float(line[2]) first.append([name, t1]) second.append([name, t2]) first.sort(key=lambda x: x[1]) second.sort(key=lambda x: x[1]) total_time = 0 squad_list_of_lists = [] for i in first: name = i[0] squad = [] time = 0 for j in second: if len(squad) < 3: if j[0] != name: squad.append(j[0]) time += j[1] else: break squad.insert(0, name) time += i[1] squad_list_of_lists.append([squad, time]) squad_list_of_lists.sort(key=lambda x: x[1]) print(squad_list_of_lists[0][1]) for runner in squad_list_of_lists[0][0]: print(runner)
def remdup(a): return list(set(a)) l=[] for i in range(0,5): l.append(input()) print(l) rev = l[::-1] print(rev) print(remdup(l)) print([i for i in range(0,10) if i%2==0])
def remdup(a): return list(set(a)) l = [] for i in range(0, 5): l.append(input()) print(l) rev = l[::-1] print(rev) print(remdup(l)) print([i for i in range(0, 10) if i % 2 == 0])
''' Created on 1.12.2016 @author: Darren '''''' Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in the array." '''
""" Created on 1.12.2016 @author: Darren Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in the array." """
# This is Pessimistic Error Pruning. def prune(t): # If the node is a leaf node, stop pruning. if t.label != None: return L = t.leaf_sum N = t.N p = (t.RT + 0.5*L)/N # When the following condition is satisfied, # replace the subtree with a leaf node. if t.RT + 0.5 - (N*p*(1-p))**0.5 < t.RT + 0.5*L: # The label of the leaf node depends on the # majority label of the subtree. t.label = t.majority return # Prune the tree recursively. prune(t.left) prune(t.right)
def prune(t): if t.label != None: return l = t.leaf_sum n = t.N p = (t.RT + 0.5 * L) / N if t.RT + 0.5 - (N * p * (1 - p)) ** 0.5 < t.RT + 0.5 * L: t.label = t.majority return prune(t.left) prune(t.right)
__author__ = 'haukurk' def log_exception(sender, exception, **extra): """ Log an exception to our logging framework. @param sender: sender @param exception: exception triggered @**extra: other params. @return: void """ sender.logger.debug('Got exception during processing: %s', exception) def error_incorrect_version(version): """ Return a response when the client is using incorrect API version. @param version: version in use. @return: dict """ return {"status": "error", "message": "incorrect API version "+str(version)+" used."} def error_object_not_found(): """ Return an error response when something is not found, like a object in a database. @return: dict """ return {"status": "error", "message": "object not found"} def error_commit_error(ex): """ Return an error response when database commit fails somehow. Like when inserting into a database and you get a unique constraint violated. @return: dict """ return {"status": "error", "message": "error when committing object to database", "exception": ex.message}
__author__ = 'haukurk' def log_exception(sender, exception, **extra): """ Log an exception to our logging framework. @param sender: sender @param exception: exception triggered @**extra: other params. @return: void """ sender.logger.debug('Got exception during processing: %s', exception) def error_incorrect_version(version): """ Return a response when the client is using incorrect API version. @param version: version in use. @return: dict """ return {'status': 'error', 'message': 'incorrect API version ' + str(version) + ' used.'} def error_object_not_found(): """ Return an error response when something is not found, like a object in a database. @return: dict """ return {'status': 'error', 'message': 'object not found'} def error_commit_error(ex): """ Return an error response when database commit fails somehow. Like when inserting into a database and you get a unique constraint violated. @return: dict """ return {'status': 'error', 'message': 'error when committing object to database', 'exception': ex.message}
"""Top-level package for trailscraper.""" __author__ = """Florian Sellmayr""" __email__ = 'florian.sellmayr@gmail.com' __version__ = '0.6.5'
"""Top-level package for trailscraper.""" __author__ = 'Florian Sellmayr' __email__ = 'florian.sellmayr@gmail.com' __version__ = '0.6.5'
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isCousins(self, root: 'TreeNode', x: 'int', y: 'int') -> 'bool': m = {} def traverse(node, parent=None, depth=0): if node: m[node.val] = (parent, depth) traverse(node.left, node.val, depth+1) traverse(node.right, node.val, depth + 1) traverse(root) return m[x][0] != m[y][0] and m[x][1] == m[y][1]
class Solution: def is_cousins(self, root: 'TreeNode', x: 'int', y: 'int') -> 'bool': m = {} def traverse(node, parent=None, depth=0): if node: m[node.val] = (parent, depth) traverse(node.left, node.val, depth + 1) traverse(node.right, node.val, depth + 1) traverse(root) return m[x][0] != m[y][0] and m[x][1] == m[y][1]
class Singleton(type): instance = None def __call__(cls, *args, **kwargs): if not cls.instance: cls.instance = super(Singleton, cls).__call__(*args, **kwargs) return cls.instance # Taken from https://github.com/tomerghelber/singleton-factory class SingletonFactory(type): """ Singleton Factory - keeps one object with the same hash of the same cls. Returns: An existing instance. """ __instances = dict() def __call__(cls, *args, **kwargs): if cls not in cls.__instances: cls.__instances[cls] = dict() new_obj = super(SingletonFactory, cls).__call__(*args, **kwargs) if hash(new_obj) not in cls.__instances[cls]: cls.__instances[cls][hash(new_obj)] = new_obj return cls.__instances[cls][hash(new_obj)]
class Singleton(type): instance = None def __call__(cls, *args, **kwargs): if not cls.instance: cls.instance = super(Singleton, cls).__call__(*args, **kwargs) return cls.instance class Singletonfactory(type): """ Singleton Factory - keeps one object with the same hash of the same cls. Returns: An existing instance. """ __instances = dict() def __call__(cls, *args, **kwargs): if cls not in cls.__instances: cls.__instances[cls] = dict() new_obj = super(SingletonFactory, cls).__call__(*args, **kwargs) if hash(new_obj) not in cls.__instances[cls]: cls.__instances[cls][hash(new_obj)] = new_obj return cls.__instances[cls][hash(new_obj)]
#To find whether the number is +ve,-ve or 0 x=int(input("Enter a number")) def check_num(x): if x>0: print("The",x,"is positive") elif x<0: print("The",x,"is negative") else: print("The",x,"is zero") check_num(x)
x = int(input('Enter a number')) def check_num(x): if x > 0: print('The', x, 'is positive') elif x < 0: print('The', x, 'is negative') else: print('The', x, 'is zero') check_num(x)
"""Constants for propensity_matching library.""" MINIMUM_DF_COUNT = 4000 MINIMUM_POS_COUNT = 1000 UTIL_BOOST_THRESH_1 = MINIMUM_POS_COUNT UTIL_BOOST_THRESH_2 = MINIMUM_DF_COUNT UTIL_BOOST_THRESH_3 = 50000 SAMPLES_PER_FEATURE = 100 SMALL_MATCH_THRESHOLD = 3000**3
"""Constants for propensity_matching library.""" minimum_df_count = 4000 minimum_pos_count = 1000 util_boost_thresh_1 = MINIMUM_POS_COUNT util_boost_thresh_2 = MINIMUM_DF_COUNT util_boost_thresh_3 = 50000 samples_per_feature = 100 small_match_threshold = 3000 ** 3
class RequestError(Exception): """The base class for all errors.""" def __init__(self, code, error, retry_after=None): pass class Unauthorized(RequestError): """Raised if your API Key is invalid or blocked.""" def __init__(self, url, code): self.code = code self.error = 'Your API Key is invalid or blocked.\nURL: ' + url super().__init__(self.code, self.error) class NotFoundError(RequestError): """Raised if an invalid player tag or club tag has been passed.""" def __init__(self, url, code): self.code = code self.error = 'An incorrect tag has been passed.\nURL: ' + url super().__init__(self.code, self.error) class RateLimitError(RequestError): """Raised when the rate limit is reached.""" def __init__(self, url, code, retry_after): self.code = code self.retry_after = retry_after self.error = 'The rate limit has been reached.\nURL: ' + url super().__init__(self.code, self.error, retry_after=self.retry_after) class UnexpectedError(RequestError): """Raised if an unknown error has occured.""" def __init__(self, url, code): self.code = code self.error = 'An unexpected error has occured.\nURL: ' + url super().__init__(self.code, self.error) class ServerError(RequestError): """Raised if the API is down.""" def __init__(self, url, code): self.code = code self.error = 'The API is down. Please be patient and try again later.\nURL: ' + url super().__init__(self.code, self.error)
class Requesterror(Exception): """The base class for all errors.""" def __init__(self, code, error, retry_after=None): pass class Unauthorized(RequestError): """Raised if your API Key is invalid or blocked.""" def __init__(self, url, code): self.code = code self.error = 'Your API Key is invalid or blocked.\nURL: ' + url super().__init__(self.code, self.error) class Notfounderror(RequestError): """Raised if an invalid player tag or club tag has been passed.""" def __init__(self, url, code): self.code = code self.error = 'An incorrect tag has been passed.\nURL: ' + url super().__init__(self.code, self.error) class Ratelimiterror(RequestError): """Raised when the rate limit is reached.""" def __init__(self, url, code, retry_after): self.code = code self.retry_after = retry_after self.error = 'The rate limit has been reached.\nURL: ' + url super().__init__(self.code, self.error, retry_after=self.retry_after) class Unexpectederror(RequestError): """Raised if an unknown error has occured.""" def __init__(self, url, code): self.code = code self.error = 'An unexpected error has occured.\nURL: ' + url super().__init__(self.code, self.error) class Servererror(RequestError): """Raised if the API is down.""" def __init__(self, url, code): self.code = code self.error = 'The API is down. Please be patient and try again later.\nURL: ' + url super().__init__(self.code, self.error)
#!/usr/bin/python3 ################################ # File Name: DocTestExample.py # Author: Chadd Williams # Date: 10/17/2014 # Class: CS 360 # Assignment: Lecture Examples # Purpose: Demonstrate PyTest ################################ # Run these test cases via: # chadd@bart:~> python3 -m doctest -v DocTestExample.py # Simple int example def testIntAddition(left: int, right: int)->"sum of left and right": """Test the + operator for ints Test a simple two in example >>> testIntAddition(1,2) 3 Use the same int twice, no problem >>> testIntAddition(2,2) 4 Try to add a list to a set! TypeError! Only show the first and last lines for the error message The ... is a wild card The ... is tabbed in TWICE >>> testIntAddition([2], {3}) Traceback (most recent call last): ... TypeError: can only concatenate list (not "set") to list """ return left + right # Simple List example def printFirstItemInList(theList: "list of items"): """ Retrieve the first item from the list and print it Test a list of ints >>> printFirstItemInList( [ 0, 1, 2] ) 0 Test a list of strings >>> printFirstItemInList( ["CS 360", "CS 150", "CS 300" ] ) CS 360 Generate a list comphrension >>> printFirstItemInList( [ x+1 for x in range(10) ] ) 1 Work with a list of tuples >>> printFirstItemInList( [ (x,x+1, x-1) for x in range(10) ] ) (0, 1, -1) """ item = theList[0] print(item) # Test Output of print and return value # that \ at the end of the line allows you to continue # the same statement on the next line! def printAndReturnSum(*args: "variadic param")\ ->"return sum of ints provided as parameters": """ Print and return the sum of the args that are ints >>> printAndReturnSum(1,2,3) 6 6 >>> printAndReturnSum("bob", 1) 1 1 """ total = 0 for x in args: # type check at run time! if type(x) is int : total += x print(total) return total
def test_int_addition(left: int, right: int) -> 'sum of left and right': """Test the + operator for ints Test a simple two in example >>> testIntAddition(1,2) 3 Use the same int twice, no problem >>> testIntAddition(2,2) 4 Try to add a list to a set! TypeError! Only show the first and last lines for the error message The ... is a wild card The ... is tabbed in TWICE >>> testIntAddition([2], {3}) Traceback (most recent call last): ... TypeError: can only concatenate list (not "set") to list """ return left + right def print_first_item_in_list(theList: 'list of items'): """ Retrieve the first item from the list and print it Test a list of ints >>> printFirstItemInList( [ 0, 1, 2] ) 0 Test a list of strings >>> printFirstItemInList( ["CS 360", "CS 150", "CS 300" ] ) CS 360 Generate a list comphrension >>> printFirstItemInList( [ x+1 for x in range(10) ] ) 1 Work with a list of tuples >>> printFirstItemInList( [ (x,x+1, x-1) for x in range(10) ] ) (0, 1, -1) """ item = theList[0] print(item) def print_and_return_sum(*args: 'variadic param') -> 'return sum of ints provided as parameters': """ Print and return the sum of the args that are ints >>> printAndReturnSum(1,2,3) 6 6 >>> printAndReturnSum("bob", 1) 1 1 """ total = 0 for x in args: if type(x) is int: total += x print(total) return total
try: raise Exception() except Exception as e: print("hello", str(e))
try: raise exception() except Exception as e: print('hello', str(e))
database = { 'default': 'mysql', 'connections': { 'mysql': { 'name': 'mytodo', 'username': 'root', 'password': '', 'connection': 'mysql:host=127.0.0.1', }, }, 'migrations': 'migrations', }
database = {'default': 'mysql', 'connections': {'mysql': {'name': 'mytodo', 'username': 'root', 'password': '', 'connection': 'mysql:host=127.0.0.1'}}, 'migrations': 'migrations'}
# CONCATENATION firstName = "Helder" lastName = "Pereira" fullName = "Helder" + " " + lastName print(fullName)
first_name = 'Helder' last_name = 'Pereira' full_name = 'Helder' + ' ' + lastName print(fullName)
#!/usr/bin/python # -*- coding:utf-8 -*- ''' sqlmapapi restful interface by zhangh (zhanghang.org#gmail.com) ''' # api task_new = "task/new" task_del = "task/<taskid>/delete" admin_task_list = "admin/<taskid>/list" admin_task_flush = "admin/<taskid>/flush" option_task_list = "option/<taskid>/list" option_task_get = "option/<taskid>/get" option_task_set = "option/<taskid>/set" scan_task_start = "scan/<taskid>/start" scan_task_stop = "scan/<taskid>/stop" scan_task_kill = "scan/<taskid>/kill" scan_task_status = "scan/<taskid>/status" scan_task_data = "scan/<taskid>/data" scan_task_log = "scan/<taskid>/log/<start>/<end>" scan_task_log = "scan/<taskid>/log" download_task = "download/<taskid>/<target>/<filename:path>" # config taskid = "<taskid>" dbOld = 0 dbNew = 1 host = '172.22.1.44' port = 2000 password = 'SEC' joblist = 'job.set' sqlinj = 'sqlinj'
""" sqlmapapi restful interface by zhangh (zhanghang.org#gmail.com) """ task_new = 'task/new' task_del = 'task/<taskid>/delete' admin_task_list = 'admin/<taskid>/list' admin_task_flush = 'admin/<taskid>/flush' option_task_list = 'option/<taskid>/list' option_task_get = 'option/<taskid>/get' option_task_set = 'option/<taskid>/set' scan_task_start = 'scan/<taskid>/start' scan_task_stop = 'scan/<taskid>/stop' scan_task_kill = 'scan/<taskid>/kill' scan_task_status = 'scan/<taskid>/status' scan_task_data = 'scan/<taskid>/data' scan_task_log = 'scan/<taskid>/log/<start>/<end>' scan_task_log = 'scan/<taskid>/log' download_task = 'download/<taskid>/<target>/<filename:path>' taskid = '<taskid>' db_old = 0 db_new = 1 host = '172.22.1.44' port = 2000 password = 'SEC' joblist = 'job.set' sqlinj = 'sqlinj'
def path_initial_steps(path, node): ''' takes in a list of arcs and a node and returns the list of nodes the node can reach ''' initial_steps = [] for arc in path: if arc[0] == node: initial_steps.append(arc) return initial_steps def path_end_points(path, node): ''' takes in a list of arcs and a node and returns the list of nodes the node can reach ''' nodes_reachable = [] initial_steps = path_initial_steps(path, node) while len(initial_steps) > 0: new_steps = [] for arc in initial_steps: nodes_reachable.append(arc[1]) new_steps.append(arc[1]) new_arcs = [] for node in new_steps: arcs_per_node = path_initial_steps(path, node) if len(arcs_per_node) > 0: for arc2 in arcs_per_node: new_arcs.append(arc2) initial_steps = new_arcs return nodes_reachable def is_projective_arc(path, arc): head = arc[0] dependent = arc[1] nodes_reachable = path_end_points(path, head) if head < dependent: relevant_nodes = [x for x in range(head + 1, dependent)] else: relevant_nodes = [x for x in range(dependent + 1, head)] for node in relevant_nodes: if node not in nodes_reachable: return False return True def is_projective_tree(tree): for arc in tree: if not is_projective_arc(tree, arc): return False return True
def path_initial_steps(path, node): """ takes in a list of arcs and a node and returns the list of nodes the node can reach """ initial_steps = [] for arc in path: if arc[0] == node: initial_steps.append(arc) return initial_steps def path_end_points(path, node): """ takes in a list of arcs and a node and returns the list of nodes the node can reach """ nodes_reachable = [] initial_steps = path_initial_steps(path, node) while len(initial_steps) > 0: new_steps = [] for arc in initial_steps: nodes_reachable.append(arc[1]) new_steps.append(arc[1]) new_arcs = [] for node in new_steps: arcs_per_node = path_initial_steps(path, node) if len(arcs_per_node) > 0: for arc2 in arcs_per_node: new_arcs.append(arc2) initial_steps = new_arcs return nodes_reachable def is_projective_arc(path, arc): head = arc[0] dependent = arc[1] nodes_reachable = path_end_points(path, head) if head < dependent: relevant_nodes = [x for x in range(head + 1, dependent)] else: relevant_nodes = [x for x in range(dependent + 1, head)] for node in relevant_nodes: if node not in nodes_reachable: return False return True def is_projective_tree(tree): for arc in tree: if not is_projective_arc(tree, arc): return False return True
#!/usr/bin/env python3 """ determine the shape of a matrix """ def matrix_shape(matrix): """ function to calculatre matrix shape """ shape = [] while type(matrix) is list: shape.append(len(matrix)) matrix = matrix[0] return shape
""" determine the shape of a matrix """ def matrix_shape(matrix): """ function to calculatre matrix shape """ shape = [] while type(matrix) is list: shape.append(len(matrix)) matrix = matrix[0] return shape
"""Basic registry for model builders.""" BUILDERS = dict() def register(name): """Registers a new model builder function under the given model name.""" def add_to_dict(func): BUILDERS[name] = func return func return add_to_dict def get_builder(model_name): """Fetches the model builder function associated with the given model name""" return BUILDERS[model_name]
"""Basic registry for model builders.""" builders = dict() def register(name): """Registers a new model builder function under the given model name.""" def add_to_dict(func): BUILDERS[name] = func return func return add_to_dict def get_builder(model_name): """Fetches the model builder function associated with the given model name""" return BUILDERS[model_name]
""" Title | Project Author: Keegan Skeate Contact: <keegan@cannlytics.com> Created: Updated: License: MIT License <https://github.com/cannlytics/cannlytics-ai/blob/main/LICENSE> """ # Initialize a Socrata client. # app_token = os.environ.get('APP_TOKEN', None) # client = Socrata('opendata.mass-cannabis-control.com', app_token) # # Get sales by product type. # products = client.get('xwf2-j7g9', limit=2000) # products_data = pd.DataFrame.from_records(products) # # Get licensees. # licensees = client.get("hmwt-yiqy", limit=2000) # licensees_data = pd.DataFrame.from_records(licensees) # # Get the monthly average price per ounce. # avg_price = client.get("rqtv-uenj", limit=2000) # avg_price_data = pd.DataFrame.from_records(avg_price) # # Get production stats (total employees, total plants, etc.) # production = client.get("j3q7-3usu", limit=2000, order='saledate DESC') # production_data = pd.DataFrame.from_records(production)
""" Title | Project Author: Keegan Skeate Contact: <keegan@cannlytics.com> Created: Updated: License: MIT License <https://github.com/cannlytics/cannlytics-ai/blob/main/LICENSE> """
def x(): return 1 x()
def x(): return 1 x()
class Screen: """ Abstract class for drawing to the LCD The main program will transition between displaying various "screens" based on high-level logic """ def draw(self, cr): raise NotImplementedError("Must implement draw") def stop(self): """ Some screens may need to initialize threads in order to display content. These screens should terminate those threads when this method is called. """ pass """ Name of this screen (for manual triggering via shared memory) """ def get_name(self): raise NotImplementedError("Must implement get_name")
class Screen: """ Abstract class for drawing to the LCD The main program will transition between displaying various "screens" based on high-level logic """ def draw(self, cr): raise not_implemented_error('Must implement draw') def stop(self): """ Some screens may need to initialize threads in order to display content. These screens should terminate those threads when this method is called. """ pass '\n Name of this screen (for manual triggering via shared memory)\n ' def get_name(self): raise not_implemented_error('Must implement get_name')
class MudAction: """ Contains all of the information about attempted physical actions within the world. Whenever a Mob, Item, Character, etc tries to do anything in the game world, an instance is created and sent around to all the other chars, items, room, etc. """ def __init__(self, actionType, playerRef, data1='', \ data2='', data3='', string=''): self.info = {} self.info['actionType'] = actionType self.info['playerRef'] = playerRef self.info['data1'] = data1 self.info['data2'] = data2 self.info['data3'] = data3 self.info['string'] = string def setType(self, type): """Sets the action type to the provided string.""" self.info['actionType'] = type def setData1(self, data): """Sets the Data1 field of the action.""" self.info['data1'] = data def setData2(self, data): """Sets the Data2 field of the action.""" self.info['data2'] = data def setData3(self, data): """Sets the Data3 field of the action.""" self.info['data3'] = data def setString(self, data): """Sets the string field of the action.""" # TODO: Probably not neccessary to call this string. Holdover from # the translated C++ code. self.string = data def getType(self): """Returns the type of action.""" return self.info['actionType'] def getPlayerRef(self): """Returns a reference to the player who generated the action.""" return self.info['playerRef'] def getString(self): """Returns the String value of the action.""" return self.info['string'] def getData1(self): """Returns the data1 field.""" return self.info['data1'] def getData2(self): """Returns the data2 field.""" return self.info['data2'] def getData3(self): """Returns the data3 field.""" return self.info['data3'] class TimedAction(MudAction): def __init__(self, actionType, playerRef, data1='', \ data2='', data3='', string=''): MudAction.__init__(self, actionType, playerRef, data1='', \ data2='', data3='', string='') self.executionTime = None self.actionEvent = None self.valid = True def getExecutionTime(self): """ Returns the time (in miliseconds after start of MUD) that the action should be executed. """ return self.executionTime def setExecutionTime(self, time): """ Sets the time (in milliseconds after the MUD has started) that the action should be executed. """ self.executionTime = time def hook(self): """ This hooks a timed action to all it's references. """ # TODO: Some error checking code in case the instance/hook no longer # exists? Same for unhook... if type(self.getPlayerRef()) == 'instance': self.getPlayerRef().addHook(self) if type(self.getData1()) == 'instance': self.getData1().addHook(self) if type(self.getData2()) == 'instance': self.getData1().addHook(self) if type(self.getData3()) == 'instance': self.getData1().addHook(self) def unhook(self): """ This removes a timed action from all it's references. """ if type(self.getPlayerRef()) == 'instance': self.getPlayerRef().removeHook(self) if type(self.getData1()) == 'instance': self.getData1().removeHook(self) if type(self.getData2()) == 'instance': self.getData1().removeHook(self) if type(self.getData3()) == 'instance': self.getData1().removeHook(self) def setValid(self, value): """ Sets the validity of the action. """ if value == True: self.valid = True elif value == False: self.valid = False else: #TODO: Code to notify that it is an invalid value? return
class Mudaction: """ Contains all of the information about attempted physical actions within the world. Whenever a Mob, Item, Character, etc tries to do anything in the game world, an instance is created and sent around to all the other chars, items, room, etc. """ def __init__(self, actionType, playerRef, data1='', data2='', data3='', string=''): self.info = {} self.info['actionType'] = actionType self.info['playerRef'] = playerRef self.info['data1'] = data1 self.info['data2'] = data2 self.info['data3'] = data3 self.info['string'] = string def set_type(self, type): """Sets the action type to the provided string.""" self.info['actionType'] = type def set_data1(self, data): """Sets the Data1 field of the action.""" self.info['data1'] = data def set_data2(self, data): """Sets the Data2 field of the action.""" self.info['data2'] = data def set_data3(self, data): """Sets the Data3 field of the action.""" self.info['data3'] = data def set_string(self, data): """Sets the string field of the action.""" self.string = data def get_type(self): """Returns the type of action.""" return self.info['actionType'] def get_player_ref(self): """Returns a reference to the player who generated the action.""" return self.info['playerRef'] def get_string(self): """Returns the String value of the action.""" return self.info['string'] def get_data1(self): """Returns the data1 field.""" return self.info['data1'] def get_data2(self): """Returns the data2 field.""" return self.info['data2'] def get_data3(self): """Returns the data3 field.""" return self.info['data3'] class Timedaction(MudAction): def __init__(self, actionType, playerRef, data1='', data2='', data3='', string=''): MudAction.__init__(self, actionType, playerRef, data1='', data2='', data3='', string='') self.executionTime = None self.actionEvent = None self.valid = True def get_execution_time(self): """ Returns the time (in miliseconds after start of MUD) that the action should be executed. """ return self.executionTime def set_execution_time(self, time): """ Sets the time (in milliseconds after the MUD has started) that the action should be executed. """ self.executionTime = time def hook(self): """ This hooks a timed action to all it's references. """ if type(self.getPlayerRef()) == 'instance': self.getPlayerRef().addHook(self) if type(self.getData1()) == 'instance': self.getData1().addHook(self) if type(self.getData2()) == 'instance': self.getData1().addHook(self) if type(self.getData3()) == 'instance': self.getData1().addHook(self) def unhook(self): """ This removes a timed action from all it's references. """ if type(self.getPlayerRef()) == 'instance': self.getPlayerRef().removeHook(self) if type(self.getData1()) == 'instance': self.getData1().removeHook(self) if type(self.getData2()) == 'instance': self.getData1().removeHook(self) if type(self.getData3()) == 'instance': self.getData1().removeHook(self) def set_valid(self, value): """ Sets the validity of the action. """ if value == True: self.valid = True elif value == False: self.valid = False else: return
def internet_on(): with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Log,Testing Internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) global ledSwitch global connected global powerSwitch try: powerSwitch = 0 urllib.request.urlopen('http://216.58.207.206') #urllib.urlopen('http://216.58.207.206', timeout=4) with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Log,We have an internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) ledSwitch = 1 Thread(target = led_green_alert).start() try: powerSwitch = 0 tts = gTTS(text="Code green! All communication systems are online and working within normal parameters." , lang='en') tts.save("internet_on.mp3") os.system("mpg321 -q internet_on.mp3") except: powerSwitch = 1 os.system("mpg321 -q internet_on_backup.mp3") pass connected = 1 ledSwitch = 0 time.sleep(2) except: powerSwitch = 1 with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Error,No internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) ledSwitch = 1 Thread(target = led_red_alert).start() try: powerSwitch = 1 tts = gTTS(text="Alert! All communications are down. Alert! Systems running in emergency mode. Alert! Restoring communications, priority alpha." , lang='en') tts.save("internet_off.mp3") os.system("mpg321 -q internet_off.mp3") os.system("mpg321 -q vader_breathe.mp3") os.system("mpg321 -q vader_dont_fail.mp3") except: powerSwitch = 1 os.system("mpg321 -q internet_off_backup.mp3") os.system("mpg321 -q vader_breathe.mp3") os.system("mpg321 -q vader_dont_fail.mp3") pass connected = 0 ledSwitch = 0 time.sleep(2) pass def internet_on_thread(): global powerSwitch global ledSwitch global connected while True: time.sleep(180) with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Log,Testing Internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) if connected == 1: try: powerSwitch = 0 urllib.request.urlopen('http://216.58.207.206') #urllib.urlopen('http://216.58.207.206', timeout=4) with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Log,We have an internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) connected = 1 except: powerSwitch = 1 with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Error,No internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) ledSwitch = 1 Thread(target = led_red_alert).start() try: powerSwitch = 1 tts = gTTS(text="Alert! All communications are down. Alert! Systems running in emergency mode. Alert! Restoring communications, priority alpha." , lang='en') tts.save("internet_off.mp3") os.system("mpg321 -q internet_off.mp3") os.system("mpg321 -q vader_breathe.mp3") os.system("mpg321 -q vader_dont_fail.mp3") except: powerSwitch = 1 os.system("mpg321 -q internet_off_backup.mp3") os.system("mpg321 -q vader_breathe.mp3") os.system("mpg321 -q vader_dont_fail.mp3") pass ledSwitch = 0 connected = 0 time.sleep(2) pass elif connected == 0: try: powerSwitch = 0 urllib.request.urlopen('http://216.58.192.142') with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Log,We have an internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) ledSwitch = 1 Thread(target = led_green_alert).start() try: powerSwitch = 0 tts = gTTS(text="Code green! All communication systems are online and working within normal parameters." , lang='en') tts.save("internet_on.mp3") os.system("mpg321 -q internet_on.mp3") except: powerSwitch = 1 os.system("mpg321 -q internet_on_backup.mp3") pass ledSwitch = 0 connected = 1 time.sleep(2) except: powerSwitch = 1 with open("error_log.csv", "a") as error_log: error_log.write("\n{0},Error,No internet connection.".format(strftime("%Y-%m-%d %H:%M:%S"))) connected = 0 pass
def internet_on(): with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Log,Testing Internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) global ledSwitch global connected global powerSwitch try: power_switch = 0 urllib.request.urlopen('http://216.58.207.206') with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Log,We have an internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) led_switch = 1 thread(target=led_green_alert).start() try: power_switch = 0 tts = g_tts(text='Code green! All communication systems are online and working within normal parameters.', lang='en') tts.save('internet_on.mp3') os.system('mpg321 -q internet_on.mp3') except: power_switch = 1 os.system('mpg321 -q internet_on_backup.mp3') pass connected = 1 led_switch = 0 time.sleep(2) except: power_switch = 1 with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Error,No internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) led_switch = 1 thread(target=led_red_alert).start() try: power_switch = 1 tts = g_tts(text='Alert! All communications are down. Alert! Systems running in emergency mode. Alert! Restoring communications, priority alpha.', lang='en') tts.save('internet_off.mp3') os.system('mpg321 -q internet_off.mp3') os.system('mpg321 -q vader_breathe.mp3') os.system('mpg321 -q vader_dont_fail.mp3') except: power_switch = 1 os.system('mpg321 -q internet_off_backup.mp3') os.system('mpg321 -q vader_breathe.mp3') os.system('mpg321 -q vader_dont_fail.mp3') pass connected = 0 led_switch = 0 time.sleep(2) pass def internet_on_thread(): global powerSwitch global ledSwitch global connected while True: time.sleep(180) with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Log,Testing Internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) if connected == 1: try: power_switch = 0 urllib.request.urlopen('http://216.58.207.206') with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Log,We have an internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) connected = 1 except: power_switch = 1 with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Error,No internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) led_switch = 1 thread(target=led_red_alert).start() try: power_switch = 1 tts = g_tts(text='Alert! All communications are down. Alert! Systems running in emergency mode. Alert! Restoring communications, priority alpha.', lang='en') tts.save('internet_off.mp3') os.system('mpg321 -q internet_off.mp3') os.system('mpg321 -q vader_breathe.mp3') os.system('mpg321 -q vader_dont_fail.mp3') except: power_switch = 1 os.system('mpg321 -q internet_off_backup.mp3') os.system('mpg321 -q vader_breathe.mp3') os.system('mpg321 -q vader_dont_fail.mp3') pass led_switch = 0 connected = 0 time.sleep(2) pass elif connected == 0: try: power_switch = 0 urllib.request.urlopen('http://216.58.192.142') with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Log,We have an internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) led_switch = 1 thread(target=led_green_alert).start() try: power_switch = 0 tts = g_tts(text='Code green! All communication systems are online and working within normal parameters.', lang='en') tts.save('internet_on.mp3') os.system('mpg321 -q internet_on.mp3') except: power_switch = 1 os.system('mpg321 -q internet_on_backup.mp3') pass led_switch = 0 connected = 1 time.sleep(2) except: power_switch = 1 with open('error_log.csv', 'a') as error_log: error_log.write('\n{0},Error,No internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S'))) connected = 0 pass
# coding: utf-8 """***************************************************************************** * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software * and any derivatives exclusively with Microchip products. It is your * responsibility to comply with third party license terms applicable to your * use of third party software (including open source software) that may * accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. *****************************************************************************""" ################################################################################################### ########################################## Callbacks ############################################# ################################################################################################### def updateSupcConfigVisibleProperty(symbol, event): symbol.setVisible(event["value"]) def updateBOD33PrescalerVisibleProperty(symbol, event): if supcSym_BOD33_STDBYCFG.getValue() == 1 or supcSym_BOD33_RUNHIB.getValue() == True or supcSym_BOD33_RUNBKUP.getValue() == True: symbol.setVisible(True) else: symbol.setVisible(False) def updateVrefVisibleProperty(symbol, event): if supcSym_VREF_VREFOE.getValue() == True and supcSym_VREF_ONDEMAND.getValue() == False: symbol.setVisible(False) else: symbol.setVisible(True) def interruptControl(symbol, event): Database.setSymbolValue("core", InterruptVector, event["value"], 2) Database.setSymbolValue("core", InterruptHandlerLock, event["value"], 2) if event["value"] == True: Database.setSymbolValue("core", InterruptHandler, supcInstanceName.getValue() + "_BODDET_InterruptHandler", 2) else: Database.setSymbolValue("core", InterruptHandler, supcInstanceName.getValue() + "_BODDET_Handler", 2) ################################################################################################### ########################################## Component ############################################# ################################################################################################### def instantiateComponent(supcComponent): global supcSym_BOD33_STDBYCFG global supcSym_BOD33_RUNHIB global supcSym_BOD33_RUNBKUP global supcSym_VREF_VREFOE global supcSym_VREF_ONDEMAND global supcInstanceName global InterruptVector global InterruptHandler global InterruptHandlerLock global supcSym_INTENSET supcInstanceName = supcComponent.createStringSymbol("SUPC_INSTANCE_NAME", None) supcInstanceName.setVisible(False) supcInstanceName.setDefaultValue(supcComponent.getID().upper()) #BOD33 Menu supcSym_BOD33_Menu= supcComponent.createMenuSymbol("BOD33_MENU", None) supcSym_BOD33_Menu.setLabel("VDD Brown-Out Detector (BOD33) Configuration") #BOD33 interrupt mode supcSym_INTENSET = supcComponent.createBooleanSymbol("SUPC_INTERRUPT_ENABLE", supcSym_BOD33_Menu) supcSym_INTENSET.setLabel("Enable BOD Interrupt") supcSym_INTENSET.setDefaultValue(False) # Interrupt Warning status supcSym_IntEnComment = supcComponent.createCommentSymbol("SUPC_INTERRUPT_ENABLE_COMMENT", supcSym_BOD33_Menu) supcSym_IntEnComment.setVisible(False) supcSym_IntEnComment.setLabel("Warning!!! SUPC Interrupt is Disabled in Interrupt Manager") supcSym_IntEnComment.setDependencies(interruptControl, ["SUPC_INTERRUPT_ENABLE"]) #BOD33 RUNHIB supcSym_BOD33_RUNHIB = supcComponent.createBooleanSymbol("SUPC_BOD33_RUNHIB", supcSym_BOD33_Menu) supcSym_BOD33_RUNHIB.setLabel("Run in Hibernate Mode") supcSym_BOD33_RUNHIB.setDescription("Configures BOD33 operation in Hibernate Sleep Mode") supcSym_BOD33_RUNHIB.setDefaultValue(False) #BOD33 RUNBKUP supcSym_BOD33_RUNBKUP = supcComponent.createBooleanSymbol("SUPC_BOD33_RUNBKUP", supcSym_BOD33_Menu) supcSym_BOD33_RUNBKUP.setLabel("Run in Backup Mode") supcSym_BOD33_RUNBKUP.setDescription("Configures BOD33 operation in Backup Sleep Mode") supcSym_BOD33_RUNBKUP.setDefaultValue(False) #BOD33 RUNSTDBY supcSym_BOD33_RUNSTDBY = supcComponent.createBooleanSymbol("SUPC_BOD33_RUNSTDBY", supcSym_BOD33_Menu) supcSym_BOD33_RUNSTDBY.setLabel("Run in Standby Mode") supcSym_BOD33_RUNSTDBY.setDescription("Configures BOD33 operation in Standby Sleep Mode") supcSym_BOD33_RUNSTDBY.setDefaultValue(False) #BOD33 STDBYCFG mode supcSym_BOD33_STDBYCFG = supcComponent.createKeyValueSetSymbol("SUPC_BOD33_STDBYCFG", supcSym_BOD33_Menu) supcSym_BOD33_STDBYCFG.setLabel("Select Standby Mode Operation") supcSym_BOD33_STDBYCFG.setDescription("Configures whether BOD33 should operate in continuous or sampling mode in Standby Sleep Mode") supcSym_BOD33_STDBYCFG.addKey("CONT_MODE", "0", "Continuous Mode") supcSym_BOD33_STDBYCFG.addKey("SAMP_MODE", "1", "Sampling Mode") supcSym_BOD33_STDBYCFG.setDefaultValue(0) supcSym_BOD33_STDBYCFG.setOutputMode("Value") supcSym_BOD33_STDBYCFG.setDisplayMode("Description") supcSym_BOD33_STDBYCFG.setVisible(False) supcSym_BOD33_STDBYCFG.setDependencies(updateSupcConfigVisibleProperty, ["SUPC_BOD33_RUNSTDBY"]) #BOD33 PSEL supcSym_BOD33_PSEL = supcComponent.createKeyValueSetSymbol("SUPC_BOD33_PSEL", supcSym_BOD33_Menu) supcSym_BOD33_PSEL.setLabel("Select Prescaler for Sampling Clock") supcSym_BOD33_PSEL.setDescription("Configures the sampling clock prescaler when BOD33 is operating in sampling Mode") supcSym_BOD33_PSEL.setVisible(False) supcSym_BOD33_PSEL.setDependencies(updateBOD33PrescalerVisibleProperty, ["SUPC_BOD33_STDBYCFG", "SUPC_BOD33_RUNHIB", "SUPC_BOD33_RUNBKUP"]) supcBOD33PselNode = ATDF.getNode("/avr-tools-device-file/modules/module@[name=\"SUPC\"]/value-group@[name=\"SUPC_BOD33__PSEL\"]") supcBOD33PselValues = [] supcBOD33PselValues = supcBOD33PselNode.getChildren() #PSEL value 0 is not usable in sampling mode. Thus the loop starts from 1. for index in range (1, len(supcBOD33PselValues)): supcBOD33PselKeyName = supcBOD33PselValues[index].getAttribute("name") supcBOD33PselKeyDescription = supcBOD33PselValues[index].getAttribute("caption") supcBOD33PselKeyValue = supcBOD33PselValues[index].getAttribute("value") supcSym_BOD33_PSEL.addKey(supcBOD33PselKeyName, supcBOD33PselKeyValue, supcBOD33PselKeyDescription) supcSym_BOD33_PSEL.setDefaultValue(0) supcSym_BOD33_PSEL.setOutputMode("Value") supcSym_BOD33_PSEL.setDisplayMode("Description") #BOD Configuration comment supcSym_BOD33_FuseComment = supcComponent.createCommentSymbol("SUPC_CONFIG_COMMENT", supcSym_BOD33_Menu) supcSym_BOD33_FuseComment.setLabel("Note: Configure BOD33 Fuses using 'System' component") #VREG Menu supcSym_VREG_Menu= supcComponent.createMenuSymbol("VREG_MENU", None) supcSym_VREG_Menu.setLabel("Voltage Regulator (VREG) Configuration") #VREG RUNBKUP mode supcSym_VREG_RUNBKUP = supcComponent.createKeyValueSetSymbol("SUPC_VREG_RUNBKUP", supcSym_VREG_Menu) supcSym_VREG_RUNBKUP.setLabel("Main Voltage Regulator operation in backup sleep") supcSym_VREG_RUNBKUP.setDescription("Selects Main Voltage Regulator operation in backup sleep") supcSym_VREG_RUNBKUP.addKey("REG_OFF", "0", "Regulator stopped") supcSym_VREG_RUNBKUP.addKey("REG_ON", "1", "Regulator not stopped") supcSym_VREG_RUNBKUP.setDefaultValue(0) supcSym_VREG_RUNBKUP.setOutputMode("Value") supcSym_VREG_RUNBKUP.setDisplayMode("Description") #VREG VESN supcSym_VREG_VSEN = supcComponent.createBooleanSymbol("SUPC_VREG_VSEN", supcSym_VREG_Menu) supcSym_VREG_VSEN.setLabel("Enable Voltage Scaling") supcSym_VREG_VSEN.setDescription("Enable smooth transition of VDDCORE") supcSym_VREG_VSEN.setDefaultValue(False) #VREG VSPER supcSym_VREG_VSPER = supcComponent.createIntegerSymbol("SUPC_VREG_VSPER", supcSym_VREG_Menu) supcSym_VREG_VSPER.setLabel("Voltage Scaling Period") supcSym_VREG_VSEN.setDescription("The time is ((2^VSPER) * T), where T is an internal period (typ 250 ns).") supcSym_VREG_VSPER.setDefaultValue(0) supcSym_VREG_VSPER.setMin(0) supcSym_VREG_VSPER.setMax(7) supcSym_VREG_VSPER.setVisible(False) supcSym_VREG_VSPER.setDependencies(updateSupcConfigVisibleProperty, ["SUPC_VREG_VSEN"]) #VREF Menu supcSym_VREF_Menu= supcComponent.createMenuSymbol("VREF_MENU", None) supcSym_VREF_Menu.setLabel("Voltage Reference (VREF) Configuration") supcSym_VREF_SEL = supcComponent.createKeyValueSetSymbol("SUPC_VREF_SEL", supcSym_VREF_Menu) supcSym_VREF_SEL.setLabel("Voltage Reference value") supcSym_VREF_SEL.setDescription("Select the Voltage Reference typical value") supcVREFSelNode = ATDF.getNode("/avr-tools-device-file/modules/module@[name=\"SUPC\"]/value-group@[name=\"SUPC_VREF__SEL\"]") supcVREFSelValues = [] supcVREFSelValues = supcVREFSelNode.getChildren() for index in range (0, len(supcVREFSelValues)): supcVREFSelKeyName = supcVREFSelValues[index].getAttribute("name") supcVREFSelKeyDescription = supcVREFSelValues[index].getAttribute("caption") supcVREFSelKeyValue = supcVREFSelValues[index].getAttribute("value") supcSym_VREF_SEL.addKey(supcVREFSelKeyName, supcVREFSelKeyValue, supcVREFSelKeyDescription) supcSym_VREF_SEL.setDefaultValue(0) supcSym_VREF_SEL.setOutputMode("Value") supcSym_VREF_SEL.setDisplayMode("Description") #VREF ONDEMAND mode supcSym_VREF_ONDEMAND = supcComponent.createBooleanSymbol("SUPC_VREF_ONDEMAND", supcSym_VREF_Menu) supcSym_VREF_ONDEMAND.setLabel("Enable On demand") supcSym_VREF_ONDEMAND.setDescription("If this option is enabled, the voltage reference is disabled when no peripheral is requesting it.") supcSym_VREF_ONDEMAND.setDefaultValue(False) #VREF RUNSTDBY mode supcSym_VREF_RUNSTDBY = supcComponent.createBooleanSymbol("SUPC_VREF_RUNSTDBY", supcSym_VREF_Menu) supcSym_VREF_RUNSTDBY.setLabel("Enable Run in Standby") supcSym_VREF_RUNSTDBY.setDescription("Enable VREF operation in Standby Sleep Mode") #VREF VREFOE supcSym_VREF_VREFOE = supcComponent.createBooleanSymbol("SUPC_VREF_VREFOE", supcSym_VREF_Menu) supcSym_VREF_VREFOE.setLabel("Enable VREF output") supcSym_VREF_VREFOE.setDescription("Enable VREF connection to ADC. If ONDEMAND is 0 and VREF is enabled, Temperature Sensor cannot be used") supcSym_VREF_VREFOE.setDefaultValue(False) #VREF TSEN supcSym_VREF_TSEN = supcComponent.createBooleanSymbol("SUPC_VREF_TSEN", supcSym_VREF_Menu) supcSym_VREF_TSEN.setLabel("Enable Temperature Sensor") supcSym_VREF_TSEN.setDescription("Enable Temperature Sensor connection to ADC") supcSym_VREF_TSEN.setDefaultValue(False) supcSym_VREF_TSEN.setDependencies(updateVrefVisibleProperty, ["SUPC_VREF_ONDEMAND", "SUPC_VREF_VREFOE"]) #BBPS Menu supcSym_BBPS_Menu= supcComponent.createMenuSymbol("SUPC_BBPS", None) supcSym_BBPS_Menu.setLabel("Battery Backup Power Switch Configuraiton") #BBPS supply switching supcSym_BBPS = supcComponent.createBooleanSymbol("SUPC_BBPS_WAKEEN", supcSym_BBPS_Menu) supcSym_BBPS.setLabel("Wake Device on BBPS Switching") supcSym_BBPS.setDescription("The device can be woken up when switched from battery backup power to Main Power.") #SUPC Output pin configuration #For pin names, refer 'Supply Controller Pinout' in Datasheet supcSym_BKOUT_Menu= supcComponent.createMenuSymbol("SUPC_BKOUT", None) supcSym_BKOUT_Menu.setLabel("SUPC Output pin configuraiton") #SUPC Output pin 0 supcSym_BKOUT0 = supcComponent.createBooleanSymbol("SUPC_BKOUT_0", supcSym_BKOUT_Menu) supcSym_BKOUT0.setLabel("Enable OUT0") supcSym_BKOUT0.setDescription("OUT0 pin can be driven by SUPC. It can be toggled by SUPC, based on RTC Events") supcSym_BKOUT0.setDefaultValue(False) #RTCTGCL 0 supcSym_BKOUT_RTCTGL0 = supcComponent.createBooleanSymbol("SUPC_BKOUT_RTCTGCL0", supcSym_BKOUT0) supcSym_BKOUT_RTCTGL0.setLabel("Toggle OUT0 on RTC Event") supcSym_BKOUT_RTCTGL0.setDescription("OUT0 pin can be toggled by SUPC, based on RTC Events") supcSym_BKOUT_RTCTGL0.setDependencies(updateSupcConfigVisibleProperty, ["SUPC_BKOUT_0"]) supcSym_BKOUT_RTCTGL0.setVisible(False) #SUPC Output pin 1 supcSym_BKOUT1 = supcComponent.createBooleanSymbol("SUPC_BKOUT_1", supcSym_BKOUT_Menu) supcSym_BKOUT1.setLabel("Enable OUT1") supcSym_BKOUT1.setDescription("OUT1 pin can be driven by SUPC. It can be toggled by SUPC, based on RTC Events") supcSym_BKOUT1.setDefaultValue(False) #RTCTGCL 1 supcSym_BKOUT_RTCTGL1 = supcComponent.createBooleanSymbol("SUPC_BKOUT_RTCTGCL1", supcSym_BKOUT1) supcSym_BKOUT_RTCTGL1.setLabel("Toggle OUT1 on RTC Event") supcSym_BKOUT_RTCTGL1.setDescription("OUT1 pin can be toggled by SUPC, based on RTC Events") supcSym_BKOUT_RTCTGL1.setDependencies(updateSupcConfigVisibleProperty, ["SUPC_BKOUT_1"]) supcSym_BKOUT_RTCTGL1.setVisible(False) ############################################################################ #### Dependency #### ############################################################################ InterruptVector = supcInstanceName.getValue() + "_BODDET_INTERRUPT_ENABLE" InterruptHandler = supcInstanceName.getValue() + "_BODDET_INTERRUPT_HANDLER" InterruptHandlerLock = supcInstanceName.getValue()+ "_BODDET_INTERRUPT_HANDLER_LOCK" ################################################################################################### ####################################### Code Generation ########################################## ################################################################################################### configName = Variables.get("__CONFIGURATION_NAME") supcSym_HeaderFile = supcComponent.createFileSymbol("SUPC_HEADER", None) supcSym_HeaderFile.setSourcePath("../peripheral/supc_u2407/templates/plib_supc.h.ftl") supcSym_HeaderFile.setOutputName("plib_"+supcInstanceName.getValue().lower()+".h") supcSym_HeaderFile.setDestPath("/peripheral/supc/") supcSym_HeaderFile.setProjectPath("config/" + configName + "/peripheral/supc/") supcSym_HeaderFile.setType("HEADER") supcSym_HeaderFile.setMarkup(True) supcSym_SourceFile = supcComponent.createFileSymbol("SUPC_SOURCE", None) supcSym_SourceFile.setSourcePath("../peripheral/supc_u2407/templates/plib_supc.c.ftl") supcSym_SourceFile.setOutputName("plib_"+supcInstanceName.getValue().lower()+".c") supcSym_SourceFile.setDestPath("/peripheral/supc/") supcSym_SourceFile.setProjectPath("config/" + configName + "/peripheral/supc/") supcSym_SourceFile.setType("SOURCE") supcSym_SourceFile.setMarkup(True) supcSym_SystemInitFile = supcComponent.createFileSymbol("SUPC_SYS_INT", None) supcSym_SystemInitFile.setType("STRING") supcSym_SystemInitFile.setOutputName("core.LIST_SYSTEM_INIT_C_SYS_INITIALIZE_PERIPHERALS") supcSym_SystemInitFile.setSourcePath("../peripheral/supc_u2407/templates/system/initialization.c.ftl") supcSym_SystemInitFile.setMarkup(True) supcSym_SystemDefFile = supcComponent.createFileSymbol("SUPC_SYS_DEF", None) supcSym_SystemDefFile.setType("STRING") supcSym_SystemDefFile.setOutputName("core.LIST_SYSTEM_DEFINITIONS_H_INCLUDES") supcSym_SystemDefFile.setSourcePath("../peripheral/supc_u2407/templates/system/definitions.h.ftl") supcSym_SystemDefFile.setMarkup(True)
"""***************************************************************************** * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software * and any derivatives exclusively with Microchip products. It is your * responsibility to comply with third party license terms applicable to your * use of third party software (including open source software) that may * accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. *****************************************************************************""" def update_supc_config_visible_property(symbol, event): symbol.setVisible(event['value']) def update_bod33_prescaler_visible_property(symbol, event): if supcSym_BOD33_STDBYCFG.getValue() == 1 or supcSym_BOD33_RUNHIB.getValue() == True or supcSym_BOD33_RUNBKUP.getValue() == True: symbol.setVisible(True) else: symbol.setVisible(False) def update_vref_visible_property(symbol, event): if supcSym_VREF_VREFOE.getValue() == True and supcSym_VREF_ONDEMAND.getValue() == False: symbol.setVisible(False) else: symbol.setVisible(True) def interrupt_control(symbol, event): Database.setSymbolValue('core', InterruptVector, event['value'], 2) Database.setSymbolValue('core', InterruptHandlerLock, event['value'], 2) if event['value'] == True: Database.setSymbolValue('core', InterruptHandler, supcInstanceName.getValue() + '_BODDET_InterruptHandler', 2) else: Database.setSymbolValue('core', InterruptHandler, supcInstanceName.getValue() + '_BODDET_Handler', 2) def instantiate_component(supcComponent): global supcSym_BOD33_STDBYCFG global supcSym_BOD33_RUNHIB global supcSym_BOD33_RUNBKUP global supcSym_VREF_VREFOE global supcSym_VREF_ONDEMAND global supcInstanceName global InterruptVector global InterruptHandler global InterruptHandlerLock global supcSym_INTENSET supc_instance_name = supcComponent.createStringSymbol('SUPC_INSTANCE_NAME', None) supcInstanceName.setVisible(False) supcInstanceName.setDefaultValue(supcComponent.getID().upper()) supc_sym_bod33__menu = supcComponent.createMenuSymbol('BOD33_MENU', None) supcSym_BOD33_Menu.setLabel('VDD Brown-Out Detector (BOD33) Configuration') supc_sym_intenset = supcComponent.createBooleanSymbol('SUPC_INTERRUPT_ENABLE', supcSym_BOD33_Menu) supcSym_INTENSET.setLabel('Enable BOD Interrupt') supcSym_INTENSET.setDefaultValue(False) supc_sym__int_en_comment = supcComponent.createCommentSymbol('SUPC_INTERRUPT_ENABLE_COMMENT', supcSym_BOD33_Menu) supcSym_IntEnComment.setVisible(False) supcSym_IntEnComment.setLabel('Warning!!! SUPC Interrupt is Disabled in Interrupt Manager') supcSym_IntEnComment.setDependencies(interruptControl, ['SUPC_INTERRUPT_ENABLE']) supc_sym_bod33_runhib = supcComponent.createBooleanSymbol('SUPC_BOD33_RUNHIB', supcSym_BOD33_Menu) supcSym_BOD33_RUNHIB.setLabel('Run in Hibernate Mode') supcSym_BOD33_RUNHIB.setDescription('Configures BOD33 operation in Hibernate Sleep Mode') supcSym_BOD33_RUNHIB.setDefaultValue(False) supc_sym_bod33_runbkup = supcComponent.createBooleanSymbol('SUPC_BOD33_RUNBKUP', supcSym_BOD33_Menu) supcSym_BOD33_RUNBKUP.setLabel('Run in Backup Mode') supcSym_BOD33_RUNBKUP.setDescription('Configures BOD33 operation in Backup Sleep Mode') supcSym_BOD33_RUNBKUP.setDefaultValue(False) supc_sym_bod33_runstdby = supcComponent.createBooleanSymbol('SUPC_BOD33_RUNSTDBY', supcSym_BOD33_Menu) supcSym_BOD33_RUNSTDBY.setLabel('Run in Standby Mode') supcSym_BOD33_RUNSTDBY.setDescription('Configures BOD33 operation in Standby Sleep Mode') supcSym_BOD33_RUNSTDBY.setDefaultValue(False) supc_sym_bod33_stdbycfg = supcComponent.createKeyValueSetSymbol('SUPC_BOD33_STDBYCFG', supcSym_BOD33_Menu) supcSym_BOD33_STDBYCFG.setLabel('Select Standby Mode Operation') supcSym_BOD33_STDBYCFG.setDescription('Configures whether BOD33 should operate in continuous or sampling mode in Standby Sleep Mode') supcSym_BOD33_STDBYCFG.addKey('CONT_MODE', '0', 'Continuous Mode') supcSym_BOD33_STDBYCFG.addKey('SAMP_MODE', '1', 'Sampling Mode') supcSym_BOD33_STDBYCFG.setDefaultValue(0) supcSym_BOD33_STDBYCFG.setOutputMode('Value') supcSym_BOD33_STDBYCFG.setDisplayMode('Description') supcSym_BOD33_STDBYCFG.setVisible(False) supcSym_BOD33_STDBYCFG.setDependencies(updateSupcConfigVisibleProperty, ['SUPC_BOD33_RUNSTDBY']) supc_sym_bod33_psel = supcComponent.createKeyValueSetSymbol('SUPC_BOD33_PSEL', supcSym_BOD33_Menu) supcSym_BOD33_PSEL.setLabel('Select Prescaler for Sampling Clock') supcSym_BOD33_PSEL.setDescription('Configures the sampling clock prescaler when BOD33 is operating in sampling Mode') supcSym_BOD33_PSEL.setVisible(False) supcSym_BOD33_PSEL.setDependencies(updateBOD33PrescalerVisibleProperty, ['SUPC_BOD33_STDBYCFG', 'SUPC_BOD33_RUNHIB', 'SUPC_BOD33_RUNBKUP']) supc_bod33_psel_node = ATDF.getNode('/avr-tools-device-file/modules/module@[name="SUPC"]/value-group@[name="SUPC_BOD33__PSEL"]') supc_bod33_psel_values = [] supc_bod33_psel_values = supcBOD33PselNode.getChildren() for index in range(1, len(supcBOD33PselValues)): supc_bod33_psel_key_name = supcBOD33PselValues[index].getAttribute('name') supc_bod33_psel_key_description = supcBOD33PselValues[index].getAttribute('caption') supc_bod33_psel_key_value = supcBOD33PselValues[index].getAttribute('value') supcSym_BOD33_PSEL.addKey(supcBOD33PselKeyName, supcBOD33PselKeyValue, supcBOD33PselKeyDescription) supcSym_BOD33_PSEL.setDefaultValue(0) supcSym_BOD33_PSEL.setOutputMode('Value') supcSym_BOD33_PSEL.setDisplayMode('Description') supc_sym_bod33__fuse_comment = supcComponent.createCommentSymbol('SUPC_CONFIG_COMMENT', supcSym_BOD33_Menu) supcSym_BOD33_FuseComment.setLabel("Note: Configure BOD33 Fuses using 'System' component") supc_sym_vreg__menu = supcComponent.createMenuSymbol('VREG_MENU', None) supcSym_VREG_Menu.setLabel('Voltage Regulator (VREG) Configuration') supc_sym_vreg_runbkup = supcComponent.createKeyValueSetSymbol('SUPC_VREG_RUNBKUP', supcSym_VREG_Menu) supcSym_VREG_RUNBKUP.setLabel('Main Voltage Regulator operation in backup sleep') supcSym_VREG_RUNBKUP.setDescription('Selects Main Voltage Regulator operation in backup sleep') supcSym_VREG_RUNBKUP.addKey('REG_OFF', '0', 'Regulator stopped') supcSym_VREG_RUNBKUP.addKey('REG_ON', '1', 'Regulator not stopped') supcSym_VREG_RUNBKUP.setDefaultValue(0) supcSym_VREG_RUNBKUP.setOutputMode('Value') supcSym_VREG_RUNBKUP.setDisplayMode('Description') supc_sym_vreg_vsen = supcComponent.createBooleanSymbol('SUPC_VREG_VSEN', supcSym_VREG_Menu) supcSym_VREG_VSEN.setLabel('Enable Voltage Scaling') supcSym_VREG_VSEN.setDescription('Enable smooth transition of VDDCORE') supcSym_VREG_VSEN.setDefaultValue(False) supc_sym_vreg_vsper = supcComponent.createIntegerSymbol('SUPC_VREG_VSPER', supcSym_VREG_Menu) supcSym_VREG_VSPER.setLabel('Voltage Scaling Period') supcSym_VREG_VSEN.setDescription('The time is ((2^VSPER) * T), where T is an internal period (typ 250 ns).') supcSym_VREG_VSPER.setDefaultValue(0) supcSym_VREG_VSPER.setMin(0) supcSym_VREG_VSPER.setMax(7) supcSym_VREG_VSPER.setVisible(False) supcSym_VREG_VSPER.setDependencies(updateSupcConfigVisibleProperty, ['SUPC_VREG_VSEN']) supc_sym_vref__menu = supcComponent.createMenuSymbol('VREF_MENU', None) supcSym_VREF_Menu.setLabel('Voltage Reference (VREF) Configuration') supc_sym_vref_sel = supcComponent.createKeyValueSetSymbol('SUPC_VREF_SEL', supcSym_VREF_Menu) supcSym_VREF_SEL.setLabel('Voltage Reference value') supcSym_VREF_SEL.setDescription('Select the Voltage Reference typical value') supc_vref_sel_node = ATDF.getNode('/avr-tools-device-file/modules/module@[name="SUPC"]/value-group@[name="SUPC_VREF__SEL"]') supc_vref_sel_values = [] supc_vref_sel_values = supcVREFSelNode.getChildren() for index in range(0, len(supcVREFSelValues)): supc_vref_sel_key_name = supcVREFSelValues[index].getAttribute('name') supc_vref_sel_key_description = supcVREFSelValues[index].getAttribute('caption') supc_vref_sel_key_value = supcVREFSelValues[index].getAttribute('value') supcSym_VREF_SEL.addKey(supcVREFSelKeyName, supcVREFSelKeyValue, supcVREFSelKeyDescription) supcSym_VREF_SEL.setDefaultValue(0) supcSym_VREF_SEL.setOutputMode('Value') supcSym_VREF_SEL.setDisplayMode('Description') supc_sym_vref_ondemand = supcComponent.createBooleanSymbol('SUPC_VREF_ONDEMAND', supcSym_VREF_Menu) supcSym_VREF_ONDEMAND.setLabel('Enable On demand') supcSym_VREF_ONDEMAND.setDescription('If this option is enabled, the voltage reference is disabled when no peripheral is requesting it.') supcSym_VREF_ONDEMAND.setDefaultValue(False) supc_sym_vref_runstdby = supcComponent.createBooleanSymbol('SUPC_VREF_RUNSTDBY', supcSym_VREF_Menu) supcSym_VREF_RUNSTDBY.setLabel('Enable Run in Standby') supcSym_VREF_RUNSTDBY.setDescription('Enable VREF operation in Standby Sleep Mode') supc_sym_vref_vrefoe = supcComponent.createBooleanSymbol('SUPC_VREF_VREFOE', supcSym_VREF_Menu) supcSym_VREF_VREFOE.setLabel('Enable VREF output') supcSym_VREF_VREFOE.setDescription('Enable VREF connection to ADC. If ONDEMAND is 0 and VREF is enabled, Temperature Sensor cannot be used') supcSym_VREF_VREFOE.setDefaultValue(False) supc_sym_vref_tsen = supcComponent.createBooleanSymbol('SUPC_VREF_TSEN', supcSym_VREF_Menu) supcSym_VREF_TSEN.setLabel('Enable Temperature Sensor') supcSym_VREF_TSEN.setDescription('Enable Temperature Sensor connection to ADC') supcSym_VREF_TSEN.setDefaultValue(False) supcSym_VREF_TSEN.setDependencies(updateVrefVisibleProperty, ['SUPC_VREF_ONDEMAND', 'SUPC_VREF_VREFOE']) supc_sym_bbps__menu = supcComponent.createMenuSymbol('SUPC_BBPS', None) supcSym_BBPS_Menu.setLabel('Battery Backup Power Switch Configuraiton') supc_sym_bbps = supcComponent.createBooleanSymbol('SUPC_BBPS_WAKEEN', supcSym_BBPS_Menu) supcSym_BBPS.setLabel('Wake Device on BBPS Switching') supcSym_BBPS.setDescription('The device can be woken up when switched from battery backup power to Main Power.') supc_sym_bkout__menu = supcComponent.createMenuSymbol('SUPC_BKOUT', None) supcSym_BKOUT_Menu.setLabel('SUPC Output pin configuraiton') supc_sym_bkout0 = supcComponent.createBooleanSymbol('SUPC_BKOUT_0', supcSym_BKOUT_Menu) supcSym_BKOUT0.setLabel('Enable OUT0') supcSym_BKOUT0.setDescription('OUT0 pin can be driven by SUPC. It can be toggled by SUPC, based on RTC Events') supcSym_BKOUT0.setDefaultValue(False) supc_sym_bkout_rtctgl0 = supcComponent.createBooleanSymbol('SUPC_BKOUT_RTCTGCL0', supcSym_BKOUT0) supcSym_BKOUT_RTCTGL0.setLabel('Toggle OUT0 on RTC Event') supcSym_BKOUT_RTCTGL0.setDescription('OUT0 pin can be toggled by SUPC, based on RTC Events') supcSym_BKOUT_RTCTGL0.setDependencies(updateSupcConfigVisibleProperty, ['SUPC_BKOUT_0']) supcSym_BKOUT_RTCTGL0.setVisible(False) supc_sym_bkout1 = supcComponent.createBooleanSymbol('SUPC_BKOUT_1', supcSym_BKOUT_Menu) supcSym_BKOUT1.setLabel('Enable OUT1') supcSym_BKOUT1.setDescription('OUT1 pin can be driven by SUPC. It can be toggled by SUPC, based on RTC Events') supcSym_BKOUT1.setDefaultValue(False) supc_sym_bkout_rtctgl1 = supcComponent.createBooleanSymbol('SUPC_BKOUT_RTCTGCL1', supcSym_BKOUT1) supcSym_BKOUT_RTCTGL1.setLabel('Toggle OUT1 on RTC Event') supcSym_BKOUT_RTCTGL1.setDescription('OUT1 pin can be toggled by SUPC, based on RTC Events') supcSym_BKOUT_RTCTGL1.setDependencies(updateSupcConfigVisibleProperty, ['SUPC_BKOUT_1']) supcSym_BKOUT_RTCTGL1.setVisible(False) interrupt_vector = supcInstanceName.getValue() + '_BODDET_INTERRUPT_ENABLE' interrupt_handler = supcInstanceName.getValue() + '_BODDET_INTERRUPT_HANDLER' interrupt_handler_lock = supcInstanceName.getValue() + '_BODDET_INTERRUPT_HANDLER_LOCK' config_name = Variables.get('__CONFIGURATION_NAME') supc_sym__header_file = supcComponent.createFileSymbol('SUPC_HEADER', None) supcSym_HeaderFile.setSourcePath('../peripheral/supc_u2407/templates/plib_supc.h.ftl') supcSym_HeaderFile.setOutputName('plib_' + supcInstanceName.getValue().lower() + '.h') supcSym_HeaderFile.setDestPath('/peripheral/supc/') supcSym_HeaderFile.setProjectPath('config/' + configName + '/peripheral/supc/') supcSym_HeaderFile.setType('HEADER') supcSym_HeaderFile.setMarkup(True) supc_sym__source_file = supcComponent.createFileSymbol('SUPC_SOURCE', None) supcSym_SourceFile.setSourcePath('../peripheral/supc_u2407/templates/plib_supc.c.ftl') supcSym_SourceFile.setOutputName('plib_' + supcInstanceName.getValue().lower() + '.c') supcSym_SourceFile.setDestPath('/peripheral/supc/') supcSym_SourceFile.setProjectPath('config/' + configName + '/peripheral/supc/') supcSym_SourceFile.setType('SOURCE') supcSym_SourceFile.setMarkup(True) supc_sym__system_init_file = supcComponent.createFileSymbol('SUPC_SYS_INT', None) supcSym_SystemInitFile.setType('STRING') supcSym_SystemInitFile.setOutputName('core.LIST_SYSTEM_INIT_C_SYS_INITIALIZE_PERIPHERALS') supcSym_SystemInitFile.setSourcePath('../peripheral/supc_u2407/templates/system/initialization.c.ftl') supcSym_SystemInitFile.setMarkup(True) supc_sym__system_def_file = supcComponent.createFileSymbol('SUPC_SYS_DEF', None) supcSym_SystemDefFile.setType('STRING') supcSym_SystemDefFile.setOutputName('core.LIST_SYSTEM_DEFINITIONS_H_INCLUDES') supcSym_SystemDefFile.setSourcePath('../peripheral/supc_u2407/templates/system/definitions.h.ftl') supcSym_SystemDefFile.setMarkup(True)
# encoding: utf-8 # module System.Linq.Dynamic calls itself Dynamic # from Wms.RemotingImplementation,Version=1.23.1.0,Culture=neutral,PublicKeyToken=null # by generator 1.145 # no doc # no important # no functions # classes class DynamicClass(object): # no doc def ZZZ(self): """hardcoded/mock instance of the class""" return DynamicClass() instance=ZZZ() """hardcoded/returns an instance of the class""" def ToString(self): """ ToString(self: DynamicClass) -> str """ pass class DynamicExpression(object): # no doc def ZZZ(self): """hardcoded/mock instance of the class""" return DynamicExpression() instance=ZZZ() """hardcoded/returns an instance of the class""" @staticmethod def CreateClass(properties): """ CreateClass(*properties: Array[DynamicProperty]) -> Type CreateClass(properties: IEnumerable[DynamicProperty]) -> Type """ pass @staticmethod def Parse(resultType,expression,values): """ Parse(resultType: Type,expression: str,*values: Array[object]) -> Expression """ pass @staticmethod def ParseLambda(*__args): """ ParseLambda(itType: Type,resultType: Type,expression: str,*values: Array[object]) -> LambdaExpression ParseLambda(parameters: Array[ParameterExpression],resultType: Type,expression: str,*values: Array[object]) -> LambdaExpression ParseLambda[(T,S)](expression: str,*values: Array[object]) -> Expression[Func[T,S]] """ pass __all__=[ 'CreateClass', 'Parse', 'ParseLambda', ] class DynamicProperty(object): """ DynamicProperty(name: str,type: Type) """ def ZZZ(self): """hardcoded/mock instance of the class""" return DynamicProperty() instance=ZZZ() """hardcoded/returns an instance of the class""" @staticmethod def __new__(self,name,type): """ __new__(cls: type,name: str,type: Type) """ pass Name=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: Name(self: DynamicProperty) -> str """ Type=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: Type(self: DynamicProperty) -> Type """ class DynamicQueryable(object): # no doc def ZZZ(self): """hardcoded/mock instance of the class""" return DynamicQueryable() instance=ZZZ() """hardcoded/returns an instance of the class""" @staticmethod def Any(source): """ Any(source: IQueryable) -> bool """ pass @staticmethod def Count(source): """ Count(source: IQueryable) -> int """ pass @staticmethod def GroupBy(source,keySelector,elementSelector,values): """ GroupBy(source: IQueryable,keySelector: str,elementSelector: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def OrderBy(source,ordering,values): """ OrderBy[T](source: IQueryable[T],ordering: str,*values: Array[object]) -> IQueryable[T] OrderBy(source: IQueryable,ordering: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def Select(source,selector,values): """ Select(source: IQueryable,selector: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def Skip(source,count): """ Skip(source: IQueryable,count: int) -> IQueryable """ pass @staticmethod def Take(source,count): """ Take(source: IQueryable,count: int) -> IQueryable """ pass @staticmethod def Where(source,predicate,values): """ Where[T](source: IQueryable[T],predicate: str,*values: Array[object]) -> IQueryable[T] Where(source: IQueryable,predicate: str,*values: Array[object]) -> IQueryable """ pass __all__=[ 'Any', 'Count', 'GroupBy', 'OrderBy', 'Select', 'Skip', 'Take', 'Where', ] class ParseException(Exception): """ ParseException(message: str,position: int) """ def ZZZ(self): """hardcoded/mock instance of the class""" return ParseException() instance=ZZZ() """hardcoded/returns an instance of the class""" def ToString(self): """ ToString(self: ParseException) -> str """ pass def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self,message,position): """ __new__(cls: type,message: str,position: int) """ pass def __str__(self,*args): pass Position=property(lambda self: object(),lambda self,v: None,lambda self: None) """Get: Position(self: ParseException) -> int """ SerializeObjectState=None
class Dynamicclass(object): def zzz(self): """hardcoded/mock instance of the class""" return dynamic_class() instance = zzz() 'hardcoded/returns an instance of the class' def to_string(self): """ ToString(self: DynamicClass) -> str """ pass class Dynamicexpression(object): def zzz(self): """hardcoded/mock instance of the class""" return dynamic_expression() instance = zzz() 'hardcoded/returns an instance of the class' @staticmethod def create_class(properties): """ CreateClass(*properties: Array[DynamicProperty]) -> Type CreateClass(properties: IEnumerable[DynamicProperty]) -> Type """ pass @staticmethod def parse(resultType, expression, values): """ Parse(resultType: Type,expression: str,*values: Array[object]) -> Expression """ pass @staticmethod def parse_lambda(*__args): """ ParseLambda(itType: Type,resultType: Type,expression: str,*values: Array[object]) -> LambdaExpression ParseLambda(parameters: Array[ParameterExpression],resultType: Type,expression: str,*values: Array[object]) -> LambdaExpression ParseLambda[(T,S)](expression: str,*values: Array[object]) -> Expression[Func[T,S]] """ pass __all__ = ['CreateClass', 'Parse', 'ParseLambda'] class Dynamicproperty(object): """ DynamicProperty(name: str,type: Type) """ def zzz(self): """hardcoded/mock instance of the class""" return dynamic_property() instance = zzz() 'hardcoded/returns an instance of the class' @staticmethod def __new__(self, name, type): """ __new__(cls: type,name: str,type: Type) """ pass name = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: Name(self: DynamicProperty) -> str\n\n\n\n' type = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: Type(self: DynamicProperty) -> Type\n\n\n\n' class Dynamicqueryable(object): def zzz(self): """hardcoded/mock instance of the class""" return dynamic_queryable() instance = zzz() 'hardcoded/returns an instance of the class' @staticmethod def any(source): """ Any(source: IQueryable) -> bool """ pass @staticmethod def count(source): """ Count(source: IQueryable) -> int """ pass @staticmethod def group_by(source, keySelector, elementSelector, values): """ GroupBy(source: IQueryable,keySelector: str,elementSelector: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def order_by(source, ordering, values): """ OrderBy[T](source: IQueryable[T],ordering: str,*values: Array[object]) -> IQueryable[T] OrderBy(source: IQueryable,ordering: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def select(source, selector, values): """ Select(source: IQueryable,selector: str,*values: Array[object]) -> IQueryable """ pass @staticmethod def skip(source, count): """ Skip(source: IQueryable,count: int) -> IQueryable """ pass @staticmethod def take(source, count): """ Take(source: IQueryable,count: int) -> IQueryable """ pass @staticmethod def where(source, predicate, values): """ Where[T](source: IQueryable[T],predicate: str,*values: Array[object]) -> IQueryable[T] Where(source: IQueryable,predicate: str,*values: Array[object]) -> IQueryable """ pass __all__ = ['Any', 'Count', 'GroupBy', 'OrderBy', 'Select', 'Skip', 'Take', 'Where'] class Parseexception(Exception): """ ParseException(message: str,position: int) """ def zzz(self): """hardcoded/mock instance of the class""" return parse_exception() instance = zzz() 'hardcoded/returns an instance of the class' def to_string(self): """ ToString(self: ParseException) -> str """ pass def __init__(self, *args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self, message, position): """ __new__(cls: type,message: str,position: int) """ pass def __str__(self, *args): pass position = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Get: Position(self: ParseException) -> int\n\n\n\n' serialize_object_state = None
""" This problem was asked by Stripe. Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3. You can modify the input array in-place. """ # i really had no clue how to do it in linear time and constant space, here are some answers, though: # https://stackoverflow.com/questions/51346136/given-an-array-of-integers-find-the-first-missing-positive-integer-in-linear-ti # using the indices does the trick def lowest_integer(numbers): min_number = min(numbers) max_number = max(numbers) if (min_number > 1): return 1 else: lowest_integer = max_number + 1 """ kudos to pmcarpan from stackoverflow: Assuming the array can be modified, We divide the array into 2 parts such that the first part consists of only positive numbers. Say we have the starting index as 0 and the ending index as end(exclusive). We traverse the array from index 0 to end. We take the absolute value of the element at that index - say the value is x. If x > end we do nothing. If not, we make the sign of the element at index x-1 negative. (Clarification: We do not toggle the sign. If the value is positive, it becomes negative. If it is negative, it remains negative. In pseudo code, this would be something like if (arr[x-1] > 0) arr[x-1] = -arr[x-1] and not arr[x-1] = -arr[x-1].) Finally, we traverse the array once more from index 0 to end. In case we encounter a positive element at some index, we output index + 1. This is the answer. However, if we do not encounter any positive element, it means that integers 1 to end occur in the array. We output end + 1. It can also be the case that all the numbers are non-positive making end = 0. The output end + 1 = 1 remains correct. All the steps can be done in O(n) time and using O(1) space. Example: Initial Array: 1 -1 -5 -3 3 4 2 8 Step 1 partition: 1 8 2 4 3 | -3 -5 -1, end = 5 In step 2 we change the signs of the positive numbers to keep track of which integers have already occurred. For example, here array[2] = -2 < 0, it suggests that 2 + 1 = 3 has already occurred in the array. Basically, we change the value of the element having index i to negative if i+1 is in the array. Step 2 Array changes to: -1 -8 -2 -4 3 | -3 -5 -1 In step 3, if some value array[index] is positive, it means that we did not find any integer of value index + 1 in step 2. Step 3: Traversing from index 0 to end, we find array[4] = 3 > 0 The answer is 4 + 1 = 5 """
""" This problem was asked by Stripe. Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3. You can modify the input array in-place. """ def lowest_integer(numbers): min_number = min(numbers) max_number = max(numbers) if min_number > 1: return 1 else: lowest_integer = max_number + 1 '\nkudos to pmcarpan from stackoverflow:\n\nAssuming the array can be modified,\n\nWe divide the array into 2 parts such that the first part consists of only positive numbers. Say we have the starting index as 0 and the ending index as end(exclusive).\n\nWe traverse the array from index 0 to end. We take the absolute value of the element at that index - say the value is x.\n\nIf x > end we do nothing.\nIf not, we make the sign of the element at index x-1 negative. (Clarification: We do not toggle the sign. If the value is positive, it becomes negative. If it is negative, it remains negative. In pseudo code, this would be something like if (arr[x-1] > 0) arr[x-1] = -arr[x-1] and not arr[x-1] = -arr[x-1].)\nFinally, we traverse the array once more from index 0 to end. In case we encounter a positive element at some index, we output index + 1. This is the answer. However, if we do not encounter any positive element, it means that integers 1 to end occur in the array. We output end + 1.\n\nIt can also be the case that all the numbers are non-positive making end = 0. The output end + 1 = 1 remains correct.\n\nAll the steps can be done in O(n) time and using O(1) space.\n\nExample:\n\nInitial Array: 1 -1 -5 -3 3 4 2 8\nStep 1 partition: 1 8 2 4 3 | -3 -5 -1, end = 5\nIn step 2 we change the signs of the positive numbers to keep track of which integers have already occurred. For example, here array[2] = -2 < 0, it suggests that 2 + 1 = 3 has already occurred in the array. Basically, we change the value of the element having index i to negative if i+1 is in the array.\n\nStep 2 Array changes to: -1 -8 -2 -4 3 | -3 -5 -1\nIn step 3, if some value array[index] is positive, it means that we did not find any integer of value index + 1 in step 2.\n\nStep 3: Traversing from index 0 to end, we find array[4] = 3 > 0\n The answer is 4 + 1 = 5\n \n'
# -*- coding: utf-8 -*- """ Created on Tue Aug 28 15:57:01 2014 Reference URL: http://carina.fcaglp.unlp.edu.ar/ida/archivos/tabla_constantes.pdf @author: yang """ # ---- Universal constants # universal gravitational constant: N/m^2/kg^{-2} G = 6.67e-11 # ---- Earth # acceleration due to gravity at sea level: m/s^2 g = 9.81 # Radias of the Earth: m Re = 6.37e6 # rotation rate of the Earth: s^{-1} Omega = 7.292e-5 # ---- Air # Typical density of air at sea level: kg/m^3 rho_a = 1.25 # gas constant for dry air: J/K/kg Rd = 287 # specific heat of dry air at constant pressure: J/K/kg cp = 1004 # specific heat of dry air at constant volume: J/K/kg cv = 717 # ---- Water # density of liquid water at 0^0C: kg/m^3 rho_w = 1e3 # gas constant for water vapor Rv = 461 # latent heat of vaporization at 0^0C: J/kg Lv = 2.50e6 # molecular weight ratio of H2O to dry air epsilon = 0.622 # ---- Others T0 = 273.15
""" Created on Tue Aug 28 15:57:01 2014 Reference URL: http://carina.fcaglp.unlp.edu.ar/ida/archivos/tabla_constantes.pdf @author: yang """ g = 6.67e-11 g = 9.81 re = 6370000.0 omega = 7.292e-05 rho_a = 1.25 rd = 287 cp = 1004 cv = 717 rho_w = 1000.0 rv = 461 lv = 2500000.0 epsilon = 0.622 t0 = 273.15
# # PySNMP MIB module ATM-TC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ATM-TC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:04:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") ObjectIdentity, NotificationType, Integer32, ModuleIdentity, TimeTicks, Gauge32, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, iso, MibIdentifier, IpAddress, Counter32, Unsigned32, mib_2 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "NotificationType", "Integer32", "ModuleIdentity", "TimeTicks", "Gauge32", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "iso", "MibIdentifier", "IpAddress", "Counter32", "Unsigned32", "mib-2") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") atmTCMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 37, 3)) if mibBuilder.loadTexts: atmTCMIB.setLastUpdated('9810190200Z') if mibBuilder.loadTexts: atmTCMIB.setOrganization('IETF AToMMIB Working Group') class AtmAddr(TextualConvention, OctetString): status = 'current' displayHint = '1x' subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 40) class AtmConnCastType(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3)) namedValues = NamedValues(("p2p", 1), ("p2mpRoot", 2), ("p2mpLeaf", 3)) class AtmConnKind(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5)) namedValues = NamedValues(("pvc", 1), ("svcIncoming", 2), ("svcOutgoing", 3), ("spvcInitiator", 4), ("spvcTarget", 5)) class AtmIlmiNetworkPrefix(TextualConvention, OctetString): reference = 'ATM Forum, Integrated Local Management Interface (ILMI) Specification, Version 4.0, af-ilmi-0065.000, September 1996, Section 9 ATM Forum, ATM User-Network Interface Signalling Specification, Version 4.0 (UNI 4.0), af-sig-0061.000, June 1996, Section 3' status = 'current' subtypeSpec = OctetString.subtypeSpec + ConstraintsUnion(ValueSizeConstraint(8, 8), ValueSizeConstraint(13, 13), ) class AtmInterfaceType(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) namedValues = NamedValues(("other", 1), ("autoConfig", 2), ("ituDss2", 3), ("atmfUni3Dot0", 4), ("atmfUni3Dot1", 5), ("atmfUni4Dot0", 6), ("atmfIispUni3Dot0", 7), ("atmfIispUni3Dot1", 8), ("atmfIispUni4Dot0", 9), ("atmfPnni1Dot0", 10), ("atmfBici2Dot0", 11), ("atmfUniPvcOnly", 12), ("atmfNniPvcOnly", 13)) class AtmServiceCategory(TextualConvention, Integer32): reference = 'ATM Forum Traffic Management Specification, Version 4.0, af-tm-0056.000, June 1996.' status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6)) namedValues = NamedValues(("other", 1), ("cbr", 2), ("rtVbr", 3), ("nrtVbr", 4), ("abr", 5), ("ubr", 6)) class AtmSigDescrParamIndex(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) class AtmTrafficDescrParamIndex(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 2147483647) class AtmVcIdentifier(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 65535) class AtmVpIdentifier(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 4095) class AtmVorXAdminStatus(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("up", 1), ("down", 2)) class AtmVorXLastChange(TextualConvention, TimeTicks): status = 'current' class AtmVorXOperStatus(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3)) namedValues = NamedValues(("up", 1), ("down", 2), ("unknown", 3)) atmTrafficDescriptorTypes = MibIdentifier((1, 3, 6, 1, 2, 1, 37, 1, 1)) atmObjectIdentities = MibIdentifier((1, 3, 6, 1, 2, 1, 37, 3, 1)) atmNoTrafficDescriptor = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 1)) if mibBuilder.loadTexts: atmNoTrafficDescriptor.setStatus('deprecated') atmNoClpNoScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 2)) if mibBuilder.loadTexts: atmNoClpNoScr.setStatus('current') atmClpNoTaggingNoScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 3)) if mibBuilder.loadTexts: atmClpNoTaggingNoScr.setStatus('deprecated') atmClpTaggingNoScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 4)) if mibBuilder.loadTexts: atmClpTaggingNoScr.setStatus('deprecated') atmNoClpScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 5)) if mibBuilder.loadTexts: atmNoClpScr.setStatus('current') atmClpNoTaggingScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 6)) if mibBuilder.loadTexts: atmClpNoTaggingScr.setStatus('current') atmClpTaggingScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 7)) if mibBuilder.loadTexts: atmClpTaggingScr.setStatus('current') atmClpNoTaggingMcr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 8)) if mibBuilder.loadTexts: atmClpNoTaggingMcr.setStatus('current') atmClpTransparentNoScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 9)) if mibBuilder.loadTexts: atmClpTransparentNoScr.setStatus('current') atmClpTransparentScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 10)) if mibBuilder.loadTexts: atmClpTransparentScr.setStatus('current') atmNoClpTaggingNoScr = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 11)) if mibBuilder.loadTexts: atmNoClpTaggingNoScr.setStatus('current') atmNoClpNoScrCdvt = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 12)) if mibBuilder.loadTexts: atmNoClpNoScrCdvt.setStatus('current') atmNoClpScrCdvt = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 13)) if mibBuilder.loadTexts: atmNoClpScrCdvt.setStatus('current') atmClpNoTaggingScrCdvt = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 14)) if mibBuilder.loadTexts: atmClpNoTaggingScrCdvt.setStatus('current') atmClpTaggingScrCdvt = ObjectIdentity((1, 3, 6, 1, 2, 1, 37, 1, 1, 15)) if mibBuilder.loadTexts: atmClpTaggingScrCdvt.setStatus('current') mibBuilder.exportSymbols("ATM-TC-MIB", atmNoTrafficDescriptor=atmNoTrafficDescriptor, PYSNMP_MODULE_ID=atmTCMIB, AtmInterfaceType=AtmInterfaceType, AtmVcIdentifier=AtmVcIdentifier, atmClpTaggingScr=atmClpTaggingScr, AtmVpIdentifier=AtmVpIdentifier, atmObjectIdentities=atmObjectIdentities, atmNoClpNoScrCdvt=atmNoClpNoScrCdvt, AtmIlmiNetworkPrefix=AtmIlmiNetworkPrefix, atmClpNoTaggingMcr=atmClpNoTaggingMcr, AtmServiceCategory=AtmServiceCategory, atmNoClpScrCdvt=atmNoClpScrCdvt, AtmVorXAdminStatus=AtmVorXAdminStatus, AtmVorXLastChange=AtmVorXLastChange, AtmSigDescrParamIndex=AtmSigDescrParamIndex, AtmAddr=AtmAddr, atmNoClpScr=atmNoClpScr, atmTrafficDescriptorTypes=atmTrafficDescriptorTypes, AtmVorXOperStatus=AtmVorXOperStatus, atmClpTaggingScrCdvt=atmClpTaggingScrCdvt, AtmTrafficDescrParamIndex=AtmTrafficDescrParamIndex, AtmConnKind=AtmConnKind, atmClpTaggingNoScr=atmClpTaggingNoScr, AtmConnCastType=AtmConnCastType, atmClpNoTaggingScr=atmClpNoTaggingScr, atmNoClpTaggingNoScr=atmNoClpTaggingNoScr, atmClpNoTaggingScrCdvt=atmClpNoTaggingScrCdvt, atmNoClpNoScr=atmNoClpNoScr, atmClpNoTaggingNoScr=atmClpNoTaggingNoScr, atmTCMIB=atmTCMIB, atmClpTransparentScr=atmClpTransparentScr, atmClpTransparentNoScr=atmClpTransparentNoScr)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, constraints_union, single_value_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (object_identity, notification_type, integer32, module_identity, time_ticks, gauge32, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, iso, mib_identifier, ip_address, counter32, unsigned32, mib_2) = mibBuilder.importSymbols('SNMPv2-SMI', 'ObjectIdentity', 'NotificationType', 'Integer32', 'ModuleIdentity', 'TimeTicks', 'Gauge32', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'iso', 'MibIdentifier', 'IpAddress', 'Counter32', 'Unsigned32', 'mib-2') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') atm_tcmib = module_identity((1, 3, 6, 1, 2, 1, 37, 3)) if mibBuilder.loadTexts: atmTCMIB.setLastUpdated('9810190200Z') if mibBuilder.loadTexts: atmTCMIB.setOrganization('IETF AToMMIB Working Group') class Atmaddr(TextualConvention, OctetString): status = 'current' display_hint = '1x' subtype_spec = OctetString.subtypeSpec + value_size_constraint(0, 40) class Atmconncasttype(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3)) named_values = named_values(('p2p', 1), ('p2mpRoot', 2), ('p2mpLeaf', 3)) class Atmconnkind(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5)) named_values = named_values(('pvc', 1), ('svcIncoming', 2), ('svcOutgoing', 3), ('spvcInitiator', 4), ('spvcTarget', 5)) class Atmilminetworkprefix(TextualConvention, OctetString): reference = 'ATM Forum, Integrated Local Management Interface (ILMI) Specification, Version 4.0, af-ilmi-0065.000, September 1996, Section 9 ATM Forum, ATM User-Network Interface Signalling Specification, Version 4.0 (UNI 4.0), af-sig-0061.000, June 1996, Section 3' status = 'current' subtype_spec = OctetString.subtypeSpec + constraints_union(value_size_constraint(8, 8), value_size_constraint(13, 13)) class Atminterfacetype(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) named_values = named_values(('other', 1), ('autoConfig', 2), ('ituDss2', 3), ('atmfUni3Dot0', 4), ('atmfUni3Dot1', 5), ('atmfUni4Dot0', 6), ('atmfIispUni3Dot0', 7), ('atmfIispUni3Dot1', 8), ('atmfIispUni4Dot0', 9), ('atmfPnni1Dot0', 10), ('atmfBici2Dot0', 11), ('atmfUniPvcOnly', 12), ('atmfNniPvcOnly', 13)) class Atmservicecategory(TextualConvention, Integer32): reference = 'ATM Forum Traffic Management Specification, Version 4.0, af-tm-0056.000, June 1996.' status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6)) named_values = named_values(('other', 1), ('cbr', 2), ('rtVbr', 3), ('nrtVbr', 4), ('abr', 5), ('ubr', 6)) class Atmsigdescrparamindex(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 2147483647) class Atmtrafficdescrparamindex(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 2147483647) class Atmvcidentifier(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 65535) class Atmvpidentifier(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + value_range_constraint(0, 4095) class Atmvorxadminstatus(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2)) named_values = named_values(('up', 1), ('down', 2)) class Atmvorxlastchange(TextualConvention, TimeTicks): status = 'current' class Atmvorxoperstatus(TextualConvention, Integer32): status = 'current' subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3)) named_values = named_values(('up', 1), ('down', 2), ('unknown', 3)) atm_traffic_descriptor_types = mib_identifier((1, 3, 6, 1, 2, 1, 37, 1, 1)) atm_object_identities = mib_identifier((1, 3, 6, 1, 2, 1, 37, 3, 1)) atm_no_traffic_descriptor = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 1)) if mibBuilder.loadTexts: atmNoTrafficDescriptor.setStatus('deprecated') atm_no_clp_no_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 2)) if mibBuilder.loadTexts: atmNoClpNoScr.setStatus('current') atm_clp_no_tagging_no_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 3)) if mibBuilder.loadTexts: atmClpNoTaggingNoScr.setStatus('deprecated') atm_clp_tagging_no_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 4)) if mibBuilder.loadTexts: atmClpTaggingNoScr.setStatus('deprecated') atm_no_clp_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 5)) if mibBuilder.loadTexts: atmNoClpScr.setStatus('current') atm_clp_no_tagging_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 6)) if mibBuilder.loadTexts: atmClpNoTaggingScr.setStatus('current') atm_clp_tagging_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 7)) if mibBuilder.loadTexts: atmClpTaggingScr.setStatus('current') atm_clp_no_tagging_mcr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 8)) if mibBuilder.loadTexts: atmClpNoTaggingMcr.setStatus('current') atm_clp_transparent_no_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 9)) if mibBuilder.loadTexts: atmClpTransparentNoScr.setStatus('current') atm_clp_transparent_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 10)) if mibBuilder.loadTexts: atmClpTransparentScr.setStatus('current') atm_no_clp_tagging_no_scr = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 11)) if mibBuilder.loadTexts: atmNoClpTaggingNoScr.setStatus('current') atm_no_clp_no_scr_cdvt = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 12)) if mibBuilder.loadTexts: atmNoClpNoScrCdvt.setStatus('current') atm_no_clp_scr_cdvt = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 13)) if mibBuilder.loadTexts: atmNoClpScrCdvt.setStatus('current') atm_clp_no_tagging_scr_cdvt = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 14)) if mibBuilder.loadTexts: atmClpNoTaggingScrCdvt.setStatus('current') atm_clp_tagging_scr_cdvt = object_identity((1, 3, 6, 1, 2, 1, 37, 1, 1, 15)) if mibBuilder.loadTexts: atmClpTaggingScrCdvt.setStatus('current') mibBuilder.exportSymbols('ATM-TC-MIB', atmNoTrafficDescriptor=atmNoTrafficDescriptor, PYSNMP_MODULE_ID=atmTCMIB, AtmInterfaceType=AtmInterfaceType, AtmVcIdentifier=AtmVcIdentifier, atmClpTaggingScr=atmClpTaggingScr, AtmVpIdentifier=AtmVpIdentifier, atmObjectIdentities=atmObjectIdentities, atmNoClpNoScrCdvt=atmNoClpNoScrCdvt, AtmIlmiNetworkPrefix=AtmIlmiNetworkPrefix, atmClpNoTaggingMcr=atmClpNoTaggingMcr, AtmServiceCategory=AtmServiceCategory, atmNoClpScrCdvt=atmNoClpScrCdvt, AtmVorXAdminStatus=AtmVorXAdminStatus, AtmVorXLastChange=AtmVorXLastChange, AtmSigDescrParamIndex=AtmSigDescrParamIndex, AtmAddr=AtmAddr, atmNoClpScr=atmNoClpScr, atmTrafficDescriptorTypes=atmTrafficDescriptorTypes, AtmVorXOperStatus=AtmVorXOperStatus, atmClpTaggingScrCdvt=atmClpTaggingScrCdvt, AtmTrafficDescrParamIndex=AtmTrafficDescrParamIndex, AtmConnKind=AtmConnKind, atmClpTaggingNoScr=atmClpTaggingNoScr, AtmConnCastType=AtmConnCastType, atmClpNoTaggingScr=atmClpNoTaggingScr, atmNoClpTaggingNoScr=atmNoClpTaggingNoScr, atmClpNoTaggingScrCdvt=atmClpNoTaggingScrCdvt, atmNoClpNoScr=atmNoClpNoScr, atmClpNoTaggingNoScr=atmClpNoTaggingNoScr, atmTCMIB=atmTCMIB, atmClpTransparentScr=atmClpTransparentScr, atmClpTransparentNoScr=atmClpTransparentNoScr)
class Member(object): """ A member of the etcd cluster. :ivar id: ID of the member :ivar name: human-readable name of the member :ivar peer_urls: list of URLs the member exposes to the cluster for communication :ivar client_urls: list of URLs the member exposes to clients for communication """ def __init__(self, id, name, peer_urls, client_urls, etcd_client=None): self.id = id self.name = name self.peer_urls = peer_urls self.client_urls = client_urls self._etcd_client = etcd_client def __str__(self): return ('Member {id}: peer urls: {peer_urls}, client ' 'urls: {client_urls}'.format(id=self.id, peer_urls=self.peer_urls, client_urls=self.client_urls)) def remove(self): """Remove this member from the cluster.""" self._etcd_client.remove_member(self.id) def update(self, peer_urls): """ Update the configuration of this member. :param peer_urls: new list of peer urls the member will use to communicate with the cluster """ self._etcd_client.update_member(self.id, peer_urls) @property def active_alarms(self): """Get active alarms of the member. :returns: Alarms """ return self._etcd_client.list_alarms(member_id=self.id)
class Member(object): """ A member of the etcd cluster. :ivar id: ID of the member :ivar name: human-readable name of the member :ivar peer_urls: list of URLs the member exposes to the cluster for communication :ivar client_urls: list of URLs the member exposes to clients for communication """ def __init__(self, id, name, peer_urls, client_urls, etcd_client=None): self.id = id self.name = name self.peer_urls = peer_urls self.client_urls = client_urls self._etcd_client = etcd_client def __str__(self): return 'Member {id}: peer urls: {peer_urls}, client urls: {client_urls}'.format(id=self.id, peer_urls=self.peer_urls, client_urls=self.client_urls) def remove(self): """Remove this member from the cluster.""" self._etcd_client.remove_member(self.id) def update(self, peer_urls): """ Update the configuration of this member. :param peer_urls: new list of peer urls the member will use to communicate with the cluster """ self._etcd_client.update_member(self.id, peer_urls) @property def active_alarms(self): """Get active alarms of the member. :returns: Alarms """ return self._etcd_client.list_alarms(member_id=self.id)