content
stringlengths 7
1.05M
|
---|
"""Crie um programa que leia o nome completo de uma pessoa e mostre:
- O nome com todas as letras maiúsculas;
- O nome com todas as letras minúsculas;
Quantas letras ao todo, sem considerar espaços;
Quantas letras tem o primeiro nome:"""
n = str(input('Digite seu nome completo: ')).strip()
#div = n.split()
print(n.upper())
print(n.lower())
#print('Número de letras: {}'.format(len(''.join(div))))
print('Número de letras: {}'.format(len(n) - n.count(' ')))
#print('Número de letras do primeiro nome: {}'.format(len(div[0])))
print('Número de letras do primeiro nome: {}'.format(n.find(' '))) |
bot_fav_color = "blue"
# Creating a parent class to use for various games
class Player:
def __init__(self, name, fav_color):
self.name = name
self.fav_color = fav_color
def __str__(self):
if self.fav_color == "blue":
return f"Hi {self.name} 😉! My favorite color is also blue 🐬!"
return f"Hi {self.name} 😉! I think {self.fav_color} is an awesome color 🎨!"
# Forming a repeatable stack structure
class Stack:
def __init__(self, abc):
self.height = 4
self.abc = abc
def move_piece(self):
row, col = [int(value) for value in input("Please tell the host your move in row#,col# format. ").split(',')]
if not -1 < row < 5 or not -1 < col < 5:
self.move_piece()
else:
if self.height > 0:
self.height -= 1
else:
return "Stack is empty. 😯"
def __str__(self):
return "l" * self.height
# To give the player 3 stacks of 4 pieces and identify whether they are playing as white or black
class GobletPlayer(Player):
def __init__(self, name, fav_color, wb):
self.color = wb
self.stack_a = Stack(name + '_a')
self.stack_b = Stack(name + '_b')
self.stack_c = Stack(name + '_c')
super().__init__(name, fav_color)
def choose_stack(self):
print(f"Stack A: {self.stack_a}, Stack B: {self.stack_b}, Stack C: {self.stack_c}")
stack = input("Please enter which stack you will take the piece from (a, b, c, or z). ")
# Defined move in case stack choice is z
move = None
if stack == 'a':
move = self.stack_a.move_piece()
elif stack == 'b':
move = self.stack_b.move_piece()
elif stack == 'c':
move = self.stack_c.move_piece()
else:
input("Please tell the host your original piece location in row#,col# format. ")
_row, _col = [int(value) for value in input("Please tell the host your final piece location in row#,col# format. ").split(',')]
if move is not None:
print(move)
self.choose_stack()
# Initializing player variables
p1name, p1fav, p1col = input("Player 1: Enter your name, favorite color, and piece color (White/Black) separated by spaces: ").split()
player1 = GobletPlayer(p1name, p1fav, p1col)
print(player1)
p2name, p2fav, p2col = input("Player 2: Enter your name, favorite color, and piece color (White/Black) separated by spaces: ").split()
player2 = GobletPlayer(p2name, p2fav, p2col)
print(player2)
host_inquiry = int(input("Which player is the host? ")[-1])
if host_inquiry == 1:
host_name = player1.name
else:
host_name = player2.name
# End case for while loop
game_end = False
# Increment token to not ask about winning the game before round 5
i = 0
print('''Your goal in Gobblet Gobblers is to place four of your pieces in a horizontal, vertical or diagonal row.
Your pieces can stack on top of each other and they start the game nested, off the board.
On a turn, you either play one exposed piece from your three off-the-board piles or move one piece on the board to any other spot on the board where it fits.
A larger piece can cover any smaller piece.
Your memory is tested as you try to remember which color one of your larger pieces is covering before you move it.
As soon as a player has four like-colored pieces in a row, he wins — except in one case:
If you lift your piece and reveal an opponent's piece that finishes a four-in-a-row, you don't immediately lose;
you can't return the piece to its starting location, but if you can place it over one of the opponent's two other pieces in that row, the game continues.\n''')
while not game_end:
print(host_name + ", send game picture. 📷")
# Spacer input ask that can take any text
input("Did you send the picture? ")
print(player1.name + ": " + player1.color)
player1.choose_stack()
print(host_name + ", make the move.\n")
# Switch to player 2 move
print(player2.name + ": " + player2.color)
player2.choose_stack()
print(host_name + ", make the move.")
i += 1
# Double confirmed decision to leave the game
continue_game = input("Would you like to keep playing? (y/n) 🎲 ")
if continue_game == 'n' and input("\n Are you sure you want to end the game? ❌ (y/n) ") == 'y':
game_end = True
if i > 4:
won_game = input("Has anyone won yet? 👑 (y/n) ")
if won_game == 'y' and input("Really? 😲 (y/n) ") == 'y':
game_end = True
else:
"Thanks for playing the game! 💙"
|
'''011 - PINTANDO PAREDES.
PROGRAMA QUE LEIA LARGURA E ALTURA DE UMA ÁREA E MOSTRE A QUANTIDADE DE TINTA QUE SERÁ NECESSÁRIO
TINTA = 4.5m'''
L = float(input('Qual a Largura da parede: '))
A = float(input('Qual a Altura da parede: '))
AT = L * A
T = AT / 4.5
print('Sua parede tem a dimensão de {} x {}, então sua área é {:.2f}m²'.format(L, A, AT))
print('Para pintar essa área, você precisará de {:.2f}l de tinta'.format(T))
'''015 - ALUGUEL DE CARRO.
PROGRAMA QUE QUANTIDADE DE DIAS, QUILOMETRAGEM RODADA E FAÇA OS CALCULOS PARA DAR O VALOR DO ALUGUEL
DIAS = R$ 60 e KM = R$ 0.15'''
dias = int(input('Quantos dias você ficou com o carro? '))
km = float(input("Quantos Km's foram rodados? "))
Total = (dias * 60) + (km * 0.15)
print('O carro ficou alugado por {} dias, com um total de {:.2f}km rodados, totalizando o pagamento de: R${:.2f}'.format(dias, km, Total))
|
""" if
print('programa de notas')
def evaluacion(nota):
valoracion="aprovado"
if nota < 5:
valoracion='suspendido'
else:
valoracion='aprovo'
return valoracion
dato = input('ingrese la nota: ')
print(evaluacion(int(dato))) """
""" for
# recorro una lista
for i in ["primavera", "otoño"]: #[1,2,3]:
print('hola: ' + str(i)) # ,end='' # sin salto de linea
# imprime tantas veces como caracteres
for i in "prueba":
print("hola: " + i)
# validar correo
email = False
for i in "[email protected]":
if(i=="@"):
email = True
print("email is " + str(email)) """
"""
iteracion = 0
while iteracion <= 3:
iteracion += 1
print("text: ", str(iteracion)) """
for i in range(5,20,3): # 5 -- 9 of 3 in 3
print(i) |
#Task 4: Login functionality
# In its parameter list, define three parameters: database, username, and password.
def login(database, username, password):
if username in dict.keys(database) and database[username] == password:
print("Welcome back: ", username)
elif username in dict.keys(database) or password in dict.values(database):
print("Check your credentials again!")
else:
print("Something went wrong")
def register(database, username):
if username in dict.values(database):
print("Username already registered")
else:
print("Username successfully registered: ", username)
def donate(username):
donation_amount = float(input("Enter an amount to donate: "))
donation = f'{username} donated ${donation_amount}'
return donation
def show_donations(donations):
print("\n--- All Donations ---")
if not donations:
print("There are currently no donations")
else:
for d in donations:
print(d)
|
H, W = map(int, input().split())
N = 0
a_map = []
for i in range(H):
a = list(map(int, input().split()))
a_map.append(a)
result = []
for i in range(H):
for j in range(W):
if a_map[i][j]%2==1:
if j < W - 1:
N += 1
result.append([i + 1, j + 1, i + 1, j + 2])
a_map[i][j + 1] += 1;
a_map[i][j] -= 1;
elif i < H - 1:
N += 1;
result.append([i + 1, j + 1, i + 2, j + 1])
a_map[i][j] -= 1;
a_map[i + 1][j] += 1;
print(N)
for a in result:
print(a[0], a[1], a[2], a[3])
|
class Stairs:
def designs(self, maxHeight, minWidth, totalHeight, totalWidth):
c = 0
for r in xrange(1, maxHeight + 1):
if totalHeight % r == 0:
n = totalHeight / r
if (
n > 1
and totalWidth % (n - 1) == 0
and totalWidth / (n - 1) >= minWidth
):
c += 1
return c
|
# Solve the Equation
class Solution(object):
def solveEquation(self, equation):
"""
:type equation: str
:rtype: str
"""
left, right = equation.split('=')
a1, b1 = self.get_coefficients(left)
a2, b2 = self.get_coefficients(right)
a, b = a1 - a2, b2 - b1 # ax = b
if a == 0:
if b == 0:
return "Infinite solutions"
else:
return "No solution"
else:
return "x={}".format(b / a)
def get_coefficients(self, s):
a = b = 0
sign = 1
i = j = 0
while i < len(s):
if s[i] == '+':
sign = 1
i += 1
elif s[i] == '-':
sign = -1
i += 1
else:
j = i
while j < len(s) and s[j] not in '+-':
j += 1
token = s[i:j]
if token == 'x':
a += sign
elif token[-1] == 'x':
a += sign * int(token[:-1])
else:
b += sign * int(token)
i = j
return a, b
|
# 邮箱验证链接有效时间:s
VERIF_EMAIL_TOKEN_EXPIRES = 7200
# 登录用户收货地址最大数量
USER_ADDRESS_COUNTS_LIMIT = 20
# 登录用户浏览记录保存最大数量
USER_BROWSING_HISTORY_COUNTS_LIMIT = 5
|
# $Filename$
# $Authors$
# Last Changed: $Date$ $Committer$ $Revision-Id$
#
# Copyright (c) 2003-2011, German Aerospace Center (DLR)
# All rights reserved.
#
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are
#met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the German Aerospace Center nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
Contains wrapper class around the property representation used in the core package.
"""
__version__ = "$Revision-Id:$"
class PropertyDescription(object):
"""
Wrapper around the internal property representation giving restricted access to
the relevant parameters.
All instance variables are read-only.
@ivar identifier: This is the logical identifier of the property.
@type identifier: C{unicode}
@ivar category: This holds the category of the property, i.e. if the property is
system, data model or user specific.
System specific: property can NOT be deleted from resource, values are read-only
Data model specific: property can NOT be deleted from resource, values changeable
User specific: property can be deleted from resource, values changeable
@type category: C{unicode}, for possible values see:
L{constants<datafinder.script_api.properties.constants>}
@ivar displayName: A readable name that can be presented in a user interface.
@type displayName: C{unicode}
@ivar description: Describes the purpose of the property.
@type description: C{unicode}
@ivar notNull: Flag indicating if C{None} is a allowed property value or not.
@type notNull: C{bool}
@ivar defaultValue: A default value for the property that is used for creation of the property on a resource.
@type defaultValue: The type of the default value depends on the property definition.
@ivar restrictions: This parameter holds the defined property restrictions that are
represented by parameters. The returned mapping can contain the following keys:
minimumValue: Defining the lower boundary of a value range.
maximumValue: Defining the upper boundary of a value range.
minimumLength: Defining the lower boundary of a length range.
maximumLength: Defining the upper boundary of a length range.
minimumNumberOfDecimalPlaces: Defining the minimum number of decimal places.
maximumNumberOfDecimalPlaces: Defining the maximum number of decimal places.
pattern: Regular expression pattern that restricts a string value.
options: A list of options the value can be chosen from.
optionsMandatory: Boolean indicating whether the value MUST be from the list of options.
subTypes: List of strings identifying supported types.
The possible restrictions depend on the type.
@type restrictions: C{dict}
@ivar namespace: Name space in which the property is valid, e.g. used to distinguish
different C{name} properties of different data types.
@type namespace: C{unicode}
"""
def __init__(self, propertyDefinition):
"""
Constructor.
@param propertyRepresentation: The property definition.
@type propertyRepresentation: L{PropertyTemplate<datafinder.application.metadata.property_types.PropertyBase>}
"""
self.__propertyDefinition = propertyDefinition
def __getIdentifier(self):
"""
Returns the identifier of the property.
"""
return self.__propertyDefinition.identifier
identifier = property(__getIdentifier)
def __getType(self):
""" Returns the propertyType. """
return self.__propertyDefinition.type
type = property(__getType)
def __getDisplayName(self):
"""
Returns the display name of the property.
"""
return self.__propertyDefinition.displayName
displayName = property(__getDisplayName)
def __getCategory(self):
"""
Returns the property category.
"""
return self.__propertyDefinition.category
category = property(__getCategory)
def __getDescription(self):
"""
Returns the property description.
"""
return self.__propertyDefinition.description
description = property(__getDescription)
def __getDefaultValue(self):
"""
Returns the specific default value.
"""
return self.__propertyDefinition.defaultValue
defaultValue = property(__getDefaultValue)
def __getNotNull(self):
"""
Returns whether the value can be C{None} or not.
"""
return self.__propertyDefinition.notNull
notNull = property(__getNotNull)
def __getNamespace(self):
"""
Returns the namespace.
"""
return self.__propertyDefinition.namespace
namespace = property(__getNamespace)
def __getRestrictions(self):
"""
Returns the defined restrictions of the property.
"""
return self.__propertyDefinition.restrictions
restrictions = property(__getRestrictions)
def __repr__(self):
""" Returns a readable representation. """
return self.identifier + " Type: " + self.type \
+ " Category: " + self.category
|
length = int(raw_input())
s = raw_input()
n = length / 4
A = T = G = C = 0
for i in s:
if i == 'A':
A += 1
elif i == 'T':
T += 1
elif i == 'G':
G += 1
else:
C += 1
res = 0
if A != n or C != n or G != n or T != n:
res = length
l = 0
for r in xrange(length):
if s[r] == 'A':
A -= 1
if s[r] == 'T':
T -= 1
if s[r] == 'G':
G -= 1
if s[r] == 'C':
C -= 1
while A <= n and C <= n and G <= n and T <= n and l <= r:
res = min(res, r - l + 1)
if s[l] == 'A':
A += 1
if s[l] == 'T':
T += 1
if s[l] == 'G':
G += 1
if s[l] == 'C':
C += 1
l += 1
print(res)
|
class JellyBean:
def __init__( self, mass = 0 ):
self.mass = mass
def __add__( self, other ):
other_mass = other.mass
other.mass = 0
return JellyBean( self.mass + other_mass )
def __sub__( self, other ):
self_mass = self.mass
self.mass -= other.mass
def __str__( self ):
return f"Mass: { self.mass }"
def __repr__( self ):
return f"{ self.__dict__ }"
jelly = JellyBean( 3 )
bean = JellyBean( 2 )
jelly += bean
print( jelly )
print( bean ) |
def fatorial(a,b=0):
"""
Uma função que calcula o fatorial de um número
:param a: Número a ser calculado
:param b: Variável de escolha que define a visualização dos cálculos
:return: Sem retorno
"""
f = a
if b == 1:
for c in range(a-1,1,-1):
f = f * c
print(f)
else:
for c in range(a-1,1,-1):
print(f'{f} x {c} = ',end='')
f = f * c
print(f)
print(f)
#Programa principal
n = int(input('Digite um número para saber seu fatorial: '))
esc = int(input('Digite [0] para mostrar os cálculos e [1] para esconder: '))
fatorial(n,esc) |
class PlayerAlreadyHasItemError(Exception):
pass
class PlayerNotInitializedError(Exception):
pass
|
valorProduto = float(input('Insira o valor do produto: R$'))
porcentagem = int(input('Insira a % de desconto deste produto: '))
valorDesconto = porcentagem*valorProduto/100
print(f'O valor final é de: R${valorProduto-valorDesconto:.2f} ')
|
# Preferences defaults
PREFERENCES_PATH = "./config/preferences.json"
PREFERENCES_DEFAULTS = {
'on_time': 1200,
'off_time': 300
}
# Bot configureation
DISCORD_TOKEN = "from https://discord.com/developers"
ADMIN_ID = 420
USER_ID = 999
DEV_MODE = True
PREFIX = '!!'
PREFIXES = ('johnsmith ', 'john smith ')
COGS_LIST = ['cogs.misc', 'cogs.testing', 'cogs.admin'] |
# สร้าง list
def detail(data): # data รับมาเป็น list
for i in data:
print("{}".format(i))
score = []
print("{}".format(score))
print("{}".format(type(score)))
for i in range(5):
x = int(input('Enter Score : '))
score.append(x)
print("{}".format(score))
detail(score)
# List Comprehension
# พ.ศ.-543 --> ค.ศ.
c = [(i - 543) for i in range(2500, 2565)]
print("{}".format(c))
dollar = [(i / 31.8) for i in range(1, 101)]
print("{}".format(dollar))
|
# has_good_credit = True
# has_criminal_record = True
#
# if has_good_credit and not has_criminal_record:
# print("Eligible for loan")
# temperature = 35
#
# if temperature > 30:
# print("It's a hot day")
# else:
# print("It's not a hot day")
name = "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
if len(name) < 3:
print("Name must be at least 3 characters long")
elif len(name) > 50:
print("Name cannot be more than 50 characters long")
else:
print("Name looks good!")
|
x = ''
while True:
x = input()
print(x)
if x == 'end':
break
print('end') |
# -*- coding: utf-8 -*-
def main():
s = sorted([input() for _ in range(15)])
print(s[6])
if __name__ == '__main__':
main()
|
#prctice8-14
#汽车
def make_car(name, brand, **other):
car = {}
car['name'] = name
car['brand']=brand
for key, value in other.items():
car[key]=value
return car
car = make_car('subaru', 'outback',
color= 'blue',
tow_package=True)
print(car)
|
class Calculadora(object):
"""docstring for Calculadora"""
memoria = 10
def suma(a, b):
return a + b
def resta(a, b):
return a - b
def multiplicacion(a, b):
return a * b
def division(a, b):
return a / b
@classmethod
def numerosPrimos(cls, limite):
rango = range(2, limite)
return [primo for primo in rango if sum(primo % num == 0 for num in rango) < 2][:cls.memoria]
calc = Calculadora
print(calc.numerosPrimos(100)) |
# Perulangan pada set dan dictionary
print('\n==========Perulangan Pada Set==========')
set_integer = {10, 20, 30, 40, 50}
# Cara pertama
for item in set_integer:
print(item, end=' ')
print('')
# Cara kedua
for i in range(len(set_integer)):
print(list(set_integer)[i], end=' ')
print('')
# Cara ketiga
i = 0
while i < len(set_integer):
print(list(set_integer)[i], end=' ')
i = i + 1
print('\n\n==========Perulangan Pada Dictionary==========')
# Menambah item
dictionary_kosong = {}
list_string = ['aku', 'sedang', 'belajar', 'python']
for i in range(len(list_string)):
dictionary_kosong[i] = list_string[i]
# dictionary_kosong.update({i:list_string[i]})
print(dictionary_kosong)
# Menampilkan item
dictionary_hari = {1:'Senin',
2:'Selasa',
3:'Rabu',
4:'Kamis',
5:'Jumat',
6:'Sabtu',
7:'Minggu'}
# Cara pertama
for key in dictionary_hari.keys():
print(key, end=' ' )
print('')
for value in dictionary_hari.values():
print(value, end=' ')
print('')
# Cara kedua
for key, value in dictionary_hari.items():
print(key, value, end=' ')
print('')
# Cara ketiga
i = 0
while i < len(dictionary_hari):
key = list(dictionary_hari.keys())
print(key[i], dictionary_hari[key[i]], end=' ')
i = i + 1
|
# -*- coding: utf-8 -*-
minha_string = "O rato roeu a roupa do rei de Roma"
busca = minha_string.find("rei") #recebe como parametro a busca
print(busca) #mostra a posição da busca
print(minha_string[busca:]) #mostra tudo que vem após a busca
busca = minha_string.find("Rainha")
print(busca) #caso não encontre o resultado da busca retorna -1 |
# -*- coding: utf-8 -*-
# @Author: zengjq
# @Date: 2020-10-21 14:04:31
# @Last Modified by: zengjq
# @Last Modified time: 2020-10-21 14:45:03
class Solution:
# 90 mem 100
# 把大数往nums1的末尾移动
def merge(self, nums1, m, nums2, n):
while m and n:
if nums1[m-1] > nums2[n-1]:
nums1[m+n-1] = nums1[m-1]
m -= 1
else:
nums1[m+n-1] = nums2[n-1]
n -= 1
nums1[:n] = nums2[:n]
return nums1
if __name__ == '__main__':
l1 = [1,2,3,0,0,0]
l2 = [2,5,6]
s = Solution()
r = s.merge(l1,3,l2,3)
print(r)
|
def word_time(word, elapsed_time):
return [word, elapsed_time]
p0 = [word_time('START', 0), word_time('What', 0.2), word_time('great', 0.4), word_time('luck', 0.8)]
p1 = [word_time('START', 0), word_time('What', 0.6), word_time('great', 0.8), word_time('luck', 1.19)]
p0
p1 |
# Definition for singly-linked list.
# class LinkedListNode:
# def __init__(self, value = 0, next = None):
# self.value = value
# self.next = next
class Solution:
def containsCycle(self, head):
if not head or not head.next:
return False
current = head
s = set()
while current:
if id(current) in s:
return True
s.add(id(current))
current = current.next
return False
|
def inf():
while True:
yield
for _ in inf():
input('>')
|
def grep(pattern):
print("Searching for", pattern)
while True:
line = (yield)
if pattern in line:
print(line)
search = grep('coroutine')
next(search)
search.send("I love you")
search.send("Don't you love me")
search.send("I love coroutines")
|
# -*- coding: utf-8 -*-
def extraNumber(A, B, C):
if A == B: return C
elif A == C: return B
else: return A
extraNumber = lambda A, B, C: C if (A == B) else B if (A == C) else A
"""
Given three integers, two of them are guaranteed to be equal, find the third one.
Example
For A = 2, B = 4 and C = 2, the output should be
extraNumber(A, B, C) = 4.
Input/Output
[time limit] 4000ms (py)
[input] integer A
Constraints:
1 ≤ A ≤ 10^9.
[input] integer B
Constraints:
1 ≤ B ≤ 10^9.
[input] integer C
Constraints:
1 ≤ C ≤ 10^9.
[output] integer
"""
|
def conf():
return {
"id":"discord",
"description":"this is the discord c360 component",
"enabled":False,
} |
"""Custom errors and exceptions."""
class MusicAssistantError(Exception):
"""Custom Exception for all errors."""
class ProviderUnavailableError(MusicAssistantError):
"""Error raised when trying to access mediaitem of unavailable provider."""
class MediaNotFoundError(MusicAssistantError):
"""Error raised when trying to access non existing media item."""
class InvalidDataError(MusicAssistantError):
"""Error raised when an object has invalid data."""
class AlreadyRegisteredError(MusicAssistantError):
"""Error raised when a duplicate music provider or player is registered."""
class SetupFailedError(MusicAssistantError):
"""Error raised when setup of a provider or player failed."""
class LoginFailed(MusicAssistantError):
"""Error raised when a login failed."""
class AudioError(MusicAssistantError):
"""Error raised when an issue arrised when processing audio."""
class QueueEmpty(MusicAssistantError):
"""Error raised when trying to start queue stream while queue is empty."""
|
S = input()
l = len(S)
nhug = 0
for i in range(l//2):
if S[i] != S[l-1-i]:
nhug += 1
print(nhug)
|
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def greet(self):
print("Hi there! I'm {}, {} years old!".format(self.name, self.age))
maria = Person("Maria Popova", 25)
pesho = Person("Pesho", 27)
print(maria)
# name = Maria Popova
# age = 25 |
class Solution:
def maxNumber(self, nums1, nums2, k):
def merge(arr1, arr2):
res, i, j = [], 0, 0
while i < len(arr1) and j < len(arr2):
if arr1[i:] >= arr2[j:]:
res.append(arr1[i])
i += 1
else:
res.append(arr2[j])
j += 1
if i < len(arr1): res += arr1[i:]
elif j < len(arr2): res += arr2[j:]
return res
def makeArr(arr, l):
i, res = 0, []
for r in range(l - 1, -1, -1):
num, i = max(arr[i:-r] or arr[i:])
i = -i + 1
res.append(num)
return res
nums1, nums2, choices = [(num, -i) for i, num in enumerate(nums1)], [(num, -i) for i, num in enumerate(nums2)], []
for m in range(k + 1):
if m > len(nums1) or k - m > len(nums2): continue
arr1, arr2 = makeArr(nums1, m), makeArr(nums2, k - m)
choices.append(merge(arr1, arr2))
return max(choices)
|
def sudoku2(grid):
seen = set()
# Iterate through grid
for i in range(len(grid)):
for j in range(len(grid[i])):
current_value = grid[i][j]
if current_value != ".":
if (
(current_value + " found in row " + str(i)) in seen
or (current_value + " found in column " + str(j)) in seen
or (
current_value
+ " found in subgrid "
+ str(i // 3)
+ "-"
+ str(j // 3)
)
in seen
):
return False
seen.add(current_value + " found in row " + str(i))
seen.add(current_value + " found in column " + str(j))
seen.add(
current_value
+ " found in subgrid "
+ str(i // 3)
+ "-"
+ str(j // 3)
)
return True
|
"""Constants for the tankerkoenig integration."""
DOMAIN = "tankerkoenig"
NAME = "tankerkoenig"
CONF_FUEL_TYPES = "fuel_types"
CONF_STATIONS = "stations"
FUEL_TYPES = ["e5", "e10", "diesel"]
|
FEATURES = 'FEATURES'
AUTH_GITHUB = 'AUTH_GITHUB'
AUTH_GITLAB = 'AUTH_GITLAB'
AUTH_BITBUCKET = 'AUTH_BITBUCKET'
AUTH_AZURE = 'AUTH_AZURE'
AFFINITIES = 'AFFINITIES'
ARCHIVES_ROOT = 'ARCHIVES_ROOT'
DOWNLOADS_ROOT = 'DOWNLOADS_ROOT'
ADMIN = 'ADMIN'
NODE_SELECTORS = 'NODE_SELECTORS'
TOLERATIONS = 'TOLERATIONS'
ANNOTATIONS = 'ANNOTATIONS'
K8S_SECRETS = 'K8S_SECRETS'
K8S_CONFIG_MAPS = 'K8S_CONFIG_MAPS'
K8S_RESOURCES = 'K8S_RESOURCES'
ENV_VARS = 'ENV_VARS'
NOTEBOOKS = 'NOTEBOOKS'
TENSORBOARDS = 'TENSORBOARDS'
GROUPS = 'GROUPS'
BUILD_JOBS = 'BUILD_JOBS'
KANIKO = 'KANIKO'
SCHEDULER = 'SCHEDULER'
STATS = 'STATS'
EMAIL = 'EMAIL'
CONTAINER_NAME = 'CONTAINER_NAME'
MAX_RESTARTS = 'MAX_RESTARTS'
INTEGRATIONS_WEBHOOKS = 'INTEGRATIONS_WEBHOOKS'
TTL = 'TTL'
REPOS = 'REPOS'
SIDECARS = 'SIDECARS'
INIT = 'INIT'
K8S = 'K8S'
CLEANING_INTERVALS = 'CLEANING_INTERVALS'
POLYFLOW = 'POLYFLOW'
SERVICE_ACCOUNTS = 'SERVICE_ACCOUNTS'
ACCESS = 'ACCESS'
|
# Emma is playing a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. She can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus or . She must avoid the thunderheads. Determine the minimum number of jumps it will take Emma to jump from her starting postion to the last cloud. It is always possible to win the game.
# For each game, Emma will get an array of clouds numbered if they are safe or if they must be avoided. For example, indexed from . The number on each cloud is its index in the list so she must avoid the clouds at indexes and . She could follow the following two paths: or . The first path takes jumps while the second takes .
# Function Description
# Complete the jumpingOnClouds function in the editor below. It should return the minimum number of jumps required, as an integer.
# jumpingOnClouds has the following parameter(s):
# c: an array of binary integers
# Input Format
# The first line contains an integer , the total number of clouds. The second line contains space-separated binary integers describing clouds where .
# Constraints
# Output Format
# Print the minimum number of jumps needed to win the game.
# Sample Input 0
# 7
# 0 0 1 0 0 1 0
# Sample Output 0
# 4
# Explanation 0:
# Emma must avoid and . She can win the game with a minimum of jumps:
def jumpingOnClouds(c):
if len(c) == 1:
return 0
if len(c) == 2:
return 0 if c[1] == 1 else 1
if c[2] == 1:
return 1 + jumpingOnClouds(c[1:])
if c[2] == 0:
return 1 + jumpingOnClouds(c[2:])
print(jumpingOnClouds([0, 0, 0, 0, 1, 0]))
array = [0, 0, 0, 0, 1, 0]
print(array[1:])
|
def aumentar(v=0, t=0, per=False):
res = v + (v*t/100)
return res if per is False else f'{moeda(res)}'
def diminuir(v=0, t=0, per=False):
res = v - (v*t/100)
return res if per == False else f'{moeda(res)}'
def dobro(v=0, per=False):
res = v*2
return res if not per else f'{moeda(res)}'
def metade(v=0, per=False):
res = v /2
return res if per==False else f'{moeda(res)}'
def moeda(v=0, cifrao='R$'):
return f'{cifrao}{v:.2f}'.replace(".", ",")
def resumo(v=0, au=10, dim=5):
print('-=-'*12)
print(f'{"RESUMO DO PREÇO":^35}')
print('-=-'*12)
print(f'Preço analisado: \t{moeda(v)}'
f'\nDobro do preço: \t{dobro(v, True)}'
f'\nMetade do preço: \t{metade(v, True)}'
f'\n{au}% de aumento: \t{aumentar(v, au, True)}'
f'\n{dim}% de redução: \t{diminuir(v, dim, True)}')
print('-=-'*12) |
def func(*args):
print(args)
print(*args)
a = [1, 2, 3]
# here "a" is passed as tuple of list: ([1, 2, 3],)
func(a)
# print(args) -> ([1, 2, 3],)
# print(*args) -> [1, 2, 3]
# here "a" is passed as tuple of integers: (1, 2, 3)
func(*a)
# print(args) -> (1, 2, 3)
# print(*args) -> 1 2 3
|
def main():
while True:
n,m = map(int, input().split())
if n==0 and m==0:
break
D = [9] * n
H = [0] * m
for d in range(n):
D[d] = int(input())
for k in range(m):
H[k] = int(input())
D.sort() # sorting is an important
H.sort() # pre-processing step
gold = 0
d = 0
k = 0 # both arrays are sorted
while d < n and k < m: # while not done yet
while k < m and D[d] > H[k]:
k += 1 # find required knight k
if k == m:
break # loowater is doomed :S
gold += H[k] # pay this amount of gold
d += 1 # next dragon
k += 1 # next knight
if d == n:
print("{}".format(gold)) # all dragons are chopped
else:
print("Loowater is doomed!")
main()
|
# Write a Python class to find validity of a string of parentheses, '(', ')', '{', '}', '[' ']’. These brackets must be close in the correct order. for example "()" and "()[]{}" are valid but "[)", "({[)]" and "{{{" are invalid.
class validity:
def f(str):
a= ['()', '{}', '[]']
while any(i in str for i in a):
for j in a:
str = str.replace(j, '')
return not str
s = input("enter: ")
print(s, "-", "is balanced" if validity.f(s) else "is Unbalanced") |
# Default Configurations
DEFAULT_PYTHON_PATH = '/usr/bin/python'
DEFAULT_STD_OUT_LOG_LOC = '/usr/local/bin/log/env_var_manager.log'
DEFAULT_STSD_ERR_LOG_LOC = '/usr/local/bin/log/env_var_manager.log'
DEFAULT_START_INTERVAL = 120
|
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while True:
ok = input(prompt)
# in 关键字。它测定序列中是否包含某个确定的值。
if ok in ('y', 'yes', 'ye'):
return True
if ok in ('n', 'no', 'nop', 'nope '):
return False
retries = retries -1
if retries < 0:
raise OSError('uncooperative use')
print(complaint)
# 只给出必要的参数:
# ask_ok('Do you really want to quit?')
# 给出一个可选的参数:
# ask_ok('Ok to overwrite the file?', 2)
# 或者给出所有的参数:
# ask_ok('OK to overwrite the file?', 2, 'Come on, only yes or no!')
# 默认值在函数 定义 作用域被解析
i = 5
def f(arg=i):
print(arg)
i = 6
f()
# 默认值只被赋值一次。这使得当默认值是可变对象时会有所不同,比如列表、字典或者大多数类的实例。例如,下面的函数在后续调用过程中会累积(前面)传给它的参数
print('\n')
def f2(a, L=[]):
L.append(a)
return L
print(f2(1))
print(f2(2))
print(f2(3))
# 如果你不想让默认值在后续调用中累积,你可以像下面一样定义函数:
print('\n')
def f3(a, L=None):
if L is None:
L = []
L.append(a)
return L
print(f3(1))
print(f3(2))
print(f3(3))
# 函数可以通过 关键字参数 的形式来调用,形如 keyword = value
print("\n")
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
print("-- This parrot wouldn't", action, end=' ')
print("if you put", voltage, "volts througn it.")
print("-- Lovely plumage, the", type)
print("-- It's", state, "!")
parrot(100) # 传一个参数
print("\n")
parrot(voltage=0.5) # 传一个参数
print("\n")
parrot(voltage=1000000, action='VOOOOOM')
print("\n")
parrot('a thousand', state='pushing up the daisies')
# 任何参数都不可以多次赋值
print("\n")
def function(a):
pass
# function(0, a=0)
# 引入一个形如 **name 的参数时,它接收一个字典,该字典包含了所有未出现在形式参数列表中的关键字参数
# 使用一个形如 *name (下一小节详细介绍) 的形式参数,它接收一个元组(下一节中会详细介绍),包含了所有没有出现在形式参数列表中的参数值
# *name 必须在 **name 之前出现
print("\n")
def cheeseshop(kind, *arguments, **keywords):
print("-- Do you have any", kind, "?")
print("-- I'm sorry, we're all out of", kind)
for arg in arguments:
print(arg)
print("-" * 40)
keys = sorted(keywords.keys())
for kw in keys:
print(kw, ":", keywords[kw])
cheeseshop("Limburger", "It's very runny, sir.",
"It's really very, VERY runny, sir.",
shopkeeper = "Michael Palin",
client="John Cleese",
sketch="Cheese Shop Sketch")
# 一个最不常用的选择是可以让函数调用可变个数的参数。这些参数被包装进一个元组,在这些可变个数的参数之前,可以有零到多个普通的参数
# 通常,这些 可变 参数是参数列表中的最后一个,因为它们将把所有的剩余输入参数传递给函数
# 任何出现在 *args 后的参数是关键字参数,这意味着,他们只能被用作关键字,而不是位置参数
def write_multiple_items(file, separator, *args):
file.write(separator.join(args))
print("\n")
def concat(*args, sep=","):
print(sep.join(args))
concat('那就这这样吧', '当然爱都曲终人散')
print("\n")
concat('那就这这样吧', '当然爱都曲终人散', '不要再想了', sep="\n")
|
n=int(input())
students={}
for k in range(0,n):
name = input()
grade=float(input())
if not name in students:
students[name]=[grade]
else:
students[name].append(grade)
for j in students:
gradesCount=len(students[j]); gradesSum=0
for k in range(0,len(students[j])):
gradesSum+=students[j][k]
students[j]=gradesSum/gradesCount
if students[j]<4.50:
students[j]="Doesn't pass"
for j in students:
if students[j]=="Doesn't pass":
continue
else:
print(f"{j} -> {students[j]:.2f}")
|
def problem_2():
"By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms."
sequence = [1]
total, sequence_next = 0, 0
# While the next term in the Fibonacci sequence is under 4000000...
while(sequence_next < 4000000):
# Calculate the next term in the sequence and append it to the list
sequence_next = sequence[len(sequence) - 1] + \
sequence[len(sequence) - 2]
sequence.append(sequence_next)
# If the entry is even, add it to the sum of even numbered terms
if(sequence_next % 2 == 0):
total += sequence_next
return total
if __name__ == "__main__":
answer = problem_2()
print(answer)
|
"""
创建函数,计算IQ等级
ma = int(input("请输入你的心里年龄:"))
ca = int(input("请输入你的实际年龄:"))
iq = ma / ca * 100
if 140 <= iq:
print("天才")
elif 120 <= iq:
print("超常")
elif 110 <= iq:
print("聪慧")
elif 90 <= iq:
print("正常")
elif 80 <= iq:
print("迟钝")
else:
print("低能")
"""
def get_iq(ma,ca):
iq = ma / ca * 100
if 140 <= iq: return ("天才")
if 120 <= iq: return ("超常")
if 110 <= iq: return ("聪慧")
if 90 <= iq: return ("正常")
if 80 <= iq: return ("迟钝")
return "低能"
print(get_iq(30,20))
|
#
# PySNMP MIB module HUAWEI-VPLS-TNL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-VPLS-TNL-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:49:40 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, ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint")
hwDatacomm, = mibBuilder.importSymbols("HUAWEI-MIB", "hwDatacomm")
InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex")
ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup")
ModuleIdentity, MibIdentifier, Counter32, Counter64, IpAddress, Integer32, NotificationType, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, ObjectIdentity, TimeTicks, Bits, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "ModuleIdentity", "MibIdentifier", "Counter32", "Counter64", "IpAddress", "Integer32", "NotificationType", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "ObjectIdentity", "TimeTicks", "Bits", "Gauge32")
TextualConvention, RowStatus, DisplayString, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "RowStatus", "DisplayString", "TruthValue")
hwL2VpnVplsTnlExt = ModuleIdentity((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6))
if mibBuilder.loadTexts: hwL2VpnVplsTnlExt.setLastUpdated('200812151925Z')
if mibBuilder.loadTexts: hwL2VpnVplsTnlExt.setOrganization('Huawei Technologies Co., Ltd.')
if mibBuilder.loadTexts: hwL2VpnVplsTnlExt.setContactInfo('R&D BeiJing, Huawei Technologies co.,Ltd. Huawei Bld.,NO.3 Xinxi Rd., Shang-Di Information Industry Base, Hai-Dian District Beijing P.R. China Zip:100085 Http://www.huawei.com E-mail:[email protected]')
if mibBuilder.loadTexts: hwL2VpnVplsTnlExt.setDescription('This MIB defines all the objects that containing VPLS tunnel information.')
hwL2Vpn = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119))
hwVplsTunnelMIBObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1))
hwVplsTunnelTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1), )
if mibBuilder.loadTexts: hwVplsTunnelTable.setStatus('current')
if mibBuilder.loadTexts: hwVplsTunnelTable.setDescription('Information about VPLS PW Tunnel. This object is used to get VPLS PW tunnel table.')
hwVplsTunnelEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1), ).setIndexNames((0, "HUAWEI-VPLS-TNL-MIB", "hwVplsVsiName"), (0, "HUAWEI-VPLS-TNL-MIB", "hwVplsNexthopPeer"), (0, "HUAWEI-VPLS-TNL-MIB", "hwVplsSiteOrPwId"), (0, "HUAWEI-VPLS-TNL-MIB", "hwVplsPeerTnlId"))
if mibBuilder.loadTexts: hwVplsTunnelEntry.setStatus('current')
if mibBuilder.loadTexts: hwVplsTunnelEntry.setDescription('It is used to get detailed tunnel information.')
hwVplsVsiName = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 31)))
if mibBuilder.loadTexts: hwVplsVsiName.setStatus('current')
if mibBuilder.loadTexts: hwVplsVsiName.setDescription('The name of this VPLS instance.')
hwVplsNexthopPeer = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 2), IpAddress())
if mibBuilder.loadTexts: hwVplsNexthopPeer.setStatus('current')
if mibBuilder.loadTexts: hwVplsNexthopPeer.setDescription('The ip address of the peer PE.')
hwVplsSiteOrPwId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 3), Unsigned32())
if mibBuilder.loadTexts: hwVplsSiteOrPwId.setStatus('current')
if mibBuilder.loadTexts: hwVplsSiteOrPwId.setDescription('Remote Site ID for BGP Mode, or PW id for LDP Mode')
hwVplsPeerTnlId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 4), Unsigned32())
if mibBuilder.loadTexts: hwVplsPeerTnlId.setStatus('current')
if mibBuilder.loadTexts: hwVplsPeerTnlId.setDescription('The Tunnel ID.')
hwVplsTnlName = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 5), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsTnlName.setStatus('current')
if mibBuilder.loadTexts: hwVplsTnlName.setDescription('The name of this Tunnel.')
hwVplsTnlType = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("lsp", 1), ("crlsp", 2), ("other", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsTnlType.setStatus('current')
if mibBuilder.loadTexts: hwVplsTnlType.setDescription('The type of this Tunnel. e.g. LSP/GRE/CR-LSP...')
hwVplsTnlSrcAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 7), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsTnlSrcAddress.setStatus('current')
if mibBuilder.loadTexts: hwVplsTnlSrcAddress.setDescription('The source ip address of this tunnel.')
hwVplsTnlDestAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 8), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsTnlDestAddress.setStatus('current')
if mibBuilder.loadTexts: hwVplsTnlDestAddress.setDescription('The destination ip address of this tunnel.')
hwVplsLspIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspIndex.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspIndex.setDescription('The index of lsp.')
hwVplsLspOutIf = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 10), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspOutIf.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspOutIf.setDescription('The out-interface of lsp.')
hwVplsLspOutLabel = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspOutLabel.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspOutLabel.setDescription('The out-label of lsp.')
hwVplsLspNextHop = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 12), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspNextHop.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspNextHop.setDescription('The next-hop of lsp.')
hwVplsLspFec = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 13), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspFec.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspFec.setDescription('The Fec of lsp.')
hwVplsLspFecPfxLen = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 14), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspFecPfxLen.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspFecPfxLen.setDescription('The length of mask for hwVplsLspFec.')
hwVplsLspIsBackup = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 15), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspIsBackup.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspIsBackup.setDescription('Indicate whether the lsp is main.')
hwVplsIsBalance = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 16), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsIsBalance.setStatus('current')
if mibBuilder.loadTexts: hwVplsIsBalance.setDescription('Property of Balance. Rerurn True if Tunnel-Policy is configed.')
hwVplsLspTunnelId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 17), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspTunnelId.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspTunnelId.setDescription('This object indicates the tunnel ID of the tunnel interface.')
hwVplsLspSignType = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20))).clone(namedValues=NamedValues(("ldp", 1), ("crLdp", 2), ("rsvp", 3), ("bgp", 4), ("l3vpn", 5), ("static", 6), ("crStatic", 7), ("bgpIpv6", 8), ("staticHa", 9), ("l2vpnIpv6", 10), ("maxSignal", 20)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hwVplsLspSignType.setStatus('current')
if mibBuilder.loadTexts: hwVplsLspSignType.setDescription('This object indicates the signaling protocol of the tunnel.')
hwVplsTnlRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 1, 1, 1, 50), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hwVplsTnlRowStatus.setStatus('current')
if mibBuilder.loadTexts: hwVplsTnlRowStatus.setDescription('The operating state of the row.')
hwVplsTunnelMIBTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 2))
hwVplsTunnelMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 3))
hwVplsTunnelMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 3, 1))
hwVplsTunnelMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 3, 1, 1)).setObjects(("HUAWEI-VPLS-TNL-MIB", "hwVplsTunnelGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
hwVplsTunnelMIBCompliance = hwVplsTunnelMIBCompliance.setStatus('current')
if mibBuilder.loadTexts: hwVplsTunnelMIBCompliance.setDescription('The compliance statement for systems supporting the HUAWEI-VPLS-TNL-MIB.')
hwVplsTunnelMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 3, 2))
hwVplsTunnelGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 119, 6, 3, 2, 1)).setObjects(("HUAWEI-VPLS-TNL-MIB", "hwVplsTnlName"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsTnlType"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsTnlSrcAddress"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsTnlDestAddress"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspOutIf"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspOutLabel"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspNextHop"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspFec"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspFecPfxLen"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspIsBackup"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsIsBalance"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspTunnelId"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsLspSignType"), ("HUAWEI-VPLS-TNL-MIB", "hwVplsTnlRowStatus"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
hwVplsTunnelGroup = hwVplsTunnelGroup.setStatus('current')
if mibBuilder.loadTexts: hwVplsTunnelGroup.setDescription('The VPLS tunnel group.')
mibBuilder.exportSymbols("HUAWEI-VPLS-TNL-MIB", hwVplsSiteOrPwId=hwVplsSiteOrPwId, hwVplsTunnelMIBConformance=hwVplsTunnelMIBConformance, hwVplsIsBalance=hwVplsIsBalance, PYSNMP_MODULE_ID=hwL2VpnVplsTnlExt, hwVplsTunnelMIBCompliances=hwVplsTunnelMIBCompliances, hwVplsTunnelMIBObjects=hwVplsTunnelMIBObjects, hwVplsTunnelGroup=hwVplsTunnelGroup, hwVplsTunnelMIBTraps=hwVplsTunnelMIBTraps, hwVplsTnlRowStatus=hwVplsTnlRowStatus, hwVplsLspSignType=hwVplsLspSignType, hwVplsTunnelMIBCompliance=hwVplsTunnelMIBCompliance, hwVplsLspFec=hwVplsLspFec, hwVplsLspTunnelId=hwVplsLspTunnelId, hwVplsLspIndex=hwVplsLspIndex, hwVplsTunnelEntry=hwVplsTunnelEntry, hwVplsTunnelMIBGroups=hwVplsTunnelMIBGroups, hwVplsTnlName=hwVplsTnlName, hwVplsLspOutIf=hwVplsLspOutIf, hwVplsLspFecPfxLen=hwVplsLspFecPfxLen, hwL2Vpn=hwL2Vpn, hwVplsTnlType=hwVplsTnlType, hwVplsTunnelTable=hwVplsTunnelTable, hwVplsLspNextHop=hwVplsLspNextHop, hwVplsTnlSrcAddress=hwVplsTnlSrcAddress, hwVplsTnlDestAddress=hwVplsTnlDestAddress, hwVplsPeerTnlId=hwVplsPeerTnlId, hwL2VpnVplsTnlExt=hwL2VpnVplsTnlExt, hwVplsLspOutLabel=hwVplsLspOutLabel, hwVplsLspIsBackup=hwVplsLspIsBackup, hwVplsNexthopPeer=hwVplsNexthopPeer, hwVplsVsiName=hwVplsVsiName)
|
nome = 'Luiz Otávio'
idade = 32
altura = 1.80
e_maior = idade > 18
peso = 80
imc = peso / (altura**2)
print(nome, 'tem', idade, 'anos de idade e seu imc é', imc)
#
print(f'{nome} tem {idade} anos de idade e seu imc é {imc:.2f}')
print('{} tem {} anos de idade e seu imc é {:.2f}'.format(nome, idade, imc))
# No exemplo abaixo nome pode ser representado por 0, idade 1 e imc 2
print('{0} tem {1} anos de idade {1} e {0}seu imc é {2:.2f}'.format(nome, idade, imc))
# Também é possível declarar as representações
print('{n} tem {im} anos de idade {n} e {i}seu imc é {i:.2f}'.format(n=nome, i=idade, im=imc)) |
print('a sequence from 0 to 2')
for i in range(3):
print(i)
print('----------------------')
print('a sequence from 2 to 4')
for i in range(2, 5):
print(i)
print('----------------------')
print('a sequence from 2 to 8 with a step of 2')
for i in range(2, 9, 2):
print(i)
'''
Output:
a sequence from 0 to 2
0
1
2
----------------------
a sequence from 2 to 4
2
3
4
----------------------
a sequence from 2 to 8 with a step of 2
2
4
6
8
''' |
class MockResponse:
def __init__(self, status_code, data):
self.status_code = status_code
self.data = data
def json(self):
return self.data
class AuthenticationMock:
def get_token(self):
pass
def get_headers(self):
return {"Authorization": "Bearer token"}
def give_response(status_code, data):
return MockResponse(status_code, data)
GUIDS_MOCK = {
"resources": [
{
"entity": {
"name": "test1",
"space_guid": "space",
"state": "STARTED"
},
"metadata": {
"guid": "guid",
"updated_at": "2012-01-01T13:00:00Z"
}
},
{
"entity": {
"name": "test2",
"space_guid": "space",
"state": "STOPPED"
},
"metadata": {
"guid": "guid",
"updated_at": "2012-01-01T13:00:00Z"
}
}
]
} |
#Creating a Tuple
newtuple = 'a','b','c','d'
print(newtuple)
# Tuple with 1 element
tupple = 'a',
print(tupple)
newtuple1 = tuple('abcd')
print(newtuple1)
print("------------------")
#Accessing Tuples
newtuple = 'a','b','c','d'
print(newtuple[1])
print(newtuple[-1])
#Traversing a Tuple
for i in newtuple:
print(i)
print("------------------")
#Searching a tuple
print('b' in newtuple) |
my_favorite_things = {'food': ['burgers', 'pho', 'mangoes'], 'basketball': ['dribbling', 'passing', 'shooting']}
# A list uses square brackets while a dictionary uses curly braces.
my_favorite_things['movies'] = ['Avengers', 'Star Wars']
# my_favorite_things of movies is value
# A square bracket after a variable allows you to indicate which key you're talking about.
print(my_favorite_things['food'])
# We are giving the computer the value of the key food in the variable my_favorite_things.
# We have to be very SPECIFIC in our language on python so the program can understand us.
appliances = ['lamp', 'toaster', 'microwave']
# lists a dictionary were numbers are the keys
print(appliances[1])
appliances[1] = 'blender'
# Use line 12 format to reassign the value the index or position in a list.
print(appliances)
my_favorite_things['movies'].append('Harry Potter')
print(my_favorite_things['movies'])
def plus_5(x):
return x + 5
p = plus_5(3)
print(p)
def max(x, y):
if x < y:
return y
else:
return x
v = max(3, 11)
print(v)
|
#
# @lc app=leetcode id=2 lang=python
#
# [2] Add Two Numbers
#
# @lc code=start
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
if l1 == None:
return l2
if l2 == None:
return l1
head1 = l1
head2 = l2
ret = ListNode()
head = ret
toSum = 0
while (head1 != None and head2 != None):
cur = ListNode((head1.val+head2.val+toSum)%10, None)
head.next = cur
head = cur
toSum = (head1.val+head2.val+toSum)/10
head1 = head1.next
head2 = head2.next
while (head1 != None):
cur = ListNode((head1.val+toSum)%10, None)
head.next = cur
head = cur
toSum = (head1.val+toSum)/10
head1 = head1.next
while (head2 != None):
cur = ListNode((head2.val+toSum)%10, None)
head.next = cur
head = cur
toSum = (head2.val+toSum)/10
head2 = head2.next
if toSum != 0:
head.next = ListNode(toSum, None)
return ret.next
# @lc code=end
|
def get_words_indexes(words_indexes_dictionary, review):
words = review.split(' ')
words_indexes = set()
for word in words:
if word in words_indexes_dictionary:
word_index = words_indexes_dictionary[word]
words_indexes.add(word_index)
return words_indexes |
bool_expected_methods = [
'__abs__',
'__add__',
'__and__',
'__bool__',
'__ceil__',
'__class__',
'__delattr__',
'__dir__',
'__divmod__',
'__doc__',
'__eq__',
'__float__',
'__floor__',
'__floordiv__',
'__format__',
'__ge__',
'__getattribute__',
'__getnewargs__',
'__gt__',
'__hash__',
'__index__',
'__init__',
'__init_subclass__',
'__int__',
'__invert__',
'__le__',
'__lshift__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__neg__',
'__new__',
'__or__',
'__pos__',
'__pow__',
'__radd__',
'__rand__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rlshift__',
'__rmod__',
'__rmul__',
'__ror__',
'__round__',
'__rpow__',
'__rrshift__',
'__rshift__',
'__rsub__',
'__rtruediv__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'__trunc__',
'__xor__',
'bit_length',
'conjugate',
'denominator',
'from_bytes',
'imag',
'numerator',
'real',
'to_bytes',
]
bytearray_expected_methods = [
'__add__',
'__alloc__',
'__class__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__iadd__',
'__imul__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'append',
'capitalize',
'center',
'clear',
'copy',
'count',
'decode',
'endswith',
'expandtabs',
'extend',
'find',
'fromhex',
'hex',
'index',
'insert',
'isalnum',
'isalpha',
'isascii',
'isdigit',
'islower',
'isspace',
'istitle',
'isupper',
'join',
'ljust',
'lower',
'lstrip',
'maketrans',
'partition',
'pop',
'remove',
'replace',
'reverse',
'rfind',
'rindex',
'rjust',
'rpartition',
'rsplit',
'rstrip',
'split',
'splitlines',
'startswith',
'strip',
'swapcase',
'title',
'translate',
'upper',
'zfill',
]
bytes_expected_methods = [
'__add__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'capitalize',
'center',
'count',
'decode',
'endswith',
'expandtabs',
'find',
'fromhex',
'hex',
'index',
'isalnum',
'isalpha',
'isascii',
'isdigit',
'islower',
'isspace',
'istitle',
'isupper',
'join',
'ljust',
'lower',
'lstrip',
'maketrans',
'partition',
'replace',
'rfind',
'rindex',
'rjust',
'rpartition',
'rsplit',
'rstrip',
'split',
'splitlines',
'startswith',
'strip',
'swapcase',
'title',
'translate',
'upper',
'zfill',
]
complex_expected_methods = [
'__abs__',
'__add__',
'__bool__',
'__class__',
'__delattr__',
'__dir__',
'__divmod__',
'__doc__',
'__eq__',
'__float__',
'__floordiv__',
'__format__',
'__ge__',
'__getattribute__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__int__',
'__le__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__neg__',
'__new__',
'__pos__',
'__pow__',
'__radd__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rmod__',
'__rmul__',
'__rpow__',
'__rsub__',
'__rtruediv__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'conjugate',
'imag',
'real',
]
dict_expected_methods = [
'__class__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'clear',
'copy',
'fromkeys',
'get',
'items',
'keys',
'pop',
'popitem',
'setdefault',
'update',
'values',
]
float_expected_methods = [
'__abs__',
'__add__',
'__bool__',
'__class__',
'__delattr__',
'__dir__',
'__divmod__',
'__doc__',
'__eq__',
'__float__',
'__floordiv__',
'__format__',
'__ge__',
'__getattribute__',
'__getformat__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__int__',
'__le__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__neg__',
'__new__',
'__pos__',
'__pow__',
'__radd__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rmod__',
'__rmul__',
'__round__',
'__rpow__',
'__rsub__',
'__rtruediv__',
'__set_format__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'__trunc__',
'as_integer_ratio',
'conjugate',
'fromhex',
'hex',
'imag',
'is_integer',
'real',
]
frozenset_expected_methods = [
'__and__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__or__',
'__rand__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__ror__',
'__rsub__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__xor__',
'copy',
'difference',
'intersection',
'isdisjoint',
'issubset',
'issuperset',
'symmetric_difference',
'union',
]
int_expected_methods = [
'__abs__',
'__add__',
'__and__',
'__bool__',
'__ceil__',
'__class__',
'__delattr__',
'__dir__',
'__divmod__',
'__doc__',
'__eq__',
'__float__',
'__floor__',
'__floordiv__',
'__format__',
'__ge__',
'__getattribute__',
'__getnewargs__',
'__gt__',
'__hash__',
'__index__',
'__init__',
'__init_subclass__',
'__int__',
'__invert__',
'__le__',
'__lshift__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__neg__',
'__new__',
'__or__',
'__pos__',
'__pow__',
'__radd__',
'__rand__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rlshift__',
'__rmod__',
'__rmul__',
'__ror__',
'__round__',
'__rpow__',
'__rrshift__',
'__rshift__',
'__rsub__',
'__rtruediv__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'__trunc__',
'__xor__',
'bit_length',
'conjugate',
'denominator',
'from_bytes',
'imag',
'numerator',
'real',
'to_bytes',
]
iter_expected_methods = [
'__class__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__length_hint__',
'__lt__',
'__ne__',
'__new__',
'__next__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setstate__',
'__sizeof__',
'__str__',
'__subclasshook__',
]
list_expected_methods = [
'__add__',
'__class__',
'__contains__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__iadd__',
'__imul__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__rmul__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'append',
'clear',
'copy',
'count',
'extend',
'index',
'insert',
'pop',
'remove',
'reverse',
'sort',
]
memoryview_expected_methods = [
'__class__',
'__delattr__',
'__delitem__',
'__dir__',
'__doc__',
'__enter__',
'__eq__',
'__exit__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'c_contiguous',
'cast',
'contiguous',
'f_contiguous',
'format',
'hex',
'itemsize',
'nbytes',
'ndim',
'obj',
'readonly',
'release',
'shape',
'strides',
'suboffsets',
'tobytes',
'tolist',
]
range_expected_methods = [
'__bool__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__reversed__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'count',
'index',
'start',
'step',
'stop',
]
set_expected_methods = [
'__and__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__iand__',
'__init__',
'__init_subclass__',
'__ior__',
'__isub__',
'__iter__',
'__ixor__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__or__',
'__rand__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__ror__',
'__rsub__',
'__rxor__',
'__setattr__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__xor__',
'add',
'clear',
'copy',
'difference',
'difference_update',
'discard',
'intersection',
'intersection_update',
'isdisjoint',
'issubset',
'issuperset',
'pop',
'remove',
'symmetric_difference',
'symmetric_difference_update',
'union',
'update',
]
string_expected_methods = [
'__add__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'capitalize',
'casefold',
'center',
'count',
'encode',
'endswith',
'expandtabs',
'find',
'format',
'format_map',
'index',
'isalnum',
'isalpha',
'isascii',
'isdecimal',
'isdigit',
'isidentifier',
'islower',
'isnumeric',
'isprintable',
'isspace',
'istitle',
'isupper',
'join',
'ljust',
'lower',
'lstrip',
'maketrans',
'partition',
'replace',
'rfind',
'rindex',
'rjust',
'rpartition',
'rsplit',
'rstrip',
'split',
'splitlines',
'startswith',
'strip',
'swapcase',
'title',
'translate',
'upper',
'zfill'
]
tuple_expected_methods = [
'__add__',
'__class__',
'__contains__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'count',
'index',
]
object_expected_methods = [
'__repr__',
'__hash__',
'__str__',
'__getattribute__',
'__setattr__',
'__delattr__',
'__lt__',
'__le__',
'__eq__',
'__ne__',
'__gt__',
'__ge__',
'__init__',
'__new__',
'__reduce_ex__',
'__reduce__',
'__subclasshook__',
'__init_subclass__',
'__format__',
'__sizeof__',
'__dir__',
'__class__',
'__doc__'
]
not_implemented = []
for method in bool_expected_methods:
try:
if not hasattr(bool, method):
not_implemented.append(("bool", method))
except NameError:
not_implemented.append(("bool", method))
for method in bytearray_expected_methods:
try:
if not hasattr(bytearray(), method):
not_implemented.append(("bytearray", method))
except NameError:
not_implemented.append(("bytearray", method))
for method in bytes_expected_methods:
try:
if not hasattr(bytes, method):
not_implemented.append(("bytes", method))
except NameError:
not_implemented.append(("bytes", method))
for method in complex_expected_methods:
try:
if not hasattr(complex, method):
not_implemented.append(("complex", method))
except NameError:
not_implemented.append(("complex", method))
for method in dict_expected_methods:
try:
if not hasattr(dict, method):
not_implemented.append(("dict", method))
except NameError:
not_implemented.append(("dict", method))
for method in float_expected_methods:
try:
if not hasattr(float, method):
not_implemented.append(("float", method))
except NameError:
not_implemented.append(("float", method))
for method in frozenset_expected_methods:
# TODO: uncomment this when frozenset is implemented
# try:
# if not hasattr(frozenset, method):
# not_implemented.append(("frozenset", method))
# except NameError:
not_implemented.append(("frozenset", method))
for method in int_expected_methods:
try:
if not hasattr(int, method):
not_implemented.append(("int", method))
except NameError:
not_implemented.append(("int", method))
for method in iter_expected_methods:
try:
if not hasattr(iter([]), method):
not_implemented.append(("iter", method))
except NameError:
not_implemented.append(("iter", method))
for method in list_expected_methods:
try:
if not hasattr(list, method):
not_implemented.append(("list", method))
except NameError:
not_implemented.append(("list", method))
for method in memoryview_expected_methods:
# TODO: uncomment this when memoryview is implemented
# try:
# if not hasattr(memoryview, method):
# not_implemented.append(("memoryview", method))
# except NameError:
not_implemented.append(("memoryview", method))
for method in range_expected_methods:
try:
if not hasattr(range, method):
not_implemented.append(("range", method))
except NameError:
not_implemented.append(("range", method))
for method in set_expected_methods:
try:
if not hasattr(set, method):
not_implemented.append(("set", method))
except NameError:
not_implemented.append(("set", method))
for method in string_expected_methods:
try:
if not hasattr(str, method):
not_implemented.append(("string", method))
except NameError:
not_implemented.append(("string", method))
for method in tuple_expected_methods:
try:
if not hasattr(tuple, method):
not_implemented.append(("tuple", method))
except NameError:
not_implemented.append(("tuple", method))
for method in object_expected_methods:
try:
if not hasattr(bool, method):
not_implemented.append(("object", method))
except NameError:
not_implemented.append(("object", method))
for r in not_implemented:
print(r[0], ".", r[1])
else:
print("Not much \\o/")
|
#the program calculates the average of numbers whose input is in the form of a string
def average():
numbers = str(input("Enter a string of numbers: "))
numbers = numbers.split()
numbers2 = []
total = 0
for number in numbers:
number = int(number)
total += number
numbers2.append(number)
avg = total // len(numbers2)
print(avg)
average()
|
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
num_dict = {}
for i, num in enumerate(nums):
n = target - num
if n not in num_dict:
num_dict[num] = i
else:
return [num_dict[n], i]
|
def pick_arr(arr, b):
nums = arr[:b]
idxsum = sum(nums)
maxsum = idxsum
for i in range(b):
remove = nums.pop()
add = arr.pop()
idxsum = idxsum - remove + add
maxsum = max(maxsum, idxsum)
return maxsum
print(pick_arr([5,-2,3,1,2], 3))
|
#!/usr/bin/env python
# encoding: utf-8
class HashInterface(object):
@staticmethod
def hash(*arg):
pass
|
class Solution:
def solve(self, nums):
ans = [-1]*len(nums)
unmatched = []
for i in range(len(nums)):
while unmatched and unmatched[0][0] < nums[i]:
ans[heappop(unmatched)[1]] = nums[i]
heappush(unmatched, [nums[i], i])
for i in range(len(nums)):
while unmatched and unmatched[0][0] < nums[i]:
ans[heappop(unmatched)[1]] = nums[i]
return ans
|
# This is a sample Python script.
# Press shift+⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
'''
multi comment
'''
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
print(5 + 87965789097654895857)
print(4.234234)
print(complex(5431242341234123, 23412341234123412))
f_boolean = False
t_boolean = True
print(f_boolean, t_boolean)
multi_line_string = '''kek
wait
big
string'''
print(multi_line_string)
print(len(multi_line_string))
some_str = "some string"
print(some_str[-1]) # prints g
print(some_str[-11]) # prints can only go over the length but can't cycle back
other_str = "0123456789"
print("3 to 6: " + other_str[3:7]) # will print 3456 because index 7 is NOT included
print("all: " + other_str[0:len(other_str)]) # will print everything
print("step2: " + other_str[0:len(other_str):2]) # print every other number starting from 0
print("other: " + other_str[::-1]) # print other way around
print("before 5: " + other_str[:5]) # 01234
print("after 5: " + other_str[5:]) # 56789
print(5 ** 2) # 5^2 == 25
print(5 / 2) # 2.5
print(5 // 2) # 2
print(5 % 4) # 1 (modulo)
list1 = [1,2,3]
list2 = [1,2,3]
print(list1 is list2) # identity
print(list1 == list2) # equal to
print(True and False, True or False, False or True, not True, not False) # false, true, true, false, true
print(10 * True, 10 * False) # true = 1, false == 0
print("Hello, world!!!", 1, 3, 4, {5, 5, 5}, end="", sep=" ;*; ")
print()
num2 = 20 # Binary Value = 10100
print(~num2, num2 ^ num2, num2 << 2, num2 >> 2)
print("kekw " * 3)
print("Hello" in "Hello, Worlds")
print([1, "qwer", 12.2, 'v'])
# print all methods of str
print(dir(str))
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
'''
Created on Aug 30, 2012
@author: philipkershaw
'''
|
SETTINGS = {
'gee': {
'service_account': None,
'privatekey_file': None,
}
}
|
grid = [
[0,0,0,0,7,0,0,8,4],
[0,0,0,8,0,0,9,7,0],
[0,1,0,0,0,0,2,0,0],
[0,0,3,0,0,0,8,9,0],
[8,2,0,4,9,0,0,3,6],
[9,0,0,0,0,8,0,0,0],
[0,7,0,0,0,0,0,0,0],
[0,0,4,0,0,0,0,6,0],
[1,0,6,0,0,7,3,0,2],
]
def print_matriz():
for y in range(0,9):
for x in range(0,9):
if x in [2,5]:
print(f'{grid[y][x]} ',end='')
print('|', end='')
else:
print(f'{grid[y][x]} ',end='')
print('')
if y in [2,5]:
print('------|'*2,end='')
print('------')
print()
#passos para ver se certo numero é possivel em certo espaço
def possible(x,y,n):
global grid
for i in range(0,9): #varrer a linha a busca de n
if grid[y][i] == n:
return False
for j in range(0,9): #varrer a coluna a busca de n
if grid[j][x] == n:
return False
x0 = (x//3)*3
y0 = (y//3)*3
for i in range(0,3):
for j in range(0,3):
if grid[y0+i][x0+j] == n:
return False
return True
#resolver o sudoku inteiro
def solve():
for y in range(0,9):
for x in range(0,9):
if grid[y][x] == 0:
for n in range(1,10):
if possible(x,y,n):
grid[y][x] = n
solve()
grid[y][x] = 0
return
print_matriz()
#Programa principal
print_matriz()
solve()
|
def fibonacci(n):
"""
Def: In mathematics, the Fibonacci numbers are the numbers in the following
integer sequence, called the Fibonacci sequence, and characterized by the
fact that every number after the first two is the sum of the two preceding
ones: `0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...`
"""
fibonacci_sequence = [0, 1]
for i in range(0, n, 1):
next = fibonacci_sequence[i] + fibonacci_sequence[i + 1]
fibonacci_sequence.append(next)
return fibonacci_sequence[:-2]
|
# Fried Chicken Damage Skin
success = sm.addDamageSkin(2435960)
if success:
sm.chat("The Fried Chicken Damage Skin has been added to your account's damage skin collection.")
# sm.consumeItem(2435960)
|
# -*- coding: utf-8 -*-
# Tests for the different contrib/localflavor/ form fields.
localflavor_tests = r"""
# USZipCodeField ##############################################################
USZipCodeField validates that the data is either a five-digit U.S. zip code or
a zip+4.
>>> from django.contrib.localflavor.us.forms import USZipCodeField
>>> f = USZipCodeField()
>>> f.clean('60606')
u'60606'
>>> f.clean(60606)
u'60606'
>>> f.clean('04000')
u'04000'
>>> f.clean('4000')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean('60606-1234')
u'60606-1234'
>>> f.clean('6060-1234')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean('60606-')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = USZipCodeField(required=False)
>>> f.clean('60606')
u'60606'
>>> f.clean(60606)
u'60606'
>>> f.clean('04000')
u'04000'
>>> f.clean('4000')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean('60606-1234')
u'60606-1234'
>>> f.clean('6060-1234')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean('60606-')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# USPhoneNumberField ##########################################################
USPhoneNumberField validates that the data is a valid U.S. phone number,
including the area code. It's normalized to XXX-XXX-XXXX format.
>>> from django.contrib.localflavor.us.forms import USPhoneNumberField
>>> f = USPhoneNumberField()
>>> f.clean('312-555-1212')
u'312-555-1212'
>>> f.clean('3125551212')
u'312-555-1212'
>>> f.clean('312 555-1212')
u'312-555-1212'
>>> f.clean('(312) 555-1212')
u'312-555-1212'
>>> f.clean('312 555 1212')
u'312-555-1212'
>>> f.clean('312.555.1212')
u'312-555-1212'
>>> f.clean('312.555-1212')
u'312-555-1212'
>>> f.clean(' (312) 555.1212 ')
u'312-555-1212'
>>> f.clean('555-1212')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in XXX-XXX-XXXX format.']
>>> f.clean('312-55-1212')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in XXX-XXX-XXXX format.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = USPhoneNumberField(required=False)
>>> f.clean('312-555-1212')
u'312-555-1212'
>>> f.clean('3125551212')
u'312-555-1212'
>>> f.clean('312 555-1212')
u'312-555-1212'
>>> f.clean('(312) 555-1212')
u'312-555-1212'
>>> f.clean('312 555 1212')
u'312-555-1212'
>>> f.clean('312.555.1212')
u'312-555-1212'
>>> f.clean('312.555-1212')
u'312-555-1212'
>>> f.clean(' (312) 555.1212 ')
u'312-555-1212'
>>> f.clean('555-1212')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in XXX-XXX-XXXX format.']
>>> f.clean('312-55-1212')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in XXX-XXX-XXXX format.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# USStateField ################################################################
USStateField validates that the data is either an abbreviation or name of a
U.S. state.
>>> from django.contrib.localflavor.us.forms import USStateField
>>> f = USStateField()
>>> f.clean('il')
u'IL'
>>> f.clean('IL')
u'IL'
>>> f.clean('illinois')
u'IL'
>>> f.clean(' illinois ')
u'IL'
>>> f.clean(60606)
Traceback (most recent call last):
...
ValidationError: [u'Enter a U.S. state or territory.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = USStateField(required=False)
>>> f.clean('il')
u'IL'
>>> f.clean('IL')
u'IL'
>>> f.clean('illinois')
u'IL'
>>> f.clean(' illinois ')
u'IL'
>>> f.clean(60606)
Traceback (most recent call last):
...
ValidationError: [u'Enter a U.S. state or territory.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# USStateSelect ###############################################################
USStateSelect is a Select widget that uses a list of U.S. states/territories
as its choices.
>>> from django.contrib.localflavor.us.forms import USStateSelect
>>> w = USStateSelect()
>>> print w.render('state', 'IL')
<select name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AS">American Samoa</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
<option value="FM">Federated States of Micronesia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="GU">Guam</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL" selected="selected">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MH">Marshall Islands</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="MP">Northern Mariana Islands</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PW">Palau</option>
<option value="PA">Pennsylvania</option>
<option value="PR">Puerto Rico</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VI">Virgin Islands</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
# USSocialSecurityNumberField #################################################
>>> from django.contrib.localflavor.us.forms import USSocialSecurityNumberField
>>> f = USSocialSecurityNumberField()
>>> f.clean('987-65-4330')
u'987-65-4330'
>>> f.clean('987654330')
u'987-65-4330'
>>> f.clean('078-05-1120')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.']
# UKPostcodeField #############################################################
UKPostcodeField validates that the data is a valid UK postcode.
>>> from django.contrib.localflavor.uk.forms import UKPostcodeField
>>> f = UKPostcodeField()
>>> f.clean('BT32 4PX')
u'BT32 4PX'
>>> f.clean('GIR 0AA')
u'GIR 0AA'
>>> f.clean('BT324PX')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
>>> f.clean('1NV 4L1D')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = UKPostcodeField(required=False)
>>> f.clean('BT32 4PX')
u'BT32 4PX'
>>> f.clean('GIR 0AA')
u'GIR 0AA'
>>> f.clean('1NV 4L1D')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
>>> f.clean('BT324PX')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postcode. A space is required between the two postcode parts.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# FRZipCodeField #############################################################
FRZipCodeField validates that the data is a valid FR zipcode.
>>> from django.contrib.localflavor.fr.forms import FRZipCodeField
>>> f = FRZipCodeField()
>>> f.clean('75001')
u'75001'
>>> f.clean('93200')
u'93200'
>>> f.clean('2A200')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean('980001')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = FRZipCodeField(required=False)
>>> f.clean('75001')
u'75001'
>>> f.clean('93200')
u'93200'
>>> f.clean('2A200')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean('980001')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# FRPhoneNumberField ##########################################################
FRPhoneNumberField validates that the data is a valid french phone number.
It's normalized to 0X XX XX XX XX format. Dots are valid too.
>>> from django.contrib.localflavor.fr.forms import FRPhoneNumberField
>>> f = FRPhoneNumberField()
>>> f.clean('01 55 44 58 64')
u'01 55 44 58 64'
>>> f.clean('0155445864')
u'01 55 44 58 64'
>>> f.clean('01 5544 5864')
u'01 55 44 58 64'
>>> f.clean('01 55.44.58.64')
u'01 55 44 58 64'
>>> f.clean('01.55.44.58.64')
u'01 55 44 58 64'
>>> f.clean('01,55,44,58,64')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.']
>>> f.clean('555 015 544')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = FRPhoneNumberField(required=False)
>>> f.clean('01 55 44 58 64')
u'01 55 44 58 64'
>>> f.clean('0155445864')
u'01 55 44 58 64'
>>> f.clean('01 5544 5864')
u'01 55 44 58 64'
>>> f.clean('01 55.44.58.64')
u'01 55 44 58 64'
>>> f.clean('01.55.44.58.64')
u'01 55 44 58 64'
>>> f.clean('01,55,44,58,64')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.']
>>> f.clean('555 015 544')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# FRDepartmentSelect ###############################################################
FRDepartmentSelect is a Select widget that uses a list of french departments
including DOM TOM
>>> from django.contrib.localflavor.fr.forms import FRDepartmentSelect
>>> w = FRDepartmentSelect()
>>> print w.render('dep', 'Paris')
<select name="dep">
<option value="01">01 - Ain</option>
<option value="02">02 - Aisne</option>
<option value="03">03 - Allier</option>
<option value="04">04 - Alpes-de-Haute-Provence</option>
<option value="05">05 - Hautes-Alpes</option>
<option value="06">06 - Alpes-Maritimes</option>
<option value="07">07 - Ardeche</option>
<option value="08">08 - Ardennes</option>
<option value="09">09 - Ariege</option>
<option value="10">10 - Aube</option>
<option value="11">11 - Aude</option>
<option value="12">12 - Aveyron</option>
<option value="13">13 - Bouches-du-Rhone</option>
<option value="14">14 - Calvados</option>
<option value="15">15 - Cantal</option>
<option value="16">16 - Charente</option>
<option value="17">17 - Charente-Maritime</option>
<option value="18">18 - Cher</option>
<option value="19">19 - Correze</option>
<option value="21">21 - Cote-d'Or</option>
<option value="22">22 - Cotes-d'Armor</option>
<option value="23">23 - Creuse</option>
<option value="24">24 - Dordogne</option>
<option value="25">25 - Doubs</option>
<option value="26">26 - Drome</option>
<option value="27">27 - Eure</option>
<option value="28">28 - Eure-et-Loire</option>
<option value="29">29 - Finistere</option>
<option value="2A">2A - Corse-du-Sud</option>
<option value="2B">2B - Haute-Corse</option>
<option value="30">30 - Gard</option>
<option value="31">31 - Haute-Garonne</option>
<option value="32">32 - Gers</option>
<option value="33">33 - Gironde</option>
<option value="34">34 - Herault</option>
<option value="35">35 - Ille-et-Vilaine</option>
<option value="36">36 - Indre</option>
<option value="37">37 - Indre-et-Loire</option>
<option value="38">38 - Isere</option>
<option value="39">39 - Jura</option>
<option value="40">40 - Landes</option>
<option value="41">41 - Loir-et-Cher</option>
<option value="42">42 - Loire</option>
<option value="43">43 - Haute-Loire</option>
<option value="44">44 - Loire-Atlantique</option>
<option value="45">45 - Loiret</option>
<option value="46">46 - Lot</option>
<option value="47">47 - Lot-et-Garonne</option>
<option value="48">48 - Lozere</option>
<option value="49">49 - Maine-et-Loire</option>
<option value="50">50 - Manche</option>
<option value="51">51 - Marne</option>
<option value="52">52 - Haute-Marne</option>
<option value="53">53 - Mayenne</option>
<option value="54">54 - Meurthe-et-Moselle</option>
<option value="55">55 - Meuse</option>
<option value="56">56 - Morbihan</option>
<option value="57">57 - Moselle</option>
<option value="58">58 - Nievre</option>
<option value="59">59 - Nord</option>
<option value="60">60 - Oise</option>
<option value="61">61 - Orne</option>
<option value="62">62 - Pas-de-Calais</option>
<option value="63">63 - Puy-de-Dome</option>
<option value="64">64 - Pyrenees-Atlantiques</option>
<option value="65">65 - Hautes-Pyrenees</option>
<option value="66">66 - Pyrenees-Orientales</option>
<option value="67">67 - Bas-Rhin</option>
<option value="68">68 - Haut-Rhin</option>
<option value="69">69 - Rhone</option>
<option value="70">70 - Haute-Saone</option>
<option value="71">71 - Saone-et-Loire</option>
<option value="72">72 - Sarthe</option>
<option value="73">73 - Savoie</option>
<option value="74">74 - Haute-Savoie</option>
<option value="75">75 - Paris</option>
<option value="76">76 - Seine-Maritime</option>
<option value="77">77 - Seine-et-Marne</option>
<option value="78">78 - Yvelines</option>
<option value="79">79 - Deux-Sevres</option>
<option value="80">80 - Somme</option>
<option value="81">81 - Tarn</option>
<option value="82">82 - Tarn-et-Garonne</option>
<option value="83">83 - Var</option>
<option value="84">84 - Vaucluse</option>
<option value="85">85 - Vendee</option>
<option value="86">86 - Vienne</option>
<option value="87">87 - Haute-Vienne</option>
<option value="88">88 - Vosges</option>
<option value="89">89 - Yonne</option>
<option value="90">90 - Territoire de Belfort</option>
<option value="91">91 - Essonne</option>
<option value="92">92 - Hauts-de-Seine</option>
<option value="93">93 - Seine-Saint-Denis</option>
<option value="94">94 - Val-de-Marne</option>
<option value="95">95 - Val-d'Oise</option>
<option value="2A">2A - Corse du sud</option>
<option value="2B">2B - Haute Corse</option>
<option value="971">971 - Guadeloupe</option>
<option value="972">972 - Martinique</option>
<option value="973">973 - Guyane</option>
<option value="974">974 - La Reunion</option>
<option value="975">975 - Saint-Pierre-et-Miquelon</option>
<option value="976">976 - Mayotte</option>
<option value="984">984 - Terres Australes et Antarctiques</option>
<option value="986">986 - Wallis et Futuna</option>
<option value="987">987 - Polynesie Francaise</option>
<option value="988">988 - Nouvelle-Caledonie</option>
</select>
# JPPostalCodeField ###############################################################
A form field that validates its input is a Japanese postcode.
Accepts 7 digits(with/out hyphen).
>>> from django.contrib.localflavor.jp.forms import JPPostalCodeField
>>> f = JPPostalCodeField()
>>> f.clean('251-0032')
u'2510032'
>>> f.clean('2510032')
u'2510032'
>>> f.clean('2510-032')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
>>> f.clean('251a0032')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
>>> f.clean('a51-0032')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
>>> f.clean('25100321')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = JPPostalCodeField(required=False)
>>> f.clean('251-0032')
u'2510032'
>>> f.clean('2510032')
u'2510032'
>>> f.clean('2510-032')
Traceback (most recent call last):
...
ValidationError: [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
>>> f.clean('')
u''
>>> f.clean(None)
u''
# JPPrefectureSelect ###############################################################
A Select widget that uses a list of Japanese prefectures as its choices.
>>> from django.contrib.localflavor.jp.forms import JPPrefectureSelect
>>> w = JPPrefectureSelect()
>>> print w.render('prefecture', 'kanagawa')
<select name="prefecture">
<option value="hokkaido">Hokkaido</option>
<option value="aomori">Aomori</option>
<option value="iwate">Iwate</option>
<option value="miyagi">Miyagi</option>
<option value="akita">Akita</option>
<option value="yamagata">Yamagata</option>
<option value="fukushima">Fukushima</option>
<option value="ibaraki">Ibaraki</option>
<option value="tochigi">Tochigi</option>
<option value="gunma">Gunma</option>
<option value="saitama">Saitama</option>
<option value="chiba">Chiba</option>
<option value="tokyo">Tokyo</option>
<option value="kanagawa" selected="selected">Kanagawa</option>
<option value="yamanashi">Yamanashi</option>
<option value="nagano">Nagano</option>
<option value="niigata">Niigata</option>
<option value="toyama">Toyama</option>
<option value="ishikawa">Ishikawa</option>
<option value="fukui">Fukui</option>
<option value="gifu">Gifu</option>
<option value="shizuoka">Shizuoka</option>
<option value="aichi">Aichi</option>
<option value="mie">Mie</option>
<option value="shiga">Shiga</option>
<option value="kyoto">Kyoto</option>
<option value="osaka">Osaka</option>
<option value="hyogo">Hyogo</option>
<option value="nara">Nara</option>
<option value="wakayama">Wakayama</option>
<option value="tottori">Tottori</option>
<option value="shimane">Shimane</option>
<option value="okayama">Okayama</option>
<option value="hiroshima">Hiroshima</option>
<option value="yamaguchi">Yamaguchi</option>
<option value="tokushima">Tokushima</option>
<option value="kagawa">Kagawa</option>
<option value="ehime">Ehime</option>
<option value="kochi">Kochi</option>
<option value="fukuoka">Fukuoka</option>
<option value="saga">Saga</option>
<option value="nagasaki">Nagasaki</option>
<option value="kumamoto">Kumamoto</option>
<option value="oita">Oita</option>
<option value="miyazaki">Miyazaki</option>
<option value="kagoshima">Kagoshima</option>
<option value="okinawa">Okinawa</option>
</select>
# ITZipCodeField #############################################################
>>> from django.contrib.localflavor.it.forms import ITZipCodeField
>>> f = ITZipCodeField()
>>> f.clean('00100')
u'00100'
>>> f.clean(' 00100')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid zip code.']
# ITRegionSelect #############################################################
>>> from django.contrib.localflavor.it.forms import ITRegionSelect
>>> w = ITRegionSelect()
>>> w.render('regions', 'PMN')
u'<select name="regions">\n<option value="ABR">Abruzzo</option>\n<option value="BAS">Basilicata</option>\n<option value="CAL">Calabria</option>\n<option value="CAM">Campania</option>\n<option value="EMR">Emilia-Romagna</option>\n<option value="FVG">Friuli-Venezia Giulia</option>\n<option value="LAZ">Lazio</option>\n<option value="LIG">Liguria</option>\n<option value="LOM">Lombardia</option>\n<option value="MAR">Marche</option>\n<option value="MOL">Molise</option>\n<option value="PMN" selected="selected">Piemonte</option>\n<option value="PUG">Puglia</option>\n<option value="SAR">Sardegna</option>\n<option value="SIC">Sicilia</option>\n<option value="TOS">Toscana</option>\n<option value="TAA">Trentino-Alto Adige</option>\n<option value="UMB">Umbria</option>\n<option value="VAO">Valle d\u2019Aosta</option>\n<option value="VEN">Veneto</option>\n</select>'
# ITSocialSecurityNumberField #################################################
>>> from django.contrib.localflavor.it.forms import ITSocialSecurityNumberField
>>> f = ITSocialSecurityNumberField()
>>> f.clean('LVSGDU99T71H501L')
u'LVSGDU99T71H501L'
>>> f.clean('LBRRME11A01L736W')
u'LBRRME11A01L736W'
>>> f.clean('lbrrme11a01l736w')
u'LBRRME11A01L736W'
>>> f.clean('LBR RME 11A01 L736W')
u'LBRRME11A01L736W'
>>> f.clean('LBRRME11A01L736A')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Social Security number.']
>>> f.clean('%BRRME11A01L736W')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Social Security number.']
# ITVatNumberField ###########################################################
>>> from django.contrib.localflavor.it.forms import ITVatNumberField
>>> f = ITVatNumberField()
>>> f.clean('07973780013')
u'07973780013'
>>> f.clean('7973780013')
u'07973780013'
>>> f.clean(7973780013)
u'07973780013'
>>> f.clean('07973780014')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid VAT number.']
>>> f.clean('A7973780013')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid VAT number.']
# FIZipCodeField #############################################################
FIZipCodeField validates that the data is a valid FI zipcode.
>>> from django.contrib.localflavor.fi.forms import FIZipCodeField
>>> f = FIZipCodeField()
>>> f.clean('20540')
u'20540'
>>> f.clean('20101')
u'20101'
>>> f.clean('20s40')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean('205401')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = FIZipCodeField(required=False)
>>> f.clean('20540')
u'20540'
>>> f.clean('20101')
u'20101'
>>> f.clean('20s40')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean('205401')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
# FIMunicipalitySelect ###############################################################
A Select widget that uses a list of Finnish municipalities as its choices.
>>> from django.contrib.localflavor.fi.forms import FIMunicipalitySelect
>>> w = FIMunicipalitySelect()
>>> unicode(w.render('municipalities', 'turku'))
u'<select name="municipalities">\n<option value="akaa">Akaa</option>\n<option value="alaharma">Alah\xe4rm\xe4</option>\n<option value="alajarvi">Alaj\xe4rvi</option>\n<option value="alastaro">Alastaro</option>\n<option value="alavieska">Alavieska</option>\n<option value="alavus">Alavus</option>\n<option value="anjalankoski">Anjalankoski</option>\n<option value="artjarvi">Artj\xe4rvi</option>\n<option value="asikkala">Asikkala</option>\n<option value="askainen">Askainen</option>\n<option value="askola">Askola</option>\n<option value="aura">Aura</option>\n<option value="brando">Br\xe4nd\xf6</option>\n<option value="dragsfjard">Dragsfj\xe4rd</option>\n<option value="eckero">Ecker\xf6</option>\n<option value="elimaki">Elim\xe4ki</option>\n<option value="eno">Eno</option>\n<option value="enonkoski">Enonkoski</option>\n<option value="enontekio">Enonteki\xf6</option>\n<option value="espoo">Espoo</option>\n<option value="eura">Eura</option>\n<option value="eurajoki">Eurajoki</option>\n<option value="evijarvi">Evij\xe4rvi</option>\n<option value="finstrom">Finstr\xf6m</option>\n<option value="forssa">Forssa</option>\n<option value="foglo">F\xf6gl\xf6</option>\n<option value="geta">Geta</option>\n<option value="haapajarvi">Haapaj\xe4rvi</option>\n<option value="haapavesi">Haapavesi</option>\n<option value="hailuoto">Hailuoto</option>\n<option value="halikko">Halikko</option>\n<option value="halsua">Halsua</option>\n<option value="hamina">Hamina</option>\n<option value="hammarland">Hammarland</option>\n<option value="hankasalmi">Hankasalmi</option>\n<option value="hanko">Hanko</option>\n<option value="harjavalta">Harjavalta</option>\n<option value="hartola">Hartola</option>\n<option value="hattula">Hattula</option>\n<option value="hauho">Hauho</option>\n<option value="haukipudas">Haukipudas</option>\n<option value="hausjarvi">Hausj\xe4rvi</option>\n<option value="heinola">Heinola</option>\n<option value="heinavesi">Hein\xe4vesi</option>\n<option value="helsinki">Helsinki</option>\n<option value="himanka">Himanka</option>\n<option value="hirvensalmi">Hirvensalmi</option>\n<option value="hollola">Hollola</option>\n<option value="honkajoki">Honkajoki</option>\n<option value="houtskari">Houtskari</option>\n<option value="huittinen">Huittinen</option>\n<option value="humppila">Humppila</option>\n<option value="hyrynsalmi">Hyrynsalmi</option>\n<option value="hyvinkaa">Hyvink\xe4\xe4</option>\n<option value="hameenkoski">H\xe4meenkoski</option>\n<option value="hameenkyro">H\xe4meenkyr\xf6</option>\n<option value="hameenlinna">H\xe4meenlinna</option>\n<option value="ii">Ii</option>\n<option value="iisalmi">Iisalmi</option>\n<option value="iitti">Iitti</option>\n<option value="ikaalinen">Ikaalinen</option>\n<option value="ilmajoki">Ilmajoki</option>\n<option value="ilomantsi">Ilomantsi</option>\n<option value="imatra">Imatra</option>\n<option value="inari">Inari</option>\n<option value="inio">Ini\xf6</option>\n<option value="inkoo">Inkoo</option>\n<option value="isojoki">Isojoki</option>\n<option value="isokyro">Isokyr\xf6</option>\n<option value="jaala">Jaala</option>\n<option value="jalasjarvi">Jalasj\xe4rvi</option>\n<option value="janakkala">Janakkala</option>\n<option value="joensuu">Joensuu</option>\n<option value="jokioinen">Jokioinen</option>\n<option value="jomala">Jomala</option>\n<option value="joroinen">Joroinen</option>\n<option value="joutsa">Joutsa</option>\n<option value="joutseno">Joutseno</option>\n<option value="juankoski">Juankoski</option>\n<option value="jurva">Jurva</option>\n<option value="juuka">Juuka</option>\n<option value="juupajoki">Juupajoki</option>\n<option value="juva">Juva</option>\n<option value="jyvaskyla">Jyv\xe4skyl\xe4</option>\n<option value="jyvaskylan_mlk">Jyv\xe4skyl\xe4n maalaiskunta</option>\n<option value="jamijarvi">J\xe4mij\xe4rvi</option>\n<option value="jamsa">J\xe4ms\xe4</option>\n<option value="jamsankoski">J\xe4ms\xe4nkoski</option>\n<option value="jarvenpaa">J\xe4rvenp\xe4\xe4</option>\n<option value="kaarina">Kaarina</option>\n<option value="kaavi">Kaavi</option>\n<option value="kajaani">Kajaani</option>\n<option value="kalajoki">Kalajoki</option>\n<option value="kalvola">Kalvola</option>\n<option value="kangasala">Kangasala</option>\n<option value="kangasniemi">Kangasniemi</option>\n<option value="kankaanpaa">Kankaanp\xe4\xe4</option>\n<option value="kannonkoski">Kannonkoski</option>\n<option value="kannus">Kannus</option>\n<option value="karijoki">Karijoki</option>\n<option value="karjaa">Karjaa</option>\n<option value="karjalohja">Karjalohja</option>\n<option value="karkkila">Karkkila</option>\n<option value="karstula">Karstula</option>\n<option value="karttula">Karttula</option>\n<option value="karvia">Karvia</option>\n<option value="kaskinen">Kaskinen</option>\n<option value="kauhajoki">Kauhajoki</option>\n<option value="kauhava">Kauhava</option>\n<option value="kauniainen">Kauniainen</option>\n<option value="kaustinen">Kaustinen</option>\n<option value="keitele">Keitele</option>\n<option value="kemi">Kemi</option>\n<option value="kemijarvi">Kemij\xe4rvi</option>\n<option value="keminmaa">Keminmaa</option>\n<option value="kemio">Kemi\xf6</option>\n<option value="kempele">Kempele</option>\n<option value="kerava">Kerava</option>\n<option value="kerimaki">Kerim\xe4ki</option>\n<option value="kestila">Kestil\xe4</option>\n<option value="kesalahti">Kes\xe4lahti</option>\n<option value="keuruu">Keuruu</option>\n<option value="kihnio">Kihni\xf6</option>\n<option value="kiikala">Kiikala</option>\n<option value="kiikoinen">Kiikoinen</option>\n<option value="kiiminki">Kiiminki</option>\n<option value="kinnula">Kinnula</option>\n<option value="kirkkonummi">Kirkkonummi</option>\n<option value="kisko">Kisko</option>\n<option value="kitee">Kitee</option>\n<option value="kittila">Kittil\xe4</option>\n<option value="kiukainen">Kiukainen</option>\n<option value="kiuruvesi">Kiuruvesi</option>\n<option value="kivijarvi">Kivij\xe4rvi</option>\n<option value="kokemaki">Kokem\xe4ki</option>\n<option value="kokkola">Kokkola</option>\n<option value="kolari">Kolari</option>\n<option value="konnevesi">Konnevesi</option>\n<option value="kontiolahti">Kontiolahti</option>\n<option value="korpilahti">Korpilahti</option>\n<option value="korppoo">Korppoo</option>\n<option value="korsnas">Korsn\xe4s</option>\n<option value="kortesjarvi">Kortesj\xe4rvi</option>\n<option value="koskitl">KoskiTl</option>\n<option value="kotka">Kotka</option>\n<option value="kouvola">Kouvola</option>\n<option value="kristiinankaupunki">Kristiinankaupunki</option>\n<option value="kruunupyy">Kruunupyy</option>\n<option value="kuhmalahti">Kuhmalahti</option>\n<option value="kuhmo">Kuhmo</option>\n<option value="kuhmoinen">Kuhmoinen</option>\n<option value="kumlinge">Kumlinge</option>\n<option value="kuopio">Kuopio</option>\n<option value="kuortane">Kuortane</option>\n<option value="kurikka">Kurikka</option>\n<option value="kuru">Kuru</option>\n<option value="kustavi">Kustavi</option>\n<option value="kuusamo">Kuusamo</option>\n<option value="kuusankoski">Kuusankoski</option>\n<option value="kuusjoki">Kuusjoki</option>\n<option value="kylmakoski">Kylm\xe4koski</option>\n<option value="kyyjarvi">Kyyj\xe4rvi</option>\n<option value="kalvia">K\xe4lvi\xe4</option>\n<option value="karkola">K\xe4rk\xf6l\xe4</option>\n<option value="karsamaki">K\xe4rs\xe4m\xe4ki</option>\n<option value="kokar">K\xf6kar</option>\n<option value="koylio">K\xf6yli\xf6</option>\n<option value="lahti">Lahti</option>\n<option value="laihia">Laihia</option>\n<option value="laitila">Laitila</option>\n<option value="lammi">Lammi</option>\n<option value="lapinjarvi">Lapinj\xe4rvi</option>\n<option value="lapinlahti">Lapinlahti</option>\n<option value="lappajarvi">Lappaj\xe4rvi</option>\n<option value="lappeenranta">Lappeenranta</option>\n<option value="lappi">Lappi</option>\n<option value="lapua">Lapua</option>\n<option value="laukaa">Laukaa</option>\n<option value="lavia">Lavia</option>\n<option value="lehtimaki">Lehtim\xe4ki</option>\n<option value="leivonmaki">Leivonm\xe4ki</option>\n<option value="lemi">Lemi</option>\n<option value="lemland">Lemland</option>\n<option value="lempaala">Lemp\xe4\xe4l\xe4</option>\n<option value="lemu">Lemu</option>\n<option value="leppavirta">Lepp\xe4virta</option>\n<option value="lestijarvi">Lestij\xe4rvi</option>\n<option value="lieksa">Lieksa</option>\n<option value="lieto">Lieto</option>\n<option value="liljendal">Liljendal</option>\n<option value="liminka">Liminka</option>\n<option value="liperi">Liperi</option>\n<option value="lohja">Lohja</option>\n<option value="lohtaja">Lohtaja</option>\n<option value="loimaa">Loimaa</option>\n<option value="loppi">Loppi</option>\n<option value="loviisa">Loviisa</option>\n<option value="luhanka">Luhanka</option>\n<option value="lumijoki">Lumijoki</option>\n<option value="lumparland">Lumparland</option>\n<option value="luoto">Luoto</option>\n<option value="luumaki">Luum\xe4ki</option>\n<option value="luvia">Luvia</option>\n<option value="maalahti">Maalahti</option>\n<option value="maaninka">Maaninka</option>\n<option value="maarianhamina">Maarianhamina</option>\n<option value="marttila">Marttila</option>\n<option value="masku">Masku</option>\n<option value="mellila">Mellil\xe4</option>\n<option value="merijarvi">Merij\xe4rvi</option>\n<option value="merikarvia">Merikarvia</option>\n<option value="merimasku">Merimasku</option>\n<option value="miehikkala">Miehikk\xe4l\xe4</option>\n<option value="mikkeli">Mikkeli</option>\n<option value="mouhijarvi">Mouhij\xe4rvi</option>\n<option value="muhos">Muhos</option>\n<option value="multia">Multia</option>\n<option value="muonio">Muonio</option>\n<option value="mustasaari">Mustasaari</option>\n<option value="muurame">Muurame</option>\n<option value="muurla">Muurla</option>\n<option value="mynamaki">Myn\xe4m\xe4ki</option>\n<option value="myrskyla">Myrskyl\xe4</option>\n<option value="mantsala">M\xe4nts\xe4l\xe4</option>\n<option value="mantta">M\xe4ntt\xe4</option>\n<option value="mantyharju">M\xe4ntyharju</option>\n<option value="naantali">Naantali</option>\n<option value="nakkila">Nakkila</option>\n<option value="nastola">Nastola</option>\n<option value="nauvo">Nauvo</option>\n<option value="nilsia">Nilsi\xe4</option>\n<option value="nivala">Nivala</option>\n<option value="nokia">Nokia</option>\n<option value="noormarkku">Noormarkku</option>\n<option value="nousiainen">Nousiainen</option>\n<option value="nummi-pusula">Nummi-Pusula</option>\n<option value="nurmes">Nurmes</option>\n<option value="nurmijarvi">Nurmij\xe4rvi</option>\n<option value="nurmo">Nurmo</option>\n<option value="narpio">N\xe4rpi\xf6</option>\n<option value="oravainen">Oravainen</option>\n<option value="orimattila">Orimattila</option>\n<option value="oripaa">Orip\xe4\xe4</option>\n<option value="orivesi">Orivesi</option>\n<option value="oulainen">Oulainen</option>\n<option value="oulu">Oulu</option>\n<option value="oulunsalo">Oulunsalo</option>\n<option value="outokumpu">Outokumpu</option>\n<option value="padasjoki">Padasjoki</option>\n<option value="paimio">Paimio</option>\n<option value="paltamo">Paltamo</option>\n<option value="parainen">Parainen</option>\n<option value="parikkala">Parikkala</option>\n<option value="parkano">Parkano</option>\n<option value="pedersore">Peders\xf6re</option>\n<option value="pelkosenniemi">Pelkosenniemi</option>\n<option value="pello">Pello</option>\n<option value="perho">Perho</option>\n<option value="pernaja">Pernaja</option>\n<option value="pernio">Perni\xf6</option>\n<option value="pertteli">Pertteli</option>\n<option value="pertunmaa">Pertunmaa</option>\n<option value="petajavesi">Pet\xe4j\xe4vesi</option>\n<option value="pieksamaki">Pieks\xe4m\xe4ki</option>\n<option value="pielavesi">Pielavesi</option>\n<option value="pietarsaari">Pietarsaari</option>\n<option value="pihtipudas">Pihtipudas</option>\n<option value="piikkio">Piikki\xf6</option>\n<option value="piippola">Piippola</option>\n<option value="pirkkala">Pirkkala</option>\n<option value="pohja">Pohja</option>\n<option value="polvijarvi">Polvij\xe4rvi</option>\n<option value="pomarkku">Pomarkku</option>\n<option value="pori">Pori</option>\n<option value="pornainen">Pornainen</option>\n<option value="porvoo">Porvoo</option>\n<option value="posio">Posio</option>\n<option value="pudasjarvi">Pudasj\xe4rvi</option>\n<option value="pukkila">Pukkila</option>\n<option value="pulkkila">Pulkkila</option>\n<option value="punkaharju">Punkaharju</option>\n<option value="punkalaidun">Punkalaidun</option>\n<option value="puolanka">Puolanka</option>\n<option value="puumala">Puumala</option>\n<option value="pyhtaa">Pyht\xe4\xe4</option>\n<option value="pyhajoki">Pyh\xe4joki</option>\n<option value="pyhajarvi">Pyh\xe4j\xe4rvi</option>\n<option value="pyhanta">Pyh\xe4nt\xe4</option>\n<option value="pyharanta">Pyh\xe4ranta</option>\n<option value="pyhaselka">Pyh\xe4selk\xe4</option>\n<option value="pylkonmaki">Pylk\xf6nm\xe4ki</option>\n<option value="palkane">P\xe4lk\xe4ne</option>\n<option value="poytya">P\xf6yty\xe4</option>\n<option value="raahe">Raahe</option>\n<option value="raisio">Raisio</option>\n<option value="rantasalmi">Rantasalmi</option>\n<option value="rantsila">Rantsila</option>\n<option value="ranua">Ranua</option>\n<option value="rauma">Rauma</option>\n<option value="rautalampi">Rautalampi</option>\n<option value="rautavaara">Rautavaara</option>\n<option value="rautjarvi">Rautj\xe4rvi</option>\n<option value="reisjarvi">Reisj\xe4rvi</option>\n<option value="renko">Renko</option>\n<option value="riihimaki">Riihim\xe4ki</option>\n<option value="ristiina">Ristiina</option>\n<option value="ristijarvi">Ristij\xe4rvi</option>\n<option value="rovaniemi">Rovaniemi</option>\n<option value="ruokolahti">Ruokolahti</option>\n<option value="ruotsinpyhtaa">Ruotsinpyht\xe4\xe4</option>\n<option value="ruovesi">Ruovesi</option>\n<option value="rusko">Rusko</option>\n<option value="rymattyla">Rym\xe4ttyl\xe4</option>\n<option value="raakkyla">R\xe4\xe4kkyl\xe4</option>\n<option value="saarijarvi">Saarij\xe4rvi</option>\n<option value="salla">Salla</option>\n<option value="salo">Salo</option>\n<option value="saltvik">Saltvik</option>\n<option value="sammatti">Sammatti</option>\n<option value="sauvo">Sauvo</option>\n<option value="savitaipale">Savitaipale</option>\n<option value="savonlinna">Savonlinna</option>\n<option value="savonranta">Savonranta</option>\n<option value="savukoski">Savukoski</option>\n<option value="seinajoki">Sein\xe4joki</option>\n<option value="sievi">Sievi</option>\n<option value="siikainen">Siikainen</option>\n<option value="siikajoki">Siikajoki</option>\n<option value="siilinjarvi">Siilinj\xe4rvi</option>\n<option value="simo">Simo</option>\n<option value="sipoo">Sipoo</option>\n<option value="siuntio">Siuntio</option>\n<option value="sodankyla">Sodankyl\xe4</option>\n<option value="soini">Soini</option>\n<option value="somero">Somero</option>\n<option value="sonkajarvi">Sonkaj\xe4rvi</option>\n<option value="sotkamo">Sotkamo</option>\n<option value="sottunga">Sottunga</option>\n<option value="sulkava">Sulkava</option>\n<option value="sund">Sund</option>\n<option value="suomenniemi">Suomenniemi</option>\n<option value="suomusjarvi">Suomusj\xe4rvi</option>\n<option value="suomussalmi">Suomussalmi</option>\n<option value="suonenjoki">Suonenjoki</option>\n<option value="sysma">Sysm\xe4</option>\n<option value="sakyla">S\xe4kyl\xe4</option>\n<option value="sarkisalo">S\xe4rkisalo</option>\n<option value="taipalsaari">Taipalsaari</option>\n<option value="taivalkoski">Taivalkoski</option>\n<option value="taivassalo">Taivassalo</option>\n<option value="tammela">Tammela</option>\n<option value="tammisaari">Tammisaari</option>\n<option value="tampere">Tampere</option>\n<option value="tarvasjoki">Tarvasjoki</option>\n<option value="tervo">Tervo</option>\n<option value="tervola">Tervola</option>\n<option value="teuva">Teuva</option>\n<option value="tohmajarvi">Tohmaj\xe4rvi</option>\n<option value="toholampi">Toholampi</option>\n<option value="toivakka">Toivakka</option>\n<option value="tornio">Tornio</option>\n<option value="turku" selected="selected">Turku</option>\n<option value="tuulos">Tuulos</option>\n<option value="tuusniemi">Tuusniemi</option>\n<option value="tuusula">Tuusula</option>\n<option value="tyrnava">Tyrn\xe4v\xe4</option>\n<option value="toysa">T\xf6ys\xe4</option>\n<option value="ullava">Ullava</option>\n<option value="ulvila">Ulvila</option>\n<option value="urjala">Urjala</option>\n<option value="utajarvi">Utaj\xe4rvi</option>\n<option value="utsjoki">Utsjoki</option>\n<option value="uurainen">Uurainen</option>\n<option value="uusikaarlepyy">Uusikaarlepyy</option>\n<option value="uusikaupunki">Uusikaupunki</option>\n<option value="vaala">Vaala</option>\n<option value="vaasa">Vaasa</option>\n<option value="vahto">Vahto</option>\n<option value="valkeakoski">Valkeakoski</option>\n<option value="valkeala">Valkeala</option>\n<option value="valtimo">Valtimo</option>\n<option value="vammala">Vammala</option>\n<option value="vampula">Vampula</option>\n<option value="vantaa">Vantaa</option>\n<option value="varkaus">Varkaus</option>\n<option value="varpaisjarvi">Varpaisj\xe4rvi</option>\n<option value="vehmaa">Vehmaa</option>\n<option value="velkua">Velkua</option>\n<option value="vesanto">Vesanto</option>\n<option value="vesilahti">Vesilahti</option>\n<option value="veteli">Veteli</option>\n<option value="vierema">Vierem\xe4</option>\n<option value="vihanti">Vihanti</option>\n<option value="vihti">Vihti</option>\n<option value="viitasaari">Viitasaari</option>\n<option value="vilppula">Vilppula</option>\n<option value="vimpeli">Vimpeli</option>\n<option value="virolahti">Virolahti</option>\n<option value="virrat">Virrat</option>\n<option value="vardo">V\xe5rd\xf6</option>\n<option value="vahakyro">V\xe4h\xe4kyr\xf6</option>\n<option value="vastanfjard">V\xe4stanfj\xe4rd</option>\n<option value="voyri-maksamaa">V\xf6yri-Maksamaa</option>\n<option value="yliharma">Ylih\xe4rm\xe4</option>\n<option value="yli-ii">Yli-Ii</option>\n<option value="ylikiiminki">Ylikiiminki</option>\n<option value="ylistaro">Ylistaro</option>\n<option value="ylitornio">Ylitornio</option>\n<option value="ylivieska">Ylivieska</option>\n<option value="ylamaa">Yl\xe4maa</option>\n<option value="ylane">Yl\xe4ne</option>\n<option value="ylojarvi">Yl\xf6j\xe4rvi</option>\n<option value="ypaja">Yp\xe4j\xe4</option>\n<option value="aetsa">\xc4ets\xe4</option>\n<option value="ahtari">\xc4ht\xe4ri</option>\n<option value="aanekoski">\xc4\xe4nekoski</option>\n</select>'
# FISocialSecurityNumber
##############################################################
>>> from django.contrib.localflavor.fi.forms import FISocialSecurityNumber
>>> f = FISocialSecurityNumber()
>>> f.clean('010101-0101')
u'010101-0101'
>>> f.clean('010101+0101')
u'010101+0101'
>>> f.clean('010101A0101')
u'010101A0101'
>>> f.clean('101010-0102')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Finnish social security number.']
>>> f.clean('10a010-0101')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Finnish social security number.']
>>> f.clean('101010-0\xe401')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Finnish social security number.']
>>> f.clean('101010b0101')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Finnish social security number.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = FISocialSecurityNumber(required=False)
>>> f.clean('010101-0101')
u'010101-0101'
>>> f.clean(None)
u''
>>> f.clean('')
u''
# BRZipCodeField ############################################################
>>> from django.contrib.localflavor.br.forms import BRZipCodeField
>>> f = BRZipCodeField()
>>> f.clean('12345-123')
u'12345-123'
>>> f.clean('12345_123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('1234-123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('abcde-abc')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('-123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = BRZipCodeField(required=False)
>>> f.clean(None)
u''
>>> f.clean('')
u''
>>> f.clean('-123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('abcde-abc')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('1234-123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345_123')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-123')
u'12345-123'
# BRCNPJField ############################################################
>>> from django.contrib.localflavor.br.forms import BRCNPJField
>>> f = BRCNPJField(required=True)
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('12-345-678/9012-10')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CNPJ number.']
>>> f.clean('12.345.678/9012-10')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CNPJ number.']
>>> f.clean('12345678/9012-10')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CNPJ number.']
>>> f.clean('64.132.916/0001-88')
'64.132.916/0001-88'
>>> f.clean('64-132-916/0001-88')
'64-132-916/0001-88'
>>> f.clean('64132916/0001-88')
'64132916/0001-88'
>>> f.clean('64.132.916/0001-XX')
Traceback (most recent call last):
...
ValidationError: [u'This field requires only numbers.']
>>> f = BRCNPJField(required=False)
>>> f.clean('')
u''
# BRCPFField #################################################################
>>> from django.contrib.localflavor.br.forms import BRCPFField
>>> f = BRCPFField()
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('489.294.654-54')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CPF number.']
>>> f.clean('295.669.575-98')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CPF number.']
>>> f.clean('539.315.127-22')
Traceback (most recent call last):
...
ValidationError: [u'Invalid CPF number.']
>>> f.clean('663.256.017-26')
u'663.256.017-26'
>>> f.clean('66325601726')
u'66325601726'
>>> f.clean('375.788.573-20')
u'375.788.573-20'
>>> f.clean('84828509895')
u'84828509895'
>>> f.clean('375.788.573-XX')
Traceback (most recent call last):
...
ValidationError: [u'This field requires only numbers.']
>>> f.clean('375.788.573-000')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at most 14 characters.']
>>> f.clean('123.456.78')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at least 11 characters.']
>>> f.clean('123456789555')
Traceback (most recent call last):
...
ValidationError: [u'This field requires at most 11 digits or 14 characters.']
>>> f = BRCPFField(required=False)
>>> f.clean('')
u''
>>> f.clean(None)
u''
# BRPhoneNumberField #########################################################
>>> from django.contrib.localflavor.br.forms import BRPhoneNumberField
>>> f = BRPhoneNumberField()
>>> f.clean('41-3562-3464')
u'41-3562-3464'
>>> f.clean('4135623464')
u'41-3562-3464'
>>> f.clean('41 3562-3464')
u'41-3562-3464'
>>> f.clean('41 3562 3464')
u'41-3562-3464'
>>> f.clean('(41) 3562 3464')
u'41-3562-3464'
>>> f.clean('41.3562.3464')
u'41-3562-3464'
>>> f.clean('41.3562-3464')
u'41-3562-3464'
>>> f.clean(' (41) 3562.3464')
u'41-3562-3464'
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = BRPhoneNumberField(required=False)
>>> f.clean('')
u''
>>> f.clean(None)
u''
>>> f.clean(' (41) 3562.3464')
u'41-3562-3464'
>>> f.clean('41.3562-3464')
u'41-3562-3464'
>>> f.clean('(41) 3562 3464')
u'41-3562-3464'
>>> f.clean('4135623464')
u'41-3562-3464'
>>> f.clean('41 3562-3464')
u'41-3562-3464'
# BRStateSelect ##############################################################
>>> from django.contrib.localflavor.br.forms import BRStateSelect
>>> w = BRStateSelect()
>>> w.render('states', 'PR')
u'<select name="states">\n<option value="AC">Acre</option>\n<option value="AL">Alagoas</option>\n<option value="AP">Amap\xe1</option>\n<option value="AM">Amazonas</option>\n<option value="BA">Bahia</option>\n<option value="CE">Cear\xe1</option>\n<option value="DF">Distrito Federal</option>\n<option value="ES">Esp\xedrito Santo</option>\n<option value="GO">Goi\xe1s</option>\n<option value="MA">Maranh\xe3o</option>\n<option value="MT">Mato Grosso</option>\n<option value="MS">Mato Grosso do Sul</option>\n<option value="MG">Minas Gerais</option>\n<option value="PA">Par\xe1</option>\n<option value="PB">Para\xedba</option>\n<option value="PR" selected="selected">Paran\xe1</option>\n<option value="PE">Pernambuco</option>\n<option value="PI">Piau\xed</option>\n<option value="RJ">Rio de Janeiro</option>\n<option value="RN">Rio Grande do Norte</option>\n<option value="RS">Rio Grande do Sul</option>\n<option value="RO">Rond\xf4nia</option>\n<option value="RR">Roraima</option>\n<option value="SC">Santa Catarina</option>\n<option value="SP">S\xe3o Paulo</option>\n<option value="SE">Sergipe</option>\n<option value="TO">Tocantins</option>\n</select>'
# DEZipCodeField ##############################################################
>>> from django.contrib.localflavor.de.forms import DEZipCodeField
>>> f = DEZipCodeField()
>>> f.clean('99423')
u'99423'
>>> f.clean(' 99423')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXXX.']
# DEStateSelect #############################################################
>>> from django.contrib.localflavor.de.forms import DEStateSelect
>>> w = DEStateSelect()
>>> w.render('states', 'TH')
u'<select name="states">\n<option value="BW">Baden-Wuerttemberg</option>\n<option value="BY">Bavaria</option>\n<option value="BE">Berlin</option>\n<option value="BB">Brandenburg</option>\n<option value="HB">Bremen</option>\n<option value="HH">Hamburg</option>\n<option value="HE">Hessen</option>\n<option value="MV">Mecklenburg-Western Pomerania</option>\n<option value="NI">Lower Saxony</option>\n<option value="NW">North Rhine-Westphalia</option>\n<option value="RP">Rhineland-Palatinate</option>\n<option value="SL">Saarland</option>\n<option value="SN">Saxony</option>\n<option value="ST">Saxony-Anhalt</option>\n<option value="SH">Schleswig-Holstein</option>\n<option value="TH" selected="selected">Thuringia</option>\n</select>'
# DEIdentityCardNumberField #################################################
>>> from django.contrib.localflavor.de.forms import DEIdentityCardNumberField
>>> f = DEIdentityCardNumberField()
>>> f.clean('7549313035D-6004103-0903042-0')
u'7549313035D-6004103-0903042-0'
>>> f.clean('9786324830D 6104243 0910271 2')
u'9786324830D-6104243-0910271-2'
>>> f.clean('0434657485D-6407276-0508137-9')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.']
# CHZipCodeField ############################################################
>>> from django.contrib.localflavor.ch.forms import CHZipCodeField
>>> f = CHZipCodeField()
>>> f.clean('800x')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXX.']
>>> f.clean('80 00')
Traceback (most recent call last):
...
ValidationError: [u'Enter a zip code in the format XXXX.']
>>> f.clean('8000')
u'8000'
# CHPhoneNumberField ########################################################
>>> from django.contrib.localflavor.ch.forms import CHPhoneNumberField
>>> f = CHPhoneNumberField()
>>> f.clean('01234567890')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0XX XXX XX XX format.']
>>> f.clean('1234567890')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must be in 0XX XXX XX XX format.']
>>> f.clean('0123456789')
u'012 345 67 89'
# CHIdentityCardNumberField #################################################
>>> from django.contrib.localflavor.ch.forms import CHIdentityCardNumberField
>>> f = CHIdentityCardNumberField()
>>> f.clean('C1234567<0')
u'C1234567<0'
>>> f.clean('C1234567<1')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.']
>>> f.clean('2123456700')
u'2123456700'
>>> f.clean('2123456701')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.']
# CHStateSelect #############################################################
>>> from django.contrib.localflavor.ch.forms import CHStateSelect
>>> w = CHStateSelect()
>>> w.render('state', 'AG')
u'<select name="state">\n<option value="AG" selected="selected">Aargau</option>\n<option value="AI">Appenzell Innerrhoden</option>\n<option value="AR">Appenzell Ausserrhoden</option>\n<option value="BS">Basel-Stadt</option>\n<option value="BL">Basel-Land</option>\n<option value="BE">Berne</option>\n<option value="FR">Fribourg</option>\n<option value="GE">Geneva</option>\n<option value="GL">Glarus</option>\n<option value="GR">Graubuenden</option>\n<option value="JU">Jura</option>\n<option value="LU">Lucerne</option>\n<option value="NE">Neuchatel</option>\n<option value="NW">Nidwalden</option>\n<option value="OW">Obwalden</option>\n<option value="SH">Schaffhausen</option>\n<option value="SZ">Schwyz</option>\n<option value="SO">Solothurn</option>\n<option value="SG">St. Gallen</option>\n<option value="TG">Thurgau</option>\n<option value="TI">Ticino</option>\n<option value="UR">Uri</option>\n<option value="VS">Valais</option>\n<option value="VD">Vaud</option>\n<option value="ZG">Zug</option>\n<option value="ZH">Zurich</option>\n</select>'
## AUPostCodeField ##########################################################
A field that accepts a four digit Australian post code.
>>> from django.contrib.localflavor.au.forms import AUPostCodeField
>>> f = AUPostCodeField()
>>> f.clean('1234')
u'1234'
>>> f.clean('2000')
u'2000'
>>> f.clean('abcd')
Traceback (most recent call last):
...
ValidationError: [u'Enter a 4 digit post code.']
>>> f.clean('20001')
Traceback (most recent call last):
...
ValidationError: [u'Enter a 4 digit post code.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = AUPostCodeField(required=False)
>>> f.clean('1234')
u'1234'
>>> f.clean('2000')
u'2000'
>>> f.clean('abcd')
Traceback (most recent call last):
...
ValidationError: [u'Enter a 4 digit post code.']
>>> f.clean('20001')
Traceback (most recent call last):
...
ValidationError: [u'Enter a 4 digit post code.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
## AUPhoneNumberField ########################################################
A field that accepts a 10 digit Australian phone number.
llows spaces and parentheses around area code.
>>> from django.contrib.localflavor.au.forms import AUPhoneNumberField
>>> f = AUPhoneNumberField()
>>> f.clean('1234567890')
u'1234567890'
>>> f.clean('0213456789')
u'0213456789'
>>> f.clean('02 13 45 67 89')
u'0213456789'
>>> f.clean('(02) 1345 6789')
u'0213456789'
>>> f.clean('(02) 1345-6789')
u'0213456789'
>>> f.clean('(02)1345-6789')
u'0213456789'
>>> f.clean('0408 123 456')
u'0408123456'
>>> f.clean('123')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must contain 10 digits.']
>>> f.clean('1800DJANGO')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must contain 10 digits.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = AUPhoneNumberField(required=False)
>>> f.clean('1234567890')
u'1234567890'
>>> f.clean('0213456789')
u'0213456789'
>>> f.clean('02 13 45 67 89')
u'0213456789'
>>> f.clean('(02) 1345 6789')
u'0213456789'
>>> f.clean('(02) 1345-6789')
u'0213456789'
>>> f.clean('(02)1345-6789')
u'0213456789'
>>> f.clean('0408 123 456')
u'0408123456'
>>> f.clean('123')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must contain 10 digits.']
>>> f.clean('1800DJANGO')
Traceback (most recent call last):
...
ValidationError: [u'Phone numbers must contain 10 digits.']
>>> f.clean(None)
u''
>>> f.clean('')
u''
## AUStateSelect #############################################################
AUStateSelect is a Select widget that uses a list of Australian
states/territories as its choices.
>>> from django.contrib.localflavor.au.forms import AUStateSelect
>>> f = AUStateSelect()
>>> print f.render('state', 'NSW')
<select name="state">
<option value="ACT">Australian Capital Territory</option>
<option value="NSW" selected="selected">New South Wales</option>
<option value="NT">Northern Territory</option>
<option value="QLD">Queensland</option>
<option value="SA">South Australia</option>
<option value="TAS">Tasmania</option>
<option value="VIC">Victoria</option>
<option value="WA">Western Australia</option>
</select>
## ISIdNumberField #############################################################
>>> from django.contrib.localflavor.is_.forms import *
>>> f = ISIdNumberField()
>>> f.clean('2308803449')
u'230880-3449'
>>> f.clean('230880-3449')
u'230880-3449'
>>> f.clean('230880 3449')
u'230880-3449'
>>> f.clean('230880343')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at least 10 characters.']
>>> f.clean('230880343234')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at most 11 characters.']
>>> f.clean('abcdefghijk')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean('2308803439')
Traceback (most recent call last):
...
ValidationError: [u'The Icelandic identification number is not valid.']
>>> f.clean('2308803440')
u'230880-3440'
>>> f = ISIdNumberField(required=False)
>>> f.clean(None)
u''
>>> f.clean('')
u''
## ISPhoneNumberField #############################################################
>>> from django.contrib.localflavor.is_.forms import *
>>> f = ISPhoneNumberField()
>>> f.clean('1234567')
u'1234567'
>>> f.clean('123 4567')
u'1234567'
>>> f.clean('123-4567')
u'1234567'
>>> f.clean('123-456')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid value.']
>>> f.clean('123456')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at least 7 characters.']
>>> f.clean('123456555')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at most 8 characters.']
>>> f.clean('abcdefg')
Traceback (most recent call last):
ValidationError: [u'Enter a valid value.']
>>> f.clean(' 1234567 ')
Traceback (most recent call last):
...
ValidationError: [u'Ensure this value has at most 8 characters.']
>>> f.clean(' 12367 ')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid value.']
>>> f.clean('')
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f.clean(None)
Traceback (most recent call last):
...
ValidationError: [u'This field is required.']
>>> f = ISPhoneNumberField(required=False)
>>> f.clean(None)
u''
>>> f.clean('')
u''
## ISPostalCodeSelect #############################################################
>>> from django.contrib.localflavor.is_.forms import *
>>> f = ISPostalCodeSelect()
>>> f.render('foo', 'bar')
u'<select name="foo">\n<option value="101">101 Reykjav\xedk</option>\n<option value="103">103 Reykjav\xedk</option>\n<option value="104">104 Reykjav\xedk</option>\n<option value="105">105 Reykjav\xedk</option>\n<option value="107">107 Reykjav\xedk</option>\n<option value="108">108 Reykjav\xedk</option>\n<option value="109">109 Reykjav\xedk</option>\n<option value="110">110 Reykjav\xedk</option>\n<option value="111">111 Reykjav\xedk</option>\n<option value="112">112 Reykjav\xedk</option>\n<option value="113">113 Reykjav\xedk</option>\n<option value="116">116 Kjalarnes</option>\n<option value="121">121 Reykjav\xedk</option>\n<option value="123">123 Reykjav\xedk</option>\n<option value="124">124 Reykjav\xedk</option>\n<option value="125">125 Reykjav\xedk</option>\n<option value="127">127 Reykjav\xedk</option>\n<option value="128">128 Reykjav\xedk</option>\n<option value="129">129 Reykjav\xedk</option>\n<option value="130">130 Reykjav\xedk</option>\n<option value="132">132 Reykjav\xedk</option>\n<option value="150">150 Reykjav\xedk</option>\n<option value="155">155 Reykjav\xedk</option>\n<option value="170">170 Seltjarnarnes</option>\n<option value="172">172 Seltjarnarnes</option>\n<option value="190">190 Vogar</option>\n<option value="200">200 K\xf3pavogur</option>\n<option value="201">201 K\xf3pavogur</option>\n<option value="202">202 K\xf3pavogur</option>\n<option value="203">203 K\xf3pavogur</option>\n<option value="210">210 Gar\xf0ab\xe6r</option>\n<option value="212">212 Gar\xf0ab\xe6r</option>\n<option value="220">220 Hafnarfj\xf6r\xf0ur</option>\n<option value="221">221 Hafnarfj\xf6r\xf0ur</option>\n<option value="222">222 Hafnarfj\xf6r\xf0ur</option>\n<option value="225">225 \xc1lftanes</option>\n<option value="230">230 Reykjanesb\xe6r</option>\n<option value="232">232 Reykjanesb\xe6r</option>\n<option value="233">233 Reykjanesb\xe6r</option>\n<option value="235">235 Keflav\xedkurflugv\xf6llur</option>\n<option value="240">240 Grindav\xedk</option>\n<option value="245">245 Sandger\xf0i</option>\n<option value="250">250 Gar\xf0ur</option>\n<option value="260">260 Reykjanesb\xe6r</option>\n<option value="270">270 Mosfellsb\xe6r</option>\n<option value="300">300 Akranes</option>\n<option value="301">301 Akranes</option>\n<option value="302">302 Akranes</option>\n<option value="310">310 Borgarnes</option>\n<option value="311">311 Borgarnes</option>\n<option value="320">320 Reykholt \xed Borgarfir\xf0i</option>\n<option value="340">340 Stykkish\xf3lmur</option>\n<option value="345">345 Flatey \xe1 Brei\xf0afir\xf0i</option>\n<option value="350">350 Grundarfj\xf6r\xf0ur</option>\n<option value="355">355 \xd3lafsv\xedk</option>\n<option value="356">356 Sn\xe6fellsb\xe6r</option>\n<option value="360">360 Hellissandur</option>\n<option value="370">370 B\xfa\xf0ardalur</option>\n<option value="371">371 B\xfa\xf0ardalur</option>\n<option value="380">380 Reykh\xf3lahreppur</option>\n<option value="400">400 \xcdsafj\xf6r\xf0ur</option>\n<option value="401">401 \xcdsafj\xf6r\xf0ur</option>\n<option value="410">410 Hn\xedfsdalur</option>\n<option value="415">415 Bolungarv\xedk</option>\n<option value="420">420 S\xfa\xf0av\xedk</option>\n<option value="425">425 Flateyri</option>\n<option value="430">430 Su\xf0ureyri</option>\n<option value="450">450 Patreksfj\xf6r\xf0ur</option>\n<option value="451">451 Patreksfj\xf6r\xf0ur</option>\n<option value="460">460 T\xe1lknafj\xf6r\xf0ur</option>\n<option value="465">465 B\xedldudalur</option>\n<option value="470">470 \xdeingeyri</option>\n<option value="471">471 \xdeingeyri</option>\n<option value="500">500 Sta\xf0ur</option>\n<option value="510">510 H\xf3lmav\xedk</option>\n<option value="512">512 H\xf3lmav\xedk</option>\n<option value="520">520 Drangsnes</option>\n<option value="522">522 Kj\xf6rvogur</option>\n<option value="523">523 B\xe6r</option>\n<option value="524">524 Nor\xf0urfj\xf6r\xf0ur</option>\n<option value="530">530 Hvammstangi</option>\n<option value="531">531 Hvammstangi</option>\n<option value="540">540 Bl\xf6ndu\xf3s</option>\n<option value="541">541 Bl\xf6ndu\xf3s</option>\n<option value="545">545 Skagastr\xf6nd</option>\n<option value="550">550 Sau\xf0\xe1rkr\xf3kur</option>\n<option value="551">551 Sau\xf0\xe1rkr\xf3kur</option>\n<option value="560">560 Varmahl\xed\xf0</option>\n<option value="565">565 Hofs\xf3s</option>\n<option value="566">566 Hofs\xf3s</option>\n<option value="570">570 Flj\xf3t</option>\n<option value="580">580 Siglufj\xf6r\xf0ur</option>\n<option value="600">600 Akureyri</option>\n<option value="601">601 Akureyri</option>\n<option value="602">602 Akureyri</option>\n<option value="603">603 Akureyri</option>\n<option value="610">610 Greniv\xedk</option>\n<option value="611">611 Gr\xedmsey</option>\n<option value="620">620 Dalv\xedk</option>\n<option value="621">621 Dalv\xedk</option>\n<option value="625">625 \xd3lafsfj\xf6r\xf0ur</option>\n<option value="630">630 Hr\xedsey</option>\n<option value="640">640 H\xfasav\xedk</option>\n<option value="641">641 H\xfasav\xedk</option>\n<option value="645">645 Fossh\xf3ll</option>\n<option value="650">650 Laugar</option>\n<option value="660">660 M\xfdvatn</option>\n<option value="670">670 K\xf3pasker</option>\n<option value="671">671 K\xf3pasker</option>\n<option value="675">675 Raufarh\xf6fn</option>\n<option value="680">680 \xde\xf3rsh\xf6fn</option>\n<option value="681">681 \xde\xf3rsh\xf6fn</option>\n<option value="685">685 Bakkafj\xf6r\xf0ur</option>\n<option value="690">690 Vopnafj\xf6r\xf0ur</option>\n<option value="700">700 Egilssta\xf0ir</option>\n<option value="701">701 Egilssta\xf0ir</option>\n<option value="710">710 Sey\xf0isfj\xf6r\xf0ur</option>\n<option value="715">715 Mj\xf3ifj\xf6r\xf0ur</option>\n<option value="720">720 Borgarfj\xf6r\xf0ur eystri</option>\n<option value="730">730 Rey\xf0arfj\xf6r\xf0ur</option>\n<option value="735">735 Eskifj\xf6r\xf0ur</option>\n<option value="740">740 Neskaupsta\xf0ur</option>\n<option value="750">750 F\xe1skr\xfa\xf0sfj\xf6r\xf0ur</option>\n<option value="755">755 St\xf6\xf0varfj\xf6r\xf0ur</option>\n<option value="760">760 Brei\xf0dalsv\xedk</option>\n<option value="765">765 Dj\xfapivogur</option>\n<option value="780">780 H\xf6fn \xed Hornafir\xf0i</option>\n<option value="781">781 H\xf6fn \xed Hornafir\xf0i</option>\n<option value="785">785 \xd6r\xe6fi</option>\n<option value="800">800 Selfoss</option>\n<option value="801">801 Selfoss</option>\n<option value="802">802 Selfoss</option>\n<option value="810">810 Hverager\xf0i</option>\n<option value="815">815 \xdeorl\xe1ksh\xf6fn</option>\n<option value="820">820 Eyrarbakki</option>\n<option value="825">825 Stokkseyri</option>\n<option value="840">840 Laugarvatn</option>\n<option value="845">845 Fl\xfa\xf0ir</option>\n<option value="850">850 Hella</option>\n<option value="851">851 Hella</option>\n<option value="860">860 Hvolsv\xf6llur</option>\n<option value="861">861 Hvolsv\xf6llur</option>\n<option value="870">870 V\xedk</option>\n<option value="871">871 V\xedk</option>\n<option value="880">880 Kirkjub\xe6jarklaustur</option>\n<option value="900">900 Vestmannaeyjar</option>\n<option value="902">902 Vestmannaeyjar</option>\n</select>'
## CLRutField #############################################################
CLRutField is a Field that checks the validity of the Chilean
personal identification number (RUT). It has two modes relaxed (default) and
strict.
>>> from django.contrib.localflavor.cl.forms import CLRutField
>>> rut = CLRutField()
>>> rut.clean('11-6')
'11-6'
>>> rut.clean('116')
'11-6'
# valid format, bad verifier.
>>> rut.clean('11.111.111-0')
Traceback (most recent call last):
...
ValidationError: [u'The Chilean RUT is not valid.']
>>> rut.clean('111')
Traceback (most recent call last):
...
ValidationError: [u'The Chilean RUT is not valid.']
>>> rut.clean('767484100')
'76.748.410-0'
>>> rut.clean('78.412.790-7')
'78.412.790-7'
>>> rut.clean('8.334.6043')
'8.334.604-3'
>>> rut.clean('76793310-K')
'76.793.310-K'
Strict RUT usage (does not allow imposible values)
>>> rut = CLRutField(strict=True)
>>> rut.clean('11-6')
Traceback (most recent call last):
...
ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.']
# valid format, bad verifier.
>>> rut.clean('11.111.111-0')
Traceback (most recent call last):
...
ValidationError: [u'The Chilean RUT is not valid.']
# Correct input, invalid format.
>>> rut.clean('767484100')
Traceback (most recent call last):
...
ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.']
>>> rut.clean('78.412.790-7')
'78.412.790-7'
>>> rut.clean('8.334.6043')
Traceback (most recent call last):
...
ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.']
>>> rut.clean('76793310-K')
Traceback (most recent call last):
...
ValidationError: [u'Enter valid a Chilean RUT. The format is XX.XXX.XXX-X.']
"""
|
class Solution(object):
def decompressRLElist(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
new = []
for i in range(len(nums)/2):
new += nums[2*i] * [nums[2*i+1]]
return new |
# -*- coding: utf-8 -*-
BADREQUEST = 400
UNAUTHORIZED = 401
FORBIDDEN = 403
GONE = 410
TOOMANYREQUESTS = 412
class DnsdbException(Exception):
def __init__(self, message, errcode=500, detail=None, msg_ch=u''):
self.message = message
self.errcode = errcode
self.detail = detail
self.msg_ch = msg_ch
super(DnsdbException, self).__init__()
def __str__(self):
return self.message
def json(self):
return dict(code=self.errcode, why=self.message)
class Unauthorized(DnsdbException):
def __init__(self, message='Unauthorized', errcode=UNAUTHORIZED, detail=None, msg_ch=u''):
super(Unauthorized, self).__init__(message, errcode, detail, msg_ch)
class Forbidden(DnsdbException):
def __init__(self, message='Forbidden', errcode=FORBIDDEN, detail=None, msg_ch=u''):
super(Forbidden, self).__init__(message, errcode, detail, msg_ch)
class OperationLogErr(DnsdbException):
def __init__(self, message, errcode=500, detail=None, msg_ch=u''):
super(OperationLogErr, self).__init__(message, errcode, detail, msg_ch)
class BadParam(DnsdbException):
def __init__(self, message='Bad params', errcode=BADREQUEST, detail=None, msg_ch=u''):
super(BadParam, self).__init__(message, errcode, detail, msg_ch)
class UpdaterErr(DnsdbException):
pass
class ConfigErr(UpdaterErr):
def __init__(self, message):
super(ConfigErr, self).__init__(message=message, errcode=501)
|
#create class
class Event:
#create class variables
def __init__(self , eventId , eventType , themeColor , location):
self.eventId = eventId
self.eventType = eventType
self.themeColor = themeColor
self.location = location
#define class functions
def displayEventDetails(self):
print()
print("Event Type = " + self.eventType)
print("Theme Color = " + self.themeColor)
print("Location = " + self.location)
def setEventLocation(self):
self.location = input("Input new location of event " + str(self.eventId) + " : ") |
"""
1. Основы циклов.
a. Напишите цикл for, который выводит ASCII-коды всех символов в стро-
ке с именем S. Для преобразования символов в целочисленные ASCII-
коды используйте встроенную функцию ord(character). (Поэксперимен-
тируйте с ней в интерактивной оболочке, чтобы понять, как она рабо-
тает.)
b. Затем измените цикл так, чтобы он вычислял сумму кодов ASCII всех
символов в строке.
c. Наконец, измените свой программный код так, чтобы он возвращал но-
вый список, содержащий ASCII-коды всех символов в строке. Дает ли
выражение map(ord, S) похожий результат?
"""
S = input('Введите строку для преобразования: ')
count = 0
codes = []
for ch in S:
print('{} -> {}'.format(ch, ord(ch))) # task a.
count += ord(ch) # task b.
codes.append(ord(ch)) # task c.
print('Сумма кодов ASCII всех символов в строке -> {}'.format(count))
print(codes)
for ch in map(ord, S):
print(ch)
|
class Piece:
def __init__(self, row, col):
self.clicked = False
self.numAround = -1
self.flagged = False
self.row, self.col = row, col
def setNeighbors(self, neighbors):
self.neighbors = neighbors
def getNumFlaggedAround(self):
num = 0
for n in self.neighbors:
num += 1 if n.flagged else 0
return num
def getNumUnclickedAround(self):
num = 0
for n in self.neighbors:
num += 0 if n.clicked else 1
return num
def hasClickedNeighbor(self):
for n in self.neighbors:
if n.clicked:
return True
return False |
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
@AUTHOR:Joselyn Zhao
@CONTACT:[email protected]
@HOME_PAGE:joselynzhao.top
@SOFTWERE:PyCharm
@FILE:del.py
@TIME:2020/4/29 19:57
@DES:
'''
dict = {'shuxue':99,'yuwen':99,'yingyu':99}
print('shuxue:',dict['shuxue'])
print('yuwen:',dict['yuwen'])
print('yingyu:',dict['yingyu'])
dict['wuli'] = 100
dict['huaxue'] = 89
print(dict)
del dict['yingyu']
print(dict) |
# Input is square matrix A whose rows are sorted lists.
# Returns a list B by merging all rows into a single list.
#
# Goal: O(n^2 log n)
# Actually O(n^2 log(n^2)) but since log(n^2) == 2log(n) and constant factors can be ignored => O(2log(n)) can be relaxed to O(log(n))
def mergesort(Sublists):
sublists_count=len(Sublists)
if (sublists_count is 0): return Sublists
elif(sublists_count is 1): return Sublists[0]
k=sublists_count//2
first_half=mergesort(Sublists[:k])
second_half=mergesort(Sublists[k:])
return merge(first_half,second_half) # This merge operation takes O(n) time
def merge(list1,list2):
if list2 is []: return list1
Result=[]
list1_ptr=0
list2_ptr=0
while (list1_ptr<len(list1) and list2_ptr<len(list2)):
if (list1[list1_ptr]<=list2[list2_ptr]):
Result.append(list1[list1_ptr])
list1_ptr+=1
elif(list1[list1_ptr]>list2[list2_ptr]):
Result.append(list2[list2_ptr])
list2_ptr+=1
while (list1_ptr<len(list1)):
Result.append(list1[list1_ptr])
list1_ptr+=1
while (list2_ptr<len(list2)):
Result.append(list2[list2_ptr])
list2_ptr+=1
return Result
if __name__ == "__main__":
A=[[1,2,8],
[2,3,9],
[3,4,4]]
print(mergesort(A)) |
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
#
# Author: Flyaway - [email protected]
# Blog: zhouyichu.com
#
# Python release: 3.4.5
#
# Date: 2017-02-28 13:43:07
# Last modified: 2017-03-01 17:02:35
"""
Database for DIRT
"""
class Path:
"""Path is the real data structure that store in the database.
"""
def __init__(self, path, slotX, slotY):
self._path = path
self._slot = dict()
self._slot['slotX'] = dict()
self._slot['slotY'] = dict()
self._slot['slotX'][slotX] = 1
self._slot['slotY'][slotY] = 1
########################################################
# Public methods
########################################################
def insert(self, slotX, slotY):
self.slotX[slotX] = self.slotX.get(slotX, 0) + 1
self.slotY[slotY] = self.slotY.get(slotY, 0) + 1
self._check()
def slot(self, value):
"""Return the whole slot based on the given value.
Args:
value: str - 'SlotX' ot 'SlotY'
"""
return self._slot[value]
########################################################
# Property
########################################################
@property
def path(self):
return self._path
@property
def slotX(self):
return self._slot['slotX']
@property
def slotY(self):
return self._slot['slotY']
########################################################
# Magic methods
########################################################
def __len__(self):
"""Return the total number of slots.
"""
return sum([v for v in self.slotY.values()])
def __eq__(self, other):
return self.path == other.path
def __hash__(self):
return hash(self.path)
########################################################
# Private methods
########################################################
def _check(self):
"""To make ure the number of slotX and slotY is equal
"""
X = sum([v for v in self.slotX.values()])
Y = sum([v for v in self.slotY.values()])
assert X == Y
class Database:
"""Construct the Triple Database.
As a database, there should be some basic operations:
Attributes:
self_db: dict(path)
- insert(): Insert a new item.
- search(): Seach for a particular item.
"""
def __init__(self):
self._db = dict()
def insert(self, triple):
path = triple.path
slotX = triple.slotX
slotY = triple.slotY
if triple.path not in self._db:
ins = Path(path, slotX, slotY)
self._db[path] = ins
else:
self._db[path].insert(slotX, slotY)
def path_number(self):
"""Return the numbe of paths intotal.
"""
values = sum([len(v) for v in self._db.values()])
return values
def apply_minfreq(self, k):
paths = [p for p in self._db if len(self._db[p]) < k]
for p in paths:
del self._db[p]
def search_counter(self, path=None, slot=None, filler=None):
"""Search the counter number based on the given path, slotX and slotY.
Args:
path: str
"""
if path is None:
inss = self._db.values()
else:
inss = [self._db[path]]
if slot is None:
raise Exception('Must given a slot name !')
value = 0
slots = [ins.slot(slot) for ins in inss]
if filler is None:
value += sum([sum(v.values()) for v in slots])
else:
value = sum([v.get(filler, 0) for v in slots])
return value
def search_words(self, path, slot):
"""Return all the words the fill the slot in path.
Return:
set(str)
"""
ins = self._db[path]
return set(ins.slot(slot).keys())
########################################################
# Magic methods
########################################################
def __len__(self):
"""Return the number of distinct paths.
"""
return len(self._db)
def __contains__(self, path):
"""Check if the given path is in the database.
"""
return path in self._db
def __iter__(self):
return iter(self._db.keys())
|
def non_contiguous_motif(str1, dna_list):
index = -1
num = 0
for i in str1:
for j in dna_list:
index+= 1
if i == j:
num = index
return num
|
#!/usr/bin/env python
NAME = 'Microsoft ISA Server'
def is_waf(self):
detected = False
r = self.invalid_host()
if r is None:
return
if r.reason in self.isaservermatch:
detected = True
return detected
|
#
# PySNMP MIB module Unisphere-Data-L2F-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Unisphere-Data-L2F-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:24:37 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")
ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint")
InterfaceIndex, InterfaceIndexOrZero = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex", "InterfaceIndexOrZero")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
IpAddress, ModuleIdentity, ObjectIdentity, NotificationType, Bits, Integer32, iso, Counter32, Unsigned32, TimeTicks, MibIdentifier, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "ModuleIdentity", "ObjectIdentity", "NotificationType", "Bits", "Integer32", "iso", "Counter32", "Unsigned32", "TimeTicks", "MibIdentifier", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32")
TruthValue, TextualConvention, DisplayString, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "TruthValue", "TextualConvention", "DisplayString", "RowStatus")
usDataMibs, = mibBuilder.importSymbols("Unisphere-Data-MIBs", "usDataMibs")
UsdEnable, = mibBuilder.importSymbols("Unisphere-Data-TC", "UsdEnable")
usdL2fMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53))
usdL2fMIB.setRevisions(('2001-09-25 13:54', '2001-09-19 18:07',))
if mibBuilder.loadTexts: usdL2fMIB.setLastUpdated('200109251354Z')
if mibBuilder.loadTexts: usdL2fMIB.setOrganization('Unisphere Networks, Inc.')
class UsdL2fTunnelId(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 65535)
class UsdL2fSessionId(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(0, 65535)
class UsdL2fAdminState(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1, 2))
namedValues = NamedValues(("enabled", 0), ("disabled", 1), ("drain", 2))
class UsdL2fTransport(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(0, 1))
namedValues = NamedValues(("other", 0), ("udpIp", 1))
usdL2fTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 0))
usdL2fObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1))
usdL2fTrapControl = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 2))
usdL2fConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3))
usdL2fSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1))
usdL2fDestination = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2))
usdL2fTunnel = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3))
usdL2fSession = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4))
usdL2fTransport = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5))
usdL2fSystemConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 1))
usdL2fSystemStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2))
usdL2fSysConfigAdminState = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 1, 1), UsdL2fAdminState()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: usdL2fSysConfigAdminState.setStatus('current')
usdL2fSysConfigDestructTimeout = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 3600))).setUnits('seconds').setMaxAccess("readwrite")
if mibBuilder.loadTexts: usdL2fSysConfigDestructTimeout.setStatus('current')
usdL2fSysConfigIpChecksumEnable = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 1, 3), UsdEnable()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: usdL2fSysConfigIpChecksumEnable.setStatus('current')
usdL2fSysConfigReceiveDataSequencingIgnore = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 1, 4), UsdEnable()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: usdL2fSysConfigReceiveDataSequencingIgnore.setStatus('current')
usdL2fSysStatusProtocolVersion = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(2, 256))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusProtocolVersion.setStatus('current')
usdL2fSysStatusVendorName = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 2), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusVendorName.setStatus('current')
usdL2fSysStatusFirmwareRev = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 3), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusFirmwareRev.setStatus('current')
usdL2fSysStatusTotalDestinations = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusTotalDestinations.setStatus('current')
usdL2fSysStatusFailedDestinations = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusFailedDestinations.setStatus('current')
usdL2fSysStatusActiveDestinations = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 6), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusActiveDestinations.setStatus('current')
usdL2fSysStatusTotalTunnels = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusTotalTunnels.setStatus('current')
usdL2fSysStatusFailedTunnels = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusFailedTunnels.setStatus('current')
usdL2fSysStatusFailedTunnelAuthens = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusFailedTunnelAuthens.setStatus('current')
usdL2fSysStatusActiveTunnels = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 10), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusActiveTunnels.setStatus('current')
usdL2fSysStatusTotalSessions = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusTotalSessions.setStatus('current')
usdL2fSysStatusFailedSessions = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusFailedSessions.setStatus('current')
usdL2fSysStatusActiveSessions = MibScalar((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 1, 2, 13), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSysStatusActiveSessions.setStatus('current')
usdL2fDestConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1))
usdL2fDestStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2))
usdL2fDestStatistics = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3))
usdL2fDestConfigTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1, 2), )
if mibBuilder.loadTexts: usdL2fDestConfigTable.setStatus('current')
usdL2fDestConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1, 2, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fDestConfigIfIndex"))
if mibBuilder.loadTexts: usdL2fDestConfigEntry.setStatus('current')
usdL2fDestConfigIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1, 2, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fDestConfigIfIndex.setStatus('current')
usdL2fDestConfigRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1, 2, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fDestConfigRowStatus.setStatus('current')
usdL2fDestConfigAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 1, 2, 1, 3), UsdL2fAdminState().clone('enabled')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fDestConfigAdminState.setStatus('current')
usdL2fDestStatusTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1), )
if mibBuilder.loadTexts: usdL2fDestStatusTable.setStatus('current')
usdL2fDestStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fDestStatusIfIndex"))
if mibBuilder.loadTexts: usdL2fDestStatusEntry.setStatus('current')
usdL2fDestStatusIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fDestStatusIfIndex.setStatus('current')
usdL2fDestStatusTransport = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 2), UsdL2fTransport()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusTransport.setStatus('current')
usdL2fDestStatusEffectiveAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 3), UsdL2fAdminState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusEffectiveAdminState.setStatus('current')
usdL2fDestStatusTotalTunnels = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusTotalTunnels.setStatus('current')
usdL2fDestStatusFailedTunnels = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusFailedTunnels.setStatus('current')
usdL2fDestStatusFailedTunnelAuthens = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusFailedTunnelAuthens.setStatus('current')
usdL2fDestStatusActiveTunnels = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 7), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusActiveTunnels.setStatus('current')
usdL2fDestStatusTotalSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusTotalSessions.setStatus('current')
usdL2fDestStatusFailedSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusFailedSessions.setStatus('current')
usdL2fDestStatusActiveSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 2, 1, 1, 10), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatusActiveSessions.setStatus('current')
usdL2fDestStatTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1), )
if mibBuilder.loadTexts: usdL2fDestStatTable.setStatus('current')
usdL2fDestStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fDestStatIfIndex"))
if mibBuilder.loadTexts: usdL2fDestStatEntry.setStatus('current')
usdL2fDestStatIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fDestStatIfIndex.setStatus('current')
usdL2fDestStatCtlRecvOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 2), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlRecvOctets.setStatus('current')
usdL2fDestStatCtlRecvPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlRecvPackets.setStatus('current')
usdL2fDestStatCtlRecvErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlRecvErrors.setStatus('current')
usdL2fDestStatCtlRecvDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlRecvDiscards.setStatus('current')
usdL2fDestStatCtlSendOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlSendOctets.setStatus('current')
usdL2fDestStatCtlSendPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlSendPackets.setStatus('current')
usdL2fDestStatCtlSendErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlSendErrors.setStatus('current')
usdL2fDestStatCtlSendDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatCtlSendDiscards.setStatus('current')
usdL2fDestStatPayRecvOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPayRecvOctets.setStatus('current')
usdL2fDestStatPayRecvPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPayRecvPackets.setStatus('current')
usdL2fDestStatPayRecvErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPayRecvErrors.setStatus('current')
usdL2fDestStatPayRecvDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 13), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPayRecvDiscards.setStatus('current')
usdL2fDestStatPaySendOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 14), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPaySendOctets.setStatus('current')
usdL2fDestStatPaySendPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 15), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPaySendPackets.setStatus('current')
usdL2fDestStatPaySendErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 16), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPaySendErrors.setStatus('current')
usdL2fDestStatPaySendDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 2, 3, 1, 1, 17), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fDestStatPaySendDiscards.setStatus('current')
usdL2fTunnelConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1))
usdL2fTunnelStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2))
usdL2fTunnelStatistics = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3))
usdL2fTunnelMap = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4))
usdL2fTunnelConfigTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1, 2), )
if mibBuilder.loadTexts: usdL2fTunnelConfigTable.setStatus('current')
usdL2fTunnelConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1, 2, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fTunnelConfigIfIndex"))
if mibBuilder.loadTexts: usdL2fTunnelConfigEntry.setStatus('current')
usdL2fTunnelConfigIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1, 2, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fTunnelConfigIfIndex.setStatus('current')
usdL2fTunnelConfigRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1, 2, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fTunnelConfigRowStatus.setStatus('current')
usdL2fTunnelConfigAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 1, 2, 1, 3), UsdL2fAdminState().clone('enabled')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fTunnelConfigAdminState.setStatus('current')
usdL2fTunnelStatusTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1), )
if mibBuilder.loadTexts: usdL2fTunnelStatusTable.setStatus('current')
usdL2fTunnelStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusIfIndex"))
if mibBuilder.loadTexts: usdL2fTunnelStatusEntry.setStatus('current')
usdL2fTunnelStatusIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fTunnelStatusIfIndex.setStatus('current')
usdL2fTunnelStatusTransport = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 2), UsdL2fTransport()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusTransport.setStatus('current')
usdL2fTunnelStatusLocalTunnelId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 3), UsdL2fTunnelId()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusLocalTunnelId.setStatus('current')
usdL2fTunnelStatusRemoteTunnelId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 4), UsdL2fTunnelId()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusRemoteTunnelId.setStatus('current')
usdL2fTunnelStatusEffectiveAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 5), UsdL2fAdminState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusEffectiveAdminState.setStatus('current')
usdL2fTunnelStatusState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("idle", 0), ("connecting", 1), ("established", 2), ("disconnecting", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusState.setStatus('current')
usdL2fTunnelStatusInitiated = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2))).clone(namedValues=NamedValues(("none", 0), ("local", 1), ("remote", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusInitiated.setStatus('current')
usdL2fTunnelStatusRemoteHostName = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 8), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusRemoteHostName.setStatus('current')
usdL2fTunnelStatusTotalSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusTotalSessions.setStatus('current')
usdL2fTunnelStatusFailedSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusFailedSessions.setStatus('current')
usdL2fTunnelStatusActiveSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 11), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusActiveSessions.setStatus('current')
usdL2fTunnelStatusLastErrorCode = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusLastErrorCode.setStatus('current')
usdL2fTunnelStatusLastErrorMessage = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 13), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusLastErrorMessage.setStatus('current')
usdL2fTunnelStatusCumEstabTime = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 2, 1, 1, 14), Unsigned32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatusCumEstabTime.setStatus('current')
usdL2fTunnelStatTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1), )
if mibBuilder.loadTexts: usdL2fTunnelStatTable.setStatus('current')
usdL2fTunnelStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fTunnelStatIfIndex"))
if mibBuilder.loadTexts: usdL2fTunnelStatEntry.setStatus('current')
usdL2fTunnelStatIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fTunnelStatIfIndex.setStatus('current')
usdL2fTunnelStatCtlRecvOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 2), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlRecvOctets.setStatus('current')
usdL2fTunnelStatCtlRecvPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlRecvPackets.setStatus('current')
usdL2fTunnelStatCtlRecvErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlRecvErrors.setStatus('current')
usdL2fTunnelStatCtlRecvDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlRecvDiscards.setStatus('current')
usdL2fTunnelStatCtlSendOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlSendOctets.setStatus('current')
usdL2fTunnelStatCtlSendPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlSendPackets.setStatus('current')
usdL2fTunnelStatCtlSendErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlSendErrors.setStatus('current')
usdL2fTunnelStatCtlSendDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlSendDiscards.setStatus('current')
usdL2fTunnelStatPayRecvOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPayRecvOctets.setStatus('current')
usdL2fTunnelStatPayRecvPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPayRecvPackets.setStatus('current')
usdL2fTunnelStatPayRecvErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 12), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPayRecvErrors.setStatus('current')
usdL2fTunnelStatPayRecvDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 13), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPayRecvDiscards.setStatus('current')
usdL2fTunnelStatPaySendOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 14), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPaySendOctets.setStatus('current')
usdL2fTunnelStatPaySendPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 15), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPaySendPackets.setStatus('current')
usdL2fTunnelStatPaySendErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 16), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPaySendErrors.setStatus('current')
usdL2fTunnelStatPaySendDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 17), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatPaySendDiscards.setStatus('current')
usdL2fTunnelStatCtlRecvOutOfSequence = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 3, 1, 1, 18), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fTunnelStatCtlRecvOutOfSequence.setStatus('current')
usdL2fMapTifSidToSifTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 1), )
if mibBuilder.loadTexts: usdL2fMapTifSidToSifTable.setStatus('current')
usdL2fMapTifSidToSifEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fMapTifSidToSifTunnelIfIndex"), (0, "Unisphere-Data-L2F-MIB", "usdL2fMapTifSidToSifLocalSessionId"))
if mibBuilder.loadTexts: usdL2fMapTifSidToSifEntry.setStatus('current')
usdL2fMapTifSidToSifTunnelIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fMapTifSidToSifTunnelIfIndex.setStatus('current')
usdL2fMapTifSidToSifLocalSessionId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 1, 1, 2), UsdL2fSessionId())
if mibBuilder.loadTexts: usdL2fMapTifSidToSifLocalSessionId.setStatus('current')
usdL2fMapTifSidToSifSessionIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 1, 1, 3), InterfaceIndex()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fMapTifSidToSifSessionIfIndex.setStatus('current')
usdL2fMapTidToTifTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 2), )
if mibBuilder.loadTexts: usdL2fMapTidToTifTable.setStatus('current')
usdL2fMapTidToTifEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 2, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fMapTidToTifLocalTunnelId"))
if mibBuilder.loadTexts: usdL2fMapTidToTifEntry.setStatus('current')
usdL2fMapTidToTifLocalTunnelId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 2, 1, 1), UsdL2fTunnelId())
if mibBuilder.loadTexts: usdL2fMapTidToTifLocalTunnelId.setStatus('current')
usdL2fMapTidToTifIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 3, 4, 2, 1, 2), InterfaceIndex()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fMapTidToTifIfIndex.setStatus('current')
usdL2fSessionConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1))
usdL2fSessionStatus = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2))
usdL2fSessionStatistics = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3))
usdL2fSessionConfigTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1, 2), )
if mibBuilder.loadTexts: usdL2fSessionConfigTable.setStatus('current')
usdL2fSessionConfigEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1, 2, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fSessionConfigIfIndex"))
if mibBuilder.loadTexts: usdL2fSessionConfigEntry.setStatus('current')
usdL2fSessionConfigIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1, 2, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fSessionConfigIfIndex.setStatus('current')
usdL2fSessionConfigRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1, 2, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fSessionConfigRowStatus.setStatus('current')
usdL2fSessionConfigAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 1, 2, 1, 3), UsdL2fAdminState().clone('enabled')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: usdL2fSessionConfigAdminState.setStatus('current')
usdL2fSessionStatusTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1), )
if mibBuilder.loadTexts: usdL2fSessionStatusTable.setStatus('current')
usdL2fSessionStatusEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fSessionStatusIfIndex"))
if mibBuilder.loadTexts: usdL2fSessionStatusEntry.setStatus('current')
usdL2fSessionStatusIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fSessionStatusIfIndex.setStatus('current')
usdL2fSessionStatusLocalSessionId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 2), UsdL2fSessionId()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusLocalSessionId.setStatus('current')
usdL2fSessionStatusRemoteSessionId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 3), UsdL2fSessionId()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusRemoteSessionId.setStatus('current')
usdL2fSessionStatusUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 4), DisplayString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusUserName.setStatus('current')
usdL2fSessionStatusEffectiveAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 5), UsdL2fAdminState()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusEffectiveAdminState.setStatus('current')
usdL2fSessionStatusState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("idle", 0), ("connecting", 1), ("established", 2), ("disconnecting", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusState.setStatus('current')
usdL2fSessionStatusCallType = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4))).clone(namedValues=NamedValues(("none", 0), ("lacIncoming", 1), ("lnsIncoming", 2), ("lacOutgoing", 3), ("lnsOutgoing", 4)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusCallType.setStatus('current')
usdL2fSessionStatusTxConnectSpeed = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 8), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusTxConnectSpeed.setStatus('current')
usdL2fSessionStatusRxConnectSpeed = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 9), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusRxConnectSpeed.setStatus('current')
usdL2fSessionStatusProxyLcp = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 10), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusProxyLcp.setStatus('current')
usdL2fSessionStatusAuthMethod = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("pppChap", 1), ("pppPap", 2), ("pppMsChap", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusAuthMethod.setStatus('current')
usdL2fSessionStatusSequencingState = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("remote", 1), ("local", 2), ("both", 3)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusSequencingState.setStatus('current')
usdL2fSessionStatusLacTunneledIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 13), InterfaceIndexOrZero()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusLacTunneledIfIndex.setStatus('current')
usdL2fSessionStatusCumEstabTime = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 2, 1, 1, 14), Unsigned32()).setUnits('seconds').setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatusCumEstabTime.setStatus('current')
usdL2fSessionStatTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1), )
if mibBuilder.loadTexts: usdL2fSessionStatTable.setStatus('current')
usdL2fSessionStatEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fSessionStatIfIndex"))
if mibBuilder.loadTexts: usdL2fSessionStatEntry.setStatus('current')
usdL2fSessionStatIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fSessionStatIfIndex.setStatus('current')
usdL2fSessionStatPayRecvOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 2), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPayRecvOctets.setStatus('current')
usdL2fSessionStatPayRecvPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 3), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPayRecvPackets.setStatus('current')
usdL2fSessionStatPayRecvErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPayRecvErrors.setStatus('current')
usdL2fSessionStatPayRecvDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPayRecvDiscards.setStatus('current')
usdL2fSessionStatPaySendOctets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPaySendOctets.setStatus('current')
usdL2fSessionStatPaySendPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 7), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPaySendPackets.setStatus('current')
usdL2fSessionStatPaySendErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 8), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPaySendErrors.setStatus('current')
usdL2fSessionStatPaySendDiscards = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 9), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPaySendDiscards.setStatus('current')
usdL2fSessionStatRecvOutOfSequence = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 10), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatRecvOutOfSequence.setStatus('current')
usdL2fSessionStatResequencingTimeouts = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 11), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatResequencingTimeouts.setStatus('current')
usdL2fSessionStatPayLostPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 4, 3, 1, 1, 12), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fSessionStatPayLostPackets.setStatus('current')
usdL2fTransportUdpIp = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1))
usdL2fUdpIpDestination = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1))
usdL2fUdpIpTunnel = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2))
usdL2fUdpIpDestTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1), )
if mibBuilder.loadTexts: usdL2fUdpIpDestTable.setStatus('current')
usdL2fUdpIpDestEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fUdpIpDestIfIndex"))
if mibBuilder.loadTexts: usdL2fUdpIpDestEntry.setStatus('current')
usdL2fUdpIpDestIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fUdpIpDestIfIndex.setStatus('current')
usdL2fUdpIpDestRouterIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1, 1, 2), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpDestRouterIndex.setStatus('current')
usdL2fUdpIpDestLocalAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpDestLocalAddress.setStatus('current')
usdL2fUdpIpDestRemoteAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 1, 1, 1, 4), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpDestRemoteAddress.setStatus('current')
usdL2fUdpIpTunnelTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1), )
if mibBuilder.loadTexts: usdL2fUdpIpTunnelTable.setStatus('current')
usdL2fUdpIpTunnelEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1), ).setIndexNames((0, "Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelIfIndex"))
if mibBuilder.loadTexts: usdL2fUdpIpTunnelEntry.setStatus('current')
usdL2fUdpIpTunnelIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 1), InterfaceIndex())
if mibBuilder.loadTexts: usdL2fUdpIpTunnelIfIndex.setStatus('current')
usdL2fUdpIpTunnelRouterIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 2), Unsigned32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpTunnelRouterIndex.setStatus('current')
usdL2fUdpIpTunnelLocalAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 3), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpTunnelLocalAddress.setStatus('current')
usdL2fUdpIpTunnelLocalPort = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpTunnelLocalPort.setStatus('current')
usdL2fUdpIpTunnelRemoteAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 5), IpAddress()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpTunnelRemoteAddress.setStatus('current')
usdL2fUdpIpTunnelRemotePort = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 1, 5, 1, 2, 1, 1, 6), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: usdL2fUdpIpTunnelRemotePort.setStatus('current')
usdL2fGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1))
usdL2fCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 2))
usdL2fCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 2, 1)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fConfigGroup"), ("Unisphere-Data-L2F-MIB", "usdL2fStatusGroup"), ("Unisphere-Data-L2F-MIB", "usdL2fStatGroup"), ("Unisphere-Data-L2F-MIB", "usdL2fMapGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fCompliance = usdL2fCompliance.setStatus('current')
usdL2fConfigGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1, 1)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fSysConfigAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fSysConfigDestructTimeout"), ("Unisphere-Data-L2F-MIB", "usdL2fSysConfigIpChecksumEnable"), ("Unisphere-Data-L2F-MIB", "usdL2fSysConfigReceiveDataSequencingIgnore"), ("Unisphere-Data-L2F-MIB", "usdL2fDestConfigRowStatus"), ("Unisphere-Data-L2F-MIB", "usdL2fDestConfigAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelConfigRowStatus"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelConfigAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionConfigRowStatus"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionConfigAdminState"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fConfigGroup = usdL2fConfigGroup.setStatus('current')
usdL2fStatusGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1, 2)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fSysStatusProtocolVersion"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusVendorName"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusFirmwareRev"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusTotalDestinations"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusFailedDestinations"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusActiveDestinations"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusTotalTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusFailedTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusFailedTunnelAuthens"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusActiveTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusTotalSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusFailedSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fSysStatusActiveSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusTransport"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusEffectiveAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusTotalTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusFailedTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusFailedTunnelAuthens"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusActiveTunnels"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusTotalSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusFailedSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatusActiveSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusTransport"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusLocalTunnelId"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusRemoteTunnelId"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusEffectiveAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusState"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusInitiated"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusRemoteHostName"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusTotalSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusFailedSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusActiveSessions"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusLastErrorCode"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusLastErrorMessage"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatusCumEstabTime"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusLocalSessionId"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusRemoteSessionId"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusUserName"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusEffectiveAdminState"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusState"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusCallType"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusTxConnectSpeed"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusRxConnectSpeed"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusProxyLcp"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusAuthMethod"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusSequencingState"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusLacTunneledIfIndex"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatusCumEstabTime"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fStatusGroup = usdL2fStatusGroup.setStatus('current')
usdL2fStatGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1, 3)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlRecvOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlRecvPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlRecvErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlRecvDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlSendOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlSendPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlSendErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatCtlSendDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPayRecvOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPayRecvPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPayRecvErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPayRecvDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPaySendOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPaySendPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPaySendErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fDestStatPaySendDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlRecvOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlRecvPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlRecvErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlRecvDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlSendOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlSendPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlSendErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlSendDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPayRecvOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPayRecvPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPayRecvErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPayRecvDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPaySendOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPaySendPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPaySendErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatPaySendDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fTunnelStatCtlRecvOutOfSequence"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPayRecvOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPayRecvPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPayRecvErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPayRecvDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPaySendOctets"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPaySendPackets"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPaySendErrors"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPaySendDiscards"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatRecvOutOfSequence"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatResequencingTimeouts"), ("Unisphere-Data-L2F-MIB", "usdL2fSessionStatPayLostPackets"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fStatGroup = usdL2fStatGroup.setStatus('current')
usdL2fMapGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1, 4)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fMapTifSidToSifSessionIfIndex"), ("Unisphere-Data-L2F-MIB", "usdL2fMapTidToTifIfIndex"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fMapGroup = usdL2fMapGroup.setStatus('current')
usdL2fUdpIpGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 53, 3, 1, 5)).setObjects(("Unisphere-Data-L2F-MIB", "usdL2fUdpIpDestRouterIndex"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpDestLocalAddress"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpDestRemoteAddress"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelRouterIndex"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelLocalAddress"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelLocalPort"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelRemoteAddress"), ("Unisphere-Data-L2F-MIB", "usdL2fUdpIpTunnelRemotePort"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
usdL2fUdpIpGroup = usdL2fUdpIpGroup.setStatus('current')
mibBuilder.exportSymbols("Unisphere-Data-L2F-MIB", usdL2fUdpIpTunnelEntry=usdL2fUdpIpTunnelEntry, usdL2fTraps=usdL2fTraps, usdL2fTunnelConfigEntry=usdL2fTunnelConfigEntry, usdL2fSessionStatusUserName=usdL2fSessionStatusUserName, usdL2fDestStatPaySendErrors=usdL2fDestStatPaySendErrors, usdL2fDestConfigIfIndex=usdL2fDestConfigIfIndex, usdL2fTunnelStatCtlSendPackets=usdL2fTunnelStatCtlSendPackets, usdL2fTunnelStatusCumEstabTime=usdL2fTunnelStatusCumEstabTime, usdL2fDestStatusTable=usdL2fDestStatusTable, usdL2fDestStatusFailedTunnelAuthens=usdL2fDestStatusFailedTunnelAuthens, usdL2fTunnelStatusTable=usdL2fTunnelStatusTable, usdL2fSessionStatistics=usdL2fSessionStatistics, usdL2fSysStatusFailedTunnels=usdL2fSysStatusFailedTunnels, usdL2fSystemStatus=usdL2fSystemStatus, usdL2fDestStatusActiveSessions=usdL2fDestStatusActiveSessions, usdL2fTunnelStatCtlRecvDiscards=usdL2fTunnelStatCtlRecvDiscards, usdL2fSysStatusActiveDestinations=usdL2fSysStatusActiveDestinations, usdL2fUdpIpTunnel=usdL2fUdpIpTunnel, usdL2fDestStatusEntry=usdL2fDestStatusEntry, usdL2fDestStatCtlRecvOctets=usdL2fDestStatCtlRecvOctets, usdL2fDestStatus=usdL2fDestStatus, usdL2fTrapControl=usdL2fTrapControl, usdL2fObjects=usdL2fObjects, usdL2fDestStatCtlRecvErrors=usdL2fDestStatCtlRecvErrors, usdL2fTunnelStatusTransport=usdL2fTunnelStatusTransport, usdL2fTransport=usdL2fTransport, usdL2fDestStatPayRecvDiscards=usdL2fDestStatPayRecvDiscards, usdL2fTunnelStatusEffectiveAdminState=usdL2fTunnelStatusEffectiveAdminState, usdL2fDestStatusIfIndex=usdL2fDestStatusIfIndex, usdL2fUdpIpDestEntry=usdL2fUdpIpDestEntry, usdL2fTunnelConfigTable=usdL2fTunnelConfigTable, usdL2fSessionStatPaySendDiscards=usdL2fSessionStatPaySendDiscards, usdL2fStatGroup=usdL2fStatGroup, usdL2fMapTidToTifLocalTunnelId=usdL2fMapTidToTifLocalTunnelId, usdL2fDestConfigEntry=usdL2fDestConfigEntry, usdL2fSessionStatusTable=usdL2fSessionStatusTable, usdL2fTunnelStatPaySendErrors=usdL2fTunnelStatPaySendErrors, usdL2fSysStatusFirmwareRev=usdL2fSysStatusFirmwareRev, usdL2fMapTidToTifTable=usdL2fMapTidToTifTable, usdL2fDestStatPayRecvPackets=usdL2fDestStatPayRecvPackets, usdL2fUdpIpDestRemoteAddress=usdL2fUdpIpDestRemoteAddress, usdL2fSession=usdL2fSession, usdL2fSysStatusProtocolVersion=usdL2fSysStatusProtocolVersion, usdL2fSysStatusVendorName=usdL2fSysStatusVendorName, usdL2fSessionConfigEntry=usdL2fSessionConfigEntry, usdL2fSessionStatPayRecvErrors=usdL2fSessionStatPayRecvErrors, usdL2fTunnelStatPayRecvPackets=usdL2fTunnelStatPayRecvPackets, usdL2fSessionConfigRowStatus=usdL2fSessionConfigRowStatus, usdL2fMapTifSidToSifTable=usdL2fMapTifSidToSifTable, usdL2fUdpIpDestIfIndex=usdL2fUdpIpDestIfIndex, usdL2fStatusGroup=usdL2fStatusGroup, usdL2fMapTifSidToSifEntry=usdL2fMapTifSidToSifEntry, usdL2fSysStatusTotalDestinations=usdL2fSysStatusTotalDestinations, usdL2fDestStatusFailedSessions=usdL2fDestStatusFailedSessions, usdL2fDestStatCtlSendOctets=usdL2fDestStatCtlSendOctets, usdL2fTunnelStatus=usdL2fTunnelStatus, usdL2fUdpIpTunnelLocalAddress=usdL2fUdpIpTunnelLocalAddress, usdL2fTunnelStatusLastErrorCode=usdL2fTunnelStatusLastErrorCode, usdL2fUdpIpDestLocalAddress=usdL2fUdpIpDestLocalAddress, usdL2fDestConfigAdminState=usdL2fDestConfigAdminState, usdL2fTunnelConfigRowStatus=usdL2fTunnelConfigRowStatus, usdL2fTunnelStatusFailedSessions=usdL2fTunnelStatusFailedSessions, usdL2fTunnelStatusActiveSessions=usdL2fTunnelStatusActiveSessions, usdL2fSessionStatusEntry=usdL2fSessionStatusEntry, usdL2fMapTidToTifEntry=usdL2fMapTidToTifEntry, usdL2fSessionConfigAdminState=usdL2fSessionConfigAdminState, usdL2fDestStatTable=usdL2fDestStatTable, usdL2fTunnelStatusTotalSessions=usdL2fTunnelStatusTotalSessions, usdL2fTunnelStatCtlSendOctets=usdL2fTunnelStatCtlSendOctets, usdL2fTunnelStatTable=usdL2fTunnelStatTable, usdL2fMapTifSidToSifLocalSessionId=usdL2fMapTifSidToSifLocalSessionId, usdL2fSessionStatPaySendOctets=usdL2fSessionStatPaySendOctets, usdL2fSystem=usdL2fSystem, usdL2fSessionStatIfIndex=usdL2fSessionStatIfIndex, usdL2fSessionConfig=usdL2fSessionConfig, usdL2fDestStatPaySendOctets=usdL2fDestStatPaySendOctets, usdL2fSessionStatResequencingTimeouts=usdL2fSessionStatResequencingTimeouts, usdL2fCompliance=usdL2fCompliance, usdL2fSessionStatusCallType=usdL2fSessionStatusCallType, usdL2fSessionStatPayRecvPackets=usdL2fSessionStatPayRecvPackets, usdL2fTunnelStatPaySendDiscards=usdL2fTunnelStatPaySendDiscards, usdL2fTunnelMap=usdL2fTunnelMap, usdL2fConformance=usdL2fConformance, usdL2fSysStatusTotalTunnels=usdL2fSysStatusTotalTunnels, usdL2fDestStatCtlRecvPackets=usdL2fDestStatCtlRecvPackets, usdL2fTunnelStatCtlRecvErrors=usdL2fTunnelStatCtlRecvErrors, usdL2fTunnelStatCtlSendErrors=usdL2fTunnelStatCtlSendErrors, usdL2fSessionStatusRxConnectSpeed=usdL2fSessionStatusRxConnectSpeed, usdL2fSystemConfig=usdL2fSystemConfig, usdL2fSessionStatusTxConnectSpeed=usdL2fSessionStatusTxConnectSpeed, usdL2fSessionStatusSequencingState=usdL2fSessionStatusSequencingState, usdL2fDestStatEntry=usdL2fDestStatEntry, usdL2fUdpIpGroup=usdL2fUdpIpGroup, usdL2fTunnelStatPaySendPackets=usdL2fTunnelStatPaySendPackets, usdL2fTunnelStatusEntry=usdL2fTunnelStatusEntry, usdL2fSessionStatusRemoteSessionId=usdL2fSessionStatusRemoteSessionId, usdL2fDestConfigTable=usdL2fDestConfigTable, usdL2fDestStatPayRecvErrors=usdL2fDestStatPayRecvErrors, usdL2fSysStatusFailedDestinations=usdL2fSysStatusFailedDestinations, usdL2fDestStatIfIndex=usdL2fDestStatIfIndex, UsdL2fTunnelId=UsdL2fTunnelId, usdL2fDestStatCtlRecvDiscards=usdL2fDestStatCtlRecvDiscards, usdL2fTunnelStatusIfIndex=usdL2fTunnelStatusIfIndex, usdL2fSessionStatusProxyLcp=usdL2fSessionStatusProxyLcp, usdL2fSessionStatusState=usdL2fSessionStatusState, usdL2fSessionStatusCumEstabTime=usdL2fSessionStatusCumEstabTime, usdL2fUdpIpDestRouterIndex=usdL2fUdpIpDestRouterIndex, UsdL2fSessionId=UsdL2fSessionId, usdL2fMIB=usdL2fMIB, usdL2fUdpIpDestTable=usdL2fUdpIpDestTable, usdL2fDestStatusTotalTunnels=usdL2fDestStatusTotalTunnels, usdL2fSessionStatus=usdL2fSessionStatus, usdL2fDestStatCtlSendErrors=usdL2fDestStatCtlSendErrors, usdL2fSessionStatusLacTunneledIfIndex=usdL2fSessionStatusLacTunneledIfIndex, usdL2fMapTifSidToSifSessionIfIndex=usdL2fMapTifSidToSifSessionIfIndex, usdL2fDestStatCtlSendPackets=usdL2fDestStatCtlSendPackets, usdL2fDestStatPaySendPackets=usdL2fDestStatPaySendPackets, usdL2fSessionStatPayRecvDiscards=usdL2fSessionStatPayRecvDiscards, usdL2fTunnel=usdL2fTunnel, usdL2fUdpIpTunnelRemoteAddress=usdL2fUdpIpTunnelRemoteAddress, usdL2fGroups=usdL2fGroups, usdL2fCompliances=usdL2fCompliances, usdL2fDestConfig=usdL2fDestConfig, UsdL2fTransport=UsdL2fTransport, usdL2fTunnelStatPayRecvDiscards=usdL2fTunnelStatPayRecvDiscards, usdL2fTransportUdpIp=usdL2fTransportUdpIp, usdL2fTunnelStatCtlRecvOutOfSequence=usdL2fTunnelStatCtlRecvOutOfSequence, UsdL2fAdminState=UsdL2fAdminState, usdL2fTunnelStatPayRecvErrors=usdL2fTunnelStatPayRecvErrors, usdL2fTunnelStatusRemoteTunnelId=usdL2fTunnelStatusRemoteTunnelId, usdL2fTunnelStatistics=usdL2fTunnelStatistics, PYSNMP_MODULE_ID=usdL2fMIB, usdL2fSessionStatusLocalSessionId=usdL2fSessionStatusLocalSessionId, usdL2fTunnelStatusLastErrorMessage=usdL2fTunnelStatusLastErrorMessage, usdL2fTunnelStatPaySendOctets=usdL2fTunnelStatPaySendOctets, usdL2fMapTifSidToSifTunnelIfIndex=usdL2fMapTifSidToSifTunnelIfIndex, usdL2fDestConfigRowStatus=usdL2fDestConfigRowStatus, usdL2fDestination=usdL2fDestination, usdL2fTunnelStatusRemoteHostName=usdL2fTunnelStatusRemoteHostName, usdL2fSysConfigDestructTimeout=usdL2fSysConfigDestructTimeout, usdL2fSessionStatRecvOutOfSequence=usdL2fSessionStatRecvOutOfSequence, usdL2fSysConfigAdminState=usdL2fSysConfigAdminState, usdL2fDestStatusEffectiveAdminState=usdL2fDestStatusEffectiveAdminState, usdL2fTunnelStatusState=usdL2fTunnelStatusState, usdL2fTunnelStatIfIndex=usdL2fTunnelStatIfIndex, usdL2fDestStatusTransport=usdL2fDestStatusTransport, usdL2fTunnelConfig=usdL2fTunnelConfig, usdL2fDestStatPaySendDiscards=usdL2fDestStatPaySendDiscards, usdL2fDestStatusActiveTunnels=usdL2fDestStatusActiveTunnels, usdL2fSysStatusFailedTunnelAuthens=usdL2fSysStatusFailedTunnelAuthens, usdL2fDestStatusTotalSessions=usdL2fDestStatusTotalSessions, usdL2fDestStatCtlSendDiscards=usdL2fDestStatCtlSendDiscards, usdL2fSessionConfigTable=usdL2fSessionConfigTable, usdL2fSessionStatPaySendErrors=usdL2fSessionStatPaySendErrors, usdL2fSessionStatPayLostPackets=usdL2fSessionStatPayLostPackets, usdL2fSysStatusFailedSessions=usdL2fSysStatusFailedSessions, usdL2fSessionStatPaySendPackets=usdL2fSessionStatPaySendPackets, usdL2fTunnelStatCtlRecvPackets=usdL2fTunnelStatCtlRecvPackets, usdL2fDestStatistics=usdL2fDestStatistics, usdL2fTunnelStatPayRecvOctets=usdL2fTunnelStatPayRecvOctets, usdL2fSysStatusActiveTunnels=usdL2fSysStatusActiveTunnels, usdL2fSessionStatusIfIndex=usdL2fSessionStatusIfIndex, usdL2fUdpIpTunnelRouterIndex=usdL2fUdpIpTunnelRouterIndex, usdL2fSysStatusActiveSessions=usdL2fSysStatusActiveSessions, usdL2fUdpIpTunnelRemotePort=usdL2fUdpIpTunnelRemotePort, usdL2fDestStatusFailedTunnels=usdL2fDestStatusFailedTunnels, usdL2fUdpIpTunnelLocalPort=usdL2fUdpIpTunnelLocalPort, usdL2fUdpIpDestination=usdL2fUdpIpDestination, usdL2fConfigGroup=usdL2fConfigGroup, usdL2fTunnelStatEntry=usdL2fTunnelStatEntry, usdL2fSessionConfigIfIndex=usdL2fSessionConfigIfIndex, usdL2fMapTidToTifIfIndex=usdL2fMapTidToTifIfIndex, usdL2fTunnelConfigIfIndex=usdL2fTunnelConfigIfIndex, usdL2fTunnelStatusLocalTunnelId=usdL2fTunnelStatusLocalTunnelId, usdL2fDestStatPayRecvOctets=usdL2fDestStatPayRecvOctets, usdL2fTunnelStatCtlSendDiscards=usdL2fTunnelStatCtlSendDiscards, usdL2fSysConfigReceiveDataSequencingIgnore=usdL2fSysConfigReceiveDataSequencingIgnore, usdL2fSessionStatusEffectiveAdminState=usdL2fSessionStatusEffectiveAdminState, usdL2fUdpIpTunnelTable=usdL2fUdpIpTunnelTable, usdL2fSessionStatTable=usdL2fSessionStatTable, usdL2fSessionStatPayRecvOctets=usdL2fSessionStatPayRecvOctets, usdL2fSysStatusTotalSessions=usdL2fSysStatusTotalSessions, usdL2fUdpIpTunnelIfIndex=usdL2fUdpIpTunnelIfIndex, usdL2fTunnelStatCtlRecvOctets=usdL2fTunnelStatCtlRecvOctets, usdL2fSessionStatusAuthMethod=usdL2fSessionStatusAuthMethod, usdL2fSessionStatEntry=usdL2fSessionStatEntry, usdL2fMapGroup=usdL2fMapGroup, usdL2fTunnelConfigAdminState=usdL2fTunnelConfigAdminState, usdL2fTunnelStatusInitiated=usdL2fTunnelStatusInitiated, usdL2fSysConfigIpChecksumEnable=usdL2fSysConfigIpChecksumEnable)
|
# -*- coding: utf-8 -*-
# Docstring
"""Run the Full create_MW_potential_2014 set of scripts."""
__author__ = "Nathaniel Starkman"
__all__ = [
"main",
]
###############################################################################
# IMPORTS
###############################################################################
# END
|
enu = 3
zenn = 0
for ai in range(enu, -1, -1):
zenn += ai*ai*ai
print(zenn)
|
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
File for Message object and associated functions.
The Message object's key function is to prevent users from editing fields in an action
or observation dict unintentionally.
"""
class Message(dict):
"""
Class for observations and actions in ParlAI.
Functions like a dict, but triggers a RuntimeError when calling __setitem__ for a
key that already exists in the dict.
"""
def __setitem__(self, key, val):
if key in self:
raise RuntimeError(
'Message already contains key `{}`. If this was intentional, '
'please use the function `force_set(key, value)`.'.format(key)
)
super().__setitem__(key, val)
def force_set(self, key, val):
super().__setitem__(key, val)
def copy(self):
return Message(self)
|
deck = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']
value = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
deck_values = dict(zip(deck, value))
hand = [input() for _ in range(6)]
hand_values = [deck_values.get(card) for card in hand]
print(sum(hand_values) / 6)
|
def validate(opciones, eleccion): #recibe las opciones en una lista y lo que introdujo el usuario
# Definir validación de eleccion
##########################################################################
#pass
while eleccion not in opciones: #mientras la eleccion no este en la lista de opciones
eleccion = input('Opcion inválida. Ingrese una de las opciones válidas: ')
return eleccion #si se ingresa una opcion valida se retorna el valor de la eleccion válida
##########################################################################
return eleccion
if __name__ == '__main__':
eleccion = input('Ingresa una Opción: ').lower()
# letras = ['a','b','c','d'] # pueden probar con letras también para verificar su funcionamiento.
numeros = ['0','1']
# Si se ingresan valores no validos a eleccion debe seguir preguntando
validate(numeros, eleccion)
|
"""Codon to amino acid dictionary"""
codon_to_aa = {
"TTT": "F",
"TTC": "F",
"TTA": "L",
"TTG": "L",
"TCT": "S",
"TCC": "S",
"TCA": "S",
"TCG": "S",
"TAT": "Y",
"TAC": "Y",
"TAA": "*",
"TAG": "*",
"TGT": "C",
"TGC": "C",
"TGA": "*",
"TGG": "W",
"CTT": "L",
"CTC": "L",
"CTA": "L",
"CTG": "L",
"CCT": "P",
"CCC": "P",
"CCA": "P",
"CCG": "P",
"CAT": "H",
"CAC": "H",
"CAA": "Q",
"CAG": "Q",
"CGT": "R",
"CGC": "R",
"CGA": "R",
"CGG": "R",
"ATT": "I",
"ATC": "I",
"ATA": "I",
"ATG": "M",
"ACT": "T",
"ACC": "T",
"ACA": "T",
"ACG": "T",
"AAT": "N",
"AAC": "N",
"AAA": "K",
"AAG": "K",
"AGT": "S",
"AGC": "S",
"AGA": "R",
"AGG": "R",
"GTT": "V",
"GTC": "V",
"GTA": "V",
"GTG": "V",
"GCT": "A",
"GCC": "A",
"GCA": "A",
"GCG": "A",
"GAT": "D",
"GAC": "D",
"GAA": "E",
"GAG": "E",
"GGT": "G",
"GGC": "G",
"GGA": "G",
"GGG": "G",
}
"""Amino acid to codon dictionary, using extended nucleotide letters"""
aa_to_codon_extended = {
"A": ["GCX"],
"B": ["RAY"],
"C": ["TGY"],
"D": ["GAY"],
"E": ["GAR"],
"F": ["TTY"],
"G": ["GGX"],
"H": ["CAY"],
"I": ["ATH"],
# 'J': ['-'],
"K": ["AAR"],
"L": ["TTR", "CTX", "YTR"],
"M": ["ATG"],
"N": ["AAY"],
# 'O': ['-'],
"P": ["CCX"],
"Q": ["CAR"],
"R": ["CGX", "AGR", "MGR"],
"S": ["TCX", "AGY"],
"T": ["ACX"],
# "U": ["-"],
"V": ["GTX"],
"W": ["TGG"],
"X": ["XXX"],
"Y": ["TAY"],
"Z": ["SAR"],
".": ["-"], # no amino acid (deletion or gap)
"*": ["TAR", "TRA"], # STOP codons
}
"""Codon to amino acid dictionary, using extended nucleotide letters"""
codon_extended_to_aa = {
"GCX": "A",
"RAY": "B",
"TGY": "C",
"GAY": "D",
"GAR": "E",
"TTY": "F",
"GGX": "G",
"CAY": "H",
"ATH": "I",
# "-": "J",
"AAR": "K",
"TTR": "L",
"CTX": "L",
"YTR": "L",
"ATG": "M",
"AAY": "N",
# "-": "O",
"CCX": "P",
"CAR": "Q",
"CGX": "R",
"AGR": "R",
"MGR": "R",
"TCX": "S",
"AGY": "S",
"ACX": "T",
# "-": "U",
"GTX": "V",
"TGG": "W",
"XXX": "X",
"TAY": "Y",
"SAR": "Z",
# "-": ".", # no amino acid (deletion or gap)
"TAR": "*", # STOP codon
"TRA": "*", # STOP codon
}
"""Extended nucleotide letter to nucleotide letter dictionary"""
ambiguity_code_to_nt_set = {
"A": {"A"},
"G": {"G"},
"C": {"C"},
"T": {"T"},
"Y": {"C", "T"},
"R": {"A", "G"},
"W": {"A", "T"},
"S": {"G", "C"},
"K": {"T", "G"},
"M": {"C", "A"},
"D": {"A", "G", "T"},
"V": {"A", "C", "G"},
"H": {"A", "C", "T"},
"B": {"C", "G", "T"},
"X": {"A", "C", "G", "T"},
"N": {"A", "C", "G", "T"},
}
"""Extended nucleotide letter to complement letter dictionary"""
complement_table = {
"A": "T",
"G": "C",
"C": "G",
"T": "A",
"Y": "R",
"R": "Y",
"W": "W",
"S": "S",
"K": "M",
"M": "K",
"D": "H",
"V": "B",
"H": "D",
"B": "V",
"X": "X",
"N": "N",
}
allowed_aa_transitions = {
"A": ["G", "A", "V", "L", "I"],
"B": ["D", "E", "N", "Q", "B", "Z"],
"C": ["S", "C", "M", "T"],
"D": ["D", "E", "N", "Q", "B", "Z"],
"E": ["D", "E", "N", "Q", "B", "Z"],
"F": ["F", "Y", "W"],
"G": ["G", "A", "V", "L", "I"],
"H": ["H", "K", "R"],
"I": ["G", "A", "V", "L", "I"],
# 'J': ['J'],
"K": ["H", "K", "R"],
"L": ["G", "A", "V", "L", "I"],
"M": ["S", "C", "M", "T"],
"N": ["D", "E", "N", "Q", "B", "Z"],
# 'O': ['O'],
"P": ["P"],
"Q": ["D", "E", "N", "Q", "B", "Z"],
"R": ["H", "K", "R"],
"S": ["S", "C", "M", "T"],
"T": ["S", "C", "M", "T"],
# "U": ['S', 'C', 'U', 'M', 'T'],
"V": ["G", "A", "V", "L", "I"],
"W": ["F", "Y", "W"],
"X": ["X"],
"Y": ["F", "Y", "W"],
"Z": ["D", "E", "N", "Q", "B", "Z"],
".": ["."],
"*": ["*"],
}
def make_transition_dictionary(aa_to_codon_extended, allowed_aa_transitions):
transition_dictionary = {}
for aa, aa_list in allowed_aa_transitions.items():
codons = []
for aa_element in aa_list:
triplets_to_add = aa_to_codon_extended[aa_element]
codons = codons + triplets_to_add
transition_dictionary[aa] = codons
return transition_dictionary
# TODO rename aa_to_codon_extended --> transition_dictionary and references elsewhere
def generate_swaptable(codon_to_aa, aa_to_codon_extended):
"""Generate a codon to extended codon dictionary"""
codon_to_codon_extended = dict()
for k, v in codon_to_aa.items():
codon_to_codon_extended[k] = tuple(aa_to_codon_extended[v])
return codon_to_codon_extended
def compare_letters(letter1, letter2, table=ambiguity_code_to_nt_set):
"""Compare two extended nucleotide letters and return True if they match"""
set1 = table[letter1]
set2 = table[letter2]
if set1 & set2 != set():
is_match = True
else:
is_match = False
return is_match
|
# -*- coding: utf-8 -*-
class RedirectError(Exception):
def __init__(self, response):
self.response = response
class NotLoggedInError(Exception):
pass
class SessionNotFreshError(Exception):
pass |
class Cell(object):
def __init__(self):
self.neighbours = [None for _ in range(8)]
self.current_state = False
self.next_state = False
self.fixed = False
def count_neighbours(self) -> int:
count = 0
for n in self.neighbours:
if n.current_state:
count += 1
return count
def ready_change(self):
if self.fixed:
self.next_state = True
else:
count = self.count_neighbours()
if self.current_state:
self.next_state = count in [2, 3]
else:
self.next_state = count == 3
def switch(self):
self.current_state = self.next_state
def __str__(self):
return '#' if self.current_state else '.'
class Life(object):
def __init__(self, initial_grid):
self.grid = [[Cell() for _ in range(100)] for _ in range(100)]
self.setup_grid(initial_grid)
def setup_grid(self, initial_grid, fixed_corners=False):
for row, line in enumerate(self.grid):
for col, cell in enumerate(line):
if fixed_corners and (col == 0 or col == 99) and (row == 0 or row == 99):
cell.current_state = True
cell.fixed = True
cell.neighbours = []
else:
cell.current_state = initial_grid[row][col] == '#'
cell.neighbours = [self.grid[r][c] for r, c in self.neighbours(row, col)]
def neighbours(self, row, col):
for n_r, n_c in [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]:
pos = row + n_r, col + n_c
if 0 <= pos[0] < 100 and 0 <= pos[1] < 100:
yield pos
def on_lamps(self):
return sum(1 for line in self.grid for cell in line if cell.current_state)
def generation(self):
for line in self.grid:
for cell in line:
cell.ready_change()
for line in self.grid:
for cell in line:
cell.switch()
def print_grid(self):
for line in self.grid:
for cell in line:
print(cell, end='')
print()
if __name__ == '__main__':
with open('input') as f:
initial_grid = f.read().splitlines(keepends=False)
life = Life(initial_grid)
for _ in range(100):
life.generation()
life.print_grid()
print(f'Part 1: {life.on_lamps()}')
# Part 1: 814
life.setup_grid(initial_grid, fixed_corners=True)
for _ in range(100):
life.generation()
life.print_grid()
print(f'Part 2: {life.on_lamps()}')
# Part 2: 924
|
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: aghast_generated
class DimensionOrder(object):
c_order = 0
fortran_order = 1
|
def specialPolynomial(x, n):
s = 1
k = 0
while s <= n:
k += 1
s += x**k
return k-1
if __name__ == '__main__':
input0 = [2, 10, 1, 3]
input1 = [5, 111111110, 100, 140]
expectedOutput = [1, 7, 99, 4]
assert len(input0) == len(expectedOutput), '# input0 = {}, # expectedOutput = {}'.format(len(input0), len(expectedOutput))
assert len(input1) == len(expectedOutput), '# input1 = {}, # expectedOutput = {}'.format(len(input1), len(expectedOutput))
for i, expected in enumerate(expectedOutput):
actual = specialPolynomial(input0[i], input1[i])
assert actual == expected, 'specialPolynomial({}, {}) returned {}, but expected {}'.format(input0[i], input1[i], actual, expected)
print('PASSES {} out of {} tests'.format(len(expectedOutput), len(expectedOutput))) |
class TermGroupScope:
"""Specifies the values different group types can take within the termStore."""
global_ = 0
system = 1
siteCollection = 2
unknownFutureValue = 3
|
arphabet_to_ipa = {
'aa': 'ɑ',
'ae': 'æ',
'ah':'ʌ',
'ao':'ɔ',
'aw':'W',
'ax':'ə',
'axr':'ɚ',
'ay':'Y',
'eh':'ɛ',
'er':'ɝ',
'ey':'e',
'ih':'ɪ',
'ix':'ɨ',
'iy':'i',
'ow':'o',
'oy':'O',
'uh':'ʊ',
'uw':'u',
'ux':'ʉ',
'b':'b',
'ch':'C',
'd':'d',
'dh':'ð',
'dx':'ɾ',
'el':'l̩',
'em':'m̩',
'en':'n̩',
'f':'f',
'g':'g',
'hh':'h',
'h':'h',
'jh':'J',
'k':'k',
'l':'l',
'm':'m',
'n':'n',
'ng':'ŋ',
'nx':'ɾ̃',
'p':'p',
'q':'ʔ',
'r':'ɹ',
's':'s',
'sh':'ʃ',
't':'t',
'th':'θ',
'v':'v',
'w':'w',
'wh':'ʍ',
'y':'j',
'z':'z',
'zh':'ʒ',
'ax-h':'ə̥',
'bcl':'b̚',
'dcl':'d̚',
'eng':'ŋ̍',
'gcl':'ɡ̚',
'hv':'ɦ',
'kcl':'k̚',
'pcl':'p̚',
'tcl':'t̚',
'epi':'S',
'pau':'P',
}
|
def render_q(world, q_learner):
qvalues_list = []
for h in range(world.height):
row = []
qvalues_row = []
for w in range(world.width):
loc = torch.LongTensor([h, w])
c = world.get_at(loc)
# print('c', c)
if c == '' or c == 'A':
world.set_agent_loc(loc)
s = world.get_state()
s = s.view(1, *s.size())
qvalues = q_learner(Variable(s))
# print('qvalues', qvalues)
qvalue, a = qvalues.data.max(1)
qvalue = qvalue[0]
qvalues_row.append(qvalue)
a = a[0]
# print('a', a)
act, direction = world.render_action(a)
# print(act, dir)
if act == 'M':
row.append(direction)
elif act == 'C':
row.append('c')
elif act == 'E':
row.append('e')
else:
row.append(c)
qvalues_row.append(0)
print(''.join(row))
qvalues_list.append(qvalues_row)
print('')
for row in qvalues_list:
print(' '.join(['%.2f' % q for q in row]))
def render_policy(world, state_features, policy):
for h in range(world.height):
row = []
for w in range(world.width):
loc = torch.LongTensor([h, w])
c = world.get_at(loc)
if c == '' or c == 'A':
world.set_agent_loc(loc)
s = world.get_state()
s = s.view(1, *s.size())
global_idxes = torch.LongTensor([[0]])
phi = state_features(Variable(s))
action_probs_l, elig_idxes_pairs, actions, entropy, (matches_argmax_count, stochastic_draws_count) = policy(
phi, global_idxes=global_idxes)
# print('actions[0]', actions[0])
# asdf
a = actions[0][0]
act, direction = world.render_action(a)
if act == 'M':
row.append(direction)
elif act == 'C':
row.append('c')
elif act == 'E':
row.append('e')
else:
row.append(c)
print(''.join(row))
def render_v(value_png, world, state_features, value_function):
"""
assumptions on world. has following properties:
- height
- width
- locs (location of various objects, like food)
- reps
and methods:
- get_at(loc)
- set_agent_loc(loc)
- get_state()
- render()
state_features is a net, that takes a world state, and generates features
value_function takes state_features, and outputs a value
value_png is path to generated png file
"""
v_matrix = torch.FloatTensor(world.height, world.width).fill_(0)
for h in range(world.height):
row = []
for w in range(world.width):
loc = torch.LongTensor([h, w])
c = world.get_at(loc)
if c == '' or c == 'A':
world.set_agent_loc(loc)
s = world.get_state()
s = s.view(1, *s.size())
phi = state_features(Variable(s))
v = value_function(phi).data[0][0]
v_matrix[h, w] = v
row.append('%.3f' % v)
else:
row.append(c)
print(' '.join(row))
# values_list.append(values_row)
print('')
world.render()
print('v_matrix', v_matrix)
plt.clf()
plt.imshow(v_matrix.numpy(), interpolation='nearest')
for loc in world.locs:
_loc = loc['loc']
p = loc['p']
plt.text(_loc[1], _loc[0], '[%s:%s]' % (p, world.reps[p]))
plt.colorbar()
plt.savefig(value_png)
# for row in values_list:
# print(' '.join(['%.2f' % q for q in row]))
|
__all__ = [
"deployment_pb2",
"repository_pb2",
"status_pb2",
"yatai_service_pb2_grpc",
"yatai_service_pb2",
]
|
class UnresolvedChild(Exception):
"""
Exception raised when children should be lazyloaded first
"""
pass
class TimeConstraintError(Exception):
"""
Exception raised when it is not possble to satisfy timing constraints
"""
pass
|
def solve():
N = int(input())
V = list(map(int, input().split()))
V1 = sorted(V[::2])
V2 = sorted(V[1::2])
flag = -1
for i in range(1, N):
i_ = i // 2
# if i&1: print('Check {} {}'.format(V1[i_], V2[i_]))
# if i&1==0: print('Check {} {}'.format(V2[i_-1], V1[i_]))
if i&1 and V1[i_] > V2[i_] or i&1==0 and V2[i_-1] > V1[i_]: # odd
flag = i - 1
break
print('OK') if flag == -1 else print(flag)
if __name__ == '__main__':
T = int(input())
for t in range(T):
print('Case #{}: '.format(t+1), end='')
solve() |
"""
This file contains mappings:
parameters_names_mapping - Mapping of Tcl/Tk command attributes
to methods of Qt/own objects.
Own objects are included because
of implementation details such as
menu problem (see description of
Implementer file.
parameters_values_mapping - Mapping of Tcl/Tk attributes values
to valid values for parameters of
methods got from parameters_names_mapping.
Mappigs are obtained with get_parameters_names_mapping and
get_parameters_values_mapping functions respectively with
private _get_mapping function.
Mappings are used by tktoqt file.
Note that this could be heavily extended - TODO.
Note that this might get changed when problem with step 5) from Implementer
will be solved - TODO.
"""
parameters_names_mapping = {
"all": {
'-text': 'setText',
'-fg': 'setStyleSheet',
'-padx': 'setStyleSheet',
'-pady': 'setStyleSheet',
# TODO Margins and so on.
},
"QPushButton": {
'-command': 'clicked.connect',
},
"QWidget": {
'-width': 'setMinimumWidth',
'-height': 'setMinimumHeight',
'-background': 'setStyleSheet',
},
"QGridBox": {
'-text': 'setTitle',
'-relief': 'setStyleSheet',
},
"QMenu": {
# TODO Remove if combinations working.
'-label': 'addAction',
# TODO Remove if combinations working.
'-command': 'triggered[QAction].connect',
'-menu': 'addMenu',
},
"QListWidget": {
'-insert': 'addItem',
},
"QGroupBox": {
'-text': 'setTitle',
},
"QLabel": {
'-text': 'setText',
},
"QSpinBox": {
'-from': 'setMinimum',
'-to': 'setMaximum',
},
"QRadioButton": {
# TODO finish StringVar '-variable': 'setText',
'-command': 'toggled.connect'
},
"QComboBox": {
'-values': 'addItems',
# TODO finish StringVar'-textvariable': 'setText',
},
"QPixmap": {
'-file': 'load',
# TODO finish StringVar'-textvariable': 'setText',
},
"Menu": { # TODO: Might change name
'-menu': 'add_menu', # My own function
'-label': 'remember_label',
},
"Implementer": { # TODO: Might change name
'-menu': 'create_menu', # My own function
},
}
def get_parameters_names_mapping(class_name):
# TODO Docs.
return _get_mapping(class_name, parameters_names_mapping)
parameters_values_mapping = {
"all": {
'-padx': 'padding: {} px;',
# TODO Difference between horizontal and vertical padding? ...
'-pady': 'padding: {} px;',
'-fg': 'color: {} ;',
},
"QWidget": {
'-background': 'background-color: {} ;',
},
}
def get_parameters_values_mapping(class_name):
# TODO Docs.
return _get_mapping(class_name, parameters_values_mapping)
def _get_mapping(class_name, mapping):
# TODO Docs.
output = mapping["all"].copy()
override_and_extra_parameters = mapping.get(class_name.__name__, {})
for key in override_and_extra_parameters:
output[key] = override_and_extra_parameters[key]
return output
|
def module4():
print(123 == '123') #______
print(123 == int('123')) #______
print('ABC' == 'abc') #______
print(True == 1) #______
print(False == "") #______
print(False == bool("")) #______ |
def target(x0, sink):
print(f'input: {x0}')
while True:
task = yield
x0 = task(x0)
sink.send(x0)
def sink():
try:
while True:
x = yield
except GeneratorExit:
print(f'final output: {x}')
|
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head:
return None
fake_head = ListNode(None)
fake_head.next = head
last_node = fake_head
curr_node = fake_head.next
duplicate_val = None
while curr_node:
if curr_node and curr_node.next and curr_node.val == curr_node.next.val:
# Update deplicate_val
duplicate_val = curr_node.val
if curr_node.val == duplicate_val:
last_node.next = curr_node.next
curr_node = curr_node.next
else:
last_node = curr_node
curr_node = curr_node.next
return fake_head.next |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.