content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
---|---|
S = str(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
print("Bad")
else:
print("Good") | s = str(input())
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
print('Bad')
else:
print('Good') |
def main():
squareSum = 0 #(1 + 2)^2 square of the sums
sumSquare = 0 #1^2 + 2^2 sum of the squares
for i in range(1, 101):
sumSquare += i ** 2
squareSum += i
squareSum = squareSum ** 2
print(str(squareSum - sumSquare))
if __name__ == '__main__':
main()
| def main():
square_sum = 0
sum_square = 0
for i in range(1, 101):
sum_square += i ** 2
square_sum += i
square_sum = squareSum ** 2
print(str(squareSum - sumSquare))
if __name__ == '__main__':
main() |
def find_space(board):
for i in range(0,9):
for j in range(0,9):
if board[i][j]==0:
return (i,j)
return None
def check(board,num,r,c):
for i in range(0,9):
if board[r][i]==num and c!=i:
return False
for i in range(0,9):
if board[i][c]==num and r!=i:
return False
x=r//3
y=c//3
for i in range(x*3,x*3+3):
for j in range(y*3,y*3+3):
if board[i][j]==num and r!=i and c!=j:
return False
return True
def enter_datas(board):
for i in range(1,10):
print("Enter the Datas in Row ",i)
x=[int(i) for i in input().split()]
board.append(x)
def show(board):
for i in range(0,9):
for j in range(0,9):
if j==2 or j==5:
print(board[i][j]," | ",end="")
else:
print(board[i][j],end=" ")
if i==2 or i==5:
print("\n-----------------------\n")
else:
print("\n")
def solve(board):
x=find_space(board)
if not x:
return True
else:
r,c=x
for i in range(1,10):
if check(board,i,r,c):
board[r][c]=i
if solve(board):
return True
board[r][c]=0
return False
board=[]
enter_datas(board)
show(board)
solve(board)
print("\n\n")
show(board)
'''
Enter the Datas in a Row
7 8 0 4 0 0 1 2 0
Enter the Datas in a Row
6 0 0 0 7 5 0 0 9
Enter the Datas in a Row
0 0 0 6 0 1 0 7 8
Enter the Datas in a Row
0 0 7 0 4 0 2 6 0
Enter the Datas in a Row
0 0 1 0 5 0 9 3 0
Enter the Datas in a Row
9 0 4 0 6 0 0 0 5
Enter the Datas in a Row
0 7 0 3 0 0 0 1 2
Enter the Datas in a Row
1 2 0 0 0 7 4 0 0
Enter the Datas in a Row
0 4 9 2 0 6 0 0 7
''' | def find_space(board):
for i in range(0, 9):
for j in range(0, 9):
if board[i][j] == 0:
return (i, j)
return None
def check(board, num, r, c):
for i in range(0, 9):
if board[r][i] == num and c != i:
return False
for i in range(0, 9):
if board[i][c] == num and r != i:
return False
x = r // 3
y = c // 3
for i in range(x * 3, x * 3 + 3):
for j in range(y * 3, y * 3 + 3):
if board[i][j] == num and r != i and (c != j):
return False
return True
def enter_datas(board):
for i in range(1, 10):
print('Enter the Datas in Row ', i)
x = [int(i) for i in input().split()]
board.append(x)
def show(board):
for i in range(0, 9):
for j in range(0, 9):
if j == 2 or j == 5:
print(board[i][j], ' | ', end='')
else:
print(board[i][j], end=' ')
if i == 2 or i == 5:
print('\n-----------------------\n')
else:
print('\n')
def solve(board):
x = find_space(board)
if not x:
return True
else:
(r, c) = x
for i in range(1, 10):
if check(board, i, r, c):
board[r][c] = i
if solve(board):
return True
board[r][c] = 0
return False
board = []
enter_datas(board)
show(board)
solve(board)
print('\n\n')
show(board)
'\nEnter the Datas in a Row\n7 8 0 4 0 0 1 2 0\nEnter the Datas in a Row\n6 0 0 0 7 5 0 0 9\nEnter the Datas in a Row\n0 0 0 6 0 1 0 7 8\nEnter the Datas in a Row\n0 0 7 0 4 0 2 6 0\nEnter the Datas in a Row\n0 0 1 0 5 0 9 3 0\nEnter the Datas in a Row\n9 0 4 0 6 0 0 0 5\nEnter the Datas in a Row\n0 7 0 3 0 0 0 1 2\nEnter the Datas in a Row\n1 2 0 0 0 7 4 0 0\nEnter the Datas in a Row\n0 4 9 2 0 6 0 0 7\n' |
# A simple list
myList = [10,20,4,5,6,2,9,10,2,3,34,14]
#print the whole list
print("The List is {}".format(myList))
# printing elemts of the list one by one
print("printing elemts of the list one by one")
for elements in myList:
print(elements)
print("")
#printing elements that are greater than 10 only
print("printing elements that are greater than 10 only")
for elements in myList:
if(elements>10):
print(elements)
#printing elements that are greater that 10 but by using a list and appending the elements on it
newList = []
for elements in myList:
if(elements <10):
newList.append(elements)
print("")
print("Print the new List \n{}".format(newList))
#print the above list part using a single line
print(" The list is {}".format([item for item in myList if item < 10]))
# here [item { This is the out put} for item { the is the for part} in myList {This Is the input list} if item <10 {This is the condition}]
#Ask the user for an input and print the elemets of list less than that number
print("Input a number : ")
num = int(input())
print(" The elemnts of the list less that {} are {}".format(num,[item for item in myList if item < num]))
| my_list = [10, 20, 4, 5, 6, 2, 9, 10, 2, 3, 34, 14]
print('The List is {}'.format(myList))
print('printing elemts of the list one by one')
for elements in myList:
print(elements)
print('')
print('printing elements that are greater than 10 only')
for elements in myList:
if elements > 10:
print(elements)
new_list = []
for elements in myList:
if elements < 10:
newList.append(elements)
print('')
print('Print the new List \n{}'.format(newList))
print(' The list is {}'.format([item for item in myList if item < 10]))
print('Input a number : ')
num = int(input())
print(' The elemnts of the list less that {} are {}'.format(num, [item for item in myList if item < num])) |
#!/usr/bin/env python
# encoding: utf-8
'''
@author: yuxiqian
@license: MIT
@contact: [email protected]
@software: electsys-api
@file: electsysApi/shared/exception.py
@time: 2019/1/9
'''
class RequestError(BaseException):
pass
class ParseError(BaseException):
pass
class ParseWarning(Warning):
pass
| """
@author: yuxiqian
@license: MIT
@contact: [email protected]
@software: electsys-api
@file: electsysApi/shared/exception.py
@time: 2019/1/9
"""
class Requesterror(BaseException):
pass
class Parseerror(BaseException):
pass
class Parsewarning(Warning):
pass |
def extractKaedesan721TumblrCom(item):
'''
Parser for 'kaedesan721.tumblr.com'
'''
bad_tags = [
'FanArt',
"htr asks",
'Spanish translations',
'htr anime','my thoughts',
'Cats',
'answered',
'ask meme',
'relay convos',
'translation related post',
'nightmare fuel',
'htr manga',
'memes',
'htrweek',
'Video Games',
'Animation',
'replies',
'jazz',
'Music',
]
if any([bad in item['tags'] for bad in bad_tags]):
return None
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
if "my translations" in item['tags']:
tagmap = [
('Hakata Tonkotsu Ramens', 'Hakata Tonkotsu Ramens', 'translated'),
('hakata tonktosu ramens', 'Hakata Tonkotsu Ramens', 'translated'),
('PRC', 'PRC', 'translated'),
('Loiterous', 'Loiterous', 'oel'),
]
for tagname, name, tl_type in tagmap:
if tagname in item['tags']:
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False | def extract_kaedesan721_tumblr_com(item):
"""
Parser for 'kaedesan721.tumblr.com'
"""
bad_tags = ['FanArt', 'htr asks', 'Spanish translations', 'htr anime', 'my thoughts', 'Cats', 'answered', 'ask meme', 'relay convos', 'translation related post', 'nightmare fuel', 'htr manga', 'memes', 'htrweek', 'Video Games', 'Animation', 'replies', 'jazz', 'Music']
if any([bad in item['tags'] for bad in bad_tags]):
return None
(vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title'])
if not (chp or vol) or 'preview' in item['title'].lower():
return None
if 'my translations' in item['tags']:
tagmap = [('Hakata Tonkotsu Ramens', 'Hakata Tonkotsu Ramens', 'translated'), ('hakata tonktosu ramens', 'Hakata Tonkotsu Ramens', 'translated'), ('PRC', 'PRC', 'translated'), ('Loiterous', 'Loiterous', 'oel')]
for (tagname, name, tl_type) in tagmap:
if tagname in item['tags']:
return build_release_message_with_type(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False |
#!/usr/bin/python3
# --- 001 > U5W2P1_Task3_w1
def solution(i):
return float(i)
if __name__ == "__main__":
print('----------start------------')
i = 12
print(solution( i ))
print('------------end------------')
| def solution(i):
return float(i)
if __name__ == '__main__':
print('----------start------------')
i = 12
print(solution(i))
print('------------end------------') |
n = int(input())
intz = [int(x) for x in input().split()]
alice = 0
bob = 0
for i, num in zip(range(n), sorted(intz)[::-1]):
if i%2 == 0:
alice += num
else:
bob += num
print(alice, bob) | n = int(input())
intz = [int(x) for x in input().split()]
alice = 0
bob = 0
for (i, num) in zip(range(n), sorted(intz)[::-1]):
if i % 2 == 0:
alice += num
else:
bob += num
print(alice, bob) |
class Test:
def __init__(self):
pass
def hi(self):
print("hello world") | class Test:
def __init__(self):
pass
def hi(self):
print('hello world') |
def rec_sum(n):
if(n<=1):
return n
else:
return(n+rec_sum(n-1))
| def rec_sum(n):
if n <= 1:
return n
else:
return n + rec_sum(n - 1) |
#
# PySNMP MIB module HPN-ICF-VOICE-IF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-VOICE-IF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:41:57 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ValueSizeConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint")
hpnicfVoice, = mibBuilder.importSymbols("HPN-ICF-OID-MIB", "hpnicfVoice")
ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
TimeTicks, Unsigned32, Gauge32, NotificationType, MibIdentifier, ModuleIdentity, Counter32, IpAddress, iso, Counter64, ObjectIdentity, Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "Unsigned32", "Gauge32", "NotificationType", "MibIdentifier", "ModuleIdentity", "Counter32", "IpAddress", "iso", "Counter64", "ObjectIdentity", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
hpnicfVoiceInterface = ModuleIdentity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13))
hpnicfVoiceInterface.setRevisions(('2007-12-10 17:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: hpnicfVoiceInterface.setRevisionsDescriptions(('The initial version of this MIB file.',))
if mibBuilder.loadTexts: hpnicfVoiceInterface.setLastUpdated('200712101700Z')
if mibBuilder.loadTexts: hpnicfVoiceInterface.setOrganization('')
if mibBuilder.loadTexts: hpnicfVoiceInterface.setContactInfo('')
if mibBuilder.loadTexts: hpnicfVoiceInterface.setDescription('This MIB file is to provide the definition of the voice interface general configuration.')
hpnicfVoiceIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1))
hpnicfVoiceIfConfigTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1), )
if mibBuilder.loadTexts: hpnicfVoiceIfConfigTable.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfConfigTable.setDescription('The table contains configurable parameters for both analog voice interface and digital voice interface.')
hpnicfVoiceIfConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: hpnicfVoiceIfConfigEntry.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfConfigEntry.setDescription('The entry of voice interface table.')
hpnicfVoiceIfCfgCngOn = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgCngOn.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgCngOn.setDescription('This object indicates whether the silence gaps should be filled with background noise. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicfVoiceIfCfgNonLinearSwitch = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgNonLinearSwitch.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgNonLinearSwitch.setDescription('This object expresses the nonlinear processing is enable or disable for the voice interface. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line. Currently, only digital voice subscriber lines can be set disabled.')
hpnicfVoiceIfCfgInputGain = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-140, 139))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgInputGain.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgInputGain.setDescription('This object indicates the amount of gain added to the receiver side of the voice interface. Unit is 0.1 db. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicfVoiceIfCfgOutputGain = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-140, 139))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgOutputGain.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgOutputGain.setDescription('This object indicates the amount of gain added to the send side of the voice interface. Unit is 0.1 db. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicfVoiceIfCfgEchoCancelSwitch = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgEchoCancelSwitch.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgEchoCancelSwitch.setDescription('This object indicates whether the echo cancellation is enabled. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicfVoiceIfCfgEchoCancelDelay = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 64))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgEchoCancelDelay.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgEchoCancelDelay.setDescription("This object indicates the delay of the echo cancellation for the voice interface. This value couldn't be modified unless hpnicfVoiceIfCfgEchoCancelSwitch is enable. Unit is milliseconds. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line. The default value of this object is 32.")
hpnicfVoiceIfCfgTimerDialInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 300))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgTimerDialInterval.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgTimerDialInterval.setDescription('The interval, in seconds, between two dialing numbers. The default value of this object is 10 seconds. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 with loop-start or ground-start protocol voice subscriber line.')
hpnicfVoiceIfCfgTimerFirstDial = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 300))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgTimerFirstDial.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgTimerFirstDial.setDescription('The period of time, in seconds, before dialing the first number. The default value of this object is 10 seconds. It is applicable to FXO, FXS subscriber lines and E1/T1 with loop-start or ground-start protocol voice subscriber line.')
hpnicfVoiceIfCfgPrivateline = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 9), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgPrivateline.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgPrivateline.setDescription('This object indicates the E.164 phone number for plar mode. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicfVoiceIfCfgRegTone = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 10), OctetString().subtype(subtypeSpec=ConstraintsUnion(ValueSizeConstraint(0, 0), ValueSizeConstraint(2, 3), ))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfVoiceIfCfgRegTone.setStatus('current')
if mibBuilder.loadTexts: hpnicfVoiceIfCfgRegTone.setDescription('This object uses 2 or 3 letter country code specify voice parameters of different countrys. This value will take effect on all voice interfaces of all cards on the device.')
mibBuilder.exportSymbols("HPN-ICF-VOICE-IF-MIB", hpnicfVoiceInterface=hpnicfVoiceInterface, hpnicfVoiceIfCfgEchoCancelDelay=hpnicfVoiceIfCfgEchoCancelDelay, hpnicfVoiceIfConfigEntry=hpnicfVoiceIfConfigEntry, PYSNMP_MODULE_ID=hpnicfVoiceInterface, hpnicfVoiceIfObjects=hpnicfVoiceIfObjects, hpnicfVoiceIfCfgNonLinearSwitch=hpnicfVoiceIfCfgNonLinearSwitch, hpnicfVoiceIfCfgTimerFirstDial=hpnicfVoiceIfCfgTimerFirstDial, hpnicfVoiceIfCfgPrivateline=hpnicfVoiceIfCfgPrivateline, hpnicfVoiceIfCfgInputGain=hpnicfVoiceIfCfgInputGain, hpnicfVoiceIfCfgRegTone=hpnicfVoiceIfCfgRegTone, hpnicfVoiceIfCfgTimerDialInterval=hpnicfVoiceIfCfgTimerDialInterval, hpnicfVoiceIfCfgCngOn=hpnicfVoiceIfCfgCngOn, hpnicfVoiceIfCfgEchoCancelSwitch=hpnicfVoiceIfCfgEchoCancelSwitch, hpnicfVoiceIfCfgOutputGain=hpnicfVoiceIfCfgOutputGain, hpnicfVoiceIfConfigTable=hpnicfVoiceIfConfigTable)
| (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint')
(hpnicf_voice,) = mibBuilder.importSymbols('HPN-ICF-OID-MIB', 'hpnicfVoice')
(if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(time_ticks, unsigned32, gauge32, notification_type, mib_identifier, module_identity, counter32, ip_address, iso, counter64, object_identity, integer32, mib_scalar, mib_table, mib_table_row, mib_table_column, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'TimeTicks', 'Unsigned32', 'Gauge32', 'NotificationType', 'MibIdentifier', 'ModuleIdentity', 'Counter32', 'IpAddress', 'iso', 'Counter64', 'ObjectIdentity', 'Integer32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Bits')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
hpnicf_voice_interface = module_identity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13))
hpnicfVoiceInterface.setRevisions(('2007-12-10 17:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
hpnicfVoiceInterface.setRevisionsDescriptions(('The initial version of this MIB file.',))
if mibBuilder.loadTexts:
hpnicfVoiceInterface.setLastUpdated('200712101700Z')
if mibBuilder.loadTexts:
hpnicfVoiceInterface.setOrganization('')
if mibBuilder.loadTexts:
hpnicfVoiceInterface.setContactInfo('')
if mibBuilder.loadTexts:
hpnicfVoiceInterface.setDescription('This MIB file is to provide the definition of the voice interface general configuration.')
hpnicf_voice_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1))
hpnicf_voice_if_config_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1))
if mibBuilder.loadTexts:
hpnicfVoiceIfConfigTable.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfConfigTable.setDescription('The table contains configurable parameters for both analog voice interface and digital voice interface.')
hpnicf_voice_if_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'))
if mibBuilder.loadTexts:
hpnicfVoiceIfConfigEntry.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfConfigEntry.setDescription('The entry of voice interface table.')
hpnicf_voice_if_cfg_cng_on = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('enable')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgCngOn.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgCngOn.setDescription('This object indicates whether the silence gaps should be filled with background noise. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicf_voice_if_cfg_non_linear_switch = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('enable')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgNonLinearSwitch.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgNonLinearSwitch.setDescription('This object expresses the nonlinear processing is enable or disable for the voice interface. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line. Currently, only digital voice subscriber lines can be set disabled.')
hpnicf_voice_if_cfg_input_gain = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(-140, 139))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgInputGain.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgInputGain.setDescription('This object indicates the amount of gain added to the receiver side of the voice interface. Unit is 0.1 db. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicf_voice_if_cfg_output_gain = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(-140, 139))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgOutputGain.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgOutputGain.setDescription('This object indicates the amount of gain added to the send side of the voice interface. Unit is 0.1 db. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicf_voice_if_cfg_echo_cancel_switch = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('enable')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgEchoCancelSwitch.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgEchoCancelSwitch.setDescription('This object indicates whether the echo cancellation is enabled. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicf_voice_if_cfg_echo_cancel_delay = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(0, 64))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgEchoCancelDelay.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgEchoCancelDelay.setDescription("This object indicates the delay of the echo cancellation for the voice interface. This value couldn't be modified unless hpnicfVoiceIfCfgEchoCancelSwitch is enable. Unit is milliseconds. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line. The default value of this object is 32.")
hpnicf_voice_if_cfg_timer_dial_interval = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(1, 300))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgTimerDialInterval.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgTimerDialInterval.setDescription('The interval, in seconds, between two dialing numbers. The default value of this object is 10 seconds. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 with loop-start or ground-start protocol voice subscriber line.')
hpnicf_voice_if_cfg_timer_first_dial = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(1, 300))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgTimerFirstDial.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgTimerFirstDial.setDescription('The period of time, in seconds, before dialing the first number. The default value of this object is 10 seconds. It is applicable to FXO, FXS subscriber lines and E1/T1 with loop-start or ground-start protocol voice subscriber line.')
hpnicf_voice_if_cfg_privateline = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 9), display_string().subtype(subtypeSpec=value_size_constraint(0, 31))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgPrivateline.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgPrivateline.setDescription('This object indicates the E.164 phone number for plar mode. It is applicable to FXO, FXS, E&M subscriber lines and E1/T1 voice subscriber line.')
hpnicf_voice_if_cfg_reg_tone = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 39, 13, 1, 1, 1, 10), octet_string().subtype(subtypeSpec=constraints_union(value_size_constraint(0, 0), value_size_constraint(2, 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgRegTone.setStatus('current')
if mibBuilder.loadTexts:
hpnicfVoiceIfCfgRegTone.setDescription('This object uses 2 or 3 letter country code specify voice parameters of different countrys. This value will take effect on all voice interfaces of all cards on the device.')
mibBuilder.exportSymbols('HPN-ICF-VOICE-IF-MIB', hpnicfVoiceInterface=hpnicfVoiceInterface, hpnicfVoiceIfCfgEchoCancelDelay=hpnicfVoiceIfCfgEchoCancelDelay, hpnicfVoiceIfConfigEntry=hpnicfVoiceIfConfigEntry, PYSNMP_MODULE_ID=hpnicfVoiceInterface, hpnicfVoiceIfObjects=hpnicfVoiceIfObjects, hpnicfVoiceIfCfgNonLinearSwitch=hpnicfVoiceIfCfgNonLinearSwitch, hpnicfVoiceIfCfgTimerFirstDial=hpnicfVoiceIfCfgTimerFirstDial, hpnicfVoiceIfCfgPrivateline=hpnicfVoiceIfCfgPrivateline, hpnicfVoiceIfCfgInputGain=hpnicfVoiceIfCfgInputGain, hpnicfVoiceIfCfgRegTone=hpnicfVoiceIfCfgRegTone, hpnicfVoiceIfCfgTimerDialInterval=hpnicfVoiceIfCfgTimerDialInterval, hpnicfVoiceIfCfgCngOn=hpnicfVoiceIfCfgCngOn, hpnicfVoiceIfCfgEchoCancelSwitch=hpnicfVoiceIfCfgEchoCancelSwitch, hpnicfVoiceIfCfgOutputGain=hpnicfVoiceIfCfgOutputGain, hpnicfVoiceIfConfigTable=hpnicfVoiceIfConfigTable) |
gScore = 0 #use this to index g(n)
fScore = 1 #use this to index f(n)
previous = 2 #use this to index previous node
inf = 10000 #use this for value of infinity
#we represent the graph usind adjacent list
#as dictionary of dictionaries
G = {
'biratnagar' : {'itahari' : 22, 'biratchowk' : 30, 'rangeli': 25},
'itahari' : {'biratnagar' : 22, 'dharan' : 20, 'biratchowk' : 11},
'dharan' : {'itahari' : 20},
'biratchowk' : {'biratnagar' : 30, 'itahari' : 11, 'kanepokhari' :10},
'rangeli' : {'biratnagar' : 25, 'kanepokhari' : 25, 'urlabari' : 40},
'kanepokhari' : {'rangeli' : 25, 'biratchowk' : 10, 'urlabari' : 12},
'urlabari' : {'rangeli' : 40, 'kanepokhari' : 12, 'damak' : 6},
'damak' : {'urlabari' : 6}
}
def h(city):
#returns straight line distance from a city to damak
h = {
'biratnagar' : 46,
'itahari' : 39,
'dharan' : 41,
'rangeli' : 28,
'biratchowk' : 29,
'kanepokhari' : 17,
'urlabari' : 6,
'damak' : 0
}
return h[city]
def getMinimum(unvisited):
#returns city with minimum f(n)
currDist = inf
leastFScoreCity = ''
for city in unvisited:
if unvisited[city][fScore] < currDist:
currDist = unvisited[city][fScore]
leastFScoreCity = city
return leastFScoreCity
def aStar(G, start, goal):
visited = {} #we declare visited list as empty dict
unvisited = {} #we declare unvisited list as empty dict
#we now add every city to the unvisited
for city in G.keys():
unvisited[city] = [inf, inf, ""]
hScore = h(start)
#for starting node, the g(n) is 0, so f(n) will be h(n)
unvisited[start] = [0, hScore, ""]
finished = False
while finished == False:
#if there are no nodes to evaluate in unvisited
if len(unvisited) == 0:
finished = True
else:
#find the node with lowest f(n) from open list
currentNode = getMinimum(unvisited)
if currentNode == goal:
finished = True
#copy data to visited list
visited[currentNode] = unvisited[currentNode]
else:
#we examine the neighbors of currentNode
for neighbor in G[currentNode]:
#we only check unvisited neighbors
if neighbor not in visited:
newGScore = unvisited[currentNode][gScore] + G[currentNode][neighbor]
if newGScore < unvisited[neighbor][gScore]:
unvisited[neighbor][gScore] = newGScore
unvisited[neighbor][fScore] = newGScore + h(neighbor)
unvisited[neighbor][previous] = currentNode
#we now add currentNode to the visited list
visited[currentNode] = unvisited[currentNode]
#we now remove the currentNode from unvisited
del unvisited[currentNode]
return visited
def findPath(visitSequence, goal):
answer = []
answer.append(goal)
currCity = goal
while visitSequence[currCity][previous] != '':
prevCity = visitSequence[currCity][previous]
answer.append(prevCity)
currCity = prevCity
return answer[::-1]
start = 'biratnagar'
goal = 'damak'
visitSequence = aStar(G, start, goal)
path = findPath(visitSequence, goal)
print(path)
| g_score = 0
f_score = 1
previous = 2
inf = 10000
g = {'biratnagar': {'itahari': 22, 'biratchowk': 30, 'rangeli': 25}, 'itahari': {'biratnagar': 22, 'dharan': 20, 'biratchowk': 11}, 'dharan': {'itahari': 20}, 'biratchowk': {'biratnagar': 30, 'itahari': 11, 'kanepokhari': 10}, 'rangeli': {'biratnagar': 25, 'kanepokhari': 25, 'urlabari': 40}, 'kanepokhari': {'rangeli': 25, 'biratchowk': 10, 'urlabari': 12}, 'urlabari': {'rangeli': 40, 'kanepokhari': 12, 'damak': 6}, 'damak': {'urlabari': 6}}
def h(city):
h = {'biratnagar': 46, 'itahari': 39, 'dharan': 41, 'rangeli': 28, 'biratchowk': 29, 'kanepokhari': 17, 'urlabari': 6, 'damak': 0}
return h[city]
def get_minimum(unvisited):
curr_dist = inf
least_f_score_city = ''
for city in unvisited:
if unvisited[city][fScore] < currDist:
curr_dist = unvisited[city][fScore]
least_f_score_city = city
return leastFScoreCity
def a_star(G, start, goal):
visited = {}
unvisited = {}
for city in G.keys():
unvisited[city] = [inf, inf, '']
h_score = h(start)
unvisited[start] = [0, hScore, '']
finished = False
while finished == False:
if len(unvisited) == 0:
finished = True
else:
current_node = get_minimum(unvisited)
if currentNode == goal:
finished = True
visited[currentNode] = unvisited[currentNode]
else:
for neighbor in G[currentNode]:
if neighbor not in visited:
new_g_score = unvisited[currentNode][gScore] + G[currentNode][neighbor]
if newGScore < unvisited[neighbor][gScore]:
unvisited[neighbor][gScore] = newGScore
unvisited[neighbor][fScore] = newGScore + h(neighbor)
unvisited[neighbor][previous] = currentNode
visited[currentNode] = unvisited[currentNode]
del unvisited[currentNode]
return visited
def find_path(visitSequence, goal):
answer = []
answer.append(goal)
curr_city = goal
while visitSequence[currCity][previous] != '':
prev_city = visitSequence[currCity][previous]
answer.append(prevCity)
curr_city = prevCity
return answer[::-1]
start = 'biratnagar'
goal = 'damak'
visit_sequence = a_star(G, start, goal)
path = find_path(visitSequence, goal)
print(path) |
t=int(input(""))
while (t>0):
n=int(input(""))
f=1
for i in range(1,n+1):
f=f*i
print(f)
t=t-1
| t = int(input(''))
while t > 0:
n = int(input(''))
f = 1
for i in range(1, n + 1):
f = f * i
print(f)
t = t - 1 |
#Area of a rectangle = width x length
#Perimeter of a rectangle = 2 x [length + width#
width_input = float (input("\nPlease enter width: "))
length_input = float (input("Please enter length: "))
areaofRectangle = width_input * length_input
perimeterofRectangle = 2 * (width_input * length_input)
print ("\nArea of Rectangle is: " , areaofRectangle, "CM")
print("\nPerimeter of Rectangle is: ", perimeterofRectangle, "CM")
| width_input = float(input('\nPlease enter width: '))
length_input = float(input('Please enter length: '))
areaof_rectangle = width_input * length_input
perimeterof_rectangle = 2 * (width_input * length_input)
print('\nArea of Rectangle is: ', areaofRectangle, 'CM')
print('\nPerimeter of Rectangle is: ', perimeterofRectangle, 'CM') |
class DNASuitEdge:
COMPONENT_CODE = 22
def __init__(self, startPoint, endPoint, zoneId):
self.startPoint = startPoint
self.endPoint = endPoint
self.zoneId = zoneId
def setStartPoint(self, startPoint):
self.startPoint = startPoint
def setEndPoint(self, endPoint):
self.endPoint = endPoint
def setZoneId(self, zoneId):
self.zoneId = zoneId
| class Dnasuitedge:
component_code = 22
def __init__(self, startPoint, endPoint, zoneId):
self.startPoint = startPoint
self.endPoint = endPoint
self.zoneId = zoneId
def set_start_point(self, startPoint):
self.startPoint = startPoint
def set_end_point(self, endPoint):
self.endPoint = endPoint
def set_zone_id(self, zoneId):
self.zoneId = zoneId |
# This just shifts 1 to i th BIT
def BIT(i: int) -> int:
return int(1 << i)
# This class is equvalent to a C++ enum
class EventType:
Null, \
WindowClose, WindowResize, WindowFocus, WindowMoved, \
AppTick, AppUpdate, AppRender, \
KeyPressed, KeyReleased, CharInput, \
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled \
= range(0, 15)
# This class is equvalent to a C++ enum
# It uses bitstream to represent flags, so
# a single Event can have multiple flags
class EventCategory:
Null = 0
Application = BIT(0)
Input = BIT(1)
Keyboard = BIT(2)
Mouse = BIT(3)
MouseButton = BIT(4)
class Event:
Handled = False
@property
def EventType(self) -> int:
pass
@property
def Name(self) -> str:
return type(self)
@property
def CategoryFlags(self) -> int:
pass
def ToString(self) -> str:
return self.GetName()
def IsInCategory(self, category: int) -> bool:
return bool(self.CategoryFlags & category)
def __repr__(self) -> str:
return self.ToString()
class EventDispatcher:
__slots__ = ("_Event",)
def __init__(self, event: Event) -> None:
self._Event = event
def Dispach(self, func, eventType: int) -> bool:
if (self._Event.EventType == eventType):
handeled = func(self._Event)
self._Event.Handled = handeled
return True
return False
| def bit(i: int) -> int:
return int(1 << i)
class Eventtype:
(null, window_close, window_resize, window_focus, window_moved, app_tick, app_update, app_render, key_pressed, key_released, char_input, mouse_button_pressed, mouse_button_released, mouse_moved, mouse_scrolled) = range(0, 15)
class Eventcategory:
null = 0
application = bit(0)
input = bit(1)
keyboard = bit(2)
mouse = bit(3)
mouse_button = bit(4)
class Event:
handled = False
@property
def event_type(self) -> int:
pass
@property
def name(self) -> str:
return type(self)
@property
def category_flags(self) -> int:
pass
def to_string(self) -> str:
return self.GetName()
def is_in_category(self, category: int) -> bool:
return bool(self.CategoryFlags & category)
def __repr__(self) -> str:
return self.ToString()
class Eventdispatcher:
__slots__ = ('_Event',)
def __init__(self, event: Event) -> None:
self._Event = event
def dispach(self, func, eventType: int) -> bool:
if self._Event.EventType == eventType:
handeled = func(self._Event)
self._Event.Handled = handeled
return True
return False |
class Users:
usernamep = 'your_user_email'
passwordp = 'your_password'
linkp = 'https://www.instagram.com/stories/cznburak/'
| class Users:
usernamep = 'your_user_email'
passwordp = 'your_password'
linkp = 'https://www.instagram.com/stories/cznburak/' |
INSTANCES = 405
ITERS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 50, 100]
N_ITERS = len(ITERS)
# === RESULTS GATHERING ====================================================== #
# results_m is a [INSTANCES][N_ITERS] matrix to store every test result
results_m = [[0 for x in range(N_ITERS)] for y in range(INSTANCES)]
for I in range(N_ITERS):
fin = open("tests/" + str(ITERS[I]))
out = fin.read()
fin.close()
counter = 0
for line in out.splitlines():
results_m[counter][I] = int(line)
counter += 1
# === CALCULATING AVERAGES =================================================== #
averages = [0.0 for x in range(N_ITERS)]
for I in range(INSTANCES):
for J in range(N_ITERS):
results_m[I][J] = results_m[I][J] - results_m[I][0]
if (results_m[I][N_ITERS-1] != 0):
results_m[I][J] = float(results_m[I][J] / results_m[I][N_ITERS-1])
averages[J] += results_m[I][J]
for J in range(N_ITERS):
averages[J] = averages[J]/INSTANCES
for J in range(N_ITERS-1, 1, -1):
averages[J] -= averages[J-1]
# === PRINTING RESULTS ======================================================= #
print("========================================")
print(" all tests:")
for J in range(1, N_ITERS):
if (ITERS[J] < 10):
print(" " + str(ITERS[J]) + ": " + str(100 * averages[J]) + '%')
elif (ITERS[J] < 100):
print(" " + str(ITERS[J]) + ": " + str(100 * averages[J]) + '%')
else:
print(" " + str(ITERS[J]) + ": " + str(100 * averages[J]) + '%')
print("========================================")
# ============================================================================ #
| instances = 405
iters = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 50, 100]
n_iters = len(ITERS)
results_m = [[0 for x in range(N_ITERS)] for y in range(INSTANCES)]
for i in range(N_ITERS):
fin = open('tests/' + str(ITERS[I]))
out = fin.read()
fin.close()
counter = 0
for line in out.splitlines():
results_m[counter][I] = int(line)
counter += 1
averages = [0.0 for x in range(N_ITERS)]
for i in range(INSTANCES):
for j in range(N_ITERS):
results_m[I][J] = results_m[I][J] - results_m[I][0]
if results_m[I][N_ITERS - 1] != 0:
results_m[I][J] = float(results_m[I][J] / results_m[I][N_ITERS - 1])
averages[J] += results_m[I][J]
for j in range(N_ITERS):
averages[J] = averages[J] / INSTANCES
for j in range(N_ITERS - 1, 1, -1):
averages[J] -= averages[J - 1]
print('========================================')
print(' all tests:')
for j in range(1, N_ITERS):
if ITERS[J] < 10:
print(' ' + str(ITERS[J]) + ': ' + str(100 * averages[J]) + '%')
elif ITERS[J] < 100:
print(' ' + str(ITERS[J]) + ': ' + str(100 * averages[J]) + '%')
else:
print(' ' + str(ITERS[J]) + ': ' + str(100 * averages[J]) + '%')
print('========================================') |
#
# PySNMP MIB module SW-VLAN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-VLAN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:12:44 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")
ValueRangeConstraint, ValueSizeConstraint, ConstraintsUnion, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ConstraintsIntersection", "SingleValueConstraint")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
enterprises, iso, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, Counter32, Integer32, Unsigned32, Gauge32, IpAddress, ObjectIdentity, MibIdentifier, Counter64, TimeTicks, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "enterprises", "iso", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "Counter32", "Integer32", "Unsigned32", "Gauge32", "IpAddress", "ObjectIdentity", "MibIdentifier", "Counter64", "TimeTicks", "NotificationType")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
class MacAddress(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(6, 6)
fixedLength = 6
class VlanIndex(Integer32):
subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(1, 4094)
class PortList(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(12, 12)
fixedLength = 12
marconi = MibIdentifier((1, 3, 6, 1, 4, 1, 326))
systems = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2))
external = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20))
dlink = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1))
dlinkcommon = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 1))
golf = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2))
golfproducts = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1))
es2000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3))
golfcommon = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2))
marconi_mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2)).setLabel("marconi-mgmt")
es2000Mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28))
swL2Mgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2))
swVlan = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8))
swVlanCtrl = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1))
swMacBaseVlan = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2))
swPortBaseVlan = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3))
swVlanCtrlMode = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("mac-base", 3), ("ieee8021q", 4), ("port-base", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swVlanCtrlMode.setStatus('mandatory')
if mibBuilder.loadTexts: swVlanCtrlMode.setDescription('This object controls which Vlan function will be enable (or disable) when the switch hub restart at the startup (power on) or warm start.')
swVlanInfoStatus = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("mac-base", 3), ("ieee8021q", 4), ("port-base", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swVlanInfoStatus.setStatus('mandatory')
if mibBuilder.loadTexts: swVlanInfoStatus.setDescription('This object indicates which Vlan function be enable (or disable) in mandatoryly stage. There are no effect when change swVlanCtrlMode vlaue in the system running.')
swVlanSnmpPortVlan = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 3), VlanIndex()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swVlanSnmpPortVlan.setStatus('mandatory')
if mibBuilder.loadTexts: swVlanSnmpPortVlan.setDescription('Indicates the Vlan which the SNMP port belongs to. The value range is 1 to 4094.')
swMacBaseVlanInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1))
swMacBaseVlanMaxNum = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanMaxNum.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanMaxNum.setDescription('The maximum number of Mac base Vlan allowed by the system.')
swMacBaseVlanAddrMaxNum = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanAddrMaxNum.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrMaxNum.setDescription('The maximum number of entries in Mac-based Vlan address table.')
swMacBaseVlanCtrlTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2), )
if mibBuilder.loadTexts: swMacBaseVlanCtrlTable.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanCtrlTable.setDescription('A table that contains information about MAC base Vlan entries for which the switch has forwarding and/or filtering information. This information is used by the transparent switching function in determining how to propagate a received frame.')
swMacBaseVlanCtrlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1), ).setIndexNames((0, "SW-VLAN-MIB", "swMacBaseVlanDesc"))
if mibBuilder.loadTexts: swMacBaseVlanCtrlEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanCtrlEntry.setDescription('A list of information about a specific MAC base Vlan configuration portlist for which the switch has some forwarding and/or filtering information.')
swMacBaseVlanDesc = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 12))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanDesc.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanDesc.setDescription('A textual description of the Mac Base Vlan for memorization. The string cannot set to empty string. There is a default value for this string.')
swMacBaseVlanMacMember = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanMacMember.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanMacMember.setDescription('This object indicates the total number of MAC addresses contained in the VLAN entry.')
swMacBaseVlanCtrlState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("disabled", 2), ("enabled", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swMacBaseVlanCtrlState.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanCtrlState.setDescription('This object indicates the MacBase Vlan state.')
swMacBaseVlanAddrTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3), )
if mibBuilder.loadTexts: swMacBaseVlanAddrTable.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrTable.setDescription('A table that contains information about unicast or multicast entries for which the switch has forwarding and/or filtering information. This information is used by the transparent switching function in determining how to propagate a received frame. Note that the priority of MacBaseVlanAddr table entries is lowest than Filtering Table and FDB Table, i.e. if there is a table hash collision between the entries of MacBaseVlanAddr Table and Filtering Table inside the switch H/W address table, then Filtering Table entry overwrite the colliding entry of MacBaseVlanAddr Table. This state is same of FDB table. See swFdbFilterTable and swFdbStaticTable description also.')
swMacBaseVlanAddrEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1), ).setIndexNames((0, "SW-VLAN-MIB", "swMacBaseVlanAddr"))
if mibBuilder.loadTexts: swMacBaseVlanAddrEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrEntry.setDescription('A list of information about a specific unicast or multicast MAC address for which the switch has some forwarding and/or filtering information.')
swMacBaseVlanAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 1), MacAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanAddr.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddr.setDescription('This object indictaes a unicast or multicast MAC address for which the bridge has forwarding and/or filtering information.')
swMacBaseVlanAddrVlanDesc = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 64))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swMacBaseVlanAddrVlanDesc.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrVlanDesc.setDescription('A textual description of the Mac Base Vlan for memorization.')
swMacBaseVlanAddrState = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("valid", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swMacBaseVlanAddrState.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrState.setDescription('This object indicates the MacBase Vlan Address entry state. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. invalid(2) - writing this value to the object, and then the corresponding entry will be removed from the table. valid(3) - this entry is reside in the table.')
swMacBaseVlanAddrStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("apply", 2), ("not-apply", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swMacBaseVlanAddrStatus.setStatus('mandatory')
if mibBuilder.loadTexts: swMacBaseVlanAddrStatus.setDescription('This object indicates the MacBase Vlan Address entry state. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. apply(2) - this entry is currently in use and reside in the table. not-apply(3) - this entry is reside in the table but currently not in use due to conflict with filter table.')
swPortBaseVlanTotalNum = MibScalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanTotalNum.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanTotalNum.setDescription('The total number of Port-Base Vlan which is in enabled state within this switch hub.')
swPortBaseVlanDefaultVlanTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2), )
if mibBuilder.loadTexts: swPortBaseVlanDefaultVlanTable.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultVlanTable.setDescription('A table that contains default Port-Based VLAN list entries for the switch. The entry (Vid = 1,i.e. swPortBaseVlanDefaultPvid = 1) is defalut Port-Based VLAN , maintained by system.')
swPortBaseVlanDefaultVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1), ).setIndexNames((0, "SW-VLAN-MIB", "swPortBaseVlanDefaultPvid"))
if mibBuilder.loadTexts: swPortBaseVlanDefaultVlanEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultVlanEntry.setDescription('A list of default Port-Based VLAN information in swPortBaseVlanDefaultVlanTable.')
swPortBaseVlanDefaultPvid = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanDefaultPvid.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultPvid.setDescription('This object indicates the default Port-Base Vlan ID. It occupies only 1 entry in VLAN table, with VID=1.')
swPortBaseVlanDefaultDesc = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 12))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanDefaultDesc.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultDesc.setDescription('A textual description of the Port-Base Vlan.')
swPortBaseVlanDefaultPortList = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 3), PortList()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanDefaultPortList.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultPortList.setDescription('This object indicates the port member set of the specified Vlan. Each Vlan has a octect string to indicate the port map. The most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port.')
swPortBaseVlanDefaultPortNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanDefaultPortNumber.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanDefaultPortNumber.setDescription('This object indicates the number of ports of the entry.')
swPortBaseVlanConfigTable = MibTable((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3), )
if mibBuilder.loadTexts: swPortBaseVlanConfigTable.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigTable.setDescription("A table that contains Port-Based VLAN list entries for the switch. The device can't support port overlapping in Port-Based VLAN.")
swPortBaseVlanConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1), ).setIndexNames((0, "SW-VLAN-MIB", "swPortBaseVlanConfigPvid"))
if mibBuilder.loadTexts: swPortBaseVlanConfigEntry.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigEntry.setDescription('A list of information about a specific Port-Based VLAN configuration in swPortBaseVlanConfigTable.')
swPortBaseVlanConfigPvid = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(2, 12))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanConfigPvid.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigPvid.setDescription('This object indicates the Port-Base Vlan ID. There are up to 11 entries for current product now. The object range varies from 2 to 12.')
swPortBaseVlanConfigDesc = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 12))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swPortBaseVlanConfigDesc.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigDesc.setDescription('A textual description of the Port-Base Vlan. It cannot be a null string. And each description must be unique in the table.')
swPortBaseVlanConfigPortList = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 3), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swPortBaseVlanConfigPortList.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigPortList.setDescription('This object indicates which ports are belong to the Vlan. Each Vlan has a octect string to indicate with port map. The most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port.')
swPortBaseVlanConfigPortNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swPortBaseVlanConfigPortNumber.setStatus('mandatory')
if mibBuilder.loadTexts: swPortBaseVlanConfigPortNumber.setDescription('This object indicates the number of ports of the entry.')
mibBuilder.exportSymbols("SW-VLAN-MIB", marconi=marconi, swPortBaseVlanDefaultVlanEntry=swPortBaseVlanDefaultVlanEntry, swVlan=swVlan, swPortBaseVlanConfigTable=swPortBaseVlanConfigTable, golf=golf, swVlanCtrl=swVlanCtrl, swMacBaseVlanAddrEntry=swMacBaseVlanAddrEntry, swPortBaseVlanDefaultDesc=swPortBaseVlanDefaultDesc, swMacBaseVlanAddr=swMacBaseVlanAddr, swMacBaseVlanMacMember=swMacBaseVlanMacMember, swPortBaseVlanConfigPortNumber=swPortBaseVlanConfigPortNumber, swPortBaseVlanDefaultVlanTable=swPortBaseVlanDefaultVlanTable, swPortBaseVlan=swPortBaseVlan, swMacBaseVlanAddrMaxNum=swMacBaseVlanAddrMaxNum, swL2Mgmt=swL2Mgmt, dlinkcommon=dlinkcommon, swPortBaseVlanConfigEntry=swPortBaseVlanConfigEntry, swPortBaseVlanConfigPortList=swPortBaseVlanConfigPortList, swVlanSnmpPortVlan=swVlanSnmpPortVlan, swMacBaseVlanCtrlState=swMacBaseVlanCtrlState, PortList=PortList, external=external, swMacBaseVlanAddrStatus=swMacBaseVlanAddrStatus, swPortBaseVlanTotalNum=swPortBaseVlanTotalNum, swMacBaseVlan=swMacBaseVlan, swVlanInfoStatus=swVlanInfoStatus, swMacBaseVlanDesc=swMacBaseVlanDesc, swPortBaseVlanDefaultPvid=swPortBaseVlanDefaultPvid, dlink=dlink, MacAddress=MacAddress, swVlanCtrlMode=swVlanCtrlMode, golfproducts=golfproducts, systems=systems, swMacBaseVlanCtrlTable=swMacBaseVlanCtrlTable, swMacBaseVlanAddrVlanDesc=swMacBaseVlanAddrVlanDesc, marconi_mgmt=marconi_mgmt, swMacBaseVlanMaxNum=swMacBaseVlanMaxNum, swMacBaseVlanCtrlEntry=swMacBaseVlanCtrlEntry, swPortBaseVlanDefaultPortList=swPortBaseVlanDefaultPortList, swMacBaseVlanAddrTable=swMacBaseVlanAddrTable, swPortBaseVlanConfigPvid=swPortBaseVlanConfigPvid, swPortBaseVlanConfigDesc=swPortBaseVlanConfigDesc, VlanIndex=VlanIndex, swPortBaseVlanDefaultPortNumber=swPortBaseVlanDefaultPortNumber, golfcommon=golfcommon, swMacBaseVlanAddrState=swMacBaseVlanAddrState, es2000Mgmt=es2000Mgmt, es2000=es2000, swMacBaseVlanInfo=swMacBaseVlanInfo)
| (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, constraints_union, constraints_intersection, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'SingleValueConstraint')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(enterprises, iso, module_identity, mib_scalar, mib_table, mib_table_row, mib_table_column, bits, counter32, integer32, unsigned32, gauge32, ip_address, object_identity, mib_identifier, counter64, time_ticks, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'enterprises', 'iso', 'ModuleIdentity', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Bits', 'Counter32', 'Integer32', 'Unsigned32', 'Gauge32', 'IpAddress', 'ObjectIdentity', 'MibIdentifier', 'Counter64', 'TimeTicks', 'NotificationType')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
class Macaddress(OctetString):
subtype_spec = OctetString.subtypeSpec + value_size_constraint(6, 6)
fixed_length = 6
class Vlanindex(Integer32):
subtype_spec = Integer32.subtypeSpec + value_range_constraint(1, 4094)
class Portlist(OctetString):
subtype_spec = OctetString.subtypeSpec + value_size_constraint(12, 12)
fixed_length = 12
marconi = mib_identifier((1, 3, 6, 1, 4, 1, 326))
systems = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2))
external = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20))
dlink = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1))
dlinkcommon = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 1))
golf = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2))
golfproducts = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1))
es2000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 1, 3))
golfcommon = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2))
marconi_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2)).setLabel('marconi-mgmt')
es2000_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28))
sw_l2_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2))
sw_vlan = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8))
sw_vlan_ctrl = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1))
sw_mac_base_vlan = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2))
sw_port_base_vlan = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3))
sw_vlan_ctrl_mode = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('mac-base', 3), ('ieee8021q', 4), ('port-base', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swVlanCtrlMode.setStatus('mandatory')
if mibBuilder.loadTexts:
swVlanCtrlMode.setDescription('This object controls which Vlan function will be enable (or disable) when the switch hub restart at the startup (power on) or warm start.')
sw_vlan_info_status = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('mac-base', 3), ('ieee8021q', 4), ('port-base', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swVlanInfoStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
swVlanInfoStatus.setDescription('This object indicates which Vlan function be enable (or disable) in mandatoryly stage. There are no effect when change swVlanCtrlMode vlaue in the system running.')
sw_vlan_snmp_port_vlan = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 1, 3), vlan_index()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swVlanSnmpPortVlan.setStatus('mandatory')
if mibBuilder.loadTexts:
swVlanSnmpPortVlan.setDescription('Indicates the Vlan which the SNMP port belongs to. The value range is 1 to 4094.')
sw_mac_base_vlan_info = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1))
sw_mac_base_vlan_max_num = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanMaxNum.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanMaxNum.setDescription('The maximum number of Mac base Vlan allowed by the system.')
sw_mac_base_vlan_addr_max_num = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanAddrMaxNum.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrMaxNum.setDescription('The maximum number of entries in Mac-based Vlan address table.')
sw_mac_base_vlan_ctrl_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2))
if mibBuilder.loadTexts:
swMacBaseVlanCtrlTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanCtrlTable.setDescription('A table that contains information about MAC base Vlan entries for which the switch has forwarding and/or filtering information. This information is used by the transparent switching function in determining how to propagate a received frame.')
sw_mac_base_vlan_ctrl_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1)).setIndexNames((0, 'SW-VLAN-MIB', 'swMacBaseVlanDesc'))
if mibBuilder.loadTexts:
swMacBaseVlanCtrlEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanCtrlEntry.setDescription('A list of information about a specific MAC base Vlan configuration portlist for which the switch has some forwarding and/or filtering information.')
sw_mac_base_vlan_desc = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 1), display_string().subtype(subtypeSpec=value_size_constraint(1, 12))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanDesc.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanDesc.setDescription('A textual description of the Mac Base Vlan for memorization. The string cannot set to empty string. There is a default value for this string.')
sw_mac_base_vlan_mac_member = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanMacMember.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanMacMember.setDescription('This object indicates the total number of MAC addresses contained in the VLAN entry.')
sw_mac_base_vlan_ctrl_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 2, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('disabled', 2), ('enabled', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swMacBaseVlanCtrlState.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanCtrlState.setDescription('This object indicates the MacBase Vlan state.')
sw_mac_base_vlan_addr_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3))
if mibBuilder.loadTexts:
swMacBaseVlanAddrTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrTable.setDescription('A table that contains information about unicast or multicast entries for which the switch has forwarding and/or filtering information. This information is used by the transparent switching function in determining how to propagate a received frame. Note that the priority of MacBaseVlanAddr table entries is lowest than Filtering Table and FDB Table, i.e. if there is a table hash collision between the entries of MacBaseVlanAddr Table and Filtering Table inside the switch H/W address table, then Filtering Table entry overwrite the colliding entry of MacBaseVlanAddr Table. This state is same of FDB table. See swFdbFilterTable and swFdbStaticTable description also.')
sw_mac_base_vlan_addr_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1)).setIndexNames((0, 'SW-VLAN-MIB', 'swMacBaseVlanAddr'))
if mibBuilder.loadTexts:
swMacBaseVlanAddrEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrEntry.setDescription('A list of information about a specific unicast or multicast MAC address for which the switch has some forwarding and/or filtering information.')
sw_mac_base_vlan_addr = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 1), mac_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanAddr.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddr.setDescription('This object indictaes a unicast or multicast MAC address for which the bridge has forwarding and/or filtering information.')
sw_mac_base_vlan_addr_vlan_desc = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(1, 64))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swMacBaseVlanAddrVlanDesc.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrVlanDesc.setDescription('A textual description of the Mac Base Vlan for memorization.')
sw_mac_base_vlan_addr_state = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('valid', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swMacBaseVlanAddrState.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrState.setDescription('This object indicates the MacBase Vlan Address entry state. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. invalid(2) - writing this value to the object, and then the corresponding entry will be removed from the table. valid(3) - this entry is reside in the table.')
sw_mac_base_vlan_addr_status = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 2, 3, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('apply', 2), ('not-apply', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swMacBaseVlanAddrStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
swMacBaseVlanAddrStatus.setDescription('This object indicates the MacBase Vlan Address entry state. other(1) - this entry is currently in use but the conditions under which it will remain so are different from each of the following values. apply(2) - this entry is currently in use and reside in the table. not-apply(3) - this entry is reside in the table but currently not in use due to conflict with filter table.')
sw_port_base_vlan_total_num = mib_scalar((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanTotalNum.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanTotalNum.setDescription('The total number of Port-Base Vlan which is in enabled state within this switch hub.')
sw_port_base_vlan_default_vlan_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2))
if mibBuilder.loadTexts:
swPortBaseVlanDefaultVlanTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultVlanTable.setDescription('A table that contains default Port-Based VLAN list entries for the switch. The entry (Vid = 1,i.e. swPortBaseVlanDefaultPvid = 1) is defalut Port-Based VLAN , maintained by system.')
sw_port_base_vlan_default_vlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1)).setIndexNames((0, 'SW-VLAN-MIB', 'swPortBaseVlanDefaultPvid'))
if mibBuilder.loadTexts:
swPortBaseVlanDefaultVlanEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultVlanEntry.setDescription('A list of default Port-Based VLAN information in swPortBaseVlanDefaultVlanTable.')
sw_port_base_vlan_default_pvid = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPvid.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPvid.setDescription('This object indicates the default Port-Base Vlan ID. It occupies only 1 entry in VLAN table, with VID=1.')
sw_port_base_vlan_default_desc = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(1, 12))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultDesc.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultDesc.setDescription('A textual description of the Port-Base Vlan.')
sw_port_base_vlan_default_port_list = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 3), port_list()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPortList.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPortList.setDescription('This object indicates the port member set of the specified Vlan. Each Vlan has a octect string to indicate the port map. The most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port.')
sw_port_base_vlan_default_port_number = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 2, 1, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPortNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanDefaultPortNumber.setDescription('This object indicates the number of ports of the entry.')
sw_port_base_vlan_config_table = mib_table((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3))
if mibBuilder.loadTexts:
swPortBaseVlanConfigTable.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigTable.setDescription("A table that contains Port-Based VLAN list entries for the switch. The device can't support port overlapping in Port-Based VLAN.")
sw_port_base_vlan_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1)).setIndexNames((0, 'SW-VLAN-MIB', 'swPortBaseVlanConfigPvid'))
if mibBuilder.loadTexts:
swPortBaseVlanConfigEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigEntry.setDescription('A list of information about a specific Port-Based VLAN configuration in swPortBaseVlanConfigTable.')
sw_port_base_vlan_config_pvid = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(2, 12))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPvid.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPvid.setDescription('This object indicates the Port-Base Vlan ID. There are up to 11 entries for current product now. The object range varies from 2 to 12.')
sw_port_base_vlan_config_desc = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(1, 12))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swPortBaseVlanConfigDesc.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigDesc.setDescription('A textual description of the Port-Base Vlan. It cannot be a null string. And each description must be unique in the table.')
sw_port_base_vlan_config_port_list = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 3), port_list()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPortList.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPortList.setDescription('This object indicates which ports are belong to the Vlan. Each Vlan has a octect string to indicate with port map. The most significant bit represents the lowest numbered port, and the least significant bit represents the highest numbered port.')
sw_port_base_vlan_config_port_number = mib_table_column((1, 3, 6, 1, 4, 1, 326, 2, 20, 1, 2, 2, 2, 28, 2, 8, 3, 3, 1, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPortNumber.setStatus('mandatory')
if mibBuilder.loadTexts:
swPortBaseVlanConfigPortNumber.setDescription('This object indicates the number of ports of the entry.')
mibBuilder.exportSymbols('SW-VLAN-MIB', marconi=marconi, swPortBaseVlanDefaultVlanEntry=swPortBaseVlanDefaultVlanEntry, swVlan=swVlan, swPortBaseVlanConfigTable=swPortBaseVlanConfigTable, golf=golf, swVlanCtrl=swVlanCtrl, swMacBaseVlanAddrEntry=swMacBaseVlanAddrEntry, swPortBaseVlanDefaultDesc=swPortBaseVlanDefaultDesc, swMacBaseVlanAddr=swMacBaseVlanAddr, swMacBaseVlanMacMember=swMacBaseVlanMacMember, swPortBaseVlanConfigPortNumber=swPortBaseVlanConfigPortNumber, swPortBaseVlanDefaultVlanTable=swPortBaseVlanDefaultVlanTable, swPortBaseVlan=swPortBaseVlan, swMacBaseVlanAddrMaxNum=swMacBaseVlanAddrMaxNum, swL2Mgmt=swL2Mgmt, dlinkcommon=dlinkcommon, swPortBaseVlanConfigEntry=swPortBaseVlanConfigEntry, swPortBaseVlanConfigPortList=swPortBaseVlanConfigPortList, swVlanSnmpPortVlan=swVlanSnmpPortVlan, swMacBaseVlanCtrlState=swMacBaseVlanCtrlState, PortList=PortList, external=external, swMacBaseVlanAddrStatus=swMacBaseVlanAddrStatus, swPortBaseVlanTotalNum=swPortBaseVlanTotalNum, swMacBaseVlan=swMacBaseVlan, swVlanInfoStatus=swVlanInfoStatus, swMacBaseVlanDesc=swMacBaseVlanDesc, swPortBaseVlanDefaultPvid=swPortBaseVlanDefaultPvid, dlink=dlink, MacAddress=MacAddress, swVlanCtrlMode=swVlanCtrlMode, golfproducts=golfproducts, systems=systems, swMacBaseVlanCtrlTable=swMacBaseVlanCtrlTable, swMacBaseVlanAddrVlanDesc=swMacBaseVlanAddrVlanDesc, marconi_mgmt=marconi_mgmt, swMacBaseVlanMaxNum=swMacBaseVlanMaxNum, swMacBaseVlanCtrlEntry=swMacBaseVlanCtrlEntry, swPortBaseVlanDefaultPortList=swPortBaseVlanDefaultPortList, swMacBaseVlanAddrTable=swMacBaseVlanAddrTable, swPortBaseVlanConfigPvid=swPortBaseVlanConfigPvid, swPortBaseVlanConfigDesc=swPortBaseVlanConfigDesc, VlanIndex=VlanIndex, swPortBaseVlanDefaultPortNumber=swPortBaseVlanDefaultPortNumber, golfcommon=golfcommon, swMacBaseVlanAddrState=swMacBaseVlanAddrState, es2000Mgmt=es2000Mgmt, es2000=es2000, swMacBaseVlanInfo=swMacBaseVlanInfo) |
class DFA:
current_state = None
current_letter = None
valid = True
def __init__(
self, name, alphabet, states, delta_function, start_state, final_states
):
self.name = name
self.alphabet = alphabet
self.states = states
self.delta_function = delta_function
self.start_state = start_state
self.final_states = final_states
self.current_state = start_state
def transition_to_state_with_input(self, letter):
if self.valid:
if (self.current_state, letter) not in self.delta_function.keys():
self.valid = False
return
self.current_state = self.delta_function[(self.current_state, letter)]
self.current_letter = letter
else:
return
def in_accept_state(self):
return self.current_state in self.final_states and self.valid
def go_to_initial_state(self):
self.current_letter = None
self.valid = True
self.current_state = self.start_state
def run_with_word(self, word):
self.go_to_initial_state()
for letter in word:
self.transition_to_state_with_input(letter)
continue
return self.in_accept_state()
def run_with_letters(self, word):
self.go_to_initial_state()
for letter in word:
if self.run_with_letter(letter):
return
else:
return
def run_with_letter(self, letter):
self.transition_to_state_with_input(letter)
return self.current_state
def __len__(self):
return len(self.states)
| class Dfa:
current_state = None
current_letter = None
valid = True
def __init__(self, name, alphabet, states, delta_function, start_state, final_states):
self.name = name
self.alphabet = alphabet
self.states = states
self.delta_function = delta_function
self.start_state = start_state
self.final_states = final_states
self.current_state = start_state
def transition_to_state_with_input(self, letter):
if self.valid:
if (self.current_state, letter) not in self.delta_function.keys():
self.valid = False
return
self.current_state = self.delta_function[self.current_state, letter]
self.current_letter = letter
else:
return
def in_accept_state(self):
return self.current_state in self.final_states and self.valid
def go_to_initial_state(self):
self.current_letter = None
self.valid = True
self.current_state = self.start_state
def run_with_word(self, word):
self.go_to_initial_state()
for letter in word:
self.transition_to_state_with_input(letter)
continue
return self.in_accept_state()
def run_with_letters(self, word):
self.go_to_initial_state()
for letter in word:
if self.run_with_letter(letter):
return
else:
return
def run_with_letter(self, letter):
self.transition_to_state_with_input(letter)
return self.current_state
def __len__(self):
return len(self.states) |
class LambdaError(Exception):
def __init__(self, description):
self.description = description
class BadRequestError(LambdaError):
pass
class ForbiddenError(LambdaError):
pass
class InternalServerError(LambdaError):
pass
class NotFoundError(LambdaError):
pass
class ValidationError(LambdaError):
pass
class FormattingError(LambdaError):
pass
class EventValidationError(ValidationError):
pass
class ResultValidationError(ValidationError):
pass
| class Lambdaerror(Exception):
def __init__(self, description):
self.description = description
class Badrequesterror(LambdaError):
pass
class Forbiddenerror(LambdaError):
pass
class Internalservererror(LambdaError):
pass
class Notfounderror(LambdaError):
pass
class Validationerror(LambdaError):
pass
class Formattingerror(LambdaError):
pass
class Eventvalidationerror(ValidationError):
pass
class Resultvalidationerror(ValidationError):
pass |
pkgname = "xrandr"
pkgver = "1.5.1"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf"]
makedepends = ["libxrandr-devel"]
pkgdesc = "Command line interface to X RandR extension"
maintainer = "q66 <[email protected]>"
license = "MIT"
url = "https://xorg.freedesktop.org"
source = f"$(XORG_SITE)/app/{pkgname}-{pkgver}.tar.xz"
sha256 = "7bc76daf9d72f8aff885efad04ce06b90488a1a169d118dea8a2b661832e8762"
def post_install(self):
self.install_license("COPYING")
| pkgname = 'xrandr'
pkgver = '1.5.1'
pkgrel = 0
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf']
makedepends = ['libxrandr-devel']
pkgdesc = 'Command line interface to X RandR extension'
maintainer = 'q66 <[email protected]>'
license = 'MIT'
url = 'https://xorg.freedesktop.org'
source = f'$(XORG_SITE)/app/{pkgname}-{pkgver}.tar.xz'
sha256 = '7bc76daf9d72f8aff885efad04ce06b90488a1a169d118dea8a2b661832e8762'
def post_install(self):
self.install_license('COPYING') |
# Validate input
while True:
print('Enter your age:')
age = input()
if age.isdecimal():
break
print('Pleas enter a number for your age.')
| while True:
print('Enter your age:')
age = input()
if age.isdecimal():
break
print('Pleas enter a number for your age.') |
#
# PySNMP MIB module Fore-Common-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Fore-Common-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:14:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Bits, MibIdentifier, enterprises, Counter64, Unsigned32, ModuleIdentity, Counter32, TimeTicks, NotificationType, ObjectIdentity, IpAddress, Gauge32, Integer32, iso, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "MibIdentifier", "enterprises", "Counter64", "Unsigned32", "ModuleIdentity", "Counter32", "TimeTicks", "NotificationType", "ObjectIdentity", "IpAddress", "Gauge32", "Integer32", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
fore = ModuleIdentity((1, 3, 6, 1, 4, 1, 326))
if mibBuilder.loadTexts: fore.setLastUpdated('9911050000Z')
if mibBuilder.loadTexts: fore.setOrganization('Marconi Communications')
if mibBuilder.loadTexts: fore.setContactInfo(' Postal: Marconi Communications, Inc. 5000 Marconi Drive Warrendale, PA 15086-7502 Tel: +1 724 742 6999 Email: [email protected] Web: http://www.marconi.com')
if mibBuilder.loadTexts: fore.setDescription('Definitions common to all FORE private MIBS.')
admin = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1))
systems = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2))
foreExperiment = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 3))
operations = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 1))
snmpErrors = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 2))
snmpTrapDest = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 3))
snmpAccess = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 4))
assembly = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 5))
fileXfr = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 6))
rmonExtensions = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 7))
preDot1qVlanMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 8))
snmpTrapLog = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 9))
ilmisnmp = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 10))
entityExtensionMIB = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 11))
ilmiRegistry = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 14))
foreIfExtension = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 15))
frameInternetworking = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 16))
ifExtensions = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 1, 17))
atmAdapter = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 1))
atmSwitch = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2))
etherSwitch = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 3))
atmAccess = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 5))
hubSwitchRouter = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 6))
ipoa = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 7))
stackSwitch = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 10))
switchRouter = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 15))
software = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 2))
asxd = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 2, 1))
hardware = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 1))
asx = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 1, 1))
asx200wg = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 4))
asx200bx = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 5))
asx200bxe = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 6))
cabletron9A000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 7))
asx1000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 8))
le155 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 9))
sfcs200wg = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 10))
sfcs200bx = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 11))
sfcs1000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 12))
tnx210 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 15))
tnx1100 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 16))
asx1200 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 17))
asx4000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 18))
le25 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 19))
esx3000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 20))
tnx1100b = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 21))
asx150 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 22))
bxr48000 = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 24))
asx4000m = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 25))
axhIp = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 26))
axhSig = MibIdentifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 27))
class SpansAddress(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(8, 8)
fixedLength = 8
class AtmAddress(OctetString):
subtypeSpec = OctetString.subtypeSpec + ConstraintsUnion(ValueSizeConstraint(8, 8), ValueSizeConstraint(20, 20), )
class NsapPrefix(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(13, 13)
fixedLength = 13
class NsapAddr(OctetString):
subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(20, 20)
fixedLength = 20
class TransitNetwork(DisplayString):
subtypeSpec = DisplayString.subtypeSpec + ValueSizeConstraint(1, 4)
class TrapNumber(Integer32):
pass
class EntryStatus(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))
namedValues = NamedValues(("valid", 1), ("createRequest", 2), ("underCreation", 3), ("invalid", 4))
class AtmSigProtocol(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))
namedValues = NamedValues(("other", 1), ("spans", 2), ("q2931", 3), ("pvc", 4), ("spvc", 5), ("oam", 6), ("spvcSpans", 7), ("spvcPnni", 8), ("rcc", 9), ("fsig", 10), ("mpls", 11), ("ipCtl", 12), ("oam-ctl", 13))
class GeneralState(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("normal", 1), ("fail", 2))
class IntegerBitString(Integer32):
pass
class ConnectionType(Integer32):
pass
mibBuilder.exportSymbols("Fore-Common-MIB", ilmiRegistry=ilmiRegistry, fore=fore, ilmisnmp=ilmisnmp, NsapPrefix=NsapPrefix, atmAccess=atmAccess, snmpTrapDest=snmpTrapDest, rmonExtensions=rmonExtensions, preDot1qVlanMIB=preDot1qVlanMIB, operations=operations, ipoa=ipoa, software=software, tnx1100=tnx1100, snmpErrors=snmpErrors, sfcs200bx=sfcs200bx, snmpAccess=snmpAccess, sfcs200wg=sfcs200wg, le25=le25, sfcs1000=sfcs1000, esx3000=esx3000, frameInternetworking=frameInternetworking, asx4000m=asx4000m, AtmAddress=AtmAddress, assembly=assembly, ConnectionType=ConnectionType, axhIp=axhIp, bxr48000=bxr48000, ifExtensions=ifExtensions, asx=asx, asxd=asxd, asx4000=asx4000, TransitNetwork=TransitNetwork, fileXfr=fileXfr, EntryStatus=EntryStatus, foreIfExtension=foreIfExtension, asx1000=asx1000, asx200bxe=asx200bxe, axhSig=axhSig, TrapNumber=TrapNumber, SpansAddress=SpansAddress, IntegerBitString=IntegerBitString, atmSwitch=atmSwitch, cabletron9A000=cabletron9A000, AtmSigProtocol=AtmSigProtocol, tnx1100b=tnx1100b, asx200bx=asx200bx, etherSwitch=etherSwitch, asx1200=asx1200, hubSwitchRouter=hubSwitchRouter, entityExtensionMIB=entityExtensionMIB, switchRouter=switchRouter, NsapAddr=NsapAddr, asx200wg=asx200wg, systems=systems, atmAdapter=atmAdapter, foreExperiment=foreExperiment, PYSNMP_MODULE_ID=fore, admin=admin, le155=le155, GeneralState=GeneralState, hardware=hardware, stackSwitch=stackSwitch, asx150=asx150, tnx210=tnx210, snmpTrapLog=snmpTrapLog)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueSizeConstraint')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(bits, mib_identifier, enterprises, counter64, unsigned32, module_identity, counter32, time_ticks, notification_type, object_identity, ip_address, gauge32, integer32, iso, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'Bits', 'MibIdentifier', 'enterprises', 'Counter64', 'Unsigned32', 'ModuleIdentity', 'Counter32', 'TimeTicks', 'NotificationType', 'ObjectIdentity', 'IpAddress', 'Gauge32', 'Integer32', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
fore = module_identity((1, 3, 6, 1, 4, 1, 326))
if mibBuilder.loadTexts:
fore.setLastUpdated('9911050000Z')
if mibBuilder.loadTexts:
fore.setOrganization('Marconi Communications')
if mibBuilder.loadTexts:
fore.setContactInfo(' Postal: Marconi Communications, Inc. 5000 Marconi Drive Warrendale, PA 15086-7502 Tel: +1 724 742 6999 Email: [email protected] Web: http://www.marconi.com')
if mibBuilder.loadTexts:
fore.setDescription('Definitions common to all FORE private MIBS.')
admin = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1))
systems = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2))
fore_experiment = mib_identifier((1, 3, 6, 1, 4, 1, 326, 3))
operations = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 1))
snmp_errors = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 2))
snmp_trap_dest = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 3))
snmp_access = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 4))
assembly = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 5))
file_xfr = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 6))
rmon_extensions = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 7))
pre_dot1q_vlan_mib = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 8))
snmp_trap_log = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 9))
ilmisnmp = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 10))
entity_extension_mib = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 11))
ilmi_registry = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 14))
fore_if_extension = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 15))
frame_internetworking = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 16))
if_extensions = mib_identifier((1, 3, 6, 1, 4, 1, 326, 1, 17))
atm_adapter = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 1))
atm_switch = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2))
ether_switch = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 3))
atm_access = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 5))
hub_switch_router = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 6))
ipoa = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 7))
stack_switch = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 10))
switch_router = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 15))
software = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 2))
asxd = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 2, 1))
hardware = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 1))
asx = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 1, 1))
asx200wg = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 4))
asx200bx = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 5))
asx200bxe = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 6))
cabletron9_a000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 7))
asx1000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 8))
le155 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 9))
sfcs200wg = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 10))
sfcs200bx = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 11))
sfcs1000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 12))
tnx210 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 15))
tnx1100 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 16))
asx1200 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 17))
asx4000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 18))
le25 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 19))
esx3000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 20))
tnx1100b = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 21))
asx150 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 22))
bxr48000 = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 24))
asx4000m = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 25))
axh_ip = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 26))
axh_sig = mib_identifier((1, 3, 6, 1, 4, 1, 326, 2, 2, 27))
class Spansaddress(OctetString):
subtype_spec = OctetString.subtypeSpec + value_size_constraint(8, 8)
fixed_length = 8
class Atmaddress(OctetString):
subtype_spec = OctetString.subtypeSpec + constraints_union(value_size_constraint(8, 8), value_size_constraint(20, 20))
class Nsapprefix(OctetString):
subtype_spec = OctetString.subtypeSpec + value_size_constraint(13, 13)
fixed_length = 13
class Nsapaddr(OctetString):
subtype_spec = OctetString.subtypeSpec + value_size_constraint(20, 20)
fixed_length = 20
class Transitnetwork(DisplayString):
subtype_spec = DisplayString.subtypeSpec + value_size_constraint(1, 4)
class Trapnumber(Integer32):
pass
class Entrystatus(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4))
named_values = named_values(('valid', 1), ('createRequest', 2), ('underCreation', 3), ('invalid', 4))
class Atmsigprotocol(Integer32):
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), ('spans', 2), ('q2931', 3), ('pvc', 4), ('spvc', 5), ('oam', 6), ('spvcSpans', 7), ('spvcPnni', 8), ('rcc', 9), ('fsig', 10), ('mpls', 11), ('ipCtl', 12), ('oam-ctl', 13))
class Generalstate(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2))
named_values = named_values(('normal', 1), ('fail', 2))
class Integerbitstring(Integer32):
pass
class Connectiontype(Integer32):
pass
mibBuilder.exportSymbols('Fore-Common-MIB', ilmiRegistry=ilmiRegistry, fore=fore, ilmisnmp=ilmisnmp, NsapPrefix=NsapPrefix, atmAccess=atmAccess, snmpTrapDest=snmpTrapDest, rmonExtensions=rmonExtensions, preDot1qVlanMIB=preDot1qVlanMIB, operations=operations, ipoa=ipoa, software=software, tnx1100=tnx1100, snmpErrors=snmpErrors, sfcs200bx=sfcs200bx, snmpAccess=snmpAccess, sfcs200wg=sfcs200wg, le25=le25, sfcs1000=sfcs1000, esx3000=esx3000, frameInternetworking=frameInternetworking, asx4000m=asx4000m, AtmAddress=AtmAddress, assembly=assembly, ConnectionType=ConnectionType, axhIp=axhIp, bxr48000=bxr48000, ifExtensions=ifExtensions, asx=asx, asxd=asxd, asx4000=asx4000, TransitNetwork=TransitNetwork, fileXfr=fileXfr, EntryStatus=EntryStatus, foreIfExtension=foreIfExtension, asx1000=asx1000, asx200bxe=asx200bxe, axhSig=axhSig, TrapNumber=TrapNumber, SpansAddress=SpansAddress, IntegerBitString=IntegerBitString, atmSwitch=atmSwitch, cabletron9A000=cabletron9A000, AtmSigProtocol=AtmSigProtocol, tnx1100b=tnx1100b, asx200bx=asx200bx, etherSwitch=etherSwitch, asx1200=asx1200, hubSwitchRouter=hubSwitchRouter, entityExtensionMIB=entityExtensionMIB, switchRouter=switchRouter, NsapAddr=NsapAddr, asx200wg=asx200wg, systems=systems, atmAdapter=atmAdapter, foreExperiment=foreExperiment, PYSNMP_MODULE_ID=fore, admin=admin, le155=le155, GeneralState=GeneralState, hardware=hardware, stackSwitch=stackSwitch, asx150=asx150, tnx210=tnx210, snmpTrapLog=snmpTrapLog) |
class Page(object):
def __init__(self, params):
self.size = 2 ** 10
self.Time = False
self.R = False
self.M = False
| class Page(object):
def __init__(self, params):
self.size = 2 ** 10
self.Time = False
self.R = False
self.M = False |
ftxus = {
'api_key':'YOUR_API_KEY',
'api_secret':'YOUR_API_SECRET'
}
| ftxus = {'api_key': 'YOUR_API_KEY', 'api_secret': 'YOUR_API_SECRET'} |
a = [1, 2, 3, 4]
def subset(a, n):
if n == 1:
return n
else:
return (subset(a[n - 1]), subset(a[n - 2]))
print(subset(a, n=4))
| a = [1, 2, 3, 4]
def subset(a, n):
if n == 1:
return n
else:
return (subset(a[n - 1]), subset(a[n - 2]))
print(subset(a, n=4)) |
def print_formatted(number):
# your code goes here
for i in range(1, number +1):
width = len(f"{number:b}")
print(f"{i:{width}} {i:{width}o} {i:{width}X} {i:{width}b}")
| def print_formatted(number):
for i in range(1, number + 1):
width = len(f'{number:b}')
print(f'{i:{width}} {i:{width}o} {i:{width}X} {i:{width}b}') |
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
dp = [inf] * (amount + 1)
dp[0] = 0
for coin in coins:
for x in range(coin, amount + 1):
dp[x] = min(dp[x], dp[x - coin] + 1)
return dp[amount] if dp[amount] != inf else -1
| class Solution:
def coin_change(self, coins: List[int], amount: int) -> int:
dp = [inf] * (amount + 1)
dp[0] = 0
for coin in coins:
for x in range(coin, amount + 1):
dp[x] = min(dp[x], dp[x - coin] + 1)
return dp[amount] if dp[amount] != inf else -1 |
#
# PySNMP MIB module Intel-Common-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Intel-Common-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:54:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
ModuleIdentity, ObjectIdentity, iso, Integer32, Bits, Counter64, Counter32, Gauge32, NotificationType, Unsigned32, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, TimeTicks, enterprises = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "ObjectIdentity", "iso", "Integer32", "Bits", "Counter64", "Counter32", "Gauge32", "NotificationType", "Unsigned32", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "TimeTicks", "enterprises")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
intel = MibIdentifier((1, 3, 6, 1, 4, 1, 343))
identifiers = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1))
products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2))
experimental = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 3))
information_technology = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 4)).setLabel("information-technology")
sysProducts = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 5))
mib2ext = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 6))
hw = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 7))
wekiva = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 111))
systems = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1))
objects = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 2))
comm_methods = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 3)).setLabel("comm-methods")
pc_systems = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 1)).setLabel("pc-systems")
proxy_systems = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 2)).setLabel("proxy-systems")
hub_systems = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3)).setLabel("hub-systems")
switch_systems = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 4)).setLabel("switch-systems")
local_proxy_1 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 3, 1)).setLabel("local-proxy-1")
pc_novell_1 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 3, 2)).setLabel("pc-novell-1")
express10_100Stack = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 1)).setLabel("express10-100Stack")
express12TX = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 2))
express24TX = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 3))
expressReserved = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 4))
expressBridge = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 6))
express210_12 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 7)).setLabel("express210-12")
express210_24 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 8)).setLabel("express210-24")
express220_12 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 9)).setLabel("express220-12")
express220_24 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 10)).setLabel("express220-24")
express300Stack = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 11))
express320_16 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 12)).setLabel("express320-16")
express320_24 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 13)).setLabel("express320-24")
pc_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 1)).setLabel("pc-products")
hub_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 2)).setLabel("hub-products")
proxy = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 3))
print_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 4)).setLabel("print-products")
network_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 5)).setLabel("network-products")
snmp_agents = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 6)).setLabel("snmp-agents")
nic_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 7)).setLabel("nic-products")
server_management = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 10)).setLabel("server-management")
switch_products = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 11)).setLabel("switch-products")
i2o = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 120))
express110 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 2, 1))
netport_1 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 1)).setLabel("netport-1")
netport_2 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 2)).setLabel("netport-2")
netport_express = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 3)).setLabel("netport-express")
lanDesk = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 1))
ld_alarms = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 1, 1)).setLabel("ld-alarms")
internetServer_2 = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 2)).setLabel("internetServer-2")
iS_alarms = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 2, 1)).setLabel("iS-alarms")
mibBuilder.exportSymbols("Intel-Common-MIB", express220_24=express220_24, express110=express110, snmp_agents=snmp_agents, switch_systems=switch_systems, objects=objects, proxy=proxy, lanDesk=lanDesk, express12TX=express12TX, mib2ext=mib2ext, experimental=experimental, express210_24=express210_24, sysProducts=sysProducts, netport_1=netport_1, internetServer_2=internetServer_2, intel=intel, pc_novell_1=pc_novell_1, products=products, express320_24=express320_24, proxy_systems=proxy_systems, express320_16=express320_16, identifiers=identifiers, express300Stack=express300Stack, wekiva=wekiva, express10_100Stack=express10_100Stack, hub_systems=hub_systems, ld_alarms=ld_alarms, server_management=server_management, switch_products=switch_products, i2o=i2o, netport_express=netport_express, network_products=network_products, expressBridge=expressBridge, express220_12=express220_12, local_proxy_1=local_proxy_1, systems=systems, comm_methods=comm_methods, express210_12=express210_12, pc_products=pc_products, hub_products=hub_products, expressReserved=expressReserved, netport_2=netport_2, pc_systems=pc_systems, hw=hw, express24TX=express24TX, print_products=print_products, information_technology=information_technology, iS_alarms=iS_alarms, nic_products=nic_products)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ValueSizeConstraint', 'SingleValueConstraint')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(module_identity, object_identity, iso, integer32, bits, counter64, counter32, gauge32, notification_type, unsigned32, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, time_ticks, enterprises) = mibBuilder.importSymbols('SNMPv2-SMI', 'ModuleIdentity', 'ObjectIdentity', 'iso', 'Integer32', 'Bits', 'Counter64', 'Counter32', 'Gauge32', 'NotificationType', 'Unsigned32', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'TimeTicks', 'enterprises')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
intel = mib_identifier((1, 3, 6, 1, 4, 1, 343))
identifiers = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1))
products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2))
experimental = mib_identifier((1, 3, 6, 1, 4, 1, 343, 3))
information_technology = mib_identifier((1, 3, 6, 1, 4, 1, 343, 4)).setLabel('information-technology')
sys_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 5))
mib2ext = mib_identifier((1, 3, 6, 1, 4, 1, 343, 6))
hw = mib_identifier((1, 3, 6, 1, 4, 1, 343, 7))
wekiva = mib_identifier((1, 3, 6, 1, 4, 1, 343, 111))
systems = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1))
objects = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 2))
comm_methods = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 3)).setLabel('comm-methods')
pc_systems = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 1)).setLabel('pc-systems')
proxy_systems = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 2)).setLabel('proxy-systems')
hub_systems = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3)).setLabel('hub-systems')
switch_systems = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 4)).setLabel('switch-systems')
local_proxy_1 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 3, 1)).setLabel('local-proxy-1')
pc_novell_1 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 3, 2)).setLabel('pc-novell-1')
express10_100_stack = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 1)).setLabel('express10-100Stack')
express12_tx = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 2))
express24_tx = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 3))
express_reserved = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 4))
express_bridge = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 6))
express210_12 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 7)).setLabel('express210-12')
express210_24 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 8)).setLabel('express210-24')
express220_12 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 9)).setLabel('express220-12')
express220_24 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 10)).setLabel('express220-24')
express300_stack = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 11))
express320_16 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 12)).setLabel('express320-16')
express320_24 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 1, 1, 3, 13)).setLabel('express320-24')
pc_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 1)).setLabel('pc-products')
hub_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 2)).setLabel('hub-products')
proxy = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 3))
print_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 4)).setLabel('print-products')
network_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 5)).setLabel('network-products')
snmp_agents = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 6)).setLabel('snmp-agents')
nic_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 7)).setLabel('nic-products')
server_management = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 10)).setLabel('server-management')
switch_products = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 11)).setLabel('switch-products')
i2o = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 120))
express110 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 2, 1))
netport_1 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 1)).setLabel('netport-1')
netport_2 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 2)).setLabel('netport-2')
netport_express = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 4, 3)).setLabel('netport-express')
lan_desk = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 1))
ld_alarms = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 1, 1)).setLabel('ld-alarms')
internet_server_2 = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 2)).setLabel('internetServer-2')
i_s_alarms = mib_identifier((1, 3, 6, 1, 4, 1, 343, 2, 5, 2, 1)).setLabel('iS-alarms')
mibBuilder.exportSymbols('Intel-Common-MIB', express220_24=express220_24, express110=express110, snmp_agents=snmp_agents, switch_systems=switch_systems, objects=objects, proxy=proxy, lanDesk=lanDesk, express12TX=express12TX, mib2ext=mib2ext, experimental=experimental, express210_24=express210_24, sysProducts=sysProducts, netport_1=netport_1, internetServer_2=internetServer_2, intel=intel, pc_novell_1=pc_novell_1, products=products, express320_24=express320_24, proxy_systems=proxy_systems, express320_16=express320_16, identifiers=identifiers, express300Stack=express300Stack, wekiva=wekiva, express10_100Stack=express10_100Stack, hub_systems=hub_systems, ld_alarms=ld_alarms, server_management=server_management, switch_products=switch_products, i2o=i2o, netport_express=netport_express, network_products=network_products, expressBridge=expressBridge, express220_12=express220_12, local_proxy_1=local_proxy_1, systems=systems, comm_methods=comm_methods, express210_12=express210_12, pc_products=pc_products, hub_products=hub_products, expressReserved=expressReserved, netport_2=netport_2, pc_systems=pc_systems, hw=hw, express24TX=express24TX, print_products=print_products, information_technology=information_technology, iS_alarms=iS_alarms, nic_products=nic_products) |
name = input()
class_school = 1
sum_of_grades = 0
ejected = False
failed = 0
while True:
grade = float(input())
if grade >= 4.00:
sum_of_grades += grade
if class_school == 12:
break
class_school += 1
else:
failed += 1
if failed == 2:
ejected = True
break
if ejected:
print(f"{name} has been excluded at {class_school} grade")
else:
average = sum_of_grades / class_school
print(f"{name} graduated. Average grade: {average:.2f}")
| name = input()
class_school = 1
sum_of_grades = 0
ejected = False
failed = 0
while True:
grade = float(input())
if grade >= 4.0:
sum_of_grades += grade
if class_school == 12:
break
class_school += 1
else:
failed += 1
if failed == 2:
ejected = True
break
if ejected:
print(f'{name} has been excluded at {class_school} grade')
else:
average = sum_of_grades / class_school
print(f'{name} graduated. Average grade: {average:.2f}') |
class Solution:
def minSwapsCouples(self, row: List[int]) -> int:
parent=[i for i in range(len(row))]
for i in range(1,len(row),2):
parent[i]-=1
def findpath(u,parent):
if parent[u]!=u:
parent[u]=findpath(parent[u],parent)
return parent[u]
for i in range(0,len(row),2):
u_parent=findpath(row[i],parent)
v_parent=findpath(row[i+1],parent)
parent[u_parent]=v_parent
return (len(row)//2)-sum([1 for i in range(0,len(row),2) if parent[i]==parent[i+1]==i])
| class Solution:
def min_swaps_couples(self, row: List[int]) -> int:
parent = [i for i in range(len(row))]
for i in range(1, len(row), 2):
parent[i] -= 1
def findpath(u, parent):
if parent[u] != u:
parent[u] = findpath(parent[u], parent)
return parent[u]
for i in range(0, len(row), 2):
u_parent = findpath(row[i], parent)
v_parent = findpath(row[i + 1], parent)
parent[u_parent] = v_parent
return len(row) // 2 - sum([1 for i in range(0, len(row), 2) if parent[i] == parent[i + 1] == i]) |
class Token:
def __init__(self, type=None, value=None):
self.type = type
self.value = value
def __str__(self):
return "Token({0}, {1})".format(self.type, self.value) | class Token:
def __init__(self, type=None, value=None):
self.type = type
self.value = value
def __str__(self):
return 'Token({0}, {1})'.format(self.type, self.value) |
def not_found_handler():
return '404. Path not found'
def internal_error_handler():
return '500. Internal error' | def not_found_handler():
return '404. Path not found'
def internal_error_handler():
return '500. Internal error' |
def transform_file(infile,outfile,templates):
with open(infile,'r') as fh:
indata = fh.read()
lines = indata.split('\n')
outlines = []
for line in lines:
if '//ATL_BEGIN' in line:
start = line.find('//ATL_BEGIN')
spacing = line[:start]
start = line.find('<') + 1
end = line.find('>')
tkey = line[start:end]
ttxt = templates[tkey]
for tl in ttxt:
outlines.append(spacing + tl)
else:
outlines.append(line)
with open(outfile,'w') as fh:
for line in outlines:
fh.write(line+'\n') | def transform_file(infile, outfile, templates):
with open(infile, 'r') as fh:
indata = fh.read()
lines = indata.split('\n')
outlines = []
for line in lines:
if '//ATL_BEGIN' in line:
start = line.find('//ATL_BEGIN')
spacing = line[:start]
start = line.find('<') + 1
end = line.find('>')
tkey = line[start:end]
ttxt = templates[tkey]
for tl in ttxt:
outlines.append(spacing + tl)
else:
outlines.append(line)
with open(outfile, 'w') as fh:
for line in outlines:
fh.write(line + '\n') |
#!/usr/bin/env python
# Copyright 2017 Google Inc. All Rights Reserved.
#
# 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.
# ************************************************************************************
# YOU NEED TO MODIFY THE FOLLOWING METADATA TO ADAPT THE TRAINER TEMPLATE TO YOUR DATA
# ************************************************************************************
# Task type can be either 'classification', 'regression', or 'custom'
# This is based on the target feature in the dataset, and whether you use a canned or a custom estimator
TASK_TYPE = '' # classification | regression | custom
# A List of all the columns (header) present in the input data file(s) in order to parse it.
# Note that, not all the columns present here will be input features to your model.
HEADER = []
# List of the default values of all the columns present in the input data.
# This helps decoding the data types of the columns.
HEADER_DEFAULTS = []
# List of the feature names of type int or float.
INPUT_NUMERIC_FEATURE_NAMES = []
# Numeric features constructed, if any, in process_features function in input.py module,
# as part of reading data.
CONSTRUCTED_NUMERIC_FEATURE_NAMES = []
# Dictionary of feature names with int values, but to be treated as categorical features.
# In the dictionary, the key is the feature name, and the value is the num_buckets (count of distinct values).
INPUT_CATEGORICAL_FEATURE_NAMES_WITH_IDENTITY = {}
# Categorical features with identity constructed, if any, in process_features function in input.py module,
# as part of reading data. Usually include constructed boolean flags.
CONSTRUCTED_CATEGORICAL_FEATURE_NAMES_WITH_IDENTITY = {}
# Dictionary of categorical features with few nominal values (to be encoded as one-hot indicators).
# In the dictionary, the key is the feature name, and the value is the list of feature vocabulary.
INPUT_CATEGORICAL_FEATURE_NAMES_WITH_VOCABULARY = {}
# Dictionary of categorical features with many values (sparse features).
# In the dictionary, the key is the feature name, and the value is the bucket size.
INPUT_CATEGORICAL_FEATURE_NAMES_WITH_HASH_BUCKET = {}
# List of all the categorical feature names.
# This is programmatically created based on the previous inputs.
INPUT_CATEGORICAL_FEATURE_NAMES = list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_IDENTITY.keys()) \
+ list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_VOCABULARY.keys()) \
+ list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_HASH_BUCKET.keys())
# List of all the input feature names to be used in the model.
# This is programmatically created based on the previous inputs.
INPUT_FEATURE_NAMES = INPUT_NUMERIC_FEATURE_NAMES + INPUT_CATEGORICAL_FEATURE_NAMES
# Column includes the relative weight of each record.
WEIGHT_COLUMN_NAME = None
# Target feature name (response or class variable).
TARGET_NAME = ''
# List of the class values (labels) in a classification dataset.
TARGET_LABELS = []
# List of the columns expected during serving (which is probably different to the header of the training data).
SERVING_COLUMNS = []
# List of the default values of all the columns of the serving data.
# This helps decoding the data types of the columns.
SERVING_DEFAULTS = []
| task_type = ''
header = []
header_defaults = []
input_numeric_feature_names = []
constructed_numeric_feature_names = []
input_categorical_feature_names_with_identity = {}
constructed_categorical_feature_names_with_identity = {}
input_categorical_feature_names_with_vocabulary = {}
input_categorical_feature_names_with_hash_bucket = {}
input_categorical_feature_names = list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_IDENTITY.keys()) + list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_VOCABULARY.keys()) + list(INPUT_CATEGORICAL_FEATURE_NAMES_WITH_HASH_BUCKET.keys())
input_feature_names = INPUT_NUMERIC_FEATURE_NAMES + INPUT_CATEGORICAL_FEATURE_NAMES
weight_column_name = None
target_name = ''
target_labels = []
serving_columns = []
serving_defaults = [] |
#
#
# This is Support for Drawing Bullet Charts
#
#
#
#
#
#
#
'''
This is the return json value to the javascript front end
{ "canvasName":"canvas1","featuredColor":"Green", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 1" },
{ "canvasName":"canvas2","featuredColor":"Blue", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 2" },
{ "canvasName":"canvas3","featuredColor":"Red", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 3" },
'''
class template_support():
def __init__(self , redis_handle, statistics_module):
self.redis_handle = redis_handle
self.statistics_module = statistics_module
def generate_current_canvas_list( self, schedule_name, *args, **kwargs ):
return_value = []
self.schedule_name = schedule_name
data = self.statistics_module.schedule_data[ schedule_name ]
current_data = self.statistics_module.get_current_data( data["step_number"],schedule_name )
limit_values = self.statistics_module.get_current_limit_values( data["step_number"],schedule_name )
for i in range(0,data["step_number"]):
temp = {}
temp["canvasName"] = "canvas1" +str(i+1)
temp["titleText"] = "Step " +str(i+1)
temp["qualScale1Color"] = "Black"
temp["featuredColor"] = "Red"
temp["qualScale1"] = limit_values[i]['limit_avg']
temp["featuredMeasure"] = current_data[i]
temp["limit"] = limit_values[i]['limit_std']
temp["step"] = i
return_value.append(temp)
return return_value
def generate_canvas_list(self, schedule_name, flow_id , *args,**kwargs):
return_value = []
self.schedule_name = schedule_name
data = self.statistics_module.schedule_data[ schedule_name ]
flow_sensors = self.statistics_module.sensor_names
flow_sensor_name = flow_sensors[flow_id]
conversion_rate = self.statistics_module.conversion_rate[flow_id]
flow_data = self.statistics_module.get_average_flow_data( data["step_number"], flow_sensor_name, schedule_name )
limit_values = self.statistics_module.get_flow_limit_values( data["step_number"], flow_sensor_name, schedule_name )
for i in limit_values:
try:
i['limit_avg'] = float(i['limit_avg'])*conversion_rate
i['limit_std'] = float(i['limit_std'])*conversion_rate
except:
pass
corrected_flow = []
for i in flow_data:
temp1 = []
for j in i:
temp1.append( j *conversion_rate)
corrected_flow.append(temp1)
for i in range(0,data["step_number"]):
temp = {}
temp["canvasName"] = "canvas1" +str(i+1)
temp["titleText"] = "Step " +str(i+1)
temp["qualScale1Color"] = "Black"
temp["featuredColor"] = "Red"
try:
temp["qualScale1"] = limit_values[i]['limit_avg']
except:
temp["qualScale1"] = 0
try:
temp["featuredMeasure"] = corrected_flow[i]
except:
temp["featuredMeasure"] = 0
try:
temp["limit"] = limit_values[i]['limit_std']
except:
temp["limit"] = 0
return_value.append(temp)
return return_value
| """
This is the return json value to the javascript front end
{ "canvasName":"canvas1","featuredColor":"Green", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 1" },
{ "canvasName":"canvas2","featuredColor":"Blue", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 2" },
{ "canvasName":"canvas3","featuredColor":"Red", "featuredMeasure":14.5,
"qualScale1":14.5, "qualScale1Color":"Black","titleText":"Step 3" },
"""
class Template_Support:
def __init__(self, redis_handle, statistics_module):
self.redis_handle = redis_handle
self.statistics_module = statistics_module
def generate_current_canvas_list(self, schedule_name, *args, **kwargs):
return_value = []
self.schedule_name = schedule_name
data = self.statistics_module.schedule_data[schedule_name]
current_data = self.statistics_module.get_current_data(data['step_number'], schedule_name)
limit_values = self.statistics_module.get_current_limit_values(data['step_number'], schedule_name)
for i in range(0, data['step_number']):
temp = {}
temp['canvasName'] = 'canvas1' + str(i + 1)
temp['titleText'] = 'Step ' + str(i + 1)
temp['qualScale1Color'] = 'Black'
temp['featuredColor'] = 'Red'
temp['qualScale1'] = limit_values[i]['limit_avg']
temp['featuredMeasure'] = current_data[i]
temp['limit'] = limit_values[i]['limit_std']
temp['step'] = i
return_value.append(temp)
return return_value
def generate_canvas_list(self, schedule_name, flow_id, *args, **kwargs):
return_value = []
self.schedule_name = schedule_name
data = self.statistics_module.schedule_data[schedule_name]
flow_sensors = self.statistics_module.sensor_names
flow_sensor_name = flow_sensors[flow_id]
conversion_rate = self.statistics_module.conversion_rate[flow_id]
flow_data = self.statistics_module.get_average_flow_data(data['step_number'], flow_sensor_name, schedule_name)
limit_values = self.statistics_module.get_flow_limit_values(data['step_number'], flow_sensor_name, schedule_name)
for i in limit_values:
try:
i['limit_avg'] = float(i['limit_avg']) * conversion_rate
i['limit_std'] = float(i['limit_std']) * conversion_rate
except:
pass
corrected_flow = []
for i in flow_data:
temp1 = []
for j in i:
temp1.append(j * conversion_rate)
corrected_flow.append(temp1)
for i in range(0, data['step_number']):
temp = {}
temp['canvasName'] = 'canvas1' + str(i + 1)
temp['titleText'] = 'Step ' + str(i + 1)
temp['qualScale1Color'] = 'Black'
temp['featuredColor'] = 'Red'
try:
temp['qualScale1'] = limit_values[i]['limit_avg']
except:
temp['qualScale1'] = 0
try:
temp['featuredMeasure'] = corrected_flow[i]
except:
temp['featuredMeasure'] = 0
try:
temp['limit'] = limit_values[i]['limit_std']
except:
temp['limit'] = 0
return_value.append(temp)
return return_value |
declerations_test_text_001 = '''
list1 = [
1,
]
'''
declerations_test_text_002 = '''
list1 = [
1,
2,
]
'''
declerations_test_text_003 = '''
tuple1 = (
1,
)
'''
declerations_test_text_004 = '''
tuple1 = (
1,
2,
)
'''
declerations_test_text_005 = '''
set1 = {
1,
}
'''
declerations_test_text_006 = '''
set1 = {
1,
2,
}
'''
declerations_test_text_007 = '''
dict1 = {
'key': 1,
}
'''
declerations_test_text_008 = '''
dict1 = {
'key1': 1,
'key2': 2,
}
'''
declerations_test_text_009 = '''
return [
1,
]
'''
declerations_test_text_010 = '''
return [
1,
2,
]
'''
declerations_test_text_011 = '''
return (
1,
)
'''
declerations_test_text_012 = '''
return (
1,
2,
)
'''
declerations_test_text_013 = '''
return {
1,
}
'''
declerations_test_text_014 = '''
return {
1,
2,
}
'''
declerations_test_text_015 = '''
return {
'key': 1,
}
'''
declerations_test_text_016 = '''
return {
'key1': 1,
'key2': 2,
}
'''
declerations_test_text_017 = '''
yield [
1,
]
'''
declerations_test_text_018 = '''
yield [
1,
2,
]
'''
declerations_test_text_019 = '''
yield (
1,
)
'''
declerations_test_text_020 = '''
yield (
1,
2,
)
'''
declerations_test_text_021 = '''
yield {
1,
}
'''
declerations_test_text_022 = '''
yield {
1,
2,
}
'''
declerations_test_text_023 = '''
yield {
'key': 1,
}
'''
declerations_test_text_024 = '''
yield {
'key1': 1,
'key2': 2,
}
'''
declerations_test_text_025 = '''
list1 = [
[
1,
],
]
'''
declerations_test_text_026 = '''
list1 = [
[
1,
2,
],
]
'''
declerations_test_text_027 = '''
tuple1 = (
(
1,
),
)
'''
declerations_test_text_028 = '''
tuple1 = (
(
1,
2,
),
)
'''
declerations_test_text_029 = '''
set1 = {
{
1,
},
}
'''
declerations_test_text_030 = '''
set1 = {
{
1,
2,
},
}
'''
declerations_test_text_031 = '''
dict1 = {
'key': {
'key': 1,
},
}
'''
declerations_test_text_032 = '''
dict1 = {
'key1': {
'key1': 1,
'key2': 2,
},
'key2': {
'key1': 1,
'key2': 2,
},
}
'''
declerations_test_text_033 = '''
return [
[
1,
],
]
'''
declerations_test_text_034 = '''
return [
[
1,
2,
],
]
'''
declerations_test_text_035 = '''
return (
(
1,
),
)
'''
declerations_test_text_036 = '''
return (
(
1,
2,
),
)
'''
declerations_test_text_037 = '''
return {
{
1,
},
}
'''
declerations_test_text_038 = '''
return {
{
1,
2,
},
}
'''
declerations_test_text_039 = '''
return {
'key': {
'key': 1,
},
}
'''
declerations_test_text_040 = '''
return {
'key1': {
'key1': 1,
'key2': 2,
},
'key2': {
'key1': 1,
'key2': 2,
},
}
'''
declerations_test_text_041 = '''
yield [
[
1,
],
]
'''
declerations_test_text_042 = '''
yield [
[
1,
2,
],
]
'''
declerations_test_text_043 = '''
yield (
(
1,
),
)
'''
declerations_test_text_044 = '''
yield (
(
1,
2,
),
)
'''
declerations_test_text_045 = '''
yield {
{
1,
},
}
'''
declerations_test_text_046 = '''
yield {
{
1,
2,
},
}
'''
declerations_test_text_047 = '''
yield {
'key': {
'key': 1,
},
}
'''
declerations_test_text_048 = '''
yield {
'key1': {
'key1': 1,
'key2': 2,
},
'key2': {
'key1': 1,
'key2': 2,
},
}
'''
declerations_test_text_049 = '''
list1 = [
[
2,
],
]
'''
declerations_test_text_050 = '''
list_1 = [
[
[
2,
],
],
]
'''
declerations_test_text_051 = '''
list_1 = [
(
2,
),
]
'''
declerations_test_text_052 = '''
list_1 = [
{
'key1': 'value1',
},
]
'''
declerations_test_text_053 = '''
list_1 = [
call(
param1,
),
]
'''
declerations_test_text_054 = '''
entry_1, entry_2 = call()
'''
declerations_test_text_055 = '''
(
entry_1,
entry_2,
) = call()
'''
declerations_test_text_056 = '''
[
1
for a, b in call()
]
'''
declerations_test_text_057 = '''
{
'key': [
'entry_1',
'entry_2',
]
}
'''
declerations_test_text_058 = '''
list_1 = [instance.attribute]
'''
declerations_test_text_059 = '''
list_1 = [1]
'''
declerations_test_text_060 = '''
list_1 = [test]
'''
declerations_test_text_061 = '''
dict_1 = {}
'''
declerations_test_text_062 = '''
list_1 = [term[1]]
'''
declerations_test_text_063 = '''
test = {
'list_of_lists': [
[],
],
}
'''
declerations_test_text_064 = '''
class ClassName:
pass
'''
declerations_test_text_065 = '''
class ClassName(
Class1,
Class2,
):
pass
'''
declerations_test_text_066 = '''
class ClassName():
pass
'''
declerations_test_text_067 = '''
class ClassName(Class1, Class2):
pass
'''
declerations_test_text_068 = '''
class ClassName(
Class1,
Class2
):
pass
'''
declerations_test_text_069 = '''
def function_name():
pass
'''
declerations_test_text_070 = '''
def function_name( ):
pass
'''
declerations_test_text_071 = '''
def function_name(
):
pass
'''
declerations_test_text_072 = '''
def function_name(
):
pass
'''
declerations_test_text_073 = '''
def function_name(
arg1,
arg2,
):
pass
'''
declerations_test_text_074 = '''
def function_name(
arg1,
arg2
):
pass
'''
declerations_test_text_075 = '''
def function_name(arg1):
pass
'''
declerations_test_text_076 = '''
def function_name(
arg1, arg2,
):
pass
'''
declerations_test_text_077 = '''
def function_name(
arg1,
arg2,
):
pass
'''
declerations_test_text_078 = '''
def function_name(
arg1,
**kwargs
):
pass
'''
declerations_test_text_079 = '''
class Class:
def function_name_two(
self,
arg1,
arg2,
):
pass
'''
declerations_test_text_080 = '''
class Class:
@property
def function_name_one(
self,
):
pass
'''
declerations_test_text_081 = '''
def function_name(
*args,
**kwargs
):
pass
'''
declerations_test_text_082 = '''
class A:
def b():
class B:
pass
'''
declerations_test_text_083 = '''
@decorator(
param=1,
)
def function_name(
param_one,
param_two,
):
pass
'''
declerations_test_text_084 = '''
class ClassA:
def function_a():
pass
class TestServerHandler(
http.server.BaseHTTPRequestHandler,
):
pass
'''
declerations_test_text_085 = '''
def function(
param_a,
param_b=[
'test',
],
):
pass
'''
declerations_test_text_086 = '''
@decorator
class DecoratedClass(
ClassBase,
):
pass
'''
declerations_test_text_087 = '''
class ClassName(
object,
):
pass
'''
declerations_test_text_088 = '''
pixel[x,y] = 10
'''
declerations_test_text_089 = '''
@decorator.one
@decorator.two()
class DecoratedClass:
pass
'''
declerations_test_text_090 = '''
@staticmethod
def static_method():
pass
'''
declerations_test_text_091 = '''
@decorator1
@decorator2
def static_method(
param1,
param2,
):
pass
'''
declerations_test_text_092 = '''
@decorator1(
param=1,
)
def method():
pass
'''
declerations_test_text_093 = '''
try:
pass
except Exception:
pass
'''
declerations_test_text_094 = '''
try:
pass
except (
Exception1,
Exception2,
):
pass
'''
declerations_test_text_095 = '''
try:
pass
except Exception as exception:
pass
'''
declerations_test_text_096 = '''
try:
pass
except (
Exception1,
Exception2,
) as exception:
pass
'''
declerations_test_text_097 = '''
try:
pass
except Exception as e:
pass
'''
declerations_test_text_098 = '''
try:
pass
except (
Exception1,
Exception2,
) as e:
pass
'''
declerations_test_text_099 = '''
dict1 = {
'key_one': 1, 'key_two': 2,
}
'''
declerations_test_text_100 = '''
dict1 = {
'key_one': 1,
'key_two': 2,
}
'''
declerations_test_text_101 = '''
dict1 = {
'key_one': 1,
'key_two': 2,
}
'''
declerations_test_text_102 = '''
dict1 = {
'key_one':
1,
}
'''
declerations_test_text_103 = '''
dict_one = {
'list_comp': [
{
'key_one': 'value',
}
for i in range(5)
],
'dict_comp': {
'key_one': i
for i in range(5)
},
'set_comp': {
i
for i in range(5)
},
'generator_comp': (
i
for i in range(5)
),
}
'''
declerations_test_text_104 = '''
dict_one = {
'text_key': 'value',
f'formatted_text_key': 'value',
name_key: 'value',
1: 'value',
dictionary['name']: 'value',
object.attribute: 'value',
}
dict_two = {
'key_text_multiline': \'\'\'
text
\'\'\',
1: 'text',
function(
param=1,
): 'text',
'text'.format(
param=1,
): 'text',
'long_text': (
'first line'
'second line'
),
**other_dict,
}
'''
declerations_test_text_105 = '''
async def function(
param1,
):
pass
'''
declerations_test_text_106 = '''
def no_args_function():
pass
def no_args_function() :
pass
def no_args_function ():
pass
def no_args_function( ):
pass
def no_args_function():
pass
def no_args_function() -> None:
pass
def no_args_function() -> None :
pass
def no_args_function () -> None:
pass
def no_args_function( ) -> None:
pass
def no_args_function() -> None:
pass
'''
declerations_test_text_107 = '''
class Class:
@decorator(
param=1,
)
async def function():
pass
'''
declerations_test_text_108 = '''
list_a = [
\'\'\'
multiline
string
\'\'\',
\'\'\'
multiline
string
\'\'\',
]
'''
declerations_test_text_109 = '''
list_with_empty_tuple = [
(),
]
'''
| declerations_test_text_001 = '\nlist1 = [\n 1,\n]\n'
declerations_test_text_002 = '\nlist1 = [\n 1,\n 2,\n]\n'
declerations_test_text_003 = '\ntuple1 = (\n 1,\n)\n'
declerations_test_text_004 = '\ntuple1 = (\n 1,\n 2,\n)\n'
declerations_test_text_005 = '\nset1 = {\n 1,\n}\n'
declerations_test_text_006 = '\nset1 = {\n 1,\n 2,\n}\n'
declerations_test_text_007 = "\ndict1 = {\n 'key': 1,\n}\n"
declerations_test_text_008 = "\ndict1 = {\n 'key1': 1,\n 'key2': 2,\n}\n"
declerations_test_text_009 = '\nreturn [\n 1,\n]\n'
declerations_test_text_010 = '\nreturn [\n 1,\n 2,\n]\n'
declerations_test_text_011 = '\nreturn (\n 1,\n)\n'
declerations_test_text_012 = '\nreturn (\n 1,\n 2,\n)\n'
declerations_test_text_013 = '\nreturn {\n 1,\n}\n'
declerations_test_text_014 = '\nreturn {\n 1,\n 2,\n}\n'
declerations_test_text_015 = "\nreturn {\n 'key': 1,\n}\n"
declerations_test_text_016 = "\nreturn {\n 'key1': 1,\n 'key2': 2,\n}\n"
declerations_test_text_017 = '\nyield [\n 1,\n]\n'
declerations_test_text_018 = '\nyield [\n 1,\n 2,\n]\n'
declerations_test_text_019 = '\nyield (\n 1,\n)\n'
declerations_test_text_020 = '\nyield (\n 1,\n 2,\n)\n'
declerations_test_text_021 = '\nyield {\n 1,\n}\n'
declerations_test_text_022 = '\nyield {\n 1,\n 2,\n}\n'
declerations_test_text_023 = "\nyield {\n 'key': 1,\n}\n"
declerations_test_text_024 = "\nyield {\n 'key1': 1,\n 'key2': 2,\n}\n"
declerations_test_text_025 = '\nlist1 = [\n [\n 1,\n ],\n]\n'
declerations_test_text_026 = '\nlist1 = [\n [\n 1,\n 2,\n ],\n]\n'
declerations_test_text_027 = '\ntuple1 = (\n (\n 1,\n ),\n)\n'
declerations_test_text_028 = '\ntuple1 = (\n (\n 1,\n 2,\n ),\n)\n'
declerations_test_text_029 = '\nset1 = {\n {\n 1,\n },\n}\n'
declerations_test_text_030 = '\nset1 = {\n {\n 1,\n 2,\n },\n}\n'
declerations_test_text_031 = "\ndict1 = {\n 'key': {\n 'key': 1,\n },\n}\n"
declerations_test_text_032 = "\ndict1 = {\n 'key1': {\n 'key1': 1,\n 'key2': 2,\n },\n 'key2': {\n 'key1': 1,\n 'key2': 2,\n },\n}\n"
declerations_test_text_033 = '\nreturn [\n [\n 1,\n ],\n]\n'
declerations_test_text_034 = '\nreturn [\n [\n 1,\n 2,\n ],\n]\n'
declerations_test_text_035 = '\nreturn (\n (\n 1,\n ),\n)\n'
declerations_test_text_036 = '\nreturn (\n (\n 1,\n 2,\n ),\n)\n'
declerations_test_text_037 = '\nreturn {\n {\n 1,\n },\n}\n'
declerations_test_text_038 = '\nreturn {\n {\n 1,\n 2,\n },\n}\n'
declerations_test_text_039 = "\nreturn {\n 'key': {\n 'key': 1,\n },\n}\n"
declerations_test_text_040 = "\nreturn {\n 'key1': {\n 'key1': 1,\n 'key2': 2,\n },\n 'key2': {\n 'key1': 1,\n 'key2': 2,\n },\n}\n"
declerations_test_text_041 = '\nyield [\n [\n 1,\n ],\n]\n'
declerations_test_text_042 = '\nyield [\n [\n 1,\n 2,\n ],\n]\n'
declerations_test_text_043 = '\nyield (\n (\n 1,\n ),\n)\n'
declerations_test_text_044 = '\nyield (\n (\n 1,\n 2,\n ),\n)\n'
declerations_test_text_045 = '\nyield {\n {\n 1,\n },\n}\n'
declerations_test_text_046 = '\nyield {\n {\n 1,\n 2,\n },\n}\n'
declerations_test_text_047 = "\nyield {\n 'key': {\n 'key': 1,\n },\n}\n"
declerations_test_text_048 = "\nyield {\n 'key1': {\n 'key1': 1,\n 'key2': 2,\n },\n 'key2': {\n 'key1': 1,\n 'key2': 2,\n },\n}\n"
declerations_test_text_049 = '\nlist1 = [\n [\n 2,\n ],\n]\n'
declerations_test_text_050 = '\nlist_1 = [\n [\n [\n 2,\n ],\n ],\n]\n'
declerations_test_text_051 = '\nlist_1 = [\n (\n 2,\n ),\n]\n'
declerations_test_text_052 = "\nlist_1 = [\n {\n 'key1': 'value1',\n },\n]\n"
declerations_test_text_053 = '\nlist_1 = [\n call(\n param1,\n ),\n]\n'
declerations_test_text_054 = '\nentry_1, entry_2 = call()\n'
declerations_test_text_055 = '\n(\n entry_1,\n entry_2,\n) = call()\n'
declerations_test_text_056 = '\n[\n 1\n for a, b in call()\n]\n'
declerations_test_text_057 = "\n{\n 'key': [\n 'entry_1',\n 'entry_2',\n ]\n}\n"
declerations_test_text_058 = '\nlist_1 = [instance.attribute]\n'
declerations_test_text_059 = '\nlist_1 = [1]\n'
declerations_test_text_060 = '\nlist_1 = [test]\n'
declerations_test_text_061 = '\ndict_1 = {}\n'
declerations_test_text_062 = '\nlist_1 = [term[1]]\n'
declerations_test_text_063 = "\ntest = {\n 'list_of_lists': [\n [],\n ],\n}\n"
declerations_test_text_064 = '\nclass ClassName:\n pass\n'
declerations_test_text_065 = '\nclass ClassName(\n Class1,\n Class2,\n):\n pass\n'
declerations_test_text_066 = '\nclass ClassName():\n pass\n'
declerations_test_text_067 = '\nclass ClassName(Class1, Class2):\n pass\n'
declerations_test_text_068 = '\nclass ClassName(\n Class1,\n Class2\n):\n pass\n'
declerations_test_text_069 = '\ndef function_name():\n pass\n'
declerations_test_text_070 = '\ndef function_name( ):\n pass\n'
declerations_test_text_071 = '\ndef function_name(\n):\n pass\n'
declerations_test_text_072 = '\ndef function_name(\n\n):\n pass\n'
declerations_test_text_073 = '\ndef function_name(\n arg1,\n arg2,\n):\n pass\n'
declerations_test_text_074 = '\ndef function_name(\n arg1,\n arg2\n):\n pass\n'
declerations_test_text_075 = '\ndef function_name(arg1):\n pass\n'
declerations_test_text_076 = '\ndef function_name(\n arg1, arg2,\n):\n pass\n'
declerations_test_text_077 = '\ndef function_name(\n arg1,\n arg2,\n):\n pass\n'
declerations_test_text_078 = '\ndef function_name(\n arg1,\n **kwargs\n):\n pass\n'
declerations_test_text_079 = '\nclass Class:\n def function_name_two(\n self,\n arg1,\n arg2,\n ):\n pass\n'
declerations_test_text_080 = '\nclass Class:\n @property\n def function_name_one(\n self,\n ):\n pass\n'
declerations_test_text_081 = '\ndef function_name(\n *args,\n **kwargs\n):\n pass\n'
declerations_test_text_082 = '\nclass A:\n def b():\n class B:\n pass\n'
declerations_test_text_083 = '\n@decorator(\n param=1,\n)\ndef function_name(\n param_one,\n param_two,\n):\n pass\n'
declerations_test_text_084 = '\nclass ClassA:\n def function_a():\n pass\n\n class TestServerHandler(\n http.server.BaseHTTPRequestHandler,\n ):\n pass\n'
declerations_test_text_085 = "\ndef function(\n param_a,\n param_b=[\n 'test',\n ],\n):\n pass\n"
declerations_test_text_086 = '\n@decorator\nclass DecoratedClass(\n ClassBase,\n):\n pass\n'
declerations_test_text_087 = '\nclass ClassName(\n object,\n):\n pass\n'
declerations_test_text_088 = '\npixel[x,y] = 10\n'
declerations_test_text_089 = '\[email protected]\[email protected]()\nclass DecoratedClass:\n pass\n'
declerations_test_text_090 = '\n@staticmethod\ndef static_method():\n pass\n'
declerations_test_text_091 = '\n@decorator1\n@decorator2\ndef static_method(\n param1,\n param2,\n):\n pass\n'
declerations_test_text_092 = '\n@decorator1(\n param=1,\n)\ndef method():\n pass\n'
declerations_test_text_093 = '\ntry:\n pass\nexcept Exception:\n pass\n'
declerations_test_text_094 = '\ntry:\n pass\nexcept (\n Exception1,\n Exception2,\n):\n pass\n'
declerations_test_text_095 = '\ntry:\n pass\nexcept Exception as exception:\n pass\n'
declerations_test_text_096 = '\ntry:\n pass\nexcept (\n Exception1,\n Exception2,\n) as exception:\n pass\n'
declerations_test_text_097 = '\ntry:\n pass\nexcept Exception as e:\n pass\n'
declerations_test_text_098 = '\ntry:\n pass\nexcept (\n Exception1,\n Exception2,\n) as e:\n pass\n'
declerations_test_text_099 = "\ndict1 = {\n 'key_one': 1, 'key_two': 2,\n}\n"
declerations_test_text_100 = "\ndict1 = {\n 'key_one': 1,\n 'key_two': 2,\n}\n"
declerations_test_text_101 = "\ndict1 = {\n 'key_one': 1,\n 'key_two': 2,\n}\n"
declerations_test_text_102 = "\ndict1 = {\n 'key_one':\n 1,\n}\n"
declerations_test_text_103 = "\ndict_one = {\n 'list_comp': [\n {\n 'key_one': 'value',\n }\n for i in range(5)\n ],\n 'dict_comp': {\n 'key_one': i\n for i in range(5)\n },\n 'set_comp': {\n i\n for i in range(5)\n },\n 'generator_comp': (\n i\n for i in range(5)\n ),\n}\n"
declerations_test_text_104 = "\ndict_one = {\n 'text_key': 'value',\n f'formatted_text_key': 'value',\n name_key: 'value',\n 1: 'value',\n dictionary['name']: 'value',\n object.attribute: 'value',\n}\ndict_two = {\n 'key_text_multiline': '''\n text\n ''',\n 1: 'text',\n function(\n param=1,\n ): 'text',\n 'text'.format(\n param=1,\n ): 'text',\n 'long_text': (\n 'first line'\n 'second line'\n ),\n **other_dict,\n}\n"
declerations_test_text_105 = '\nasync def function(\n param1,\n\n):\n pass\n'
declerations_test_text_106 = '\ndef no_args_function():\n pass\ndef no_args_function() :\n pass\ndef no_args_function ():\n pass\ndef no_args_function( ):\n pass\ndef no_args_function():\n pass\n\ndef no_args_function() -> None:\n pass\ndef no_args_function() -> None :\n pass\ndef no_args_function () -> None:\n pass\ndef no_args_function( ) -> None:\n pass\ndef no_args_function() -> None:\n pass\n'
declerations_test_text_107 = '\nclass Class:\n @decorator(\n param=1,\n )\n async def function():\n pass\n'
declerations_test_text_108 = "\nlist_a = [\n '''\n multiline\n string\n ''',\n '''\n multiline\n string\n ''',\n]\n"
declerations_test_text_109 = '\nlist_with_empty_tuple = [\n (),\n]\n' |
file_berita = open("berita.txt", "r")
berita = file_berita.read()
berita = berita.split()
berita = [x.lower() for x in berita]
berita = list(set(berita))
berita = sorted(berita)
print (berita) | file_berita = open('berita.txt', 'r')
berita = file_berita.read()
berita = berita.split()
berita = [x.lower() for x in berita]
berita = list(set(berita))
berita = sorted(berita)
print(berita) |
rzymskie={'I':1,'II':2,'III':3,'IV':4,'V':5,'VI':6,'VII':7,'VIII':8}
print(rzymskie)
print('Jeden element slownika: \n')
print(rzymskie['I'])
| rzymskie = {'I': 1, 'II': 2, 'III': 3, 'IV': 4, 'V': 5, 'VI': 6, 'VII': 7, 'VIII': 8}
print(rzymskie)
print('Jeden element slownika: \n')
print(rzymskie['I']) |
H, W = map(int, input().split())
A = [input() for _ in range(H)]
if H + W - 1 == sum(a.count('#') for a in A):
print('Possible')
else:
print('Impossible')
| (h, w) = map(int, input().split())
a = [input() for _ in range(H)]
if H + W - 1 == sum((a.count('#') for a in A)):
print('Possible')
else:
print('Impossible') |
# File: etl.py
# Purpose: To do the `Transform` step of an Extract-Transform-Load.
# Programmer: Amal Shehu
# Course: Exercism
# Date: Thursday 22 September 2016, 03:40 PM
def transform(words):
new_words = dict()
for point, letters in words.items():
for letter in letters:
new_words[letter.lower()] = point
return new_words
| def transform(words):
new_words = dict()
for (point, letters) in words.items():
for letter in letters:
new_words[letter.lower()] = point
return new_words |
def have(subj, obj):
subj.add(obj)
def change(subj, obj, state):
pass
if __name__ == '__main__':
main() | def have(subj, obj):
subj.add(obj)
def change(subj, obj, state):
pass
if __name__ == '__main__':
main() |
# A bot that picks the first action from the list for the first two rounds,
# and then exists with an exception.
# Used only for tests.
game_name = input()
play_as = int(input())
print("ready")
while True:
print("start")
num_actions = 0
while True:
message = input()
if message == "tournament over":
print("tournament over")
sys.exit(0)
if message.startswith("match over"):
print("match over")
break
public_buf, private_buf, *legal_actions = message.split(" ")
should_act = len(legal_actions) > 0
if should_act:
num_actions += 1
print(legal_actions[-1])
else:
print("ponder")
if num_actions > 2:
raise RuntimeError
| game_name = input()
play_as = int(input())
print('ready')
while True:
print('start')
num_actions = 0
while True:
message = input()
if message == 'tournament over':
print('tournament over')
sys.exit(0)
if message.startswith('match over'):
print('match over')
break
(public_buf, private_buf, *legal_actions) = message.split(' ')
should_act = len(legal_actions) > 0
if should_act:
num_actions += 1
print(legal_actions[-1])
else:
print('ponder')
if num_actions > 2:
raise RuntimeError |
'''
f we want to add a single element to an existing set, we can use the .add() operation.
It adds the element to the set and returns 'None'.
Example
>>> s = set('HackerRank')
>>> s.add('H')
>>> print s
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
>>> print s.add('HackerRank')
None
>>> print s
set(['a', 'c', 'e', 'HackerRank', 'H', 'k', 'n', 'r', 'R'])
The first line contains an integer N, the total number of country stamps.
The next N lines contains the name of the country where the stamp is from.
Output Format
Output the total number of distinct country stamps on a single line.
'''
n = int(input())
countries = set()
for i in range(n):
countries.add(input())
print(len(countries))
| """
f we want to add a single element to an existing set, we can use the .add() operation.
It adds the element to the set and returns 'None'.
Example
>>> s = set('HackerRank')
>>> s.add('H')
>>> print s
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
>>> print s.add('HackerRank')
None
>>> print s
set(['a', 'c', 'e', 'HackerRank', 'H', 'k', 'n', 'r', 'R'])
The first line contains an integer N, the total number of country stamps.
The next N lines contains the name of the country where the stamp is from.
Output Format
Output the total number of distinct country stamps on a single line.
"""
n = int(input())
countries = set()
for i in range(n):
countries.add(input())
print(len(countries)) |
class LeagueGame:
def __init__(self, data):
self.patch = data['patch']
self.win = data['win']
self.side = data['side']
self.opp = data['opp']
self.bans = data['bans']
self.vs_bans = data['vs_bans']
self.picks = data['picks']
self.vs_picks = data['vs_picks']
self.players = data['players']
class LeaguePlayer:
def __init__(self, n_games, n_wins, data):
self.n_games = n_games
self.n_wins = n_wins
self.K = data['K']
self.D = data['D']
self.A = data['A']
self.CS = data['CS']
self.CSM = data['CSM']
self.G = data['G']
self.GM = data['GM']
self.KPAR = data['KPAR']
self.KS = data['KS']
self.GS = data['GS']
class LeagueTeam:
def __init__(self, players, data):
self.players = players
self.region = data['region']
self.season = data['season']
self.WL = data['WL']
self.avg_gm_dur = data['avg_gm_dur']
self.most_banned_by = data['most_banned_by']
self.most_banned_vs = data['most_banned_vs']
self.economy = data['economy']
self.aggression = data['aggression']
self.objectives = data['objectives']
self.vision = data['vision']
| class Leaguegame:
def __init__(self, data):
self.patch = data['patch']
self.win = data['win']
self.side = data['side']
self.opp = data['opp']
self.bans = data['bans']
self.vs_bans = data['vs_bans']
self.picks = data['picks']
self.vs_picks = data['vs_picks']
self.players = data['players']
class Leagueplayer:
def __init__(self, n_games, n_wins, data):
self.n_games = n_games
self.n_wins = n_wins
self.K = data['K']
self.D = data['D']
self.A = data['A']
self.CS = data['CS']
self.CSM = data['CSM']
self.G = data['G']
self.GM = data['GM']
self.KPAR = data['KPAR']
self.KS = data['KS']
self.GS = data['GS']
class Leagueteam:
def __init__(self, players, data):
self.players = players
self.region = data['region']
self.season = data['season']
self.WL = data['WL']
self.avg_gm_dur = data['avg_gm_dur']
self.most_banned_by = data['most_banned_by']
self.most_banned_vs = data['most_banned_vs']
self.economy = data['economy']
self.aggression = data['aggression']
self.objectives = data['objectives']
self.vision = data['vision'] |
text1 = '''ABCDEF
GHIJKL
MNOPQRS
TUVWXYZ
'''
text2 = 'ABCDEF\
GHIJKL\
MNOPQRS\
TUVWXYZ'
text3 = 'ABCD\'EF\'GHIJKL'
text4 = 'ABCDEF\nGHIJKL\nMNOPQRS\nTUVWXYZ'
text5 = 'ABCDEF\fGHIJKL\fMNOPQRS\fTUVWXYZ'
print(text1)
print('-' * 25)
print(text2)
print('-' * 25)
print(text3)
print('-' * 25)
print(text4)
print('-' * 25)
print(text5) | text1 = 'ABCDEF\nGHIJKL\nMNOPQRS\nTUVWXYZ\n'
text2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
text3 = "ABCD'EF'GHIJKL"
text4 = 'ABCDEF\nGHIJKL\nMNOPQRS\nTUVWXYZ'
text5 = 'ABCDEF\x0cGHIJKL\x0cMNOPQRS\x0cTUVWXYZ'
print(text1)
print('-' * 25)
print(text2)
print('-' * 25)
print(text3)
print('-' * 25)
print(text4)
print('-' * 25)
print(text5) |
# unihernandez22
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math, brute force
n = int(input())
for a in range(n):
breaked = True
for b in range(-1000, 1000):
if a**5 - b**5 == n:
print(a, b)
break;
else:
breaked = False
if breaked:
break
| n = int(input())
for a in range(n):
breaked = True
for b in range(-1000, 1000):
if a ** 5 - b ** 5 == n:
print(a, b)
break
else:
breaked = False
if breaked:
break |
T = int(input())
P = int(input())
controle = 0 #Uso para guardar o valor maior que o limite
while P != 0:
P = int(input())
if P >= T:
controle = 1 #coloquei 1 so pra ser diferente de 0
if controle == 1:
print("ALARME")
else:
print("O Havai pode dormir tranquilo") | t = int(input())
p = int(input())
controle = 0
while P != 0:
p = int(input())
if P >= T:
controle = 1
if controle == 1:
print('ALARME')
else:
print('O Havai pode dormir tranquilo') |
__all__ = [
"aggregation",
"association",
"composition",
"connection",
"containment",
"dependency",
"includes",
"membership",
"ownership",
"responsibility",
"usage"
] | __all__ = ['aggregation', 'association', 'composition', 'connection', 'containment', 'dependency', 'includes', 'membership', 'ownership', 'responsibility', 'usage'] |
class AxisIndex(): #TODO: read this value from config file
LEFT_RIGHT=0
FORWARD_BACKWARDS=1
ROTATE=2
UP_DOWN=3
class ButtonIndex():
TRIGGER = 0
SIDE_BUTTON = 1
HOVERING = 2
EXIT = 10
class ThresHold():
SENDING_TIME = 0.5 | class Axisindex:
left_right = 0
forward_backwards = 1
rotate = 2
up_down = 3
class Buttonindex:
trigger = 0
side_button = 1
hovering = 2
exit = 10
class Threshold:
sending_time = 0.5 |
#!/Users/francischen/opt/anaconda3/bin/python
#pythons sorts are STABLE: order is the same as original in tie.
# sort: key, reverse
q = ['two','twelve','One','3']
#sort q, result being a modified list. nothing is returned
q.sort()
print(q)
q = ['two','twelve','One','3',"this has lots of t's"]
q.sort(reverse=True)
print(q)
def f(x):
return x.count('t')
q.sort(key = f)
print(q)
q = ['twelve','two','One','3',"this has lots of t's"]
q.sort(key=f)
print(q)
#Multiple sorts
q = ['twelve','two','One','3',"this has lots of t's"]
q.sort()
q.sort(key=f)
# sort based on 1,2,and then 3
# sort 3, then sort 2, then sort 1
print(q)
def complicated(x):
return(x.count('t'),len(x),x)
q = ['two','otw','wot','Z','t','tt','longer t']
q.sort(key=complicated)
print(q) | q = ['two', 'twelve', 'One', '3']
q.sort()
print(q)
q = ['two', 'twelve', 'One', '3', "this has lots of t's"]
q.sort(reverse=True)
print(q)
def f(x):
return x.count('t')
q.sort(key=f)
print(q)
q = ['twelve', 'two', 'One', '3', "this has lots of t's"]
q.sort(key=f)
print(q)
q = ['twelve', 'two', 'One', '3', "this has lots of t's"]
q.sort()
q.sort(key=f)
print(q)
def complicated(x):
return (x.count('t'), len(x), x)
q = ['two', 'otw', 'wot', 'Z', 't', 'tt', 'longer t']
q.sort(key=complicated)
print(q) |
# buildifier: disable=module-docstring
load(":native_tools_toolchain.bzl", "access_tool")
def get_cmake_data(ctx):
return _access_and_expect_label_copied("@rules_foreign_cc//tools/build_defs:cmake_toolchain", ctx, "cmake")
def get_ninja_data(ctx):
return _access_and_expect_label_copied("@rules_foreign_cc//tools/build_defs:ninja_toolchain", ctx, "ninja")
def get_make_data(ctx):
return _access_and_expect_label_copied("@rules_foreign_cc//tools/build_defs:make_toolchain", ctx, "make")
def _access_and_expect_label_copied(toolchain_type_, ctx, tool_name):
tool_data = access_tool(toolchain_type_, ctx, tool_name)
if tool_data.target:
# This could be made more efficient by changing the
# toolchain to provide the executable as a target
cmd_file = tool_data
for f in tool_data.target.files.to_list():
if f.path.endswith("/" + tool_data.path):
cmd_file = f
break
return struct(
deps = [tool_data.target],
# as the tool will be copied into tools directory
path = "$EXT_BUILD_ROOT/{}".format(cmd_file.path),
)
else:
return struct(
deps = [],
path = tool_data.path,
)
| load(':native_tools_toolchain.bzl', 'access_tool')
def get_cmake_data(ctx):
return _access_and_expect_label_copied('@rules_foreign_cc//tools/build_defs:cmake_toolchain', ctx, 'cmake')
def get_ninja_data(ctx):
return _access_and_expect_label_copied('@rules_foreign_cc//tools/build_defs:ninja_toolchain', ctx, 'ninja')
def get_make_data(ctx):
return _access_and_expect_label_copied('@rules_foreign_cc//tools/build_defs:make_toolchain', ctx, 'make')
def _access_and_expect_label_copied(toolchain_type_, ctx, tool_name):
tool_data = access_tool(toolchain_type_, ctx, tool_name)
if tool_data.target:
cmd_file = tool_data
for f in tool_data.target.files.to_list():
if f.path.endswith('/' + tool_data.path):
cmd_file = f
break
return struct(deps=[tool_data.target], path='$EXT_BUILD_ROOT/{}'.format(cmd_file.path))
else:
return struct(deps=[], path=tool_data.path) |
fname = input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
list = list()
f = open(fname)
count = 0
for line in f:
line = line.rstrip()
list = line.split()
if list == []: continue
elif list[0].lower() == 'from':
count += 1
print(list[1])
print("There were", count, "lines in the file with From as the first word") | fname = input('Enter file name: ')
if len(fname) < 1:
fname = 'mbox-short.txt'
list = list()
f = open(fname)
count = 0
for line in f:
line = line.rstrip()
list = line.split()
if list == []:
continue
elif list[0].lower() == 'from':
count += 1
print(list[1])
print('There were', count, 'lines in the file with From as the first word') |
class FollowupEvent:
def __init__(self, name, data=None):
self.name = name
self.data = data
class Response:
def __init__(self, text=None, followup_event=None):
self.speech = text
self.display_text = text
self.followup_event = followup_event
class UserInput:
def __init__(self, message: str, session_id: str, params: dict, text: str, action: str, intent: str):
self.message = message
self.session_id = session_id
self.params = params
self.raw = text
self.action = action
self.intent = intent
| class Followupevent:
def __init__(self, name, data=None):
self.name = name
self.data = data
class Response:
def __init__(self, text=None, followup_event=None):
self.speech = text
self.display_text = text
self.followup_event = followup_event
class Userinput:
def __init__(self, message: str, session_id: str, params: dict, text: str, action: str, intent: str):
self.message = message
self.session_id = session_id
self.params = params
self.raw = text
self.action = action
self.intent = intent |
def test_list_devices(client):
devices = client.devices()
assert len(devices) > 0
assert any(map(lambda device: device.serial == "emulator-5554", devices))
def test_list_devices_by_state(client):
devices = client.devices(client.BOOTLOADER)
assert len(devices) == 0
devices = client.devices(client.OFFLINE)
assert len(devices) == 0
devices = client.devices(client.DEVICE)
assert len(devices) == 1
def test_version(client):
version = client.version()
assert type(version) == int
assert version != 0
def test_list_forward(client, device):
client.killforward_all()
result = client.list_forward()
assert not result
device.forward("tcp:6000", "tcp:6000")
result = client.list_forward()
assert result["emulator-5554"]["tcp:6000"] == "tcp:6000"
client.killforward_all()
result = client.list_forward()
assert not result
def test_features(client):
assert client.features()
| def test_list_devices(client):
devices = client.devices()
assert len(devices) > 0
assert any(map(lambda device: device.serial == 'emulator-5554', devices))
def test_list_devices_by_state(client):
devices = client.devices(client.BOOTLOADER)
assert len(devices) == 0
devices = client.devices(client.OFFLINE)
assert len(devices) == 0
devices = client.devices(client.DEVICE)
assert len(devices) == 1
def test_version(client):
version = client.version()
assert type(version) == int
assert version != 0
def test_list_forward(client, device):
client.killforward_all()
result = client.list_forward()
assert not result
device.forward('tcp:6000', 'tcp:6000')
result = client.list_forward()
assert result['emulator-5554']['tcp:6000'] == 'tcp:6000'
client.killforward_all()
result = client.list_forward()
assert not result
def test_features(client):
assert client.features() |
def si(p,r,t):
n= (p+r+t)//3
return n
| def si(p, r, t):
n = (p + r + t) // 3
return n |
#!/usr/bin/env python3
# This is gonna be up to you. But basically I envisioned a system where you have a students in a classroom. Where the
# classroom only has information, like who is the teacher, how many students are there. And it's like an online class,
# so students don't know who their peers are, or who their teacher is, but can do things like study, and take test and
# stuff. Etc. But get used to how objects interact with each other and try to call stuff from other places while being
# commanded all in main():
class Student:
def __init__(self, name, laziness=5):
self.name = name
self.preparedness = 0
self._laziness = laziness
def takeTest(self, hardness):
# TODO: return a score that's 100 - difference between hardness and preparedness (score capped at 100)
return 0
def doHomework(self):
# TODO: return a score of either 0 or 100 depending on how lazy they are. Implementation is up to you.
return 0
def study(self):
# TODO: increment preparedness by a random number between 1-10 (prerparedness capped at 100)
pass
class Teacher:
def __init__(self, name):
self.name = name
self.classroom = None
self.test_grades = {}
self.homework_grades = {}
def administerTest(self, students, hardness):
# TODO: Given a hardness of a test and list of students. Make each student take test and log their grades
pass
def giveHomework(self, students):
# TODO: Given homework to student and log in their grades
pass
def giveGrades(self, students):
# TODO: Given all the test scores and homework score in each student, give 30% to HW and 70% to test.
# TODO: Return list of passed students and remove them from classroom. Clear grades for all remaining students
pass
class ClassRoom:
def __init__(self):
self.class_size_limit = 10
self.students = {}
self.teacher = None
def addStudent(self, student):
# TODO: add student to class. Print something if they try to add the same student or go over the limit
pass
def assignTeacherToClass(self, teacher):
# TODO: Assign teacher, also prompt user if they want to switch teacher if one already assigned or same teacher
pass
def getStudents(self):
# TODO: return a list of students
return
if __name__ == '__main__':
classroom = ClassRoom()
teacher = Teacher('Doctor Jones')
mike = Student('Mike')
sally = Student('Sally', laziness=1)
lebron = Student('Lebron', laziness=10)
# TODO: Assign a teacher to the classroom and add the students to the classroom. Then make the students study
# TODO: Make Students to homework, etc, exams, then pass or fail them, etc. Play around with it.
| class Student:
def __init__(self, name, laziness=5):
self.name = name
self.preparedness = 0
self._laziness = laziness
def take_test(self, hardness):
return 0
def do_homework(self):
return 0
def study(self):
pass
class Teacher:
def __init__(self, name):
self.name = name
self.classroom = None
self.test_grades = {}
self.homework_grades = {}
def administer_test(self, students, hardness):
pass
def give_homework(self, students):
pass
def give_grades(self, students):
pass
class Classroom:
def __init__(self):
self.class_size_limit = 10
self.students = {}
self.teacher = None
def add_student(self, student):
pass
def assign_teacher_to_class(self, teacher):
pass
def get_students(self):
return
if __name__ == '__main__':
classroom = class_room()
teacher = teacher('Doctor Jones')
mike = student('Mike')
sally = student('Sally', laziness=1)
lebron = student('Lebron', laziness=10) |
# https://github.com/ArtemNikolaev/gb-hw/issues/24
def multiple_of_20_21():
return (i for i in range(20, 241) if i % 20 == 0 or i % 21 == 0)
print(list(multiple_of_20_21()))
| def multiple_of_20_21():
return (i for i in range(20, 241) if i % 20 == 0 or i % 21 == 0)
print(list(multiple_of_20_21())) |
def cc_resources(name, data):
out_inc = name + ".inc"
cmd = ('echo "static const struct FileToc kPackedFiles[] = {" > $(@); \n' +
"for j in $(SRCS); do\n" +
' echo "{\\"$$(basename "$${j}")\\"," >> $(@);\n' +
' echo "R\\"filecontent($$(< $${j}))filecontent\\"" >> $(@);\n' +
' echo "}," >> $(@);\n' +
"done &&\n" +
'echo "{nullptr, nullptr}};" >> $(@)')
if len(data) == 0:
fail("Empty `data` attribute in `%s`" % name)
native.genrule(
name = name,
outs = [out_inc],
srcs = data,
cmd = cmd,
)
# Returns the generated files directory root.
#
# Note: workaround for https://github.com/bazelbuild/bazel/issues/4463.
def gendir():
if native.repository_name() == "@":
return "$(GENDIR)"
return "$(GENDIR)/external/" + native.repository_name().lstrip("@")
| def cc_resources(name, data):
out_inc = name + '.inc'
cmd = 'echo "static const struct FileToc kPackedFiles[] = {" > $(@); \n' + 'for j in $(SRCS); do\n' + ' echo "{\\"$$(basename "$${j}")\\"," >> $(@);\n' + ' echo "R\\"filecontent($$(< $${j}))filecontent\\"" >> $(@);\n' + ' echo "}," >> $(@);\n' + 'done &&\n' + 'echo "{nullptr, nullptr}};" >> $(@)'
if len(data) == 0:
fail('Empty `data` attribute in `%s`' % name)
native.genrule(name=name, outs=[out_inc], srcs=data, cmd=cmd)
def gendir():
if native.repository_name() == '@':
return '$(GENDIR)'
return '$(GENDIR)/external/' + native.repository_name().lstrip('@') |
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def say_hello(self):
print('Hello, my name is {} and I am {} years old'.format(self.name, self.age))
if __name__ == '__main__':
person = Person('David', 34)
print('Age: {}'.format(person.age))
person.say_hello() | class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def say_hello(self):
print('Hello, my name is {} and I am {} years old'.format(self.name, self.age))
if __name__ == '__main__':
person = person('David', 34)
print('Age: {}'.format(person.age))
person.say_hello() |
num= int (input("enter number of rows="))
for i in range (1,num+1):
for j in range(1,num-i+1):
print (" ",end="")
for j in range(2 and 9):
print("2","9")
for i in range(1, 6):
for j in range(1, 10):
if i==5 or i+j==5 or j-i==4:
print("*", end="")
else:
print(end=" ")
print()
| num = int(input('enter number of rows='))
for i in range(1, num + 1):
for j in range(1, num - i + 1):
print(' ', end='')
for j in range(2 and 9):
print('2', '9')
for i in range(1, 6):
for j in range(1, 10):
if i == 5 or i + j == 5 or j - i == 4:
print('*', end='')
else:
print(end=' ')
print() |
'''
Problem:-
Given a string s, find the longest palindromic substring in s.
You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab"
Note: "aba" is also a valid answer.
'''
class Solution:
def longestPalindrome(self, s: str) -> str:
res = ""
resLen = 0
for i in range(len(s)):
# odd length
l, r = i, i
while l >= 0 and r < len(s) and s[l] == s[r]:
if (r - l + 1) > resLen:
res = s[l:r + 1]
resLen = r - l + 1
l -= 1
r += 1
# even length
l, r = i, i + 1
while l >= 0 and r < len(s) and s[l] == s[r]:
if (r - l + 1) > resLen:
res = s[l:r + 1]
resLen = r - l + 1
l -= 1
r += 1
return res | """
Problem:-
Given a string s, find the longest palindromic substring in s.
You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab"
Note: "aba" is also a valid answer.
"""
class Solution:
def longest_palindrome(self, s: str) -> str:
res = ''
res_len = 0
for i in range(len(s)):
(l, r) = (i, i)
while l >= 0 and r < len(s) and (s[l] == s[r]):
if r - l + 1 > resLen:
res = s[l:r + 1]
res_len = r - l + 1
l -= 1
r += 1
(l, r) = (i, i + 1)
while l >= 0 and r < len(s) and (s[l] == s[r]):
if r - l + 1 > resLen:
res = s[l:r + 1]
res_len = r - l + 1
l -= 1
r += 1
return res |
# 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 minDiffInBST(self, root: Optional[TreeNode]) -> int:
output=[]
stack=[root]
while(stack):
cur = stack.pop(0)
output.append(cur.val)
if cur.left:
stack.append(cur.left)
if cur.right:
stack.append(cur.right)
sorted_output=sorted(output)
diff = sorted_output[1]-sorted_output[0]
for i in range(2,len(sorted_output)):
if sorted_output[i]-sorted_output[i-1]<diff:
diff=sorted_output[i]-sorted_output[i-1]
return diff | class Solution:
def min_diff_in_bst(self, root: Optional[TreeNode]) -> int:
output = []
stack = [root]
while stack:
cur = stack.pop(0)
output.append(cur.val)
if cur.left:
stack.append(cur.left)
if cur.right:
stack.append(cur.right)
sorted_output = sorted(output)
diff = sorted_output[1] - sorted_output[0]
for i in range(2, len(sorted_output)):
if sorted_output[i] - sorted_output[i - 1] < diff:
diff = sorted_output[i] - sorted_output[i - 1]
return diff |
PREFIX = "/video/tvkultura"
NAME = "TVKultura.Ru"
ICON = "tvkultura.png"
ART = "tvkultura.jpg"
BASE_URL = "https://tvkultura.ru/"
BRAND_URL = BASE_URL+"brand/"
# Channel initialization
def Start():
ObjectContainer.title1 = NAME
HTTP.Headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0'
# Main menu
@handler(PREFIX, NAME, thumb=ICON, art=ART)
def MainMenu():
brands = SharedCodeService.vgtrk.brand_menu(BRAND_URL)
oc = ObjectContainer(title1=NAME)
for brand in brands.list:
oc.add(DirectoryObject(
key=Callback(BrandMenu, url=brand.href),
title=brand.title,
summary=brand.about + ("\n\n[" + brand.schedule + "]" if brand.schedule else ''),
thumb=Resource.ContentsOfURLWithFallback(url=brand.big_thumb, fallback=brand.small_thumb),
))
return oc
@route(PREFIX+'/brand')
def BrandMenu(url):
brand = SharedCodeService.vgtrk.brand_detail(url)
if brand.video_href:
return VideoViewTypePictureMenu(brand.video_href)
@route(PREFIX+'/video/viewtype-picture')
def VideoViewTypePictureMenu(url, page=1, referer=None, page_title=None, next_title=None):
videos = SharedCodeService.vgtrk.video_menu(url, page=page, referer=referer, page_title=page_title, next_title=next_title)
video_items = videos.view_type('picture')
oc = ObjectContainer(title1=videos.title)
for video in video_items.list:
oc.add(MetadataRecordForItem(video))
next_page = video_items.next_page
if next_page is not None:
oc.add(NextPageObject(
key=Callback(
VideoViewTypePictureMenu,
url=next_page.href,
page=int(page) + 1,
referer=url if referer is None else referer,
page_title=videos.title,
next_title=next_page.title
),
title=next_page.title,
))
return oc
@route(PREFIX+'/video/viewtype-picture/children')
def VideoViewTypePictureChildren(url, referer=None, page_title=None):
video_items = SharedCodeService.vgtrk.video_children(url, referer=referer, page_title=page_title)
oc = ObjectContainer(title1=page_title)
for video in video_items.list:
oc.add(EpisodeObjectForItem(video))
return oc
def MetadataRecordForItem(video):
if video.has_children:
return DirectoryObject(
key=Callback(VideoViewTypePictureChildren, url=video.ajaxurl, referer=video.href, page_title=video.title),
title=video.title,
thumb=video.thumb,
)
return EpisodeObjectForItem(video)
def EpisodeObjectForItem(video):
callback = Callback(MetadataObjectForURL, href=video.href, thumb=video.thumb, title=video.title)
return EpisodeObject(
key=callback,
rating_key=video.href,
title=video.title,
thumb=video.thumb,
items=MediaObjectsForURL(callback),
)
def MetadataObjectForURL(href, thumb, title, **kwargs):
# This is a sort-of replacement for the similar method from the URL Services, just different parameters list.
page = SharedCodeService.vgtrk.video_page(href)
video_clip_object = VideoClipObject(
key=Callback(MetadataObjectForURL, href=href, thumb=thumb, title=title, **kwargs),
rating_key=href,
title=title,
thumb=thumb,
summary=page.full_text,
items=MediaObjectsForURL(
Callback(PlayVideo, href=href)
),
**kwargs
)
return ObjectContainer(
no_cache=True,
objects=[video_clip_object]
)
def MediaObjectsForURL(callback):
# This is a sort-of replacement for the similar method from the URL Services, just different parameters list.
return [
MediaObject(
container=Container.MP4,
video_codec=VideoCodec.H264,
audio_codec=AudioCodec.AAC,
parts=[
PartObject(key=callback)
]
)
]
@indirect
def PlayVideo(href):
page = SharedCodeService.vgtrk.video_page(href)
json = JSON.ObjectFromURL(page.datavideo_href, headers={'Referer': page.video_iframe_href})
medialist = json['data']['playlist']['medialist']
if len(medialist) > 1:
raise RuntimeWarning('More than one media found, each should have been set as a PartObject!')
quality = str(json['data']['playlist']['priority_quality'])
transport = 'http'
if 'sources' not in medialist[0] and medialist[0]['errors']:
raise Ex.PlexNonCriticalError(2005, medialist[0]['errors'])
video_url = medialist[0]['sources'][transport][quality]
Log('Redirecting to video URL: %s' % video_url)
return IndirectResponse(
VideoClipObject,
key=video_url,
http_headers={'Referer': page.video_iframe_href},
metadata_kwargs={'summary': page.full_text}
)
| prefix = '/video/tvkultura'
name = 'TVKultura.Ru'
icon = 'tvkultura.png'
art = 'tvkultura.jpg'
base_url = 'https://tvkultura.ru/'
brand_url = BASE_URL + 'brand/'
def start():
ObjectContainer.title1 = NAME
HTTP.Headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0'
@handler(PREFIX, NAME, thumb=ICON, art=ART)
def main_menu():
brands = SharedCodeService.vgtrk.brand_menu(BRAND_URL)
oc = object_container(title1=NAME)
for brand in brands.list:
oc.add(directory_object(key=callback(BrandMenu, url=brand.href), title=brand.title, summary=brand.about + ('\n\n[' + brand.schedule + ']' if brand.schedule else ''), thumb=Resource.ContentsOfURLWithFallback(url=brand.big_thumb, fallback=brand.small_thumb)))
return oc
@route(PREFIX + '/brand')
def brand_menu(url):
brand = SharedCodeService.vgtrk.brand_detail(url)
if brand.video_href:
return video_view_type_picture_menu(brand.video_href)
@route(PREFIX + '/video/viewtype-picture')
def video_view_type_picture_menu(url, page=1, referer=None, page_title=None, next_title=None):
videos = SharedCodeService.vgtrk.video_menu(url, page=page, referer=referer, page_title=page_title, next_title=next_title)
video_items = videos.view_type('picture')
oc = object_container(title1=videos.title)
for video in video_items.list:
oc.add(metadata_record_for_item(video))
next_page = video_items.next_page
if next_page is not None:
oc.add(next_page_object(key=callback(VideoViewTypePictureMenu, url=next_page.href, page=int(page) + 1, referer=url if referer is None else referer, page_title=videos.title, next_title=next_page.title), title=next_page.title))
return oc
@route(PREFIX + '/video/viewtype-picture/children')
def video_view_type_picture_children(url, referer=None, page_title=None):
video_items = SharedCodeService.vgtrk.video_children(url, referer=referer, page_title=page_title)
oc = object_container(title1=page_title)
for video in video_items.list:
oc.add(episode_object_for_item(video))
return oc
def metadata_record_for_item(video):
if video.has_children:
return directory_object(key=callback(VideoViewTypePictureChildren, url=video.ajaxurl, referer=video.href, page_title=video.title), title=video.title, thumb=video.thumb)
return episode_object_for_item(video)
def episode_object_for_item(video):
callback = callback(MetadataObjectForURL, href=video.href, thumb=video.thumb, title=video.title)
return episode_object(key=callback, rating_key=video.href, title=video.title, thumb=video.thumb, items=media_objects_for_url(callback))
def metadata_object_for_url(href, thumb, title, **kwargs):
page = SharedCodeService.vgtrk.video_page(href)
video_clip_object = video_clip_object(key=callback(MetadataObjectForURL, href=href, thumb=thumb, title=title, **kwargs), rating_key=href, title=title, thumb=thumb, summary=page.full_text, items=media_objects_for_url(callback(PlayVideo, href=href)), **kwargs)
return object_container(no_cache=True, objects=[video_clip_object])
def media_objects_for_url(callback):
return [media_object(container=Container.MP4, video_codec=VideoCodec.H264, audio_codec=AudioCodec.AAC, parts=[part_object(key=callback)])]
@indirect
def play_video(href):
page = SharedCodeService.vgtrk.video_page(href)
json = JSON.ObjectFromURL(page.datavideo_href, headers={'Referer': page.video_iframe_href})
medialist = json['data']['playlist']['medialist']
if len(medialist) > 1:
raise runtime_warning('More than one media found, each should have been set as a PartObject!')
quality = str(json['data']['playlist']['priority_quality'])
transport = 'http'
if 'sources' not in medialist[0] and medialist[0]['errors']:
raise Ex.PlexNonCriticalError(2005, medialist[0]['errors'])
video_url = medialist[0]['sources'][transport][quality]
log('Redirecting to video URL: %s' % video_url)
return indirect_response(VideoClipObject, key=video_url, http_headers={'Referer': page.video_iframe_href}, metadata_kwargs={'summary': page.full_text}) |
# Tuples
coordinates = (4, 5) # Cant be changed or modified
print(coordinates[1])
# coordinates[1] = 10
# print(coordinates[1])
| coordinates = (4, 5)
print(coordinates[1]) |
# ###########################################################
# ## generate menu
# ###########################################################
_a = request.application
_c = request.controller
_f = request.function
response.title = '%s %s' % (_f, '/'.join(request.args))
response.subtitle = 'admin'
response.menu = [(T('site'), _f == 'site', URL(_a,'default','site'))]
if request.args:
_t = request.args[0]
response.menu.append((T('edit'), _c == 'default' and _f == 'design',
URL(_a,'default','design',args=_t)))
response.menu.append((T('about'), _c == 'default' and _f == 'about',
URL(_a,'default','about',args=_t)))
response.menu.append((T('errors'), _c == 'default' and _f == 'errors',
URL(_a,'default','errors',args=_t)))
response.menu.append((T('versioning'),
_c == 'mercurial' and _f == 'commit',
URL(_a,'mercurial','commit',args=_t)))
if not session.authorized:
response.menu = [(T('login'), True, '')]
else:
response.menu.append((T('logout'), False,
URL(_a,'default',f='logout')))
response.menu.append((T('help'), False, URL('examples','default','index')))
| _a = request.application
_c = request.controller
_f = request.function
response.title = '%s %s' % (_f, '/'.join(request.args))
response.subtitle = 'admin'
response.menu = [(t('site'), _f == 'site', url(_a, 'default', 'site'))]
if request.args:
_t = request.args[0]
response.menu.append((t('edit'), _c == 'default' and _f == 'design', url(_a, 'default', 'design', args=_t)))
response.menu.append((t('about'), _c == 'default' and _f == 'about', url(_a, 'default', 'about', args=_t)))
response.menu.append((t('errors'), _c == 'default' and _f == 'errors', url(_a, 'default', 'errors', args=_t)))
response.menu.append((t('versioning'), _c == 'mercurial' and _f == 'commit', url(_a, 'mercurial', 'commit', args=_t)))
if not session.authorized:
response.menu = [(t('login'), True, '')]
else:
response.menu.append((t('logout'), False, url(_a, 'default', f='logout')))
response.menu.append((t('help'), False, url('examples', 'default', 'index'))) |
tempratures = [10,-20, -289, 100]
def c_to_f(c):
if c<-273.15:
return ""
return c* 9/5 +32
def writeToFile(input):
with open("output.txt","a") as file:
file.write(input)
for temp in tempratures:
writeToFile(str(c_to_f(temp)))
| tempratures = [10, -20, -289, 100]
def c_to_f(c):
if c < -273.15:
return ''
return c * 9 / 5 + 32
def write_to_file(input):
with open('output.txt', 'a') as file:
file.write(input)
for temp in tempratures:
write_to_file(str(c_to_f(temp))) |
class VoiceClient(object):
def __init__(self, base_obj):
self.base_obj = base_obj
self.api_resource = "/voice/v1/{}"
def create(self,
direction,
to,
caller_id,
execution_logic,
reference_logic='',
country_iso2='us',
technology='pstn',
status_callback_uri=''):
api_resource = self.api_resource.format(direction)
return self.base_obj.post(api_resource=api_resource, direction=direction, to=to,
caller_id=caller_id, execution_logic=execution_logic, reference_logic=reference_logic,
country_iso2=country_iso2, technology=technology, status_callback_uri=status_callback_uri)
def update(self, reference_id, execution_logic):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.put(api_resource=api_resource,
execution_logic=execution_logic)
def delete(self, reference_id):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.delete(api_resource=api_resource)
def get_status(self, reference_id):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.get(api_resource=api_resource)
| class Voiceclient(object):
def __init__(self, base_obj):
self.base_obj = base_obj
self.api_resource = '/voice/v1/{}'
def create(self, direction, to, caller_id, execution_logic, reference_logic='', country_iso2='us', technology='pstn', status_callback_uri=''):
api_resource = self.api_resource.format(direction)
return self.base_obj.post(api_resource=api_resource, direction=direction, to=to, caller_id=caller_id, execution_logic=execution_logic, reference_logic=reference_logic, country_iso2=country_iso2, technology=technology, status_callback_uri=status_callback_uri)
def update(self, reference_id, execution_logic):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.put(api_resource=api_resource, execution_logic=execution_logic)
def delete(self, reference_id):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.delete(api_resource=api_resource)
def get_status(self, reference_id):
api_resource = self.api_resource.format(reference_id)
return self.base_obj.get(api_resource=api_resource) |
expected_output = {
"ospf-statistics-information": {
"ospf-statistics": {
"dbds-retransmit": "203656",
"dbds-retransmit-5seconds": "0",
"flood-queue-depth": "0",
"lsas-acknowledged": "225554974",
"lsas-acknowledged-5seconds": "0",
"lsas-flooded": "66582263",
"lsas-flooded-5seconds": "0",
"lsas-high-prio-flooded": "375568998",
"lsas-high-prio-flooded-5seconds": "0",
"lsas-nbr-transmit": "3423982",
"lsas-nbr-transmit-5seconds": "0",
"lsas-requested": "3517",
"lsas-requested-5seconds": "0",
"lsas-retransmit": "8064643",
"lsas-retransmit-5seconds": "0",
"ospf-errors": {
"subnet-mismatch-error": "12"
},
"packet-statistics": [
{
"ospf-packet-type": "Hello",
"packets-received": "5703920",
"packets-received-5seconds": "3",
"packets-sent": "6202169",
"packets-sent-5seconds": "0"
},
{
"ospf-packet-type": "DbD",
"packets-received": "185459",
"packets-received-5seconds": "0",
"packets-sent": "212983",
"packets-sent-5seconds": "0"
},
{
"ospf-packet-type": "LSReq",
"packets-received": "208",
"packets-received-5seconds": "0",
"packets-sent": "214",
"packets-sent-5seconds": "0"
},
{
"ospf-packet-type": "LSUpdate",
"packets-received": "16742100",
"packets-received-5seconds": "0",
"packets-sent": "15671465",
"packets-sent-5seconds": "0"
},
{
"ospf-packet-type": "LSAck",
"packets-received": "2964236",
"packets-received-5seconds": "0",
"packets-sent": "5229203",
"packets-sent-5seconds": "0"
}
],
"total-database-summaries": "0",
"total-linkstate-request": "0",
"total-retransmits": "0"
}
}
}
| expected_output = {'ospf-statistics-information': {'ospf-statistics': {'dbds-retransmit': '203656', 'dbds-retransmit-5seconds': '0', 'flood-queue-depth': '0', 'lsas-acknowledged': '225554974', 'lsas-acknowledged-5seconds': '0', 'lsas-flooded': '66582263', 'lsas-flooded-5seconds': '0', 'lsas-high-prio-flooded': '375568998', 'lsas-high-prio-flooded-5seconds': '0', 'lsas-nbr-transmit': '3423982', 'lsas-nbr-transmit-5seconds': '0', 'lsas-requested': '3517', 'lsas-requested-5seconds': '0', 'lsas-retransmit': '8064643', 'lsas-retransmit-5seconds': '0', 'ospf-errors': {'subnet-mismatch-error': '12'}, 'packet-statistics': [{'ospf-packet-type': 'Hello', 'packets-received': '5703920', 'packets-received-5seconds': '3', 'packets-sent': '6202169', 'packets-sent-5seconds': '0'}, {'ospf-packet-type': 'DbD', 'packets-received': '185459', 'packets-received-5seconds': '0', 'packets-sent': '212983', 'packets-sent-5seconds': '0'}, {'ospf-packet-type': 'LSReq', 'packets-received': '208', 'packets-received-5seconds': '0', 'packets-sent': '214', 'packets-sent-5seconds': '0'}, {'ospf-packet-type': 'LSUpdate', 'packets-received': '16742100', 'packets-received-5seconds': '0', 'packets-sent': '15671465', 'packets-sent-5seconds': '0'}, {'ospf-packet-type': 'LSAck', 'packets-received': '2964236', 'packets-received-5seconds': '0', 'packets-sent': '5229203', 'packets-sent-5seconds': '0'}], 'total-database-summaries': '0', 'total-linkstate-request': '0', 'total-retransmits': '0'}}} |
N = int(input())
S = input()
if N % 2 == 1:
print('No')
exit()
if S[:N // 2] == S[N // 2:]:
print('Yes')
else:
print('No')
| n = int(input())
s = input()
if N % 2 == 1:
print('No')
exit()
if S[:N // 2] == S[N // 2:]:
print('Yes')
else:
print('No') |
#!/usr/bin/env python
#
# Cloudlet Infrastructure for Mobile Computing
# - Task Assistance
#
# Author: Zhuo Chen <[email protected]>
#
# Copyright (C) 2011-2013 Carnegie Mellon University
# 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.
#
# If True, configurations are set to process video stream in real-time (use
# with lego_server.py)
# If False, configurations are set to process one independent image (use with
# img.py)
IS_STREAMING = True
RECOGNIZE_ONLY = False
# Port for communication between proxy and task server
TASK_SERVER_PORT = 6090
BEST_ENGINE = "LEGO_FAST"
CHECK_ALGORITHM = "table"
CHECK_LAST_TH = 1
# Port for communication between master and workder proxies
MASTER_SERVER_PORT = 6091
# Whether or not to save the displayed image in a temporary directory
SAVE_IMAGE = False
# Convert all incoming frames to a fixed size to ease processing
IMAGE_HEIGHT = 360
IMAGE_WIDTH = 640
BLUR_KERNEL_SIZE = int(IMAGE_WIDTH // 16 + 1)
# Display
DISPLAY_MAX_PIXEL = 640
DISPLAY_SCALE = 5
DISPLAY_LIST_ALL = ['test', 'input', 'DoB', 'mask_black', 'mask_black_dots',
'board', 'board_border_line', 'board_edge', 'board_grey',
'board_mask_black', 'board_mask_black_dots', 'board_DoB',
'edge_inv',
'edge',
'board_n0', 'board_n1', 'board_n2', 'board_n3', 'board_n4',
'board_n5', 'board_n6',
'lego_u_edge_S', 'lego_u_edge_norm_L', 'lego_u_dots_L',
'lego_full', 'lego', 'lego_only_color',
'lego_correct', 'lego_rect', 'lego_cropped', 'lego_color',
'plot_line', 'lego_syn',
'guidance']
DISPLAY_LIST_TEST = ['input', 'board', 'lego_u_edge_S', 'lego_u_edge_norm_L',
'lego_u_dots_L', 'lego_syn']
DISPLAY_LIST_STREAM = ['input', 'lego_syn']
# DISPLAY_LIST_TASK = ['input', 'board', 'lego_syn', 'guidance']
DISPLAY_LIST_TASK = []
if not IS_STREAMING:
DISPLAY_LIST = DISPLAY_LIST_TEST
else:
if RECOGNIZE_ONLY:
DISPLAY_LIST = DISPLAY_LIST_STREAM
else:
DISPLAY_LIST = DISPLAY_LIST_TASK
DISPLAY_WAIT_TIME = 1 if IS_STREAMING else 500
## Black dots
BD_COUNT_N_ROW = 9
BD_COUNT_N_COL = 16
BD_BLOCK_HEIGHT = IMAGE_HEIGHT // BD_COUNT_N_ROW
BD_BLOCK_WIDTH = IMAGE_WIDTH // BD_COUNT_N_COL
BD_BLOCK_SPAN = max(BD_BLOCK_HEIGHT, BD_BLOCK_WIDTH)
BD_BLOCK_AREA = BD_BLOCK_HEIGHT * BD_BLOCK_WIDTH
BD_COUNT_THRESH = 25
BD_MAX_PERI = (IMAGE_HEIGHT + IMAGE_HEIGHT) // 40
BD_MAX_SPAN = int(BD_MAX_PERI / 4.0 + 0.5)
# Two ways to check black dot size:
# 'simple': check contour length and area
# 'complete": check x & y max span also
CHECK_BD_SIZE = 'simple'
## Color detection
# H: hue, S: saturation, V: value (which means brightness)
# L: lower_bound, U: upper_bound, TH: threshold
# TODO:
BLUE = {'H': 110, 'S_L': 100, 'B_TH': 110} # H: 108
YELLOW = {'H': 30, 'S_L': 100, 'B_TH': 170} # H: 25 B_TH: 180
GREEN = {'H': 70, 'S_L': 100, 'B_TH': 60} # H: 80 B_TH: 75
RED = {'H': 0, 'S_L': 100, 'B_TH': 130}
BLACK = {'S_U': 70, 'V_U': 60}
# WHITE = {'S_U' : 60, 'B_L' : 101, 'B_TH' : 160} # this includes side white,
# too
WHITE = {'S_U': 60, 'V_L': 150}
BD_DOB_MIN_V = 30
# If using a labels to represent color, this is the right color: 0 means
# nothing (background) and 7 means unsure
COLOR_ORDER = ['nothing', 'white', 'green', 'yellow', 'red', 'blue', 'black',
'unsure']
## Board
BOARD_MIN_AREA = BD_BLOCK_AREA * 7
BOARD_MIN_LINE_LENGTH = BD_BLOCK_SPAN
BOARD_MIN_VOTE = BD_BLOCK_SPAN // 2
# Once board is detected, convert it to a perspective-corrected standard size
# for further processing
BOARD_RECONSTRUCT_HEIGHT = 155 * 1
BOARD_RECONSTRUCT_WIDTH = 270 * 1
BOARD_BD_MAX_PERI = (BOARD_RECONSTRUCT_HEIGHT + BOARD_RECONSTRUCT_WIDTH) // 30
BOARD_BD_MAX_SPAN = int(BOARD_BD_MAX_PERI / 4.0 + 1.5)
BOARD_RECONSTRUCT_AREA = BOARD_RECONSTRUCT_HEIGHT * BOARD_RECONSTRUCT_WIDTH
BOARD_RECONSTRUCT_PERI = (
BOARD_RECONSTRUCT_HEIGHT +
BOARD_RECONSTRUCT_WIDTH) * 2
BOARD_RECONSTRUCT_CENTER = (
BOARD_RECONSTRUCT_HEIGHT // 2, BOARD_RECONSTRUCT_WIDTH // 2)
## Bricks
BRICK_HEIGHT = BOARD_RECONSTRUCT_HEIGHT / 12.25 # magic number
BRICK_WIDTH = BOARD_RECONSTRUCT_WIDTH / 26.2 # magic number
BRICK_HEIGHT_THICKNESS_RATIO = 15 / 12.25 # magic number
BLOCK_DETECTION_OFFSET = 2
BRICK_MIN_BM_RATIO = .85
## Optimizations
# If True, performs a second step fine-grained board detection algorithm.
# Depending on the other algorithms, this is usually not needed.
OPT_FINE_BOARD = False
# Treat background pixels differently
OPT_NOTHING = False
BM_WINDOW_MIN_TIME = 0.1
BM_WINDOW_MIN_COUNT = 1
# The percentage of right pixels in each block must be higher than this
# threshold
WORST_RATIO_BLOCK_THRESH = 0.6
# If True, do perspective correction first, then color normalization
# If False, do perspective correction after color has been normalized
# Not used anymore...
PERS_NORM = True
## Consts
ACTION_ADD = 0
ACTION_REMOVE = 1
ACTION_TARGET = 2
ACTION_MOVE = 3
DIRECTION_NONE = 0
DIRECTION_UP = 1
DIRECTION_DOWN = 2
GOOD_WORDS = ["Excellent. ", "Great. ", "Good job. ", "Wonderful. "]
def setup(is_streaming):
global IS_STREAMING, DISPLAY_LIST, DISPLAY_WAIT_TIME, SAVE_IMAGE
IS_STREAMING = is_streaming
if not IS_STREAMING:
DISPLAY_LIST = DISPLAY_LIST_TEST
else:
if RECOGNIZE_ONLY:
DISPLAY_LIST = DISPLAY_LIST_STREAM
else:
DISPLAY_LIST = DISPLAY_LIST_TASK
DISPLAY_WAIT_TIME = 1 if IS_STREAMING else 500
SAVE_IMAGE = not IS_STREAMING
| is_streaming = True
recognize_only = False
task_server_port = 6090
best_engine = 'LEGO_FAST'
check_algorithm = 'table'
check_last_th = 1
master_server_port = 6091
save_image = False
image_height = 360
image_width = 640
blur_kernel_size = int(IMAGE_WIDTH // 16 + 1)
display_max_pixel = 640
display_scale = 5
display_list_all = ['test', 'input', 'DoB', 'mask_black', 'mask_black_dots', 'board', 'board_border_line', 'board_edge', 'board_grey', 'board_mask_black', 'board_mask_black_dots', 'board_DoB', 'edge_inv', 'edge', 'board_n0', 'board_n1', 'board_n2', 'board_n3', 'board_n4', 'board_n5', 'board_n6', 'lego_u_edge_S', 'lego_u_edge_norm_L', 'lego_u_dots_L', 'lego_full', 'lego', 'lego_only_color', 'lego_correct', 'lego_rect', 'lego_cropped', 'lego_color', 'plot_line', 'lego_syn', 'guidance']
display_list_test = ['input', 'board', 'lego_u_edge_S', 'lego_u_edge_norm_L', 'lego_u_dots_L', 'lego_syn']
display_list_stream = ['input', 'lego_syn']
display_list_task = []
if not IS_STREAMING:
display_list = DISPLAY_LIST_TEST
elif RECOGNIZE_ONLY:
display_list = DISPLAY_LIST_STREAM
else:
display_list = DISPLAY_LIST_TASK
display_wait_time = 1 if IS_STREAMING else 500
bd_count_n_row = 9
bd_count_n_col = 16
bd_block_height = IMAGE_HEIGHT // BD_COUNT_N_ROW
bd_block_width = IMAGE_WIDTH // BD_COUNT_N_COL
bd_block_span = max(BD_BLOCK_HEIGHT, BD_BLOCK_WIDTH)
bd_block_area = BD_BLOCK_HEIGHT * BD_BLOCK_WIDTH
bd_count_thresh = 25
bd_max_peri = (IMAGE_HEIGHT + IMAGE_HEIGHT) // 40
bd_max_span = int(BD_MAX_PERI / 4.0 + 0.5)
check_bd_size = 'simple'
blue = {'H': 110, 'S_L': 100, 'B_TH': 110}
yellow = {'H': 30, 'S_L': 100, 'B_TH': 170}
green = {'H': 70, 'S_L': 100, 'B_TH': 60}
red = {'H': 0, 'S_L': 100, 'B_TH': 130}
black = {'S_U': 70, 'V_U': 60}
white = {'S_U': 60, 'V_L': 150}
bd_dob_min_v = 30
color_order = ['nothing', 'white', 'green', 'yellow', 'red', 'blue', 'black', 'unsure']
board_min_area = BD_BLOCK_AREA * 7
board_min_line_length = BD_BLOCK_SPAN
board_min_vote = BD_BLOCK_SPAN // 2
board_reconstruct_height = 155 * 1
board_reconstruct_width = 270 * 1
board_bd_max_peri = (BOARD_RECONSTRUCT_HEIGHT + BOARD_RECONSTRUCT_WIDTH) // 30
board_bd_max_span = int(BOARD_BD_MAX_PERI / 4.0 + 1.5)
board_reconstruct_area = BOARD_RECONSTRUCT_HEIGHT * BOARD_RECONSTRUCT_WIDTH
board_reconstruct_peri = (BOARD_RECONSTRUCT_HEIGHT + BOARD_RECONSTRUCT_WIDTH) * 2
board_reconstruct_center = (BOARD_RECONSTRUCT_HEIGHT // 2, BOARD_RECONSTRUCT_WIDTH // 2)
brick_height = BOARD_RECONSTRUCT_HEIGHT / 12.25
brick_width = BOARD_RECONSTRUCT_WIDTH / 26.2
brick_height_thickness_ratio = 15 / 12.25
block_detection_offset = 2
brick_min_bm_ratio = 0.85
opt_fine_board = False
opt_nothing = False
bm_window_min_time = 0.1
bm_window_min_count = 1
worst_ratio_block_thresh = 0.6
pers_norm = True
action_add = 0
action_remove = 1
action_target = 2
action_move = 3
direction_none = 0
direction_up = 1
direction_down = 2
good_words = ['Excellent. ', 'Great. ', 'Good job. ', 'Wonderful. ']
def setup(is_streaming):
global IS_STREAMING, DISPLAY_LIST, DISPLAY_WAIT_TIME, SAVE_IMAGE
is_streaming = is_streaming
if not IS_STREAMING:
display_list = DISPLAY_LIST_TEST
elif RECOGNIZE_ONLY:
display_list = DISPLAY_LIST_STREAM
else:
display_list = DISPLAY_LIST_TASK
display_wait_time = 1 if IS_STREAMING else 500
save_image = not IS_STREAMING |
class Node():
def __init__(self, value=None):
self.children = []
self.parent = None
self.value = value
def add_child(self, node):
if type(node).__name__ == 'Node':
node.parent = self
self.children.append(node)
else:
raise ValueError
def get_parent(self):
return self.parent.value if self.parent else 'root' | class Node:
def __init__(self, value=None):
self.children = []
self.parent = None
self.value = value
def add_child(self, node):
if type(node).__name__ == 'Node':
node.parent = self
self.children.append(node)
else:
raise ValueError
def get_parent(self):
return self.parent.value if self.parent else 'root' |
# https://leetcode.com/problems/minimum-moves-to-equal-array-elements/
# Explanation: https://leetcode.com/problems/minimum-moves-to-equal-array-elements/discuss/93817/It-is-a-math-question
# Source: https://leetcode.com/problems/minimum-moves-to-equal-array-elements/discuss/272994/Python-Greedy-Sum-Min*Len
class Solution:
def minMoves(self, nums: List[int]) -> int:
return sum(nums) - min(nums)*len(nums) | class Solution:
def min_moves(self, nums: List[int]) -> int:
return sum(nums) - min(nums) * len(nums) |
# Event: LCCS Python Fundamental Skills Workshop
# Date: Dec 2018
# Author: Joe English, PDST
# eMail: [email protected]
# Purpose: To find (and fix) two syntax errors
# A program to display Green Eggs and Ham (v4)
def showChorus():
print()
print("I do not like green eggs and ham.")
print("I do not like them Sam-I-am.")
print()
def showVerse1():
print("I do not like them here or there.")
print("I do not like them anywhere.")
print("I do not like them in a house")
print("I do not like them with a mouse")
def displayVerse2():
print("I do not like them in a box")
print("I do not like them with a fox")
print("I will not eat them in the rain.")
print("I will not eat them on a train")
# Program execution starts here
showChorus()
displayVerse1() # SYNTAX ERROR 1 - function 'displayVerse1' does not exist
showChorus()
showVerse2() # SYNTAX ERROR 2 - function 'showVerse2' does not exist
showChorus()
| def show_chorus():
print()
print('I do not like green eggs and ham.')
print('I do not like them Sam-I-am.')
print()
def show_verse1():
print('I do not like them here or there.')
print('I do not like them anywhere.')
print('I do not like them in a house')
print('I do not like them with a mouse')
def display_verse2():
print('I do not like them in a box')
print('I do not like them with a fox')
print('I will not eat them in the rain.')
print('I will not eat them on a train')
show_chorus()
display_verse1()
show_chorus()
show_verse2()
show_chorus() |
_base_ = [
'../_base_/models/repdet_repvgg_pafpn.py',
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_poly.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RepDet',
pretrained='/data/kartikes/repvgg_models/repvgg_b1g2.pth',
backbone=dict(
type='RepVGG',
arch='B1g2',
out_stages=[1, 2, 3, 4],
activation='ReLU',
last_channel=1024,
deploy=False),
neck=dict(
type='NanoPAN',
in_channels=[128, 256, 512, 1024],
out_channels=256,
num_outs=5,
start_level=1,
add_extra_convs='on_input'),
bbox_head=dict(
type='NanoDetHead',
num_classes=80,
in_channels=256,
stacked_convs=2,
feat_channels=256,
share_cls_reg=True,
reg_max=10,
norm_cfg=dict(type='BN', requires_grad=True),
anchor_generator=dict(
type='AnchorGenerator',
ratios=[1.0],
octave_base_scale=8,
scales_per_octave=1,
strides=[8, 16, 32]),
loss_cls=dict(
type='QualityFocalLoss',
use_sigmoid=True,
beta=2.0,
loss_weight=1.0),
loss_dfl=dict(type='DistributionFocalLoss', loss_weight=0.25),
loss_bbox=dict(type='GIoULoss', loss_weight=2.0))
)
optimizer = dict(type='SGD', lr=0.025, momentum=0.9, weight_decay=0.0001)
data = dict(
samples_per_gpu=4,
workers_per_gpu=2)
find_unused_parameters=True
runner = dict(type='EpochBasedRunner', max_epochs=12)
| _base_ = ['../_base_/models/repdet_repvgg_pafpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_poly.py', '../_base_/default_runtime.py']
model = dict(type='RepDet', pretrained='/data/kartikes/repvgg_models/repvgg_b1g2.pth', backbone=dict(type='RepVGG', arch='B1g2', out_stages=[1, 2, 3, 4], activation='ReLU', last_channel=1024, deploy=False), neck=dict(type='NanoPAN', in_channels=[128, 256, 512, 1024], out_channels=256, num_outs=5, start_level=1, add_extra_convs='on_input'), bbox_head=dict(type='NanoDetHead', num_classes=80, in_channels=256, stacked_convs=2, feat_channels=256, share_cls_reg=True, reg_max=10, norm_cfg=dict(type='BN', requires_grad=True), anchor_generator=dict(type='AnchorGenerator', ratios=[1.0], octave_base_scale=8, scales_per_octave=1, strides=[8, 16, 32]), loss_cls=dict(type='QualityFocalLoss', use_sigmoid=True, beta=2.0, loss_weight=1.0), loss_dfl=dict(type='DistributionFocalLoss', loss_weight=0.25), loss_bbox=dict(type='GIoULoss', loss_weight=2.0)))
optimizer = dict(type='SGD', lr=0.025, momentum=0.9, weight_decay=0.0001)
data = dict(samples_per_gpu=4, workers_per_gpu=2)
find_unused_parameters = True
runner = dict(type='EpochBasedRunner', max_epochs=12) |
# Holy Stone - Holy Ground at the Snowfield (3rd job)
questIDs = [1431, 1432, 1433, 1435, 1436, 1437, 1439, 1440, 1442, 1443, 1445, 1446, 1447, 1448]
hasQuest = False
for qid in questIDs:
if sm.hasQuest(qid):
hasQuest = True
break
if hasQuest:
if sm.sendAskYesNo("#b(A mysterious energy surrounds this stone. Do you want to investigate?)"):
sm.warpInstanceIn(910540000, 0)
else:
sm.sendSayOkay("#b(A mysterious energy surrounds this stone)#k")
| quest_i_ds = [1431, 1432, 1433, 1435, 1436, 1437, 1439, 1440, 1442, 1443, 1445, 1446, 1447, 1448]
has_quest = False
for qid in questIDs:
if sm.hasQuest(qid):
has_quest = True
break
if hasQuest:
if sm.sendAskYesNo('#b(A mysterious energy surrounds this stone. Do you want to investigate?)'):
sm.warpInstanceIn(910540000, 0)
else:
sm.sendSayOkay('#b(A mysterious energy surrounds this stone)#k') |
class CustomException(Exception):
def __init__(self, *args, **kwargs):
return super().__init__(self, *args, **kwargs)
def __str__(self):
return str(self.args [1])
class DeprecatedException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class DailyLimitException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class InvalidArgumentException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class IdOrAuthEmptyException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class NotFoundException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class NotSupported(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class SessionLimitException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class WrongCredentials(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class PaladinsOnlyException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class SmiteOnlyException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class RealmRoyaleOnlyException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class PlayerNotFoundException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class GetMatchPlayerDetailsException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class UnexpectedException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class RequestErrorException(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
| class Customexception(Exception):
def __init__(self, *args, **kwargs):
return super().__init__(self, *args, **kwargs)
def __str__(self):
return str(self.args[1])
class Deprecatedexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Dailylimitexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Invalidargumentexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Idorauthemptyexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Notfoundexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Notsupported(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Sessionlimitexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Wrongcredentials(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Paladinsonlyexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Smiteonlyexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Realmroyaleonlyexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Playernotfoundexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Getmatchplayerdetailsexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Unexpectedexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
class Requesterrorexception(CustomException):
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs) |
def f(x):
if x <= -2:
f = 1 - (x + 2)**2
return f
if -2 < x <= 2:
f = -(x/2)
return f
if 2 < x:
f = (x - 2)**2 + 1
return f
x = int(input())
print(f(x))
| def f(x):
if x <= -2:
f = 1 - (x + 2) ** 2
return f
if -2 < x <= 2:
f = -(x / 2)
return f
if 2 < x:
f = (x - 2) ** 2 + 1
return f
x = int(input())
print(f(x)) |
dnas = [
['jVXfX<', 37, 64, 24.67, 14, 7, -4.53, {'ott_len': 42, 'ott_percent': 508, 'stop_loss': 263, 'risk_reward': 65, 'chop_rsi_len': 31, 'chop_bandwidth': 83}],
['o:JK9p', 50, 62, 32.74, 37, 8, -0.2, {'ott_len': 45, 'ott_percent': 259, 'stop_loss': 201, 'risk_reward': 41, 'chop_rsi_len': 12, 'chop_bandwidth': 274}],
['tGVME/', 35, 74, 20.06, 20, 10, -4.75, {'ott_len': 48, 'ott_percent': 375, 'stop_loss': 254, 'risk_reward': 43, 'chop_rsi_len': 20, 'chop_bandwidth': 36}],
['a<<sMo', 59, 27, 25.74, 33, 6, -1.06, {'ott_len': 36, 'ott_percent': 277, 'stop_loss': 139, 'risk_reward': 76, 'chop_rsi_len': 24, 'chop_bandwidth': 271}],
['`Ol@gL', 29, 65, 9.47, 25, 8, -2.95, {'ott_len': 36, 'ott_percent': 446, 'stop_loss': 351, 'risk_reward': 31, 'chop_rsi_len': 40, 'chop_bandwidth': 142}],
['SWJi?Y', 36, 73, 32.8, 37, 8, -0.92, {'ott_len': 28, 'ott_percent': 516, 'stop_loss': 201, 'risk_reward': 68, 'chop_rsi_len': 16, 'chop_bandwidth': 190}],
['v@WLkU', 46, 47, 45.51, 20, 10, -4.43, {'ott_len': 49, 'ott_percent': 313, 'stop_loss': 258, 'risk_reward': 42, 'chop_rsi_len': 43, 'chop_bandwidth': 175}],
['lR\\iHN', 38, 62, 35.84, 28, 7, -4.01, {'ott_len': 43, 'ott_percent': 472, 'stop_loss': 280, 'risk_reward': 68, 'chop_rsi_len': 21, 'chop_bandwidth': 149}],
['l7\\gc^', 60, 35, 42.7, 25, 8, -1.2, {'ott_len': 43, 'ott_percent': 233, 'stop_loss': 280, 'risk_reward': 66, 'chop_rsi_len': 38, 'chop_bandwidth': 208}],
['wLXY\\1', 36, 71, 20.85, 14, 7, -4.76, {'ott_len': 50, 'ott_percent': 419, 'stop_loss': 263, 'risk_reward': 53, 'chop_rsi_len': 34, 'chop_bandwidth': 43}],
['i7nMgb', 54, 24, 28.38, 0, 4, -2.04, {'ott_len': 41, 'ott_percent': 233, 'stop_loss': 360, 'risk_reward': 43, 'chop_rsi_len': 40, 'chop_bandwidth': 223}],
['F/0eI[', 40, 154, 33.68, 42, 21, 2.91, {'ott_len': 20, 'ott_percent': 162, 'stop_loss': 85, 'risk_reward': 64, 'chop_rsi_len': 22, 'chop_bandwidth': 197}],
['\\ERgMp', 53, 28, 16.3, 33, 6, -2.59, {'ott_len': 33, 'ott_percent': 357, 'stop_loss': 236, 'risk_reward': 66, 'chop_rsi_len': 24, 'chop_bandwidth': 274}],
['_7@QqN', 44, 87, 28.24, 46, 15, 3.21, {'ott_len': 35, 'ott_percent': 233, 'stop_loss': 156, 'risk_reward': 46, 'chop_rsi_len': 46, 'chop_bandwidth': 149}],
['OEJO,F', 41, 105, 33.62, 20, 10, -4.61, {'ott_len': 25, 'ott_percent': 357, 'stop_loss': 201, 'risk_reward': 45, 'chop_rsi_len': 4, 'chop_bandwidth': 120}],
['5swn)a', 30, 86, 13.25, 8, 12, -6.03, {'ott_len': 9, 'ott_percent': 765, 'stop_loss': 400, 'risk_reward': 72, 'chop_rsi_len': 3, 'chop_bandwidth': 219}],
['4juD3[', 36, 95, 32.91, 14, 7, -3.13, {'ott_len': 8, 'ott_percent': 685, 'stop_loss': 391, 'risk_reward': 35, 'chop_rsi_len': 9, 'chop_bandwidth': 197}],
['91u6iJ', 33, 163, 31.1, 25, 27, -3.59, {'ott_len': 12, 'ott_percent': 180, 'stop_loss': 391, 'risk_reward': 22, 'chop_rsi_len': 41, 'chop_bandwidth': 135}],
['c3rg61', 39, 91, 11.05, 27, 11, -1.18, {'ott_len': 38, 'ott_percent': 197, 'stop_loss': 378, 'risk_reward': 66, 'chop_rsi_len': 11, 'chop_bandwidth': 43}],
['\\BAZGb', 40, 71, 22.33, 36, 11, -3.44, {'ott_len': 33, 'ott_percent': 330, 'stop_loss': 161, 'risk_reward': 54, 'chop_rsi_len': 21, 'chop_bandwidth': 223}],
['H<XF,l', 40, 98, 31.16, 16, 12, -5.22, {'ott_len': 21, 'ott_percent': 277, 'stop_loss': 263, 'risk_reward': 37, 'chop_rsi_len': 4, 'chop_bandwidth': 260}],
['5Bl/TL', 32, 153, 26.35, 28, 21, 0.03, {'ott_len': 9, 'ott_percent': 330, 'stop_loss': 351, 'risk_reward': 16, 'chop_rsi_len': 29, 'chop_bandwidth': 142}],
['DFRlX-', 38, 112, 21.16, 27, 11, -1.95, {'ott_len': 18, 'ott_percent': 366, 'stop_loss': 236, 'risk_reward': 70, 'chop_rsi_len': 31, 'chop_bandwidth': 28}],
['1EkquE', 33, 156, 45.58, 27, 18, -1.61, {'ott_len': 7, 'ott_percent': 357, 'stop_loss': 347, 'risk_reward': 75, 'chop_rsi_len': 49, 'chop_bandwidth': 116}],
['D9YmB.', 35, 139, 12.09, 42, 14, -1.17, {'ott_len': 18, 'ott_percent': 251, 'stop_loss': 267, 'risk_reward': 71, 'chop_rsi_len': 18, 'chop_bandwidth': 32}],
['_(KrZG', 40, 145, 18.09, 28, 21, -4.73, {'ott_len': 35, 'ott_percent': 100, 'stop_loss': 205, 'risk_reward': 76, 'chop_rsi_len': 32, 'chop_bandwidth': 124}],
['1CndgF', 34, 156, 49.82, 41, 17, 2.8, {'ott_len': 7, 'ott_percent': 339, 'stop_loss': 360, 'risk_reward': 63, 'chop_rsi_len': 40, 'chop_bandwidth': 120}],
['tutp,b', 50, 40, 52.45, 0, 5, -5.75, {'ott_len': 48, 'ott_percent': 782, 'stop_loss': 387, 'risk_reward': 74, 'chop_rsi_len': 4, 'chop_bandwidth': 223}],
['07t1iJ', 30, 199, 23.05, 26, 30, -1.64, {'ott_len': 6, 'ott_percent': 233, 'stop_loss': 387, 'risk_reward': 18, 'chop_rsi_len': 41, 'chop_bandwidth': 135}],
['75\\adC', 37, 200, 68.9, 21, 32, -4.78, {'ott_len': 10, 'ott_percent': 215, 'stop_loss': 280, 'risk_reward': 61, 'chop_rsi_len': 38, 'chop_bandwidth': 109}],
]
| dnas = [['jVXfX<', 37, 64, 24.67, 14, 7, -4.53, {'ott_len': 42, 'ott_percent': 508, 'stop_loss': 263, 'risk_reward': 65, 'chop_rsi_len': 31, 'chop_bandwidth': 83}], ['o:JK9p', 50, 62, 32.74, 37, 8, -0.2, {'ott_len': 45, 'ott_percent': 259, 'stop_loss': 201, 'risk_reward': 41, 'chop_rsi_len': 12, 'chop_bandwidth': 274}], ['tGVME/', 35, 74, 20.06, 20, 10, -4.75, {'ott_len': 48, 'ott_percent': 375, 'stop_loss': 254, 'risk_reward': 43, 'chop_rsi_len': 20, 'chop_bandwidth': 36}], ['a<<sMo', 59, 27, 25.74, 33, 6, -1.06, {'ott_len': 36, 'ott_percent': 277, 'stop_loss': 139, 'risk_reward': 76, 'chop_rsi_len': 24, 'chop_bandwidth': 271}], ['`Ol@gL', 29, 65, 9.47, 25, 8, -2.95, {'ott_len': 36, 'ott_percent': 446, 'stop_loss': 351, 'risk_reward': 31, 'chop_rsi_len': 40, 'chop_bandwidth': 142}], ['SWJi?Y', 36, 73, 32.8, 37, 8, -0.92, {'ott_len': 28, 'ott_percent': 516, 'stop_loss': 201, 'risk_reward': 68, 'chop_rsi_len': 16, 'chop_bandwidth': 190}], ['v@WLkU', 46, 47, 45.51, 20, 10, -4.43, {'ott_len': 49, 'ott_percent': 313, 'stop_loss': 258, 'risk_reward': 42, 'chop_rsi_len': 43, 'chop_bandwidth': 175}], ['lR\\iHN', 38, 62, 35.84, 28, 7, -4.01, {'ott_len': 43, 'ott_percent': 472, 'stop_loss': 280, 'risk_reward': 68, 'chop_rsi_len': 21, 'chop_bandwidth': 149}], ['l7\\gc^', 60, 35, 42.7, 25, 8, -1.2, {'ott_len': 43, 'ott_percent': 233, 'stop_loss': 280, 'risk_reward': 66, 'chop_rsi_len': 38, 'chop_bandwidth': 208}], ['wLXY\\1', 36, 71, 20.85, 14, 7, -4.76, {'ott_len': 50, 'ott_percent': 419, 'stop_loss': 263, 'risk_reward': 53, 'chop_rsi_len': 34, 'chop_bandwidth': 43}], ['i7nMgb', 54, 24, 28.38, 0, 4, -2.04, {'ott_len': 41, 'ott_percent': 233, 'stop_loss': 360, 'risk_reward': 43, 'chop_rsi_len': 40, 'chop_bandwidth': 223}], ['F/0eI[', 40, 154, 33.68, 42, 21, 2.91, {'ott_len': 20, 'ott_percent': 162, 'stop_loss': 85, 'risk_reward': 64, 'chop_rsi_len': 22, 'chop_bandwidth': 197}], ['\\ERgMp', 53, 28, 16.3, 33, 6, -2.59, {'ott_len': 33, 'ott_percent': 357, 'stop_loss': 236, 'risk_reward': 66, 'chop_rsi_len': 24, 'chop_bandwidth': 274}], ['_7@QqN', 44, 87, 28.24, 46, 15, 3.21, {'ott_len': 35, 'ott_percent': 233, 'stop_loss': 156, 'risk_reward': 46, 'chop_rsi_len': 46, 'chop_bandwidth': 149}], ['OEJO,F', 41, 105, 33.62, 20, 10, -4.61, {'ott_len': 25, 'ott_percent': 357, 'stop_loss': 201, 'risk_reward': 45, 'chop_rsi_len': 4, 'chop_bandwidth': 120}], ['5swn)a', 30, 86, 13.25, 8, 12, -6.03, {'ott_len': 9, 'ott_percent': 765, 'stop_loss': 400, 'risk_reward': 72, 'chop_rsi_len': 3, 'chop_bandwidth': 219}], ['4juD3[', 36, 95, 32.91, 14, 7, -3.13, {'ott_len': 8, 'ott_percent': 685, 'stop_loss': 391, 'risk_reward': 35, 'chop_rsi_len': 9, 'chop_bandwidth': 197}], ['91u6iJ', 33, 163, 31.1, 25, 27, -3.59, {'ott_len': 12, 'ott_percent': 180, 'stop_loss': 391, 'risk_reward': 22, 'chop_rsi_len': 41, 'chop_bandwidth': 135}], ['c3rg61', 39, 91, 11.05, 27, 11, -1.18, {'ott_len': 38, 'ott_percent': 197, 'stop_loss': 378, 'risk_reward': 66, 'chop_rsi_len': 11, 'chop_bandwidth': 43}], ['\\BAZGb', 40, 71, 22.33, 36, 11, -3.44, {'ott_len': 33, 'ott_percent': 330, 'stop_loss': 161, 'risk_reward': 54, 'chop_rsi_len': 21, 'chop_bandwidth': 223}], ['H<XF,l', 40, 98, 31.16, 16, 12, -5.22, {'ott_len': 21, 'ott_percent': 277, 'stop_loss': 263, 'risk_reward': 37, 'chop_rsi_len': 4, 'chop_bandwidth': 260}], ['5Bl/TL', 32, 153, 26.35, 28, 21, 0.03, {'ott_len': 9, 'ott_percent': 330, 'stop_loss': 351, 'risk_reward': 16, 'chop_rsi_len': 29, 'chop_bandwidth': 142}], ['DFRlX-', 38, 112, 21.16, 27, 11, -1.95, {'ott_len': 18, 'ott_percent': 366, 'stop_loss': 236, 'risk_reward': 70, 'chop_rsi_len': 31, 'chop_bandwidth': 28}], ['1EkquE', 33, 156, 45.58, 27, 18, -1.61, {'ott_len': 7, 'ott_percent': 357, 'stop_loss': 347, 'risk_reward': 75, 'chop_rsi_len': 49, 'chop_bandwidth': 116}], ['D9YmB.', 35, 139, 12.09, 42, 14, -1.17, {'ott_len': 18, 'ott_percent': 251, 'stop_loss': 267, 'risk_reward': 71, 'chop_rsi_len': 18, 'chop_bandwidth': 32}], ['_(KrZG', 40, 145, 18.09, 28, 21, -4.73, {'ott_len': 35, 'ott_percent': 100, 'stop_loss': 205, 'risk_reward': 76, 'chop_rsi_len': 32, 'chop_bandwidth': 124}], ['1CndgF', 34, 156, 49.82, 41, 17, 2.8, {'ott_len': 7, 'ott_percent': 339, 'stop_loss': 360, 'risk_reward': 63, 'chop_rsi_len': 40, 'chop_bandwidth': 120}], ['tutp,b', 50, 40, 52.45, 0, 5, -5.75, {'ott_len': 48, 'ott_percent': 782, 'stop_loss': 387, 'risk_reward': 74, 'chop_rsi_len': 4, 'chop_bandwidth': 223}], ['07t1iJ', 30, 199, 23.05, 26, 30, -1.64, {'ott_len': 6, 'ott_percent': 233, 'stop_loss': 387, 'risk_reward': 18, 'chop_rsi_len': 41, 'chop_bandwidth': 135}], ['75\\adC', 37, 200, 68.9, 21, 32, -4.78, {'ott_len': 10, 'ott_percent': 215, 'stop_loss': 280, 'risk_reward': 61, 'chop_rsi_len': 38, 'chop_bandwidth': 109}]] |
lista = list(range(0,10001))
for cont in range(0,10001):
print(lista[cont])
for valor in lista:
print(valor) | lista = list(range(0, 10001))
for cont in range(0, 10001):
print(lista[cont])
for valor in lista:
print(valor) |
cont = 1
while True:
t = int(input('Quer saber a tabuada de que numero ? '))
if t < 0:
break
for c in range (1, 11):
print(f'{t} X {c} = {t * c}')
print('Obrigado!') | cont = 1
while True:
t = int(input('Quer saber a tabuada de que numero ? '))
if t < 0:
break
for c in range(1, 11):
print(f'{t} X {c} = {t * c}')
print('Obrigado!') |
#!/usr/bin/env python3
seq = 'ACGACGCAGGAGGAGAGTTTCAGAGATCACGAATACATCCATATTACCCAGAGAGAG'
w = 11
for i in range(len(seq) - w + 1):
count = 0
for j in range(i, i + w):
if seq[j] == 'G' or seq[j] == 'C':
count += 1
print(f'{i} {seq[i:i+w]} {(count / w) : .4f}')
| seq = 'ACGACGCAGGAGGAGAGTTTCAGAGATCACGAATACATCCATATTACCCAGAGAGAG'
w = 11
for i in range(len(seq) - w + 1):
count = 0
for j in range(i, i + w):
if seq[j] == 'G' or seq[j] == 'C':
count += 1
print(f'{i} {seq[i:i + w]} {count / w: .4f}') |
# Princess No Damage Skin (30-Days)
success = sm.addDamageSkin(2432803)
if success:
sm.chat("The Princess No Damage Skin (30-Days) has been added to your account's damage skin collection.")
| success = sm.addDamageSkin(2432803)
if success:
sm.chat("The Princess No Damage Skin (30-Days) has been added to your account's damage skin collection.") |
# 1) count = To count how many time a particular word & char. is appearing
x = "Keep grinding keep hustling"
print(x.count("t"))
# 2) index = To get index of letter(gives the lowest index)
x="Keep grinding keep hustling"
print(x.index("t")) # will give the lowest index value of (t)
# 3) find = To get index of letter(gives the lowest index) | Return -1 on failure.
x = "Keep grinding keep hustling"
print(x.find("t"))
'''
NOTE : print(x.index("t",34)) : Search starts from index value 34 including 34
'''
| x = 'Keep grinding keep hustling'
print(x.count('t'))
x = 'Keep grinding keep hustling'
print(x.index('t'))
x = 'Keep grinding keep hustling'
print(x.find('t'))
'\nNOTE : print(x.index("t",34)) : Search starts from index value 34 including 34\n' |
# example of redefinition __repr__ and __str__ of exception
class MyBad(Exception):
def __str__(self):
return 'My mistake!'
class MyBad2(Exception):
def __repr__(self):
return 'Not calable' # because buid-in method has __str__
try:
raise MyBad('spam')
except MyBad as X:
print(X) # My mistake!
print(X.args) # ('spam',)
try:
raise MyBad2('spam')
except MyBad2 as X:
print(X) # spam
print(X.args) # ('spam',)
raise MyBad('spam') # __main__.MyBad2: My mistake!
# raise MyBad2('spam') # __main__.MyBad2: spam | class Mybad(Exception):
def __str__(self):
return 'My mistake!'
class Mybad2(Exception):
def __repr__(self):
return 'Not calable'
try:
raise my_bad('spam')
except MyBad as X:
print(X)
print(X.args)
try:
raise my_bad2('spam')
except MyBad2 as X:
print(X)
print(X.args)
raise my_bad('spam') |
class Solution:
def findUnsortedSubarray(self, nums: List[int]) -> int:
'''
T: O(n log n) and S: O(1)
'''
n = len(nums)
sorted_nums = sorted(nums)
start, end = n + 1, -1
for i in range(n):
if nums[i] != sorted_nums[i]:
start = min(start, i)
end = max(end, i)
diff = end - start
return diff + 1 if diff > 0 else 0
| class Solution:
def find_unsorted_subarray(self, nums: List[int]) -> int:
"""
T: O(n log n) and S: O(1)
"""
n = len(nums)
sorted_nums = sorted(nums)
(start, end) = (n + 1, -1)
for i in range(n):
if nums[i] != sorted_nums[i]:
start = min(start, i)
end = max(end, i)
diff = end - start
return diff + 1 if diff > 0 else 0 |
# "javascript" section for javascript. see @app.route('/config.js') in app/views.py
# oauth constants
HOSTNAME = "http://hackathon.chinacloudapp.cn" # host name of the UI site
QQ_OAUTH_STATE = "openhackathon" # todo state should be constant. Actually it should be unguessable to prevent CSFA
HACkATHON_API_ENDPOINT = "http://hackathon.chinacloudapp.cn:15000"
Config = {
"environment": "local",
"login": {
"github": {
"access_token_url": 'https://github.com/login/oauth/access_token?client_id=a10e2290ed907918d5ab&client_secret=5b240a2a1bed6a6cf806fc2f34eb38a33ce03d75&redirect_uri=%s/github&code=' % HOSTNAME,
"user_info_url": 'https://api.github.com/user?access_token=',
"emails_info_url": 'https://api.github.com/user/emails?access_token='
},
"qq": {
"access_token_url": 'https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=101192358&client_secret=d94f8e7baee4f03371f52d21c4400cab&redirect_uri=%s/qq&code=' % HOSTNAME,
"openid_url": 'https://graph.qq.com/oauth2.0/me?access_token=',
"user_info_url": 'https://graph.qq.com/user/get_user_info?access_token=%s&oauth_consumer_key=%s&openid=%s'
},
"gitcafe": {
"access_token_url": 'https://api.gitcafe.com/oauth/token?client_id=25ba4f6f90603bd2f3d310d11c0665d937db8971c8a5db00f6c9b9852547d6b8&client_secret=e3d821e82d15096054abbc7fbf41727d3650cab6404a242373f5c446c0918634&redirect_uri=%s/gitcafe&grant_type=authorization_code&code=' % HOSTNAME
},
"provider_enabled": ["github", "qq", "gitcafe"],
"session_minutes": 60,
"token_expiration_minutes": 60 * 24
},
"hackathon-api": {
"endpoint": HACkATHON_API_ENDPOINT
},
"javascript": {
"renren": {
"clientID": "client_id=7e0932f4c5b34176b0ca1881f5e88562",
"redirect_url": "redirect_uri=%s/renren" % HOSTNAME,
"scope": "scope=read_user_message+read_user_feed+read_user_photo",
"response_type": "response_type=token",
},
"github": {
"clientID": "client_id=a10e2290ed907918d5ab",
"redirect_uri": "redirect_uri=%s/github" % HOSTNAME,
"scope": "scope=user",
},
"google": {
"clientID": "client_id=304944766846-7jt8jbm39f1sj4kf4gtsqspsvtogdmem.apps.googleusercontent.com",
"redirect_url": "redirect_uri=%s/google" % HOSTNAME,
"scope": "scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email",
"response_type": "response_type=token",
},
"qq": {
"clientID": "client_id=101192358",
"redirect_uri": "redirect_uri=%s/qq" % HOSTNAME,
"scope": "scope=get_user_info",
"state": "state=%s" % QQ_OAUTH_STATE,
"response_type": "response_type=code",
},
"gitcafe": {
"clientID": "client_id=25ba4f6f90603bd2f3d310d11c0665d937db8971c8a5db00f6c9b9852547d6b8",
"clientSecret": "client_secret=e3d821e82d15096054abbc7fbf41727d3650cab6404a242373f5c446c0918634",
"redirect_uri": "redirect_uri=http://hackathon.chinacloudapp.cn/gitcafe",
"response_type": "response_type=code",
"scope": "scope=public"
},
"hackathon": {
"name": "open-xml-sdk",
"endpoint": HACkATHON_API_ENDPOINT
}
}
}
| hostname = 'http://hackathon.chinacloudapp.cn'
qq_oauth_state = 'openhackathon'
ha_ck_athon_api_endpoint = 'http://hackathon.chinacloudapp.cn:15000'
config = {'environment': 'local', 'login': {'github': {'access_token_url': 'https://github.com/login/oauth/access_token?client_id=a10e2290ed907918d5ab&client_secret=5b240a2a1bed6a6cf806fc2f34eb38a33ce03d75&redirect_uri=%s/github&code=' % HOSTNAME, 'user_info_url': 'https://api.github.com/user?access_token=', 'emails_info_url': 'https://api.github.com/user/emails?access_token='}, 'qq': {'access_token_url': 'https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=101192358&client_secret=d94f8e7baee4f03371f52d21c4400cab&redirect_uri=%s/qq&code=' % HOSTNAME, 'openid_url': 'https://graph.qq.com/oauth2.0/me?access_token=', 'user_info_url': 'https://graph.qq.com/user/get_user_info?access_token=%s&oauth_consumer_key=%s&openid=%s'}, 'gitcafe': {'access_token_url': 'https://api.gitcafe.com/oauth/token?client_id=25ba4f6f90603bd2f3d310d11c0665d937db8971c8a5db00f6c9b9852547d6b8&client_secret=e3d821e82d15096054abbc7fbf41727d3650cab6404a242373f5c446c0918634&redirect_uri=%s/gitcafe&grant_type=authorization_code&code=' % HOSTNAME}, 'provider_enabled': ['github', 'qq', 'gitcafe'], 'session_minutes': 60, 'token_expiration_minutes': 60 * 24}, 'hackathon-api': {'endpoint': HACkATHON_API_ENDPOINT}, 'javascript': {'renren': {'clientID': 'client_id=7e0932f4c5b34176b0ca1881f5e88562', 'redirect_url': 'redirect_uri=%s/renren' % HOSTNAME, 'scope': 'scope=read_user_message+read_user_feed+read_user_photo', 'response_type': 'response_type=token'}, 'github': {'clientID': 'client_id=a10e2290ed907918d5ab', 'redirect_uri': 'redirect_uri=%s/github' % HOSTNAME, 'scope': 'scope=user'}, 'google': {'clientID': 'client_id=304944766846-7jt8jbm39f1sj4kf4gtsqspsvtogdmem.apps.googleusercontent.com', 'redirect_url': 'redirect_uri=%s/google' % HOSTNAME, 'scope': 'scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email', 'response_type': 'response_type=token'}, 'qq': {'clientID': 'client_id=101192358', 'redirect_uri': 'redirect_uri=%s/qq' % HOSTNAME, 'scope': 'scope=get_user_info', 'state': 'state=%s' % QQ_OAUTH_STATE, 'response_type': 'response_type=code'}, 'gitcafe': {'clientID': 'client_id=25ba4f6f90603bd2f3d310d11c0665d937db8971c8a5db00f6c9b9852547d6b8', 'clientSecret': 'client_secret=e3d821e82d15096054abbc7fbf41727d3650cab6404a242373f5c446c0918634', 'redirect_uri': 'redirect_uri=http://hackathon.chinacloudapp.cn/gitcafe', 'response_type': 'response_type=code', 'scope': 'scope=public'}, 'hackathon': {'name': 'open-xml-sdk', 'endpoint': HACkATHON_API_ENDPOINT}}} |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
if not target or not original or not cloned: return None
if target.val == original.val == cloned.val: return cloned
node = self.getTargetCopy(original.left, cloned.left, target)
if node: return node
node = self.getTargetCopy(original.right, cloned.right, target)
if node: return node
return None
| class Solution:
def get_target_copy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
if not target or not original or (not cloned):
return None
if target.val == original.val == cloned.val:
return cloned
node = self.getTargetCopy(original.left, cloned.left, target)
if node:
return node
node = self.getTargetCopy(original.right, cloned.right, target)
if node:
return node
return None |
class City:
name = "city"
size = "default"
draw = -1
danger = -1
population = [] | class City:
name = 'city'
size = 'default'
draw = -1
danger = -1
population = [] |
# >>> s = set("Hacker")
# >>> print s.difference("Rank")
# set(['c', 'r', 'e', 'H'])
# >>> print s.difference(set(['R', 'a', 'n', 'k']))
# set(['c', 'r', 'e', 'H'])
# >>> print s.difference(['R', 'a', 'n', 'k'])
# set(['c', 'r', 'e', 'H'])
# >>> print s.difference(enumerate(['R', 'a', 'n', 'k']))
# set(['a', 'c', 'r', 'e', 'H', 'k'])
# >>> print s.difference({"Rank":1})
# set(['a', 'c', 'e', 'H', 'k', 'r'])
# >>> s - set("Rank")
# set(['H', 'c', 'r', 'e'])
if __name__ == "__main__":
eng = input()
eng_stu = set(map(int, input().split()))
fre = input()
fre_stu = set(map(int, input().split()))
eng_only = eng_stu - fre_stu
print(len(eng_only))
| if __name__ == '__main__':
eng = input()
eng_stu = set(map(int, input().split()))
fre = input()
fre_stu = set(map(int, input().split()))
eng_only = eng_stu - fre_stu
print(len(eng_only)) |
SECRET_KEY = None
DB_HOST = "localhost"
DB_NAME = "kido"
DB_USERNAME = "kido"
DB_PASSWORD = "kido"
COMPRESSOR_DEBUG = False
COMPRESSOR_OFFLINE_COMPRESS = True
| secret_key = None
db_host = 'localhost'
db_name = 'kido'
db_username = 'kido'
db_password = 'kido'
compressor_debug = False
compressor_offline_compress = True |
def consolidate(sets):
setlist = [s for s in sets if s]
for i, s1 in enumerate(setlist):
if s1:
for s2 in setlist[i+1:]:
intersection = s1.intersection(s2)
if intersection:
s2.update(s1)
s1.clear()
s1 = s2
return [s for s in setlist if s]
| def consolidate(sets):
setlist = [s for s in sets if s]
for (i, s1) in enumerate(setlist):
if s1:
for s2 in setlist[i + 1:]:
intersection = s1.intersection(s2)
if intersection:
s2.update(s1)
s1.clear()
s1 = s2
return [s for s in setlist if s] |
class InterpreterException(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class SymbolNotFound(InterpreterException):
pass
class UnexpectedCharacter(InterpreterException):
pass
class ParserSyntaxError(InterpreterException):
pass
class DuplicateSymbol(InterpreterException):
pass
class InterpreterRuntimeError(InterpreterException):
pass
class InvalidParamCount(InterpreterRuntimeError):
pass | class Interpreterexception(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class Symbolnotfound(InterpreterException):
pass
class Unexpectedcharacter(InterpreterException):
pass
class Parsersyntaxerror(InterpreterException):
pass
class Duplicatesymbol(InterpreterException):
pass
class Interpreterruntimeerror(InterpreterException):
pass
class Invalidparamcount(InterpreterRuntimeError):
pass |
#Copyright (c) 2009-11, Walter Bender, Tony Forster
# This procedure is invoked when the user-definable block on the
# "extras" palette is selected.
# Usage: Import this code into a Python (user-definable) block; when
# this code is run, the current mouse status will be pushed to the
# FILO heap. If a mouse button event occurs, a y, x, and 1 are pushed
# to the heap. If no button is pressed, 0 is pushed to the heap.
# To use these data, pop the heap in a compare block to determine if a
# button has been pushed. If a 1 was popped from the heap, pop the x
# and y coordinates.
def myblock(tw, x): # ignore second argument
''' Push mouse event to stack '''
if tw.mouse_flag == 1:
# push y first so x will be popped first
tw.lc.heap.append((tw.canvas.height / 2) - tw.mouse_y)
tw.lc.heap.append(tw.mouse_x - (tw.canvas.width / 2))
tw.lc.heap.append(1) # mouse event
tw.mouse_flag = 0
else:
tw.lc.heap.append(0) # no mouse event
| def myblock(tw, x):
""" Push mouse event to stack """
if tw.mouse_flag == 1:
tw.lc.heap.append(tw.canvas.height / 2 - tw.mouse_y)
tw.lc.heap.append(tw.mouse_x - tw.canvas.width / 2)
tw.lc.heap.append(1)
tw.mouse_flag = 0
else:
tw.lc.heap.append(0) |
can_juggle = True
# The code below has problems. See if
# you can fix them!
#if can_juggle print("I can juggle!")
#else
print("I can't juggle.")
| can_juggle = True
print("I can't juggle.") |
# decompiled-by-hand & optimized
# definitely not gonna refactor this one
# 0.18s on pypy3
ip_reg = 4
reg = [0, 0, 0, 0, 0, 0]
i = 0
seen = set()
lst = []
while True:
i += 1
break_true = False
while True:
if break_true:
if i == 1:
print("1)", reg[1])
if reg[1] in seen:
if len(lst) == 25000:
p2 = max(seen, key=lambda x: lst.index(x))
print("2)", p2)
exit()
seen.add(reg[1])
lst.append(reg[1])
break
reg[2] = reg[1] | 65536 # 6
reg[1] = 8725355 # 7
while True:
reg[5] = reg[2] & 255 # 8
reg[1] += reg[5] # 9
reg[1] &= 16777215 # 10
reg[1] *= 65899 # 11
reg[1] &= 16777215 # 12
reg[2] = reg[2] // 256
if reg[2] == 0:
break_true = True
break
break_true = False
| ip_reg = 4
reg = [0, 0, 0, 0, 0, 0]
i = 0
seen = set()
lst = []
while True:
i += 1
break_true = False
while True:
if break_true:
if i == 1:
print('1)', reg[1])
if reg[1] in seen:
if len(lst) == 25000:
p2 = max(seen, key=lambda x: lst.index(x))
print('2)', p2)
exit()
seen.add(reg[1])
lst.append(reg[1])
break
reg[2] = reg[1] | 65536
reg[1] = 8725355
while True:
reg[5] = reg[2] & 255
reg[1] += reg[5]
reg[1] &= 16777215
reg[1] *= 65899
reg[1] &= 16777215
reg[2] = reg[2] // 256
if reg[2] == 0:
break_true = True
break
break_true = False |
# See
# The configuration file should be a valid Python source file with a python extension (e.g. gunicorn.conf.py).
# https://docs.gunicorn.org/en/stable/configure.html
bind='127.0.0.1:8962'
timeout=75
daemon=True
user='user'
accesslog='/var/local/log/user/blockchain_backup.gunicorn.access.log'
errorlog='/var/local/log/user/blockchain_backup.gunicorn.error.log'
log_level='debug'
capture_output=True
max_requests=3
workers=1
| bind = '127.0.0.1:8962'
timeout = 75
daemon = True
user = 'user'
accesslog = '/var/local/log/user/blockchain_backup.gunicorn.access.log'
errorlog = '/var/local/log/user/blockchain_backup.gunicorn.error.log'
log_level = 'debug'
capture_output = True
max_requests = 3
workers = 1 |
size = 5
m = (2 * size)-2
for i in range(0, size):
for j in range(0, m):
print(end=" ")
m = m - 1
for j in range(0, i + 1):
if(m%2!=0):
print("*", end=" ")
print("") | size = 5
m = 2 * size - 2
for i in range(0, size):
for j in range(0, m):
print(end=' ')
m = m - 1
for j in range(0, i + 1):
if m % 2 != 0:
print('*', end=' ')
print('') |
__version__ = '2.0.0'
__description__ = 'Sample for calculations with data from the ctrlX Data Layer'
__author__ = 'Fantastic Python Developers'
__licence__ = 'MIT License'
__copyright__ = 'Copyright (c) 2021 Bosch Rexroth AG' | __version__ = '2.0.0'
__description__ = 'Sample for calculations with data from the ctrlX Data Layer'
__author__ = 'Fantastic Python Developers'
__licence__ = 'MIT License'
__copyright__ = 'Copyright (c) 2021 Bosch Rexroth AG' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.