content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
---|---|
"""
This module contains the general settings used across modules.
"""
FPS = 60
WINDOW_WIDTH = 1100
WINDOW_HEIGHT = 600
TIME_MULTIPLIER = 1.0
| """
This module contains the general settings used across modules.
"""
fps = 60
window_width = 1100
window_height = 600
time_multiplier = 1.0 |
class Solution:
def longestSubarray(self, nums: List[int]) -> int:
k = 1
max_len, i = 0, 0
for j in range(len(nums)):
if nums[j] == 0:
k -= 1
if k < 0:
if nums[i] == 0:
k += 1
i += 1
max_len = max(max_len, j - i)
return max_len
| class Solution:
def longest_subarray(self, nums: List[int]) -> int:
k = 1
(max_len, i) = (0, 0)
for j in range(len(nums)):
if nums[j] == 0:
k -= 1
if k < 0:
if nums[i] == 0:
k += 1
i += 1
max_len = max(max_len, j - i)
return max_len |
ROOT_WK_API_URL = "https://api.wanikani.com/v2/"
RESOURCES_WITHOUT_IDS = ["user", "collection", "report"]
SUBJECT_ENDPOINT = "subjects"
SINGLE_SUBJECT_ENPOINT = r"subjects/\d+"
ASSIGNMENT_ENDPOINT = "assignments"
REVIEW_STATS_ENDPOINT = "review_statistics"
STUDY_MATERIALS_ENDPOINT = "study_materials"
REVIEWS_ENDPOINT = "reviews"
LEVEL_PROGRESSIONS_ENDPOINT = "level_progressions"
RESETS_ENDPOINT = "resets"
SUMMARY_ENDPOINT = "summary"
USER_ENDPOINT = "user"
| root_wk_api_url = 'https://api.wanikani.com/v2/'
resources_without_ids = ['user', 'collection', 'report']
subject_endpoint = 'subjects'
single_subject_enpoint = 'subjects/\\d+'
assignment_endpoint = 'assignments'
review_stats_endpoint = 'review_statistics'
study_materials_endpoint = 'study_materials'
reviews_endpoint = 'reviews'
level_progressions_endpoint = 'level_progressions'
resets_endpoint = 'resets'
summary_endpoint = 'summary'
user_endpoint = 'user' |
"""
Script testing 14.4.2 control from OWASP ASVS 4.0:
'Verify that all API responses contain a Content-Disposition: attachment;
filename="api.json" header (or other appropriate filename for the content
type).'
The script will raise an alert if 'Content-Disposition' header is present but not follow the format - Content-Disposition: attachment; filename=
"""
def scan(ps, msg, src):
#find "Content-Disposition" header
header = str(msg.getResponseHeader().getHeader("Content-Disposition"))
#alert parameters
alertRisk= 1
alertConfidence = 2
alertTitle = "14.4.2 Verify that all API responses contain a Content-Disposition."
alertDescription = "Verify that all API responses contain a Content-Disposition: attachment; filename='api.json'header (or other appropriate filename for the content type)."
url = msg.getRequestHeader().getURI().toString()
alertParam = ""
alertAttack = ""
alertInfo = "https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload"
alertSolution = "Use the format 'Content-Disposition: attachment; filename=' for API responses"
alertEvidence = ""
cweID = 116
wascID = 0
# if "attachment; filename=" is not in "Content-Disposition" header, raise alert
if ("attachment; filename=" not in header.lower()):
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDescription,
url, alertParam, alertAttack, alertInfo, alertSolution, alertEvidence, cweID, wascID, msg);
| """
Script testing 14.4.2 control from OWASP ASVS 4.0:
'Verify that all API responses contain a Content-Disposition: attachment;
filename="api.json" header (or other appropriate filename for the content
type).'
The script will raise an alert if 'Content-Disposition' header is present but not follow the format - Content-Disposition: attachment; filename=
"""
def scan(ps, msg, src):
header = str(msg.getResponseHeader().getHeader('Content-Disposition'))
alert_risk = 1
alert_confidence = 2
alert_title = '14.4.2 Verify that all API responses contain a Content-Disposition.'
alert_description = "Verify that all API responses contain a Content-Disposition: attachment; filename='api.json'header (or other appropriate filename for the content type)."
url = msg.getRequestHeader().getURI().toString()
alert_param = ''
alert_attack = ''
alert_info = 'https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload'
alert_solution = "Use the format 'Content-Disposition: attachment; filename=' for API responses"
alert_evidence = ''
cwe_id = 116
wasc_id = 0
if 'attachment; filename=' not in header.lower():
ps.raiseAlert(alertRisk, alertConfidence, alertTitle, alertDescription, url, alertParam, alertAttack, alertInfo, alertSolution, alertEvidence, cweID, wascID, msg) |
MAX_N = 10000 + 1
isprime = [True] * (MAX_N)
isprime[0] = False
isprime[1] = False
for i in range(2, MAX_N):
if not isprime[i]:
continue
for j in range(i+i, MAX_N, i):
isprime[j] = False
T = int(input())
for _ in range(T):
n = int(input())
for i in range(n//2, 1, -1):
if isprime[i] and isprime[n-i]:
print('%d %d' % (i, n-i))
break
| max_n = 10000 + 1
isprime = [True] * MAX_N
isprime[0] = False
isprime[1] = False
for i in range(2, MAX_N):
if not isprime[i]:
continue
for j in range(i + i, MAX_N, i):
isprime[j] = False
t = int(input())
for _ in range(T):
n = int(input())
for i in range(n // 2, 1, -1):
if isprime[i] and isprime[n - i]:
print('%d %d' % (i, n - i))
break |
#
# PySNMP MIB module DOCS-LOADBALANCING-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DOCS-LOADBALANCING-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:53:17 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")
ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint")
clabProjDocsis, = mibBuilder.importSymbols("CLAB-DEF-MIB", "clabProjDocsis")
docsIfCmtsCmStatusIndex, docsIfCmtsCmStatusEntry = mibBuilder.importSymbols("DOCS-IF-MIB", "docsIfCmtsCmStatusIndex", "docsIfCmtsCmStatusEntry")
InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex")
ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance")
ModuleIdentity, Gauge32, Counter32, IpAddress, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, Bits, TimeTicks, Counter64, Unsigned32, zeroDotZero, Integer32, iso, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "Gauge32", "Counter32", "IpAddress", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "Bits", "TimeTicks", "Counter64", "Unsigned32", "zeroDotZero", "Integer32", "iso", "ObjectIdentity")
TimeStamp, TruthValue, TextualConvention, DisplayString, RowStatus, RowPointer, MacAddress = mibBuilder.importSymbols("SNMPv2-TC", "TimeStamp", "TruthValue", "TextualConvention", "DisplayString", "RowStatus", "RowPointer", "MacAddress")
docsLoadBalanceMib = ModuleIdentity((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2))
docsLoadBalanceMib.setRevisions(('2004-03-10 17:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: docsLoadBalanceMib.setRevisionsDescriptions(('Initial version of this mib module.',))
if mibBuilder.loadTexts: docsLoadBalanceMib.setLastUpdated('200403101700Z')
if mibBuilder.loadTexts: docsLoadBalanceMib.setOrganization('Cable Television Laboratories, Inc')
if mibBuilder.loadTexts: docsLoadBalanceMib.setContactInfo(' Postal: Cable Television Laboratories, Inc. 400 Centennial Parkway Louisville, Colorado 80027-1266 U.S.A. Phone: +1 303-661-9100 Fax: +1 303-661-9199 E-mail: mibs@cablelabs.com')
if mibBuilder.loadTexts: docsLoadBalanceMib.setDescription('This is the MIB Module for the load balancing. Load balancing is manageable on a per-CM basis. Each CM is assigned: a) to a set of channels (a Load Balancing Group) among which it can be moved by the CMTS b) a policy which governs if and when the CM can be moved c) a priority value which can be used by the CMTS in order to select CMs to move.')
class ChannelChgInitTechMap(TextualConvention, Bits):
description = "This textual convention enumerates the Initialization techniques for Dynamic Channel Change (DCC). The techniques are represented by the 5 most significant bits (MSB). Bits 0 through 4 map to initialization techniques 0 through 4. Each bit position represents the internal associated technique as described below: reinitializeMac(0) : Reinitialize the MAC broadcastInitRanging(1): Perform Broadcast initial ranging on new channel before normal operation unicastInitRanging(2) : Perform unicast ranging on new channel before normal operation initRanging(3) : Perform either broadcast or unicast ranging on new channel before normal operation direct(4) : Use the new channel(s) directly without re-initializing or ranging Multiple bits selection in 1's means the CMTS selects the best suitable technique among the selected in a proprietary manner. An empty value or a value with all bits in '0' means no channel changes allowed"
status = 'current'
namedValues = NamedValues(("reinitializeMac", 0), ("broadcastInitRanging", 1), ("unicastInitRanging", 2), ("initRanging", 3), ("direct", 4))
docsLoadBalNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 0))
docsLoadBalMibObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1))
docsLoadBalSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1))
docsLoadBalChgOverObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2))
docsLoadBalGrpObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3))
docsLoadBalPolicyObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4))
docsLoadBalChgOverGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1))
docsLoadBalEnable = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 1), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalEnable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalEnable.setDescription('Setting this object to true(1) enables internal autonomous load balancing operation on this CMTS. Setting it to false(2) disables the autonomous load balancing operations. However moving a cable modem via docsLoadBalChgOverTable is allowed even when this object is set to false(2).')
docsLoadBalChgOverMacAddress = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 1), MacAddress().clone(hexValue="000000000000")).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverMacAddress.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverMacAddress.setDescription('The mac address of the cable modem that the CMTS instructs to move to a new downstream frequency and/or upstream channel.')
docsLoadBalChgOverDownFrequency = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000000000))).setUnits('hertz').setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverDownFrequency.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverDownFrequency.setDescription('The new downstream frequency to which the cable modem is instructed to move. The value 0 indicates that the CMTS does not create a TLV for the downstream frequency in the DCC-REQ message. This object has no meaning when executing UCC operations.')
docsLoadBalChgOverUpChannelId = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 255)).clone(-1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverUpChannelId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverUpChannelId.setDescription('The new upstream channel ID to which the cable modem is instructed to move. The value -1 indicates that the CMTS does not create a TLV for the upstream channel ID in the channel change request.')
docsLoadBalChgOverInitTech = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 4), ChannelChgInitTechMap()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverInitTech.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverInitTech.setDescription("The initialization technique that the cable modem is instructed to use when performing change over operation. By default this object is initialized with all the defined bits having a value of '1'.")
docsLoadBalChgOverCmd = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("any", 1), ("dcc", 2), ("ucc", 3))).clone('any')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverCmd.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverCmd.setDescription('The change over command that the CMTS is instructed use when performing change over operation. The any(1) value indicates that the CMTS is to use its own algorithm to determine the appropriate command.')
docsLoadBalChgOverCommit = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 6), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalChgOverCommit.setReference('Data-Over-Cable Service Interface Specifications: Radio Frequency Interface Specification SP-RFIv2.0-I04-030730, Sections C.4.1, 11.4.5.1.')
if mibBuilder.loadTexts: docsLoadBalChgOverCommit.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverCommit.setDescription("The command to execute the DCC/UCC operation when set to true(1). The following are reasons for rejecting an SNMP SET to this object: - The MAC address in docsLoadBalChgOverMacAddr is not an existing MAC address in docsIfCmtsMacToCmEntry. - docsLoadBalChgOverCmd is ucc(3) and docsLoadBalChgOverUpChannelId is '-1', - docsLoadBalChgOverUpChannelId is '-1' and docsLoadBalChgOverDownFrequency is '0'. - DCC/UCC operation is currently being executed for the cable modem, on which the new command is committed, specifically if the value of docsLoadBalChgOverStatusValue is one of: messageSent(1), modemDeparting(4), waitToSendMessage(6). - An UCC operation is committed for a non-existing upstream channel ID or the corresponding ifOperStatus is down(2). - A DCC operation is committed for an invalid or non-existing downstream frequency, or the corresponding ifOperStatus is down(2). In those cases, the SET is rejected with an error code 'commitFailed'. After processing the SNMP SET the information in docsLoadBalChgOverGroup is updated in a corresponding entry in docsLoadBalChgOverStatusEntry. Reading this object always returns false(2).")
docsLoadBalChgOverLastCommit = MibScalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 7), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverLastCommit.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverLastCommit.setDescription('The value of sysUpTime when docsLoadBalChgOverCommit was last set to true. Zero if never set.')
docsLoadBalChgOverStatusTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2), )
if mibBuilder.loadTexts: docsLoadBalChgOverStatusTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusTable.setDescription('A table of CMTS operation entries to reports the status of cable modems instructed to move to a new downstream and/or upstream channel. Using the docsLoadBalChgOverGroup objects. An entry in this table is created or updated for the entry with docsIfCmtsCmStatusIndex that correspond to the cable modem MAC address of the Load Balancing operation. docsLoadBalChgOverCommit to true(1).')
docsLoadBalChgOverStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1), ).setIndexNames((0, "DOCS-IF-MIB", "docsIfCmtsCmStatusIndex"))
if mibBuilder.loadTexts: docsLoadBalChgOverStatusEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusEntry.setDescription('A CMTS operation entry to instruct a cable modem to move to a new downstream frequency and/or upstream channel. An operator can use this to initiate an operation in CMTS to instruct the selected cable modem to move to a new downstream frequency and/or upstream channel.')
docsLoadBalChgOverStatusMacAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 1), MacAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusMacAddr.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusMacAddr.setDescription('The mac address set in docsLoadBalChgOverMacAddress.')
docsLoadBalChgOverStatusDownFreq = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000000000))).setUnits('hertz').setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusDownFreq.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusDownFreq.setDescription('The Downstream frequency set in docsLoadBalChgOverDownFrequency.')
docsLoadBalChgOverStatusUpChnId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 255)).clone(-1)).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusUpChnId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusUpChnId.setDescription('The upstream channel ID set in docsLoadBalChgOverUpChannelId.')
docsLoadBalChgOverStatusInitTech = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 4), ChannelChgInitTechMap()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusInitTech.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusInitTech.setDescription('The initialization technique set in docsLoadBalChgOverInitTech.')
docsLoadBalChgOverStatusCmd = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("any", 1), ("dcc", 2), ("ucc", 3))).clone('any')).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusCmd.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusCmd.setDescription('The load balancing command set in docsLoadBalChgOverCmd.')
docsLoadBalChgOverStatusValue = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("messageSent", 1), ("noOpNeeded", 2), ("modemDeparting", 3), ("waitToSendMessage", 4), ("cmOperationRejected", 5), ("cmtsOperationRejected", 6), ("timeOutT13", 7), ("timeOutT15", 8), ("rejectinit", 9), ("success", 10))).clone('waitToSendMessage')).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusValue.setReference('Data-Over-Cable Service Interface Specifications: Radio Frequency Interface Specification SP-RFIv2.0-I04-030730, Sections C.4.1, 11.4.5.1.')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusValue.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusValue.setDescription("The status of the specified DCC/UCC operation. The enumerations are: messageSent(1): The CMTS has sent change over request message to the cable modem. noOpNeed(2): A operation was requested in which neither the DS Frequency nor the Upstream Channel ID was changed. An active value in this entry's row status indicates that no CMTS operation is required. modemDeparting(3): The cable modem has responded with a change over response of either a DCC-RSP with a confirmation code of depart(180) or a UCC-RSP. waitToSendMessage(4): The specified operation is active and CMTS is waiting to send the channel change message with channel info to the cable modem. cmOperationRejected(5): Channel Change (such as DCC or UCC) operation was rejected by the cable modem. cmtsOperationRejected(6) Channel Change (such as DCC or UCC) operation was rejected by the Cable modem Termination System. timeOutT13(7): Failure due to no DCC-RSP with confirmation code depart(180) received prior to expiration of the T13 timer. timeOutT15(8): T15 timer timed out prior to the arrival of a bandwidth request, RNG-REQ message, or DCC-RSP message with confirmation code of arrive(181) from the cable modem. rejectInit(9): DCC operation rejected due to unsupported initialization tech requested. success(10): CMTS received an indication that the CM successfully completed the change over operation. e.g., If an initialization technique of re-initialize the MAC is used, success in indicated by the receipt of a DCC-RSP message with a confirmation code of depart(180). In all other cases, success is indicated by: (1) the CMTS received a DCC-RSP message with confirmation code of arrive(181) or (2) the CMTS internally confirms the presence of the CM on the new channel.")
docsLoadBalChgOverStatusUpdate = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 7), TimeStamp()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChgOverStatusUpdate.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChgOverStatusUpdate.setDescription('The value of sysUpTime when docsLoadBalChgOverStatusValue was last updated.')
docsLoadBalGrpTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1), )
if mibBuilder.loadTexts: docsLoadBalGrpTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpTable.setDescription('This table contains the attributes of the load balancing groups present in this CMTS.')
docsLoadBalGrpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalGrpId"))
if mibBuilder.loadTexts: docsLoadBalGrpEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpEntry.setDescription('A set of attributes of load balancing group in the CMTS. It is index by a docsLoadBalGrpId which is unique within a CMTS. Entries in this table persist after CMTS initialization.')
docsLoadBalGrpId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: docsLoadBalGrpId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpId.setDescription('A unique index assigned to the load balancing group by the CMTS.')
docsLoadBalGrpIsRestricted = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 2), TruthValue().clone('false')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalGrpIsRestricted.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpIsRestricted.setDescription('A value true(1)Indicates type of load balancing group. A Restricted Load Balancing Group is associated to a specific provisioned set of cable modems. Restricted Load Balancing Group is used to accommodate a topology specific or provisioning specific restriction. Example such as a group that are reserved for business customers). Setting this object to true(1) means it is a Restricted Load Balancing type and setting it to false(2) means it is a General Load Balancing group type. This object should not be changed while its group ID is referenced by an active entry in docsLoadBalRestrictCmEntry.')
docsLoadBalGrpInitTech = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 3), ChannelChgInitTechMap()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalGrpInitTech.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpInitTech.setDescription("The initialization techniques that the CMTS can use when load balancing cable modems in the load balancing group. By default this object is initialized with all the defined bits having a value of '1'.")
docsLoadBalGrpDefaultPolicy = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalGrpDefaultPolicy.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpDefaultPolicy.setDescription('Each Load Balancing Group has a default Load Balancing Policy. A policy is described by a set of conditions (rules) that govern the load balancing process for a cable modem. The CMTS assigns this Policy ID value to a cable modem associated with the group ID when the cable modem does not signal a Policy ID during registration. The Policy ID value is intended to be a numeric reference to a row entry in docsLoadBalPolicyEntry. However, It is not required to have an existing or active entry in docsLoadBalPolicyEntry when setting the value of docsLoadBalGrpDefaultPolicy, in which case it indicates no policy is associated with the load Balancing Group. The Policy ID of value 0 is reserved to indicate no policy is associated with the load balancing group.')
docsLoadBalGrpEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 5), TruthValue().clone('true')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalGrpEnable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpEnable.setDescription('Setting this object to true(1) enables internal autonomous load balancing on this group. Setting it to false(2) disables the load balancing operation on this group.')
docsLoadBalGrpChgOverSuccess = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalGrpChgOverSuccess.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpChgOverSuccess.setDescription('The number of successful load balancing change over operations initiated within this load balancing group.')
docsLoadBalGrpChgOverFails = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalGrpChgOverFails.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpChgOverFails.setDescription('The number of failed load balancing change over operations initiated within this load balancing group.')
docsLoadBalGrpStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 8), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalGrpStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalGrpStatus.setDescription("Indicates the status of the row in this table. Setting this object to 'destroy' or 'notInService' for a group ID entry already referenced by docsLoadBalChannelEntry, docsLoadBalChnPairsEntry or docsLoadBalRestrictCmEntry returns an error code inconsistentValue.")
docsLoadBalChannelTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2), )
if mibBuilder.loadTexts: docsLoadBalChannelTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChannelTable.setDescription('Lists all upstream and downstream channels associated with load balancing groups.')
docsLoadBalChannelEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalGrpId"), (0, "DOCS-LOADBALANCING-MIB", "docsLoadBalChannelIfIndex"))
if mibBuilder.loadTexts: docsLoadBalChannelEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChannelEntry.setDescription('Lists a specific upstream or downstream, within a load Balancing group. An entry in this table exists for each ifEntry with an ifType of docsCableDownstream(128) and docsCableUpstream(129) associated with the Load Balancing Group. Entries in this table persist after CMTS initialization.')
docsLoadBalChannelIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: docsLoadBalChannelIfIndex.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChannelIfIndex.setDescription('The ifIndex of either the downstream or upstream.')
docsLoadBalChannelStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalChannelStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChannelStatus.setDescription("Indicates the status of the rows in this table. Creating entries in this table requires an existing value for docsLoadBalGrpId in docsLoadBalGrpEntry and an existing value of docsLoadBalChannelIfIndex in ifEntry, otherwise is rejected with error 'noCreation'. Setting this object to 'destroy' or 'notInService for a a row entry that is being referenced by docsLoadBalChnPairsEntry is rejected with error code inconsistentValue.")
docsLoadBalChnPairsTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3), )
if mibBuilder.loadTexts: docsLoadBalChnPairsTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsTable.setDescription('This table contains pairs of upstream channels within a Load Balancing Group. Entries in this table are used to override the initialization techniques defined for the associated Load Balancing Group.')
docsLoadBalChnPairsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalGrpId"), (0, "DOCS-LOADBALANCING-MIB", "docsLoadBalChnPairsIfIndexDepart"), (0, "DOCS-LOADBALANCING-MIB", "docsLoadBalChnPairsIfIndexArrive"))
if mibBuilder.loadTexts: docsLoadBalChnPairsEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsEntry.setDescription('An entry in this table describes a channel pair for which an initialization technique override is needed. On a CMTS which supports logical upstream channels (ifType is equal to docsCableUpstreamChannel(205)), the entries in this table correspond to pairs of ifType 205. On a CMTS which only supports physical upstream channels (ifType is equal to docsCableUpstream(129)), the entries in this table correspond to pairs of ifType 129. Entries in this table persist after CMTS initialization.')
docsLoadBalChnPairsIfIndexDepart = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: docsLoadBalChnPairsIfIndexDepart.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsIfIndexDepart.setDescription('This index indicates the ifIndex of the upstream channel from which a cable modem would depart in a load balancing channel change operation.')
docsLoadBalChnPairsIfIndexArrive = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 2), InterfaceIndex())
if mibBuilder.loadTexts: docsLoadBalChnPairsIfIndexArrive.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsIfIndexArrive.setDescription('This index indicates the ifIndex of the upstream channel on which a cable modem would arrive in a load balancing channel change operation.')
docsLoadBalChnPairsOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("operational", 1), ("notOperational", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: docsLoadBalChnPairsOperStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsOperStatus.setDescription('Operational status of the channel pair. The value operational(1) indicates that ifOperStatus of both channels is up(1). The value notOperational(2) means that ifOperStatus of one or both is not up(1).')
docsLoadBalChnPairsInitTech = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 4), ChannelChgInitTechMap()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalChnPairsInitTech.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsInitTech.setDescription("Specifies initialization technique for load balancing for the Depart/Arrive pair. By default this object's value is the initialization technique configured for the Load Balancing Group indicated by docsLoadBalGrpId.")
docsLoadBalChnPairsRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 5), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalChnPairsRowStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalChnPairsRowStatus.setDescription("The object for conceptual rows creation. An attempt to create a row with values for docsLoadBalChnPairsIfIndexDepart or docsLoadBalChnPairsIfIndexArrive which are not a part of the Load Balancing Group (or for a 2.0 CMTS are not logical channels (ifType 205)) are rejected with a 'noCreation' error status reported. There is no restriction on settings columns in this table when the value of docsLoadBalChnPairsRowStatus is active(1).")
docsLoadBalRestrictCmTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4), )
if mibBuilder.loadTexts: docsLoadBalRestrictCmTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmTable.setDescription('Lists all cable modems in each Restricted Load Balancing Groups.')
docsLoadBalRestrictCmEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalGrpId"), (0, "DOCS-LOADBALANCING-MIB", "docsLoadBalRestrictCmIndex"))
if mibBuilder.loadTexts: docsLoadBalRestrictCmEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmEntry.setDescription('An entry of modem within a restricted load balancing group type. An entry represents a cable modem that is associated with the Restricted Load Balancing Group ID of a Restricted Load Balancing Group. Entries in this table persist after CMTS initialization.')
docsLoadBalRestrictCmIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: docsLoadBalRestrictCmIndex.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmIndex.setDescription('The index that uniquely identifies an entry which represents restricted cable modem(s) within each Restricted Load Balancing Group.')
docsLoadBalRestrictCmMACAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 2), MacAddress()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalRestrictCmMACAddr.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmMACAddr.setDescription('Mac Address of the cable modem within the restricted load balancing group.')
docsLoadBalRestrictCmMacAddrMask = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 3), OctetString().subtype(subtypeSpec=ConstraintsUnion(ValueSizeConstraint(0, 0), ValueSizeConstraint(6, 6), )).clone(hexValue="")).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalRestrictCmMacAddrMask.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmMacAddrMask.setDescription('A bit mask acting as a wild card to associate a set of modem MAC addresses to the same Group ID. Cable modem look up is performed first with entries containing this value not null, if several entries match, the largest consecutive bit match from MSB to LSB is used. Empty value is equivalent to the bit mask all in ones.')
docsLoadBalRestrictCmStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 4), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalRestrictCmStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalRestrictCmStatus.setDescription("Indicates the status of the rows in this table. The attempt to create an entry associated to a group ID with docsLoadBalGrpIsRestricted equal to false(2) returns an error 'noCreation'. There is no restriction on settings columns in this table any time.")
docsLoadBalPolicyTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1), )
if mibBuilder.loadTexts: docsLoadBalPolicyTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyTable.setDescription('This table describes the set of Load Balancing policies. Rows in this table might be referenced by rows in docsLoadBalGrpEntry.')
docsLoadBalPolicyEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalPolicyId"), (0, "DOCS-LOADBALANCING-MIB", "docsLoadBalPolicyRuleId"))
if mibBuilder.loadTexts: docsLoadBalPolicyEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyEntry.setDescription('Entries containing rules for policies. When a load balancing policy is defined by multiple rules, all the rules apply. Load balancing rules can be created to allow for specific vendor-defined load balancing actions. However there is a basic rule that the CMTS is required to support by configuring a pointer in docsLoadBalPolicyRulePtr to the table docsLoadBalBasicRuleTable. Vendor specific rules may be added by pointing the object docsLoadBalPolicyRulePtr to proprietary mib structures. Entries in this table persist after CMTS initialization.')
docsLoadBalPolicyId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: docsLoadBalPolicyId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyId.setDescription('An index identifying the Load Balancing Policy.')
docsLoadBalPolicyRuleId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: docsLoadBalPolicyRuleId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyRuleId.setDescription('An index for the rules entries associated within a policy.')
docsLoadBalPolicyRulePtr = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 3), RowPointer().clone((0, 0))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalPolicyRulePtr.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyRulePtr.setDescription('A pointer to an entry in a rule table. E.g., docsLoadBalBasicRuleEnable in docsLoadBalBasicRuleEntry. A value pointing to zeroDotZero, an inactive Row or a non-existing entry is treated as no rule defined for this policy entry.')
docsLoadBalPolicyRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 5), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalPolicyRowStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPolicyRowStatus.setDescription("The status of this conceptual row. There is no restriction on settings columns in this table when the value of docsLoadBalPolicyRowStatus is active(1). Setting this object to 'destroy' or 'notInService' for a row entry that is being referenced by docsLoadBalGrpDefaultPolicy in docsLoadBalGrpEntry returns an error code inconsistentValue.")
docsLoadBalBasicRuleTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2), )
if mibBuilder.loadTexts: docsLoadBalBasicRuleTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleTable.setDescription('DOCSIS defined basic ruleset for load Balancing Policy. This table enables of disable load balancing for the groups pointing to this ruleset in the policy group.')
docsLoadBalBasicRuleEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1), ).setIndexNames((0, "DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleId"))
if mibBuilder.loadTexts: docsLoadBalBasicRuleEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleEntry.setDescription('An entry of DOCSIS defined basic ruleset. The object docsLoadBalBasicRuleEnable is used for instantiating an entry in this table via a RowPointer. Entries in this table persist after CMTS initialization.')
docsLoadBalBasicRuleId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 4294967295)))
if mibBuilder.loadTexts: docsLoadBalBasicRuleId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleId.setDescription('The unique index for this row.')
docsLoadBalBasicRuleEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2), ("disabledPeriod", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalBasicRuleEnable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleEnable.setDescription('When using this ruleset, load balancing is enabled or disabled by the values enabled(1) and disabled(2) respectively. Additionally, a Load Balancing disabling period is defined in docsLoadBalBasicRuleDisStart and docsLoadBalBasicRuleDisPeriod if this object value is set to disabledPeriod(3).')
docsLoadBalBasicRuleDisStart = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 86400))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalBasicRuleDisStart.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleDisStart.setDescription('if object docsLoadBalBasicRuleEnable is disablePeriod(3) Load Balancing is disabled starting at this object value time (seconds from 12 AM). Otherwise, this object has no meaning.')
docsLoadBalBasicRuleDisPeriod = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 4), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 86400))).setUnits('seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalBasicRuleDisPeriod.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleDisPeriod.setDescription('If object docsLoadBalBasicRuleEnable is disablePeriod(3) Load Balancing is disabled for the period of time defined between docsLoadBalBasicRuleDisStart and docsLoadBalBasicRuleDisStart plus the period of time of docsLoadBalBasicRuleDisPeriod. Otherwise, this object value has no meaning.')
docsLoadBalBasicRuleRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 5), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: docsLoadBalBasicRuleRowStatus.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleRowStatus.setDescription("This object is to create or delete rows in this table. There is no restriction for changing this row status or object's values in this table at any time.")
docsLoadBalCmtsCmStatusTable = MibTable((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4), )
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusTable.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusTable.setDescription('The list contains the load balancing attributes associated with the cable modem. ')
docsLoadBalCmtsCmStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1), )
docsIfCmtsCmStatusEntry.registerAugmentions(("DOCS-LOADBALANCING-MIB", "docsLoadBalCmtsCmStatusEntry"))
docsLoadBalCmtsCmStatusEntry.setIndexNames(*docsIfCmtsCmStatusEntry.getIndexNames())
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusEntry.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusEntry.setDescription('Additional objects for docsIfCmtsCmStatusTable entry that relate to load balancing ')
docsLoadBalCmtsCmStatusGroupId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 1), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusGroupId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusGroupId.setDescription('The Group ID associated with this cable modem.')
docsLoadBalCmtsCmStatusPolicyId = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 2), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusPolicyId.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusPolicyId.setDescription('The Policy ID associated with this cable modem.')
docsLoadBalCmtsCmStatusPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 3), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusPriority.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusPriority.setDescription('The Priority associated with this cable modem.')
docsLoadBalConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2))
docsLoadBalCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 1))
docsLoadBalGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2))
docsLoadBalBasicCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 1, 1)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalSystemGroup"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalParametersGroup"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalPoliciesGroup"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleGroup"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalCmtsCmStatusGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalBasicCompliance = docsLoadBalBasicCompliance.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicCompliance.setDescription('The compliance statement for DOCSIS load balancing systems.')
docsLoadBalSystemGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 1)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalEnable"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverMacAddress"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverDownFrequency"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverUpChannelId"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverInitTech"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverCmd"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverCommit"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverLastCommit"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusMacAddr"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusDownFreq"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusUpChnId"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusInitTech"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusCmd"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusValue"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChgOverStatusUpdate"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalSystemGroup = docsLoadBalSystemGroup.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalSystemGroup.setDescription('A collection of objects providing system-wide parameters for load balancing.')
docsLoadBalParametersGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 2)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpIsRestricted"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpInitTech"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpDefaultPolicy"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpEnable"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpChgOverSuccess"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpChgOverFails"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalGrpStatus"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChannelStatus"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChnPairsOperStatus"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChnPairsInitTech"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalChnPairsRowStatus"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalRestrictCmMACAddr"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalRestrictCmMacAddrMask"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalRestrictCmStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalParametersGroup = docsLoadBalParametersGroup.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalParametersGroup.setDescription('A collection of objects containing the load balancing parameters.')
docsLoadBalPoliciesGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 3)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalPolicyRulePtr"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalPolicyRowStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalPoliciesGroup = docsLoadBalPoliciesGroup.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalPoliciesGroup.setDescription('A collection of objects providing policies.')
docsLoadBalBasicRuleGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 4)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleEnable"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleDisStart"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleDisPeriod"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalBasicRuleRowStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalBasicRuleGroup = docsLoadBalBasicRuleGroup.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalBasicRuleGroup.setDescription('DOCSIS defined basic Ruleset for load balancing policies.')
docsLoadBalCmtsCmStatusGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 5)).setObjects(("DOCS-LOADBALANCING-MIB", "docsLoadBalCmtsCmStatusGroupId"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalCmtsCmStatusPolicyId"), ("DOCS-LOADBALANCING-MIB", "docsLoadBalCmtsCmStatusPriority"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docsLoadBalCmtsCmStatusGroup = docsLoadBalCmtsCmStatusGroup.setStatus('current')
if mibBuilder.loadTexts: docsLoadBalCmtsCmStatusGroup.setDescription('Cable mode status extension objects.')
mibBuilder.exportSymbols("DOCS-LOADBALANCING-MIB", docsLoadBalChgOverStatusEntry=docsLoadBalChgOverStatusEntry, docsLoadBalCmtsCmStatusTable=docsLoadBalCmtsCmStatusTable, docsLoadBalCmtsCmStatusEntry=docsLoadBalCmtsCmStatusEntry, docsLoadBalBasicRuleDisStart=docsLoadBalBasicRuleDisStart, docsLoadBalBasicCompliance=docsLoadBalBasicCompliance, docsLoadBalChnPairsIfIndexDepart=docsLoadBalChnPairsIfIndexDepart, docsLoadBalChgOverStatusValue=docsLoadBalChgOverStatusValue, docsLoadBalMibObjects=docsLoadBalMibObjects, docsLoadBalEnable=docsLoadBalEnable, docsLoadBalGrpChgOverFails=docsLoadBalGrpChgOverFails, docsLoadBalCmtsCmStatusPriority=docsLoadBalCmtsCmStatusPriority, docsLoadBalBasicRuleDisPeriod=docsLoadBalBasicRuleDisPeriod, docsLoadBalChgOverStatusMacAddr=docsLoadBalChgOverStatusMacAddr, docsLoadBalGrpDefaultPolicy=docsLoadBalGrpDefaultPolicy, docsLoadBalGrpInitTech=docsLoadBalGrpInitTech, docsLoadBalRestrictCmStatus=docsLoadBalRestrictCmStatus, docsLoadBalChgOverGroup=docsLoadBalChgOverGroup, docsLoadBalChnPairsIfIndexArrive=docsLoadBalChnPairsIfIndexArrive, docsLoadBalChgOverLastCommit=docsLoadBalChgOverLastCommit, docsLoadBalPolicyEntry=docsLoadBalPolicyEntry, docsLoadBalChgOverStatusUpdate=docsLoadBalChgOverStatusUpdate, docsLoadBalChannelEntry=docsLoadBalChannelEntry, docsLoadBalChnPairsEntry=docsLoadBalChnPairsEntry, docsLoadBalGrpIsRestricted=docsLoadBalGrpIsRestricted, docsLoadBalSystem=docsLoadBalSystem, docsLoadBalChnPairsInitTech=docsLoadBalChnPairsInitTech, docsLoadBalBasicRuleGroup=docsLoadBalBasicRuleGroup, docsLoadBalChgOverStatusUpChnId=docsLoadBalChgOverStatusUpChnId, docsLoadBalParametersGroup=docsLoadBalParametersGroup, docsLoadBalBasicRuleEntry=docsLoadBalBasicRuleEntry, docsLoadBalRestrictCmMacAddrMask=docsLoadBalRestrictCmMacAddrMask, docsLoadBalPolicyRulePtr=docsLoadBalPolicyRulePtr, docsLoadBalGrpStatus=docsLoadBalGrpStatus, docsLoadBalSystemGroup=docsLoadBalSystemGroup, docsLoadBalGrpChgOverSuccess=docsLoadBalGrpChgOverSuccess, docsLoadBalPolicyObjects=docsLoadBalPolicyObjects, docsLoadBalGroups=docsLoadBalGroups, docsLoadBalanceMib=docsLoadBalanceMib, docsLoadBalChgOverInitTech=docsLoadBalChgOverInitTech, docsLoadBalChgOverStatusDownFreq=docsLoadBalChgOverStatusDownFreq, docsLoadBalGrpObjects=docsLoadBalGrpObjects, docsLoadBalChnPairsTable=docsLoadBalChnPairsTable, docsLoadBalCompliances=docsLoadBalCompliances, docsLoadBalCmtsCmStatusPolicyId=docsLoadBalCmtsCmStatusPolicyId, docsLoadBalGrpEnable=docsLoadBalGrpEnable, docsLoadBalBasicRuleRowStatus=docsLoadBalBasicRuleRowStatus, docsLoadBalChgOverStatusInitTech=docsLoadBalChgOverStatusInitTech, docsLoadBalGrpTable=docsLoadBalGrpTable, docsLoadBalChgOverCmd=docsLoadBalChgOverCmd, docsLoadBalGrpEntry=docsLoadBalGrpEntry, docsLoadBalRestrictCmIndex=docsLoadBalRestrictCmIndex, docsLoadBalChannelTable=docsLoadBalChannelTable, docsLoadBalChgOverObjects=docsLoadBalChgOverObjects, docsLoadBalPolicyTable=docsLoadBalPolicyTable, docsLoadBalBasicRuleTable=docsLoadBalBasicRuleTable, docsLoadBalGrpId=docsLoadBalGrpId, docsLoadBalChgOverDownFrequency=docsLoadBalChgOverDownFrequency, docsLoadBalChgOverUpChannelId=docsLoadBalChgOverUpChannelId, docsLoadBalChgOverCommit=docsLoadBalChgOverCommit, docsLoadBalPolicyRowStatus=docsLoadBalPolicyRowStatus, docsLoadBalRestrictCmMACAddr=docsLoadBalRestrictCmMACAddr, docsLoadBalPolicyId=docsLoadBalPolicyId, docsLoadBalRestrictCmTable=docsLoadBalRestrictCmTable, PYSNMP_MODULE_ID=docsLoadBalanceMib, docsLoadBalNotifications=docsLoadBalNotifications, docsLoadBalBasicRuleEnable=docsLoadBalBasicRuleEnable, docsLoadBalPolicyRuleId=docsLoadBalPolicyRuleId, docsLoadBalChnPairsOperStatus=docsLoadBalChnPairsOperStatus, docsLoadBalChgOverMacAddress=docsLoadBalChgOverMacAddress, docsLoadBalRestrictCmEntry=docsLoadBalRestrictCmEntry, docsLoadBalBasicRuleId=docsLoadBalBasicRuleId, docsLoadBalChannelIfIndex=docsLoadBalChannelIfIndex, docsLoadBalCmtsCmStatusGroup=docsLoadBalCmtsCmStatusGroup, docsLoadBalConformance=docsLoadBalConformance, docsLoadBalCmtsCmStatusGroupId=docsLoadBalCmtsCmStatusGroupId, docsLoadBalChannelStatus=docsLoadBalChannelStatus, docsLoadBalChnPairsRowStatus=docsLoadBalChnPairsRowStatus, docsLoadBalChgOverStatusTable=docsLoadBalChgOverStatusTable, ChannelChgInitTechMap=ChannelChgInitTechMap, docsLoadBalChgOverStatusCmd=docsLoadBalChgOverStatusCmd, docsLoadBalPoliciesGroup=docsLoadBalPoliciesGroup)
| (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, constraints_union, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint')
(clab_proj_docsis,) = mibBuilder.importSymbols('CLAB-DEF-MIB', 'clabProjDocsis')
(docs_if_cmts_cm_status_index, docs_if_cmts_cm_status_entry) = mibBuilder.importSymbols('DOCS-IF-MIB', 'docsIfCmtsCmStatusIndex', 'docsIfCmtsCmStatusEntry')
(interface_index,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndex')
(object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance')
(module_identity, gauge32, counter32, ip_address, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, notification_type, bits, time_ticks, counter64, unsigned32, zero_dot_zero, integer32, iso, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'ModuleIdentity', 'Gauge32', 'Counter32', 'IpAddress', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'NotificationType', 'Bits', 'TimeTicks', 'Counter64', 'Unsigned32', 'zeroDotZero', 'Integer32', 'iso', 'ObjectIdentity')
(time_stamp, truth_value, textual_convention, display_string, row_status, row_pointer, mac_address) = mibBuilder.importSymbols('SNMPv2-TC', 'TimeStamp', 'TruthValue', 'TextualConvention', 'DisplayString', 'RowStatus', 'RowPointer', 'MacAddress')
docs_load_balance_mib = module_identity((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2))
docsLoadBalanceMib.setRevisions(('2004-03-10 17:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
docsLoadBalanceMib.setRevisionsDescriptions(('Initial version of this mib module.',))
if mibBuilder.loadTexts:
docsLoadBalanceMib.setLastUpdated('200403101700Z')
if mibBuilder.loadTexts:
docsLoadBalanceMib.setOrganization('Cable Television Laboratories, Inc')
if mibBuilder.loadTexts:
docsLoadBalanceMib.setContactInfo(' Postal: Cable Television Laboratories, Inc. 400 Centennial Parkway Louisville, Colorado 80027-1266 U.S.A. Phone: +1 303-661-9100 Fax: +1 303-661-9199 E-mail: mibs@cablelabs.com')
if mibBuilder.loadTexts:
docsLoadBalanceMib.setDescription('This is the MIB Module for the load balancing. Load balancing is manageable on a per-CM basis. Each CM is assigned: a) to a set of channels (a Load Balancing Group) among which it can be moved by the CMTS b) a policy which governs if and when the CM can be moved c) a priority value which can be used by the CMTS in order to select CMs to move.')
class Channelchginittechmap(TextualConvention, Bits):
description = "This textual convention enumerates the Initialization techniques for Dynamic Channel Change (DCC). The techniques are represented by the 5 most significant bits (MSB). Bits 0 through 4 map to initialization techniques 0 through 4. Each bit position represents the internal associated technique as described below: reinitializeMac(0) : Reinitialize the MAC broadcastInitRanging(1): Perform Broadcast initial ranging on new channel before normal operation unicastInitRanging(2) : Perform unicast ranging on new channel before normal operation initRanging(3) : Perform either broadcast or unicast ranging on new channel before normal operation direct(4) : Use the new channel(s) directly without re-initializing or ranging Multiple bits selection in 1's means the CMTS selects the best suitable technique among the selected in a proprietary manner. An empty value or a value with all bits in '0' means no channel changes allowed"
status = 'current'
named_values = named_values(('reinitializeMac', 0), ('broadcastInitRanging', 1), ('unicastInitRanging', 2), ('initRanging', 3), ('direct', 4))
docs_load_bal_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 0))
docs_load_bal_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1))
docs_load_bal_system = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1))
docs_load_bal_chg_over_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2))
docs_load_bal_grp_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3))
docs_load_bal_policy_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4))
docs_load_bal_chg_over_group = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1))
docs_load_bal_enable = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 1), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalEnable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalEnable.setDescription('Setting this object to true(1) enables internal autonomous load balancing operation on this CMTS. Setting it to false(2) disables the autonomous load balancing operations. However moving a cable modem via docsLoadBalChgOverTable is allowed even when this object is set to false(2).')
docs_load_bal_chg_over_mac_address = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 1), mac_address().clone(hexValue='000000000000')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverMacAddress.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverMacAddress.setDescription('The mac address of the cable modem that the CMTS instructs to move to a new downstream frequency and/or upstream channel.')
docs_load_bal_chg_over_down_frequency = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 1000000000))).setUnits('hertz').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverDownFrequency.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverDownFrequency.setDescription('The new downstream frequency to which the cable modem is instructed to move. The value 0 indicates that the CMTS does not create a TLV for the downstream frequency in the DCC-REQ message. This object has no meaning when executing UCC operations.')
docs_load_bal_chg_over_up_channel_id = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(-1, 255)).clone(-1)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverUpChannelId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverUpChannelId.setDescription('The new upstream channel ID to which the cable modem is instructed to move. The value -1 indicates that the CMTS does not create a TLV for the upstream channel ID in the channel change request.')
docs_load_bal_chg_over_init_tech = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 4), channel_chg_init_tech_map()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverInitTech.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverInitTech.setDescription("The initialization technique that the cable modem is instructed to use when performing change over operation. By default this object is initialized with all the defined bits having a value of '1'.")
docs_load_bal_chg_over_cmd = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('any', 1), ('dcc', 2), ('ucc', 3))).clone('any')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverCmd.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverCmd.setDescription('The change over command that the CMTS is instructed use when performing change over operation. The any(1) value indicates that the CMTS is to use its own algorithm to determine the appropriate command.')
docs_load_bal_chg_over_commit = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 6), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalChgOverCommit.setReference('Data-Over-Cable Service Interface Specifications: Radio Frequency Interface Specification SP-RFIv2.0-I04-030730, Sections C.4.1, 11.4.5.1.')
if mibBuilder.loadTexts:
docsLoadBalChgOverCommit.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverCommit.setDescription("The command to execute the DCC/UCC operation when set to true(1). The following are reasons for rejecting an SNMP SET to this object: - The MAC address in docsLoadBalChgOverMacAddr is not an existing MAC address in docsIfCmtsMacToCmEntry. - docsLoadBalChgOverCmd is ucc(3) and docsLoadBalChgOverUpChannelId is '-1', - docsLoadBalChgOverUpChannelId is '-1' and docsLoadBalChgOverDownFrequency is '0'. - DCC/UCC operation is currently being executed for the cable modem, on which the new command is committed, specifically if the value of docsLoadBalChgOverStatusValue is one of: messageSent(1), modemDeparting(4), waitToSendMessage(6). - An UCC operation is committed for a non-existing upstream channel ID or the corresponding ifOperStatus is down(2). - A DCC operation is committed for an invalid or non-existing downstream frequency, or the corresponding ifOperStatus is down(2). In those cases, the SET is rejected with an error code 'commitFailed'. After processing the SNMP SET the information in docsLoadBalChgOverGroup is updated in a corresponding entry in docsLoadBalChgOverStatusEntry. Reading this object always returns false(2).")
docs_load_bal_chg_over_last_commit = mib_scalar((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 1, 7), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverLastCommit.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverLastCommit.setDescription('The value of sysUpTime when docsLoadBalChgOverCommit was last set to true. Zero if never set.')
docs_load_bal_chg_over_status_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2))
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusTable.setDescription('A table of CMTS operation entries to reports the status of cable modems instructed to move to a new downstream and/or upstream channel. Using the docsLoadBalChgOverGroup objects. An entry in this table is created or updated for the entry with docsIfCmtsCmStatusIndex that correspond to the cable modem MAC address of the Load Balancing operation. docsLoadBalChgOverCommit to true(1).')
docs_load_bal_chg_over_status_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1)).setIndexNames((0, 'DOCS-IF-MIB', 'docsIfCmtsCmStatusIndex'))
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusEntry.setDescription('A CMTS operation entry to instruct a cable modem to move to a new downstream frequency and/or upstream channel. An operator can use this to initiate an operation in CMTS to instruct the selected cable modem to move to a new downstream frequency and/or upstream channel.')
docs_load_bal_chg_over_status_mac_addr = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 1), mac_address()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusMacAddr.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusMacAddr.setDescription('The mac address set in docsLoadBalChgOverMacAddress.')
docs_load_bal_chg_over_status_down_freq = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 1000000000))).setUnits('hertz').setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusDownFreq.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusDownFreq.setDescription('The Downstream frequency set in docsLoadBalChgOverDownFrequency.')
docs_load_bal_chg_over_status_up_chn_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(-1, 255)).clone(-1)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusUpChnId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusUpChnId.setDescription('The upstream channel ID set in docsLoadBalChgOverUpChannelId.')
docs_load_bal_chg_over_status_init_tech = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 4), channel_chg_init_tech_map()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusInitTech.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusInitTech.setDescription('The initialization technique set in docsLoadBalChgOverInitTech.')
docs_load_bal_chg_over_status_cmd = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('any', 1), ('dcc', 2), ('ucc', 3))).clone('any')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusCmd.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusCmd.setDescription('The load balancing command set in docsLoadBalChgOverCmd.')
docs_load_bal_chg_over_status_value = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('messageSent', 1), ('noOpNeeded', 2), ('modemDeparting', 3), ('waitToSendMessage', 4), ('cmOperationRejected', 5), ('cmtsOperationRejected', 6), ('timeOutT13', 7), ('timeOutT15', 8), ('rejectinit', 9), ('success', 10))).clone('waitToSendMessage')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusValue.setReference('Data-Over-Cable Service Interface Specifications: Radio Frequency Interface Specification SP-RFIv2.0-I04-030730, Sections C.4.1, 11.4.5.1.')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusValue.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusValue.setDescription("The status of the specified DCC/UCC operation. The enumerations are: messageSent(1): The CMTS has sent change over request message to the cable modem. noOpNeed(2): A operation was requested in which neither the DS Frequency nor the Upstream Channel ID was changed. An active value in this entry's row status indicates that no CMTS operation is required. modemDeparting(3): The cable modem has responded with a change over response of either a DCC-RSP with a confirmation code of depart(180) or a UCC-RSP. waitToSendMessage(4): The specified operation is active and CMTS is waiting to send the channel change message with channel info to the cable modem. cmOperationRejected(5): Channel Change (such as DCC or UCC) operation was rejected by the cable modem. cmtsOperationRejected(6) Channel Change (such as DCC or UCC) operation was rejected by the Cable modem Termination System. timeOutT13(7): Failure due to no DCC-RSP with confirmation code depart(180) received prior to expiration of the T13 timer. timeOutT15(8): T15 timer timed out prior to the arrival of a bandwidth request, RNG-REQ message, or DCC-RSP message with confirmation code of arrive(181) from the cable modem. rejectInit(9): DCC operation rejected due to unsupported initialization tech requested. success(10): CMTS received an indication that the CM successfully completed the change over operation. e.g., If an initialization technique of re-initialize the MAC is used, success in indicated by the receipt of a DCC-RSP message with a confirmation code of depart(180). In all other cases, success is indicated by: (1) the CMTS received a DCC-RSP message with confirmation code of arrive(181) or (2) the CMTS internally confirms the presence of the CM on the new channel.")
docs_load_bal_chg_over_status_update = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 2, 2, 1, 7), time_stamp()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusUpdate.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChgOverStatusUpdate.setDescription('The value of sysUpTime when docsLoadBalChgOverStatusValue was last updated.')
docs_load_bal_grp_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1))
if mibBuilder.loadTexts:
docsLoadBalGrpTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpTable.setDescription('This table contains the attributes of the load balancing groups present in this CMTS.')
docs_load_bal_grp_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpId'))
if mibBuilder.loadTexts:
docsLoadBalGrpEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpEntry.setDescription('A set of attributes of load balancing group in the CMTS. It is index by a docsLoadBalGrpId which is unique within a CMTS. Entries in this table persist after CMTS initialization.')
docs_load_bal_grp_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
docsLoadBalGrpId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpId.setDescription('A unique index assigned to the load balancing group by the CMTS.')
docs_load_bal_grp_is_restricted = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 2), truth_value().clone('false')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalGrpIsRestricted.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpIsRestricted.setDescription('A value true(1)Indicates type of load balancing group. A Restricted Load Balancing Group is associated to a specific provisioned set of cable modems. Restricted Load Balancing Group is used to accommodate a topology specific or provisioning specific restriction. Example such as a group that are reserved for business customers). Setting this object to true(1) means it is a Restricted Load Balancing type and setting it to false(2) means it is a General Load Balancing group type. This object should not be changed while its group ID is referenced by an active entry in docsLoadBalRestrictCmEntry.')
docs_load_bal_grp_init_tech = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 3), channel_chg_init_tech_map()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalGrpInitTech.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpInitTech.setDescription("The initialization techniques that the CMTS can use when load balancing cable modems in the load balancing group. By default this object is initialized with all the defined bits having a value of '1'.")
docs_load_bal_grp_default_policy = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalGrpDefaultPolicy.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpDefaultPolicy.setDescription('Each Load Balancing Group has a default Load Balancing Policy. A policy is described by a set of conditions (rules) that govern the load balancing process for a cable modem. The CMTS assigns this Policy ID value to a cable modem associated with the group ID when the cable modem does not signal a Policy ID during registration. The Policy ID value is intended to be a numeric reference to a row entry in docsLoadBalPolicyEntry. However, It is not required to have an existing or active entry in docsLoadBalPolicyEntry when setting the value of docsLoadBalGrpDefaultPolicy, in which case it indicates no policy is associated with the load Balancing Group. The Policy ID of value 0 is reserved to indicate no policy is associated with the load balancing group.')
docs_load_bal_grp_enable = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 5), truth_value().clone('true')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalGrpEnable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpEnable.setDescription('Setting this object to true(1) enables internal autonomous load balancing on this group. Setting it to false(2) disables the load balancing operation on this group.')
docs_load_bal_grp_chg_over_success = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 6), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalGrpChgOverSuccess.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpChgOverSuccess.setDescription('The number of successful load balancing change over operations initiated within this load balancing group.')
docs_load_bal_grp_chg_over_fails = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 7), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalGrpChgOverFails.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpChgOverFails.setDescription('The number of failed load balancing change over operations initiated within this load balancing group.')
docs_load_bal_grp_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 1, 1, 8), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalGrpStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalGrpStatus.setDescription("Indicates the status of the row in this table. Setting this object to 'destroy' or 'notInService' for a group ID entry already referenced by docsLoadBalChannelEntry, docsLoadBalChnPairsEntry or docsLoadBalRestrictCmEntry returns an error code inconsistentValue.")
docs_load_bal_channel_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2))
if mibBuilder.loadTexts:
docsLoadBalChannelTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChannelTable.setDescription('Lists all upstream and downstream channels associated with load balancing groups.')
docs_load_bal_channel_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpId'), (0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalChannelIfIndex'))
if mibBuilder.loadTexts:
docsLoadBalChannelEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChannelEntry.setDescription('Lists a specific upstream or downstream, within a load Balancing group. An entry in this table exists for each ifEntry with an ifType of docsCableDownstream(128) and docsCableUpstream(129) associated with the Load Balancing Group. Entries in this table persist after CMTS initialization.')
docs_load_bal_channel_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1, 1), interface_index())
if mibBuilder.loadTexts:
docsLoadBalChannelIfIndex.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChannelIfIndex.setDescription('The ifIndex of either the downstream or upstream.')
docs_load_bal_channel_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 2, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalChannelStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChannelStatus.setDescription("Indicates the status of the rows in this table. Creating entries in this table requires an existing value for docsLoadBalGrpId in docsLoadBalGrpEntry and an existing value of docsLoadBalChannelIfIndex in ifEntry, otherwise is rejected with error 'noCreation'. Setting this object to 'destroy' or 'notInService for a a row entry that is being referenced by docsLoadBalChnPairsEntry is rejected with error code inconsistentValue.")
docs_load_bal_chn_pairs_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3))
if mibBuilder.loadTexts:
docsLoadBalChnPairsTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsTable.setDescription('This table contains pairs of upstream channels within a Load Balancing Group. Entries in this table are used to override the initialization techniques defined for the associated Load Balancing Group.')
docs_load_bal_chn_pairs_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpId'), (0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalChnPairsIfIndexDepart'), (0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalChnPairsIfIndexArrive'))
if mibBuilder.loadTexts:
docsLoadBalChnPairsEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsEntry.setDescription('An entry in this table describes a channel pair for which an initialization technique override is needed. On a CMTS which supports logical upstream channels (ifType is equal to docsCableUpstreamChannel(205)), the entries in this table correspond to pairs of ifType 205. On a CMTS which only supports physical upstream channels (ifType is equal to docsCableUpstream(129)), the entries in this table correspond to pairs of ifType 129. Entries in this table persist after CMTS initialization.')
docs_load_bal_chn_pairs_if_index_depart = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 1), interface_index())
if mibBuilder.loadTexts:
docsLoadBalChnPairsIfIndexDepart.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsIfIndexDepart.setDescription('This index indicates the ifIndex of the upstream channel from which a cable modem would depart in a load balancing channel change operation.')
docs_load_bal_chn_pairs_if_index_arrive = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 2), interface_index())
if mibBuilder.loadTexts:
docsLoadBalChnPairsIfIndexArrive.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsIfIndexArrive.setDescription('This index indicates the ifIndex of the upstream channel on which a cable modem would arrive in a load balancing channel change operation.')
docs_load_bal_chn_pairs_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('operational', 1), ('notOperational', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
docsLoadBalChnPairsOperStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsOperStatus.setDescription('Operational status of the channel pair. The value operational(1) indicates that ifOperStatus of both channels is up(1). The value notOperational(2) means that ifOperStatus of one or both is not up(1).')
docs_load_bal_chn_pairs_init_tech = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 4), channel_chg_init_tech_map()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalChnPairsInitTech.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsInitTech.setDescription("Specifies initialization technique for load balancing for the Depart/Arrive pair. By default this object's value is the initialization technique configured for the Load Balancing Group indicated by docsLoadBalGrpId.")
docs_load_bal_chn_pairs_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 3, 1, 5), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalChnPairsRowStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalChnPairsRowStatus.setDescription("The object for conceptual rows creation. An attempt to create a row with values for docsLoadBalChnPairsIfIndexDepart or docsLoadBalChnPairsIfIndexArrive which are not a part of the Load Balancing Group (or for a 2.0 CMTS are not logical channels (ifType 205)) are rejected with a 'noCreation' error status reported. There is no restriction on settings columns in this table when the value of docsLoadBalChnPairsRowStatus is active(1).")
docs_load_bal_restrict_cm_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4))
if mibBuilder.loadTexts:
docsLoadBalRestrictCmTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmTable.setDescription('Lists all cable modems in each Restricted Load Balancing Groups.')
docs_load_bal_restrict_cm_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpId'), (0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalRestrictCmIndex'))
if mibBuilder.loadTexts:
docsLoadBalRestrictCmEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmEntry.setDescription('An entry of modem within a restricted load balancing group type. An entry represents a cable modem that is associated with the Restricted Load Balancing Group ID of a Restricted Load Balancing Group. Entries in this table persist after CMTS initialization.')
docs_load_bal_restrict_cm_index = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
docsLoadBalRestrictCmIndex.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmIndex.setDescription('The index that uniquely identifies an entry which represents restricted cable modem(s) within each Restricted Load Balancing Group.')
docs_load_bal_restrict_cm_mac_addr = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 2), mac_address()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmMACAddr.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmMACAddr.setDescription('Mac Address of the cable modem within the restricted load balancing group.')
docs_load_bal_restrict_cm_mac_addr_mask = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 3), octet_string().subtype(subtypeSpec=constraints_union(value_size_constraint(0, 0), value_size_constraint(6, 6))).clone(hexValue='')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmMacAddrMask.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmMacAddrMask.setDescription('A bit mask acting as a wild card to associate a set of modem MAC addresses to the same Group ID. Cable modem look up is performed first with entries containing this value not null, if several entries match, the largest consecutive bit match from MSB to LSB is used. Empty value is equivalent to the bit mask all in ones.')
docs_load_bal_restrict_cm_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 3, 4, 1, 4), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalRestrictCmStatus.setDescription("Indicates the status of the rows in this table. The attempt to create an entry associated to a group ID with docsLoadBalGrpIsRestricted equal to false(2) returns an error 'noCreation'. There is no restriction on settings columns in this table any time.")
docs_load_bal_policy_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1))
if mibBuilder.loadTexts:
docsLoadBalPolicyTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyTable.setDescription('This table describes the set of Load Balancing policies. Rows in this table might be referenced by rows in docsLoadBalGrpEntry.')
docs_load_bal_policy_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalPolicyId'), (0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalPolicyRuleId'))
if mibBuilder.loadTexts:
docsLoadBalPolicyEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyEntry.setDescription('Entries containing rules for policies. When a load balancing policy is defined by multiple rules, all the rules apply. Load balancing rules can be created to allow for specific vendor-defined load balancing actions. However there is a basic rule that the CMTS is required to support by configuring a pointer in docsLoadBalPolicyRulePtr to the table docsLoadBalBasicRuleTable. Vendor specific rules may be added by pointing the object docsLoadBalPolicyRulePtr to proprietary mib structures. Entries in this table persist after CMTS initialization.')
docs_load_bal_policy_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
docsLoadBalPolicyId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyId.setDescription('An index identifying the Load Balancing Policy.')
docs_load_bal_policy_rule_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
docsLoadBalPolicyRuleId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyRuleId.setDescription('An index for the rules entries associated within a policy.')
docs_load_bal_policy_rule_ptr = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 3), row_pointer().clone((0, 0))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalPolicyRulePtr.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyRulePtr.setDescription('A pointer to an entry in a rule table. E.g., docsLoadBalBasicRuleEnable in docsLoadBalBasicRuleEntry. A value pointing to zeroDotZero, an inactive Row or a non-existing entry is treated as no rule defined for this policy entry.')
docs_load_bal_policy_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 1, 1, 5), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalPolicyRowStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPolicyRowStatus.setDescription("The status of this conceptual row. There is no restriction on settings columns in this table when the value of docsLoadBalPolicyRowStatus is active(1). Setting this object to 'destroy' or 'notInService' for a row entry that is being referenced by docsLoadBalGrpDefaultPolicy in docsLoadBalGrpEntry returns an error code inconsistentValue.")
docs_load_bal_basic_rule_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2))
if mibBuilder.loadTexts:
docsLoadBalBasicRuleTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleTable.setDescription('DOCSIS defined basic ruleset for load Balancing Policy. This table enables of disable load balancing for the groups pointing to this ruleset in the policy group.')
docs_load_bal_basic_rule_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1)).setIndexNames((0, 'DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleId'))
if mibBuilder.loadTexts:
docsLoadBalBasicRuleEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleEntry.setDescription('An entry of DOCSIS defined basic ruleset. The object docsLoadBalBasicRuleEnable is used for instantiating an entry in this table via a RowPointer. Entries in this table persist after CMTS initialization.')
docs_load_bal_basic_rule_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 4294967295)))
if mibBuilder.loadTexts:
docsLoadBalBasicRuleId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleId.setDescription('The unique index for this row.')
docs_load_bal_basic_rule_enable = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2), ('disabledPeriod', 3)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleEnable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleEnable.setDescription('When using this ruleset, load balancing is enabled or disabled by the values enabled(1) and disabled(2) respectively. Additionally, a Load Balancing disabling period is defined in docsLoadBalBasicRuleDisStart and docsLoadBalBasicRuleDisPeriod if this object value is set to disabledPeriod(3).')
docs_load_bal_basic_rule_dis_start = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 86400))).setUnits('seconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleDisStart.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleDisStart.setDescription('if object docsLoadBalBasicRuleEnable is disablePeriod(3) Load Balancing is disabled starting at this object value time (seconds from 12 AM). Otherwise, this object has no meaning.')
docs_load_bal_basic_rule_dis_period = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 4), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 86400))).setUnits('seconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleDisPeriod.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleDisPeriod.setDescription('If object docsLoadBalBasicRuleEnable is disablePeriod(3) Load Balancing is disabled for the period of time defined between docsLoadBalBasicRuleDisStart and docsLoadBalBasicRuleDisStart plus the period of time of docsLoadBalBasicRuleDisPeriod. Otherwise, this object value has no meaning.')
docs_load_bal_basic_rule_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 4, 2, 1, 5), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleRowStatus.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleRowStatus.setDescription("This object is to create or delete rows in this table. There is no restriction for changing this row status or object's values in this table at any time.")
docs_load_bal_cmts_cm_status_table = mib_table((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4))
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusTable.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusTable.setDescription('The list contains the load balancing attributes associated with the cable modem. ')
docs_load_bal_cmts_cm_status_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1))
docsIfCmtsCmStatusEntry.registerAugmentions(('DOCS-LOADBALANCING-MIB', 'docsLoadBalCmtsCmStatusEntry'))
docsLoadBalCmtsCmStatusEntry.setIndexNames(*docsIfCmtsCmStatusEntry.getIndexNames())
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusEntry.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusEntry.setDescription('Additional objects for docsIfCmtsCmStatusTable entry that relate to load balancing ')
docs_load_bal_cmts_cm_status_group_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 1), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusGroupId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusGroupId.setDescription('The Group ID associated with this cable modem.')
docs_load_bal_cmts_cm_status_policy_id = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 2), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusPolicyId.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusPolicyId.setDescription('The Policy ID associated with this cable modem.')
docs_load_bal_cmts_cm_status_priority = mib_table_column((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 1, 1, 4, 1, 3), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusPriority.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusPriority.setDescription('The Priority associated with this cable modem.')
docs_load_bal_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2))
docs_load_bal_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 1))
docs_load_bal_groups = mib_identifier((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2))
docs_load_bal_basic_compliance = module_compliance((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 1, 1)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalSystemGroup'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalParametersGroup'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalPoliciesGroup'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleGroup'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalCmtsCmStatusGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_basic_compliance = docsLoadBalBasicCompliance.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicCompliance.setDescription('The compliance statement for DOCSIS load balancing systems.')
docs_load_bal_system_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 1)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalEnable'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverMacAddress'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverDownFrequency'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverUpChannelId'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverInitTech'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverCmd'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverCommit'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverLastCommit'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusMacAddr'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusDownFreq'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusUpChnId'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusInitTech'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusCmd'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusValue'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChgOverStatusUpdate'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_system_group = docsLoadBalSystemGroup.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalSystemGroup.setDescription('A collection of objects providing system-wide parameters for load balancing.')
docs_load_bal_parameters_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 2)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpIsRestricted'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpInitTech'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpDefaultPolicy'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpEnable'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpChgOverSuccess'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpChgOverFails'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalGrpStatus'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChannelStatus'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChnPairsOperStatus'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChnPairsInitTech'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalChnPairsRowStatus'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalRestrictCmMACAddr'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalRestrictCmMacAddrMask'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalRestrictCmStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_parameters_group = docsLoadBalParametersGroup.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalParametersGroup.setDescription('A collection of objects containing the load balancing parameters.')
docs_load_bal_policies_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 3)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalPolicyRulePtr'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalPolicyRowStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_policies_group = docsLoadBalPoliciesGroup.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalPoliciesGroup.setDescription('A collection of objects providing policies.')
docs_load_bal_basic_rule_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 4)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleEnable'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleDisStart'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleDisPeriod'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalBasicRuleRowStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_basic_rule_group = docsLoadBalBasicRuleGroup.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalBasicRuleGroup.setDescription('DOCSIS defined basic Ruleset for load balancing policies.')
docs_load_bal_cmts_cm_status_group = object_group((1, 3, 6, 1, 4, 1, 4491, 2, 1, 2, 2, 2, 5)).setObjects(('DOCS-LOADBALANCING-MIB', 'docsLoadBalCmtsCmStatusGroupId'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalCmtsCmStatusPolicyId'), ('DOCS-LOADBALANCING-MIB', 'docsLoadBalCmtsCmStatusPriority'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
docs_load_bal_cmts_cm_status_group = docsLoadBalCmtsCmStatusGroup.setStatus('current')
if mibBuilder.loadTexts:
docsLoadBalCmtsCmStatusGroup.setDescription('Cable mode status extension objects.')
mibBuilder.exportSymbols('DOCS-LOADBALANCING-MIB', docsLoadBalChgOverStatusEntry=docsLoadBalChgOverStatusEntry, docsLoadBalCmtsCmStatusTable=docsLoadBalCmtsCmStatusTable, docsLoadBalCmtsCmStatusEntry=docsLoadBalCmtsCmStatusEntry, docsLoadBalBasicRuleDisStart=docsLoadBalBasicRuleDisStart, docsLoadBalBasicCompliance=docsLoadBalBasicCompliance, docsLoadBalChnPairsIfIndexDepart=docsLoadBalChnPairsIfIndexDepart, docsLoadBalChgOverStatusValue=docsLoadBalChgOverStatusValue, docsLoadBalMibObjects=docsLoadBalMibObjects, docsLoadBalEnable=docsLoadBalEnable, docsLoadBalGrpChgOverFails=docsLoadBalGrpChgOverFails, docsLoadBalCmtsCmStatusPriority=docsLoadBalCmtsCmStatusPriority, docsLoadBalBasicRuleDisPeriod=docsLoadBalBasicRuleDisPeriod, docsLoadBalChgOverStatusMacAddr=docsLoadBalChgOverStatusMacAddr, docsLoadBalGrpDefaultPolicy=docsLoadBalGrpDefaultPolicy, docsLoadBalGrpInitTech=docsLoadBalGrpInitTech, docsLoadBalRestrictCmStatus=docsLoadBalRestrictCmStatus, docsLoadBalChgOverGroup=docsLoadBalChgOverGroup, docsLoadBalChnPairsIfIndexArrive=docsLoadBalChnPairsIfIndexArrive, docsLoadBalChgOverLastCommit=docsLoadBalChgOverLastCommit, docsLoadBalPolicyEntry=docsLoadBalPolicyEntry, docsLoadBalChgOverStatusUpdate=docsLoadBalChgOverStatusUpdate, docsLoadBalChannelEntry=docsLoadBalChannelEntry, docsLoadBalChnPairsEntry=docsLoadBalChnPairsEntry, docsLoadBalGrpIsRestricted=docsLoadBalGrpIsRestricted, docsLoadBalSystem=docsLoadBalSystem, docsLoadBalChnPairsInitTech=docsLoadBalChnPairsInitTech, docsLoadBalBasicRuleGroup=docsLoadBalBasicRuleGroup, docsLoadBalChgOverStatusUpChnId=docsLoadBalChgOverStatusUpChnId, docsLoadBalParametersGroup=docsLoadBalParametersGroup, docsLoadBalBasicRuleEntry=docsLoadBalBasicRuleEntry, docsLoadBalRestrictCmMacAddrMask=docsLoadBalRestrictCmMacAddrMask, docsLoadBalPolicyRulePtr=docsLoadBalPolicyRulePtr, docsLoadBalGrpStatus=docsLoadBalGrpStatus, docsLoadBalSystemGroup=docsLoadBalSystemGroup, docsLoadBalGrpChgOverSuccess=docsLoadBalGrpChgOverSuccess, docsLoadBalPolicyObjects=docsLoadBalPolicyObjects, docsLoadBalGroups=docsLoadBalGroups, docsLoadBalanceMib=docsLoadBalanceMib, docsLoadBalChgOverInitTech=docsLoadBalChgOverInitTech, docsLoadBalChgOverStatusDownFreq=docsLoadBalChgOverStatusDownFreq, docsLoadBalGrpObjects=docsLoadBalGrpObjects, docsLoadBalChnPairsTable=docsLoadBalChnPairsTable, docsLoadBalCompliances=docsLoadBalCompliances, docsLoadBalCmtsCmStatusPolicyId=docsLoadBalCmtsCmStatusPolicyId, docsLoadBalGrpEnable=docsLoadBalGrpEnable, docsLoadBalBasicRuleRowStatus=docsLoadBalBasicRuleRowStatus, docsLoadBalChgOverStatusInitTech=docsLoadBalChgOverStatusInitTech, docsLoadBalGrpTable=docsLoadBalGrpTable, docsLoadBalChgOverCmd=docsLoadBalChgOverCmd, docsLoadBalGrpEntry=docsLoadBalGrpEntry, docsLoadBalRestrictCmIndex=docsLoadBalRestrictCmIndex, docsLoadBalChannelTable=docsLoadBalChannelTable, docsLoadBalChgOverObjects=docsLoadBalChgOverObjects, docsLoadBalPolicyTable=docsLoadBalPolicyTable, docsLoadBalBasicRuleTable=docsLoadBalBasicRuleTable, docsLoadBalGrpId=docsLoadBalGrpId, docsLoadBalChgOverDownFrequency=docsLoadBalChgOverDownFrequency, docsLoadBalChgOverUpChannelId=docsLoadBalChgOverUpChannelId, docsLoadBalChgOverCommit=docsLoadBalChgOverCommit, docsLoadBalPolicyRowStatus=docsLoadBalPolicyRowStatus, docsLoadBalRestrictCmMACAddr=docsLoadBalRestrictCmMACAddr, docsLoadBalPolicyId=docsLoadBalPolicyId, docsLoadBalRestrictCmTable=docsLoadBalRestrictCmTable, PYSNMP_MODULE_ID=docsLoadBalanceMib, docsLoadBalNotifications=docsLoadBalNotifications, docsLoadBalBasicRuleEnable=docsLoadBalBasicRuleEnable, docsLoadBalPolicyRuleId=docsLoadBalPolicyRuleId, docsLoadBalChnPairsOperStatus=docsLoadBalChnPairsOperStatus, docsLoadBalChgOverMacAddress=docsLoadBalChgOverMacAddress, docsLoadBalRestrictCmEntry=docsLoadBalRestrictCmEntry, docsLoadBalBasicRuleId=docsLoadBalBasicRuleId, docsLoadBalChannelIfIndex=docsLoadBalChannelIfIndex, docsLoadBalCmtsCmStatusGroup=docsLoadBalCmtsCmStatusGroup, docsLoadBalConformance=docsLoadBalConformance, docsLoadBalCmtsCmStatusGroupId=docsLoadBalCmtsCmStatusGroupId, docsLoadBalChannelStatus=docsLoadBalChannelStatus, docsLoadBalChnPairsRowStatus=docsLoadBalChnPairsRowStatus, docsLoadBalChgOverStatusTable=docsLoadBalChgOverStatusTable, ChannelChgInitTechMap=ChannelChgInitTechMap, docsLoadBalChgOverStatusCmd=docsLoadBalChgOverStatusCmd, docsLoadBalPoliciesGroup=docsLoadBalPoliciesGroup) |
"""
Linear State Space Element Class
"""
class Element(object):
"""
State space member
"""
def __init__(self):
self.sys_id = str() # A string with the name of the element
self.sys = None # The actual object
self.ss = None # The state space object
self.settings = dict()
def initialise(self, data, sys_id):
self.sys_id = sys_id
settings = data.linear.settings[sys_id] # Load settings, the settings should be stored in data.linear.settings
# data.linear.settings should be created in the class above containing the entire set up
# Get the actual class object (like lingebm) from a dictionary in the same way that it is done for the solvers
# in sharpy
# sys = sys_from_string(sys_id)
# To use the decorator idea we would first need to instantiate the class. Need to see how this is done with NL
# SHARPy
def assemble(self):
pass | """
Linear State Space Element Class
"""
class Element(object):
"""
State space member
"""
def __init__(self):
self.sys_id = str()
self.sys = None
self.ss = None
self.settings = dict()
def initialise(self, data, sys_id):
self.sys_id = sys_id
settings = data.linear.settings[sys_id]
def assemble(self):
pass |
"""Constants."""
# A ``None``-ish constant for use where ``None`` may be a valid value.
NOT_SET = type('NOT_SET', (), {
'__bool__': (lambda self: False),
'__str__': (lambda self: 'NOT_SET'),
'__repr__': (lambda self: 'NOT_SET'),
'__copy__': (lambda self: self),
})()
# An alias for NOT_SET that may be more semantically-correct in some
# contexts.
NO_DEFAULT = NOT_SET
| """Constants."""
not_set = type('NOT_SET', (), {'__bool__': lambda self: False, '__str__': lambda self: 'NOT_SET', '__repr__': lambda self: 'NOT_SET', '__copy__': lambda self: self})()
no_default = NOT_SET |
class Solution:
def minCut(self, s: str) -> int:
dp=self.isPal(s)
return self.bfs(s,dp)
def isPal(self,s):
dp=[[False for i in s] for i in s]
for i in range(len(s)):
dp[i][i]=True
if i+1<len(s):
dp[i][i+1]=True if s[i]==s[i+1] else False
for i in range(len(s)):
for j in range(1,min(i+1,len(s)-i)):
# if j==1:
# dp[i][i+j]=True if s[i]==s[i+j] else False
# dp[i-j][i] = True if s[i] == s[i - j] else False
# else:
if i-j>-1 and i+j<len(s):
dp[i-j][i+j]= True if s[i-j]==s[i+j] and dp[i-j+1][i+j-1] else False
if i-j>-1 and i+j+1<len(s):
dp[i-j][i+j+1]=True if s[i-j]==s[i+1+j] and dp[i-j+1][i+j] else False
return dp
def bfs(self,s,dp):
q=list()
depth=1
for i in range(len(dp[0])):
if dp[0][i]:
if i==len(s)-1:
return 0
q.append(i+1)
while q:
size=len(q)
for i in range(size):
c=q[0]
q.pop(0)
for index in range(len(dp[c])):
if dp[c][index]:
if index==len(s)-1:
return depth
q.append(index+1)
depth+=1
return depth
if __name__ == '__main__':
sol=Solution()
# s='aammbbc'
# s='bb'
s="fifgbeajcacehiicccfecbfhhgfiiecdcjjffbghdidbhbdbfbfjccgbbdcjheccfbhafehieabbdfeigbiaggchaeghaijfbjhi"
print(sol.minCut(s)) | class Solution:
def min_cut(self, s: str) -> int:
dp = self.isPal(s)
return self.bfs(s, dp)
def is_pal(self, s):
dp = [[False for i in s] for i in s]
for i in range(len(s)):
dp[i][i] = True
if i + 1 < len(s):
dp[i][i + 1] = True if s[i] == s[i + 1] else False
for i in range(len(s)):
for j in range(1, min(i + 1, len(s) - i)):
if i - j > -1 and i + j < len(s):
dp[i - j][i + j] = True if s[i - j] == s[i + j] and dp[i - j + 1][i + j - 1] else False
if i - j > -1 and i + j + 1 < len(s):
dp[i - j][i + j + 1] = True if s[i - j] == s[i + 1 + j] and dp[i - j + 1][i + j] else False
return dp
def bfs(self, s, dp):
q = list()
depth = 1
for i in range(len(dp[0])):
if dp[0][i]:
if i == len(s) - 1:
return 0
q.append(i + 1)
while q:
size = len(q)
for i in range(size):
c = q[0]
q.pop(0)
for index in range(len(dp[c])):
if dp[c][index]:
if index == len(s) - 1:
return depth
q.append(index + 1)
depth += 1
return depth
if __name__ == '__main__':
sol = solution()
s = 'fifgbeajcacehiicccfecbfhhgfiiecdcjjffbghdidbhbdbfbfjccgbbdcjheccfbhafehieabbdfeigbiaggchaeghaijfbjhi'
print(sol.minCut(s)) |
def main(j, args, params, tags, tasklet):
params.merge(args)
doc = params.doc
tags = params.tags
out = ""
cmdstr = params.macrostr.split(":", 1)[1].replace("}}", "").strip()
md5 = j.base.byteprocessor.hashMd5(cmdstr)
j.system.fs.createDir(j.system.fs.joinPaths(j.core.portal.active.filesroot, "dot"))
path = j.system.fs.joinPaths(j.core.portal.active.filesroot, "dot", md5)
if not j.system.fs.exists(path + ".png"):
j.system.fs.writeFile(path + ".dot", cmdstr)
cmd = "dot -Tpng %s.dot -o %s.png" % (path, path)
# for i in range(5):
rescode, result = j.system.process.execute(cmd)
# if result.find("warning")==011:
if result.find("warning") != -1:
out = result
out += '\n'
out += "##DOT FILE WAS##:\n"
out += cmdstr
out += "##END OF DOT FILE##\n"
out = "{{code:\n%s\n}}" % out
params.result = out
return params
out = "!/files/dot/%s.png!" % md5
params.result = (out, doc)
return params
def match(j, args, params, tags, tasklet):
return True
| def main(j, args, params, tags, tasklet):
params.merge(args)
doc = params.doc
tags = params.tags
out = ''
cmdstr = params.macrostr.split(':', 1)[1].replace('}}', '').strip()
md5 = j.base.byteprocessor.hashMd5(cmdstr)
j.system.fs.createDir(j.system.fs.joinPaths(j.core.portal.active.filesroot, 'dot'))
path = j.system.fs.joinPaths(j.core.portal.active.filesroot, 'dot', md5)
if not j.system.fs.exists(path + '.png'):
j.system.fs.writeFile(path + '.dot', cmdstr)
cmd = 'dot -Tpng %s.dot -o %s.png' % (path, path)
(rescode, result) = j.system.process.execute(cmd)
if result.find('warning') != -1:
out = result
out += '\n'
out += '##DOT FILE WAS##:\n'
out += cmdstr
out += '##END OF DOT FILE##\n'
out = '{{code:\n%s\n}}' % out
params.result = out
return params
out = '!/files/dot/%s.png!' % md5
params.result = (out, doc)
return params
def match(j, args, params, tags, tasklet):
return True |
"""
Exceptions module
"""
class CuckooHashMapFullException(Exception):
"""
Exception raised when filter is full.
"""
pass
| """
Exceptions module
"""
class Cuckoohashmapfullexception(Exception):
"""
Exception raised when filter is full.
"""
pass |
class Solution:
def strStr(self, haystack: str, needle: str) -> int:
if needle == "":
return 0
for i in range(0, len(haystack) - len(needle) + 1):
print(haystack[i : i + len(needle)], needle)
if haystack[i : i + len(needle)] == needle:
return i
return -1 | class Solution:
def str_str(self, haystack: str, needle: str) -> int:
if needle == '':
return 0
for i in range(0, len(haystack) - len(needle) + 1):
print(haystack[i:i + len(needle)], needle)
if haystack[i:i + len(needle)] == needle:
return i
return -1 |
"""
499. Word Count (Map Reduce)
https://www.lintcode.com/problem/word-count-map-reduce/description
"""
class WordCount:
# @param {str} line a text, for example "Bye Bye see you next"
def mapper(self, _, line):
# Write your code here
# Please use 'yield key, value'
word_lists = line.split(" ")
for word in word_lists:
yield word, 1
# @param key is from mapper
# @param values is a set of value with the same key
def reducer(self, key, values):
# Write your code here
# Please use 'yield key, value'
yield key, sum(values)
| """
499. Word Count (Map Reduce)
https://www.lintcode.com/problem/word-count-map-reduce/description
"""
class Wordcount:
def mapper(self, _, line):
word_lists = line.split(' ')
for word in word_lists:
yield (word, 1)
def reducer(self, key, values):
yield (key, sum(values)) |
class Solution:
def mergeTrees(self, t1, t2):
"""
:type t1: TreeNode
:type t2: TreeNode
:rtype: TreeNode
"""
# This method changes the existing tree instead of returning a new one
if t1 and t2:
t1.val += t2.val
t1.left = self.mergeTrees(t1.left, t2.left)
t1.right = self.mergeTrees(t1.right, t2.right)
return t1
else:
return t1 or t2
| class Solution:
def merge_trees(self, t1, t2):
"""
:type t1: TreeNode
:type t2: TreeNode
:rtype: TreeNode
"""
if t1 and t2:
t1.val += t2.val
t1.left = self.mergeTrees(t1.left, t2.left)
t1.right = self.mergeTrees(t1.right, t2.right)
return t1
else:
return t1 or t2 |
n = int(input())
m = int(input())
r = m
for i in range(n):
a, b = map(int, input().split())
m += a
m -= b
if m < 0:
print(0)
exit()
r = max(r, m)
print(r)
| n = int(input())
m = int(input())
r = m
for i in range(n):
(a, b) = map(int, input().split())
m += a
m -= b
if m < 0:
print(0)
exit()
r = max(r, m)
print(r) |
name = " alberT"
one = name.rsplit()
print("one:", one)
two = name.index('al', 0)
print("two:", two)
three = name.index('T', -1)
print("three:", three)
four = name.replace('l', 'p')
print("four:", four)
five = name.split('l')
print("five:", five)
six = name.upper()
print("six:", six)
seven = name.lower()
print("seven:", seven)
eight = name[1]
print("eight:", eight )
nine = name[:3]
print("nine:", nine)
ten = name[-2:]
print("ten:", ten)
eleven = name.index("e")
print("eleven:", eleven)
twelve = name[:-1]
print("twelve:", twelve) | name = ' alberT'
one = name.rsplit()
print('one:', one)
two = name.index('al', 0)
print('two:', two)
three = name.index('T', -1)
print('three:', three)
four = name.replace('l', 'p')
print('four:', four)
five = name.split('l')
print('five:', five)
six = name.upper()
print('six:', six)
seven = name.lower()
print('seven:', seven)
eight = name[1]
print('eight:', eight)
nine = name[:3]
print('nine:', nine)
ten = name[-2:]
print('ten:', ten)
eleven = name.index('e')
print('eleven:', eleven)
twelve = name[:-1]
print('twelve:', twelve) |
n = int(input())
s = [[0] * 10 for _ in range(n + 1)]
s[1] = [0] + [1] * 9
mod = 1000 ** 3
for i in range(2, n + 1):
for j in range(0, 9 + 1):
if j >= 1:
s[i][j] += s[i - 1][j - 1]
if j <= 8:
s[i][j] += s[i - 1][j + 1]
print(sum(s[n]) % mod) | n = int(input())
s = [[0] * 10 for _ in range(n + 1)]
s[1] = [0] + [1] * 9
mod = 1000 ** 3
for i in range(2, n + 1):
for j in range(0, 9 + 1):
if j >= 1:
s[i][j] += s[i - 1][j - 1]
if j <= 8:
s[i][j] += s[i - 1][j + 1]
print(sum(s[n]) % mod) |
class RpnCalcError(Exception):
"""Calculator Generic Exception"""
pass
class StackDepletedError(RpnCalcError):
""" Stack is out of items """
pass
| class Rpncalcerror(Exception):
"""Calculator Generic Exception"""
pass
class Stackdepletederror(RpnCalcError):
""" Stack is out of items """
pass |
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Definition of all Rainman2 exceptions
"""
__author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
__date__ = 'Wednesday, February 14th 2018, 11:38:08 am'
class FileOpenError(IOError):
"""
Exception raised when a file couldn't be opened.
"""
pass
class AgentNotSupported(Exception):
"""
Exception raised when agent is not valid for requested algorithm
"""
pass
class AgentMethodNotImplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an agent
that is not implemented yet.
"""
pass
class AlgorithmNotImplemented(NotImplementedError):
"""
Exception raised when trying to access algorithm that is not
implemented yet.
"""
pass
class AlgorithmMethodNotImplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an algorithm
that is not implemented yet.
"""
pass
class ClientNotImplemented(NotImplementedError):
"""
Exception raised when trying to access client that is not
implemented yet.
"""
pass
class ClientMethodNotImplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of a client
that is not implemented yet.
"""
pass
class EnvironmentNotImplemented(NotImplementedError):
"""
Exception raised when trying to access Environment that is not
implemented yet.
"""
pass
class EnvironmentMethodNotImplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an environment
that is not implemented yet.
"""
pass
class ExternalServerError(Exception):
"""
Exception raised when external server is not accessible
"""
pass
| """
Definition of all Rainman2 exceptions
"""
__author__ = 'Ari Saha (arisaha@icloud.com), Mingyang Liu(liux3941@umn.edu)'
__date__ = 'Wednesday, February 14th 2018, 11:38:08 am'
class Fileopenerror(IOError):
"""
Exception raised when a file couldn't be opened.
"""
pass
class Agentnotsupported(Exception):
"""
Exception raised when agent is not valid for requested algorithm
"""
pass
class Agentmethodnotimplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an agent
that is not implemented yet.
"""
pass
class Algorithmnotimplemented(NotImplementedError):
"""
Exception raised when trying to access algorithm that is not
implemented yet.
"""
pass
class Algorithmmethodnotimplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an algorithm
that is not implemented yet.
"""
pass
class Clientnotimplemented(NotImplementedError):
"""
Exception raised when trying to access client that is not
implemented yet.
"""
pass
class Clientmethodnotimplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of a client
that is not implemented yet.
"""
pass
class Environmentnotimplemented(NotImplementedError):
"""
Exception raised when trying to access Environment that is not
implemented yet.
"""
pass
class Environmentmethodnotimplemented(NotImplementedError):
"""
Exception raised when trying to access a private method of an environment
that is not implemented yet.
"""
pass
class Externalservererror(Exception):
"""
Exception raised when external server is not accessible
"""
pass |
__title__ = "FisherExactTest"
__version__ = "1.0.1"
__author__ = "Ae-Mc"
__author_email__ = "ae_mc@mail.ru"
__description__ = "Two tailed Fisher's exact test wrote in pure Python"
__url__ = "https://github.com/Ae-Mc/Fisher"
__classifiers__ = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Utilities"
]
| __title__ = 'FisherExactTest'
__version__ = '1.0.1'
__author__ = 'Ae-Mc'
__author_email__ = 'ae_mc@mail.ru'
__description__ = "Two tailed Fisher's exact test wrote in pure Python"
__url__ = 'https://github.com/Ae-Mc/Fisher'
__classifiers__ = ['Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Topic :: Utilities'] |
# -*- coding: utf-8 -*-
class Solution:
def sortSentence(self, s: str) -> str:
tokens = s.split()
result = [None] * len(tokens)
for token in tokens:
word, index = token[:-1], int(token[-1])
result[index - 1] = word
return ' '.join(result)
if __name__ == '__main__':
solution = Solution()
assert 'This is a sentence' == solution.sortSentence('is2 sentence4 This1 a3')
assert 'Me Myself and I' == solution.sortSentence('Myself2 Me1 I4 and3')
| class Solution:
def sort_sentence(self, s: str) -> str:
tokens = s.split()
result = [None] * len(tokens)
for token in tokens:
(word, index) = (token[:-1], int(token[-1]))
result[index - 1] = word
return ' '.join(result)
if __name__ == '__main__':
solution = solution()
assert 'This is a sentence' == solution.sortSentence('is2 sentence4 This1 a3')
assert 'Me Myself and I' == solution.sortSentence('Myself2 Me1 I4 and3') |
"""Specifies the supported Bazel versions."""
CURRENT_BAZEL_VERSION = "5.0.0"
OTHER_BAZEL_VERSIONS = [
"6.0.0-pre.20220223.1",
]
SUPPORTED_BAZEL_VERSIONS = [
CURRENT_BAZEL_VERSION,
] + OTHER_BAZEL_VERSIONS
| """Specifies the supported Bazel versions."""
current_bazel_version = '5.0.0'
other_bazel_versions = ['6.0.0-pre.20220223.1']
supported_bazel_versions = [CURRENT_BAZEL_VERSION] + OTHER_BAZEL_VERSIONS |
def _compile(words):
if not len(words):
return None, ''
num = None
if words[0].isdigit():
num = int(words[0])
words = words[1:]
return num, ' '.join(words)
def _split_out_colons(terms):
newterms = []
for term in terms:
if ':' in term:
subterms = term.split(':')
for sub in subterms:
newterms.append(sub)
newterms.append(':')
newterms = newterms[:-1]
else:
newterms.append(term)
return [term for term in newterms if len(term)]
# parse user command text
def user_command(text):
terms = text.strip().split()
terms = _split_out_colons(terms)
cmd = {}
if len(terms) == 0:
return cmd
cmd['verb'] = terms[0]
mode = 'directobject'
flags = ['with', 'by', 'from', 'for', 'to', ':']
words = []
for term in terms[1:]:
if mode == ':':
words.append(term)
elif term in flags:
num, cmd[mode] = _compile(words)
if not len(cmd[mode]):
cmd.pop(mode)
if num:
cmd[mode+'_num'] = num
words = []
mode = term
else:
words.append(term)
if len(words):
num, cmd[mode] = _compile(words)
if num:
cmd[mode+'_num'] = num
return cmd | def _compile(words):
if not len(words):
return (None, '')
num = None
if words[0].isdigit():
num = int(words[0])
words = words[1:]
return (num, ' '.join(words))
def _split_out_colons(terms):
newterms = []
for term in terms:
if ':' in term:
subterms = term.split(':')
for sub in subterms:
newterms.append(sub)
newterms.append(':')
newterms = newterms[:-1]
else:
newterms.append(term)
return [term for term in newterms if len(term)]
def user_command(text):
terms = text.strip().split()
terms = _split_out_colons(terms)
cmd = {}
if len(terms) == 0:
return cmd
cmd['verb'] = terms[0]
mode = 'directobject'
flags = ['with', 'by', 'from', 'for', 'to', ':']
words = []
for term in terms[1:]:
if mode == ':':
words.append(term)
elif term in flags:
(num, cmd[mode]) = _compile(words)
if not len(cmd[mode]):
cmd.pop(mode)
if num:
cmd[mode + '_num'] = num
words = []
mode = term
else:
words.append(term)
if len(words):
(num, cmd[mode]) = _compile(words)
if num:
cmd[mode + '_num'] = num
return cmd |
class BankAccount:
def __init__(self, checking = None, savings = None):
self._checking = checking
self._savings = savings
def get_checking(self):
return self._checking
def set_checking(self, new_checking):
self._checking = new_checking
def get_savings(self):
return self._savings
def set_savings(self, new_savings):
self._savings = new_savings
my_account = BankAccount()
my_account.set_checking(523.48)
print(my_account.get_checking())
my_account.set_savings(386.15)
print(my_account.get_savings()) | class Bankaccount:
def __init__(self, checking=None, savings=None):
self._checking = checking
self._savings = savings
def get_checking(self):
return self._checking
def set_checking(self, new_checking):
self._checking = new_checking
def get_savings(self):
return self._savings
def set_savings(self, new_savings):
self._savings = new_savings
my_account = bank_account()
my_account.set_checking(523.48)
print(my_account.get_checking())
my_account.set_savings(386.15)
print(my_account.get_savings()) |
"""
LeetCode Problem: 344. Reverse String
Link: https://leetcode.com/problems/reverse-string/
Language: Python
Written by: Mostofa Adib Shakib
Time Complexity: O(n)
Space Complexity: O(1)
"""
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
low = 0
high = len(s) - 1
while low < high:
s[low], s[high] = s[high], s[low]
low += 1
high -= 1 | """
LeetCode Problem: 344. Reverse String
Link: https://leetcode.com/problems/reverse-string/
Language: Python
Written by: Mostofa Adib Shakib
Time Complexity: O(n)
Space Complexity: O(1)
"""
class Solution:
def reverse_string(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
low = 0
high = len(s) - 1
while low < high:
(s[low], s[high]) = (s[high], s[low])
low += 1
high -= 1 |
# abba
# foo bar bar foo
text1 = list(input())
text2 = input().split()
# text1 = set(text1)
print(text1)
print(text2)
for i in range(len(text1)):
if text1[i] == "a":
text1[i] = 1
else:
text1[i] = 0
for i in range(len(text2)):
if text2[i] == "foo":
text2[i] = 1
else:
text2[i] = 0
print(text1)
print(text2)
if (text1 == text2):
print(True)
else:
print(False)
| text1 = list(input())
text2 = input().split()
print(text1)
print(text2)
for i in range(len(text1)):
if text1[i] == 'a':
text1[i] = 1
else:
text1[i] = 0
for i in range(len(text2)):
if text2[i] == 'foo':
text2[i] = 1
else:
text2[i] = 0
print(text1)
print(text2)
if text1 == text2:
print(True)
else:
print(False) |
#!/usr/bin/env python3
'''
The MIT License (MIT)
Copyright (c) 2014 Mark Haines
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''
def asdata(obj, asdata):
if isinstance(obj, Data):
return obj.asdata(asdata)
elif isinstance(obj, str):
return obj
elif hasattr(obj, '_asdict'):
return asdata(obj._asdict(), asdata)
elif isinstance(obj, dict):
return dict((k, asdata(v, asdata)) for (k, v) in obj.items())
else:
try:
return list(asdata(child, asdata) for child in obj)
except:
return obj
class Data:
def asdata(self, asdata = asdata):
return dict((k, asdata(v, asdata)) for (k, v) in self.__dict__.items())
def __repr__(self):
return self.asdata().__repr__()
| """
The MIT License (MIT)
Copyright (c) 2014 Mark Haines
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
def asdata(obj, asdata):
if isinstance(obj, Data):
return obj.asdata(asdata)
elif isinstance(obj, str):
return obj
elif hasattr(obj, '_asdict'):
return asdata(obj._asdict(), asdata)
elif isinstance(obj, dict):
return dict(((k, asdata(v, asdata)) for (k, v) in obj.items()))
else:
try:
return list((asdata(child, asdata) for child in obj))
except:
return obj
class Data:
def asdata(self, asdata=asdata):
return dict(((k, asdata(v, asdata)) for (k, v) in self.__dict__.items()))
def __repr__(self):
return self.asdata().__repr__() |
class Solution:
def isIdealPermutation(self, A: List[int]) -> bool:
n = len(A)
g = local = 0
for i in range(1, n):
if A[i] < A[i-1]:
local += 1
if A[i] < i:
diff = i - A[i]
g += diff * (diff+1) // 2
return g == local
| class Solution:
def is_ideal_permutation(self, A: List[int]) -> bool:
n = len(A)
g = local = 0
for i in range(1, n):
if A[i] < A[i - 1]:
local += 1
if A[i] < i:
diff = i - A[i]
g += diff * (diff + 1) // 2
return g == local |
xval = 0
xvalue1 = 1
xvalue2 = 2
print(xvalue1 + xvalue2)
| xval = 0
xvalue1 = 1
xvalue2 = 2
print(xvalue1 + xvalue2) |
class Order():
def __init__(self, exchCode, sym_, _sym, orderType, price, side, qty, stopPrice=''):
self.odid = None
self.status = None
self.tempOdid = None
self.sym_ = sym_
self._sym = _sym
self.symbol = sym_ + _sym
self.exchCode = exchCode.upper()
self.orderType = orderType
self.price = price
self.fair = -1.0
self.side = side.upper()
self.sign = '+' if self.side == 'BUY' else '-' # for logging only
# self.order_type_id = None # Only for Coinigy
# self.price_type_id = None # Only for Coinigy
self.qty = qty
self.stop_price = stopPrice
self.orderExposure = -1.0
# timestamp
self.createTs = -1.0
self.activeTs = -1.0
self.cxlTs = -1.0
self.cxledTs = -1.0
self.filledTs = -1.0
# for pricing
self.eq = -1.0
# for order handling
self.nbFillQ = 0
self.nbMissingAck = 0
self.nbExtRej = 0
self.nbNone = 0
self.nbFalseActive = 0
| class Order:
def __init__(self, exchCode, sym_, _sym, orderType, price, side, qty, stopPrice=''):
self.odid = None
self.status = None
self.tempOdid = None
self.sym_ = sym_
self._sym = _sym
self.symbol = sym_ + _sym
self.exchCode = exchCode.upper()
self.orderType = orderType
self.price = price
self.fair = -1.0
self.side = side.upper()
self.sign = '+' if self.side == 'BUY' else '-'
self.qty = qty
self.stop_price = stopPrice
self.orderExposure = -1.0
self.createTs = -1.0
self.activeTs = -1.0
self.cxlTs = -1.0
self.cxledTs = -1.0
self.filledTs = -1.0
self.eq = -1.0
self.nbFillQ = 0
self.nbMissingAck = 0
self.nbExtRej = 0
self.nbNone = 0
self.nbFalseActive = 0 |
def add_native_methods(clazz):
def initProto____():
raise NotImplementedError()
def socketCreate__boolean__(a0, a1):
raise NotImplementedError()
def socketConnect__java_net_InetAddress__int__int__(a0, a1, a2, a3):
raise NotImplementedError()
def socketBind__java_net_InetAddress__int__boolean__(a0, a1, a2, a3):
raise NotImplementedError()
def socketListen__int__(a0, a1):
raise NotImplementedError()
def socketAccept__java_net_SocketImpl__(a0, a1):
raise NotImplementedError()
def socketAvailable____(a0):
raise NotImplementedError()
def socketClose0__boolean__(a0, a1):
raise NotImplementedError()
def socketShutdown__int__(a0, a1):
raise NotImplementedError()
def socketNativeSetOption__int__boolean__java_lang_Object__(a0, a1, a2, a3):
raise NotImplementedError()
def socketGetOption__int__java_lang_Object__(a0, a1, a2):
raise NotImplementedError()
def socketSendUrgentData__int__(a0, a1):
raise NotImplementedError()
clazz.initProto____ = staticmethod(initProto____)
clazz.socketCreate__boolean__ = socketCreate__boolean__
clazz.socketConnect__java_net_InetAddress__int__int__ = socketConnect__java_net_InetAddress__int__int__
clazz.socketBind__java_net_InetAddress__int__boolean__ = socketBind__java_net_InetAddress__int__boolean__
clazz.socketListen__int__ = socketListen__int__
clazz.socketAccept__java_net_SocketImpl__ = socketAccept__java_net_SocketImpl__
clazz.socketAvailable____ = socketAvailable____
clazz.socketClose0__boolean__ = socketClose0__boolean__
clazz.socketShutdown__int__ = socketShutdown__int__
clazz.socketNativeSetOption__int__boolean__java_lang_Object__ = socketNativeSetOption__int__boolean__java_lang_Object__
clazz.socketGetOption__int__java_lang_Object__ = socketGetOption__int__java_lang_Object__
clazz.socketSendUrgentData__int__ = socketSendUrgentData__int__
| def add_native_methods(clazz):
def init_proto____():
raise not_implemented_error()
def socket_create__boolean__(a0, a1):
raise not_implemented_error()
def socket_connect__java_net__inet_address__int__int__(a0, a1, a2, a3):
raise not_implemented_error()
def socket_bind__java_net__inet_address__int__boolean__(a0, a1, a2, a3):
raise not_implemented_error()
def socket_listen__int__(a0, a1):
raise not_implemented_error()
def socket_accept__java_net__socket_impl__(a0, a1):
raise not_implemented_error()
def socket_available____(a0):
raise not_implemented_error()
def socket_close0__boolean__(a0, a1):
raise not_implemented_error()
def socket_shutdown__int__(a0, a1):
raise not_implemented_error()
def socket_native_set_option__int__boolean__java_lang__object__(a0, a1, a2, a3):
raise not_implemented_error()
def socket_get_option__int__java_lang__object__(a0, a1, a2):
raise not_implemented_error()
def socket_send_urgent_data__int__(a0, a1):
raise not_implemented_error()
clazz.initProto____ = staticmethod(initProto____)
clazz.socketCreate__boolean__ = socketCreate__boolean__
clazz.socketConnect__java_net_InetAddress__int__int__ = socketConnect__java_net_InetAddress__int__int__
clazz.socketBind__java_net_InetAddress__int__boolean__ = socketBind__java_net_InetAddress__int__boolean__
clazz.socketListen__int__ = socketListen__int__
clazz.socketAccept__java_net_SocketImpl__ = socketAccept__java_net_SocketImpl__
clazz.socketAvailable____ = socketAvailable____
clazz.socketClose0__boolean__ = socketClose0__boolean__
clazz.socketShutdown__int__ = socketShutdown__int__
clazz.socketNativeSetOption__int__boolean__java_lang_Object__ = socketNativeSetOption__int__boolean__java_lang_Object__
clazz.socketGetOption__int__java_lang_Object__ = socketGetOption__int__java_lang_Object__
clazz.socketSendUrgentData__int__ = socketSendUrgentData__int__ |
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 8 09:45:29 2018
@author: abaena
"""
DATATYPE_AGENT = 'agent'
DATATYPE_PATH_METRICS = 'pathmet'
DATATYPE_LOG_EVENTS = 'logeve'
DATATYPE_LOG_METRICS = 'logmet'
DATATYPE_MONITOR_HOST = 'host'
DATATYPE_MONITOR_MICROSERVICE = 'ms'
DATATYPE_MONITOR_TOMCAT = 'tomc'
DATATYPE_MONITOR_POSTGRES = 'psql'
SOURCE_TYPE_READER = "reader"
SOURCE_TYPE_HOST = "host"
SOURCE_TYPE_SPRINGMICROSERVICE = "spring_microservice"
SOURCE_TYPE_TOMCAT = "tomcat"
SOURCE_TYPE_POSTGRES = "postgres"
MEASURE_CAT_METRIC=0
MEASURE_CAT_EVENT=1
TRANSF_TYPE_NONE=0
TRANSF_TYPE_MINMAX=1
TRANSF_TYPE_STD=2
TRANSF_TYPE_PERCENTAGE=3
TRANSF_TYPE_FUZZY_1=4
| """
Created on Sun Apr 8 09:45:29 2018
@author: abaena
"""
datatype_agent = 'agent'
datatype_path_metrics = 'pathmet'
datatype_log_events = 'logeve'
datatype_log_metrics = 'logmet'
datatype_monitor_host = 'host'
datatype_monitor_microservice = 'ms'
datatype_monitor_tomcat = 'tomc'
datatype_monitor_postgres = 'psql'
source_type_reader = 'reader'
source_type_host = 'host'
source_type_springmicroservice = 'spring_microservice'
source_type_tomcat = 'tomcat'
source_type_postgres = 'postgres'
measure_cat_metric = 0
measure_cat_event = 1
transf_type_none = 0
transf_type_minmax = 1
transf_type_std = 2
transf_type_percentage = 3
transf_type_fuzzy_1 = 4 |
''' This can be solved using the slicing method used in list. We have to modify the list by take moving the
last part of the array in reverse order and joining it with the remaining part of the list to its right'''
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
k = k % len(nums) #To reduce the a full cycle rotation
nums[:] = nums[-k:] + nums[:-k] #nums[-k:] -> end part of the list in reverse order
#nums[:-k] -> front part of the list which is attached to the right of nums[-k:] | """ This can be solved using the slicing method used in list. We have to modify the list by take moving the
last part of the array in reverse order and joining it with the remaining part of the list to its right"""
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
k = k % len(nums)
nums[:] = nums[-k:] + nums[:-k] |
# generated from genmsg/cmake/pkg-genmsg.context.in
messages_str = "/home/viki/catkin_ws/src/beginner_tutorials/msg/Num.msg"
services_str = "/home/viki/catkin_ws/src/beginner_tutorials/srv/ResetCount.srv;/home/viki/catkin_ws/src/beginner_tutorials/srv/AddTwoInts.srv"
pkg_name = "beginner_tutorials"
dependencies_str = "std_msgs"
langs = "gencpp;genlisp;genpy"
dep_include_paths_str = "beginner_tutorials;/home/viki/catkin_ws/src/beginner_tutorials/msg;std_msgs;/opt/ros/indigo/share/std_msgs/cmake/../msg"
PYTHON_EXECUTABLE = "/usr/bin/python"
package_has_static_sources = '' == 'TRUE'
genmsg_check_deps_script = "/opt/ros/indigo/share/genmsg/cmake/../../../lib/genmsg/genmsg_check_deps.py"
| messages_str = '/home/viki/catkin_ws/src/beginner_tutorials/msg/Num.msg'
services_str = '/home/viki/catkin_ws/src/beginner_tutorials/srv/ResetCount.srv;/home/viki/catkin_ws/src/beginner_tutorials/srv/AddTwoInts.srv'
pkg_name = 'beginner_tutorials'
dependencies_str = 'std_msgs'
langs = 'gencpp;genlisp;genpy'
dep_include_paths_str = 'beginner_tutorials;/home/viki/catkin_ws/src/beginner_tutorials/msg;std_msgs;/opt/ros/indigo/share/std_msgs/cmake/../msg'
python_executable = '/usr/bin/python'
package_has_static_sources = '' == 'TRUE'
genmsg_check_deps_script = '/opt/ros/indigo/share/genmsg/cmake/../../../lib/genmsg/genmsg_check_deps.py' |
x=int(input("no 1 "))
y=int(input("no 2 "))
def pow(x,y):
if y!=0:
return(x*pow(x,y-1))
else:
return 1
print(pow(x,y))
| x = int(input('no 1 '))
y = int(input('no 2 '))
def pow(x, y):
if y != 0:
return x * pow(x, y - 1)
else:
return 1
print(pow(x, y)) |
#!/usr/bin/python
hamming_threshold = [50, 60]
pattern_scale = [4.0, 6.0, 8.0, 10.0]
fp_runscript = open("/mnt/ssd/kivan/cv-stereo/scripts/eval_batch/run_batch_validation.sh", 'w')
fp_runscript.write("#!/bin/bash\n\n")
cnt = 0
for i in range(len(hamming_threshold)):
for j in range(len(pattern_scale)):
cnt += 1
filepath = "/home/kivan/Projects/cv-stereo/config_files/experiments/kitti/validation_freak/freak_tracker_validation_stage2_" + str(cnt) + ".txt"
print(filepath)
fp = open(filepath, 'w')
fp.write("odometry_method = VisualOdometryRansac\n")
fp.write("use_deformation_field = false\n")
fp.write("ransac_iters = 1000\n\n")
fp.write("tracker = StereoTracker\n")
fp.write("max_disparity = 160\n")
fp.write("stereo_wsz = 15\n")
fp.write("ncc_threshold_s = 0.7\n\n")
fp.write("tracker_mono = TrackerBFMcv\n")
fp.write("max_features = 5000\n")
fp.write("search_wsz = 230\n\n")
fp.write("hamming_threshold = " + str(hamming_threshold[i]) + "\n\n")
fp.write("detector = FeatureDetectorHarrisFREAK\n")
fp.write("harris_block_sz = 3\n")
fp.write("harris_filter_sz = 1\n")
fp.write("harris_k = 0.04\n")
fp.write("harris_thr = 1e-06\n")
fp.write("harris_margin = 15\n\n")
fp.write("freak_norm_scale = false\n")
fp.write("freak_norm_orient = false\n")
fp.write("freak_pattern_scale = " + str(pattern_scale[j]) + "\n")
fp.write("freak_num_octaves = 0\n")
fp.write("use_bundle_adjustment = false")
fp.close()
fp_runscript.write('./run_kitti_evaluation_dinodas.sh "' + filepath + '"\n')
fp_runscript.close()
| hamming_threshold = [50, 60]
pattern_scale = [4.0, 6.0, 8.0, 10.0]
fp_runscript = open('/mnt/ssd/kivan/cv-stereo/scripts/eval_batch/run_batch_validation.sh', 'w')
fp_runscript.write('#!/bin/bash\n\n')
cnt = 0
for i in range(len(hamming_threshold)):
for j in range(len(pattern_scale)):
cnt += 1
filepath = '/home/kivan/Projects/cv-stereo/config_files/experiments/kitti/validation_freak/freak_tracker_validation_stage2_' + str(cnt) + '.txt'
print(filepath)
fp = open(filepath, 'w')
fp.write('odometry_method = VisualOdometryRansac\n')
fp.write('use_deformation_field = false\n')
fp.write('ransac_iters = 1000\n\n')
fp.write('tracker = StereoTracker\n')
fp.write('max_disparity = 160\n')
fp.write('stereo_wsz = 15\n')
fp.write('ncc_threshold_s = 0.7\n\n')
fp.write('tracker_mono = TrackerBFMcv\n')
fp.write('max_features = 5000\n')
fp.write('search_wsz = 230\n\n')
fp.write('hamming_threshold = ' + str(hamming_threshold[i]) + '\n\n')
fp.write('detector = FeatureDetectorHarrisFREAK\n')
fp.write('harris_block_sz = 3\n')
fp.write('harris_filter_sz = 1\n')
fp.write('harris_k = 0.04\n')
fp.write('harris_thr = 1e-06\n')
fp.write('harris_margin = 15\n\n')
fp.write('freak_norm_scale = false\n')
fp.write('freak_norm_orient = false\n')
fp.write('freak_pattern_scale = ' + str(pattern_scale[j]) + '\n')
fp.write('freak_num_octaves = 0\n')
fp.write('use_bundle_adjustment = false')
fp.close()
fp_runscript.write('./run_kitti_evaluation_dinodas.sh "' + filepath + '"\n')
fp_runscript.close() |
#!/usr/bin/env python
colors = ['white', 'black']
sizes = ['S', 'M', 'L']
tshirts = [(color, size) for size in sizes
for color in colors ]
print(tshirts)
tshirts = [(color, size) for color in colors
for size in sizes ]
print(tshirts)
| colors = ['white', 'black']
sizes = ['S', 'M', 'L']
tshirts = [(color, size) for size in sizes for color in colors]
print(tshirts)
tshirts = [(color, size) for color in colors for size in sizes]
print(tshirts) |
if __name__ == '__main__':
n = int(input())
arr = map(int, input().split())
max = -9999999
max2 = -9999999
for i in arr:
if(i>max):
max2=max
max=i
elif i>max2 and max>i:
max2=i
print(max2) | if __name__ == '__main__':
n = int(input())
arr = map(int, input().split())
max = -9999999
max2 = -9999999
for i in arr:
if i > max:
max2 = max
max = i
elif i > max2 and max > i:
max2 = i
print(max2) |
class Stack:
def __init__(self):
self.stack = []
def add(self, dataval):
# Use list append method to add element
if dataval not in self.stack:
self.stack.append(dataval)
return True
else:
return False
# Use peek to look at the top of the stack
def peek(self):
return self.stack[-1] | class Stack:
def __init__(self):
self.stack = []
def add(self, dataval):
if dataval not in self.stack:
self.stack.append(dataval)
return True
else:
return False
def peek(self):
return self.stack[-1] |
class KataResult:
def __init__(self, revenue, ipa, cost_of_kata, net_income, cost_of_goods, kata_penalty):
self.revenue = revenue
self.ipa = ipa
self.cost_of_kata = cost_of_kata
self.net_income = net_income
self.cost_of_goods = cost_of_goods
self.kata_penalty = kata_penalty
| class Kataresult:
def __init__(self, revenue, ipa, cost_of_kata, net_income, cost_of_goods, kata_penalty):
self.revenue = revenue
self.ipa = ipa
self.cost_of_kata = cost_of_kata
self.net_income = net_income
self.cost_of_goods = cost_of_goods
self.kata_penalty = kata_penalty |
su = 0
a = [3,5,6,2,7,1]
print(sum(a))
x, y = input("Enter a two value: ").split()
x = int(x)
y = int(y)
su = a[y] + sum(a[:y])
print(su) | su = 0
a = [3, 5, 6, 2, 7, 1]
print(sum(a))
(x, y) = input('Enter a two value: ').split()
x = int(x)
y = int(y)
su = a[y] + sum(a[:y])
print(su) |
def test_topic_regexp_matching(dequeuer):
msg = {'company_name': 'test_company'}
actions_1 = tuple(dequeuer.get_actions_for_topic('object__created', msg))
actions_2 = tuple(dequeuer.get_actions_for_topic('object__deleted', msg))
actions_3 = tuple(dequeuer.get_actions_for_topic('otherthing__created', msg))
assert actions_1 == actions_2
assert actions_1 != actions_3
def test_topic_regexp_matching_with_groups(dequeuer):
msg = {'company_name': 'test_company'}
actions_1 = tuple(dequeuer.get_actions_for_topic('step__alfa__started', msg))
payload = actions_1[0][1]['run'].args[2][0]
assert 'name' in payload
assert payload['name'] == 'alfa'
assert 'status' in payload
assert payload['status'] == 'started', payload
actions_2 = tuple(dequeuer.get_actions_for_topic('step__beta__finished', msg))
actions_3 = tuple(dequeuer.get_actions_for_topic('otherthing__created', msg))
assert actions_1 == actions_2
assert actions_1 != actions_3
| def test_topic_regexp_matching(dequeuer):
msg = {'company_name': 'test_company'}
actions_1 = tuple(dequeuer.get_actions_for_topic('object__created', msg))
actions_2 = tuple(dequeuer.get_actions_for_topic('object__deleted', msg))
actions_3 = tuple(dequeuer.get_actions_for_topic('otherthing__created', msg))
assert actions_1 == actions_2
assert actions_1 != actions_3
def test_topic_regexp_matching_with_groups(dequeuer):
msg = {'company_name': 'test_company'}
actions_1 = tuple(dequeuer.get_actions_for_topic('step__alfa__started', msg))
payload = actions_1[0][1]['run'].args[2][0]
assert 'name' in payload
assert payload['name'] == 'alfa'
assert 'status' in payload
assert payload['status'] == 'started', payload
actions_2 = tuple(dequeuer.get_actions_for_topic('step__beta__finished', msg))
actions_3 = tuple(dequeuer.get_actions_for_topic('otherthing__created', msg))
assert actions_1 == actions_2
assert actions_1 != actions_3 |
# -*- coding: utf-8 -*-
VERSION = (1, 0, 4)
__version__ = "1.0.4"
__authors__ = ["Stefan Foulis <stefan.foulis@gmail.com>", ]
| version = (1, 0, 4)
__version__ = '1.0.4'
__authors__ = ['Stefan Foulis <stefan.foulis@gmail.com>'] |
'''
This is the exceptions module:
'''
'''
Exception of when user do not have the access to certain pages.
'''
class CannotAccessPageException(Exception):
pass
'''
Exception of the first password and the second password does not match during registration.
'''
class PasswordsNotMatchingException(Exception):
pass
'''
Exception of when the user input format is wrong.
'''
class WrongFormatException(Exception):
def __init__(self, message=''):
super().__init__('{}, format is incorrect.'.format(message))
'''
Exception of when the ticket name is wrong.
'''
class WrongTicketNameException(Exception):
pass
'''
Exception of when the ticket quantity is wrong.
'''
class WrongTicketQuantityException(Exception):
pass
'''
Exception of when the ticket quantity is wrong.
'''
class WrongTicketPriceException(Exception):
pass
'''
Exception of when the email already exists in user data (already registered).
'''
class EmailAlreadyExistsException(Exception):
pass | """
This is the exceptions module:
"""
'\nException of when user do not have the access to certain pages.\n'
class Cannotaccesspageexception(Exception):
pass
'\nException of the first password and the second password does not match during registration.\n'
class Passwordsnotmatchingexception(Exception):
pass
'\nException of when the user input format is wrong.\n'
class Wrongformatexception(Exception):
def __init__(self, message=''):
super().__init__('{}, format is incorrect.'.format(message))
'\nException of when the ticket name is wrong.\n'
class Wrongticketnameexception(Exception):
pass
'\nException of when the ticket quantity is wrong.\n'
class Wrongticketquantityexception(Exception):
pass
'\nException of when the ticket quantity is wrong.\n'
class Wrongticketpriceexception(Exception):
pass
'\nException of when the email already exists in user data (already registered).\n'
class Emailalreadyexistsexception(Exception):
pass |
class TransportContext(object):
""" The System.Net.TransportContext class provides additional context about the underlying transport layer. """
def GetChannelBinding(self,kind):
"""
GetChannelBinding(self: TransportContext,kind: ChannelBindingKind) -> ChannelBinding
Retrieves the requested channel binding.
kind: The type of channel binding to retrieve.
Returns: The requested System.Security.Authentication.ExtendedProtection.ChannelBinding,or null if the
channel binding is not supported by the current transport or by the operating system.
"""
pass
def GetTlsTokenBindings(self):
""" GetTlsTokenBindings(self: TransportContext) -> IEnumerable[TokenBinding] """
pass
| class Transportcontext(object):
""" The System.Net.TransportContext class provides additional context about the underlying transport layer. """
def get_channel_binding(self, kind):
"""
GetChannelBinding(self: TransportContext,kind: ChannelBindingKind) -> ChannelBinding
Retrieves the requested channel binding.
kind: The type of channel binding to retrieve.
Returns: The requested System.Security.Authentication.ExtendedProtection.ChannelBinding,or null if the
channel binding is not supported by the current transport or by the operating system.
"""
pass
def get_tls_token_bindings(self):
""" GetTlsTokenBindings(self: TransportContext) -> IEnumerable[TokenBinding] """
pass |
# Copyright 2016-2022 The FEAGI Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
def utf_detection_logic(detection_list):
# todo: Add a logic to account for cases were two top ranked items are too close
# Identifies the detected UTF character with highest activity
highest_ranked_item = '-'
second_highest_ranked_item = '-'
for item in detection_list:
if highest_ranked_item == '-':
highest_ranked_item = item
else:
if detection_list[item]['rank'] > detection_list[highest_ranked_item]['rank']:
second_highest_ranked_item = highest_ranked_item
highest_ranked_item = item
elif second_highest_ranked_item == '-':
second_highest_ranked_item = item
else:
if detection_list[item]['rank'] > detection_list[second_highest_ranked_item]['rank']:
second_highest_ranked_item = item
# todo: export detection factor to genome not parameters
detection_tolerance = 1.5
if highest_ranked_item != '-' and second_highest_ranked_item == '-':
print("Highest ranking number was chosen.")
print("1st and 2nd highest ranked numbers are: ", highest_ranked_item, second_highest_ranked_item)
return highest_ranked_item
elif highest_ranked_item != '-' and \
second_highest_ranked_item != '-' and \
detection_list[second_highest_ranked_item]['rank'] != 0:
if detection_list[highest_ranked_item]['rank'] / detection_list[second_highest_ranked_item]['rank'] > \
detection_tolerance:
print("Highest ranking number was chosen.")
print("1st and 2nd highest ranked numbers are: ", highest_ranked_item, second_highest_ranked_item)
return highest_ranked_item
else:
print(">>>> >>> >> >> >> >> > > Tolerance factor was not met!! !! !!")
print("Highest and 2nd highest ranked numbers are: ", highest_ranked_item, second_highest_ranked_item)
return '-'
else:
return '-'
# list_length = len(detection_list)
# if list_length == 1:
# for key in detection_list:
# return key
# elif list_length >= 2 or list_length == 0:
# return '-'
# else:
# temp = []
# counter = 0
# # print(">><<>><<>><<", detection_list)
# for key in detection_list:
# temp[counter] = (key, detection_list[key])
# if temp[0][1] > (3 * temp[1][1]):
# return temp[0][0]
# elif temp[1][1] > (3 * temp[0][1]):
# return temp[1][0]
# else:
# return '-'
# Load copy of all MNIST training images into mnist_data in form of an iterator. Each object has image label + image
| def utf_detection_logic(detection_list):
highest_ranked_item = '-'
second_highest_ranked_item = '-'
for item in detection_list:
if highest_ranked_item == '-':
highest_ranked_item = item
elif detection_list[item]['rank'] > detection_list[highest_ranked_item]['rank']:
second_highest_ranked_item = highest_ranked_item
highest_ranked_item = item
elif second_highest_ranked_item == '-':
second_highest_ranked_item = item
elif detection_list[item]['rank'] > detection_list[second_highest_ranked_item]['rank']:
second_highest_ranked_item = item
detection_tolerance = 1.5
if highest_ranked_item != '-' and second_highest_ranked_item == '-':
print('Highest ranking number was chosen.')
print('1st and 2nd highest ranked numbers are: ', highest_ranked_item, second_highest_ranked_item)
return highest_ranked_item
elif highest_ranked_item != '-' and second_highest_ranked_item != '-' and (detection_list[second_highest_ranked_item]['rank'] != 0):
if detection_list[highest_ranked_item]['rank'] / detection_list[second_highest_ranked_item]['rank'] > detection_tolerance:
print('Highest ranking number was chosen.')
print('1st and 2nd highest ranked numbers are: ', highest_ranked_item, second_highest_ranked_item)
return highest_ranked_item
else:
print('>>>> >>> >> >> >> >> > > Tolerance factor was not met!! !! !!')
print('Highest and 2nd highest ranked numbers are: ', highest_ranked_item, second_highest_ranked_item)
return '-'
else:
return '-' |
def is_triangle(func):
def wrapped(sides):
if any(i <= 0 for i in sides):
return False
sum_ = sum(sides)
if any(sides[i] > sum_ - sides[i] for i in range(3)):
return False
return func(sides)
return wrapped
@is_triangle
def is_equilateral(sides):
return len(set(sides)) == 1
@is_triangle
def is_isosceles(sides):
return len(set(sides)) != 3
@is_triangle
def is_scalene(sides):
return len(set(sides)) == 3
| def is_triangle(func):
def wrapped(sides):
if any((i <= 0 for i in sides)):
return False
sum_ = sum(sides)
if any((sides[i] > sum_ - sides[i] for i in range(3))):
return False
return func(sides)
return wrapped
@is_triangle
def is_equilateral(sides):
return len(set(sides)) == 1
@is_triangle
def is_isosceles(sides):
return len(set(sides)) != 3
@is_triangle
def is_scalene(sides):
return len(set(sides)) == 3 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
BOT_NAME = 'book'
SPIDER_MODULES = ['book.spiders']
NEWSPIDER_MODULE = 'book.spiders'
IMAGES_STORE = '../storage/book/'
COOKIES_ENABLED = True
COOKIE_DEBUG = True
LOG_LEVEL = 'INFO'
# LOG_LEVEL = 'DEBUG'
CONCURRENT_REQUESTS = 100
CONCURRENT_REQUESTS_PER_DOMAIN = 1000
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, \
like Gecko) Chrome/49.0.2623.87 Safari/537.36"
DEFAULT_REQUEST_HEADERS = {
'Referer': 'https://m.douban.com/book/'
}
ITEM_PIPELINES = {
'book.pipelines.CoverPipeline': 0,
'book.pipelines.BookPipeline': 1,
}
| bot_name = 'book'
spider_modules = ['book.spiders']
newspider_module = 'book.spiders'
images_store = '../storage/book/'
cookies_enabled = True
cookie_debug = True
log_level = 'INFO'
concurrent_requests = 100
concurrent_requests_per_domain = 1000
user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36'
default_request_headers = {'Referer': 'https://m.douban.com/book/'}
item_pipelines = {'book.pipelines.CoverPipeline': 0, 'book.pipelines.BookPipeline': 1} |
AP = "AP"
BP = "BP"
ARRIVE = "ARRIVE"
NEUROMODULATORS = "NEUROMODULATORS"
TARGET = "TARGET"
OBSERVE = "OBSERVE"
SET_FREQUENCY = "SET_FREQUENCY"
DEACTIVATE = "DEACTIVATE"
ENCODE_INFORMATION = "ENCODE_INFORMATION"
| ap = 'AP'
bp = 'BP'
arrive = 'ARRIVE'
neuromodulators = 'NEUROMODULATORS'
target = 'TARGET'
observe = 'OBSERVE'
set_frequency = 'SET_FREQUENCY'
deactivate = 'DEACTIVATE'
encode_information = 'ENCODE_INFORMATION' |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 9 00:00:43 2018
@author: joy
"""
print(5 + 3)
print(9 - 1)
print(2 * 4)
print(16//2) | """
Created on Tue Jan 9 00:00:43 2018
@author: joy
"""
print(5 + 3)
print(9 - 1)
print(2 * 4)
print(16 // 2) |
#! /usr/bin/python3
print("HELLO PYTHON")
| print('HELLO PYTHON') |
try:
with open('proxies.txt', 'r') as file:
proxy = [ line.rstrip() for line in file.readlines()]
except FileNotFoundError:
raise Exception('Proxies.txt not found.') | try:
with open('proxies.txt', 'r') as file:
proxy = [line.rstrip() for line in file.readlines()]
except FileNotFoundError:
raise exception('Proxies.txt not found.') |
"""
Fragments of project version mutations
"""
PROJECT_VERSION_FRAGMENT = '''
content
id
name
projectId
'''
| """
Fragments of project version mutations
"""
project_version_fragment = '\ncontent\nid\nname\nprojectId\n' |
text = input()
punc_remove = [",", ".", "!", "?"]
for i in punc_remove:
text = text.replace(i, "")
print(text.lower()) | text = input()
punc_remove = [',', '.', '!', '?']
for i in punc_remove:
text = text.replace(i, '')
print(text.lower()) |
'''
Student: Dan Grecoe
Assignment: Homework 1
Submission of the first homework assignment. The assignment
was to create a python file with 2 functions
multiply - Takes two parameters x and y and returns the product
of the values provided.
noop - Takes 0 parameters and returns None
'''
def multiply(x, y):
return x * y
def noop():
#raise Exception("Bad things happened")
print("Dumb student program")
return None
| """
Student: Dan Grecoe
Assignment: Homework 1
Submission of the first homework assignment. The assignment
was to create a python file with 2 functions
multiply - Takes two parameters x and y and returns the product
of the values provided.
noop - Takes 0 parameters and returns None
"""
def multiply(x, y):
return x * y
def noop():
print('Dumb student program')
return None |
# `name` is the name of the package as used for `pip install package`
name = "package-name"
# `path` is the name of the package for `import package`
path = name.lower().replace("-", "_").replace(" ", "_")
version = "0.1.0"
author = "Author Name"
author_email = ""
description = "" # summary
license = "MIT"
| name = 'package-name'
path = name.lower().replace('-', '_').replace(' ', '_')
version = '0.1.0'
author = 'Author Name'
author_email = ''
description = ''
license = 'MIT' |
class TestClient:
"""
Test before_request and after_request decorators in __init__.py.
"""
def test_1(self, client): # disallowed methods
res = client.put("/")
assert res.status_code == 405
assert b"Method Not Allowed" in res.content
res = client.options("/api/post/add")
assert res.status_code == 405
assert b"Method Not Allowed" in res.content
res = client.delete("/notifications")
assert res.status_code == 405
assert b"Method Not Allowed" in res.content
def test_2(self, client): # empty/fake user agent
res = client.get("/", headers={"User-Agent": ""})
assert res.status_code == 403
assert b"No Scrappers!" in res.content
res = client.get("/board/2", headers={"User-Agent": "python/3.8"})
assert res.status_code == 403
assert b"No Scrappers!" in res.content
| class Testclient:
"""
Test before_request and after_request decorators in __init__.py.
"""
def test_1(self, client):
res = client.put('/')
assert res.status_code == 405
assert b'Method Not Allowed' in res.content
res = client.options('/api/post/add')
assert res.status_code == 405
assert b'Method Not Allowed' in res.content
res = client.delete('/notifications')
assert res.status_code == 405
assert b'Method Not Allowed' in res.content
def test_2(self, client):
res = client.get('/', headers={'User-Agent': ''})
assert res.status_code == 403
assert b'No Scrappers!' in res.content
res = client.get('/board/2', headers={'User-Agent': 'python/3.8'})
assert res.status_code == 403
assert b'No Scrappers!' in res.content |
class Graph(object):
"""
A simple undirected, weighted graph
"""
def __init__(self):
self.nodes = set()
self.edges = {}
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
self._add_edge(from_node, to_node, distance)
self._add_edge(to_node, from_node, distance)
def _add_edge(self, from_node, to_node, distance):
self.edges.setdefault(from_node, [])
self.edges[from_node].append(to_node)
self.distances[(from_node, to_node)] = distance
def dijkstra(graph, initial_node):
visited = {initial_node: 0}
nodes = set(graph.nodes)
while nodes:
min_node = None
for node in nodes:
if node in visited:
if min_node is None:
min_node = node
elif visited[node] < visited[min_node]:
min_node = node
if min_node is None:
break
nodes.remove(min_node)
cur_wt = visited[min_node]
for edge in graph.edges[min_node]:
wt = cur_wt + graph.distances[(min_node, edge)]
if edge not in visited or wt < visited[edge]:
visited[edge] = wt
return visited
def dijkstra2(graph, initial_node):
visited = {initial_node: 0}
nodes = set(graph.nodes)
while nodes:
min_node = None
for node in nodes:
if node in visited:
if min_node is None:
min_node = node
elif visited[node] < visited[min_node]:
min_node = node
if min_node is None:
break
nodes.remove(min_node)
cur_wt = visited[min_node]
for edge in graph.edges[min_node]:
wt = cur_wt + graph.distances[(min_node, edge)]
if edge not in visited or wt < visited[edge]:
visited[edge] = wt
return visited
| class Graph(object):
"""
A simple undirected, weighted graph
"""
def __init__(self):
self.nodes = set()
self.edges = {}
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
self._add_edge(from_node, to_node, distance)
self._add_edge(to_node, from_node, distance)
def _add_edge(self, from_node, to_node, distance):
self.edges.setdefault(from_node, [])
self.edges[from_node].append(to_node)
self.distances[from_node, to_node] = distance
def dijkstra(graph, initial_node):
visited = {initial_node: 0}
nodes = set(graph.nodes)
while nodes:
min_node = None
for node in nodes:
if node in visited:
if min_node is None:
min_node = node
elif visited[node] < visited[min_node]:
min_node = node
if min_node is None:
break
nodes.remove(min_node)
cur_wt = visited[min_node]
for edge in graph.edges[min_node]:
wt = cur_wt + graph.distances[min_node, edge]
if edge not in visited or wt < visited[edge]:
visited[edge] = wt
return visited
def dijkstra2(graph, initial_node):
visited = {initial_node: 0}
nodes = set(graph.nodes)
while nodes:
min_node = None
for node in nodes:
if node in visited:
if min_node is None:
min_node = node
elif visited[node] < visited[min_node]:
min_node = node
if min_node is None:
break
nodes.remove(min_node)
cur_wt = visited[min_node]
for edge in graph.edges[min_node]:
wt = cur_wt + graph.distances[min_node, edge]
if edge not in visited or wt < visited[edge]:
visited[edge] = wt
return visited |
class Config(object):
"""Configuration primitives.
Inherit from or instantiate this class and call configure() when you've got
a dictionary of configuration values you want to process and query.
Would be nice to have _expand_cidrlist() so blacklists can specify ranges.
"""
def __init__(self, config_dict=None, portlists=[]):
if config_dict is not None:
self.configure(config_dict, portlists)
def configure(self, config_dict, portlists=[], stringlists=[]):
"""Parse configuration.
Does three things:
1.) Turn dictionary keys to lowercase
2.) Turn string lists into arrays for quicker access
3.) Expand port range specifications
"""
self._dict = dict((k.lower(), v) for k, v in config_dict.items())
for entry in portlists:
portlist = self.getconfigval(entry)
if portlist:
expanded = self._expand_ports(portlist)
self.setconfigval(entry, expanded)
for entry in stringlists:
stringlist = self.getconfigval(entry)
if stringlist:
expanded = [s.strip() for s in stringlist.split(',')]
self.setconfigval(entry, expanded)
def reconfigure(self, portlists=[], stringlists=[]):
"""Same as configure(), but allows multiple callers to sequentially
apply parsing directives for port and string lists.
For instance, if a base class calls configure() specifying one set of
port lists and string lists, but a derived class knows about further
configuration items that will need to be accessed samewise, this
function can be used to leave the existing parsed data alone and only
re-parse the new port or string lists into arrays.
"""
self.configure(self._dict, portlists, stringlists)
def _expand_ports(self, ports_list):
ports = []
for i in ports_list.split(','):
if '-' not in i:
ports.append(int(i))
else:
l, h = list(map(int, i.split('-')))
ports += list(range(l, h + 1))
return ports
def _fuzzy_true(self, value):
return value.lower() in ['yes', 'on', 'true', 'enable', 'enabled']
def _fuzzy_false(self, value):
return value.lower() in ['no', 'off', 'false', 'disable', 'disabled']
def is_configured(self, opt):
return opt.lower() in list(self._dict.keys())
def is_unconfigured(self, opt):
return not self.is_configured(opt)
def is_set(self, opt):
return (self.is_configured(opt) and
self._fuzzy_true(self._dict[opt.lower()]))
def is_clear(self, opt):
return (self.is_configured(opt) and
self._fuzzy_false(self._dict[opt.lower()]))
def getconfigval(self, opt, default=None):
return self._dict[opt.lower()] if self.is_configured(opt) else default
def setconfigval(self, opt, obj):
self._dict[opt.lower()] = obj
| class Config(object):
"""Configuration primitives.
Inherit from or instantiate this class and call configure() when you've got
a dictionary of configuration values you want to process and query.
Would be nice to have _expand_cidrlist() so blacklists can specify ranges.
"""
def __init__(self, config_dict=None, portlists=[]):
if config_dict is not None:
self.configure(config_dict, portlists)
def configure(self, config_dict, portlists=[], stringlists=[]):
"""Parse configuration.
Does three things:
1.) Turn dictionary keys to lowercase
2.) Turn string lists into arrays for quicker access
3.) Expand port range specifications
"""
self._dict = dict(((k.lower(), v) for (k, v) in config_dict.items()))
for entry in portlists:
portlist = self.getconfigval(entry)
if portlist:
expanded = self._expand_ports(portlist)
self.setconfigval(entry, expanded)
for entry in stringlists:
stringlist = self.getconfigval(entry)
if stringlist:
expanded = [s.strip() for s in stringlist.split(',')]
self.setconfigval(entry, expanded)
def reconfigure(self, portlists=[], stringlists=[]):
"""Same as configure(), but allows multiple callers to sequentially
apply parsing directives for port and string lists.
For instance, if a base class calls configure() specifying one set of
port lists and string lists, but a derived class knows about further
configuration items that will need to be accessed samewise, this
function can be used to leave the existing parsed data alone and only
re-parse the new port or string lists into arrays.
"""
self.configure(self._dict, portlists, stringlists)
def _expand_ports(self, ports_list):
ports = []
for i in ports_list.split(','):
if '-' not in i:
ports.append(int(i))
else:
(l, h) = list(map(int, i.split('-')))
ports += list(range(l, h + 1))
return ports
def _fuzzy_true(self, value):
return value.lower() in ['yes', 'on', 'true', 'enable', 'enabled']
def _fuzzy_false(self, value):
return value.lower() in ['no', 'off', 'false', 'disable', 'disabled']
def is_configured(self, opt):
return opt.lower() in list(self._dict.keys())
def is_unconfigured(self, opt):
return not self.is_configured(opt)
def is_set(self, opt):
return self.is_configured(opt) and self._fuzzy_true(self._dict[opt.lower()])
def is_clear(self, opt):
return self.is_configured(opt) and self._fuzzy_false(self._dict[opt.lower()])
def getconfigval(self, opt, default=None):
return self._dict[opt.lower()] if self.is_configured(opt) else default
def setconfigval(self, opt, obj):
self._dict[opt.lower()] = obj |
__title__ = 'cisco_support'
__description__ = 'Cisco Support APIs'
__version__ = '0.1.0'
__author__ = 'Dennis Roth'
__license__ = 'MIT'
| __title__ = 'cisco_support'
__description__ = 'Cisco Support APIs'
__version__ = '0.1.0'
__author__ = 'Dennis Roth'
__license__ = 'MIT' |
elements = [int(x) for x in input().split(', ')]
even_numbers = [x for x in elements if x % 2 == 0]
odd_numbers = [x for x in elements if x % 2 != 0]
positive = [x for x in elements if x >= 0]
negative = [x for x in elements if x < 0]
print(f"Positive: {', '.join(str(x) for x in positive)}")
print(f"Negative: {', '.join(str(x) for x in negative)}")
print(f"Even: {', '.join(str(x) for x in even_numbers)}")
print(f"Odd: {', '.join(str(x) for x in odd_numbers)}")
| elements = [int(x) for x in input().split(', ')]
even_numbers = [x for x in elements if x % 2 == 0]
odd_numbers = [x for x in elements if x % 2 != 0]
positive = [x for x in elements if x >= 0]
negative = [x for x in elements if x < 0]
print(f"Positive: {', '.join((str(x) for x in positive))}")
print(f"Negative: {', '.join((str(x) for x in negative))}")
print(f"Even: {', '.join((str(x) for x in even_numbers))}")
print(f"Odd: {', '.join((str(x) for x in odd_numbers))}") |
vals = {
"yes" : 0,
"residential" : 1,
"service" : 2,
"unclassified" : 3,
"stream" : 4,
"track" : 5,
"water" : 6,
"footway" : 7,
"tertiary" : 8,
"private" : 9,
"tree" : 10,
"path" : 11,
"forest" : 12,
"secondary" : 13,
"house" : 14,
"no" : 15,
"asphalt" : 16,
"wood" : 17,
"grass" : 18,
"paved" : 19,
"primary" : 20,
"unpaved" : 21,
"bus_stop" : 22,
"parking" : 23,
"parking_aisle" : 24,
"rail" : 25,
"driveway" : 26,
"8" : 27,
"administrative" : 28,
"locality" : 29,
"turning_circle" : 30,
"crossing" : 31,
"village" : 32,
"fence" : 33,
"grade2" : 34,
"coastline" : 35,
"grade3" : 36,
"farmland" : 37,
"hamlet" : 38,
"hut" : 39,
"meadow" : 40,
"wetland" : 41,
"cycleway" : 42,
"river" : 43,
"school" : 44,
"trunk" : 45,
"gravel" : 46,
"place_of_worship" : 47,
"farm" : 48,
"grade1" : 49,
"traffic_signals" : 50,
"wall" : 51,
"garage" : 52,
"gate" : 53,
"motorway" : 54,
"living_street" : 55,
"pitch" : 56,
"grade4" : 57,
"industrial" : 58,
"road" : 59,
"ground" : 60,
"scrub" : 61,
"motorway_link" : 62,
"steps" : 63,
"ditch" : 64,
"swimming_pool" : 65,
"grade5" : 66,
"park" : 67,
"apartments" : 68,
"restaurant" : 69,
"designated" : 70,
"bench" : 71,
"survey_point" : 72,
"pedestrian" : 73,
"hedge" : 74,
"reservoir" : 75,
"riverbank" : 76,
"alley" : 77,
"farmyard" : 78,
"peak" : 79,
"level_crossing" : 80,
"roof" : 81,
"dirt" : 82,
"drain" : 83,
"garages" : 84,
"entrance" : 85,
"street_lamp" : 86,
"deciduous" : 87,
"fuel" : 88,
"trunk_link" : 89,
"information" : 90,
"playground" : 91,
"supermarket" : 92,
"primary_link" : 93,
"concrete" : 94,
"mixed" : 95,
"permissive" : 96,
"orchard" : 97,
"grave_yard" : 98,
"canal" : 99,
"garden" : 100,
"spur" : 101,
"paving_stones" : 102,
"rock" : 103,
"bollard" : 104,
"convenience" : 105,
"cemetery" : 106,
"post_box" : 107,
"commercial" : 108,
"pier" : 109,
"bank" : 110,
"hotel" : 111,
"cliff" : 112,
"retail" : 113,
"construction" : 114,
"-1" : 115,
"fast_food" : 116,
"coniferous" : 117,
"cafe" : 118,
"6" : 119,
"kindergarten" : 120,
"tower" : 121,
"hospital" : 122,
"yard" : 123,
"sand" : 124,
"public_building" : 125,
"cobblestone" : 126,
"destination" : 127,
"island" : 128,
"abandoned" : 129,
"vineyard" : 130,
"recycling" : 131,
"agricultural" : 132,
"isolated_dwelling" : 133,
"pharmacy" : 134,
"post_office" : 135,
"motorway_junction" : 136,
"pub" : 137,
"allotments" : 138,
"dam" : 139,
"secondary_link" : 140,
"lift_gate" : 141,
"siding" : 142,
"stop" : 143,
"main" : 144,
"farm_auxiliary" : 145,
"quarry" : 146,
"10" : 147,
"station" : 148,
"platform" : 149,
"taxiway" : 150,
"limited" : 151,
"sports_centre" : 152,
"cutline" : 153,
"detached" : 154,
"storage_tank" : 155,
"basin" : 156,
"bicycle_parking" : 157,
"telephone" : 158,
"terrace" : 159,
"town" : 160,
"suburb" : 161,
"bus" : 162,
"compacted" : 163,
"toilets" : 164,
"heath" : 165,
"works" : 166,
"tram" : 167,
"beach" : 168,
"culvert" : 169,
"fire_station" : 170,
"recreation_ground" : 171,
"bakery" : 172,
"police" : 173,
"atm" : 174,
"clothes" : 175,
"tertiary_link" : 176,
"waste_basket" : 177,
"attraction" : 178,
"viewpoint" : 179,
"bicycle" : 180,
"church" : 181,
"shelter" : 182,
"drinking_water" : 183,
"marsh" : 184,
"picnic_site" : 185,
"hairdresser" : 186,
"bridleway" : 187,
"retaining_wall" : 188,
"buffer_stop" : 189,
"nature_reserve" : 190,
"village_green" : 191,
"university" : 192,
"1" : 193,
"bar" : 194,
"townhall" : 195,
"mini_roundabout" : 196,
"camp_site" : 197,
"aerodrome" : 198,
"stile" : 199,
"9" : 200,
"car_repair" : 201,
"parking_space" : 202,
"library" : 203,
"pipeline" : 204,
"true" : 205,
"cycle_barrier" : 206,
"4" : 207,
"museum" : 208,
"spring" : 209,
"hunting_stand" : 210,
"disused" : 211,
"car" : 212,
"tram_stop" : 213,
"land" : 214,
"fountain" : 215,
"hiking" : 216,
"manufacture" : 217,
"vending_machine" : 218,
"kiosk" : 219,
"swamp" : 220,
"unknown" : 221,
"7" : 222,
"islet" : 223,
"shed" : 224,
"switch" : 225,
"rapids" : 226,
"office" : 227,
"bay" : 228,
"proposed" : 229,
"common" : 230,
"weir" : 231,
"grassland" : 232,
"customers" : 233,
"social_facility" : 234,
"hangar" : 235,
"doctors" : 236,
"stadium" : 237,
"give_way" : 238,
"greenhouse" : 239,
"guest_house" : 240,
"viaduct" : 241,
"doityourself" : 242,
"runway" : 243,
"bus_station" : 244,
"water_tower" : 245,
"golf_course" : 246,
"conservation" : 247,
"block" : 248,
"college" : 249,
"wastewater_plant" : 250,
"subway" : 251,
"halt" : 252,
"forestry" : 253,
"florist" : 254,
"butcher" : 255}
def getValues():
return vals
| vals = {'yes': 0, 'residential': 1, 'service': 2, 'unclassified': 3, 'stream': 4, 'track': 5, 'water': 6, 'footway': 7, 'tertiary': 8, 'private': 9, 'tree': 10, 'path': 11, 'forest': 12, 'secondary': 13, 'house': 14, 'no': 15, 'asphalt': 16, 'wood': 17, 'grass': 18, 'paved': 19, 'primary': 20, 'unpaved': 21, 'bus_stop': 22, 'parking': 23, 'parking_aisle': 24, 'rail': 25, 'driveway': 26, '8': 27, 'administrative': 28, 'locality': 29, 'turning_circle': 30, 'crossing': 31, 'village': 32, 'fence': 33, 'grade2': 34, 'coastline': 35, 'grade3': 36, 'farmland': 37, 'hamlet': 38, 'hut': 39, 'meadow': 40, 'wetland': 41, 'cycleway': 42, 'river': 43, 'school': 44, 'trunk': 45, 'gravel': 46, 'place_of_worship': 47, 'farm': 48, 'grade1': 49, 'traffic_signals': 50, 'wall': 51, 'garage': 52, 'gate': 53, 'motorway': 54, 'living_street': 55, 'pitch': 56, 'grade4': 57, 'industrial': 58, 'road': 59, 'ground': 60, 'scrub': 61, 'motorway_link': 62, 'steps': 63, 'ditch': 64, 'swimming_pool': 65, 'grade5': 66, 'park': 67, 'apartments': 68, 'restaurant': 69, 'designated': 70, 'bench': 71, 'survey_point': 72, 'pedestrian': 73, 'hedge': 74, 'reservoir': 75, 'riverbank': 76, 'alley': 77, 'farmyard': 78, 'peak': 79, 'level_crossing': 80, 'roof': 81, 'dirt': 82, 'drain': 83, 'garages': 84, 'entrance': 85, 'street_lamp': 86, 'deciduous': 87, 'fuel': 88, 'trunk_link': 89, 'information': 90, 'playground': 91, 'supermarket': 92, 'primary_link': 93, 'concrete': 94, 'mixed': 95, 'permissive': 96, 'orchard': 97, 'grave_yard': 98, 'canal': 99, 'garden': 100, 'spur': 101, 'paving_stones': 102, 'rock': 103, 'bollard': 104, 'convenience': 105, 'cemetery': 106, 'post_box': 107, 'commercial': 108, 'pier': 109, 'bank': 110, 'hotel': 111, 'cliff': 112, 'retail': 113, 'construction': 114, '-1': 115, 'fast_food': 116, 'coniferous': 117, 'cafe': 118, '6': 119, 'kindergarten': 120, 'tower': 121, 'hospital': 122, 'yard': 123, 'sand': 124, 'public_building': 125, 'cobblestone': 126, 'destination': 127, 'island': 128, 'abandoned': 129, 'vineyard': 130, 'recycling': 131, 'agricultural': 132, 'isolated_dwelling': 133, 'pharmacy': 134, 'post_office': 135, 'motorway_junction': 136, 'pub': 137, 'allotments': 138, 'dam': 139, 'secondary_link': 140, 'lift_gate': 141, 'siding': 142, 'stop': 143, 'main': 144, 'farm_auxiliary': 145, 'quarry': 146, '10': 147, 'station': 148, 'platform': 149, 'taxiway': 150, 'limited': 151, 'sports_centre': 152, 'cutline': 153, 'detached': 154, 'storage_tank': 155, 'basin': 156, 'bicycle_parking': 157, 'telephone': 158, 'terrace': 159, 'town': 160, 'suburb': 161, 'bus': 162, 'compacted': 163, 'toilets': 164, 'heath': 165, 'works': 166, 'tram': 167, 'beach': 168, 'culvert': 169, 'fire_station': 170, 'recreation_ground': 171, 'bakery': 172, 'police': 173, 'atm': 174, 'clothes': 175, 'tertiary_link': 176, 'waste_basket': 177, 'attraction': 178, 'viewpoint': 179, 'bicycle': 180, 'church': 181, 'shelter': 182, 'drinking_water': 183, 'marsh': 184, 'picnic_site': 185, 'hairdresser': 186, 'bridleway': 187, 'retaining_wall': 188, 'buffer_stop': 189, 'nature_reserve': 190, 'village_green': 191, 'university': 192, '1': 193, 'bar': 194, 'townhall': 195, 'mini_roundabout': 196, 'camp_site': 197, 'aerodrome': 198, 'stile': 199, '9': 200, 'car_repair': 201, 'parking_space': 202, 'library': 203, 'pipeline': 204, 'true': 205, 'cycle_barrier': 206, '4': 207, 'museum': 208, 'spring': 209, 'hunting_stand': 210, 'disused': 211, 'car': 212, 'tram_stop': 213, 'land': 214, 'fountain': 215, 'hiking': 216, 'manufacture': 217, 'vending_machine': 218, 'kiosk': 219, 'swamp': 220, 'unknown': 221, '7': 222, 'islet': 223, 'shed': 224, 'switch': 225, 'rapids': 226, 'office': 227, 'bay': 228, 'proposed': 229, 'common': 230, 'weir': 231, 'grassland': 232, 'customers': 233, 'social_facility': 234, 'hangar': 235, 'doctors': 236, 'stadium': 237, 'give_way': 238, 'greenhouse': 239, 'guest_house': 240, 'viaduct': 241, 'doityourself': 242, 'runway': 243, 'bus_station': 244, 'water_tower': 245, 'golf_course': 246, 'conservation': 247, 'block': 248, 'college': 249, 'wastewater_plant': 250, 'subway': 251, 'halt': 252, 'forestry': 253, 'florist': 254, 'butcher': 255}
def get_values():
return vals |
def write_file(filess, T):
f = open(filess, "w")
for o in T:
f.write("[\n")
for l in o:
f.write(str(l)+"\n")
f.write("]\n")
f.close()
def save_hidden_weight(nb_hidden, hiddenw):
for i in range(nb_hidden):
write_file("save/base_nn_hid_" + str(i+1) + "w.nn", hiddenw[i])
def load_hiddenw(filess, hiddenw):
f = open(filess, "r")
s = f.read().splitlines()
h = 0
for o in s:
#print(o)
if o == "[":
h = []
elif o == "]":
hiddenw.append(h)
else:
h.append(float(o))
def load_hidden_weight(hiddenw, nb_hidden):
for i in range(nb_hidden):
hiddenw.append([])
load_hiddenw("save/base_nn_hid_" + str(i+1) + "w.nn", hiddenw[i])
def load_hidden_weight_v(hiddenw, nb_hidden):
for i in range(nb_hidden):
hiddenw.append([])
load_hiddenw("valid/NN/base_nn_hid_" + str(i+1) + "w.nn", hiddenw[i])
def display_hidden_weight(hiddenw, nb_hidden):
for i in range(nb_hidden):
for j in hiddenw[i]:
print("------------------------------------")
I = 0
for k in j:
print(k)
I+=1
if I > 3:
break
def write_fileb(filess, T):
f = open(filess, "w")
for o in T:
f.write(str(o)+"\n")
f.close()
def save_hidden_bias(nb_hidden, hiddenb):
for i in range(nb_hidden):
write_fileb("save/base_nn_hid_" + str(i+1) + "b.nn", hiddenb[i])
def load_hiddenb(filess, hiddenb):
f = open(filess, "r")
s = f.read().splitlines()
for o in s:
hiddenb.append(float(o))
def load_hidden_bias(hiddenb, nb_hidden):
for i in range(nb_hidden):
hiddenb.append([])
load_hiddenb("save/base_nn_hid_" + str(i+1) + "b.nn", hiddenb[i])
def load_hidden_bias_v(hiddenb, nb_hidden):
for i in range(nb_hidden):
hiddenb.append([])
load_hiddenb("valid/NN/base_nn_hid_" + str(i+1) + "b.nn", hiddenb[i])
def display_hidden_bias(hiddenb, nb_hidden):
for i in range(nb_hidden):
print("------------------------------------")
for j in hiddenb[i]:
print(j)
def save_output_weight(outputw):
write_file("save/base_nn_out_w.nn", outputw[0])
def load_output_weight(outputw):
outputw.append([])
load_hiddenw("save/base_nn_out_w.nn", outputw[0])
def load_output_weight_v(outputw):
outputw.append([])
load_hiddenw("valid/NN/base_nn_out_w.nn", outputw[0])
def save_output_bias(outputb):
write_fileb("save/base_nn_out_b.nn", outputb[0])
def load_output_bias(outputb):
outputb.append([])
load_hiddenb("save/base_nn_out_b.nn", outputb[0])
def load_output_bias_v(outputb):
outputb.append([])
load_hiddenb("valid/NN/base_nn_out_b.nn", outputb[0])
| def write_file(filess, T):
f = open(filess, 'w')
for o in T:
f.write('[\n')
for l in o:
f.write(str(l) + '\n')
f.write(']\n')
f.close()
def save_hidden_weight(nb_hidden, hiddenw):
for i in range(nb_hidden):
write_file('save/base_nn_hid_' + str(i + 1) + 'w.nn', hiddenw[i])
def load_hiddenw(filess, hiddenw):
f = open(filess, 'r')
s = f.read().splitlines()
h = 0
for o in s:
if o == '[':
h = []
elif o == ']':
hiddenw.append(h)
else:
h.append(float(o))
def load_hidden_weight(hiddenw, nb_hidden):
for i in range(nb_hidden):
hiddenw.append([])
load_hiddenw('save/base_nn_hid_' + str(i + 1) + 'w.nn', hiddenw[i])
def load_hidden_weight_v(hiddenw, nb_hidden):
for i in range(nb_hidden):
hiddenw.append([])
load_hiddenw('valid/NN/base_nn_hid_' + str(i + 1) + 'w.nn', hiddenw[i])
def display_hidden_weight(hiddenw, nb_hidden):
for i in range(nb_hidden):
for j in hiddenw[i]:
print('------------------------------------')
i = 0
for k in j:
print(k)
i += 1
if I > 3:
break
def write_fileb(filess, T):
f = open(filess, 'w')
for o in T:
f.write(str(o) + '\n')
f.close()
def save_hidden_bias(nb_hidden, hiddenb):
for i in range(nb_hidden):
write_fileb('save/base_nn_hid_' + str(i + 1) + 'b.nn', hiddenb[i])
def load_hiddenb(filess, hiddenb):
f = open(filess, 'r')
s = f.read().splitlines()
for o in s:
hiddenb.append(float(o))
def load_hidden_bias(hiddenb, nb_hidden):
for i in range(nb_hidden):
hiddenb.append([])
load_hiddenb('save/base_nn_hid_' + str(i + 1) + 'b.nn', hiddenb[i])
def load_hidden_bias_v(hiddenb, nb_hidden):
for i in range(nb_hidden):
hiddenb.append([])
load_hiddenb('valid/NN/base_nn_hid_' + str(i + 1) + 'b.nn', hiddenb[i])
def display_hidden_bias(hiddenb, nb_hidden):
for i in range(nb_hidden):
print('------------------------------------')
for j in hiddenb[i]:
print(j)
def save_output_weight(outputw):
write_file('save/base_nn_out_w.nn', outputw[0])
def load_output_weight(outputw):
outputw.append([])
load_hiddenw('save/base_nn_out_w.nn', outputw[0])
def load_output_weight_v(outputw):
outputw.append([])
load_hiddenw('valid/NN/base_nn_out_w.nn', outputw[0])
def save_output_bias(outputb):
write_fileb('save/base_nn_out_b.nn', outputb[0])
def load_output_bias(outputb):
outputb.append([])
load_hiddenb('save/base_nn_out_b.nn', outputb[0])
def load_output_bias_v(outputb):
outputb.append([])
load_hiddenb('valid/NN/base_nn_out_b.nn', outputb[0]) |
class Config(object):
embedding_size = 300
n_layers = 1
hidden_size = 128
drop_prob = 0.2 | class Config(object):
embedding_size = 300
n_layers = 1
hidden_size = 128
drop_prob = 0.2 |
begin_unit
comment|'#!/usr/bin/env python'
nl|'\n'
nl|'\n'
comment|'# Copyright 2013 OpenStack Foundation'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License");'
nl|'\n'
comment|'# you may not use this file except in compliance with the License.'
nl|'\n'
comment|'# You may obtain a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'# distributed under the License is distributed on an "AS IS" BASIS,'
nl|'\n'
comment|'# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
nl|'\n'
comment|'# See the License for the specific language governing permissions and'
nl|'\n'
comment|'# limitations under the License.'
nl|'\n'
string|'"""\nScript to cleanup old XenServer /var/lock/sm locks.\n\nXenServer 5.6 and 6.0 do not appear to always cleanup locks when using a\nFileSR. ext3 has a limit of 32K inode links, so when we have 32K-2 (31998)\nlocks laying around, builds will begin to fail because we can\'t create any\nadditional locks. This cleanup script is something we can run periodically as\na stop-gap measure until this is fixed upstream.\n\nThis script should be run on the dom0 of the affected machine.\n"""'
newline|'\n'
name|'import'
name|'errno'
newline|'\n'
name|'import'
name|'optparse'
newline|'\n'
name|'import'
name|'os'
newline|'\n'
name|'import'
name|'sys'
newline|'\n'
name|'import'
name|'time'
newline|'\n'
nl|'\n'
DECL|variable|BASE
name|'BASE'
op|'='
string|"'/var/lock/sm'"
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|_get_age_days
name|'def'
name|'_get_age_days'
op|'('
name|'secs'
op|')'
op|':'
newline|'\n'
indent|' '
name|'return'
name|'float'
op|'('
name|'time'
op|'.'
name|'time'
op|'('
op|')'
op|'-'
name|'secs'
op|')'
op|'/'
number|'86400'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|_parse_args
dedent|''
name|'def'
name|'_parse_args'
op|'('
op|')'
op|':'
newline|'\n'
indent|' '
name|'parser'
op|'='
name|'optparse'
op|'.'
name|'OptionParser'
op|'('
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_option'
op|'('
string|'"-d"'
op|','
string|'"--dry-run"'
op|','
nl|'\n'
name|'action'
op|'='
string|'"store_true"'
op|','
name|'dest'
op|'='
string|'"dry_run"'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|'"don\'t actually remove locks"'
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_option'
op|'('
string|'"-l"'
op|','
string|'"--limit"'
op|','
nl|'\n'
name|'action'
op|'='
string|'"store"'
op|','
name|'type'
op|'='
string|"'int'"
op|','
name|'dest'
op|'='
string|'"limit"'
op|','
nl|'\n'
name|'default'
op|'='
name|'sys'
op|'.'
name|'maxint'
op|','
nl|'\n'
name|'help'
op|'='
string|'"max number of locks to delete (default: no limit)"'
op|')'
newline|'\n'
name|'parser'
op|'.'
name|'add_option'
op|'('
string|'"-v"'
op|','
string|'"--verbose"'
op|','
nl|'\n'
name|'action'
op|'='
string|'"store_true"'
op|','
name|'dest'
op|'='
string|'"verbose"'
op|','
name|'default'
op|'='
name|'False'
op|','
nl|'\n'
name|'help'
op|'='
string|'"don\'t print status messages to stdout"'
op|')'
newline|'\n'
nl|'\n'
name|'options'
op|','
name|'args'
op|'='
name|'parser'
op|'.'
name|'parse_args'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'try'
op|':'
newline|'\n'
indent|' '
name|'days_old'
op|'='
name|'int'
op|'('
name|'args'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
dedent|''
name|'except'
op|'('
name|'IndexError'
op|','
name|'ValueError'
op|')'
op|':'
newline|'\n'
indent|' '
name|'parser'
op|'.'
name|'print_help'
op|'('
op|')'
newline|'\n'
name|'sys'
op|'.'
name|'exit'
op|'('
number|'1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'return'
name|'options'
op|','
name|'days_old'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|main
dedent|''
name|'def'
name|'main'
op|'('
op|')'
op|':'
newline|'\n'
indent|' '
name|'options'
op|','
name|'days_old'
op|'='
name|'_parse_args'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'if'
name|'not'
name|'os'
op|'.'
name|'path'
op|'.'
name|'exists'
op|'('
name|'BASE'
op|')'
op|':'
newline|'\n'
indent|' '
name|'print'
op|'>>'
name|'sys'
op|'.'
name|'stderr'
op|','
string|'"error: \'%s\' doesn\'t exist. Make sure you\'re"'
string|'" running this on the dom0."'
op|'%'
name|'BASE'
newline|'\n'
name|'sys'
op|'.'
name|'exit'
op|'('
number|'1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'lockpaths_removed'
op|'='
number|'0'
newline|'\n'
name|'nspaths_removed'
op|'='
number|'0'
newline|'\n'
nl|'\n'
name|'for'
name|'nsname'
name|'in'
name|'os'
op|'.'
name|'listdir'
op|'('
name|'BASE'
op|')'
op|'['
op|':'
name|'options'
op|'.'
name|'limit'
op|']'
op|':'
newline|'\n'
indent|' '
name|'nspath'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
name|'BASE'
op|','
name|'nsname'
op|')'
newline|'\n'
nl|'\n'
name|'if'
name|'not'
name|'os'
op|'.'
name|'path'
op|'.'
name|'isdir'
op|'('
name|'nspath'
op|')'
op|':'
newline|'\n'
indent|' '
name|'continue'
newline|'\n'
nl|'\n'
comment|'# Remove old lockfiles'
nl|'\n'
dedent|''
name|'removed'
op|'='
number|'0'
newline|'\n'
name|'locknames'
op|'='
name|'os'
op|'.'
name|'listdir'
op|'('
name|'nspath'
op|')'
newline|'\n'
name|'for'
name|'lockname'
name|'in'
name|'locknames'
op|':'
newline|'\n'
indent|' '
name|'lockpath'
op|'='
name|'os'
op|'.'
name|'path'
op|'.'
name|'join'
op|'('
name|'nspath'
op|','
name|'lockname'
op|')'
newline|'\n'
name|'lock_age_days'
op|'='
name|'_get_age_days'
op|'('
name|'os'
op|'.'
name|'path'
op|'.'
name|'getmtime'
op|'('
name|'lockpath'
op|')'
op|')'
newline|'\n'
name|'if'
name|'lock_age_days'
op|'>'
name|'days_old'
op|':'
newline|'\n'
indent|' '
name|'lockpaths_removed'
op|'+='
number|'1'
newline|'\n'
name|'removed'
op|'+='
number|'1'
newline|'\n'
nl|'\n'
name|'if'
name|'options'
op|'.'
name|'verbose'
op|':'
newline|'\n'
indent|' '
name|'print'
string|"'Removing old lock: %03d %s'"
op|'%'
op|'('
name|'lock_age_days'
op|','
nl|'\n'
name|'lockpath'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'if'
name|'not'
name|'options'
op|'.'
name|'dry_run'
op|':'
newline|'\n'
indent|' '
name|'os'
op|'.'
name|'unlink'
op|'('
name|'lockpath'
op|')'
newline|'\n'
nl|'\n'
comment|'# Remove empty namespace paths'
nl|'\n'
dedent|''
dedent|''
dedent|''
name|'if'
name|'len'
op|'('
name|'locknames'
op|')'
op|'=='
name|'removed'
op|':'
newline|'\n'
indent|' '
name|'nspaths_removed'
op|'+='
number|'1'
newline|'\n'
nl|'\n'
name|'if'
name|'options'
op|'.'
name|'verbose'
op|':'
newline|'\n'
indent|' '
name|'print'
string|"'Removing empty namespace: %s'"
op|'%'
name|'nspath'
newline|'\n'
nl|'\n'
dedent|''
name|'if'
name|'not'
name|'options'
op|'.'
name|'dry_run'
op|':'
newline|'\n'
indent|' '
name|'try'
op|':'
newline|'\n'
indent|' '
name|'os'
op|'.'
name|'rmdir'
op|'('
name|'nspath'
op|')'
newline|'\n'
dedent|''
name|'except'
name|'OSError'
op|','
name|'e'
op|':'
newline|'\n'
indent|' '
name|'if'
name|'e'
op|'.'
name|'errno'
op|'=='
name|'errno'
op|'.'
name|'ENOTEMPTY'
op|':'
newline|'\n'
indent|' '
name|'print'
op|'>>'
name|'sys'
op|'.'
name|'stderr'
op|','
string|'"warning: directory \'%s\'"'
string|'" not empty"'
op|'%'
name|'nspath'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|' '
name|'raise'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
dedent|''
dedent|''
dedent|''
name|'if'
name|'options'
op|'.'
name|'dry_run'
op|':'
newline|'\n'
indent|' '
name|'print'
string|'"** Dry Run **"'
newline|'\n'
nl|'\n'
dedent|''
name|'print'
string|'"Total locks removed: "'
op|','
name|'lockpaths_removed'
newline|'\n'
name|'print'
string|'"Total namespaces removed: "'
op|','
name|'nspaths_removed'
newline|'\n'
nl|'\n'
nl|'\n'
dedent|''
name|'if'
name|'__name__'
op|'=='
string|"'__main__'"
op|':'
newline|'\n'
indent|' '
name|'main'
op|'('
op|')'
newline|'\n'
dedent|''
endmarker|''
end_unit
| begin_unit
comment | '#!/usr/bin/env python'
nl | '\n'
nl | '\n'
comment | '# Copyright 2013 OpenStack Foundation'
nl | '\n'
comment | '#'
nl | '\n'
comment | '# Licensed under the Apache License, Version 2.0 (the "License");'
nl | '\n'
comment | '# you may not use this file except in compliance with the License.'
nl | '\n'
comment | '# You may obtain a copy of the License at'
nl | '\n'
comment | '#'
nl | '\n'
comment | '# http://www.apache.org/licenses/LICENSE-2.0'
nl | '\n'
comment | '#'
nl | '\n'
comment | '# Unless required by applicable law or agreed to in writing, software'
nl | '\n'
comment | '# distributed under the License is distributed on an "AS IS" BASIS,'
nl | '\n'
comment | '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
nl | '\n'
comment | '# See the License for the specific language governing permissions and'
nl | '\n'
comment | '# limitations under the License.'
nl | '\n'
string | '"""\nScript to cleanup old XenServer /var/lock/sm locks.\n\nXenServer 5.6 and 6.0 do not appear to always cleanup locks when using a\nFileSR. ext3 has a limit of 32K inode links, so when we have 32K-2 (31998)\nlocks laying around, builds will begin to fail because we can\'t create any\nadditional locks. This cleanup script is something we can run periodically as\na stop-gap measure until this is fixed upstream.\n\nThis script should be run on the dom0 of the affected machine.\n"""'
newline | '\n'
name | 'import'
name | 'errno'
newline | '\n'
name | 'import'
name | 'optparse'
newline | '\n'
name | 'import'
name | 'os'
newline | '\n'
name | 'import'
name | 'sys'
newline | '\n'
name | 'import'
name | 'time'
newline | '\n'
nl | '\n'
DECL | variable | BASE
name | 'BASE'
op | '='
string | "'/var/lock/sm'"
newline | '\n'
nl | '\n'
nl | '\n'
DECL | function | _get_age_days
name | 'def'
name | '_get_age_days'
op | '('
name | 'secs'
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'return'
name | 'float'
op | '('
name | 'time'
op | '.'
name | 'time'
op | '('
op | ')'
op | '-'
name | 'secs'
op | ')'
op | '/'
number | '86400'
newline | '\n'
nl | '\n'
nl | '\n'
DECL | function | _parse_args
dedent | ''
name | 'def'
name | '_parse_args'
op | '('
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'parser'
op | '='
name | 'optparse'
op | '.'
name | 'OptionParser'
op | '('
op | ')'
newline | '\n'
name | 'parser'
op | '.'
name | 'add_option'
op | '('
string | '"-d"'
op | ','
string | '"--dry-run"'
op | ','
nl | '\n'
name | 'action'
op | '='
string | '"store_true"'
op | ','
name | 'dest'
op | '='
string | '"dry_run"'
op | ','
name | 'default'
op | '='
name | 'False'
op | ','
nl | '\n'
name | 'help'
op | '='
string | '"don\'t actually remove locks"'
op | ')'
newline | '\n'
name | 'parser'
op | '.'
name | 'add_option'
op | '('
string | '"-l"'
op | ','
string | '"--limit"'
op | ','
nl | '\n'
name | 'action'
op | '='
string | '"store"'
op | ','
name | 'type'
op | '='
string | "'int'"
op | ','
name | 'dest'
op | '='
string | '"limit"'
op | ','
nl | '\n'
name | 'default'
op | '='
name | 'sys'
op | '.'
name | 'maxint'
op | ','
nl | '\n'
name | 'help'
op | '='
string | '"max number of locks to delete (default: no limit)"'
op | ')'
newline | '\n'
name | 'parser'
op | '.'
name | 'add_option'
op | '('
string | '"-v"'
op | ','
string | '"--verbose"'
op | ','
nl | '\n'
name | 'action'
op | '='
string | '"store_true"'
op | ','
name | 'dest'
op | '='
string | '"verbose"'
op | ','
name | 'default'
op | '='
name | 'False'
op | ','
nl | '\n'
name | 'help'
op | '='
string | '"don\'t print status messages to stdout"'
op | ')'
newline | '\n'
nl | '\n'
name | 'options'
op | ','
name | 'args'
op | '='
name | 'parser'
op | '.'
name | 'parse_args'
op | '('
op | ')'
newline | '\n'
nl | '\n'
name | 'try'
op | ':'
newline | '\n'
indent | ' '
name | 'days_old'
op | '='
name | 'int'
op | '('
name | 'args'
op | '['
number | '0'
op | ']'
op | ')'
newline | '\n'
dedent | ''
name | 'except'
op | '('
name | 'IndexError'
op | ','
name | 'ValueError'
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'parser'
op | '.'
name | 'print_help'
op | '('
op | ')'
newline | '\n'
name | 'sys'
op | '.'
name | 'exit'
op | '('
number | '1'
op | ')'
newline | '\n'
nl | '\n'
dedent | ''
name | 'return'
name | 'options'
op | ','
name | 'days_old'
newline | '\n'
nl | '\n'
nl | '\n'
DECL | function | main
dedent | ''
name | 'def'
name | 'main'
op | '('
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'options'
op | ','
name | 'days_old'
op | '='
name | '_parse_args'
op | '('
op | ')'
newline | '\n'
nl | '\n'
name | 'if'
name | 'not'
name | 'os'
op | '.'
name | 'path'
op | '.'
name | 'exists'
op | '('
name | 'BASE'
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'print'
op | '>>'
name | 'sys'
op | '.'
name | 'stderr'
op | ','
string | '"error: \'%s\' doesn\'t exist. Make sure you\'re"'
string | '" running this on the dom0."'
op | '%'
name | 'BASE'
newline | '\n'
name | 'sys'
op | '.'
name | 'exit'
op | '('
number | '1'
op | ')'
newline | '\n'
nl | '\n'
dedent | ''
name | 'lockpaths_removed'
op | '='
number | '0'
newline | '\n'
name | 'nspaths_removed'
op | '='
number | '0'
newline | '\n'
nl | '\n'
name | 'for'
name | 'nsname'
name | 'in'
name | 'os'
op | '.'
name | 'listdir'
op | '('
name | 'BASE'
op | ')'
op | '['
op | ':'
name | 'options'
op | '.'
name | 'limit'
op | ']'
op | ':'
newline | '\n'
indent | ' '
name | 'nspath'
op | '='
name | 'os'
op | '.'
name | 'path'
op | '.'
name | 'join'
op | '('
name | 'BASE'
op | ','
name | 'nsname'
op | ')'
newline | '\n'
nl | '\n'
name | 'if'
name | 'not'
name | 'os'
op | '.'
name | 'path'
op | '.'
name | 'isdir'
op | '('
name | 'nspath'
op | ')'
op | ':'
newline | '\n'
indent | ' '
name | 'continue'
newline | '\n'
nl | '\n'
comment | '# Remove old lockfiles'
nl | '\n'
dedent | ''
name | 'removed'
op | '='
number | '0'
newline | '\n'
name | 'locknames'
op | '='
name | 'os'
op | '.'
name | 'listdir'
op | '('
name | 'nspath'
op | ')'
newline | '\n'
name | 'for'
name | 'lockname'
name | 'in'
name | 'locknames'
op | ':'
newline | '\n'
indent | ' '
name | 'lockpath'
op | '='
name | 'os'
op | '.'
name | 'path'
op | '.'
name | 'join'
op | '('
name | 'nspath'
op | ','
name | 'lockname'
op | ')'
newline | '\n'
name | 'lock_age_days'
op | '='
name | '_get_age_days'
op | '('
name | 'os'
op | '.'
name | 'path'
op | '.'
name | 'getmtime'
op | '('
name | 'lockpath'
op | ')'
op | ')'
newline | '\n'
name | 'if'
name | 'lock_age_days'
op | '>'
name | 'days_old'
op | ':'
newline | '\n'
indent | ' '
name | 'lockpaths_removed'
op | '+='
number | '1'
newline | '\n'
name | 'removed'
op | '+='
number | '1'
newline | '\n'
nl | '\n'
name | 'if'
name | 'options'
op | '.'
name | 'verbose'
op | ':'
newline | '\n'
indent | ' '
name | 'print'
string | "'Removing old lock: %03d %s'"
op | '%'
op | '('
name | 'lock_age_days'
op | ','
nl | '\n'
name | 'lockpath'
op | ')'
newline | '\n'
nl | '\n'
dedent | ''
name | 'if'
name | 'not'
name | 'options'
op | '.'
name | 'dry_run'
op | ':'
newline | '\n'
indent | ' '
name | 'os'
op | '.'
name | 'unlink'
op | '('
name | 'lockpath'
op | ')'
newline | '\n'
nl | '\n'
comment | '# Remove empty namespace paths'
nl | '\n'
dedent | ''
dedent | ''
dedent | ''
name | 'if'
name | 'len'
op | '('
name | 'locknames'
op | ')'
op | '=='
name | 'removed'
op | ':'
newline | '\n'
indent | ' '
name | 'nspaths_removed'
op | '+='
number | '1'
newline | '\n'
nl | '\n'
name | 'if'
name | 'options'
op | '.'
name | 'verbose'
op | ':'
newline | '\n'
indent | ' '
name | 'print'
string | "'Removing empty namespace: %s'"
op | '%'
name | 'nspath'
newline | '\n'
nl | '\n'
dedent | ''
name | 'if'
name | 'not'
name | 'options'
op | '.'
name | 'dry_run'
op | ':'
newline | '\n'
indent | ' '
name | 'try'
op | ':'
newline | '\n'
indent | ' '
name | 'os'
op | '.'
name | 'rmdir'
op | '('
name | 'nspath'
op | ')'
newline | '\n'
dedent | ''
name | 'except'
name | 'OSError'
op | ','
name | 'e'
op | ':'
newline | '\n'
indent | ' '
name | 'if'
name | 'e'
op | '.'
name | 'errno'
op | '=='
name | 'errno'
op | '.'
name | 'ENOTEMPTY'
op | ':'
newline | '\n'
indent | ' '
name | 'print'
op | '>>'
name | 'sys'
op | '.'
name | 'stderr'
op | ','
string | '"warning: directory \'%s\'"'
string | '" not empty"'
op | '%'
name | 'nspath'
newline | '\n'
dedent | ''
name | 'else'
op | ':'
newline | '\n'
indent | ' '
name | 'raise'
newline | '\n'
nl | '\n'
dedent | ''
dedent | ''
dedent | ''
dedent | ''
dedent | ''
name | 'if'
name | 'options'
op | '.'
name | 'dry_run'
op | ':'
newline | '\n'
indent | ' '
name | 'print'
string | '"** Dry Run **"'
newline | '\n'
nl | '\n'
dedent | ''
name | 'print'
string | '"Total locks removed: "'
op | ','
name | 'lockpaths_removed'
newline | '\n'
name | 'print'
string | '"Total namespaces removed: "'
op | ','
name | 'nspaths_removed'
newline | '\n'
nl | '\n'
nl | '\n'
dedent | ''
name | 'if'
name | '__name__'
op | '=='
string | "'__main__'"
op | ':'
newline | '\n'
indent | ' '
name | 'main'
op | '('
op | ')'
newline | '\n'
dedent | ''
endmarker | ''
end_unit |
class BrainfuckException(Exception):
pass
class BLexer:
""" Static class encapsulating functionality for lexing Brainfuck programs. """
symbols = [
'>', '<', '+', '-',
'.', ',', '[', ']'
]
@staticmethod
def lex(code):
""" Return a generator for tokens in some Brainfuck code. """
# The syntax of Brainfuck is so simple that nothing is really gained from converting
# symbols to some sort of Token object. Just ignore everything that isn't in Brainfuck's
# syntax.
return (char for char in code if char in BLexer.symbols)
class BrainfuckMachine:
""" Class encapsulating the core operations of a brainfuck machine. Namely,
- Move pointer left,
- Move pointer right,
- Increment cell under pointer,
- Decrement cell under pointer,
- Output value of cell under pointer,
- Input value to cell under pointer.
"""
def __init__(self, cells=256, in_func=input, out_func=chr):
self.cells = [0] * cells
self.ptr = 0
self.in_func = in_func
self.out_func = out_func
self.looppos = []
self.out_buffer = []
def right(self):
if self.ptr < len(self.cells)-1:
self.ptr += 1
def left(self):
if self.ptr > 0:
self.ptr -= 1
def incr(self):
self.cells[self.ptr] += 1
def decr(self):
self.cells[self.ptr] -= 1
def value(self):
""" Return the value of the cell under the pointer. """
return self.cells[self.ptr]
def outf(self):
return self.out_func(self.cells[self.ptr])
def inf(self):
self.cells[self.ptr] = self.in_func()
class BInterpreter:
""" Class encapsulating interpretation functionality for brainfuck code. """
def __init__(self, machine=None):
if machine:
self.machine = machine
else:
self.machine = BrainfuckMachine()
def interpret_code(self, code):
""" Interpret each character in a list or string of brainfuck tokens. """
# Iterate through every character in the code. Use indexing so that we can
# jump as necessary for square bracket loops. To identify matching brackets for forward
# jumps, move forward a position at a time, keeping track of the nesting level (starts at 1). When a
# open bracket ([) is encountered, increment the nesting level, and when a close bracket
# (]) is found, decrement it. When nesting level reaches 0, the matching bracket has been found.
# For finding the correct bracket for a backwards jump, do the same thing but with
# backwards iteration and swap when you increment and decrement.
pos = 0
while pos < len(code):
if code[pos] == '[':
if self.machine.value() == 0:
nest = 1
while nest != 0:
pos += 1
if code[pos] == '[':
nest += 1
elif code[pos] == ']':
nest -= 1
pos += 1
else:
pos += 1
elif code[pos] == ']':
if self.machine.value() != 0:
nest = 1
while nest != 0:
pos -= 1
if code[pos] == ']':
nest += 1
elif code[pos] == '[':
nest -= 1
pos += 1
else:
pos += 1
else:
self.interpret_one(code[pos])
pos += 1
def interpret_one(self, char):
""" Perform the appropriate operation for a single brainfuck character. """
if char == '>':
self.machine.right()
elif char == '<':
self.machine.left()
elif char == '+':
self.machine.incr()
elif char == '-':
self.machine.decr()
elif char == '.':
# TODO output checks
print(self.machine.outf(), end='')
elif char == ',':
# TODO input checks
self.machine.inf()
if __name__ == '__main__':
bfm = BrainfuckMachine(cells=8, out_func=chr)
bi = BInterpreter(bfm)
f = open('helloworld', 'r').read()
code = list(BLexer.lex(f))
bi.interpret_code(code) | class Brainfuckexception(Exception):
pass
class Blexer:
""" Static class encapsulating functionality for lexing Brainfuck programs. """
symbols = ['>', '<', '+', '-', '.', ',', '[', ']']
@staticmethod
def lex(code):
""" Return a generator for tokens in some Brainfuck code. """
return (char for char in code if char in BLexer.symbols)
class Brainfuckmachine:
""" Class encapsulating the core operations of a brainfuck machine. Namely,
- Move pointer left,
- Move pointer right,
- Increment cell under pointer,
- Decrement cell under pointer,
- Output value of cell under pointer,
- Input value to cell under pointer.
"""
def __init__(self, cells=256, in_func=input, out_func=chr):
self.cells = [0] * cells
self.ptr = 0
self.in_func = in_func
self.out_func = out_func
self.looppos = []
self.out_buffer = []
def right(self):
if self.ptr < len(self.cells) - 1:
self.ptr += 1
def left(self):
if self.ptr > 0:
self.ptr -= 1
def incr(self):
self.cells[self.ptr] += 1
def decr(self):
self.cells[self.ptr] -= 1
def value(self):
""" Return the value of the cell under the pointer. """
return self.cells[self.ptr]
def outf(self):
return self.out_func(self.cells[self.ptr])
def inf(self):
self.cells[self.ptr] = self.in_func()
class Binterpreter:
""" Class encapsulating interpretation functionality for brainfuck code. """
def __init__(self, machine=None):
if machine:
self.machine = machine
else:
self.machine = brainfuck_machine()
def interpret_code(self, code):
""" Interpret each character in a list or string of brainfuck tokens. """
pos = 0
while pos < len(code):
if code[pos] == '[':
if self.machine.value() == 0:
nest = 1
while nest != 0:
pos += 1
if code[pos] == '[':
nest += 1
elif code[pos] == ']':
nest -= 1
pos += 1
else:
pos += 1
elif code[pos] == ']':
if self.machine.value() != 0:
nest = 1
while nest != 0:
pos -= 1
if code[pos] == ']':
nest += 1
elif code[pos] == '[':
nest -= 1
pos += 1
else:
pos += 1
else:
self.interpret_one(code[pos])
pos += 1
def interpret_one(self, char):
""" Perform the appropriate operation for a single brainfuck character. """
if char == '>':
self.machine.right()
elif char == '<':
self.machine.left()
elif char == '+':
self.machine.incr()
elif char == '-':
self.machine.decr()
elif char == '.':
print(self.machine.outf(), end='')
elif char == ',':
self.machine.inf()
if __name__ == '__main__':
bfm = brainfuck_machine(cells=8, out_func=chr)
bi = b_interpreter(bfm)
f = open('helloworld', 'r').read()
code = list(BLexer.lex(f))
bi.interpret_code(code) |
load("@fbcode_macros//build_defs:config.bzl", "config")
load("@fbcode_macros//build_defs/config:read_configs.bzl", "read_int")
load("@fbcode_macros//build_defs:core_tools.bzl", "core_tools")
def _create_build_info(
build_mode,
buck_package,
name,
rule_type,
platform,
epochtime=0,
host="",
package_name="",
package_version="",
package_release="",
path="",
revision="",
revision_epochtime=0,
time="",
time_iso8601="",
upstream_revision="",
upstream_revision_epochtime=0,
user="",
):
return struct(
build_mode=build_mode,
rule="fbcode:" + buck_package + ":" + name,
platform=platform,
rule_type=rule_type,
epochtime=epochtime,
host=host,
package_name=package_name,
package_version=package_version,
package_release=package_release,
path=path,
revision=revision,
revision_epochtime=revision_epochtime,
time=time,
time_iso8601=time_iso8601,
upstream_revision=upstream_revision,
upstream_revision_epochtime=upstream_revision_epochtime,
user=user,
)
def _get_build_info(package_name, name, rule_type, platform):
"""
Gets a build_info struct from various configurations (or default values)
This struct has values passed in by the packaging system in order to
stamp things like the build epoch, platform, etc into the final binary.
This returns stable values by default so that non-release builds do not
affect rulekeys.
Args:
package_name: The name of the package that contains the build rule
that needs build info. No leading slashes
name: The name of the rule that needs build info
rule_type: The type of rule that is being built. This should be the
macro name, not the underlying rule type. (e.g. cpp_binary,
not cxx_binary)
platform: The platform that is being built for
"""
build_mode = config.get_build_mode()
if core_tools.is_core_tool(package_name,name):
return _create_build_info(
build_mode,
package_name,
name,
rule_type,
platform,
)
else:
return _create_build_info(
build_mode,
package_name,
name,
rule_type,
platform,
epochtime=read_int("build_info", "epochtime", 0),
host=native.read_config("build_info", "host", ""),
package_name=native.read_config("build_info", "package_name", ""),
package_version=native.read_config("build_info", "package_version", ""),
package_release=native.read_config("build_info", "package_release", ""),
path=native.read_config("build_info", "path", ""),
revision=native.read_config("build_info", "revision", ""),
revision_epochtime=read_int("build_info", "revision_epochtime", 0),
time=native.read_config("build_info", "time", ""),
time_iso8601=native.read_config("build_info", "time_iso8601", ""),
upstream_revision=native.read_config("build_info", "upstream_revision", ""),
upstream_revision_epochtime=read_int("build_info", "upstream_revision_epochtime", 0),
user=native.read_config("build_info", "user", ""),
)
build_info = struct(
get_build_info = _get_build_info,
)
| load('@fbcode_macros//build_defs:config.bzl', 'config')
load('@fbcode_macros//build_defs/config:read_configs.bzl', 'read_int')
load('@fbcode_macros//build_defs:core_tools.bzl', 'core_tools')
def _create_build_info(build_mode, buck_package, name, rule_type, platform, epochtime=0, host='', package_name='', package_version='', package_release='', path='', revision='', revision_epochtime=0, time='', time_iso8601='', upstream_revision='', upstream_revision_epochtime=0, user=''):
return struct(build_mode=build_mode, rule='fbcode:' + buck_package + ':' + name, platform=platform, rule_type=rule_type, epochtime=epochtime, host=host, package_name=package_name, package_version=package_version, package_release=package_release, path=path, revision=revision, revision_epochtime=revision_epochtime, time=time, time_iso8601=time_iso8601, upstream_revision=upstream_revision, upstream_revision_epochtime=upstream_revision_epochtime, user=user)
def _get_build_info(package_name, name, rule_type, platform):
"""
Gets a build_info struct from various configurations (or default values)
This struct has values passed in by the packaging system in order to
stamp things like the build epoch, platform, etc into the final binary.
This returns stable values by default so that non-release builds do not
affect rulekeys.
Args:
package_name: The name of the package that contains the build rule
that needs build info. No leading slashes
name: The name of the rule that needs build info
rule_type: The type of rule that is being built. This should be the
macro name, not the underlying rule type. (e.g. cpp_binary,
not cxx_binary)
platform: The platform that is being built for
"""
build_mode = config.get_build_mode()
if core_tools.is_core_tool(package_name, name):
return _create_build_info(build_mode, package_name, name, rule_type, platform)
else:
return _create_build_info(build_mode, package_name, name, rule_type, platform, epochtime=read_int('build_info', 'epochtime', 0), host=native.read_config('build_info', 'host', ''), package_name=native.read_config('build_info', 'package_name', ''), package_version=native.read_config('build_info', 'package_version', ''), package_release=native.read_config('build_info', 'package_release', ''), path=native.read_config('build_info', 'path', ''), revision=native.read_config('build_info', 'revision', ''), revision_epochtime=read_int('build_info', 'revision_epochtime', 0), time=native.read_config('build_info', 'time', ''), time_iso8601=native.read_config('build_info', 'time_iso8601', ''), upstream_revision=native.read_config('build_info', 'upstream_revision', ''), upstream_revision_epochtime=read_int('build_info', 'upstream_revision_epochtime', 0), user=native.read_config('build_info', 'user', ''))
build_info = struct(get_build_info=_get_build_info) |
sm.setSpeakerID(1013000)
sm.sendNext("Ugh. This isn't going to work. I need something else. No plants. No meat. What, you have no idea? But you're the master, and you're older than me, too. You must know what'd be good for me!")
sm.setPlayerAsSpeaker()
sm.sendSay("#bBut I don't. It's not like age has anything to do with this...")
sm.setSpeakerID(1013000)
if sm.sendAskAccept("Since you're older, you must be more experienced in the world, too. Makes sense that you'd know more than me. Oh, fine. I'll ask someone who's even older than you, master!"):
if not sm.hasQuest(parentID):
sm.startQuest(parentID)
sm.setPlayerAsSpeaker()
sm.sendSayOkay("#b#b(You already asked Dad once, but you don't have any better ideas. Time to ask him again!)")
else:
sm.sendNext("No use trying to find an answer to this on my own. I'd better look for #bsomeone older and wiser than master#k!")
sm.dispose() | sm.setSpeakerID(1013000)
sm.sendNext("Ugh. This isn't going to work. I need something else. No plants. No meat. What, you have no idea? But you're the master, and you're older than me, too. You must know what'd be good for me!")
sm.setPlayerAsSpeaker()
sm.sendSay("#bBut I don't. It's not like age has anything to do with this...")
sm.setSpeakerID(1013000)
if sm.sendAskAccept("Since you're older, you must be more experienced in the world, too. Makes sense that you'd know more than me. Oh, fine. I'll ask someone who's even older than you, master!"):
if not sm.hasQuest(parentID):
sm.startQuest(parentID)
sm.setPlayerAsSpeaker()
sm.sendSayOkay("#b#b(You already asked Dad once, but you don't have any better ideas. Time to ask him again!)")
else:
sm.sendNext("No use trying to find an answer to this on my own. I'd better look for #bsomeone older and wiser than master#k!")
sm.dispose() |
class Solution:
def chooseandswap (self, A):
opt = 'a'
fir = A[0]
arr = [0]*26
for s in A :
arr[ord(s)-97] += 1
i = 0
while i < len(A) :
if opt > 'z' :
break
while opt < fir :
if opt in A :
ans = ""
for s in A :
if s == opt :
ans += fir
elif s == fir :
ans += opt
else :
ans += s
return ans
opt = chr(ord(opt) + 1)
opt = chr(ord(opt) + 1)
while i < len(A) and A[i] <= fir :
i += 1
if i < len(A) :
fir = A[i]
return A
if __name__ == '__main__':
ob = Solution()
t = int (input ())
for _ in range (t):
A = input()
ans = ob.chooseandswap(A)
print(ans)
| class Solution:
def chooseandswap(self, A):
opt = 'a'
fir = A[0]
arr = [0] * 26
for s in A:
arr[ord(s) - 97] += 1
i = 0
while i < len(A):
if opt > 'z':
break
while opt < fir:
if opt in A:
ans = ''
for s in A:
if s == opt:
ans += fir
elif s == fir:
ans += opt
else:
ans += s
return ans
opt = chr(ord(opt) + 1)
opt = chr(ord(opt) + 1)
while i < len(A) and A[i] <= fir:
i += 1
if i < len(A):
fir = A[i]
return A
if __name__ == '__main__':
ob = solution()
t = int(input())
for _ in range(t):
a = input()
ans = ob.chooseandswap(A)
print(ans) |
class AccountManager(object):
def __init__(self, balance = 0):
self.balance = balance
def getBalance(self):
return self.balance
def withdraw(self, value):
if self.balance >= value:
self.balance = self.balance - value
print('Successful Withdrawal.')
else:
print('Insufficient Funds')
def deposit(self, value):
self.balance = self.balance + value
print('Successful Deposit')
def income(self, rate):
self.balance = self.balance + self.balance*rate
class AccountCommon(AccountManager):
def __init__(self, balance = 0):
super(AccountCommon, self).__init__(balance=balance)
def getBalance(self):
return super().getBalance()
def deposit(self, value):
super().deposit(value)
def withdraw(self, value):
super().withdraw(value)
def income(self, rate):
super().income(rate)
def message(self):
print('Common account balance: %.2f' % self.getBalance())
class AccountSpetial(AccountManager):
def __init__(self, balance = 0):
super(AccountSpetial, self).__init__(balance=balance)
def getBalance(self):
return super().getBalance()
def deposit(self, value):
super().deposit(value)
def withdraw(self, value):
super().withdraw(value)
def message(self):
print('Common account balance: %.2f' % self.getBalance())
if __name__ == '__main__':
commonAccount = AccountCommon(500)
commonAccount.deposit(500)
commonAccount.withdraw(100)
commonAccount.income(0.005)
commonAccount.message()
print(' ------- ')
spetialAccount = AccountSpetial(1000)
spetialAccount.deposit(500)
spetialAccount.withdraw(200)
spetialAccount.message()
| class Accountmanager(object):
def __init__(self, balance=0):
self.balance = balance
def get_balance(self):
return self.balance
def withdraw(self, value):
if self.balance >= value:
self.balance = self.balance - value
print('Successful Withdrawal.')
else:
print('Insufficient Funds')
def deposit(self, value):
self.balance = self.balance + value
print('Successful Deposit')
def income(self, rate):
self.balance = self.balance + self.balance * rate
class Accountcommon(AccountManager):
def __init__(self, balance=0):
super(AccountCommon, self).__init__(balance=balance)
def get_balance(self):
return super().getBalance()
def deposit(self, value):
super().deposit(value)
def withdraw(self, value):
super().withdraw(value)
def income(self, rate):
super().income(rate)
def message(self):
print('Common account balance: %.2f' % self.getBalance())
class Accountspetial(AccountManager):
def __init__(self, balance=0):
super(AccountSpetial, self).__init__(balance=balance)
def get_balance(self):
return super().getBalance()
def deposit(self, value):
super().deposit(value)
def withdraw(self, value):
super().withdraw(value)
def message(self):
print('Common account balance: %.2f' % self.getBalance())
if __name__ == '__main__':
common_account = account_common(500)
commonAccount.deposit(500)
commonAccount.withdraw(100)
commonAccount.income(0.005)
commonAccount.message()
print(' ------- ')
spetial_account = account_spetial(1000)
spetialAccount.deposit(500)
spetialAccount.withdraw(200)
spetialAccount.message() |
class Response(object):
"""
"""
def __init__(self, status_code, text):
self.content = text
self.cached = False
self.status_code = status_code
self.ok = self.status_code < 400
@property
def text(self):
return self.content
def __repr__(self):
return 'HTTP {} {}'.format(self.status_code, self.content)
| class Response(object):
"""
"""
def __init__(self, status_code, text):
self.content = text
self.cached = False
self.status_code = status_code
self.ok = self.status_code < 400
@property
def text(self):
return self.content
def __repr__(self):
return 'HTTP {} {}'.format(self.status_code, self.content) |
# Exercicio 01 Tuplas
x = int(input('Digite o primeiro numero: '))
y = int(input('Digite o segundo numero: '))
cont = 1
soma = x
while cont < y:
soma = soma + x
cont = cont + 1
print('O resultado eh: {}' .format(soma))
| x = int(input('Digite o primeiro numero: '))
y = int(input('Digite o segundo numero: '))
cont = 1
soma = x
while cont < y:
soma = soma + x
cont = cont + 1
print('O resultado eh: {}'.format(soma)) |
'''
To have a error free way of accessing and updating private variables, we create specific methods for this.
Those methods which are meant to set a value to a private variable are called setter methods and methods
meant to access private variable values are called getter methods.
The below code is an example of getter and setter methods:
'''
class Customer:
def __init__(self, id, name, age, wallet_balance):
self.id = id
self.name = name
self.age = age
self.__wallet_balance = wallet_balance
def set_wallet_balance(self, amount):
if amount < 1000 and amount> 0:
self.__wallet_balance = amount
def get_wallet_balance(self):
return self.__wallet_balance
c1=Customer(100, "Gopal", 24, 1000)
c1.set_wallet_balance(120)
print(c1.get_wallet_balance())
| """
To have a error free way of accessing and updating private variables, we create specific methods for this.
Those methods which are meant to set a value to a private variable are called setter methods and methods
meant to access private variable values are called getter methods.
The below code is an example of getter and setter methods:
"""
class Customer:
def __init__(self, id, name, age, wallet_balance):
self.id = id
self.name = name
self.age = age
self.__wallet_balance = wallet_balance
def set_wallet_balance(self, amount):
if amount < 1000 and amount > 0:
self.__wallet_balance = amount
def get_wallet_balance(self):
return self.__wallet_balance
c1 = customer(100, 'Gopal', 24, 1000)
c1.set_wallet_balance(120)
print(c1.get_wallet_balance()) |
class Solution:
def isMatch(self, s: str, p: str) -> bool:
# this is a dynamic programming solution fot this
matrix = [[False for x in range(len(p) + 1)] for x in range(len(s) + 1)]
matrix[0][0] = True
for i in range(1, len(matrix[0])):
if p[i - 1] == "*":
matrix[0][i] = matrix[0][i - 1]
for i in range(1, len(matrix)):
for j in range(1, len(matrix[0])):
if s[i - 1] == p[j - 1] or p[j - 1] == "?":
matrix[i][j] = matrix[i - 1][j - 1]
elif p[j - 1] == "*":
matrix[i][j] = matrix[i][j - 1] or matrix[i - 1][j]
else:
matrix[i][j] = False
return matrix[len(s)][len(p)]
| class Solution:
def is_match(self, s: str, p: str) -> bool:
matrix = [[False for x in range(len(p) + 1)] for x in range(len(s) + 1)]
matrix[0][0] = True
for i in range(1, len(matrix[0])):
if p[i - 1] == '*':
matrix[0][i] = matrix[0][i - 1]
for i in range(1, len(matrix)):
for j in range(1, len(matrix[0])):
if s[i - 1] == p[j - 1] or p[j - 1] == '?':
matrix[i][j] = matrix[i - 1][j - 1]
elif p[j - 1] == '*':
matrix[i][j] = matrix[i][j - 1] or matrix[i - 1][j]
else:
matrix[i][j] = False
return matrix[len(s)][len(p)] |
# https://open.kattis.com/problems/luhnchecksum
for _ in range(int(input())):
count = 0
for i, d in enumerate(reversed(input())):
if i % 2 == 0:
count += int(d)
continue
x = 2 * int(d)
if x < 10:
count += x
else:
x = str(x)
count += int(x[0]) + int(x[1])
print('PASS' if count % 10 == 0 else 'FAIL')
| for _ in range(int(input())):
count = 0
for (i, d) in enumerate(reversed(input())):
if i % 2 == 0:
count += int(d)
continue
x = 2 * int(d)
if x < 10:
count += x
else:
x = str(x)
count += int(x[0]) + int(x[1])
print('PASS' if count % 10 == 0 else 'FAIL') |
inputFile = "3-input"
outputFile = "3-output"
dir = {'L': [-1,0],'R': [1,0],'U': [0,1],'D': [0,-1]}
def readFile():
file = open(inputFile, "r")
A,B = file.readlines()
A,B = [line.split(",") for line in [A,B]]
file.close()
return A,B
def writeFile(a, b):
file = open(outputFile, "w+")
file.write("Part 1: " + a + "\n")
file.write("Part 2: " + b)
file.close()
def mapCommands(A):
cx, cy, step = 0, 0, 0
mapped = [[0]*20000 for _ in range(20000)]
for cmd in A:
ax,ay = dir[cmd[0]][0],dir[cmd[0]][1]
for _ in range(int(cmd[1:])):
cx += ax
cy += ay
step += 1
mapped[cx+10000][cy+10000] = step
return mapped
def findIntersects(A, B):
mapped = mapCommands(A);
cx, cy, step = 0, 0, 0
dist = 10000000
steps = 10000000
for cmd in B:
for _ in range(int(cmd[1:])):
cx += dir[cmd[0]][0]
cy += dir[cmd[0]][1]
step += 1
aStep = mapped[cx+10000][cy+10000]
aDist = abs(cx)+abs(cy)
if aStep != 0:
if (dist > aDist): dist = aDist
if (steps > aStep + step): steps = aStep + step
return dist, steps
def main():
A,B = readFile()
solA, solB = findIntersects(A, B)
print(solA, solB)
#writeFile(str(solA), str(solB))
if __name__ == '__main__': main() | input_file = '3-input'
output_file = '3-output'
dir = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
def read_file():
file = open(inputFile, 'r')
(a, b) = file.readlines()
(a, b) = [line.split(',') for line in [A, B]]
file.close()
return (A, B)
def write_file(a, b):
file = open(outputFile, 'w+')
file.write('Part 1: ' + a + '\n')
file.write('Part 2: ' + b)
file.close()
def map_commands(A):
(cx, cy, step) = (0, 0, 0)
mapped = [[0] * 20000 for _ in range(20000)]
for cmd in A:
(ax, ay) = (dir[cmd[0]][0], dir[cmd[0]][1])
for _ in range(int(cmd[1:])):
cx += ax
cy += ay
step += 1
mapped[cx + 10000][cy + 10000] = step
return mapped
def find_intersects(A, B):
mapped = map_commands(A)
(cx, cy, step) = (0, 0, 0)
dist = 10000000
steps = 10000000
for cmd in B:
for _ in range(int(cmd[1:])):
cx += dir[cmd[0]][0]
cy += dir[cmd[0]][1]
step += 1
a_step = mapped[cx + 10000][cy + 10000]
a_dist = abs(cx) + abs(cy)
if aStep != 0:
if dist > aDist:
dist = aDist
if steps > aStep + step:
steps = aStep + step
return (dist, steps)
def main():
(a, b) = read_file()
(sol_a, sol_b) = find_intersects(A, B)
print(solA, solB)
if __name__ == '__main__':
main() |
name = 'Urban Dictionary Therapy'
__all__ = ['UDTherapy',
'helper']
| name = 'Urban Dictionary Therapy'
__all__ = ['UDTherapy', 'helper'] |
# -*- coding: utf-8 -*-
"""
Solution to Project Euler problem 179 - Consecutive positive divisors
Author: Jaime Liew
https://github.com/jaimeliew1/Project_Euler_Solutions
"""
def run():
N = int(1e7)
n_factors = [1 for _ in range(N + 1)]
# can start at 2 because 1 is a divisor for all numbers and wont change the
# relative count.
# Factor counting loop
for i in range(2, N + 1):
n = i
while n < N:
n_factors[n] += 1
n += i
# Evaluate factor count array
count = 0
for i in range(N):
if n_factors[i] == n_factors[i + 1]:
count += 1
return count
if __name__ == "__main__":
print(run())
| """
Solution to Project Euler problem 179 - Consecutive positive divisors
Author: Jaime Liew
https://github.com/jaimeliew1/Project_Euler_Solutions
"""
def run():
n = int(10000000.0)
n_factors = [1 for _ in range(N + 1)]
for i in range(2, N + 1):
n = i
while n < N:
n_factors[n] += 1
n += i
count = 0
for i in range(N):
if n_factors[i] == n_factors[i + 1]:
count += 1
return count
if __name__ == '__main__':
print(run()) |
"""
Problem:
--------
Design a data structure that supports the following two operations:
- `void addNum(int num)`: Add a integer number from the data stream to the data structure.
- `double findMedian()`: Return the median of all elements so far.
"""
class MedianFinder:
def __init__(self):
"""
Initialize your data structure here.
"""
self.list = []
def addNum(self, num: int) -> None:
# Traverse through the list and check if `num` > ith element
# If yes, insert `num` in that index
# This keeps the list sorted at all times
for i in range(len(self.list)):
if num > self.list[i]:
self.list.insert(i, num)
return
# If `num` is the largest element or is the first one to be added
self.list.append(num)
def findMedian(self) -> float:
# Find index of the middle element (floor division by 2)
mid_index = len(self.list) // 2
if len(self.list) % 2 == 0:
# If number of elements = EVEN
# Return average of the middle 2 elements
return (self.list[mid_index - 1] + self.list[mid_index]) / 2
else:
# If number of elements = ODD
# Return the middle element
return self.list[mid_index]
# Your MedianFinder object will be instantiated and called as such:
# obj = MedianFinder()
# obj.addNum(num)
# param_2 = obj.findMedian()
| """
Problem:
--------
Design a data structure that supports the following two operations:
- `void addNum(int num)`: Add a integer number from the data stream to the data structure.
- `double findMedian()`: Return the median of all elements so far.
"""
class Medianfinder:
def __init__(self):
"""
Initialize your data structure here.
"""
self.list = []
def add_num(self, num: int) -> None:
for i in range(len(self.list)):
if num > self.list[i]:
self.list.insert(i, num)
return
self.list.append(num)
def find_median(self) -> float:
mid_index = len(self.list) // 2
if len(self.list) % 2 == 0:
return (self.list[mid_index - 1] + self.list[mid_index]) / 2
else:
return self.list[mid_index] |
class SimulateMode:
@staticmethod
def start_simulation(device, guide=None):
return
| class Simulatemode:
@staticmethod
def start_simulation(device, guide=None):
return |
# Uses python3
n = int(input())
if n == 1:
print(1)
print(1)
quit()
W = n
prizes = []
for i in range(1, n):
if W>2*i:
prizes.append(i)
W -= i
else:
prizes.append(W)
break
print(len(prizes))
print(' '.join([str(i) for i in prizes])) | n = int(input())
if n == 1:
print(1)
print(1)
quit()
w = n
prizes = []
for i in range(1, n):
if W > 2 * i:
prizes.append(i)
w -= i
else:
prizes.append(W)
break
print(len(prizes))
print(' '.join([str(i) for i in prizes])) |
# Question 8
# Print even numbers in a list, stop printing when the number is 237
numbers = [
386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345,
399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217,
815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717,
958,743, 527
]
for i in range(len(numbers)):
if numbers[i] % 2 == 0:
print(numbers[i])
elif numbers[i] == 237:
break
# Alternative,
""" for x in numbers:
if x % 2 == 0:
print(x)
elif x == 237:
break """
| numbers = [386, 462, 47, 418, 907, 344, 236, 375, 823, 566, 597, 978, 328, 615, 953, 345, 399, 162, 758, 219, 918, 237, 412, 566, 826, 248, 866, 950, 626, 949, 687, 217, 815, 67, 104, 58, 512, 24, 892, 894, 767, 553, 81, 379, 843, 831, 445, 742, 717, 958, 743, 527]
for i in range(len(numbers)):
if numbers[i] % 2 == 0:
print(numbers[i])
elif numbers[i] == 237:
break
' for x in numbers:\n\tif x % 2 == 0:\n\t\tprint(x)\n\telif x == 237:\n\t\tbreak ' |
requested_toppings = ['mushrooms', 'extra cheese']
if 'mushrooms' in requested_toppings:
print("Adding mushrooms.")
if 'pepperoni' in requested_toppings:
print("Adding pepperoni.")
if 'extra cheese' in requested_toppings:
print("Adding extra cheese.")
print("\nFinished making your first pizza!")
if 'mushrooms' in requested_toppings:
print("Adding mushrooms.")
elif 'pepperoni' in requested_toppings:
print("Adding pepperoni.")
elif 'extra cheese' in requested_toppings:
print("Adding extra cheese.")
print("\nFinished making your second pizza!") | requested_toppings = ['mushrooms', 'extra cheese']
if 'mushrooms' in requested_toppings:
print('Adding mushrooms.')
if 'pepperoni' in requested_toppings:
print('Adding pepperoni.')
if 'extra cheese' in requested_toppings:
print('Adding extra cheese.')
print('\nFinished making your first pizza!')
if 'mushrooms' in requested_toppings:
print('Adding mushrooms.')
elif 'pepperoni' in requested_toppings:
print('Adding pepperoni.')
elif 'extra cheese' in requested_toppings:
print('Adding extra cheese.')
print('\nFinished making your second pizza!') |
# markdownv2 python-telegram-bot specific
joined = '{} joined group `{}`'
not_joined = '{} is already in group `{}`'
left = '{} left group `{}`'
not_left = '{} did not join group `{}` before'
mention_failed = 'There are no users to mention'
no_groups = 'There are no groups for this chat'
# html python-telegram-bot specific
start_text = """
Hello!
@everyone_mention_bot here.
I am here to help you with multiple user mentions.
<b>Usage</b>:
Users that joined the group by <code>/join</code> command,
can be mentioned after typing one of those in your message:
<code>@all</code>, <code>@channel</code>, <code>@chat</code>, <code>@everyone</code>, <code>@group</code> or <code>@here</code>.
If you did create a group named <code>gaming</code>, simply use <code>@gaming</code> to call users from that group.
You can also use <code>/everyone</code> command.
<b>Commands</b>:
<pre>/join {group-name}</pre>
Joins (or creates if group did not exist before) group.
<pre>/leave {group-name}</pre>
Leaves (or deletes if no other users are left) the group
<pre>/everyone {group-name}</pre>
Mentions everyone that joined the group.
<pre>/groups</pre>
Show all created groups in this chat.
<pre>/start</pre>
Show start & help text
<b>Please note</b>
<code>{group-name}</code> is not required, <code>default</code> if not given.
"""
| joined = '{} joined group `{}`'
not_joined = '{} is already in group `{}`'
left = '{} left group `{}`'
not_left = '{} did not join group `{}` before'
mention_failed = 'There are no users to mention'
no_groups = 'There are no groups for this chat'
start_text = '\nHello!\n@everyone_mention_bot here.\nI am here to help you with multiple user mentions.\n\n<b>Usage</b>:\nUsers that joined the group by <code>/join</code> command, \ncan be mentioned after typing one of those in your message: \n<code>@all</code>, <code>@channel</code>, <code>@chat</code>, <code>@everyone</code>, <code>@group</code> or <code>@here</code>.\n\nIf you did create a group named <code>gaming</code>, simply use <code>@gaming</code> to call users from that group.\n\nYou can also use <code>/everyone</code> command.\n\n<b>Commands</b>:\n<pre>/join {group-name}</pre>\nJoins (or creates if group did not exist before) group.\n\n<pre>/leave {group-name}</pre>\nLeaves (or deletes if no other users are left) the group\n\n<pre>/everyone {group-name}</pre>\nMentions everyone that joined the group.\n\n<pre>/groups</pre>\nShow all created groups in this chat.\n\n<pre>/start</pre>\nShow start & help text\n\n<b>Please note</b>\n<code>{group-name}</code> is not required, <code>default</code> if not given.\n' |
"""Defines a rule for runsc test targets."""
load("@io_bazel_rules_go//go:def.bzl", _go_test = "go_test")
# runtime_test is a macro that will create targets to run the given test target
# with different runtime options.
def runtime_test(**kwargs):
"""Runs the given test target with different runtime options."""
name = kwargs["name"]
_go_test(**kwargs)
kwargs["name"] = name + "_hostnet"
kwargs["args"] = ["--runtime-type=hostnet"]
_go_test(**kwargs)
kwargs["name"] = name + "_kvm"
kwargs["args"] = ["--runtime-type=kvm"]
_go_test(**kwargs)
kwargs["name"] = name + "_overlay"
kwargs["args"] = ["--runtime-type=overlay"]
_go_test(**kwargs)
| """Defines a rule for runsc test targets."""
load('@io_bazel_rules_go//go:def.bzl', _go_test='go_test')
def runtime_test(**kwargs):
"""Runs the given test target with different runtime options."""
name = kwargs['name']
_go_test(**kwargs)
kwargs['name'] = name + '_hostnet'
kwargs['args'] = ['--runtime-type=hostnet']
_go_test(**kwargs)
kwargs['name'] = name + '_kvm'
kwargs['args'] = ['--runtime-type=kvm']
_go_test(**kwargs)
kwargs['name'] = name + '_overlay'
kwargs['args'] = ['--runtime-type=overlay']
_go_test(**kwargs) |
# Copyright 2019-2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""utils"""
# input format begin
DEFAULT = "DefaultFormat"
NCHW = "NCHW"
NHWC = "NHWC"
HWCN = "HWCN"
NC1HWC0 = "NC1HWC0"
FRAC_Z = "FracZ"
# input format end
# fusion type begin
ELEMWISE = "ELEMWISE"
CONVLUTION = "CONVLUTION"
COMMREDUCE = "COMMREDUCE"
SEGMENT = "SEGMENT"
OPAQUE = "OPAQUE"
# fusion type end
BINDS = "binds" | """utils"""
default = 'DefaultFormat'
nchw = 'NCHW'
nhwc = 'NHWC'
hwcn = 'HWCN'
nc1_hwc0 = 'NC1HWC0'
frac_z = 'FracZ'
elemwise = 'ELEMWISE'
convlution = 'CONVLUTION'
commreduce = 'COMMREDUCE'
segment = 'SEGMENT'
opaque = 'OPAQUE'
binds = 'binds' |
# -*- coding: utf-8 -*-
MNIST_DATASET_PATH = 'raw_data/mnist.pkl.gz'
TEST_FOLDER = 'test/'
TRAIN_FOLDER = 'train/'
MODEL_FILE_PATH = 'model/recognizer.pickle'
LABEL_ENCODER_FILE_PATH = 'model/label_encoder.pickle'
# Manual
DEMO_HELP_MSG = '\n' + \
'Input parameter is incorrect\n' + \
'Display help: \'python demo.py -h\''
TRAINER_HELP_MSG = '\n' + \
'Input parameter is incorrect\n' + \
'Display help: \'python extractor.py -h\''
| mnist_dataset_path = 'raw_data/mnist.pkl.gz'
test_folder = 'test/'
train_folder = 'train/'
model_file_path = 'model/recognizer.pickle'
label_encoder_file_path = 'model/label_encoder.pickle'
demo_help_msg = '\n' + 'Input parameter is incorrect\n' + "Display help: 'python demo.py -h'"
trainer_help_msg = '\n' + 'Input parameter is incorrect\n' + "Display help: 'python extractor.py -h'" |
#! /usr/bin/env python
def cut_the_sticks(a):
cuts = []
while len(a) > 0:
cutter = a.pop()
if cutter == 0:
continue
for i in range(len(a)):
a[i] -= cutter
cuts.append(len(a) + 1)
return cuts
if __name__ == '__main__':
_ = input()
value = map(int, input().split(' '))
res = cut_the_sticks(sorted(value, reverse=True))
for v in res:
print(v)
| def cut_the_sticks(a):
cuts = []
while len(a) > 0:
cutter = a.pop()
if cutter == 0:
continue
for i in range(len(a)):
a[i] -= cutter
cuts.append(len(a) + 1)
return cuts
if __name__ == '__main__':
_ = input()
value = map(int, input().split(' '))
res = cut_the_sticks(sorted(value, reverse=True))
for v in res:
print(v) |
"""
Configuration for docs
"""
# source_link = "https://github.com/[org_name]/pos_multie_print"
# docs_base_url = "https://[org_name].github.io/pos_multie_print"
# headline = "App that does everything"
# sub_heading = "Yes, you got that right the first time, everything"
def get_context(context):
context.brand_html = "POS Multiple Print"
| """
Configuration for docs
"""
def get_context(context):
context.brand_html = 'POS Multiple Print' |
n, k, v = int(input()), int(input()), []
for i in range(n): v.append(int(input()))
v = sorted(v, reverse=True)
print(k + v[k:].count(v[k-1]))
| (n, k, v) = (int(input()), int(input()), [])
for i in range(n):
v.append(int(input()))
v = sorted(v, reverse=True)
print(k + v[k:].count(v[k - 1])) |
#! python3
# __author__ = "YangJiaHao"
# date: 2018/1/26
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
d = dict()
l, r = 0, 0
res = 0
while r < len(s):
if s[r] not in d:
d[s[r]] = None
r += 1
res = max(res, r - l)
else:
del d[s[l]]
l += 1
return res
class Solution2:
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
lookup = {}
offset = -1
longest = 0
for idx, char in enumerate(s):
if char in lookup:
if offset < lookup[char]:
offset = lookup[char]
lookup[char] = idx
length = idx - offset
if length > longest:
longest = length
return longest
if __name__ == '__main__':
solution = Solution()
theMax = solution.lengthOfLongestSubstring("aaaabc")
print(theMax)
| class Solution:
def length_of_longest_substring(self, s: str) -> int:
d = dict()
(l, r) = (0, 0)
res = 0
while r < len(s):
if s[r] not in d:
d[s[r]] = None
r += 1
res = max(res, r - l)
else:
del d[s[l]]
l += 1
return res
class Solution2:
def length_of_longest_substring(self, s):
"""
:type s: str
:rtype: int
"""
lookup = {}
offset = -1
longest = 0
for (idx, char) in enumerate(s):
if char in lookup:
if offset < lookup[char]:
offset = lookup[char]
lookup[char] = idx
length = idx - offset
if length > longest:
longest = length
return longest
if __name__ == '__main__':
solution = solution()
the_max = solution.lengthOfLongestSubstring('aaaabc')
print(theMax) |
def get_field_name_from_line(line):
return line.split(':')[1].strip()
def remove_description(line):
if '-' in line:
return line.split('-')[0].strip()
else:
return line
def split_multiple_field_names(line):
if ',' in line:
field_names = line.split(',')
return map(lambda x: x.strip().upper(), field_names)
else:
return [line.upper()]
f = open('../data/8-20-17.nm2')
out = open('../data/8-20-17-field-names.txt', 'w')
for line in f:
if line.startswith('FieldName'):
field_name = get_field_name_from_line(line)
field_name = remove_description(field_name)
field_name_list = split_multiple_field_names(field_name)
for name in field_name_list:
out.writelines([name, '\n'])
f.close()
out.close() | def get_field_name_from_line(line):
return line.split(':')[1].strip()
def remove_description(line):
if '-' in line:
return line.split('-')[0].strip()
else:
return line
def split_multiple_field_names(line):
if ',' in line:
field_names = line.split(',')
return map(lambda x: x.strip().upper(), field_names)
else:
return [line.upper()]
f = open('../data/8-20-17.nm2')
out = open('../data/8-20-17-field-names.txt', 'w')
for line in f:
if line.startswith('FieldName'):
field_name = get_field_name_from_line(line)
field_name = remove_description(field_name)
field_name_list = split_multiple_field_names(field_name)
for name in field_name_list:
out.writelines([name, '\n'])
f.close()
out.close() |
class Circle:
def __init__(self, radius):
self.radius = radius
def compute_area(self):
return self.radius ** 2 * 3.14
circle = Circle(2)
print("Area of circuit: " + str(circle.compute_area()))
| class Circle:
def __init__(self, radius):
self.radius = radius
def compute_area(self):
return self.radius ** 2 * 3.14
circle = circle(2)
print('Area of circuit: ' + str(circle.compute_area())) |
class Solution:
def addStrings(self, num1: str, num2: str) -> str:
i, j, result, carry = len(num1) - 1, len(num2) - 1, '', 0
while i >= 0 or j >= 0:
if i >= 0:
carry += ord(num1[i]) - ord('0')
if j >= 0:
carry += ord(num2[j]) - ord('0')
result += chr(carry % 10 + ord('0'))
carry //= 10
i -= 1
j -= 1
if carry == 1:
result += '1'
return result[::-1]
| class Solution:
def add_strings(self, num1: str, num2: str) -> str:
(i, j, result, carry) = (len(num1) - 1, len(num2) - 1, '', 0)
while i >= 0 or j >= 0:
if i >= 0:
carry += ord(num1[i]) - ord('0')
if j >= 0:
carry += ord(num2[j]) - ord('0')
result += chr(carry % 10 + ord('0'))
carry //= 10
i -= 1
j -= 1
if carry == 1:
result += '1'
return result[::-1] |
word = input('Enter a word')
len = len(word)
for i in range(len-1, -1, -1):
print(word[i], end='')
| word = input('Enter a word')
len = len(word)
for i in range(len - 1, -1, -1):
print(word[i], end='') |
ss = input('Please give me a string: ')
if ss == ss[::-1]:
print("Yes, %s is a palindrome." % ss)
else:
print('Nevermind, %s isn\'t a palindrome.' % ss)
| ss = input('Please give me a string: ')
if ss == ss[::-1]:
print('Yes, %s is a palindrome.' % ss)
else:
print("Nevermind, %s isn't a palindrome." % ss) |
class AbridgerError(Exception):
pass
class ConfigFileLoaderError(AbridgerError):
pass
class IncludeError(ConfigFileLoaderError):
pass
class DataError(ConfigFileLoaderError):
pass
class FileNotFoundError(ConfigFileLoaderError):
pass
class DatabaseUrlError(AbridgerError):
pass
class ExtractionModelError(AbridgerError):
pass
class UnknownTableError(AbridgerError):
pass
class UnknownColumnError(AbridgerError):
pass
class InvalidConfigError(ExtractionModelError):
pass
class RelationIntegrityError(ExtractionModelError):
pass
class GeneratorError(Exception):
pass
class CyclicDependencyError(GeneratorError):
pass
| class Abridgererror(Exception):
pass
class Configfileloadererror(AbridgerError):
pass
class Includeerror(ConfigFileLoaderError):
pass
class Dataerror(ConfigFileLoaderError):
pass
class Filenotfounderror(ConfigFileLoaderError):
pass
class Databaseurlerror(AbridgerError):
pass
class Extractionmodelerror(AbridgerError):
pass
class Unknowntableerror(AbridgerError):
pass
class Unknowncolumnerror(AbridgerError):
pass
class Invalidconfigerror(ExtractionModelError):
pass
class Relationintegrityerror(ExtractionModelError):
pass
class Generatorerror(Exception):
pass
class Cyclicdependencyerror(GeneratorError):
pass |
def aumentar(preco, taxa):
p = preco + (preco * taxa/100)
return p
def diminuir(preco, taxa):
p = preco - (preco * taxa/100)
return p
def dobro(preco):
p = preco * 2
return p
def metade(preco):
p = preco / 2
return p
| def aumentar(preco, taxa):
p = preco + preco * taxa / 100
return p
def diminuir(preco, taxa):
p = preco - preco * taxa / 100
return p
def dobro(preco):
p = preco * 2
return p
def metade(preco):
p = preco / 2
return p |
DOMAIN = "fitx"
ICON = "mdi:weight-lifter"
CONF_LOCATIONS = 'locations'
CONF_ID = 'id'
ATTR_ADDRESS = "address"
ATTR_STUDIO_NAME = "studioName"
ATTR_ID = CONF_ID
ATTR_URL = "url"
DEFAULT_ENDPOINT = "https://www.fitx.de/fitnessstudios/{id}"
REQUEST_METHOD = "GET"
REQUEST_AUTH = None
REQUEST_HEADERS = None
REQUEST_PAYLOAD = None
REQUEST_VERIFY_SSL = True | domain = 'fitx'
icon = 'mdi:weight-lifter'
conf_locations = 'locations'
conf_id = 'id'
attr_address = 'address'
attr_studio_name = 'studioName'
attr_id = CONF_ID
attr_url = 'url'
default_endpoint = 'https://www.fitx.de/fitnessstudios/{id}'
request_method = 'GET'
request_auth = None
request_headers = None
request_payload = None
request_verify_ssl = True |
#!/usr/bin/env python3
# coding: UTF-8
'''!
module description
@author <A href="email:fulkgl@gmail.com">George L Fulk</A>
'''
__version__ = 0.01
def main():
'''!
main description
'''
print("Hello world")
return 0
if __name__ == "__main__":
# command line entry point
main()
# END #
| """!
module description
@author <A href="email:fulkgl@gmail.com">George L Fulk</A>
"""
__version__ = 0.01
def main():
"""!
main description
"""
print('Hello world')
return 0
if __name__ == '__main__':
main() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.