content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
coords = []
for ry in range(-2, 3):
for rx in range(2, -3, -1):
x = rx / 4
y = ry / 4
coords.append((x,y))
for p in range(16):
y, x = divmod(p, 4)
top_right = coords[(y+1)*5 + x]
top_left = coords[(y+1)*5 + x + 1]
bottom_left = coords[y*5 + x + 1]
bottom_right = coords[y*5 + x]
line = '{{{{ {} }}}},'.format(', '.join('{: .2f}f' for _ in range(12)))
line = line.format(
top_right[0], top_right[1],
top_left[0], top_left[1],
bottom_left[0], bottom_left[1],
top_right[0], top_right[1],
bottom_left[0], bottom_left[1],
bottom_right[0], bottom_right[1],
)
print(line)
| coords = []
for ry in range(-2, 3):
for rx in range(2, -3, -1):
x = rx / 4
y = ry / 4
coords.append((x, y))
for p in range(16):
(y, x) = divmod(p, 4)
top_right = coords[(y + 1) * 5 + x]
top_left = coords[(y + 1) * 5 + x + 1]
bottom_left = coords[y * 5 + x + 1]
bottom_right = coords[y * 5 + x]
line = '{{{{ {} }}}},'.format(', '.join(('{: .2f}f' for _ in range(12))))
line = line.format(top_right[0], top_right[1], top_left[0], top_left[1], bottom_left[0], bottom_left[1], top_right[0], top_right[1], bottom_left[0], bottom_left[1], bottom_right[0], bottom_right[1])
print(line) |
"""df[{}] = df[{}].astype({})"""
def run(dfs: dict, settings: dict) -> dict:
"""df[{}] = df[{}].astype({})"""
if 'columns' not in settings:
raise Exception('Missing columns param')
dfs[settings['df']] = dfs[settings['df']].astype(settings['columns'])
return dfs
| """df[{}] = df[{}].astype({})"""
def run(dfs: dict, settings: dict) -> dict:
"""df[{}] = df[{}].astype({})"""
if 'columns' not in settings:
raise exception('Missing columns param')
dfs[settings['df']] = dfs[settings['df']].astype(settings['columns'])
return dfs |
# -*- coding: utf-8 -*-
__author__ = 'Bruno Paes'
__email__ = 'brunopaes05@gmail.com'
__github__ = 'https://www.github.com/Brunopaes'
__status__ = 'Finalised'
class Viginere(object):
@staticmethod
def encrypt(plaintext, key):
key_length = len(key)
key_as_int = [ord(i) for i in key]
plaintext_int = [ord(i) for i in plaintext]
ciphertext = ''
for i in range(len(plaintext_int)):
value = (plaintext_int[i] + key_as_int[i % key_length]) % 26
ciphertext += chr(value + 65)
return ciphertext
@staticmethod
def decrypt(ciphertext, key):
key_length = len(key)
key_as_int = [ord(i) for i in key]
ciphertext_int = [ord(i) for i in ciphertext]
plaintext = ''
for i in range(len(ciphertext_int)):
value = (ciphertext_int[i] - key_as_int[i % key_length]) % 26
plaintext += chr(value + 65)
return plaintext
if __name__ == '__main__':
c = Viginere()
print(c.decrypt('efsdsetpe', 'espm'))
| __author__ = 'Bruno Paes'
__email__ = 'brunopaes05@gmail.com'
__github__ = 'https://www.github.com/Brunopaes'
__status__ = 'Finalised'
class Viginere(object):
@staticmethod
def encrypt(plaintext, key):
key_length = len(key)
key_as_int = [ord(i) for i in key]
plaintext_int = [ord(i) for i in plaintext]
ciphertext = ''
for i in range(len(plaintext_int)):
value = (plaintext_int[i] + key_as_int[i % key_length]) % 26
ciphertext += chr(value + 65)
return ciphertext
@staticmethod
def decrypt(ciphertext, key):
key_length = len(key)
key_as_int = [ord(i) for i in key]
ciphertext_int = [ord(i) for i in ciphertext]
plaintext = ''
for i in range(len(ciphertext_int)):
value = (ciphertext_int[i] - key_as_int[i % key_length]) % 26
plaintext += chr(value + 65)
return plaintext
if __name__ == '__main__':
c = viginere()
print(c.decrypt('efsdsetpe', 'espm')) |
"""
Hash tables :: Day 1 Notes: Arrays
An array:
* Stores a sequence of elements
* Each element must be the same data type
* Occupies a contiguous block of memory
* Can access data in constant time with this equation:
`memory_address = starting_address + index * data_size`
"""
class DynamicArray:
def __init__(self, capacity=1):
self.count = 0 # Number of elements in the array
self.capacity = capacity # Total amount of storage in array
self.storage = [None] * capacity
def insert(self, index, value):
"""Inserts a value into list at index.
Complexity: O(n)"""
# Check if we have enough capacity
if self.count >= self.capacity:
# If not, make more room
self.resize()
# Shift every item after index to right by 1
for i in range(self.count, index, -1):
self.storage[i] = self.storage[i - 1]
# Add new value at the index
self.storage[index] = value
# Increment count
self.count += 1
def append(self, value):
"""Appends a value to the end of array.
Complexity: O(1)"""
# Check if array has enough capacity
if self.count >= self.capacity:
# If not, resize up
self.resize()
# Add value to the index of count
self.storage[self.count] = value
# Increment count
self.count += 1
def resize(self):
"""Doubles the capacity of array."""
self.capacity *= 2
# Allocate a new storage array with double capacity
new_storage = [None] * self.capacity
# Copy all ements from old storage to new
for i in range(self.count):
new_storage[i] = self.storage[i]
self.storage = new_storage
a = DynamicArray(2)
a.insert(0, 19)
a.insert(0, 14)
print(a.storage)
a.append(9)
a.append(8)
print(a.storage)
a.append(7)
print(a.storage)
| """
Hash tables :: Day 1 Notes: Arrays
An array:
* Stores a sequence of elements
* Each element must be the same data type
* Occupies a contiguous block of memory
* Can access data in constant time with this equation:
`memory_address = starting_address + index * data_size`
"""
class Dynamicarray:
def __init__(self, capacity=1):
self.count = 0
self.capacity = capacity
self.storage = [None] * capacity
def insert(self, index, value):
"""Inserts a value into list at index.
Complexity: O(n)"""
if self.count >= self.capacity:
self.resize()
for i in range(self.count, index, -1):
self.storage[i] = self.storage[i - 1]
self.storage[index] = value
self.count += 1
def append(self, value):
"""Appends a value to the end of array.
Complexity: O(1)"""
if self.count >= self.capacity:
self.resize()
self.storage[self.count] = value
self.count += 1
def resize(self):
"""Doubles the capacity of array."""
self.capacity *= 2
new_storage = [None] * self.capacity
for i in range(self.count):
new_storage[i] = self.storage[i]
self.storage = new_storage
a = dynamic_array(2)
a.insert(0, 19)
a.insert(0, 14)
print(a.storage)
a.append(9)
a.append(8)
print(a.storage)
a.append(7)
print(a.storage) |
predictor_url = 'http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2'
predictor_file = '../weights/shape_predictor_68_face_landmarks.dat'
p2v_model_gdrive_id = '1op5_zyH4CWm_JFDdCUPZM4X-A045ETex'
sample_image = '../examples/sample.jpg'
| predictor_url = 'http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2'
predictor_file = '../weights/shape_predictor_68_face_landmarks.dat'
p2v_model_gdrive_id = '1op5_zyH4CWm_JFDdCUPZM4X-A045ETex'
sample_image = '../examples/sample.jpg' |
def main(request, response):
name = request.GET.first(b"name")
value = request.GET.first(b"value")
source_origin = request.headers.get(b"origin", None)
response_headers = [(b"Set-Cookie", name + b"=" + value),
(b"Access-Control-Allow-Origin", source_origin),
(b"Access-Control-Allow-Credentials", b"true")]
return (200, response_headers, u"")
| def main(request, response):
name = request.GET.first(b'name')
value = request.GET.first(b'value')
source_origin = request.headers.get(b'origin', None)
response_headers = [(b'Set-Cookie', name + b'=' + value), (b'Access-Control-Allow-Origin', source_origin), (b'Access-Control-Allow-Credentials', b'true')]
return (200, response_headers, u'') |
# Leetcode 435. Non-overlapping Intervals
#
# Link: https://leetcode.com/problems/non-overlapping-intervals/
# Difficulty: Medium
# Solution using sorting.
# Complexity:
# O(NlogN) time | where N represent the number of intervals
# O(1) space
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key = lambda pair : pair[0])
result = 0
prevEnd = intervals[0][1]
for start, end in intervals[1:]:
if start >= prevEnd:
# Not overlapping if prevEnd < start
prevEnd = end
else:
# Overlapping if prevEnd > start
# Remove the longest one
result += 1
prevEnd = min(prevEnd, end)
return result
| class Solution:
def erase_overlap_intervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key=lambda pair: pair[0])
result = 0
prev_end = intervals[0][1]
for (start, end) in intervals[1:]:
if start >= prevEnd:
prev_end = end
else:
result += 1
prev_end = min(prevEnd, end)
return result |
BOARD_TILE_SIZE = 56 # the size of each board tile
BOARD_PLAYER_SIZE = 20 # the size of each player icon
BOARD_MARGIN = (10, 0) # margins, in pixels (for player icons)
PLAYER_ICON_IMAGE_SIZE = 32 # the size of the image to download, should a power of 2 and higher than BOARD_PLAYER_SIZE
MAX_PLAYERS = 4 # depends on the board size/quality, 4 is for the default board
# board definition (from, to)
BOARD = {
# ladders
2: 38,
7: 14,
8: 31,
15: 26,
21: 42,
28: 84,
36: 44,
51: 67,
71: 91,
78: 98,
87: 94,
# snakes
99: 80,
95: 75,
92: 88,
89: 68,
74: 53,
64: 60,
62: 19,
49: 11,
46: 25,
16: 6
}
| board_tile_size = 56
board_player_size = 20
board_margin = (10, 0)
player_icon_image_size = 32
max_players = 4
board = {2: 38, 7: 14, 8: 31, 15: 26, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91, 78: 98, 87: 94, 99: 80, 95: 75, 92: 88, 89: 68, 74: 53, 64: 60, 62: 19, 49: 11, 46: 25, 16: 6} |
def truncate(string, length):
"Ensure a string is no longer than a given length."
if len(string) <= length:
return string
else:
return string[:length]
| def truncate(string, length):
"""Ensure a string is no longer than a given length."""
if len(string) <= length:
return string
else:
return string[:length] |
def insertionSort(arr, size):
for i in range(1, size):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
return arr
def shakerSort(arr, size):
left = 0
right = size - 1
lastSwap = 0
while left < right:
for i in range(left, right):
if arr[i] > arr[i + 1]:
arr[i], arr[i + 1] = arr[i + 1], arr[i]
lastSwap = i
right = lastSwap
for i in range(right, left, -1):
if arr[i - 1] > arr[i]:
arr[i], arr[i - 1] = arr[i - 1], arr[i]
lastSwap = i
left = lastSwap
return arr
def selectionSort(arr, size):
for i in range(size - 1):
minIndex = i
for j in range(i + 1, size):
if arr[minIndex] > arr[j]:
minIndex = j
arr[minIndex], arr[i] = arr[i], arr[minIndex]
return arr
if __name__ == '__main__':
a = [1, 2, 3, 4, 5]
b = [5, 4, 3, 2, 1]
c = [4, 2 ,3, 5, 1]
print(insertionSort(a, 5))
print(shakerSort(a, 5))
print(selectionSort(a, 5))
print(insertionSort(b, 5))
print(shakerSort(b, 5))
print(selectionSort(b, 5))
print(insertionSort(c, 5))
print(shakerSort(c, 5))
print(selectionSort(c, 5))
print(insertionSort([1], 1))
print(shakerSort([1], 1))
print(selectionSort([1], 1))
print(insertionSort([], 0))
print(shakerSort([], 0))
print(selectionSort([], 0))
print(insertionSort(["ab", "make", "draw"], 3))
print(insertionSort([2, 1, 3, 4, 5], 5))
| def insertion_sort(arr, size):
for i in range(1, size):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
return arr
def shaker_sort(arr, size):
left = 0
right = size - 1
last_swap = 0
while left < right:
for i in range(left, right):
if arr[i] > arr[i + 1]:
(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
last_swap = i
right = lastSwap
for i in range(right, left, -1):
if arr[i - 1] > arr[i]:
(arr[i], arr[i - 1]) = (arr[i - 1], arr[i])
last_swap = i
left = lastSwap
return arr
def selection_sort(arr, size):
for i in range(size - 1):
min_index = i
for j in range(i + 1, size):
if arr[minIndex] > arr[j]:
min_index = j
(arr[minIndex], arr[i]) = (arr[i], arr[minIndex])
return arr
if __name__ == '__main__':
a = [1, 2, 3, 4, 5]
b = [5, 4, 3, 2, 1]
c = [4, 2, 3, 5, 1]
print(insertion_sort(a, 5))
print(shaker_sort(a, 5))
print(selection_sort(a, 5))
print(insertion_sort(b, 5))
print(shaker_sort(b, 5))
print(selection_sort(b, 5))
print(insertion_sort(c, 5))
print(shaker_sort(c, 5))
print(selection_sort(c, 5))
print(insertion_sort([1], 1))
print(shaker_sort([1], 1))
print(selection_sort([1], 1))
print(insertion_sort([], 0))
print(shaker_sort([], 0))
print(selection_sort([], 0))
print(insertion_sort(['ab', 'make', 'draw'], 3))
print(insertion_sort([2, 1, 3, 4, 5], 5)) |
def mergeOverlappingIntervals(intervals):
sortedIntervals = sorted(intervals, key=lambda x: x[0])
overlappingIntervals = []
left = sortedIntervals[0][0]
right = sortedIntervals[0][1]
for i in range(1, len(sortedIntervals)):
if right >= sortedIntervals[i][0]:
right = max(right, sortedIntervals[i][1])
else:
overlappingIntervals.append([left, right])
left, right = sortedIntervals[i][0], sortedIntervals[i][1]
overlappingIntervals.append([left, right])
return overlappingIntervals
| def merge_overlapping_intervals(intervals):
sorted_intervals = sorted(intervals, key=lambda x: x[0])
overlapping_intervals = []
left = sortedIntervals[0][0]
right = sortedIntervals[0][1]
for i in range(1, len(sortedIntervals)):
if right >= sortedIntervals[i][0]:
right = max(right, sortedIntervals[i][1])
else:
overlappingIntervals.append([left, right])
(left, right) = (sortedIntervals[i][0], sortedIntervals[i][1])
overlappingIntervals.append([left, right])
return overlappingIntervals |
# hash
class Solution(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
count_map = {}
res = []
for num in nums1:
count_map[num] = count_map.get(num, 0) + 1
for num in nums2:
if count_map.get(num, 0) > 0:
res.append(num)
count_map[num] -= 1
return res
# tow-pointers
class Solution2(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
nums1.sort()
nums2.sort()
left = 0
right = 0
res = []
while(left < len(nums1) and right < len(nums2)):
if nums1[left] > nums2[right]:
right += 1
elif nums1[left] < nums2[right]:
left += 1
else:
res.append(nums1[left])
left += 1
right += 1
return res | class Solution(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
count_map = {}
res = []
for num in nums1:
count_map[num] = count_map.get(num, 0) + 1
for num in nums2:
if count_map.get(num, 0) > 0:
res.append(num)
count_map[num] -= 1
return res
class Solution2(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
nums1.sort()
nums2.sort()
left = 0
right = 0
res = []
while left < len(nums1) and right < len(nums2):
if nums1[left] > nums2[right]:
right += 1
elif nums1[left] < nums2[right]:
left += 1
else:
res.append(nums1[left])
left += 1
right += 1
return res |
class GameLogic:
def __int__(self):
self
def add_lander(self, lander):
self.lander = lander
def update(self, delta_time):
self.lander.update_lander(delta_time) | class Gamelogic:
def __int__(self):
self
def add_lander(self, lander):
self.lander = lander
def update(self, delta_time):
self.lander.update_lander(delta_time) |
data = []
with open("data.txt") as file:
data = [int(x) for x in file.read().split(",")]
def part_one(data, noun, verb):
opcode = 0
data_c = data[:]
data_c[1] = noun
data_c[2] = verb
while True:
if data_c[opcode] == 1:
data_c[data_c[opcode + 3]] = data_c[data_c[opcode + 1]] + data_c[data_c[opcode + 2]]
elif data_c[opcode] == 2:
data_c[data_c[opcode + 3]] = data_c[data_c[opcode + 1]] * data_c[data_c[opcode + 2]]
elif data_c[opcode] == 99:
break
else:
print("It failed!")
opcode += 4
return data_c[0]
def part_two(data):
for noun in range(100):
for verb in range(100):
if part_one(data, noun, verb) == 19690720:
return 100 * noun + verb
print(part_two(data))
| data = []
with open('data.txt') as file:
data = [int(x) for x in file.read().split(',')]
def part_one(data, noun, verb):
opcode = 0
data_c = data[:]
data_c[1] = noun
data_c[2] = verb
while True:
if data_c[opcode] == 1:
data_c[data_c[opcode + 3]] = data_c[data_c[opcode + 1]] + data_c[data_c[opcode + 2]]
elif data_c[opcode] == 2:
data_c[data_c[opcode + 3]] = data_c[data_c[opcode + 1]] * data_c[data_c[opcode + 2]]
elif data_c[opcode] == 99:
break
else:
print('It failed!')
opcode += 4
return data_c[0]
def part_two(data):
for noun in range(100):
for verb in range(100):
if part_one(data, noun, verb) == 19690720:
return 100 * noun + verb
print(part_two(data)) |
# coding=utf8
"""
Prolog Grammar of ATIS
"""
GRAMMAR_DICTIONARY = {}
ROOT_RULE = 'statement -> [answer]'
GRAMMAR_DICTIONARY['statement'] = ['(answer ws)']
GRAMMAR_DICTIONARY['answer'] = [
'("answer_1(" var "," goal ")")',
'("answer_2(" var "," var "," goal ")")',
'("answer_3(" var "," var "," var "," goal ")")',
'("answer_4(" var "," var "," var "," var "," goal ")")',
]
# Goal
GRAMMAR_DICTIONARY['goal'] = [
'(declaration)',
'(unit_relation)',
'(binary_relation)',
'(triplet_relation)',
'(meta)',
'("(" goal conjunction ")")',
'("or(" goal conjunction ")")',
'("not(" goal conjunction ")")'
]
GRAMMAR_DICTIONARY['conjunction'] = [
'("," goal conjunction)',
'""'
]
# Variable
GRAMMAR_DICTIONARY['var'] = ['"%s"' % chr(97+i) for i in range(26)]
# Declaration
GRAMMAR_DICTIONARY['declaration'] = [
'("const(" var "," object ")")']
# Object
GRAMMAR_DICTIONARY['object'] = [
'(fare_basis_code)', '(meal_code)', '(airport_code)', '(airline_code)',
'(aircraft_code_object)', '(city_name)', '(time)', '(flight_number_object)',
'(class_description)', '(day_period)', '(state_name)',
'(day_number)', '(month)', '(day)', '(dollar)', '(meal_description)',
'("hour(9)")', '(integer)', '(basis_type)', '(year)',
'("days_code(sa)")', '("manufacturer(boeing)")'
]
GRAMMAR_DICTIONARY['fare_basis_code'] = ['("fare_basis_code(" fare_basis_code_value ")")']
GRAMMAR_DICTIONARY['fare_basis_code_value'] = ['"_qx"', '"_qw"', '"_qo"', '"_fn"', '"_yn"', '"_bh"', '"_k"', '"_b"', '"_h"', '"_f"', '"_q"', '"_c"', '"_y"', '"_m"',]
GRAMMAR_DICTIONARY['meal_code'] = ['("meal_code(" meal_code_value ")")']
GRAMMAR_DICTIONARY['meal_code_value'] = ['"ap_58"', '"ap_57"', '"d_s"', '"b"', '"ap_55"', '"s_"', '"sd_d"', '"ls"', '"ap_68"', '"ap_80"', '"ap"', '"s"', ]
GRAMMAR_DICTIONARY['airline_code'] = ['("airline_code(" airline_code_value ")")']
GRAMMAR_DICTIONARY['airline_code_value'] = ['"usair"', '"co"', '"ua"', '"delta"', '"as"', '"ff"', '"canadian_airlines_international"', '"us"', '"nx"', '"hp"', '"aa"', '"kw"', '"ml"', '"nw"', '"ac"', '"tw"', '"yx"', '"ea"', '"dl"', '"wn"', '"lh"', '"cp"']
GRAMMAR_DICTIONARY['airport_code'] = ['("airport_code(" airport_code_value ")")']
GRAMMAR_DICTIONARY['airport_code_value'] = ['"dallas"', '"ont"', '"stapelton"', '"bna"', '"bwi"', '"iad"', '"sfo"', '"phl"', '"pit"', '"slc"', '"phx"', '"lax"', '"bur"', '"ind"', '"iah"', '"dtw"', '"las"', '"dal"', '"den"', '"atl"', '"ewr"', '"bos"', '"tpa"', '"jfk"', '"mke"', '"oak"', '"yyz"', '"dfw"', '"cvg"', '"hou"', '"lga"', '"ord"', '"mia"', '"mco"']
GRAMMAR_DICTIONARY['aircraft_code_object'] = ['("aircraft_code(" aircraft_code_value ")")']
GRAMMAR_DICTIONARY['aircraft_code_value'] = ['"m80"', '"dc10"', '"727"', '"d9s"', '"f28"', '"j31"', '"767"', '"734"', '"73s"', '"747"', '"737"', '"733"', '"d10"', '"100"', '"757"', '"72s"']
GRAMMAR_DICTIONARY['city_name'] = ['("city_name(" city_name_value ")")']
GRAMMAR_DICTIONARY['city_name_value'] = ['"cleveland"', '"milwaukee"', '"detroit"', '"los_angeles"', '"miami"', '"salt_lake_city"', '"ontario"', '"tacoma"', '"memphis"', '"denver"', '"san_francisco"', '"new_york"', '"tampa"', '"washington"', '"westchester_county"', '"boston"', '"newark"', '"pittsburgh"', '"charlotte"', '"columbus"', '"atlanta"', '"oakland"', '"kansas_city"', '"st_louis"', '"nashville"', '"chicago"', '"fort_worth"', '"san_jose"', '"dallas"', '"philadelphia"', '"st_petersburg"', '"baltimore"', '"san_diego"', '"cincinnati"', '"long_beach"', '"phoenix"', '"indianapolis"', '"burbank"', '"montreal"', '"seattle"', '"st_paul"', '"minneapolis"', '"houston"', '"orlando"', '"toronto"', '"las_vegas"']
GRAMMAR_DICTIONARY['time'] = ['("time(" time_value ")")']
GRAMMAR_DICTIONARY['time_value'] = [
'"1850"', '"1110"', '"2000"', '"1815"', '"1024"', '"1500"',
'"1900"', '"1600"', '"1300"', '"1800"', '"1200"', '"1628"',
'"1830"', '"823"', '"1245"', '"1524"', '"200"', '"1615"',
'"1230"', '"705"', '"1045"', '"1700"', '"1115"', '"1645"',
'"1730"', '"815"', '"0"', '"500"', '"1205"', '"1940"',
'"1400"', '"1130"', '"2200"', '"645"', '"718"', '"2220"',
'"600"', '"630"', '"800"', '"838"', '"1330"', '"845"', '"1630"',
'"1715"', '"2010"', '"1000"', '"1619"', '"2100"', '"1505"',
'"2400"', '"1923"', '"100"', '"1145"', '"2300"', '"1620"',
'"2023"', '"2358"', '"1425"', '"720"', '"1310"', '"700"', '"650"',
'"1410"', '"1030"', '"1900"', '"1017"', '"1430"', '"900"', '"1930"',
'"1133"', '"1220"', '"2226"', '"1100"', '"819"', '"755"', '"2134"', '"555"', '"1"',
]
GRAMMAR_DICTIONARY['flight_number_object'] = ['("flight_number(" flight_number_value ")")']
GRAMMAR_DICTIONARY['flight_number_value'] = [
'"1291"', '"345"', '"813"', '"71"', '"1059"', '"212"', '"1209"',
'"281"', '"201"', '"324"', '"19"', '"352"', '"137338"', '"4400"',
'"323"', '"505"', '"825"', '"82"', '"279"', '"1055"', '"296"', '"315"',
'"1765"', '"405"', '"771"', '"106"', '"2153"', '"257"', '"402"',
'"343"', '"98"', '"1039"', '"217"', '"539"', '"459"', '"417"',
'"1083"', '"3357"', '"311"', '"210"', '"139"', '"852"', '"838"',
'"415"', '"3724"', '"21"', '"928"', '"269"', '"270"',
'"297"', '"746"', '"1222"', '"271"'
]
GRAMMAR_DICTIONARY['class_description'] = ['("class_description(" class_description_value ")")']
GRAMMAR_DICTIONARY['class_description_value'] = ['"thrift"', '"coach"', '"first"', '"business"']
GRAMMAR_DICTIONARY['day_period'] = ['("day_period(" day_period_value ")")']
GRAMMAR_DICTIONARY['day_period_value'] = ['"early"', '"afternoon"', '"late_evening"', '"late_night"', '"mealtime"', '"evening"', '"pm"', '"daytime"', '"breakfast"', '"morning"', '"late"']
GRAMMAR_DICTIONARY['state_name'] = ['("state_name(" state_name_value ")")']
GRAMMAR_DICTIONARY['state_name_value'] = ['"minnesota"', '"florida"', '"arizona"', '"nevada"', '"california"']
GRAMMAR_DICTIONARY['day_number'] = ['("day_number(" day_number_value ")")']
GRAMMAR_DICTIONARY['day_number_value'] = ['"13"', '"29"', '"28"', '"22"', '"21"', '"16"', '"30"', '"12"', '"18"', '"19"', '"31"', '"20"', '"27"', '"6"', '"26"', '"17"', '"11"', '"10"', '"15"', '"23"', '"24"', '"25"', '"14"', '"1"', '"3"', '"8"', '"5"', '"2"', '"9"', '"4"', '"7"']
GRAMMAR_DICTIONARY['month'] = ['("month(" month_value ")")']
GRAMMAR_DICTIONARY['month_value'] = ['"april"', '"august"', '"may"', '"october"', '"june"', '"november"', '"september"', '"february"', '"december"', '"march"', '"july"', '"january"']
GRAMMAR_DICTIONARY['day'] = ['("day(" day_value ")")']
GRAMMAR_DICTIONARY['day_value'] = ['"monday"', '"wednesday"', '"thursday"', '"tuesday"', '"saturday"', '"friday"', '"sunday"']
GRAMMAR_DICTIONARY['dollar'] = ['("dollar(" dollar_value ")")']
GRAMMAR_DICTIONARY['dollar_value'] = ['"1000"', '"1500"', '"466"', '"1288"', '"300"', '"329"', '"416"', '"124"', '"932"', '"1100"', '"200"', '"500"', '"100"', '"415"', '"150"', '"400"']
GRAMMAR_DICTIONARY['meal_description'] = ['("meal_description(" meal_description_value ")")']
GRAMMAR_DICTIONARY['meal_description_value'] = ['"snack"', '"breakfast"', '"lunch"', '"dinner"']
GRAMMAR_DICTIONARY['integer'] = ['("integer(" integer_value ")")']
GRAMMAR_DICTIONARY['integer_value'] = ['"2"', '"1"', '"3"']
GRAMMAR_DICTIONARY['basis_type'] = ['("basis_type(" basis_type_value ")")']
GRAMMAR_DICTIONARY['basis_type_value'] = ['"737"', '"767"']
GRAMMAR_DICTIONARY['year'] = ['("year(" year_value ")")']
GRAMMAR_DICTIONARY['year_value'] = ['"1991"', '"1993"', '"1992"']
# Unit Relation
GRAMMAR_DICTIONARY['unit_relation'] = [
# Flight
'(is_flight)', '(is_oneway)', '(is_round_trip)', '(is_daily_flight)',
'(is_flight_has_stop)', '(is_non_stop_flight)', '(is_flight_economy)',
'(is_flight_has_meal)', '(is_economy)', '(is_discounted_flight)',
'(is_flight_overnight)', '(is_connecting_flight)',
# Meal
'(is_meal)', '(is_meal_code)',
# Airline
'(is_airline)',
# Transport way
'(is_rapid_transit)', '(is_taxi)', '(is_air_taxi_operation)', '(is_ground_transport_on_weekday)',
'(is_ground_transport)', '(is_limousine)', '(is_rental_car)',
# Aircraft
'(is_flight_turboprop)', '(is_turboprop)', '(aircraft_code)', '(is_aircraft)', '(is_flight_jet)',
# Time
'(is_day_after_tomorrow_flight)', '(is_flight_tonight)', '(is_today_flight)',
'(is_tomorrow_flight)', '(is_flight_on_weekday)', '(is_tomorrow_arrival_flight)',
# Other
'(is_time_zone_code)', '(is_class_of_service)', '(is_city)',
'(is_airport)', '(is_fare_basis_code)', '(is_booking_class_t)',
]
GRAMMAR_DICTIONARY['is_discounted_flight'] = ['("is_discounted_flight(" var ")")']
GRAMMAR_DICTIONARY['is_taxi'] = ['("is_taxi(" var ")")']
GRAMMAR_DICTIONARY['is_economy'] = ['("is_economy(" var ")")']
GRAMMAR_DICTIONARY['is_flight_on_weekday'] = ['("is_flight_on_weekday(" var ")")']
GRAMMAR_DICTIONARY['is_time_zone_code'] = ['("is_time_zone_code(" var ")")']
GRAMMAR_DICTIONARY['is_air_taxi_operation'] = ['("is_air_taxi_operation(" var ")")']
GRAMMAR_DICTIONARY['is_fare_basis_code'] = ['("is_fare_basis_code(" var ")")']
GRAMMAR_DICTIONARY['is_meal_code'] = ['("is_meal_code(" var ")")']
GRAMMAR_DICTIONARY['is_limousine'] = ['("is_limousine(" var ")")']
GRAMMAR_DICTIONARY['is_flight_tonight'] = ['("is_flight_tonight(" var ")")']
GRAMMAR_DICTIONARY['is_tomorrow_arrival_flight'] = ['("is_tomorrow_arrival_flight(" var ")")']
GRAMMAR_DICTIONARY['is_tomorrow_flight'] = ['("is_tomorrow_flight(" var ")")']
GRAMMAR_DICTIONARY['is_daily_flight'] = ['("is_daily_flight(" var ")")']
GRAMMAR_DICTIONARY['_minutes_distant'] = ['("_minutes_distant(" var ")")']
GRAMMAR_DICTIONARY['is_flight'] = ['("is_flight(" var ")")']
GRAMMAR_DICTIONARY['is_city'] = ['("is_city(" var ")")']
GRAMMAR_DICTIONARY['is_booking_class_t'] = ['("is_booking_class_t(" var ")")']
GRAMMAR_DICTIONARY['is_rapid_transit'] = ['("is_rapid_transit(" var ")")']
GRAMMAR_DICTIONARY['is_oneway'] = ['("is_oneway(" var ")")']
GRAMMAR_DICTIONARY['is_airport'] = ['("is_airport(" var ")")']
GRAMMAR_DICTIONARY['is_flight_has_stop'] = ['("is_flight_has_stop(" var ")")']
GRAMMAR_DICTIONARY['aircraft_code'] = ['("aircraft_code(" var ")")']
GRAMMAR_DICTIONARY['is_day_after_tomorrow_flight'] = ['("is_day_after_tomorrow_flight(" var ")")']
GRAMMAR_DICTIONARY['is_airline'] = ['("is_airline(" var ")")']
GRAMMAR_DICTIONARY['is_flight_economy'] = ['("is_flight_economy(" var ")")']
GRAMMAR_DICTIONARY['is_class_of_service'] = ['("is_class_of_service(" var ")")']
GRAMMAR_DICTIONARY['is_aircraft'] = ['("is_aircraft(" var ")")']
GRAMMAR_DICTIONARY['is_today_flight'] = ['("is_today_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_has_meal'] = ['("is_flight_has_meal(" var ")")']
GRAMMAR_DICTIONARY['is_ground_transport'] = ['("is_ground_transport(" var ")")']
GRAMMAR_DICTIONARY['is_non_stop_flight'] = ['("is_non_stop_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_turboprop'] = ['("is_flight_turboprop(" var ")")']
GRAMMAR_DICTIONARY['is_meal'] = ['("is_meal(" var ")")']
GRAMMAR_DICTIONARY['is_round_trip'] = ['("is_round_trip(" var ")")']
GRAMMAR_DICTIONARY['is_ground_transport_on_weekday'] = ['("is_ground_transport_on_weekday(" var ")")']
GRAMMAR_DICTIONARY['is_turboprop'] = ['("is_turboprop(" var ")")']
GRAMMAR_DICTIONARY['is_rental_car'] = ['("is_rental_car(" var ")")']
GRAMMAR_DICTIONARY['is_connecting_flight'] = ['("is_connecting_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_jet'] = ['("is_flight_jet(" var ")")']
GRAMMAR_DICTIONARY['is_flight_overnight'] = ['("is_flight_overnight(" var ")")']
# Binary Predicate
GRAMMAR_DICTIONARY['binary_relation'] = [
# General
'(_named)',
# Flight property
'(is_flight_has_specific_fare_basis_code)', '(is_flight_has_booking_class)',
'(is_flight_stop_at_city)', '(is_flight_on_year)', '(is_flight_during_day)',
'(is_flight_stops_specify_number_of_times)', '(is_flight_meal_code)',
'(is_from)', '(is_flight_day_return)', '(is_flight_day_number_return)',
'(is_flight_departure_time)', '(is_flight_month_return)',
'(is_flight_month_arrival)', '(is_flight_approx_return_time)',
'(is_flight_before_day)', '(is_flight_approx_arrival_time)',
'(is_flight_day_number_arrival)',
'(is_flight_arrival_time)', '(is_flight_with_specific_aircraft)',
'(is_flight_on_day_number)', '(is_flight_on_day)', '(is_flight_manufacturer)',
'(is_flight_aircraft)', '(is_flight_stop_at_airport)',
'(is_flight_during_day_arrival)', '(is_flight_days_from_today)',
'(is_fare_basis_code_class_type)', '(is_flight_after_day)',
'(is_flight_day_arrival)', '(is_flight_approx_departure_time)',
'(is_flight_has_specific_meal)', '(is_next_days_flight)',
'(is_flight_has_class_type)', '(is_to)', '(is_flight_airline)',
'(p_flight_fare)', '(is_flight_number)',
# Airport
'(is_airport_of_city)', '(is_airline_services)', '(is_services)', '(is_from_airports_of_city)',
# Ground Transport
'(is_from_airport)', '(is_to_city)', '(is_loc_t_state)',
# Aircraft
'(is_mf)', '(is_loc_t)', '(is_aircraft_basis_type)', '(is_aircraft_airline)',
# Other
'(is_flight_cost_fare)',
'(is_loc_t_city_time_zone)',
'(is_airline_provide_meal)',
'(is_airline_has_booking_class)',
# Entity
'(minimum_connection_time)', '(p_flight_stop_arrival_time)',
'(p_ground_fare)', '(p_booking_class_fare)',
'(airline_name)', '(abbrev)', '(capacity)', '(minutes_distant)', '(is_time_elapsed)',
'(p_flight_restriction_code)'
]
GRAMMAR_DICTIONARY['airline_name'] = ['("airline_name(" var "," var ")")']
GRAMMAR_DICTIONARY['_named'] = ['("_named(" var "," var ")")']
GRAMMAR_DICTIONARY['is_time_elapsed'] = ['("is_time_elapsed(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_specific_fare_basis_code'] = ['("is_flight_has_specific_fare_basis_code(" var "," var ")")']
GRAMMAR_DICTIONARY['abbrev'] = ['("abbrev(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_during_day'] = ['("is_flight_during_day(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_booking_class'] = ['("is_flight_has_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_has_booking_class'] = ['("is_airline_has_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['capacity'] = ['("capacity(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_airline_code'] = ['("get_flight_airline_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stop_at_city'] = ['("is_flight_stop_at_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_year'] = ['("is_flight_on_year(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stops_specify_number_of_times'] = ['("is_flight_stops_specify_number_of_times(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from_airport'] = ['("is_from_airport(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_meal_code'] = ['("is_flight_meal_code(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_airline_code'] = ['("p_flight_airline_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from'] = ['("is_from(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_return'] = ['("is_flight_day_return(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_fare'] = ['("get_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_number_return'] = ['("is_flight_day_number_return(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_departure_time'] = ['("is_flight_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_month_return'] = ['("is_flight_month_return(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_month_arrival'] = ['("is_flight_month_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_number'] = ['("is_flight_number(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_cost_fare'] = ['("is_flight_cost_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_return_time'] = ['("is_flight_approx_return_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_before_day'] = ['("is_flight_before_day(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_arrival_time'] = ['("is_flight_approx_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airport_of_city'] = ['("is_airport_of_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_number_arrival'] = ['("is_flight_day_number_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_services'] = ['("is_airline_services(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_airline'] = ['("is_flight_airline(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_arrival_time'] = ['("is_flight_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_with_specific_aircraft'] = ['("is_flight_with_specific_aircraft(" var "," var ")")']
GRAMMAR_DICTIONARY['is_mf'] = ['("is_mf(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_aircraft_code'] = ['("get_flight_aircraft_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_day_number'] = ['("is_flight_on_day_number(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t'] = ['("is_loc_t(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_day'] = ['("is_flight_on_day(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_restriction_code'] = ['("get_flight_restriction_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_to_city'] = ['("is_to_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_manufacturer'] = ['("is_flight_manufacturer(" var "," var ")")']
GRAMMAR_DICTIONARY['minutes_distant'] = ['("minutes_distant(" var "," var ")")']
GRAMMAR_DICTIONARY['is_services'] = ['("is_services(" var "," var ")")']
GRAMMAR_DICTIONARY['p_booking_class_fare'] = ['("p_booking_class_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_aircraft_code'] = ['("p_flight_aircraft_code(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_restriction_code'] = ['("p_flight_restriction_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_aircraft'] = ['("is_flight_aircraft(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stop_at_airport'] = ['("is_flight_stop_at_airport(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_during_day_arrival'] = ['("is_flight_during_day_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['departure_time'] = ['("departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['arrival_time'] = ['("arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_fare_basis_code_class_type'] = ['("is_fare_basis_code_class_type(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_after_day'] = ['("is_flight_after_day(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_booking_class'] = ['("p_flight_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['get_number_of_stops'] = ['("get_number_of_stops(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_days_from_today'] = ['("is_flight_days_from_today(" var "," var ")")']
GRAMMAR_DICTIONARY['minimum_connection_time'] = ['("minimum_connection_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_aircraft_basis_type'] = ['("is_aircraft_basis_type(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_arrival'] = ['("is_flight_day_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t_state'] = ['("is_loc_t_state(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_departure_time'] = ['("is_flight_approx_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from_airports_of_city'] = ['("is_from_airports_of_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_specific_meal'] = ['("is_flight_has_specific_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_fare'] = ['("p_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_next_days_flight'] = ['("is_next_days_flight(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_class_type'] = ['("is_flight_has_class_type(" var "," var ")")']
GRAMMAR_DICTIONARY['time_elapsed'] = ['("time_elapsed(" var "," var ")")']
GRAMMAR_DICTIONARY['is_to'] = ['("is_to(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t_city_time_zone'] = ['("is_loc_t_city_time_zone(" var "," var ")")']
GRAMMAR_DICTIONARY['is_aircraft_airline'] = ['("is_aircraft_airline(" var "," var ")")']
GRAMMAR_DICTIONARY['p_ground_fare'] = ['("p_ground_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_provide_meal'] = ['("is_airline_provide_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_meal'] = ['("p_flight_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_stop_arrival_time'] = ['("p_flight_stop_arrival_time(" var "," var ")")']
# Triplet Relations
GRAMMAR_DICTIONARY['triplet_relation'] = ['(miles_distant_between_city)', '(miles_distant)']
GRAMMAR_DICTIONARY['miles_distant_between_city'] = ['("miles_distant_between_city(" var "," var "," var ")")']
GRAMMAR_DICTIONARY['miles_distant'] = ['("miles_distant(" var "," var "," var ")")']
# Meta Predicates
GRAMMAR_DICTIONARY['meta'] = [
'(equals)', '(equals_arrival_time)',
'(larger_than_arrival_time)', '(larger_than_capacity)', '(larger_than_departure_time)',
'(larger_than_number_of_stops)', '(less_than_flight_cost)', '(less_than_departure_time)',
'(less_than_flight_fare)', '(less_than_arrival_time)', '(count)', '(argmax_capacity)',
'(argmax_arrival_time)', '(argmax_departure_time)', '(argmax_get_number_of_stops)',
'(argmax_get_flight_fare)', '(argmax_count)', '(argmin_time_elapsed)',
'(argmin_get_number_of_stops)', '(argmin_time_elapsed)', '(argmin_arrival_time)',
'(argmin_capacity)', '(argmin_departure_time)', '(argmin_get_flight_fare)',
'(argmin_miles_distant)', '(max)', '(min)', '(sum_capacity)', '(sum_get_number_of_stops)'
]
GRAMMAR_DICTIONARY['equals'] = ['("equals(" var "," var ")")']
GRAMMAR_DICTIONARY['equals_arrival_time'] = ['("equals_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_arrival_time'] = ['("larger_than_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_capacity'] = ['("larger_than_capacity(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_departure_time'] = ['("larger_than_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_number_of_stops'] = ['("larger_than_number_of_stops(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_flight_cost'] = ['("less_than_flight_cost(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_departure_time'] = ['("less_than_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_flight_fare'] = ['("less_than_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_arrival_time'] = ['("less_than_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['count'] = ['("count(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY['max'] = ['("_max(" var "," goal ")")']
GRAMMAR_DICTIONARY['min'] = ['("_min(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_capacity'] = ['("argmax_capacity(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_arrival_time'] = ['("argmax_arrival_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_departure_time'] = ['("argmax_departure_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_get_number_of_stops'] = ['("argmax_get_number_of_stops(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_get_flight_fare'] = ['("argmax_get_flight_fare(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_count'] = ['("argmax_count(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_arrival_time'] = ['("argmin_arrival_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_capacity'] = ['("argmin_capacity(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_departure_time'] = ['("argmin_departure_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_get_number_of_stops'] = ['("argmin_get_number_of_stops(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_get_flight_fare'] = ['("argmin_get_flight_fare(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_miles_distant'] = ['("argmin_miles_distant(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_time_elapsed'] = ['("argmin_time_elapsed(" var "," goal ")")']
GRAMMAR_DICTIONARY['sum_capacity'] = ['("sum_capacity(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY['sum_get_number_of_stops'] = ['("sum_get_number_of_stops(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY["ws"] = ['~"\s*"i']
GRAMMAR_DICTIONARY["wsp"] = ['~"\s+"i']
COPY_TERMINAL_SET = {
'fare_basis_code_value', 'meal_code_value', 'airport_code_value', 'airline_code_value',
'aircraft_code_value', 'city_name_value', 'time_value', 'flight_number_value',
'class_description_value', 'day_period_value', 'state_name_value',
'day_number_value', 'month_value', 'day_value', 'dollar_value', 'meal_description_value',
'integer_value', 'basis_type_value', 'year_value',
} | """
Prolog Grammar of ATIS
"""
grammar_dictionary = {}
root_rule = 'statement -> [answer]'
GRAMMAR_DICTIONARY['statement'] = ['(answer ws)']
GRAMMAR_DICTIONARY['answer'] = ['("answer_1(" var "," goal ")")', '("answer_2(" var "," var "," goal ")")', '("answer_3(" var "," var "," var "," goal ")")', '("answer_4(" var "," var "," var "," var "," goal ")")']
GRAMMAR_DICTIONARY['goal'] = ['(declaration)', '(unit_relation)', '(binary_relation)', '(triplet_relation)', '(meta)', '("(" goal conjunction ")")', '("or(" goal conjunction ")")', '("not(" goal conjunction ")")']
GRAMMAR_DICTIONARY['conjunction'] = ['("," goal conjunction)', '""']
GRAMMAR_DICTIONARY['var'] = ['"%s"' % chr(97 + i) for i in range(26)]
GRAMMAR_DICTIONARY['declaration'] = ['("const(" var "," object ")")']
GRAMMAR_DICTIONARY['object'] = ['(fare_basis_code)', '(meal_code)', '(airport_code)', '(airline_code)', '(aircraft_code_object)', '(city_name)', '(time)', '(flight_number_object)', '(class_description)', '(day_period)', '(state_name)', '(day_number)', '(month)', '(day)', '(dollar)', '(meal_description)', '("hour(9)")', '(integer)', '(basis_type)', '(year)', '("days_code(sa)")', '("manufacturer(boeing)")']
GRAMMAR_DICTIONARY['fare_basis_code'] = ['("fare_basis_code(" fare_basis_code_value ")")']
GRAMMAR_DICTIONARY['fare_basis_code_value'] = ['"_qx"', '"_qw"', '"_qo"', '"_fn"', '"_yn"', '"_bh"', '"_k"', '"_b"', '"_h"', '"_f"', '"_q"', '"_c"', '"_y"', '"_m"']
GRAMMAR_DICTIONARY['meal_code'] = ['("meal_code(" meal_code_value ")")']
GRAMMAR_DICTIONARY['meal_code_value'] = ['"ap_58"', '"ap_57"', '"d_s"', '"b"', '"ap_55"', '"s_"', '"sd_d"', '"ls"', '"ap_68"', '"ap_80"', '"ap"', '"s"']
GRAMMAR_DICTIONARY['airline_code'] = ['("airline_code(" airline_code_value ")")']
GRAMMAR_DICTIONARY['airline_code_value'] = ['"usair"', '"co"', '"ua"', '"delta"', '"as"', '"ff"', '"canadian_airlines_international"', '"us"', '"nx"', '"hp"', '"aa"', '"kw"', '"ml"', '"nw"', '"ac"', '"tw"', '"yx"', '"ea"', '"dl"', '"wn"', '"lh"', '"cp"']
GRAMMAR_DICTIONARY['airport_code'] = ['("airport_code(" airport_code_value ")")']
GRAMMAR_DICTIONARY['airport_code_value'] = ['"dallas"', '"ont"', '"stapelton"', '"bna"', '"bwi"', '"iad"', '"sfo"', '"phl"', '"pit"', '"slc"', '"phx"', '"lax"', '"bur"', '"ind"', '"iah"', '"dtw"', '"las"', '"dal"', '"den"', '"atl"', '"ewr"', '"bos"', '"tpa"', '"jfk"', '"mke"', '"oak"', '"yyz"', '"dfw"', '"cvg"', '"hou"', '"lga"', '"ord"', '"mia"', '"mco"']
GRAMMAR_DICTIONARY['aircraft_code_object'] = ['("aircraft_code(" aircraft_code_value ")")']
GRAMMAR_DICTIONARY['aircraft_code_value'] = ['"m80"', '"dc10"', '"727"', '"d9s"', '"f28"', '"j31"', '"767"', '"734"', '"73s"', '"747"', '"737"', '"733"', '"d10"', '"100"', '"757"', '"72s"']
GRAMMAR_DICTIONARY['city_name'] = ['("city_name(" city_name_value ")")']
GRAMMAR_DICTIONARY['city_name_value'] = ['"cleveland"', '"milwaukee"', '"detroit"', '"los_angeles"', '"miami"', '"salt_lake_city"', '"ontario"', '"tacoma"', '"memphis"', '"denver"', '"san_francisco"', '"new_york"', '"tampa"', '"washington"', '"westchester_county"', '"boston"', '"newark"', '"pittsburgh"', '"charlotte"', '"columbus"', '"atlanta"', '"oakland"', '"kansas_city"', '"st_louis"', '"nashville"', '"chicago"', '"fort_worth"', '"san_jose"', '"dallas"', '"philadelphia"', '"st_petersburg"', '"baltimore"', '"san_diego"', '"cincinnati"', '"long_beach"', '"phoenix"', '"indianapolis"', '"burbank"', '"montreal"', '"seattle"', '"st_paul"', '"minneapolis"', '"houston"', '"orlando"', '"toronto"', '"las_vegas"']
GRAMMAR_DICTIONARY['time'] = ['("time(" time_value ")")']
GRAMMAR_DICTIONARY['time_value'] = ['"1850"', '"1110"', '"2000"', '"1815"', '"1024"', '"1500"', '"1900"', '"1600"', '"1300"', '"1800"', '"1200"', '"1628"', '"1830"', '"823"', '"1245"', '"1524"', '"200"', '"1615"', '"1230"', '"705"', '"1045"', '"1700"', '"1115"', '"1645"', '"1730"', '"815"', '"0"', '"500"', '"1205"', '"1940"', '"1400"', '"1130"', '"2200"', '"645"', '"718"', '"2220"', '"600"', '"630"', '"800"', '"838"', '"1330"', '"845"', '"1630"', '"1715"', '"2010"', '"1000"', '"1619"', '"2100"', '"1505"', '"2400"', '"1923"', '"100"', '"1145"', '"2300"', '"1620"', '"2023"', '"2358"', '"1425"', '"720"', '"1310"', '"700"', '"650"', '"1410"', '"1030"', '"1900"', '"1017"', '"1430"', '"900"', '"1930"', '"1133"', '"1220"', '"2226"', '"1100"', '"819"', '"755"', '"2134"', '"555"', '"1"']
GRAMMAR_DICTIONARY['flight_number_object'] = ['("flight_number(" flight_number_value ")")']
GRAMMAR_DICTIONARY['flight_number_value'] = ['"1291"', '"345"', '"813"', '"71"', '"1059"', '"212"', '"1209"', '"281"', '"201"', '"324"', '"19"', '"352"', '"137338"', '"4400"', '"323"', '"505"', '"825"', '"82"', '"279"', '"1055"', '"296"', '"315"', '"1765"', '"405"', '"771"', '"106"', '"2153"', '"257"', '"402"', '"343"', '"98"', '"1039"', '"217"', '"539"', '"459"', '"417"', '"1083"', '"3357"', '"311"', '"210"', '"139"', '"852"', '"838"', '"415"', '"3724"', '"21"', '"928"', '"269"', '"270"', '"297"', '"746"', '"1222"', '"271"']
GRAMMAR_DICTIONARY['class_description'] = ['("class_description(" class_description_value ")")']
GRAMMAR_DICTIONARY['class_description_value'] = ['"thrift"', '"coach"', '"first"', '"business"']
GRAMMAR_DICTIONARY['day_period'] = ['("day_period(" day_period_value ")")']
GRAMMAR_DICTIONARY['day_period_value'] = ['"early"', '"afternoon"', '"late_evening"', '"late_night"', '"mealtime"', '"evening"', '"pm"', '"daytime"', '"breakfast"', '"morning"', '"late"']
GRAMMAR_DICTIONARY['state_name'] = ['("state_name(" state_name_value ")")']
GRAMMAR_DICTIONARY['state_name_value'] = ['"minnesota"', '"florida"', '"arizona"', '"nevada"', '"california"']
GRAMMAR_DICTIONARY['day_number'] = ['("day_number(" day_number_value ")")']
GRAMMAR_DICTIONARY['day_number_value'] = ['"13"', '"29"', '"28"', '"22"', '"21"', '"16"', '"30"', '"12"', '"18"', '"19"', '"31"', '"20"', '"27"', '"6"', '"26"', '"17"', '"11"', '"10"', '"15"', '"23"', '"24"', '"25"', '"14"', '"1"', '"3"', '"8"', '"5"', '"2"', '"9"', '"4"', '"7"']
GRAMMAR_DICTIONARY['month'] = ['("month(" month_value ")")']
GRAMMAR_DICTIONARY['month_value'] = ['"april"', '"august"', '"may"', '"october"', '"june"', '"november"', '"september"', '"february"', '"december"', '"march"', '"july"', '"january"']
GRAMMAR_DICTIONARY['day'] = ['("day(" day_value ")")']
GRAMMAR_DICTIONARY['day_value'] = ['"monday"', '"wednesday"', '"thursday"', '"tuesday"', '"saturday"', '"friday"', '"sunday"']
GRAMMAR_DICTIONARY['dollar'] = ['("dollar(" dollar_value ")")']
GRAMMAR_DICTIONARY['dollar_value'] = ['"1000"', '"1500"', '"466"', '"1288"', '"300"', '"329"', '"416"', '"124"', '"932"', '"1100"', '"200"', '"500"', '"100"', '"415"', '"150"', '"400"']
GRAMMAR_DICTIONARY['meal_description'] = ['("meal_description(" meal_description_value ")")']
GRAMMAR_DICTIONARY['meal_description_value'] = ['"snack"', '"breakfast"', '"lunch"', '"dinner"']
GRAMMAR_DICTIONARY['integer'] = ['("integer(" integer_value ")")']
GRAMMAR_DICTIONARY['integer_value'] = ['"2"', '"1"', '"3"']
GRAMMAR_DICTIONARY['basis_type'] = ['("basis_type(" basis_type_value ")")']
GRAMMAR_DICTIONARY['basis_type_value'] = ['"737"', '"767"']
GRAMMAR_DICTIONARY['year'] = ['("year(" year_value ")")']
GRAMMAR_DICTIONARY['year_value'] = ['"1991"', '"1993"', '"1992"']
GRAMMAR_DICTIONARY['unit_relation'] = ['(is_flight)', '(is_oneway)', '(is_round_trip)', '(is_daily_flight)', '(is_flight_has_stop)', '(is_non_stop_flight)', '(is_flight_economy)', '(is_flight_has_meal)', '(is_economy)', '(is_discounted_flight)', '(is_flight_overnight)', '(is_connecting_flight)', '(is_meal)', '(is_meal_code)', '(is_airline)', '(is_rapid_transit)', '(is_taxi)', '(is_air_taxi_operation)', '(is_ground_transport_on_weekday)', '(is_ground_transport)', '(is_limousine)', '(is_rental_car)', '(is_flight_turboprop)', '(is_turboprop)', '(aircraft_code)', '(is_aircraft)', '(is_flight_jet)', '(is_day_after_tomorrow_flight)', '(is_flight_tonight)', '(is_today_flight)', '(is_tomorrow_flight)', '(is_flight_on_weekday)', '(is_tomorrow_arrival_flight)', '(is_time_zone_code)', '(is_class_of_service)', '(is_city)', '(is_airport)', '(is_fare_basis_code)', '(is_booking_class_t)']
GRAMMAR_DICTIONARY['is_discounted_flight'] = ['("is_discounted_flight(" var ")")']
GRAMMAR_DICTIONARY['is_taxi'] = ['("is_taxi(" var ")")']
GRAMMAR_DICTIONARY['is_economy'] = ['("is_economy(" var ")")']
GRAMMAR_DICTIONARY['is_flight_on_weekday'] = ['("is_flight_on_weekday(" var ")")']
GRAMMAR_DICTIONARY['is_time_zone_code'] = ['("is_time_zone_code(" var ")")']
GRAMMAR_DICTIONARY['is_air_taxi_operation'] = ['("is_air_taxi_operation(" var ")")']
GRAMMAR_DICTIONARY['is_fare_basis_code'] = ['("is_fare_basis_code(" var ")")']
GRAMMAR_DICTIONARY['is_meal_code'] = ['("is_meal_code(" var ")")']
GRAMMAR_DICTIONARY['is_limousine'] = ['("is_limousine(" var ")")']
GRAMMAR_DICTIONARY['is_flight_tonight'] = ['("is_flight_tonight(" var ")")']
GRAMMAR_DICTIONARY['is_tomorrow_arrival_flight'] = ['("is_tomorrow_arrival_flight(" var ")")']
GRAMMAR_DICTIONARY['is_tomorrow_flight'] = ['("is_tomorrow_flight(" var ")")']
GRAMMAR_DICTIONARY['is_daily_flight'] = ['("is_daily_flight(" var ")")']
GRAMMAR_DICTIONARY['_minutes_distant'] = ['("_minutes_distant(" var ")")']
GRAMMAR_DICTIONARY['is_flight'] = ['("is_flight(" var ")")']
GRAMMAR_DICTIONARY['is_city'] = ['("is_city(" var ")")']
GRAMMAR_DICTIONARY['is_booking_class_t'] = ['("is_booking_class_t(" var ")")']
GRAMMAR_DICTIONARY['is_rapid_transit'] = ['("is_rapid_transit(" var ")")']
GRAMMAR_DICTIONARY['is_oneway'] = ['("is_oneway(" var ")")']
GRAMMAR_DICTIONARY['is_airport'] = ['("is_airport(" var ")")']
GRAMMAR_DICTIONARY['is_flight_has_stop'] = ['("is_flight_has_stop(" var ")")']
GRAMMAR_DICTIONARY['aircraft_code'] = ['("aircraft_code(" var ")")']
GRAMMAR_DICTIONARY['is_day_after_tomorrow_flight'] = ['("is_day_after_tomorrow_flight(" var ")")']
GRAMMAR_DICTIONARY['is_airline'] = ['("is_airline(" var ")")']
GRAMMAR_DICTIONARY['is_flight_economy'] = ['("is_flight_economy(" var ")")']
GRAMMAR_DICTIONARY['is_class_of_service'] = ['("is_class_of_service(" var ")")']
GRAMMAR_DICTIONARY['is_aircraft'] = ['("is_aircraft(" var ")")']
GRAMMAR_DICTIONARY['is_today_flight'] = ['("is_today_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_has_meal'] = ['("is_flight_has_meal(" var ")")']
GRAMMAR_DICTIONARY['is_ground_transport'] = ['("is_ground_transport(" var ")")']
GRAMMAR_DICTIONARY['is_non_stop_flight'] = ['("is_non_stop_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_turboprop'] = ['("is_flight_turboprop(" var ")")']
GRAMMAR_DICTIONARY['is_meal'] = ['("is_meal(" var ")")']
GRAMMAR_DICTIONARY['is_round_trip'] = ['("is_round_trip(" var ")")']
GRAMMAR_DICTIONARY['is_ground_transport_on_weekday'] = ['("is_ground_transport_on_weekday(" var ")")']
GRAMMAR_DICTIONARY['is_turboprop'] = ['("is_turboprop(" var ")")']
GRAMMAR_DICTIONARY['is_rental_car'] = ['("is_rental_car(" var ")")']
GRAMMAR_DICTIONARY['is_connecting_flight'] = ['("is_connecting_flight(" var ")")']
GRAMMAR_DICTIONARY['is_flight_jet'] = ['("is_flight_jet(" var ")")']
GRAMMAR_DICTIONARY['is_flight_overnight'] = ['("is_flight_overnight(" var ")")']
GRAMMAR_DICTIONARY['binary_relation'] = ['(_named)', '(is_flight_has_specific_fare_basis_code)', '(is_flight_has_booking_class)', '(is_flight_stop_at_city)', '(is_flight_on_year)', '(is_flight_during_day)', '(is_flight_stops_specify_number_of_times)', '(is_flight_meal_code)', '(is_from)', '(is_flight_day_return)', '(is_flight_day_number_return)', '(is_flight_departure_time)', '(is_flight_month_return)', '(is_flight_month_arrival)', '(is_flight_approx_return_time)', '(is_flight_before_day)', '(is_flight_approx_arrival_time)', '(is_flight_day_number_arrival)', '(is_flight_arrival_time)', '(is_flight_with_specific_aircraft)', '(is_flight_on_day_number)', '(is_flight_on_day)', '(is_flight_manufacturer)', '(is_flight_aircraft)', '(is_flight_stop_at_airport)', '(is_flight_during_day_arrival)', '(is_flight_days_from_today)', '(is_fare_basis_code_class_type)', '(is_flight_after_day)', '(is_flight_day_arrival)', '(is_flight_approx_departure_time)', '(is_flight_has_specific_meal)', '(is_next_days_flight)', '(is_flight_has_class_type)', '(is_to)', '(is_flight_airline)', '(p_flight_fare)', '(is_flight_number)', '(is_airport_of_city)', '(is_airline_services)', '(is_services)', '(is_from_airports_of_city)', '(is_from_airport)', '(is_to_city)', '(is_loc_t_state)', '(is_mf)', '(is_loc_t)', '(is_aircraft_basis_type)', '(is_aircraft_airline)', '(is_flight_cost_fare)', '(is_loc_t_city_time_zone)', '(is_airline_provide_meal)', '(is_airline_has_booking_class)', '(minimum_connection_time)', '(p_flight_stop_arrival_time)', '(p_ground_fare)', '(p_booking_class_fare)', '(airline_name)', '(abbrev)', '(capacity)', '(minutes_distant)', '(is_time_elapsed)', '(p_flight_restriction_code)']
GRAMMAR_DICTIONARY['airline_name'] = ['("airline_name(" var "," var ")")']
GRAMMAR_DICTIONARY['_named'] = ['("_named(" var "," var ")")']
GRAMMAR_DICTIONARY['is_time_elapsed'] = ['("is_time_elapsed(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_specific_fare_basis_code'] = ['("is_flight_has_specific_fare_basis_code(" var "," var ")")']
GRAMMAR_DICTIONARY['abbrev'] = ['("abbrev(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_during_day'] = ['("is_flight_during_day(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_booking_class'] = ['("is_flight_has_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_has_booking_class'] = ['("is_airline_has_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['capacity'] = ['("capacity(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_airline_code'] = ['("get_flight_airline_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stop_at_city'] = ['("is_flight_stop_at_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_year'] = ['("is_flight_on_year(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stops_specify_number_of_times'] = ['("is_flight_stops_specify_number_of_times(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from_airport'] = ['("is_from_airport(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_meal_code'] = ['("is_flight_meal_code(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_airline_code'] = ['("p_flight_airline_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from'] = ['("is_from(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_return'] = ['("is_flight_day_return(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_fare'] = ['("get_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_number_return'] = ['("is_flight_day_number_return(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_departure_time'] = ['("is_flight_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_month_return'] = ['("is_flight_month_return(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_month_arrival'] = ['("is_flight_month_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_number'] = ['("is_flight_number(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_cost_fare'] = ['("is_flight_cost_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_return_time'] = ['("is_flight_approx_return_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_before_day'] = ['("is_flight_before_day(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_arrival_time'] = ['("is_flight_approx_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airport_of_city'] = ['("is_airport_of_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_number_arrival'] = ['("is_flight_day_number_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_services'] = ['("is_airline_services(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_airline'] = ['("is_flight_airline(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_arrival_time'] = ['("is_flight_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_with_specific_aircraft'] = ['("is_flight_with_specific_aircraft(" var "," var ")")']
GRAMMAR_DICTIONARY['is_mf'] = ['("is_mf(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_aircraft_code'] = ['("get_flight_aircraft_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_day_number'] = ['("is_flight_on_day_number(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t'] = ['("is_loc_t(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_on_day'] = ['("is_flight_on_day(" var "," var ")")']
GRAMMAR_DICTIONARY['get_flight_restriction_code'] = ['("get_flight_restriction_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_to_city'] = ['("is_to_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_manufacturer'] = ['("is_flight_manufacturer(" var "," var ")")']
GRAMMAR_DICTIONARY['minutes_distant'] = ['("minutes_distant(" var "," var ")")']
GRAMMAR_DICTIONARY['is_services'] = ['("is_services(" var "," var ")")']
GRAMMAR_DICTIONARY['p_booking_class_fare'] = ['("p_booking_class_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_aircraft_code'] = ['("p_flight_aircraft_code(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_restriction_code'] = ['("p_flight_restriction_code(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_aircraft'] = ['("is_flight_aircraft(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_stop_at_airport'] = ['("is_flight_stop_at_airport(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_during_day_arrival'] = ['("is_flight_during_day_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['departure_time'] = ['("departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['arrival_time'] = ['("arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_fare_basis_code_class_type'] = ['("is_fare_basis_code_class_type(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_after_day'] = ['("is_flight_after_day(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_booking_class'] = ['("p_flight_booking_class(" var "," var ")")']
GRAMMAR_DICTIONARY['get_number_of_stops'] = ['("get_number_of_stops(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_days_from_today'] = ['("is_flight_days_from_today(" var "," var ")")']
GRAMMAR_DICTIONARY['minimum_connection_time'] = ['("minimum_connection_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_aircraft_basis_type'] = ['("is_aircraft_basis_type(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_day_arrival'] = ['("is_flight_day_arrival(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t_state'] = ['("is_loc_t_state(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_approx_departure_time'] = ['("is_flight_approx_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['is_from_airports_of_city'] = ['("is_from_airports_of_city(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_specific_meal'] = ['("is_flight_has_specific_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_fare'] = ['("p_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_next_days_flight'] = ['("is_next_days_flight(" var "," var ")")']
GRAMMAR_DICTIONARY['is_flight_has_class_type'] = ['("is_flight_has_class_type(" var "," var ")")']
GRAMMAR_DICTIONARY['time_elapsed'] = ['("time_elapsed(" var "," var ")")']
GRAMMAR_DICTIONARY['is_to'] = ['("is_to(" var "," var ")")']
GRAMMAR_DICTIONARY['is_loc_t_city_time_zone'] = ['("is_loc_t_city_time_zone(" var "," var ")")']
GRAMMAR_DICTIONARY['is_aircraft_airline'] = ['("is_aircraft_airline(" var "," var ")")']
GRAMMAR_DICTIONARY['p_ground_fare'] = ['("p_ground_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['is_airline_provide_meal'] = ['("is_airline_provide_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_meal'] = ['("p_flight_meal(" var "," var ")")']
GRAMMAR_DICTIONARY['p_flight_stop_arrival_time'] = ['("p_flight_stop_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['triplet_relation'] = ['(miles_distant_between_city)', '(miles_distant)']
GRAMMAR_DICTIONARY['miles_distant_between_city'] = ['("miles_distant_between_city(" var "," var "," var ")")']
GRAMMAR_DICTIONARY['miles_distant'] = ['("miles_distant(" var "," var "," var ")")']
GRAMMAR_DICTIONARY['meta'] = ['(equals)', '(equals_arrival_time)', '(larger_than_arrival_time)', '(larger_than_capacity)', '(larger_than_departure_time)', '(larger_than_number_of_stops)', '(less_than_flight_cost)', '(less_than_departure_time)', '(less_than_flight_fare)', '(less_than_arrival_time)', '(count)', '(argmax_capacity)', '(argmax_arrival_time)', '(argmax_departure_time)', '(argmax_get_number_of_stops)', '(argmax_get_flight_fare)', '(argmax_count)', '(argmin_time_elapsed)', '(argmin_get_number_of_stops)', '(argmin_time_elapsed)', '(argmin_arrival_time)', '(argmin_capacity)', '(argmin_departure_time)', '(argmin_get_flight_fare)', '(argmin_miles_distant)', '(max)', '(min)', '(sum_capacity)', '(sum_get_number_of_stops)']
GRAMMAR_DICTIONARY['equals'] = ['("equals(" var "," var ")")']
GRAMMAR_DICTIONARY['equals_arrival_time'] = ['("equals_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_arrival_time'] = ['("larger_than_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_capacity'] = ['("larger_than_capacity(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_departure_time'] = ['("larger_than_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['larger_than_number_of_stops'] = ['("larger_than_number_of_stops(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_flight_cost'] = ['("less_than_flight_cost(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_departure_time'] = ['("less_than_departure_time(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_flight_fare'] = ['("less_than_flight_fare(" var "," var ")")']
GRAMMAR_DICTIONARY['less_than_arrival_time'] = ['("less_than_arrival_time(" var "," var ")")']
GRAMMAR_DICTIONARY['count'] = ['("count(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY['max'] = ['("_max(" var "," goal ")")']
GRAMMAR_DICTIONARY['min'] = ['("_min(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_capacity'] = ['("argmax_capacity(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_arrival_time'] = ['("argmax_arrival_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_departure_time'] = ['("argmax_departure_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_get_number_of_stops'] = ['("argmax_get_number_of_stops(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_get_flight_fare'] = ['("argmax_get_flight_fare(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmax_count'] = ['("argmax_count(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_arrival_time'] = ['("argmin_arrival_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_capacity'] = ['("argmin_capacity(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_departure_time'] = ['("argmin_departure_time(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_get_number_of_stops'] = ['("argmin_get_number_of_stops(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_get_flight_fare'] = ['("argmin_get_flight_fare(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_miles_distant'] = ['("argmin_miles_distant(" var "," goal ")")']
GRAMMAR_DICTIONARY['argmin_time_elapsed'] = ['("argmin_time_elapsed(" var "," goal ")")']
GRAMMAR_DICTIONARY['sum_capacity'] = ['("sum_capacity(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY['sum_get_number_of_stops'] = ['("sum_get_number_of_stops(" var "," goal "," var ")")']
GRAMMAR_DICTIONARY['ws'] = ['~"\\s*"i']
GRAMMAR_DICTIONARY['wsp'] = ['~"\\s+"i']
copy_terminal_set = {'fare_basis_code_value', 'meal_code_value', 'airport_code_value', 'airline_code_value', 'aircraft_code_value', 'city_name_value', 'time_value', 'flight_number_value', 'class_description_value', 'day_period_value', 'state_name_value', 'day_number_value', 'month_value', 'day_value', 'dollar_value', 'meal_description_value', 'integer_value', 'basis_type_value', 'year_value'} |
var = 'foo'
def ex2():
var = 'bar'
print ('inside the function var is ', var)
ex2()
def ex3():
global var
var = 'bar'
print ('inside the function var is ', var)
ex3()
print ('outside the function var is ', var)
| var = 'foo'
def ex2():
var = 'bar'
print('inside the function var is ', var)
ex2()
def ex3():
global var
var = 'bar'
print('inside the function var is ', var)
ex3()
print('outside the function var is ', var) |
code = bytearray([
0xa9, 0xff,
0x8d, 0x02, 0x60,
0xa9, 0x55, # lda #$55
0x8d, 0x00, 0x60, #sta $6000
0xa9, 0x00, # lda #00
0x8d, 0x00, 0x60, #sta $6000
0x4c, 0x05, 0x80 #jmp 8005 (#lda $55)
])
rom = code + bytearray([0xea] * (32768 - len(code)) )
rom[0x7ffc] = 0x00
rom[0x7ffd] = 0x80
with open("rom.bin", "wb") as out_file:
out_file.write(rom);
| code = bytearray([169, 255, 141, 2, 96, 169, 85, 141, 0, 96, 169, 0, 141, 0, 96, 76, 5, 128])
rom = code + bytearray([234] * (32768 - len(code)))
rom[32764] = 0
rom[32765] = 128
with open('rom.bin', 'wb') as out_file:
out_file.write(rom) |
_sampler = None
def get_sampler():
return _sampler
def set_sampler(sampler):
global _sampler
_sampler = sampler
| _sampler = None
def get_sampler():
return _sampler
def set_sampler(sampler):
global _sampler
_sampler = sampler |
class Node:
def __init__(self,id,parent,val):
self.id=id
self.parent=parent
self.ch1,self.ch2=0,0
self.val=val
self.leaf=True
n=int(input())
orix=[*map(int,input().split())]
x=sorted(orix)
node=dict()
node[1]=Node(1,0,-1)
cnt=1
li=[]
for i in x:
li2=[]
root=node[1]
for j in range(i):
if root.ch1==0:
cnt+=1
node[cnt]=Node(cnt,root.id,0)
root.ch1=cnt
root.leaf=False
root=node[cnt]
li2.append("0")
elif root.ch2==0:
cnt+=1
node[cnt]=Node(cnt,root.id,1)
root.ch2=cnt
if j==i-1:
while root.id!=1:
if node[root.ch1].leaf and node[root.ch2].leaf:
root.leaf=True
root=node[root.parent]
else: break
else: root=node[cnt]
li2.append("1")
elif not node[root.ch1].leaf:
root=node[root.ch1]
li2.append("0")
elif not node[root.ch2].leaf:
root=node[root.ch2]
li2.append("1")
else:
print(-1)
exit(0)
li.append("".join(li2))
print(1)
for i in li:
for j in range(n):
if orix[j]==len(i):
break
orix[j]=i
for i in orix: print(i) | class Node:
def __init__(self, id, parent, val):
self.id = id
self.parent = parent
(self.ch1, self.ch2) = (0, 0)
self.val = val
self.leaf = True
n = int(input())
orix = [*map(int, input().split())]
x = sorted(orix)
node = dict()
node[1] = node(1, 0, -1)
cnt = 1
li = []
for i in x:
li2 = []
root = node[1]
for j in range(i):
if root.ch1 == 0:
cnt += 1
node[cnt] = node(cnt, root.id, 0)
root.ch1 = cnt
root.leaf = False
root = node[cnt]
li2.append('0')
elif root.ch2 == 0:
cnt += 1
node[cnt] = node(cnt, root.id, 1)
root.ch2 = cnt
if j == i - 1:
while root.id != 1:
if node[root.ch1].leaf and node[root.ch2].leaf:
root.leaf = True
root = node[root.parent]
else:
break
else:
root = node[cnt]
li2.append('1')
elif not node[root.ch1].leaf:
root = node[root.ch1]
li2.append('0')
elif not node[root.ch2].leaf:
root = node[root.ch2]
li2.append('1')
else:
print(-1)
exit(0)
li.append(''.join(li2))
print(1)
for i in li:
for j in range(n):
if orix[j] == len(i):
break
orix[j] = i
for i in orix:
print(i) |
#!/usr/bin/env python
# coding=utf-8
'''
@Author: John
@Email: johnjim0816@gmail.com
@Date: 2019-11-15 13:46:12
@LastEditor: John
@LastEditTime: 2020-07-29 22:43:12
@Discription:
@Environment:
'''
class Solution:
def singleNumber(self, nums: List[int]) -> int:
seen_once = seen_twice = 0
for num in nums:
seen_once = ~seen_twice & (seen_once ^ num)
seen_twice = ~seen_once & (seen_twice ^ num)
return seen_once | """
@Author: John
@Email: johnjim0816@gmail.com
@Date: 2019-11-15 13:46:12
@LastEditor: John
@LastEditTime: 2020-07-29 22:43:12
@Discription:
@Environment:
"""
class Solution:
def single_number(self, nums: List[int]) -> int:
seen_once = seen_twice = 0
for num in nums:
seen_once = ~seen_twice & (seen_once ^ num)
seen_twice = ~seen_once & (seen_twice ^ num)
return seen_once |
res = 0
i = 0
nb = int(input())
if nb == -1:
while i != 'F':
i = input()
if i != 'F':
res += int(i)
else:
for x in range(nb):
i = int(input())
res += i
print(res) | res = 0
i = 0
nb = int(input())
if nb == -1:
while i != 'F':
i = input()
if i != 'F':
res += int(i)
else:
for x in range(nb):
i = int(input())
res += i
print(res) |
#
# Example file for working with conditional statements
#
def main():
x, y = 10, 100
# conditional flow uses if, elif, else
if x < y:
print("x is smaller than y")
elif x == y:
print("x has same value as y")
else:
print("x is larger than y")
# conditional statements let you use "a if C else b"
result = "x is less than y" if x < y else "x is same as or larger than y"
print(result)
if __name__ == "__main__":
main()
| def main():
(x, y) = (10, 100)
if x < y:
print('x is smaller than y')
elif x == y:
print('x has same value as y')
else:
print('x is larger than y')
result = 'x is less than y' if x < y else 'x is same as or larger than y'
print(result)
if __name__ == '__main__':
main() |
class AreaLight:
def __init__(self, shape_id, intensity, two_sided = False):
assert(intensity.device.type == 'cpu')
self.shape_id = shape_id
self.intensity = intensity
self.two_sided = two_sided
def state_dict(self):
return {
'shape_id': self.shape_id,
'intensity': self.intensity,
'two_sided': self.two_sided
}
@classmethod
def load_state_dict(cls, state_dict):
return cls(
state_dict['shape_id'],
state_dict['intensity'],
state_dict['two_sided'])
| class Arealight:
def __init__(self, shape_id, intensity, two_sided=False):
assert intensity.device.type == 'cpu'
self.shape_id = shape_id
self.intensity = intensity
self.two_sided = two_sided
def state_dict(self):
return {'shape_id': self.shape_id, 'intensity': self.intensity, 'two_sided': self.two_sided}
@classmethod
def load_state_dict(cls, state_dict):
return cls(state_dict['shape_id'], state_dict['intensity'], state_dict['two_sided']) |
"""
Scaling functions that take PCB and modbus register version numbers, and convert raw
register values into real values.
"""
def scale_5v(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to a voltage (if reverse=False), or convert a value in Volts to raw (if reverse=True).
For now, raw values are hundredths of a volt, positive only.
:param value: raw register contents as a value from 0-65535, or a voltage in Volts
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Volts
"""
if reverse:
return int(value * 100) & 0xFFFF
else:
return value / 100.0
def scale_48v(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to a voltage (if reverse=False), or convert a value in Volts to raw (if reverse=True).
For now, raw values are hundredths of a volt, positive only.
:param value: raw register contents as a value from 0-65535, or a voltage in Volts
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Volts
"""
if reverse:
return int(value * 100) & 0xFFFF
else:
return value / 100.0
def scale_temp(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to deg C (if reverse=False), or convert a value in deg C to raw (if reverse=True).
For now, raw values are hundredths of a deg C, as a signed 16-bit integer value
:param value: raw register contents as a value from 0-65535, or a floating point temperature in degrees
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: value in deg C (if reverse=False), or raw value as an unsigned 16 bit integer
"""
if reverse:
if value < 0:
return (int(value * 100) + 65536) & 0xFFFF
else:
return int(value * 100) & 0xFFFF
else:
if value >= 32768:
value -= 65536
return value / 100.0 # raw_value is a signed 16-bit integer containing temp in 1/100th of a degree
# TODO - fix all the uses (and simulated ports in sim_smartbox) to use no conversion, raw ADU values
def scale_FEMcurrent(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to mA.
Note that for now, this returns the value unchanged, in both directions, until we settle on a final representation.
:param value: raw register contents as a value from 0-65535, or crude estimate of the current in Amps
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in mA
"""
return value
def scale_48vcurrent(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to Amps (if reverse=False), or convert a value in Amps to raw (if reverse=True).
For now, raw values are hundredths of an Amp, positive only.
:param value: raw register contents as a value from 0-65535, or current in Amps
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Amps
"""
if reverse:
return int(value * 100) & 0xFFFF
else:
return value / 100.0
| """
Scaling functions that take PCB and modbus register version numbers, and convert raw
register values into real values.
"""
def scale_5v(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to a voltage (if reverse=False), or convert a value in Volts to raw (if reverse=True).
For now, raw values are hundredths of a volt, positive only.
:param value: raw register contents as a value from 0-65535, or a voltage in Volts
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Volts
"""
if reverse:
return int(value * 100) & 65535
else:
return value / 100.0
def scale_48v(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to a voltage (if reverse=False), or convert a value in Volts to raw (if reverse=True).
For now, raw values are hundredths of a volt, positive only.
:param value: raw register contents as a value from 0-65535, or a voltage in Volts
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Volts
"""
if reverse:
return int(value * 100) & 65535
else:
return value / 100.0
def scale_temp(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to deg C (if reverse=False), or convert a value in deg C to raw (if reverse=True).
For now, raw values are hundredths of a deg C, as a signed 16-bit integer value
:param value: raw register contents as a value from 0-65535, or a floating point temperature in degrees
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: value in deg C (if reverse=False), or raw value as an unsigned 16 bit integer
"""
if reverse:
if value < 0:
return int(value * 100) + 65536 & 65535
else:
return int(value * 100) & 65535
else:
if value >= 32768:
value -= 65536
return value / 100.0
def scale_fe_mcurrent(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to mA.
Note that for now, this returns the value unchanged, in both directions, until we settle on a final representation.
:param value: raw register contents as a value from 0-65535, or crude estimate of the current in Amps
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in mA
"""
return value
def scale_48vcurrent(value, reverse=False, pcb_version=0):
"""
Given a raw register value and the PCB version number, find out what scale and offset are needed, convert the raw
value to Amps (if reverse=False), or convert a value in Amps to raw (if reverse=True).
For now, raw values are hundredths of an Amp, positive only.
:param value: raw register contents as a value from 0-65535, or current in Amps
:param reverse: Boolean, True to perform physical->raw conversion instead of raw->physical
:param pcb_version: integer PCB version number, 0-65535
:return: output_value in Amps
"""
if reverse:
return int(value * 100) & 65535
else:
return value / 100.0 |
#
# PySNMP MIB module CISCO-VOICE-CAS-MODULE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-VOICE-CAS-MODULE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:02:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion")
ciscoMgmt, = mibBuilder.importSymbols("CISCO-SMI", "ciscoMgmt")
EntPhysicalIndexOrZero, = mibBuilder.importSymbols("CISCO-TC", "EntPhysicalIndexOrZero")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
ModuleCompliance, NotificationGroup, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup")
IpAddress, Counter32, TimeTicks, Gauge32, Unsigned32, MibIdentifier, Bits, iso, ObjectIdentity, Counter64, ModuleIdentity, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Counter32", "TimeTicks", "Gauge32", "Unsigned32", "MibIdentifier", "Bits", "iso", "ObjectIdentity", "Counter64", "ModuleIdentity", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32")
TextualConvention, DisplayString, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "RowStatus")
ciscoVoiceCasModuleMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 9, 389))
ciscoVoiceCasModuleMIB.setRevisions(('2004-03-15 00:00',))
if mibBuilder.loadTexts: ciscoVoiceCasModuleMIB.setLastUpdated('200403150000Z')
if mibBuilder.loadTexts: ciscoVoiceCasModuleMIB.setOrganization('Cisco Systems, Inc.')
ciscoVoiceCasModuleNotifs = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 0))
ciscoVoiceCasModuleObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 1))
cvcmCasConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1))
class CvcmCasPatternBitPosition(TextualConvention, Bits):
status = 'current'
namedValues = NamedValues(("dBit", 0), ("cBit", 1), ("bBit", 2), ("aBit", 3))
class CvcmCasBitAction(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
namedValues = NamedValues(("casBitNoAction", 1), ("casBitSetToZero", 2), ("casBitSetToOne", 3), ("casBitInvertBit", 4), ("casBitInvertABit", 5), ("casBitInvertBBit", 6), ("casBitInvertCBit", 7), ("casBitInvertDBit", 8), ("casBitABit", 9), ("casBitBBit", 10), ("casBitCBit", 11), ("casBitDBit", 12))
cvcmABCDBitTemplateConfigTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1), )
if mibBuilder.loadTexts: cvcmABCDBitTemplateConfigTable.setStatus('current')
cvcmABCDBitTemplateConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1), ).setIndexNames((0, "CISCO-VOICE-CAS-MODULE-MIB", "cvcmModuleIndex"), (0, "CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasTemplateIndex"), (0, "CISCO-VOICE-CAS-MODULE-MIB", "cvcmABCDPatternIndex"))
if mibBuilder.loadTexts: cvcmABCDBitTemplateConfigEntry.setStatus('current')
cvcmModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: cvcmModuleIndex.setStatus('current')
cvcmCasTemplateIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 2), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: cvcmCasTemplateIndex.setStatus('current')
cvcmABCDPatternIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 16)))
if mibBuilder.loadTexts: cvcmABCDPatternIndex.setStatus('current')
cvcmModulePhysicalIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 4), EntPhysicalIndexOrZero()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cvcmModulePhysicalIndex.setStatus('current')
cvcmCasTemplateName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 5), SnmpAdminString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasTemplateName.setStatus('current')
cvcmABCDIncomingPattern = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 6), CvcmCasPatternBitPosition()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmABCDIncomingPattern.setStatus('current')
cvcmABCDOutgoingPattern = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 7), CvcmCasPatternBitPosition()).setMaxAccess("readonly")
if mibBuilder.loadTexts: cvcmABCDOutgoingPattern.setStatus('current')
cvcmCasABitAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 8), CvcmCasBitAction().clone('casBitABit')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasABitAction.setStatus('current')
cvcmCasBBitAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 9), CvcmCasBitAction().clone('casBitBBit')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasBBitAction.setStatus('current')
cvcmCasCBitAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 10), CvcmCasBitAction().clone('casBitCBit')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasCBitAction.setStatus('current')
cvcmCasDBitAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 11), CvcmCasBitAction().clone('casBitDBit')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasDBitAction.setStatus('current')
cvcmCasBitRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 12), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cvcmCasBitRowStatus.setStatus('current')
cvcmMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2))
cvcmMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 1))
cvcmMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 2))
ciscoVoiceCasModuleMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 2, 1)).setObjects(("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasBitGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
ciscoVoiceCasModuleMIBCompliance = ciscoVoiceCasModuleMIBCompliance.setStatus('current')
cvcmCasBitGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 1, 1)).setObjects(("CISCO-VOICE-CAS-MODULE-MIB", "cvcmModulePhysicalIndex"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasTemplateName"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmABCDIncomingPattern"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmABCDOutgoingPattern"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasABitAction"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasBBitAction"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasCBitAction"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasDBitAction"), ("CISCO-VOICE-CAS-MODULE-MIB", "cvcmCasBitRowStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cvcmCasBitGroup = cvcmCasBitGroup.setStatus('current')
mibBuilder.exportSymbols("CISCO-VOICE-CAS-MODULE-MIB", cvcmModulePhysicalIndex=cvcmModulePhysicalIndex, ciscoVoiceCasModuleMIB=ciscoVoiceCasModuleMIB, cvcmModuleIndex=cvcmModuleIndex, CvcmCasBitAction=CvcmCasBitAction, cvcmMIBCompliances=cvcmMIBCompliances, PYSNMP_MODULE_ID=ciscoVoiceCasModuleMIB, cvcmABCDOutgoingPattern=cvcmABCDOutgoingPattern, cvcmCasTemplateName=cvcmCasTemplateName, cvcmABCDIncomingPattern=cvcmABCDIncomingPattern, cvcmCasABitAction=cvcmCasABitAction, cvcmCasCBitAction=cvcmCasCBitAction, cvcmCasTemplateIndex=cvcmCasTemplateIndex, cvcmABCDPatternIndex=cvcmABCDPatternIndex, ciscoVoiceCasModuleMIBCompliance=ciscoVoiceCasModuleMIBCompliance, cvcmABCDBitTemplateConfigEntry=cvcmABCDBitTemplateConfigEntry, cvcmCasBitGroup=cvcmCasBitGroup, ciscoVoiceCasModuleNotifs=ciscoVoiceCasModuleNotifs, cvcmCasConfig=cvcmCasConfig, cvcmMIBConformance=cvcmMIBConformance, cvcmCasBitRowStatus=cvcmCasBitRowStatus, ciscoVoiceCasModuleObjects=ciscoVoiceCasModuleObjects, CvcmCasPatternBitPosition=CvcmCasPatternBitPosition, cvcmCasBBitAction=cvcmCasBBitAction, cvcmABCDBitTemplateConfigTable=cvcmABCDBitTemplateConfigTable, cvcmMIBGroups=cvcmMIBGroups, cvcmCasDBitAction=cvcmCasDBitAction)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsUnion')
(cisco_mgmt,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoMgmt')
(ent_physical_index_or_zero,) = mibBuilder.importSymbols('CISCO-TC', 'EntPhysicalIndexOrZero')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(module_compliance, notification_group, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup', 'ObjectGroup')
(ip_address, counter32, time_ticks, gauge32, unsigned32, mib_identifier, bits, iso, object_identity, counter64, module_identity, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Counter32', 'TimeTicks', 'Gauge32', 'Unsigned32', 'MibIdentifier', 'Bits', 'iso', 'ObjectIdentity', 'Counter64', 'ModuleIdentity', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32')
(textual_convention, display_string, row_status) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString', 'RowStatus')
cisco_voice_cas_module_mib = module_identity((1, 3, 6, 1, 4, 1, 9, 9, 389))
ciscoVoiceCasModuleMIB.setRevisions(('2004-03-15 00:00',))
if mibBuilder.loadTexts:
ciscoVoiceCasModuleMIB.setLastUpdated('200403150000Z')
if mibBuilder.loadTexts:
ciscoVoiceCasModuleMIB.setOrganization('Cisco Systems, Inc.')
cisco_voice_cas_module_notifs = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 0))
cisco_voice_cas_module_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 1))
cvcm_cas_config = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1))
class Cvcmcaspatternbitposition(TextualConvention, Bits):
status = 'current'
named_values = named_values(('dBit', 0), ('cBit', 1), ('bBit', 2), ('aBit', 3))
class Cvcmcasbitaction(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
named_values = named_values(('casBitNoAction', 1), ('casBitSetToZero', 2), ('casBitSetToOne', 3), ('casBitInvertBit', 4), ('casBitInvertABit', 5), ('casBitInvertBBit', 6), ('casBitInvertCBit', 7), ('casBitInvertDBit', 8), ('casBitABit', 9), ('casBitBBit', 10), ('casBitCBit', 11), ('casBitDBit', 12))
cvcm_abcd_bit_template_config_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1))
if mibBuilder.loadTexts:
cvcmABCDBitTemplateConfigTable.setStatus('current')
cvcm_abcd_bit_template_config_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1)).setIndexNames((0, 'CISCO-VOICE-CAS-MODULE-MIB', 'cvcmModuleIndex'), (0, 'CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasTemplateIndex'), (0, 'CISCO-VOICE-CAS-MODULE-MIB', 'cvcmABCDPatternIndex'))
if mibBuilder.loadTexts:
cvcmABCDBitTemplateConfigEntry.setStatus('current')
cvcm_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 2147483647)))
if mibBuilder.loadTexts:
cvcmModuleIndex.setStatus('current')
cvcm_cas_template_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 2), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 2147483647)))
if mibBuilder.loadTexts:
cvcmCasTemplateIndex.setStatus('current')
cvcm_abcd_pattern_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 16)))
if mibBuilder.loadTexts:
cvcmABCDPatternIndex.setStatus('current')
cvcm_module_physical_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 4), ent_physical_index_or_zero()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cvcmModulePhysicalIndex.setStatus('current')
cvcm_cas_template_name = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 5), snmp_admin_string()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasTemplateName.setStatus('current')
cvcm_abcd_incoming_pattern = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 6), cvcm_cas_pattern_bit_position()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmABCDIncomingPattern.setStatus('current')
cvcm_abcd_outgoing_pattern = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 7), cvcm_cas_pattern_bit_position()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cvcmABCDOutgoingPattern.setStatus('current')
cvcm_cas_a_bit_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 8), cvcm_cas_bit_action().clone('casBitABit')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasABitAction.setStatus('current')
cvcm_cas_b_bit_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 9), cvcm_cas_bit_action().clone('casBitBBit')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasBBitAction.setStatus('current')
cvcm_cas_c_bit_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 10), cvcm_cas_bit_action().clone('casBitCBit')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasCBitAction.setStatus('current')
cvcm_cas_d_bit_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 11), cvcm_cas_bit_action().clone('casBitDBit')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasDBitAction.setStatus('current')
cvcm_cas_bit_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 389, 1, 1, 1, 1, 12), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cvcmCasBitRowStatus.setStatus('current')
cvcm_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2))
cvcm_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 1))
cvcm_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 2))
cisco_voice_cas_module_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 2, 1)).setObjects(('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasBitGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cisco_voice_cas_module_mib_compliance = ciscoVoiceCasModuleMIBCompliance.setStatus('current')
cvcm_cas_bit_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 389, 2, 1, 1)).setObjects(('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmModulePhysicalIndex'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasTemplateName'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmABCDIncomingPattern'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmABCDOutgoingPattern'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasABitAction'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasBBitAction'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasCBitAction'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasDBitAction'), ('CISCO-VOICE-CAS-MODULE-MIB', 'cvcmCasBitRowStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cvcm_cas_bit_group = cvcmCasBitGroup.setStatus('current')
mibBuilder.exportSymbols('CISCO-VOICE-CAS-MODULE-MIB', cvcmModulePhysicalIndex=cvcmModulePhysicalIndex, ciscoVoiceCasModuleMIB=ciscoVoiceCasModuleMIB, cvcmModuleIndex=cvcmModuleIndex, CvcmCasBitAction=CvcmCasBitAction, cvcmMIBCompliances=cvcmMIBCompliances, PYSNMP_MODULE_ID=ciscoVoiceCasModuleMIB, cvcmABCDOutgoingPattern=cvcmABCDOutgoingPattern, cvcmCasTemplateName=cvcmCasTemplateName, cvcmABCDIncomingPattern=cvcmABCDIncomingPattern, cvcmCasABitAction=cvcmCasABitAction, cvcmCasCBitAction=cvcmCasCBitAction, cvcmCasTemplateIndex=cvcmCasTemplateIndex, cvcmABCDPatternIndex=cvcmABCDPatternIndex, ciscoVoiceCasModuleMIBCompliance=ciscoVoiceCasModuleMIBCompliance, cvcmABCDBitTemplateConfigEntry=cvcmABCDBitTemplateConfigEntry, cvcmCasBitGroup=cvcmCasBitGroup, ciscoVoiceCasModuleNotifs=ciscoVoiceCasModuleNotifs, cvcmCasConfig=cvcmCasConfig, cvcmMIBConformance=cvcmMIBConformance, cvcmCasBitRowStatus=cvcmCasBitRowStatus, ciscoVoiceCasModuleObjects=ciscoVoiceCasModuleObjects, CvcmCasPatternBitPosition=CvcmCasPatternBitPosition, cvcmCasBBitAction=cvcmCasBBitAction, cvcmABCDBitTemplateConfigTable=cvcmABCDBitTemplateConfigTable, cvcmMIBGroups=cvcmMIBGroups, cvcmCasDBitAction=cvcmCasDBitAction) |
#
# PySNMP MIB module CISCOSB-rlInterfaces (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-rlInterfaces
# Produced by pysmi-0.3.4 at Wed May 1 12:24:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, SingleValueConstraint, ValueSizeConstraint, ConstraintsUnion, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsUnion", "ValueRangeConstraint")
rlIfInterfaces, switch001 = mibBuilder.importSymbols("CISCOSB-MIB", "rlIfInterfaces", "switch001")
InterfaceIndexOrZero, ifIndex, InterfaceIndex = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero", "ifIndex", "InterfaceIndex")
PortList, = mibBuilder.importSymbols("Q-BRIDGE-MIB", "PortList")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter32, Gauge32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, Bits, iso, ObjectIdentity, TimeTicks, IpAddress, ModuleIdentity, MibIdentifier, NotificationType, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Gauge32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "Bits", "iso", "ObjectIdentity", "TimeTicks", "IpAddress", "ModuleIdentity", "MibIdentifier", "NotificationType", "Integer32")
RowStatus, DisplayString, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TruthValue", "TextualConvention")
swInterfaces = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43))
swInterfaces.setRevisions(('2013-04-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: swInterfaces.setRevisionsDescriptions(('Added MODULE-IDENTITY',))
if mibBuilder.loadTexts: swInterfaces.setLastUpdated('201304010000Z')
if mibBuilder.loadTexts: swInterfaces.setOrganization('Cisco Small Business')
if mibBuilder.loadTexts: swInterfaces.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>')
if mibBuilder.loadTexts: swInterfaces.setDescription('The private MIB module definition for Switch Interfaces.')
class AutoNegCapabilitiesBits(TextualConvention, Bits):
description = 'Auto negotiation capabilities bits.'
status = 'current'
namedValues = NamedValues(("default", 0), ("unknown", 1), ("tenHalf", 2), ("tenFull", 3), ("fastHalf", 4), ("fastFull", 5), ("gigaHalf", 6), ("gigaFull", 7), ("tenGigaFull", 8))
swIfTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1), )
if mibBuilder.loadTexts: swIfTable.setStatus('current')
if mibBuilder.loadTexts: swIfTable.setDescription('Switch media specific information and configuration of the device interfaces.')
swIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1), ).setIndexNames((0, "CISCOSB-rlInterfaces", "swIfIndex"))
if mibBuilder.loadTexts: swIfEntry.setStatus('current')
if mibBuilder.loadTexts: swIfEntry.setDescription('Defines the contents of each line in the swIfTable table.')
swIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfIndex.setStatus('current')
if mibBuilder.loadTexts: swIfIndex.setDescription('Index to the swIfTable. The interface defined by a particular value of this index is the same interface as identified by the same value of ifIndex (MIB II).')
swIfPhysAddressType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("default", 1), ("reserve", 2))).clone('default')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPhysAddressType.setStatus('obsolete')
if mibBuilder.loadTexts: swIfPhysAddressType.setDescription(' This variable indicates whether the physical address assigned to this interface should be the default one or be chosen from the set of reserved physical addresses of the device.')
swIfDuplexAdminMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("half", 2), ("full", 3))).clone('none')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfDuplexAdminMode.setStatus('current')
if mibBuilder.loadTexts: swIfDuplexAdminMode.setDescription("This variable specifies whether this interface should operate in half duplex or full duplex mode. This specification will take effect only if swIfSpeedDuplexAutoNegotiation is disabled. A value of 'none' is returned if a value of the variable hasn't been set.")
swIfDuplexOperMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("half", 1), ("full", 2), ("hybrid", 3), ("unknown", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfDuplexOperMode.setStatus('current')
if mibBuilder.loadTexts: swIfDuplexOperMode.setDescription(' This variable indicates whether this interface operates in half duplex or full duplex mode. This variable can have the values hybrid or unknown only for a trunk. unknown - only if trunk operative status is not present.')
swIfBackPressureMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfBackPressureMode.setStatus('current')
if mibBuilder.loadTexts: swIfBackPressureMode.setDescription('This variable indicates whether this interface activates back pressure when congested.')
swIfTaggedMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('disable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfTaggedMode.setStatus('current')
if mibBuilder.loadTexts: swIfTaggedMode.setDescription('If enable, this interface operates in tagged mode, i.e all frames sent out through this interface will have the 802.1Q header. If disabled the frames will not be tagged.')
swIfTransceiverType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("regular", 1), ("fiberOptics", 2), ("comboRegular", 3), ("comboFiberOptics", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfTransceiverType.setStatus('current')
if mibBuilder.loadTexts: swIfTransceiverType.setDescription(' This variable indicates the transceiver type of this interface.')
swIfLockAdminStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("locked", 1), ("unlocked", 2))).clone('unlocked')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfLockAdminStatus.setStatus('current')
if mibBuilder.loadTexts: swIfLockAdminStatus.setDescription('This variable indicates whether this interface should operate in locked or unlocked mode. In unlocked mode the device learns all MAC addresses from this port and forwards all frames arrived at this port. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
swIfLockOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("locked", 1), ("unlocked", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfLockOperStatus.setStatus('current')
if mibBuilder.loadTexts: swIfLockOperStatus.setDescription('This variable defines whether this interface operates in locked or unlocked mode. It is locked in each of the following two cases: 1) if swLockAdminStatus is set to locked 2) no IP/IPX interface is defined over this interface and no VLAN contains this interface. In unlocked mode the device learns all MAC addresses from this port and forwards all frames arrived at this port. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
swIfType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("eth10M", 1), ("eth100M", 2), ("eth1000M", 3), ("eth10G", 4), ("unknown", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfType.setStatus('current')
if mibBuilder.loadTexts: swIfType.setDescription(' This variable specifies the type of interface.')
swIfDefaultTag = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfDefaultTag.setStatus('current')
if mibBuilder.loadTexts: swIfDefaultTag.setDescription('This variable specifies the default VLAN tag which will be attached to outgoing frames if swIfTaggedMode for this interface is enabled.')
swIfDefaultPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 7))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfDefaultPriority.setStatus('current')
if mibBuilder.loadTexts: swIfDefaultPriority.setDescription(' This variable specifies the default port priority.')
swIfStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 13), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfStatus.setStatus('current')
if mibBuilder.loadTexts: swIfStatus.setDescription('The status of a table entry. It is used to delete an entry from this table.')
swIfFlowControlMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("on", 1), ("off", 2), ("autoNegotiation", 3), ("enabledRx", 4), ("enabledTx", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfFlowControlMode.setStatus('current')
if mibBuilder.loadTexts: swIfFlowControlMode.setDescription("on - Flow control will be enabled on this interface according to the IEEE 802.3x standard. off - Flow control is disabled. autoNegotiation - Flow control will be enabled or disabled on this interface. If enabled, it will operate as specified by the IEEE 802.3x standard. enabledRx - Flow control will be enabled on this interface for recieved frames. enabledTx - Flow control will be enabled on this interface for transmitted frames. An attempt to set this object to 'enabledRx(4)' or 'enabledTx(5)' will fail on interfaces that do not support operation at greater than 100 Mb/s. In any case, flow control can work only if swIfDuplexOperMode is full.")
swIfSpeedAdminMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 15), Integer32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfSpeedAdminMode.setStatus('current')
if mibBuilder.loadTexts: swIfSpeedAdminMode.setDescription("This variable specifies the required speed of this interface in bits per second. This specification will take effect only if swIfSpeedDuplexAutoNegotiation is disabled. A value of 10 is returned for 10G. A value of 0 is returned if the value of the variable hasn't been set.")
swIfSpeedDuplexAutoNegotiation = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfSpeedDuplexAutoNegotiation.setStatus('current')
if mibBuilder.loadTexts: swIfSpeedDuplexAutoNegotiation.setDescription('If enabled the speed and duplex mode will be set by the device through the autonegotiation process. Otherwise these characteristics will be set according to the values of swIfSpeedAdminMode and swIfSpeedDuplexAutoNegotiation.')
swIfOperFlowControlMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("on", 1), ("off", 2), ("enabledRx", 3), ("enabledTx", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperFlowControlMode.setStatus('current')
if mibBuilder.loadTexts: swIfOperFlowControlMode.setDescription('on - Flow control is enabled on this interface according to the IEEE 802.3x standard. off - Flow control is disabled. enabledRx - Flow control is enabled on this interface for recieved frames. enabledTx - Flow control is enabled on this interface for transmitted frames.')
swIfOperSpeedDuplexAutoNegotiation = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2), ("hybrid", 3), ("unknown", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperSpeedDuplexAutoNegotiation.setStatus('current')
if mibBuilder.loadTexts: swIfOperSpeedDuplexAutoNegotiation.setDescription('If enabled the speed and duplex are determined by the device through the autonegotiation process. If disabled these characteristics are determined according to the values of swIfSpeedAdminMode and swIfDuplexAdminMode. hybrid - only for a trunk. unknown - only for ports that there operative status is not present.')
swIfOperBackPressureMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2), ("hybrid", 3), ("unknown", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperBackPressureMode.setStatus('current')
if mibBuilder.loadTexts: swIfOperBackPressureMode.setDescription('This variable indicates the operative back pressure mode of this interface.')
swIfAdminLockAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("discard", 1), ("forwardNormal", 2), ("discardDisable", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAdminLockAction.setStatus('current')
if mibBuilder.loadTexts: swIfAdminLockAction.setDescription('This variable indicates which action this interface should be taken in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
swIfOperLockAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("discard", 1), ("forwardNormal", 2), ("discardDisable", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperLockAction.setStatus('current')
if mibBuilder.loadTexts: swIfOperLockAction.setDescription('This variable indicates which action this interface actually takes in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
swIfAdminLockTrapEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 22), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAdminLockTrapEnable.setStatus('current')
if mibBuilder.loadTexts: swIfAdminLockTrapEnable.setDescription('This variable indicates whether to create a SNMP trap in the locked mode.')
swIfOperLockTrapEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 23), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperLockTrapEnable.setStatus('current')
if mibBuilder.loadTexts: swIfOperLockTrapEnable.setDescription('This variable indicates whether a SNMP trap can be created in the locked mode.')
swIfOperSuspendedStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 24), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperSuspendedStatus.setStatus('current')
if mibBuilder.loadTexts: swIfOperSuspendedStatus.setDescription('This variable indicates whether the port is suspended or not due to some feature. After reboot this value is false')
swIfLockOperTrapCount = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfLockOperTrapCount.setStatus('current')
if mibBuilder.loadTexts: swIfLockOperTrapCount.setDescription("This variable indicates the trap counter status per ifIndex (i.e. number of received packets since the last trap sent due to a packet which was received on this ifIndex). It's relevant only in locked mode while trap is enabled.")
swIfLockAdminTrapFrequency = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 26), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfLockAdminTrapFrequency.setStatus('current')
if mibBuilder.loadTexts: swIfLockAdminTrapFrequency.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap per ifIndex. It's relevant only in locked mode and in trap enabled.")
swIfReActivate = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 27), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfReActivate.setStatus('current')
if mibBuilder.loadTexts: swIfReActivate.setDescription('This variable reactivates (enables) an ifIndex (which was suspended)')
swIfAdminMdix = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("cross", 1), ("normal", 2), ("auto", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAdminMdix.setStatus('current')
if mibBuilder.loadTexts: swIfAdminMdix.setDescription('The configuration is on a physical port, not include trunks. cross - The interface should force crossover. normal - The interface should not force crossover. auto - Auto mdix is enabled on the interface.')
swIfOperMdix = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 29), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("cross", 1), ("normal", 2), ("unknown", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperMdix.setStatus('current')
if mibBuilder.loadTexts: swIfOperMdix.setDescription('cross - The interface is in crossover mode. normal - The interface is not in crossover mode. unknown - Only for port that its operative status is not present or down.')
swIfHostMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 30), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("single", 1), ("multiple", 2), ("multiple-auth", 3))).clone('single')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfHostMode.setStatus('current')
if mibBuilder.loadTexts: swIfHostMode.setDescription("This variable indicates the 802.1X host mode of a port. Relevant when the port's 802.1X control is auto. In addtion multiple-auth was added.")
swIfSingleHostViolationAdminAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 31), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("discard", 1), ("forwardNormal", 2), ("discardDisable", 3))).clone('discard')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfSingleHostViolationAdminAction.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationAdminAction.setDescription('This variable indicates which action this interface should take in single authorized. Possible actions: discard - every packet is dropped. forwardNormal - every packet is forwarded according to the DST address. discardDisable - drops the first packet and suspends the port.')
swIfSingleHostViolationOperAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 32), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("discard", 1), ("forwardNormal", 2), ("discardDisable", 3))).clone('discard')).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfSingleHostViolationOperAction.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationOperAction.setDescription('This variable indicates which action this interface actually takes in single authorized. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
swIfSingleHostViolationAdminTrapEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 33), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfSingleHostViolationAdminTrapEnable.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationAdminTrapEnable.setDescription('This variable indicates whether to create a SNMP trap in single authorized.')
swIfSingleHostViolationOperTrapEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 34), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfSingleHostViolationOperTrapEnable.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationOperTrapEnable.setDescription('This variable indicates whether a SNMP trap can be created in the single authorized.')
swIfSingleHostViolationOperTrapCount = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 35), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfSingleHostViolationOperTrapCount.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationOperTrapCount.setDescription("This variable indicates the trap counter status per ifIndex (i.e. number of received packets since the last trap sent due to a packet which was received on this ifIndex). It's relevant only in single authorized while trap is enabled.")
swIfSingleHostViolationAdminTrapFrequency = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 36), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfSingleHostViolationAdminTrapFrequency.setStatus('current')
if mibBuilder.loadTexts: swIfSingleHostViolationAdminTrapFrequency.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap per ifIndex. It's relevant only in single authorized and in trap enabled. A value of 0 means that trap is disabled.")
swIfLockLimitationMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 37), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("disabled", 1), ("dynamic", 2), ("secure-permanent", 3), ("secure-delete-on-reset", 4)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfLockLimitationMode.setStatus('current')
if mibBuilder.loadTexts: swIfLockLimitationMode.setDescription("This variable indicates what is the learning limitation on the locked interface. Possible values: disabled - learning is stopped. The dynamic addresses associated with the port are not aged out or relearned on other port as long as the port is locked. dynamic - dynamic addresses can be learned up to the maximum dynamic addresses allowed on the port. Relearning and aging of the dynamic addresses are enabled. The learned addresses aren't kept after reset. secure-permanent - secure addresses can be learned up to the maximum addresses allowed on the port. Relearning and aging of addresses are disabled. The learned addresses are kept after reset. secure-delete-on-reset - secure addresses can be learned up to the maximum addresses allowed on the port. Relearning and aging of addresses are disabled. The learned addresses are not kept after reset.")
swIfLockMaxMacAddresses = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 38), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647)).clone(1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfLockMaxMacAddresses.setStatus('current')
if mibBuilder.loadTexts: swIfLockMaxMacAddresses.setDescription("This variable defines the maximum number of dynamic addresses that can be asscoiated with the locked interface. It isn't relevant in disabled limitation mode.")
swIfLockMacAddressesCount = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 39), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfLockMacAddressesCount.setStatus('current')
if mibBuilder.loadTexts: swIfLockMacAddressesCount.setDescription("This variable indicates the actual number of dynamic addresses that can be asscoiated with the locked interface. It isn't relevant in disabled limitation mode.")
swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 40), AutoNegCapabilitiesBits().clone(namedValues=NamedValues(("default", 0)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities.setStatus('current')
if mibBuilder.loadTexts: swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities.setDescription("Administrative auto negotiation capabilities of the interface that can be advertised when swIfSpeedDuplexAutoNegotiation is enabled. default bit means advertise all the port's capabilities according to its type.")
swIfOperSpeedDuplexAutoNegotiationLocalCapabilities = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 41), AutoNegCapabilitiesBits()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperSpeedDuplexAutoNegotiationLocalCapabilities.setStatus('current')
if mibBuilder.loadTexts: swIfOperSpeedDuplexAutoNegotiationLocalCapabilities.setDescription('Operative auto negotiation capabilities of the remote link. unknown bit means that port operative status is not up.')
swIfSpeedDuplexNegotiationRemoteCapabilities = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 42), AutoNegCapabilitiesBits()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfSpeedDuplexNegotiationRemoteCapabilities.setStatus('current')
if mibBuilder.loadTexts: swIfSpeedDuplexNegotiationRemoteCapabilities.setDescription('Operative auto negotiation capabilities of the remote link. unknown bit means that port operative status is not up, or auto negotiation process not complete, or remote link is not auto negotiation able.')
swIfAdminComboMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 43), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("force-fiber", 1), ("force-copper", 2), ("prefer-fiber", 3), ("prefer-copper", 4))).clone('prefer-fiber')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAdminComboMode.setStatus('current')
if mibBuilder.loadTexts: swIfAdminComboMode.setDescription('This variable specifies the administrative mode of a combo Ethernet interface.')
swIfOperComboMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 44), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("fiber", 1), ("copper", 2), ("unknown", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfOperComboMode.setStatus('current')
if mibBuilder.loadTexts: swIfOperComboMode.setDescription('This variable specifies the operative mode of a combo Ethernet interface.')
swIfAutoNegotiationMasterSlavePreference = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 45), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("preferMaster", 1), ("preferSlave", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfAutoNegotiationMasterSlavePreference.setStatus('current')
if mibBuilder.loadTexts: swIfAutoNegotiationMasterSlavePreference.setDescription('This variable specifies the administrative mode of the Maste-Slave preference in auto negotiation.')
swIfMibVersion = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfMibVersion.setStatus('current')
if mibBuilder.loadTexts: swIfMibVersion.setDescription("The swIfTable Mib's version, the current version is 3.")
swIfPortLockSupport = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("supported", 1), ("notSupported", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfPortLockSupport.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockSupport.setDescription('indicates if the locked port package is supported.')
swIfPortLockActionSupport = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 1)).setFixedLength(1)).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfPortLockActionSupport.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockActionSupport.setDescription('indicates which port lock actions are supported: (bit 0 is the most significant bit) bit 0 - discard bit 1 - forwardNormal bit 2 - discardDisable')
swIfPortLockTrapSupport = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 5), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 1)).setFixedLength(1)).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfPortLockTrapSupport.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockTrapSupport.setDescription('indicates with which port lock actions the trap option is supported (e.g. discard indicates that trap is supported only when the portlock action is discard): (bit 0 is the most significant bit) bit 0 - discard bit 1 - forwardNormal bit 2 - discardDisable')
swIfPortLockIfRangeTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6), )
if mibBuilder.loadTexts: swIfPortLockIfRangeTable.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeTable.setDescription('Port lock interfaces range configuration')
swIfPortLockIfRangeEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1), ).setIndexNames((0, "CISCOSB-rlInterfaces", "swIfPortLockIfRangeIndex"))
if mibBuilder.loadTexts: swIfPortLockIfRangeEntry.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeEntry.setDescription('Defines the contents of each line in the swIfPortLockIfRangeTable table.')
swIfPortLockIfRangeIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: swIfPortLockIfRangeIndex.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeIndex.setDescription('Index to the swIfPortLockIfRangeTable.')
swIfPortLockIfRange = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 2), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPortLockIfRange.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRange.setDescription('The set of interfaces to which the port lock parameters should be configured')
swIfPortLockIfRangeLockStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("locked", 1), ("unlocked", 2))).clone('unlocked')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPortLockIfRangeLockStatus.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeLockStatus.setDescription('This variable indicates whether the interfaces range should operate in locked or unlocked mode. In unlocked mode the device learns all MAC addresses from these interfaces and forwards all frames arrived at these interfaces. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
swIfPortLockIfRangeAction = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("discard", 1), ("forwardNormal", 2), ("discardDisable", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPortLockIfRangeAction.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeAction.setDescription('This variable indicates which action for these interfaces should be take in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
swIfPortLockIfRangeTrapEn = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 5), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPortLockIfRangeTrapEn.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeTrapEn.setDescription('This variable indicates whether to create a SNMP trap in the locked mode.')
swIfPortLockIfRangeTrapFreq = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1000000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfPortLockIfRangeTrapFreq.setStatus('current')
if mibBuilder.loadTexts: swIfPortLockIfRangeTrapFreq.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap for these interfaces. It's relevant only in locked mode and in trap enabled.")
swIfExtTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7), )
if mibBuilder.loadTexts: swIfExtTable.setStatus('current')
if mibBuilder.loadTexts: swIfExtTable.setDescription('Display information and configuration of the device interfaces.')
swIfExtEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
if mibBuilder.loadTexts: swIfExtEntry.setStatus('current')
if mibBuilder.loadTexts: swIfExtEntry.setDescription('Defines the contents of each row in the swIfExtTable.')
swIfExtSFPSpeed = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("default", 1), ("eth100M", 2), ("eth1G", 3))).clone('default')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: swIfExtSFPSpeed.setStatus('current')
if mibBuilder.loadTexts: swIfExtSFPSpeed.setDescription('Configure speed of an SFP Ethernet interface.')
rlIfMibVersion = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfMibVersion.setStatus('current')
if mibBuilder.loadTexts: rlIfMibVersion.setDescription("MIB's version, the current version is 1.")
rlIfNumOfPhPorts = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfNumOfPhPorts.setStatus('current')
if mibBuilder.loadTexts: rlIfNumOfPhPorts.setDescription('Total number of physical ports on this device (including all stack units)')
rlIfMapOfOnPhPorts = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 3), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfMapOfOnPhPorts.setStatus('current')
if mibBuilder.loadTexts: rlIfMapOfOnPhPorts.setDescription("Each bit in this octet string indicates that the correspondig port's ifOperStatus is ON if set. The mapping of port number to bits in this octet string is as follows: The port with the L2 interface number 1 is mapped to the least significant bit of the 1st octet, the port with L2 ifNumber 2 to the next significant bit in the 1st octet, port 8 to the most-significant bit of the in the 1st octet, port 9 to the least significant bit of the 2nd octet, etc. and in general, port n to bit corresponding to 2**((n mod 8) -1) in byte n/8 + 1")
rlIfClearPortMibCounters = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 4), PortList()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfClearPortMibCounters.setStatus('current')
if mibBuilder.loadTexts: rlIfClearPortMibCounters.setDescription('Each bit that is set in this portList represent a port that its mib counters should be reset.')
rlIfNumOfUserDefinedPorts = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 5), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfNumOfUserDefinedPorts.setStatus('current')
if mibBuilder.loadTexts: rlIfNumOfUserDefinedPorts.setDescription('The number of user defined ports on this device.')
rlIfFirstOutOfBandIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfFirstOutOfBandIfIndex.setStatus('current')
if mibBuilder.loadTexts: rlIfFirstOutOfBandIfIndex.setDescription('First ifIndex of out-of-band port. This scalar exists only the device has out of band ports.')
rlIfNumOfLoopbackPorts = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 7), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfNumOfLoopbackPorts.setStatus('current')
if mibBuilder.loadTexts: rlIfNumOfLoopbackPorts.setDescription('The number of loopback ports on this device.')
rlIfFirstLoopbackIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfFirstLoopbackIfIndex.setStatus('current')
if mibBuilder.loadTexts: rlIfFirstLoopbackIfIndex.setDescription('First ifIndex of loopback port. This scalar will exists only if rlIfNumOfLoopbackPorts is different from 0.')
rlIfExistingPortList = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 9), PortList()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfExistingPortList.setStatus('current')
if mibBuilder.loadTexts: rlIfExistingPortList.setDescription("Indicates which ports/trunks exist in the system. It doesn't indicate which are present.")
rlIfBaseMACAddressPerIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 10), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfBaseMACAddressPerIfIndex.setStatus('current')
if mibBuilder.loadTexts: rlIfBaseMACAddressPerIfIndex.setDescription('Indicates if the system will assign a unique MAC per Ethernet port or not.')
rlFlowControlCascadeMode = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlFlowControlCascadeMode.setStatus('current')
if mibBuilder.loadTexts: rlFlowControlCascadeMode.setDescription('enable disable flow control on cascade ports')
rlFlowControlCascadeType = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("internalonly", 1), ("internalexternal", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlFlowControlCascadeType.setStatus('current')
if mibBuilder.loadTexts: rlFlowControlCascadeType.setDescription('define which type of ports will be affected by flow control on cascade ports')
rlFlowControlRxPerSystem = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 13), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlFlowControlRxPerSystem.setStatus('current')
if mibBuilder.loadTexts: rlFlowControlRxPerSystem.setDescription('define if flow control RX is supported per system.')
rlCascadePortProtectionAction = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 14), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlCascadePortProtectionAction.setStatus('current')
if mibBuilder.loadTexts: rlCascadePortProtectionAction.setDescription('As a result of this set all of the local cascade ports will stop being consider unstable and will be force up.')
rlManagementIfIndex = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 15), InterfaceIndex()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlManagementIfIndex.setStatus('current')
if mibBuilder.loadTexts: rlManagementIfIndex.setDescription('Specify L2 bound management interface index in a single IP address system when configurable management interface is supported.')
rlIfClearStackPortsCounters = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 16), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfClearStackPortsCounters.setStatus('current')
if mibBuilder.loadTexts: rlIfClearStackPortsCounters.setDescription('As a result of this set all counters of all external cascade ports will be cleared.')
rlIfClearPortMacAddresses = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 17), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfClearPortMacAddresses.setStatus('current')
if mibBuilder.loadTexts: rlIfClearPortMacAddresses.setDescription('if port is non secure, its all dynamic MAC addresses are cleared. if port is secure, its all secure MAC addresses which have learned or configured are cleared.')
rlIfCutThroughPacketLength = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(257, 16383)).clone(1522)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutThroughPacketLength.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughPacketLength.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode.')
rlIfCutPriorityZero = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 19), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityZero.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityZero.setDescription('Enable or disable cut-Through for priority 0.')
rlIfCutPriorityOne = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 20), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityOne.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityOne.setDescription('Enable or disable cut-Through for priority 1.')
rlIfCutPriorityTwo = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 21), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityTwo.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityTwo.setDescription('Enable or disable cut-Through for priority 2.')
rlIfCutPriorityThree = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 22), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityThree.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityThree.setDescription('Enable or disable cut-Through for priority 3.')
rlIfCutPriorityFour = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 23), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityFour.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityFour.setDescription('Enable or disable cut-Through for priority 4.')
rlIfCutPriorityFive = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 24), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPriorityFive.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPriorityFive.setDescription('Enable or disable cut-Through for priority 5.')
rlIfCutPrioritySix = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 25), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPrioritySix.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPrioritySix.setDescription('Enable or disable cut-Through for priority 6.')
rlIfCutPrioritySeven = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 26), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutPrioritySeven.setStatus('current')
if mibBuilder.loadTexts: rlIfCutPrioritySeven.setDescription('Enable or disable cut-Through for priority 7.')
rlIfCutThroughTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27), )
if mibBuilder.loadTexts: rlIfCutThroughTable.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughTable.setDescription('Information and configuration of cut-through feature.')
rlIfCutThroughEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1), ).setIndexNames((0, "CISCOSB-rlInterfaces", "swIfIndex"))
if mibBuilder.loadTexts: rlIfCutThroughEntry.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughEntry.setDescription('Defines the contents of each line in the swIfTable table.')
rlIfCutThroughPriorityEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 1), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutThroughPriorityEnable.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughPriorityEnable.setDescription('Enable or disable cut-through for a priority for an interface.')
rlIfCutThroughUntaggedEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 2), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlIfCutThroughUntaggedEnable.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughUntaggedEnable.setDescription('Enable or disable cut-through for untagged packets for an interface.')
rlIfCutThroughOperMode = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 3), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlIfCutThroughOperMode.setStatus('current')
if mibBuilder.loadTexts: rlIfCutThroughOperMode.setDescription('Operational mode of spesific cut-through interface.')
rlCutThroughPacketLength = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 28), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlCutThroughPacketLength.setStatus('current')
if mibBuilder.loadTexts: rlCutThroughPacketLength.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode.')
rlCutThroughPacketLengthAfterReset = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 29), Integer32().subtype(subtypeSpec=ValueRangeConstraint(257, 16383)).clone(1522)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlCutThroughPacketLengthAfterReset.setStatus('current')
if mibBuilder.loadTexts: rlCutThroughPacketLengthAfterReset.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode after reset.')
rlCutThroughEnable = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 30), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlCutThroughEnable.setStatus('current')
if mibBuilder.loadTexts: rlCutThroughEnable.setDescription('Cut-Through global enable mode.')
rlCutThroughEnableAfterReset = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 31), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlCutThroughEnableAfterReset.setStatus('current')
if mibBuilder.loadTexts: rlCutThroughEnableAfterReset.setDescription('Cut-Through global enable mode after reset.')
rlFlowControlMode = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 32), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("send-receive", 1), ("receive-only", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlFlowControlMode.setStatus('current')
if mibBuilder.loadTexts: rlFlowControlMode.setDescription('Define which mode will be enabled on flow control enabled ports. The interfaces with enabled flow control will receive pause frames, but will not send flow control pause frames Send-receive: The interfaces with enabled flow control will receive and send pause frames. Receive-only: The interfaces with enabled flow control will receive pause frames, but will not send flow control pause frames.')
mibBuilder.exportSymbols("CISCOSB-rlInterfaces", rlFlowControlCascadeType=rlFlowControlCascadeType, rlIfNumOfPhPorts=rlIfNumOfPhPorts, rlIfFirstLoopbackIfIndex=rlIfFirstLoopbackIfIndex, rlIfNumOfLoopbackPorts=rlIfNumOfLoopbackPorts, swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities=swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities, PYSNMP_MODULE_ID=swInterfaces, swIfMibVersion=swIfMibVersion, rlIfClearPortMacAddresses=rlIfClearPortMacAddresses, swIfStatus=swIfStatus, swIfOperSpeedDuplexAutoNegotiation=swIfOperSpeedDuplexAutoNegotiation, swIfSingleHostViolationOperTrapCount=swIfSingleHostViolationOperTrapCount, rlIfClearPortMibCounters=rlIfClearPortMibCounters, swIfOperFlowControlMode=swIfOperFlowControlMode, swIfAdminMdix=swIfAdminMdix, swIfDuplexAdminMode=swIfDuplexAdminMode, swIfPortLockTrapSupport=swIfPortLockTrapSupport, swIfPortLockIfRangeIndex=swIfPortLockIfRangeIndex, rlIfClearStackPortsCounters=rlIfClearStackPortsCounters, swIfTransceiverType=swIfTransceiverType, swInterfaces=swInterfaces, swIfPortLockSupport=swIfPortLockSupport, swIfDefaultTag=swIfDefaultTag, swIfSingleHostViolationAdminTrapEnable=swIfSingleHostViolationAdminTrapEnable, swIfTable=swIfTable, rlIfCutPriorityThree=rlIfCutPriorityThree, swIfOperLockTrapEnable=swIfOperLockTrapEnable, rlCascadePortProtectionAction=rlCascadePortProtectionAction, rlFlowControlRxPerSystem=rlFlowControlRxPerSystem, swIfType=swIfType, rlIfCutThroughPriorityEnable=rlIfCutThroughPriorityEnable, rlIfCutPriorityTwo=rlIfCutPriorityTwo, swIfHostMode=swIfHostMode, rlIfCutPriorityFour=rlIfCutPriorityFour, rlCutThroughPacketLengthAfterReset=rlCutThroughPacketLengthAfterReset, rlIfMibVersion=rlIfMibVersion, swIfDuplexOperMode=swIfDuplexOperMode, rlIfCutPrioritySix=rlIfCutPrioritySix, AutoNegCapabilitiesBits=AutoNegCapabilitiesBits, rlIfNumOfUserDefinedPorts=rlIfNumOfUserDefinedPorts, rlIfCutPriorityOne=rlIfCutPriorityOne, swIfPortLockActionSupport=swIfPortLockActionSupport, swIfSpeedAdminMode=swIfSpeedAdminMode, rlIfMapOfOnPhPorts=rlIfMapOfOnPhPorts, swIfSingleHostViolationOperTrapEnable=swIfSingleHostViolationOperTrapEnable, swIfOperLockAction=swIfOperLockAction, rlIfCutPrioritySeven=rlIfCutPrioritySeven, rlFlowControlMode=rlFlowControlMode, rlIfExistingPortList=rlIfExistingPortList, rlManagementIfIndex=rlManagementIfIndex, rlIfCutThroughTable=rlIfCutThroughTable, swIfLockOperStatus=swIfLockOperStatus, swIfAdminLockAction=swIfAdminLockAction, swIfOperComboMode=swIfOperComboMode, swIfBackPressureMode=swIfBackPressureMode, rlCutThroughPacketLength=rlCutThroughPacketLength, swIfDefaultPriority=swIfDefaultPriority, swIfOperBackPressureMode=swIfOperBackPressureMode, rlIfCutThroughPacketLength=rlIfCutThroughPacketLength, swIfOperMdix=swIfOperMdix, rlIfFirstOutOfBandIfIndex=rlIfFirstOutOfBandIfIndex, rlIfCutThroughOperMode=rlIfCutThroughOperMode, swIfOperSpeedDuplexAutoNegotiationLocalCapabilities=swIfOperSpeedDuplexAutoNegotiationLocalCapabilities, rlCutThroughEnable=rlCutThroughEnable, swIfOperSuspendedStatus=swIfOperSuspendedStatus, rlCutThroughEnableAfterReset=rlCutThroughEnableAfterReset, swIfSingleHostViolationAdminTrapFrequency=swIfSingleHostViolationAdminTrapFrequency, swIfAdminLockTrapEnable=swIfAdminLockTrapEnable, swIfPhysAddressType=swIfPhysAddressType, swIfSingleHostViolationOperAction=swIfSingleHostViolationOperAction, swIfExtTable=swIfExtTable, swIfPortLockIfRangeTrapEn=swIfPortLockIfRangeTrapEn, swIfPortLockIfRange=swIfPortLockIfRange, swIfPortLockIfRangeLockStatus=swIfPortLockIfRangeLockStatus, swIfLockAdminStatus=swIfLockAdminStatus, swIfReActivate=swIfReActivate, swIfPortLockIfRangeEntry=swIfPortLockIfRangeEntry, swIfLockMacAddressesCount=swIfLockMacAddressesCount, swIfLockAdminTrapFrequency=swIfLockAdminTrapFrequency, rlIfCutThroughUntaggedEnable=rlIfCutThroughUntaggedEnable, rlIfCutPriorityFive=rlIfCutPriorityFive, swIfAdminComboMode=swIfAdminComboMode, swIfIndex=swIfIndex, swIfPortLockIfRangeAction=swIfPortLockIfRangeAction, swIfFlowControlMode=swIfFlowControlMode, rlIfBaseMACAddressPerIfIndex=rlIfBaseMACAddressPerIfIndex, swIfPortLockIfRangeTrapFreq=swIfPortLockIfRangeTrapFreq, swIfEntry=swIfEntry, swIfSingleHostViolationAdminAction=swIfSingleHostViolationAdminAction, swIfExtSFPSpeed=swIfExtSFPSpeed, swIfPortLockIfRangeTable=swIfPortLockIfRangeTable, rlFlowControlCascadeMode=rlFlowControlCascadeMode, rlIfCutThroughEntry=rlIfCutThroughEntry, swIfTaggedMode=swIfTaggedMode, swIfAutoNegotiationMasterSlavePreference=swIfAutoNegotiationMasterSlavePreference, swIfSpeedDuplexAutoNegotiation=swIfSpeedDuplexAutoNegotiation, swIfLockOperTrapCount=swIfLockOperTrapCount, swIfSpeedDuplexNegotiationRemoteCapabilities=swIfSpeedDuplexNegotiationRemoteCapabilities, swIfExtEntry=swIfExtEntry, swIfLockLimitationMode=swIfLockLimitationMode, swIfLockMaxMacAddresses=swIfLockMaxMacAddresses, rlIfCutPriorityZero=rlIfCutPriorityZero)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, constraints_union, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsUnion', 'ValueRangeConstraint')
(rl_if_interfaces, switch001) = mibBuilder.importSymbols('CISCOSB-MIB', 'rlIfInterfaces', 'switch001')
(interface_index_or_zero, if_index, interface_index) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero', 'ifIndex', 'InterfaceIndex')
(port_list,) = mibBuilder.importSymbols('Q-BRIDGE-MIB', 'PortList')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(counter32, gauge32, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, bits, iso, object_identity, time_ticks, ip_address, module_identity, mib_identifier, notification_type, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'Gauge32', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'Bits', 'iso', 'ObjectIdentity', 'TimeTicks', 'IpAddress', 'ModuleIdentity', 'MibIdentifier', 'NotificationType', 'Integer32')
(row_status, display_string, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'DisplayString', 'TruthValue', 'TextualConvention')
sw_interfaces = module_identity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43))
swInterfaces.setRevisions(('2013-04-01 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
swInterfaces.setRevisionsDescriptions(('Added MODULE-IDENTITY',))
if mibBuilder.loadTexts:
swInterfaces.setLastUpdated('201304010000Z')
if mibBuilder.loadTexts:
swInterfaces.setOrganization('Cisco Small Business')
if mibBuilder.loadTexts:
swInterfaces.setContactInfo('Postal: 170 West Tasman Drive San Jose , CA 95134-1706 USA Website: Cisco Small Business Home http://www.cisco.com/smb>;, Cisco Small Business Support Community <http://www.cisco.com/go/smallbizsupport>')
if mibBuilder.loadTexts:
swInterfaces.setDescription('The private MIB module definition for Switch Interfaces.')
class Autonegcapabilitiesbits(TextualConvention, Bits):
description = 'Auto negotiation capabilities bits.'
status = 'current'
named_values = named_values(('default', 0), ('unknown', 1), ('tenHalf', 2), ('tenFull', 3), ('fastHalf', 4), ('fastFull', 5), ('gigaHalf', 6), ('gigaFull', 7), ('tenGigaFull', 8))
sw_if_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1))
if mibBuilder.loadTexts:
swIfTable.setStatus('current')
if mibBuilder.loadTexts:
swIfTable.setDescription('Switch media specific information and configuration of the device interfaces.')
sw_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1)).setIndexNames((0, 'CISCOSB-rlInterfaces', 'swIfIndex'))
if mibBuilder.loadTexts:
swIfEntry.setStatus('current')
if mibBuilder.loadTexts:
swIfEntry.setDescription('Defines the contents of each line in the swIfTable table.')
sw_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfIndex.setStatus('current')
if mibBuilder.loadTexts:
swIfIndex.setDescription('Index to the swIfTable. The interface defined by a particular value of this index is the same interface as identified by the same value of ifIndex (MIB II).')
sw_if_phys_address_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('default', 1), ('reserve', 2))).clone('default')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPhysAddressType.setStatus('obsolete')
if mibBuilder.loadTexts:
swIfPhysAddressType.setDescription(' This variable indicates whether the physical address assigned to this interface should be the default one or be chosen from the set of reserved physical addresses of the device.')
sw_if_duplex_admin_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('none', 1), ('half', 2), ('full', 3))).clone('none')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfDuplexAdminMode.setStatus('current')
if mibBuilder.loadTexts:
swIfDuplexAdminMode.setDescription("This variable specifies whether this interface should operate in half duplex or full duplex mode. This specification will take effect only if swIfSpeedDuplexAutoNegotiation is disabled. A value of 'none' is returned if a value of the variable hasn't been set.")
sw_if_duplex_oper_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('half', 1), ('full', 2), ('hybrid', 3), ('unknown', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfDuplexOperMode.setStatus('current')
if mibBuilder.loadTexts:
swIfDuplexOperMode.setDescription(' This variable indicates whether this interface operates in half duplex or full duplex mode. This variable can have the values hybrid or unknown only for a trunk. unknown - only if trunk operative status is not present.')
sw_if_back_pressure_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfBackPressureMode.setStatus('current')
if mibBuilder.loadTexts:
swIfBackPressureMode.setDescription('This variable indicates whether this interface activates back pressure when congested.')
sw_if_tagged_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2))).clone('disable')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfTaggedMode.setStatus('current')
if mibBuilder.loadTexts:
swIfTaggedMode.setDescription('If enable, this interface operates in tagged mode, i.e all frames sent out through this interface will have the 802.1Q header. If disabled the frames will not be tagged.')
sw_if_transceiver_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('regular', 1), ('fiberOptics', 2), ('comboRegular', 3), ('comboFiberOptics', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfTransceiverType.setStatus('current')
if mibBuilder.loadTexts:
swIfTransceiverType.setDescription(' This variable indicates the transceiver type of this interface.')
sw_if_lock_admin_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('locked', 1), ('unlocked', 2))).clone('unlocked')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfLockAdminStatus.setStatus('current')
if mibBuilder.loadTexts:
swIfLockAdminStatus.setDescription('This variable indicates whether this interface should operate in locked or unlocked mode. In unlocked mode the device learns all MAC addresses from this port and forwards all frames arrived at this port. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
sw_if_lock_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('locked', 1), ('unlocked', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfLockOperStatus.setStatus('current')
if mibBuilder.loadTexts:
swIfLockOperStatus.setDescription('This variable defines whether this interface operates in locked or unlocked mode. It is locked in each of the following two cases: 1) if swLockAdminStatus is set to locked 2) no IP/IPX interface is defined over this interface and no VLAN contains this interface. In unlocked mode the device learns all MAC addresses from this port and forwards all frames arrived at this port. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
sw_if_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('eth10M', 1), ('eth100M', 2), ('eth1000M', 3), ('eth10G', 4), ('unknown', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfType.setStatus('current')
if mibBuilder.loadTexts:
swIfType.setDescription(' This variable specifies the type of interface.')
sw_if_default_tag = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 11), integer32().subtype(subtypeSpec=value_range_constraint(0, 4095))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfDefaultTag.setStatus('current')
if mibBuilder.loadTexts:
swIfDefaultTag.setDescription('This variable specifies the default VLAN tag which will be attached to outgoing frames if swIfTaggedMode for this interface is enabled.')
sw_if_default_priority = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 12), integer32().subtype(subtypeSpec=value_range_constraint(0, 7))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfDefaultPriority.setStatus('current')
if mibBuilder.loadTexts:
swIfDefaultPriority.setDescription(' This variable specifies the default port priority.')
sw_if_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 13), row_status()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfStatus.setStatus('current')
if mibBuilder.loadTexts:
swIfStatus.setDescription('The status of a table entry. It is used to delete an entry from this table.')
sw_if_flow_control_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('on', 1), ('off', 2), ('autoNegotiation', 3), ('enabledRx', 4), ('enabledTx', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfFlowControlMode.setStatus('current')
if mibBuilder.loadTexts:
swIfFlowControlMode.setDescription("on - Flow control will be enabled on this interface according to the IEEE 802.3x standard. off - Flow control is disabled. autoNegotiation - Flow control will be enabled or disabled on this interface. If enabled, it will operate as specified by the IEEE 802.3x standard. enabledRx - Flow control will be enabled on this interface for recieved frames. enabledTx - Flow control will be enabled on this interface for transmitted frames. An attempt to set this object to 'enabledRx(4)' or 'enabledTx(5)' will fail on interfaces that do not support operation at greater than 100 Mb/s. In any case, flow control can work only if swIfDuplexOperMode is full.")
sw_if_speed_admin_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 15), integer32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfSpeedAdminMode.setStatus('current')
if mibBuilder.loadTexts:
swIfSpeedAdminMode.setDescription("This variable specifies the required speed of this interface in bits per second. This specification will take effect only if swIfSpeedDuplexAutoNegotiation is disabled. A value of 10 is returned for 10G. A value of 0 is returned if the value of the variable hasn't been set.")
sw_if_speed_duplex_auto_negotiation = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 16), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfSpeedDuplexAutoNegotiation.setStatus('current')
if mibBuilder.loadTexts:
swIfSpeedDuplexAutoNegotiation.setDescription('If enabled the speed and duplex mode will be set by the device through the autonegotiation process. Otherwise these characteristics will be set according to the values of swIfSpeedAdminMode and swIfSpeedDuplexAutoNegotiation.')
sw_if_oper_flow_control_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 17), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('on', 1), ('off', 2), ('enabledRx', 3), ('enabledTx', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperFlowControlMode.setStatus('current')
if mibBuilder.loadTexts:
swIfOperFlowControlMode.setDescription('on - Flow control is enabled on this interface according to the IEEE 802.3x standard. off - Flow control is disabled. enabledRx - Flow control is enabled on this interface for recieved frames. enabledTx - Flow control is enabled on this interface for transmitted frames.')
sw_if_oper_speed_duplex_auto_negotiation = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 18), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2), ('hybrid', 3), ('unknown', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperSpeedDuplexAutoNegotiation.setStatus('current')
if mibBuilder.loadTexts:
swIfOperSpeedDuplexAutoNegotiation.setDescription('If enabled the speed and duplex are determined by the device through the autonegotiation process. If disabled these characteristics are determined according to the values of swIfSpeedAdminMode and swIfDuplexAdminMode. hybrid - only for a trunk. unknown - only for ports that there operative status is not present.')
sw_if_oper_back_pressure_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 19), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('enable', 1), ('disable', 2), ('hybrid', 3), ('unknown', 4)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperBackPressureMode.setStatus('current')
if mibBuilder.loadTexts:
swIfOperBackPressureMode.setDescription('This variable indicates the operative back pressure mode of this interface.')
sw_if_admin_lock_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 20), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('discard', 1), ('forwardNormal', 2), ('discardDisable', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAdminLockAction.setStatus('current')
if mibBuilder.loadTexts:
swIfAdminLockAction.setDescription('This variable indicates which action this interface should be taken in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
sw_if_oper_lock_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 21), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('discard', 1), ('forwardNormal', 2), ('discardDisable', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperLockAction.setStatus('current')
if mibBuilder.loadTexts:
swIfOperLockAction.setDescription('This variable indicates which action this interface actually takes in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
sw_if_admin_lock_trap_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 22), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAdminLockTrapEnable.setStatus('current')
if mibBuilder.loadTexts:
swIfAdminLockTrapEnable.setDescription('This variable indicates whether to create a SNMP trap in the locked mode.')
sw_if_oper_lock_trap_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 23), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperLockTrapEnable.setStatus('current')
if mibBuilder.loadTexts:
swIfOperLockTrapEnable.setDescription('This variable indicates whether a SNMP trap can be created in the locked mode.')
sw_if_oper_suspended_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 24), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperSuspendedStatus.setStatus('current')
if mibBuilder.loadTexts:
swIfOperSuspendedStatus.setDescription('This variable indicates whether the port is suspended or not due to some feature. After reboot this value is false')
sw_if_lock_oper_trap_count = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 25), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfLockOperTrapCount.setStatus('current')
if mibBuilder.loadTexts:
swIfLockOperTrapCount.setDescription("This variable indicates the trap counter status per ifIndex (i.e. number of received packets since the last trap sent due to a packet which was received on this ifIndex). It's relevant only in locked mode while trap is enabled.")
sw_if_lock_admin_trap_frequency = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 26), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfLockAdminTrapFrequency.setStatus('current')
if mibBuilder.loadTexts:
swIfLockAdminTrapFrequency.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap per ifIndex. It's relevant only in locked mode and in trap enabled.")
sw_if_re_activate = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 27), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfReActivate.setStatus('current')
if mibBuilder.loadTexts:
swIfReActivate.setDescription('This variable reactivates (enables) an ifIndex (which was suspended)')
sw_if_admin_mdix = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 28), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('cross', 1), ('normal', 2), ('auto', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAdminMdix.setStatus('current')
if mibBuilder.loadTexts:
swIfAdminMdix.setDescription('The configuration is on a physical port, not include trunks. cross - The interface should force crossover. normal - The interface should not force crossover. auto - Auto mdix is enabled on the interface.')
sw_if_oper_mdix = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 29), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('cross', 1), ('normal', 2), ('unknown', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperMdix.setStatus('current')
if mibBuilder.loadTexts:
swIfOperMdix.setDescription('cross - The interface is in crossover mode. normal - The interface is not in crossover mode. unknown - Only for port that its operative status is not present or down.')
sw_if_host_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 30), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('single', 1), ('multiple', 2), ('multiple-auth', 3))).clone('single')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfHostMode.setStatus('current')
if mibBuilder.loadTexts:
swIfHostMode.setDescription("This variable indicates the 802.1X host mode of a port. Relevant when the port's 802.1X control is auto. In addtion multiple-auth was added.")
sw_if_single_host_violation_admin_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 31), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('discard', 1), ('forwardNormal', 2), ('discardDisable', 3))).clone('discard')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminAction.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminAction.setDescription('This variable indicates which action this interface should take in single authorized. Possible actions: discard - every packet is dropped. forwardNormal - every packet is forwarded according to the DST address. discardDisable - drops the first packet and suspends the port.')
sw_if_single_host_violation_oper_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 32), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('discard', 1), ('forwardNormal', 2), ('discardDisable', 3))).clone('discard')).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperAction.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperAction.setDescription('This variable indicates which action this interface actually takes in single authorized. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
sw_if_single_host_violation_admin_trap_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 33), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminTrapEnable.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminTrapEnable.setDescription('This variable indicates whether to create a SNMP trap in single authorized.')
sw_if_single_host_violation_oper_trap_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 34), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperTrapEnable.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperTrapEnable.setDescription('This variable indicates whether a SNMP trap can be created in the single authorized.')
sw_if_single_host_violation_oper_trap_count = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 35), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperTrapCount.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationOperTrapCount.setDescription("This variable indicates the trap counter status per ifIndex (i.e. number of received packets since the last trap sent due to a packet which was received on this ifIndex). It's relevant only in single authorized while trap is enabled.")
sw_if_single_host_violation_admin_trap_frequency = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 36), integer32().subtype(subtypeSpec=value_range_constraint(0, 1000000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminTrapFrequency.setStatus('current')
if mibBuilder.loadTexts:
swIfSingleHostViolationAdminTrapFrequency.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap per ifIndex. It's relevant only in single authorized and in trap enabled. A value of 0 means that trap is disabled.")
sw_if_lock_limitation_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 37), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('disabled', 1), ('dynamic', 2), ('secure-permanent', 3), ('secure-delete-on-reset', 4)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfLockLimitationMode.setStatus('current')
if mibBuilder.loadTexts:
swIfLockLimitationMode.setDescription("This variable indicates what is the learning limitation on the locked interface. Possible values: disabled - learning is stopped. The dynamic addresses associated with the port are not aged out or relearned on other port as long as the port is locked. dynamic - dynamic addresses can be learned up to the maximum dynamic addresses allowed on the port. Relearning and aging of the dynamic addresses are enabled. The learned addresses aren't kept after reset. secure-permanent - secure addresses can be learned up to the maximum addresses allowed on the port. Relearning and aging of addresses are disabled. The learned addresses are kept after reset. secure-delete-on-reset - secure addresses can be learned up to the maximum addresses allowed on the port. Relearning and aging of addresses are disabled. The learned addresses are not kept after reset.")
sw_if_lock_max_mac_addresses = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 38), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647)).clone(1)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfLockMaxMacAddresses.setStatus('current')
if mibBuilder.loadTexts:
swIfLockMaxMacAddresses.setDescription("This variable defines the maximum number of dynamic addresses that can be asscoiated with the locked interface. It isn't relevant in disabled limitation mode.")
sw_if_lock_mac_addresses_count = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 39), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfLockMacAddressesCount.setStatus('current')
if mibBuilder.loadTexts:
swIfLockMacAddressesCount.setDescription("This variable indicates the actual number of dynamic addresses that can be asscoiated with the locked interface. It isn't relevant in disabled limitation mode.")
sw_if_admin_speed_duplex_auto_negotiation_local_capabilities = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 40), auto_neg_capabilities_bits().clone(namedValues=named_values(('default', 0)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities.setStatus('current')
if mibBuilder.loadTexts:
swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities.setDescription("Administrative auto negotiation capabilities of the interface that can be advertised when swIfSpeedDuplexAutoNegotiation is enabled. default bit means advertise all the port's capabilities according to its type.")
sw_if_oper_speed_duplex_auto_negotiation_local_capabilities = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 41), auto_neg_capabilities_bits()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperSpeedDuplexAutoNegotiationLocalCapabilities.setStatus('current')
if mibBuilder.loadTexts:
swIfOperSpeedDuplexAutoNegotiationLocalCapabilities.setDescription('Operative auto negotiation capabilities of the remote link. unknown bit means that port operative status is not up.')
sw_if_speed_duplex_negotiation_remote_capabilities = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 42), auto_neg_capabilities_bits()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfSpeedDuplexNegotiationRemoteCapabilities.setStatus('current')
if mibBuilder.loadTexts:
swIfSpeedDuplexNegotiationRemoteCapabilities.setDescription('Operative auto negotiation capabilities of the remote link. unknown bit means that port operative status is not up, or auto negotiation process not complete, or remote link is not auto negotiation able.')
sw_if_admin_combo_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 43), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('force-fiber', 1), ('force-copper', 2), ('prefer-fiber', 3), ('prefer-copper', 4))).clone('prefer-fiber')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAdminComboMode.setStatus('current')
if mibBuilder.loadTexts:
swIfAdminComboMode.setDescription('This variable specifies the administrative mode of a combo Ethernet interface.')
sw_if_oper_combo_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 44), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('fiber', 1), ('copper', 2), ('unknown', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfOperComboMode.setStatus('current')
if mibBuilder.loadTexts:
swIfOperComboMode.setDescription('This variable specifies the operative mode of a combo Ethernet interface.')
sw_if_auto_negotiation_master_slave_preference = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 1, 1, 45), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('preferMaster', 1), ('preferSlave', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfAutoNegotiationMasterSlavePreference.setStatus('current')
if mibBuilder.loadTexts:
swIfAutoNegotiationMasterSlavePreference.setDescription('This variable specifies the administrative mode of the Maste-Slave preference in auto negotiation.')
sw_if_mib_version = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfMibVersion.setStatus('current')
if mibBuilder.loadTexts:
swIfMibVersion.setDescription("The swIfTable Mib's version, the current version is 3.")
sw_if_port_lock_support = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('supported', 1), ('notSupported', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfPortLockSupport.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockSupport.setDescription('indicates if the locked port package is supported.')
sw_if_port_lock_action_support = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 4), octet_string().subtype(subtypeSpec=value_size_constraint(1, 1)).setFixedLength(1)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfPortLockActionSupport.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockActionSupport.setDescription('indicates which port lock actions are supported: (bit 0 is the most significant bit) bit 0 - discard bit 1 - forwardNormal bit 2 - discardDisable')
sw_if_port_lock_trap_support = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 5), octet_string().subtype(subtypeSpec=value_size_constraint(1, 1)).setFixedLength(1)).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfPortLockTrapSupport.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockTrapSupport.setDescription('indicates with which port lock actions the trap option is supported (e.g. discard indicates that trap is supported only when the portlock action is discard): (bit 0 is the most significant bit) bit 0 - discard bit 1 - forwardNormal bit 2 - discardDisable')
sw_if_port_lock_if_range_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6))
if mibBuilder.loadTexts:
swIfPortLockIfRangeTable.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeTable.setDescription('Port lock interfaces range configuration')
sw_if_port_lock_if_range_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1)).setIndexNames((0, 'CISCOSB-rlInterfaces', 'swIfPortLockIfRangeIndex'))
if mibBuilder.loadTexts:
swIfPortLockIfRangeEntry.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeEntry.setDescription('Defines the contents of each line in the swIfPortLockIfRangeTable table.')
sw_if_port_lock_if_range_index = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
swIfPortLockIfRangeIndex.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeIndex.setDescription('Index to the swIfPortLockIfRangeTable.')
sw_if_port_lock_if_range = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 2), port_list()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPortLockIfRange.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRange.setDescription('The set of interfaces to which the port lock parameters should be configured')
sw_if_port_lock_if_range_lock_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('locked', 1), ('unlocked', 2))).clone('unlocked')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPortLockIfRangeLockStatus.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeLockStatus.setDescription('This variable indicates whether the interfaces range should operate in locked or unlocked mode. In unlocked mode the device learns all MAC addresses from these interfaces and forwards all frames arrived at these interfaces. In locked mode no new MAC addresses are learned and only frames with known source MAC addresses are forwarded.')
sw_if_port_lock_if_range_action = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('discard', 1), ('forwardNormal', 2), ('discardDisable', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPortLockIfRangeAction.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeAction.setDescription('This variable indicates which action for these interfaces should be take in locked mode and therefore relevant only in locked mode. Possible actions: discard(1) - every packet is dropped. forwardNormal(2) - every packet is forwarded according to the DST address. discardDisable(3) - drops the first packet and suspends the port.')
sw_if_port_lock_if_range_trap_en = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 5), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPortLockIfRangeTrapEn.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeTrapEn.setDescription('This variable indicates whether to create a SNMP trap in the locked mode.')
sw_if_port_lock_if_range_trap_freq = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 6, 1, 6), integer32().subtype(subtypeSpec=value_range_constraint(1, 1000000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfPortLockIfRangeTrapFreq.setStatus('current')
if mibBuilder.loadTexts:
swIfPortLockIfRangeTrapFreq.setDescription("This variable indicates the minimal frequency (in seconds) of sending a trap for these interfaces. It's relevant only in locked mode and in trap enabled.")
sw_if_ext_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7))
if mibBuilder.loadTexts:
swIfExtTable.setStatus('current')
if mibBuilder.loadTexts:
swIfExtTable.setDescription('Display information and configuration of the device interfaces.')
sw_if_ext_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex'))
if mibBuilder.loadTexts:
swIfExtEntry.setStatus('current')
if mibBuilder.loadTexts:
swIfExtEntry.setDescription('Defines the contents of each row in the swIfExtTable.')
sw_if_ext_sfp_speed = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 43, 7, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('default', 1), ('eth100M', 2), ('eth1G', 3))).clone('default')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
swIfExtSFPSpeed.setStatus('current')
if mibBuilder.loadTexts:
swIfExtSFPSpeed.setDescription('Configure speed of an SFP Ethernet interface.')
rl_if_mib_version = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 1), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfMibVersion.setStatus('current')
if mibBuilder.loadTexts:
rlIfMibVersion.setDescription("MIB's version, the current version is 1.")
rl_if_num_of_ph_ports = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 2), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfNumOfPhPorts.setStatus('current')
if mibBuilder.loadTexts:
rlIfNumOfPhPorts.setDescription('Total number of physical ports on this device (including all stack units)')
rl_if_map_of_on_ph_ports = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 3), octet_string()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfMapOfOnPhPorts.setStatus('current')
if mibBuilder.loadTexts:
rlIfMapOfOnPhPorts.setDescription("Each bit in this octet string indicates that the correspondig port's ifOperStatus is ON if set. The mapping of port number to bits in this octet string is as follows: The port with the L2 interface number 1 is mapped to the least significant bit of the 1st octet, the port with L2 ifNumber 2 to the next significant bit in the 1st octet, port 8 to the most-significant bit of the in the 1st octet, port 9 to the least significant bit of the 2nd octet, etc. and in general, port n to bit corresponding to 2**((n mod 8) -1) in byte n/8 + 1")
rl_if_clear_port_mib_counters = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 4), port_list()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfClearPortMibCounters.setStatus('current')
if mibBuilder.loadTexts:
rlIfClearPortMibCounters.setDescription('Each bit that is set in this portList represent a port that its mib counters should be reset.')
rl_if_num_of_user_defined_ports = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 5), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfNumOfUserDefinedPorts.setStatus('current')
if mibBuilder.loadTexts:
rlIfNumOfUserDefinedPorts.setDescription('The number of user defined ports on this device.')
rl_if_first_out_of_band_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 6), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfFirstOutOfBandIfIndex.setStatus('current')
if mibBuilder.loadTexts:
rlIfFirstOutOfBandIfIndex.setDescription('First ifIndex of out-of-band port. This scalar exists only the device has out of band ports.')
rl_if_num_of_loopback_ports = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 7), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfNumOfLoopbackPorts.setStatus('current')
if mibBuilder.loadTexts:
rlIfNumOfLoopbackPorts.setDescription('The number of loopback ports on this device.')
rl_if_first_loopback_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 8), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfFirstLoopbackIfIndex.setStatus('current')
if mibBuilder.loadTexts:
rlIfFirstLoopbackIfIndex.setDescription('First ifIndex of loopback port. This scalar will exists only if rlIfNumOfLoopbackPorts is different from 0.')
rl_if_existing_port_list = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 9), port_list()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfExistingPortList.setStatus('current')
if mibBuilder.loadTexts:
rlIfExistingPortList.setDescription("Indicates which ports/trunks exist in the system. It doesn't indicate which are present.")
rl_if_base_mac_address_per_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 10), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfBaseMACAddressPerIfIndex.setStatus('current')
if mibBuilder.loadTexts:
rlIfBaseMACAddressPerIfIndex.setDescription('Indicates if the system will assign a unique MAC per Ethernet port or not.')
rl_flow_control_cascade_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlFlowControlCascadeMode.setStatus('current')
if mibBuilder.loadTexts:
rlFlowControlCascadeMode.setDescription('enable disable flow control on cascade ports')
rl_flow_control_cascade_type = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('internalonly', 1), ('internalexternal', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlFlowControlCascadeType.setStatus('current')
if mibBuilder.loadTexts:
rlFlowControlCascadeType.setDescription('define which type of ports will be affected by flow control on cascade ports')
rl_flow_control_rx_per_system = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 13), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlFlowControlRxPerSystem.setStatus('current')
if mibBuilder.loadTexts:
rlFlowControlRxPerSystem.setDescription('define if flow control RX is supported per system.')
rl_cascade_port_protection_action = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 14), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlCascadePortProtectionAction.setStatus('current')
if mibBuilder.loadTexts:
rlCascadePortProtectionAction.setDescription('As a result of this set all of the local cascade ports will stop being consider unstable and will be force up.')
rl_management_if_index = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 15), interface_index()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlManagementIfIndex.setStatus('current')
if mibBuilder.loadTexts:
rlManagementIfIndex.setDescription('Specify L2 bound management interface index in a single IP address system when configurable management interface is supported.')
rl_if_clear_stack_ports_counters = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 16), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfClearStackPortsCounters.setStatus('current')
if mibBuilder.loadTexts:
rlIfClearStackPortsCounters.setDescription('As a result of this set all counters of all external cascade ports will be cleared.')
rl_if_clear_port_mac_addresses = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 17), interface_index_or_zero()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfClearPortMacAddresses.setStatus('current')
if mibBuilder.loadTexts:
rlIfClearPortMacAddresses.setDescription('if port is non secure, its all dynamic MAC addresses are cleared. if port is secure, its all secure MAC addresses which have learned or configured are cleared.')
rl_if_cut_through_packet_length = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 18), integer32().subtype(subtypeSpec=value_range_constraint(257, 16383)).clone(1522)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutThroughPacketLength.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughPacketLength.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode.')
rl_if_cut_priority_zero = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 19), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityZero.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityZero.setDescription('Enable or disable cut-Through for priority 0.')
rl_if_cut_priority_one = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 20), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityOne.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityOne.setDescription('Enable or disable cut-Through for priority 1.')
rl_if_cut_priority_two = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 21), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityTwo.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityTwo.setDescription('Enable or disable cut-Through for priority 2.')
rl_if_cut_priority_three = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 22), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityThree.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityThree.setDescription('Enable or disable cut-Through for priority 3.')
rl_if_cut_priority_four = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 23), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityFour.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityFour.setDescription('Enable or disable cut-Through for priority 4.')
rl_if_cut_priority_five = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 24), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPriorityFive.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPriorityFive.setDescription('Enable or disable cut-Through for priority 5.')
rl_if_cut_priority_six = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 25), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPrioritySix.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPrioritySix.setDescription('Enable or disable cut-Through for priority 6.')
rl_if_cut_priority_seven = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 26), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutPrioritySeven.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutPrioritySeven.setDescription('Enable or disable cut-Through for priority 7.')
rl_if_cut_through_table = mib_table((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27))
if mibBuilder.loadTexts:
rlIfCutThroughTable.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughTable.setDescription('Information and configuration of cut-through feature.')
rl_if_cut_through_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1)).setIndexNames((0, 'CISCOSB-rlInterfaces', 'swIfIndex'))
if mibBuilder.loadTexts:
rlIfCutThroughEntry.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughEntry.setDescription('Defines the contents of each line in the swIfTable table.')
rl_if_cut_through_priority_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 1), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutThroughPriorityEnable.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughPriorityEnable.setDescription('Enable or disable cut-through for a priority for an interface.')
rl_if_cut_through_untagged_enable = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 2), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlIfCutThroughUntaggedEnable.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughUntaggedEnable.setDescription('Enable or disable cut-through for untagged packets for an interface.')
rl_if_cut_through_oper_mode = mib_table_column((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 27, 1, 3), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlIfCutThroughOperMode.setStatus('current')
if mibBuilder.loadTexts:
rlIfCutThroughOperMode.setDescription('Operational mode of spesific cut-through interface.')
rl_cut_through_packet_length = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 28), integer32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlCutThroughPacketLength.setStatus('current')
if mibBuilder.loadTexts:
rlCutThroughPacketLength.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode.')
rl_cut_through_packet_length_after_reset = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 29), integer32().subtype(subtypeSpec=value_range_constraint(257, 16383)).clone(1522)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlCutThroughPacketLengthAfterReset.setStatus('current')
if mibBuilder.loadTexts:
rlCutThroughPacketLengthAfterReset.setDescription('The default packet length that is assigned to a packet in the Cut-Through mode after reset.')
rl_cut_through_enable = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 30), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
rlCutThroughEnable.setStatus('current')
if mibBuilder.loadTexts:
rlCutThroughEnable.setDescription('Cut-Through global enable mode.')
rl_cut_through_enable_after_reset = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 31), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlCutThroughEnableAfterReset.setStatus('current')
if mibBuilder.loadTexts:
rlCutThroughEnableAfterReset.setDescription('Cut-Through global enable mode after reset.')
rl_flow_control_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 54, 32), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('send-receive', 1), ('receive-only', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
rlFlowControlMode.setStatus('current')
if mibBuilder.loadTexts:
rlFlowControlMode.setDescription('Define which mode will be enabled on flow control enabled ports. The interfaces with enabled flow control will receive pause frames, but will not send flow control pause frames Send-receive: The interfaces with enabled flow control will receive and send pause frames. Receive-only: The interfaces with enabled flow control will receive pause frames, but will not send flow control pause frames.')
mibBuilder.exportSymbols('CISCOSB-rlInterfaces', rlFlowControlCascadeType=rlFlowControlCascadeType, rlIfNumOfPhPorts=rlIfNumOfPhPorts, rlIfFirstLoopbackIfIndex=rlIfFirstLoopbackIfIndex, rlIfNumOfLoopbackPorts=rlIfNumOfLoopbackPorts, swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities=swIfAdminSpeedDuplexAutoNegotiationLocalCapabilities, PYSNMP_MODULE_ID=swInterfaces, swIfMibVersion=swIfMibVersion, rlIfClearPortMacAddresses=rlIfClearPortMacAddresses, swIfStatus=swIfStatus, swIfOperSpeedDuplexAutoNegotiation=swIfOperSpeedDuplexAutoNegotiation, swIfSingleHostViolationOperTrapCount=swIfSingleHostViolationOperTrapCount, rlIfClearPortMibCounters=rlIfClearPortMibCounters, swIfOperFlowControlMode=swIfOperFlowControlMode, swIfAdminMdix=swIfAdminMdix, swIfDuplexAdminMode=swIfDuplexAdminMode, swIfPortLockTrapSupport=swIfPortLockTrapSupport, swIfPortLockIfRangeIndex=swIfPortLockIfRangeIndex, rlIfClearStackPortsCounters=rlIfClearStackPortsCounters, swIfTransceiverType=swIfTransceiverType, swInterfaces=swInterfaces, swIfPortLockSupport=swIfPortLockSupport, swIfDefaultTag=swIfDefaultTag, swIfSingleHostViolationAdminTrapEnable=swIfSingleHostViolationAdminTrapEnable, swIfTable=swIfTable, rlIfCutPriorityThree=rlIfCutPriorityThree, swIfOperLockTrapEnable=swIfOperLockTrapEnable, rlCascadePortProtectionAction=rlCascadePortProtectionAction, rlFlowControlRxPerSystem=rlFlowControlRxPerSystem, swIfType=swIfType, rlIfCutThroughPriorityEnable=rlIfCutThroughPriorityEnable, rlIfCutPriorityTwo=rlIfCutPriorityTwo, swIfHostMode=swIfHostMode, rlIfCutPriorityFour=rlIfCutPriorityFour, rlCutThroughPacketLengthAfterReset=rlCutThroughPacketLengthAfterReset, rlIfMibVersion=rlIfMibVersion, swIfDuplexOperMode=swIfDuplexOperMode, rlIfCutPrioritySix=rlIfCutPrioritySix, AutoNegCapabilitiesBits=AutoNegCapabilitiesBits, rlIfNumOfUserDefinedPorts=rlIfNumOfUserDefinedPorts, rlIfCutPriorityOne=rlIfCutPriorityOne, swIfPortLockActionSupport=swIfPortLockActionSupport, swIfSpeedAdminMode=swIfSpeedAdminMode, rlIfMapOfOnPhPorts=rlIfMapOfOnPhPorts, swIfSingleHostViolationOperTrapEnable=swIfSingleHostViolationOperTrapEnable, swIfOperLockAction=swIfOperLockAction, rlIfCutPrioritySeven=rlIfCutPrioritySeven, rlFlowControlMode=rlFlowControlMode, rlIfExistingPortList=rlIfExistingPortList, rlManagementIfIndex=rlManagementIfIndex, rlIfCutThroughTable=rlIfCutThroughTable, swIfLockOperStatus=swIfLockOperStatus, swIfAdminLockAction=swIfAdminLockAction, swIfOperComboMode=swIfOperComboMode, swIfBackPressureMode=swIfBackPressureMode, rlCutThroughPacketLength=rlCutThroughPacketLength, swIfDefaultPriority=swIfDefaultPriority, swIfOperBackPressureMode=swIfOperBackPressureMode, rlIfCutThroughPacketLength=rlIfCutThroughPacketLength, swIfOperMdix=swIfOperMdix, rlIfFirstOutOfBandIfIndex=rlIfFirstOutOfBandIfIndex, rlIfCutThroughOperMode=rlIfCutThroughOperMode, swIfOperSpeedDuplexAutoNegotiationLocalCapabilities=swIfOperSpeedDuplexAutoNegotiationLocalCapabilities, rlCutThroughEnable=rlCutThroughEnable, swIfOperSuspendedStatus=swIfOperSuspendedStatus, rlCutThroughEnableAfterReset=rlCutThroughEnableAfterReset, swIfSingleHostViolationAdminTrapFrequency=swIfSingleHostViolationAdminTrapFrequency, swIfAdminLockTrapEnable=swIfAdminLockTrapEnable, swIfPhysAddressType=swIfPhysAddressType, swIfSingleHostViolationOperAction=swIfSingleHostViolationOperAction, swIfExtTable=swIfExtTable, swIfPortLockIfRangeTrapEn=swIfPortLockIfRangeTrapEn, swIfPortLockIfRange=swIfPortLockIfRange, swIfPortLockIfRangeLockStatus=swIfPortLockIfRangeLockStatus, swIfLockAdminStatus=swIfLockAdminStatus, swIfReActivate=swIfReActivate, swIfPortLockIfRangeEntry=swIfPortLockIfRangeEntry, swIfLockMacAddressesCount=swIfLockMacAddressesCount, swIfLockAdminTrapFrequency=swIfLockAdminTrapFrequency, rlIfCutThroughUntaggedEnable=rlIfCutThroughUntaggedEnable, rlIfCutPriorityFive=rlIfCutPriorityFive, swIfAdminComboMode=swIfAdminComboMode, swIfIndex=swIfIndex, swIfPortLockIfRangeAction=swIfPortLockIfRangeAction, swIfFlowControlMode=swIfFlowControlMode, rlIfBaseMACAddressPerIfIndex=rlIfBaseMACAddressPerIfIndex, swIfPortLockIfRangeTrapFreq=swIfPortLockIfRangeTrapFreq, swIfEntry=swIfEntry, swIfSingleHostViolationAdminAction=swIfSingleHostViolationAdminAction, swIfExtSFPSpeed=swIfExtSFPSpeed, swIfPortLockIfRangeTable=swIfPortLockIfRangeTable, rlFlowControlCascadeMode=rlFlowControlCascadeMode, rlIfCutThroughEntry=rlIfCutThroughEntry, swIfTaggedMode=swIfTaggedMode, swIfAutoNegotiationMasterSlavePreference=swIfAutoNegotiationMasterSlavePreference, swIfSpeedDuplexAutoNegotiation=swIfSpeedDuplexAutoNegotiation, swIfLockOperTrapCount=swIfLockOperTrapCount, swIfSpeedDuplexNegotiationRemoteCapabilities=swIfSpeedDuplexNegotiationRemoteCapabilities, swIfExtEntry=swIfExtEntry, swIfLockLimitationMode=swIfLockLimitationMode, swIfLockMaxMacAddresses=swIfLockMaxMacAddresses, rlIfCutPriorityZero=rlIfCutPriorityZero) |
def solveQuestion(inputPath):
fileP = open(inputPath, 'r')
fileLines = fileP.readlines()
fileP.close()
newPosition = []
numRows = len(fileLines)
numCols = len(fileLines[0].strip('\n'))
for line in fileLines:
currentLine = []
for grid in line.strip('\n'):
currentLine.append(grid)
newPosition.append(currentLine)
lastPosition = []
counter = 0
while lastPosition != newPosition:
lastPosition = list(newPosition)
newPosition =[]
counter += 1
for row in range(numRows):
currentLine = []
for col in range(numCols):
if lastPosition[row][col] == '.':
currentLine.append('.')
continue
numNeighbors = getNeighbors(lastPosition, row, col, numRows, numCols)
if numNeighbors == 0 and lastPosition[row][col] == 'L':
currentLine.append('#')
elif numNeighbors >= 4 and lastPosition[row][col] == '#':
currentLine.append('L')
else:
currentLine.append(lastPosition[row][col])
newPosition.append(currentLine)
totalOccupied = 0
for position in newPosition:
totalOccupied += ''.join(position).count('#')
return totalOccupied
def getNeighbors(lastPosition, row, col, maxRow, maxCol):
indexMove = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
counter = 0
for index in indexMove:
rowActual = row + index[0]
colActual = col + index[1]
if rowActual < 0 or colActual < 0:
continue
if rowActual == maxRow:
continue
if colActual == maxCol:
continue
if lastPosition[rowActual][colActual] == '#':
counter += 1
return counter
print(solveQuestion('InputD11Q1.txt'))
| def solve_question(inputPath):
file_p = open(inputPath, 'r')
file_lines = fileP.readlines()
fileP.close()
new_position = []
num_rows = len(fileLines)
num_cols = len(fileLines[0].strip('\n'))
for line in fileLines:
current_line = []
for grid in line.strip('\n'):
currentLine.append(grid)
newPosition.append(currentLine)
last_position = []
counter = 0
while lastPosition != newPosition:
last_position = list(newPosition)
new_position = []
counter += 1
for row in range(numRows):
current_line = []
for col in range(numCols):
if lastPosition[row][col] == '.':
currentLine.append('.')
continue
num_neighbors = get_neighbors(lastPosition, row, col, numRows, numCols)
if numNeighbors == 0 and lastPosition[row][col] == 'L':
currentLine.append('#')
elif numNeighbors >= 4 and lastPosition[row][col] == '#':
currentLine.append('L')
else:
currentLine.append(lastPosition[row][col])
newPosition.append(currentLine)
total_occupied = 0
for position in newPosition:
total_occupied += ''.join(position).count('#')
return totalOccupied
def get_neighbors(lastPosition, row, col, maxRow, maxCol):
index_move = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
counter = 0
for index in indexMove:
row_actual = row + index[0]
col_actual = col + index[1]
if rowActual < 0 or colActual < 0:
continue
if rowActual == maxRow:
continue
if colActual == maxCol:
continue
if lastPosition[rowActual][colActual] == '#':
counter += 1
return counter
print(solve_question('InputD11Q1.txt')) |
"""
The trick here is that I am using the new_ls parameter as a list to append.
Since this list is created on first call to the function it is the same object that
I append to.
"""
def rc(ls, new_ls=[]):
for x in ls:
if isinstance(x, list):
rc(x, new_ls)
else:
new_ls.append(x)
return new_ls
| """
The trick here is that I am using the new_ls parameter as a list to append.
Since this list is created on first call to the function it is the same object that
I append to.
"""
def rc(ls, new_ls=[]):
for x in ls:
if isinstance(x, list):
rc(x, new_ls)
else:
new_ls.append(x)
return new_ls |
n = int(input())
if n%2 != 0:
print('Weird')
else:
if n in range(2, 6):
print('Not Weird')
if n in range(6, 21):
print('Weird')
if n > 20:
print('Not Weird')
| n = int(input())
if n % 2 != 0:
print('Weird')
else:
if n in range(2, 6):
print('Not Weird')
if n in range(6, 21):
print('Weird')
if n > 20:
print('Not Weird') |
def add_numbers(start, end):
total=0
for i in range(start,end+1):
total=total+i
return total
test1 = add_numbers(333, 777)
print(test1)
| def add_numbers(start, end):
total = 0
for i in range(start, end + 1):
total = total + i
return total
test1 = add_numbers(333, 777)
print(test1) |
MOD = 10 ** 9 + 7
n, k = map(int, input().split())
dp = [0] * (k + 1)
ans = 0
for x in range(k, 0, -1):
dp[x] = pow(k // x, n, MOD)
for i in range(2 * x, k + 1, x):
dp[x] -= dp[i]
ans += dp[x] * x
ans %= MOD
print(ans) | mod = 10 ** 9 + 7
(n, k) = map(int, input().split())
dp = [0] * (k + 1)
ans = 0
for x in range(k, 0, -1):
dp[x] = pow(k // x, n, MOD)
for i in range(2 * x, k + 1, x):
dp[x] -= dp[i]
ans += dp[x] * x
ans %= MOD
print(ans) |
# Bidirectional BFS
class Solution(object):
def minKnightMoves(self, x, y):
offsets = [(1, 2), (2, 1), (2, -1), (1, -2), (-1, -2), (-2, -1), (-2, 1), (-1, 2)]
q1 = collections.deque([(0, 0)])
q2 = collections.deque([(x, y)])
steps1 = {(0, 0): 0} #steps needed starting from (0, 0)
steps2 = {(x, y): 0} #steps needed starting from (x,y)
while q1 and q2:
i1, j1 = q1.popleft()
if (i1, j1) in steps2: return steps1[(i1, j1)]+steps2[(i1, j1)]
i2, j2 = q2.popleft()
if (i2, j2) in steps1: return steps1[(i2, j2)]+steps2[(i2, j2)]
for ox, oy in offsets:
nextI1 = i1+ox
nextJ1 = j1+oy
if (nextI1, nextJ1) not in steps1:
q1.append((nextI1, nextJ1))
steps1[(nextI1, nextJ1)] = steps1[(i1, j1)]+1
nextI2 = i2+ox
nextJ2 = j2+oy
if (nextI2, nextJ2) not in steps2:
q2.append((nextI2, nextJ2))
steps2[(nextI2, nextJ2)] = steps2[(i2, j2)]+1
return float('inf') | class Solution(object):
def min_knight_moves(self, x, y):
offsets = [(1, 2), (2, 1), (2, -1), (1, -2), (-1, -2), (-2, -1), (-2, 1), (-1, 2)]
q1 = collections.deque([(0, 0)])
q2 = collections.deque([(x, y)])
steps1 = {(0, 0): 0}
steps2 = {(x, y): 0}
while q1 and q2:
(i1, j1) = q1.popleft()
if (i1, j1) in steps2:
return steps1[i1, j1] + steps2[i1, j1]
(i2, j2) = q2.popleft()
if (i2, j2) in steps1:
return steps1[i2, j2] + steps2[i2, j2]
for (ox, oy) in offsets:
next_i1 = i1 + ox
next_j1 = j1 + oy
if (nextI1, nextJ1) not in steps1:
q1.append((nextI1, nextJ1))
steps1[nextI1, nextJ1] = steps1[i1, j1] + 1
next_i2 = i2 + ox
next_j2 = j2 + oy
if (nextI2, nextJ2) not in steps2:
q2.append((nextI2, nextJ2))
steps2[nextI2, nextJ2] = steps2[i2, j2] + 1
return float('inf') |
class School:
def __init__(self):
self.list_students = list()
self.list_data = list()
def add_student(self, name, grade):
self.list_students.append({"name": name, "grade": grade})
def roster(self):
return self.sort_student_list_by_name_and_grade()
def grade(self, grade_number):
return self.expect_grade_number_and_return_list_ordered(grade_number)
def sort_student_list_by_name_and_grade(self):
sorted_list = sorted(self.list_students, key=lambda k: (k['grade'], k['name']))
return self.add_to_a_new_list_student_list(sorted_list)
def add_to_a_new_list_student_list(self, list_name):
for names_students in list_name:
self.list_data.append(names_students["name"])
return self.list_data
def expect_grade_number_and_return_list_ordered(self, grade_number):
for names_students in self.list_students:
if names_students["grade"] == grade_number:
self.list_data.append(names_students["name"])
return sorted(self.list_data)
| class School:
def __init__(self):
self.list_students = list()
self.list_data = list()
def add_student(self, name, grade):
self.list_students.append({'name': name, 'grade': grade})
def roster(self):
return self.sort_student_list_by_name_and_grade()
def grade(self, grade_number):
return self.expect_grade_number_and_return_list_ordered(grade_number)
def sort_student_list_by_name_and_grade(self):
sorted_list = sorted(self.list_students, key=lambda k: (k['grade'], k['name']))
return self.add_to_a_new_list_student_list(sorted_list)
def add_to_a_new_list_student_list(self, list_name):
for names_students in list_name:
self.list_data.append(names_students['name'])
return self.list_data
def expect_grade_number_and_return_list_ordered(self, grade_number):
for names_students in self.list_students:
if names_students['grade'] == grade_number:
self.list_data.append(names_students['name'])
return sorted(self.list_data) |
#!/usr/bin/python3
# * Copyright (c) 2020-2021, Happiest Minds Technologies Limited Intellectual Property. All rights reserved.
# *
# * SPDX-License-Identifier: LGPL-2.1-only
PE1_binding_chk = 'ipv4 PE1ID/32 P1ID imp-null'
P1_binding_chk1 = 'ipv4 P1ID/32 PE1ID imp-null'
P1_binding_chk2 = 'ipv4 P1ID/32 PE2ID imp-null'
PE2_binding_chk = 'ipv4 PE2ID/32 P1ID imp-null'
| pe1_binding_chk = 'ipv4 PE1ID/32 P1ID imp-null'
p1_binding_chk1 = 'ipv4 P1ID/32 PE1ID imp-null'
p1_binding_chk2 = 'ipv4 P1ID/32 PE2ID imp-null'
pe2_binding_chk = 'ipv4 PE2ID/32 P1ID imp-null' |
# Url source:
# https://stackoverflow.com/questions/6260089/strange-result-when-removing-item-from-a-list
numbers = list(range(1, 50))
for i in numbers:
if i < 20:
numbers.remove(i)
print(numbers)
| numbers = list(range(1, 50))
for i in numbers:
if i < 20:
numbers.remove(i)
print(numbers) |
class Solution:
def shortestPathLength(self, graph):
def dp(node, mask):
state = (node, mask)
if state in cache:
return cache[state]
if mask & (mask - 1) == 0:
# Base case - mask only has a single "1", which means
# that only one node has been visited (the current node)
return 0
cache[state] = float("inf") # Avoid infinite loop in recursion
for neighbor in graph[node]:
if mask & (1 << neighbor):
already_visited = 1 + dp(neighbor, mask)
not_visited = 1 + dp(neighbor, mask ^ (1 << node))
cache[state] = min(cache[state], already_visited, not_visited)
return cache[state]
n = len(graph)
ending_mask = (1 << n) - 1
cache = {}
return min(dp(node, ending_mask) for node in range(n))
| class Solution:
def shortest_path_length(self, graph):
def dp(node, mask):
state = (node, mask)
if state in cache:
return cache[state]
if mask & mask - 1 == 0:
return 0
cache[state] = float('inf')
for neighbor in graph[node]:
if mask & 1 << neighbor:
already_visited = 1 + dp(neighbor, mask)
not_visited = 1 + dp(neighbor, mask ^ 1 << node)
cache[state] = min(cache[state], already_visited, not_visited)
return cache[state]
n = len(graph)
ending_mask = (1 << n) - 1
cache = {}
return min((dp(node, ending_mask) for node in range(n))) |
def format_dict(data, sep_item=", ", sep_key_value="=", brackets=True):
output = ""
delim = ""
for key, value in data.items():
output += f"{delim}{key}{sep_key_value}{value}"
delim = f"{sep_item}"
return f"{{{output}}}" if brackets else f"{output}"
def powerdict(data): # https://stackoverflow.com/a/1482320
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield {key: data[key] for mask, key in zip(masks, data) if i & mask}
def powerset(data): # https://stackoverflow.com/a/1482320
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield {element for mask, element in zip(masks, data) if i & mask}
def powerlist(data): # https://stackoverflow.com/a/1482320
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield [element for mask, element in zip(masks, data) if i & mask]
def issubdict(a, b):
return all(key in b for key in a.keys()) and all(b[key] == value for key, value in a.items())
| def format_dict(data, sep_item=', ', sep_key_value='=', brackets=True):
output = ''
delim = ''
for (key, value) in data.items():
output += f'{delim}{key}{sep_key_value}{value}'
delim = f'{sep_item}'
return f'{{{output}}}' if brackets else f'{output}'
def powerdict(data):
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield {key: data[key] for (mask, key) in zip(masks, data) if i & mask}
def powerset(data):
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield {element for (mask, element) in zip(masks, data) if i & mask}
def powerlist(data):
n = len(data)
masks = [1 << i for i in range(n)]
for i in range(1 << n):
yield [element for (mask, element) in zip(masks, data) if i & mask]
def issubdict(a, b):
return all((key in b for key in a.keys())) and all((b[key] == value for (key, value) in a.items())) |
#!/usr/bin/env python3
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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.
# These are the snippets shown during the demo videos in C2M2
# Each snippet is followed by the corresponding output when executed in the
# Python interpreter.
# >>> file = open("spider.txt")
# >>> print(file.readline())
# The itsy bitsy spider climbed up the waterspout.
#
# >>> print(file.readline())
# Down came the rain
#
# >>> print(file.read())
# and washed the spider out.
# Out came the sun
# and dried up all the rain
# and the itsy bitsy spider climbed up the spout again.
#
# >>> file.close()
#
# >>> with open("spider.txt") as file:
# ... print(file.readline())
# ...
# The itsy bitsy spider climbed up the waterspout.
#
# >>> with open("spider.txt") as file:
# ... for line in file:
# ... print(line.upper())
# ...
#
# THE ITSY BITSY SPIDER CLIMBED UP THE WATERSPOUT.
#
# DOWN CAME THE RAIN
#
# AND WASHED THE SPIDER OUT.
#
# OUT CAME THE SUN
#
# AND DRIED UP ALL THE RAIN
#
# AND THE ITSY BITSY SPIDER CLIMBED UP THE SPOUT AGAIN.
#
#
# >>> with open("spider.txt") as file:
# ... for line in file:
# ... print(line.strip().upper())
# ...
# THE ITSY BITSY SPIDER CLIMBED UP THE WATERSPOUT.
# DOWN CAME THE RAIN
# AND WASHED THE SPIDER OUT.
# OUT CAME THE SUN
# AND DRIED UP ALL THE RAIN
# AND THE ITSY BITSY SPIDER CLIMBED UP THE SPOUT AGAIN.
#
# >>> file = open("spider.txt")
# >>> lines = file.readlines()
# >>> file.close()
# >>> lines.sort()
# >>> print(lines)
# ['Down came the rain\n', 'Out came the sun\n', 'The itsy bitsy spider climbed up the waterspout.\n', 'and dried up all the rain\n', 'and the itsy bitsy spider climbed up the spout again.\n', 'and washed the spider out.\n']
#
# >>> with open("novel.txt", "w") as file:
# ... file.write("It was a dark and stormy night")
# ...
# 30
#
# >>> import os
# >>> os.remove("novel.txt")
# >>>
#
# >>> os.remove("novel.txt")
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# FileNotFoundError: [Errno 2] No such file or directory: 'novel.txt'
#
# >>> os.rename("first_draft.txt", "finished_masterpiece.txt")
# >>>
#
#
# >>> os.path.exists("finished_masterpiece.txt")
# True
# >>> os.path.exists("userlist.txt")
# False
#
# >>> os.path.getsize("spider.txt")
# 192
#
# >>> os.path.getmtime("spider.txt")
# 1556990746.582071
#
# >>> import datetime
# >>> timestamp = os.path.getmtime("spider.txt")
# >>> datetime.datetime.fromtimestamp(timestamp)
# datetime.datetime(2019, 5, 4, 19, 25, 46, 582071)
#
# >>> os.path.abspath("spider.txt")
# '/home/user/spider.txt'
#
# >>> print(os.getcwd())
# /home/user
#
#
# >>> os.mkdir("new_dir")
# >>> os.chdir("new_dir")
#
# >>> os.getcwd()
# '/home/user/new_dir'
#
# >>> os.mkdir("newer_dir")
# >>> os.rmdir("newer_dir")
#
# >>> import os
# >>> os.listdir("website")
# ['index.html', 'images', 'favicon.ico']
#
dir = "website"
for name in os.listdir(dir):
fullname = os.path.join(dir, name)
if os.path.isdir(fullname):
print("{} is a directory".format(fullname))
else:
print("{} is a file".format(fullname))
# >>> dir = "website"
# >>> for name in os.listdir(dir):
# ... fullname = os.path.join(dir, name)
# ... if os.path.isdir(fullname):
# ... print("{} is a directory".format(fullname))
# ... else:
# ... print("{} is a file".format(fullname))
# ...
# website/index.html is a file
# website/images is a directory
# website/favicon.ico is a file
#
# # CSV files
# # ---------
#
# >>> import csv
# >>> f = open("csv_file.txt")
# >>> csv_f = csv.reader(f)
# >>> for row in csv_f:
# ... name, phone, role = row
# ... print("Name: {}, Phone: {}, Role: {}".format(name, phone, role))
# ...
# Name: Sabrina Green, Phone: 802-867-5309, Role: System Administrator
# Name: Eli Jones, Phone: 684-3481127, Role: IT specialist
# Name: Melody Daniels, Phone: 846-687-7436, Role: Programmer
# Name: Charlie Rivera, Phone: 698-746-3357, Role: Web Developer
#
# >>> f.close()
#
# >>> hosts = [["workstation.local", "192.168.25.46"],["webserver.cloud", "10.2.5.6"]]
# >>> with open('hosts.csv', 'w') as hosts_csv:
# ... writer = csv.writer(hosts_csv)
# ... writer.writerows(hosts)
# ...
#
with open('software.csv') as software:
reader = csv.DictReader(software)
for row in reader:
print(("{} has {} users").format(row["name"], row["users"]))
# >>> with open('software.csv') as software:
# ... reader = csv.DictReader(software)
# ... for row in reader:
# ... print(("{} has {} users").format(row["name"], row["users"]))
# ...
# MailTree has 324 users
# CalDoor has 22 users
# Chatty Chicken has 4 users
#
#
# users = [ {"name": "Sol Mansi", "username": "solm", "department": "IT infrastructure"},
# {"name": "Lio Nelson", "username": "lion", "department": "User Experience Research"},
# {"name": "Charlie Grey", "username": "greyc", "department": "Development"}]
# keys = ["name", "username", "department"]
# with open('by_department.csv', 'w') as by_department:
# writer = csv.DictWriter(by_department, fieldnames=keys)
# writer.writeheader()
# writer.writerows(users)
| dir = 'website'
for name in os.listdir(dir):
fullname = os.path.join(dir, name)
if os.path.isdir(fullname):
print('{} is a directory'.format(fullname))
else:
print('{} is a file'.format(fullname))
with open('software.csv') as software:
reader = csv.DictReader(software)
for row in reader:
print('{} has {} users'.format(row['name'], row['users'])) |
class Solution:
def shortestPathBinaryMatrix(self, grid: List[List[int]]) -> int:
if grid[0][0] == 1:
return -1
def neighbor8(i, j):
n = len(grid)
for di in (-1, 0, 1):
for dj in (-1, 0, 1):
if di == dj == 0:
continue
newi, newj = i + di, j + dj
if 0 <= newi < n and 0 <= newj < n and grid[newi][newj] == 0:
yield (newi, newj)
n = len(grid)
ds = [[math.inf] * n for _ in range(n)]
queue = collections.deque([(0, 0)])
ds[0][0] = 1
while queue:
i, j = queue.popleft()
if i == j == n - 1:
return ds[n - 1][n - 1]
for newi, newj in neighbor8(i, j):
if ds[i][j] + 1 < ds[newi][newj]:
ds[newi][newj] = ds[i][j] + 1
queue.append((newi, newj))
return -1
| class Solution:
def shortest_path_binary_matrix(self, grid: List[List[int]]) -> int:
if grid[0][0] == 1:
return -1
def neighbor8(i, j):
n = len(grid)
for di in (-1, 0, 1):
for dj in (-1, 0, 1):
if di == dj == 0:
continue
(newi, newj) = (i + di, j + dj)
if 0 <= newi < n and 0 <= newj < n and (grid[newi][newj] == 0):
yield (newi, newj)
n = len(grid)
ds = [[math.inf] * n for _ in range(n)]
queue = collections.deque([(0, 0)])
ds[0][0] = 1
while queue:
(i, j) = queue.popleft()
if i == j == n - 1:
return ds[n - 1][n - 1]
for (newi, newj) in neighbor8(i, j):
if ds[i][j] + 1 < ds[newi][newj]:
ds[newi][newj] = ds[i][j] + 1
queue.append((newi, newj))
return -1 |
first = "Aditya"
last = "Mhambrey"
full = first+" "+last
print(full)
full = f"{first} {last} {2+2} {len(first)}"
print(full)
course = " Python Programming"
print(course.upper())
print(course.lower())
print(course.title()) # First Letter of every Word is capital
print(course.strip()) # Getting rid of white space
print(course.rstrip()) # Getting rid of white space from right similar for Left
print(course.find("Pro")) # Same as JS, -1 for wrong case
print(course.replace("P", "-"))
print("Programming" in course)
print("Programming" not in course)
| first = 'Aditya'
last = 'Mhambrey'
full = first + ' ' + last
print(full)
full = f'{first} {last} {2 + 2} {len(first)}'
print(full)
course = ' Python Programming'
print(course.upper())
print(course.lower())
print(course.title())
print(course.strip())
print(course.rstrip())
print(course.find('Pro'))
print(course.replace('P', '-'))
print('Programming' in course)
print('Programming' not in course) |
"""
@author: acfromspace
"""
# Time complexity: O(n^2)
# Space complexity: O(n)
def bubble_sort_1(data):
for i in range(len(data)-1, 0, -1):
for j in range(i):
if data[j] > data[j+1]:
data[j], data[j+1] = data[j+1], data[j]
return data
def bubble_sort_2(data):
# %last_index% is here to keep check of amount of passes, not needed for bubble sort.
last_index = len(data) - 1
# Checks last step to see if it was the last needed step.
is_sorted = False
while last_index > 0 and not is_sorted:
for i in range(last_index):
if data[i] > data[i + 1]:
data[i], data[i + 1] = data[i + 1], data[i]
is_sorted = False
else:
is_sorted = True
last_index -= 1
print("Early Exit: ", is_sorted, " | ", len(data) - last_index, " Passes")
def bubble_sort_3(data):
is_sorted = False
while not is_sorted:
is_sorted = True
for i in range(len(data)-1):
if data[i] > data[i+1]:
data[i], data[i+1] = data[i+1], data[i]
is_sorted = False
return data
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_1(test_list)
print(test_list, "\n")
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_2(test_list)
print(test_list, "\n")
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_3(test_list)
print(test_list)
"""
Output:
[9, 5, 1, 3, 6, -2, -8]
[-8, -2, 1, 3, 5, 6, 9]
[9, 5, 1, 3, 6, -2, -8]
Early Exit: False | 7 Passes
[-8, -2, 1, 3, 5, 6, 9]
[9, 5, 1, 3, 6, -2, -8]
[-8, -2, 1, 3, 5, 6, 9]
"""
| """
@author: acfromspace
"""
def bubble_sort_1(data):
for i in range(len(data) - 1, 0, -1):
for j in range(i):
if data[j] > data[j + 1]:
(data[j], data[j + 1]) = (data[j + 1], data[j])
return data
def bubble_sort_2(data):
last_index = len(data) - 1
is_sorted = False
while last_index > 0 and (not is_sorted):
for i in range(last_index):
if data[i] > data[i + 1]:
(data[i], data[i + 1]) = (data[i + 1], data[i])
is_sorted = False
else:
is_sorted = True
last_index -= 1
print('Early Exit: ', is_sorted, ' | ', len(data) - last_index, ' Passes')
def bubble_sort_3(data):
is_sorted = False
while not is_sorted:
is_sorted = True
for i in range(len(data) - 1):
if data[i] > data[i + 1]:
(data[i], data[i + 1]) = (data[i + 1], data[i])
is_sorted = False
return data
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_1(test_list)
print(test_list, '\n')
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_2(test_list)
print(test_list, '\n')
test_list = [9, 5, 1, 3, 6, -2, -8]
print(test_list)
bubble_sort_3(test_list)
print(test_list)
'\nOutput:\n\n[9, 5, 1, 3, 6, -2, -8]\n[-8, -2, 1, 3, 5, 6, 9]\n\n[9, 5, 1, 3, 6, -2, -8]\nEarly Exit: False | 7 Passes\n[-8, -2, 1, 3, 5, 6, 9]\n\n[9, 5, 1, 3, 6, -2, -8]\n[-8, -2, 1, 3, 5, 6, 9]\n' |
class Node:
def __init__(self, value, next=None):
self.value = value
self.next = next
def has_cycle(head):
slow, fast = head, head
while fast is not None and fast.next is not None:
fast = fast.next.next
slow = slow.next
if slow == fast:
return True # found the cycle
return False
| class Node:
def __init__(self, value, next=None):
self.value = value
self.next = next
def has_cycle(head):
(slow, fast) = (head, head)
while fast is not None and fast.next is not None:
fast = fast.next.next
slow = slow.next
if slow == fast:
return True
return False |
#Sort an array of 0s, 1s and 2s
#It is a problem from geeksforgeeks and can be solved using python code
#Given an array A of size N containing 0s, 1s, and 2s; you need to sort the array in ascending order.
# Here t is the number of test cases,
# i is an iterative variable,
# n is the number of elements in list,
# x is the list in which elements are to be entered
# and sort() is a python in-built function which will sort the list of elements in ascending order
t = int(input())
for i in range(t):
n = int(input())
x = list(map(int, input().split()))
x.sort()
for i in x: print(i, end=" ")
print()
#This code is contributed by Akhil
| t = int(input())
for i in range(t):
n = int(input())
x = list(map(int, input().split()))
x.sort()
for i in x:
print(i, end=' ')
print() |
# list(map(int, input().split()))
# int(input())
def main():
X = int(input())
if X >= 30:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
| def main():
x = int(input())
if X >= 30:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main() |
class ManageCards:
cards = {}
cards["154-98-11-133-118"] = "1"
cards["64-91-169-137-59"] = "2"
cards["46-245-168-137-250"] = "3"
cards["198-241-168-137-22"] = "4"
cards["127-72-227-41-253"] = "5"
cards["78-4-170-137-105"] = "6"
cards["119-174-226-41-18"] = "7"
cards["98-155-250-41-42"] = "8"
cards["1-112-169-137-81"] = "9"
cards["26-171-169-137-145"] = "10"
cards["167-132-229-41-239"] = "11"
cards["150-234-168-137-93"] = "12"
def getCardFromUID(self, uid):
try:
return self.cards[uid]
except KeyError:
return None
| class Managecards:
cards = {}
cards['154-98-11-133-118'] = '1'
cards['64-91-169-137-59'] = '2'
cards['46-245-168-137-250'] = '3'
cards['198-241-168-137-22'] = '4'
cards['127-72-227-41-253'] = '5'
cards['78-4-170-137-105'] = '6'
cards['119-174-226-41-18'] = '7'
cards['98-155-250-41-42'] = '8'
cards['1-112-169-137-81'] = '9'
cards['26-171-169-137-145'] = '10'
cards['167-132-229-41-239'] = '11'
cards['150-234-168-137-93'] = '12'
def get_card_from_uid(self, uid):
try:
return self.cards[uid]
except KeyError:
return None |
# Copyright 2017 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Generates configuration for a single NAT gateway """
def GenerateConfig(context):
"""Generates config."""
prefix = context.env['name']
zone = context.properties['zone']
resources = []
#reserve a static IP address
ip_name = prefix + '-ip'
resources.append({
'name': ip_name,
'type': 'compute.v1.address',
'properties': {
'region': context.properties['region']
}
})
# create an instance template that points to a reserved static IP address
template_name = prefix + '-it'
runtime_var_name = prefix + '/0'
resources.append({
'name': template_name,
'type': 'compute.v1.instanceTemplate',
'properties': {
'properties': {
'disks': [{
'deviceName': 'boot',
'type': 'PERSISTENT',
'mode': 'READ_WRITE',
'boot': True,
'autoDelete': True,
'initializeParams': {
'sourceImage': context.properties['image'],
'diskType': context.properties['diskType'],
'diskSizeGb': context.properties['diskSizeGb']
}
}],
'tags': {
'items': [context.properties['nat-gw-tag']]
},
'machineType': context.properties['machineType'],
'metadata': {
'items': [{
'key': 'startup-script',
'value': context.properties['startupScript']
},
{
'key': 'runtime-variable',
'value': runtime_var_name
},
{
'key': 'runtime-config',
'value': context.properties['runtimeConfigName']
},
]
},
'serviceAccounts': [{
'email': 'default',
'scopes': [
# The following scope allows an instance to create runtime variable resources.
'https://www.googleapis.com/auth/cloudruntimeconfig'
]
}],
'canIpForward': True,
'networkInterfaces': [{
'network': context.properties['network'],
'subnetwork': context.properties['subnetwork'],
'accessConfigs': [{
'name': 'External-IP',
'type': 'ONE_TO_ONE_NAT',
'natIP': '$(ref.' + ip_name + '.address)' }]
}]
}
}
})
# create an instance greoup manager of size 1 with autohealing enabled
# it will make sure that the NAT gateway VM is always up
igm_name = prefix + '-igm'
resources.append({
'name': igm_name,
'type': 'compute.beta.instanceGroupManager',
'properties': {
'baseInstanceName': prefix + '-vm',
'instanceTemplate': '$(ref.' + template_name + '.selfLink)',
'targetSize': 1,
'zone': zone,
'autoHealingPolicies': [{
'initialDelaySec': 120,
'healthCheck': context.properties['healthCheck']
}]
}
})
# Wait until a GCE VM is created by the instance group manager.
waiter_name = prefix + '-waiter'
resources.append({
'name': waiter_name,
'type': 'runtimeconfig.v1beta1.waiter',
'properties': {
'parent': context.properties['runtimeConfig'],
'waiter': waiter_name,
'timeout': '120s',
'success': {
'cardinality': {
'path': prefix,
'number': 1
}
}
},
'metadata': {
'dependsOn': [igm_name]
}
})
# Find a name of the GCE VM created by the instance group manager
get_mig_instances = prefix + '-get-mig-instances'
resources.append({
'name': get_mig_instances,
'action': 'gcp-types/compute-v1:compute.instanceGroupManagers.listManagedInstances',
'properties': {
'instanceGroupManager': igm_name,
'project': context.properties['projectId'],
'zone': zone,
},
'metadata': {
'dependsOn': [waiter_name]
}
})
#create a route that will allow to use the NAT gateway VM as a next hop
route_name = prefix + 'route'
resources.append({
'name': route_name,
'type': 'compute.v1.route',
'properties': {
'network': context.properties['network'],
'tags': [context.properties['nated-vm-tag']],
'destRange': '0.0.0.0/0',
'priority': context.properties['routePriority'],
'nextHopInstance': '$(ref.' + get_mig_instances + '.managedInstances[0].instance)'
}
})
return {'resources': resources} | """Generates configuration for a single NAT gateway """
def generate_config(context):
"""Generates config."""
prefix = context.env['name']
zone = context.properties['zone']
resources = []
ip_name = prefix + '-ip'
resources.append({'name': ip_name, 'type': 'compute.v1.address', 'properties': {'region': context.properties['region']}})
template_name = prefix + '-it'
runtime_var_name = prefix + '/0'
resources.append({'name': template_name, 'type': 'compute.v1.instanceTemplate', 'properties': {'properties': {'disks': [{'deviceName': 'boot', 'type': 'PERSISTENT', 'mode': 'READ_WRITE', 'boot': True, 'autoDelete': True, 'initializeParams': {'sourceImage': context.properties['image'], 'diskType': context.properties['diskType'], 'diskSizeGb': context.properties['diskSizeGb']}}], 'tags': {'items': [context.properties['nat-gw-tag']]}, 'machineType': context.properties['machineType'], 'metadata': {'items': [{'key': 'startup-script', 'value': context.properties['startupScript']}, {'key': 'runtime-variable', 'value': runtime_var_name}, {'key': 'runtime-config', 'value': context.properties['runtimeConfigName']}]}, 'serviceAccounts': [{'email': 'default', 'scopes': ['https://www.googleapis.com/auth/cloudruntimeconfig']}], 'canIpForward': True, 'networkInterfaces': [{'network': context.properties['network'], 'subnetwork': context.properties['subnetwork'], 'accessConfigs': [{'name': 'External-IP', 'type': 'ONE_TO_ONE_NAT', 'natIP': '$(ref.' + ip_name + '.address)'}]}]}}})
igm_name = prefix + '-igm'
resources.append({'name': igm_name, 'type': 'compute.beta.instanceGroupManager', 'properties': {'baseInstanceName': prefix + '-vm', 'instanceTemplate': '$(ref.' + template_name + '.selfLink)', 'targetSize': 1, 'zone': zone, 'autoHealingPolicies': [{'initialDelaySec': 120, 'healthCheck': context.properties['healthCheck']}]}})
waiter_name = prefix + '-waiter'
resources.append({'name': waiter_name, 'type': 'runtimeconfig.v1beta1.waiter', 'properties': {'parent': context.properties['runtimeConfig'], 'waiter': waiter_name, 'timeout': '120s', 'success': {'cardinality': {'path': prefix, 'number': 1}}}, 'metadata': {'dependsOn': [igm_name]}})
get_mig_instances = prefix + '-get-mig-instances'
resources.append({'name': get_mig_instances, 'action': 'gcp-types/compute-v1:compute.instanceGroupManagers.listManagedInstances', 'properties': {'instanceGroupManager': igm_name, 'project': context.properties['projectId'], 'zone': zone}, 'metadata': {'dependsOn': [waiter_name]}})
route_name = prefix + 'route'
resources.append({'name': route_name, 'type': 'compute.v1.route', 'properties': {'network': context.properties['network'], 'tags': [context.properties['nated-vm-tag']], 'destRange': '0.0.0.0/0', 'priority': context.properties['routePriority'], 'nextHopInstance': '$(ref.' + get_mig_instances + '.managedInstances[0].instance)'}})
return {'resources': resources} |
'''An e-commerce website wishes to find the lucky customer who will be eligible for full value cash back. For this purpose,a number N is fed to the system. It will return another number that is calculated by an algorithm. In the algorithm, a sequence is generated, in which each number n the sum of the preceding numbers. initially the sequence will have two 1's in it.
The System will return the Nth number from the generated sequence which is treated as the order ID. The lucky customer will be one who has placed that order.
Write an alorithm to help the website find the lucky customer.
Input Format
an integer value from the user
Constraints
no constraints
Output Format
print order ID as an integer
Sample Input 0
8
Sample Output 0
21
Sample Input 1
5
Sample Output 1
5'''
#solution
def lucky(num):
n1 = 1
n2 = 1
summ = 0
for i in range(2,num):
summ = n1+n2
n1 = n2
n2 = summ
return summ
print(lucky(int(input()))) | """An e-commerce website wishes to find the lucky customer who will be eligible for full value cash back. For this purpose,a number N is fed to the system. It will return another number that is calculated by an algorithm. In the algorithm, a sequence is generated, in which each number n the sum of the preceding numbers. initially the sequence will have two 1's in it.
The System will return the Nth number from the generated sequence which is treated as the order ID. The lucky customer will be one who has placed that order.
Write an alorithm to help the website find the lucky customer.
Input Format
an integer value from the user
Constraints
no constraints
Output Format
print order ID as an integer
Sample Input 0
8
Sample Output 0
21
Sample Input 1
5
Sample Output 1
5"""
def lucky(num):
n1 = 1
n2 = 1
summ = 0
for i in range(2, num):
summ = n1 + n2
n1 = n2
n2 = summ
return summ
print(lucky(int(input()))) |
class CommonsShared:
# period, step, and episode counter
periods_counter = 1
steps_counter = 1
episode_number = 0
# number of periods considered for calculating short and long term sustainabilities
n_steps_short_term = 1
n_steps_long_term = 4
# number of agents
n_agents = 5
# max periods per episode
max_episode_periods = 10
# rounds played by each agent in a period
agents_loop_steps = 20
# resources growing rate and environment carrying capacity
growing_rate = 0.3 # Ghorbani uses 0.25 - 0.35
carrying_capacity = 50000 # Ghorbani uses 10000 - 20000
# probability of being caught wrong-doing
punishment_probability = 1
# max replenishment (dependent on growth function)
max_replenishment = carrying_capacity * growing_rate * 0.5 ** 2
# max consumption, penalty, and increases in consumption and penalty
max_penalty_multiplier = 3
max_penalty_multiplier_increase = 0.5
max_limit_exploit = max_replenishment * 2 / n_agents # two times max replenishment
max_limit_exploit_increase = 1000
#consumption and replenishment buffers
consumed_buffer = []
consumed = []
replenished_buffer = []
replenished = []
| class Commonsshared:
periods_counter = 1
steps_counter = 1
episode_number = 0
n_steps_short_term = 1
n_steps_long_term = 4
n_agents = 5
max_episode_periods = 10
agents_loop_steps = 20
growing_rate = 0.3
carrying_capacity = 50000
punishment_probability = 1
max_replenishment = carrying_capacity * growing_rate * 0.5 ** 2
max_penalty_multiplier = 3
max_penalty_multiplier_increase = 0.5
max_limit_exploit = max_replenishment * 2 / n_agents
max_limit_exploit_increase = 1000
consumed_buffer = []
consumed = []
replenished_buffer = []
replenished = [] |
"""Top-level package for CY Quant Components."""
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__author__ = """Gatro CY"""
__email__ = 'cragodn@gmail.com'
__version__ = '0.3.14'
| """Top-level package for CY Quant Components."""
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__author__ = 'Gatro CY'
__email__ = 'cragodn@gmail.com'
__version__ = '0.3.14' |
def test_ci_placeholder():
# This empty test is used within the CI to
# setup the tox venv without running the test suite
# if we simply skip all test with pytest -k=wrong_pattern
# pytest command would return with exit_code=5 (i.e "no tests run")
# making travis fail
# this empty test is the recommended way to handle this
# as described in https://github.com/pytest-dev/pytest/issues/2393
pass
| def test_ci_placeholder():
pass |
if __name__ == '__main__':
x = 1
y = [2]
x, = y
print(x)
| if __name__ == '__main__':
x = 1
y = [2]
(x,) = y
print(x) |
class Decoder:
def __init__(self, alphabet, symbol):
self._alphabet = alphabet
self._symbol = symbol
self._reconstructed_extended_dict = {
int(symbol): letter for letter, symbol in self._alphabet.copy().items()
}
def decode(self, encoded_input):
output = ""
last_decoded_symbol = ""
for current_decoded_symbol in self._decoded_symbols(encoded_input):
if current_decoded_symbol is None:
value_to_add = last_decoded_symbol + last_decoded_symbol[0]
current_decoded_symbol = value_to_add
else:
value_to_add = last_decoded_symbol + current_decoded_symbol[0]
output += current_decoded_symbol
last_decoded_symbol = current_decoded_symbol
self._update_dict(value_to_add)
return output
def _decoded_symbols(self, encoded_input):
i = 0
while i < len(encoded_input):
symbol_length = self._symbol.next_bit_length
current_symbol = encoded_input[i : i + symbol_length]
current_int_symbol = int(current_symbol)
current_decoded_symbol = self._reconstructed_extended_dict.get(
current_int_symbol
)
i += symbol_length
yield current_decoded_symbol
def _update_dict(self, value_to_add):
if value_to_add not in self._reconstructed_extended_dict.values():
self._reconstructed_extended_dict[int(next(self._symbol))] = value_to_add
| class Decoder:
def __init__(self, alphabet, symbol):
self._alphabet = alphabet
self._symbol = symbol
self._reconstructed_extended_dict = {int(symbol): letter for (letter, symbol) in self._alphabet.copy().items()}
def decode(self, encoded_input):
output = ''
last_decoded_symbol = ''
for current_decoded_symbol in self._decoded_symbols(encoded_input):
if current_decoded_symbol is None:
value_to_add = last_decoded_symbol + last_decoded_symbol[0]
current_decoded_symbol = value_to_add
else:
value_to_add = last_decoded_symbol + current_decoded_symbol[0]
output += current_decoded_symbol
last_decoded_symbol = current_decoded_symbol
self._update_dict(value_to_add)
return output
def _decoded_symbols(self, encoded_input):
i = 0
while i < len(encoded_input):
symbol_length = self._symbol.next_bit_length
current_symbol = encoded_input[i:i + symbol_length]
current_int_symbol = int(current_symbol)
current_decoded_symbol = self._reconstructed_extended_dict.get(current_int_symbol)
i += symbol_length
yield current_decoded_symbol
def _update_dict(self, value_to_add):
if value_to_add not in self._reconstructed_extended_dict.values():
self._reconstructed_extended_dict[int(next(self._symbol))] = value_to_add |
listanum = [[],[]] #Primeiro colchete numeros pares e segundo colchete numeros impares
valor = 0
for cont in range(1,8):
valor = int(input("Digite um valor: "))
if valor % 2 ==0:
listanum[0].append(valor)
else:
listanum[1].append(valor)
listanum[0].sort()
listanum[1].sort()
print(f"Os numeros pares digitados foram {listanum[0]}")
print(f"Os numeros impares digitados foram {listanum[1]}")
| listanum = [[], []]
valor = 0
for cont in range(1, 8):
valor = int(input('Digite um valor: '))
if valor % 2 == 0:
listanum[0].append(valor)
else:
listanum[1].append(valor)
listanum[0].sort()
listanum[1].sort()
print(f'Os numeros pares digitados foram {listanum[0]}')
print(f'Os numeros impares digitados foram {listanum[1]}') |
""" --- Day 3: Toboggan Trajectory ---
With the toboggan login problems resolved, you set off toward the airport. While travel by toboggan might be easy, it's certainly not safe: there's very minimal steering and the area is covered in trees. You'll need to see which angles will take you near the fewest trees.
Due to the local geology, trees in this area only grow on exact integer coordinates in a grid. You make a map (your puzzle input) of the open squares (.) and trees (#) you can see. For example:
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#
These aren't the only trees, though; due to something you read about once involving arboreal genetics and biome stability, the same pattern repeats to the right many times:
..##.........##.........##.........##.........##.........##....... --->
#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.##.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........#.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...##....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.# --->
You start on the open square (.) in the top-left corner and need to reach the bottom (below the bottom-most row on your map).
The toboggan can only follow a few specific slopes (you opted for a cheaper model that prefers rational numbers); start by counting all the trees you would encounter for the slope right 3, down 1:
From your starting position at the top-left, check the position that is right 3 and down 1. Then, check the position that is right 3 and down 1 from there, and so on until you go past the bottom of the map.
The locations you'd check in the above example are marked here with O where there was an open square and X where there was a tree:
..##.........##.........##.........##.........##.........##....... --->
#..O#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....X..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#O#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..X...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.X#.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#.O..#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........X.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.X#...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...#X....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...X.#.#..#...#.#.#..#...#.#.#..#...#.# --->
In this example, traversing the map using this slope would cause you to encounter 7 trees.
Starting at the top-left corner of your map and following a slope of right 3 and down 1, how many trees would you encounter? """
""" --- Part Two ---
Time to check the rest of the slopes - you need to minimize the probability of a sudden arboreal stop, after all.
Determine the number of trees you would encounter if, for each of the following slopes, you start at the top-left corner and traverse the map all the way to the bottom:
Right 1, down 1.
Right 3, down 1. (This is the slope you already checked.)
Right 5, down 1.
Right 7, down 1.
Right 1, down 2.
In the above example, these slopes would find 2, 7, 3, 4, and 2 tree(s) respectively; multiplied together, these produce the answer 336.
What do you get if you multiply together the number of trees encountered on each of the listed slopes? """
# Initialize variables
d03_input = []
# Read the input, stripping newlines from the end of each line and saving each line as an item in a list
with open('d03/d03_input.txt') as f:
d03_input = [(line.rstrip()) for line in f]
f.close()
print(d03_input)
path = d03_input
num_trees = 0
i = 0
j = 0
num_trees_1_1 = 0
i_1_1 = 0
j_1_1 = 0
num_trees_1_5 = 0
i_1_5 = 0
j_1_5 = 0
num_trees_1_7 = 0
i_1_7 = 0
j_1_7 = 0
num_trees_2_1 = 0
i_2_1 = 0
j_2_1 = 0
for line in path:
if i < len(path):
if j >= len(line):
j-=(len(line))
if line[j] == '#':
num_trees+=1
print(i, len(line), j, line[j], num_trees)
i+=1
j+=3
if i_1_1 < len(path):
if j_1_1 >= len(line):
j_1_1-=(len(line))
if line[j_1_1] == '#':
num_trees_1_1+=1
print(i_1_1, len(line), j_1_1, line[j_1_1], num_trees_1_1)
i_1_1+=1
j_1_1+=1
if i_1_5 < len(path):
if j_1_5 >= len(line):
j_1_5-=(len(line))
if line[j_1_5] == '#':
num_trees_1_5+=1
print(i_1_5, len(line), j_1_5, line[j_1_5], num_trees_1_5)
i_1_5+=1
j_1_5+=5
if i_1_7 < len(path):
if j_1_7 >= len(line):
j_1_7-=(len(line))
if line[j_1_7] == '#':
num_trees_1_7+=1
print(i_1_7, len(line), j_1_7, line[j_1_7], num_trees_1_7)
i_1_7+=1
j_1_7+=7
if i_2_1 < len(path):
if (i_2_1) % 2 == 0:
if j_2_1 >= len(line):
j_2_1-=(len(line))
if line[j_2_1] == '#':
num_trees_2_1+=1
print(i_2_1, len(line), j_2_1, line[j_2_1], num_trees_2_1)
i_2_1+=1
j_2_1+=1
print(num_trees, num_trees_1_1, num_trees_1_5, num_trees_1_7, num_trees_2_1)
print(num_trees * num_trees_1_1 * num_trees_1_5 * num_trees_1_7 * num_trees_2_1)
| """ --- Day 3: Toboggan Trajectory ---
With the toboggan login problems resolved, you set off toward the airport. While travel by toboggan might be easy, it's certainly not safe: there's very minimal steering and the area is covered in trees. You'll need to see which angles will take you near the fewest trees.
Due to the local geology, trees in this area only grow on exact integer coordinates in a grid. You make a map (your puzzle input) of the open squares (.) and trees (#) you can see. For example:
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#
These aren't the only trees, though; due to something you read about once involving arboreal genetics and biome stability, the same pattern repeats to the right many times:
..##.........##.........##.........##.........##.........##....... --->
#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.##.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........#.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...##....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.# --->
You start on the open square (.) in the top-left corner and need to reach the bottom (below the bottom-most row on your map).
The toboggan can only follow a few specific slopes (you opted for a cheaper model that prefers rational numbers); start by counting all the trees you would encounter for the slope right 3, down 1:
From your starting position at the top-left, check the position that is right 3 and down 1. Then, check the position that is right 3 and down 1 from there, and so on until you go past the bottom of the map.
The locations you'd check in the above example are marked here with O where there was an open square and X where there was a tree:
..##.........##.........##.........##.........##.........##....... --->
#..O#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..
.#....X..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.
..#.#...#O#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#
.#...##..#..X...##..#..#...##..#..#...##..#..#...##..#..#...##..#.
..#.##.......#.X#.......#.##.......#.##.......#.##.......#.##..... --->
.#.#.#....#.#.#.#.O..#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#
.#........#.#........X.#........#.#........#.#........#.#........#
#.##...#...#.##...#...#.X#...#...#.##...#...#.##...#...#.##...#...
#...##....##...##....##...#X....##...##....##...##....##...##....#
.#..#...#.#.#..#...#.#.#..#...X.#.#..#...#.#.#..#...#.#.#..#...#.# --->
In this example, traversing the map using this slope would cause you to encounter 7 trees.
Starting at the top-left corner of your map and following a slope of right 3 and down 1, how many trees would you encounter? """
' --- Part Two ---\nTime to check the rest of the slopes - you need to minimize the probability of a sudden arboreal stop, after all.\n\nDetermine the number of trees you would encounter if, for each of the following slopes, you start at the top-left corner and traverse the map all the way to the bottom:\n\nRight 1, down 1.\nRight 3, down 1. (This is the slope you already checked.)\nRight 5, down 1.\nRight 7, down 1.\nRight 1, down 2.\nIn the above example, these slopes would find 2, 7, 3, 4, and 2 tree(s) respectively; multiplied together, these produce the answer 336.\n\nWhat do you get if you multiply together the number of trees encountered on each of the listed slopes? '
d03_input = []
with open('d03/d03_input.txt') as f:
d03_input = [line.rstrip() for line in f]
f.close()
print(d03_input)
path = d03_input
num_trees = 0
i = 0
j = 0
num_trees_1_1 = 0
i_1_1 = 0
j_1_1 = 0
num_trees_1_5 = 0
i_1_5 = 0
j_1_5 = 0
num_trees_1_7 = 0
i_1_7 = 0
j_1_7 = 0
num_trees_2_1 = 0
i_2_1 = 0
j_2_1 = 0
for line in path:
if i < len(path):
if j >= len(line):
j -= len(line)
if line[j] == '#':
num_trees += 1
print(i, len(line), j, line[j], num_trees)
i += 1
j += 3
if i_1_1 < len(path):
if j_1_1 >= len(line):
j_1_1 -= len(line)
if line[j_1_1] == '#':
num_trees_1_1 += 1
print(i_1_1, len(line), j_1_1, line[j_1_1], num_trees_1_1)
i_1_1 += 1
j_1_1 += 1
if i_1_5 < len(path):
if j_1_5 >= len(line):
j_1_5 -= len(line)
if line[j_1_5] == '#':
num_trees_1_5 += 1
print(i_1_5, len(line), j_1_5, line[j_1_5], num_trees_1_5)
i_1_5 += 1
j_1_5 += 5
if i_1_7 < len(path):
if j_1_7 >= len(line):
j_1_7 -= len(line)
if line[j_1_7] == '#':
num_trees_1_7 += 1
print(i_1_7, len(line), j_1_7, line[j_1_7], num_trees_1_7)
i_1_7 += 1
j_1_7 += 7
if i_2_1 < len(path):
if i_2_1 % 2 == 0:
if j_2_1 >= len(line):
j_2_1 -= len(line)
if line[j_2_1] == '#':
num_trees_2_1 += 1
print(i_2_1, len(line), j_2_1, line[j_2_1], num_trees_2_1)
i_2_1 += 1
j_2_1 += 1
print(num_trees, num_trees_1_1, num_trees_1_5, num_trees_1_7, num_trees_2_1)
print(num_trees * num_trees_1_1 * num_trees_1_5 * num_trees_1_7 * num_trees_2_1) |
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Mirantis Inc.
#
# 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.
"""This module has different wrappers for the data structures."""
class PaginationResult:
"""PaginationResult wraps a data about a certain page in pagination."""
def __init__(self, model_class, items, pagination):
self.model_class = model_class
self.items = items
self.pagination = pagination
self.total = items.count()
def make_api_structure(self):
"""Makes API structure, converatable to JSON."""
if self.pagination["all"]:
return self.response_all()
return self.response_paginated()
def response_all(self):
return {
"total": self.total,
"per_page": self.total,
"page": 1,
"items": list(self.modelize(self.items))
}
def response_paginated(self):
items = self.items
page_items_before = self.pagination["per_page"] \
* (self.pagination["page"] - 1)
if page_items_before:
items = items.skip(page_items_before)
items = items.limit(self.pagination["per_page"])
return {
"items": list(self.modelize(items)),
"page": self.pagination["page"],
"per_page": self.pagination["per_page"],
"total": self.total
}
def modelize(self, items):
for item in items:
model = self.model_class()
model.update_from_db_document(item)
yield model
| """This module has different wrappers for the data structures."""
class Paginationresult:
"""PaginationResult wraps a data about a certain page in pagination."""
def __init__(self, model_class, items, pagination):
self.model_class = model_class
self.items = items
self.pagination = pagination
self.total = items.count()
def make_api_structure(self):
"""Makes API structure, converatable to JSON."""
if self.pagination['all']:
return self.response_all()
return self.response_paginated()
def response_all(self):
return {'total': self.total, 'per_page': self.total, 'page': 1, 'items': list(self.modelize(self.items))}
def response_paginated(self):
items = self.items
page_items_before = self.pagination['per_page'] * (self.pagination['page'] - 1)
if page_items_before:
items = items.skip(page_items_before)
items = items.limit(self.pagination['per_page'])
return {'items': list(self.modelize(items)), 'page': self.pagination['page'], 'per_page': self.pagination['per_page'], 'total': self.total}
def modelize(self, items):
for item in items:
model = self.model_class()
model.update_from_db_document(item)
yield model |
path = "../data/stockfish_norm.csv"
scores = open( path)
last_scores = open( "last_scores.fea", "w")
for row in scores:
last_scores.write( row.rsplit(" ", 1)[1])
scores.close()
last_scores.close() | path = '../data/stockfish_norm.csv'
scores = open(path)
last_scores = open('last_scores.fea', 'w')
for row in scores:
last_scores.write(row.rsplit(' ', 1)[1])
scores.close()
last_scores.close() |
"""
noop.py: An event filter that does nothing to the input.
"""
def main(event):
return event
| """
noop.py: An event filter that does nothing to the input.
"""
def main(event):
return event |
class MudCommand:
"""
This is the base class for all commands in the MUD.
"""
def __init__(self):
self.info = {}
self.info['cmdName'] = ''
self.info['helpText'] = ''
self.info['useExample'] = ''
def setType(self, type):
self.info['actiontype'] = type
def getName(self):
return self.info['cmdName']
def getHelpText(self):
return self.info['helpText']
def getUseExample(self):
return self.info['useExample'] | class Mudcommand:
"""
This is the base class for all commands in the MUD.
"""
def __init__(self):
self.info = {}
self.info['cmdName'] = ''
self.info['helpText'] = ''
self.info['useExample'] = ''
def set_type(self, type):
self.info['actiontype'] = type
def get_name(self):
return self.info['cmdName']
def get_help_text(self):
return self.info['helpText']
def get_use_example(self):
return self.info['useExample'] |
def get_human_readable_time(seconds: float) -> str:
"""Convert seconds into a human-readable string.
Args:
seconds: number of seconds
Returns:
String that displays time in Days Hours, Minutes, Seconds format
"""
prefix = "-" if seconds < 0 else ""
seconds = abs(seconds)
int_seconds = int(seconds)
days, int_seconds = divmod(int_seconds, 86400)
hours, int_seconds = divmod(int_seconds, 3600)
minutes, int_seconds = divmod(int_seconds, 60)
if days > 0:
time_string = f"{days}d{hours}h{minutes}m{int_seconds}s"
elif hours > 0:
time_string = f"{hours}h{minutes}m{int_seconds}s"
elif minutes > 0:
time_string = f"{minutes}m{int_seconds}s"
else:
time_string = f"{seconds:.3f}s"
return prefix + time_string
| def get_human_readable_time(seconds: float) -> str:
"""Convert seconds into a human-readable string.
Args:
seconds: number of seconds
Returns:
String that displays time in Days Hours, Minutes, Seconds format
"""
prefix = '-' if seconds < 0 else ''
seconds = abs(seconds)
int_seconds = int(seconds)
(days, int_seconds) = divmod(int_seconds, 86400)
(hours, int_seconds) = divmod(int_seconds, 3600)
(minutes, int_seconds) = divmod(int_seconds, 60)
if days > 0:
time_string = f'{days}d{hours}h{minutes}m{int_seconds}s'
elif hours > 0:
time_string = f'{hours}h{minutes}m{int_seconds}s'
elif minutes > 0:
time_string = f'{minutes}m{int_seconds}s'
else:
time_string = f'{seconds:.3f}s'
return prefix + time_string |
def mutation(word_list):
if all(i in word_list[0].lower() for i in word_list[1].lower()):
return True
return False
print(mutation(["hello", "Hello"]))
print(mutation(["hello", "hey"]))
print(mutation(["Alien", "line"]))
| def mutation(word_list):
if all((i in word_list[0].lower() for i in word_list[1].lower())):
return True
return False
print(mutation(['hello', 'Hello']))
print(mutation(['hello', 'hey']))
print(mutation(['Alien', 'line'])) |
"""Kata url: https://www.codewars.com/kata/5556282156230d0e5e000089."""
def dna_to_rna(dna: str) -> str:
return dna.replace('T', 'U')
| """Kata url: https://www.codewars.com/kata/5556282156230d0e5e000089."""
def dna_to_rna(dna: str) -> str:
return dna.replace('T', 'U') |
def index(req):
req.content_type = "text/html"
req.add_common_vars()
env_vars = req.subprocess_env.copy()
req.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
req.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">')
req.write('<head><title>mod_python.publisher</title></head>')
req.write('<body>')
req.write('<h1>Environment Variables</h1>')
req.write('<table border="1">')
for key in env_vars:
req.write('<tr><td>%s</td><td>%s</td></tr>' % (key, env_vars[key]))
req.write('</table>')
req.write('</body>')
req.write('</html>')
| def index(req):
req.content_type = 'text/html'
req.add_common_vars()
env_vars = req.subprocess_env.copy()
req.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
req.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">')
req.write('<head><title>mod_python.publisher</title></head>')
req.write('<body>')
req.write('<h1>Environment Variables</h1>')
req.write('<table border="1">')
for key in env_vars:
req.write('<tr><td>%s</td><td>%s</td></tr>' % (key, env_vars[key]))
req.write('</table>')
req.write('</body>')
req.write('</html>') |
# coding=utf-8
"""
A basic rules engine, as well as a set of standard predicates and transformers.
* Predicates are the equivalent of a conditional. They take the comparable
given in the rule on the left and compare it to the value being tested
on the right, returning a boolean.
* Transformers can be considered a form of result. If a rule is matched, the
transformer is run.
See each module below for more information on how everything works.
Submodules
==========
.. currentmodule:: ultros.core.rules
.. autosummary::
:toctree: rules
constants
engine
predicates
transformers
"""
__author__ = "Gareth Coles"
| """
A basic rules engine, as well as a set of standard predicates and transformers.
* Predicates are the equivalent of a conditional. They take the comparable
given in the rule on the left and compare it to the value being tested
on the right, returning a boolean.
* Transformers can be considered a form of result. If a rule is matched, the
transformer is run.
See each module below for more information on how everything works.
Submodules
==========
.. currentmodule:: ultros.core.rules
.. autosummary::
:toctree: rules
constants
engine
predicates
transformers
"""
__author__ = 'Gareth Coles' |
class Vehicle:
name = ""
kind = "car"
color = ""
value = 00.00
def description (self):
desc ="%s is a %s %s worth $%.2f." % (self.name,self.color,self.kind,self.value)
return desc
car1 = Vehicle()
car1.name = "Fuso"
car1.color = "grey"
car1.kind = "lorry"
car1.value = 1000
car2 = Vehicle()
car2.name = "ferrari"
car2.color = "Red"
car2.kind = "convertible"
car2.value = 5000
print (car1.description())
print (car2.description()) | class Vehicle:
name = ''
kind = 'car'
color = ''
value = 0.0
def description(self):
desc = '%s is a %s %s worth $%.2f.' % (self.name, self.color, self.kind, self.value)
return desc
car1 = vehicle()
car1.name = 'Fuso'
car1.color = 'grey'
car1.kind = 'lorry'
car1.value = 1000
car2 = vehicle()
car2.name = 'ferrari'
car2.color = 'Red'
car2.kind = 'convertible'
car2.value = 5000
print(car1.description())
print(car2.description()) |
class ContactHelper:
def __init__(self, app):
self.app = app
def create(self, contact):
wd = self.app.wd
# init contact creation
wd.find_element_by_link_text("add new").click()
# foll contact form
wd.find_element_by_name("firstname").click()
wd.find_element_by_name("firstname").clear()
wd.find_element_by_name("firstname").send_keys(contact.firstname)
wd.find_element_by_name("lastname").click()
wd.find_element_by_name("lastname").clear()
wd.find_element_by_name("lastname").send_keys(contact.lastname)
wd.find_element_by_name("address").click()
wd.find_element_by_name("address").clear()
wd.find_element_by_name("address").send_keys(contact.address)
wd.find_element_by_name("mobile").click()
wd.find_element_by_name("mobile").clear()
wd.find_element_by_name("mobile").send_keys(contact.mobile)
wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()
self.return_to_contacts_page()
def return_to_contacts_page(self):
wd = self.app.wd
wd.find_element_by_link_text("home").click() | class Contacthelper:
def __init__(self, app):
self.app = app
def create(self, contact):
wd = self.app.wd
wd.find_element_by_link_text('add new').click()
wd.find_element_by_name('firstname').click()
wd.find_element_by_name('firstname').clear()
wd.find_element_by_name('firstname').send_keys(contact.firstname)
wd.find_element_by_name('lastname').click()
wd.find_element_by_name('lastname').clear()
wd.find_element_by_name('lastname').send_keys(contact.lastname)
wd.find_element_by_name('address').click()
wd.find_element_by_name('address').clear()
wd.find_element_by_name('address').send_keys(contact.address)
wd.find_element_by_name('mobile').click()
wd.find_element_by_name('mobile').clear()
wd.find_element_by_name('mobile').send_keys(contact.mobile)
wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click()
self.return_to_contacts_page()
def return_to_contacts_page(self):
wd = self.app.wd
wd.find_element_by_link_text('home').click() |
class Solution(object):
def arrayNesting(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dict = {}
ans = 0
for i in nums:
if i in dict:
continue
label = nums.index(i)
dict[label] = 1
x = i
tot = 1
while (x != label):
dict[x] = 1
tot += 1
x = nums[x]
if tot > ans :
ans = tot
#print(tot)
return ans
s = Solution()
print(s.arrayNesting([5,4,0,3,1,6,2])) | class Solution(object):
def array_nesting(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
dict = {}
ans = 0
for i in nums:
if i in dict:
continue
label = nums.index(i)
dict[label] = 1
x = i
tot = 1
while x != label:
dict[x] = 1
tot += 1
x = nums[x]
if tot > ans:
ans = tot
return ans
s = solution()
print(s.arrayNesting([5, 4, 0, 3, 1, 6, 2])) |
#
# Copyright (c) 2017 Amit Green. All rights reserved.
#
@gem('Gem.Codec')
def gem():
require_gem('Gem.Import')
PythonCodec = import_module('codecs')
python_encode_ascii = PythonCodec.getencoder('ascii')
@export
def encode_ascii(s):
return python_encode_ascii(s)[0]
| @gem('Gem.Codec')
def gem():
require_gem('Gem.Import')
python_codec = import_module('codecs')
python_encode_ascii = PythonCodec.getencoder('ascii')
@export
def encode_ascii(s):
return python_encode_ascii(s)[0] |
num1 = 1.5
num2 = 6.3
sum = num1 + num2
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
| num1 = 1.5
num2 = 6.3
sum = num1 + num2
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) |
"""This problem was asked by Palantir.
In academia, the h-index is a metric used to calculate the impact of a researcher's papers.
It is calculated as follows:
A researcher has index h if at least h of her N papers have h citations each.
If there are multiple h satisfying this formula, the maximum is chosen.
For example, suppose N = 5, and the respective citations of each paper are [4, 3, 0, 1, 5].
Then the h-index would be 3, since the researcher has 3 papers with at least 3 citations.
Given a list of paper citations of a researcher, calculate their h-index.
""" | """This problem was asked by Palantir.
In academia, the h-index is a metric used to calculate the impact of a researcher's papers.
It is calculated as follows:
A researcher has index h if at least h of her N papers have h citations each.
If there are multiple h satisfying this formula, the maximum is chosen.
For example, suppose N = 5, and the respective citations of each paper are [4, 3, 0, 1, 5].
Then the h-index would be 3, since the researcher has 3 papers with at least 3 citations.
Given a list of paper citations of a researcher, calculate their h-index.
""" |
a = []
while True:
k = 0
resposta = str(input('digite uma expressao qualquer:')).strip()
for itens in resposta:
if itens == '(':
a.append(resposta)
elif itens == ')':
if len(a) == 0:
print('expressao invalida')
k = 1
break
elif len(a) != 0:
a.pop()
if len(a) > 0:
print('''Expressao invalida
Tente novamente!!''')
elif len(a) == 0 and resposta[0] != ')' and resposta.count('(') == resposta.count(')') and k == 0:
print('Expressao valida!!')
print(a)
while True:
c = str(input('deseja continuar ? [S/N] ')).strip().upper()
if c == 'S' or c == 'N':
break
if c == 'N':
break
| a = []
while True:
k = 0
resposta = str(input('digite uma expressao qualquer:')).strip()
for itens in resposta:
if itens == '(':
a.append(resposta)
elif itens == ')':
if len(a) == 0:
print('expressao invalida')
k = 1
break
elif len(a) != 0:
a.pop()
if len(a) > 0:
print('Expressao invalida\n Tente novamente!!')
elif len(a) == 0 and resposta[0] != ')' and (resposta.count('(') == resposta.count(')')) and (k == 0):
print('Expressao valida!!')
print(a)
while True:
c = str(input('deseja continuar ? [S/N] ')).strip().upper()
if c == 'S' or c == 'N':
break
if c == 'N':
break |
# -*- coding: utf-8 -*-
"""XML Utilities.
XML scripts in Python.
* ppx: pretty print XML source in human readable form.
* xp: use XPath expression to select nodes in XML source.
* validate: validate XML source with XSD or DTD.
* transform: transform XML source with XSLT.
"""
# Xul version.
__version_info__ = ('2', '4', '0')
__version__ = '.'.join(__version_info__)
| """XML Utilities.
XML scripts in Python.
* ppx: pretty print XML source in human readable form.
* xp: use XPath expression to select nodes in XML source.
* validate: validate XML source with XSD or DTD.
* transform: transform XML source with XSLT.
"""
__version_info__ = ('2', '4', '0')
__version__ = '.'.join(__version_info__) |
# Copyright (c) 2019 Damian Grzywna
# Licensed under the zlib/libpng License
# http://opensource.org/licenses/zlib/
__all__ = ('__title__', '__summary__', '__uri__', '__version_info__',
'__version__', '__author__', '__maintainer__', '__email__',
'__copyright__', '__license__')
__title__ = "aptiv.digitRecognizer"
__summary__ = "Small application to recognize handwritten digits on the image using machine learning algorithm."
__uri__ = "https://github.com/dawis96/digitRecognizer"
__version_info__ = type("version_info", (), dict(serial=0,
major=0, minor=1, micro=0, releaselevel="alpha"))
__version__ = "{0.major}.{0.minor}.{0.micro}{1}{2}".format(__version_info__,
dict(final="", alpha="a", beta="b", rc="rc")[__version_info__.releaselevel],
"" if __version_info__.releaselevel == "final" else __version_info__.serial)
__author__ = "Damian Grzywna"
__maintainer__ = "Damian Grzywna"
__email__ = "dawis996@gmail.com"
__copyright__ = "Copyright (c) 2019, {0}".format(__author__)
__license__ = "zlib/libpng License ; {0}".format(
"http://opensource.org/licenses/zlib/")
| __all__ = ('__title__', '__summary__', '__uri__', '__version_info__', '__version__', '__author__', '__maintainer__', '__email__', '__copyright__', '__license__')
__title__ = 'aptiv.digitRecognizer'
__summary__ = 'Small application to recognize handwritten digits on the image using machine learning algorithm.'
__uri__ = 'https://github.com/dawis96/digitRecognizer'
__version_info__ = type('version_info', (), dict(serial=0, major=0, minor=1, micro=0, releaselevel='alpha'))
__version__ = '{0.major}.{0.minor}.{0.micro}{1}{2}'.format(__version_info__, dict(final='', alpha='a', beta='b', rc='rc')[__version_info__.releaselevel], '' if __version_info__.releaselevel == 'final' else __version_info__.serial)
__author__ = 'Damian Grzywna'
__maintainer__ = 'Damian Grzywna'
__email__ = 'dawis996@gmail.com'
__copyright__ = 'Copyright (c) 2019, {0}'.format(__author__)
__license__ = 'zlib/libpng License ; {0}'.format('http://opensource.org/licenses/zlib/') |
class Array:
n = 0
arr = []
def print_array(self):
print(self.arr)
def get_user_input(self):
self.n = int(input('Enter the size of array: '))
print('Enter the elements of array in next line (space separated)')
self.arr = list(map(int, input().split()))
| class Array:
n = 0
arr = []
def print_array(self):
print(self.arr)
def get_user_input(self):
self.n = int(input('Enter the size of array: '))
print('Enter the elements of array in next line (space separated)')
self.arr = list(map(int, input().split())) |
#!/usr/bin/env python3
"""
Xtremeloader reloaded...
Lookup for lx products
sample curl calls:
curl -d 'state=productlist&substate=categorized&category=Cellphone+EPINs' -X POST 'https://loadxtreme.ph/cgi-bin/ajax.cgi'
(refer to xtremeloader repo)
List of cat:
[Cellphone EPINs]
[Internet / Broadband] - Internet / Broadband </option>
[Landline] - Landline </option>
[Online Entertainment] - Online Entertainment </option>
[Online Games] - Online Games </option>
[Over-The-Air (OTA)] - Over-The-Air (OTA) </option>
[Satellite / Cable TV] - Satellite / Cable TV </option>
[Utilities] - Utilities </option>
[myLIFE] - myLIFE </option>
"""
if __name__ == '__main__':
print("Hello, World!") | """
Xtremeloader reloaded...
Lookup for lx products
sample curl calls:
curl -d 'state=productlist&substate=categorized&category=Cellphone+EPINs' -X POST 'https://loadxtreme.ph/cgi-bin/ajax.cgi'
(refer to xtremeloader repo)
List of cat:
[Cellphone EPINs]
[Internet / Broadband] - Internet / Broadband </option>
[Landline] - Landline </option>
[Online Entertainment] - Online Entertainment </option>
[Online Games] - Online Games </option>
[Over-The-Air (OTA)] - Over-The-Air (OTA) </option>
[Satellite / Cable TV] - Satellite / Cable TV </option>
[Utilities] - Utilities </option>
[myLIFE] - myLIFE </option>
"""
if __name__ == '__main__':
print('Hello, World!') |
def hello(name):
print("hello", name, "!")
hello("xxcfun") | def hello(name):
print('hello', name, '!')
hello('xxcfun') |
# def fun(num):
# if num>5:
# return True
# else:
# return False
fun=lambda x: x>5
l=[1,2,3,4,45,35,43,523]
print(list(filter(fun,l))) | fun = lambda x: x > 5
l = [1, 2, 3, 4, 45, 35, 43, 523]
print(list(filter(fun, l))) |
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None
def remove_node(self):
if self.next:
self.next.previous = self.previous
if self.previous:
self.previous.next = self.next
self.next = None
self.previous = None | class Node:
def __init__(self, value):
self.value = value
self.next = None
self.previous = None
def remove_node(self):
if self.next:
self.next.previous = self.previous
if self.previous:
self.previous.next = self.next
self.next = None
self.previous = None |
path = "./Inputs/day5.txt"
# path = "./Inputs/day5Test.txt"
def part1():
seats = getSeats()
highestSeat = max(seats)
print("Part 1:")
print(highestSeat)
def part2():
seats = getSeats()
# get the missing seat
difference = sorted(set(range(seats[0], seats[-1] + 1)).difference(seats))
print("Part 2:")
print(difference[0])
def getSeats():
seats = []
with open(path) as file:
for line in file.readlines():
rows = list(range(128))
cols = list(range(8))
letters = list(line.rstrip('\n'))
for letter in letters:
if(letter == 'F' or letter == 'B'):
rows = splitList(rows, letter)
elif(letter == 'L' or letter == 'R'):
cols = splitList(cols, letter)
row = rows[0]
col = cols[0]
seat = row * 8 + col
seats.append(seat)
return seats
def splitList(origList, part):
if (part == 'F' or part == 'L'):
# take first half
new_list = origList[:len(origList)//2]
else:
# take second half
new_list = origList[len(origList)//2:]
return new_list
part1()
part2()
| path = './Inputs/day5.txt'
def part1():
seats = get_seats()
highest_seat = max(seats)
print('Part 1:')
print(highestSeat)
def part2():
seats = get_seats()
difference = sorted(set(range(seats[0], seats[-1] + 1)).difference(seats))
print('Part 2:')
print(difference[0])
def get_seats():
seats = []
with open(path) as file:
for line in file.readlines():
rows = list(range(128))
cols = list(range(8))
letters = list(line.rstrip('\n'))
for letter in letters:
if letter == 'F' or letter == 'B':
rows = split_list(rows, letter)
elif letter == 'L' or letter == 'R':
cols = split_list(cols, letter)
row = rows[0]
col = cols[0]
seat = row * 8 + col
seats.append(seat)
return seats
def split_list(origList, part):
if part == 'F' or part == 'L':
new_list = origList[:len(origList) // 2]
else:
new_list = origList[len(origList) // 2:]
return new_list
part1()
part2() |
def max(*args):
if len(args) == 0:
return 'no numbers given'
m = args[0]
for arg in args:
if arg > m:
m = arg
return m
print(max())
print(max(5, 12, 3, 6, 7, 10, 9))
| def max(*args):
if len(args) == 0:
return 'no numbers given'
m = args[0]
for arg in args:
if arg > m:
m = arg
return m
print(max())
print(max(5, 12, 3, 6, 7, 10, 9)) |
def solution(N):
n = 0; current = 1; nex = 1
while n <N-1:
current, nex = nex, current+nex
n +=1
return 2*(current+nex)
| def solution(N):
n = 0
current = 1
nex = 1
while n < N - 1:
(current, nex) = (nex, current + nex)
n += 1
return 2 * (current + nex) |
a = [2012, 2013, 2014]
print (a)
print (a[0])
print (a[1])
print (a[2])
b = 2012
c = [b, 2015, 20.1, "Hello", "Hi"]
print (c[1:4])
| a = [2012, 2013, 2014]
print(a)
print(a[0])
print(a[1])
print(a[2])
b = 2012
c = [b, 2015, 20.1, 'Hello', 'Hi']
print(c[1:4]) |
# SB1 may have terrible calibration (is 2x as faint, and wasn't appropriately
# statwt'd b/c it didn't go through the pipeline)
vis = [#'16B-202.sb32532587.eb32875589.57663.07622001157.ms',
'16B-202.sb32957824.eb33105444.57748.63243916667.ms',
'16B-202.sb32957824.eb33142274.57752.64119381944.ms',
'16B-202.sb32957824.eb33234671.57760.62953023148.ms',
]
contspw = '2,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,22,23,24,25,26,28,29,30,31,32,34,35,36,37,39,42,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64'
"""
Normal, shallow tclean imaging of both fields
"""
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_robust0_wproj'
tclean(vis=vis,
imagename=imagename,
field='W51e2w',
spw=contspw,
weighting='briggs',
robust=0.0,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
outframe='LSRK',
savemodel='none',
selectdata=True)
impbcor(imagename=myimagebase+'.image', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.pbcor', fitsimage=myimagebase+'.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask',
'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_robust0_wproj'
tclean(vis=vis,
imagename=imagename,
field='W51 North',
spw=contspw,
weighting='briggs',
robust=0.0,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
outframe='LSRK',
savemodel='none',
selectdata=True)
impbcor(imagename=myimagebase+'.image', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.pbcor', fitsimage=myimagebase+'.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask',
'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
"""
nterms=2, spectral slope cleaning
"""
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_2terms_robust0_wproj'
tclean(vis=vis,
imagename=imagename,
field='W51e2w',
spw=contspw,
weighting='briggs',
robust=0.0,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
deconvolver='mtmfs',
outframe='LSRK',
savemodel='none',
nterms=2,
selectdata=True)
impbcor(imagename=myimagebase+'.image.tt0', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.tt0.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.tt0.pbcor', fitsimage=myimagebase+'.image.tt0.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask',
'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_2terms_robust0_wproj'
tclean(vis=vis,
imagename=imagename,
field='W51 North',
spw=contspw,
weighting='briggs',
robust=0.0,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
deconvolver='mtmfs',
outframe='LSRK',
savemodel='none',
nterms=2,
selectdata=True)
impbcor(imagename=myimagebase+'.image.tt0', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.tt0.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.tt0.pbcor', fitsimage=myimagebase+'.image.tt0.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask',
'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
for robust,suffix in [(-2,'uniform'), (0,'robust0'), (2,'natural')]:
output = myimagebase = imagename = 'W51e5_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis,
imagename=imagename,
field='W51e2w,W51 North',
phasecenter="J2000 19h23m41.858 +14d30m56.674",
spw=contspw,
weighting='briggs',
robust=robust,
imsize=[2560,2560],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
outframe='LSRK',
savemodel='none',
selectdata=True)
impbcor(imagename=myimagebase+'.image', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.pbcor', fitsimage=myimagebase+'.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for robust,suffix in [(-2,'uniform'), (0,'robust0'), (2,'natural')]:
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis,
imagename=imagename,
field='W51 North',
spw=contspw,
weighting='briggs',
robust=robust,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
outframe='LSRK',
savemodel='none',
selectdata=True)
impbcor(imagename=myimagebase+'.image', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.pbcor', fitsimage=myimagebase+'.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for robust,suffix in [(-2,'uniform'), (0,'robust0'), (2,'natural')]:
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis,
imagename=imagename,
field='W51e2w',
spw=contspw,
weighting='briggs',
robust=robust,
imsize=[5120,5120],
cell=['0.01 arcsec'],
threshold='1.0 mJy',
niter=10000,
gridder='wproject',
wprojplanes=32,
specmode='mfs',
outframe='LSRK',
savemodel='none',
selectdata=True)
impbcor(imagename=myimagebase+'.image', pbimage=myimagebase+'.pb', outfile=myimagebase+'.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase+'.image.pbcor', fitsimage=myimagebase+'.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.pb', fitsimage=myimagebase+'.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase+'.residual', fitsimage=myimagebase+'.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask',
'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
| vis = ['16B-202.sb32957824.eb33105444.57748.63243916667.ms', '16B-202.sb32957824.eb33142274.57752.64119381944.ms', '16B-202.sb32957824.eb33234671.57760.62953023148.ms']
contspw = '2,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,22,23,24,25,26,28,29,30,31,32,34,35,36,37,39,42,44,45,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64'
'\nNormal, shallow tclean imaging of both fields\n'
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_robust0_wproj'
tclean(vis=vis, imagename=imagename, field='W51e2w', spw=contspw, weighting='briggs', robust=0.0, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', outframe='LSRK', savemodel='none', selectdata=True)
impbcor(imagename=myimagebase + '.image', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.pbcor', fitsimage=myimagebase + '.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask', 'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_robust0_wproj'
tclean(vis=vis, imagename=imagename, field='W51 North', spw=contspw, weighting='briggs', robust=0.0, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', outframe='LSRK', savemodel='none', selectdata=True)
impbcor(imagename=myimagebase + '.image', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.pbcor', fitsimage=myimagebase + '.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask', 'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
'\nnterms=2, spectral slope cleaning\n'
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_2terms_robust0_wproj'
tclean(vis=vis, imagename=imagename, field='W51e2w', spw=contspw, weighting='briggs', robust=0.0, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', deconvolver='mtmfs', outframe='LSRK', savemodel='none', nterms=2, selectdata=True)
impbcor(imagename=myimagebase + '.image.tt0', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.tt0.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.tt0.pbcor', fitsimage=myimagebase + '.image.tt0.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask', 'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_2terms_robust0_wproj'
tclean(vis=vis, imagename=imagename, field='W51 North', spw=contspw, weighting='briggs', robust=0.0, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', deconvolver='mtmfs', outframe='LSRK', savemodel='none', nterms=2, selectdata=True)
impbcor(imagename=myimagebase + '.image.tt0', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.tt0.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.tt0.pbcor', fitsimage=myimagebase + '.image.tt0.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask', 'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix))
for (robust, suffix) in [(-2, 'uniform'), (0, 'robust0'), (2, 'natural')]:
output = myimagebase = imagename = 'W51e5_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis, imagename=imagename, field='W51e2w,W51 North', phasecenter='J2000 19h23m41.858 +14d30m56.674', spw=contspw, weighting='briggs', robust=robust, imsize=[2560, 2560], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', outframe='LSRK', savemodel='none', selectdata=True)
impbcor(imagename=myimagebase + '.image', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.pbcor', fitsimage=myimagebase + '.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for (robust, suffix) in [(-2, 'uniform'), (0, 'robust0'), (2, 'natural')]:
output = myimagebase = imagename = 'W51North_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis, imagename=imagename, field='W51 North', spw=contspw, weighting='briggs', robust=robust, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', outframe='LSRK', savemodel='none', selectdata=True)
impbcor(imagename=myimagebase + '.image', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.pbcor', fitsimage=myimagebase + '.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for (robust, suffix) in [(-2, 'uniform'), (0, 'robust0'), (2, 'natural')]:
output = myimagebase = imagename = 'W51e2w_QbandAarray_cont_spws_continuum_cal_clean_{0}_wproj'.format(suffix)
tclean(vis=vis, imagename=imagename, field='W51e2w', spw=contspw, weighting='briggs', robust=robust, imsize=[5120, 5120], cell=['0.01 arcsec'], threshold='1.0 mJy', niter=10000, gridder='wproject', wprojplanes=32, specmode='mfs', outframe='LSRK', savemodel='none', selectdata=True)
impbcor(imagename=myimagebase + '.image', pbimage=myimagebase + '.pb', outfile=myimagebase + '.image.pbcor', overwrite=True)
exportfits(imagename=myimagebase + '.image.pbcor', fitsimage=myimagebase + '.image.pbcor.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.pb', fitsimage=myimagebase + '.pb.fits', overwrite=True, dropdeg=True)
exportfits(imagename=myimagebase + '.residual', fitsimage=myimagebase + '.residual.fits', overwrite=True, dropdeg=True)
for suffix in ('pb', 'weight', 'sumwt', 'psf', 'model', 'mask', 'image', 'residual'):
os.system('rm -rf {0}.{1}'.format(output, suffix)) |
class Solution:
def _breakIntoLines(self, words: List[str], maxWidth: int) -> List[List[str]]:
allLines = []
charCount = 0
# list of strings for easy append
currLine = []
for word in words:
wordLen = len(word)
if wordLen + charCount > maxWidth:
# start a new line
allLines.append(currLine)
charCount = 0
currLine = []
currLine.append(word)
charCount += (wordLen+1)
allLines.append(currLine)
return allLines
def _generateSpaces(self, line: List[str], idx: int, numLines: int, maxWidth: int) -> List[str]:
spaces = maxWidth - sum([len(word) for word in line])
numWords = len(line)
countSpaces = numWords - 1
# if not both these cases, then need left justification
if numWords > 1 and idx != numLines-1:
minSpace = spaces // countSpaces
remainingSpaces = spaces - (minSpace * countSpaces)
spacesToFill = [minSpace for _ in range(countSpaces)]
for x in range(remainingSpaces):
spacesToFill[x] += 1
# for the last word
spacesToFill.append(0)
else:
# left justified cases
extraSpace = spaces - countSpaces
spacesToFill = [1 for _ in range(countSpaces)]
# for the last word, fill remaining width with space
spacesToFill.append(extraSpace)
return spacesToFill
def fullJustify(self, words: List[str], maxWidth: int) -> List[str]:
allLines = self._breakIntoLines(words, maxWidth)
numLines = len(allLines)
for idx, line in enumerate(allLines):
spacesToFill = self._generateSpaces(line, idx, numLines, maxWidth)
newLine = []
for j, word in enumerate(line):
newLine.append(word)
newLine.append(' ' * spacesToFill[j])
allLines[idx] = newLine
return list(map(lambda x: ''.join(x), allLines)) | class Solution:
def _break_into_lines(self, words: List[str], maxWidth: int) -> List[List[str]]:
all_lines = []
char_count = 0
curr_line = []
for word in words:
word_len = len(word)
if wordLen + charCount > maxWidth:
allLines.append(currLine)
char_count = 0
curr_line = []
currLine.append(word)
char_count += wordLen + 1
allLines.append(currLine)
return allLines
def _generate_spaces(self, line: List[str], idx: int, numLines: int, maxWidth: int) -> List[str]:
spaces = maxWidth - sum([len(word) for word in line])
num_words = len(line)
count_spaces = numWords - 1
if numWords > 1 and idx != numLines - 1:
min_space = spaces // countSpaces
remaining_spaces = spaces - minSpace * countSpaces
spaces_to_fill = [minSpace for _ in range(countSpaces)]
for x in range(remainingSpaces):
spacesToFill[x] += 1
spacesToFill.append(0)
else:
extra_space = spaces - countSpaces
spaces_to_fill = [1 for _ in range(countSpaces)]
spacesToFill.append(extraSpace)
return spacesToFill
def full_justify(self, words: List[str], maxWidth: int) -> List[str]:
all_lines = self._breakIntoLines(words, maxWidth)
num_lines = len(allLines)
for (idx, line) in enumerate(allLines):
spaces_to_fill = self._generateSpaces(line, idx, numLines, maxWidth)
new_line = []
for (j, word) in enumerate(line):
newLine.append(word)
newLine.append(' ' * spacesToFill[j])
allLines[idx] = newLine
return list(map(lambda x: ''.join(x), allLines)) |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '\xc2\xce\xc6\x9e\xff\xa7\x1b:\xc7O\x919\xdf=}d'
_lr_action_items = {'TAG':([20,25,32,44,45,],[-21,-19,39,-22,-20,]),'LBRACE':([10,13,15,24,],[-9,17,20,-10,]),'RPAREN':([14,18,19,26,31,],[-11,-12,24,34,-13,]),'RBRACE':([17,20,22,25,32,35,41,42,44,45,],[-14,-21,27,-19,38,-17,-15,-16,-22,-20,]),'FIELD_HIGH':([17,22,35,41,42,],[-14,30,-17,-15,-16,]),'MASK':([20,25,44,],[-21,33,-22,]),'PADDING':([17,22,35,41,42,],[-14,28,-17,-15,-16,]),'FIELD':([17,22,35,41,42,],[-14,29,-17,-15,-16,]),'BASE':([0,2,5,7,8,9,27,34,38,],[-2,3,-3,-5,-4,-6,-8,-7,-18,]),'COMMA':([14,16,18,19,31,],[-11,21,-12,23,-13,]),'LPAREN':([9,10,],[12,14,]),'INTLIT':([3,12,21,28,33,36,37,40,43,],[9,16,26,35,40,41,42,44,45,]),'IDENTIFIER':([4,6,11,14,23,29,30,39,],[10,11,15,18,31,36,37,43,]),'TAGGED_UNION':([0,2,5,7,8,9,27,34,38,],[-2,6,-3,-5,-4,-6,-8,-7,-18,]),'BLOCK':([0,2,5,7,8,9,27,34,38,],[-2,4,-3,-5,-4,-6,-8,-7,-18,]),'$end':([0,1,2,5,7,8,9,27,34,38,],[-2,0,-1,-3,-5,-4,-6,-8,-7,-18,]),}
_lr_action = { }
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = { }
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'entity_list':([0,],[2,]),'fields':([17,],[22,]),'opt_visible_order_spec':([10,],[13,]),'masks':([20,],[25,]),'start':([0,],[1,]),'base':([2,],[5,]),'visible_order_spec':([14,],[19,]),'tags':([25,],[32,]),'tagged_union':([2,],[7,]),'block':([2,],[8,]),}
_lr_goto = { }
for _k, _v in _lr_goto_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_goto: _lr_goto[_x] = { }
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> start","S'",1,None,None,None),
('start -> entity_list','start',1,'p_start','bitfield_gen.py',93),
('entity_list -> <empty>','entity_list',0,'p_entity_list_empty','bitfield_gen.py',97),
('entity_list -> entity_list base','entity_list',2,'p_entity_list_base','bitfield_gen.py',101),
('entity_list -> entity_list block','entity_list',2,'p_entity_list_block','bitfield_gen.py',108),
('entity_list -> entity_list tagged_union','entity_list',2,'p_entity_list_union','bitfield_gen.py',114),
('base -> BASE INTLIT','base',2,'p_base_simple','bitfield_gen.py',120),
('base -> BASE INTLIT LPAREN INTLIT COMMA INTLIT RPAREN','base',7,'p_base_mask','bitfield_gen.py',124),
('block -> BLOCK IDENTIFIER opt_visible_order_spec LBRACE fields RBRACE','block',6,'p_block','bitfield_gen.py',128),
('opt_visible_order_spec -> <empty>','opt_visible_order_spec',0,'p_opt_visible_order_spec_empty','bitfield_gen.py',133),
('opt_visible_order_spec -> LPAREN visible_order_spec RPAREN','opt_visible_order_spec',3,'p_opt_visible_order_spec','bitfield_gen.py',137),
('visible_order_spec -> <empty>','visible_order_spec',0,'p_visible_order_spec_empty','bitfield_gen.py',141),
('visible_order_spec -> IDENTIFIER','visible_order_spec',1,'p_visible_order_spec_single','bitfield_gen.py',145),
('visible_order_spec -> visible_order_spec COMMA IDENTIFIER','visible_order_spec',3,'p_visible_order_spec','bitfield_gen.py',149),
('fields -> <empty>','fields',0,'p_fields_empty','bitfield_gen.py',153),
('fields -> fields FIELD IDENTIFIER INTLIT','fields',4,'p_fields_field','bitfield_gen.py',157),
('fields -> fields FIELD_HIGH IDENTIFIER INTLIT','fields',4,'p_fields_field_high','bitfield_gen.py',161),
('fields -> fields PADDING INTLIT','fields',3,'p_fields_padding','bitfield_gen.py',165),
('tagged_union -> TAGGED_UNION IDENTIFIER IDENTIFIER LBRACE masks tags RBRACE','tagged_union',7,'p_tagged_union','bitfield_gen.py',169),
('tags -> <empty>','tags',0,'p_tags_empty','bitfield_gen.py',174),
('tags -> tags TAG IDENTIFIER INTLIT','tags',4,'p_tags','bitfield_gen.py',178),
('masks -> <empty>','masks',0,'p_masks_empty','bitfield_gen.py',182),
('masks -> masks MASK INTLIT INTLIT','masks',4,'p_masks','bitfield_gen.py',186),
]
| _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = 'ÂÎÆ\x9eÿ§\x1b:ÇO\x919ß=}d'
_lr_action_items = {'TAG': ([20, 25, 32, 44, 45], [-21, -19, 39, -22, -20]), 'LBRACE': ([10, 13, 15, 24], [-9, 17, 20, -10]), 'RPAREN': ([14, 18, 19, 26, 31], [-11, -12, 24, 34, -13]), 'RBRACE': ([17, 20, 22, 25, 32, 35, 41, 42, 44, 45], [-14, -21, 27, -19, 38, -17, -15, -16, -22, -20]), 'FIELD_HIGH': ([17, 22, 35, 41, 42], [-14, 30, -17, -15, -16]), 'MASK': ([20, 25, 44], [-21, 33, -22]), 'PADDING': ([17, 22, 35, 41, 42], [-14, 28, -17, -15, -16]), 'FIELD': ([17, 22, 35, 41, 42], [-14, 29, -17, -15, -16]), 'BASE': ([0, 2, 5, 7, 8, 9, 27, 34, 38], [-2, 3, -3, -5, -4, -6, -8, -7, -18]), 'COMMA': ([14, 16, 18, 19, 31], [-11, 21, -12, 23, -13]), 'LPAREN': ([9, 10], [12, 14]), 'INTLIT': ([3, 12, 21, 28, 33, 36, 37, 40, 43], [9, 16, 26, 35, 40, 41, 42, 44, 45]), 'IDENTIFIER': ([4, 6, 11, 14, 23, 29, 30, 39], [10, 11, 15, 18, 31, 36, 37, 43]), 'TAGGED_UNION': ([0, 2, 5, 7, 8, 9, 27, 34, 38], [-2, 6, -3, -5, -4, -6, -8, -7, -18]), 'BLOCK': ([0, 2, 5, 7, 8, 9, 27, 34, 38], [-2, 4, -3, -5, -4, -6, -8, -7, -18]), '$end': ([0, 1, 2, 5, 7, 8, 9, 27, 34, 38], [-2, 0, -1, -3, -5, -4, -6, -8, -7, -18])}
_lr_action = {}
for (_k, _v) in _lr_action_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_action:
_lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'entity_list': ([0], [2]), 'fields': ([17], [22]), 'opt_visible_order_spec': ([10], [13]), 'masks': ([20], [25]), 'start': ([0], [1]), 'base': ([2], [5]), 'visible_order_spec': ([14], [19]), 'tags': ([25], [32]), 'tagged_union': ([2], [7]), 'block': ([2], [8])}
_lr_goto = {}
for (_k, _v) in _lr_goto_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_goto:
_lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [("S' -> start", "S'", 1, None, None, None), ('start -> entity_list', 'start', 1, 'p_start', 'bitfield_gen.py', 93), ('entity_list -> <empty>', 'entity_list', 0, 'p_entity_list_empty', 'bitfield_gen.py', 97), ('entity_list -> entity_list base', 'entity_list', 2, 'p_entity_list_base', 'bitfield_gen.py', 101), ('entity_list -> entity_list block', 'entity_list', 2, 'p_entity_list_block', 'bitfield_gen.py', 108), ('entity_list -> entity_list tagged_union', 'entity_list', 2, 'p_entity_list_union', 'bitfield_gen.py', 114), ('base -> BASE INTLIT', 'base', 2, 'p_base_simple', 'bitfield_gen.py', 120), ('base -> BASE INTLIT LPAREN INTLIT COMMA INTLIT RPAREN', 'base', 7, 'p_base_mask', 'bitfield_gen.py', 124), ('block -> BLOCK IDENTIFIER opt_visible_order_spec LBRACE fields RBRACE', 'block', 6, 'p_block', 'bitfield_gen.py', 128), ('opt_visible_order_spec -> <empty>', 'opt_visible_order_spec', 0, 'p_opt_visible_order_spec_empty', 'bitfield_gen.py', 133), ('opt_visible_order_spec -> LPAREN visible_order_spec RPAREN', 'opt_visible_order_spec', 3, 'p_opt_visible_order_spec', 'bitfield_gen.py', 137), ('visible_order_spec -> <empty>', 'visible_order_spec', 0, 'p_visible_order_spec_empty', 'bitfield_gen.py', 141), ('visible_order_spec -> IDENTIFIER', 'visible_order_spec', 1, 'p_visible_order_spec_single', 'bitfield_gen.py', 145), ('visible_order_spec -> visible_order_spec COMMA IDENTIFIER', 'visible_order_spec', 3, 'p_visible_order_spec', 'bitfield_gen.py', 149), ('fields -> <empty>', 'fields', 0, 'p_fields_empty', 'bitfield_gen.py', 153), ('fields -> fields FIELD IDENTIFIER INTLIT', 'fields', 4, 'p_fields_field', 'bitfield_gen.py', 157), ('fields -> fields FIELD_HIGH IDENTIFIER INTLIT', 'fields', 4, 'p_fields_field_high', 'bitfield_gen.py', 161), ('fields -> fields PADDING INTLIT', 'fields', 3, 'p_fields_padding', 'bitfield_gen.py', 165), ('tagged_union -> TAGGED_UNION IDENTIFIER IDENTIFIER LBRACE masks tags RBRACE', 'tagged_union', 7, 'p_tagged_union', 'bitfield_gen.py', 169), ('tags -> <empty>', 'tags', 0, 'p_tags_empty', 'bitfield_gen.py', 174), ('tags -> tags TAG IDENTIFIER INTLIT', 'tags', 4, 'p_tags', 'bitfield_gen.py', 178), ('masks -> <empty>', 'masks', 0, 'p_masks_empty', 'bitfield_gen.py', 182), ('masks -> masks MASK INTLIT INTLIT', 'masks', 4, 'p_masks', 'bitfield_gen.py', 186)] |
class Solution:
def romanToInt(self, s: str) -> int:
symbol_map = {
"I": (0, 1),
"V": (1, 5),
"X": (2, 10),
"L": (3, 50),
"C": (4, 100),
"D": (5, 500),
"M": (6, 1000)
}
position = 0
value = 0
for symbol in reversed(s):
if symbol_map[symbol][0] < position:
value -= symbol_map[symbol][1]
else:
value += symbol_map[symbol][1]
position = symbol_map[symbol][0]
return value
print(Solution().romanToInt("III")) # 3
print(Solution().romanToInt("LVIII")) # 58
print(Solution().romanToInt("MCMXCIV")) # 1994
| class Solution:
def roman_to_int(self, s: str) -> int:
symbol_map = {'I': (0, 1), 'V': (1, 5), 'X': (2, 10), 'L': (3, 50), 'C': (4, 100), 'D': (5, 500), 'M': (6, 1000)}
position = 0
value = 0
for symbol in reversed(s):
if symbol_map[symbol][0] < position:
value -= symbol_map[symbol][1]
else:
value += symbol_map[symbol][1]
position = symbol_map[symbol][0]
return value
print(solution().romanToInt('III'))
print(solution().romanToInt('LVIII'))
print(solution().romanToInt('MCMXCIV')) |
class PolicyNetwork(ModelBase):
def __init__(self,
preprocessor,
input_size=80*80,
hidden_size=200,
gamma=0.99): # Reward discounting factor
super(PolicyNetwork, self).__init__()
self.preprocessor = preprocessor
self.input_size = input_size
self.hidden_size = hidden_size
self.gamma = gamma
self.add_param('w1', (hidden_size, input_size))
self.add_param('w2', (1, hidden_size))
def forward(self, X):
"""Forward pass to obtain the action probabilities for each observation in `X`."""
a = np.dot(self.params['w1'], X.T)
h = np.maximum(0, a)
logits = np.dot(h.T, self.params['w2'].T)
p = 1.0 / (1.0 + np.exp(-logits))
return p
def choose_action(self, p):
"""Return an action `a` and corresponding label `y` using the probability float `p`."""
a = 2 if numpy.random.uniform() < p else 3
y = 1 if a == 2 else 0
return a, y
| class Policynetwork(ModelBase):
def __init__(self, preprocessor, input_size=80 * 80, hidden_size=200, gamma=0.99):
super(PolicyNetwork, self).__init__()
self.preprocessor = preprocessor
self.input_size = input_size
self.hidden_size = hidden_size
self.gamma = gamma
self.add_param('w1', (hidden_size, input_size))
self.add_param('w2', (1, hidden_size))
def forward(self, X):
"""Forward pass to obtain the action probabilities for each observation in `X`."""
a = np.dot(self.params['w1'], X.T)
h = np.maximum(0, a)
logits = np.dot(h.T, self.params['w2'].T)
p = 1.0 / (1.0 + np.exp(-logits))
return p
def choose_action(self, p):
"""Return an action `a` and corresponding label `y` using the probability float `p`."""
a = 2 if numpy.random.uniform() < p else 3
y = 1 if a == 2 else 0
return (a, y) |
#!/bin/python
#This script is made to remove ID's from a file that contains every ID of every contig.
def file_opener(of_file):
with open(of_file, 'r') as f:
return f.readlines()
def filter(all, matched):
filterd = []
for a in matched:
if a not in matched:
filterd.append(a)
return filterd
def file_writer(data, of_file):
content = ""
for line in data:
content += line + "\n"
file = open(of_file, "w")
file.write(content)
file.close()
def main():
all_ids = file_opener('/home/richard.wissels/Foram-assembly/data/contig_ids.txt')
matched_ids = file_opener('/home/richard.wissels/Foram-assembly/results/uniq_1e-43_contig_matches.txt')
filterd_ids = filter(all_ids, matched_ids)
file_writer(filterd_ids, '/home/richard.wissels/Foram-assembly/results/non_matched_contig_ids.txt')
main()
| def file_opener(of_file):
with open(of_file, 'r') as f:
return f.readlines()
def filter(all, matched):
filterd = []
for a in matched:
if a not in matched:
filterd.append(a)
return filterd
def file_writer(data, of_file):
content = ''
for line in data:
content += line + '\n'
file = open(of_file, 'w')
file.write(content)
file.close()
def main():
all_ids = file_opener('/home/richard.wissels/Foram-assembly/data/contig_ids.txt')
matched_ids = file_opener('/home/richard.wissels/Foram-assembly/results/uniq_1e-43_contig_matches.txt')
filterd_ids = filter(all_ids, matched_ids)
file_writer(filterd_ids, '/home/richard.wissels/Foram-assembly/results/non_matched_contig_ids.txt')
main() |
"""
You are given a binary tree and you need to write a function that can determine if it is height-balanced.
A height-balanced tree can be defined as a binary tree in which the left and right subtrees of every node differ in height by a maximum of 1.
"""
#
# Binary trees are already defined with this interface:
# class Tree(object):
# def __init__(self, x):
# self.value = x
# self.left = None
# self.right = None
def get_height(root):
if root is None:
return 0
return 1 + max(get_height(root.left), get_height(root.right))
def balancedBinaryTree(root):
if root is None:
return True
return balancedBinaryTree(root.right) and balancedBinaryTree(root.left) and abs(get_height(root.left) - get_height(root.right)) <= 1
| """
You are given a binary tree and you need to write a function that can determine if it is height-balanced.
A height-balanced tree can be defined as a binary tree in which the left and right subtrees of every node differ in height by a maximum of 1.
"""
def get_height(root):
if root is None:
return 0
return 1 + max(get_height(root.left), get_height(root.right))
def balanced_binary_tree(root):
if root is None:
return True
return balanced_binary_tree(root.right) and balanced_binary_tree(root.left) and (abs(get_height(root.left) - get_height(root.right)) <= 1) |
# This is to write an escape function to escape text at the MarkdownV2 style.
#
# **NOTE**
# The [1]'s content provides some notes on how strings should be escaped,
# but let the user deal with it himself; there are such things as "the string
# ___italic underline___ should be changed to ___italic underline_\r__,
# where \r is a character with code 13", but this program's aim is not being a
# perfect text parser/a perfect escaper of symbols at text.
#
# References:
# -----------
#
# [1]: https://core.telegram.org/bots/api#markdownv2-style
#
# Bot API version: 5.3
# import re
_special_symbols = {
'_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{',
'}', '.', '!'
}
def escape(string: str) -> str:
for symbol in _special_symbols:
# Escape each special symbol
string = string.replace(symbol, '\\' + symbol)
# Mind that such sequences, being replaced, do not intersect.
# Replacement order is not important.
return string
| _special_symbols = {'_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'}
def escape(string: str) -> str:
for symbol in _special_symbols:
string = string.replace(symbol, '\\' + symbol)
return string |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def node2num(node):
val = 0
while node:
val = val * 10 + node.val
node = node.next
return val
if l1 == None:
return l2
if l2 == None:
return l1
res = node2num(l1) + node2num(l2)
dummyNode = ListNode(0)
startNode = dummyNode
for i in str(res):
startNode.next = ListNode(int(i))
startNode = startNode.next
return dummyNode.next
| class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
def node2num(node):
val = 0
while node:
val = val * 10 + node.val
node = node.next
return val
if l1 == None:
return l2
if l2 == None:
return l1
res = node2num(l1) + node2num(l2)
dummy_node = list_node(0)
start_node = dummyNode
for i in str(res):
startNode.next = list_node(int(i))
start_node = startNode.next
return dummyNode.next |
#generator2.py
class Week:
def __init__(self):
self.days = {1:'Monday', 2: "Tuesday",
3:"Wednesday", 4: "Thursday",
5:"Friday", 6:"Saturday", 7:"Sunday"}
def week_gen(self):
for x in self.days:
yield self.days[x]
if(__name__ == "__main__"):
wk = Week()
iter1 = wk.week_gen()
iter2 = iter(wk.week_gen())
print(iter1.__next__())
print(iter2.__next__())
print(next(iter1))
print(next(iter2)) | class Week:
def __init__(self):
self.days = {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5: 'Friday', 6: 'Saturday', 7: 'Sunday'}
def week_gen(self):
for x in self.days:
yield self.days[x]
if __name__ == '__main__':
wk = week()
iter1 = wk.week_gen()
iter2 = iter(wk.week_gen())
print(iter1.__next__())
print(iter2.__next__())
print(next(iter1))
print(next(iter2)) |
s1 = '854'
print(s1.isnumeric()) # -- ISN1
s2 = '\u00B2368'
print(s2.isnumeric()) # -- ISN2
s3 = '\u00BC'
print(s3.isnumeric()) # -- ISN3
s4='python895'
print(s4.isnumeric()) # -- ISN4
s5='100m2'
print(s5.isnumeric()) # -- ISN5
| s1 = '854'
print(s1.isnumeric())
s2 = '²368'
print(s2.isnumeric())
s3 = '¼'
print(s3.isnumeric())
s4 = 'python895'
print(s4.isnumeric())
s5 = '100m2'
print(s5.isnumeric()) |
# class LLNode:
# def __init__(self, val, next=None):
# self.val = val
# self.next = next
class Solution:
def solve(self, node, k):
# Write your code here
n = 0
curr = node
while curr:
curr = curr.next
n += 1
if k%n==0:
return node
if k>n:
k = k%n
curr = node
k1 = n-k-1
while k1!=0:
curr = curr.next
k1 -= 1
replace = curr
head = curr.next
while curr.next:
curr = curr.next
curr.next = node
replace.next = None
return head
| class Solution:
def solve(self, node, k):
n = 0
curr = node
while curr:
curr = curr.next
n += 1
if k % n == 0:
return node
if k > n:
k = k % n
curr = node
k1 = n - k - 1
while k1 != 0:
curr = curr.next
k1 -= 1
replace = curr
head = curr.next
while curr.next:
curr = curr.next
curr.next = node
replace.next = None
return head |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def nextLargerNodes(self, head: ListNode) -> List[int]:
if not head:
return [0]
node = head
# this stack will contain the elements that we don't know its next greater node
# alongside its index, to insert in correct place
stack = [(0, node.val)]
node = node.next
# starts the array with one element and increase it as we start iterating over the nodes
result = [0]
i = 1
while node: # iterate over the linked list
# do this until we find an element that is not greater that current node
# or stack is empry
while stack and node.val > stack[-1][-1]:
pos, val = stack.pop() # get index and value of top of stack
result[pos] = node.val # update the greater element it the given index
stack.append((i, node.val))
node = node.next
i += 1
result.append(0) # increase by 1 each new visited node
# any element in the stack does not have a greater element
while stack:
pos, val = stack.pop()
result[pos] = 0
return result | class Solution:
def next_larger_nodes(self, head: ListNode) -> List[int]:
if not head:
return [0]
node = head
stack = [(0, node.val)]
node = node.next
result = [0]
i = 1
while node:
while stack and node.val > stack[-1][-1]:
(pos, val) = stack.pop()
result[pos] = node.val
stack.append((i, node.val))
node = node.next
i += 1
result.append(0)
while stack:
(pos, val) = stack.pop()
result[pos] = 0
return result |
class Config():
API_KEY = '9b680a8b-22d4-4069-b0e6-f6cc97cd9d71'
API_URL = 'https://api.demo.11b.io'
API_ACCOUNT = 'A00-000-030'
config = Config() | class Config:
api_key = '9b680a8b-22d4-4069-b0e6-f6cc97cd9d71'
api_url = 'https://api.demo.11b.io'
api_account = 'A00-000-030'
config = config() |
'''
One cool aspect of using an outer join is that, because it returns all rows from both merged tables and null where they do not match, you can use it to find rows that do not have a match in the other table. To try for yourself, you have been given two tables with a list of actors from two popular movies: Iron Man 1 and Iron Man 2. Most of the actors played in both movies. Use an outer join to find actors who did not act in both movies.
The Iron Man 1 table is called iron_1_actors, and Iron Man 2 table is called iron_2_actors. Both tables have been loaded for you and a few rows printed so you can see the structure.
'''
# Merge iron_1_actors to iron_2_actors on id with outer join using suffixes
iron_1_and_2 = iron_1_actors.merge(iron_2_actors,
on='id',
how='outer',
suffixes=('_1', '_2'))
# Create an index that returns true if name_1 or name_2 are null
m = ((iron_1_and_2['name_1'].isnull()) |
(iron_1_and_2['name_2'].isnull()))
# Print the first few rows of iron_1_and_2
print(iron_1_and_2[m].head()) | """
One cool aspect of using an outer join is that, because it returns all rows from both merged tables and null where they do not match, you can use it to find rows that do not have a match in the other table. To try for yourself, you have been given two tables with a list of actors from two popular movies: Iron Man 1 and Iron Man 2. Most of the actors played in both movies. Use an outer join to find actors who did not act in both movies.
The Iron Man 1 table is called iron_1_actors, and Iron Man 2 table is called iron_2_actors. Both tables have been loaded for you and a few rows printed so you can see the structure.
"""
iron_1_and_2 = iron_1_actors.merge(iron_2_actors, on='id', how='outer', suffixes=('_1', '_2'))
m = iron_1_and_2['name_1'].isnull() | iron_1_and_2['name_2'].isnull()
print(iron_1_and_2[m].head()) |
#
# PySNMP MIB module CISCO-ANNOUNCEMENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ANNOUNCEMENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:50:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion")
cmgwIndex, = mibBuilder.importSymbols("CISCO-MEDIA-GATEWAY-MIB", "cmgwIndex")
ciscoMgmt, = mibBuilder.importSymbols("CISCO-SMI", "ciscoMgmt")
InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
ObjectGroup, NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "NotificationGroup", "ModuleCompliance")
Counter64, Bits, iso, Counter32, Gauge32, Integer32, Unsigned32, ObjectIdentity, ModuleIdentity, MibIdentifier, NotificationType, TimeTicks, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "Bits", "iso", "Counter32", "Gauge32", "Integer32", "Unsigned32", "ObjectIdentity", "ModuleIdentity", "MibIdentifier", "NotificationType", "TimeTicks", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn")
RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString")
ciscoAnnouncementMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 9, 8888))
ciscoAnnouncementMIB.setRevisions(('2003-03-25 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: ciscoAnnouncementMIB.setRevisionsDescriptions(('Initial version of the MIB.',))
if mibBuilder.loadTexts: ciscoAnnouncementMIB.setLastUpdated('200303250000Z')
if mibBuilder.loadTexts: ciscoAnnouncementMIB.setOrganization('Cisco Systems, Inc.')
if mibBuilder.loadTexts: ciscoAnnouncementMIB.setContactInfo(' Cisco Systems Customer Service Postal: 170 W Tasman Drive San Jose, CA 95134 USA Tel: +1 800 553-NETS E-mail: cs-voice-gateway@cisco.com')
if mibBuilder.loadTexts: ciscoAnnouncementMIB.setDescription('This MIB defines the objects for announcement system supported on media gateway. With announcement system setup, media gateway will have the capability to play pre-recorded audio files. The audio files can be played in either direction over existing connections (calls) or towards the Time Division Multiplexed (TDM) network on a TDM endpoint that is terminated on the media gateway. ')
ciscoAnnouncementMIBNotifs = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 0))
ciscoAnnouncementMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1))
ciscoAnnouncementMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2))
cannoGeneric = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1))
cannoControlConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1))
cannoAudioFileConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2))
cannoControlTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1), )
if mibBuilder.loadTexts: cannoControlTable.setStatus('current')
if mibBuilder.loadTexts: cannoControlTable.setDescription('The MIB objects in this table are used to control the announcement system of media gateway. ')
cannoControlEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1), ).setIndexNames((0, "CISCO-MEDIA-GATEWAY-MIB", "cmgwIndex"))
if mibBuilder.loadTexts: cannoControlEntry.setStatus('current')
if mibBuilder.loadTexts: cannoControlEntry.setDescription('An entry in this table contains the control parameters of the announcement system on media gateway. ')
cannoAudioFileServerName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoAudioFileServerName.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileServerName.setDescription('This object specifies the domain name of an announcement file server that resides in an IP network and is reachable from the media gateway. The default value of this object is NULL string(size is 0). Before using any object in this table, this object should be configured to non NULL. ')
cannoDnResolution = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("internalOnly", 1), ("externalOnly", 2))).clone('internalOnly')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoDnResolution.setStatus('current')
if mibBuilder.loadTexts: cannoDnResolution.setDescription('This object specifies the domain name resolution for the domain name of the Announcement File server which is specified by the cannoAudioFileServerName object. If this object is set to internalOnly(1), the IP address associated with the file server (cannoAudioFileServerName) will be determined by the cannoIpAddress object. ')
cannoIpAddressType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 3), InetAddressType().clone('ipv4')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoIpAddressType.setStatus('current')
if mibBuilder.loadTexts: cannoIpAddressType.setDescription('This object specifies the IP address type of cannoIpAddress. This object is not applicable when cannoDnResolution is set to externalOnly(2). ')
cannoIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 4), InetAddress().clone(hexValue="00000000")).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoIpAddress.setStatus('current')
if mibBuilder.loadTexts: cannoIpAddress.setDescription('This object specifies the IP address associated with the cannoAudioFileServerName. This object is not applicable when cannoDnResolution is set to externalOnly(2). ')
cannoAgeTime = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 5), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535)).clone(10080)).setUnits('minutes').setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoAgeTime.setStatus('current')
if mibBuilder.loadTexts: cannoAgeTime.setDescription("This object specifies the maximum life-span(in minutes) of the dynamic announcement files in the cache. A dynamic announcement file starts aging as soon as it is brought into the cache from the file server. When a dynamic file age crosses the 'cannoAgeTime' threshold, the file will be removed from the cache. The value zero time specifies that 'cannoAgeTime' is disabled. ")
cannoSubDirPath = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 6), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoSubDirPath.setStatus('current')
if mibBuilder.loadTexts: cannoSubDirPath.setDescription('This object specifies the directory path under the default TFTP directory in the Announcement File server for announcement files. The individual characters in cannoSubDirPath may be alphanumeric characters, forward slashes, backward slashes, periods, dashes, and underscores, but no embedded spaces. The last character of cannoSubDirPath must not be a dash. ')
cannoReqTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 7), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 50)).clone(5)).setUnits('seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoReqTimeout.setStatus('current')
if mibBuilder.loadTexts: cannoReqTimeout.setDescription("This object specifies the time for a play announcement request to be serviced. The cannoReqTimeout is the time within which an announcement must start playing after receiving announcement request. If the announcement system cannot start playing the announcement within cannoReqTimeout seconds since the request was received, the play request will be aborted. The value zero time specifies that 'cannoReqTimeout' is disabled. ")
cannoMaxPermanent = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 8), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 500)).clone(41)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: cannoMaxPermanent.setStatus('current')
if mibBuilder.loadTexts: cannoMaxPermanent.setDescription('This object specifies the maximum number of permanent announcement files that can be added to the media gateway. The space on media gateway cache is reserved for the cannoMaxPermanent number of permanent announcement files and the permanent announcement files should be stored on media gateway cache forever until to be deleted. The value zero specifies that media gateway only support dynamic announcement file. ')
cannoAudioFileTable = MibTable((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1), )
if mibBuilder.loadTexts: cannoAudioFileTable.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileTable.setDescription('The MIB objects in this table contain information to manage audio announcement files. ')
cannoAudioFileEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1), ).setIndexNames((0, "CISCO-MEDIA-GATEWAY-MIB", "cmgwIndex"), (0, "CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileNumber"))
if mibBuilder.loadTexts: cannoAudioFileEntry.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileEntry.setDescription('Each entry in the cannoAudioFileTable consists of management information for a specific announcement file, which include file descriptor, name, type, age, duration, number of cycles, status. ')
cannoAudioFileNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 9999)))
if mibBuilder.loadTexts: cannoAudioFileNumber.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileNumber.setDescription('A unique index to identify announcement file to be used in media gateway. ')
cannoAudioFileDescr = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 2), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileDescr.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileDescr.setDescription('A textual string containing information about the audio file. User can store any information to this object such as which customer using this audio file, usage of the audio file, etc.. ')
cannoAudioFileName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileName.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileName.setDescription('This object specifies the name of a valid announcement file which has been stored in cannoAudioFileTable. This file name may include path or subdirectory information. The individual characters in this name may be alphanumeric characters, forward slashes, backward slashes, periods, dashes, and underscores, but no embedded spaces. The last character of the name must not be a dash or a forward slash. ')
cannoAudioFileStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("cached", 1), ("loading", 2), ("invalidFile", 3), ("loadFailed", 4), ("notCached", 5)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: cannoAudioFileStatus.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileStatus.setDescription("This object indicates the status of the the audio file: cached (1): the file successfully downloaded to media gateway cache cache is the memory on media gateway which is used to store announcement files. loading (2): the file in process of downloading invalidFile(3): the file on Announcement File server is too large or corrupted loadFailed (4): timeout when trying to download the file notCached (5): the file is not in cache Note: The cache is the memory on media gateway which is used to store announcement files. Some of space on the cache is reserved for the permanent announcement files (refer to 'cannoMaxPermanent'), the rest of cache is for the dynamic announcement files. The 'notCached' is applicable only for the dynamic announcement files in the following cases: 1. The dynamic file age reaches to 'cannoAgeTime', the status of the file will be changed from 'cached' to 'notCached'. 2. If the cache is full for the dynamic files, and if user try to add a new dynamic file, the one of the dynamic files on cache will be removed by LRU algorithm. The status of that file will be changed from 'cached' to 'notCached'. 3. If there is no space for the dynamic files (whole cache is reserved for the permanent file), the status of the dynamic files is set to 'notCached'. ")
cannoAudioFileOperStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inPlaying", 1), ("notPlaying", 2), ("delPending", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: cannoAudioFileOperStatus.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileOperStatus.setDescription('This object indicates the current operational status of the entry: inPlaying (1): the file is in playing notPlaying (2): the file is not in playing delPending (3): deletion is pending because the file is in playing ')
cannoAudioFilePlayNoc = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 6), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647)).clone(1)).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFilePlayNoc.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFilePlayNoc.setDescription("This object specifies number of cycles the announcement file is played. This object is used only when the Play Announcement signal from the MGC does not include a 'cannoAudioFilePlayNoc' parameter. The value zero is used to represent an announcement that continuously plays or loops. ")
cannoAudioFileDuration = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 7), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setUnits('10 milliseconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileDuration.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileDuration.setDescription("This object indicates the duration to play the announcement for one cycle, it is applicable only for the fixed announcement play. This object is used only when the Play Announcement signal from the MGC does not include a 'cannoAudioFileDuration' parameter. For the fixed announcement play, the 'cannoAudioFilePlayNoc' and the 'cannoAudioFileDuration' are used together to determine how long the announcement is to be played. The value zero indicates that this is a variable announcement play and only the 'cannoAudioFilePlayNoc' is used to determine the play time. ")
cannoAudioFileType = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("dynamic", 1), ("permanent", 2))).clone('dynamic')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileType.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileType.setDescription('This object specifies announcement file type. dynamic(1) : Dynamic file can be removed from cache if file age(cannoAudioFileAge) reaches cannoAgeTime or according to LRU algorithm when cache is full permanent(2): Permanent file should be stored on cache forever except to be deleted. The max number of permanent file can be stored on cache is determined by cannoMaxPermanent. ')
cannoAudioFileAge = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 9), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setUnits('minutes').setMaxAccess("readonly")
if mibBuilder.loadTexts: cannoAudioFileAge.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileAge.setDescription("This object indicates that announcement file age in cache, it is only for dynamic file. A dynamic announcement file starts aging as soon as it is brought into the cache from the Announcement File server. When the 'cannoAudioFileAge' reach to 'cannoAgeTime', then the file will be removed from cache. This object is not applicable for two cases: (1)For the permanent files, because the the permanent files should be stored on cache forever except to be deleted. (2)The 'cannoAgeTime' is set to zero which means the cannoAgeTime is infinite and 'cannoAudioFileAge' can never reach the cannoAgeTime. ")
cannoAudioFileAdminDeletion = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("gracefully", 1), ("forcefully", 2))).clone('gracefully')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileAdminDeletion.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileAdminDeletion.setDescription('This object specifies entry deletion behavior: gracefully(1): gateway will not stop the current announcement file playing (till it completes) while deleting this entry. forcefully(2): gateway will immediately stop current announcement file playing while deleting this entry ')
cannoAudioFileRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 11), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: cannoAudioFileRowStatus.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileRowStatus.setDescription("This object is used to create or delete an entry. The mandatory objects for creating an entry in this table: 'cannoAudioFileName' The following objects are not allowed to be modified after the entry to be added: 'cannoAudioFileName' 'cannoAudioFileType' ")
cannoMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 1))
cannoMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2))
cannoMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 1, 1)).setObjects(("CISCO-ANNOUNCEMENT-MIB", "cannoControlGroup"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cannoMIBCompliance = cannoMIBCompliance.setStatus('current')
if mibBuilder.loadTexts: cannoMIBCompliance.setDescription(' The compliance statement for Announcement File')
cannoControlGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2, 1)).setObjects(("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileServerName"), ("CISCO-ANNOUNCEMENT-MIB", "cannoDnResolution"), ("CISCO-ANNOUNCEMENT-MIB", "cannoIpAddressType"), ("CISCO-ANNOUNCEMENT-MIB", "cannoIpAddress"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAgeTime"), ("CISCO-ANNOUNCEMENT-MIB", "cannoSubDirPath"), ("CISCO-ANNOUNCEMENT-MIB", "cannoReqTimeout"), ("CISCO-ANNOUNCEMENT-MIB", "cannoMaxPermanent"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cannoControlGroup = cannoControlGroup.setStatus('current')
if mibBuilder.loadTexts: cannoControlGroup.setDescription('This group contains objects related to announcement system control on media gateway. ')
cannoAudioFileGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2, 2)).setObjects(("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileDescr"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileName"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileStatus"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileOperStatus"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFilePlayNoc"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileDuration"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileType"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileAge"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileAdminDeletion"), ("CISCO-ANNOUNCEMENT-MIB", "cannoAudioFileRowStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
cannoAudioFileGroup = cannoAudioFileGroup.setStatus('current')
if mibBuilder.loadTexts: cannoAudioFileGroup.setDescription('This group contains objects related to announcement files on media gateway. ')
mibBuilder.exportSymbols("CISCO-ANNOUNCEMENT-MIB", cannoAudioFileDescr=cannoAudioFileDescr, ciscoAnnouncementMIBConformance=ciscoAnnouncementMIBConformance, cannoMaxPermanent=cannoMaxPermanent, ciscoAnnouncementMIB=ciscoAnnouncementMIB, cannoControlTable=cannoControlTable, cannoAudioFilePlayNoc=cannoAudioFilePlayNoc, cannoIpAddressType=cannoIpAddressType, cannoAudioFileName=cannoAudioFileName, cannoAgeTime=cannoAgeTime, cannoAudioFileOperStatus=cannoAudioFileOperStatus, cannoAudioFileGroup=cannoAudioFileGroup, cannoMIBCompliance=cannoMIBCompliance, cannoDnResolution=cannoDnResolution, PYSNMP_MODULE_ID=ciscoAnnouncementMIB, cannoAudioFileStatus=cannoAudioFileStatus, cannoAudioFileConfig=cannoAudioFileConfig, cannoAudioFileAge=cannoAudioFileAge, cannoControlEntry=cannoControlEntry, cannoAudioFileNumber=cannoAudioFileNumber, cannoGeneric=cannoGeneric, cannoSubDirPath=cannoSubDirPath, cannoControlGroup=cannoControlGroup, cannoAudioFileTable=cannoAudioFileTable, cannoMIBCompliances=cannoMIBCompliances, cannoControlConfig=cannoControlConfig, cannoIpAddress=cannoIpAddress, cannoAudioFileAdminDeletion=cannoAudioFileAdminDeletion, cannoAudioFileEntry=cannoAudioFileEntry, cannoAudioFileType=cannoAudioFileType, ciscoAnnouncementMIBObjects=ciscoAnnouncementMIBObjects, cannoMIBGroups=cannoMIBGroups, cannoAudioFileServerName=cannoAudioFileServerName, cannoAudioFileRowStatus=cannoAudioFileRowStatus, cannoAudioFileDuration=cannoAudioFileDuration, cannoReqTimeout=cannoReqTimeout, ciscoAnnouncementMIBNotifs=ciscoAnnouncementMIBNotifs)
| (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion')
(cmgw_index,) = mibBuilder.importSymbols('CISCO-MEDIA-GATEWAY-MIB', 'cmgwIndex')
(cisco_mgmt,) = mibBuilder.importSymbols('CISCO-SMI', 'ciscoMgmt')
(inet_address, inet_address_type) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddress', 'InetAddressType')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(object_group, notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'NotificationGroup', 'ModuleCompliance')
(counter64, bits, iso, counter32, gauge32, integer32, unsigned32, object_identity, module_identity, mib_identifier, notification_type, time_ticks, ip_address, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'Bits', 'iso', 'Counter32', 'Gauge32', 'Integer32', 'Unsigned32', 'ObjectIdentity', 'ModuleIdentity', 'MibIdentifier', 'NotificationType', 'TimeTicks', 'IpAddress', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn')
(row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString')
cisco_announcement_mib = module_identity((1, 3, 6, 1, 4, 1, 9, 9, 8888))
ciscoAnnouncementMIB.setRevisions(('2003-03-25 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
ciscoAnnouncementMIB.setRevisionsDescriptions(('Initial version of the MIB.',))
if mibBuilder.loadTexts:
ciscoAnnouncementMIB.setLastUpdated('200303250000Z')
if mibBuilder.loadTexts:
ciscoAnnouncementMIB.setOrganization('Cisco Systems, Inc.')
if mibBuilder.loadTexts:
ciscoAnnouncementMIB.setContactInfo(' Cisco Systems Customer Service Postal: 170 W Tasman Drive San Jose, CA 95134 USA Tel: +1 800 553-NETS E-mail: cs-voice-gateway@cisco.com')
if mibBuilder.loadTexts:
ciscoAnnouncementMIB.setDescription('This MIB defines the objects for announcement system supported on media gateway. With announcement system setup, media gateway will have the capability to play pre-recorded audio files. The audio files can be played in either direction over existing connections (calls) or towards the Time Division Multiplexed (TDM) network on a TDM endpoint that is terminated on the media gateway. ')
cisco_announcement_mib_notifs = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 0))
cisco_announcement_mib_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1))
cisco_announcement_mib_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2))
canno_generic = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1))
canno_control_config = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1))
canno_audio_file_config = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2))
canno_control_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1))
if mibBuilder.loadTexts:
cannoControlTable.setStatus('current')
if mibBuilder.loadTexts:
cannoControlTable.setDescription('The MIB objects in this table are used to control the announcement system of media gateway. ')
canno_control_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1)).setIndexNames((0, 'CISCO-MEDIA-GATEWAY-MIB', 'cmgwIndex'))
if mibBuilder.loadTexts:
cannoControlEntry.setStatus('current')
if mibBuilder.loadTexts:
cannoControlEntry.setDescription('An entry in this table contains the control parameters of the announcement system on media gateway. ')
canno_audio_file_server_name = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 1), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoAudioFileServerName.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileServerName.setDescription('This object specifies the domain name of an announcement file server that resides in an IP network and is reachable from the media gateway. The default value of this object is NULL string(size is 0). Before using any object in this table, this object should be configured to non NULL. ')
canno_dn_resolution = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('internalOnly', 1), ('externalOnly', 2))).clone('internalOnly')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoDnResolution.setStatus('current')
if mibBuilder.loadTexts:
cannoDnResolution.setDescription('This object specifies the domain name resolution for the domain name of the Announcement File server which is specified by the cannoAudioFileServerName object. If this object is set to internalOnly(1), the IP address associated with the file server (cannoAudioFileServerName) will be determined by the cannoIpAddress object. ')
canno_ip_address_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 3), inet_address_type().clone('ipv4')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoIpAddressType.setStatus('current')
if mibBuilder.loadTexts:
cannoIpAddressType.setDescription('This object specifies the IP address type of cannoIpAddress. This object is not applicable when cannoDnResolution is set to externalOnly(2). ')
canno_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 4), inet_address().clone(hexValue='00000000')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoIpAddress.setStatus('current')
if mibBuilder.loadTexts:
cannoIpAddress.setDescription('This object specifies the IP address associated with the cannoAudioFileServerName. This object is not applicable when cannoDnResolution is set to externalOnly(2). ')
canno_age_time = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 5), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535)).clone(10080)).setUnits('minutes').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoAgeTime.setStatus('current')
if mibBuilder.loadTexts:
cannoAgeTime.setDescription("This object specifies the maximum life-span(in minutes) of the dynamic announcement files in the cache. A dynamic announcement file starts aging as soon as it is brought into the cache from the file server. When a dynamic file age crosses the 'cannoAgeTime' threshold, the file will be removed from the cache. The value zero time specifies that 'cannoAgeTime' is disabled. ")
canno_sub_dir_path = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 6), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 255))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoSubDirPath.setStatus('current')
if mibBuilder.loadTexts:
cannoSubDirPath.setDescription('This object specifies the directory path under the default TFTP directory in the Announcement File server for announcement files. The individual characters in cannoSubDirPath may be alphanumeric characters, forward slashes, backward slashes, periods, dashes, and underscores, but no embedded spaces. The last character of cannoSubDirPath must not be a dash. ')
canno_req_timeout = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 7), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 50)).clone(5)).setUnits('seconds').setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoReqTimeout.setStatus('current')
if mibBuilder.loadTexts:
cannoReqTimeout.setDescription("This object specifies the time for a play announcement request to be serviced. The cannoReqTimeout is the time within which an announcement must start playing after receiving announcement request. If the announcement system cannot start playing the announcement within cannoReqTimeout seconds since the request was received, the play request will be aborted. The value zero time specifies that 'cannoReqTimeout' is disabled. ")
canno_max_permanent = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 1, 1, 1, 8), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 500)).clone(41)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
cannoMaxPermanent.setStatus('current')
if mibBuilder.loadTexts:
cannoMaxPermanent.setDescription('This object specifies the maximum number of permanent announcement files that can be added to the media gateway. The space on media gateway cache is reserved for the cannoMaxPermanent number of permanent announcement files and the permanent announcement files should be stored on media gateway cache forever until to be deleted. The value zero specifies that media gateway only support dynamic announcement file. ')
canno_audio_file_table = mib_table((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1))
if mibBuilder.loadTexts:
cannoAudioFileTable.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileTable.setDescription('The MIB objects in this table contain information to manage audio announcement files. ')
canno_audio_file_entry = mib_table_row((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1)).setIndexNames((0, 'CISCO-MEDIA-GATEWAY-MIB', 'cmgwIndex'), (0, 'CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileNumber'))
if mibBuilder.loadTexts:
cannoAudioFileEntry.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileEntry.setDescription('Each entry in the cannoAudioFileTable consists of management information for a specific announcement file, which include file descriptor, name, type, age, duration, number of cycles, status. ')
canno_audio_file_number = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 9999)))
if mibBuilder.loadTexts:
cannoAudioFileNumber.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileNumber.setDescription('A unique index to identify announcement file to be used in media gateway. ')
canno_audio_file_descr = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 2), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileDescr.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileDescr.setDescription('A textual string containing information about the audio file. User can store any information to this object such as which customer using this audio file, usage of the audio file, etc.. ')
canno_audio_file_name = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 3), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileName.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileName.setDescription('This object specifies the name of a valid announcement file which has been stored in cannoAudioFileTable. This file name may include path or subdirectory information. The individual characters in this name may be alphanumeric characters, forward slashes, backward slashes, periods, dashes, and underscores, but no embedded spaces. The last character of the name must not be a dash or a forward slash. ')
canno_audio_file_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('cached', 1), ('loading', 2), ('invalidFile', 3), ('loadFailed', 4), ('notCached', 5)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cannoAudioFileStatus.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileStatus.setDescription("This object indicates the status of the the audio file: cached (1): the file successfully downloaded to media gateway cache cache is the memory on media gateway which is used to store announcement files. loading (2): the file in process of downloading invalidFile(3): the file on Announcement File server is too large or corrupted loadFailed (4): timeout when trying to download the file notCached (5): the file is not in cache Note: The cache is the memory on media gateway which is used to store announcement files. Some of space on the cache is reserved for the permanent announcement files (refer to 'cannoMaxPermanent'), the rest of cache is for the dynamic announcement files. The 'notCached' is applicable only for the dynamic announcement files in the following cases: 1. The dynamic file age reaches to 'cannoAgeTime', the status of the file will be changed from 'cached' to 'notCached'. 2. If the cache is full for the dynamic files, and if user try to add a new dynamic file, the one of the dynamic files on cache will be removed by LRU algorithm. The status of that file will be changed from 'cached' to 'notCached'. 3. If there is no space for the dynamic files (whole cache is reserved for the permanent file), the status of the dynamic files is set to 'notCached'. ")
canno_audio_file_oper_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inPlaying', 1), ('notPlaying', 2), ('delPending', 3)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
cannoAudioFileOperStatus.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileOperStatus.setDescription('This object indicates the current operational status of the entry: inPlaying (1): the file is in playing notPlaying (2): the file is not in playing delPending (3): deletion is pending because the file is in playing ')
canno_audio_file_play_noc = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 6), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 2147483647)).clone(1)).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFilePlayNoc.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFilePlayNoc.setDescription("This object specifies number of cycles the announcement file is played. This object is used only when the Play Announcement signal from the MGC does not include a 'cannoAudioFilePlayNoc' parameter. The value zero is used to represent an announcement that continuously plays or loops. ")
canno_audio_file_duration = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 7), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setUnits('10 milliseconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileDuration.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileDuration.setDescription("This object indicates the duration to play the announcement for one cycle, it is applicable only for the fixed announcement play. This object is used only when the Play Announcement signal from the MGC does not include a 'cannoAudioFileDuration' parameter. For the fixed announcement play, the 'cannoAudioFilePlayNoc' and the 'cannoAudioFileDuration' are used together to determine how long the announcement is to be played. The value zero indicates that this is a variable announcement play and only the 'cannoAudioFilePlayNoc' is used to determine the play time. ")
canno_audio_file_type = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('dynamic', 1), ('permanent', 2))).clone('dynamic')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileType.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileType.setDescription('This object specifies announcement file type. dynamic(1) : Dynamic file can be removed from cache if file age(cannoAudioFileAge) reaches cannoAgeTime or according to LRU algorithm when cache is full permanent(2): Permanent file should be stored on cache forever except to be deleted. The max number of permanent file can be stored on cache is determined by cannoMaxPermanent. ')
canno_audio_file_age = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 9), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setUnits('minutes').setMaxAccess('readonly')
if mibBuilder.loadTexts:
cannoAudioFileAge.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileAge.setDescription("This object indicates that announcement file age in cache, it is only for dynamic file. A dynamic announcement file starts aging as soon as it is brought into the cache from the Announcement File server. When the 'cannoAudioFileAge' reach to 'cannoAgeTime', then the file will be removed from cache. This object is not applicable for two cases: (1)For the permanent files, because the the permanent files should be stored on cache forever except to be deleted. (2)The 'cannoAgeTime' is set to zero which means the cannoAgeTime is infinite and 'cannoAudioFileAge' can never reach the cannoAgeTime. ")
canno_audio_file_admin_deletion = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('gracefully', 1), ('forcefully', 2))).clone('gracefully')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileAdminDeletion.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileAdminDeletion.setDescription('This object specifies entry deletion behavior: gracefully(1): gateway will not stop the current announcement file playing (till it completes) while deleting this entry. forcefully(2): gateway will immediately stop current announcement file playing while deleting this entry ')
canno_audio_file_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 9, 9, 8888, 1, 1, 2, 1, 1, 11), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
cannoAudioFileRowStatus.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileRowStatus.setDescription("This object is used to create or delete an entry. The mandatory objects for creating an entry in this table: 'cannoAudioFileName' The following objects are not allowed to be modified after the entry to be added: 'cannoAudioFileName' 'cannoAudioFileType' ")
canno_mib_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 1))
canno_mib_groups = mib_identifier((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2))
canno_mib_compliance = module_compliance((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 1, 1)).setObjects(('CISCO-ANNOUNCEMENT-MIB', 'cannoControlGroup'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
canno_mib_compliance = cannoMIBCompliance.setStatus('current')
if mibBuilder.loadTexts:
cannoMIBCompliance.setDescription(' The compliance statement for Announcement File')
canno_control_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2, 1)).setObjects(('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileServerName'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoDnResolution'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoIpAddressType'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoIpAddress'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAgeTime'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoSubDirPath'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoReqTimeout'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoMaxPermanent'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
canno_control_group = cannoControlGroup.setStatus('current')
if mibBuilder.loadTexts:
cannoControlGroup.setDescription('This group contains objects related to announcement system control on media gateway. ')
canno_audio_file_group = object_group((1, 3, 6, 1, 4, 1, 9, 9, 8888, 2, 2, 2)).setObjects(('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileDescr'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileName'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileStatus'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileOperStatus'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFilePlayNoc'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileDuration'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileType'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileAge'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileAdminDeletion'), ('CISCO-ANNOUNCEMENT-MIB', 'cannoAudioFileRowStatus'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
canno_audio_file_group = cannoAudioFileGroup.setStatus('current')
if mibBuilder.loadTexts:
cannoAudioFileGroup.setDescription('This group contains objects related to announcement files on media gateway. ')
mibBuilder.exportSymbols('CISCO-ANNOUNCEMENT-MIB', cannoAudioFileDescr=cannoAudioFileDescr, ciscoAnnouncementMIBConformance=ciscoAnnouncementMIBConformance, cannoMaxPermanent=cannoMaxPermanent, ciscoAnnouncementMIB=ciscoAnnouncementMIB, cannoControlTable=cannoControlTable, cannoAudioFilePlayNoc=cannoAudioFilePlayNoc, cannoIpAddressType=cannoIpAddressType, cannoAudioFileName=cannoAudioFileName, cannoAgeTime=cannoAgeTime, cannoAudioFileOperStatus=cannoAudioFileOperStatus, cannoAudioFileGroup=cannoAudioFileGroup, cannoMIBCompliance=cannoMIBCompliance, cannoDnResolution=cannoDnResolution, PYSNMP_MODULE_ID=ciscoAnnouncementMIB, cannoAudioFileStatus=cannoAudioFileStatus, cannoAudioFileConfig=cannoAudioFileConfig, cannoAudioFileAge=cannoAudioFileAge, cannoControlEntry=cannoControlEntry, cannoAudioFileNumber=cannoAudioFileNumber, cannoGeneric=cannoGeneric, cannoSubDirPath=cannoSubDirPath, cannoControlGroup=cannoControlGroup, cannoAudioFileTable=cannoAudioFileTable, cannoMIBCompliances=cannoMIBCompliances, cannoControlConfig=cannoControlConfig, cannoIpAddress=cannoIpAddress, cannoAudioFileAdminDeletion=cannoAudioFileAdminDeletion, cannoAudioFileEntry=cannoAudioFileEntry, cannoAudioFileType=cannoAudioFileType, ciscoAnnouncementMIBObjects=ciscoAnnouncementMIBObjects, cannoMIBGroups=cannoMIBGroups, cannoAudioFileServerName=cannoAudioFileServerName, cannoAudioFileRowStatus=cannoAudioFileRowStatus, cannoAudioFileDuration=cannoAudioFileDuration, cannoReqTimeout=cannoReqTimeout, ciscoAnnouncementMIBNotifs=ciscoAnnouncementMIBNotifs) |
# Will you make it?
def zero_fuel(distance_to_pump, mpg, fuel_left):
if ( distance_to_pump - mpg*fuel_left )>0:
result = False
else:
result = True
return result
| def zero_fuel(distance_to_pump, mpg, fuel_left):
if distance_to_pump - mpg * fuel_left > 0:
result = False
else:
result = True
return result |
"""
So we gonna need a way to check quest progress.
This might be as simple as checking if Admiral has a Ship or we might have to check if he completed 1-1 4 times while jumping in one leg
I have no idea.
At first I intended to write a simple function for each Quest, but the Admiral can activate and deactivate stuff at will, so we have to
make it persistent somehow.
So my idea is to have a column in the AdmiralQuest table that saves a JSON with quest data and then the function reads and interprets this.
Please look forward for the chaos that ensues.
"""
| """
So we gonna need a way to check quest progress.
This might be as simple as checking if Admiral has a Ship or we might have to check if he completed 1-1 4 times while jumping in one leg
I have no idea.
At first I intended to write a simple function for each Quest, but the Admiral can activate and deactivate stuff at will, so we have to
make it persistent somehow.
So my idea is to have a column in the AdmiralQuest table that saves a JSON with quest data and then the function reads and interprets this.
Please look forward for the chaos that ensues.
""" |
def fib(n, calc):
if n == 0 or n == 1:
if len(calc) < 2:
calc.append(n)
return calc[n], calc
elif len(calc)-1 >= n:
return calc[n], calc
elif n >= 2:
res1, c = fib(n-1, calc)
res2, c = fib(n-2, calc)
res = res1 + res2
calc.append(res)
return res, calc
else:
return calc[n], calc
a = int(input())
res = ''
calc = []
for num in range(0, a):
n, calc = fib(num, calc)
res += str(n) + ' '
print(res.strip())
| def fib(n, calc):
if n == 0 or n == 1:
if len(calc) < 2:
calc.append(n)
return (calc[n], calc)
elif len(calc) - 1 >= n:
return (calc[n], calc)
elif n >= 2:
(res1, c) = fib(n - 1, calc)
(res2, c) = fib(n - 2, calc)
res = res1 + res2
calc.append(res)
return (res, calc)
else:
return (calc[n], calc)
a = int(input())
res = ''
calc = []
for num in range(0, a):
(n, calc) = fib(num, calc)
res += str(n) + ' '
print(res.strip()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.