content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# DFLOW LIBRARY:
# dflow utilities module
# with new range function
# and dictenumerate
def range(_from, _to, step=1):
out = []
aux = _from
while aux < _to:
out.append(aux)
aux += step
return out
def dictenumerate(d):
return {k: v for v, k in enumerate(d)}
def prod(x):
res = 1
for X in x:
res *= X
return res | def range(_from, _to, step=1):
out = []
aux = _from
while aux < _to:
out.append(aux)
aux += step
return out
def dictenumerate(d):
return {k: v for (v, k) in enumerate(d)}
def prod(x):
res = 1
for x in x:
res *= X
return res |
class TFException(Exception):
pass
class TFAPIUnavailable(Exception):
pass
class TFLogParsingException(Exception):
def __init__(self, type):
self.type = type | class Tfexception(Exception):
pass
class Tfapiunavailable(Exception):
pass
class Tflogparsingexception(Exception):
def __init__(self, type):
self.type = type |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isSubtree(self, s, t, match=False):
"""
:type s: TreeNode
:type t: TreeNode
:rtype: bool
"""
# parameter match is a flag to judge s.parent == t.parent
if not s and not t: return True
elif not s or not t: return False
if match and s.val != t.val: return False
if s.val == t.val and self.isSubtree(s.right, t.right, True) and self.isSubtree(s.left, t.left, True): return True
return self.isSubtree(s.right, t, match) or self.isSubtree(s.left, t, match)
class Solution:
def isSubtree(self, s: TreeNode, t: TreeNode) -> bool:
# very slowly. most time wasted on self.judge function which can merge to self.subtree function
stri = "s: {}, t: {}"
ts = s.val if s is not None else 'none'
tt = t.val if t is not None else 'none'
# print(stri.format(ts, tt))
if (s is None) ^ (t is None):
# print('a')
return False
if (s is None) and (t is None):
# print('b')
return True
if s.val == t.val and self.judge(s, t):
return True
# print('d')
A = self.isSubtree(s.left, t)
# print("e")
B = self.isSubtree(s.right, t)
# print('f')
return A or B
def judge(self, s, t):
sq = [s]
tq = [t]
while len(sq) > 0 and len(tq) > 0:
ts = sq.pop()
tt = tq.pop()
if (ts is None) ^ (tt is None):
return False
if ts is None and tt is None:
continue
if ts.val != tt.val:
return False
sq.append(ts.left)
sq.append(ts.right)
tq.append(tt.left)
tq.append(tt.right)
if len(sq) == len(tq) == 0:
return True
return False | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def is_subtree(self, s, t, match=False):
"""
:type s: TreeNode
:type t: TreeNode
:rtype: bool
"""
if not s and (not t):
return True
elif not s or not t:
return False
if match and s.val != t.val:
return False
if s.val == t.val and self.isSubtree(s.right, t.right, True) and self.isSubtree(s.left, t.left, True):
return True
return self.isSubtree(s.right, t, match) or self.isSubtree(s.left, t, match)
class Solution:
def is_subtree(self, s: TreeNode, t: TreeNode) -> bool:
stri = 's: {}, t: {}'
ts = s.val if s is not None else 'none'
tt = t.val if t is not None else 'none'
if (s is None) ^ (t is None):
return False
if s is None and t is None:
return True
if s.val == t.val and self.judge(s, t):
return True
a = self.isSubtree(s.left, t)
b = self.isSubtree(s.right, t)
return A or B
def judge(self, s, t):
sq = [s]
tq = [t]
while len(sq) > 0 and len(tq) > 0:
ts = sq.pop()
tt = tq.pop()
if (ts is None) ^ (tt is None):
return False
if ts is None and tt is None:
continue
if ts.val != tt.val:
return False
sq.append(ts.left)
sq.append(ts.right)
tq.append(tt.left)
tq.append(tt.right)
if len(sq) == len(tq) == 0:
return True
return False |
"""
Some models such as
A model with high precision
"""
class Model_Regression():
def __init__(self):
self.name = 'a_good_model'
def predict(self,x):
y = x*2
return y
if __name__ == '__main__':
model = Model_Regression()
print(model.predict(1)) | """
Some models such as
A model with high precision
"""
class Model_Regression:
def __init__(self):
self.name = 'a_good_model'
def predict(self, x):
y = x * 2
return y
if __name__ == '__main__':
model = model__regression()
print(model.predict(1)) |
print("Hello Aline and Basti!")
print("What's up?")
# We need escaping: \" cancels its meaning.
print("Are you \"Monty\"?")
# Alternatively you can use ':
print('Are you "Monty"?')
# But you will need escaping for the last:
print("Can't you just pretend you were \"Monty\"?")
# or
print('Can\'t you just pretend you were "Monty"?')
| print('Hello Aline and Basti!')
print("What's up?")
print('Are you "Monty"?')
print('Are you "Monty"?')
print('Can\'t you just pretend you were "Monty"?')
print('Can\'t you just pretend you were "Monty"?') |
class Action:
"""A thing that is done.
The responsibility of action is to do something that is important in the game. Thus, it has one
method, execute(), which should be overridden by derived classes.
"""
def execute(self, cast, script, callback):
"""Executes something that is important in the game. This method should be overriden by
derived classes.
Args:
cast: An instance of Cast containing the actors in the game.
script: An instance of Script containing the actions in the game.
callback: An instance of ActionCallback so we can change the scene.
"""
raise NotImplementedError("execute not implemented in base class") | class Action:
"""A thing that is done.
The responsibility of action is to do something that is important in the game. Thus, it has one
method, execute(), which should be overridden by derived classes.
"""
def execute(self, cast, script, callback):
"""Executes something that is important in the game. This method should be overriden by
derived classes.
Args:
cast: An instance of Cast containing the actors in the game.
script: An instance of Script containing the actions in the game.
callback: An instance of ActionCallback so we can change the scene.
"""
raise not_implemented_error('execute not implemented in base class') |
"""
The core Becca code
This package contains all the learning algorithms and heuristics
implemented together in a functional learning agent. Most users
won't need to modify anything in this package. Only core developers,
those who want to experiment with and improve the underlying
learning algorithms and their implementations, should need to muck
around with it.
See the brohrer/becca_test repository for examples of how to implement it with a world.
"""
| """
The core Becca code
This package contains all the learning algorithms and heuristics
implemented together in a functional learning agent. Most users
won't need to modify anything in this package. Only core developers,
those who want to experiment with and improve the underlying
learning algorithms and their implementations, should need to muck
around with it.
See the brohrer/becca_test repository for examples of how to implement it with a world.
""" |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 1 10:42:25 2017
@author: wuyiming
"""
SR = 16000
H = 512
FFT_SIZE = 1024
BATCH_SIZE = 64
PATCH_LENGTH = 128
PATH_FFT = "/media/wuyiming/TOSHIBA EXT/UNetFFT/"
| """
Created on Wed Nov 1 10:42:25 2017
@author: wuyiming
"""
sr = 16000
h = 512
fft_size = 1024
batch_size = 64
patch_length = 128
path_fft = '/media/wuyiming/TOSHIBA EXT/UNetFFT/' |
#
# PySNMP MIB module MIB-INTEL-IP (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MIB-INTEL-IP
# Produced by pysmi-0.3.4 at Wed May 1 14:12:01 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, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint")
mib2ext, = mibBuilder.importSymbols("INTEL-GEN-MIB", "mib2ext")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Unsigned32, Counter32, ModuleIdentity, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, TimeTicks, Bits, Gauge32, MibIdentifier, Integer32, IpAddress, ObjectIdentity, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "Counter32", "ModuleIdentity", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "TimeTicks", "Bits", "Gauge32", "MibIdentifier", "Integer32", "IpAddress", "ObjectIdentity", "Counter64")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
ipr = MibIdentifier((1, 3, 6, 1, 4, 1, 343, 6, 38))
class RowStatus(Integer32):
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))
namedValues = NamedValues(("active", 1), ("notInService", 2), ("notReady", 3), ("createAndGo", 4), ("createAndWait", 5), ("destroy", 6))
rtIpRouteTable = MibTable((1, 3, 6, 1, 4, 1, 343, 6, 38, 1), )
if mibBuilder.loadTexts: rtIpRouteTable.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteTable.setDescription("This entity's IP Routing table.")
rtIpRouteEntry = MibTableRow((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1), ).setIndexNames((0, "MIB-INTEL-IP", "rtIpRouteChassis"), (0, "MIB-INTEL-IP", "rtIpRouteModule"), (0, "MIB-INTEL-IP", "rtIpRouteInst"), (0, "MIB-INTEL-IP", "rtIpRouteDest"), (0, "MIB-INTEL-IP", "rtIpRouteMask"), (0, "MIB-INTEL-IP", "rtIpRouteIfIndex"), (0, "MIB-INTEL-IP", "rtIpRouteNextHop"))
if mibBuilder.loadTexts: rtIpRouteEntry.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteEntry.setDescription('A route to a particular destination.')
rtIpRouteChassis = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteChassis.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteChassis.setDescription('Chassis number in stack that contains the module.')
rtIpRouteModule = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteModule.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteModule.setDescription('Module number in the chassis.')
rtIpRouteInst = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteInst.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteInst.setDescription('Routing table instance number.')
rtIpRouteDest = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteDest.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteDest.setDescription('The destination IP address of this route.')
rtIpRouteMask = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 5), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteMask.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteMask.setDescription('Indicate the mask to be logical-ANDed with the destination address before being compared to the value in the rtIpRouteDest field.')
rtIpRouteIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteIfIndex.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteIfIndex.setDescription('The interface that the frame is forwarded on.')
rtIpRouteNextHop = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 7), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteNextHop.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteNextHop.setDescription('The IP address of the next hop of this route.')
rtIpRoutePref = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRoutePref.setStatus('optional')
if mibBuilder.loadTexts: rtIpRoutePref.setDescription('The preference value for this route.')
rtIpRouteMetric = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteMetric.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteMetric.setDescription("The routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's rtIpRouteProto value.")
rtIpRouteProto = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("direct", 1), ("static", 2), ("ospf", 3), ("rip", 4), ("other", 5), ("all", 6)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteProto.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteProto.setDescription('The routing mechanism via which this route was learned.')
rtIpRouteAge = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRouteAge.setStatus('optional')
if mibBuilder.loadTexts: rtIpRouteAge.setDescription("The number of seconds since this route was last updated or otherwise detemined to be correct. Note that no semantics of 'too old' can be implied except through knowledge of the routing protocol by which the route was learned.")
rtIpRteTable = MibTable((1, 3, 6, 1, 4, 1, 343, 6, 38, 2), )
if mibBuilder.loadTexts: rtIpRteTable.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteTable.setDescription('The list of all routing table entries (RTE). There may be several entries describing a route to the same destination (entries with the same IP address and mask but different preference, protocol or metric). Forwarding engine uses only the best one - this one which can be found in the Routing Table. All other entries as well the best one are available in rtIpRteTable. If for some reason the best entry has been lost then the best one will be chosen from other entries to the same destination.')
rtIpRteEntry = MibTableRow((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1), ).setIndexNames((0, "MIB-INTEL-IP", "rtIpRteChassis"), (0, "MIB-INTEL-IP", "rtIpRteModule"), (0, "MIB-INTEL-IP", "rtIpRteInst"), (0, "MIB-INTEL-IP", "rtIpRteDest"), (0, "MIB-INTEL-IP", "rtIpRteMask"), (0, "MIB-INTEL-IP", "rtIpRtePref"), (0, "MIB-INTEL-IP", "rtIpRteProto"), (0, "MIB-INTEL-IP", "rtIpRteIfIndex"), (0, "MIB-INTEL-IP", "rtIpRteNextHop"))
if mibBuilder.loadTexts: rtIpRteEntry.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteEntry.setDescription('A route to a particular destination.')
rtIpRteChassis = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteChassis.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteChassis.setDescription('Chassis number in stack that contains the module.')
rtIpRteModule = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteModule.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteModule.setDescription('Module number in the chassis.')
rtIpRteInst = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteInst.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteInst.setDescription('Alternative routing table instance number.')
rtIpRteDest = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteDest.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteDest.setDescription('The destination IP address of this route.')
rtIpRteMask = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 5), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteMask.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteMask.setDescription('Indicate the mask to be logical-ANDed with the destination address before being compared to the value in the rtIpRteDest field.')
rtIpRtePref = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRtePref.setStatus('optional')
if mibBuilder.loadTexts: rtIpRtePref.setDescription('The preference value for this route.')
rtIpRteProto = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))).clone(namedValues=NamedValues(("direct", 1), ("static", 2), ("ospf", 3), ("rip", 4), ("other", 5), ("all", 6)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteProto.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteProto.setDescription('The routing mechanism via which this route was learned.')
rtIpRteIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteIfIndex.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteIfIndex.setDescription('The interface that the frame is forwarded on.')
rtIpRteNextHop = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 9), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteNextHop.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteNextHop.setDescription('The IP address of the next hop of this route.')
rtIpRteState = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpRteState.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteState.setDescription('The state of the route.')
rtIpRteAge = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 11), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rtIpRteAge.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteAge.setDescription("The number of seconds since this route was last updated or otherwise detemined to be correct. Note that no semantics of 'too old' can be implied except through knowledge of the routing protocol by which the route was learned.")
rtIpRteMetric = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 12), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpRteMetric.setStatus('optional')
if mibBuilder.loadTexts: rtIpRteMetric.setDescription('The metric of the alternative route.')
rtIpStaticRouteTable = MibTable((1, 3, 6, 1, 4, 1, 343, 6, 38, 3), )
if mibBuilder.loadTexts: rtIpStaticRouteTable.setStatus('optional')
if mibBuilder.loadTexts: rtIpStaticRouteTable.setDescription('A table of all configured static routes.')
rtIpStaticRouteEntry = MibTableRow((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1), ).setIndexNames((0, "MIB-INTEL-IP", "rtIpStRtChassis"), (0, "MIB-INTEL-IP", "rtIpStRtModule"), (0, "MIB-INTEL-IP", "rtIpStRtInst"), (0, "MIB-INTEL-IP", "rtIpStRtDest"), (0, "MIB-INTEL-IP", "rtIpStRtMask"), (0, "MIB-INTEL-IP", "rtIpStRtPref"), (0, "MIB-INTEL-IP", "rtIpStRtIfIndex"), (0, "MIB-INTEL-IP", "rtIpStRtNextHop"))
if mibBuilder.loadTexts: rtIpStaticRouteEntry.setStatus('optional')
if mibBuilder.loadTexts: rtIpStaticRouteEntry.setDescription('An entry describing a single static route.')
rtIpStRtChassis = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 1), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtChassis.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtChassis.setDescription('Chassis number in stack that contains the module.')
rtIpStRtModule = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 2), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtModule.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtModule.setDescription('Module number in the chassis.')
rtIpStRtInst = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 3), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtInst.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtInst.setDescription('Static routing table instance number.')
rtIpStRtDest = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 4), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtDest.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtDest.setDescription('The destination IP address of this route.')
rtIpStRtMask = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 5), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtMask.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtMask.setDescription('The destination IP mask of this route.')
rtIpStRtPref = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 6), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtPref.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtPref.setDescription('The preference value for this route. This value should be unique (neither other static routes to the same destination nor other protocols can use this value).')
rtIpStRtIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 7), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtIfIndex.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtIfIndex.setDescription('The interface that the frame is forwarded on.')
rtIpStRtNextHop = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 8), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtNextHop.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtNextHop.setDescription('The IP address of the next hop of this route.')
rtIpStRtMetric = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 9), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtMetric.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtMetric.setDescription('The routing metric for this route.')
rtIpStRtStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 10), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtStatus.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtStatus.setDescription("The status of the route. Setting it to 'destroy'(6) removes the static route from router's configuration.")
rtIpStRtState = MibTableColumn((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rtIpStRtState.setStatus('optional')
if mibBuilder.loadTexts: rtIpStRtState.setDescription('The current state of the route.')
mibBuilder.exportSymbols("MIB-INTEL-IP", rtIpRoutePref=rtIpRoutePref, rtIpStRtIfIndex=rtIpStRtIfIndex, rtIpRteEntry=rtIpRteEntry, rtIpRouteInst=rtIpRouteInst, rtIpStRtMask=rtIpStRtMask, rtIpRouteEntry=rtIpRouteEntry, rtIpRteMask=rtIpRteMask, rtIpRteState=rtIpRteState, rtIpRteProto=rtIpRteProto, rtIpRouteMetric=rtIpRouteMetric, rtIpRteDest=rtIpRteDest, rtIpRteInst=rtIpRteInst, ipr=ipr, rtIpRteAge=rtIpRteAge, rtIpRouteProto=rtIpRouteProto, rtIpRouteNextHop=rtIpRouteNextHop, rtIpRouteModule=rtIpRouteModule, rtIpRteNextHop=rtIpRteNextHop, rtIpRteModule=rtIpRteModule, rtIpStRtDest=rtIpStRtDest, rtIpRteIfIndex=rtIpRteIfIndex, rtIpStaticRouteEntry=rtIpStaticRouteEntry, RowStatus=RowStatus, rtIpStRtMetric=rtIpStRtMetric, rtIpRouteDest=rtIpRouteDest, rtIpRouteChassis=rtIpRouteChassis, rtIpRouteMask=rtIpRouteMask, rtIpRteTable=rtIpRteTable, rtIpRouteTable=rtIpRouteTable, rtIpStRtPref=rtIpStRtPref, rtIpStaticRouteTable=rtIpStaticRouteTable, rtIpRteChassis=rtIpRteChassis, rtIpRouteAge=rtIpRouteAge, rtIpRteMetric=rtIpRteMetric, rtIpStRtState=rtIpStRtState, rtIpRtePref=rtIpRtePref, rtIpStRtChassis=rtIpStRtChassis, rtIpStRtStatus=rtIpStRtStatus, rtIpStRtModule=rtIpStRtModule, rtIpStRtNextHop=rtIpStRtNextHop, rtIpStRtInst=rtIpStRtInst, rtIpRouteIfIndex=rtIpRouteIfIndex)
| (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueRangeConstraint')
(mib2ext,) = mibBuilder.importSymbols('INTEL-GEN-MIB', 'mib2ext')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(unsigned32, counter32, module_identity, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, iso, time_ticks, bits, gauge32, mib_identifier, integer32, ip_address, object_identity, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'Counter32', 'ModuleIdentity', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'iso', 'TimeTicks', 'Bits', 'Gauge32', 'MibIdentifier', 'Integer32', 'IpAddress', 'ObjectIdentity', 'Counter64')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
ipr = mib_identifier((1, 3, 6, 1, 4, 1, 343, 6, 38))
class Rowstatus(Integer32):
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))
named_values = named_values(('active', 1), ('notInService', 2), ('notReady', 3), ('createAndGo', 4), ('createAndWait', 5), ('destroy', 6))
rt_ip_route_table = mib_table((1, 3, 6, 1, 4, 1, 343, 6, 38, 1))
if mibBuilder.loadTexts:
rtIpRouteTable.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteTable.setDescription("This entity's IP Routing table.")
rt_ip_route_entry = mib_table_row((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1)).setIndexNames((0, 'MIB-INTEL-IP', 'rtIpRouteChassis'), (0, 'MIB-INTEL-IP', 'rtIpRouteModule'), (0, 'MIB-INTEL-IP', 'rtIpRouteInst'), (0, 'MIB-INTEL-IP', 'rtIpRouteDest'), (0, 'MIB-INTEL-IP', 'rtIpRouteMask'), (0, 'MIB-INTEL-IP', 'rtIpRouteIfIndex'), (0, 'MIB-INTEL-IP', 'rtIpRouteNextHop'))
if mibBuilder.loadTexts:
rtIpRouteEntry.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteEntry.setDescription('A route to a particular destination.')
rt_ip_route_chassis = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteChassis.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteChassis.setDescription('Chassis number in stack that contains the module.')
rt_ip_route_module = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteModule.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteModule.setDescription('Module number in the chassis.')
rt_ip_route_inst = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteInst.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteInst.setDescription('Routing table instance number.')
rt_ip_route_dest = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 4), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteDest.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteDest.setDescription('The destination IP address of this route.')
rt_ip_route_mask = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 5), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteMask.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteMask.setDescription('Indicate the mask to be logical-ANDed with the destination address before being compared to the value in the rtIpRouteDest field.')
rt_ip_route_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 6), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteIfIndex.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteIfIndex.setDescription('The interface that the frame is forwarded on.')
rt_ip_route_next_hop = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 7), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteNextHop.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteNextHop.setDescription('The IP address of the next hop of this route.')
rt_ip_route_pref = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRoutePref.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRoutePref.setDescription('The preference value for this route.')
rt_ip_route_metric = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 9), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteMetric.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteMetric.setDescription("The routing metric for this route. The semantics of this metric are determined by the routing-protocol specified in the route's rtIpRouteProto value.")
rt_ip_route_proto = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('direct', 1), ('static', 2), ('ospf', 3), ('rip', 4), ('other', 5), ('all', 6)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteProto.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteProto.setDescription('The routing mechanism via which this route was learned.')
rt_ip_route_age = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 1, 1, 11), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRouteAge.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRouteAge.setDescription("The number of seconds since this route was last updated or otherwise detemined to be correct. Note that no semantics of 'too old' can be implied except through knowledge of the routing protocol by which the route was learned.")
rt_ip_rte_table = mib_table((1, 3, 6, 1, 4, 1, 343, 6, 38, 2))
if mibBuilder.loadTexts:
rtIpRteTable.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteTable.setDescription('The list of all routing table entries (RTE). There may be several entries describing a route to the same destination (entries with the same IP address and mask but different preference, protocol or metric). Forwarding engine uses only the best one - this one which can be found in the Routing Table. All other entries as well the best one are available in rtIpRteTable. If for some reason the best entry has been lost then the best one will be chosen from other entries to the same destination.')
rt_ip_rte_entry = mib_table_row((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1)).setIndexNames((0, 'MIB-INTEL-IP', 'rtIpRteChassis'), (0, 'MIB-INTEL-IP', 'rtIpRteModule'), (0, 'MIB-INTEL-IP', 'rtIpRteInst'), (0, 'MIB-INTEL-IP', 'rtIpRteDest'), (0, 'MIB-INTEL-IP', 'rtIpRteMask'), (0, 'MIB-INTEL-IP', 'rtIpRtePref'), (0, 'MIB-INTEL-IP', 'rtIpRteProto'), (0, 'MIB-INTEL-IP', 'rtIpRteIfIndex'), (0, 'MIB-INTEL-IP', 'rtIpRteNextHop'))
if mibBuilder.loadTexts:
rtIpRteEntry.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteEntry.setDescription('A route to a particular destination.')
rt_ip_rte_chassis = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteChassis.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteChassis.setDescription('Chassis number in stack that contains the module.')
rt_ip_rte_module = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteModule.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteModule.setDescription('Module number in the chassis.')
rt_ip_rte_inst = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteInst.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteInst.setDescription('Alternative routing table instance number.')
rt_ip_rte_dest = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 4), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteDest.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteDest.setDescription('The destination IP address of this route.')
rt_ip_rte_mask = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 5), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteMask.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteMask.setDescription('Indicate the mask to be logical-ANDed with the destination address before being compared to the value in the rtIpRteDest field.')
rt_ip_rte_pref = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 6), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRtePref.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRtePref.setDescription('The preference value for this route.')
rt_ip_rte_proto = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))).clone(namedValues=named_values(('direct', 1), ('static', 2), ('ospf', 3), ('rip', 4), ('other', 5), ('all', 6)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteProto.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteProto.setDescription('The routing mechanism via which this route was learned.')
rt_ip_rte_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteIfIndex.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteIfIndex.setDescription('The interface that the frame is forwarded on.')
rt_ip_rte_next_hop = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 9), ip_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteNextHop.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteNextHop.setDescription('The IP address of the next hop of this route.')
rt_ip_rte_state = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpRteState.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteState.setDescription('The state of the route.')
rt_ip_rte_age = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 11), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rtIpRteAge.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteAge.setDescription("The number of seconds since this route was last updated or otherwise detemined to be correct. Note that no semantics of 'too old' can be implied except through knowledge of the routing protocol by which the route was learned.")
rt_ip_rte_metric = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 2, 1, 12), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpRteMetric.setStatus('optional')
if mibBuilder.loadTexts:
rtIpRteMetric.setDescription('The metric of the alternative route.')
rt_ip_static_route_table = mib_table((1, 3, 6, 1, 4, 1, 343, 6, 38, 3))
if mibBuilder.loadTexts:
rtIpStaticRouteTable.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStaticRouteTable.setDescription('A table of all configured static routes.')
rt_ip_static_route_entry = mib_table_row((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1)).setIndexNames((0, 'MIB-INTEL-IP', 'rtIpStRtChassis'), (0, 'MIB-INTEL-IP', 'rtIpStRtModule'), (0, 'MIB-INTEL-IP', 'rtIpStRtInst'), (0, 'MIB-INTEL-IP', 'rtIpStRtDest'), (0, 'MIB-INTEL-IP', 'rtIpStRtMask'), (0, 'MIB-INTEL-IP', 'rtIpStRtPref'), (0, 'MIB-INTEL-IP', 'rtIpStRtIfIndex'), (0, 'MIB-INTEL-IP', 'rtIpStRtNextHop'))
if mibBuilder.loadTexts:
rtIpStaticRouteEntry.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStaticRouteEntry.setDescription('An entry describing a single static route.')
rt_ip_st_rt_chassis = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 1), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtChassis.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtChassis.setDescription('Chassis number in stack that contains the module.')
rt_ip_st_rt_module = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 2), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtModule.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtModule.setDescription('Module number in the chassis.')
rt_ip_st_rt_inst = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 3), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtInst.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtInst.setDescription('Static routing table instance number.')
rt_ip_st_rt_dest = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 4), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtDest.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtDest.setDescription('The destination IP address of this route.')
rt_ip_st_rt_mask = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 5), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtMask.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtMask.setDescription('The destination IP mask of this route.')
rt_ip_st_rt_pref = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 6), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtPref.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtPref.setDescription('The preference value for this route. This value should be unique (neither other static routes to the same destination nor other protocols can use this value).')
rt_ip_st_rt_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 7), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtIfIndex.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtIfIndex.setDescription('The interface that the frame is forwarded on.')
rt_ip_st_rt_next_hop = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 8), ip_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtNextHop.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtNextHop.setDescription('The IP address of the next hop of this route.')
rt_ip_st_rt_metric = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 9), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtMetric.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtMetric.setDescription('The routing metric for this route.')
rt_ip_st_rt_status = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 10), row_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtStatus.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtStatus.setDescription("The status of the route. Setting it to 'destroy'(6) removes the static route from router's configuration.")
rt_ip_st_rt_state = mib_table_column((1, 3, 6, 1, 4, 1, 343, 6, 38, 3, 1, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rtIpStRtState.setStatus('optional')
if mibBuilder.loadTexts:
rtIpStRtState.setDescription('The current state of the route.')
mibBuilder.exportSymbols('MIB-INTEL-IP', rtIpRoutePref=rtIpRoutePref, rtIpStRtIfIndex=rtIpStRtIfIndex, rtIpRteEntry=rtIpRteEntry, rtIpRouteInst=rtIpRouteInst, rtIpStRtMask=rtIpStRtMask, rtIpRouteEntry=rtIpRouteEntry, rtIpRteMask=rtIpRteMask, rtIpRteState=rtIpRteState, rtIpRteProto=rtIpRteProto, rtIpRouteMetric=rtIpRouteMetric, rtIpRteDest=rtIpRteDest, rtIpRteInst=rtIpRteInst, ipr=ipr, rtIpRteAge=rtIpRteAge, rtIpRouteProto=rtIpRouteProto, rtIpRouteNextHop=rtIpRouteNextHop, rtIpRouteModule=rtIpRouteModule, rtIpRteNextHop=rtIpRteNextHop, rtIpRteModule=rtIpRteModule, rtIpStRtDest=rtIpStRtDest, rtIpRteIfIndex=rtIpRteIfIndex, rtIpStaticRouteEntry=rtIpStaticRouteEntry, RowStatus=RowStatus, rtIpStRtMetric=rtIpStRtMetric, rtIpRouteDest=rtIpRouteDest, rtIpRouteChassis=rtIpRouteChassis, rtIpRouteMask=rtIpRouteMask, rtIpRteTable=rtIpRteTable, rtIpRouteTable=rtIpRouteTable, rtIpStRtPref=rtIpStRtPref, rtIpStaticRouteTable=rtIpStaticRouteTable, rtIpRteChassis=rtIpRteChassis, rtIpRouteAge=rtIpRouteAge, rtIpRteMetric=rtIpRteMetric, rtIpStRtState=rtIpStRtState, rtIpRtePref=rtIpRtePref, rtIpStRtChassis=rtIpStRtChassis, rtIpStRtStatus=rtIpStRtStatus, rtIpStRtModule=rtIpStRtModule, rtIpStRtNextHop=rtIpStRtNextHop, rtIpStRtInst=rtIpStRtInst, rtIpRouteIfIndex=rtIpRouteIfIndex) |
#!/usr/bin/env python
while True:
pass
| while True:
pass |
"""Mock turtle module.
"""
def goto(x, y):
pass
def up():
pass
def down():
pass
def color(name):
pass
def begin_fill():
pass
def end_fill():
pass
def forward(steps):
pass
def left(degrees):
pass
| """Mock turtle module.
"""
def goto(x, y):
pass
def up():
pass
def down():
pass
def color(name):
pass
def begin_fill():
pass
def end_fill():
pass
def forward(steps):
pass
def left(degrees):
pass |
'''
Get various integer numbers. In the end, show the average between all values and the lowest and the highest.
Asks the user if they want to continue or not.
'''
number = int(input('Choose a number: '))
again = input('Do you want to continue? [S/N]').strip().upper()
total = 1
minimum = maximum = number
while again == 'S':
number2 = int(input('Choose another number: '))
total += 1
number += number2
again = input('Do you want to continue? [S/N]').strip().upper()
if number2 > maximum:
maximum = number2
elif number2 < minimum:
minimum = number2
print(f'The average of these \033[34m{total}\033[m number is \033[34m{number / total:.2f}\033[m.')
print(f'The highest is \033[34m{maximum}\033[m, and the lowest is \033[34m{minimum}\033[m.')
| """
Get various integer numbers. In the end, show the average between all values and the lowest and the highest.
Asks the user if they want to continue or not.
"""
number = int(input('Choose a number: '))
again = input('Do you want to continue? [S/N]').strip().upper()
total = 1
minimum = maximum = number
while again == 'S':
number2 = int(input('Choose another number: '))
total += 1
number += number2
again = input('Do you want to continue? [S/N]').strip().upper()
if number2 > maximum:
maximum = number2
elif number2 < minimum:
minimum = number2
print(f'The average of these \x1b[34m{total}\x1b[m number is \x1b[34m{number / total:.2f}\x1b[m.')
print(f'The highest is \x1b[34m{maximum}\x1b[m, and the lowest is \x1b[34m{minimum}\x1b[m.') |
# -*- coding:utf-8 -*-
"""
"""
class Delegate:
daily_forge = 0.
gift = property(
lambda obj: obj.share*obj.daily_forge/(obj.vote+obj.cumul-obj.exclude),
None, None,
""
)
@staticmethod
def configure(blocktime=8, delegates=51, reward=2):
assert isinstance(blocktime, int)
assert isinstance(delegates, int)
assert isinstance(reward, (float, int))
Delegate.blocktime = blocktime
Delegate.delegates = delegates
Delegate.reward = float(reward)
Delegate.daily_forge = 24 * 3600./(blocktime*delegates) * reward
def __init__(self, username, share, vote=0, exclude=0):
assert 0. < share < 1.
self.username = username
self.share = float(share)
self.vote = vote
self.exclude = exclude
self.cumul = 0
def daily(self, vote):
return self.share * self.daily_forge * vote/(self.vote+vote-self.exclude)
def yir(self, vote):
total = 365 * self.daily(vote)
return total/vote
def best(*delegates):
return sorted(delegates, key=lambda d:d.gift, reverse=True)[0]
def reset(*delegates):
[setattr(d, "cumul", 0) for d in delegates]
def solve(vote, delegates, step=1):
c = 0
for c in range(step, vote, step):
best(*delegates).cumul += step
best(*delegates).cumul += (vote-c)
return {d.username:d.cumul for d in delegates}
| """
"""
class Delegate:
daily_forge = 0.0
gift = property(lambda obj: obj.share * obj.daily_forge / (obj.vote + obj.cumul - obj.exclude), None, None, '')
@staticmethod
def configure(blocktime=8, delegates=51, reward=2):
assert isinstance(blocktime, int)
assert isinstance(delegates, int)
assert isinstance(reward, (float, int))
Delegate.blocktime = blocktime
Delegate.delegates = delegates
Delegate.reward = float(reward)
Delegate.daily_forge = 24 * 3600.0 / (blocktime * delegates) * reward
def __init__(self, username, share, vote=0, exclude=0):
assert 0.0 < share < 1.0
self.username = username
self.share = float(share)
self.vote = vote
self.exclude = exclude
self.cumul = 0
def daily(self, vote):
return self.share * self.daily_forge * vote / (self.vote + vote - self.exclude)
def yir(self, vote):
total = 365 * self.daily(vote)
return total / vote
def best(*delegates):
return sorted(delegates, key=lambda d: d.gift, reverse=True)[0]
def reset(*delegates):
[setattr(d, 'cumul', 0) for d in delegates]
def solve(vote, delegates, step=1):
c = 0
for c in range(step, vote, step):
best(*delegates).cumul += step
best(*delegates).cumul += vote - c
return {d.username: d.cumul for d in delegates} |
print(3 * 3 == 6)
print(50 % 5 == 0)
Name = "Sam"
print(Name == "SaM")
fruits = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
for fruit in fruits:
if fruit == "apple":
print("Apple is present")
elif "cherry" in fruit:
print("Cherry is also present") | print(3 * 3 == 6)
print(50 % 5 == 0)
name = 'Sam'
print(Name == 'SaM')
fruits = ['apple', 'banana', 'cherry', 'orange', 'kiwi', 'melon', 'mango']
for fruit in fruits:
if fruit == 'apple':
print('Apple is present')
elif 'cherry' in fruit:
print('Cherry is also present') |
#!/usr/bin/python3
'''
helloworld.py
Simple Hello world program. This is considered to be the
first program that anyone would write when learing a new language.
Author: Rich Lynch
Created for merit badge college.
Released to the public under the MIT license.
'''
print ("Hello World") | """
helloworld.py
Simple Hello world program. This is considered to be the
first program that anyone would write when learing a new language.
Author: Rich Lynch
Created for merit badge college.
Released to the public under the MIT license.
"""
print('Hello World') |
# -*- coding: utf-8 -*-
'''
Configuration of Capsul and external software operated through capsul.
'''
| """
Configuration of Capsul and external software operated through capsul.
""" |
version = "0.9.8"
_default_base_dir = "./archive"
class Options:
"""Holds Archiver options."""
def __init__(self, base_dir, use_ssl=False, silent=False, verbose=False, delay=2, thread_check_delay=90, dl_threads_per_site=5, dl_thread_wait=1, skip_thumbs=False, thumbs_only=False, skip_js=False, skip_css=False, follow_child_threads=False, follow_to_other_boards=False, run_once=False):
self.base_dir = base_dir
self.use_ssl = use_ssl
self.silent = silent
self.verbose = verbose
self.delay = float(delay)
self.thread_check_delay = float(thread_check_delay)
self.dl_threads_per_site = int(dl_threads_per_site)
self.dl_thread_wait = float(dl_thread_wait)
self.skip_thumbs = skip_thumbs
self.thumbs_only = thumbs_only
self.skip_js = skip_js
self.skip_css = skip_css
self.follow_child_threads = follow_child_threads
self.follow_to_other_boards = follow_to_other_boards
self.run_once = run_once
class Archiver:
"""Archives the given imageboard threads."""
def __init__(self, options=None):
if options is None:
options = Options(_default_base_dir)
self.options = options
self.callbacks_lock = threading.Lock()
self.callbacks = {"all": []}
self.archivers = []
for archiver in default_archivers:
self.archivers.append(archiver(self.update_status, self.options))
def shutdown(self):
"""Shutdown the archiver."""
for archiver in self.archivers:
archiver.shutdown()
def add_thread(self, url):
"""Archive the given thread if possible"""
url_archived = False
for archiver in self.archivers:
if archiver.url_valid(url):
archiver.add_thread(url)
url_archived = True
if url_archived:
return True
else:
print("We could not find a valid archiver for:", url)
return False
@property
def existing_threads(self):
"""Return how many threads exist."""
threads = 0
for archiver in self.archivers:
threads += archiver.existing_threads
return threads
@property
def files_to_download(self):
"""Return whether we still have files to download."""
for archiver in self.archivers:
if archiver.files_to_download:
return True
return False
def register_callback(self, cb_type, handler):
"""Register a callback."""
with self.callbacks_lock:
if cb_type not in self.callbacks:
self.callbacks[cb_type] = []
if handler not in self.callbacks[cb_type]:
self.callbacks[cb_type].append(handler)
def unregister_callback(self, cb_type, handler):
"""Remove a callback."""
with self.callbacks_lock:
if cb_type in self.callbacks and handler in self.callbacks[cb_type]:
self.callbacks[cb_type].remove(handler)
def update_status(self, cb_type, info):
"""Update thread status, call callbacks where appropriate."""
with self.callbacks_lock:
called = []
if cb_type in self.callbacks:
for handler in self.callbacks[cb_type]:
handler(cb_type, info)
called.append(handler)
for handler in self.callbacks["all"]:
if handler not in called:
handler(cb_type, info) | version = '0.9.8'
_default_base_dir = './archive'
class Options:
"""Holds Archiver options."""
def __init__(self, base_dir, use_ssl=False, silent=False, verbose=False, delay=2, thread_check_delay=90, dl_threads_per_site=5, dl_thread_wait=1, skip_thumbs=False, thumbs_only=False, skip_js=False, skip_css=False, follow_child_threads=False, follow_to_other_boards=False, run_once=False):
self.base_dir = base_dir
self.use_ssl = use_ssl
self.silent = silent
self.verbose = verbose
self.delay = float(delay)
self.thread_check_delay = float(thread_check_delay)
self.dl_threads_per_site = int(dl_threads_per_site)
self.dl_thread_wait = float(dl_thread_wait)
self.skip_thumbs = skip_thumbs
self.thumbs_only = thumbs_only
self.skip_js = skip_js
self.skip_css = skip_css
self.follow_child_threads = follow_child_threads
self.follow_to_other_boards = follow_to_other_boards
self.run_once = run_once
class Archiver:
"""Archives the given imageboard threads."""
def __init__(self, options=None):
if options is None:
options = options(_default_base_dir)
self.options = options
self.callbacks_lock = threading.Lock()
self.callbacks = {'all': []}
self.archivers = []
for archiver in default_archivers:
self.archivers.append(archiver(self.update_status, self.options))
def shutdown(self):
"""Shutdown the archiver."""
for archiver in self.archivers:
archiver.shutdown()
def add_thread(self, url):
"""Archive the given thread if possible"""
url_archived = False
for archiver in self.archivers:
if archiver.url_valid(url):
archiver.add_thread(url)
url_archived = True
if url_archived:
return True
else:
print('We could not find a valid archiver for:', url)
return False
@property
def existing_threads(self):
"""Return how many threads exist."""
threads = 0
for archiver in self.archivers:
threads += archiver.existing_threads
return threads
@property
def files_to_download(self):
"""Return whether we still have files to download."""
for archiver in self.archivers:
if archiver.files_to_download:
return True
return False
def register_callback(self, cb_type, handler):
"""Register a callback."""
with self.callbacks_lock:
if cb_type not in self.callbacks:
self.callbacks[cb_type] = []
if handler not in self.callbacks[cb_type]:
self.callbacks[cb_type].append(handler)
def unregister_callback(self, cb_type, handler):
"""Remove a callback."""
with self.callbacks_lock:
if cb_type in self.callbacks and handler in self.callbacks[cb_type]:
self.callbacks[cb_type].remove(handler)
def update_status(self, cb_type, info):
"""Update thread status, call callbacks where appropriate."""
with self.callbacks_lock:
called = []
if cb_type in self.callbacks:
for handler in self.callbacks[cb_type]:
handler(cb_type, info)
called.append(handler)
for handler in self.callbacks['all']:
if handler not in called:
handler(cb_type, info) |
class StepsLoss:
def __init__(self, loss):
self.steps = None
self.loss = loss
def set_steps(self, steps):
self.steps = steps
def __call__(self, y_pred, y_true):
if self.steps is not None:
y_pred = y_pred[:, :, : self.steps]
y_true = y_true[:, :, : self.steps]
# print(f"y_pred.shape: {y_pred.shape}, y_true.shape: {y_true.shape}")
return self.loss(y_pred, y_true)
| class Stepsloss:
def __init__(self, loss):
self.steps = None
self.loss = loss
def set_steps(self, steps):
self.steps = steps
def __call__(self, y_pred, y_true):
if self.steps is not None:
y_pred = y_pred[:, :, :self.steps]
y_true = y_true[:, :, :self.steps]
return self.loss(y_pred, y_true) |
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
# O(n) time | O(n) space
lst = []
startRow, endRow = 0, len(matrix) - 1
startColumn, endColumn = 0, len(matrix[0]) - 1
place = (0, 0)
while startRow <= endRow and startColumn <= endColumn:
if place == (0, 0):
for j in range(startColumn, endColumn + 1):
lst.append(matrix[startRow][j])
startRow += 1
place = (0, -1)
elif place == (0, -1):
for i in range(startRow, endRow + 1):
lst.append(matrix[i][endColumn])
endColumn -= 1
place = (-1, -1)
elif place == (-1, -1):
for j in reversed(range(startColumn, endColumn + 1)):
lst.append(matrix[endRow][j])
endRow -= 1
place = (-1, 0)
elif place == (-1, 0):
for i in reversed(range(startRow, endRow + 1)):
lst.append(matrix[i][startColumn])
startColumn += 1
place = (0, 0)
return lst
| class Solution:
def spiral_order(self, matrix: List[List[int]]) -> List[int]:
lst = []
(start_row, end_row) = (0, len(matrix) - 1)
(start_column, end_column) = (0, len(matrix[0]) - 1)
place = (0, 0)
while startRow <= endRow and startColumn <= endColumn:
if place == (0, 0):
for j in range(startColumn, endColumn + 1):
lst.append(matrix[startRow][j])
start_row += 1
place = (0, -1)
elif place == (0, -1):
for i in range(startRow, endRow + 1):
lst.append(matrix[i][endColumn])
end_column -= 1
place = (-1, -1)
elif place == (-1, -1):
for j in reversed(range(startColumn, endColumn + 1)):
lst.append(matrix[endRow][j])
end_row -= 1
place = (-1, 0)
elif place == (-1, 0):
for i in reversed(range(startRow, endRow + 1)):
lst.append(matrix[i][startColumn])
start_column += 1
place = (0, 0)
return lst |
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 20 14:15:56 2018
@author: Chris
"""
path = r'C:\Users\Chris\Desktop\Machine Learning Raw Data\air-quality-madrid\stations.csv'
stations = pd.read_csv(path)
stations.head()
geometry = [Point(xy) for xy in zip(stations['lon'], stations['lat'])]
crs = {'init': 'epsg:4326'}
geoDF_stations = gpd.GeoDataFrame(stations, crs=crs, geometry=geometry)
geoDF_stations_new = geoDF_stations.to_crs({'init': 'epsg:25830'})
#geoDF_stations.head()
# Plot all points
#geoDF_stations.plot(marker='co', color='r', markersize=10.0)
streetsystem = gpd.read_file('C:/Users/Chris/Desktop/Machine Learning Raw Data/900BTQKCJT/call2016.shp')
#streetsystem.plot(color='green', markersize=5);
#geoDF_stations.crs = {'init' :'epsg:4326'}
# you could shorten it to a one-liner, but it's a lot less readable:
#streetsystem = LineString(zip(*convert_etrs89_to_lonlat(*zip(*streetsaslinestring.coords))))
base = geoDF_stations_new.plot(color='white', edgecolor='red',markersize=100.0)
streetsystem.plot(ax=base, color='blue',markersize=0.1) | """
Created on Sat Oct 20 14:15:56 2018
@author: Chris
"""
path = 'C:\\Users\\Chris\\Desktop\\Machine Learning Raw Data\\air-quality-madrid\\stations.csv'
stations = pd.read_csv(path)
stations.head()
geometry = [point(xy) for xy in zip(stations['lon'], stations['lat'])]
crs = {'init': 'epsg:4326'}
geo_df_stations = gpd.GeoDataFrame(stations, crs=crs, geometry=geometry)
geo_df_stations_new = geoDF_stations.to_crs({'init': 'epsg:25830'})
streetsystem = gpd.read_file('C:/Users/Chris/Desktop/Machine Learning Raw Data/900BTQKCJT/call2016.shp')
base = geoDF_stations_new.plot(color='white', edgecolor='red', markersize=100.0)
streetsystem.plot(ax=base, color='blue', markersize=0.1) |
# network image size
IMAGE_WIDTH = 128
IMAGE_HEIGHT = 64
# license number construction
DOWNSAMPLE_FACTOR = 2 ** 2 # <= pool size ** number of pool layers
MAX_TEXT_LEN = 10
| image_width = 128
image_height = 64
downsample_factor = 2 ** 2
max_text_len = 10 |
#!/usr/bin/python
def readFile(fileName):
paramsFile = open(fileName)
paramFileLines = paramsFile.readlines()
return paramFileLines
#number of expected molecular lines
def getExpectedLineNum(fileName):
lines = readFile(fileName)
print(lines[0])
return lines[0]
#frequency ranges of all expected molecular lines
#NOTE: deprecated in cluster environment
def getExpectedLines(fileName):
result = []
lines = readFile(fileName)
for i in range(1, len(lines)):
line = lines[i].split(" ")
result.append((line[0], line[1][0:len(line[1]) - 1]))
print(result)
return result | def read_file(fileName):
params_file = open(fileName)
param_file_lines = paramsFile.readlines()
return paramFileLines
def get_expected_line_num(fileName):
lines = read_file(fileName)
print(lines[0])
return lines[0]
def get_expected_lines(fileName):
result = []
lines = read_file(fileName)
for i in range(1, len(lines)):
line = lines[i].split(' ')
result.append((line[0], line[1][0:len(line[1]) - 1]))
print(result)
return result |
#!/usr/bin/env python3
# https://abc051.contest.atcoder.jp/tasks/abc051_d
INF = 10 ** 9
n, m = map(int, input().split())
a = [[INF] * n for _ in range(n)]
e = [None] * m
for i in range(n): a[i][i] = 0
for i in range(m):
u, v, w = map(int, input().split())
u -= 1
v -= 1
e[i] = (u, v, w)
a[u][v] = w
a[v][u] = w
for k in range(n):
for i in range(n):
for j in range(n):
a[i][j] = min(a[i][j], a[i][k] + a[k][j])
c = 0
for u, v, w in e:
if a[u][v] != w: c += 1
print(c)
| inf = 10 ** 9
(n, m) = map(int, input().split())
a = [[INF] * n for _ in range(n)]
e = [None] * m
for i in range(n):
a[i][i] = 0
for i in range(m):
(u, v, w) = map(int, input().split())
u -= 1
v -= 1
e[i] = (u, v, w)
a[u][v] = w
a[v][u] = w
for k in range(n):
for i in range(n):
for j in range(n):
a[i][j] = min(a[i][j], a[i][k] + a[k][j])
c = 0
for (u, v, w) in e:
if a[u][v] != w:
c += 1
print(c) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class ListNode:
def __init__(self, x, n):
self.val = x
self.next = n
class Solution:
def mergeTwoLists(self, l1, l2):
pre = tmp = None
cur = l1
while cur and cur.next:
if cur.val > l2.val:
tmp = cur
cur = l2
if pre:
pre.next = cur
cur.next = tmp
l2 = l2.next
if not l2:
break
cur = cur.next
if l2:
cur.next = l2
return l1
def createTestA(self):
l1 = ListNode(1, ListNode(2, ListNode(4, None)))
l2 = ListNode(1, ListNode(3, ListNode(4, None)))
print(self.mergeTwoLists(l1, l2))
t = Solution()
t.createTestA()
| class Listnode:
def __init__(self, x, n):
self.val = x
self.next = n
class Solution:
def merge_two_lists(self, l1, l2):
pre = tmp = None
cur = l1
while cur and cur.next:
if cur.val > l2.val:
tmp = cur
cur = l2
if pre:
pre.next = cur
cur.next = tmp
l2 = l2.next
if not l2:
break
cur = cur.next
if l2:
cur.next = l2
return l1
def create_test_a(self):
l1 = list_node(1, list_node(2, list_node(4, None)))
l2 = list_node(1, list_node(3, list_node(4, None)))
print(self.mergeTwoLists(l1, l2))
t = solution()
t.createTestA() |
class AsupDestination(basestring):
"""
smtp|http|noteto|retransmit
Possible values:
<ul>
<li> "smtp" ,
<li> "http" ,
<li> "noteto" ,
<li> "retransmit"
</ul>
"""
@staticmethod
def get_api_name():
return "asup-destination"
| class Asupdestination(basestring):
"""
smtp|http|noteto|retransmit
Possible values:
<ul>
<li> "smtp" ,
<li> "http" ,
<li> "noteto" ,
<li> "retransmit"
</ul>
"""
@staticmethod
def get_api_name():
return 'asup-destination' |
def parseRaspFile(filepath):
headerpassed = False
data = {
'motor name':None,
'motor diameter':None,
'motor length':None,
'motor delay': None,
'propellant weight': None,
'total weight': None,
'manufacturer': None,
'thrust data': {'time':[],'thrust':[]}
}
with open(filepath) as enginefile:
while True:
line = enginefile.readline()
if not line:
break
if not headerpassed:
if line[0].isalpha():
headerpassed = True
name, diam, length, delay, prop_weight, total_weight, manufacturer = parseRaspHeader(line)
data['motor name'] = name
data['motor diameter'] = diam
data['motor length'] = length
data['motor delay'] = delay
data['propellant weight'] = prop_weight
data['total weight'] = total_weight
data['manufacturer'] = manufacturer
else:
try:
time, thrust = parseRaspDataLine(line)
data['thrust data']['time'].append(time)
data['thrust data']['thrust'].append(thrust)
except:
break
enginefile.close()
return data
def parseRaspDataLine(line):
# first float is the time
# second is the thrust (N)
contents = line.split()
time = float(contents[0])
thrust = float(contents[1])
return time, thrust
def parseRaspHeader(header):
# the content of the header is as follows:
# 1. Motor Name
# 2. Motor Diameter
# 3. Motor Length
# 4. Motor Delay
# 5. Propellant Weight
# 6. Total Weight
# 7. Manufacturer
# parse by spaces
headercontents = header.split()
motor_name = headercontents[0]
motor_diameter = float(headercontents[1])
motor_length = float(headercontents[2])
motor_delay = float(headercontents[3])
propellant_weight = float(headercontents[4])
total_weight = float(headercontents[5])
manufacturer = headercontents[6]
return motor_name, motor_diameter, motor_length, motor_delay, propellant_weight, total_weight, manufacturer
| def parse_rasp_file(filepath):
headerpassed = False
data = {'motor name': None, 'motor diameter': None, 'motor length': None, 'motor delay': None, 'propellant weight': None, 'total weight': None, 'manufacturer': None, 'thrust data': {'time': [], 'thrust': []}}
with open(filepath) as enginefile:
while True:
line = enginefile.readline()
if not line:
break
if not headerpassed:
if line[0].isalpha():
headerpassed = True
(name, diam, length, delay, prop_weight, total_weight, manufacturer) = parse_rasp_header(line)
data['motor name'] = name
data['motor diameter'] = diam
data['motor length'] = length
data['motor delay'] = delay
data['propellant weight'] = prop_weight
data['total weight'] = total_weight
data['manufacturer'] = manufacturer
else:
try:
(time, thrust) = parse_rasp_data_line(line)
data['thrust data']['time'].append(time)
data['thrust data']['thrust'].append(thrust)
except:
break
enginefile.close()
return data
def parse_rasp_data_line(line):
contents = line.split()
time = float(contents[0])
thrust = float(contents[1])
return (time, thrust)
def parse_rasp_header(header):
headercontents = header.split()
motor_name = headercontents[0]
motor_diameter = float(headercontents[1])
motor_length = float(headercontents[2])
motor_delay = float(headercontents[3])
propellant_weight = float(headercontents[4])
total_weight = float(headercontents[5])
manufacturer = headercontents[6]
return (motor_name, motor_diameter, motor_length, motor_delay, propellant_weight, total_weight, manufacturer) |
"""
Author: Kagaya john
Tutorial 9 : Dictionaries
"""
"""
Python Dictionaries
Dictionary
A dictionary is a collection which is unordered, changeable and indexed.
In Python dictionaries are written with curly brackets, and they have keys and values.
Example
Using the len() method to return the number of items:"""
thisdict = {
"apple": "green",
"banana": "yellow",
"cherry": "red"
}
print(thisdict)
#Change the apple color to "red":
thisdict = {
"apple": "green",
"banana": "yellow",
"cherry": "red"
}
thisdict["apple"] = "red"
print(thisdict)
| """
Author: Kagaya john
Tutorial 9 : Dictionaries
"""
'\nPython Dictionaries\nDictionary\nA dictionary is a collection which is unordered, changeable and indexed.\n In Python dictionaries are written with curly brackets, and they have keys and values.\n\nExample\nUsing the len() method to return the number of items:'
thisdict = {'apple': 'green', 'banana': 'yellow', 'cherry': 'red'}
print(thisdict)
thisdict = {'apple': 'green', 'banana': 'yellow', 'cherry': 'red'}
thisdict['apple'] = 'red'
print(thisdict) |
class Solution:
def maxSumDivThree(self, nums: List[int]) -> int:
ones = []
twos = []
ans = 0
for num in nums:
ans += num
if num % 3 == 1:
ones.append(num)
elif num % 3 == 2:
twos.append(num)
if ans % 3 == 0:
return ans
ones.sort()
twos.sort()
if ans % 3 == 1:
best = 0
if ones:
best = ans - ones[0]
if len(twos) >= 2:
best = max(best, ans - twos[0] - twos[1])
else: # ans % 3 == 2:
best = 0
if twos:
best = ans - twos[0]
if len(ones) >= 2:
best = max(best, ans - ones[0] - ones[1])
return best
| class Solution:
def max_sum_div_three(self, nums: List[int]) -> int:
ones = []
twos = []
ans = 0
for num in nums:
ans += num
if num % 3 == 1:
ones.append(num)
elif num % 3 == 2:
twos.append(num)
if ans % 3 == 0:
return ans
ones.sort()
twos.sort()
if ans % 3 == 1:
best = 0
if ones:
best = ans - ones[0]
if len(twos) >= 2:
best = max(best, ans - twos[0] - twos[1])
else:
best = 0
if twos:
best = ans - twos[0]
if len(ones) >= 2:
best = max(best, ans - ones[0] - ones[1])
return best |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Problem 031
The Minion Game
Source : https://www.hackerrank.com/challenges/the-minion-game/problem
"""
def is_vowel(c):
return c in ("A","E","I","O","U")
def minion_game(word):
p1, p2 = 0, 0
nb = len(word)
for i in range(nb):
if is_vowel(word[i]):
p2 += nb - i
else:
p1 += nb - i
if p1 > p2:
print("Stuart", p1)
elif p1 < p2:
print("Kevin", p2)
else:
print("Draw")
if __name__ == '__main__':
s = input()
minion_game(s)
| """Problem 031
The Minion Game
Source : https://www.hackerrank.com/challenges/the-minion-game/problem
"""
def is_vowel(c):
return c in ('A', 'E', 'I', 'O', 'U')
def minion_game(word):
(p1, p2) = (0, 0)
nb = len(word)
for i in range(nb):
if is_vowel(word[i]):
p2 += nb - i
else:
p1 += nb - i
if p1 > p2:
print('Stuart', p1)
elif p1 < p2:
print('Kevin', p2)
else:
print('Draw')
if __name__ == '__main__':
s = input()
minion_game(s) |
def evaluate_shard(out_csv_name, pw_ji, labels_x, labels_y, d = 0.00, d_step = 0.005, d_max=1.0):
h.save_to_csv(data_rows=[[
"Distance Threshhold",
"True Positives",
"False Positives",
"True Negative",
"False Negative",
"Num True Same",
"Num True Diff",
]], outfile_name=out_csv_name, mode="w")
# calculate true accepts / false accepts based on labels
n_labels = len(labels_x)
tl_row = np.repeat( np.array(labels_x).reshape((n_labels,1)), n_labels, axis=1 )
tl_col = np.repeat( np.array(labels_y).reshape((1,n_labels)), n_labels, axis=0 )
p_same = np.equal(tl_row, tl_col).astype("int8")
p_diff = np.not_equal(tl_row, tl_col).astype("int8")
num_true_same = p_same.sum()
num_true_diff = p_diff.sum()
while True:
calc_same = np.zeros((n_labels, n_labels))
calc_same[np.where(pw_ji<=d)]=1
tp = np.sum(np.logical_and(calc_same, p_same))
fp = np.sum(np.logical_and(calc_same, np.logical_not(p_same)))
tn = np.sum(np.logical_and(np.logical_not(calc_same), np.logical_not(p_same)))
fn = np.sum(np.logical_and(np.logical_not(calc_same), p_same))
h.save_to_csv(data_rows=[[d, tp, fp, tn, fn,num_true_same,num_true_diff]], outfile_name=out_csv_name, mode="a")
d+=d_step
if d>d_max:
break
def evaluate_all_shards(inputs, labels, shard_size,shard_indizes, results_fn, d_start=0.0, d_step=0.005, d_max=1.0 ):
for shard_index in shard_indizes:
shard_x, shard_y = shard_index
print("Current shard", shard_index)
start_index_x = shard_x*shard_size
start_index_y = shard_y*shard_size
end_index_x = min((shard_x+1)*shard_size, num_test_examples)
end_index_y = min((shard_y+1)*shard_size, num_test_examples)
# calcualte pairwise distances
shard_inputs_x = inputs[start_index_x:end_index_x,:]
shard_labels_x = labels[start_index_x:end_index_x]
shard_inputs_y = inputs[start_index_y:end_index_y,:]
shard_labels_y = labels[start_index_y:end_index_y]
pw_ji = pairwise_distances(shard_inputs_x,shard_inputs_y, metric=jaccard_distance, n_jobs=8)
# evaluate pairwise distances
out_csv_name = results_fn+"_%0.2d-%0.2d"%(shard_x, shard_y)
evaluate_shard(out_csv_name, pw_ji, shard_labels_x, shard_labels_y, d=d_start, d_step = d_step, d_max=d_max)
def run_evaluation(inputs, labels, shard_size, results_fn, d_start=0.0, d_step=0.005, d_max=1.0):
results_fn = results_fn%shard_size
num_test_examples = inputs.shape[0]
num_x = inputs.shape[0]//shard_size
if not num_test_examples%shard_size==0 :# need to be a square matrix
print("Allowed shard sizes")
for i in range(100, num_test_examples):
if num_test_examples%i==0:
print(i)
0/0
shard_indizes = list(itertools.product(range(num_x),repeat=2))
num_shards = len(shard_indizes)
num_distances = len(list(np.arange(d_start,d_max,d_step)))
num_metrics = 7
evaluate_all_shards(inputs, labels, shard_size, shard_indizes, results_fn, d_start, d_step, d_max )
all_data = np.ndarray(shape=(num_shards, num_distances, num_metrics), dtype="float32")
for i, shard_index in enumerate(shard_indizes):
# load shard
shard_x, shard_y = shard_index
out_csv_name = results_fn+"_%0.2d-%0.2d"%(shard_x, shard_y)
shard_data = h.load_from_csv(out_csv_name)
shard_data = shard_data[1:] # cut header row
all_data[i] = np.array(shard_data)
final_data = np.ndarray(shape=(num_distances, 10), dtype="float32")
final_data[:,0] = all_data[0,:,0] # all distances (are same over all shards)
final_data[:,1] = all_data.sum(axis=0)[:,1] # True Positives
final_data[:,2] = all_data.sum(axis=0)[:,2] # False Positives
final_data[:,3] = all_data.sum(axis=0)[:,3] # True Negatives
final_data[:,4] = all_data.sum(axis=0)[:,4] # False Negatives
final_data[:,5] = all_data.sum(axis=0)[:,5] # Num true same (are same over all shards)
final_data[:,6] = all_data.sum(axis=0)[:,6] # Num true diff (are same over all shards)
final_data[:,7] = final_data[:,1]/final_data[:,5] # validation rate
final_data[:,8] = final_data[:,2]/final_data[:,6] # false acceptance rate
final_data[:,9] = (final_data[:,1] + final_data[:,3]) / (final_data[:,1:1+4].sum(axis=1))
h.save_to_csv(data_rows=[[
"Distance Threshhold",
"True Positives",
"False Positives",
"True Negative",
"False Negative",
"Num true same",
"Num true diff",
"Validation Rate",
"False Acceptance Rate",
"Accuracy"
]], outfile_name=results_fn, mode="w", convert_float=False)
h.save_to_csv(data_rows=final_data, outfile_name=results_fn, mode="a", convert_float=True)
logger.info("Evaluation done, saved to '%s'"%results_fn)
return final_data | def evaluate_shard(out_csv_name, pw_ji, labels_x, labels_y, d=0.0, d_step=0.005, d_max=1.0):
h.save_to_csv(data_rows=[['Distance Threshhold', 'True Positives', 'False Positives', 'True Negative', 'False Negative', 'Num True Same', 'Num True Diff']], outfile_name=out_csv_name, mode='w')
n_labels = len(labels_x)
tl_row = np.repeat(np.array(labels_x).reshape((n_labels, 1)), n_labels, axis=1)
tl_col = np.repeat(np.array(labels_y).reshape((1, n_labels)), n_labels, axis=0)
p_same = np.equal(tl_row, tl_col).astype('int8')
p_diff = np.not_equal(tl_row, tl_col).astype('int8')
num_true_same = p_same.sum()
num_true_diff = p_diff.sum()
while True:
calc_same = np.zeros((n_labels, n_labels))
calc_same[np.where(pw_ji <= d)] = 1
tp = np.sum(np.logical_and(calc_same, p_same))
fp = np.sum(np.logical_and(calc_same, np.logical_not(p_same)))
tn = np.sum(np.logical_and(np.logical_not(calc_same), np.logical_not(p_same)))
fn = np.sum(np.logical_and(np.logical_not(calc_same), p_same))
h.save_to_csv(data_rows=[[d, tp, fp, tn, fn, num_true_same, num_true_diff]], outfile_name=out_csv_name, mode='a')
d += d_step
if d > d_max:
break
def evaluate_all_shards(inputs, labels, shard_size, shard_indizes, results_fn, d_start=0.0, d_step=0.005, d_max=1.0):
for shard_index in shard_indizes:
(shard_x, shard_y) = shard_index
print('Current shard', shard_index)
start_index_x = shard_x * shard_size
start_index_y = shard_y * shard_size
end_index_x = min((shard_x + 1) * shard_size, num_test_examples)
end_index_y = min((shard_y + 1) * shard_size, num_test_examples)
shard_inputs_x = inputs[start_index_x:end_index_x, :]
shard_labels_x = labels[start_index_x:end_index_x]
shard_inputs_y = inputs[start_index_y:end_index_y, :]
shard_labels_y = labels[start_index_y:end_index_y]
pw_ji = pairwise_distances(shard_inputs_x, shard_inputs_y, metric=jaccard_distance, n_jobs=8)
out_csv_name = results_fn + '_%0.2d-%0.2d' % (shard_x, shard_y)
evaluate_shard(out_csv_name, pw_ji, shard_labels_x, shard_labels_y, d=d_start, d_step=d_step, d_max=d_max)
def run_evaluation(inputs, labels, shard_size, results_fn, d_start=0.0, d_step=0.005, d_max=1.0):
results_fn = results_fn % shard_size
num_test_examples = inputs.shape[0]
num_x = inputs.shape[0] // shard_size
if not num_test_examples % shard_size == 0:
print('Allowed shard sizes')
for i in range(100, num_test_examples):
if num_test_examples % i == 0:
print(i)
0 / 0
shard_indizes = list(itertools.product(range(num_x), repeat=2))
num_shards = len(shard_indizes)
num_distances = len(list(np.arange(d_start, d_max, d_step)))
num_metrics = 7
evaluate_all_shards(inputs, labels, shard_size, shard_indizes, results_fn, d_start, d_step, d_max)
all_data = np.ndarray(shape=(num_shards, num_distances, num_metrics), dtype='float32')
for (i, shard_index) in enumerate(shard_indizes):
(shard_x, shard_y) = shard_index
out_csv_name = results_fn + '_%0.2d-%0.2d' % (shard_x, shard_y)
shard_data = h.load_from_csv(out_csv_name)
shard_data = shard_data[1:]
all_data[i] = np.array(shard_data)
final_data = np.ndarray(shape=(num_distances, 10), dtype='float32')
final_data[:, 0] = all_data[0, :, 0]
final_data[:, 1] = all_data.sum(axis=0)[:, 1]
final_data[:, 2] = all_data.sum(axis=0)[:, 2]
final_data[:, 3] = all_data.sum(axis=0)[:, 3]
final_data[:, 4] = all_data.sum(axis=0)[:, 4]
final_data[:, 5] = all_data.sum(axis=0)[:, 5]
final_data[:, 6] = all_data.sum(axis=0)[:, 6]
final_data[:, 7] = final_data[:, 1] / final_data[:, 5]
final_data[:, 8] = final_data[:, 2] / final_data[:, 6]
final_data[:, 9] = (final_data[:, 1] + final_data[:, 3]) / final_data[:, 1:1 + 4].sum(axis=1)
h.save_to_csv(data_rows=[['Distance Threshhold', 'True Positives', 'False Positives', 'True Negative', 'False Negative', 'Num true same', 'Num true diff', 'Validation Rate', 'False Acceptance Rate', 'Accuracy']], outfile_name=results_fn, mode='w', convert_float=False)
h.save_to_csv(data_rows=final_data, outfile_name=results_fn, mode='a', convert_float=True)
logger.info("Evaluation done, saved to '%s'" % results_fn)
return final_data |
__query_all = {
# DO NOT CHANGE THE FIRST KEY VALUE, IT HAS TO BE FIRST.
'question_select_all_desc_by_date':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC',
'question_select_all_asc_by_date':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time ASC',
'question_select_all_desc_by_view':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY view_number DESC',
'question_select_all_asc_by_view':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY view_number ASC',
'question_select_all_desc_by_vote':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY vote_number DESC',
'question_select_all_asc_by_vote':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY vote_number ASC',
'question_select_all_desc_by_title':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY title DESC',
'question_select_all_asc_by_title':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY title ASC',
'question_select_all_desc_by_question':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY message DESC',
'question_select_all_asc_by_question':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY message ASC',
'question_select_limit_5_desc_by_date':
'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC LIMIT 5',
'question_select_by_id':
"""SELECT id, submission_time, view_number, vote_number, title, message, image, user_id
FROM question WHERE id = %s""",
'question_update_view_number_by_id':
'UPDATE question SET view_number = view_number + 1 WHERE id = %s',
'answer_select_by_id':
"""SELECT id, submission_time, vote_number, question_id, message, image, user_id, acceptance
FROM answer WHERE question_id = %s ORDER BY submission_time DESC""",
'question_update_vote_number_by_id':
'UPDATE question SET vote_number = vote_number + %s WHERE id = %s',
'answer_update_vote_number_by_id':
'UPDATE answer SET vote_number = vote_number + %s WHERE id = %s',
'question_insert':
'INSERT INTO question (title, message, user_id) VALUES (%s, %s, %s)',
'answer_insert':
'INSERT INTO answer (question_id, message, user_id) VALUES (%s, %s, %s)',
'answer_get_img_path':
'SELECT image FROM answer WHERE question_id = %s',
'question_delete':
'DELETE FROM question WHERE id = %s RETURNING image',
'question_update':
'UPDATE question SET title = %s, message = %s WHERE id = %s',
'question_update_img':
'UPDATE question SET image = %s WHERE id = %s',
'answer_update_img':
'UPDATE answer SET image = %s WHERE id = %s',
'answer_delete':
'DELETE FROM answer WHERE id = %s RETURNING image, question_id',
'answer_count_fk_question_id':
'SELECT COUNT(question_id) FROM answer WHERE question_id = %s',
'comment_insert_to_question':
'INSERT INTO comment (question_id, message, user_id) VALUES (%s, %s, %s)',
'comment_insert_to_answer':
'INSERT INTO comment (question_id, answer_id, message, user_id) VALUES (%s, %s, %s, %s)',
'comment_select_by_question_id':
'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE question_id = %s ORDER BY submission_time DESC',
'comment_select_by_comment_id':
'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE id = %s',
'comment_update_by_id':
'UPDATE comment SET message = %s, submission_time = NOW(), edited_number = edited_number + 1 WHERE id = %s',
'advanced_search':
"""SELECT question.id, 'Q' || question.id, question.title || ' ' || question.message, question.submission_time AS date
FROM question
WHERE question.title || ' ' || question.message ILIKE %(search)s
UNION
SELECT answer.question_id, 'A' || answer.question_id, answer.message, answer.submission_time AS date
FROM answer
WHERE answer.message ILIKE %(search)s
UNION
SELECT comment.question_id, 'C' || comment.question_id, comment.message, comment.submission_time AS date
FROM comment
WHERE comment.message ILIKE %(search)s
ORDER BY date DESC""",
'questions_search':
"""SELECT DISTINCT q.id, q.submission_time, q.view_number, q.vote_number, q.title, q.message, q.image
FROM question q
INNER JOIN answer a ON q.id = a.question_id
WHERE (q.title ILIKE %(search)s OR q.message ILIKE %(search)s) OR a.message ILIKE %(search)s
ORDER BY q.submission_time DESC""",
'tag_select':
'SELECT id, title FROM tag ORDER BY title',
'question_tag_insert':
'INSERT INTO question_tag (question_id, tag_id) VALUES (%s, %s)',
'question_tag_select_by_question_id':
'SELECT id, question_id, tag_id FROM question_tag WHERE question_id = %s',
'tag_insert':
'INSERT INTO tag (title) VALUES (%s)',
'tag_question_tag_select_by_question_id':
"""SELECT question_tag.id, tag.title
FROM tag, question_tag
WHERE question_tag.tag_id = tag.id AND question_tag.question_id = %s
ORDER BY tag.title""",
'question_tag_delete_by_id':
'DELETE FROM question_tag WHERE id = %s',
'comment_delete':
'DELETE FROM comment WHERE id = %s RETURNING question_id',
'answer_update_by_id':
'UPDATE answer SET message = %s WHERE id = %s',
'answer_select_message_by_id':
'SELECT message FROM answer WHERE id = %s',
'users_registration':
'INSERT INTO users (email, pwd) VALUES (%s, %s)',
'users_select_by_email':
'SELECT id, email, pwd FROM users WHERE email = %s',
'users_activation':
"""SELECT u.id, u.email, u.registration_time,
(SELECT COUNT(q.user_id) FROM question AS q WHERE q.user_id = u.id),
(SELECT COUNT(a.user_id) FROM answer AS a WHERE a.user_id = u.id),
(SELECT COUNT(c.user_id) FROM comment AS c WHERE c.user_id = u.id), u.reputation
FROM users AS u
GROUP BY u.id
ORDER BY u.email""",
'user_activation_page':
"""SELECT u.id, u.email, u.registration_time,
(SELECT COUNT(q.user_id) FROM question AS q WHERE q.user_id = u.id),
(SELECT COUNT(a.user_id) FROM answer AS a WHERE a.user_id = u.id),
(SELECT COUNT(c.user_id) FROM comment AS c WHERE c.user_id = u.id), u.reputation
FROM users AS u
WHERE u.id = %s
GROUP BY u.id""",
'question_select_by_user_id':
"""SELECT id, submission_time, view_number, vote_number, title, message
FROM question WHERE user_id = %s ORDER BY submission_time DESC""",
'answer_select_by_user_id':
"""SELECT id, submission_time, vote_number, question_id, message
FROM answer WHERE user_id = %s ORDER BY submission_time DESC""",
'comment_select_by_user_id':
'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE user_id = %s',
'answer_update_acceptance_by_id':
'UPDATE answer SET acceptance = %s WHERE id = %s',
'users_gain_lost_reputation':
'UPDATE users SET reputation = reputation + %s WHERE id = %s',
'tag_select_list_count_questions':
"""SELECT t.id, t.title, COUNT(qt.tag_id)
FROM tag AS t
LEFT JOIN question_tag AS qt ON t.id = qt.tag_id
GROUP BY t.id
ORDER BY t.title""",
'question_select_by_tag':
"""SELECT q.id, q.submission_time, q.view_number, q.vote_number, q.title, q.message
FROM question AS q
INNER JOIN question_tag AS qt ON qt.question_id = q.id
WHERE qt.tag_id = %s
ORDER BY q.submission_time DESC""",
}
class Query:
def __init__(self, query_dict):
self.__query = query_dict
def __getattr__(self, key):
try:
return self.__query[key]
except KeyError as e:
raise AttributeError(e)
query = Query(__query_all)
| __query_all = {'question_select_all_desc_by_date': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC', 'question_select_all_asc_by_date': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time ASC', 'question_select_all_desc_by_view': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY view_number DESC', 'question_select_all_asc_by_view': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY view_number ASC', 'question_select_all_desc_by_vote': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY vote_number DESC', 'question_select_all_asc_by_vote': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY vote_number ASC', 'question_select_all_desc_by_title': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY title DESC', 'question_select_all_asc_by_title': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY title ASC', 'question_select_all_desc_by_question': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY message DESC', 'question_select_all_asc_by_question': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY message ASC', 'question_select_limit_5_desc_by_date': 'SELECT id, submission_time, view_number, vote_number, title, message, image FROM question ORDER BY submission_time DESC LIMIT 5', 'question_select_by_id': 'SELECT id, submission_time, view_number, vote_number, title, message, image, user_id \n FROM question WHERE id = %s', 'question_update_view_number_by_id': 'UPDATE question SET view_number = view_number + 1 WHERE id = %s', 'answer_select_by_id': 'SELECT id, submission_time, vote_number, question_id, message, image, user_id, acceptance \n FROM answer WHERE question_id = %s ORDER BY submission_time DESC', 'question_update_vote_number_by_id': 'UPDATE question SET vote_number = vote_number + %s WHERE id = %s', 'answer_update_vote_number_by_id': 'UPDATE answer SET vote_number = vote_number + %s WHERE id = %s', 'question_insert': 'INSERT INTO question (title, message, user_id) VALUES (%s, %s, %s)', 'answer_insert': 'INSERT INTO answer (question_id, message, user_id) VALUES (%s, %s, %s)', 'answer_get_img_path': 'SELECT image FROM answer WHERE question_id = %s', 'question_delete': 'DELETE FROM question WHERE id = %s RETURNING image', 'question_update': 'UPDATE question SET title = %s, message = %s WHERE id = %s', 'question_update_img': 'UPDATE question SET image = %s WHERE id = %s', 'answer_update_img': 'UPDATE answer SET image = %s WHERE id = %s', 'answer_delete': 'DELETE FROM answer WHERE id = %s RETURNING image, question_id', 'answer_count_fk_question_id': 'SELECT COUNT(question_id) FROM answer WHERE question_id = %s', 'comment_insert_to_question': 'INSERT INTO comment (question_id, message, user_id) VALUES (%s, %s, %s)', 'comment_insert_to_answer': 'INSERT INTO comment (question_id, answer_id, message, user_id) VALUES (%s, %s, %s, %s)', 'comment_select_by_question_id': 'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE question_id = %s ORDER BY submission_time DESC', 'comment_select_by_comment_id': 'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE id = %s', 'comment_update_by_id': 'UPDATE comment SET message = %s, submission_time = NOW(), edited_number = edited_number + 1 WHERE id = %s', 'advanced_search': "SELECT question.id, 'Q' || question.id, question.title || ' ' || question.message, question.submission_time AS date\n FROM question\n WHERE question.title || ' ' || question.message ILIKE %(search)s\n UNION\n SELECT answer.question_id, 'A' || answer.question_id, answer.message, answer.submission_time AS date\n FROM answer\n WHERE answer.message ILIKE %(search)s\n UNION\n SELECT comment.question_id, 'C' || comment.question_id, comment.message, comment.submission_time AS date\n FROM comment\n WHERE comment.message ILIKE %(search)s\n ORDER BY date DESC", 'questions_search': 'SELECT DISTINCT q.id, q.submission_time, q.view_number, q.vote_number, q.title, q.message, q.image\n FROM question q\n INNER JOIN answer a ON q.id = a.question_id\n WHERE (q.title ILIKE %(search)s OR q.message ILIKE %(search)s) OR a.message ILIKE %(search)s\n ORDER BY q.submission_time DESC', 'tag_select': 'SELECT id, title FROM tag ORDER BY title', 'question_tag_insert': 'INSERT INTO question_tag (question_id, tag_id) VALUES (%s, %s)', 'question_tag_select_by_question_id': 'SELECT id, question_id, tag_id FROM question_tag WHERE question_id = %s', 'tag_insert': 'INSERT INTO tag (title) VALUES (%s)', 'tag_question_tag_select_by_question_id': 'SELECT question_tag.id, tag.title\n FROM tag, question_tag\n WHERE question_tag.tag_id = tag.id AND question_tag.question_id = %s\n ORDER BY tag.title', 'question_tag_delete_by_id': 'DELETE FROM question_tag WHERE id = %s', 'comment_delete': 'DELETE FROM comment WHERE id = %s RETURNING question_id', 'answer_update_by_id': 'UPDATE answer SET message = %s WHERE id = %s', 'answer_select_message_by_id': 'SELECT message FROM answer WHERE id = %s', 'users_registration': 'INSERT INTO users (email, pwd) VALUES (%s, %s)', 'users_select_by_email': 'SELECT id, email, pwd FROM users WHERE email = %s', 'users_activation': 'SELECT u.id, u.email, u.registration_time,\n (SELECT COUNT(q.user_id) FROM question AS q WHERE q.user_id = u.id),\n (SELECT COUNT(a.user_id) FROM answer AS a WHERE a.user_id = u.id),\n (SELECT COUNT(c.user_id) FROM comment AS c WHERE c.user_id = u.id), u.reputation\n FROM users AS u\n GROUP BY u.id\n ORDER BY u.email', 'user_activation_page': 'SELECT u.id, u.email, u.registration_time,\n (SELECT COUNT(q.user_id) FROM question AS q WHERE q.user_id = u.id),\n (SELECT COUNT(a.user_id) FROM answer AS a WHERE a.user_id = u.id),\n (SELECT COUNT(c.user_id) FROM comment AS c WHERE c.user_id = u.id), u.reputation\n FROM users AS u\n WHERE u.id = %s\n GROUP BY u.id', 'question_select_by_user_id': 'SELECT id, submission_time, view_number, vote_number, title, message \n FROM question WHERE user_id = %s ORDER BY submission_time DESC', 'answer_select_by_user_id': 'SELECT id, submission_time, vote_number, question_id, message \n FROM answer WHERE user_id = %s ORDER BY submission_time DESC', 'comment_select_by_user_id': 'SELECT id, question_id, answer_id, message, submission_time, edited_number FROM comment WHERE user_id = %s', 'answer_update_acceptance_by_id': 'UPDATE answer SET acceptance = %s WHERE id = %s', 'users_gain_lost_reputation': 'UPDATE users SET reputation = reputation + %s WHERE id = %s', 'tag_select_list_count_questions': 'SELECT t.id, t.title, COUNT(qt.tag_id)\n FROM tag AS t\n LEFT JOIN question_tag AS qt ON t.id = qt.tag_id\n GROUP BY t.id\n ORDER BY t.title', 'question_select_by_tag': 'SELECT q.id, q.submission_time, q.view_number, q.vote_number, q.title, q.message\n FROM question AS q\n INNER JOIN question_tag AS qt ON qt.question_id = q.id\n WHERE qt.tag_id = %s\n ORDER BY q.submission_time DESC'}
class Query:
def __init__(self, query_dict):
self.__query = query_dict
def __getattr__(self, key):
try:
return self.__query[key]
except KeyError as e:
raise attribute_error(e)
query = query(__query_all) |
class EmptyRainfallError(ValueError):
pass
class EmptyWaterlevelError(ValueError):
pass
class NoMethodError(ValueError):
pass | class Emptyrainfallerror(ValueError):
pass
class Emptywaterlevelerror(ValueError):
pass
class Nomethoderror(ValueError):
pass |
"""
TOTAL BUTTON COUNT: 26 Buttons
GROUP NAMES: Enumerates each of the groups of buttons on controller.
BUTTON NAMES: Enumerates each of the names for each button on the controller.
GROUP SIZES: Dictionary containing the total number of buttons in each group.
BUTTON GROUPS: Dictionary where keys are group names and entries are lists of button names specific to that group.
BUTTON LOCATIONS: Dictionary where keys are button names and entries are X,Y tuple center coordinates for a button.
"""
TOTAL_BUTTON_COUNT = 26
GROUP_NAMES = [
"Top_Left",
"Bottom_Left",
"Top_Center",
"Top_Right",
"Bottom_Right",
"Left_Side", # Rocker switch and Nunchuk button assignments.
]
BUTTON_NAMES = [
# Contains the following button names: Button_1, Button_2, ... BUTTON_TOTAL_BUTTON_COUNT.
f"Button_{x}"
for x in range(1, TOTAL_BUTTON_COUNT + 1)
]
# Number of buttons in each group.
GROUP_SIZES = {
GROUP_NAMES[0]: 5, # Top Left (1-5)
GROUP_NAMES[1]: 4, # Bottom Left (6-9)
GROUP_NAMES[2]: 1, # Top Center (10)
GROUP_NAMES[3]: 8, # Top Right (11-18)
GROUP_NAMES[4]: 5, # Bottom Right (19-23)
GROUP_NAMES[5]: 3, # Left Side (24-26)
}
# Specific buttons assigned to each group.
BUTTON_GROUPS = {
GROUP_NAMES[0]: BUTTON_NAMES[0:5],
GROUP_NAMES[1]: BUTTON_NAMES[5:9],
GROUP_NAMES[2]: BUTTON_NAMES[9:10],
GROUP_NAMES[3]: BUTTON_NAMES[10:18],
GROUP_NAMES[4]: BUTTON_NAMES[18:23],
GROUP_NAMES[5]: BUTTON_NAMES[23:],
}
# Specific tuple assignments representing the default X,Y button coordinates for each button.
# a JSON type configuration file can probably be provided that's skin-specific however these are the defaults.
BUTTON_LOCATIONS = {
"Button_1": (361, 136),
"Button_2": (195, 253),
"Button_3": (270, 210),
"Button_4": (352, 218),
"Button_5": (434, 227),
"Button_6": (435, 378),
"Button_7": (517, 378),
"Button_8": (476, 449),
"Button_9": (558, 449),
"Button_10": (611, 91),
"Button_11": (795, 184),
"Button_12": (863, 136),
"Button_13": (945, 139),
"Button_14": (1020, 172),
"Button_15": (804, 266),
"Button_16": (871, 218),
"Button_17": (953, 221),
"Button_18": (1029, 254),
"Button_19": (706, 378),
"Button_20": (789, 378),
"Button_21": (664, 449),
"Button_22": (747, 449),
"Button_23": (706, 520),
"Button_24": (0, 41), # Left Side Rocker Toggle in Top Left
"Button_25": (976, 492), # Right Nunchuk Top button display in Bottom Right
"Button_26": (976, 570), # Right Nunchuk Bottom button display in Bottom Right
}
| """
TOTAL BUTTON COUNT: 26 Buttons
GROUP NAMES: Enumerates each of the groups of buttons on controller.
BUTTON NAMES: Enumerates each of the names for each button on the controller.
GROUP SIZES: Dictionary containing the total number of buttons in each group.
BUTTON GROUPS: Dictionary where keys are group names and entries are lists of button names specific to that group.
BUTTON LOCATIONS: Dictionary where keys are button names and entries are X,Y tuple center coordinates for a button.
"""
total_button_count = 26
group_names = ['Top_Left', 'Bottom_Left', 'Top_Center', 'Top_Right', 'Bottom_Right', 'Left_Side']
button_names = [f'Button_{x}' for x in range(1, TOTAL_BUTTON_COUNT + 1)]
group_sizes = {GROUP_NAMES[0]: 5, GROUP_NAMES[1]: 4, GROUP_NAMES[2]: 1, GROUP_NAMES[3]: 8, GROUP_NAMES[4]: 5, GROUP_NAMES[5]: 3}
button_groups = {GROUP_NAMES[0]: BUTTON_NAMES[0:5], GROUP_NAMES[1]: BUTTON_NAMES[5:9], GROUP_NAMES[2]: BUTTON_NAMES[9:10], GROUP_NAMES[3]: BUTTON_NAMES[10:18], GROUP_NAMES[4]: BUTTON_NAMES[18:23], GROUP_NAMES[5]: BUTTON_NAMES[23:]}
button_locations = {'Button_1': (361, 136), 'Button_2': (195, 253), 'Button_3': (270, 210), 'Button_4': (352, 218), 'Button_5': (434, 227), 'Button_6': (435, 378), 'Button_7': (517, 378), 'Button_8': (476, 449), 'Button_9': (558, 449), 'Button_10': (611, 91), 'Button_11': (795, 184), 'Button_12': (863, 136), 'Button_13': (945, 139), 'Button_14': (1020, 172), 'Button_15': (804, 266), 'Button_16': (871, 218), 'Button_17': (953, 221), 'Button_18': (1029, 254), 'Button_19': (706, 378), 'Button_20': (789, 378), 'Button_21': (664, 449), 'Button_22': (747, 449), 'Button_23': (706, 520), 'Button_24': (0, 41), 'Button_25': (976, 492), 'Button_26': (976, 570)} |
# O(n^2) time | O(1) Space
# def twoNumberSum(array, targetSum):
# for i in range(len(array)):
# firstNum = array[i]
# for j in range(i+1, array[j]):
# secondNum = array[j]
# if firstNum + secondNum == targetSum:
# return [firstNum,secondNum]
# return []
# O(n) time | O(n) space
# def twoNumberSum(array, targetSum):
# nums = {}
# for num in array:
# if targetSum - num in nums:
# return [targetSum-num, num]
# else:
# nums[num] = True
# return []
# O(nlog(n)) time | O(1) space
def twoNumberSum(array, targetSum):
array.sort()
left = 0
right = len(array) - 1
while left < right:
currentSum = array[left] + array[right]
if currentSum == targetSum:
return [array[left], array[right]]
elif currentSum < targetSum:
left += 1
elif currentSum > targetSum:
right -= 1
return []
arrays = [6, 5, -1, -4, 8, 6, 11]
target = 10
print(twoNumberSum(arrays, target))
| def two_number_sum(array, targetSum):
array.sort()
left = 0
right = len(array) - 1
while left < right:
current_sum = array[left] + array[right]
if currentSum == targetSum:
return [array[left], array[right]]
elif currentSum < targetSum:
left += 1
elif currentSum > targetSum:
right -= 1
return []
arrays = [6, 5, -1, -4, 8, 6, 11]
target = 10
print(two_number_sum(arrays, target)) |
class Solution:
def isStrobogrammatic(self, num: str) -> bool:
# create a hash table for 180 degree rotation mapping
helper = {'0':'0','1':'1','6':'9','8':'8','9':'6'}
# flip the given string
num2 = ''
n = len(num)
i = n - 1
while i >= 0:
if num[i] in helper:
num2 += helper[num[i]]
else:
return False
i -= 1
return num2 == num
| class Solution:
def is_strobogrammatic(self, num: str) -> bool:
helper = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6'}
num2 = ''
n = len(num)
i = n - 1
while i >= 0:
if num[i] in helper:
num2 += helper[num[i]]
else:
return False
i -= 1
return num2 == num |
## floating point
class Number(Primitive):
def __init__(self, V, prec=4):
Primitive.__init__(self, float(V))
## precision: digits after decimal `.`
self.prec = prec
| class Number(Primitive):
def __init__(self, V, prec=4):
Primitive.__init__(self, float(V))
self.prec = prec |
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 8 19:30:21 2018
@author: lenovo
"""
def Bsearch(A, key):
length = len(A)
if length == 0:
return -1
A.sort()
left = 0
right = length - 1
while left <= right:
mid = int((left + right) / 2)
if key == A[mid]:
return mid
elif key < A[mid]:
right = mid - 1
else:
left = mid + 1
return -1
test = [0, 0]
print(Bsearch(test, 0))
| """
Created on Wed Aug 8 19:30:21 2018
@author: lenovo
"""
def bsearch(A, key):
length = len(A)
if length == 0:
return -1
A.sort()
left = 0
right = length - 1
while left <= right:
mid = int((left + right) / 2)
if key == A[mid]:
return mid
elif key < A[mid]:
right = mid - 1
else:
left = mid + 1
return -1
test = [0, 0]
print(bsearch(test, 0)) |
#media sources
dataurl_src = "'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA'"
throttler = "'../resources/range-request.php?rate=100000&fileloc=";
mp4_src = throttler + "preload.mp4&nocache=' + Math.random()";
ogg_src = throttler + "preload.ogv&nocache=' + Math.random()";
webm_src = throttler + "preload.webm&nocache=' + Math.random()";
#preload="auto" event orders
auto_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
auto_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata canplay canplaythrough $/g'
auto_to_none_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
auto_to_none_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata canplay canplaythrough $/g'
#preload="metadata" event/state orders
metadata_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend $/g'
metadata_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata suspend $/g'
metadata_event_order_play_after_suspend = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend (progress )*canplay (progress )*canplaythrough $/g'
metadata_event_order_play_after_suspend_dataurl = '/^loadstart progress loadedmetadata loadeddata suspend canplay canplaythrough $/g'
metadata_networkstate_after_suspend = "HTMLMediaElement.NETWORK_IDLE"
metadata_readystate_after_suspend = "HTMLMediaElement.HAVE_CURRENT_DATA"
metadata_readystate_before_src = "HTMLMediaElement.HAVE_NOTHING"
metadata_networkstate_order = "eval('/^(' + HTMLMediaElement.NETWORK_LOADING + ' )+(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"
metadata_networkstate_order_dataurl = "eval('/^(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"
metadata_readystate_order = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+' + HTMLMediaElement.HAVE_METADATA + '(' + HTMLMediaElement.HAVE_CURRENT_DATA + ' )+$/g')"
metadata_readystate_order_dataurl = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+(' + HTMLMediaElement.HAVE_ENOUGH_DATA + ' )+$/g')"
#preload="none" event orders
none_event_order = '/^loadstart suspend $/g'
none_event_order_dataurl = none_event_order
none_event_order_play_after_suspend = '/^loadstart suspend (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
none_event_order_play_after_suspend_dataurl = '/^loadstart suspend progress loadedmetadata loadeddata canplay canplaythrough $/g'
none_to_metadata_event_order = '/^loadstart suspend (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend $/g'
none_to_metadata_event_order_dataurl = '/^loadstart suspend progress loadedmetadata loadeddata suspend $/g'
timeout = 10000
timeout_dataurl = 5000
testsuite = {
'*' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'timeout' : timeout}}
],
#preload="auto"
'../auto/preload-auto-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : auto_event_order_dataurl, 'start_state' : 'auto', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : auto_event_order, 'start_state' : 'auto', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : auto_event_order, 'start_state' : 'auto', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : auto_event_order, 'start_state' : 'auto', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../auto/preload-auto-to-none-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : auto_to_none_event_order_dataurl, 'start_state' : 'auto', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../auto/preload-auto-to-metadata-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : auto_to_none_event_order_dataurl, 'start_state' : 'auto', 'end_state' : 'metadata', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'metadata', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'metadata', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : auto_to_none_event_order, 'start_state' : 'auto', 'end_state' : 'metadata', 'start_event' : 'loadstart', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
#preload="metadata"
'../metadata/preload-metadata-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : metadata_event_order_dataurl, 'start_state' : 'metadata', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'timeout' : timeout}}
],
'../metadata/preload-metadata-event-order-play-after-suspend.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : metadata_event_order_play_after_suspend_dataurl, 'start_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../metadata/preload-metadata-networkstate-after-suspend.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-readystate-after-suspend.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'semantics/events/sync/preload-metadata-networkstate-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'states_expected' : metadata_networkstate_order_dataurl, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'states_expected' : metadata_networkstate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}}
],
'semantics/events/sync/preload-metadata-readystate-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'states_expected' : metadata_readystate_order_dataurl, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'states_expected' : metadata_readystate_order, 'start_state' : 'metadata', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-buffered.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'max_buffer' : '0.0001', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'max_buffer' : '60', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'max_buffer' : '60', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-auto-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : metadata_event_order_play_after_suspend_dataurl, 'start_state' : 'metadata', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : metadata_event_order_play_after_suspend, 'start_state' : 'metadata', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : metadata_event_order_dataurl, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : metadata_event_order, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-after-src-networkstate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-after-src-readystate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-after-source-readystate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-before-src-readystate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-before-source-readystate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_before_src, 'start_state' : 'metadata', 'end_state' : 'none', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-after-loadstart-networkstate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_networkstate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'networkState', 'timeout' : timeout}}
],
'../metadata/preload-metadata-to-none-after-loadstart-readystate.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'state_expected' : metadata_readystate_after_suspend, 'start_state' : 'metadata', 'end_state' : 'none', 'start_event' : 'loadstart', 'end_event' : 'suspend', 'test_state_type' : 'readyState', 'timeout' : timeout}}
],
#preload="none"
'../none/preload-none-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_event_order_dataurl, 'start_state' : 'none', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_event_order, 'start_state' : 'none', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_event_order, 'start_state' : 'none', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_event_order, 'start_state' : 'none', 'end_event' : 'suspend', 'timeout' : timeout}}
],
'../none/preload-none-event-order-autoplay.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : auto_event_order_dataurl, 'start_state' : 'none', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : auto_event_order, 'start_state' : 'none', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : auto_event_order, 'start_state' : 'none', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : auto_event_order, 'start_state' : 'none', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../none/preload-none-event-order-autoplay-after-suspend.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_event_order_play_after_suspend_dataurl, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../none/preload-none-event-order-play-after-suspend.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_event_order_play_after_suspend_dataurl, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../none/preload-none-to-auto-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_event_order_play_after_suspend_dataurl, 'start_state' : 'none', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_event_order_play_after_suspend, 'start_state' : 'none', 'end_state' : 'auto', 'start_event' : 'suspend', 'end_event' : 'canplaythrough', 'timeout' : timeout}}
],
'../none/preload-none-to-invalid-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_to_metadata_event_order_dataurl, 'start_state' : 'none', 'end_state' : 'invalid', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'invalid', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'invalid', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'invalid', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}}
],
'../none/preload-none-to-metadata-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_to_metadata_event_order_dataurl, 'start_state' : 'none', 'end_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'end_state' : 'metadata', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}}
],
'../none/preload-none-remove-attribute-event-order.tpl' : [
{'test_suffix' : 'dataurl', 'test_mapping' : {'media_type' : 'wave', 'media_src' : dataurl_src, 'events_expected' : none_to_metadata_event_order_dataurl, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout_dataurl}},
{'test_suffix' : 'mp4', 'test_mapping' : {'media_type' : 'mp4', 'media_src' : mp4_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'ogg', 'test_mapping' : {'media_type' : 'ogg', 'media_src' : ogg_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}},
{'test_suffix' : 'webm', 'test_mapping' : {'media_type' : 'webm', 'media_src' : webm_src, 'events_expected' : none_to_metadata_event_order, 'start_state' : 'none', 'start_event' : 'suspend', 'end_event' : 'suspend', 'timeout' : timeout}}
]
}
| dataurl_src = "'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA'"
throttler = "'../resources/range-request.php?rate=100000&fileloc="
mp4_src = throttler + "preload.mp4&nocache=' + Math.random()"
ogg_src = throttler + "preload.ogv&nocache=' + Math.random()"
webm_src = throttler + "preload.webm&nocache=' + Math.random()"
auto_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
auto_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata canplay canplaythrough $/g'
auto_to_none_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
auto_to_none_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata canplay canplaythrough $/g'
metadata_event_order = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend $/g'
metadata_event_order_dataurl = '/^loadstart progress loadedmetadata loadeddata suspend $/g'
metadata_event_order_play_after_suspend = '/^loadstart (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend (progress )*canplay (progress )*canplaythrough $/g'
metadata_event_order_play_after_suspend_dataurl = '/^loadstart progress loadedmetadata loadeddata suspend canplay canplaythrough $/g'
metadata_networkstate_after_suspend = 'HTMLMediaElement.NETWORK_IDLE'
metadata_readystate_after_suspend = 'HTMLMediaElement.HAVE_CURRENT_DATA'
metadata_readystate_before_src = 'HTMLMediaElement.HAVE_NOTHING'
metadata_networkstate_order = "eval('/^(' + HTMLMediaElement.NETWORK_LOADING + ' )+(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"
metadata_networkstate_order_dataurl = "eval('/^(' + HTMLMediaElement.NETWORK_IDLE + ' )+$/g')"
metadata_readystate_order = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+' + HTMLMediaElement.HAVE_METADATA + '(' + HTMLMediaElement.HAVE_CURRENT_DATA + ' )+$/g')"
metadata_readystate_order_dataurl = "eval('/^(' + HTMLMediaElement.HAVE_NOTHING + ' )+(' + HTMLMediaElement.HAVE_ENOUGH_DATA + ' )+$/g')"
none_event_order = '/^loadstart suspend $/g'
none_event_order_dataurl = none_event_order
none_event_order_play_after_suspend = '/^loadstart suspend (progress )+loadedmetadata (progress )*loadeddata (progress )*canplay (progress )*canplaythrough $/g'
none_event_order_play_after_suspend_dataurl = '/^loadstart suspend progress loadedmetadata loadeddata canplay canplaythrough $/g'
none_to_metadata_event_order = '/^loadstart suspend (progress )+loadedmetadata (progress )*loadeddata (progress )*suspend $/g'
none_to_metadata_event_order_dataurl = '/^loadstart suspend progress loadedmetadata loadeddata suspend $/g'
timeout = 10000
timeout_dataurl = 5000
testsuite = {'*': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'timeout': timeout}}], '../auto/preload-auto-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': auto_event_order_dataurl, 'start_state': 'auto', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': auto_event_order, 'start_state': 'auto', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': auto_event_order, 'start_state': 'auto', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': auto_event_order, 'start_state': 'auto', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../auto/preload-auto-to-none-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': auto_to_none_event_order_dataurl, 'start_state': 'auto', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../auto/preload-auto-to-metadata-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': auto_to_none_event_order_dataurl, 'start_state': 'auto', 'end_state': 'metadata', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'metadata', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'metadata', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': auto_to_none_event_order, 'start_state': 'auto', 'end_state': 'metadata', 'start_event': 'loadstart', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../metadata/preload-metadata-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': metadata_event_order_dataurl, 'start_state': 'metadata', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_event': 'suspend', 'timeout': timeout}}], '../metadata/preload-metadata-event-order-play-after-suspend.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': metadata_event_order_play_after_suspend_dataurl, 'start_state': 'metadata', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../metadata/preload-metadata-networkstate-after-suspend.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}], '../metadata/preload-metadata-readystate-after-suspend.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], 'semantics/events/sync/preload-metadata-networkstate-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'states_expected': metadata_networkstate_order_dataurl, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'states_expected': metadata_networkstate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'states_expected': metadata_networkstate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'states_expected': metadata_networkstate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}], 'semantics/events/sync/preload-metadata-readystate-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'states_expected': metadata_readystate_order_dataurl, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'states_expected': metadata_readystate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'states_expected': metadata_readystate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'states_expected': metadata_readystate_order, 'start_state': 'metadata', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../metadata/preload-metadata-buffered.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'max_buffer': '0.0001', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'max_buffer': '60', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'max_buffer': '60', 'timeout': timeout}}], '../metadata/preload-metadata-to-auto-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': metadata_event_order_play_after_suspend_dataurl, 'start_state': 'metadata', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': metadata_event_order_play_after_suspend, 'start_state': 'metadata', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': metadata_event_order_dataurl, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': metadata_event_order, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-after-src-networkstate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-after-src-readystate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-after-source-readystate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-before-src-readystate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-before-source-readystate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_before_src, 'start_state': 'metadata', 'end_state': 'none', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-after-loadstart-networkstate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_networkstate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'networkState', 'timeout': timeout}}], '../metadata/preload-metadata-to-none-after-loadstart-readystate.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'state_expected': metadata_readystate_after_suspend, 'start_state': 'metadata', 'end_state': 'none', 'start_event': 'loadstart', 'end_event': 'suspend', 'test_state_type': 'readyState', 'timeout': timeout}}], '../none/preload-none-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_event_order_dataurl, 'start_state': 'none', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_event_order, 'start_state': 'none', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_event_order, 'start_state': 'none', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_event_order, 'start_state': 'none', 'end_event': 'suspend', 'timeout': timeout}}], '../none/preload-none-event-order-autoplay.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': auto_event_order_dataurl, 'start_state': 'none', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': auto_event_order, 'start_state': 'none', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': auto_event_order, 'start_state': 'none', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': auto_event_order, 'start_state': 'none', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../none/preload-none-event-order-autoplay-after-suspend.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_event_order_play_after_suspend_dataurl, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../none/preload-none-event-order-play-after-suspend.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_event_order_play_after_suspend_dataurl, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../none/preload-none-to-auto-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_event_order_play_after_suspend_dataurl, 'start_state': 'none', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_event_order_play_after_suspend, 'start_state': 'none', 'end_state': 'auto', 'start_event': 'suspend', 'end_event': 'canplaythrough', 'timeout': timeout}}], '../none/preload-none-to-invalid-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_to_metadata_event_order_dataurl, 'start_state': 'none', 'end_state': 'invalid', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'invalid', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'invalid', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'invalid', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}], '../none/preload-none-to-metadata-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_to_metadata_event_order_dataurl, 'start_state': 'none', 'end_state': 'metadata', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'metadata', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'metadata', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'end_state': 'metadata', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}], '../none/preload-none-remove-attribute-event-order.tpl': [{'test_suffix': 'dataurl', 'test_mapping': {'media_type': 'wave', 'media_src': dataurl_src, 'events_expected': none_to_metadata_event_order_dataurl, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout_dataurl}}, {'test_suffix': 'mp4', 'test_mapping': {'media_type': 'mp4', 'media_src': mp4_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'ogg', 'test_mapping': {'media_type': 'ogg', 'media_src': ogg_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}, {'test_suffix': 'webm', 'test_mapping': {'media_type': 'webm', 'media_src': webm_src, 'events_expected': none_to_metadata_event_order, 'start_state': 'none', 'start_event': 'suspend', 'end_event': 'suspend', 'timeout': timeout}}]} |
class SecureList(object):
def __init__(self, lst):
self.lst = list(lst)
def __getitem__(self, item):
return self.lst.pop(item)
def __len__(self):
return len(self.lst)
def __repr__(self):
tmp, self.lst = self.lst, []
return repr(tmp)
def __str__(self):
tmp, self.lst = self.lst, []
return str(tmp)
| class Securelist(object):
def __init__(self, lst):
self.lst = list(lst)
def __getitem__(self, item):
return self.lst.pop(item)
def __len__(self):
return len(self.lst)
def __repr__(self):
(tmp, self.lst) = (self.lst, [])
return repr(tmp)
def __str__(self):
(tmp, self.lst) = (self.lst, [])
return str(tmp) |
first_card = input().strip().upper()
second_card = input().strip().upper()
third_card = input().strip().upper()
total_point = 0
if first_card == 'A':
total_point += 1
elif first_card in 'JQK':
total_point += 10
else:
total_point += int(first_card)
if second_card == 'A':
total_point += 1
elif second_card in 'JQK':
total_point += 10
else:
total_point += int(second_card)
if third_card == 'A':
total_point += 1
elif third_card in 'JQK':
total_point += 10
else:
total_point += int(third_card)
if total_point < 17:
print('hit')
elif total_point > 21:
print('bust')
else:
print('stand')
| first_card = input().strip().upper()
second_card = input().strip().upper()
third_card = input().strip().upper()
total_point = 0
if first_card == 'A':
total_point += 1
elif first_card in 'JQK':
total_point += 10
else:
total_point += int(first_card)
if second_card == 'A':
total_point += 1
elif second_card in 'JQK':
total_point += 10
else:
total_point += int(second_card)
if third_card == 'A':
total_point += 1
elif third_card in 'JQK':
total_point += 10
else:
total_point += int(third_card)
if total_point < 17:
print('hit')
elif total_point > 21:
print('bust')
else:
print('stand') |
class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class List:
def __init__(self):
self.head = None
self.tail = None
self.this = None
def add_to_tail(self, val):
new_node = Node(val)
if self.empty():
self.head = self.tail = new_node
else:
new_node.prev = self.this
if self.this.next:
new_node.next = self.this.next
new_node.next.prev = new_node
else:
self.tail = new_node
new_node.prev.next = new_node
self.this = self.tail
# self.size += 1
def empty(self):
return self.head is None
def _damp(self):
nodes = []
current_node = self.head
while current_node:
nodes.append(current_node.data)
current_node = current_node.next
return nodes
def print(self):
print(*self._damp())
def print_reverse(self):
print(*(self._damp()[::-1]))
n = int(input())
values = list(map(int, input().split()))
linked_list = List()
for v in values: linked_list.add_to_tail(v)
linked_list.print()
linked_list.print_reverse()
| class Node:
def __init__(self, data, next=None):
self.data = data
self.next = next
class List:
def __init__(self):
self.head = None
self.tail = None
self.this = None
def add_to_tail(self, val):
new_node = node(val)
if self.empty():
self.head = self.tail = new_node
else:
new_node.prev = self.this
if self.this.next:
new_node.next = self.this.next
new_node.next.prev = new_node
else:
self.tail = new_node
new_node.prev.next = new_node
self.this = self.tail
def empty(self):
return self.head is None
def _damp(self):
nodes = []
current_node = self.head
while current_node:
nodes.append(current_node.data)
current_node = current_node.next
return nodes
def print(self):
print(*self._damp())
def print_reverse(self):
print(*self._damp()[::-1])
n = int(input())
values = list(map(int, input().split()))
linked_list = list()
for v in values:
linked_list.add_to_tail(v)
linked_list.print()
linked_list.print_reverse() |
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'chromium_code': 1,
},
'targets': [
{
# GN version: //ui/events/keycodes:xkb
'target_name': 'keycodes_xkb',
'type': 'static_library',
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/ui/events/events.gyp:dom_keycode_converter',
],
'sources': [
'keyboard_code_conversion_xkb.cc',
'keyboard_code_conversion_xkb.h',
'scoped_xkb.h',
'xkb_keysym.h',
],
},
],
'conditions': [
['use_x11==1', {
'targets': [
{
# GN version: //ui/events/keycodes:x11
'target_name': 'keycodes_x11',
'type': '<(component)',
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/build/linux/system.gyp:x11',
'<(DEPTH)/ui/gfx/x/gfx_x11.gyp:gfx_x11',
'../events.gyp:dom_keycode_converter',
'keycodes_xkb',
],
'defines': [
'KEYCODES_X_IMPLEMENTATION',
],
'sources': [
'keycodes_x_export.h',
'keyboard_code_conversion_x.cc',
'keyboard_code_conversion_x.h',
'keysym_to_unicode.cc',
'keysym_to_unicode.h',
],
},
],
}],
],
}
| {'variables': {'chromium_code': 1}, 'targets': [{'target_name': 'keycodes_xkb', 'type': 'static_library', 'dependencies': ['<(DEPTH)/base/base.gyp:base', '<(DEPTH)/ui/events/events.gyp:dom_keycode_converter'], 'sources': ['keyboard_code_conversion_xkb.cc', 'keyboard_code_conversion_xkb.h', 'scoped_xkb.h', 'xkb_keysym.h']}], 'conditions': [['use_x11==1', {'targets': [{'target_name': 'keycodes_x11', 'type': '<(component)', 'dependencies': ['<(DEPTH)/base/base.gyp:base', '<(DEPTH)/build/linux/system.gyp:x11', '<(DEPTH)/ui/gfx/x/gfx_x11.gyp:gfx_x11', '../events.gyp:dom_keycode_converter', 'keycodes_xkb'], 'defines': ['KEYCODES_X_IMPLEMENTATION'], 'sources': ['keycodes_x_export.h', 'keyboard_code_conversion_x.cc', 'keyboard_code_conversion_x.h', 'keysym_to_unicode.cc', 'keysym_to_unicode.h']}]}]]} |
# from typing import Any
class SensorCache(object):
# instance = None
soil_moisture: float = 0
temperature: float = 0
humidity: float = 0
# def __init__(self):
# if SensorCache.instance:
# return
# self.soil_moisture: float = 0
# self.temperature: int = 0
# self.humidity: float = 0
# def __get__(key: str):
# def __getattribute__(self, name):
# if name in attrKeys:
# return externalData[name]
# return super(Transform, self).__getattribute__(name)
# def __setattr__(self, name, value):
# if name in attrKeys:
# externalData[name] = value
# else:
# super(Transform, self).__setattr__(name, value)
# @classmethod
# def __set__(cls, key: str, value: Any):
# cls[key] = value
| class Sensorcache(object):
soil_moisture: float = 0
temperature: float = 0
humidity: float = 0 |
#
# PySNMP MIB module NMS-ERPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-ERPS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:22:01 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")
SingleValueConstraint, ValueSizeConstraint, ValueRangeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ConstraintsUnion")
nmslocal, = mibBuilder.importSymbols("NMS-SMI", "nmslocal")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter64, Counter32, NotificationType, Bits, Gauge32, ModuleIdentity, ObjectIdentity, IpAddress, TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, MibIdentifier, Unsigned32, iso = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "Counter32", "NotificationType", "Bits", "Gauge32", "ModuleIdentity", "ObjectIdentity", "IpAddress", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "MibIdentifier", "Unsigned32", "iso")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
nmsERPS = MibIdentifier((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231))
nmsERPSRings = MibScalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRings.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRings.setDescription('The number of ethernet ring instances.')
nmsERPSInconsistenceCheck = MibScalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSInconsistenceCheck.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSInconsistenceCheck.setDescription('A value indicates that the ring-port inconsistence check is enabled or disabled.')
nmsERPSPduRx = MibScalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSPduRx.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSPduRx.setDescription('The total number of input PDUs.')
nmsERPSPduRxDropped = MibScalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSPduRxDropped.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSPduRxDropped.setDescription('The number of input discarded PDUs.')
nmsERPSPduTx = MibScalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSPduTx.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSPduTx.setDescription('The total number of output PDUs.')
nmsERPSRingTable = MibTable((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6), )
if mibBuilder.loadTexts: nmsERPSRingTable.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingTable.setDescription('A table that contains information of rings.')
nmsERPSRingTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1), ).setIndexNames((0, "NMS-ERPS-MIB", "nmsERPSRingID"))
if mibBuilder.loadTexts: nmsERPSRingTableEntry.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingTableEntry.setDescription('A table that contains information of rings.')
nmsERPSRingID = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingID.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingID.setDescription('The index of ring instances.')
nmsERPSRingNodeID = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingNodeID.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingNodeID.setDescription('The ring node identifier composed of a priority value and the bridge MAC address.')
nmsERPSRingPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPorts.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPorts.setDescription('The number of interfaces which are configured in a ring.')
nmsERPSRingRole = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("notRplOwner", 0), ("rplOwner", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingRole.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingRole.setDescription('A value indicates whether one port of the ring node is the Ring protection link(RPL).')
nmsERPSRingState = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("idle", 0), ("protection", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingState.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingState.setDescription('The ring protection state machine value.')
nmsERPSRingWTR = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("notWaitToRestore", 0), ("waitToRestore", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingWTR.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingWTR.setDescription('This value from the RPL-Owner indicates whether it is Waiting to restore.')
nmsERPSRingWtrWhile = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingWtrWhile.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingWtrWhile.setDescription('The Wait-to-restore timer value, in seconds, which is the time left before the RPL-Owner restores from Protection state.')
nmsERPSRingSignalFail = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("noSignalFail", 0), ("signalFail", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingSignalFail.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingSignalFail.setDescription('A value indicates if a ring port is failed.')
nmsERPSRingSending = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 9), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingSending.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingSending.setDescription('The type of PDUs being sent.')
nmsERPSRingRplOwnerID = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingRplOwnerID.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingRplOwnerID.setDescription("The RPL-Owner's identifier, recorded from a superior discovery PDU.")
nmsERPSRingRplOwnerMAC = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 11), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 32))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingRplOwnerMAC.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingRplOwnerMAC.setDescription("The RPL-Owner's bridge MAC address, recorded from a NR-RB PDU.")
nmsERPSRingDiscovering = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("notDiscovering", 0), ("discovering", 1), ("disabled", 2), ("enabled", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingDiscovering.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscovering.setDescription('A value indicates if the ring discovery process is running.')
nmsERPSRingDiscoverWhile = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 13), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingDiscoverWhile.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscoverWhile.setDescription('The discovery timer value, in seconds. Remaining time of the discovery process.')
nmsERPSRingPriorityValue = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 14), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingPriorityValue.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPriorityValue.setDescription('The configured ring node priority value. The lowest priority makes a node RPL-Owner in the ring. Available range is from 0 to 61440, in steps of 4096.')
nmsERPSRingWtrTime = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 15), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingWtrTime.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingWtrTime.setDescription('The configured Wait-to-restore time, in seconds.')
nmsERPSRingGuardTime = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 16), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingGuardTime.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingGuardTime.setDescription('The configured Guard-time, in 10ms.')
nmsERPSRingSendTime = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 17), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingSendTime.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingSendTime.setDescription('The configured interval of ring protection PDUs, in seconds.')
nmsERPSRingDiscoveryTime = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 18), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingDiscoveryTime.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscoveryTime.setDescription('The duration configured for discovery process, in seconds.')
nmsERPSRingDpduInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 19), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingDpduInterval.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDpduInterval.setDescription('The configured interval of ring discovery PDUs, in seconds.')
nmsERPSRingDiscoveryCount = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 20), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingDiscoveryCount.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscoveryCount.setDescription('The total number of discovery process ever started.')
nmsERPSRingDiscoveryLastDuration = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 21), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingDiscoveryLastDuration.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscoveryLastDuration.setDescription('Runtime of the last discovery process, in 10 ms.')
nmsERPSRingDiscoveryLastElapsed = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 22), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingDiscoveryLastElapsed.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingDiscoveryLastElapsed.setDescription('Elapsed time since last discovery started, in seconds.')
nmsERPSRingAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 23), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: nmsERPSRingAdminStatus.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingAdminStatus.setDescription("A read-create value that indicates the configuration status of the ring instance. Set this value to 'enabled' to start the ring or 'disabled' to stop it.")
nmsERPSRingPort1 = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 24), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: nmsERPSRingPort1.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort1.setDescription('The interface index of the first ring port. Value 0 indicates that the first port is not configured. This value is read-write.')
nmsERPSRingPort1AdminType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingPort1AdminType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort1AdminType.setDescription("The configured type of the first ring port. Set this value to 'rpl' to configure the Ring-Protection-Link.")
nmsERPSRingPort1OperType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort1OperType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort1OperType.setDescription('The running type of the first ring port.')
nmsERPSRingPort1State = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 27), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("blocking", 0), ("forwarding", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort1State.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort1State.setDescription('Forwarding state of the first ring port.')
nmsERPSRingPort1Status = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("link-down", 0), ("link-up", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort1Status.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort1Status.setDescription('Link status of the first ring port.')
nmsERPSRingPort2 = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 29), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: nmsERPSRingPort2.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort2.setDescription('The interface index of the second ring port. Value 0 indicates that the second port is not configured. This value is read-write..')
nmsERPSRingPort2AdminType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 30), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: nmsERPSRingPort2AdminType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort2AdminType.setDescription("The configured type of the second ring port. Set this value to 'rpl' to configure the Ring-Protection-Link.")
nmsERPSRingPort2OperType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 31), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort2OperType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort2OperType.setDescription('The running type of the second ring port.')
nmsERPSRingPort2State = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 32), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("blocking", 0), ("forwarding", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort2State.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort2State.setDescription('Forwarding state of the second ring port.')
nmsERPSRingPort2Status = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 33), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("link-down", 0), ("link-up", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort2Status.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort2Status.setDescription('Link status of the second ring port.')
nmsERPSRingPortTable = MibTable((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7), )
if mibBuilder.loadTexts: nmsERPSRingPortTable.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortTable.setDescription('A table that contains informations of ring ports.')
nmsERPSRingPortTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1), ).setIndexNames((0, "NMS-ERPS-MIB", "nmsERPSRingPortRingID"), (0, "NMS-ERPS-MIB", "nmsERPSRingPort"))
if mibBuilder.loadTexts: nmsERPSRingPortTableEntry.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortTableEntry.setDescription('A table that contains informations of ring ports.')
nmsERPSRingPortRingID = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortRingID.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortRingID.setDescription('The index of ring instance, in which this port is configured.')
nmsERPSRingPort = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPort.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPort.setDescription('Interface index of the ring port.')
nmsERPSRingPortAdminType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortAdminType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortAdminType.setDescription('A value indicates that if the port is configured as the Ring Protection Link(RPL).')
nmsERPSRingPortOperType = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("ring-port", 0), ("rpl", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortOperType.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortOperType.setDescription("A value indicates that if the port is running as the Ring Protection Link(RPL). This value may be different with the value of 'nmsERPSRingPortAdminType'")
nmsERPSRingPortState = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("blocking", 0), ("forwarding", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortState.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortState.setDescription('State of a ring port, forwarding or blocking.')
nmsERPSRingPortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("link-down", 0), ("link-up", 1)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortStatus.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortStatus.setDescription('Link status of a ring port.')
nmsERPSRingPortForwards = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortForwards.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortForwards.setDescription('The number of times this port transitioned to forwarding state.')
nmsERPSRingPortForwardLastElapsed = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortForwardLastElapsed.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortForwardLastElapsed.setDescription('Elapsed time since the port became forwarding, in seconds.')
nmsERPSRingPortRx = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortRx.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortRx.setDescription('The number of received PDUs on this port.')
nmsERPSRingPortTx = MibTableColumn((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 10), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: nmsERPSRingPortTx.setStatus('mandatory')
if mibBuilder.loadTexts: nmsERPSRingPortTx.setDescription('The number of transmitted PDUs on this port.')
nmsERPSRingNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8))
nmsERPSRingRoleChange = NotificationType((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8, 1)).setObjects(("NMS-ERPS-MIB", "nmsERPSRingID"), ("NMS-ERPS-MIB", "nmsERPSRingNodeID"), ("NMS-ERPS-MIB", "nmsERPSRingRole"))
if mibBuilder.loadTexts: nmsERPSRingRoleChange.setStatus('current')
if mibBuilder.loadTexts: nmsERPSRingRoleChange.setDescription('The notification is generated when ring node role changes.')
nmsERPSRingStateChange = NotificationType((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8, 2)).setObjects(("NMS-ERPS-MIB", "nmsERPSRingID"), ("NMS-ERPS-MIB", "nmsERPSRingNodeID"), ("NMS-ERPS-MIB", "nmsERPSRingRole"), ("NMS-ERPS-MIB", "nmsERPSRingState"))
if mibBuilder.loadTexts: nmsERPSRingStateChange.setStatus('current')
if mibBuilder.loadTexts: nmsERPSRingStateChange.setDescription('The notification is generated when a RPL-Owner detects that the state of ring changed.')
mibBuilder.exportSymbols("NMS-ERPS-MIB", nmsERPS=nmsERPS, nmsERPSRingPorts=nmsERPSRingPorts, nmsERPSInconsistenceCheck=nmsERPSInconsistenceCheck, nmsERPSRings=nmsERPSRings, nmsERPSPduRx=nmsERPSPduRx, nmsERPSRingSignalFail=nmsERPSRingSignalFail, nmsERPSRingPort1OperType=nmsERPSRingPort1OperType, nmsERPSRingPortOperType=nmsERPSRingPortOperType, nmsERPSRingDiscoverWhile=nmsERPSRingDiscoverWhile, nmsERPSRingDiscoveryTime=nmsERPSRingDiscoveryTime, nmsERPSRingNodeID=nmsERPSRingNodeID, nmsERPSRingDiscoveryCount=nmsERPSRingDiscoveryCount, nmsERPSRingPortForwards=nmsERPSRingPortForwards, nmsERPSRingTableEntry=nmsERPSRingTableEntry, nmsERPSRingTable=nmsERPSRingTable, nmsERPSRingPort=nmsERPSRingPort, nmsERPSRingPort2State=nmsERPSRingPort2State, nmsERPSRingPort2Status=nmsERPSRingPort2Status, nmsERPSRingDiscovering=nmsERPSRingDiscovering, nmsERPSRingDiscoveryLastDuration=nmsERPSRingDiscoveryLastDuration, nmsERPSRingPortAdminType=nmsERPSRingPortAdminType, nmsERPSRingID=nmsERPSRingID, nmsERPSRingNotifications=nmsERPSRingNotifications, nmsERPSRingWTR=nmsERPSRingWTR, nmsERPSRingDpduInterval=nmsERPSRingDpduInterval, nmsERPSRingPort2=nmsERPSRingPort2, nmsERPSRingPort2OperType=nmsERPSRingPort2OperType, nmsERPSRingGuardTime=nmsERPSRingGuardTime, nmsERPSRingPort1AdminType=nmsERPSRingPort1AdminType, nmsERPSRingPort1Status=nmsERPSRingPort1Status, nmsERPSPduRxDropped=nmsERPSPduRxDropped, nmsERPSRingPriorityValue=nmsERPSRingPriorityValue, nmsERPSRingState=nmsERPSRingState, nmsERPSRingSending=nmsERPSRingSending, nmsERPSRingPort1=nmsERPSRingPort1, nmsERPSRingSendTime=nmsERPSRingSendTime, nmsERPSRingPortTx=nmsERPSRingPortTx, nmsERPSRingPortRingID=nmsERPSRingPortRingID, nmsERPSRingRplOwnerID=nmsERPSRingRplOwnerID, nmsERPSRingWtrTime=nmsERPSRingWtrTime, nmsERPSRingPort1State=nmsERPSRingPort1State, nmsERPSRingPortTable=nmsERPSRingPortTable, nmsERPSRingPortState=nmsERPSRingPortState, nmsERPSRingPortForwardLastElapsed=nmsERPSRingPortForwardLastElapsed, nmsERPSRingDiscoveryLastElapsed=nmsERPSRingDiscoveryLastElapsed, nmsERPSRingPortTableEntry=nmsERPSRingPortTableEntry, nmsERPSRingWtrWhile=nmsERPSRingWtrWhile, nmsERPSRingPortStatus=nmsERPSRingPortStatus, nmsERPSRingAdminStatus=nmsERPSRingAdminStatus, nmsERPSRingPortRx=nmsERPSRingPortRx, nmsERPSRingStateChange=nmsERPSRingStateChange, nmsERPSRingPort2AdminType=nmsERPSRingPort2AdminType, nmsERPSRingRoleChange=nmsERPSRingRoleChange, nmsERPSPduTx=nmsERPSPduTx, nmsERPSRingRole=nmsERPSRingRole, nmsERPSRingRplOwnerMAC=nmsERPSRingRplOwnerMAC)
| (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion')
(nmslocal,) = mibBuilder.importSymbols('NMS-SMI', 'nmslocal')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(counter64, counter32, notification_type, bits, gauge32, module_identity, object_identity, ip_address, time_ticks, mib_scalar, mib_table, mib_table_row, mib_table_column, integer32, mib_identifier, unsigned32, iso) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'Counter32', 'NotificationType', 'Bits', 'Gauge32', 'ModuleIdentity', 'ObjectIdentity', 'IpAddress', 'TimeTicks', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32', 'MibIdentifier', 'Unsigned32', 'iso')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
nms_erps = mib_identifier((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231))
nms_erps_rings = mib_scalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRings.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRings.setDescription('The number of ethernet ring instances.')
nms_erps_inconsistence_check = mib_scalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('disabled', 0), ('enabled', 1)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSInconsistenceCheck.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSInconsistenceCheck.setDescription('A value indicates that the ring-port inconsistence check is enabled or disabled.')
nms_erps_pdu_rx = mib_scalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSPduRx.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSPduRx.setDescription('The total number of input PDUs.')
nms_erps_pdu_rx_dropped = mib_scalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 4), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSPduRxDropped.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSPduRxDropped.setDescription('The number of input discarded PDUs.')
nms_erps_pdu_tx = mib_scalar((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSPduTx.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSPduTx.setDescription('The total number of output PDUs.')
nms_erps_ring_table = mib_table((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6))
if mibBuilder.loadTexts:
nmsERPSRingTable.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingTable.setDescription('A table that contains information of rings.')
nms_erps_ring_table_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1)).setIndexNames((0, 'NMS-ERPS-MIB', 'nmsERPSRingID'))
if mibBuilder.loadTexts:
nmsERPSRingTableEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingTableEntry.setDescription('A table that contains information of rings.')
nms_erps_ring_id = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingID.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingID.setDescription('The index of ring instances.')
nms_erps_ring_node_id = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 32))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingNodeID.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingNodeID.setDescription('The ring node identifier composed of a priority value and the bridge MAC address.')
nms_erps_ring_ports = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 3), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPorts.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPorts.setDescription('The number of interfaces which are configured in a ring.')
nms_erps_ring_role = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('notRplOwner', 0), ('rplOwner', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingRole.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingRole.setDescription('A value indicates whether one port of the ring node is the Ring protection link(RPL).')
nms_erps_ring_state = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('idle', 0), ('protection', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingState.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingState.setDescription('The ring protection state machine value.')
nms_erps_ring_wtr = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('notWaitToRestore', 0), ('waitToRestore', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingWTR.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingWTR.setDescription('This value from the RPL-Owner indicates whether it is Waiting to restore.')
nms_erps_ring_wtr_while = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 7), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingWtrWhile.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingWtrWhile.setDescription('The Wait-to-restore timer value, in seconds, which is the time left before the RPL-Owner restores from Protection state.')
nms_erps_ring_signal_fail = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('noSignalFail', 0), ('signalFail', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingSignalFail.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingSignalFail.setDescription('A value indicates if a ring port is failed.')
nms_erps_ring_sending = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 9), display_string().subtype(subtypeSpec=value_size_constraint(0, 32))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingSending.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingSending.setDescription('The type of PDUs being sent.')
nms_erps_ring_rpl_owner_id = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 10), display_string().subtype(subtypeSpec=value_size_constraint(0, 32))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingRplOwnerID.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingRplOwnerID.setDescription("The RPL-Owner's identifier, recorded from a superior discovery PDU.")
nms_erps_ring_rpl_owner_mac = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 11), display_string().subtype(subtypeSpec=value_size_constraint(0, 32))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingRplOwnerMAC.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingRplOwnerMAC.setDescription("The RPL-Owner's bridge MAC address, recorded from a NR-RB PDU.")
nms_erps_ring_discovering = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1, 2, 3))).clone(namedValues=named_values(('notDiscovering', 0), ('discovering', 1), ('disabled', 2), ('enabled', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingDiscovering.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscovering.setDescription('A value indicates if the ring discovery process is running.')
nms_erps_ring_discover_while = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 13), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingDiscoverWhile.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscoverWhile.setDescription('The discovery timer value, in seconds. Remaining time of the discovery process.')
nms_erps_ring_priority_value = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 14), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingPriorityValue.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPriorityValue.setDescription('The configured ring node priority value. The lowest priority makes a node RPL-Owner in the ring. Available range is from 0 to 61440, in steps of 4096.')
nms_erps_ring_wtr_time = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 15), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingWtrTime.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingWtrTime.setDescription('The configured Wait-to-restore time, in seconds.')
nms_erps_ring_guard_time = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 16), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingGuardTime.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingGuardTime.setDescription('The configured Guard-time, in 10ms.')
nms_erps_ring_send_time = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 17), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingSendTime.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingSendTime.setDescription('The configured interval of ring protection PDUs, in seconds.')
nms_erps_ring_discovery_time = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 18), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryTime.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryTime.setDescription('The duration configured for discovery process, in seconds.')
nms_erps_ring_dpdu_interval = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 19), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingDpduInterval.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDpduInterval.setDescription('The configured interval of ring discovery PDUs, in seconds.')
nms_erps_ring_discovery_count = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 20), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryCount.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryCount.setDescription('The total number of discovery process ever started.')
nms_erps_ring_discovery_last_duration = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 21), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryLastDuration.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryLastDuration.setDescription('Runtime of the last discovery process, in 10 ms.')
nms_erps_ring_discovery_last_elapsed = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 22), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryLastElapsed.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingDiscoveryLastElapsed.setDescription('Elapsed time since last discovery started, in seconds.')
nms_erps_ring_admin_status = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 23), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('disabled', 0), ('enabled', 1)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
nmsERPSRingAdminStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingAdminStatus.setDescription("A read-create value that indicates the configuration status of the ring instance. Set this value to 'enabled' to start the ring or 'disabled' to stop it.")
nms_erps_ring_port1 = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 24), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
nmsERPSRingPort1.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort1.setDescription('The interface index of the first ring port. Value 0 indicates that the first port is not configured. This value is read-write.')
nms_erps_ring_port1_admin_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 25), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingPort1AdminType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort1AdminType.setDescription("The configured type of the first ring port. Set this value to 'rpl' to configure the Ring-Protection-Link.")
nms_erps_ring_port1_oper_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 26), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort1OperType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort1OperType.setDescription('The running type of the first ring port.')
nms_erps_ring_port1_state = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 27), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('blocking', 0), ('forwarding', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort1State.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort1State.setDescription('Forwarding state of the first ring port.')
nms_erps_ring_port1_status = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 28), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('link-down', 0), ('link-up', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort1Status.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort1Status.setDescription('Link status of the first ring port.')
nms_erps_ring_port2 = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 29), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
nmsERPSRingPort2.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort2.setDescription('The interface index of the second ring port. Value 0 indicates that the second port is not configured. This value is read-write..')
nms_erps_ring_port2_admin_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 30), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
nmsERPSRingPort2AdminType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort2AdminType.setDescription("The configured type of the second ring port. Set this value to 'rpl' to configure the Ring-Protection-Link.")
nms_erps_ring_port2_oper_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 31), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort2OperType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort2OperType.setDescription('The running type of the second ring port.')
nms_erps_ring_port2_state = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 32), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('blocking', 0), ('forwarding', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort2State.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort2State.setDescription('Forwarding state of the second ring port.')
nms_erps_ring_port2_status = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 6, 1, 33), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('link-down', 0), ('link-up', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort2Status.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort2Status.setDescription('Link status of the second ring port.')
nms_erps_ring_port_table = mib_table((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7))
if mibBuilder.loadTexts:
nmsERPSRingPortTable.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortTable.setDescription('A table that contains informations of ring ports.')
nms_erps_ring_port_table_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1)).setIndexNames((0, 'NMS-ERPS-MIB', 'nmsERPSRingPortRingID'), (0, 'NMS-ERPS-MIB', 'nmsERPSRingPort'))
if mibBuilder.loadTexts:
nmsERPSRingPortTableEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortTableEntry.setDescription('A table that contains informations of ring ports.')
nms_erps_ring_port_ring_id = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortRingID.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortRingID.setDescription('The index of ring instance, in which this port is configured.')
nms_erps_ring_port = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPort.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPort.setDescription('Interface index of the ring port.')
nms_erps_ring_port_admin_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortAdminType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortAdminType.setDescription('A value indicates that if the port is configured as the Ring Protection Link(RPL).')
nms_erps_ring_port_oper_type = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('ring-port', 0), ('rpl', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortOperType.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortOperType.setDescription("A value indicates that if the port is running as the Ring Protection Link(RPL). This value may be different with the value of 'nmsERPSRingPortAdminType'")
nms_erps_ring_port_state = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('blocking', 0), ('forwarding', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortState.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortState.setDescription('State of a ring port, forwarding or blocking.')
nms_erps_ring_port_status = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 1))).clone(namedValues=named_values(('link-down', 0), ('link-up', 1)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortStatus.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortStatus.setDescription('Link status of a ring port.')
nms_erps_ring_port_forwards = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 7), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortForwards.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortForwards.setDescription('The number of times this port transitioned to forwarding state.')
nms_erps_ring_port_forward_last_elapsed = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortForwardLastElapsed.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortForwardLastElapsed.setDescription('Elapsed time since the port became forwarding, in seconds.')
nms_erps_ring_port_rx = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 9), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortRx.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortRx.setDescription('The number of received PDUs on this port.')
nms_erps_ring_port_tx = mib_table_column((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 7, 1, 10), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
nmsERPSRingPortTx.setStatus('mandatory')
if mibBuilder.loadTexts:
nmsERPSRingPortTx.setDescription('The number of transmitted PDUs on this port.')
nms_erps_ring_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8))
nms_erps_ring_role_change = notification_type((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8, 1)).setObjects(('NMS-ERPS-MIB', 'nmsERPSRingID'), ('NMS-ERPS-MIB', 'nmsERPSRingNodeID'), ('NMS-ERPS-MIB', 'nmsERPSRingRole'))
if mibBuilder.loadTexts:
nmsERPSRingRoleChange.setStatus('current')
if mibBuilder.loadTexts:
nmsERPSRingRoleChange.setDescription('The notification is generated when ring node role changes.')
nms_erps_ring_state_change = notification_type((1, 3, 6, 1, 4, 1, 11606, 10, 2, 231, 8, 2)).setObjects(('NMS-ERPS-MIB', 'nmsERPSRingID'), ('NMS-ERPS-MIB', 'nmsERPSRingNodeID'), ('NMS-ERPS-MIB', 'nmsERPSRingRole'), ('NMS-ERPS-MIB', 'nmsERPSRingState'))
if mibBuilder.loadTexts:
nmsERPSRingStateChange.setStatus('current')
if mibBuilder.loadTexts:
nmsERPSRingStateChange.setDescription('The notification is generated when a RPL-Owner detects that the state of ring changed.')
mibBuilder.exportSymbols('NMS-ERPS-MIB', nmsERPS=nmsERPS, nmsERPSRingPorts=nmsERPSRingPorts, nmsERPSInconsistenceCheck=nmsERPSInconsistenceCheck, nmsERPSRings=nmsERPSRings, nmsERPSPduRx=nmsERPSPduRx, nmsERPSRingSignalFail=nmsERPSRingSignalFail, nmsERPSRingPort1OperType=nmsERPSRingPort1OperType, nmsERPSRingPortOperType=nmsERPSRingPortOperType, nmsERPSRingDiscoverWhile=nmsERPSRingDiscoverWhile, nmsERPSRingDiscoveryTime=nmsERPSRingDiscoveryTime, nmsERPSRingNodeID=nmsERPSRingNodeID, nmsERPSRingDiscoveryCount=nmsERPSRingDiscoveryCount, nmsERPSRingPortForwards=nmsERPSRingPortForwards, nmsERPSRingTableEntry=nmsERPSRingTableEntry, nmsERPSRingTable=nmsERPSRingTable, nmsERPSRingPort=nmsERPSRingPort, nmsERPSRingPort2State=nmsERPSRingPort2State, nmsERPSRingPort2Status=nmsERPSRingPort2Status, nmsERPSRingDiscovering=nmsERPSRingDiscovering, nmsERPSRingDiscoveryLastDuration=nmsERPSRingDiscoveryLastDuration, nmsERPSRingPortAdminType=nmsERPSRingPortAdminType, nmsERPSRingID=nmsERPSRingID, nmsERPSRingNotifications=nmsERPSRingNotifications, nmsERPSRingWTR=nmsERPSRingWTR, nmsERPSRingDpduInterval=nmsERPSRingDpduInterval, nmsERPSRingPort2=nmsERPSRingPort2, nmsERPSRingPort2OperType=nmsERPSRingPort2OperType, nmsERPSRingGuardTime=nmsERPSRingGuardTime, nmsERPSRingPort1AdminType=nmsERPSRingPort1AdminType, nmsERPSRingPort1Status=nmsERPSRingPort1Status, nmsERPSPduRxDropped=nmsERPSPduRxDropped, nmsERPSRingPriorityValue=nmsERPSRingPriorityValue, nmsERPSRingState=nmsERPSRingState, nmsERPSRingSending=nmsERPSRingSending, nmsERPSRingPort1=nmsERPSRingPort1, nmsERPSRingSendTime=nmsERPSRingSendTime, nmsERPSRingPortTx=nmsERPSRingPortTx, nmsERPSRingPortRingID=nmsERPSRingPortRingID, nmsERPSRingRplOwnerID=nmsERPSRingRplOwnerID, nmsERPSRingWtrTime=nmsERPSRingWtrTime, nmsERPSRingPort1State=nmsERPSRingPort1State, nmsERPSRingPortTable=nmsERPSRingPortTable, nmsERPSRingPortState=nmsERPSRingPortState, nmsERPSRingPortForwardLastElapsed=nmsERPSRingPortForwardLastElapsed, nmsERPSRingDiscoveryLastElapsed=nmsERPSRingDiscoveryLastElapsed, nmsERPSRingPortTableEntry=nmsERPSRingPortTableEntry, nmsERPSRingWtrWhile=nmsERPSRingWtrWhile, nmsERPSRingPortStatus=nmsERPSRingPortStatus, nmsERPSRingAdminStatus=nmsERPSRingAdminStatus, nmsERPSRingPortRx=nmsERPSRingPortRx, nmsERPSRingStateChange=nmsERPSRingStateChange, nmsERPSRingPort2AdminType=nmsERPSRingPort2AdminType, nmsERPSRingRoleChange=nmsERPSRingRoleChange, nmsERPSPduTx=nmsERPSPduTx, nmsERPSRingRole=nmsERPSRingRole, nmsERPSRingRplOwnerMAC=nmsERPSRingRplOwnerMAC) |
"""
1. The larger the time-step $\Delta t$ the more the estimate $p_1$ deviates
from the exact $p(t_1)$.
2. There is a linear relationship between $\Delta t$ and $e_1$: double the time-step double the error.
3. Make more shorter time-steps
""" | """
1. The larger the time-step $\\Delta t$ the more the estimate $p_1$ deviates
from the exact $p(t_1)$.
2. There is a linear relationship between $\\Delta t$ and $e_1$: double the time-step double the error.
3. Make more shorter time-steps
""" |
def quote_info(text):
return f"<blockquote class=info>{text}</blockquote>"
def quote_warning(text):
return f"<blockquote class=warning>{text}</blockquote>"
def quote_danger(text):
return f"<blockquote class=danger>{text}</blockquote>"
def code(text):
return f"<code>{text}</code>"
def html_link(link_text, url):
return f"<a href='{url}'>{link_text}</a>"
| def quote_info(text):
return f'<blockquote class=info>{text}</blockquote>'
def quote_warning(text):
return f'<blockquote class=warning>{text}</blockquote>'
def quote_danger(text):
return f'<blockquote class=danger>{text}</blockquote>'
def code(text):
return f'<code>{text}</code>'
def html_link(link_text, url):
return f"<a href='{url}'>{link_text}</a>" |
#!/usr/bin/env python
# encoding: utf-8
class postag(object):
# ref: http://universaldependencies.org/u/pos/index.html
# Open class words
ADJ = "ADJ"
ADV = "ADV"
INTJ = "INTJ"
NOUN = "NOUN"
PROPN = "PROPN"
VERB = "VERB"
# Closed class words
ADP = "ADP"
AUX ="AUX"
CCONJ = "CCONJ"
DET = "DET"
NUM = "NUM"
PART = "PART"
PRON = "PRON"
SCONJ = "SCONJ"
# Other
PUNCT = "PUNCT"
SYM = "SYM"
X = "X"
class dep_v1(object):
# VERSION
VERSION = "1.0"
# subj relations
nsubj = "nsubj"
nsubjpass = "nsubjpass"
nsubjcop = "nsubj:cop"
csubj = "csubj"
csubjpass = "csubjpass"
# obj relations
dobj = "dobj"
iobj = "iobj"
# copular
cop = "cop"
# auxiliary
aux = "aux"
auxpass = "auxpass"
# negation
neg = "neg"
# non-nominal modifier
amod = "amod"
advmod = "advmod"
# nominal modifers
nmod = "nmod"
nmod_poss = "nmod:poss"
nmod_tmod = "nmod:tmod"
nmod_npmod = "nmod:npmod"
nmod_gobj = "nmod:gobj"
obl = "nmod"
obl_npmod = "nmod:npmod"
# appositional modifier
appos = "appos"
# cooordination
cc = "cc"
conj = "conj"
cc_preconj = "cc:preconj"
# marker
mark = "mark"
case = "case"
# fixed multiword expression
mwe = "fixed"
# parataxis
parataxis = "parataxis"
# punctuation
punct = "punct"
# clausal complement
ccomp = "ccomp"
xcomp = "xcomp"
xcompds = "xcomp:ds"
# relative clause
advcl = "advcl"
acl = "acl"
aclrelcl = "acl:relcl"
# unknown dep
dep = "dep"
SUBJ = {nsubj, csubj, nsubjpass, csubjpass}
OBJ = {dobj, iobj}
NMODS = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj}
ADJ_LIKE_MODS = {amod, appos, acl, aclrelcl}
ARG_LIKE = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj, nsubj, csubj,
csubjpass, dobj, iobj}
# trivial symbols to be stripped out
TRIVIALS = {mark, cc, punct}
# These dependents of a predicate root shouldn't be included in the
# predicate phrase.
PRED_DEPS_TO_DROP = {ccomp, csubj, advcl, acl, aclrelcl, nmod_tmod,
parataxis, appos, dep}
# These dependents of an argument root shouldn't be included in the
# argument pharse if the argument root is the gov of the predicate root.
SPECIAL_ARG_DEPS_TO_DROP = {nsubj, dobj, iobj, csubj, csubjpass, neg,
aux, advcl, auxpass, ccomp, cop, mark, mwe,
parataxis}
# Predicates of these rels are hard to find arguments.
HARD_TO_FIND_ARGS = {amod, dep, conj, acl, aclrelcl, advcl}
class dep_v2(object):
# VERSION
VERSION = "2.0"
# subj relations
nsubj = "nsubj"
nsubjpass = "nsubj:pass"
nsubjcop = "nsubj:cop"
csubj = "csubj"
csubjpass = "csubj:pass"
# obj relations
dobj = "obj"
iobj = "iobj"
# auxiliary
aux = "aux"
auxpass = "aux:pass"
# negation
neg = "neg"
# copular
cop = "cop"
# non-nominal modifier
amod = "amod"
advmod = "advmod"
# nominal modifers
nmod = "nmod"
nmod_poss = "nmod:poss"
nmod_tmod = "nmod:tmod"
nmod_npmod = "nmod:npmod"
nmod_gobj = "nmod:gobj"
obl = "obl"
obl_npmod = "obl:npmod"
# appositional modifier
appos = "appos"
# cooordination
cc = "cc"
conj = "conj"
cc_preconj = "cc:preconj"
# marker
mark = "mark"
case = "case"
# fixed multiword expression
mwe = "fixed"
# parataxis
parataxis = "parataxis"
# punctuation
punct = "punct"
# clausal complement
ccomp = "ccomp"
xcomp = "xcomp"
xcompds = "xcomp:ds"
# relative clause
advcl = "advcl"
acl = "acl"
aclrelcl = "acl:relcl"
# unknown dep
dep = "dep"
SUBJ = {nsubj, csubj, nsubjpass, csubjpass}
OBJ = {dobj, iobj}
NMODS = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj}
ADJ_LIKE_MODS = {amod, appos, acl, aclrelcl}
ARG_LIKE = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj, nsubj, csubj,
csubjpass, dobj, iobj}
# trivial symbols to be stripped out
TRIVIALS = {mark, cc, punct}
# These dependents of a predicate root shouldn't be included in the
# predicate phrase.
PRED_DEPS_TO_DROP = {ccomp, csubj, advcl, acl, aclrelcl, nmod_tmod,
parataxis, appos, dep}
# These dependents of an argument root shouldn't be included in the
# argument pharse if the argument root is the gov of the predicate root.
SPECIAL_ARG_DEPS_TO_DROP = {nsubj, dobj, iobj, csubj, csubjpass, neg,
aux, advcl, auxpass, ccomp, cop, mark, mwe,
parataxis}
# Predicates of these deps are hard to find arguments.
HARD_TO_FIND_ARGS = {amod, dep, conj, acl, aclrelcl, advcl}
| class Postag(object):
adj = 'ADJ'
adv = 'ADV'
intj = 'INTJ'
noun = 'NOUN'
propn = 'PROPN'
verb = 'VERB'
adp = 'ADP'
aux = 'AUX'
cconj = 'CCONJ'
det = 'DET'
num = 'NUM'
part = 'PART'
pron = 'PRON'
sconj = 'SCONJ'
punct = 'PUNCT'
sym = 'SYM'
x = 'X'
class Dep_V1(object):
version = '1.0'
nsubj = 'nsubj'
nsubjpass = 'nsubjpass'
nsubjcop = 'nsubj:cop'
csubj = 'csubj'
csubjpass = 'csubjpass'
dobj = 'dobj'
iobj = 'iobj'
cop = 'cop'
aux = 'aux'
auxpass = 'auxpass'
neg = 'neg'
amod = 'amod'
advmod = 'advmod'
nmod = 'nmod'
nmod_poss = 'nmod:poss'
nmod_tmod = 'nmod:tmod'
nmod_npmod = 'nmod:npmod'
nmod_gobj = 'nmod:gobj'
obl = 'nmod'
obl_npmod = 'nmod:npmod'
appos = 'appos'
cc = 'cc'
conj = 'conj'
cc_preconj = 'cc:preconj'
mark = 'mark'
case = 'case'
mwe = 'fixed'
parataxis = 'parataxis'
punct = 'punct'
ccomp = 'ccomp'
xcomp = 'xcomp'
xcompds = 'xcomp:ds'
advcl = 'advcl'
acl = 'acl'
aclrelcl = 'acl:relcl'
dep = 'dep'
subj = {nsubj, csubj, nsubjpass, csubjpass}
obj = {dobj, iobj}
nmods = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj}
adj_like_mods = {amod, appos, acl, aclrelcl}
arg_like = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj, nsubj, csubj, csubjpass, dobj, iobj}
trivials = {mark, cc, punct}
pred_deps_to_drop = {ccomp, csubj, advcl, acl, aclrelcl, nmod_tmod, parataxis, appos, dep}
special_arg_deps_to_drop = {nsubj, dobj, iobj, csubj, csubjpass, neg, aux, advcl, auxpass, ccomp, cop, mark, mwe, parataxis}
hard_to_find_args = {amod, dep, conj, acl, aclrelcl, advcl}
class Dep_V2(object):
version = '2.0'
nsubj = 'nsubj'
nsubjpass = 'nsubj:pass'
nsubjcop = 'nsubj:cop'
csubj = 'csubj'
csubjpass = 'csubj:pass'
dobj = 'obj'
iobj = 'iobj'
aux = 'aux'
auxpass = 'aux:pass'
neg = 'neg'
cop = 'cop'
amod = 'amod'
advmod = 'advmod'
nmod = 'nmod'
nmod_poss = 'nmod:poss'
nmod_tmod = 'nmod:tmod'
nmod_npmod = 'nmod:npmod'
nmod_gobj = 'nmod:gobj'
obl = 'obl'
obl_npmod = 'obl:npmod'
appos = 'appos'
cc = 'cc'
conj = 'conj'
cc_preconj = 'cc:preconj'
mark = 'mark'
case = 'case'
mwe = 'fixed'
parataxis = 'parataxis'
punct = 'punct'
ccomp = 'ccomp'
xcomp = 'xcomp'
xcompds = 'xcomp:ds'
advcl = 'advcl'
acl = 'acl'
aclrelcl = 'acl:relcl'
dep = 'dep'
subj = {nsubj, csubj, nsubjpass, csubjpass}
obj = {dobj, iobj}
nmods = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj}
adj_like_mods = {amod, appos, acl, aclrelcl}
arg_like = {nmod, obl, nmod_npmod, nmod_tmod, nmod_gobj, nsubj, csubj, csubjpass, dobj, iobj}
trivials = {mark, cc, punct}
pred_deps_to_drop = {ccomp, csubj, advcl, acl, aclrelcl, nmod_tmod, parataxis, appos, dep}
special_arg_deps_to_drop = {nsubj, dobj, iobj, csubj, csubjpass, neg, aux, advcl, auxpass, ccomp, cop, mark, mwe, parataxis}
hard_to_find_args = {amod, dep, conj, acl, aclrelcl, advcl} |
print("-----------\nOmzetten van lengte-eenheden - Kilometers naar miles.\n")
while True:
print ("Geef de kilometers in die naar miles moeten omgezet.\nGebruik alleen getallen!")
km = str(input("Kilometers: "))
try:
km = float(km.replace(",", ".")) # replace comma with dot, if user entered a comma
miles = round(km * 0.621371, 2)
print ("----> [{0}] kilometers zijn gelijk aan [{1}] miles. ---".format(km, miles))
except Exception as e:
print ("Opgelet gebruik enkel getallen! Geen tekst.")
choice = input("Wil je nog een omzetting doen? y/n : ")
if choice.lower() != "y" and choice.lower() != "yes":
break
| print('-----------\nOmzetten van lengte-eenheden - Kilometers naar miles.\n')
while True:
print('Geef de kilometers in die naar miles moeten omgezet.\nGebruik alleen getallen!')
km = str(input('Kilometers: '))
try:
km = float(km.replace(',', '.'))
miles = round(km * 0.621371, 2)
print('----> [{0}] kilometers zijn gelijk aan [{1}] miles. ---'.format(km, miles))
except Exception as e:
print('Opgelet gebruik enkel getallen! Geen tekst.')
choice = input('Wil je nog een omzetting doen? y/n : ')
if choice.lower() != 'y' and choice.lower() != 'yes':
break |
#!/usr/bin/env python3
"""
implementation of recursive hilbert enumeration
"""
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def up(point):
point.y += 1
def down(point):
point.y -= 1
def left(point):
point.x -= 1
def right(point):
point.x += 1
def hilbert(n, point=Point(), up=up, down=down, left=left, right=right):
"""
recursive hilbert enumeration
"""
if n == 0:
yield point.x, point.y
return
yield from hilbert(n - 1, point, right, left, down, up)
up(point)
yield from hilbert(n - 1, point, up, down, left, right)
right(point)
yield from hilbert(n - 1, point, up, down, left, right)
down(point)
yield from hilbert(n - 1, point, left, right, up, down)
| """
implementation of recursive hilbert enumeration
"""
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def up(point):
point.y += 1
def down(point):
point.y -= 1
def left(point):
point.x -= 1
def right(point):
point.x += 1
def hilbert(n, point=point(), up=up, down=down, left=left, right=right):
"""
recursive hilbert enumeration
"""
if n == 0:
yield (point.x, point.y)
return
yield from hilbert(n - 1, point, right, left, down, up)
up(point)
yield from hilbert(n - 1, point, up, down, left, right)
right(point)
yield from hilbert(n - 1, point, up, down, left, right)
down(point)
yield from hilbert(n - 1, point, left, right, up, down) |
class Pair(object):
def __init__(self, individual1, individual2):
self.ind1 = individual1
self.ind2 = individual2
| class Pair(object):
def __init__(self, individual1, individual2):
self.ind1 = individual1
self.ind2 = individual2 |
class atom(object):
def __init__(self,atno,x,y,z):
self.atno = atno
self.position = (x,y,z)
# this is constructor
def symbol(self): # a class method
return atno__to__Symbol[atno]
def __repr__(self): # a class method
return '%d %10.4f %10.4f %10.4f%'
(self.atno, self.position[0], self.position[1],
self.position[2])
# toString
| class Atom(object):
def __init__(self, atno, x, y, z):
self.atno = atno
self.position = (x, y, z)
def symbol(self):
return atno__to__Symbol[atno]
def __repr__(self):
return '%d %10.4f %10.4f %10.4f%'
(self.atno, self.position[0], self.position[1], self.position[2]) |
class Data:
def __init__(self, startingArray):
self.dict = {
"Category" : 0,
"Month" : 1,
"Day" : 2,
"RepeatType" : 3,
"Time" : 4,
}
self.list = ["Category","Month", "Day", "RepeatMonth", "Time"]
self.data = startingArray
def setData(self, array):
self.data = array
def getData(self):
return self.data
def getDataIndex(self, index):
return self.data[index]
def getDataLen(self):
return len(self.data)
def getDataIndexIdentifier(self, index, identifier):
return self.data[index][identifier]
def getAllDataIdentifier(self, identifier):
array = {}
for i in self.data:
array.append(i[identifier])
return array
def getAllDataIDList(self, idList):
out = {}
for i in self.data:
temp = {}
for j in idList:
temp.append(i[j])
out.append(temp)
return out
def convertData(self, dict):
out = ""
counter = 0
for i in dict:
counter += 1
print(dict[i])
out = out + str(dict[i])
if(counter != 5):
out = out + " ,"
return out
def getDataFiltered(self, filter, filterType, dataType):
# print("Filter ", filter)
array = []
for i in self.data:
# print("Left Side of boolean check",i[self.dict[filterType]],int(i[self.dict[filterType]]) == filter)
if(int(i[self.dict[filterType]]) == filter):
array.append(int(i[self.dict[dataType]]))
# print("array after appending",array)
return array
| class Data:
def __init__(self, startingArray):
self.dict = {'Category': 0, 'Month': 1, 'Day': 2, 'RepeatType': 3, 'Time': 4}
self.list = ['Category', 'Month', 'Day', 'RepeatMonth', 'Time']
self.data = startingArray
def set_data(self, array):
self.data = array
def get_data(self):
return self.data
def get_data_index(self, index):
return self.data[index]
def get_data_len(self):
return len(self.data)
def get_data_index_identifier(self, index, identifier):
return self.data[index][identifier]
def get_all_data_identifier(self, identifier):
array = {}
for i in self.data:
array.append(i[identifier])
return array
def get_all_data_id_list(self, idList):
out = {}
for i in self.data:
temp = {}
for j in idList:
temp.append(i[j])
out.append(temp)
return out
def convert_data(self, dict):
out = ''
counter = 0
for i in dict:
counter += 1
print(dict[i])
out = out + str(dict[i])
if counter != 5:
out = out + ' ,'
return out
def get_data_filtered(self, filter, filterType, dataType):
array = []
for i in self.data:
if int(i[self.dict[filterType]]) == filter:
array.append(int(i[self.dict[dataType]]))
return array |
class Solution:
def findJudge(self, n: int, trust: List[List[int]]) -> int:
if not trust and n == 1:
return 1
Trust = defaultdict(list)
Trusted = defaultdict(list)
for a, b in trust:
Trust[a].append(b)
Trusted[b].append(a)
for i, t in Trusted.items():
if len(t) == n - 1 and Trust[i] == []:
return i
return -1
| class Solution:
def find_judge(self, n: int, trust: List[List[int]]) -> int:
if not trust and n == 1:
return 1
trust = defaultdict(list)
trusted = defaultdict(list)
for (a, b) in trust:
Trust[a].append(b)
Trusted[b].append(a)
for (i, t) in Trusted.items():
if len(t) == n - 1 and Trust[i] == []:
return i
return -1 |
HOST = "irc.twitch.tv"
PORT = 6667
NICK = "simpleaibot"
PASS = "oauth:tldegtq435nf1dgdps8ik9opfw9pin"
CHAN = "simpleaibot"
OWNER = ["sinstr_syko", "aloeblinka"]
| host = 'irc.twitch.tv'
port = 6667
nick = 'simpleaibot'
pass = 'oauth:tldegtq435nf1dgdps8ik9opfw9pin'
chan = 'simpleaibot'
owner = ['sinstr_syko', 'aloeblinka'] |
N,K=map(int,input().split())
L=[1]*(N+1)
for j in range(2,N+1):
if L[j]: key=j
for i in range(key,N+1,key):
if L[i]:
L[i]=0
K-=1
if K==0:
print(i)
exit() | (n, k) = map(int, input().split())
l = [1] * (N + 1)
for j in range(2, N + 1):
if L[j]:
key = j
for i in range(key, N + 1, key):
if L[i]:
L[i] = 0
k -= 1
if K == 0:
print(i)
exit() |
"""lists"""
#import json
class Lists:
"""lists"""
def __init__(self, twitter):
self.twitter = twitter
def list(self, params):
"""Hello"""
pass
def members(self, params):
"""Hello"""
pass
def memberships(self, params):
"""Hello"""
pass
def ownerships(self, params):
"""Hello"""
pass
def show(self, params):
"""Hello"""
pass
def statuses(self, params):
"""Hello"""
pass
def subscribers(self, params):
"""Hello"""
pass
def subscriptions(self, params):
"""Hello"""
pass
def create(self, params):
"""Hello"""
pass
def destory(self, params):
"""Hello"""
pass
def update(self, params):
"""Hello"""
pass
| """lists"""
class Lists:
"""lists"""
def __init__(self, twitter):
self.twitter = twitter
def list(self, params):
"""Hello"""
pass
def members(self, params):
"""Hello"""
pass
def memberships(self, params):
"""Hello"""
pass
def ownerships(self, params):
"""Hello"""
pass
def show(self, params):
"""Hello"""
pass
def statuses(self, params):
"""Hello"""
pass
def subscribers(self, params):
"""Hello"""
pass
def subscriptions(self, params):
"""Hello"""
pass
def create(self, params):
"""Hello"""
pass
def destory(self, params):
"""Hello"""
pass
def update(self, params):
"""Hello"""
pass |
def fact(n = 5):
if n < 2:
return 1
else:
return n * fact(n-1)
num = input("Enter a number to get its factorial: ")
if num == 'None' or num == '' or num == ' ':
print("Factorial of default value is: ",fact())
else:
print("Factorial of number is: ",fact(int(num)))
| def fact(n=5):
if n < 2:
return 1
else:
return n * fact(n - 1)
num = input('Enter a number to get its factorial: ')
if num == 'None' or num == '' or num == ' ':
print('Factorial of default value is: ', fact())
else:
print('Factorial of number is: ', fact(int(num))) |
SUCCESS_GENERAL = 2000
SUCCESS_USER_REGISTERED = 2001
SUCCESS_USER_LOGGED_IN = 2002
ERROR_USER_ALREADY_REGISTERED = 4000
ERROR_USER_LOGIN = 4001
ERROR_LOGIN_FAILED_SYSTEM_ERROR = 4002 | success_general = 2000
success_user_registered = 2001
success_user_logged_in = 2002
error_user_already_registered = 4000
error_user_login = 4001
error_login_failed_system_error = 4002 |
"""
Ludolph: Monitoring Jabber Bot
Version: 1.0.1
Homepage: https://github.com/erigones/Ludolph
Copyright (C) 2012-2017 Erigones, s. r. o.
See the LICENSE file for copying permission.
"""
__version__ = '1.0.1'
__author__ = 'Erigones, s. r. o.'
__copyright__ = 'Copyright 2012-2017, Erigones, s. r. o.'
| """
Ludolph: Monitoring Jabber Bot
Version: 1.0.1
Homepage: https://github.com/erigones/Ludolph
Copyright (C) 2012-2017 Erigones, s. r. o.
See the LICENSE file for copying permission.
"""
__version__ = '1.0.1'
__author__ = 'Erigones, s. r. o.'
__copyright__ = 'Copyright 2012-2017, Erigones, s. r. o.' |
#
# PySNMP MIB module AVICI-SMI (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AVICI-SMI
# Produced by pysmi-0.3.4 at Wed May 1 11:32:28 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")
ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ConstraintsIntersection")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Unsigned32, enterprises, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, Integer32, NotificationType, Counter32, iso, TimeTicks, IpAddress, Bits, ObjectIdentity, Gauge32, ModuleIdentity, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "enterprises", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "Integer32", "NotificationType", "Counter32", "iso", "TimeTicks", "IpAddress", "Bits", "ObjectIdentity", "Gauge32", "ModuleIdentity", "Counter64")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
avici = ModuleIdentity((1, 3, 6, 1, 4, 1, 2474))
avici.setRevisions(('1970-01-01 00:00', '1970-01-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: avici.setRevisionsDescriptions(('Changed arc names, removed unnecessary arcs.', 'Created MIB module.',))
if mibBuilder.loadTexts: avici.setLastUpdated('990330095500Z')
if mibBuilder.loadTexts: avici.setOrganization('Avici Systems, Inc.')
if mibBuilder.loadTexts: avici.setContactInfo(' Avici Systems, Inc. 101 Billerica Avenue North Billerica, MA 01862-1256 (978) 964-2000 (978) 964-2100 (fax) snmp@avici.com')
if mibBuilder.loadTexts: avici.setDescription('This MIB module contains the structure of management information for all vendor-specific MIBs authored by Avici Systems, Inc.')
aviciMibs = ObjectIdentity((1, 3, 6, 1, 4, 1, 2474, 1))
if mibBuilder.loadTexts: aviciMibs.setStatus('current')
if mibBuilder.loadTexts: aviciMibs.setDescription('aviciMibs is the root where Avici Proprietary MIB modules are defined.')
aviciProducts = ObjectIdentity((1, 3, 6, 1, 4, 1, 2474, 2))
if mibBuilder.loadTexts: aviciProducts.setStatus('current')
if mibBuilder.loadTexts: aviciProducts.setDescription('aviciProducts contains the sysObjectID values for all Avici products.')
aviciExperimental = ObjectIdentity((1, 3, 6, 1, 4, 1, 2474, 3))
if mibBuilder.loadTexts: aviciExperimental.setStatus('current')
if mibBuilder.loadTexts: aviciExperimental.setDescription('aviciExperimental is a temporary place for experimental MIBs.')
aviciTypes = ObjectIdentity((1, 3, 6, 1, 4, 1, 2474, 4))
if mibBuilder.loadTexts: aviciTypes.setStatus('current')
if mibBuilder.loadTexts: aviciTypes.setDescription('aviciTypes is the root where Avici textual convention MIB modules are defined.')
mibBuilder.exportSymbols("AVICI-SMI", aviciProducts=aviciProducts, PYSNMP_MODULE_ID=avici, aviciTypes=aviciTypes, aviciExperimental=aviciExperimental, avici=avici, aviciMibs=aviciMibs)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, value_range_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ConstraintsIntersection')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(unsigned32, enterprises, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, integer32, notification_type, counter32, iso, time_ticks, ip_address, bits, object_identity, gauge32, module_identity, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'enterprises', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'Integer32', 'NotificationType', 'Counter32', 'iso', 'TimeTicks', 'IpAddress', 'Bits', 'ObjectIdentity', 'Gauge32', 'ModuleIdentity', 'Counter64')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
avici = module_identity((1, 3, 6, 1, 4, 1, 2474))
avici.setRevisions(('1970-01-01 00:00', '1970-01-01 00:00'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
avici.setRevisionsDescriptions(('Changed arc names, removed unnecessary arcs.', 'Created MIB module.'))
if mibBuilder.loadTexts:
avici.setLastUpdated('990330095500Z')
if mibBuilder.loadTexts:
avici.setOrganization('Avici Systems, Inc.')
if mibBuilder.loadTexts:
avici.setContactInfo(' Avici Systems, Inc. 101 Billerica Avenue North Billerica, MA 01862-1256 (978) 964-2000 (978) 964-2100 (fax) snmp@avici.com')
if mibBuilder.loadTexts:
avici.setDescription('This MIB module contains the structure of management information for all vendor-specific MIBs authored by Avici Systems, Inc.')
avici_mibs = object_identity((1, 3, 6, 1, 4, 1, 2474, 1))
if mibBuilder.loadTexts:
aviciMibs.setStatus('current')
if mibBuilder.loadTexts:
aviciMibs.setDescription('aviciMibs is the root where Avici Proprietary MIB modules are defined.')
avici_products = object_identity((1, 3, 6, 1, 4, 1, 2474, 2))
if mibBuilder.loadTexts:
aviciProducts.setStatus('current')
if mibBuilder.loadTexts:
aviciProducts.setDescription('aviciProducts contains the sysObjectID values for all Avici products.')
avici_experimental = object_identity((1, 3, 6, 1, 4, 1, 2474, 3))
if mibBuilder.loadTexts:
aviciExperimental.setStatus('current')
if mibBuilder.loadTexts:
aviciExperimental.setDescription('aviciExperimental is a temporary place for experimental MIBs.')
avici_types = object_identity((1, 3, 6, 1, 4, 1, 2474, 4))
if mibBuilder.loadTexts:
aviciTypes.setStatus('current')
if mibBuilder.loadTexts:
aviciTypes.setDescription('aviciTypes is the root where Avici textual convention MIB modules are defined.')
mibBuilder.exportSymbols('AVICI-SMI', aviciProducts=aviciProducts, PYSNMP_MODULE_ID=avici, aviciTypes=aviciTypes, aviciExperimental=aviciExperimental, avici=avici, aviciMibs=aviciMibs) |
# Copyright 2020 Google LLC
#
# 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
#
# https://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.
# ------------------------------------------------------------------
# GA Details
GA_ACCOUNT_ID = ""
GA_PROPERTY_ID = ""
GA_DATASET_ID = ""
# BQML Details -
# Ensure that the BQ result headers resemble the data import schema
# E.g. If data import schema looks like - ga:clientId, ga:dimension1, etc.
# BQ result headers should like ga_clientId, ga_dimension1, etc.
BQML_PREDICT_QUERY = """
"""
# -------------------------------------------------------------------
# Options for logging & error monitoring
# LOGGING: Create BQ Table for logs with schema as follows -
# time TIMESTAMP, status STRING, error ERROR
ENABLE_BQ_LOGGING = False
# ERROR MONITORING: Sign up for the free Sendgrid API.
ENABLE_SENDGRID_EMAIL_REPORTING = False
# (OPTIONAL) Workflow Logging - BQ details, if enabled
GCP_PROJECT_ID = ""
BQ_DATASET_NAME = ""
BQ_TABLE_NAME = ""
# (OPTIONAL) Email Reporting - Sendgrid details, if enabled
SENDGRID_API_KEY = ""
TO_EMAIL = ""
# -------------------------------------------------------------------
# (OPTIONAL) Email Reporting - Additional Parameters
FROM_EMAIL = "workflow@example.com"
SUBJECT = "FAILED: Audience Upload to GA"
HTML_CONTENT = """
<p>
Hi WorkflowUser, <br>
Your BQML Custom Audience Upload has failed- <br>
Time: {0} UTC <br>
Reason: {1}
</p>
"""
| ga_account_id = ''
ga_property_id = ''
ga_dataset_id = ''
bqml_predict_query = '\n '
enable_bq_logging = False
enable_sendgrid_email_reporting = False
gcp_project_id = ''
bq_dataset_name = ''
bq_table_name = ''
sendgrid_api_key = ''
to_email = ''
from_email = 'workflow@example.com'
subject = 'FAILED: Audience Upload to GA'
html_content = '\n <p>\n Hi WorkflowUser, <br>\n Your BQML Custom Audience Upload has failed- <br>\n Time: {0} UTC <br>\n Reason: {1}\n </p>\n ' |
{
"uidPageJourney": {
W3Const.w3PropType: W3Const.w3TypePanel,
W3Const.w3PropSubUI: [
"uidJourneyTab"
]
},
"uidJourneyTab": {
W3Const.w3PropType: W3Const.w3TypeTab,
W3Const.w3PropSubUI: [
["uidJourneyTabJourneyLabel", "uidJourneyTabJourneyPanel"],
["uidJourneyTabMapLabel", "uidJourneyTabMapPanel"]
],
W3Const.w3PropCSS: {
# CSS for tab only support these format
"border-width": "1px",
"border-style": "solid",
"background-color": "white"
}
},
"uidJourneyTabJourneyLabel": {
W3Const.w3PropType: W3Const.w3TypeLabel,
W3Const.w3PropString: "sidJourneyTabJourney",
W3Const.w3PropClass: "cidLRPadding"
},
"uidJourneyTabMapLabel": {
W3Const.w3PropType: W3Const.w3TypeLabel,
W3Const.w3PropString: "sidJourneyTabMap",
W3Const.w3PropClass: "cidLRPadding"
},
"JourneyTab": ImportPartial("EJUIJourneyTab.py"),
"MapTab": ImportPartial("EJUIMapTab.py")
}
| {'uidPageJourney': {W3Const.w3PropType: W3Const.w3TypePanel, W3Const.w3PropSubUI: ['uidJourneyTab']}, 'uidJourneyTab': {W3Const.w3PropType: W3Const.w3TypeTab, W3Const.w3PropSubUI: [['uidJourneyTabJourneyLabel', 'uidJourneyTabJourneyPanel'], ['uidJourneyTabMapLabel', 'uidJourneyTabMapPanel']], W3Const.w3PropCSS: {'border-width': '1px', 'border-style': 'solid', 'background-color': 'white'}}, 'uidJourneyTabJourneyLabel': {W3Const.w3PropType: W3Const.w3TypeLabel, W3Const.w3PropString: 'sidJourneyTabJourney', W3Const.w3PropClass: 'cidLRPadding'}, 'uidJourneyTabMapLabel': {W3Const.w3PropType: W3Const.w3TypeLabel, W3Const.w3PropString: 'sidJourneyTabMap', W3Const.w3PropClass: 'cidLRPadding'}, 'JourneyTab': import_partial('EJUIJourneyTab.py'), 'MapTab': import_partial('EJUIMapTab.py')} |
def custom_send(socket):
socket.send("message from mod.myfunc()")
def custom_recv(socket):
socket.recv()
def custom_measure(q):
return q.measure()
| def custom_send(socket):
socket.send('message from mod.myfunc()')
def custom_recv(socket):
socket.recv()
def custom_measure(q):
return q.measure() |
#This one is straight out the standard library.
def _default_mime_types():
types_map = {
'.cdf' : 'application/x-cdf',
'.cdf' : 'application/x-netcdf',
'.xls' : 'application/excel',
'.xls' : 'application/vnd.ms-excel',
}
| def _default_mime_types():
types_map = {'.cdf': 'application/x-cdf', '.cdf': 'application/x-netcdf', '.xls': 'application/excel', '.xls': 'application/vnd.ms-excel'} |
s = input()
ret = 0
for i in range(len(s)//2):
if s[i] != s[-(i+1)]:
ret += 1
print(ret)
| s = input()
ret = 0
for i in range(len(s) // 2):
if s[i] != s[-(i + 1)]:
ret += 1
print(ret) |
SBOX = (
(0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76),
(0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0),
(0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15),
(0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75),
(0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84),
(0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF),
(0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8),
(0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2),
(0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73),
(0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB),
(0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79),
(0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08),
(0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A),
(0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E),
(0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF),
(0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16),
)
INV_SBOX = (
(0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB),
(0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB),
(0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E),
(0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25),
(0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92),
(0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84),
(0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06),
(0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B),
(0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73),
(0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E),
(0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B),
(0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4),
(0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F),
(0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF),
(0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61),
(0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D),
)
RCON = (
(0x01, 0x00, 0x00, 0x00),
(0x02, 0x00, 0x00, 0x00),
(0x04, 0x00, 0x00, 0x00),
(0x08, 0x00, 0x00, 0x00),
(0x10, 0x00, 0x00, 0x00),
(0x20, 0x00, 0x00, 0x00),
(0x40, 0x00, 0x00, 0x00),
(0x80, 0x00, 0x00, 0x00),
(0x1B, 0x00, 0x00, 0x00),
(0x36, 0x00, 0x00, 0x00),
)
# ----------------------------------------------------------------------------------------------------------------------
_MULTIPLY_BY_1 = tuple(range(256))
_MULTIPLY_BY_2 = (
0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E,
0x20, 0x22, 0x24, 0x26, 0x28, 0x2A, 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3A, 0x3C, 0x3E,
0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E,
0x60, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E,
0x80, 0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E,
0xA0, 0xA2, 0xA4, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0xB6, 0xB8, 0xBA, 0xBC, 0xBE,
0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0xCE, 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC, 0xDE,
0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEA, 0xEC, 0xEE, 0xF0, 0xF2, 0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE,
0x1B, 0x19, 0x1F, 0x1D, 0x13, 0x11, 0x17, 0x15, 0x0B, 0x09, 0x0F, 0x0D, 0x03, 0x01, 0x07, 0x05,
0x3B, 0x39, 0x3F, 0x3D, 0x33, 0x31, 0x37, 0x35, 0x2B, 0x29, 0x2F, 0x2D, 0x23, 0x21, 0x27, 0x25,
0x5B, 0x59, 0x5F, 0x5D, 0x53, 0x51, 0x57, 0x55, 0x4B, 0x49, 0x4F, 0x4D, 0x43, 0x41, 0x47, 0x45,
0x7B, 0x79, 0x7F, 0x7D, 0x73, 0x71, 0x77, 0x75, 0x6B, 0x69, 0x6F, 0x6D, 0x63, 0x61, 0x67, 0x65,
0x9B, 0x99, 0x9F, 0x9D, 0x93, 0x91, 0x97, 0x95, 0x8B, 0x89, 0x8F, 0x8D, 0x83, 0x81, 0x87, 0x85,
0xBB, 0xB9, 0xBF, 0xBD, 0xB3, 0xB1, 0xB7, 0xB5, 0xAB, 0xA9, 0xAF, 0xAD, 0xA3, 0xA1, 0xA7, 0xA5,
0xDB, 0xD9, 0xDF, 0xDD, 0xD3, 0xD1, 0xD7, 0xD5, 0xCB, 0xC9, 0xCF, 0xCD, 0xC3, 0xC1, 0xC7, 0xC5,
0xFB, 0xF9, 0xFF, 0xFD, 0xF3, 0xF1, 0xF7, 0xF5, 0xEB, 0xE9, 0xEF, 0xED, 0xE3, 0xE1, 0xE7, 0xE5,
)
_MULTIPLY_BY_3 = (
0x00, 0x03, 0x06, 0x05, 0x0C, 0x0F, 0x0A, 0x09, 0x18, 0x1B, 0x1E, 0x1D, 0x14, 0x17, 0x12, 0x11,
0x30, 0x33, 0x36, 0x35, 0x3C, 0x3F, 0x3A, 0x39, 0x28, 0x2B, 0x2E, 0x2D, 0x24, 0x27, 0x22, 0x21,
0x60, 0x63, 0x66, 0x65, 0x6C, 0x6F, 0x6A, 0x69, 0x78, 0x7B, 0x7E, 0x7D, 0x74, 0x77, 0x72, 0x71,
0x50, 0x53, 0x56, 0x55, 0x5C, 0x5F, 0x5A, 0x59, 0x48, 0x4B, 0x4E, 0x4D, 0x44, 0x47, 0x42, 0x41,
0xC0, 0xC3, 0xC6, 0xC5, 0xCC, 0xCF, 0xCA, 0xC9, 0xD8, 0xDB, 0xDE, 0xDD, 0xD4, 0xD7, 0xD2, 0xD1,
0xF0, 0xF3, 0xF6, 0xF5, 0xFC, 0xFF, 0xFA, 0xF9, 0xE8, 0xEB, 0xEE, 0xED, 0xE4, 0xE7, 0xE2, 0xE1,
0xA0, 0xA3, 0xA6, 0xA5, 0xAC, 0xAF, 0xAA, 0xA9, 0xB8, 0xBB, 0xBE, 0xBD, 0xB4, 0xB7, 0xB2, 0xB1,
0x90, 0x93, 0x96, 0x95, 0x9C, 0x9F, 0x9A, 0x99, 0x88, 0x8B, 0x8E, 0x8D, 0x84, 0x87, 0x82, 0x81,
0x9B, 0x98, 0x9D, 0x9E, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8F, 0x8C, 0x89, 0x8A,
0xAB, 0xA8, 0xAD, 0xAE, 0xA7, 0xA4, 0xA1, 0xA2, 0xB3, 0xB0, 0xB5, 0xB6, 0xBF, 0xBC, 0xB9, 0xBA,
0xFB, 0xF8, 0xFD, 0xFE, 0xF7, 0xF4, 0xF1, 0xF2, 0xE3, 0xE0, 0xE5, 0xE6, 0xEF, 0xEC, 0xE9, 0xEA,
0xCB, 0xC8, 0xCD, 0xCE, 0xC7, 0xC4, 0xC1, 0xC2, 0xD3, 0xD0, 0xD5, 0xD6, 0xDF, 0xDC, 0xD9, 0xDA,
0x5B, 0x58, 0x5D, 0x5E, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4F, 0x4C, 0x49, 0x4A,
0x6B, 0x68, 0x6D, 0x6E, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7F, 0x7C, 0x79, 0x7A,
0x3B, 0x38, 0x3D, 0x3E, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2F, 0x2C, 0x29, 0x2A,
0x0B, 0x08, 0x0D, 0x0E, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1F, 0x1C, 0x19, 0x1A,
)
_MULTIPLY_BY_9 = (
0x00, 0x09, 0x12, 0x1B, 0x24, 0x2D, 0x36, 0x3F, 0x48, 0x41, 0x5A, 0x53, 0x6C, 0x65, 0x7E, 0x77,
0x90, 0x99, 0x82, 0x8B, 0xB4, 0xBD, 0xA6, 0xAF, 0xD8, 0xD1, 0xCA, 0xC3, 0xFC, 0xF5, 0xEE, 0xE7,
0x3B, 0x32, 0x29, 0x20, 0x1F, 0x16, 0x0D, 0x04, 0x73, 0x7A, 0x61, 0x68, 0x57, 0x5E, 0x45, 0x4C,
0xAB, 0xA2, 0xB9, 0xB0, 0x8F, 0x86, 0x9D, 0x94, 0xE3, 0xEA, 0xF1, 0xF8, 0xC7, 0xCE, 0xD5, 0xDC,
0x76, 0x7F, 0x64, 0x6D, 0x52, 0x5B, 0x40, 0x49, 0x3E, 0x37, 0x2C, 0x25, 0x1A, 0x13, 0x08, 0x01,
0xE6, 0xEF, 0xF4, 0xFD, 0xC2, 0xCB, 0xD0, 0xD9, 0xAE, 0xA7, 0xBC, 0xB5, 0x8A, 0x83, 0x98, 0x91,
0x4D, 0x44, 0x5F, 0x56, 0x69, 0x60, 0x7B, 0x72, 0x05, 0x0C, 0x17, 0x1E, 0x21, 0x28, 0x33, 0x3A,
0xDD, 0xD4, 0xCF, 0xC6, 0xF9, 0xF0, 0xEB, 0xE2, 0x95, 0x9C, 0x87, 0x8E, 0xB1, 0xB8, 0xA3, 0xAA,
0xEC, 0xE5, 0xFE, 0xF7, 0xC8, 0xC1, 0xDA, 0xD3, 0xA4, 0xAD, 0xB6, 0xBF, 0x80, 0x89, 0x92, 0x9B,
0x7C, 0x75, 0x6E, 0x67, 0x58, 0x51, 0x4A, 0x43, 0x34, 0x3D, 0x26, 0x2F, 0x10, 0x19, 0x02, 0x0B,
0xD7, 0xDE, 0xC5, 0xCC, 0xF3, 0xFA, 0xE1, 0xE8, 0x9F, 0x96, 0x8D, 0x84, 0xBB, 0xB2, 0xA9, 0xA0,
0x47, 0x4E, 0x55, 0x5C, 0x63, 0x6A, 0x71, 0x78, 0x0F, 0x06, 0x1D, 0x14, 0x2B, 0x22, 0x39, 0x30,
0x9A, 0x93, 0x88, 0x81, 0xBE, 0xB7, 0xAC, 0xA5, 0xD2, 0xDB, 0xC0, 0xC9, 0xF6, 0xFF, 0xE4, 0xED,
0x0A, 0x03, 0x18, 0x11, 0x2E, 0x27, 0x3C, 0x35, 0x42, 0x4B, 0x50, 0x59, 0x66, 0x6F, 0x74, 0x7D,
0xA1, 0xA8, 0xB3, 0xBA, 0x85, 0x8C, 0x97, 0x9E, 0xE9, 0xE0, 0xFB, 0xF2, 0xCD, 0xC4, 0xDF, 0xD6,
0x31, 0x38, 0x23, 0x2A, 0x15, 0x1C, 0x07, 0x0E, 0x79, 0x70, 0x6B, 0x62, 0x5D, 0x54, 0x4F, 0x46,
)
_MULTIPLY_BY_11 = (
0x00, 0x0B, 0x16, 0x1D, 0x2C, 0x27, 0x3A, 0x31, 0x58, 0x53, 0x4E, 0x45, 0x74, 0x7F, 0x62, 0x69,
0xB0, 0xBB, 0xA6, 0xAD, 0x9C, 0x97, 0x8A, 0x81, 0xE8, 0xE3, 0xFE, 0xF5, 0xC4, 0xCF, 0xD2, 0xD9,
0x7B, 0x70, 0x6D, 0x66, 0x57, 0x5C, 0x41, 0x4A, 0x23, 0x28, 0x35, 0x3E, 0x0F, 0x04, 0x19, 0x12,
0xCB, 0xC0, 0xDD, 0xD6, 0xE7, 0xEC, 0xF1, 0xFA, 0x93, 0x98, 0x85, 0x8E, 0xBF, 0xB4, 0xA9, 0xA2,
0xF6, 0xFD, 0xE0, 0xEB, 0xDA, 0xD1, 0xCC, 0xC7, 0xAE, 0xA5, 0xB8, 0xB3, 0x82, 0x89, 0x94, 0x9F,
0x46, 0x4D, 0x50, 0x5B, 0x6A, 0x61, 0x7C, 0x77, 0x1E, 0x15, 0x08, 0x03, 0x32, 0x39, 0x24, 0x2F,
0x8D, 0x86, 0x9B, 0x90, 0xA1, 0xAA, 0xB7, 0xBC, 0xD5, 0xDE, 0xC3, 0xC8, 0xF9, 0xF2, 0xEF, 0xE4,
0x3D, 0x36, 0x2B, 0x20, 0x11, 0x1A, 0x07, 0x0C, 0x65, 0x6E, 0x73, 0x78, 0x49, 0x42, 0x5F, 0x54,
0xF7, 0xFC, 0xE1, 0xEA, 0xDB, 0xD0, 0xCD, 0xC6, 0xAF, 0xA4, 0xB9, 0xB2, 0x83, 0x88, 0x95, 0x9E,
0x47, 0x4C, 0x51, 0x5A, 0x6B, 0x60, 0x7D, 0x76, 0x1F, 0x14, 0x09, 0x02, 0x33, 0x38, 0x25, 0x2E,
0x8C, 0x87, 0x9A, 0x91, 0xA0, 0xAB, 0xB6, 0xBD, 0xD4, 0xDF, 0xC2, 0xC9, 0xF8, 0xF3, 0xEE, 0xE5,
0x3C, 0x37, 0x2A, 0x21, 0x10, 0x1B, 0x06, 0x0D, 0x64, 0x6F, 0x72, 0x79, 0x48, 0x43, 0x5E, 0x55,
0x01, 0x0A, 0x17, 0x1C, 0x2D, 0x26, 0x3B, 0x30, 0x59, 0x52, 0x4F, 0x44, 0x75, 0x7E, 0x63, 0x68,
0xB1, 0xBA, 0xA7, 0xAC, 0x9D, 0x96, 0x8B, 0x80, 0xE9, 0xE2, 0xFF, 0xF4, 0xC5, 0xCE, 0xD3, 0xD8,
0x7A, 0x71, 0x6C, 0x67, 0x56, 0x5D, 0x40, 0x4B, 0x22, 0x29, 0x34, 0x3F, 0x0E, 0x05, 0x18, 0x13,
0xCA, 0xC1, 0xDC, 0xD7, 0xE6, 0xED, 0xF0, 0xFB, 0x92, 0x99, 0x84, 0x8F, 0xBE, 0xB5, 0xA8, 0xA3,
)
_MULTIPLY_BY_13 = (
0x00, 0x0D, 0x1A, 0x17, 0x34, 0x39, 0x2E, 0x23, 0x68, 0x65, 0x72, 0x7F, 0x5C, 0x51, 0x46, 0x4B,
0xD0, 0xDD, 0xCA, 0xC7, 0xE4, 0xE9, 0xFE, 0xF3, 0xB8, 0xB5, 0xA2, 0xAF, 0x8C, 0x81, 0x96, 0x9B,
0xBB, 0xB6, 0xA1, 0xAC, 0x8F, 0x82, 0x95, 0x98, 0xD3, 0xDE, 0xC9, 0xC4, 0xE7, 0xEA, 0xFD, 0xF0,
0x6B, 0x66, 0x71, 0x7C, 0x5F, 0x52, 0x45, 0x48, 0x03, 0x0E, 0x19, 0x14, 0x37, 0x3A, 0x2D, 0x20,
0x6D, 0x60, 0x77, 0x7A, 0x59, 0x54, 0x43, 0x4E, 0x05, 0x08, 0x1F, 0x12, 0x31, 0x3C, 0x2B, 0x26,
0xBD, 0xB0, 0xA7, 0xAA, 0x89, 0x84, 0x93, 0x9E, 0xD5, 0xD8, 0xCF, 0xC2, 0xE1, 0xEC, 0xFB, 0xF6,
0xD6, 0xDB, 0xCC, 0xC1, 0xE2, 0xEF, 0xF8, 0xF5, 0xBE, 0xB3, 0xA4, 0xA9, 0x8A, 0x87, 0x90, 0x9D,
0x06, 0x0B, 0x1C, 0x11, 0x32, 0x3F, 0x28, 0x25, 0x6E, 0x63, 0x74, 0x79, 0x5A, 0x57, 0x40, 0x4D,
0xDA, 0xD7, 0xC0, 0xCD, 0xEE, 0xE3, 0xF4, 0xF9, 0xB2, 0xBF, 0xA8, 0xA5, 0x86, 0x8B, 0x9C, 0x91,
0x0A, 0x07, 0x10, 0x1D, 0x3E, 0x33, 0x24, 0x29, 0x62, 0x6F, 0x78, 0x75, 0x56, 0x5B, 0x4C, 0x41,
0x61, 0x6C, 0x7B, 0x76, 0x55, 0x58, 0x4F, 0x42, 0x09, 0x04, 0x13, 0x1E, 0x3D, 0x30, 0x27, 0x2A,
0xB1, 0xBC, 0xAB, 0xA6, 0x85, 0x88, 0x9F, 0x92, 0xD9, 0xD4, 0xC3, 0xCE, 0xED, 0xE0, 0xF7, 0xFA,
0xB7, 0xBA, 0xAD, 0xA0, 0x83, 0x8E, 0x99, 0x94, 0xDF, 0xD2, 0xC5, 0xC8, 0xEB, 0xE6, 0xF1, 0xFC,
0x67, 0x6A, 0x7D, 0x70, 0x53, 0x5E, 0x49, 0x44, 0x0F, 0x02, 0x15, 0x18, 0x3B, 0x36, 0x21, 0x2C,
0x0C, 0x01, 0x16, 0x1B, 0x38, 0x35, 0x22, 0x2F, 0x64, 0x69, 0x7E, 0x73, 0x50, 0x5D, 0x4A, 0x47,
0xDC, 0xD1, 0xC6, 0xCB, 0xE8, 0xE5, 0xF2, 0xFF, 0xB4, 0xB9, 0xAE, 0xA3, 0x80, 0x8D, 0x9A, 0x97,
)
_MULTIPLY_BY_14 = (
0x00, 0x0E, 0x1C, 0x12, 0x38, 0x36, 0x24, 0x2A, 0x70, 0x7E, 0x6C, 0x62, 0x48, 0x46, 0x54, 0x5A,
0xE0, 0xEE, 0xFC, 0xF2, 0xD8, 0xD6, 0xC4, 0xCA, 0x90, 0x9E, 0x8C, 0x82, 0xA8, 0xA6, 0xB4, 0xBA,
0xDB, 0xD5, 0xC7, 0xC9, 0xE3, 0xED, 0xFF, 0xF1, 0xAB, 0xA5, 0xB7, 0xB9, 0x93, 0x9D, 0x8F, 0x81,
0x3B, 0x35, 0x27, 0x29, 0x03, 0x0D, 0x1F, 0x11, 0x4B, 0x45, 0x57, 0x59, 0x73, 0x7D, 0x6F, 0x61,
0xAD, 0xA3, 0xB1, 0xBF, 0x95, 0x9B, 0x89, 0x87, 0xDD, 0xD3, 0xC1, 0xCF, 0xE5, 0xEB, 0xF9, 0xF7,
0x4D, 0x43, 0x51, 0x5F, 0x75, 0x7B, 0x69, 0x67, 0x3D, 0x33, 0x21, 0x2F, 0x05, 0x0B, 0x19, 0x17,
0x76, 0x78, 0x6A, 0x64, 0x4E, 0x40, 0x52, 0x5C, 0x06, 0x08, 0x1A, 0x14, 0x3E, 0x30, 0x22, 0x2C,
0x96, 0x98, 0x8A, 0x84, 0xAE, 0xA0, 0xB2, 0xBC, 0xE6, 0xE8, 0xFA, 0xF4, 0xDE, 0xD0, 0xC2, 0xCC,
0x41, 0x4F, 0x5D, 0x53, 0x79, 0x77, 0x65, 0x6B, 0x31, 0x3F, 0x2D, 0x23, 0x09, 0x07, 0x15, 0x1B,
0xA1, 0xAF, 0xBD, 0xB3, 0x99, 0x97, 0x85, 0x8B, 0xD1, 0xDF, 0xCD, 0xC3, 0xE9, 0xE7, 0xF5, 0xFB,
0x9A, 0x94, 0x86, 0x88, 0xA2, 0xAC, 0xBE, 0xB0, 0xEA, 0xE4, 0xF6, 0xF8, 0xD2, 0xDC, 0xCE, 0xC0,
0x7A, 0x74, 0x66, 0x68, 0x42, 0x4C, 0x5E, 0x50, 0x0A, 0x04, 0x16, 0x18, 0x32, 0x3C, 0x2E, 0x20,
0xEC, 0xE2, 0xF0, 0xFE, 0xD4, 0xDA, 0xC8, 0xC6, 0x9C, 0x92, 0x80, 0x8E, 0xA4, 0xAA, 0xB8, 0xB6,
0x0C, 0x02, 0x10, 0x1E, 0x34, 0x3A, 0x28, 0x26, 0x7C, 0x72, 0x60, 0x6E, 0x44, 0x4A, 0x58, 0x56,
0x37, 0x39, 0x2B, 0x25, 0x0F, 0x01, 0x13, 0x1D, 0x47, 0x49, 0x5B, 0x55, 0x7F, 0x71, 0x63, 0x6D,
0xD7, 0xD9, 0xCB, 0xC5, 0xEF, 0xE1, 0xF3, 0xFD, 0xA7, 0xA9, 0xBB, 0xB5, 0x9F, 0x91, 0x83, 0x8D,
)
MIX_COLUMNS_MATRIX = (
(_MULTIPLY_BY_2, _MULTIPLY_BY_3, _MULTIPLY_BY_1, _MULTIPLY_BY_1),
(_MULTIPLY_BY_1, _MULTIPLY_BY_2, _MULTIPLY_BY_3, _MULTIPLY_BY_1),
(_MULTIPLY_BY_1, _MULTIPLY_BY_1, _MULTIPLY_BY_2, _MULTIPLY_BY_3),
(_MULTIPLY_BY_3, _MULTIPLY_BY_1, _MULTIPLY_BY_1, _MULTIPLY_BY_2),
)
INV_MIX_COLUMNS_MATRIX = (
(_MULTIPLY_BY_14, _MULTIPLY_BY_11, _MULTIPLY_BY_13, _MULTIPLY_BY_9),
(_MULTIPLY_BY_9, _MULTIPLY_BY_14, _MULTIPLY_BY_11, _MULTIPLY_BY_13),
(_MULTIPLY_BY_13, _MULTIPLY_BY_9, _MULTIPLY_BY_14, _MULTIPLY_BY_11),
(_MULTIPLY_BY_11, _MULTIPLY_BY_13, _MULTIPLY_BY_9, _MULTIPLY_BY_14),
)
| sbox = ((99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118), (202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192), (183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21), (4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117), (9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132), (83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207), (208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168), (81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210), (205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115), (96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219), (224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121), (231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8), (186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138), (112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158), (225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223), (140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22))
inv_sbox = ((82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251), (124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203), (84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78), (8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37), (114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146), (108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132), (144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6), (208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107), (58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115), (150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110), (71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27), (252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244), (31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95), (96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239), (160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97), (23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125))
rcon = ((1, 0, 0, 0), (2, 0, 0, 0), (4, 0, 0, 0), (8, 0, 0, 0), (16, 0, 0, 0), (32, 0, 0, 0), (64, 0, 0, 0), (128, 0, 0, 0), (27, 0, 0, 0), (54, 0, 0, 0))
_multiply_by_1 = tuple(range(256))
_multiply_by_2 = (0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 27, 25, 31, 29, 19, 17, 23, 21, 11, 9, 15, 13, 3, 1, 7, 5, 59, 57, 63, 61, 51, 49, 55, 53, 43, 41, 47, 45, 35, 33, 39, 37, 91, 89, 95, 93, 83, 81, 87, 85, 75, 73, 79, 77, 67, 65, 71, 69, 123, 121, 127, 125, 115, 113, 119, 117, 107, 105, 111, 109, 99, 97, 103, 101, 155, 153, 159, 157, 147, 145, 151, 149, 139, 137, 143, 141, 131, 129, 135, 133, 187, 185, 191, 189, 179, 177, 183, 181, 171, 169, 175, 173, 163, 161, 167, 165, 219, 217, 223, 221, 211, 209, 215, 213, 203, 201, 207, 205, 195, 193, 199, 197, 251, 249, 255, 253, 243, 241, 247, 245, 235, 233, 239, 237, 227, 225, 231, 229)
_multiply_by_3 = (0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33, 96, 99, 102, 101, 108, 111, 106, 105, 120, 123, 126, 125, 116, 119, 114, 113, 80, 83, 86, 85, 92, 95, 90, 89, 72, 75, 78, 77, 68, 71, 66, 65, 192, 195, 198, 197, 204, 207, 202, 201, 216, 219, 222, 221, 212, 215, 210, 209, 240, 243, 246, 245, 252, 255, 250, 249, 232, 235, 238, 237, 228, 231, 226, 225, 160, 163, 166, 165, 172, 175, 170, 169, 184, 187, 190, 189, 180, 183, 178, 177, 144, 147, 150, 149, 156, 159, 154, 153, 136, 139, 142, 141, 132, 135, 130, 129, 155, 152, 157, 158, 151, 148, 145, 146, 131, 128, 133, 134, 143, 140, 137, 138, 171, 168, 173, 174, 167, 164, 161, 162, 179, 176, 181, 182, 191, 188, 185, 186, 251, 248, 253, 254, 247, 244, 241, 242, 227, 224, 229, 230, 239, 236, 233, 234, 203, 200, 205, 206, 199, 196, 193, 194, 211, 208, 213, 214, 223, 220, 217, 218, 91, 88, 93, 94, 87, 84, 81, 82, 67, 64, 69, 70, 79, 76, 73, 74, 107, 104, 109, 110, 103, 100, 97, 98, 115, 112, 117, 118, 127, 124, 121, 122, 59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26)
_multiply_by_9 = (0, 9, 18, 27, 36, 45, 54, 63, 72, 65, 90, 83, 108, 101, 126, 119, 144, 153, 130, 139, 180, 189, 166, 175, 216, 209, 202, 195, 252, 245, 238, 231, 59, 50, 41, 32, 31, 22, 13, 4, 115, 122, 97, 104, 87, 94, 69, 76, 171, 162, 185, 176, 143, 134, 157, 148, 227, 234, 241, 248, 199, 206, 213, 220, 118, 127, 100, 109, 82, 91, 64, 73, 62, 55, 44, 37, 26, 19, 8, 1, 230, 239, 244, 253, 194, 203, 208, 217, 174, 167, 188, 181, 138, 131, 152, 145, 77, 68, 95, 86, 105, 96, 123, 114, 5, 12, 23, 30, 33, 40, 51, 58, 221, 212, 207, 198, 249, 240, 235, 226, 149, 156, 135, 142, 177, 184, 163, 170, 236, 229, 254, 247, 200, 193, 218, 211, 164, 173, 182, 191, 128, 137, 146, 155, 124, 117, 110, 103, 88, 81, 74, 67, 52, 61, 38, 47, 16, 25, 2, 11, 215, 222, 197, 204, 243, 250, 225, 232, 159, 150, 141, 132, 187, 178, 169, 160, 71, 78, 85, 92, 99, 106, 113, 120, 15, 6, 29, 20, 43, 34, 57, 48, 154, 147, 136, 129, 190, 183, 172, 165, 210, 219, 192, 201, 246, 255, 228, 237, 10, 3, 24, 17, 46, 39, 60, 53, 66, 75, 80, 89, 102, 111, 116, 125, 161, 168, 179, 186, 133, 140, 151, 158, 233, 224, 251, 242, 205, 196, 223, 214, 49, 56, 35, 42, 21, 28, 7, 14, 121, 112, 107, 98, 93, 84, 79, 70)
_multiply_by_11 = (0, 11, 22, 29, 44, 39, 58, 49, 88, 83, 78, 69, 116, 127, 98, 105, 176, 187, 166, 173, 156, 151, 138, 129, 232, 227, 254, 245, 196, 207, 210, 217, 123, 112, 109, 102, 87, 92, 65, 74, 35, 40, 53, 62, 15, 4, 25, 18, 203, 192, 221, 214, 231, 236, 241, 250, 147, 152, 133, 142, 191, 180, 169, 162, 246, 253, 224, 235, 218, 209, 204, 199, 174, 165, 184, 179, 130, 137, 148, 159, 70, 77, 80, 91, 106, 97, 124, 119, 30, 21, 8, 3, 50, 57, 36, 47, 141, 134, 155, 144, 161, 170, 183, 188, 213, 222, 195, 200, 249, 242, 239, 228, 61, 54, 43, 32, 17, 26, 7, 12, 101, 110, 115, 120, 73, 66, 95, 84, 247, 252, 225, 234, 219, 208, 205, 198, 175, 164, 185, 178, 131, 136, 149, 158, 71, 76, 81, 90, 107, 96, 125, 118, 31, 20, 9, 2, 51, 56, 37, 46, 140, 135, 154, 145, 160, 171, 182, 189, 212, 223, 194, 201, 248, 243, 238, 229, 60, 55, 42, 33, 16, 27, 6, 13, 100, 111, 114, 121, 72, 67, 94, 85, 1, 10, 23, 28, 45, 38, 59, 48, 89, 82, 79, 68, 117, 126, 99, 104, 177, 186, 167, 172, 157, 150, 139, 128, 233, 226, 255, 244, 197, 206, 211, 216, 122, 113, 108, 103, 86, 93, 64, 75, 34, 41, 52, 63, 14, 5, 24, 19, 202, 193, 220, 215, 230, 237, 240, 251, 146, 153, 132, 143, 190, 181, 168, 163)
_multiply_by_13 = (0, 13, 26, 23, 52, 57, 46, 35, 104, 101, 114, 127, 92, 81, 70, 75, 208, 221, 202, 199, 228, 233, 254, 243, 184, 181, 162, 175, 140, 129, 150, 155, 187, 182, 161, 172, 143, 130, 149, 152, 211, 222, 201, 196, 231, 234, 253, 240, 107, 102, 113, 124, 95, 82, 69, 72, 3, 14, 25, 20, 55, 58, 45, 32, 109, 96, 119, 122, 89, 84, 67, 78, 5, 8, 31, 18, 49, 60, 43, 38, 189, 176, 167, 170, 137, 132, 147, 158, 213, 216, 207, 194, 225, 236, 251, 246, 214, 219, 204, 193, 226, 239, 248, 245, 190, 179, 164, 169, 138, 135, 144, 157, 6, 11, 28, 17, 50, 63, 40, 37, 110, 99, 116, 121, 90, 87, 64, 77, 218, 215, 192, 205, 238, 227, 244, 249, 178, 191, 168, 165, 134, 139, 156, 145, 10, 7, 16, 29, 62, 51, 36, 41, 98, 111, 120, 117, 86, 91, 76, 65, 97, 108, 123, 118, 85, 88, 79, 66, 9, 4, 19, 30, 61, 48, 39, 42, 177, 188, 171, 166, 133, 136, 159, 146, 217, 212, 195, 206, 237, 224, 247, 250, 183, 186, 173, 160, 131, 142, 153, 148, 223, 210, 197, 200, 235, 230, 241, 252, 103, 106, 125, 112, 83, 94, 73, 68, 15, 2, 21, 24, 59, 54, 33, 44, 12, 1, 22, 27, 56, 53, 34, 47, 100, 105, 126, 115, 80, 93, 74, 71, 220, 209, 198, 203, 232, 229, 242, 255, 180, 185, 174, 163, 128, 141, 154, 151)
_multiply_by_14 = (0, 14, 28, 18, 56, 54, 36, 42, 112, 126, 108, 98, 72, 70, 84, 90, 224, 238, 252, 242, 216, 214, 196, 202, 144, 158, 140, 130, 168, 166, 180, 186, 219, 213, 199, 201, 227, 237, 255, 241, 171, 165, 183, 185, 147, 157, 143, 129, 59, 53, 39, 41, 3, 13, 31, 17, 75, 69, 87, 89, 115, 125, 111, 97, 173, 163, 177, 191, 149, 155, 137, 135, 221, 211, 193, 207, 229, 235, 249, 247, 77, 67, 81, 95, 117, 123, 105, 103, 61, 51, 33, 47, 5, 11, 25, 23, 118, 120, 106, 100, 78, 64, 82, 92, 6, 8, 26, 20, 62, 48, 34, 44, 150, 152, 138, 132, 174, 160, 178, 188, 230, 232, 250, 244, 222, 208, 194, 204, 65, 79, 93, 83, 121, 119, 101, 107, 49, 63, 45, 35, 9, 7, 21, 27, 161, 175, 189, 179, 153, 151, 133, 139, 209, 223, 205, 195, 233, 231, 245, 251, 154, 148, 134, 136, 162, 172, 190, 176, 234, 228, 246, 248, 210, 220, 206, 192, 122, 116, 102, 104, 66, 76, 94, 80, 10, 4, 22, 24, 50, 60, 46, 32, 236, 226, 240, 254, 212, 218, 200, 198, 156, 146, 128, 142, 164, 170, 184, 182, 12, 2, 16, 30, 52, 58, 40, 38, 124, 114, 96, 110, 68, 74, 88, 86, 55, 57, 43, 37, 15, 1, 19, 29, 71, 73, 91, 85, 127, 113, 99, 109, 215, 217, 203, 197, 239, 225, 243, 253, 167, 169, 187, 181, 159, 145, 131, 141)
mix_columns_matrix = ((_MULTIPLY_BY_2, _MULTIPLY_BY_3, _MULTIPLY_BY_1, _MULTIPLY_BY_1), (_MULTIPLY_BY_1, _MULTIPLY_BY_2, _MULTIPLY_BY_3, _MULTIPLY_BY_1), (_MULTIPLY_BY_1, _MULTIPLY_BY_1, _MULTIPLY_BY_2, _MULTIPLY_BY_3), (_MULTIPLY_BY_3, _MULTIPLY_BY_1, _MULTIPLY_BY_1, _MULTIPLY_BY_2))
inv_mix_columns_matrix = ((_MULTIPLY_BY_14, _MULTIPLY_BY_11, _MULTIPLY_BY_13, _MULTIPLY_BY_9), (_MULTIPLY_BY_9, _MULTIPLY_BY_14, _MULTIPLY_BY_11, _MULTIPLY_BY_13), (_MULTIPLY_BY_13, _MULTIPLY_BY_9, _MULTIPLY_BY_14, _MULTIPLY_BY_11), (_MULTIPLY_BY_11, _MULTIPLY_BY_13, _MULTIPLY_BY_9, _MULTIPLY_BY_14)) |
poem = '''There was a young lady named Bright,
Whose speed was far faster than light;
She started one day In a relative way, And
returned on the previous night.'''
print(poem)
try:
fout = open('relativety', 'xt')
fout.write(poem)
fout.close()
except FileExistsError:
print('relativety already exists! That was a close one.') | poem = 'There was a young lady named Bright,\nWhose speed was far faster than light;\nShe started one day In a relative way, And\nreturned on the previous night.'
print(poem)
try:
fout = open('relativety', 'xt')
fout.write(poem)
fout.close()
except FileExistsError:
print('relativety already exists! That was a close one.') |
try:
with open("input.txt", "r") as fileContent:
timers = [int(number) for number in fileContent.readline().split(",")]
frequencies = [0] * 9
for timer in timers:
frequencies[timer] = timers.count(timer)
except FileNotFoundError:
print("[!] The input file was not found. The program will not continue.")
exit(-1)
for _ in range(256):
newborns, initialSixes = frequencies[-1], frequencies[6]
for index in range(len(frequencies)):
if index == 0 and frequencies[index] > 0:
frequencies[-1] += frequencies[index]
frequencies[6] += frequencies[index]
frequencies[index] -= frequencies[index]
if index < 8:
if frequencies[6] != initialSixes and index == 5:
frequencies[index] += initialSixes
frequencies[index + 1] -= initialSixes
elif frequencies[-1] != newborns and index == 7:
frequencies[index] += newborns
frequencies[index + 1] -= newborns
else:
frequencies[index] += frequencies[index + 1]
frequencies[index + 1] -= frequencies[index + 1]
print(sum(frequencies))
| try:
with open('input.txt', 'r') as file_content:
timers = [int(number) for number in fileContent.readline().split(',')]
frequencies = [0] * 9
for timer in timers:
frequencies[timer] = timers.count(timer)
except FileNotFoundError:
print('[!] The input file was not found. The program will not continue.')
exit(-1)
for _ in range(256):
(newborns, initial_sixes) = (frequencies[-1], frequencies[6])
for index in range(len(frequencies)):
if index == 0 and frequencies[index] > 0:
frequencies[-1] += frequencies[index]
frequencies[6] += frequencies[index]
frequencies[index] -= frequencies[index]
if index < 8:
if frequencies[6] != initialSixes and index == 5:
frequencies[index] += initialSixes
frequencies[index + 1] -= initialSixes
elif frequencies[-1] != newborns and index == 7:
frequencies[index] += newborns
frequencies[index + 1] -= newborns
else:
frequencies[index] += frequencies[index + 1]
frequencies[index + 1] -= frequencies[index + 1]
print(sum(frequencies)) |
ADMINS = (
('Admin', 'admin@tvoy_style.com'),
)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL = 'dezigner20@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'dezigner20@gmail.com'
EMAIL_HOST_PASSWORD = 'SSDD24869317SSDD**'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_PORT = 587
| admins = (('Admin', 'admin@tvoy_style.com'),)
email_backend = 'django.core.mail.backends.smtp.EmailBackend'
default_from_email = 'dezigner20@gmail.com'
email_use_tls = True
email_host = 'smtp.gmail.com'
email_host_user = 'dezigner20@gmail.com'
email_host_password = 'SSDD24869317SSDD**'
server_email = DEFAULT_FROM_EMAIL
email_port = 587 |
class Solution:
# @param {integer[]} nums
# @return {integer[]}
def productExceptSelf(self, nums):
before = []
after = []
product = 1
for num in nums:
before.append(product)
product = product * num
product = 1
for num in reversed(nums):
after.append(product)
product = product * num
after = after[::-1]
result = []
for i in range(len(nums)):
result.append(before[i] * after[i])
return result
| class Solution:
def product_except_self(self, nums):
before = []
after = []
product = 1
for num in nums:
before.append(product)
product = product * num
product = 1
for num in reversed(nums):
after.append(product)
product = product * num
after = after[::-1]
result = []
for i in range(len(nums)):
result.append(before[i] * after[i])
return result |
def f(a):
global n
if n == 0 and a == 0:
return True
if n == a%10:
return True
if n == a//10:
return True
H1,M1=list(map(int,input().split()))
H2,M2=list(map(int,input().split()))
n=int(input())
S=0
while H1 != H2 or M1 != M2:
if f(H1) or f(M1):
S+=1
if M1 + 1 == 60:
M1=0
H1+=1
else:
M1+=1
if f(H2) or f(M2):
S+=1
print(S) | def f(a):
global n
if n == 0 and a == 0:
return True
if n == a % 10:
return True
if n == a // 10:
return True
(h1, m1) = list(map(int, input().split()))
(h2, m2) = list(map(int, input().split()))
n = int(input())
s = 0
while H1 != H2 or M1 != M2:
if f(H1) or f(M1):
s += 1
if M1 + 1 == 60:
m1 = 0
h1 += 1
else:
m1 += 1
if f(H2) or f(M2):
s += 1
print(S) |
def add(x, y):
""" Add two number """
return x+y
def subtract(x,y):
return abs(x-y)
| def add(x, y):
""" Add two number """
return x + y
def subtract(x, y):
return abs(x - y) |
LOCATION_REPLACE = {
'USA': 'United States',
'KSA': 'Kingdom of Saudi Arabia',
'CA': 'Canada',
}
| location_replace = {'USA': 'United States', 'KSA': 'Kingdom of Saudi Arabia', 'CA': 'Canada'} |
def count(index):
print(index)
if index < 2:
count(index + 1)
count(0)
| def count(index):
print(index)
if index < 2:
count(index + 1)
count(0) |
def elbow_method(data, clusterer, max_k):
"""Elbow method function.
Takes dataset, "Reason" clusterer class and returns the optimum number of
clusters in range of 1 to max_k.
Args:
data (pandas.DataFrame or list of dict): Data to cluster.
clusterer (class): "Reason" clusterer.
max_k (int): Maximum k to analysis.
Returns:
k (int): Optimum number of clusters.
"""
k = None
score = _get_score(data, clusterer, 1)
for i in range(2, max_k + 1):
current_score = _get_score(data, clusterer, i)
if (score - current_score) < (score / 8):
k = i - 1
break
score = current_score
if k is None:
return max_k
return k
def _get_score(data, clusterer, k):
model = clusterer()
model.fit(data, k=k, verbose=0)
return model.inertia()
| def elbow_method(data, clusterer, max_k):
"""Elbow method function.
Takes dataset, "Reason" clusterer class and returns the optimum number of
clusters in range of 1 to max_k.
Args:
data (pandas.DataFrame or list of dict): Data to cluster.
clusterer (class): "Reason" clusterer.
max_k (int): Maximum k to analysis.
Returns:
k (int): Optimum number of clusters.
"""
k = None
score = _get_score(data, clusterer, 1)
for i in range(2, max_k + 1):
current_score = _get_score(data, clusterer, i)
if score - current_score < score / 8:
k = i - 1
break
score = current_score
if k is None:
return max_k
return k
def _get_score(data, clusterer, k):
model = clusterer()
model.fit(data, k=k, verbose=0)
return model.inertia() |
def main():
def square(n):
return n * n
if __name__ == '__main__':
main()
| def main():
def square(n):
return n * n
if __name__ == '__main__':
main() |
class Response:
def __init__(self, content, private=False, file=False):
self.content = content
self.private = private
self.file = file | class Response:
def __init__(self, content, private=False, file=False):
self.content = content
self.private = private
self.file = file |
def knapsackLight(value1, weight1, value2, weight2, maxW):
if weight1 + weight2 <= maxW:
return value1 + value2
if weight1 <= maxW and (weight2 > maxW or value1 >= value2):
return value1
if weight2 <= maxW and (weight1 > maxW or value2 >= value1):
return value2
return 0
| def knapsack_light(value1, weight1, value2, weight2, maxW):
if weight1 + weight2 <= maxW:
return value1 + value2
if weight1 <= maxW and (weight2 > maxW or value1 >= value2):
return value1
if weight2 <= maxW and (weight1 > maxW or value2 >= value1):
return value2
return 0 |
#
# PySNMP MIB module A3COM0074-SMA-VLAN-SUPPORT (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM0074-SMA-VLAN-SUPPORT
# Produced by pysmi-0.3.4 at Wed May 1 11:09:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
smaVlanSupport, = mibBuilder.importSymbols("A3COM0004-GENERIC", "smaVlanSupport")
OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection")
a3ComVlanIfIndex, = mibBuilder.importSymbols("GENERIC-3COM-VLAN-MIB-1-0-7", "a3ComVlanIfIndex")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
NotificationType, Counter32, Integer32, ObjectIdentity, Counter64, IpAddress, MibIdentifier, iso, ModuleIdentity, Unsigned32, Gauge32, TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Counter32", "Integer32", "ObjectIdentity", "Counter64", "IpAddress", "MibIdentifier", "iso", "ModuleIdentity", "Unsigned32", "Gauge32", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
a3ComVlanPrivateIfTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 35, 1), )
if mibBuilder.loadTexts: a3ComVlanPrivateIfTable.setStatus('mandatory')
if mibBuilder.loadTexts: a3ComVlanPrivateIfTable.setDescription('Private VLAN information table for internal agent operations.')
a3ComVlanPrivateIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1), ).setIndexNames((0, "GENERIC-3COM-VLAN-MIB-1-0-7", "a3ComVlanIfIndex"))
if mibBuilder.loadTexts: a3ComVlanPrivateIfEntry.setStatus('mandatory')
if mibBuilder.loadTexts: a3ComVlanPrivateIfEntry.setDescription('An individual VLAN interface entry. When an NMS wishes to create a new entry in this table, it must obtain a non-zero index from the a3ComNextAvailableVirtIfIndex object. Row creation in this table will fail if the chosen index value does not match the current value returned from the a3ComNextAvailableVirtIfIndex object.')
a3ComVlanCreateType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("automatic", 1), ("dynamic", 2), ("manual", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: a3ComVlanCreateType.setStatus('mandatory')
if mibBuilder.loadTexts: a3ComVlanCreateType.setDescription('The reason this Vlan has been created. The possible values are: automatic (1) - This VLAN was created on this unit due to replication across a stack of units. dynamic (2) - VLAN created internally by some automatic mechanism, for example GVRP. manual (3) - VLAN created by some external management application. NOTE - This MIB object may only be set by the agent. It is illegal and serves no purpose for this object to be set for some other application.')
a3ComVlanMembers = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: a3ComVlanMembers.setStatus('mandatory')
if mibBuilder.loadTexts: a3ComVlanMembers.setDescription('Total number of members of this VLAN across the entire stack. If the value of this MIB object is zero then the VLAN is not currently in use on any device in the stack.')
mibBuilder.exportSymbols("A3COM0074-SMA-VLAN-SUPPORT", a3ComVlanPrivateIfEntry=a3ComVlanPrivateIfEntry, a3ComVlanCreateType=a3ComVlanCreateType, a3ComVlanMembers=a3ComVlanMembers, a3ComVlanPrivateIfTable=a3ComVlanPrivateIfTable)
| (sma_vlan_support,) = mibBuilder.importSymbols('A3COM0004-GENERIC', 'smaVlanSupport')
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection')
(a3_com_vlan_if_index,) = mibBuilder.importSymbols('GENERIC-3COM-VLAN-MIB-1-0-7', 'a3ComVlanIfIndex')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(notification_type, counter32, integer32, object_identity, counter64, ip_address, mib_identifier, iso, module_identity, unsigned32, gauge32, time_ticks, mib_scalar, mib_table, mib_table_row, mib_table_column, bits) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Counter32', 'Integer32', 'ObjectIdentity', 'Counter64', 'IpAddress', 'MibIdentifier', 'iso', 'ModuleIdentity', 'Unsigned32', 'Gauge32', 'TimeTicks', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Bits')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
a3_com_vlan_private_if_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 35, 1))
if mibBuilder.loadTexts:
a3ComVlanPrivateIfTable.setStatus('mandatory')
if mibBuilder.loadTexts:
a3ComVlanPrivateIfTable.setDescription('Private VLAN information table for internal agent operations.')
a3_com_vlan_private_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1)).setIndexNames((0, 'GENERIC-3COM-VLAN-MIB-1-0-7', 'a3ComVlanIfIndex'))
if mibBuilder.loadTexts:
a3ComVlanPrivateIfEntry.setStatus('mandatory')
if mibBuilder.loadTexts:
a3ComVlanPrivateIfEntry.setDescription('An individual VLAN interface entry. When an NMS wishes to create a new entry in this table, it must obtain a non-zero index from the a3ComNextAvailableVirtIfIndex object. Row creation in this table will fail if the chosen index value does not match the current value returned from the a3ComNextAvailableVirtIfIndex object.')
a3_com_vlan_create_type = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('automatic', 1), ('dynamic', 2), ('manual', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
a3ComVlanCreateType.setStatus('mandatory')
if mibBuilder.loadTexts:
a3ComVlanCreateType.setDescription('The reason this Vlan has been created. The possible values are: automatic (1) - This VLAN was created on this unit due to replication across a stack of units. dynamic (2) - VLAN created internally by some automatic mechanism, for example GVRP. manual (3) - VLAN created by some external management application. NOTE - This MIB object may only be set by the agent. It is illegal and serves no purpose for this object to be set for some other application.')
a3_com_vlan_members = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 35, 1, 1, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
a3ComVlanMembers.setStatus('mandatory')
if mibBuilder.loadTexts:
a3ComVlanMembers.setDescription('Total number of members of this VLAN across the entire stack. If the value of this MIB object is zero then the VLAN is not currently in use on any device in the stack.')
mibBuilder.exportSymbols('A3COM0074-SMA-VLAN-SUPPORT', a3ComVlanPrivateIfEntry=a3ComVlanPrivateIfEntry, a3ComVlanCreateType=a3ComVlanCreateType, a3ComVlanMembers=a3ComVlanMembers, a3ComVlanPrivateIfTable=a3ComVlanPrivateIfTable) |
def countConstruct(target, word_bank, memo = None):
'''
input: target- String
word_bank- array of Strings
output: number of ways that the target can be constructed by
concatenating elements fo the word_bank array.
'''
if memo is None:
memo = {}
if target in memo:
return memo[target]
if target == '':
return 1
totalCount = 0
for word in word_bank:
if target.startswith(word):
suffix = target[len(word):]
numWaysForRest = countConstruct(suffix, word_bank, memo)
totalCount += numWaysForRest
memo[target] = totalCount
return totalCount
print(countConstruct("abcdef", ["ab","abc","cd","def","abcd"]))
print(countConstruct("purple",["purp","p","ur","le","purpl"]))
print(countConstruct("skateboard", ["bo","rd","ate","t","ska","sk","boar"]))
print(countConstruct("enterapotentpot",["a","p","ent","enter","ot","o","t"]))
print(countConstruct("eeeeeeeeeeeeeeeeeeeeeeeeeef",[
"e",
"ee",
"eee",
"eeee",
"eeeee",
"eeeeee"])) | def count_construct(target, word_bank, memo=None):
"""
input: target- String
word_bank- array of Strings
output: number of ways that the target can be constructed by
concatenating elements fo the word_bank array.
"""
if memo is None:
memo = {}
if target in memo:
return memo[target]
if target == '':
return 1
total_count = 0
for word in word_bank:
if target.startswith(word):
suffix = target[len(word):]
num_ways_for_rest = count_construct(suffix, word_bank, memo)
total_count += numWaysForRest
memo[target] = totalCount
return totalCount
print(count_construct('abcdef', ['ab', 'abc', 'cd', 'def', 'abcd']))
print(count_construct('purple', ['purp', 'p', 'ur', 'le', 'purpl']))
print(count_construct('skateboard', ['bo', 'rd', 'ate', 't', 'ska', 'sk', 'boar']))
print(count_construct('enterapotentpot', ['a', 'p', 'ent', 'enter', 'ot', 'o', 't']))
print(count_construct('eeeeeeeeeeeeeeeeeeeeeeeeeef', ['e', 'ee', 'eee', 'eeee', 'eeeee', 'eeeeee'])) |
# scenario of runs for MC covering 2012 with three eras, as proposed by ECAL/H2g for 2013 re-digi campaign
# for reference see: https://indico.cern.ch/conferenceDisplay.py?confId=243497
runProbabilityDistribution=[(194533,5.3),(200519,7.0),(206859,7.3)]
| run_probability_distribution = [(194533, 5.3), (200519, 7.0), (206859, 7.3)] |
__author__ = 'roeiherz'
"""
Given two straight line segments (represents as a start point and end point), compute the point of intersection, if any.
"""
class Line:
def __init__(self, point1, point2):
self.point1 = point1
self.point2 = point2
self.m = self.slope()
self.n = self.get_n()
def slope(self):
# X=5
if self.point1[0] == self.point2[0]:
return None
# Y=3
if self.point1[1] == self.point2[1]:
return 0
# Y=mX+N
return (self.point2[1] - self.point1[1]) / float(self.point2[0] - self.point1[0])
def get_n(self):
if self.m is None:
return None
return self.point1[1] - self.m * self.point1[0]
def find_intersection(line1, line2):
# both lines are x=5 and x=3; no intersection
if line1.m is None and line2.m is None:
return None
# both lines are y=5 and y=3; no intersection
if line1.n is None and line2.n is None:
return None
# Only one of the lines is x=5; and other y=mx+n
if line1.m is None:
x = line1.point1[0]
y = line2.m * x + line2.n
return (x, y)
if line2.m is None:
x = line2.point1[0]
y = line1.m * x + line1.n
return (x, y)
# Find intersection point
if line2.m != line1.m:
x = (line1.n - line2.n) / (line2.m - line1.m)
y = line2.m * x + line2.n
return (x, y)
else:
# Parallel
return None
if __name__ == '__main__':
line1 = Line((5, 3), (4, 2))
line2 = Line((3, 5), (2, 4))
inter = find_intersection(line1, line2) | __author__ = 'roeiherz'
'\nGiven two straight line segments (represents as a start point and end point), compute the point of intersection, if any.\n'
class Line:
def __init__(self, point1, point2):
self.point1 = point1
self.point2 = point2
self.m = self.slope()
self.n = self.get_n()
def slope(self):
if self.point1[0] == self.point2[0]:
return None
if self.point1[1] == self.point2[1]:
return 0
return (self.point2[1] - self.point1[1]) / float(self.point2[0] - self.point1[0])
def get_n(self):
if self.m is None:
return None
return self.point1[1] - self.m * self.point1[0]
def find_intersection(line1, line2):
if line1.m is None and line2.m is None:
return None
if line1.n is None and line2.n is None:
return None
if line1.m is None:
x = line1.point1[0]
y = line2.m * x + line2.n
return (x, y)
if line2.m is None:
x = line2.point1[0]
y = line1.m * x + line1.n
return (x, y)
if line2.m != line1.m:
x = (line1.n - line2.n) / (line2.m - line1.m)
y = line2.m * x + line2.n
return (x, y)
else:
return None
if __name__ == '__main__':
line1 = line((5, 3), (4, 2))
line2 = line((3, 5), (2, 4))
inter = find_intersection(line1, line2) |
def sortStack(stack):
if len(stack) == 0:
return stack
top = stack.pop()
sortStack(stack)
insertInSortedOrder(stack, top)
return stack
def insertInSortedOrder(stack, value):
if len(stack) == 0 or stack[-1] <= value:
stack.append(value)
return
top = stack.pop()
insertInSortedOrder(stack, top)
stack.append(top)
| def sort_stack(stack):
if len(stack) == 0:
return stack
top = stack.pop()
sort_stack(stack)
insert_in_sorted_order(stack, top)
return stack
def insert_in_sorted_order(stack, value):
if len(stack) == 0 or stack[-1] <= value:
stack.append(value)
return
top = stack.pop()
insert_in_sorted_order(stack, top)
stack.append(top) |
def safe_strftime(d, format_str='%Y-%m-%d %H:%M:%S') -> str:
try:
return d.strftime(format_str)
except Exception:
return ''
| def safe_strftime(d, format_str='%Y-%m-%d %H:%M:%S') -> str:
try:
return d.strftime(format_str)
except Exception:
return '' |
# WebSite Name
WebSiteName = 'Articles Journal'
######################################################################################
# Pages
__HOST = 'http://127.0.0.1:8000'
#############
# Register
SignUP = __HOST + '/Register/SignUP'
SignUP_Template = 'Register/SignUP.html'
Login = __HOST + '/Register/Login'
Login_Template = 'Register/Login.html'
#############
# Articles
Articles = __HOST
Articles_Template = 'Articles/Articles.html'
MakeArticle = __HOST + '/Articles/MakeArticle'
MakeArticle_Template = 'Articles/MakeArticle.html'
EditArticle = __HOST + '/Articles/EditArticle/'
EditArticle_Template = 'Articles/EditArticle.html'
MakeOrEditSuccess_Template = 'Articles/MakeOrEditSuccess.HTML'
Article = __HOST + '/Articles/Article/'
Article_Template = 'Articles/Article.html'
#############
# Profile
Settings = __HOST + '/Profile/Settings'
Settings_Template = 'Profile/Settings/Settings.html'
Settings_Name_Template = 'Profile/Settings/Name.html'
Settings_Password_Template = 'Profile/Settings/Password.html'
Settings_Picture_Template = 'Profile/Settings/Picture.html'
Settings_DeActivate_Template = 'Profile/Settings/DeActivate.html'
MyProfile = __HOST + '/Profile/MyProfile'
MyProfile_Template = 'Profile/MyProfile.HTML'
User = __HOST + '/Profile/User/'
User_Template = 'Profile/User.HTML'
Notifications = __HOST + '/Profile/MyNotifications'
Notifications_Template = 'Profile/MyNotifications.HTML'
#############
# Services
Help = __HOST + '/Services/Help'
Help_Template = 'Services/Help.html'
Policy = __HOST + '/Services/Policy'
Policy_Template = 'Services/Policy.html'
######################################################################################
# Status Pages
__StatusPages = 'StatusPages/'
UnAuthurithedUserPage = __StatusPages + 'UnAuthurithedUserPage.HTML'
ErrorPage = __StatusPages + 'ErrorPage.HTML'
LogOutPage = __StatusPages + 'LogOutPage.HTML'
NotFoundPage = __StatusPages + '404.HTML'
######################################################################################
# Messages
MessageBox = 'MessageBoxs/MessageBox.html'
######################################################################################
# Picture Folder
__Pictures = 'Pictures/'
# Main Pictures
LOGO = __Pictures + 'LOGO.JPG'
OnlineUser = __Pictures + 'OnlineUser.PNG'
OfflineUser = __Pictures + 'OfflineUser.PNG'
AddPicture = __Pictures + 'AddPicture.PNG'
NoNotification = __Pictures + 'NoNotification.PNG'
Notification = __Pictures + 'Notification.PNG'
Send = __Pictures + 'Send.PNG'
DropDown = __Pictures + 'DropDown.PNG'
######################################################################################
# Length
# Sign UP
Name_Len = 40
Email_Len = 100
Password_Len = 40
Picture_Len = 40
# Make Article
Article_Len = 2000
ArticleTitle_Len = 50
ArticleTags_Len = 100
# Articles
id_Len = 15
# Settings
Picture_Byte_Len = 2097152
# Article
Comment_Len = 500
# Notifications
NotificationsType_Len = 1
NotificationsMessage_Len = 300
######################################################################################
# Layouts
Base = 'Base.html'
######################################################################################
# JavaScript Folder
__JavaScript = 'JavaScript/'
#################
# important functions
__MainScripts = __JavaScript + 'MainScripts/'
JQueryScript = __MainScripts + 'jquery-3.3.1.js'
BootStrapScript = __MainScripts + 'BootStrap.js'
MiniBootStrapScript = __MainScripts + 'MiniBootStrap.js'
DropBoxScript = __MainScripts + 'BodyLoadScript.js'
JQueryRotateScript = __MainScripts + 'JQueryRotate.js'
####################
# Global Functions
__Global_Scripts = __JavaScript + 'GlobalFunctions/'
CheckLenScript = __Global_Scripts + 'CheckLen.js'
CheckinputLenScript = __Global_Scripts + 'CheckinputLen.js'
CheckPasswordScript = __Global_Scripts + 'CheckPassword.js'
CheckPatternScript = __Global_Scripts + 'CheckPattern.js'
TrigerMessageScript = __Global_Scripts + 'TriggerMessage.js'
ErrorFunctionScript = __Global_Scripts + 'SetError_Function.js'
AddPictureScript = __Global_Scripts + 'AddPicture.js'
TrigerFormScript = __Global_Scripts + 'TriggerForm.js'
CheckNameScript = __Global_Scripts + 'CheckName.js'
###################
# Pages Scripts
PagesScripts = __JavaScript + 'PagesScripts/'
######################################################################################
# CSS Folder
__CSS = 'CSS/'
# Main CSS Folders
__MainCSS = __CSS + 'MainCSS/'
AllPagesCSS = __MainCSS + 'AllPagesCSS.CSS'
# Boot Strap
BootStrapCSS = __MainCSS + 'BootStrap/bootstrap.css'
MiniBootStrapCSS = __MainCSS + 'BootStrap/bootstrap.min.css'
###################
# Pages CSS
PagesCSS = __CSS + 'PagesCSS/'
######################################################################################
# BackEnd Pages
__BackEnd = __HOST + '/BackEnd/'
CheckName = __BackEnd + 'CheckName'
CheckEmail = __BackEnd + 'CheckEmail'
LogOut = __BackEnd + 'LogOut'
GetPosts = __BackEnd + 'GetPosts'
MakeCommentPage = __BackEnd + 'MakeComment'
LikeDisLikePostPage = __BackEnd + 'LikeDisLikePost'
DeletePostPage = __BackEnd + 'DeletePost'
GetNotificationsPage = __BackEnd + 'GetNotifications'
######################################################################################
# Small Headers
__Headers = 'Headers/'
##################
__BasicHeaders = __Headers + 'BasicHeaders/'
NavBar = __BasicHeaders + 'NavBar.html'
UserLogged = __BasicHeaders + 'UserLogged.html'
UserNotLogged = __BasicHeaders + 'UserNotLogged.html'
Notifications_Header = __BasicHeaders + 'Notifications_Header.HTML'
Header = __Headers + 'Header.html'
def GetLinks(String):
Links = []
while True:
Start = String.find('[')
if Start == -1:
return
String = String[Start:]
End = String.find(']')
if End == -1:
return
Text = String[:End+1]
String = String[End+1:]
for i in range(len(String)):
if String[i] != ' ':
if String[i] != '(':
return
else:
String = String[i:]
break
Start = String.find('(')
if Start == -1:
return
String = String[Start:]
End = String.find(')')
if End == -1:
return
Link = String[:End+1]
String = String[End+1:]
Links.append([Text, Link])
Test = 'My Link is ss[Hady] (http://findhouse.com) . i (Am) [Here] (Because ) Of You'
Test2 = '[My Link is (HAHAHA)(] ( )'
Test3 = ''
GetLinks(Test3)
| web_site_name = 'Articles Journal'
__host = 'http://127.0.0.1:8000'
sign_up = __HOST + '/Register/SignUP'
sign_up__template = 'Register/SignUP.html'
login = __HOST + '/Register/Login'
login__template = 'Register/Login.html'
articles = __HOST
articles__template = 'Articles/Articles.html'
make_article = __HOST + '/Articles/MakeArticle'
make_article__template = 'Articles/MakeArticle.html'
edit_article = __HOST + '/Articles/EditArticle/'
edit_article__template = 'Articles/EditArticle.html'
make_or_edit_success__template = 'Articles/MakeOrEditSuccess.HTML'
article = __HOST + '/Articles/Article/'
article__template = 'Articles/Article.html'
settings = __HOST + '/Profile/Settings'
settings__template = 'Profile/Settings/Settings.html'
settings__name__template = 'Profile/Settings/Name.html'
settings__password__template = 'Profile/Settings/Password.html'
settings__picture__template = 'Profile/Settings/Picture.html'
settings__de_activate__template = 'Profile/Settings/DeActivate.html'
my_profile = __HOST + '/Profile/MyProfile'
my_profile__template = 'Profile/MyProfile.HTML'
user = __HOST + '/Profile/User/'
user__template = 'Profile/User.HTML'
notifications = __HOST + '/Profile/MyNotifications'
notifications__template = 'Profile/MyNotifications.HTML'
help = __HOST + '/Services/Help'
help__template = 'Services/Help.html'
policy = __HOST + '/Services/Policy'
policy__template = 'Services/Policy.html'
___status_pages = 'StatusPages/'
un_authurithed_user_page = __StatusPages + 'UnAuthurithedUserPage.HTML'
error_page = __StatusPages + 'ErrorPage.HTML'
log_out_page = __StatusPages + 'LogOutPage.HTML'
not_found_page = __StatusPages + '404.HTML'
message_box = 'MessageBoxs/MessageBox.html'
___pictures = 'Pictures/'
logo = __Pictures + 'LOGO.JPG'
online_user = __Pictures + 'OnlineUser.PNG'
offline_user = __Pictures + 'OfflineUser.PNG'
add_picture = __Pictures + 'AddPicture.PNG'
no_notification = __Pictures + 'NoNotification.PNG'
notification = __Pictures + 'Notification.PNG'
send = __Pictures + 'Send.PNG'
drop_down = __Pictures + 'DropDown.PNG'
name__len = 40
email__len = 100
password__len = 40
picture__len = 40
article__len = 2000
article_title__len = 50
article_tags__len = 100
id__len = 15
picture__byte__len = 2097152
comment__len = 500
notifications_type__len = 1
notifications_message__len = 300
base = 'Base.html'
___java_script = 'JavaScript/'
___main_scripts = __JavaScript + 'MainScripts/'
j_query_script = __MainScripts + 'jquery-3.3.1.js'
boot_strap_script = __MainScripts + 'BootStrap.js'
mini_boot_strap_script = __MainScripts + 'MiniBootStrap.js'
drop_box_script = __MainScripts + 'BodyLoadScript.js'
j_query_rotate_script = __MainScripts + 'JQueryRotate.js'
___global__scripts = __JavaScript + 'GlobalFunctions/'
check_len_script = __Global_Scripts + 'CheckLen.js'
checkinput_len_script = __Global_Scripts + 'CheckinputLen.js'
check_password_script = __Global_Scripts + 'CheckPassword.js'
check_pattern_script = __Global_Scripts + 'CheckPattern.js'
triger_message_script = __Global_Scripts + 'TriggerMessage.js'
error_function_script = __Global_Scripts + 'SetError_Function.js'
add_picture_script = __Global_Scripts + 'AddPicture.js'
triger_form_script = __Global_Scripts + 'TriggerForm.js'
check_name_script = __Global_Scripts + 'CheckName.js'
pages_scripts = __JavaScript + 'PagesScripts/'
__css = 'CSS/'
___main_css = __CSS + 'MainCSS/'
all_pages_css = __MainCSS + 'AllPagesCSS.CSS'
boot_strap_css = __MainCSS + 'BootStrap/bootstrap.css'
mini_boot_strap_css = __MainCSS + 'BootStrap/bootstrap.min.css'
pages_css = __CSS + 'PagesCSS/'
___back_end = __HOST + '/BackEnd/'
check_name = __BackEnd + 'CheckName'
check_email = __BackEnd + 'CheckEmail'
log_out = __BackEnd + 'LogOut'
get_posts = __BackEnd + 'GetPosts'
make_comment_page = __BackEnd + 'MakeComment'
like_dis_like_post_page = __BackEnd + 'LikeDisLikePost'
delete_post_page = __BackEnd + 'DeletePost'
get_notifications_page = __BackEnd + 'GetNotifications'
___headers = 'Headers/'
___basic_headers = __Headers + 'BasicHeaders/'
nav_bar = __BasicHeaders + 'NavBar.html'
user_logged = __BasicHeaders + 'UserLogged.html'
user_not_logged = __BasicHeaders + 'UserNotLogged.html'
notifications__header = __BasicHeaders + 'Notifications_Header.HTML'
header = __Headers + 'Header.html'
def get_links(String):
links = []
while True:
start = String.find('[')
if Start == -1:
return
string = String[Start:]
end = String.find(']')
if End == -1:
return
text = String[:End + 1]
string = String[End + 1:]
for i in range(len(String)):
if String[i] != ' ':
if String[i] != '(':
return
else:
string = String[i:]
break
start = String.find('(')
if Start == -1:
return
string = String[Start:]
end = String.find(')')
if End == -1:
return
link = String[:End + 1]
string = String[End + 1:]
Links.append([Text, Link])
test = 'My Link is ss[Hady] (http://findhouse.com) . i (Am) [Here] (Because ) Of You'
test2 = '[My Link is (HAHAHA)(] ( )'
test3 = ''
get_links(Test3) |
def compute_opt(exact_filename, preprocessing_filename):
datasets = set() # Dataset names
exact_solution_lookup = {} # Maps dataset names to OPT
with open(exact_filename, 'r') as infile:
# Discard header
infile.readline()
for line in infile.readlines():
line = line.split(',')
if line[1] == 'ilp':
datasets.add(line[0])
exact_solution_lookup[line[0]] = int(line[3])
oct_removed_lookup = {} # Maps dataset names to V_o
with open(preprocessing_filename, 'r') as infile:
# Discard header
infile.readline()
for line in infile.readlines():
line = line.split(',')
oct_removed_lookup[line[0]] = int(line[5])
before_oct_lookup = {} # Maps dataset names to OCT on raw data
for dataset in datasets:
before_oct_lookup[dataset] = exact_solution_lookup[dataset] +\
oct_removed_lookup[dataset]
clusters = ['aa-er', 'aa-cl', 'aa-ba', 'aa-to',
'j-er', 'j-cl', 'j-ba', 'j-to',
'b-50-er', 'b-50-cl', 'b-50-ba', 'b-50-to',
'b-100-er', 'b-100-cl', 'b-100-ba', 'b-100-to',
'gka-er', 'gka-cl', 'gka-ba', 'gka-to']
oct_before = {} # clustered by dataset
oct_after = {}
print(before_oct_lookup)
for cluster in clusters:
oct_before[cluster] = []
oct_after[cluster] = []
for dataset in datasets:
if 'aa' in dataset:
if '-er' in dataset:
oct_before['aa-er'].append(before_oct_lookup[dataset])
oct_after['aa-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['aa-cl'].append(before_oct_lookup[dataset])
oct_after['aa-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['aa-ba'].append(before_oct_lookup[dataset])
oct_after['aa-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['aa-to'].append(before_oct_lookup[dataset])
oct_after['aa-to'].append(exact_solution_lookup[dataset])
elif 'j' in dataset:
if '-er' in dataset:
oct_before['j-er'].append(before_oct_lookup[dataset])
oct_after['j-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['j-cl'].append(before_oct_lookup[dataset])
oct_after['j-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['j-ba'].append(before_oct_lookup[dataset])
oct_after['j-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['j-to'].append(before_oct_lookup[dataset])
oct_after['j-to'].append(exact_solution_lookup[dataset])
elif 'b-50' in dataset:
if '-er' in dataset:
oct_before['b-50-er'].append(before_oct_lookup[dataset])
oct_after['b-50-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['b-50-cl'].append(before_oct_lookup[dataset])
oct_after['b-50-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['b-50-ba'].append(before_oct_lookup[dataset])
oct_after['b-50-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['b-50-to'].append(before_oct_lookup[dataset])
oct_after['b-50-to'].append(exact_solution_lookup[dataset])
elif 'b-100' in dataset:
if '-er' in dataset:
oct_before['b-100-er'].append(before_oct_lookup[dataset])
oct_after['b-100-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['b-100-cl'].append(before_oct_lookup[dataset])
oct_after['b-100-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['b-100-ba'].append(before_oct_lookup[dataset])
oct_after['b-100-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['b-100-to'].append(before_oct_lookup[dataset])
oct_after['b-100-to'].append(exact_solution_lookup[dataset])
elif 'gka' in dataset:
if '-er' in dataset:
oct_before['gka-er'].append(before_oct_lookup[dataset])
oct_after['gka-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['gka-cl'].append(before_oct_lookup[dataset])
oct_after['gka-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['gka-ba'].append(before_oct_lookup[dataset])
oct_after['gka-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['gka-to'].append(before_oct_lookup[dataset])
oct_after['gka-to'].append(exact_solution_lookup[dataset])
print(oct_after)
for cluster in clusters:
try:
print('{} before'.format(cluster),
min(oct_before[cluster]),
max(oct_before[cluster]))
print('{} after:'.format(cluster),
min(oct_after[cluster]),
max(oct_after[cluster]))
except:
pass
if __name__ == "__main__":
compute_opt('results/exact_results.csv', 'results/final_preprocessing.csv')
| def compute_opt(exact_filename, preprocessing_filename):
datasets = set()
exact_solution_lookup = {}
with open(exact_filename, 'r') as infile:
infile.readline()
for line in infile.readlines():
line = line.split(',')
if line[1] == 'ilp':
datasets.add(line[0])
exact_solution_lookup[line[0]] = int(line[3])
oct_removed_lookup = {}
with open(preprocessing_filename, 'r') as infile:
infile.readline()
for line in infile.readlines():
line = line.split(',')
oct_removed_lookup[line[0]] = int(line[5])
before_oct_lookup = {}
for dataset in datasets:
before_oct_lookup[dataset] = exact_solution_lookup[dataset] + oct_removed_lookup[dataset]
clusters = ['aa-er', 'aa-cl', 'aa-ba', 'aa-to', 'j-er', 'j-cl', 'j-ba', 'j-to', 'b-50-er', 'b-50-cl', 'b-50-ba', 'b-50-to', 'b-100-er', 'b-100-cl', 'b-100-ba', 'b-100-to', 'gka-er', 'gka-cl', 'gka-ba', 'gka-to']
oct_before = {}
oct_after = {}
print(before_oct_lookup)
for cluster in clusters:
oct_before[cluster] = []
oct_after[cluster] = []
for dataset in datasets:
if 'aa' in dataset:
if '-er' in dataset:
oct_before['aa-er'].append(before_oct_lookup[dataset])
oct_after['aa-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['aa-cl'].append(before_oct_lookup[dataset])
oct_after['aa-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['aa-ba'].append(before_oct_lookup[dataset])
oct_after['aa-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['aa-to'].append(before_oct_lookup[dataset])
oct_after['aa-to'].append(exact_solution_lookup[dataset])
elif 'j' in dataset:
if '-er' in dataset:
oct_before['j-er'].append(before_oct_lookup[dataset])
oct_after['j-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['j-cl'].append(before_oct_lookup[dataset])
oct_after['j-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['j-ba'].append(before_oct_lookup[dataset])
oct_after['j-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['j-to'].append(before_oct_lookup[dataset])
oct_after['j-to'].append(exact_solution_lookup[dataset])
elif 'b-50' in dataset:
if '-er' in dataset:
oct_before['b-50-er'].append(before_oct_lookup[dataset])
oct_after['b-50-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['b-50-cl'].append(before_oct_lookup[dataset])
oct_after['b-50-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['b-50-ba'].append(before_oct_lookup[dataset])
oct_after['b-50-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['b-50-to'].append(before_oct_lookup[dataset])
oct_after['b-50-to'].append(exact_solution_lookup[dataset])
elif 'b-100' in dataset:
if '-er' in dataset:
oct_before['b-100-er'].append(before_oct_lookup[dataset])
oct_after['b-100-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['b-100-cl'].append(before_oct_lookup[dataset])
oct_after['b-100-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['b-100-ba'].append(before_oct_lookup[dataset])
oct_after['b-100-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['b-100-to'].append(before_oct_lookup[dataset])
oct_after['b-100-to'].append(exact_solution_lookup[dataset])
elif 'gka' in dataset:
if '-er' in dataset:
oct_before['gka-er'].append(before_oct_lookup[dataset])
oct_after['gka-er'].append(exact_solution_lookup[dataset])
elif '-cl' in dataset:
oct_before['gka-cl'].append(before_oct_lookup[dataset])
oct_after['gka-cl'].append(exact_solution_lookup[dataset])
elif '-ba' in dataset:
oct_before['gka-ba'].append(before_oct_lookup[dataset])
oct_after['gka-ba'].append(exact_solution_lookup[dataset])
elif '-to' in dataset:
oct_before['gka-to'].append(before_oct_lookup[dataset])
oct_after['gka-to'].append(exact_solution_lookup[dataset])
print(oct_after)
for cluster in clusters:
try:
print('{} before'.format(cluster), min(oct_before[cluster]), max(oct_before[cluster]))
print('{} after:'.format(cluster), min(oct_after[cluster]), max(oct_after[cluster]))
except:
pass
if __name__ == '__main__':
compute_opt('results/exact_results.csv', 'results/final_preprocessing.csv') |
brd = {
'name': ('StickIt! MPU-9150 V1'),
'port': {
'pmod': {
'default' : {
'scl': 'd1',
'clkin': 'd2',
'sda': 'd3',
'int': 'd5',
'fsync': 'd7'
}
},
'wing': {
'default' : {
'scl': 'd0',
'clkin': 'd3',
'sda': 'd2',
'int': 'd5',
'fsync': 'd7'
}
}
}
}
| brd = {'name': 'StickIt! MPU-9150 V1', 'port': {'pmod': {'default': {'scl': 'd1', 'clkin': 'd2', 'sda': 'd3', 'int': 'd5', 'fsync': 'd7'}}, 'wing': {'default': {'scl': 'd0', 'clkin': 'd3', 'sda': 'd2', 'int': 'd5', 'fsync': 'd7'}}}} |
def for_K():
""" Upper case Alphabet letter 'K' pattern using Python Python for loop"""
for row in range(6):
for col in range(4):
if col==0 or row+col==3 or row-col==2:
print('*', end = ' ')
else:
print(' ', end = ' ')
print()
def while_K():
""" Upper case Alphabet letter 'K' pattern using Python Python while loop"""
row = 0
while row<6:
col = 0
while col<4:
if col==0 or row+col==3 or row-col==2:
print('*', end = ' ')
else:
print(' ', end = ' ')
col += 1
print()
row += 1
| def for_k():
""" Upper case Alphabet letter 'K' pattern using Python Python for loop"""
for row in range(6):
for col in range(4):
if col == 0 or row + col == 3 or row - col == 2:
print('*', end=' ')
else:
print(' ', end=' ')
print()
def while_k():
""" Upper case Alphabet letter 'K' pattern using Python Python while loop"""
row = 0
while row < 6:
col = 0
while col < 4:
if col == 0 or row + col == 3 or row - col == 2:
print('*', end=' ')
else:
print(' ', end=' ')
col += 1
print()
row += 1 |
class BlockTerminationNotice(Exception):
pass
class IncorrectLocationException(Exception):
pass
class SootMethodNotLoadedException(Exception):
pass
class SootFieldNotLoadedException(Exception):
pass
| class Blockterminationnotice(Exception):
pass
class Incorrectlocationexception(Exception):
pass
class Sootmethodnotloadedexception(Exception):
pass
class Sootfieldnotloadedexception(Exception):
pass |
# description: various useful helpers
class DataKeys(object):
"""standard names for features
and transformations of features
"""
# core data keys
FEATURES = "features"
LABELS = "labels"
PROBABILITIES = "probs"
LOGITS = "logits"
LOGITS_NORM = "{}.norm".format(LOGITS)
ORIG_SEQ = "sequence"
SEQ_METADATA = "example_metadata"
# ensembles
LOGITS_MULTIMODEL = "{}.multimodel".format(LOGITS)
LOGITS_MULTIMODEL_NORM = "{}.norm".format(LOGITS_MULTIMODEL)
LOGITS_CI = "{}.ci".format(LOGITS)
LOGITS_CI_THRESH = "{}.thresh".format(LOGITS_CI)
# playing with feature transforms
HIDDEN_LAYER_FEATURES = "{}.nn_transform".format(FEATURES)
# for feature importance extraction
IMPORTANCE_ANCHORS = "anchors"
IMPORTANCE_GRADIENTS = "gradients"
WEIGHTED_SEQ = "{}-weighted".format(ORIG_SEQ)
WEIGHTED_SEQ_THRESHOLDS = "{}.thresholds".format(WEIGHTED_SEQ)
# clipping
ORIG_SEQ_ACTIVE = "{}.active".format(ORIG_SEQ)
ORIG_SEQ_ACTIVE_STRING = "{}.string".format(ORIG_SEQ_ACTIVE)
WEIGHTED_SEQ_ACTIVE = "{}.active".format(WEIGHTED_SEQ)
GC_CONTENT = "{}.gc_fract".format(ORIG_SEQ_ACTIVE)
WEIGHTED_SEQ_ACTIVE_CI = "{}.ci".format(WEIGHTED_SEQ_ACTIVE)
WEIGHTED_SEQ_ACTIVE_CI_THRESH = "{}.thresh".format(WEIGHTED_SEQ_ACTIVE_CI)
WEIGHTED_SEQ_MULTIMODEL = "{}.multimodel".format(WEIGHTED_SEQ_ACTIVE)
# for shuffles (generated for null models)
SHUFFLE_SUFFIX = "shuffles"
ACTIVE_SHUFFLES = SHUFFLE_SUFFIX
ORIG_SEQ_SHUF = "{}.{}".format(ORIG_SEQ, SHUFFLE_SUFFIX)
WEIGHTED_SEQ_SHUF = "{}.{}".format(WEIGHTED_SEQ, SHUFFLE_SUFFIX)
ORIG_SEQ_ACTIVE_SHUF = "{}.{}".format(ORIG_SEQ_ACTIVE, SHUFFLE_SUFFIX)
WEIGHTED_SEQ_ACTIVE_SHUF = "{}.{}".format(WEIGHTED_SEQ_ACTIVE, SHUFFLE_SUFFIX)
LOGITS_SHUF = "{}.{}".format(LOGITS, SHUFFLE_SUFFIX)
# pwm transformation keys
PWM_SCORES_ROOT = "pwm-scores"
ORIG_SEQ_PWM_HITS = "{}.pwm-hits".format(ORIG_SEQ_ACTIVE)
ORIG_SEQ_PWM_HITS_COUNT = "{}.count".format(ORIG_SEQ_PWM_HITS)
ORIG_SEQ_PWM_SCORES = "{}.{}".format(ORIG_SEQ_ACTIVE, PWM_SCORES_ROOT)
ORIG_SEQ_PWM_SCORES_THRESH = "{}.thresh".format(ORIG_SEQ_PWM_SCORES)
ORIG_SEQ_PWM_SCORES_THRESHOLDS = "{}.thresholds".format(ORIG_SEQ_PWM_SCORES)
ORIG_SEQ_PWM_SCORES_SUM = "{}.sum".format(ORIG_SEQ_PWM_SCORES_THRESH)
ORIG_SEQ_SHUF_PWM_SCORES = "{}.{}".format(ORIG_SEQ_ACTIVE_SHUF, PWM_SCORES_ROOT)
ORIG_SEQ_PWM_DENSITIES = "{}.densities".format(ORIG_SEQ_PWM_HITS)
ORIG_SEQ_PWM_MAX_DENSITIES = "{}.max".format(ORIG_SEQ_PWM_DENSITIES)
WEIGHTED_SEQ_PWM_HITS = "{}.pwm-hits".format(WEIGHTED_SEQ_ACTIVE)
WEIGHTED_SEQ_PWM_HITS_COUNT = "{}.count".format(WEIGHTED_SEQ_PWM_HITS)
WEIGHTED_SEQ_PWM_SCORES = "{}.{}".format(WEIGHTED_SEQ_ACTIVE, PWM_SCORES_ROOT)
WEIGHTED_SEQ_PWM_SCORES_THRESH = "{}.thresh".format(WEIGHTED_SEQ_PWM_SCORES)
WEIGHTED_SEQ_PWM_SCORES_THRESHOLDS = "{}.thresholds".format(WEIGHTED_SEQ_PWM_SCORES)
WEIGHTED_SEQ_PWM_SCORES_SUM = "{}.sum".format(WEIGHTED_SEQ_PWM_SCORES_THRESH) # CHECK some downstream change here
WEIGHTED_SEQ_SHUF_PWM_SCORES = "{}.{}".format(WEIGHTED_SEQ_ACTIVE_SHUF, PWM_SCORES_ROOT)
# pwm positions
ORIG_PWM_SCORES_POSITION_MAX_VAL = "{}.max.val".format(ORIG_SEQ_PWM_SCORES_THRESH)
ORIG_PWM_SCORES_POSITION_MAX_IDX = "{}.max.idx".format(ORIG_SEQ_PWM_SCORES_THRESH)
WEIGHTED_PWM_SCORES_POSITION_MAX_VAL = "{}.max.val".format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
WEIGHTED_PWM_SCORES_POSITION_MAX_IDX = "{}.max.idx".format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
WEIGHTED_PWM_SCORES_POSITION_MAX_VAL_MUT = "{}.max.val.motif_mut".format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
WEIGHTED_PWM_SCORES_POSITION_MAX_IDX_MUT = "{}.max.idx.motif_mut".format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
NULL_PWM_POSITION_INDICES = "{}.null.idx".format(PWM_SCORES_ROOT)
# significant pwms
PWM_DIFF_GROUP = "pwms.differential"
PWM_PVALS = "pwms.pvals"
PWM_SIG_ROOT = "pwms.sig"
PWM_SIG_GLOBAL = "{}.global".format(PWM_SIG_ROOT)
PWM_SCORES_AGG_GLOBAL = "{}.agg".format(PWM_SIG_GLOBAL)
PWM_SIG_CLUST = "{}.clusters".format(PWM_SIG_ROOT)
PWM_SIG_CLUST_ALL = "{}.all".format(PWM_SIG_CLUST)
PWM_SCORES_AGG_CLUST = "{}.agg".format(PWM_SIG_CLUST_ALL)
# manifold keys
MANIFOLD_ROOT = "manifold"
MANIFOLD_CENTERS = "{}.centers".format(MANIFOLD_ROOT)
MANIFOLD_THRESHOLDS = "{}.thresholds".format(MANIFOLD_ROOT)
MANIFOLD_CLUST = "{}.clusters".format(MANIFOLD_ROOT)
MANIFOLD_SCORES = "{}.scores".format(MANIFOLD_ROOT)
# manifold sig pwm keys
MANIFOLD_PWM_ROOT = "{}.pwms".format(MANIFOLD_ROOT)
MANIFOLD_PWM_SIG_GLOBAL = "{}.global".format(MANIFOLD_PWM_ROOT)
MANIFOLD_PWM_SCORES_AGG_GLOBAL = "{}.agg".format(MANIFOLD_PWM_SIG_GLOBAL)
MANIFOLD_PWM_SIG_CLUST = "{}.clusters".format(MANIFOLD_PWM_ROOT)
MANIFOLD_PWM_SIG_CLUST_ALL = "{}.all".format(MANIFOLD_PWM_SIG_CLUST)
MANIFOLD_PWM_SCORES_AGG_CLUST = "{}.agg".format(MANIFOLD_PWM_SIG_CLUST_ALL)
# cluster keys
CLUSTERS = "clusters"
# dfim transformation keys
MUT_MOTIF_ORIG_SEQ = "{}.motif_mut".format(ORIG_SEQ)
MUT_MOTIF_WEIGHTED_SEQ = "{}.motif_mut".format(WEIGHTED_SEQ)
MUT_MOTIF_POS = "{}.pos".format(MUT_MOTIF_ORIG_SEQ)
MUT_MOTIF_MASK = "{}.mask".format(MUT_MOTIF_ORIG_SEQ)
MUT_MOTIF_PRESENT = "{}.motif_mut_present".format(ORIG_SEQ)
MUT_MOTIF_LOGITS = "{}.motif_mut".format(LOGITS)
MUT_MOTIF_LOGITS_SIG = "{}.motif_mut.sig".format(LOGITS)
DFIM_SCORES = "{}.delta".format(MUT_MOTIF_WEIGHTED_SEQ)
DFIM_SCORES_DX = "{}.delta.dx".format(MUT_MOTIF_WEIGHTED_SEQ)
MUT_MOTIF_WEIGHTED_SEQ_CI = "{}.ci".format(MUT_MOTIF_WEIGHTED_SEQ)
MUT_MOTIF_WEIGHTED_SEQ_CI_THRESH = "{}.thresh".format(MUT_MOTIF_WEIGHTED_SEQ_CI)
MUT_MOTIF_LOGITS_MULTIMODEL = "{}.multimodel".format(MUT_MOTIF_LOGITS)
# dmim agg results keys
DMIM_SCORES = "dmim.motif_mut.scores"
DMIM_SCORES_SIG = "{}.sig".format(DMIM_SCORES)
DMIM_DIFF_GROUP = "dmim.differential"
DMIM_PVALS = "dmim.pvals"
DMIM_SIG_ROOT = "dmim.sig"
DMIM_SIG_ALL = "{}.all".format(DMIM_SIG_ROOT)
DMIM_ROOT = "{}.{}".format(DFIM_SCORES, PWM_SCORES_ROOT)
DMIM_SIG_RESULTS = "{}.agg.sig".format(DMIM_ROOT)
# grammar keys
GRAMMAR_ROOT = "grammar"
GRAMMAR_LABELS = "{}.labels".format(GRAMMAR_ROOT)
# synergy keys
SYNERGY_ROOT = "synergy"
SYNERGY_SCORES = "{}.scores".format(SYNERGY_ROOT)
SYNERGY_DIFF = "{}.diff".format(SYNERGY_SCORES)
SYNERGY_DIFF_SIG = "{}.sig".format(SYNERGY_DIFF)
SYNERGY_DIST = "{}.dist".format(SYNERGY_ROOT)
SYNERGY_MAX_DIST = "{}.max".format(SYNERGY_DIST)
# variant keys
VARIANT_ROOT = "variants"
VARIANT_ID = "{}.id.string".format(VARIANT_ROOT)
VARIANT_INFO = "{}.info.string".format(VARIANT_ROOT)
VARIANT_IDX = "{}.idx".format(VARIANT_ROOT)
VARIANT_DMIM = "{}.dmim".format(VARIANT_ROOT)
VARIANT_SIG = "{}.sig".format(VARIANT_ROOT)
VARIANT_IMPORTANCE = "{}.impt_score".format(VARIANT_ROOT)
# split
TASK_IDX_ROOT = "taskidx"
class MetaKeys(object):
"""standard names for metadata keys
"""
REGION_ID = "region"
ACTIVE_ID = "active"
FEATURES_ID = "features"
class ParamKeys(object):
"""standard names for params"""
# tensor management
AUX_ROOT = "{}.aux".format(DataKeys.FEATURES)
NUM_AUX = "{}.num".format(AUX_ROOT)
| class Datakeys(object):
"""standard names for features
and transformations of features
"""
features = 'features'
labels = 'labels'
probabilities = 'probs'
logits = 'logits'
logits_norm = '{}.norm'.format(LOGITS)
orig_seq = 'sequence'
seq_metadata = 'example_metadata'
logits_multimodel = '{}.multimodel'.format(LOGITS)
logits_multimodel_norm = '{}.norm'.format(LOGITS_MULTIMODEL)
logits_ci = '{}.ci'.format(LOGITS)
logits_ci_thresh = '{}.thresh'.format(LOGITS_CI)
hidden_layer_features = '{}.nn_transform'.format(FEATURES)
importance_anchors = 'anchors'
importance_gradients = 'gradients'
weighted_seq = '{}-weighted'.format(ORIG_SEQ)
weighted_seq_thresholds = '{}.thresholds'.format(WEIGHTED_SEQ)
orig_seq_active = '{}.active'.format(ORIG_SEQ)
orig_seq_active_string = '{}.string'.format(ORIG_SEQ_ACTIVE)
weighted_seq_active = '{}.active'.format(WEIGHTED_SEQ)
gc_content = '{}.gc_fract'.format(ORIG_SEQ_ACTIVE)
weighted_seq_active_ci = '{}.ci'.format(WEIGHTED_SEQ_ACTIVE)
weighted_seq_active_ci_thresh = '{}.thresh'.format(WEIGHTED_SEQ_ACTIVE_CI)
weighted_seq_multimodel = '{}.multimodel'.format(WEIGHTED_SEQ_ACTIVE)
shuffle_suffix = 'shuffles'
active_shuffles = SHUFFLE_SUFFIX
orig_seq_shuf = '{}.{}'.format(ORIG_SEQ, SHUFFLE_SUFFIX)
weighted_seq_shuf = '{}.{}'.format(WEIGHTED_SEQ, SHUFFLE_SUFFIX)
orig_seq_active_shuf = '{}.{}'.format(ORIG_SEQ_ACTIVE, SHUFFLE_SUFFIX)
weighted_seq_active_shuf = '{}.{}'.format(WEIGHTED_SEQ_ACTIVE, SHUFFLE_SUFFIX)
logits_shuf = '{}.{}'.format(LOGITS, SHUFFLE_SUFFIX)
pwm_scores_root = 'pwm-scores'
orig_seq_pwm_hits = '{}.pwm-hits'.format(ORIG_SEQ_ACTIVE)
orig_seq_pwm_hits_count = '{}.count'.format(ORIG_SEQ_PWM_HITS)
orig_seq_pwm_scores = '{}.{}'.format(ORIG_SEQ_ACTIVE, PWM_SCORES_ROOT)
orig_seq_pwm_scores_thresh = '{}.thresh'.format(ORIG_SEQ_PWM_SCORES)
orig_seq_pwm_scores_thresholds = '{}.thresholds'.format(ORIG_SEQ_PWM_SCORES)
orig_seq_pwm_scores_sum = '{}.sum'.format(ORIG_SEQ_PWM_SCORES_THRESH)
orig_seq_shuf_pwm_scores = '{}.{}'.format(ORIG_SEQ_ACTIVE_SHUF, PWM_SCORES_ROOT)
orig_seq_pwm_densities = '{}.densities'.format(ORIG_SEQ_PWM_HITS)
orig_seq_pwm_max_densities = '{}.max'.format(ORIG_SEQ_PWM_DENSITIES)
weighted_seq_pwm_hits = '{}.pwm-hits'.format(WEIGHTED_SEQ_ACTIVE)
weighted_seq_pwm_hits_count = '{}.count'.format(WEIGHTED_SEQ_PWM_HITS)
weighted_seq_pwm_scores = '{}.{}'.format(WEIGHTED_SEQ_ACTIVE, PWM_SCORES_ROOT)
weighted_seq_pwm_scores_thresh = '{}.thresh'.format(WEIGHTED_SEQ_PWM_SCORES)
weighted_seq_pwm_scores_thresholds = '{}.thresholds'.format(WEIGHTED_SEQ_PWM_SCORES)
weighted_seq_pwm_scores_sum = '{}.sum'.format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
weighted_seq_shuf_pwm_scores = '{}.{}'.format(WEIGHTED_SEQ_ACTIVE_SHUF, PWM_SCORES_ROOT)
orig_pwm_scores_position_max_val = '{}.max.val'.format(ORIG_SEQ_PWM_SCORES_THRESH)
orig_pwm_scores_position_max_idx = '{}.max.idx'.format(ORIG_SEQ_PWM_SCORES_THRESH)
weighted_pwm_scores_position_max_val = '{}.max.val'.format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
weighted_pwm_scores_position_max_idx = '{}.max.idx'.format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
weighted_pwm_scores_position_max_val_mut = '{}.max.val.motif_mut'.format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
weighted_pwm_scores_position_max_idx_mut = '{}.max.idx.motif_mut'.format(WEIGHTED_SEQ_PWM_SCORES_THRESH)
null_pwm_position_indices = '{}.null.idx'.format(PWM_SCORES_ROOT)
pwm_diff_group = 'pwms.differential'
pwm_pvals = 'pwms.pvals'
pwm_sig_root = 'pwms.sig'
pwm_sig_global = '{}.global'.format(PWM_SIG_ROOT)
pwm_scores_agg_global = '{}.agg'.format(PWM_SIG_GLOBAL)
pwm_sig_clust = '{}.clusters'.format(PWM_SIG_ROOT)
pwm_sig_clust_all = '{}.all'.format(PWM_SIG_CLUST)
pwm_scores_agg_clust = '{}.agg'.format(PWM_SIG_CLUST_ALL)
manifold_root = 'manifold'
manifold_centers = '{}.centers'.format(MANIFOLD_ROOT)
manifold_thresholds = '{}.thresholds'.format(MANIFOLD_ROOT)
manifold_clust = '{}.clusters'.format(MANIFOLD_ROOT)
manifold_scores = '{}.scores'.format(MANIFOLD_ROOT)
manifold_pwm_root = '{}.pwms'.format(MANIFOLD_ROOT)
manifold_pwm_sig_global = '{}.global'.format(MANIFOLD_PWM_ROOT)
manifold_pwm_scores_agg_global = '{}.agg'.format(MANIFOLD_PWM_SIG_GLOBAL)
manifold_pwm_sig_clust = '{}.clusters'.format(MANIFOLD_PWM_ROOT)
manifold_pwm_sig_clust_all = '{}.all'.format(MANIFOLD_PWM_SIG_CLUST)
manifold_pwm_scores_agg_clust = '{}.agg'.format(MANIFOLD_PWM_SIG_CLUST_ALL)
clusters = 'clusters'
mut_motif_orig_seq = '{}.motif_mut'.format(ORIG_SEQ)
mut_motif_weighted_seq = '{}.motif_mut'.format(WEIGHTED_SEQ)
mut_motif_pos = '{}.pos'.format(MUT_MOTIF_ORIG_SEQ)
mut_motif_mask = '{}.mask'.format(MUT_MOTIF_ORIG_SEQ)
mut_motif_present = '{}.motif_mut_present'.format(ORIG_SEQ)
mut_motif_logits = '{}.motif_mut'.format(LOGITS)
mut_motif_logits_sig = '{}.motif_mut.sig'.format(LOGITS)
dfim_scores = '{}.delta'.format(MUT_MOTIF_WEIGHTED_SEQ)
dfim_scores_dx = '{}.delta.dx'.format(MUT_MOTIF_WEIGHTED_SEQ)
mut_motif_weighted_seq_ci = '{}.ci'.format(MUT_MOTIF_WEIGHTED_SEQ)
mut_motif_weighted_seq_ci_thresh = '{}.thresh'.format(MUT_MOTIF_WEIGHTED_SEQ_CI)
mut_motif_logits_multimodel = '{}.multimodel'.format(MUT_MOTIF_LOGITS)
dmim_scores = 'dmim.motif_mut.scores'
dmim_scores_sig = '{}.sig'.format(DMIM_SCORES)
dmim_diff_group = 'dmim.differential'
dmim_pvals = 'dmim.pvals'
dmim_sig_root = 'dmim.sig'
dmim_sig_all = '{}.all'.format(DMIM_SIG_ROOT)
dmim_root = '{}.{}'.format(DFIM_SCORES, PWM_SCORES_ROOT)
dmim_sig_results = '{}.agg.sig'.format(DMIM_ROOT)
grammar_root = 'grammar'
grammar_labels = '{}.labels'.format(GRAMMAR_ROOT)
synergy_root = 'synergy'
synergy_scores = '{}.scores'.format(SYNERGY_ROOT)
synergy_diff = '{}.diff'.format(SYNERGY_SCORES)
synergy_diff_sig = '{}.sig'.format(SYNERGY_DIFF)
synergy_dist = '{}.dist'.format(SYNERGY_ROOT)
synergy_max_dist = '{}.max'.format(SYNERGY_DIST)
variant_root = 'variants'
variant_id = '{}.id.string'.format(VARIANT_ROOT)
variant_info = '{}.info.string'.format(VARIANT_ROOT)
variant_idx = '{}.idx'.format(VARIANT_ROOT)
variant_dmim = '{}.dmim'.format(VARIANT_ROOT)
variant_sig = '{}.sig'.format(VARIANT_ROOT)
variant_importance = '{}.impt_score'.format(VARIANT_ROOT)
task_idx_root = 'taskidx'
class Metakeys(object):
"""standard names for metadata keys
"""
region_id = 'region'
active_id = 'active'
features_id = 'features'
class Paramkeys(object):
"""standard names for params"""
aux_root = '{}.aux'.format(DataKeys.FEATURES)
num_aux = '{}.num'.format(AUX_ROOT) |
class Corner(object):
def __init__(self, row, column, lines):
self.row = row
self.column = column
self.lines = lines
self.done = False
for line in self.lines:
line.add_corner(self)
self.line_number = None
def check_values(self):
if self.done:
return
empty = 0
full = 0
for line in self.lines:
if line.is_full:
full += 1
if line.is_empty:
empty += 1
print(self.row, self.column, full, empty, len(self.lines))
if full + empty == len(self.lines):
return False
if full == 2:
print("two lines so other empty")
for line in self.lines:
if not line.is_full:
line.set_empty()
else:
print("skip ", line.column, line.row, line.horizontal)
self.done = True
return True
elif full == 1:
if len(self.lines) - empty == 2:
print("One line and one option")
for line in self.lines:
if not line.is_empty:
line.set_full()
self.done = True
return True
else:
if len(self.lines) - empty == 1:
print("only one still empty")
for line in self.lines:
if not line.is_full:
line.set_empty()
self.done = True
return True
return False
| class Corner(object):
def __init__(self, row, column, lines):
self.row = row
self.column = column
self.lines = lines
self.done = False
for line in self.lines:
line.add_corner(self)
self.line_number = None
def check_values(self):
if self.done:
return
empty = 0
full = 0
for line in self.lines:
if line.is_full:
full += 1
if line.is_empty:
empty += 1
print(self.row, self.column, full, empty, len(self.lines))
if full + empty == len(self.lines):
return False
if full == 2:
print('two lines so other empty')
for line in self.lines:
if not line.is_full:
line.set_empty()
else:
print('skip ', line.column, line.row, line.horizontal)
self.done = True
return True
elif full == 1:
if len(self.lines) - empty == 2:
print('One line and one option')
for line in self.lines:
if not line.is_empty:
line.set_full()
self.done = True
return True
elif len(self.lines) - empty == 1:
print('only one still empty')
for line in self.lines:
if not line.is_full:
line.set_empty()
self.done = True
return True
return False |
#Table used for the example 2split.py
#################################################################################################
source_path = "/home/user/Scrivania/Ducks/"# Where the images are
output_path = "/home/user/Scrivania/Ducks/"# Where the two directory with the cutted images will be stored
RIGHT_CUT_DIR_NAME = "right_duck" #Name of the directory thay contains the right cuts
LEFT_CUT_DIR_NAME = "left_duck" #Name of the directory thay contains the left cuts
LEFT_PREFIX = "left_quacky" #Prefix for left cuts
RIGHT_PREFIX = "right_quacky" #Prefix for right cuts
#################################################################################################
| source_path = '/home/user/Scrivania/Ducks/'
output_path = '/home/user/Scrivania/Ducks/'
right_cut_dir_name = 'right_duck'
left_cut_dir_name = 'left_duck'
left_prefix = 'left_quacky'
right_prefix = 'right_quacky' |
def logic(value, a, b):
if value:
return a
return b
hero.moveXY(20, 24);
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
hero.moveXY(30, logic(a and b and c, 33, 15))
hero.moveXY(logic(a or b or c, 20, 40), 24)
hero.moveXY(30, logic(a and b and c, 33, 15))
| def logic(value, a, b):
if value:
return a
return b
hero.moveXY(20, 24)
a = hero.findNearestFriend().getSecretA()
b = hero.findNearestFriend().getSecretB()
c = hero.findNearestFriend().getSecretC()
hero.moveXY(30, logic(a and b and c, 33, 15))
hero.moveXY(logic(a or b or c, 20, 40), 24)
hero.moveXY(30, logic(a and b and c, 33, 15)) |
def a(mem):
seen = set()
tup = tuple(mem)
count = 0
while tup not in seen:
seen.add(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if(n > max):
max = n
index = i
mem[index] = 0
index += 1
while(max > 0):
mem[index%len(mem)] += 1
max -= 1
index += 1
count += 1
tup = tuple(mem)
return count
def b(mem):
seen = []
tup = tuple(mem)
count = 0
while tup not in seen:
seen.append(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if(n > max):
max = n
index = i
mem[index] = 0
index += 1
while(max > 0):
mem[index%len(mem)] += 1
max -= 1
index += 1
count += 1
tup = tuple(mem)
return count - seen.index(tup)
with open("input.txt") as f:
nums = [int(x.strip()) for x in f.read().split("\t")]
print("Part A:", a(nums))
with open("input.txt") as f:
nums = [int(x.strip()) for x in f.read().split("\t")]
print("Part B:", b(nums))
| def a(mem):
seen = set()
tup = tuple(mem)
count = 0
while tup not in seen:
seen.add(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if n > max:
max = n
index = i
mem[index] = 0
index += 1
while max > 0:
mem[index % len(mem)] += 1
max -= 1
index += 1
count += 1
tup = tuple(mem)
return count
def b(mem):
seen = []
tup = tuple(mem)
count = 0
while tup not in seen:
seen.append(tup)
index = 0
max = 0
for i in range(len(mem)):
n = mem[i]
if n > max:
max = n
index = i
mem[index] = 0
index += 1
while max > 0:
mem[index % len(mem)] += 1
max -= 1
index += 1
count += 1
tup = tuple(mem)
return count - seen.index(tup)
with open('input.txt') as f:
nums = [int(x.strip()) for x in f.read().split('\t')]
print('Part A:', a(nums))
with open('input.txt') as f:
nums = [int(x.strip()) for x in f.read().split('\t')]
print('Part B:', b(nums)) |
def mergeSort(l):
if len(l) > 1:
mid = len(l) // 2
L = l[:mid]
R = l[mid:]
mergeSort(L)
mergeSort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
l[k] = L[i]
i += 1
else:
l[k] = R[j]
j += 1
k += 1
while i < len(L):
l[k] = L[i]
i += 1
k += 1
while j < len(R):
l[k] = R[j]
j += 1
k += 1
l = [8, 7, 12, 10, 2, 999, 45]
print(l)
mergeSort(l)
print(l) | def merge_sort(l):
if len(l) > 1:
mid = len(l) // 2
l = l[:mid]
r = l[mid:]
merge_sort(L)
merge_sort(R)
i = j = k = 0
while i < len(L) and j < len(R):
if L[i] < R[j]:
l[k] = L[i]
i += 1
else:
l[k] = R[j]
j += 1
k += 1
while i < len(L):
l[k] = L[i]
i += 1
k += 1
while j < len(R):
l[k] = R[j]
j += 1
k += 1
l = [8, 7, 12, 10, 2, 999, 45]
print(l)
merge_sort(l)
print(l) |
class Solution:
def minAbbreviation(self, target: str, dictionary: List[str]) -> str:
m = len(target)
def getMask(word: str) -> int:
# mask[i] = 0 := target[i] == word[i]
# mask[i] = 1 := target[i] != word[i]
# e.g. target = "apple"
# word = "blade"
# mask = 11110
mask = 0
for i, c in enumerate(word):
if c != target[i]:
mask |= 1 << m - 1 - i
return mask
masks = [getMask(word) for word in dictionary if len(word) == m]
if not masks:
return str(m)
abbrs = []
def getAbbr(cand: int) -> str:
abbr = ''
replacedCount = 0
for i, c in enumerate(target):
if cand >> m - 1 - i & 1:
# cand[i] = 1, abbr should show the original character
if replacedCount:
abbr += str(replacedCount)
abbr += c
replacedCount = 0
else:
# cand[i] = 0, abbr can be replaced
replacedCount += 1
if replacedCount:
abbr += str(replacedCount)
return abbr
# for all candidate representation of target
for cand in range(2**m):
# all masks have at lease one bit different from candidate
if all(cand & mask for mask in masks):
abbr = getAbbr(cand)
abbrs.append(abbr)
def getAbbrLen(abbr: str) -> int:
abbrLen = 0
i = 0
j = 0
while i < len(abbr):
if abbr[j].isalpha():
j += 1
else:
while j < len(abbr) and abbr[j].isdigit():
j += 1
abbrLen += 1
i = j
return abbrLen
return min(abbrs, key=lambda x: getAbbrLen(x))
| class Solution:
def min_abbreviation(self, target: str, dictionary: List[str]) -> str:
m = len(target)
def get_mask(word: str) -> int:
mask = 0
for (i, c) in enumerate(word):
if c != target[i]:
mask |= 1 << m - 1 - i
return mask
masks = [get_mask(word) for word in dictionary if len(word) == m]
if not masks:
return str(m)
abbrs = []
def get_abbr(cand: int) -> str:
abbr = ''
replaced_count = 0
for (i, c) in enumerate(target):
if cand >> m - 1 - i & 1:
if replacedCount:
abbr += str(replacedCount)
abbr += c
replaced_count = 0
else:
replaced_count += 1
if replacedCount:
abbr += str(replacedCount)
return abbr
for cand in range(2 ** m):
if all((cand & mask for mask in masks)):
abbr = get_abbr(cand)
abbrs.append(abbr)
def get_abbr_len(abbr: str) -> int:
abbr_len = 0
i = 0
j = 0
while i < len(abbr):
if abbr[j].isalpha():
j += 1
else:
while j < len(abbr) and abbr[j].isdigit():
j += 1
abbr_len += 1
i = j
return abbrLen
return min(abbrs, key=lambda x: get_abbr_len(x)) |
#! python3
# __author__ = "YangJiaHao"
# date: 2018/2/8
class Solution:
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if len(digits) <= 0:
return []
keys = [[''], [''], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'],
['m', 'n', 'o'], ['p', 'q', 'r', 's'], ['t', 'u', 'v'], ['w', 'x', 'y', 'z']]
result = [""]
for i in digits:
temp = []
for one in result:
for w in keys[int(i)]:
temp.append(one + w)
result = temp
return result
class Solution2:
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
result = []
if len(digits) == 0:
return result
result = ['']
string = [[], [], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o'],
['p', 'q', 'r', 's'], ['t', 'u', 'v'], ['w', 'x', 'y', 'z']]
for c in digits:
tmp = []
for c1 in result:
for c2 in string[int(c)]:
tmp.append(c1 + c2)
result = tmp
return result
if __name__ == '__main__':
so = Solution2()
ret = so.letterCombinations("234")
print(ret)
| class Solution:
def letter_combinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
if len(digits) <= 0:
return []
keys = [[''], [''], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o'], ['p', 'q', 'r', 's'], ['t', 'u', 'v'], ['w', 'x', 'y', 'z']]
result = ['']
for i in digits:
temp = []
for one in result:
for w in keys[int(i)]:
temp.append(one + w)
result = temp
return result
class Solution2:
def letter_combinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
result = []
if len(digits) == 0:
return result
result = ['']
string = [[], [], ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o'], ['p', 'q', 'r', 's'], ['t', 'u', 'v'], ['w', 'x', 'y', 'z']]
for c in digits:
tmp = []
for c1 in result:
for c2 in string[int(c)]:
tmp.append(c1 + c2)
result = tmp
return result
if __name__ == '__main__':
so = solution2()
ret = so.letterCombinations('234')
print(ret) |
{
"targets": [
{
"target_name": "example",
"sources": [ "example.cxx", "example_wrap.cxx" ]
}
]
} | {'targets': [{'target_name': 'example', 'sources': ['example.cxx', 'example_wrap.cxx']}]} |
# Event: LCCS Python Fundamental Skills Workshop
# Date: Dec 2018
# Author: Joe English, PDST
# eMail: computerscience@pdst.ie
# Solution to programming exercises 6.1 Q2
# Purpose: A program to find the GCD of any two positive integers
# Determines if one number is a factor of the other
def isFactor(a1, a2):
if a2 % a1 == 0:
return True
else:
return False
# Returns a list containing all the factors of n
def getFactors(n):
factors = []
for i in range(1, n+1):
if isFactor(i, n):
factors.append(i)
return factors
# Returns the greatest common divisor
# This is the largest number that is common to both lists
def gcd(l1, l2):
# sets don't contain duplicates
set1 = set(l1)
set2 = set(l2)
common_factors = set1.intersection(set2) # set1 & set2
return(max(common_factors))
# Main program
n1 = int(input("Enter the first number: "))
n2 = int(input("Enter the second number: "))
list_of_factors1 = getFactors(n1)
list_of_factors2 = getFactors(n2)
ans = gcd(list_of_factors1, list_of_factors2)
print("The GCD of %d and %d is %d" %(n1, n2, ans))
'''
# Alternative solution
def gcd(a, b):
while b:
a, b = b, a % b
print(a)
gcd(27, 63)
'''
| def is_factor(a1, a2):
if a2 % a1 == 0:
return True
else:
return False
def get_factors(n):
factors = []
for i in range(1, n + 1):
if is_factor(i, n):
factors.append(i)
return factors
def gcd(l1, l2):
set1 = set(l1)
set2 = set(l2)
common_factors = set1.intersection(set2)
return max(common_factors)
n1 = int(input('Enter the first number: '))
n2 = int(input('Enter the second number: '))
list_of_factors1 = get_factors(n1)
list_of_factors2 = get_factors(n2)
ans = gcd(list_of_factors1, list_of_factors2)
print('The GCD of %d and %d is %d' % (n1, n2, ans))
'\n# Alternative solution\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n \n print(a)\n\ngcd(27, 63)\n' |
assert format(5, "b") == "101"
try:
format(2, 3)
except TypeError:
pass
else:
assert False, "TypeError not raised when format is called with a number"
| assert format(5, 'b') == '101'
try:
format(2, 3)
except TypeError:
pass
else:
assert False, 'TypeError not raised when format is called with a number' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.