code
stringlengths
9
256k
<s> """<STR_LIT>""" <EOL> from nuitka . Builtins import calledWithBuiltinArgumentNamesDecorator <EOL> from . NodeBases import ( <EOL> ExpressionChildrenHavingBase , <EOL> StatementChildrenHavingBase <EOL> ) <EOL> class StatementListOperationAppend ( StatementChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT:list>" , <EOL> "<STR_LIT:value>" <EOL> ) <EOL> @ calledWithBuiltinArgumentNamesDecorator <EOL> def __init__ ( self , list_arg , value , source_ref ) : <EOL> assert list_arg is not None <EOL> assert value is not None <EOL> StatementChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT:list>" : list_arg , <EOL> "<STR_LIT:value>" : value <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getList = StatementChildrenHavingBase . childGetter ( "<STR_LIT:list>" ) <EOL> getValue = StatementChildrenHavingBase . childGetter ( "<STR_LIT:value>" ) <EOL> def computeStatement ( self , constraint_collection ) : <EOL> result , change_tags , change_desc = self . computeStatementSubExpressions ( <EOL> constraint_collection = constraint_collection <EOL> ) <EOL> if result is not self : <EOL> return result , change_tags , change_desc <EOL> constraint_collection . removeKnowledge ( self . getList ( ) ) <EOL> return self , None , None <EOL> class ExpressionListOperationExtend ( ExpressionChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT:list>" , <EOL> "<STR_LIT:value>" <EOL> ) <EOL> @ calledWithBuiltinArgumentNamesDecorator <EOL> def __init__ ( self , list_arg , value , source_ref ) : <EOL> assert list_arg is not None <EOL> assert value is not None <EOL> ExpressionChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT:list>" : list_arg , <EOL> "<STR_LIT:value>" : value <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getList = ExpressionChildrenHavingBase . childGetter ( "<STR_LIT:list>" ) <EOL> getValue = ExpressionChildrenHavingBase . childGetter ( "<STR_LIT:value>" ) <EOL> def computeExpression ( self , constraint_collection ) : <EOL> constraint_collection . removeKnowledge ( self . getList ( ) ) <EOL> return self , None , None <EOL> class ExpressionListOperationPop ( ExpressionChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT:list>" , <EOL> ) <EOL> @ calledWithBuiltinArgumentNamesDecorator <EOL> def __init__ ( self , list_arg , source_ref ) : <EOL> assert list_arg is not None <EOL> ExpressionChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT:list>" : list_arg , <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getList = ExpressionChildrenHavingBase . childGetter ( "<STR_LIT:list>" ) <EOL> def computeExpression ( self , constraint_collection ) : <EOL> constraint_collection . removeKnowledge ( self . getList ( ) ) <EOL> return self , None , None <EOL> class StatementSetOperationAdd ( StatementChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:value>" <EOL> ) <EOL> @ calledWithBuiltinArgumentNamesDecorator <EOL> def __init__ ( self , set_arg , value , source_ref ) : <EOL> assert set_arg is not None <EOL> assert value is not None <EOL> StatementChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : set_arg , <EOL> "<STR_LIT:value>" : value <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getSet = StatementChildrenHavingBase . childGetter ( <EOL> "<STR_LIT>" <EOL> ) <EOL> getValue = StatementChildrenHavingBase . childGetter ( <EOL> "<STR_LIT:value>" <EOL> ) <EOL> def computeStatement ( self , constraint_collection ) : <EOL> result , change_tags , change_desc = self . computeStatementSubExpressions ( <EOL> constraint_collection = constraint_collection <EOL> ) <EOL> if result is not self : <EOL> return result , change_tags , change_desc <EOL> constraint_collection . removeKnowledge ( self . getSet ( ) ) <EOL> return self , None , None <EOL> class ExpressionSetOperationUpdate ( ExpressionChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:value>" <EOL> ) <EOL> @ calledWithBuiltinArgumentNamesDecorator <EOL> def __init__ ( self , set_arg , value , source_ref ) : <EOL> assert set_arg is not None <EOL> assert value is not None <EOL> ExpressionChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : set_arg , <EOL> "<STR_LIT:value>" : value <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getSet = ExpressionChildrenHavingBase . childGetter ( <EOL> "<STR_LIT>" <EOL> ) <EOL> getValue = ExpressionChildrenHavingBase . childGetter ( <EOL> "<STR_LIT:value>" <EOL> ) <EOL> def computeExpression ( self , constraint_collection ) : <EOL> constraint_collection . removeKnowledge ( self . getSet ( ) ) <EOL> return self , None , None </s>
<s> """<STR_LIT>""" <EOL> from . NodeBases import ExpressionChildrenHavingBase <EOL> class ExpressionYield ( ExpressionChildrenHavingBase ) : <EOL> """<STR_LIT>""" <EOL> kind = "<STR_LIT>" <EOL> named_children = ( "<STR_LIT>" , ) <EOL> def __init__ ( self , expression , source_ref ) : <EOL> ExpressionChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : expression <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> self . exception_preserving = False <EOL> def markAsExceptionPreserving ( self ) : <EOL> self . exception_preserving = True <EOL> def isExceptionPreserving ( self ) : <EOL> return self . exception_preserving <EOL> getExpression = ExpressionChildrenHavingBase . childGetter ( "<STR_LIT>" ) <EOL> def computeExpression ( self , constraint_collection ) : <EOL> constraint_collection . removeKnowledge ( self . getExpression ( ) ) <EOL> constraint_collection . onControlFlowEscape ( self ) <EOL> constraint_collection . onExceptionRaiseExit ( BaseException ) <EOL> return self , None , None <EOL> class ExpressionYieldFrom ( ExpressionChildrenHavingBase ) : <EOL> """<STR_LIT>""" <EOL> kind = "<STR_LIT>" <EOL> named_children = ( "<STR_LIT>" , ) <EOL> def __init__ ( self , expression , source_ref ) : <EOL> ExpressionChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : expression <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> self . exception_preserving = False <EOL> def markAsExceptionPreserving ( self ) : <EOL> self . exception_preserving = True <EOL> def isExceptionPreserving ( self ) : <EOL> return self . exception_preserving <EOL> getExpression = ExpressionChildrenHavingBase . childGetter ( "<STR_LIT>" ) <EOL> def computeExpression ( self , constraint_collection ) : <EOL> constraint_collection . removeKnowledge ( self . getExpression ( ) ) <EOL> constraint_collection . onControlFlowEscape ( self ) <EOL> constraint_collection . onExceptionRaiseExit ( BaseException ) <EOL> return self , None , None </s>
<s> """<STR_LIT>""" <EOL> from nuitka . nodes . AssignNodes import ( <EOL> ExpressionTargetTempVariableRef , <EOL> ExpressionTempVariableRef , <EOL> StatementAssignmentVariable <EOL> ) <EOL> from nuitka . nodes . CallNodes import makeExpressionCall <EOL> from nuitka . nodes . ConstantRefNodes import ExpressionConstantRef <EOL> from nuitka . nodes . ContainerMakingNodes import ExpressionMakeTuple <EOL> from nuitka . nodes . FunctionNodes import ( <EOL> ExpressionFunctionCall , <EOL> ExpressionFunctionCreation , <EOL> ExpressionFunctionRef <EOL> ) <EOL> from nuitka . nodes . OutlineNodes import ExpressionOutlineBody <EOL> from nuitka . nodes . ReturnNodes import StatementReturn <EOL> from nuitka . PythonVersions import python_version <EOL> from . ComplexCallHelperFunctions import ( <EOL> getFunctionCallHelperDictionaryUnpacking , <EOL> getFunctionCallHelperKeywordsStarDict , <EOL> getFunctionCallHelperKeywordsStarList , <EOL> getFunctionCallHelperKeywordsStarListStarDict , <EOL> getFunctionCallHelperPosKeywordsStarDict , <EOL> getFunctionCallHelperPosKeywordsStarList , <EOL> getFunctionCallHelperPosKeywordsStarListStarDict , <EOL> getFunctionCallHelperPosStarDict , <EOL> getFunctionCallHelperPosStarList , <EOL> getFunctionCallHelperPosStarListStarDict , <EOL> getFunctionCallHelperStarDict , <EOL> getFunctionCallHelperStarList , <EOL> getFunctionCallHelperStarListStarDict <EOL> ) <EOL> from . Helpers import ( <EOL> buildNode , <EOL> buildNodeList , <EOL> getKind , <EOL> makeDictCreationOrConstant , <EOL> makeSequenceCreationOrConstant , <EOL> makeStatementsSequenceFromStatements <EOL> ) <EOL> from . ReformulationDictionaryCreation import buildDictionaryUnpackingArgs <EOL> from . ReformulationSequenceCreation import buildListUnpacking <EOL> def buildCallNode ( provider , node , source_ref ) : <EOL> called = buildNode ( provider , node . func , source_ref ) <EOL> if python_version >= <NUM_LIT> : <EOL> list_star_arg = None <EOL> dict_star_arg = None <EOL> positional_args = [ ] <EOL> for node_arg in node . args [ : - <NUM_LIT:1> ] : <EOL> if getKind ( node_arg ) == "<STR_LIT>" : <EOL> assert python_version >= <NUM_LIT> <EOL> list_star_arg = buildListUnpacking ( provider , node . args , source_ref ) <EOL> positional_args = [ ] <EOL> break <EOL> else : <EOL> if node . args and getKind ( node . args [ - <NUM_LIT:1> ] ) == "<STR_LIT>" : <EOL> assert python_version >= <NUM_LIT> <EOL> list_star_arg = buildNode ( provider , node . args [ - <NUM_LIT:1> ] . value , source_ref ) <EOL> positional_args = buildNodeList ( provider , node . args [ : - <NUM_LIT:1> ] , source_ref ) <EOL> else : <EOL> positional_args = buildNodeList ( provider , node . args , source_ref ) <EOL> keys = [ ] <EOL> values = [ ] <EOL> for keyword in node . keywords [ : - <NUM_LIT:1> ] : <EOL> if keyword . arg is None : <EOL> assert python_version >= <NUM_LIT> <EOL> outline_body = ExpressionOutlineBody ( <EOL> provider = provider , <EOL> name = "<STR_LIT>" , <EOL> source_ref = source_ref <EOL> ) <EOL> tmp_called = outline_body . allocateTempVariable ( <EOL> temp_scope = None , <EOL> name = "<STR_LIT>" <EOL> ) <EOL> helper_args = [ <EOL> ExpressionTempVariableRef ( <EOL> variable = tmp_called , <EOL> source_ref = source_ref <EOL> ) , <EOL> ExpressionMakeTuple ( <EOL> elements = buildDictionaryUnpackingArgs ( <EOL> provider = provider , <EOL> keys = ( keyword . arg for keyword in node . keywords ) , <EOL> values = ( keyword . value for keyword in node . keywords ) , <EOL> source_ref = source_ref <EOL> ) , <EOL> source_ref = source_ref <EOL> ) <EOL> ] <EOL> dict_star_arg = ExpressionFunctionCall ( <EOL> function = ExpressionFunctionCreation ( <EOL> function_ref = ExpressionFunctionRef ( <EOL> function_body = getFunctionCallHelperDictionaryUnpacking ( ) , <EOL> source_ref = source_ref <EOL> ) , <EOL> code_object = None , <EOL> defaults = ( ) , <EOL> kw_defaults = None , <EOL> annotations = None , <EOL> source_ref = source_ref <EOL> ) , <EOL> values = helper_args , <EOL> source_ref = source_ref , <EOL> ) <EOL> outline_body . setBody ( <EOL> makeStatementsSequenceFromStatements ( <EOL> StatementAssignmentVariable ( <EOL> variable_ref = ExpressionTargetTempVariableRef ( <EOL> variable = tmp_called , <EOL> source_ref = source_ref <EOL> ) , <EOL> source = called , <EOL> source_ref = source_ref <EOL> ) , <EOL> StatementReturn ( <EOL> expression = _makeCallNode ( <EOL> called = ExpressionTempVariableRef ( <EOL> variable = tmp_called , <EOL> source_ref = source_ref <EOL> ) , <EOL> positional_args = positional_args , <EOL> keys = keys , <EOL> values = values , <EOL> list_star_arg = list_star_arg , <EOL> dict_star_arg = dict_star_arg , <EOL> source_ref = source_ref , <EOL> ) , <EOL> source_ref = source_ref <EOL> ) <EOL> ) <EOL> ) <EOL> return outline_body <EOL> if node . keywords and node . keywords [ - <NUM_LIT:1> ] . arg is None : <EOL> assert python_version >= <NUM_LIT> <EOL> dict_star_arg = buildNode ( provider , node . keywords [ - <NUM_LIT:1> ] . value , source_ref ) <EOL> keywords = node . keywords [ : - <NUM_LIT:1> ] <EOL> else : <EOL> keywords = node . keywords <EOL> for keyword in keywords : <EOL> keys . append ( <EOL> ExpressionConstantRef ( <EOL> constant = keyword . arg , <EOL> source_ref = source_ref , <EOL> user_provided = True <EOL> ) <EOL> ) <EOL> values . append ( <EOL> buildNode ( provider , keyword . value , source_ref ) <EOL> ) <EOL> if python_version < <NUM_LIT> : <EOL> list_star_arg = buildNode ( provider , node . starargs , source_ref , True ) <EOL> dict_star_arg = buildNode ( provider , node . kwargs , source_ref , True ) <EOL> return _makeCallNode ( <EOL> called = called , <EOL> positional_args = positional_args , <EOL> keys = keys , <EOL> values = values , <EOL> list_star_arg = list_star_arg , <EOL> dict_star_arg = dict_star_arg , <EOL> source_ref = source_ref , <EOL> ) <EOL> def _makeCallNode ( called , positional_args , keys , values , list_star_arg , <EOL> dict_star_arg , source_ref ) : <EOL> if list_star_arg is None and dict_star_arg is None : <EOL> result = makeExpressionCall ( <EOL> called = called , <EOL> args = makeSequenceCreationOrConstant ( <EOL> sequence_kind = "<STR_LIT>" , <EOL> elements = positional_args , <EOL> source_ref = source_ref <EOL> ) , <EOL> kw = makeDictCreationOrConstant ( <EOL> keys = keys , <EOL> values = values , <EOL> source_ref = source_ref <EOL> ) , <EOL> source_ref = source_ref , <EOL> ) <EOL> if values : <EOL> result . setCompatibleSourceReference ( <EOL> source_ref = values [ - <NUM_LIT:1> ] . getCompatibleSourceReference ( ) <EOL> ) <EOL> elif positional_args : <EOL> result . setCompatibleSourceReference ( <EOL> source_ref = positional_args [ - <NUM_LIT:1> ] . getCompatibleSourceReference ( ) <EOL> ) <EOL> return result <EOL> else : <EOL> key = ( <EOL> len ( positional_args ) > <NUM_LIT:0> , <EOL> len ( keys ) > <NUM_LIT:0> , <EOL> list_star_arg is not None , <EOL> dict_star_arg is not None <EOL> ) <EOL> table = { <EOL> ( True , True , True , False ) : <EOL> getFunctionCallHelperPosKeywordsStarList , <EOL> ( True , False , True , False ) : <EOL> getFunctionCallHelperPosStarList , <EOL> ( False , True , True , False ) : <EOL> getFunctionCallHelperKeywordsStarList , <EOL> ( False , False , True , False ) : <EOL> getFunctionCallHelperStarList , <EOL> ( True , True , False , True ) : <EOL> getFunctionCallHelperPosKeywordsStarDict , <EOL> ( True , False , False , True ) : <EOL> getFunctionCallHelperPosStarDict , <EOL> ( False , True , False , True ) : <EOL> getFunctionCallHelperKeywordsStarDict , <EOL> ( False , False , False , True ) : <EOL> getFunctionCallHelperStarDict , <EOL> ( True , True , True , True ) : <EOL> getFunctionCallHelperPosKeywordsStarListStarDict , <EOL> ( True , False , True , True ) : <EOL> getFunctionCallHelperPosStarListStarDict , <EOL> ( False , True , True , True ) : <EOL> getFunctionCallHelperKeywordsStarListStarDict , <EOL> ( False , False , True , True ) : <EOL> getFunctionCallHelperStarListStarDict , <EOL> } <EOL> get_helper = table [ key ] <EOL> helper_args = [ called ] <EOL> if positional_args : <EOL> helper_args . append ( <EOL> makeSequenceCreationOrConstant ( <EOL> sequence_kind = "<STR_LIT>" , <EOL> elements = positional_args , <EOL> source_ref = source_ref <EOL> ) <EOL> ) <EOL> if python_version >= <NUM_LIT> and list_star_arg is not None : <EOL> helper_args . append ( list_star_arg ) <EOL> if keys : <EOL> helper_args . append ( <EOL> makeDictCreationOrConstant ( <EOL> keys = keys , <EOL> values = values , <EOL> source_ref = source_ref <EOL> ) <EOL> ) <EOL> if python_version < <NUM_LIT> and list_star_arg is not None : <EOL> helper_args . append ( list_star_arg ) <EOL> if dict_star_arg is not None : <EOL> helper_args . append ( dict_star_arg ) <EOL> result = ExpressionFunctionCall ( <EOL> function = ExpressionFunctionCreation ( <EOL> function_ref = ExpressionFunctionRef ( <EOL> function_body = get_helper ( ) , <EOL> source_ref = source_ref <EOL> ) , <EOL> code_object = None , <EOL> defaults = ( ) , <EOL> kw_defaults = None , <EOL> annotations = None , <EOL> source_ref = source_ref <EOL> ) , <EOL> values = helper_args , <EOL> source_ref = source_ref , <EOL> ) <EOL> result . setCompatibleSourceReference ( <EOL> source_ref = helper_args [ - <NUM_LIT:1> ] . getCompatibleSourceReference ( ) <EOL> ) <EOL> return result </s>
<s> import os <EOL> import shutil <EOL> import subprocess <EOL> import sys <EOL> nuitka_version = subprocess . check_output ( <EOL> "<STR_LIT>" , shell = True <EOL> ) . strip ( ) <EOL> branch_name = subprocess . check_output ( <EOL> "<STR_LIT>" . split ( ) <EOL> ) . strip ( ) <EOL> assert branch_name in ( <EOL> b"<STR_LIT>" , <EOL> b"<STR_LIT>" , <EOL> b'<STR_LIT>' , <EOL> b"<STR_LIT>" + nuitka_version , <EOL> b"<STR_LIT>" + nuitka_version <EOL> ) , branch_name <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> assert <NUM_LIT:0> == os . system ( "<STR_LIT>" ) <EOL> assert <NUM_LIT:0> == os . system ( "<STR_LIT>" ) <EOL> if branch_name . startswith ( "<STR_LIT>" ) or branch_name . startswith ( "<STR_LIT>" ) or branch_name == "<STR_LIT>" : <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> os . makedirs ( "<STR_LIT>" ) <EOL> assert <NUM_LIT:0> == os . system ( "<STR_LIT>" % nuitka_version ) <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> elif branch_name == "<STR_LIT>" : <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> os . makedirs ( "<STR_LIT>" ) <EOL> assert <NUM_LIT:0> == os . system ( "<STR_LIT>" % nuitka_version ) <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> elif branch_name == "<STR_LIT>" : <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> os . makedirs ( "<STR_LIT>" ) <EOL> assert <NUM_LIT:0> == os . system ( "<STR_LIT>" % nuitka_version ) <EOL> shutil . rmtree ( "<STR_LIT>" , ignore_errors = True ) <EOL> else : <EOL> sys . exit ( "<STR_LIT>" % branch_name ) </s>
<s> from __future__ import print_function <EOL> def local_function ( a , z = <NUM_LIT:9> ) : <EOL> b = ` a * a + <NUM_LIT:1> ` <EOL> c = ( a , b , a ** <NUM_LIT:32> , a + a ) <EOL> d = long ( '<STR_LIT:0>' ) <EOL> e = int ( "<STR_LIT>" ) <EOL> d = long ( b ) <EOL> e = long ( <NUM_LIT:1> + <NUM_LIT:1> ) <EOL> return a , b , c , d , e , z <EOL> print ( "<STR_LIT>" , local_function ( <NUM_LIT:1> , z = <NUM_LIT:5> ) ) <EOL> print ( "<STR_LIT>" ) <EOL> def nested_args_function ( ( a , b ) , c ) : <EOL> return a , b , c <EOL> print ( nested_args_function ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:3> ) ) <EOL> try : <EOL> nested_args_function ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT:3> ) <EOL> except ValueError , e : <EOL> print ( "<STR_LIT>" , e ) <EOL> try : <EOL> nested_args_function ( ( <NUM_LIT:1> , ) , <NUM_LIT:3> ) <EOL> except ValueError , e : <EOL> print ( "<STR_LIT>" , e ) <EOL> def deeply_nested_function ( ( ( a , ) , b , c , ( d , ( e , f ) ) ) ) : <EOL> return a , b , c , d , e , f <EOL> print ( "<STR_LIT>" , deeply_nested_function ( ( ( <NUM_LIT:1> , ) , <NUM_LIT:2> , <NUM_LIT:3> , ( <NUM_LIT:4> , ( <NUM_LIT:5> , <NUM_LIT:6> ) ) ) ) ) <EOL> print ( "<STR_LIT>" ) <EOL> def default_giver ( ) : <EOL> class R : <EOL> def __iter__ ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> return iter ( range ( <NUM_LIT:2> ) ) <EOL> return R ( ) <EOL> def nested_args_function_with_defaults ( ( a , b ) = default_giver ( ) , c = <NUM_LIT:5> ) : <EOL> return a , b , c <EOL> print ( "<STR_LIT>" ) <EOL> print ( nested_args_function_with_defaults ( ) ) <EOL> def comp_args1 ( ( a , b ) ) : <EOL> return a , b <EOL> def comp_args2 ( ( a , b ) = ( <NUM_LIT:3> , <NUM_LIT:4> ) ) : <EOL> return a , b <EOL> def comp_args3 ( a , ( b , c ) ) : <EOL> return a , b , c <EOL> def comp_args4 ( a = <NUM_LIT:2> , ( b , c ) = ( <NUM_LIT:3> , <NUM_LIT:4> ) ) : <EOL> return a , b , c <EOL> print ( "<STR_LIT>" , comp_args1 ( ( <NUM_LIT:2> , <NUM_LIT:1> ) ) , comp_args2 ( ) , comp_args2 ( ( <NUM_LIT:7> , <NUM_LIT:9> ) ) , comp_args3 ( <NUM_LIT:7> , ( <NUM_LIT:8> , <NUM_LIT:9> ) ) , comp_args4 ( ) ) </s>
<s> import sys , os <EOL> sys . path . insert ( <EOL> <NUM_LIT:0> , <EOL> os . path . normpath ( <EOL> os . path . join ( <EOL> os . path . dirname ( os . path . abspath ( __file__ ) ) , <EOL> "<STR_LIT:..>" <EOL> ) <EOL> ) <EOL> ) <EOL> from test_common import ( <EOL> executeReferenceChecked , <EOL> checkReferenceCount , <EOL> my_print , <EOL> ) <EOL> if not hasattr ( sys , "<STR_LIT>" ) : <EOL> my_print ( "<STR_LIT>" ) <EOL> sys . gettotalrefcount = lambda : <NUM_LIT:0> <EOL> x = <NUM_LIT> <EOL> def simpleFunction1 ( ) : <EOL> try : <EOL> raise TypeError , ( <NUM_LIT:3> , x , x , x ) <EOL> except TypeError : <EOL> pass <EOL> def simpleFunction2 ( ) : <EOL> try : <EOL> raise ValueError ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , ValueError ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> except Exception : <EOL> pass <EOL> def simpleFunction3 ( ) : <EOL> try : <EOL> raise ValueError , <NUM_LIT:2> , None <EOL> except Exception : <EOL> pass <EOL> def simpleFunction4 ( ) : <EOL> try : <EOL> raise ValueError , <NUM_LIT:2> , <NUM_LIT:3> <EOL> except Exception : <EOL> pass <EOL> def simpleFunction5 ( ) : <EOL> def nested_args_function ( ( a , b ) , c ) : <EOL> return a , b , c <EOL> nested_args_function ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:3> ) <EOL> def simpleFunction6 ( ) : <EOL> def nested_args_function ( ( a , b ) , c ) : <EOL> return a , b , c <EOL> try : <EOL> nested_args_function ( ( <NUM_LIT:1> , ) , <NUM_LIT:3> ) <EOL> except ValueError : <EOL> pass <EOL> def simpleFunction7 ( ) : <EOL> def nested_args_function ( ( a , b ) , c ) : <EOL> return a , b , c <EOL> try : <EOL> nested_args_function ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , <NUM_LIT:3> ) <EOL> except ValueError : <EOL> pass <EOL> tests_stderr = ( ) <EOL> tests_skipped = { } <EOL> result = executeReferenceChecked ( <EOL> prefix = "<STR_LIT>" , <EOL> names = globals ( ) , <EOL> tests_skipped = tests_skipped , <EOL> tests_stderr = tests_stderr <EOL> ) <EOL> sys . exit ( <NUM_LIT:0> if result else <NUM_LIT:1> ) </s>
<s> from __future__ import print_function <EOL> exec ( """<STR_LIT>""" ) <EOL> a = ( <EOL> <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> <EOL> ) <EOL> def calledRepeatedly ( ) : <EOL> args = a <EOL> python_func ( <NUM_LIT:3> , * a ) <EOL> pass <EOL> for x in xrange ( <NUM_LIT> ) : <EOL> calledRepeatedly ( ) <EOL> print ( "<STR_LIT>" ) </s>
<s> from pybench import Test <EOL> import os <EOL> import package . submodule <EOL> class SecondImport ( Test ) : <EOL> version = <NUM_LIT> <EOL> operations = <NUM_LIT:5> * <NUM_LIT:5> <EOL> rounds = <NUM_LIT> <EOL> def test ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> import os <EOL> def calibrate ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> pass <EOL> class SecondPackageImport ( Test ) : <EOL> version = <NUM_LIT> <EOL> operations = <NUM_LIT:5> * <NUM_LIT:5> <EOL> rounds = <NUM_LIT> <EOL> def test ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> import package <EOL> def calibrate ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> pass <EOL> class SecondSubmoduleImport ( Test ) : <EOL> version = <NUM_LIT> <EOL> operations = <NUM_LIT:5> * <NUM_LIT:5> <EOL> rounds = <NUM_LIT> <EOL> def test ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> import package . submodule <EOL> def calibrate ( self ) : <EOL> for i in xrange ( self . rounds ) : <EOL> pass </s>
<s> size = "<STR_LIT>" </s>
<s> from __future__ import print_function <EOL> print ( "<STR_LIT>" , __name__ ) <EOL> def someBrotherFunction ( ) : <EOL> pass <EOL> print ( "<STR_LIT>" , someBrotherFunction . __module__ ) </s>
<s> import sys <EOL> print ( "<STR_LIT>" , __name__ , sys . modules [ __name__ ] ) </s>
<s> from __future__ import print_function <EOL> from PyQt4 . QtCore import pyqtSlot , pyqtSignal , QObject , QMetaObject <EOL> class Communicate ( QObject ) : <EOL> speak = pyqtSignal ( int ) <EOL> def __init__ ( self , name = "<STR_LIT>" , parent = None ) : <EOL> QObject . __init__ ( self , parent ) <EOL> self . setObjectName ( name ) <EOL> class Speaker ( QObject ) : <EOL> @ pyqtSlot ( int ) <EOL> def on_communicator_speak ( self , stuff ) : <EOL> print ( stuff ) <EOL> speaker = Speaker ( ) <EOL> someone = Communicate ( name = "<STR_LIT>" , parent = speaker ) <EOL> QMetaObject . connectSlotsByName ( speaker ) <EOL> print ( "<STR_LIT>" , end = "<STR_LIT>" ) <EOL> someone . speak . emit ( <NUM_LIT> ) <EOL> print ( "<STR_LIT>" ) </s>
<s> def f ( ) : <EOL> try : <EOL> raise A <EOL> except : <EOL> print "<STR_LIT>" <EOL> except A : <EOL> print "<STR_LIT>" </s>
<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import os <EOL> import re <EOL> import sys <EOL> import types <EOL> import mock <EOL> def get_version ( filename ) : <EOL> init_py = open ( filename ) . read ( ) <EOL> metadata = dict ( re . findall ( "<STR_LIT>" , init_py ) ) <EOL> return metadata [ '<STR_LIT:version>' ] <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( '<STR_LIT:..>' ) ) <EOL> foo = mock . Mock ( ) <EOL> foo . __version__ = '<STR_LIT>' <EOL> sys . modules [ '<STR_LIT:foo>' ] = foo <EOL> needs_sphinx = '<STR_LIT:1.0>' <EOL> extensions = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> templates_path = [ '<STR_LIT>' ] <EOL> source_suffix = '<STR_LIT>' <EOL> master_doc = '<STR_LIT:index>' <EOL> project = '<STR_LIT>' <EOL> copyright = '<STR_LIT>' <EOL> release = get_version ( '<STR_LIT>' ) <EOL> version = '<STR_LIT:.>' . join ( release . split ( '<STR_LIT:.>' ) [ : <NUM_LIT:2> ] ) <EOL> exclude_patterns = [ '<STR_LIT>' ] <EOL> pygments_style = '<STR_LIT>' <EOL> modindex_common_prefix = [ '<STR_LIT>' ] <EOL> autodoc_default_flags = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> autodoc_member_order = '<STR_LIT>' <EOL> html_theme = '<STR_LIT:default>' <EOL> html_static_path = [ '<STR_LIT>' ] <EOL> html_use_modindex = True <EOL> html_use_index = True <EOL> html_split_index = False <EOL> html_show_sourcelink = True <EOL> htmlhelp_basename = '<STR_LIT>' <EOL> extlinks = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT:#>' ) , <EOL> } </s>
<s> CSRF_ENABLED = True <EOL> SECRET_KEY = '<STR_LIT>' </s>
<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> import sys <EOL> import imp <EOL> import ast <EOL> from pycopia import module <EOL> def get_ast ( modname ) : <EOL> """<STR_LIT>""" <EOL> fo , path , ( suffix , mode , mtype ) = module . find_module ( modname ) <EOL> try : <EOL> if mtype == imp . PY_SOURCE : <EOL> tree = ast . parse ( fo . read ( ) , filename = path , mode = '<STR_LIT>' ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" . format ( modname ) ) <EOL> finally : <EOL> fo . close ( ) <EOL> return tree <EOL> class TestmoduleVisitor ( ast . NodeVisitor ) : <EOL> def __init__ ( self , findall = True ) : <EOL> self . _classes = { } <EOL> self . _currentclass = None <EOL> self . findall = findall <EOL> def visit_ClassDef ( self , node ) : <EOL> if not self . findall : <EOL> pass <EOL> self . _currentclass = node . name <EOL> self . _classes [ node . name ] = [ ] <EOL> self . generic_visit ( node ) <EOL> def visit_Assign ( self , node ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( node . value , ast . Call ) and isinstance ( node . value . func , ast . Attribute ) : <EOL> try : <EOL> if ( node . value . func . value . value . id == "<STR_LIT>" and <EOL> node . value . func . value . attr == "<STR_LIT>" and <EOL> node . value . func . attr == "<STR_LIT>" ) : <EOL> lhs = node . targets [ <NUM_LIT:0> ] . id <EOL> param = node . value . args [ <NUM_LIT:0> ] . s <EOL> default = node . value . args [ <NUM_LIT:1> ] . s <EOL> if self . _currentclass is not None : <EOL> self . _classes . setdefault ( self . _currentclass , [ ] ) . append ( ( lhs , param , default ) ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> except AttributeError : <EOL> return <EOL> def find_classes ( modname , findall = True ) : <EOL> ast = get_ast ( modname ) <EOL> nv = TestmoduleVisitor ( findall ) <EOL> nv . visit ( ast ) <EOL> return nv . _classes <EOL> def get_class ( cls ) : <EOL> """<STR_LIT>""" <EOL> ast = get_ast ( cls . __module__ ) <EOL> nv = TestmoduleVisitor ( ) <EOL> nv . visit ( ast ) <EOL> return nv . _classes [ cls . __name__ ] <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> from pycopia import autodebug <EOL> modname = "<STR_LIT>" <EOL> print ( find_classes ( modname ) ) </s>
<s> """<STR_LIT>""" </s>
<s> """<STR_LIT>""" <EOL> import sys <EOL> import _libsmi <EOL> from pycopia import aid <EOL> _NAMES = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> for name , value in vars ( _libsmi ) . items ( ) : <EOL> if name . startswith ( "<STR_LIT>" ) and type ( value ) is int : <EOL> setattr ( sys . modules [ __name__ ] , name , aid . Enum ( value , _NAMES . get ( name , name ) ) ) <EOL> del name , value , _libsmi , sys , _NAMES </s>
<s> """<STR_LIT>""" <EOL> __all__ = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> class NMSException ( Exception ) : <EOL> def getname ( self ) : <EOL> return self . __class__ . __name__ <EOL> def getvalue ( self ) : <EOL> return self . __class__ . value <EOL> class SNMPException ( NMSException ) : <EOL> value = - <NUM_LIT:1> <EOL> class SNMPBadParameters ( SNMPException ) : <EOL> value = <NUM_LIT:0> <EOL> class SNMPBadArgument ( SNMPException ) : <EOL> value = <NUM_LIT:1> <EOL> class SNMPNotConnected ( SNMPException ) : <EOL> value = <NUM_LIT:2> <EOL> class SNMPNoResponse ( SNMPException ) : <EOL> value = <NUM_LIT:3> <EOL> class SNMPBadVersion ( SNMPException ) : <EOL> value = <NUM_LIT:4> <EOL> class SNMPBadCommunity ( SNMPException ) : <EOL> value = <NUM_LIT:5> <EOL> class SNMPBadRequestID ( SNMPException ) : <EOL> value = <NUM_LIT:6> <EOL> class SNMPEmptyResponse ( SNMPException ) : <EOL> value = <NUM_LIT:7> <EOL> class SNMPIllegalArgument ( SNMPException ) : <EOL> value = <NUM_LIT:8> <EOL> class SNMPNotImplemented ( SNMPException ) : <EOL> value = <NUM_LIT:9> <EOL> class BERError ( NMSException ) : <EOL> value = - <NUM_LIT:1> <EOL> class BERUnknownTag ( BERError ) : <EOL> value = <NUM_LIT:9> <EOL> class BERBadEncoding ( BERError ) : <EOL> value = <NUM_LIT:10> <EOL> class BERBadSubjid ( BERError ) : <EOL> value = <NUM_LIT:11> <EOL> class BERBadIPAddress ( BERError ) : <EOL> value = <NUM_LIT:12> <EOL> class BERTypeError ( BERError ) : <EOL> value = <NUM_LIT> <EOL> class BERBadArgument ( BERError ) : <EOL> value = <NUM_LIT> <EOL> class SNMPError ( SNMPException ) : <EOL> value = - <NUM_LIT:1> <EOL> def __str__ ( self ) : <EOL> return _SNMP_ERROR_STRINGS [ self . __class__ . value ] <EOL> class SNMPnoError ( SNMPError ) : <EOL> value = <NUM_LIT:0> <EOL> class SNMPtooBig ( SNMPError ) : <EOL> value = <NUM_LIT:1> <EOL> class SNMPnoSuchName ( SNMPError ) : <EOL> value = <NUM_LIT:2> <EOL> class SNMPbadValue ( SNMPError ) : <EOL> value = <NUM_LIT:3> <EOL> class SNMPreadOnly ( SNMPError ) : <EOL> value = <NUM_LIT:4> <EOL> class SNMPgenError ( SNMPError ) : <EOL> value = <NUM_LIT:5> <EOL> class SNMPnoAccess ( SNMPError ) : <EOL> value = <NUM_LIT:6> <EOL> class SNMPwrongType ( SNMPError ) : <EOL> value = <NUM_LIT:7> <EOL> class SNMPwrongLength ( SNMPError ) : <EOL> value = <NUM_LIT:8> <EOL> class SNMPwrongEncoding ( SNMPError ) : <EOL> value = <NUM_LIT:9> <EOL> class SNMPwrongValue ( SNMPError ) : <EOL> value = <NUM_LIT:10> <EOL> class SNMPnoCreation ( SNMPError ) : <EOL> value = <NUM_LIT:11> <EOL> class SNMPinconsistentValue ( SNMPError ) : <EOL> value = <NUM_LIT:12> <EOL> class SNMPresourceUnavailable ( SNMPError ) : <EOL> value = <NUM_LIT> <EOL> class SNMPcommitFailed ( SNMPError ) : <EOL> value = <NUM_LIT> <EOL> class SNMPundoFailed ( SNMPError ) : <EOL> value = <NUM_LIT:15> <EOL> class SNMPauthorizationError ( SNMPError ) : <EOL> value = <NUM_LIT:16> <EOL> class SNMPnotWritable ( SNMPError ) : <EOL> value = <NUM_LIT> <EOL> class SNMPinconsistentName ( SNMPError ) : <EOL> value = <NUM_LIT> <EOL> _SNMP_ERROR_STRINGS = { <EOL> <NUM_LIT:0> : '<STR_LIT>' , <EOL> <NUM_LIT:1> : '<STR_LIT>' , <EOL> <NUM_LIT:2> : '<STR_LIT>' , <EOL> <NUM_LIT:3> : '<STR_LIT>' , <EOL> <NUM_LIT:4> : '<STR_LIT>' , <EOL> <NUM_LIT:5> : '<STR_LIT>' , <EOL> <NUM_LIT:6> : '<STR_LIT>' , <EOL> <NUM_LIT:7> : '<STR_LIT>' , <EOL> <NUM_LIT:8> : '<STR_LIT>' , <EOL> <NUM_LIT:9> : '<STR_LIT>' , <EOL> <NUM_LIT:10> : '<STR_LIT>' , <EOL> <NUM_LIT:11> : '<STR_LIT>' , <EOL> <NUM_LIT:12> : '<STR_LIT>' , <EOL> <NUM_LIT> : '<STR_LIT>' , <EOL> <NUM_LIT> : '<STR_LIT>' , <EOL> <NUM_LIT:15> : '<STR_LIT>' , <EOL> <NUM_LIT:16> : '<STR_LIT>' , <EOL> <NUM_LIT> : '<STR_LIT>' , <EOL> <NUM_LIT> : '<STR_LIT>' <EOL> } </s>
<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> from pycopia import basicconfig <EOL> from pycopia import passwd <EOL> from pycopia import socket <EOL> LTCONFIG = "<STR_LIT>" <EOL> SITE_CONFIG = "<STR_LIT>" <EOL> def start ( config ) : <EOL> setup ( config ) <EOL> if config . DAEMON : <EOL> from pycopia import daemonize <EOL> from pycopia import logfile <EOL> lf = logfile . ManagedStdio ( config . LOGFILENAME ) <EOL> daemonize . daemonize ( lf , pidfile = config . PIDFILE ) <EOL> else : <EOL> lf = sys . stdout <EOL> fo = file ( config . PIDFILE , "<STR_LIT:w>" ) <EOL> fo . write ( "<STR_LIT>" % ( os . getpid ( ) , ) ) <EOL> fo . close ( ) <EOL> start_proc_manager ( config , lf ) <EOL> def setup ( config ) : <EOL> siteuser = passwd . getpwnam ( config . SITEUSER ) <EOL> siteowner = passwd . getpwnam ( config . SITEOWNER ) <EOL> logroot = config . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> fqdn = socket . get_fqdn ( ) <EOL> def _mkdir ( path ) : <EOL> if not os . path . isdir ( path ) : <EOL> os . mkdir ( path , <NUM_LIT:0> <NUM_LIT> ) <EOL> os . chown ( path , siteowner . uid , siteowner . gid ) <EOL> for vhost in config . VHOSTS . keys ( ) : <EOL> vhostdir = config . SITEROOT + "<STR_LIT:/>" + vhost <EOL> vhostlogdir = logroot + "<STR_LIT:/>" + vhost <EOL> if not os . path . isdir ( vhostlogdir ) : <EOL> os . mkdir ( vhostlogdir , <NUM_LIT:0> <NUM_LIT> ) <EOL> os . chown ( vhostlogdir , siteuser . uid , siteuser . gid ) <EOL> if not os . path . isdir ( vhostdir ) : <EOL> if fqdn == vhost : <EOL> os . symlink ( config . SITEROOT + "<STR_LIT>" , vhostdir ) <EOL> else : <EOL> _mkdir ( vhostdir ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> _mkdir ( vhostdir + "<STR_LIT>" ) <EOL> def start_proc_manager ( config , logfile ) : <EOL> from pycopia import proctools <EOL> from pycopia import scheduler <EOL> from pycopia import asyncio <EOL> pm = proctools . get_procmanager ( ) <EOL> libexec = config . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> for name , serverlist in config . VHOSTS . items ( ) : <EOL> for servername in serverlist : <EOL> print "<STR_LIT>" % ( servername , name ) <EOL> p = pm . spawnpipe ( "<STR_LIT>" % ( libexec , servername ) , persistent = True , logfile = logfile ) <EOL> asyncio . poller . register ( p ) <EOL> if config . USEFRONTEND : <EOL> lighttpd = proctools . which ( "<STR_LIT>" ) <EOL> if asyncio . poller : <EOL> pm . spawnpipe ( "<STR_LIT>" % ( lighttpd , LTCONFIG ) , persistent = True , logfile = logfile ) <EOL> else : <EOL> pm . spawnpipe ( "<STR_LIT>" % ( lighttpd , LTCONFIG ) ) <EOL> try : <EOL> asyncio . poller . loop ( ) <EOL> print "<STR_LIT>" <EOL> except KeyboardInterrupt : <EOL> pass <EOL> if asyncio . poller : <EOL> asyncio . poller . unregister_all ( ) <EOL> for proc in pm . getprocs ( ) : <EOL> proc . killwait ( ) <EOL> if os . path . exists ( config . PIDFILE ) : <EOL> os . unlink ( config . PIDFILE ) <EOL> def stop ( config ) : <EOL> import signal <EOL> if os . path . exists ( config . PIDFILE ) : <EOL> pid = int ( open ( config . PIDFILE ) . read ( ) . strip ( ) ) <EOL> os . kill ( pid , signal . SIGINT ) <EOL> def status ( config ) : <EOL> from pycopia . OS import procfs <EOL> if os . path . exists ( config . PIDFILE ) : <EOL> pid = int ( open ( config . PIDFILE ) . read ( ) . strip ( ) ) <EOL> s = procfs . ProcStat ( pid ) <EOL> if s and s . command . find ( config . SERVERNAME ) >= <NUM_LIT:0> : <EOL> print "<STR_LIT>" % ( pid , s . cmdline ) <EOL> return <NUM_LIT:0> <EOL> print "<STR_LIT>" <EOL> return <NUM_LIT:1> <EOL> def robots ( config ) : <EOL> user = passwd . getpwnam ( config . SITEOWNER ) <EOL> for vhost , scripts in config . VHOSTS . items ( ) : <EOL> rname = os . path . join ( config . SITEROOT , vhost , "<STR_LIT>" , "<STR_LIT>" ) <EOL> if os . path . exists ( rname ) : <EOL> continue <EOL> fo = open ( rname , "<STR_LIT:w>" ) <EOL> fo . write ( _get_robots_txt ( scripts ) ) <EOL> fo . close ( ) <EOL> os . chown ( rname , user . uid , user . gid ) <EOL> def check ( config ) : <EOL> "<STR_LIT>" <EOL> from pycopia import proctools <EOL> pm = proctools . get_procmanager ( ) <EOL> lighttpd = proctools . which ( "<STR_LIT>" ) <EOL> proc = pm . spawnpipe ( "<STR_LIT>" % ( lighttpd , LTCONFIG ) ) <EOL> out = proc . read ( ) <EOL> es = proc . wait ( ) <EOL> if es : <EOL> print out <EOL> else : <EOL> print "<STR_LIT>" % ( es , ) <EOL> def _get_robots_txt ( scripts ) : <EOL> s = [ "<STR_LIT>" ] <EOL> for name in scripts : <EOL> s . append ( "<STR_LIT>" % ( name , ) ) <EOL> s . append ( "<STR_LIT>" ) <EOL> return "<STR_LIT:\n>" . join ( s ) <EOL> _doc = """<STR_LIT>""" <EOL> def main ( argv ) : <EOL> import getopt <EOL> daemonize = True <EOL> frontend = True <EOL> dname = None <EOL> servername = os . path . basename ( argv [ <NUM_LIT:0> ] ) <EOL> logfilename = "<STR_LIT>" % ( servername , ) <EOL> pidfilename = "<STR_LIT>" % ( servername , ) <EOL> cffile = SITE_CONFIG <EOL> try : <EOL> optlist , args = getopt . getopt ( argv [ <NUM_LIT:1> : ] , "<STR_LIT>" ) <EOL> except getopt . GetoptError : <EOL> print _doc % ( servername , ) <EOL> return <EOL> for opt , optarg in optlist : <EOL> if opt in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> print _doc % ( servername , ) <EOL> return <NUM_LIT:2> <EOL> elif opt == "<STR_LIT>" : <EOL> logfilename = optarg <EOL> elif opt == "<STR_LIT>" : <EOL> daemonize = False <EOL> elif opt == "<STR_LIT>" : <EOL> frontend = False <EOL> elif opt == "<STR_LIT>" : <EOL> dname = optarg <EOL> elif opt == "<STR_LIT>" : <EOL> cffile = optarg <EOL> elif opt == "<STR_LIT>" : <EOL> pidfilename = optarg <EOL> elif opt == "<STR_LIT>" : <EOL> from pycopia import autodebug <EOL> glbl = { "<STR_LIT>" : dname or socket . get_fqdn ( ) } <EOL> config = basicconfig . get_config ( cffile , globalspace = glbl ) <EOL> config . SERVERNAME = servername <EOL> config . LOGFILENAME = logfilename <EOL> config . PIDFILE = pidfilename <EOL> config . DAEMON = daemonize <EOL> config . USEFRONTEND = frontend <EOL> config . ARGV = args <EOL> if not args : <EOL> return status ( config ) <EOL> cmd = args [ <NUM_LIT:0> ] <EOL> if cmd . startswith ( "<STR_LIT>" ) : <EOL> return status ( config ) <EOL> elif cmd . startswith ( "<STR_LIT>" ) : <EOL> return setup ( config ) <EOL> elif cmd . startswith ( "<STR_LIT>" ) : <EOL> return start ( config ) <EOL> elif cmd . startswith ( "<STR_LIT>" ) : <EOL> return stop ( config ) <EOL> elif cmd . startswith ( "<STR_LIT>" ) : <EOL> return robots ( config ) <EOL> elif cmd . startswith ( "<STR_LIT>" ) : <EOL> return check ( config ) <EOL> else : <EOL> print _doc % ( servername , ) <EOL> return <NUM_LIT:2> </s>
<s> import pycopia . XML . POM <EOL> attribRequires_32078989662874577693926404618281630689 = pycopia . XML . POM . XMLAttribute ( u'<STR_LIT>' , <NUM_LIT:7> , <NUM_LIT:12> , None ) <EOL> attribXmlns_6064471315751782428734380699212490969 = pycopia . XML . POM . XMLAttribute ( u'<STR_LIT>' , <NUM_LIT:1> , <NUM_LIT> , u'<STR_LIT>' ) <EOL> attribType_985353312225873986 = pycopia . XML . POM . XMLAttribute ( u'<STR_LIT:type>' , <NUM_LIT:7> , <NUM_LIT:11> , None ) <EOL> class Comps ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Group ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Category ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Default ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT:default>' <EOL> class Uservisible ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Langonly ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Packagelist ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Display_order ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Grouplist ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Packagereq ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT:type>' : attribType_985353312225873986 , <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> u'<STR_LIT>' : attribRequires_32078989662874577693926404618281630689 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT:type>' : attribType_985353312225873986 , <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> '<STR_LIT>' : attribRequires_32078989662874577693926404618281630689 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Groupid ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT>' <EOL> class Id ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT:id>' <EOL> class Name ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT:name>' <EOL> class Description ( pycopia . XML . POM . ElementNode ) : <EOL> ATTRIBUTES = { <EOL> u'<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> CONTENTMODEL = pycopia . XML . POM . ContentModel ( ( True , ) ) <EOL> KWATTRIBUTES = { <EOL> '<STR_LIT>' : attribXmlns_6064471315751782428734380699212490969 , <EOL> } <EOL> _name = u'<STR_LIT:description>' <EOL> GENERAL_ENTITIES = { } <EOL> _CLASSCACHE = { } </s>
<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import sys <EOL> from math import ceil <EOL> from errno import EINTR <EOL> from collections import deque <EOL> import functools <EOL> def add2builtin ( name , obj ) : <EOL> """<STR_LIT>""" <EOL> bim = sys . modules [ _biname ] <EOL> if not hasattr ( bim , name ) : <EOL> setattr ( bim , name , obj ) <EOL> def add_exception ( excclass , name = None ) : <EOL> """<STR_LIT>""" <EOL> name = name or excclass . __name__ <EOL> bimod = sys . modules [ _biname ] <EOL> if not hasattr ( bimod , name ) : <EOL> setattr ( bimod , name , excclass ) <EOL> try : <EOL> long <EOL> except NameError : <EOL> import io <EOL> long = int <EOL> _biname = "<STR_LIT>" <EOL> def execfile ( fn , glbl = None , loc = None ) : <EOL> glbl = glbl or globals ( ) <EOL> loc = loc or locals ( ) <EOL> exec ( open ( fn ) . read ( ) , glbl , loc ) <EOL> add2builtin ( "<STR_LIT>" , execfile ) <EOL> add2builtin ( "<STR_LIT>" , input ) <EOL> add2builtin ( "<STR_LIT:file>" , io . BufferedReader ) <EOL> else : <EOL> _biname = "<STR_LIT>" <EOL> execfile = execfile <EOL> def enumerate ( collection ) : <EOL> '<STR_LIT>' <EOL> i = <NUM_LIT:0> <EOL> it = iter ( collection ) <EOL> while <NUM_LIT:1> : <EOL> yield ( i , it . next ( ) ) <EOL> i += <NUM_LIT:1> <EOL> partial = functools . partial <EOL> class NULLType ( type ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , name , bases , dct ) : <EOL> return type . __new__ ( cls , name , bases , dct ) <EOL> def __init__ ( cls , name , bases , dct ) : <EOL> super ( NULLType , cls ) . __init__ ( name , bases , dct ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" <EOL> def __nonzero__ ( self ) : <EOL> return False <EOL> def __len__ ( self ) : <EOL> return <NUM_LIT:0> <EOL> def __call__ ( self , * args , ** kwargs ) : <EOL> return None <EOL> def __contains__ ( self , item ) : <EOL> return False <EOL> def __iter__ ( self ) : <EOL> return self <EOL> def __next__ ( * args ) : <EOL> raise StopIteration <EOL> def next ( * args ) : <EOL> raise StopIteration <EOL> NULL = NULLType ( "<STR_LIT>" , ( type , ) , { } ) <EOL> sow = sys . stdout . write <EOL> sew = sys . stderr . write <EOL> try : <EOL> soflush = sys . stdout . flush <EOL> except AttributeError : <EOL> soflush = NULL <EOL> try : <EOL> seflush = sys . stderr . flush <EOL> except AttributeError : <EOL> seflush = NULL <EOL> class Enum ( int ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , val , name = None ) : <EOL> v = int . __new__ ( cls , val ) <EOL> v . _name = str ( name ) <EOL> return v <EOL> def __getstate__ ( self ) : <EOL> return int ( self ) , self . _name <EOL> def __setstate__ ( self , args ) : <EOL> i , self . _name = args <EOL> def __str__ ( self ) : <EOL> return self . _name <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . __class__ . __name__ , self , self . _name ) <EOL> def for_json ( self ) : <EOL> return { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : self . _name , "<STR_LIT:value>" : int ( self ) } <EOL> class Enums ( list ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * init , ** kwinit ) : <EOL> for i , val in enumerate ( init ) : <EOL> if issubclass ( type ( val ) , list ) : <EOL> for j , subval in enumerate ( val ) : <EOL> self . append ( Enum ( i + j , str ( subval ) ) ) <EOL> elif isinstance ( val , Enum ) : <EOL> self . append ( val ) <EOL> else : <EOL> self . append ( Enum ( i , str ( val ) ) ) <EOL> for name , value in kwinit . items ( ) : <EOL> enum = Enum ( int ( value ) , name ) <EOL> self . append ( enum ) <EOL> self . _mapping = None <EOL> self . sort ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . __class__ . __name__ , list . __repr__ ( self ) ) <EOL> choices = property ( lambda s : map ( lambda e : ( int ( e ) , str ( e ) ) , s ) ) <EOL> def find ( self , value ) : <EOL> """<STR_LIT>""" <EOL> i = self . index ( int ( value ) ) <EOL> return self [ i ] <EOL> def get_mapping ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _mapping is None : <EOL> d = dict ( map ( lambda it : ( str ( it ) , it ) , self ) ) <EOL> self . _mapping = d <EOL> return d <EOL> else : <EOL> return self . _mapping <EOL> def findstring ( self , string ) : <EOL> """<STR_LIT>""" <EOL> d = self . get_mapping ( ) <EOL> try : <EOL> return d [ string ] <EOL> except KeyError : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> NO = Enum ( <NUM_LIT:0> , "<STR_LIT>" ) <EOL> YES = Enum ( <NUM_LIT:1> , "<STR_LIT>" ) <EOL> DEFAULT = Enum ( <NUM_LIT:2> , "<STR_LIT>" ) <EOL> UNKNOWN = Enum ( <NUM_LIT:3> , "<STR_LIT>" ) <EOL> class unsigned ( long ) : <EOL> """<STR_LIT>""" <EOL> floor = <NUM_LIT:0> <EOL> ceiling = <NUM_LIT> <EOL> bits = <NUM_LIT:32> <EOL> _mask = <NUM_LIT> <EOL> def __new__ ( cls , val ) : <EOL> return long . __new__ ( cls , val ) <EOL> def __init__ ( self , val ) : <EOL> if val < self . floor or val > self . ceiling : <EOL> raise OverflowError ( "<STR_LIT>" % ( val , self . __class__ . __name__ ) ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self ) <EOL> def __add__ ( self , other ) : <EOL> return self . __class__ ( long . __add__ ( self , other ) ) <EOL> def __sub__ ( self , other ) : <EOL> return self . __class__ ( long . __sub__ ( self , other ) ) <EOL> def __mul__ ( self , other ) : <EOL> return self . __class__ ( long . __mul__ ( self , other ) ) <EOL> def __floordiv__ ( self , other ) : <EOL> return self . __class__ ( long . __floordiv__ ( self , other ) ) <EOL> def __mod__ ( self , other ) : <EOL> return self . __class__ ( long . __mod__ ( self , other ) ) <EOL> def __divmod__ ( self , other ) : <EOL> return self . __class__ ( long . __divmod__ ( self , other ) ) <EOL> def __pow__ ( self , other , modulo = None ) : <EOL> return self . __class__ ( long . __pow__ ( self , other , modulo ) ) <EOL> def __lshift__ ( self , other ) : <EOL> return self . __class__ ( long . __lshift__ ( self , other ) & self . _mask ) <EOL> def __rshift__ ( self , other ) : <EOL> return self . __class__ ( long . __rshift__ ( self , other ) ) <EOL> def __and__ ( self , other ) : <EOL> return self . __class__ ( long . __and__ ( self , other ) ) <EOL> def __xor__ ( self , other ) : <EOL> return self . __class__ ( long . __xor__ ( self , other ) ) <EOL> def __or__ ( self , other ) : <EOL> return self . __class__ ( long . __or__ ( self , other ) ) <EOL> def __div__ ( self , other ) : <EOL> return self . __class__ ( long . __div__ ( self , other ) ) <EOL> def __truediv__ ( self , other ) : <EOL> return self . __class__ ( long . __truediv__ ( self , other ) ) <EOL> def __neg__ ( self ) : <EOL> return self . __class__ ( long . __neg__ ( self ) ) <EOL> def __pos__ ( self ) : <EOL> return self . __class__ ( long . __pos__ ( self ) ) <EOL> def __abs__ ( self ) : <EOL> return self . __class__ ( long . __abs__ ( self ) ) <EOL> def __invert__ ( self ) : <EOL> return self . __class__ ( long . __invert__ ( self ) ) <EOL> def __radd__ ( self , other ) : <EOL> return self . __class__ ( long . __radd__ ( self , other ) ) <EOL> def __rand__ ( self , other ) : <EOL> return self . __class__ ( long . __rand__ ( self , other ) ) <EOL> def __rdiv__ ( self , other ) : <EOL> return self . __class__ ( long . __rdiv__ ( self , other ) ) <EOL> def __rdivmod__ ( self , other ) : <EOL> return self . __class__ ( long . __rdivmod__ ( self , other ) ) <EOL> def __rfloordiv__ ( self , other ) : <EOL> return self . __class__ ( long . __rfloordiv__ ( self , other ) ) <EOL> def __rlshift__ ( self , other ) : <EOL> return self . __class__ ( long . __rlshift__ ( self , other ) ) <EOL> def __rmod__ ( self , other ) : <EOL> return self . __class__ ( long . __rmod__ ( self , other ) ) <EOL> def __rmul__ ( self , other ) : <EOL> return self . __class__ ( long . __rmul__ ( self , other ) ) <EOL> def __ror__ ( self , other ) : <EOL> return self . __class__ ( long . __ror__ ( self , other ) ) <EOL> def __rpow__ ( self , other ) : <EOL> return self . __class__ ( long . __rpow__ ( self , other ) ) <EOL> def __rrshift__ ( self , other ) : <EOL> return self . __class__ ( long . __rrshift__ ( self , other ) ) <EOL> def __rshift__ ( self , other ) : <EOL> return self . __class__ ( long . __rshift__ ( self , other ) ) <EOL> def __rsub__ ( self , other ) : <EOL> return self . __class__ ( long . __rsub__ ( self , other ) ) <EOL> def __rtruediv__ ( self , other ) : <EOL> return self . __class__ ( long . __rtruediv__ ( self , other ) ) <EOL> def __rxor__ ( self , other ) : <EOL> return self . __class__ ( long . __rxor__ ( self , other ) ) <EOL> class unsigned64 ( unsigned ) : <EOL> """<STR_LIT>""" <EOL> floor = <NUM_LIT:0> <EOL> ceiling = <NUM_LIT> <EOL> bits = <NUM_LIT:64> <EOL> _mask = <NUM_LIT> <EOL> class sortedlist ( list ) : <EOL> """<STR_LIT>""" <EOL> def insort ( self , x ) : <EOL> hi = len ( self ) <EOL> lo = <NUM_LIT:0> <EOL> while lo < hi : <EOL> mid = ( lo + hi ) // <NUM_LIT:2> <EOL> if x < self [ mid ] : <EOL> hi = mid <EOL> else : <EOL> lo = mid + <NUM_LIT:1> <EOL> self . insert ( lo , x ) <EOL> append = insort <EOL> def _printobj ( obj ) : <EOL> sow ( str ( obj ) ) <EOL> sow ( "<STR_LIT:U+0020>" ) <EOL> def _printerr ( obj ) : <EOL> sew ( str ( obj ) ) <EOL> sew ( "<STR_LIT:U+0020>" ) <EOL> def Write ( * args ) : <EOL> map ( _printobj , args ) <EOL> soflush ( ) <EOL> def Print ( * args ) : <EOL> """<STR_LIT>""" <EOL> map ( _printobj , args ) <EOL> sow ( "<STR_LIT:\n>" ) <EOL> soflush ( ) <EOL> def Printerr ( * args ) : <EOL> """<STR_LIT>""" <EOL> map ( _printerr , args ) <EOL> sew ( "<STR_LIT:\n>" ) <EOL> seflush ( ) <EOL> def IF ( test , tv , fv = None ) : <EOL> """<STR_LIT>""" <EOL> if test : <EOL> return tv <EOL> else : <EOL> return fv <EOL> def sgn ( val ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return val . _sgn_ ( ) <EOL> except AttributeError : <EOL> if val == <NUM_LIT:0> : <EOL> return <NUM_LIT:0> <EOL> if val > <NUM_LIT:0> : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return - <NUM_LIT:1> <EOL> def frange ( limit1 , limit2 = None , increment = <NUM_LIT:1.0> ) : <EOL> """<STR_LIT>""" <EOL> if limit2 is None : <EOL> limit2 , limit1 = limit1 , <NUM_LIT:0.> <EOL> else : <EOL> limit1 = float ( limit1 ) <EOL> count = int ( ceil ( ( limit2 - limit1 ) / increment ) ) <EOL> return ( limit1 + n * increment for n in xrange ( <NUM_LIT:0> , count ) ) <EOL> class Queue ( deque ) : <EOL> def push ( self , obj ) : <EOL> self . appendleft ( obj ) <EOL> class Stack ( deque ) : <EOL> def push ( self , obj ) : <EOL> self . append ( obj ) <EOL> class mapstr ( str ) : <EOL> def __new__ ( cls , initstr , ** kwargs ) : <EOL> s = str . __new__ ( cls , initstr ) <EOL> return s <EOL> def __init__ ( self , initstr , ** kwargs ) : <EOL> d = { } <EOL> for name in _findkeys ( self ) : <EOL> d [ name ] = kwargs . get ( name , None ) <EOL> self . __dict__ [ "<STR_LIT>" ] = d <EOL> def __setattr__ ( self , name , val ) : <EOL> if name not in self . __dict__ [ "<STR_LIT>" ] . keys ( ) : <EOL> raise AttributeError ( "<STR_LIT>" % ( name , ) ) <EOL> self . __dict__ [ "<STR_LIT>" ] [ name ] = val <EOL> def __getattr__ ( self , name ) : <EOL> try : <EOL> return self . __dict__ [ "<STR_LIT>" ] [ name ] <EOL> except KeyError : <EOL> raise AttributeError ( "<STR_LIT>" % ( name , ) ) <EOL> def __str__ ( self ) : <EOL> if None in self . _attribs . values ( ) : <EOL> raise ValueError ( "<STR_LIT>" % ( self . _attribs . keys ( ) , ) ) <EOL> return self % self . _attribs <EOL> def __call__ ( self , ** kwargs ) : <EOL> for name , value in kwargs . items ( ) : <EOL> setattr ( self , name , value ) <EOL> return self % self . _attribs <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , str . __repr__ ( self ) ) <EOL> @ property <EOL> def attributes ( self ) : <EOL> return self . _attribs . keys ( ) <EOL> import re <EOL> _findkeys = re . compile ( r"<STR_LIT>" ) . findall <EOL> _findfkeys = re . compile ( r"<STR_LIT>" ) . findall <EOL> del re <EOL> class formatstr ( str ) : <EOL> """<STR_LIT>""" <EOL> def __new__ ( cls , initstr , ** kwargs ) : <EOL> s = str . __new__ ( cls , initstr ) <EOL> return s <EOL> def __init__ ( self , initstr , ** kwargs ) : <EOL> d = { } <EOL> for name in _findfkeys ( self ) : <EOL> d [ name ] = kwargs . get ( name , None ) <EOL> self . __dict__ [ "<STR_LIT>" ] = d <EOL> def __setattr__ ( self , name , val ) : <EOL> if name not in self . __dict__ [ "<STR_LIT>" ] . keys ( ) : <EOL> raise AttributeError ( "<STR_LIT>" % ( name , ) ) <EOL> self . __dict__ [ "<STR_LIT>" ] [ name ] = val <EOL> def __getattr__ ( self , name ) : <EOL> try : <EOL> return self . __dict__ [ "<STR_LIT>" ] [ name ] <EOL> except KeyError : <EOL> raise AttributeError ( "<STR_LIT>" % ( name , ) ) <EOL> def __str__ ( self ) : <EOL> if None in self . _attribs . values ( ) : <EOL> raise ValueError ( "<STR_LIT>" % ( self . _attribs . keys ( ) , ) ) <EOL> return self . format ( ** self . _attribs ) <EOL> def __call__ ( self , ** kwargs ) : <EOL> for name , value in kwargs . items ( ) : <EOL> self . __setattr__ ( name , value ) <EOL> return self . format ( ** self . _attribs ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , str . __repr__ ( self ) ) <EOL> @ property <EOL> def attributes ( self ) : <EOL> return list ( self . _attribs . keys ( ) ) <EOL> def newclass ( name , * bases , ** attribs ) : <EOL> """<STR_LIT>""" <EOL> class _NewType ( type ) : <EOL> def __new__ ( cls ) : <EOL> return type . __new__ ( cls , str ( name ) , bases , attribs ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> pass <EOL> return _NewType ( ) <EOL> def debugmethod ( meth ) : <EOL> """<STR_LIT>""" <EOL> def _lambda ( * iargs , ** ikwargs ) : <EOL> try : <EOL> return meth ( * iargs , ** ikwargs ) <EOL> except : <EOL> ex , val , tb = sys . exc_info ( ) <EOL> from pycopia import debugger <EOL> debugger . post_mortem ( tb , ex , val ) <EOL> return _lambda <EOL> def systemcall ( meth ) : <EOL> """<STR_LIT>""" <EOL> from _socket import error as SocketError <EOL> def systemcallmeth ( * args , ** kwargs ) : <EOL> while <NUM_LIT:1> : <EOL> try : <EOL> rv = meth ( * args , ** kwargs ) <EOL> except EnvironmentError as why : <EOL> if why . args and why . args [ <NUM_LIT:0> ] == EINTR : <EOL> continue <EOL> else : <EOL> raise <EOL> except SocketError as why : <EOL> if why . args and why . args [ <NUM_LIT:0> ] == EINTR : <EOL> continue <EOL> else : <EOL> raise <EOL> else : <EOL> break <EOL> return rv <EOL> return systemcallmeth <EOL> def removedups ( s ) : <EOL> """<STR_LIT>""" <EOL> n = len ( s ) <EOL> if n == <NUM_LIT:0> : <EOL> return [ ] <EOL> u = { } <EOL> try : <EOL> for x in s : <EOL> u [ x ] = <NUM_LIT:1> <EOL> except TypeError : <EOL> del u <EOL> else : <EOL> return list ( u . keys ( ) ) <EOL> try : <EOL> t = list ( s ) <EOL> t . sort ( ) <EOL> except TypeError : <EOL> del t <EOL> else : <EOL> assert n > <NUM_LIT:0> <EOL> last = t [ <NUM_LIT:0> ] <EOL> lasti = i = <NUM_LIT:1> <EOL> while i < n : <EOL> if t [ i ] != last : <EOL> t [ lasti ] = last = t [ i ] <EOL> lasti = lasti + <NUM_LIT:1> <EOL> i = i + <NUM_LIT:1> <EOL> return t [ : lasti ] <EOL> u = [ ] <EOL> for x in s : <EOL> if x not in u : <EOL> u . append ( x ) <EOL> return u <EOL> def pprint_list ( clist , indent = <NUM_LIT:0> , width = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> indent = min ( max ( indent , <NUM_LIT:0> ) , width - <NUM_LIT:1> ) <EOL> if indent : <EOL> print ( "<STR_LIT:U+0020>" * indent , end = "<STR_LIT>" ) <EOL> print ( "<STR_LIT:[>" , end = "<STR_LIT>" ) <EOL> col = indent + <NUM_LIT:2> <EOL> for c in clist [ : - <NUM_LIT:1> ] : <EOL> ps = "<STR_LIT>" % ( c ) <EOL> col = col + len ( ps ) + <NUM_LIT:1> <EOL> if col > width : <EOL> print ( ) <EOL> col = indent + len ( ps ) + <NUM_LIT:1> <EOL> if indent : <EOL> print ( "<STR_LIT:U+0020>" * indent , end = "<STR_LIT>" ) <EOL> print ( ps , end = "<STR_LIT>" ) <EOL> if col + len ( clist [ - <NUM_LIT:1> ] ) > width : <EOL> print ( ) <EOL> if indent : <EOL> print ( "<STR_LIT:U+0020>" * indent , end = "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" % ( clist [ - <NUM_LIT:1> ] , ) ) <EOL> def reorder ( datalist , indexlist ) : <EOL> """<STR_LIT>""" <EOL> return [ datalist [ idx ] for idx in indexlist ] <EOL> def repeat ( self , n , f ) : <EOL> """<STR_LIT>""" <EOL> i = n <EOL> while i > <NUM_LIT:0> : <EOL> f ( ) <EOL> i -= <NUM_LIT:1> <EOL> def flatten ( alist ) : <EOL> """<STR_LIT>""" <EOL> rv = [ ] <EOL> for val in alist : <EOL> if isinstance ( val , list ) : <EOL> rv . extend ( flatten ( val ) ) <EOL> else : <EOL> rv . append ( val ) <EOL> return rv <EOL> def str2hex ( s ) : <EOL> """<STR_LIT>""" <EOL> res = [ "<STR_LIT:'>" ] <EOL> for c in s : <EOL> res . append ( "<STR_LIT>" % ord ( c ) ) <EOL> res . append ( "<STR_LIT:'>" ) <EOL> return "<STR_LIT>" . join ( res ) <EOL> def hexdigest ( s ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" . join ( [ "<STR_LIT>" % ord ( c ) for c in s ] ) <EOL> def unhexdigest ( s ) : <EOL> """<STR_LIT>""" <EOL> l = [ ] <EOL> for i in xrange ( <NUM_LIT:0> , len ( s ) , <NUM_LIT:2> ) : <EOL> l . append ( chr ( int ( s [ i : i + <NUM_LIT:2> ] , <NUM_LIT:16> ) ) ) <EOL> return "<STR_LIT>" . join ( l ) <EOL> def Import ( modname ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return sys . modules [ modname ] <EOL> except KeyError : <EOL> pass <EOL> __import__ ( modname ) <EOL> return sys . modules [ modname ] </s>
<s> """<STR_LIT>""" <EOL> import sys , os <EOL> import atexit <EOL> from pycopia import timelib <EOL> from pycopia . audio import alsacontrol <EOL> from pycopia . audio import alsaplayer <EOL> try : <EOL> import vim <EOL> except ImportError : <EOL> from pycopia . vim import vimtest as vim <EOL> vim . command ( "<STR_LIT>" ) <EOL> vim . command ( "<STR_LIT>" ) <EOL> current = None <EOL> players = { } <EOL> controllers = { } <EOL> def new_player ( ) : <EOL> global players , current <EOL> curp = players . keys ( ) <EOL> for ns in range ( <NUM_LIT:10> ) : <EOL> if ns not in curp : <EOL> break <EOL> else : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> return <EOL> players [ ns ] = alsaplayer . get_alsaplayer ( ns ) <EOL> timelib . sleep ( <NUM_LIT:3> ) <EOL> current = controllers [ ns ] = alsacontrol . get_session ( ns ) <EOL> current . clear ( ) <EOL> print "<STR_LIT>" % ( ns , ) <EOL> def switch_player ( ) : <EOL> global controllers <EOL> session = int ( vim . eval ( "<STR_LIT>" ) ) <EOL> apc = controllers . get ( session , None ) <EOL> if apc is not None : <EOL> current = apc <EOL> else : <EOL> print "<STR_LIT>" , session <EOL> def remove_player ( session = None ) : <EOL> global players , controllers , current <EOL> if session is None : <EOL> session = int ( vim . eval ( "<STR_LIT>" ) ) <EOL> print "<STR_LIT>" % ( session , ) , <EOL> apc = controllers . get ( session , None ) <EOL> if apc is not None : <EOL> try : <EOL> apc . quit ( ) <EOL> except : <EOL> pass <EOL> del controllers [ session ] <EOL> timelib . sleep ( <NUM_LIT:2> ) <EOL> p = players . get ( session , None ) <EOL> if p : <EOL> rv = p . wait ( ) <EOL> del players [ session ] <EOL> if controllers : <EOL> current = controllers . values ( ) [ <NUM_LIT:0> ] <EOL> else : <EOL> current = None <EOL> print rv <EOL> def print_sessions ( ) : <EOL> global players <EOL> for idx , s in players . items ( ) : <EOL> print "<STR_LIT>" % ( idx , s ) <EOL> def add_uri ( ) : <EOL> global current <EOL> try : <EOL> path , pos = current . add_uri ( vim . current . line ) <EOL> except : <EOL> ex , val , tb = sys . exc_info ( ) <EOL> print >> sys . stderr , "<STR_LIT>" , vim . current . line <EOL> print >> sys . stderr , ex , val <EOL> else : <EOL> print "<STR_LIT>" % ( path , pos and "<STR_LIT>" % ( pos , ) or "<STR_LIT>" ) <EOL> def insert_uri ( ) : <EOL> cp = vim . current . window . cursor [ <NUM_LIT:0> ] - <NUM_LIT:1> <EOL> vim . current . buffer [ cp : cp ] = [ "<STR_LIT>" % ( current . get_uri ( ) ) ] <EOL> def seek_to ( ) : <EOL> count = int ( vim . eval ( "<STR_LIT>" ) ) <EOL> if count == <NUM_LIT:0> : <EOL> count = int ( vim . eval ( '<STR_LIT>' ) ) <EOL> print "<STR_LIT>" % ( count , ) <EOL> current . set_position ( count ) <EOL> def cleanup ( ) : <EOL> global current <EOL> current = None <EOL> for ns in controllers . keys ( ) : <EOL> remove_player ( ns ) <EOL> def normalize ( ) : <EOL> newbuf = [ "<STR_LIT>" ] <EOL> for line in vim . current . buffer : <EOL> line = line . strip ( ) <EOL> if line : <EOL> top = newbuf . pop ( ) <EOL> if top : <EOL> top += "<STR_LIT:U+0020>" + line <EOL> else : <EOL> top = "<STR_LIT:\t>" + line <EOL> newbuf . append ( top ) <EOL> elif newbuf [ - <NUM_LIT:1> ] : <EOL> newbuf . append ( "<STR_LIT>" ) <EOL> vim . current . buffer [ : ] = newbuf <EOL> vim . command ( "<STR_LIT>" ) <EOL> atexit . register ( cleanup ) <EOL> MAPPINGS = [ <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> def mapkeys ( MAPLIST ) : <EOL> for mapping in MAPLIST : <EOL> vim . command ( mapping ) <EOL> mapkeys ( MAPPINGS ) <EOL> del MAPPINGS </s>
<s> """<STR_LIT:U+0020>""" <EOL> from pycopia . OS . Linux import Input <EOL> from pycopia . OS . Linux import event <EOL> class Mouse ( Input . EventDevice ) : <EOL> DEVNAME = '<STR_LIT>' <EOL> def initialize ( self ) : <EOL> self . _motion_cb = lambda ev : None <EOL> self . _button_cb = lambda ev : None <EOL> self . _wheel_cb = lambda ev : None <EOL> def register_motion ( self , cb ) : <EOL> self . _motion_cb = cb <EOL> def register_button ( self , cb ) : <EOL> self . _button_cb = cb <EOL> def register_wheel ( self , cb ) : <EOL> self . _wheel_cb = cb <EOL> def poll ( self ) : <EOL> while <NUM_LIT:1> : <EOL> ev = self . read ( ) <EOL> if ev . evtype == event . EV_REL : <EOL> if ev . code == event . REL_WHEEL : <EOL> self . _wheel_cb ( ev ) <EOL> else : <EOL> self . _motion_cb ( ev ) <EOL> elif ev . evtype == event . EV_KEY : <EOL> self . _button_cb ( ev ) <EOL> read_handler = poll <EOL> class MotionEventHandler ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _disp = { <EOL> event . REL_X : self . _relx , <EOL> event . REL_Y : self . _rely , <EOL> event . REL_Z : self . _relz , <EOL> } <EOL> def __call__ ( self , ev ) : <EOL> self . _disp [ ev . code ] ( ev . value ) <EOL> def _relx ( self , value ) : <EOL> return self . movement ( value , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> def _rely ( self , value ) : <EOL> return self . movement ( <NUM_LIT:0> , value , <NUM_LIT:0> ) <EOL> def _relz ( self , value ) : <EOL> return self . movement ( <NUM_LIT:0> , <NUM_LIT:0> , value ) <EOL> def movement ( self , x , y , z ) : <EOL> pass <EOL> class ButtonEventHandler ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _disp = { <EOL> event . BTN_LEFT : self . left_button , <EOL> event . BTN_RIGHT : self . right_button , <EOL> event . BTN_MIDDLE : self . middle_button , <EOL> } <EOL> def __call__ ( self , ev ) : <EOL> self . _disp [ ev . code ] ( ev . value ) <EOL> def left_button ( self , value ) : <EOL> pass <EOL> def middle_button ( self , value ) : <EOL> pass <EOL> def right_button ( self , value ) : <EOL> pass <EOL> class WheelEventHandler ( object ) : <EOL> def __call__ ( self , ev ) : <EOL> if ev . value == - <NUM_LIT:1> : <EOL> return self . down ( ) <EOL> elif ev . value == <NUM_LIT:1> : <EOL> return self . up ( ) <EOL> def up ( self ) : <EOL> pass <EOL> def down ( self ) : <EOL> pass <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> mouse = Mouse ( ) <EOL> mouse . find ( ) <EOL> print mouse <EOL> print "<STR_LIT>" , mouse . name <EOL> print "<STR_LIT>" % ( mouse . get_driverversion ( ) , ) <EOL> print "<STR_LIT>" , mouse . get_deviceid ( ) <EOL> print "<STR_LIT>" , mouse . get_features ( ) <EOL> def print_ev ( event ) : <EOL> print event <EOL> class MotionPrint ( MotionEventHandler ) : <EOL> def movement ( self , x , y , z ) : <EOL> print "<STR_LIT>" , x , "<STR_LIT>" , y , "<STR_LIT>" , z <EOL> class ButtonPrint ( ButtonEventHandler ) : <EOL> def left_button ( self , value ) : <EOL> print "<STR_LIT>" , value <EOL> def middle_button ( self , value ) : <EOL> print "<STR_LIT>" , value <EOL> def right_button ( self , value ) : <EOL> print "<STR_LIT>" , value <EOL> class WheelPrint ( WheelEventHandler ) : <EOL> def up ( self ) : <EOL> print "<STR_LIT>" <EOL> def down ( self ) : <EOL> print "<STR_LIT>" <EOL> mouse . register_motion ( MotionPrint ( ) ) <EOL> mouse . register_button ( ButtonPrint ( ) ) <EOL> mouse . register_wheel ( WheelPrint ( ) ) <EOL> try : <EOL> while <NUM_LIT:1> : <EOL> mouse . poll ( ) <EOL> except KeyboardInterrupt : <EOL> pass <EOL> mouse . close ( ) </s>
<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> import sys <EOL> if sys . version_info . major == <NUM_LIT:3> : <EOL> basestring = str <EOL> from functools import reduce <EOL> def factorial ( x ) : <EOL> """<STR_LIT>""" <EOL> return x <= <NUM_LIT:0> or reduce ( lambda a , b : a * b , range ( <NUM_LIT:1> , x + <NUM_LIT:1> ) ) <EOL> fact = factorial <EOL> def nCr ( n , r ) : <EOL> "<STR_LIT>" <EOL> return factorial ( n ) / ( factorial ( n - r ) * factorial ( r ) ) <EOL> combinations = nCr <EOL> def nPr ( n , r ) : <EOL> "<STR_LIT>" <EOL> return factorial ( n ) / factorial ( n - r ) <EOL> permutations = nPr <EOL> class Permuter ( object ) : <EOL> def __init__ ( self , seq ) : <EOL> self . seq = seq <EOL> def __iter__ ( self ) : <EOL> return PermuterIter ( self . seq ) <EOL> def __getitem__ ( self , idx ) : <EOL> return get_permutation ( self . seq , idx ) <EOL> def __len__ ( self ) : <EOL> return factorial ( len ( self . seq ) ) <EOL> class PermuterIter ( object ) : <EOL> def __init__ ( self , seq ) : <EOL> self . seq = seq <EOL> self . maximum = factorial ( len ( seq ) ) <EOL> self . i = <NUM_LIT:0> <EOL> self . is_string = isinstance ( seq , basestring ) <EOL> def __iter__ ( self ) : <EOL> return ( self ) <EOL> def __next__ ( self ) : <EOL> if self . i >= self . maximum : <EOL> raise StopIteration <EOL> n = get_permutation ( self . seq , self . i ) <EOL> self . i += <NUM_LIT:1> <EOL> if self . is_string : <EOL> return "<STR_LIT>" . join ( n ) <EOL> else : <EOL> return n <EOL> next = __next__ <EOL> def prune_end ( n , l ) : <EOL> return l [ : n ] <EOL> class ListCounter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lists ) : <EOL> self . _lists = lists <EOL> self . _lengths = [ len ( l ) for l in lists ] <EOL> if self . _lengths . count ( <NUM_LIT:0> ) > <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> self . _places = len ( self . _lengths ) <EOL> self . reset ( ) <EOL> def reset ( self ) : <EOL> self . _counters = [ <NUM_LIT:0> ] * self . _places <EOL> self . _counters [ <NUM_LIT:0> ] -= <NUM_LIT:1> <EOL> def __iter__ ( self ) : <EOL> self . reset ( ) <EOL> return self <EOL> def __next__ ( self ) : <EOL> self . _increment ( <NUM_LIT:0> ) <EOL> return self . fetch ( ) <EOL> next = __next__ <EOL> def _increment ( self , place ) : <EOL> carry , self . _counters [ place ] = divmod ( self . _counters [ place ] + <NUM_LIT:1> , self . _lengths [ place ] ) <EOL> if carry : <EOL> if place + <NUM_LIT:1> < self . _places : <EOL> return self . _increment ( place + <NUM_LIT:1> ) <EOL> else : <EOL> raise StopIteration <EOL> return carry <EOL> def fetch ( self ) : <EOL> return [ l [ i ] for l , i in zip ( self . _lists , self . _counters ) ] <EOL> def get_number ( self ) : <EOL> return reduce ( lambda a , b : a * b , self . _lengths , <NUM_LIT:1> ) <EOL> class KeywordCounter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . _names = kwargs . keys ( ) <EOL> self . _counter = ListCounter ( kwargs . values ( ) ) <EOL> def prune ( self , maxN , chooser = prune_end ) : <EOL> lists = prune ( maxN , self . _counter . _lists , chooser ) <EOL> self . _counter = ListCounter ( lists ) <EOL> def __iter__ ( self ) : <EOL> self . _counter . reset ( ) <EOL> return self <EOL> def __next__ ( self ) : <EOL> values = self . _counter . next ( ) <EOL> return self . fetch ( values ) <EOL> next = __next__ <EOL> def get_number ( self ) : <EOL> return self . _counter . get_number ( ) <EOL> def fetch ( self , values ) : <EOL> return dict ( zip ( self . _names , values ) ) <EOL> def get_permutation ( seq , index ) : <EOL> "<STR_LIT>" <EOL> seqc = list ( seq [ : ] ) <EOL> seqn = [ seqc . pop ( ) ] <EOL> divider = <NUM_LIT:2> <EOL> while seqc : <EOL> index , new_index = index // divider , index % divider <EOL> seqn . insert ( new_index , seqc . pop ( ) ) <EOL> divider += <NUM_LIT:1> <EOL> return seqn <EOL> def unique_combinations ( items , n ) : <EOL> if n == <NUM_LIT:0> : <EOL> yield [ ] <EOL> else : <EOL> for i in range ( len ( items ) ) : <EOL> for cc in unique_combinations ( items [ i + <NUM_LIT:1> : ] , n - <NUM_LIT:1> ) : <EOL> yield [ items [ i ] ] + cc <EOL> def prune ( maxN , sets , chooser = prune_end ) : <EOL> """<STR_LIT>""" <EOL> lenlist = [ len ( l ) for l in sets ] <EOL> while reduce ( lambda a , b : a * b , lenlist , <NUM_LIT:1> ) > maxN : <EOL> lv , li = maxi ( lenlist ) <EOL> lenlist [ li ] -= <NUM_LIT:1> <EOL> return [ chooser ( n , l ) for n , l in zip ( lenlist , sets ) ] <EOL> def maxi ( seq ) : <EOL> cmax = seq [ <NUM_LIT:0> ] <EOL> ci = <NUM_LIT:0> <EOL> for i , val in enumerate ( seq ) : <EOL> if val > cmax : <EOL> cmax = val <EOL> ci = i <EOL> return cmax , ci <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> from pycopia import interactive <EOL> perm = Permuter ( "<STR_LIT:abc>" ) <EOL> for p in perm : <EOL> print ( p ) <EOL> perm = Permuter ( range ( <NUM_LIT:10> ) ) <EOL> for i in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1000> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> print ( perm [ i ] ) <EOL> print ( "<STR_LIT>" ) <EOL> s1 = range ( <NUM_LIT:10> ) <EOL> s2 = range ( <NUM_LIT:5> ) <EOL> s3 = range ( <NUM_LIT:2> ) <EOL> lc = ListCounter ( prune ( <NUM_LIT> , [ s1 , s2 , s3 ] ) ) <EOL> print ( lc . get_number ( ) ) <EOL> for i , l in enumerate ( lc ) : <EOL> print ( "<STR_LIT>" % ( i , l ) ) <EOL> try : <EOL> badlc = ListCounter ( [ [ ] , s2 , s3 ] ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> kc = KeywordCounter ( arg1 = s1 , arg2 = s2 , arg3 = s3 ) <EOL> print ( kc . get_number ( ) ) <EOL> for kwargs in kc : <EOL> print ( kwargs ) </s>
<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> import struct <EOL> try : <EOL> from sys import maxint <EOL> except ImportError : <EOL> from sys import maxsize as maxint <EOL> long = int <EOL> basestring = str <EOL> ord = lambda x : x <EOL> from pycopia import socket <EOL> class IPv4 ( object ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> def __init__ ( self , address , mask = None ) : <EOL> self . _address = <NUM_LIT> ; self . _mask = None <EOL> self . __handleAddress ( address ) <EOL> if self . _mask is None : <EOL> if mask is None : <EOL> if self . _address & <NUM_LIT> == <NUM_LIT:0> : <EOL> self . _mask = <NUM_LIT> <EOL> elif self . _address & <NUM_LIT> == <NUM_LIT:0> : <EOL> self . _mask = <NUM_LIT> <EOL> else : <EOL> self . _mask = <NUM_LIT> <EOL> else : <EOL> self . __handleMask ( mask ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , ( self . _address >> <NUM_LIT> ) & <NUM_LIT> , <EOL> ( ( self . _address & <NUM_LIT> ) >> <NUM_LIT:16> ) , <EOL> ( ( self . _address & <NUM_LIT> ) >> <NUM_LIT:8> ) , <EOL> ( self . _address & <NUM_LIT> ) , <EOL> self . __mask2bits ( ) ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( ( self . _address >> <NUM_LIT> ) & <NUM_LIT> , <EOL> ( ( self . _address & <NUM_LIT> ) >> <NUM_LIT:16> ) , <EOL> ( ( self . _address & <NUM_LIT> ) >> <NUM_LIT:8> ) , <EOL> ( self . _address & <NUM_LIT> ) ) <EOL> def __getstate__ ( self ) : <EOL> return ( self . _address , self . _mask ) <EOL> def __setstate__ ( self , state ) : <EOL> self . _address , self . _mask = state <EOL> def __iter__ ( self ) : <EOL> return _NetIterator ( self ) <EOL> def getStrings ( self ) : <EOL> """<STR_LIT>""" <EOL> return itodq ( self . _address ) , itodq ( self . _mask ) , itodq ( self . broadcast ) <EOL> address_mask_broadcast = property ( getStrings ) <EOL> def cidr ( self ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" % ( itodq ( self . _address ) , self . __mask2bits ( ) ) <EOL> CIDR = property ( cidr ) <EOL> address = property ( lambda s : s . _address , <EOL> lambda s , v : s . __handleAddress ( v ) , <EOL> None , "<STR_LIT>" ) <EOL> mask = property ( lambda s : s . _mask , <EOL> lambda s , v : s . __handleMask ( v ) , <EOL> None , "<STR_LIT>" ) <EOL> maskbits = property ( lambda s : s . __mask2bits ( ) , <EOL> lambda s , v : s . __handleMask ( s . __bits2mask ( v ) ) , <EOL> None , "<STR_LIT>" ) <EOL> network = property ( lambda s : IPv4 ( s . _address & s . _mask , s . _mask ) , <EOL> None , None , "<STR_LIT>" ) <EOL> def _get_broadcast ( self ) : <EOL> if self . _mask == <NUM_LIT> : <EOL> return <NUM_LIT> <EOL> else : <EOL> return self . _address | ( ~ self . _mask & <NUM_LIT> ) <EOL> broadcast = property ( _get_broadcast ) <EOL> def _get_hostpart ( self ) : <EOL> if self . _mask == <NUM_LIT> : <EOL> return self . _address <EOL> else : <EOL> return self . _address & ( ~ self . _mask & <NUM_LIT> ) <EOL> def _set_hostpart ( self , value ) : <EOL> self . _address = ( ( self . _address & self . _mask ) | <EOL> ( long ( value ) & ( ~ self . _mask & <NUM_LIT> ) ) ) <EOL> host = property ( _get_hostpart , _set_hostpart , None , "<STR_LIT>" ) <EOL> hostpart = host <EOL> firsthost = property ( lambda s : IPv4 ( ( s . _address & s . _mask ) + <NUM_LIT:1> , s . _mask ) , <EOL> None , None , "<STR_LIT>" ) <EOL> lasthost = property ( lambda s : IPv4 ( <EOL> ( s . _address & s . _mask ) + ( ( ~ s . _mask & <NUM_LIT> ) - <NUM_LIT:1> ) , s . _mask ) , <EOL> None , None , "<STR_LIT>" ) <EOL> def __handleAddress ( self , address ) : <EOL> if isinstance ( address , basestring ) : <EOL> aml = address . split ( "<STR_LIT:/>" ) <EOL> if len ( aml ) > <NUM_LIT:1> : <EOL> self . _address = nametoi ( aml [ <NUM_LIT:0> ] ) <EOL> self . _mask = self . __bits2mask ( long ( aml [ <NUM_LIT:1> ] ) ) <EOL> else : <EOL> self . _address = nametoi ( aml [ <NUM_LIT:0> ] ) <EOL> elif type ( address ) in ( long , int ) : <EOL> self . _address = long ( address ) <EOL> elif type ( address ) is list : <EOL> assert len ( address ) >= <NUM_LIT:4> <EOL> self . _address = ( address [ <NUM_LIT:0> ] << <NUM_LIT> ) | ( address [ <NUM_LIT:1> ] << <NUM_LIT:16> ) | ( address [ <NUM_LIT:2> ] << <NUM_LIT:8> ) | address [ <NUM_LIT:3> ] <EOL> elif isinstance ( address , IPv4 ) : <EOL> self . _address = address . _address <EOL> self . _mask = address . _mask <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" . format ( address ) ) <EOL> def __handleMask ( self , mask ) : <EOL> if type ( mask ) is str : <EOL> if mask [ <NUM_LIT:0> ] == '<STR_LIT:/>' : <EOL> bits = int ( mask [ <NUM_LIT:1> : ] ) <EOL> self . _mask = self . __bits2mask ( bits ) <EOL> else : <EOL> self . _mask = dqtoi ( mask ) <EOL> elif type ( mask ) in ( long , int ) : <EOL> self . _mask = long ( mask ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % ( mask , ) ) <EOL> def __bits2mask ( self , bits ) : <EOL> if bits <= <NUM_LIT:32> and bits >= <NUM_LIT:0> : <EOL> return ( <NUM_LIT> << ( <NUM_LIT:32> - bits ) ) & <NUM_LIT> <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def __mask2bits ( self ) : <EOL> val = self . _mask <EOL> bits = <NUM_LIT:0> <EOL> for byte in range ( <NUM_LIT:4> ) : <EOL> testval = ( val >> ( byte * <NUM_LIT:8> ) ) & <NUM_LIT> <EOL> while ( testval != <NUM_LIT:0> ) : <EOL> if ( ( testval & <NUM_LIT:1> ) == <NUM_LIT:1> ) : <EOL> bits += <NUM_LIT:1> <EOL> testval >>= <NUM_LIT:1> <EOL> return bits <EOL> def __add__ ( self , increment ) : <EOL> return IPv4 ( self . _address + increment , self . _mask ) <EOL> def __sub__ ( self , decrement ) : <EOL> return IPv4 ( self . _address - decrement , self . _mask ) <EOL> def __int__ ( self ) : <EOL> return long ( self . _address ) <EOL> def __long__ ( self ) : <EOL> return long ( self . _address ) <EOL> def __hex__ ( self ) : <EOL> return hex ( self . _address ) <EOL> def __hash__ ( self ) : <EOL> return int ( self . _address % maxint ) <EOL> def __eq__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address == other . _address and self . _mask == other . _mask <EOL> def __ne__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address != other . _address <EOL> def __lt__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address < other . _address <EOL> def __gt__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address > other . _address <EOL> def __ge__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address >= other . _address <EOL> def __le__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> return self . _address <= other . _address <EOL> def __contains__ ( self , other ) : <EOL> other = self . __class__ ( other ) <EOL> if self . _mask != other . _mask : <EOL> return <NUM_LIT:0> <EOL> return ( self . _address & self . _mask ) == ( other . _address & other . _mask ) <EOL> def __getitem__ ( self , index ) : <EOL> if index >= <NUM_LIT:0> : <EOL> if index <= ( ~ self . _mask & <NUM_LIT> ) : <EOL> return IPv4 ( <EOL> ( self . _address & self . _mask ) + index , self . _mask ) <EOL> else : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> else : <EOL> if - index < ( ~ self . _mask & <NUM_LIT> ) + <NUM_LIT:1> : <EOL> return IPv4 ( ( self . _address & self . _mask ) + <EOL> ( ( ~ self . _mask & <NUM_LIT> ) + index + <NUM_LIT:1> ) , <EOL> self . _mask ) <EOL> else : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> def __setitem__ ( self , index , value ) : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> def __len__ ( self ) : <EOL> return ( ~ self . _mask & <NUM_LIT> ) + <NUM_LIT:1> <EOL> def __getslice__ ( self , start , end ) : <EOL> length = ( ~ self . _mask & <NUM_LIT> ) + <NUM_LIT:1> <EOL> selfnet = self . _address & self . _mask <EOL> if end < <NUM_LIT:0> : <EOL> end = length + end <EOL> if start < <NUM_LIT:0> : <EOL> start = length + start <EOL> start = min ( start , length ) <EOL> end = min ( end , length ) <EOL> sublist = [ ] <EOL> for i in range ( start , end ) : <EOL> sublist . append ( IPv4 ( selfnet + i , self . _mask ) ) <EOL> return sublist <EOL> def copy ( self ) : <EOL> return IPv4 ( self . _address , self . _mask ) <EOL> def __isub__ ( self , other ) : <EOL> self . _address -= long ( other ) <EOL> if self . host == ( ~ self . _mask & <NUM_LIT> ) : <EOL> self . _address -= <NUM_LIT:2> <EOL> return self <EOL> def __iadd__ ( self , other ) : <EOL> self . _address += long ( other ) <EOL> if self . host == ( ~ self . _mask & <NUM_LIT> ) : <EOL> self . _address += <NUM_LIT:2> <EOL> return self <EOL> def nexthost ( self , increment = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _address = self . _address + increment <EOL> if self . host == ( ~ self . _mask & <NUM_LIT> ) : <EOL> self . _address += <NUM_LIT:2> <EOL> return self <EOL> def previoushost ( self , decrement = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _address = self . _address - decrement <EOL> if self . host == ( ~ self . _mask & <NUM_LIT> ) : <EOL> self . _address -= <NUM_LIT:2> <EOL> return self <EOL> def set_to_first ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _address = ( self . _address & self . _mask ) + <NUM_LIT:1> <EOL> return self <EOL> def set_to_last ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _address = ( ( self . _address & self . _mask ) + <EOL> ( ( ~ self . _mask & <NUM_LIT> ) - <NUM_LIT:1> ) ) <EOL> return self <EOL> def nextnet ( self , increment = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _address = self . _address + ( ( ~ self . _mask & <NUM_LIT> ) + <NUM_LIT:1> ) * increment <EOL> return self <EOL> def previousnet ( self , decrement = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> self . _address = self . _address - ( ( ~ self . _mask & <NUM_LIT> ) + <NUM_LIT:1> ) * decrement <EOL> return self <EOL> def gethost ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> hostname , aliases , others = socket . gethostbyaddr ( str ( self ) ) <EOL> except : <EOL> return "<STR_LIT>" <EOL> return hostname <EOL> hostname = property ( gethost , None , None , "<STR_LIT>" ) <EOL> class _NetIterator ( object ) : <EOL> def __init__ ( self , net ) : <EOL> mask = self . mask = net . _mask <EOL> self . start = ( net . _address & mask ) <EOL> self . end = ( net . _address & mask ) + ( ~ mask & <NUM_LIT> ) - <NUM_LIT:1> <EOL> def __iter__ ( self ) : <EOL> return self <EOL> def __next__ ( self ) : <EOL> if self . start == self . end : <EOL> raise StopIteration <EOL> self . start += <NUM_LIT:1> <EOL> return IPv4 ( self . start , self . mask ) <EOL> next = __next__ <EOL> def nametoi ( name ) : <EOL> """<STR_LIT>""" <EOL> return dqtoi ( socket . gethostbyname ( name ) ) <EOL> def dqtoi ( dq ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> s = socket . inet_aton ( dq ) <EOL> except socket . error as why : <EOL> raise ValueError ( why ) <EOL> return ( ord ( s [ <NUM_LIT:0> ] ) << <NUM_LIT> ) + ( ord ( s [ <NUM_LIT:1> ] ) << <NUM_LIT:16> ) + ( ord ( s [ <NUM_LIT:2> ] ) << <NUM_LIT:8> ) + ( ord ( s [ <NUM_LIT:3> ] ) ) <EOL> def itodq ( addr ) : <EOL> """<STR_LIT>""" <EOL> intval = long ( addr ) <EOL> s = struct . pack ( b"<STR_LIT>" , ( intval >> <NUM_LIT> ) & <NUM_LIT> , ( intval & <NUM_LIT> ) >> <NUM_LIT:16> , <EOL> ( intval & <NUM_LIT> ) >> <NUM_LIT:8> , intval & <NUM_LIT> ) <EOL> return socket . inet_ntoa ( s ) <EOL> def iprange ( startip , number , increment = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> start = IPv4 ( startip ) <EOL> ips = [ ] <EOL> for i in range ( number ) : <EOL> ips . append ( str ( start ) ) <EOL> start . nexthost ( increment ) <EOL> return ips <EOL> def ipnetrange ( startnet , number , increment = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> start = IPv4 ( startnet ) <EOL> ips = [ ] <EOL> baseaddress = start . address <EOL> for i in range ( number ) : <EOL> start . address = baseaddress + ( ~ start . mask + <NUM_LIT:1> ) * ( i * increment ) <EOL> ips . append ( str ( start ) ) <EOL> return ips <EOL> def netrange ( startnet , number , increment = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> ips = [ ] <EOL> counter = IPv4 ( startnet ) <EOL> for i in range ( number ) : <EOL> ips . append ( counter . copy ( ) ) <EOL> counter . nextnet ( increment ) <EOL> return ips <EOL> def resolve ( host , mask = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> hostname , aliases , addresses = socket . gethostbyname_ex ( str ( host ) ) <EOL> except socket . gaierror as why : <EOL> raise ValueError ( "<STR_LIT>" % ( why [ <NUM_LIT:1> ] ) ) <EOL> if addresses : <EOL> return IPv4 ( addresses [ <NUM_LIT:0> ] , mask ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def sortnets ( l ) : <EOL> l = list ( l ) <EOL> def _netcmp ( a , b ) : <EOL> return cmp ( b . maskbits , a . maskbits ) <EOL> l . sort ( _netcmp ) <EOL> return l <EOL> def findnet ( ip , ipnets ) : <EOL> ip = IPv4 ( ip ) <EOL> for ipnet in sortnets ( ipnets ) : <EOL> ip . mask = ipnet . mask <EOL> if ip in ipnet : <EOL> return ipnet <EOL> return None <EOL> class IPRange ( object ) : <EOL> def __init__ ( self , start , end ) : <EOL> start = IPv4 ( start ) <EOL> end = IPv4 ( end ) <EOL> self . _len = long ( start ) - long ( end ) <EOL> if self . _len < <NUM_LIT:0> : <EOL> self . _len *= - <NUM_LIT:1> <EOL> self . _start = start <EOL> self . _end = end <EOL> else : <EOL> self . _start = end <EOL> self . _end = start <EOL> self . _index = <NUM_LIT:0> <EOL> assert self . _start . _mask == self . _end . _mask , "<STR_LIT>" <EOL> self . _mask = self . _start . _mask <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __module__ , self . __class__ . __name__ , self . _start , self . _end ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . _start . cidr ( ) , self . _end . cidr ( ) ) <EOL> def __contains__ ( self , other ) : <EOL> other = IPv4 ( other ) <EOL> if self . _start . _mask != other . _mask : <EOL> return False <EOL> return self . _start . _address <= other . _address and self . _end . _address >= other . _address <EOL> def __next__ ( self ) : <EOL> if self . _index <= self . _len : <EOL> rv = self . _start + self . _index <EOL> self . _index += <NUM_LIT:1> <EOL> return rv <EOL> else : <EOL> raise StopIteration <EOL> next = __next__ <EOL> def __iter__ ( self ) : <EOL> self . _index = <NUM_LIT:0> <EOL> return self <EOL> def __getitem__ ( self , idx ) : <EOL> if idx < <NUM_LIT:0> : <EOL> idx = self . _len + idx + <NUM_LIT:1> <EOL> if idx < <NUM_LIT:0> or idx > self . _len : <EOL> raise IndexError ( "<STR_LIT>" ) <EOL> else : <EOL> return self . _start + idx <EOL> class IPAddressSet ( object ) : <EOL> pass </s>
<s> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> import os <EOL> import time <EOL> import unittest <EOL> from pycopia import anypath <EOL> from pycopia import asyncio <EOL> from pycopia import asyncserver <EOL> from pycopia import basicconfig <EOL> from pycopia import benchmarks <EOL> from pycopia import charbuffer <EOL> from pycopia import cliutils <EOL> from pycopia import combinatorics <EOL> from pycopia import daemonize <EOL> from pycopia import environ <EOL> from pycopia import ezmail <EOL> from pycopia import fsm <EOL> from pycopia import guid <EOL> from pycopia import interactive <EOL> from pycopia import ipv4 <EOL> from pycopia import logfile <EOL> from pycopia import makepassword <EOL> from pycopia import md5lib <EOL> from pycopia import methodholder <EOL> from pycopia import netstring <EOL> from pycopia import rot13 <EOL> from pycopia import scheduler <EOL> from pycopia import sharedbuffer <EOL> from pycopia import smtp_envelope <EOL> from pycopia import sourcegen <EOL> from pycopia import shparser <EOL> from pycopia import table <EOL> from pycopia import texttools <EOL> from pycopia import passwd <EOL> from pycopia import re_inverse <EOL> if os . environ . get ( "<STR_LIT>" ) : <EOL> from pycopia import gtktools <EOL> from pycopia . inet import ABNF <EOL> from pycopia . inet import DICT <EOL> from pycopia . inet import fcgi <EOL> from pycopia . inet import HTTP <EOL> from pycopia . inet import httputils <EOL> from pycopia . inet import mailaliases <EOL> from pycopia . inet import rfc2822 <EOL> from pycopia . inet import SMTP <EOL> from pycopia . inet import telnet <EOL> from pycopia . inet import toc <EOL> from pycopia . ISO import iso3166 <EOL> from pycopia . ISO import iso639a <EOL> import pycopia . OS <EOL> import pycopia . OS . sequencer <EOL> class CoreTests ( unittest . TestCase ) : <EOL> def test_charbuffer ( self ) : <EOL> """<STR_LIT>""" <EOL> b = charbuffer . Buffer ( ) <EOL> b += "<STR_LIT>" <EOL> self . assertEqual ( str ( b ) , "<STR_LIT>" ) <EOL> def test_ipv4 ( self ) : <EOL> """<STR_LIT>""" <EOL> r1 = ipv4 . IPRange ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> r2 = ipv4 . IPRange ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> r3 = ipv4 . IPRange ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> l1 = list ( r1 ) <EOL> l2 = list ( r2 ) <EOL> print ( l1 ) <EOL> print ( l1 == l2 ) <EOL> print ( r3 , list ( r3 ) ) <EOL> ip = ipv4 . IPv4 ( "<STR_LIT>" ) <EOL> self . assertEqual ( ip . mask , <NUM_LIT> ) <EOL> print ( ip . address ) <EOL> ip . address = "<STR_LIT>" <EOL> print ( ip . address ) <EOL> ip . address = - <NUM_LIT> <EOL> print ( ip . CIDR ) <EOL> ip = ipv4 . IPv4 ( "<STR_LIT>" ) <EOL> print ( len ( ip ) ) <EOL> print ( len ( ipv4 . IPv4 ( "<STR_LIT>" ) ) ) <EOL> print ( len ( ipv4 . IPv4 ( "<STR_LIT>" ) ) ) <EOL> print ( len ( ipv4 . IPv4 ( "<STR_LIT>" ) ) ) <EOL> for each_ip in ip : <EOL> print ( each_ip ) <EOL> self . assertEqual ( ip . mask , <NUM_LIT> ) <EOL> self . assertEqual ( ip . address , <NUM_LIT> ) <EOL> def test_passwd ( argv ) : <EOL> pwent = passwd . getpwself ( ) <EOL> print ( repr ( pwent ) ) <EOL> print ( str ( pwent ) ) <EOL> print ( int ( pwent ) ) <EOL> print ( pwent . name ) <EOL> print ( pwent . home ) <EOL> print ( pwent . uid ) <EOL> print ( pwent [ <NUM_LIT:3> ] ) <EOL> def test_shparser ( self ) : <EOL> argv = None <EOL> def _check_argv ( argv ) : <EOL> self . assertEqual ( argv [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( argv [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( argv [ <NUM_LIT:3> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( argv [ <NUM_LIT:9> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( argv [ <NUM_LIT:10> ] , argv [ <NUM_LIT:11> ] ) <EOL> sh = shparser . ShellParser ( _check_argv ) <EOL> rv = sh . feedline ( '<STR_LIT>' ) <EOL> def test_re_inverse ( self ) : <EOL> import sre_parse <EOL> RE = r'<STR_LIT>' <EOL> print ( sre_parse . parse ( RE ) ) <EOL> for i in range ( <NUM_LIT:20> ) : <EOL> ms = re_inverse . make_match_string ( RE ) <EOL> for i in range ( <NUM_LIT:20> ) : <EOL> ms = re_inverse . make_nonmatch_string ( RE ) <EOL> def test_sequencer ( self ) : <EOL> counters = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> starttimes = [ None , None , None , None , None ] <EOL> def _test_job ( counters ) : <EOL> print ( "<STR_LIT>" ) <EOL> counters [ <NUM_LIT:0> ] += <NUM_LIT:1> <EOL> def _test_job2 ( counters ) : <EOL> print ( "<STR_LIT>" ) <EOL> counters [ <NUM_LIT:1> ] += <NUM_LIT:1> <EOL> def _test_delay_job ( counters , starttimes ) : <EOL> if counters [ <NUM_LIT:2> ] == <NUM_LIT:0> : <EOL> starttimes [ <NUM_LIT:2> ] = time . time ( ) <EOL> print ( "<STR_LIT>" ) <EOL> counters [ <NUM_LIT:2> ] += <NUM_LIT:1> <EOL> def _test_delay_job2 ( counters , starttimes ) : <EOL> if counters [ <NUM_LIT:3> ] == <NUM_LIT:0> : <EOL> starttimes [ <NUM_LIT:3> ] = time . time ( ) <EOL> print ( "<STR_LIT>" , time . time ( ) ) <EOL> counters [ <NUM_LIT:3> ] += <NUM_LIT:1> <EOL> def _test_oneshot ( counters , starttimes ) : <EOL> thetime = time . time ( ) <EOL> counters [ <NUM_LIT:4> ] += <NUM_LIT:1> <EOL> starttimes [ <NUM_LIT:4> ] = thetime <EOL> print ( "<STR_LIT>" , thetime ) <EOL> s = pycopia . OS . sequencer . Sequencer ( ) <EOL> start = time . time ( ) <EOL> s . add_task ( _test_job , <NUM_LIT> , duration = <NUM_LIT> , callback_args = ( counters , ) ) <EOL> s . add_task ( _test_job2 , <NUM_LIT> , duration = <NUM_LIT> , callback_args = ( counters , ) ) <EOL> s . add_task ( _test_delay_job , <NUM_LIT> , delay = <NUM_LIT> , duration = <NUM_LIT> , callback_args = ( counters , starttimes ) ) <EOL> s . add_task ( _test_delay_job2 , <NUM_LIT> , delay = <NUM_LIT> , duration = <NUM_LIT> , callback_args = ( counters , starttimes ) ) <EOL> s . add_task ( _test_oneshot , <NUM_LIT:0.0> , delay = <NUM_LIT:15> , callback_args = ( counters , starttimes ) ) <EOL> s . run ( ) <EOL> s . close ( ) <EOL> endtime = time . time ( ) <EOL> self . assertAlmostEqual ( endtime - start , <NUM_LIT> , places = <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( starttimes [ <NUM_LIT:2> ] - start , <NUM_LIT> , places = <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( starttimes [ <NUM_LIT:3> ] - start , <NUM_LIT> , places = <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( endtime - starttimes [ <NUM_LIT:3> ] , <NUM_LIT> , places = <NUM_LIT:2> ) <EOL> self . assertAlmostEqual ( starttimes [ <NUM_LIT:4> ] - start , <NUM_LIT> , places = <NUM_LIT:2> ) <EOL> self . assertEqual ( counters [ <NUM_LIT:0> ] , <NUM_LIT:10> ) <EOL> self . assertEqual ( counters [ <NUM_LIT:1> ] , <NUM_LIT:10> ) <EOL> self . assertEqual ( counters [ <NUM_LIT:2> ] , <NUM_LIT:6> ) <EOL> self . assertEqual ( counters [ <NUM_LIT:3> ] , <NUM_LIT:2> ) <EOL> self . assertEqual ( counters [ <NUM_LIT:4> ] , <NUM_LIT:1> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
<s> from pycopia . aid import Enum <EOL> import pycopia . SMI . Basetypes <EOL> Range = pycopia . SMI . Basetypes . Range <EOL> Ranges = pycopia . SMI . Basetypes . Ranges <EOL> from pycopia . SMI . Objects import ColumnObject , MacroObject , NotificationObject , RowObject , ScalarObject , NodeObject , ModuleObject , GroupObject <EOL> from SNMPv2_SMI import Counter32 , Counter64 , Integer32 , Gauge32 , TimeTicks , OBJECT_TYPE , MODULE_IDENTITY , NOTIFICATION_TYPE , mib_2 <EOL> from SNMPv2_CONF import OBJECT_GROUP , MODULE_COMPLIANCE <EOL> from SNMPv2_TC import TimeStamp , DisplayString , MacAddress , TEXTUAL_CONVENTION , RowStatus , TestAndIncr <EOL> from IF_MIB import OwnerString <EOL> class SNMP_REPEATER_MIB ( ModuleObject ) : <EOL> path = '<STR_LIT>' <EOL> conformance = <NUM_LIT:3> <EOL> name = '<STR_LIT>' <EOL> language = <NUM_LIT:2> <EOL> description = "<STR_LIT>" <EOL> class snmpDot3RptrMgt ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrBasicPackage ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrGroupInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrPortInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrAllRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrMonitorPackage ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrMonitorRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrMonitorGroupInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrMonitorPortInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrMonitorAllRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrAddrTrackPackage ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrAddrTrackRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrAddrTrackGroupInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrAddrTrackPortInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrTopNPackage ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrTopNRptrInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrTopNGroupInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class rptrTopNPortInfo ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class snmpRptrMod ( NodeObject ) : <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> ] ) <EOL> name = '<STR_LIT>' <EOL> class snmpRptrModConf ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class snmpRptrModCompls ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> name = '<STR_LIT>' <EOL> class snmpRptrModObjGrps ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> name = '<STR_LIT>' <EOL> class snmpRptrModNotGrps ( NodeObject ) : <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> name = '<STR_LIT>' <EOL> class OptMacAddr ( pycopia . SMI . Basetypes . OctetString ) : <EOL> status = <NUM_LIT:1> <EOL> ranges = Ranges ( Range ( <NUM_LIT:0> , <NUM_LIT:0> ) , Range ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> format = '<STR_LIT>' <EOL> class rptrGroupCapacity ( ScalarObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrOperStatus ( ScalarObject ) : <EOL> status = <NUM_LIT:2> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) , Enum ( <NUM_LIT:4> , '<STR_LIT>' ) , Enum ( <NUM_LIT:5> , '<STR_LIT>' ) , Enum ( <NUM_LIT:6> , '<STR_LIT>' ) ] <EOL> class rptrHealthText ( ScalarObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . DisplayString <EOL> class rptrReset ( ScalarObject ) : <EOL> status = <NUM_LIT:2> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrNonDisruptTest ( ScalarObject ) : <EOL> status = <NUM_LIT:2> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrTotalPartitionedPorts ( ScalarObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Gauge32 <EOL> class rptrMonitorTransmitCollisions ( ScalarObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrGroupDescr ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . DisplayString <EOL> class rptrGroupObjectID ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . ObjectIdentifier <EOL> class rptrGroupOperStatus ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) , Enum ( <NUM_LIT:4> , '<STR_LIT>' ) , Enum ( <NUM_LIT:5> , '<STR_LIT>' ) , Enum ( <NUM_LIT:6> , '<STR_LIT>' ) ] <EOL> class rptrGroupLastOperStatusChange ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . TimeTicks <EOL> class rptrGroupPortCapacity ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrPortGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrPortIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrPortAdminStatus ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrPortAutoPartitionState ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrPortOperStatus ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) ] <EOL> class rptrPortRptrId ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrInfoId ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrInfoRptrType ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) , Enum ( <NUM_LIT:4> , '<STR_LIT>' ) ] <EOL> class rptrInfoOperStatus ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) ] <EOL> class rptrInfoReset ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrInfoPartitionedPorts ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Gauge32 <EOL> class rptrInfoLastChange ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . TimeStamp <EOL> class rptrMonitorGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrMonitorGroupTotalFrames ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorGroupTotalOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorGroupTotalErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrMonitorPortIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrMonitorPortReadableFrames ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortReadableOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortFCSErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortAlignmentErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortFrameTooLongs ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:7> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortShortEvents ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:8> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortRunts ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:9> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortCollisions ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:10> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortLateEvents ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:11> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortVeryLongEvents ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:12> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortDataRateMismatches ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortAutoPartitions ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortTotalErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:15> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortLastChange ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:16> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . TimeStamp <EOL> class rptrMonitorPortIsolates ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortSymbolErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortUpper32Octets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonitorPortHCReadableOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter64 <EOL> class rptrMonTxCollisions ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonTotalFrames ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonTotalErrors ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonTotalOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonUpper32TotalOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrMonHCTotalOctets ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter64 <EOL> class rptrAddrSearchLock ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . TestAndIncr <EOL> class rptrAddrSearchStatus ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) ] <EOL> class rptrAddrSearchAddress ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . MacAddress <EOL> class rptrAddrSearchState ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:4> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT:none>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) ] <EOL> class rptrAddrSearchGroup ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrAddrSearchPort ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrAddrSearchOwner ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:7> ] ) <EOL> syntaxobject = OwnerString <EOL> class rptrAddrTrackGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrAddrTrackPortIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrAddrTrackLastSourceAddress ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . MacAddress <EOL> class rptrAddrTrackSourceAddrChanges ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Counter32 <EOL> class rptrAddrTrackNewLastSrcAddress ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = OptMacAddr <EOL> class rptrAddrTrackCapacity ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrExtAddrTrackMacIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrExtAddrTrackSourceAddress ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . MacAddress <EOL> class rptrTopNPortControlIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortRepeaterId ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortRateBase ( ColumnObject ) : <EOL> status = <NUM_LIT:1> <EOL> access = <NUM_LIT:5> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Enumeration <EOL> enumerations = [ Enum ( <NUM_LIT:1> , '<STR_LIT>' ) , Enum ( <NUM_LIT:2> , '<STR_LIT>' ) , Enum ( <NUM_LIT:3> , '<STR_LIT>' ) , Enum ( <NUM_LIT:4> , '<STR_LIT>' ) , Enum ( <NUM_LIT:5> , '<STR_LIT>' ) , Enum ( <NUM_LIT:6> , '<STR_LIT>' ) , Enum ( <NUM_LIT:7> , '<STR_LIT>' ) , Enum ( <NUM_LIT:8> , '<STR_LIT>' ) , Enum ( <NUM_LIT:9> , '<STR_LIT>' ) , Enum ( <NUM_LIT:10> , '<STR_LIT>' ) , Enum ( <NUM_LIT:11> , '<STR_LIT>' ) , Enum ( <NUM_LIT:12> , '<STR_LIT>' ) , Enum ( <NUM_LIT> , '<STR_LIT>' ) , Enum ( <NUM_LIT> , '<STR_LIT>' ) , Enum ( <NUM_LIT:15> , '<STR_LIT>' ) ] <EOL> class rptrTopNPortTimeRemaining ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortDuration ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:5> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortRequestedSize ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:6> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortGrantedSize ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:7> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortStartTime ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:8> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . TimeStamp <EOL> class rptrTopNPortOwner ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:9> ] ) <EOL> syntaxobject = OwnerString <EOL> class rptrTopNPortRowStatus ( ColumnObject ) : <EOL> access = <NUM_LIT:5> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:10> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . RowStatus <EOL> class rptrTopNPortIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortGroupIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortPortIndex ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Integer32 <EOL> class rptrTopNPortRate ( ColumnObject ) : <EOL> access = <NUM_LIT:4> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:4> ] ) <EOL> syntaxobject = pycopia . SMI . Basetypes . Gauge32 <EOL> class rptrGroupEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrGroupIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrGroupIndex , '<STR_LIT>' : rptrGroupDescr , '<STR_LIT>' : rptrGroupObjectID , '<STR_LIT>' : rptrGroupOperStatus , '<STR_LIT>' : rptrGroupLastOperStatusChange , '<STR_LIT>' : rptrGroupPortCapacity } <EOL> class rptrPortEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrPortGroupIndex , rptrPortIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrPortGroupIndex , '<STR_LIT>' : rptrPortIndex , '<STR_LIT>' : rptrPortAdminStatus , '<STR_LIT>' : rptrPortAutoPartitionState , '<STR_LIT>' : rptrPortOperStatus , '<STR_LIT>' : rptrPortRptrId } <EOL> class rptrInfoEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrInfoId ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrInfoId , '<STR_LIT>' : rptrInfoRptrType , '<STR_LIT>' : rptrInfoOperStatus , '<STR_LIT>' : rptrInfoReset , '<STR_LIT>' : rptrInfoPartitionedPorts , '<STR_LIT>' : rptrInfoLastChange } <EOL> class rptrMonitorGroupEntry ( RowObject ) : <EOL> status = <NUM_LIT:2> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrMonitorGroupIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrMonitorGroupIndex , '<STR_LIT>' : rptrMonitorGroupTotalFrames , '<STR_LIT>' : rptrMonitorGroupTotalOctets , '<STR_LIT>' : rptrMonitorGroupTotalErrors } <EOL> class rptrMonitorPortEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrMonitorPortGroupIndex , rptrMonitorPortIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrMonitorPortGroupIndex , '<STR_LIT>' : rptrMonitorPortIndex , '<STR_LIT>' : rptrMonitorPortReadableFrames , '<STR_LIT>' : rptrMonitorPortReadableOctets , '<STR_LIT>' : rptrMonitorPortFCSErrors , '<STR_LIT>' : rptrMonitorPortAlignmentErrors , '<STR_LIT>' : rptrMonitorPortFrameTooLongs , '<STR_LIT>' : rptrMonitorPortShortEvents , '<STR_LIT>' : rptrMonitorPortRunts , '<STR_LIT>' : rptrMonitorPortCollisions , '<STR_LIT>' : rptrMonitorPortLateEvents , '<STR_LIT>' : rptrMonitorPortVeryLongEvents , '<STR_LIT>' : rptrMonitorPortDataRateMismatches , '<STR_LIT>' : rptrMonitorPortAutoPartitions , '<STR_LIT>' : rptrMonitorPortTotalErrors , '<STR_LIT>' : rptrMonitorPortLastChange } <EOL> class rptrMonitor100PortEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrMonitorPortGroupIndex , rptrMonitorPortIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrMonitorPortIsolates , '<STR_LIT>' : rptrMonitorPortSymbolErrors , '<STR_LIT>' : rptrMonitorPortUpper32Octets , '<STR_LIT>' : rptrMonitorPortHCReadableOctets } <EOL> class rptrMonEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrInfoId ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrMonTxCollisions , '<STR_LIT>' : rptrMonTotalFrames , '<STR_LIT>' : rptrMonTotalErrors , '<STR_LIT>' : rptrMonTotalOctets } <EOL> class rptrMon100Entry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrInfoId ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrMonUpper32TotalOctets , '<STR_LIT>' : rptrMonHCTotalOctets } <EOL> class rptrAddrSearchEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrInfoId ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrAddrSearchLock , '<STR_LIT>' : rptrAddrSearchStatus , '<STR_LIT>' : rptrAddrSearchAddress , '<STR_LIT>' : rptrAddrSearchState , '<STR_LIT>' : rptrAddrSearchGroup , '<STR_LIT>' : rptrAddrSearchPort , '<STR_LIT>' : rptrAddrSearchOwner } <EOL> class rptrAddrTrackEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrAddrTrackGroupIndex , rptrAddrTrackPortIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrAddrTrackGroupIndex , '<STR_LIT>' : rptrAddrTrackPortIndex , '<STR_LIT>' : rptrAddrTrackLastSourceAddress , '<STR_LIT>' : rptrAddrTrackSourceAddrChanges , '<STR_LIT>' : rptrAddrTrackNewLastSrcAddress , '<STR_LIT>' : rptrAddrTrackCapacity } <EOL> class rptrExtAddrTrackEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrAddrTrackGroupIndex , rptrAddrTrackPortIndex , rptrExtAddrTrackMacIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrExtAddrTrackMacIndex , '<STR_LIT>' : rptrExtAddrTrackSourceAddress } <EOL> class rptrTopNPortControlEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrTopNPortControlIndex ] , False ) <EOL> create = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> rowstatus = rptrTopNPortRowStatus <EOL> columns = { '<STR_LIT>' : rptrTopNPortControlIndex , '<STR_LIT>' : rptrTopNPortRepeaterId , '<STR_LIT>' : rptrTopNPortRateBase , '<STR_LIT>' : rptrTopNPortTimeRemaining , '<STR_LIT>' : rptrTopNPortDuration , '<STR_LIT>' : rptrTopNPortRequestedSize , '<STR_LIT>' : rptrTopNPortGrantedSize , '<STR_LIT>' : rptrTopNPortStartTime , '<STR_LIT>' : rptrTopNPortOwner , '<STR_LIT>' : rptrTopNPortRowStatus } <EOL> class rptrTopNPortEntry ( RowObject ) : <EOL> status = <NUM_LIT:1> <EOL> index = pycopia . SMI . Objects . IndexObjects ( [ rptrTopNPortControlIndex , rptrTopNPortIndex ] , False ) <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> access = <NUM_LIT:2> <EOL> columns = { '<STR_LIT>' : rptrTopNPortIndex , '<STR_LIT>' : rptrTopNPortGroupIndex , '<STR_LIT>' : rptrTopNPortPortIndex , '<STR_LIT>' : rptrTopNPortRate } <EOL> class rptrHealth ( NotificationObject ) : <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:1> ] ) <EOL> class rptrGroupChange ( NotificationObject ) : <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:2> ] ) <EOL> class rptrResetEvent ( NotificationObject ) : <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:3> ] ) <EOL> class rptrInfoHealth ( NotificationObject ) : <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:4> ] ) <EOL> class rptrInfoResetEvent ( NotificationObject ) : <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:5> ] ) <EOL> class snmpRptrGrpBasic1516 ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> group = [ rptrGroupCapacity , rptrOperStatus , rptrHealthText , rptrReset , rptrNonDisruptTest , rptrTotalPartitionedPorts , rptrGroupIndex , rptrGroupDescr , rptrGroupObjectID , rptrGroupOperStatus , rptrGroupLastOperStatusChange , rptrGroupPortCapacity , rptrPortGroupIndex , rptrPortIndex , rptrPortAdminStatus , rptrPortAutoPartitionState , rptrPortOperStatus ] <EOL> class snmpRptrGrpMonitor1516 ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ] ) <EOL> group = [ rptrMonitorTransmitCollisions , rptrMonitorGroupIndex , rptrMonitorGroupTotalFrames , rptrMonitorGroupTotalOctets , rptrMonitorGroupTotalErrors , rptrMonitorPortGroupIndex , rptrMonitorPortIndex , rptrMonitorPortReadableFrames , rptrMonitorPortReadableOctets , rptrMonitorPortFCSErrors , rptrMonitorPortAlignmentErrors , rptrMonitorPortFrameTooLongs , rptrMonitorPortShortEvents , rptrMonitorPortRunts , rptrMonitorPortCollisions , rptrMonitorPortLateEvents , rptrMonitorPortVeryLongEvents , rptrMonitorPortDataRateMismatches , rptrMonitorPortAutoPartitions , rptrMonitorPortTotalErrors ] <EOL> class snmpRptrGrpAddrTrack1516 ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:2> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> ] ) <EOL> group = [ rptrAddrTrackGroupIndex , rptrAddrTrackPortIndex , rptrAddrTrackLastSourceAddress , rptrAddrTrackSourceAddrChanges , rptrAddrTrackNewLastSrcAddress ] <EOL> class snmpRptrGrpBasic ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> ] ) <EOL> group = [ rptrGroupIndex , rptrGroupObjectID , rptrGroupOperStatus , rptrGroupPortCapacity , rptrPortGroupIndex , rptrPortIndex , rptrPortAdminStatus , rptrPortAutoPartitionState , rptrPortOperStatus , rptrPortRptrId , rptrInfoId , rptrInfoRptrType , rptrInfoOperStatus , rptrInfoReset , rptrInfoPartitionedPorts , rptrInfoLastChange ] <EOL> class snmpRptrGrpMonitor ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:6> ] ) <EOL> group = [ rptrMonitorPortGroupIndex , rptrMonitorPortIndex , rptrMonitorPortReadableFrames , rptrMonitorPortReadableOctets , rptrMonitorPortFCSErrors , rptrMonitorPortAlignmentErrors , rptrMonitorPortFrameTooLongs , rptrMonitorPortShortEvents , rptrMonitorPortRunts , rptrMonitorPortCollisions , rptrMonitorPortLateEvents , rptrMonitorPortVeryLongEvents , rptrMonitorPortDataRateMismatches , rptrMonitorPortAutoPartitions , rptrMonitorPortTotalErrors , rptrMonitorPortLastChange , rptrMonTxCollisions , rptrMonTotalFrames , rptrMonTotalErrors , rptrMonTotalOctets ] <EOL> class snmpRptrGrpMonitor100 ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:7> ] ) <EOL> group = [ rptrMonitorPortIsolates , rptrMonitorPortSymbolErrors , rptrMonitorPortUpper32Octets , rptrMonUpper32TotalOctets ] <EOL> class snmpRptrGrpMonitor100w64 ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:8> ] ) <EOL> group = [ rptrMonitorPortHCReadableOctets , rptrMonHCTotalOctets ] <EOL> class snmpRptrGrpAddrTrack ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:9> ] ) <EOL> group = [ rptrAddrTrackGroupIndex , rptrAddrTrackPortIndex , rptrAddrTrackSourceAddrChanges , rptrAddrTrackNewLastSrcAddress , rptrAddrTrackCapacity ] <EOL> class snmpRptrGrpExtAddrTrack ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:10> ] ) <EOL> group = [ rptrExtAddrTrackMacIndex , rptrExtAddrTrackSourceAddress ] <EOL> class snmpRptrGrpRptrAddrSearch ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:11> ] ) <EOL> group = [ rptrAddrSearchLock , rptrAddrSearchStatus , rptrAddrSearchAddress , rptrAddrSearchState , rptrAddrSearchGroup , rptrAddrSearchPort , rptrAddrSearchOwner ] <EOL> class snmpRptrGrpTopNPort ( GroupObject ) : <EOL> access = <NUM_LIT:2> <EOL> status = <NUM_LIT:1> <EOL> OID = pycopia . SMI . Basetypes . ObjectIdentifier ( [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:12> ] ) <EOL> group = [ rptrTopNPortControlIndex , rptrTopNPortRepeaterId , rptrTopNPortRateBase , rptrTopNPortTimeRemaining , rptrTopNPortDuration , rptrTopNPortRequestedSize , rptrTopNPortGrantedSize , rptrTopNPortStartTime , rptrTopNPortOwner , rptrTopNPortRowStatus , rptrTopNPortIndex , rptrTopNPortGroupIndex , rptrTopNPortPortIndex , rptrTopNPortRate ] <EOL> from pycopia import SMI <EOL> SMI . update_oidmap ( __name__ ) </s>
<s> """<STR_LIT>""" <EOL> import unittest <EOL> import pycopia . mibs <EOL> import pycopia . SMI <EOL> from pycopia . mibs import SNMPv2_SMI , SNMPv2_MIB <EOL> class MibsTests ( unittest . TestCase ) : <EOL> def test_import ( self ) : <EOL> self . assertEqual ( pycopia . SMI . OIDMAP [ '<STR_LIT>' ] . OID , [ <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
<s> """<STR_LIT>""" <EOL> import sys <EOL> from pycopia import socket <EOL> class GenericServer ( object ) : <EOL> def __init__ ( self , port , host = "<STR_LIT>" ) : <EOL> self . _sock = socket . tcp_listener ( ( host , port ) , <NUM_LIT:1> ) <EOL> def listen ( self ) : <EOL> conn , addr = self . _sock . accept ( ) <EOL> print "<STR_LIT>" , addr <EOL> while <NUM_LIT:1> : <EOL> data = conn . recv ( <NUM_LIT> ) <EOL> if not data : <EOL> break <EOL> conn . send ( data ) <EOL> conn . close ( ) <EOL> def run ( self ) : <EOL> try : <EOL> while <NUM_LIT:1> : <EOL> self . listen ( ) <EOL> except KeyboardInterrupt : <EOL> return <EOL> class GenericClient ( object ) : <EOL> def __init__ ( self , host , port ) : <EOL> self . _sock = socket . connect_tcp ( host , port ) <EOL> def run ( self ) : <EOL> try : <EOL> try : <EOL> while <NUM_LIT:1> : <EOL> line = raw_input ( "<STR_LIT>" ) <EOL> self . _sock . send ( line ) <EOL> data = self . _sock . recv ( <NUM_LIT> ) <EOL> if not data : <EOL> break <EOL> else : <EOL> print data <EOL> except KeyboardInterrupt : <EOL> pass <EOL> finally : <EOL> self . _sock . close ( ) <EOL> def get_tcp_server ( port , addr = "<STR_LIT>" ) : <EOL> return GenericServer ( port , addr ) <EOL> def get_tcp_client ( addr , port ) : <EOL> return GenericClient ( addr , port ) <EOL> def _test ( argv ) : <EOL> if len ( argv ) > <NUM_LIT:1> : <EOL> if "<STR_LIT>" in argv : <EOL> s = get_tcp_server ( <NUM_LIT> , "<STR_LIT>" ) <EOL> s . run ( ) <EOL> elif "<STR_LIT:-c>" in argv : <EOL> c = get_tcp_client ( "<STR_LIT:localhost>" , <NUM_LIT> ) <EOL> print "<STR_LIT>" <EOL> c . run ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> _test ( sys . argv ) </s>
<s> """<STR_LIT>""" </s>
<s> import sys , os <EOL> from setuptools import setup <EOL> from glob import glob <EOL> NAME = "<STR_LIT>" <EOL> VERSION = "<STR_LIT:1.0>" <EOL> def get_vimvar ( ) : <EOL> from pycopia import proctools <EOL> proc = proctools . spawnpty ( "<STR_LIT>" ) <EOL> proc . write ( "<STR_LIT>" ) <EOL> proc . write ( "<STR_LIT>" ) <EOL> var = proc . read ( ) <EOL> proc . wait ( ) <EOL> proctools . remove_procmanager ( ) <EOL> start = <NUM_LIT:0> <EOL> s = [ ] <EOL> for c in var : <EOL> if not start : <EOL> if c != "<STR_LIT:/>" : <EOL> continue <EOL> else : <EOL> start = <NUM_LIT:1> <EOL> if c . isalnum ( ) or c . isspace ( ) or c == "<STR_LIT:/>" : <EOL> s . append ( c ) <EOL> else : <EOL> break <EOL> return "<STR_LIT>" . join ( s ) <EOL> def get_vimfiles ( ) : <EOL> VIM = get_vimvar ( ) <EOL> vimfiles = os . path . join ( VIM , "<STR_LIT>" ) <EOL> vimsyntax = os . path . join ( VIM , "<STR_LIT>" , "<STR_LIT>" ) <EOL> vimcolors = os . path . join ( VIM , "<STR_LIT>" , "<STR_LIT>" ) <EOL> return [ ( vimfiles , glob ( "<STR_LIT>" ) ) , <EOL> ( vimcolors , glob ( "<STR_LIT>" ) ) , <EOL> ( vimsyntax , glob ( "<STR_LIT>" ) ) , <EOL> ] <EOL> if sys . platform not in ( "<STR_LIT:win32>" , "<STR_LIT>" ) : <EOL> try : <EOL> DATA_FILES = get_vimfiles ( ) <EOL> except ( ImportError , AttributeError ) : <EOL> DATA_FILES = [ ] <EOL> else : <EOL> DATA_FILES = [ ] <EOL> setup ( name = NAME , version = VERSION , <EOL> namespace_packages = [ "<STR_LIT>" ] , <EOL> packages = [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> test_suite = "<STR_LIT>" , <EOL> zip_safe = False , <EOL> data_files = DATA_FILES , <EOL> scripts = glob ( "<STR_LIT>" ) , <EOL> dependency_links = [ <EOL> "<STR_LIT>" <EOL> ] , <EOL> description = "<STR_LIT>" , <EOL> long_description = """<STR_LIT>""" , <EOL> license = "<STR_LIT>" , <EOL> author = "<STR_LIT>" , <EOL> author_email = "<STR_LIT>" , <EOL> keywords = "<STR_LIT>" , <EOL> url = "<STR_LIT>" , <EOL> classifiers = [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> ) <EOL> if not DATA_FILES : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" ) </s>
<s> '''<STR_LIT>''' <EOL> import os <EOL> from setuptools import setup <EOL> module_path = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> version_line = filter ( lambda l : l . startswith ( '<STR_LIT>' ) , <EOL> open ( module_path ) ) [ <NUM_LIT:0> ] <EOL> __version__ = '<STR_LIT:.>' . join ( eval ( version_line . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] ) ) <EOL> setup ( <EOL> name = '<STR_LIT>' , <EOL> version = __version__ , <EOL> url = '<STR_LIT>' , <EOL> license = '<STR_LIT>' , <EOL> author = '<STR_LIT>' , <EOL> author_email = '<STR_LIT>' , <EOL> description = '<STR_LIT>' , <EOL> long_description = __doc__ , <EOL> py_modules = [ <EOL> '<STR_LIT>' <EOL> ] , <EOL> zip_safe = False , <EOL> platforms = '<STR_LIT>' , <EOL> install_requires = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> test_suite = '<STR_LIT>' , <EOL> classifiers = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> ) </s>
<s> import collections <EOL> import inspect <EOL> import time <EOL> import random <EOL> import selenium <EOL> from selenium . webdriver import Ie , Opera , Chrome , Firefox , PhantomJS <EOL> from selenium . webdriver . remote . webdriver import WebDriver <EOL> from selenium . webdriver . remote . webelement import WebElement <EOL> from selenium . webdriver . support . ui import WebDriverWait <EOL> from selenium . webdriver . support . ui import Select <EOL> from selenium . common . exceptions import ( NoSuchElementException , TimeoutException , <EOL> WebDriverException , ElementNotVisibleException , <EOL> NoAlertPresentException ) <EOL> from selenium . webdriver . common . desired_capabilities import DesiredCapabilities <EOL> def create ( drivername , * args , ** kwargs ) : <EOL> if not isinstance ( drivername , str ) : <EOL> msg = "<STR_LIT>" . format ( type ( drivername ) ) <EOL> raise TypeError ( msg ) <EOL> drivers = { '<STR_LIT>' : Ie , <EOL> '<STR_LIT>' : Opera , <EOL> '<STR_LIT>' : Chrome , <EOL> '<STR_LIT>' : Firefox , <EOL> '<STR_LIT>' : PhantomJS } <EOL> dname = drivername . lower ( ) <EOL> if dname in drivers : <EOL> try : <EOL> return SeleniumWrapper ( drivers [ dname ] ( * args , ** kwargs ) ) <EOL> except Exception as e : <EOL> raise e <EOL> else : <EOL> msg = "<STR_LIT>" . join ( ( "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( drivername ) ) ) <EOL> raise ValueError ( msg ) <EOL> def connect ( drivername , executor , custom_capabilities = None , ** kwargs ) : <EOL> if not isinstance ( drivername , str ) : <EOL> msg = "<STR_LIT>" . format ( type ( drivername ) ) <EOL> raise TypeError ( msg ) <EOL> if not isinstance ( executor , str ) : <EOL> msg = "<STR_LIT>" . format ( type ( executor ) ) <EOL> raise TypeError ( msg ) <EOL> if custom_capabilities and not isinstance ( custom_capabilities , dict ) : <EOL> msg = "<STR_LIT>" . format ( type ( custom_capabilities ) ) <EOL> raise TypeError ( msg ) <EOL> capabilities = { '<STR_LIT>' : DesiredCapabilities . INTERNETEXPLORER , <EOL> '<STR_LIT>' : DesiredCapabilities . OPERA , <EOL> '<STR_LIT>' : DesiredCapabilities . CHROME , <EOL> '<STR_LIT>' : DesiredCapabilities . FIREFOX , <EOL> '<STR_LIT>' : DesiredCapabilities . ANDROID , <EOL> '<STR_LIT>' : DesiredCapabilities . PHANTOMJS } <EOL> dname = drivername . lower ( ) <EOL> if dname in capabilities : <EOL> capability = capabilities [ dname ] <EOL> custom_capabilities = custom_capabilities or { } <EOL> for key in custom_capabilities : <EOL> capability [ key ] = custom_capabilities [ key ] <EOL> driver = selenium . webdriver . Remote ( executor , capability , ** kwargs ) <EOL> try : <EOL> return SeleniumWrapper ( driver ) <EOL> except Exception as e : <EOL> raise e <EOL> else : <EOL> msg = "<STR_LIT>" . join ( ( "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( drivername ) ) ) <EOL> raise ValueError ( msg ) <EOL> def _is_wrappable ( obj ) : <EOL> if isinstance ( obj , WebDriver ) or isinstance ( obj , WebElement ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def _chainreact ( __getattr__ ) : <EOL> def containment ( * methodname ) : <EOL> def wrap_or_else ( obj ) : <EOL> if _is_wrappable ( obj ) : <EOL> return SeleniumWrapper ( obj ) <EOL> else : <EOL> return obj <EOL> self , methodobj = __getattr__ ( * methodname ) <EOL> if inspect . isroutine ( methodobj ) : <EOL> def reaction ( * realargs ) : <EOL> result = methodobj ( * realargs ) <EOL> return wrap_or_else ( result ) <EOL> return reaction <EOL> else : <EOL> return wrap_or_else ( methodobj ) <EOL> return containment <EOL> class Performance ( object ) : <EOL> def __init__ ( self , performance ) : <EOL> if not isinstance ( performance , dict ) : <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> self . _performance = performance <EOL> @ property <EOL> def memory ( self ) : <EOL> if '<STR_LIT>' in self . _performance : <EOL> return Memory ( self . _performance [ '<STR_LIT>' ] ) <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> @ property <EOL> def navigation ( self ) : <EOL> if '<STR_LIT>' in self . _performance : <EOL> return Navigation ( self . _performance [ '<STR_LIT>' ] ) <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> @ property <EOL> def timing ( self ) : <EOL> if '<STR_LIT>' in self . _performance : <EOL> return Timing ( self . _performance [ '<STR_LIT>' ] ) <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> class Memory ( object ) : <EOL> def __init__ ( self , memory ) : <EOL> self . _memory = memory <EOL> def __getattr__ ( self , name ) : <EOL> return self . _memory [ name ] <EOL> @ property <EOL> def __dict__ ( self ) : <EOL> return self . _memory <EOL> def __iter__ ( self ) : <EOL> return iter ( self . _memory ) <EOL> class Navigation ( object ) : <EOL> def __init__ ( self , navigation ) : <EOL> self . _navigation = navigation <EOL> def __getattr__ ( self , name ) : <EOL> return self . _navigation [ name ] <EOL> @ property <EOL> def __dict__ ( self ) : <EOL> return self . _navigation <EOL> def __iter__ ( self ) : <EOL> return iter ( self . _navigation ) <EOL> class Timing ( object ) : <EOL> def __init__ ( self , timing ) : <EOL> self . _timing = timing <EOL> def __getattr__ ( self , name ) : <EOL> return self . _timing [ name ] <EOL> @ property <EOL> def __dict__ ( self ) : <EOL> return self . _timing <EOL> def __iter__ ( self ) : <EOL> return iter ( self . _timing ) <EOL> class SeleniumWrapper ( object ) : <EOL> def __init__ ( self , driver , timeout = <NUM_LIT:5> , silent = False ) : <EOL> if _is_wrappable ( driver ) : <EOL> self . _wrapped = driver <EOL> self . _timeout = timeout <EOL> self . _silent = silent <EOL> else : <EOL> msg = "<STR_LIT>" . format ( type ( driver ) ) <EOL> raise TypeError ( msg ) <EOL> @ property <EOL> def unwrap ( self ) : <EOL> return self . _wrapped <EOL> @ property <EOL> def performance ( self ) : <EOL> if isinstance ( self . _wrapped , WebDriver ) : <EOL> if self . _wrapped . execute_script ( "<STR_LIT>" ) : <EOL> timeout = time . time ( ) + <NUM_LIT> <EOL> script = "<STR_LIT>" <EOL> executor = self . _wrapped . execute_script <EOL> while time . time ( ) < timeout and not executor ( script ) : <EOL> time . sleep ( <NUM_LIT> ) <EOL> if not executor ( script ) : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> performance = self . _wrapped . execute_script ( '<STR_LIT>' ) <EOL> return Performance ( performance ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> @ property <EOL> def parent ( self ) : <EOL> if isinstance ( self . _wrapped , WebElement ) : <EOL> return self . xpath ( "<STR_LIT>" , timeout = self . _timeout ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> @ property <EOL> def to_select ( self ) : <EOL> if self . _is_selectable ( ) : <EOL> return Select ( self . unwrap ) <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> @ property <EOL> def alert ( self ) : <EOL> timeout = time . time ( ) + self . _timeout <EOL> while time . time ( ) < timeout : <EOL> try : <EOL> alert = self . _wrapped . switch_to_alert ( ) <EOL> alert . text <EOL> return alert <EOL> except NoAlertPresentException : <EOL> time . sleep ( <NUM_LIT> ) <EOL> msg = "<STR_LIT>" <EOL> raise NoAlertPresentException ( msg ) <EOL> def _settimeout ( self , timeout ) : <EOL> if isinstance ( timeout , ( int , float ) ) : <EOL> self . _timeout = timeout <EOL> else : <EOL> raise AttributeError <EOL> def _gettimeout ( self ) : <EOL> return self . _timeout <EOL> timeout = property ( _gettimeout , _settimeout ) <EOL> @ property <EOL> def silent ( self ) : <EOL> return self . _silent <EOL> @ silent . setter <EOL> def silent ( self , true_of_false ) : <EOL> if not isinstance ( true_of_false , bool ) : <EOL> raise AttributeError <EOL> self . _silent = true_of_false <EOL> def __getattribute__ ( self , name ) : <EOL> return object . __getattribute__ ( self , name ) <EOL> @ _chainreact <EOL> def __getattr__ ( self , name ) : <EOL> return self . _wrapped , getattr ( self . _wrapped , name ) <EOL> def _is_selectable ( self ) : <EOL> return self . unwrap . tag_name == '<STR_LIT>' <EOL> def _is_stopping ( self , interval ) : <EOL> before = ( self . _wrapped . location [ '<STR_LIT:x>' ] , self . _wrapped . location [ '<STR_LIT:y>' ] ) <EOL> time . sleep ( interval ) <EOL> after = ( self . _wrapped . location [ '<STR_LIT:x>' ] , self . _wrapped . location [ '<STR_LIT:y>' ] ) <EOL> return before [ <NUM_LIT:0> ] == after [ <NUM_LIT:0> ] and before [ <NUM_LIT:1> ] == after [ <NUM_LIT:1> ] <EOL> def _wait_until_stopping ( self , timeout , interval ) : <EOL> timeout = time . time ( ) + timeout <EOL> while time . time ( ) < timeout : <EOL> if self . _is_stopping ( interval ) : <EOL> return True <EOL> else : <EOL> time . sleep ( interval ) <EOL> if not self . _is_stopping ( interval ) : <EOL> raise WebDriverException ( "<STR_LIT>" . format ( sec = timeout ) ) <EOL> def _wait_until_clickable ( self , timeout , interval ) : <EOL> err_messages = [ ] <EOL> endtime = time . time ( ) + timeout <EOL> while True : <EOL> try : <EOL> self . _wrapped . click ( ) <EOL> break <EOL> except WebDriverException as e : <EOL> err_messages . append ( e . msg . split ( "<STR_LIT::>" ) [ - <NUM_LIT:1> ] . strip ( ) ) <EOL> time . sleep ( interval ) <EOL> if ( time . time ( ) > endtime ) : <EOL> if err_messages : <EOL> template = ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> msg = "<STR_LIT>" . join ( template ) . format ( sec = timeout , err = err_messages ) <EOL> raise WebDriverException ( msg ) <EOL> def _wait_until_displayed ( self , timeout , interval ) : <EOL> try : <EOL> WebDriverWait ( self . _wrapped , timeout , interval ) . until ( lambda d : d . is_displayed ( ) ) <EOL> except TimeoutException : <EOL> template = ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> msg = "<STR_LIT>" . join ( template ) . format ( sec = timeout , target = self . _wrapped . tag_name , dumped = self . _dump ( ) ) <EOL> raise ElementNotVisibleException ( msg ) <EOL> def _dump ( self ) : <EOL> element = self . _wrapped <EOL> info = { "<STR_LIT>" : element . value_of_css_property ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" : element . value_of_css_property ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" : element . value_of_css_property ( "<STR_LIT>" ) , <EOL> "<STR_LIT:width>" : element . value_of_css_property ( "<STR_LIT:width>" ) , <EOL> "<STR_LIT:x>" : element . location [ "<STR_LIT:x>" ] , <EOL> "<STR_LIT:y>" : element . location [ "<STR_LIT:y>" ] } <EOL> dumped = "<STR_LIT:U+0020>" . join ( [ "<STR_LIT>" . format ( k = k , v = info [ k ] ) for k in info ] ) <EOL> return dumped <EOL> def attr ( self , name ) : <EOL> if isinstance ( self . _wrapped , WebElement ) : <EOL> return self . _wrapped . get_attribute ( name ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> def click ( self , timeout = None , presleep = <NUM_LIT:0> , postsleep = <NUM_LIT:0> ) : <EOL> timeout = timeout or self . _timeout <EOL> if isinstance ( self . _wrapped , WebElement ) : <EOL> try : <EOL> if presleep : <EOL> time . sleep ( presleep ) <EOL> self . _wait_until_stopping ( timeout , <NUM_LIT> ) <EOL> self . _wait_until_displayed ( timeout , <NUM_LIT> ) <EOL> self . _wait_until_clickable ( timeout , <NUM_LIT> ) <EOL> if postsleep : <EOL> time . sleep ( postsleep ) <EOL> except Exception as e : <EOL> raise e <EOL> def scroll_to ( self , x , y ) : <EOL> if isinstance ( self . _wrapped , WebDriver ) : <EOL> return self . _wrapped . execute_script ( "<STR_LIT>" . format ( x , y ) ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> def scroll_by ( self , x , y ) : <EOL> if isinstance ( self . _wrapped , WebDriver ) : <EOL> return self . _wrapped . execute_script ( "<STR_LIT>" . format ( x , y ) ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> def scroll_into_view ( self , jq_identifier , align_with_top = True ) : <EOL> if isinstance ( self . _wrapped , WebDriver ) : <EOL> if self . _wrapped . execute_script ( "<STR_LIT>" ) : <EOL> script_template = "<STR_LIT>" <EOL> script = script_template . format ( jq_identifier , '<STR_LIT:true>' if align_with_top else '<STR_LIT:false>' ) <EOL> self . _wrapped . execute_script ( script ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> else : <EOL> raise AttributeError ( "<STR_LIT>" ) <EOL> def waitfor ( self , type , target , eager = False , timeout = None ) : <EOL> timeout = timeout or self . _timeout <EOL> if eager : <EOL> types = { "<STR_LIT:id>" : lambda d : d . find_elements_by_id ( target ) , <EOL> "<STR_LIT:name>" : lambda d : d . find_elements_by_name ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_elements_by_xpath ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_elements_by_link_text ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_elements_by_partial_link_text ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_elements_by_tag_name ( target ) , <EOL> "<STR_LIT:class>" : lambda d : d . find_elements_by_class_name ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_elements_by_css_selector ( target ) , } <EOL> else : <EOL> types = { "<STR_LIT:id>" : lambda d : d . find_element_by_id ( target ) , <EOL> "<STR_LIT:name>" : lambda d : d . find_element_by_name ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_element_by_xpath ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_element_by_link_text ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_element_by_partial_link_text ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_element_by_tag_name ( target ) , <EOL> "<STR_LIT:class>" : lambda d : d . find_element_by_class_name ( target ) , <EOL> "<STR_LIT>" : lambda d : d . find_element_by_css_selector ( target ) , } <EOL> finder = types [ type ] <EOL> try : <EOL> result = WebDriverWait ( self . _wrapped , timeout ) . until ( finder ) <EOL> if eager and len ( result ) : <EOL> return SeleniumContainerWrapper ( result , self . timeout , self . silent ) <EOL> elif _is_wrappable ( result ) : <EOL> return SeleniumWrapper ( result , self . timeout , self . silent ) <EOL> else : <EOL> return result <EOL> except TimeoutException : <EOL> if self . silent : <EOL> return None <EOL> else : <EOL> template = ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> msg = "<STR_LIT>" . join ( template ) . format ( sec = timeout , type = type , target = target ) <EOL> raise NoSuchElementException ( msg ) <EOL> def xpath ( self , target , eager = False , timeout = None ) : <EOL> return self . waitfor ( "<STR_LIT>" , target , eager , timeout ) <EOL> def css ( self , target , eager = False , timeout = None ) : <EOL> return self . waitfor ( "<STR_LIT>" , target , eager , timeout ) <EOL> def by_tag ( self , tag , eager = False , timeout = None , ** attributes ) : <EOL> subjects = [ "<STR_LIT>" . format ( key = k , val = attributes [ k ] ) for k in attributes ] <EOL> subject = "<STR_LIT>" . join ( subjects ) <EOL> xpath = "<STR_LIT>" . format ( tag = tag , subject = subject ) if subject else "<STR_LIT>" . format ( tag = tag ) <EOL> return self . waitfor ( '<STR_LIT>' , xpath , eager , timeout ) <EOL> def by_text ( self , text , tag = "<STR_LIT:*>" , partial = False , eager = False , timeout = None ) : <EOL> if partial : <EOL> return self . xpath ( "<STR_LIT>" . format ( tag = tag , text = text ) , eager , timeout ) <EOL> return self . xpath ( "<STR_LIT>" . format ( tag = tag , text = text ) , eager , timeout ) <EOL> def by_class ( self , target , eager = False , timeout = None ) : <EOL> return self . waitfor ( "<STR_LIT:class>" , target , eager , timeout ) <EOL> def by_id ( self , target , eager = False , timeout = None ) : <EOL> return self . waitfor ( "<STR_LIT:id>" , target , eager , timeout ) <EOL> def by_name ( self , target , eager = False , timeout = None ) : <EOL> return self . waitfor ( "<STR_LIT:name>" , target , eager , timeout ) <EOL> def by_linktxt ( self , target , eager = False , timeout = None , partial = False ) : <EOL> if partial : <EOL> return self . waitfor ( "<STR_LIT>" , target , eager , timeout = None ) <EOL> else : <EOL> return self . waitfor ( "<STR_LIT>" , target , eager , timeout ) <EOL> def href ( self , partialurl = None , eager = False , timeout = None ) : <EOL> if partialurl : <EOL> return self . xpath ( "<STR_LIT>" . format ( partialurl ) , eager , timeout ) <EOL> return self . xpath ( "<STR_LIT>" , eager , timeout ) <EOL> def img ( self , alt = None , ext = None , eager = False , timeout = None ) : <EOL> options = [ ] <EOL> if alt : <EOL> options . append ( "<STR_LIT>" . format ( alt ) ) <EOL> if ext : <EOL> options . append ( "<STR_LIT>" . format ( ext ) ) <EOL> option = "<STR_LIT>" . join ( options ) <EOL> xpath = "<STR_LIT>" + "<STR_LIT>" . format ( option ) if option else "<STR_LIT>" <EOL> return self . xpath ( xpath , eager , timeout ) <EOL> def button ( self , value , eager = False , timeout = None ) : <EOL> return self . xpath ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( value ) , eager , timeout ) <EOL> def checkbox ( self , eager = False , timeout = None , ** attributes ) : <EOL> attributes [ "<STR_LIT:type>" ] = "<STR_LIT>" <EOL> return self . by_tag ( "<STR_LIT:input>" , eager , timeout , ** attributes ) <EOL> def radio ( self , eager = False , timeout = None , ** attributes ) : <EOL> attributes [ "<STR_LIT:type>" ] = "<STR_LIT>" <EOL> return self . by_tag ( "<STR_LIT:input>" , eager , timeout , ** attributes ) <EOL> def select ( self , eager = False , timeout = None , ** attributes ) : <EOL> selected = self . by_tag ( "<STR_LIT>" , eager , timeout , ** attributes ) <EOL> if isinstance ( selected , SeleniumWrapper ) and selected . _is_selectable ( ) : <EOL> return Select ( selected . unwrap ) <EOL> elif isinstance ( selected , SeleniumContainerWrapper ) : <EOL> iterable = selected . _iterable <EOL> selected . _iterable = [ Select ( element ) for element in iterable if element . tag_name == '<STR_LIT>' ] <EOL> return selected <EOL> else : <EOL> template = ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> msg = "<STR_LIT>" . join ( template ) . format ( sec = timeout , attr = attributes ) <EOL> raise NoSuchElementException ( msg ) <EOL> class SeleniumContainerWrapper ( object ) : <EOL> def __init__ ( self , iterable , timeout = <NUM_LIT:5> , silent = False ) : <EOL> if not isinstance ( iterable , collections . Sequence ) : <EOL> msg = "<STR_LIT>" . format ( type ( iterable ) ) <EOL> raise TypeError ( msg ) <EOL> self . _iterable = iterable <EOL> self . _timeout = timeout <EOL> self . _silent = silent <EOL> @ _chainreact <EOL> def __getattr__ ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . _iterable , getattr ( self . _iterable , name ) <EOL> def __getitem__ ( self , key ) : <EOL> obj = self . _iterable [ key ] <EOL> if _is_wrappable ( obj ) : <EOL> return SeleniumWrapper ( obj , self . _timeout , self . _silent ) <EOL> return obj <EOL> def __len__ ( self ) : <EOL> return len ( self . _iterable ) <EOL> def __contains__ ( self , key ) : <EOL> key = key . unwrap if isinstance ( key , SeleniumWrapper ) else key <EOL> return key in self . _iterable <EOL> @ property <EOL> def size ( self ) : <EOL> return len ( self . _iterable ) <EOL> def sample ( self , size ) : <EOL> picked = random . sample ( self . _iterable , size ) <EOL> if isinstance ( picked , collections . Sequence ) : <EOL> return SeleniumContainerWrapper ( picked , self . _timeout , self . _silent ) <EOL> return picked <EOL> def choice ( self ) : <EOL> picked = random . choice ( self . _iterable ) <EOL> if _is_wrappable ( picked ) : <EOL> return SeleniumWrapper ( picked , self . _timeout , self . _silent ) <EOL> else : <EOL> return picked </s>
<s> import click <EOL> import os <EOL> import json <EOL> import time <EOL> import multiprocessing <EOL> from retries import retries <EOL> from hodor . cli import pass_context <EOL> from hodor . gme import obey_qps <EOL> @ click . command ( '<STR_LIT>' , short_help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , type = str ) <EOL> @ click . option ( '<STR_LIT>' , default = <NUM_LIT:5> , <EOL> help = '<STR_LIT>' ) <EOL> @ click . argument ( '<STR_LIT>' , type = click . Path ( exists = True , file_okay = False , resolve_path = True ) ) <EOL> @ pass_context <EOL> def cli ( ctx , table_id , processes , payloaddir ) : <EOL> batchRequests ( ctx , table_id , processes , payloaddir , "<STR_LIT>" ) <EOL> def batchRequests ( ctx , table_id , processes , payloaddir , operation ) : <EOL> deltafiles = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> with open ( os . path . join ( payloaddir , deltafiles [ operation ] ) ) as f : <EOL> features = json . load ( f ) <EOL> chunks = [ ( features [ "<STR_LIT>" ] [ i : i + <NUM_LIT:50> ] , ctx , operation , table_id , i ) for i in range ( <NUM_LIT:0> , len ( features [ "<STR_LIT>" ] ) , <NUM_LIT:50> ) ] <EOL> start_time = time . time ( ) <EOL> pool = multiprocessing . Pool ( processes = processes ) <EOL> stuff = pool . map ( batchRequestsThread , chunks ) <EOL> pool . close ( ) <EOL> pool . join ( ) <EOL> elapsed_secs = time . time ( ) - start_time <EOL> ttl_features = len ( features [ "<STR_LIT>" ] ) <EOL> features_per_sec = int ( ttl_features / elapsed_secs ) <EOL> ctx . log ( "<STR_LIT>" % ( "<STR_LIT>" . format ( ttl_features ) , round ( elapsed_secs / <NUM_LIT> , <NUM_LIT:2> ) , features_per_sec ) ) <EOL> def batchRequestsThread ( blob ) : <EOL> @ obey_qps ( ) <EOL> @ retries ( <NUM_LIT:10> , delay = <NUM_LIT> , backoff = <NUM_LIT> ) <EOL> def request ( resource , table_id , chunk ) : <EOL> resource ( id = table_id , body = { "<STR_LIT>" : chunk } ) . execute ( ) <EOL> chunk , ctx , operation , table_id , start_index = blob <EOL> for f in chunk : <EOL> del f [ "<STR_LIT>" ] <EOL> for p in f [ "<STR_LIT>" ] : <EOL> if isinstance ( f [ "<STR_LIT>" ] [ p ] , int ) : <EOL> f [ "<STR_LIT>" ] [ p ] = str ( f [ "<STR_LIT>" ] [ p ] ) <EOL> start_time = time . time ( ) <EOL> batchOperation = getattr ( ctx . service ( ident = multiprocessing . current_process ( ) . ident ) . tables ( ) . features ( ) , operation ) <EOL> start_time = time . time ( ) <EOL> request ( batchOperation , table_id , chunk ) <EOL> ctx . log ( "<STR_LIT>" % ( start_index , start_index + <NUM_LIT:50> , round ( time . time ( ) - start_time , <NUM_LIT:2> ) ) ) </s>
<s> import unittest <EOL> from datetime import datetime <EOL> from mock import MagicMock , patch <EOL> from application . models . datastore . chat_member_model import * <EOL> class TestPostModel ( unittest . TestCase ) : <EOL> def test_chat_member_model_properties ( self ) : <EOL> self . patchers = [ <EOL> patch ( '<STR_LIT>' , new = MagicMock ( return_value = '<STR_LIT>' ) ) , <EOL> patch ( '<STR_LIT>' , new = MagicMock ( return_value = '<STR_LIT>' ) ) , <EOL> ] <EOL> for patcher in self . patchers : <EOL> patcher . start ( ) <EOL> member = ChatMemberModel ( ) <EOL> self . assertEqual ( member . name , '<STR_LIT>' ) <EOL> self . assertEqual ( member . name_lower , '<STR_LIT>' ) <EOL> self . assertEqual ( member . token , '<STR_LIT>' ) <EOL> self . assertEqual ( member . channel_token , '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( member . create_time , datetime ) ) <EOL> for patcher in self . patchers : <EOL> patcher . stop ( ) </s>
<s> from __future__ import absolute_import , unicode_literals , print_function , division <EOL> import tempfile <EOL> import re <EOL> import os <EOL> import sublime <EOL> import sublime_plugin <EOL> from . import git_root , GitTextCommand <EOL> class GitClearAnnotationCommand ( GitTextCommand ) : <EOL> def run ( self , view ) : <EOL> self . active_view ( ) . settings ( ) . set ( '<STR_LIT>' , False ) <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> class GitToggleAnnotationsCommand ( GitTextCommand ) : <EOL> def run ( self , view ) : <EOL> if self . active_view ( ) . settings ( ) . get ( '<STR_LIT>' ) : <EOL> self . view . run_command ( '<STR_LIT>' ) <EOL> else : <EOL> self . view . run_command ( '<STR_LIT>' ) <EOL> class GitAnnotationListener ( sublime_plugin . EventListener ) : <EOL> def on_modified ( self , view ) : <EOL> if not view . settings ( ) . get ( '<STR_LIT>' ) : <EOL> return <EOL> view . run_command ( '<STR_LIT>' ) <EOL> def on_load ( self , view ) : <EOL> s = sublime . load_settings ( "<STR_LIT>" ) <EOL> if s . get ( '<STR_LIT>' ) : <EOL> view . run_command ( '<STR_LIT>' ) <EOL> class GitAnnotateCommand ( GitTextCommand ) : <EOL> def run ( self , view ) : <EOL> if hasattr ( self , "<STR_LIT>" ) : <EOL> self . compare_tmp ( None ) <EOL> return <EOL> self . tmp = tempfile . NamedTemporaryFile ( ) <EOL> self . active_view ( ) . settings ( ) . set ( '<STR_LIT>' , True ) <EOL> root = git_root ( self . get_working_dir ( ) ) <EOL> repo_file = os . path . relpath ( self . view . file_name ( ) , root ) <EOL> self . run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' . format ( repo_file ) ] , show_status = False , no_save = True , callback = self . compare_tmp , stdout = self . tmp ) <EOL> def compare_tmp ( self , result , stdout = None ) : <EOL> all_text = self . view . substr ( sublime . Region ( <NUM_LIT:0> , self . view . size ( ) ) ) <EOL> self . run_command ( [ '<STR_LIT>' , '<STR_LIT>' , self . tmp . name , '<STR_LIT:->' ] , stdin = all_text , no_save = True , show_status = False , callback = self . parse_diff ) <EOL> def parse_diff ( self , result , stdin = None ) : <EOL> lines = result . splitlines ( ) <EOL> matcher = re . compile ( '<STR_LIT>' ) <EOL> diff = [ ] <EOL> for line_index in range ( <NUM_LIT:0> , len ( lines ) ) : <EOL> line = lines [ line_index ] <EOL> if not line . startswith ( '<STR_LIT:@>' ) : <EOL> continue <EOL> match = matcher . match ( line ) <EOL> if not match : <EOL> continue <EOL> line_before , len_before , line_after , len_after = [ int ( match . group ( x ) ) for x in [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ] <EOL> chunk_index = line_index + <NUM_LIT:1> <EOL> tracked_line_index = line_after - <NUM_LIT:1> <EOL> deletion = False <EOL> insertion = False <EOL> while True : <EOL> line = lines [ chunk_index ] <EOL> if line . startswith ( '<STR_LIT:@>' ) : <EOL> break <EOL> elif line . startswith ( '<STR_LIT:->' ) : <EOL> if not line . strip ( ) == '<STR_LIT:->' : <EOL> deletion = True <EOL> tracked_line_index -= <NUM_LIT:1> <EOL> elif line . startswith ( '<STR_LIT:+>' ) : <EOL> if deletion and not line . strip ( ) == '<STR_LIT:+>' : <EOL> diff . append ( [ '<STR_LIT:x>' , tracked_line_index ] ) <EOL> insertion = True <EOL> elif not deletion : <EOL> insertion = True <EOL> diff . append ( [ '<STR_LIT:+>' , tracked_line_index ] ) <EOL> else : <EOL> if not insertion and deletion : <EOL> diff . append ( [ '<STR_LIT:->' , tracked_line_index ] ) <EOL> insertion = deletion = False <EOL> tracked_line_index += <NUM_LIT:1> <EOL> chunk_index += <NUM_LIT:1> <EOL> if chunk_index >= len ( lines ) : <EOL> break <EOL> self . annotate ( diff ) <EOL> def annotate ( self , diff ) : <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> self . view . erase_regions ( '<STR_LIT>' ) <EOL> typed_diff = { '<STR_LIT:x>' : [ ] , '<STR_LIT:+>' : [ ] , '<STR_LIT:->' : [ ] } <EOL> for change_type , line in diff : <EOL> if change_type == '<STR_LIT:->' : <EOL> full_region = self . view . full_line ( self . view . text_point ( line - <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> position = full_region . begin ( ) <EOL> for i in range ( full_region . size ( ) ) : <EOL> typed_diff [ change_type ] . append ( sublime . Region ( position + i ) ) <EOL> else : <EOL> point = self . view . text_point ( line , <NUM_LIT:0> ) <EOL> region = self . view . full_line ( point ) <EOL> if change_type == '<STR_LIT:->' : <EOL> region = sublime . Region ( point , point + <NUM_LIT:5> ) <EOL> typed_diff [ change_type ] . append ( region ) <EOL> for change in [ '<STR_LIT:x>' , '<STR_LIT:+>' ] : <EOL> self . view . add_regions ( "<STR_LIT>" . format ( change ) , typed_diff [ change ] , '<STR_LIT>' . format ( change ) , '<STR_LIT>' , sublime . HIDDEN ) <EOL> self . view . add_regions ( "<STR_LIT>" , typed_diff [ '<STR_LIT:->' ] , '<STR_LIT>' , '<STR_LIT>' , sublime . DRAW_EMPTY_AS_OVERWRITE ) </s>
<s> import random <EOL> import string <EOL> import time <EOL> from distutils . version import StrictVersion <EOL> from mock import patch <EOL> from django import get_version <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . auth . models import AnonymousUser <EOL> from django . contrib . sessions . backends . db import SessionStore <EOL> from django . core . urlresolvers import NoReverseMatch <EOL> from django . core . urlresolvers import reverse <EOL> from django . http import HttpRequest <EOL> from django . test . client import RequestFactory <EOL> from . import utils <EOL> from . import config <EOL> from . connection import parse_redis_url , get_redis_connection <EOL> from . models import AccessAttempt <EOL> from . test import DefenderTestCase , DefenderTransactionTestCase <EOL> try : <EOL> LOGIN_FORM_KEY = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ADMIN_LOGIN_URL = reverse ( '<STR_LIT>' ) <EOL> except NoReverseMatch : <EOL> ADMIN_LOGIN_URL = reverse ( '<STR_LIT>' ) <EOL> LOGIN_FORM_KEY = '<STR_LIT>' <EOL> DJANGO_VERSION = StrictVersion ( get_version ( ) ) <EOL> VALID_USERNAME = VALID_PASSWORD = '<STR_LIT>' <EOL> class AccessAttemptTest ( DefenderTestCase ) : <EOL> """<STR_LIT>""" <EOL> LOCKED_MESSAGE = '<STR_LIT>' <EOL> PERMANENT_LOCKED_MESSAGE = ( <EOL> LOCKED_MESSAGE + '<STR_LIT>' <EOL> ) <EOL> def _get_random_str ( self ) : <EOL> """<STR_LIT>""" <EOL> chars = string . ascii_uppercase + string . digits <EOL> return '<STR_LIT>' . join ( random . choice ( chars ) for x in range ( <NUM_LIT:20> ) ) <EOL> def _login ( self , username = None , password = None , user_agent = '<STR_LIT>' , <EOL> remote_addr = '<STR_LIT:127.0.0.1>' ) : <EOL> """<STR_LIT>""" <EOL> if username is None : <EOL> username = self . _get_random_str ( ) <EOL> if password is None : <EOL> password = self . _get_random_str ( ) <EOL> response = self . client . post ( ADMIN_LOGIN_URL , { <EOL> '<STR_LIT:username>' : username , <EOL> '<STR_LIT:password>' : password , <EOL> LOGIN_FORM_KEY : <NUM_LIT:1> , <EOL> } , HTTP_USER_AGENT = user_agent , REMOTE_ADDR = remote_addr ) <EOL> return response <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . user = User . objects . create_superuser ( <EOL> username = VALID_USERNAME , <EOL> email = '<STR_LIT>' , <EOL> password = VALID_PASSWORD , <EOL> ) <EOL> def test_data_integrity_of_get_blocked_ips ( self ) : <EOL> """<STR_LIT>""" <EOL> data_in = [ '<STR_LIT:127.0.0.1>' , '<STR_LIT>' ] <EOL> for ip in data_in : <EOL> utils . block_ip ( ip ) <EOL> data_out = utils . get_blocked_ips ( ) <EOL> self . assertEqual ( sorted ( data_in ) , sorted ( data_out ) ) <EOL> utils . block_ip ( None ) <EOL> data_out = utils . get_blocked_ips ( ) <EOL> self . assertEqual ( sorted ( data_in ) , sorted ( data_out ) ) <EOL> def test_data_integrity_of_get_blocked_usernames ( self ) : <EOL> """<STR_LIT>""" <EOL> data_in = [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> for username in data_in : <EOL> utils . block_username ( username ) <EOL> data_out = utils . get_blocked_usernames ( ) <EOL> self . assertEqual ( sorted ( data_in ) , sorted ( data_out ) ) <EOL> utils . block_username ( None ) <EOL> data_out = utils . get_blocked_usernames ( ) <EOL> self . assertEqual ( sorted ( data_in ) , sorted ( data_out ) ) <EOL> def test_login_get ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_failure_limit_by_ip_once ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_failure_limit_by_ip_many ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> for i in range ( <NUM_LIT:0> , random . randrange ( <NUM_LIT:1> , <NUM_LIT:10> ) ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_failure_limit_by_username_once ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> ip = '<STR_LIT>' . format ( i ) <EOL> response = self . _login ( username = VALID_USERNAME , remote_addr = ip ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_valid_login ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _login ( username = VALID_USERNAME , <EOL> password = VALID_PASSWORD ) <EOL> self . assertNotContains ( response , LOGIN_FORM_KEY , status_code = <NUM_LIT> ) <EOL> def test_reset_after_valid_login ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> self . _login ( username = VALID_USERNAME ) <EOL> self . _login ( username = VALID_USERNAME , password = VALID_PASSWORD ) <EOL> response = self . _login ( username = VALID_USERNAME ) <EOL> self . assertNotContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_blocked_ip_cannot_login ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT + <NUM_LIT:1> ) : <EOL> response = self . _login ( username = VALID_USERNAME ) <EOL> response = self . _login ( username = '<STR_LIT>' ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_blocked_username_cannot_login ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT + <NUM_LIT:1> ) : <EOL> ip = '<STR_LIT>' . format ( i ) <EOL> response = self . _login ( username = VALID_USERNAME , remote_addr = ip ) <EOL> response = self . _login ( username = VALID_USERNAME , remote_addr = '<STR_LIT>' ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_cooling_off ( self ) : <EOL> """<STR_LIT>""" <EOL> self . test_failure_limit_by_ip_once ( ) <EOL> time . sleep ( config . COOLOFF_TIME ) <EOL> if config . MOCK_REDIS : <EOL> get_redis_connection ( ) . do_expire ( ) <EOL> self . test_valid_login ( ) <EOL> def test_cooling_off_for_trusted_user ( self ) : <EOL> """<STR_LIT>""" <EOL> self . test_cooling_off ( ) <EOL> def test_long_user_agent_valid ( self ) : <EOL> """<STR_LIT>""" <EOL> long_user_agent = '<STR_LIT>' * <NUM_LIT> <EOL> response = self . _login ( username = VALID_USERNAME , password = VALID_PASSWORD , <EOL> user_agent = long_user_agent ) <EOL> self . assertNotContains ( response , LOGIN_FORM_KEY , status_code = <NUM_LIT> ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_get_ip_reverse_proxy ( self ) : <EOL> """<STR_LIT>""" <EOL> request_factory = RequestFactory ( ) <EOL> request = request_factory . get ( ADMIN_LOGIN_URL ) <EOL> request . user = AnonymousUser ( ) <EOL> request . session = SessionStore ( ) <EOL> request . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( utils . get_ip ( request ) , '<STR_LIT>' ) <EOL> request_factory = RequestFactory ( ) <EOL> request = request_factory . get ( ADMIN_LOGIN_URL ) <EOL> request . user = AnonymousUser ( ) <EOL> request . session = SessionStore ( ) <EOL> request . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( utils . get_ip ( request ) , '<STR_LIT>' ) <EOL> def test_get_ip ( self ) : <EOL> """<STR_LIT>""" <EOL> request_factory = RequestFactory ( ) <EOL> request = request_factory . get ( ADMIN_LOGIN_URL ) <EOL> request . user = AnonymousUser ( ) <EOL> request . session = SessionStore ( ) <EOL> self . assertEqual ( utils . get_ip ( request ) , '<STR_LIT:127.0.0.1>' ) <EOL> def test_long_user_agent_not_valid ( self ) : <EOL> """<STR_LIT>""" <EOL> long_user_agent = '<STR_LIT>' * <NUM_LIT> <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT + <NUM_LIT:1> ) : <EOL> response = self . _login ( user_agent = long_user_agent ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_reset_ip ( self ) : <EOL> """<STR_LIT>""" <EOL> self . test_failure_limit_by_ip_once ( ) <EOL> utils . reset_failed_attempts ( ip_address = '<STR_LIT:127.0.0.1>' ) <EOL> self . test_valid_login ( ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_failed_login_redirect_to_URL ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_failed_login_redirect_to_URL_local ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> lockout_url = '<STR_LIT>' <EOL> if DJANGO_VERSION >= StrictVersion ( '<STR_LIT>' ) : <EOL> lockout_url = '<STR_LIT>' <EOL> response = self . _login ( ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , lockout_url ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( response [ '<STR_LIT>' ] , lockout_url ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_failed_login_redirect_to_template ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> def test_failed_login_no_cooloff ( self ) : <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . PERMANENT_LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , self . PERMANENT_LOCKED_MESSAGE ) <EOL> def test_login_attempt_model ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> self . assertEqual ( AccessAttempt . objects . count ( ) , <NUM_LIT:1> ) <EOL> self . assertIsNotNone ( str ( AccessAttempt . objects . all ( ) [ <NUM_LIT:0> ] ) ) <EOL> def test_is_valid_ip ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT:127.0.0.1>' ) , True ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , False ) <EOL> self . assertEqual ( utils . is_valid_ip ( None ) , False ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , False ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , False ) <EOL> self . assertEqual ( utils . is_valid_ip ( '<STR_LIT>' ) , False ) <EOL> self . assertEqual ( <EOL> utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( <EOL> utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( <EOL> utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( <EOL> utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> self . assertEqual ( <EOL> utils . is_valid_ip ( '<STR_LIT>' ) , True ) <EOL> def test_parse_redis_url ( self ) : <EOL> """<STR_LIT>""" <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT:password>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , None ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT:password>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( None ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT:localhost>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , None ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT:password>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> conf = parse_redis_url ( "<STR_LIT>" ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , None ) <EOL> self . assertEqual ( conf . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> def test_get_ip_address_from_request ( self ) : <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ip = utils . get_ip_address_from_request ( req ) <EOL> self . assertEqual ( ip , '<STR_LIT>' ) <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ip = utils . get_ip_address_from_request ( req ) <EOL> self . assertEqual ( ip , '<STR_LIT>' ) <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ip = utils . get_ip_address_from_request ( req ) <EOL> self . assertEqual ( ip , '<STR_LIT:127.0.0.1>' ) <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> ip = utils . get_ip_address_from_request ( req ) <EOL> self . assertEqual ( ip , '<STR_LIT:127.0.0.1>' ) <EOL> req = HttpRequest ( ) <EOL> ip = utils . get_ip_address_from_request ( req ) <EOL> self . assertEqual ( ip , '<STR_LIT:127.0.0.1>' ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_get_ip_reverse_proxy_custom_header ( self ) : <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( utils . get_ip ( req ) , '<STR_LIT>' ) <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( utils . get_ip ( req ) , '<STR_LIT>' ) <EOL> req = HttpRequest ( ) <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( utils . get_ip ( req ) , '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> @ patch ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_get_user_attempts ( self ) : <EOL> ip_attempts = random . randint ( <NUM_LIT:3> , <NUM_LIT:12> ) <EOL> username_attempts = random . randint ( <NUM_LIT:3> , <NUM_LIT:12> ) <EOL> for i in range ( <NUM_LIT:0> , ip_attempts ) : <EOL> utils . increment_key ( utils . get_ip_attempt_cache_key ( '<STR_LIT>' ) ) <EOL> for i in range ( <NUM_LIT:0> , username_attempts ) : <EOL> utils . increment_key ( utils . get_username_attempt_cache_key ( '<STR_LIT>' ) ) <EOL> req = HttpRequest ( ) <EOL> req . POST [ '<STR_LIT:username>' ] = '<STR_LIT>' <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( <EOL> utils . get_user_attempts ( req ) , max ( ip_attempts , username_attempts ) <EOL> ) <EOL> req = HttpRequest ( ) <EOL> req . POST [ '<STR_LIT:username>' ] = '<STR_LIT>' <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( <EOL> utils . get_user_attempts ( req ) , username_attempts <EOL> ) <EOL> req = HttpRequest ( ) <EOL> req . POST [ '<STR_LIT:username>' ] = '<STR_LIT>' <EOL> req . META [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> self . assertEqual ( <EOL> utils . get_user_attempts ( req ) , ip_attempts <EOL> ) <EOL> def test_admin ( self ) : <EOL> """<STR_LIT>""" <EOL> from . admin import AccessAttemptAdmin <EOL> AccessAttemptAdmin <EOL> def test_decorator_middleware ( self ) : <EOL> for i in range ( <NUM_LIT:0> , int ( config . FAILURE_LIMIT ) ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> def test_get_view ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertNotContains ( response , self . LOCKED_MESSAGE ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> def test_use_celery ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( AccessAttempt . objects . count ( ) , <NUM_LIT:0> ) <EOL> for i in range ( <NUM_LIT:0> , int ( config . FAILURE_LIMIT ) ) : <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> self . assertEqual ( AccessAttempt . objects . count ( ) , <EOL> config . FAILURE_LIMIT + <NUM_LIT:1> ) <EOL> self . assertIsNotNone ( str ( AccessAttempt . objects . all ( ) [ <NUM_LIT:0> ] ) ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> def test_lockout_by_ip_and_username ( self ) : <EOL> """<STR_LIT>""" <EOL> username = '<STR_LIT>' <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( username = username ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( username = username ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> ip = '<STR_LIT>' <EOL> response = self . _login ( username = VALID_USERNAME , remote_addr = ip ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> @ patch ( '<STR_LIT>' , True ) <EOL> def test_disable_ip_lockout ( self ) : <EOL> """<STR_LIT>""" <EOL> username = '<STR_LIT>' <EOL> ip = '<STR_LIT>' <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT + <NUM_LIT:10> ) : <EOL> login_username = u"<STR_LIT>" . format ( username , i ) <EOL> response = self . _login ( username = login_username , remote_addr = ip ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> for i in range ( <NUM_LIT:0> , config . FAILURE_LIMIT ) : <EOL> response = self . _login ( username = username ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( username = username ) <EOL> self . assertContains ( response , self . LOCKED_MESSAGE ) <EOL> response = self . client . get ( ADMIN_LOGIN_URL ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> response = self . _login ( ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> second_ip = '<STR_LIT>' <EOL> response = self . _login ( username = VALID_USERNAME , remote_addr = second_ip ) <EOL> self . assertContains ( response , LOGIN_FORM_KEY ) <EOL> data_out = utils . get_blocked_ips ( ) <EOL> self . assertEqual ( data_out , [ ] ) <EOL> utils . block_ip ( second_ip ) <EOL> data_out = utils . get_blocked_ips ( ) <EOL> self . assertEqual ( data_out , [ ] ) <EOL> class DefenderTestCaseTest ( DefenderTestCase ) : <EOL> """<STR_LIT>""" <EOL> key = '<STR_LIT>' <EOL> def test_first_incr ( self ) : <EOL> utils . REDIS_SERVER . incr ( self . key ) <EOL> result = int ( utils . REDIS_SERVER . get ( self . key ) ) <EOL> self . assertEqual ( result , <NUM_LIT:1> ) <EOL> def test_second_incr ( self ) : <EOL> utils . REDIS_SERVER . incr ( self . key ) <EOL> result = int ( utils . REDIS_SERVER . get ( self . key ) ) <EOL> self . assertEqual ( result , <NUM_LIT:1> ) <EOL> class DefenderTransactionTestCaseTest ( DefenderTransactionTestCase ) : <EOL> """<STR_LIT>""" <EOL> key = '<STR_LIT>' <EOL> def test_first_incr ( self ) : <EOL> utils . REDIS_SERVER . incr ( self . key ) <EOL> result = int ( utils . REDIS_SERVER . get ( self . key ) ) <EOL> self . assertEqual ( result , <NUM_LIT:1> ) <EOL> def test_second_incr ( self ) : <EOL> utils . REDIS_SERVER . incr ( self . key ) <EOL> result = int ( utils . REDIS_SERVER . get ( self . key ) ) <EOL> self . assertEqual ( result , <NUM_LIT:1> ) <EOL> class TestUtils ( DefenderTestCase ) : <EOL> def test_username_blocking ( self ) : <EOL> username = '<STR_LIT:foo>' <EOL> self . assertFalse ( utils . is_user_already_locked ( username ) ) <EOL> utils . block_username ( username ) <EOL> self . assertTrue ( utils . is_user_already_locked ( username ) ) <EOL> utils . unblock_username ( username ) <EOL> self . assertFalse ( utils . is_user_already_locked ( username ) ) <EOL> def test_ip_address_blocking ( self ) : <EOL> ip = '<STR_LIT>' <EOL> self . assertFalse ( utils . is_source_ip_already_locked ( ip ) ) <EOL> utils . block_ip ( ip ) <EOL> self . assertTrue ( utils . is_source_ip_already_locked ( ip ) ) <EOL> utils . unblock_ip ( ip ) <EOL> self . assertFalse ( utils . is_source_ip_already_locked ( ip ) ) </s>
<s> import zmq . green as zmq <EOL> def callback_func ( out_dict , extra_prms = None ) : <EOL> print "<STR_LIT>" , out_dict [ '<STR_LIT>' ] , "<STR_LIT>" ; <EOL> if not ( '<STR_LIT>' in extra_prms ) : <EOL> print "<STR_LIT>" ; <EOL> else : <EOL> try : <EOL> context = zmq . Context ( ) <EOL> impath_sender = context . socket ( zmq . REQ ) <EOL> impath_sender . connect ( extra_prms [ '<STR_LIT>' ] ) <EOL> impath_sender . send ( str ( out_dict [ '<STR_LIT>' ] ) ) <EOL> impath_sender . recv ( ) <EOL> finally : <EOL> impath_sender . close ( ) <EOL> context . term ( ) </s>
<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import tempfile <EOL> import random <EOL> from pprint import pprint <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . dirname ( os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) ) ) <EOL> import gristle . field_math as mod <EOL> class Test_get_variance_and_stddev ( object ) : <EOL> def setup_method ( self , method ) : <EOL> pass <EOL> def _convert_float ( self , value ) : <EOL> return '<STR_LIT>' % value <EOL> def test_math_empty_list ( self ) : <EOL> list_1 = { } <EOL> list_1a = ( None , None ) <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> def test_math_identical_single_number_occuring_once ( self ) : <EOL> list_1 = { <NUM_LIT:2> : <NUM_LIT:1> } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> list_2 = { <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:2> : <NUM_LIT:1> } <EOL> list_2a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_2 , <NUM_LIT:2> ) == list_2a <EOL> assert mod . get_variance_and_stddev ( list_2 ) == list_2a <EOL> def test_math_multiple_numbers_occuring_once ( self ) : <EOL> list_1 = { <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:3> : <NUM_LIT:1> , <NUM_LIT:4> : <NUM_LIT:1> } <EOL> list_1a = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> var , stddev = mod . get_variance_and_stddev ( list_1 ) <EOL> small_var = self . _convert_float ( var ) <EOL> small_stddev = self . _convert_float ( stddev ) <EOL> assert ( small_var , small_stddev ) == list_1a <EOL> list_2 = { <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:3> : <NUM_LIT:1> , <NUM_LIT:9> : <NUM_LIT:1> , <NUM_LIT:12> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT:15> : <NUM_LIT:1> , <EOL> <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> } <EOL> list_2a = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> var , stddev = mod . get_variance_and_stddev ( list_2 ) <EOL> small_var = self . _convert_float ( var ) <EOL> small_stddev = self . _convert_float ( stddev ) <EOL> assert ( small_var , small_stddev ) == list_2a <EOL> def test_math_multiple_numbers_occurring_multiple_times ( self ) : <EOL> list_4 = { <NUM_LIT:2> : <NUM_LIT:10> , <NUM_LIT:3> : <NUM_LIT:15> , <NUM_LIT:9> : <NUM_LIT:10> , <NUM_LIT:12> : <NUM_LIT:7> , <NUM_LIT> : <NUM_LIT:4> , <NUM_LIT:15> : <NUM_LIT:2> , <EOL> <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> } <EOL> list_4a = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> var , stddev = mod . get_variance_and_stddev ( list_4 ) <EOL> small_var = self . _convert_float ( var ) <EOL> small_stddev = self . _convert_float ( stddev ) <EOL> assert ( small_var , small_stddev ) == list_4a <EOL> def test_math_identical_single_float_occuring_once ( self ) : <EOL> list_1 = { <NUM_LIT> : <NUM_LIT:1> } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> list_2 = { <NUM_LIT> : <NUM_LIT:1> } <EOL> list_2a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_2 , <NUM_LIT> ) == list_2a <EOL> assert mod . get_variance_and_stddev ( list_2 ) == list_2a <EOL> def test_math_floats_multiple_floats_occuring_once ( self ) : <EOL> list_1 = { <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> } <EOL> list_1a = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> var , stddev = mod . get_variance_and_stddev ( list_1 ) <EOL> small_var = self . _convert_float ( var ) <EOL> small_stddev = self . _convert_float ( stddev ) <EOL> assert ( small_var , small_stddev ) == list_1a <EOL> def test_math_single_float_occurring_multiple_times ( self ) : <EOL> list_1 = { <NUM_LIT> : <NUM_LIT:2> } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> def test_math_single_string_occurring_once ( self ) : <EOL> list_1 = { '<STR_LIT:2>' : <NUM_LIT:2> } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> list_1 = { '<STR_LIT:2>' : '<STR_LIT:2>' } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> def test_math_ignoring_bad_key ( self ) : <EOL> list_1 = { <NUM_LIT:2> : <NUM_LIT:2> , '<STR_LIT:bar>' : <NUM_LIT:2> } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> def test_math_ignoring_bad_value ( self ) : <EOL> list_1 = { <NUM_LIT:2> : <NUM_LIT:2> , <NUM_LIT:3> : '<STR_LIT:foo>' } <EOL> list_1a = ( <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> assert mod . get_variance_and_stddev ( list_1 , <NUM_LIT:2> ) == list_1a <EOL> assert mod . get_variance_and_stddev ( list_1 ) == list_1a <EOL> class TestGetDictMedian ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . dict_1 = { } <EOL> self . dict_1a = None <EOL> self . dict_2 = { '<STR_LIT:1>' : <NUM_LIT:1> , '<STR_LIT:2>' : <NUM_LIT:1> , '<STR_LIT:3>' : <NUM_LIT:1> , '<STR_LIT:4>' : <NUM_LIT:1> , '<STR_LIT:100>' : <NUM_LIT> } <EOL> self . dict_2a = <NUM_LIT:100> <EOL> self . dict_3 = { '<STR_LIT:2>' : <NUM_LIT:3> , '<STR_LIT:4>' : <NUM_LIT:3> } <EOL> self . dict_3a = <NUM_LIT:3> <EOL> self . dict_4 = { '<STR_LIT:1>' : <NUM_LIT:3> , '<STR_LIT:4>' : <NUM_LIT:1> } <EOL> self . dict_4a = <NUM_LIT:1> <EOL> self . mymed = mod . GetDictMedian ( ) <EOL> def test_math_a02_dicts ( self ) : <EOL> assert self . mymed . run ( self . dict_1 ) == self . dict_1a <EOL> assert self . mymed . run ( self . dict_2 ) == self . dict_2a <EOL> assert self . mymed . run ( self . dict_3 ) == self . dict_3a <EOL> assert self . mymed . run ( self . dict_4 ) == self . dict_4a <EOL> class Test_get_tuple_list ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . mymed = mod . GetDictMedian ( ) <EOL> def test_math_b01_emptiness ( self ) : <EOL> self . dict_1 = { } <EOL> self . dict_1a = None <EOL> assert self . mymed . run ( self . dict_1 ) == self . dict_1a <EOL> def test_math_b02 ( self ) : <EOL> self . dict_2 = { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT:1>' : <NUM_LIT:2> , '<STR_LIT:4>' : <NUM_LIT:4> } <EOL> self . dict_2a = [ ( '<STR_LIT:1>' , <NUM_LIT:2> ) , ( '<STR_LIT:4>' , <NUM_LIT:4> ) , ( '<STR_LIT>' , <NUM_LIT:3> ) ] <EOL> tup_list = self . mymed . _get_tuple_list ( self . dict_2 ) <EOL> assert sorted ( tup_list ) == sorted ( self . dict_2a ) <EOL> def test_math_b03 ( self ) : <EOL> self . dict_3 = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT:1>' : <NUM_LIT:1> , '<STR_LIT:4>' : <NUM_LIT:1> } <EOL> self . dict_3a = [ ( '<STR_LIT:1>' , <NUM_LIT:1> ) , ( '<STR_LIT:4>' , <NUM_LIT:1> ) , ( '<STR_LIT>' , <NUM_LIT:1> ) ] <EOL> tup_list = self . mymed . _get_tuple_list ( self . dict_3 ) <EOL> assert sorted ( tup_list ) == self . dict_3a <EOL> class Test_get_numeric_tuple_list ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . mymed = mod . GetDictMedian ( ) <EOL> self . list_1 = [ ] <EOL> self . list_1a = [ ] <EOL> self . list_2 = [ ( '<STR_LIT>' , '<STR_LIT:1>' ) ] <EOL> self . list_2a = [ ( <NUM_LIT:8> , <NUM_LIT:1> ) ] <EOL> self . list_3 = [ ( '<STR_LIT>' , <NUM_LIT:1> ) , ( <NUM_LIT:1> , '<STR_LIT:1>' ) , ( '<STR_LIT:4>' , '<STR_LIT:1>' ) ] <EOL> self . list_3a = [ ( <NUM_LIT:8> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) ] <EOL> self . list_4 = [ ( '<STR_LIT>' , '<STR_LIT:1>' ) , ( '<STR_LIT:a>' , <NUM_LIT:1> ) , ( <NUM_LIT:4> , '<STR_LIT:b>' ) ] <EOL> self . list_4a = [ ( <NUM_LIT:8> , <NUM_LIT:1> ) ] <EOL> def test_math_c01 ( self ) : <EOL> assert self . mymed . _get_numeric_tuple_list ( self . list_1 ) == self . list_1a <EOL> assert self . mymed . _get_numeric_tuple_list ( self . list_2 ) == self . list_2a <EOL> assert self . mymed . _get_numeric_tuple_list ( self . list_3 ) == self . list_3a <EOL> assert self . mymed . _get_numeric_tuple_list ( self . list_4 ) == self . list_4a <EOL> class Test_get_median_subs ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . mymed = mod . GetDictMedian ( ) <EOL> def test_math_d01 ( self ) : <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:0> ) == ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:1> ) == ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:2> ) == ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:3> ) == ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:4> ) == ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:5> ) == ( <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:6> ) == ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:7> ) == ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> assert self . mymed . _get_median_subs ( <NUM_LIT:8> ) == ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> class Test_get_median_keys ( object ) : <EOL> """<STR_LIT>""" <EOL> def setup_method ( self , method ) : <EOL> self . mymed = mod . GetDictMedian ( ) <EOL> self . med_1 = [ ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) ] <EOL> self . med_2 = [ ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:8> , <NUM_LIT:1> ) ] <EOL> self . med_3 = [ ( <NUM_LIT:1> , <NUM_LIT:1> ) ] <EOL> self . hard_1 = [ ( <NUM_LIT:1> , <NUM_LIT:6> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:8> , <NUM_LIT:1> ) ] <EOL> self . hard_2 = [ ( <NUM_LIT:1> , <NUM_LIT:5> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:8> , <NUM_LIT:1> ) ] <EOL> self . hard_3 = [ ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:8> , <NUM_LIT:1> ) , ( <NUM_LIT:10> , <NUM_LIT:1> ) , ( <NUM_LIT> , <NUM_LIT:1> ) , ( <NUM_LIT> , <NUM_LIT:1> ) ] <EOL> def test_math_e01 ( self ) : <EOL> assert self . mymed . _get_median_keys ( self . med_1 , <NUM_LIT:1> ) == <NUM_LIT:4> <EOL> assert self . mymed . _get_median_keys ( self . med_2 , <NUM_LIT:1> ) == <NUM_LIT:4> <EOL> assert self . mymed . _get_median_keys ( self . med_3 , <NUM_LIT:0> ) == <NUM_LIT:1> <EOL> assert self . mymed . _get_median_keys ( self . hard_1 , <NUM_LIT:1> ) == <NUM_LIT:1> <EOL> assert self . mymed . _get_median_keys ( self . hard_2 , <NUM_LIT:3> ) == <NUM_LIT:1> <EOL> assert self . mymed . _get_median_keys ( self . hard_3 , <NUM_LIT:3> ) == <NUM_LIT:8> <EOL> class TestGetMean ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . empty_dict_1 = { } <EOL> self . empty_dict_2 = { '<STR_LIT>' : <NUM_LIT:2> } <EOL> self . easy_dict = { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT:1>' : <NUM_LIT:2> , '<STR_LIT:3>' : <NUM_LIT:4> } <EOL> self . unk_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT:U+0020>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT:2>' : <NUM_LIT:2> } <EOL> self . med_dict_1 = { '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT:100>' : <NUM_LIT> } <EOL> self . med_dict_3 = { <NUM_LIT:2> : <NUM_LIT:1> , <NUM_LIT:3> : <NUM_LIT:1> , <NUM_LIT:9> : <NUM_LIT:1> , <NUM_LIT:12> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT:15> : <NUM_LIT:1> , <EOL> <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> , <NUM_LIT> : <NUM_LIT:1> } <EOL> def test_math_f01_emptiness ( self ) : <EOL> assert mod . get_mean ( self . empty_dict_1 ) is None <EOL> assert mod . get_mean ( self . empty_dict_2 ) is None <EOL> def test_math_f03_small_sets ( self ) : <EOL> pass <EOL> def test_math_f04_medium_sets ( self ) : <EOL> assert mod . get_mean ( self . med_dict_1 ) == <NUM_LIT> <EOL> result = '<STR_LIT>' % mod . get_mean ( self . med_dict_3 ) <EOL> assert result == str ( <NUM_LIT> ) <EOL> class Test_get_mean_length ( object ) : <EOL> def setup_method ( self , method ) : <EOL> self . empty_dict_1 = { } <EOL> self . easy_dict = { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT:1>' : <NUM_LIT:2> , '<STR_LIT:3>' : <NUM_LIT:4> } <EOL> self . unk_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT:U+0020>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT:2>' : <NUM_LIT:2> } <EOL> self . med_dict_1 = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT:a>' : <NUM_LIT:3> } <EOL> def test_math_g01_emptiness ( self ) : <EOL> assert mod . get_mean_length ( self . empty_dict_1 ) is None <EOL> def test_math_g02_unknowns ( self ) : <EOL> assert mod . get_mean_length ( self . unk_dict ) == <NUM_LIT:1> <EOL> def test_math_g03_easy_list ( self ) : <EOL> pass <EOL> def test_math_g04_small_sets ( self ) : <EOL> pass <EOL> def test_math_g05_medium_sets ( self ) : <EOL> assert mod . get_mean_length ( self . med_dict_1 ) == <NUM_LIT> </s>
<s> from __future__ import division , print_function <EOL> from sqlalchemy . ext . declarative import declarative_base <EOL> from sqlalchemy import Column , TEXT , REAL , INTEGER <EOL> class Tables ( object ) : <EOL> def get_sentence_table ( self , tablename = "<STR_LIT>" ) : <EOL> class Sentence ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> lang1 = Column ( TEXT ) <EOL> lang2 = Column ( TEXT ) <EOL> return Sentence <EOL> def get_wordprobability_table ( self , tablename ) : <EOL> class WordProbability ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> transto = Column ( TEXT ) <EOL> transfrom = Column ( TEXT ) <EOL> prob = Column ( REAL ) <EOL> return WordProbability <EOL> def get_wordalignment_table ( self , tablename ) : <EOL> class WordAlignment ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> from_pos = Column ( INTEGER ) <EOL> to_pos = Column ( INTEGER ) <EOL> to_len = Column ( INTEGER ) <EOL> from_len = Column ( INTEGER ) <EOL> prob = Column ( REAL ) <EOL> return WordAlignment <EOL> def get_phrase_table ( self , tablename = "<STR_LIT>" ) : <EOL> class Phrase ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> lang1p = Column ( TEXT ) <EOL> lang2p = Column ( TEXT ) <EOL> return Phrase <EOL> def get_transphraseprob_table ( self , tablename = "<STR_LIT>" ) : <EOL> class TransPhraseProb ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> lang1p = Column ( TEXT ) <EOL> lang2p = Column ( TEXT ) <EOL> p1_2 = Column ( REAL ) <EOL> p2_1 = Column ( REAL ) <EOL> return TransPhraseProb <EOL> def get_trigram_table ( self , tablename ) : <EOL> class Trigram ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> first = Column ( TEXT ) <EOL> second = Column ( TEXT ) <EOL> third = Column ( TEXT ) <EOL> count = Column ( INTEGER ) <EOL> return Trigram <EOL> def get_trigramprob_table ( self , tablename ) : <EOL> class TrigramProb ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> first = Column ( TEXT ) <EOL> second = Column ( TEXT ) <EOL> third = Column ( TEXT ) <EOL> prob = Column ( REAL ) <EOL> return TrigramProb <EOL> def get_trigramprobwithoutlast_table ( self , tablename ) : <EOL> class TrigramProbWithoutLast ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> first = Column ( TEXT ) <EOL> second = Column ( TEXT ) <EOL> prob = Column ( REAL ) <EOL> return TrigramProbWithoutLast <EOL> def get_unigram_table ( self , tablename ) : <EOL> class Unigram ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> first = Column ( TEXT ) <EOL> count = Column ( INTEGER ) <EOL> return Unigram <EOL> def get_unigramprob_table ( self , tablename ) : <EOL> class UnigramProb ( declarative_base ( ) ) : <EOL> __tablename__ = tablename <EOL> id = Column ( INTEGER , primary_key = True ) <EOL> first = Column ( TEXT ) <EOL> prob = Column ( REAL ) <EOL> return UnigramProb </s>
<s> import sys , os <EOL> sys . path . append ( os . path . abspath ( '<STR_LIT>' ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( '<STR_LIT:..>' ) ) <EOL> import mead <EOL> extensions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> templates_path = [ '<STR_LIT>' ] <EOL> source_suffix = '<STR_LIT>' <EOL> master_doc = '<STR_LIT:index>' <EOL> project = u'<STR_LIT>' <EOL> copyright = u'<STR_LIT>' <EOL> version = mead . core . __version__ <EOL> release = version <EOL> exclude_patterns = [ '<STR_LIT>' ] <EOL> add_function_parentheses = True <EOL> pygments_style = '<STR_LIT>' <EOL> html_theme = '<STR_LIT>' <EOL> html_theme_path = [ '<STR_LIT>' ] <EOL> html_static_path = [ '<STR_LIT>' ] <EOL> html_use_smartypants = True <EOL> html_show_sourcelink = True <EOL> html_show_sphinx = False <EOL> htmlhelp_basename = '<STR_LIT>' <EOL> latex_documents = [ <EOL> ( '<STR_LIT:index>' , '<STR_LIT>' , u'<STR_LIT>' , <EOL> u'<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> man_pages = [ <EOL> ( '<STR_LIT:index>' , '<STR_LIT>' , u'<STR_LIT>' , <EOL> [ u'<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> ] </s>
<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from . colored import ColoredString , clean <EOL> from . . utils import tsplit , schunk <EOL> NEWLINES = ( '<STR_LIT:\n>' , '<STR_LIT:\r>' , '<STR_LIT:\r\n>' ) <EOL> def min_width ( string , cols , padding = '<STR_LIT:U+0020>' ) : <EOL> """<STR_LIT>""" <EOL> is_color = isinstance ( string , ColoredString ) <EOL> stack = tsplit ( str ( string ) , NEWLINES ) <EOL> for i , substring in enumerate ( stack ) : <EOL> _sub = clean ( substring ) . ljust ( ( cols + <NUM_LIT:0> ) , padding ) <EOL> if is_color : <EOL> _sub = ( _sub . replace ( clean ( substring ) , substring ) ) <EOL> stack [ i ] = _sub <EOL> return '<STR_LIT:\n>' . join ( stack ) <EOL> def max_width ( string , cols , separator = '<STR_LIT:\n>' ) : <EOL> """<STR_LIT>""" <EOL> is_color = isinstance ( string , ColoredString ) <EOL> if is_color : <EOL> string_copy = string . _new ( '<STR_LIT>' ) <EOL> string = string . s <EOL> stack = tsplit ( string , NEWLINES ) <EOL> for i , substring in enumerate ( stack ) : <EOL> stack [ i ] = substring . split ( ) <EOL> _stack = [ ] <EOL> for row in stack : <EOL> _row = [ '<STR_LIT>' , ] <EOL> _row_i = <NUM_LIT:0> <EOL> for word in row : <EOL> if ( len ( _row [ _row_i ] ) + len ( word ) ) <= cols : <EOL> _row [ _row_i ] += word <EOL> _row [ _row_i ] += '<STR_LIT:U+0020>' <EOL> elif len ( word ) > cols : <EOL> if len ( _row [ _row_i ] ) : <EOL> _row [ _row_i ] = _row [ _row_i ] . rstrip ( ) <EOL> _row . append ( '<STR_LIT>' ) <EOL> _row_i += <NUM_LIT:1> <EOL> chunks = schunk ( word , cols ) <EOL> for i , chunk in enumerate ( chunks ) : <EOL> if not ( i + <NUM_LIT:1> ) == len ( chunks ) : <EOL> _row [ _row_i ] += chunk <EOL> _row [ _row_i ] = _row [ _row_i ] . rstrip ( ) <EOL> _row . append ( '<STR_LIT>' ) <EOL> _row_i += <NUM_LIT:1> <EOL> else : <EOL> _row [ _row_i ] += chunk <EOL> _row [ _row_i ] += '<STR_LIT:U+0020>' <EOL> else : <EOL> _row [ _row_i ] = _row [ _row_i ] . rstrip ( ) <EOL> _row . append ( '<STR_LIT>' ) <EOL> _row_i += <NUM_LIT:1> <EOL> _row [ _row_i ] += word <EOL> _row [ _row_i ] += '<STR_LIT:U+0020>' <EOL> else : <EOL> _row [ _row_i ] = _row [ _row_i ] . rstrip ( ) <EOL> _row = map ( str , _row ) <EOL> _stack . append ( separator . join ( _row ) ) <EOL> _s = '<STR_LIT:\n>' . join ( _stack ) <EOL> if is_color : <EOL> _s = string_copy . _new ( _s ) <EOL> return _s </s>
<s> import os <EOL> import sys <EOL> import envoy <EOL> try : <EOL> from setuptools import setup <EOL> except ImportError : <EOL> from distutils . core import setup <EOL> if sys . argv [ - <NUM_LIT:1> ] == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> sys . exit ( ) <EOL> required = [ ] <EOL> setup ( <EOL> name = '<STR_LIT>' , <EOL> version = envoy . __version__ , <EOL> description = '<STR_LIT>' , <EOL> long_description = open ( '<STR_LIT>' ) . read ( ) , <EOL> author = '<STR_LIT>' , <EOL> author_email = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> packages = [ '<STR_LIT>' ] , <EOL> install_requires = required , <EOL> license = '<STR_LIT>' , <EOL> classifiers = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) , <EOL> ) </s>
<s> import sys <EOL> import os <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( '<STR_LIT:..>' ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( '<STR_LIT>' ) ) <EOL> import requests <EOL> from requests import __version__ <EOL> extensions = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> templates_path = [ '<STR_LIT>' ] <EOL> source_suffix = '<STR_LIT>' <EOL> master_doc = '<STR_LIT:index>' <EOL> project = u'<STR_LIT>' <EOL> copyright = u'<STR_LIT>' <EOL> author = u'<STR_LIT>' <EOL> version = __version__ <EOL> release = __version__ <EOL> language = None <EOL> exclude_patterns = [ '<STR_LIT>' ] <EOL> add_function_parentheses = False <EOL> add_module_names = True <EOL> pygments_style = '<STR_LIT>' <EOL> todo_include_todos = True <EOL> html_theme = '<STR_LIT>' <EOL> html_theme_options = { <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : False <EOL> } <EOL> html_static_path = [ '<STR_LIT>' ] <EOL> html_use_smartypants = False <EOL> html_sidebars = { <EOL> '<STR_LIT:index>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> html_show_sourcelink = False <EOL> html_show_sphinx = False <EOL> html_show_copyright = True <EOL> htmlhelp_basename = '<STR_LIT>' <EOL> latex_elements = { <EOL> } <EOL> latex_documents = [ <EOL> ( master_doc , '<STR_LIT>' , u'<STR_LIT>' , <EOL> u'<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> man_pages = [ <EOL> ( master_doc , '<STR_LIT>' , u'<STR_LIT>' , <EOL> [ author ] , <NUM_LIT:1> ) <EOL> ] <EOL> texinfo_documents = [ <EOL> ( master_doc , '<STR_LIT>' , u'<STR_LIT>' , <EOL> author , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> epub_title = project <EOL> epub_author = author <EOL> epub_publisher = author <EOL> epub_copyright = copyright <EOL> epub_exclude_files = [ '<STR_LIT>' ] <EOL> intersphinx_mapping = { '<STR_LIT>' : ( '<STR_LIT>' , None ) } </s>
<s> from __future__ import absolute_import <EOL> from . . packages . six . moves import http_client as httplib <EOL> from . . exceptions import HeaderParsingError <EOL> def is_fp_closed ( obj ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return obj . closed <EOL> except AttributeError : <EOL> pass <EOL> try : <EOL> return obj . fp is None <EOL> except AttributeError : <EOL> pass <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def assert_header_parsing ( headers ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( headers , httplib . HTTPMessage ) : <EOL> raise TypeError ( '<STR_LIT>' . format ( <EOL> type ( headers ) ) ) <EOL> defects = getattr ( headers , '<STR_LIT>' , None ) <EOL> get_payload = getattr ( headers , '<STR_LIT>' , None ) <EOL> unparsed_data = None <EOL> if get_payload : <EOL> unparsed_data = get_payload ( ) <EOL> if defects or unparsed_data : <EOL> raise HeaderParsingError ( defects = defects , unparsed_data = unparsed_data ) <EOL> def is_response_to_head ( response ) : <EOL> """<STR_LIT>""" <EOL> method = response . _method <EOL> if isinstance ( method , int ) : <EOL> return method == <NUM_LIT:3> <EOL> return method . upper ( ) == '<STR_LIT>' </s>
<s> """<STR_LIT>""" <EOL> from tablib . core import ( <EOL> Databook , Dataset , detect_format , import_set , import_book , <EOL> InvalidDatasetType , InvalidDimensions , UnsupportedFormat , <EOL> __version__ <EOL> ) </s>
<s> """<STR_LIT>""" <EOL> import re <EOL> from decimal import Decimal <EOL> def _import_speedups ( ) : <EOL> try : <EOL> from simplejson import _speedups <EOL> return _speedups . encode_basestring_ascii , _speedups . make_encoder <EOL> except ImportError : <EOL> return None , None <EOL> c_encode_basestring_ascii , c_make_encoder = _import_speedups ( ) <EOL> from . decoder import PosInf <EOL> ESCAPE = re . compile ( r'<STR_LIT>' ) <EOL> ESCAPE_ASCII = re . compile ( r'<STR_LIT>' ) <EOL> HAS_UTF8 = re . compile ( r'<STR_LIT>' ) <EOL> ESCAPE_DCT = { <EOL> '<STR_LIT:\\>' : '<STR_LIT>' , <EOL> '<STR_LIT:">' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:\n>' : '<STR_LIT>' , <EOL> '<STR_LIT:\r>' : '<STR_LIT>' , <EOL> '<STR_LIT:\t>' : '<STR_LIT>' , <EOL> } <EOL> for i in range ( <NUM_LIT> ) : <EOL> ESCAPE_DCT . setdefault ( chr ( i ) , '<STR_LIT>' % ( i , ) ) <EOL> FLOAT_REPR = repr <EOL> def encode_basestring ( s ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( s , str ) and HAS_UTF8 . search ( s ) is not None : <EOL> s = s . decode ( '<STR_LIT:utf-8>' ) <EOL> def replace ( match ) : <EOL> return ESCAPE_DCT [ match . group ( <NUM_LIT:0> ) ] <EOL> return u'<STR_LIT:">' + ESCAPE . sub ( replace , s ) + u'<STR_LIT:">' <EOL> def py_encode_basestring_ascii ( s ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( s , str ) and HAS_UTF8 . search ( s ) is not None : <EOL> s = s . decode ( '<STR_LIT:utf-8>' ) <EOL> def replace ( match ) : <EOL> s = match . group ( <NUM_LIT:0> ) <EOL> try : <EOL> return ESCAPE_DCT [ s ] <EOL> except KeyError : <EOL> n = ord ( s ) <EOL> if n < <NUM_LIT> : <EOL> return '<STR_LIT>' % ( n , ) <EOL> else : <EOL> n -= <NUM_LIT> <EOL> s1 = <NUM_LIT> | ( ( n >> <NUM_LIT:10> ) & <NUM_LIT> ) <EOL> s2 = <NUM_LIT> | ( n & <NUM_LIT> ) <EOL> return '<STR_LIT>' % ( s1 , s2 ) <EOL> return '<STR_LIT:">' + str ( ESCAPE_ASCII . sub ( replace , s ) ) + '<STR_LIT:">' <EOL> encode_basestring_ascii = ( <EOL> c_encode_basestring_ascii or py_encode_basestring_ascii ) <EOL> class JSONEncoder ( object ) : <EOL> """<STR_LIT>""" <EOL> item_separator = '<STR_LIT:U+002CU+0020>' <EOL> key_separator = '<STR_LIT>' <EOL> def __init__ ( self , skipkeys = False , ensure_ascii = True , <EOL> check_circular = True , allow_nan = True , sort_keys = False , <EOL> indent = None , separators = None , encoding = '<STR_LIT:utf-8>' , default = None , <EOL> use_decimal = False ) : <EOL> """<STR_LIT>""" <EOL> self . skipkeys = skipkeys <EOL> self . ensure_ascii = ensure_ascii <EOL> self . check_circular = check_circular <EOL> self . allow_nan = allow_nan <EOL> self . sort_keys = sort_keys <EOL> self . use_decimal = use_decimal <EOL> if isinstance ( indent , ( int , long ) ) : <EOL> indent = '<STR_LIT:U+0020>' * indent <EOL> self . indent = indent <EOL> if separators is not None : <EOL> self . item_separator , self . key_separator = separators <EOL> elif indent is not None : <EOL> self . item_separator = '<STR_LIT:U+002C>' <EOL> if default is not None : <EOL> self . default = default <EOL> self . encoding = encoding <EOL> def default ( self , o ) : <EOL> """<STR_LIT>""" <EOL> raise TypeError ( repr ( o ) + "<STR_LIT>" ) <EOL> def encode ( self , o ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( o , basestring ) : <EOL> if isinstance ( o , str ) : <EOL> _encoding = self . encoding <EOL> if ( _encoding is not None <EOL> and not ( _encoding == '<STR_LIT:utf-8>' ) ) : <EOL> o = o . decode ( _encoding ) <EOL> if self . ensure_ascii : <EOL> return encode_basestring_ascii ( o ) <EOL> else : <EOL> return encode_basestring ( o ) <EOL> chunks = self . iterencode ( o , _one_shot = True ) <EOL> if not isinstance ( chunks , ( list , tuple ) ) : <EOL> chunks = list ( chunks ) <EOL> if self . ensure_ascii : <EOL> return '<STR_LIT>' . join ( chunks ) <EOL> else : <EOL> return u'<STR_LIT>' . join ( chunks ) <EOL> def iterencode ( self , o , _one_shot = False ) : <EOL> """<STR_LIT>""" <EOL> if self . check_circular : <EOL> markers = { } <EOL> else : <EOL> markers = None <EOL> if self . ensure_ascii : <EOL> _encoder = encode_basestring_ascii <EOL> else : <EOL> _encoder = encode_basestring <EOL> if self . encoding != '<STR_LIT:utf-8>' : <EOL> def _encoder ( o , _orig_encoder = _encoder , _encoding = self . encoding ) : <EOL> if isinstance ( o , str ) : <EOL> o = o . decode ( _encoding ) <EOL> return _orig_encoder ( o ) <EOL> def floatstr ( o , allow_nan = self . allow_nan , <EOL> _repr = FLOAT_REPR , _inf = PosInf , _neginf = - PosInf ) : <EOL> if o != o : <EOL> text = '<STR_LIT>' <EOL> elif o == _inf : <EOL> text = '<STR_LIT>' <EOL> elif o == _neginf : <EOL> text = '<STR_LIT>' <EOL> else : <EOL> return _repr ( o ) <EOL> if not allow_nan : <EOL> raise ValueError ( <EOL> "<STR_LIT>" + <EOL> repr ( o ) ) <EOL> return text <EOL> key_memo = { } <EOL> if ( _one_shot and c_make_encoder is not None <EOL> and self . indent is None ) : <EOL> _iterencode = c_make_encoder ( <EOL> markers , self . default , _encoder , self . indent , <EOL> self . key_separator , self . item_separator , self . sort_keys , <EOL> self . skipkeys , self . allow_nan , key_memo , self . use_decimal ) <EOL> else : <EOL> _iterencode = _make_iterencode ( <EOL> markers , self . default , _encoder , self . indent , floatstr , <EOL> self . key_separator , self . item_separator , self . sort_keys , <EOL> self . skipkeys , _one_shot , self . use_decimal ) <EOL> try : <EOL> return _iterencode ( o , <NUM_LIT:0> ) <EOL> finally : <EOL> key_memo . clear ( ) <EOL> class JSONEncoderForHTML ( JSONEncoder ) : <EOL> """<STR_LIT>""" <EOL> def encode ( self , o ) : <EOL> chunks = self . iterencode ( o , True ) <EOL> if self . ensure_ascii : <EOL> return '<STR_LIT>' . join ( chunks ) <EOL> else : <EOL> return u'<STR_LIT>' . join ( chunks ) <EOL> def iterencode ( self , o , _one_shot = False ) : <EOL> chunks = super ( JSONEncoderForHTML , self ) . iterencode ( o , _one_shot ) <EOL> for chunk in chunks : <EOL> chunk = chunk . replace ( '<STR_LIT:&>' , '<STR_LIT>' ) <EOL> chunk = chunk . replace ( '<STR_LIT:<>' , '<STR_LIT>' ) <EOL> chunk = chunk . replace ( '<STR_LIT:>>' , '<STR_LIT>' ) <EOL> yield chunk <EOL> def _make_iterencode ( markers , _default , _encoder , _indent , _floatstr , <EOL> _key_separator , _item_separator , _sort_keys , _skipkeys , _one_shot , <EOL> _use_decimal , <EOL> False = False , <EOL> True = True , <EOL> ValueError = ValueError , <EOL> basestring = basestring , <EOL> Decimal = Decimal , <EOL> dict = dict , <EOL> float = float , <EOL> id = id , <EOL> int = int , <EOL> isinstance = isinstance , <EOL> list = list , <EOL> long = long , <EOL> str = str , <EOL> tuple = tuple , <EOL> ) : <EOL> def _iterencode_list ( lst , _current_indent_level ) : <EOL> if not lst : <EOL> yield '<STR_LIT>' <EOL> return <EOL> if markers is not None : <EOL> markerid = id ( lst ) <EOL> if markerid in markers : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> markers [ markerid ] = lst <EOL> buf = '<STR_LIT:[>' <EOL> if _indent is not None : <EOL> _current_indent_level += <NUM_LIT:1> <EOL> newline_indent = '<STR_LIT:\n>' + ( _indent * _current_indent_level ) <EOL> separator = _item_separator + newline_indent <EOL> buf += newline_indent <EOL> else : <EOL> newline_indent = None <EOL> separator = _item_separator <EOL> first = True <EOL> for value in lst : <EOL> if first : <EOL> first = False <EOL> else : <EOL> buf = separator <EOL> if isinstance ( value , basestring ) : <EOL> yield buf + _encoder ( value ) <EOL> elif value is None : <EOL> yield buf + '<STR_LIT:null>' <EOL> elif value is True : <EOL> yield buf + '<STR_LIT:true>' <EOL> elif value is False : <EOL> yield buf + '<STR_LIT:false>' <EOL> elif isinstance ( value , ( int , long ) ) : <EOL> yield buf + str ( value ) <EOL> elif isinstance ( value , float ) : <EOL> yield buf + _floatstr ( value ) <EOL> elif _use_decimal and isinstance ( value , Decimal ) : <EOL> yield buf + str ( value ) <EOL> else : <EOL> yield buf <EOL> if isinstance ( value , ( list , tuple ) ) : <EOL> chunks = _iterencode_list ( value , _current_indent_level ) <EOL> elif isinstance ( value , dict ) : <EOL> chunks = _iterencode_dict ( value , _current_indent_level ) <EOL> else : <EOL> chunks = _iterencode ( value , _current_indent_level ) <EOL> for chunk in chunks : <EOL> yield chunk <EOL> if newline_indent is not None : <EOL> _current_indent_level -= <NUM_LIT:1> <EOL> yield '<STR_LIT:\n>' + ( _indent * _current_indent_level ) <EOL> yield '<STR_LIT:]>' <EOL> if markers is not None : <EOL> del markers [ markerid ] <EOL> def _iterencode_dict ( dct , _current_indent_level ) : <EOL> if not dct : <EOL> yield '<STR_LIT:{}>' <EOL> return <EOL> if markers is not None : <EOL> markerid = id ( dct ) <EOL> if markerid in markers : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> markers [ markerid ] = dct <EOL> yield '<STR_LIT:{>' <EOL> if _indent is not None : <EOL> _current_indent_level += <NUM_LIT:1> <EOL> newline_indent = '<STR_LIT:\n>' + ( _indent * _current_indent_level ) <EOL> item_separator = _item_separator + newline_indent <EOL> yield newline_indent <EOL> else : <EOL> newline_indent = None <EOL> item_separator = _item_separator <EOL> first = True <EOL> if _sort_keys : <EOL> items = dct . items ( ) <EOL> items . sort ( key = lambda kv : kv [ <NUM_LIT:0> ] ) <EOL> else : <EOL> items = dct . iteritems ( ) <EOL> for key , value in items : <EOL> if isinstance ( key , basestring ) : <EOL> pass <EOL> elif isinstance ( key , float ) : <EOL> key = _floatstr ( key ) <EOL> elif key is True : <EOL> key = '<STR_LIT:true>' <EOL> elif key is False : <EOL> key = '<STR_LIT:false>' <EOL> elif key is None : <EOL> key = '<STR_LIT:null>' <EOL> elif isinstance ( key , ( int , long ) ) : <EOL> key = str ( key ) <EOL> elif _skipkeys : <EOL> continue <EOL> else : <EOL> raise TypeError ( "<STR_LIT>" + repr ( key ) + "<STR_LIT>" ) <EOL> if first : <EOL> first = False <EOL> else : <EOL> yield item_separator <EOL> yield _encoder ( key ) <EOL> yield _key_separator <EOL> if isinstance ( value , basestring ) : <EOL> yield _encoder ( value ) <EOL> elif value is None : <EOL> yield '<STR_LIT:null>' <EOL> elif value is True : <EOL> yield '<STR_LIT:true>' <EOL> elif value is False : <EOL> yield '<STR_LIT:false>' <EOL> elif isinstance ( value , ( int , long ) ) : <EOL> yield str ( value ) <EOL> elif isinstance ( value , float ) : <EOL> yield _floatstr ( value ) <EOL> elif _use_decimal and isinstance ( value , Decimal ) : <EOL> yield str ( value ) <EOL> else : <EOL> if isinstance ( value , ( list , tuple ) ) : <EOL> chunks = _iterencode_list ( value , _current_indent_level ) <EOL> elif isinstance ( value , dict ) : <EOL> chunks = _iterencode_dict ( value , _current_indent_level ) <EOL> else : <EOL> chunks = _iterencode ( value , _current_indent_level ) <EOL> for chunk in chunks : <EOL> yield chunk <EOL> if newline_indent is not None : <EOL> _current_indent_level -= <NUM_LIT:1> <EOL> yield '<STR_LIT:\n>' + ( _indent * _current_indent_level ) <EOL> yield '<STR_LIT:}>' <EOL> if markers is not None : <EOL> del markers [ markerid ] <EOL> def _iterencode ( o , _current_indent_level ) : <EOL> if isinstance ( o , basestring ) : <EOL> yield _encoder ( o ) <EOL> elif o is None : <EOL> yield '<STR_LIT:null>' <EOL> elif o is True : <EOL> yield '<STR_LIT:true>' <EOL> elif o is False : <EOL> yield '<STR_LIT:false>' <EOL> elif isinstance ( o , ( int , long ) ) : <EOL> yield str ( o ) <EOL> elif isinstance ( o , float ) : <EOL> yield _floatstr ( o ) <EOL> elif isinstance ( o , ( list , tuple ) ) : <EOL> for chunk in _iterencode_list ( o , _current_indent_level ) : <EOL> yield chunk <EOL> elif isinstance ( o , dict ) : <EOL> for chunk in _iterencode_dict ( o , _current_indent_level ) : <EOL> yield chunk <EOL> elif _use_decimal and isinstance ( o , Decimal ) : <EOL> yield str ( o ) <EOL> else : <EOL> if markers is not None : <EOL> markerid = id ( o ) <EOL> if markerid in markers : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> markers [ markerid ] = o <EOL> o = _default ( o ) <EOL> for chunk in _iterencode ( o , _current_indent_level ) : <EOL> yield chunk <EOL> if markers is not None : <EOL> del markers [ markerid ] <EOL> return _iterencode </s>
<s> from xlwt import * <EOL> font0 = Font ( ) <EOL> font0 . name = '<STR_LIT>' <EOL> font0 . struck_out = True <EOL> font0 . bold = True <EOL> style0 = XFStyle ( ) <EOL> style0 . font = font0 <EOL> wb = Workbook ( ) <EOL> ws0 = wb . add_sheet ( '<STR_LIT:0>' ) <EOL> ws0 . write ( <NUM_LIT:1> , <NUM_LIT:1> , '<STR_LIT>' , style0 ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT> ) : <EOL> fnt = Font ( ) <EOL> fnt . name = '<STR_LIT>' <EOL> fnt . colour_index = i <EOL> fnt . outline = True <EOL> borders = Borders ( ) <EOL> borders . left = i <EOL> style = XFStyle ( ) <EOL> style . font = fnt <EOL> style . borders = borders <EOL> ws0 . write ( i , <NUM_LIT:2> , '<STR_LIT>' , style ) <EOL> ws0 . write ( i , <NUM_LIT:3> , hex ( i ) , style0 ) <EOL> wb . save ( '<STR_LIT>' ) </s>
<s> from BIFFRecords import ColInfoRecord <EOL> class Column ( object ) : <EOL> def __init__ ( self , colx , parent_sheet ) : <EOL> if not ( isinstance ( colx , int ) and <NUM_LIT:0> <= colx <= <NUM_LIT:255> ) : <EOL> raise ValueError ( "<STR_LIT>" % colx ) <EOL> self . _index = colx <EOL> self . _parent = parent_sheet <EOL> self . _parent_wb = parent_sheet . get_parent ( ) <EOL> self . _xf_index = <NUM_LIT> <EOL> self . width = <NUM_LIT> <EOL> self . hidden = <NUM_LIT:0> <EOL> self . level = <NUM_LIT:0> <EOL> self . collapse = <NUM_LIT:0> <EOL> def set_style ( self , style ) : <EOL> self . _xf_index = self . _parent_wb . add_style ( style ) <EOL> def width_in_pixels ( self ) : <EOL> return int ( round ( self . width * <NUM_LIT> + <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> def get_biff_record ( self ) : <EOL> options = ( self . hidden & <NUM_LIT> ) << <NUM_LIT:0> <EOL> options |= ( self . level & <NUM_LIT> ) << <NUM_LIT:8> <EOL> options |= ( self . collapse & <NUM_LIT> ) << <NUM_LIT:12> <EOL> return ColInfoRecord ( self . _index , self . _index , self . width , self . _xf_index , options ) . get ( ) </s>
<s> import re <EOL> import commit <EOL> class Diff ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , repo , a_path , b_path , a_commit , b_commit , a_mode , <EOL> b_mode , new_file , deleted_file , rename_from , <EOL> rename_to , diff ) : <EOL> self . repo = repo <EOL> self . a_path = a_path <EOL> self . b_path = b_path <EOL> if not a_commit or re . search ( r'<STR_LIT>' , a_commit ) : <EOL> self . a_commit = None <EOL> else : <EOL> self . a_commit = commit . Commit ( repo , id = a_commit ) <EOL> if not b_commit or re . search ( r'<STR_LIT>' , b_commit ) : <EOL> self . b_commit = None <EOL> else : <EOL> self . b_commit = commit . Commit ( repo , id = b_commit ) <EOL> self . a_mode = a_mode <EOL> self . b_mode = b_mode <EOL> self . new_file = new_file <EOL> self . deleted_file = deleted_file <EOL> self . rename_from = rename_from <EOL> self . rename_to = rename_to <EOL> self . renamed = rename_from != rename_to <EOL> self . diff = diff <EOL> @ classmethod <EOL> def list_from_string ( cls , repo , text ) : <EOL> diffs = [ ] <EOL> diff_header = re . compile ( r"""<STR_LIT>""" , re . VERBOSE | re . MULTILINE ) . match <EOL> for diff in ( '<STR_LIT:\n>' + text ) . split ( '<STR_LIT>' ) [ <NUM_LIT:1> : ] : <EOL> header = diff_header ( diff ) <EOL> a_path , b_path , similarity_index , rename_from , rename_to , old_mode , new_mode , new_file_mode , deleted_file_mode , a_commit , b_commit , b_mode = header . groups ( ) <EOL> new_file , deleted_file = bool ( new_file_mode ) , bool ( deleted_file_mode ) <EOL> diffs . append ( Diff ( repo , a_path , b_path , a_commit , b_commit , <EOL> old_mode or deleted_file_mode , new_mode or new_file_mode or b_mode , <EOL> new_file , deleted_file , rename_from , rename_to , diff [ header . end ( ) : ] ) ) <EOL> return diffs </s>
<s> __version__ = "<STR_LIT>" </s>
<s> import filecmp <EOL> import json <EOL> import shutil <EOL> import yaml <EOL> import vcr . migration <EOL> def test_try_migrate_with_json ( tmpdir ) : <EOL> cassette = tmpdir . join ( '<STR_LIT>' ) . strpath <EOL> shutil . copy ( '<STR_LIT>' , cassette ) <EOL> assert vcr . migration . try_migrate ( cassette ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as f : <EOL> expected_json = json . load ( f ) <EOL> with open ( cassette , '<STR_LIT:r>' ) as f : <EOL> actual_json = json . load ( f ) <EOL> assert actual_json == expected_json <EOL> def test_try_migrate_with_yaml ( tmpdir ) : <EOL> cassette = tmpdir . join ( '<STR_LIT>' ) . strpath <EOL> shutil . copy ( '<STR_LIT>' , cassette ) <EOL> assert vcr . migration . try_migrate ( cassette ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as f : <EOL> expected_yaml = yaml . load ( f ) <EOL> with open ( cassette , '<STR_LIT:r>' ) as f : <EOL> actual_yaml = yaml . load ( f ) <EOL> assert actual_yaml == expected_yaml <EOL> def test_try_migrate_with_invalid_or_new_cassettes ( tmpdir ) : <EOL> cassette = tmpdir . join ( '<STR_LIT>' ) . strpath <EOL> files = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> for file_path in files : <EOL> shutil . copy ( file_path , cassette ) <EOL> assert not vcr . migration . try_migrate ( cassette ) <EOL> assert filecmp . cmp ( cassette , file_path ) </s>
<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import functools <EOL> from six import BytesIO <EOL> from tornado import httputil <EOL> from tornado . httpclient import HTTPResponse <EOL> from vcr . errors import CannotOverwriteExistingCassetteException <EOL> from vcr . request import Request <EOL> def vcr_fetch_impl ( cassette , real_fetch_impl ) : <EOL> @ functools . wraps ( real_fetch_impl ) <EOL> def new_fetch_impl ( self , request , callback ) : <EOL> headers = request . headers . copy ( ) <EOL> if request . user_agent : <EOL> headers . setdefault ( '<STR_LIT>' , request . user_agent ) <EOL> unsupported_call = ( <EOL> getattr ( request , '<STR_LIT>' , None ) is not None or <EOL> request . header_callback is not None or <EOL> request . streaming_callback is not None <EOL> ) <EOL> if unsupported_call : <EOL> response = HTTPResponse ( <EOL> request , <EOL> <NUM_LIT> , <EOL> error = Exception ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % repr ( request ) <EOL> ) , <EOL> request_time = self . io_loop . time ( ) - request . start_time , <EOL> ) <EOL> return callback ( response ) <EOL> vcr_request = Request ( <EOL> request . method , <EOL> request . url , <EOL> request . body , <EOL> headers , <EOL> ) <EOL> if cassette . can_play_response_for ( vcr_request ) : <EOL> vcr_response = cassette . play_response ( vcr_request ) <EOL> headers = httputil . HTTPHeaders ( ) <EOL> recorded_headers = vcr_response [ '<STR_LIT>' ] <EOL> if isinstance ( recorded_headers , dict ) : <EOL> recorded_headers = recorded_headers . items ( ) <EOL> for k , vs in recorded_headers : <EOL> for v in vs : <EOL> headers . add ( k , v ) <EOL> response = HTTPResponse ( <EOL> request , <EOL> code = vcr_response [ '<STR_LIT:status>' ] [ '<STR_LIT:code>' ] , <EOL> reason = vcr_response [ '<STR_LIT:status>' ] [ '<STR_LIT:message>' ] , <EOL> headers = headers , <EOL> buffer = BytesIO ( vcr_response [ '<STR_LIT:body>' ] [ '<STR_LIT:string>' ] ) , <EOL> effective_url = vcr_response . get ( '<STR_LIT:url>' ) , <EOL> request_time = self . io_loop . time ( ) - request . start_time , <EOL> ) <EOL> return callback ( response ) <EOL> else : <EOL> if cassette . write_protected and cassette . filter_request ( <EOL> vcr_request <EOL> ) : <EOL> response = HTTPResponse ( <EOL> request , <EOL> <NUM_LIT> , <EOL> error = CannotOverwriteExistingCassetteException ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( vcr_request , cassette . _path , cassette . record_mode ) <EOL> ) , <EOL> request_time = self . io_loop . time ( ) - request . start_time , <EOL> ) <EOL> return callback ( response ) <EOL> def new_callback ( response ) : <EOL> headers = [ <EOL> ( k , response . headers . get_list ( k ) ) <EOL> for k in response . headers . keys ( ) <EOL> ] <EOL> vcr_response = { <EOL> '<STR_LIT:status>' : { <EOL> '<STR_LIT:code>' : response . code , <EOL> '<STR_LIT:message>' : response . reason , <EOL> } , <EOL> '<STR_LIT>' : headers , <EOL> '<STR_LIT:body>' : { '<STR_LIT:string>' : response . body } , <EOL> '<STR_LIT:url>' : response . effective_url , <EOL> } <EOL> cassette . append ( vcr_request , vcr_response ) <EOL> return callback ( response ) <EOL> real_fetch_impl ( self , request , new_callback ) <EOL> return new_fetch_impl </s>
<s> from distutils . core import setup <EOL> setup ( <EOL> name = "<STR_LIT>" , <EOL> version = '<STR_LIT>' , <EOL> description = "<STR_LIT>" , <EOL> long_description = open ( "<STR_LIT>" ) . read ( ) , <EOL> author = "<STR_LIT>" , <EOL> author_email = "<STR_LIT>" , <EOL> url = "<STR_LIT>" , <EOL> packages = [ <EOL> "<STR_LIT>" , <EOL> ] , <EOL> install_requires = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] , <EOL> package_dir = { "<STR_LIT>" : "<STR_LIT>" } , <EOL> classifiers = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> ) </s>
<s> from __future__ import print_function <EOL> import datetime <EOL> import getopt <EOL> import json <EOL> import logging <EOL> import os <EOL> import pprint <EOL> import sys <EOL> libpath = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> sys . path [ : <NUM_LIT:0> ] = [ os . path . join ( libpath , os . pardir , '<STR_LIT>' ) ] <EOL> import pan . afapi <EOL> debug = <NUM_LIT:0> <EOL> def main ( ) : <EOL> options = parse_opts ( ) <EOL> if options [ '<STR_LIT>' ] : <EOL> logger = logging . getLogger ( ) <EOL> if options [ '<STR_LIT>' ] == <NUM_LIT:3> : <EOL> logger . setLevel ( pan . afapi . DEBUG3 ) <EOL> elif options [ '<STR_LIT>' ] == <NUM_LIT:2> : <EOL> logger . setLevel ( pan . afapi . DEBUG2 ) <EOL> elif options [ '<STR_LIT>' ] == <NUM_LIT:1> : <EOL> logger . setLevel ( pan . afapi . DEBUG1 ) <EOL> log_format = '<STR_LIT>' <EOL> handler = logging . StreamHandler ( ) <EOL> formatter = logging . Formatter ( log_format ) <EOL> handler . setFormatter ( formatter ) <EOL> logger . addHandler ( handler ) <EOL> try : <EOL> afapi = pan . afapi . PanAFapi ( panrc_tag = options [ '<STR_LIT>' ] , <EOL> api_key = options [ '<STR_LIT>' ] , <EOL> api_version = options [ '<STR_LIT>' ] , <EOL> hostname = options [ '<STR_LIT>' ] , <EOL> timeout = options [ '<STR_LIT>' ] , <EOL> verify_cert = options [ '<STR_LIT>' ] ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print ( '<STR_LIT>' , e , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if options [ '<STR_LIT>' ] is None : <EOL> options [ '<STR_LIT>' ] = '<STR_LIT:{}>' <EOL> options [ '<STR_LIT>' ] = { } <EOL> if False : <EOL> pass <EOL> elif options [ '<STR_LIT>' ] : <EOL> export ( afapi , options ) <EOL> elif options [ '<STR_LIT>' ] : <EOL> sample_analysis ( afapi , options ) <EOL> elif options [ '<STR_LIT>' ] : <EOL> search_results ( afapi , options , <EOL> afapi . samples_search_results ) <EOL> elif options [ '<STR_LIT>' ] and options [ '<STR_LIT>' ] : <EOL> search_results ( afapi , options , <EOL> afapi . sessions_histogram_search_results ) <EOL> elif options [ '<STR_LIT>' ] and options [ '<STR_LIT>' ] : <EOL> search_results ( afapi , options , <EOL> afapi . sessions_aggregate_search_results ) <EOL> elif options [ '<STR_LIT>' ] : <EOL> search_results ( afapi , options , <EOL> afapi . sessions_search_results ) <EOL> elif options [ '<STR_LIT>' ] is not None : <EOL> session ( afapi , options ) <EOL> elif options [ '<STR_LIT>' ] : <EOL> search_results ( afapi , options , <EOL> afapi . top_tags_search_results ) <EOL> elif options [ '<STR_LIT>' ] : <EOL> tags ( afapi , options ) <EOL> elif options [ '<STR_LIT>' ] is not None : <EOL> tag ( afapi , options ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def export ( afapi , options ) : <EOL> try : <EOL> action = '<STR_LIT>' <EOL> r = afapi . export ( data = options [ '<STR_LIT>' ] ) <EOL> print_status ( action , r ) <EOL> print_response ( r , options ) <EOL> exit_for_http_status ( r ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( action , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def sample_analysis ( afapi , options ) : <EOL> try : <EOL> action = '<STR_LIT>' <EOL> r = afapi . sample_analysis ( data = options [ '<STR_LIT>' ] , <EOL> sampleid = options [ '<STR_LIT>' ] ) <EOL> print_status ( action , r ) <EOL> print_response ( r , options ) <EOL> exit_for_http_status ( r ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( action , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def tag ( afapi , options ) : <EOL> try : <EOL> action = '<STR_LIT>' <EOL> r = afapi . tag ( tagname = options [ '<STR_LIT>' ] ) <EOL> print_status ( action , r ) <EOL> print_response ( r , options ) <EOL> exit_for_http_status ( r ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( action , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def tags ( afapi , options ) : <EOL> try : <EOL> action = '<STR_LIT>' <EOL> query = { } <EOL> request = options [ '<STR_LIT>' ] <EOL> try : <EOL> obj = json . loads ( request ) <EOL> if options [ '<STR_LIT>' ] is not None : <EOL> obj [ '<STR_LIT>' ] = options [ '<STR_LIT>' ] <EOL> if options [ '<STR_LIT>' ] is not None : <EOL> obj [ '<STR_LIT>' ] = options [ '<STR_LIT>' ] <EOL> request = json . dumps ( obj ) <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> r = afapi . tags ( data = request ) <EOL> print_status ( action , r ) <EOL> print_response ( r , options ) <EOL> exit_for_http_status ( r ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( action , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def session ( afapi , options ) : <EOL> try : <EOL> action = '<STR_LIT>' <EOL> r = afapi . session ( sessionid = options [ '<STR_LIT>' ] ) <EOL> print_status ( action , r ) <EOL> print_response ( r , options ) <EOL> exit_for_http_status ( r ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( action , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def search_results ( afapi , <EOL> options , <EOL> search ) : <EOL> request = options [ '<STR_LIT>' ] <EOL> if options [ '<STR_LIT>' ] is not None : <EOL> try : <EOL> obj = json . loads ( request ) <EOL> obj [ '<STR_LIT:size>' ] = options [ '<STR_LIT>' ] <EOL> request = json . dumps ( obj ) <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if options [ '<STR_LIT>' ] is not None : <EOL> try : <EOL> obj = json . loads ( request ) <EOL> obj [ '<STR_LIT>' ] = options [ '<STR_LIT>' ] <EOL> request = json . dumps ( obj ) <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> for r in search ( data = request , terminal = options [ '<STR_LIT>' ] ) : <EOL> print_status ( r . name , r ) <EOL> if debug > <NUM_LIT:2> : <EOL> print_response ( r , options ) <EOL> if debug <= <NUM_LIT:2> : <EOL> print_response ( r , options ) <EOL> except pan . afapi . PanAFapiError as e : <EOL> print_exception ( search . __name__ , e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def print_exception ( action , e ) : <EOL> print ( '<STR_LIT>' % action , end = '<STR_LIT>' , file = sys . stderr ) <EOL> print ( '<STR_LIT>' % e , file = sys . stderr ) <EOL> def print_status ( action , r ) : <EOL> print ( '<STR_LIT>' % action , end = '<STR_LIT>' , file = sys . stderr ) <EOL> if r . http_code is not None : <EOL> print ( '<STR_LIT>' % r . http_code , end = '<STR_LIT>' , file = sys . stderr ) <EOL> if r . http_reason is not None : <EOL> print ( '<STR_LIT>' % r . http_reason , end = '<STR_LIT>' , file = sys . stderr ) <EOL> if r . http_headers is not None : <EOL> content_type = r . http_headers . get ( '<STR_LIT>' ) <EOL> if False and content_type is not None : <EOL> print ( '<STR_LIT>' % content_type , end = '<STR_LIT>' , file = sys . stderr ) <EOL> length = r . http_headers . get ( '<STR_LIT>' ) <EOL> if length is not None : <EOL> print ( '<STR_LIT>' % length , end = '<STR_LIT>' , file = sys . stderr ) <EOL> if r . json is not None : <EOL> if '<STR_LIT:message>' in r . json : <EOL> print ( '<STR_LIT>' % r . json [ '<STR_LIT:message>' ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> if '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % r . json [ '<STR_LIT>' ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> if '<STR_LIT>' in r . json : <EOL> hits = len ( r . json [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' % hits , end = '<STR_LIT>' , file = sys . stderr ) <EOL> elif '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % len ( r . json [ '<STR_LIT>' ] ) , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> elif '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % len ( r . json [ '<STR_LIT>' ] ) , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> elif '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % len ( r . json [ '<STR_LIT>' ] ) , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> if '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % r . json [ '<STR_LIT>' ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> elif '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % r . json [ '<STR_LIT>' ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> if '<STR_LIT>' in r . json and r . json [ '<STR_LIT>' ] is not None : <EOL> d = datetime . timedelta ( milliseconds = r . json [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' % str ( d ) [ : - <NUM_LIT:3> ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> if '<STR_LIT>' in r . json : <EOL> print ( '<STR_LIT>' % r . json [ '<STR_LIT>' ] , <EOL> end = '<STR_LIT>' , file = sys . stderr ) <EOL> print ( file = sys . stderr ) <EOL> def print_response ( r , options ) : <EOL> if r . http_text is None : <EOL> return <EOL> if r . http_headers is not None : <EOL> x = r . http_headers . get ( '<STR_LIT>' ) <EOL> if x is None : <EOL> return <EOL> if x . startswith ( '<STR_LIT>' ) : <EOL> print ( r . http_text ) <EOL> elif x . startswith ( '<STR_LIT:application/json>' ) : <EOL> if options [ '<STR_LIT>' ] : <EOL> print_json ( r . http_text , isjson = True ) <EOL> if options [ '<STR_LIT>' ] : <EOL> print_python ( r . http_text , isjson = True ) <EOL> def exit_for_http_status ( r ) : <EOL> if r . http_code is not None : <EOL> if not ( <NUM_LIT:200> <= r . http_code < <NUM_LIT> ) : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> else : <EOL> return <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def print_python ( obj , isjson = False ) : <EOL> if isjson : <EOL> try : <EOL> obj = json . loads ( obj ) <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> print ( obj , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> print ( pprint . pformat ( obj , indent = <NUM_LIT:4> ) ) <EOL> def print_json ( obj , isjson = False ) : <EOL> if isjson : <EOL> try : <EOL> obj = json . loads ( obj ) <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> print ( obj , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> print ( json . dumps ( obj , sort_keys = True , indent = <NUM_LIT:4> , <EOL> separators = ( '<STR_LIT:U+002C>' , '<STR_LIT>' ) ) ) <EOL> def process_arg ( s , list = False ) : <EOL> stdin_char = '<STR_LIT:->' <EOL> if s == stdin_char : <EOL> lines = sys . stdin . readlines ( ) <EOL> else : <EOL> try : <EOL> f = open ( s ) <EOL> lines = f . readlines ( ) <EOL> f . close ( ) <EOL> except IOError : <EOL> lines = [ s ] <EOL> if debug > <NUM_LIT:1> : <EOL> print ( '<STR_LIT>' , lines , file = sys . stderr ) <EOL> if list : <EOL> l = [ x . rstrip ( '<STR_LIT:\r\n>' ) for x in lines ] <EOL> return l <EOL> lines = '<STR_LIT>' . join ( lines ) <EOL> return lines <EOL> def parse_opts ( ) : <EOL> options = { <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> short_options = '<STR_LIT>' <EOL> long_options = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:version>' , '<STR_LIT>' , <EOL> ] <EOL> try : <EOL> opts , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , <EOL> short_options , <EOL> long_options ) <EOL> except getopt . GetoptError as error : <EOL> print ( error , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> for opt , arg in opts : <EOL> if False : <EOL> pass <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] . append ( process_arg ( arg ) ) <EOL> elif opt == '<STR_LIT>' : <EOL> try : <EOL> options [ '<STR_LIT>' ] = int ( arg ) <EOL> except ValueError : <EOL> print ( '<STR_LIT>' , arg , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> x = process_arg ( arg ) <EOL> options [ '<STR_LIT>' ] = x . rstrip ( '<STR_LIT:\r\n>' ) <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> if arg in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if arg == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = False <EOL> elif arg == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> else : <EOL> print ( '<STR_LIT>' , arg ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = True <EOL> elif opt == '<STR_LIT>' : <EOL> if not options [ '<STR_LIT>' ] < <NUM_LIT:3> : <EOL> print ( '<STR_LIT>' , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> global debug <EOL> debug += <NUM_LIT:1> <EOL> options [ '<STR_LIT>' ] = debug <EOL> elif opt == '<STR_LIT>' : <EOL> if arg : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> options [ '<STR_LIT>' ] = arg <EOL> elif opt == '<STR_LIT>' : <EOL> print ( '<STR_LIT>' , pan . afapi . __version__ ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif opt == '<STR_LIT>' : <EOL> usage ( ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> assert False , '<STR_LIT>' % opt <EOL> if options [ '<STR_LIT>' ] : <EOL> obj = { } <EOL> for r in options [ '<STR_LIT>' ] : <EOL> try : <EOL> x = json . loads ( r ) <EOL> except ValueError as e : <EOL> print ( '<STR_LIT>' % ( e , r ) , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> obj . update ( x ) <EOL> try : <EOL> options [ '<STR_LIT>' ] = json . dumps ( obj ) <EOL> options [ '<STR_LIT>' ] = obj <EOL> except ValueError as e : <EOL> print ( e , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if options [ '<STR_LIT>' ] > <NUM_LIT:2> : <EOL> s = pprint . pformat ( options , indent = <NUM_LIT:4> ) <EOL> print ( s , file = sys . stderr ) <EOL> return options <EOL> def usage ( ) : <EOL> usage = '''<STR_LIT>''' <EOL> print ( usage % ( os . path . basename ( sys . argv [ <NUM_LIT:0> ] ) , <EOL> pan . afapi . DEFAULT_API_VERSION ) , end = '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
<s> import binascii <EOL> import sys <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> from triplesec . crypto import PBKDF2 , XOR_HMAC_SHA3_SHA512 <EOL> from triplesec . utils import PBKDF2_params <EOL> class TripleSec_test_PBKDF2 ( unittest . TestCase ) : <EOL> def test ( self ) : <EOL> for i , v in enumerate ( test_vectors [ '<STR_LIT>' ] ) : <EOL> key = binascii . unhexlify ( v [ '<STR_LIT:key>' ] ) <EOL> salt = binascii . unhexlify ( v [ '<STR_LIT>' ] ) <EOL> derived = PBKDF2 ( key , salt , v [ '<STR_LIT>' ] , PBKDF2_params ( v [ '<STR_LIT:c>' ] , XOR_HMAC_SHA3_SHA512 ) ) <EOL> self . assertEqual ( binascii . hexlify ( derived ) , v [ '<STR_LIT>' ] . encode ( ) , repr ( v ) ) <EOL> test_vectors = { <EOL> "<STR_LIT:version>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT:64> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT:64> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT:64> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:c>" : <NUM_LIT:64> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:64> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:64> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:64> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:key>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:64> , <EOL> "<STR_LIT:c>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> ] <EOL> } </s>
<s> """<STR_LIT>""" <EOL> import sys <EOL> PY2 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> <EOL> PY3 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:3> <EOL> if PY3 : <EOL> def b ( s ) : <EOL> if isinstance ( s , bytes ) : <EOL> return s <EOL> return s . encode ( '<STR_LIT:utf8>' , '<STR_LIT:replace>' ) <EOL> def u ( s ) : <EOL> if isinstance ( s , bytes ) : <EOL> return s . decode ( '<STR_LIT:utf8>' , '<STR_LIT:replace>' ) <EOL> return s <EOL> from io import BytesIO as StringIO <EOL> from configparser import RawConfigParser <EOL> else : <EOL> def b ( s ) : <EOL> if isinstance ( s , unicode ) : <EOL> return s . encode ( '<STR_LIT:utf8>' , '<STR_LIT:replace>' ) <EOL> return s <EOL> def u ( s ) : <EOL> if isinstance ( s , unicode ) : <EOL> return s <EOL> if isinstance ( s , int ) : <EOL> s = str ( s ) <EOL> return unicode ( s , "<STR_LIT:utf8>" , "<STR_LIT:replace>" ) <EOL> from StringIO import StringIO <EOL> from ConfigParser import RawConfigParser <EOL> b . __doc__ = "<STR_LIT>" <EOL> u . __doc__ = "<STR_LIT>" </s>
<s> from TelluricFitter import TelluricFitter <EOL> from MakeModel import Modeler <EOL> import DataStructures <EOL> import FittingUtilities </s>
<s> import datetime <EOL> from django . contrib . syndication . views import Feed <EOL> from django . contrib . auth . models import User <EOL> from intranet . org . models import Diary , Event <EOL> today = datetime . date . today ( ) <EOL> yesterday = today - datetime . timedelta ( days = <NUM_LIT:3> ) <EOL> nextday = today + datetime . timedelta ( days = <NUM_LIT:8> ) <EOL> class LatestDiarys ( Feed ) : <EOL> title = "<STR_LIT>" <EOL> link = "<STR_LIT>" <EOL> description = "<STR_LIT>" <EOL> def items ( self ) : <EOL> return Diary . objects . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:10> ] <EOL> class LatestEvents ( Feed ) : <EOL> title = "<STR_LIT>" <EOL> link = "<STR_LIT>" <EOL> description = "<STR_LIT>" <EOL> def items ( self ) : <EOL> return Event . objects . filter ( start_date__range = ( today , nextday ) ) . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:15> ] <EOL> class ToDo ( Feed ) : <EOL> def get_object ( self , bits ) : <EOL> if len ( bits ) != <NUM_LIT:1> : <EOL> raise User . ObjectDoesNotExist <EOL> return User . objects . filter ( username__exact = bits [ <NUM_LIT:0> ] ) . get ( ) <EOL> def title ( self , obj ) : <EOL> return "<STR_LIT>" % obj . username <EOL> def link ( self , obj ) : <EOL> return obj . get_absolute_url ( ) <EOL> def description ( self , obj ) : <EOL> return "<STR_LIT>" % obj . username <EOL> def items ( self , obj ) : <EOL> return [ ] </s>
<s> import datetime <EOL> from django import template <EOL> from django . template import Library <EOL> from django . template import resolve_variable <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from html2text import html2text as h2t <EOL> from intranet . org . models import Scratchpad <EOL> register = Library ( ) <EOL> @ register . filter ( ) <EOL> def html2text ( value ) : <EOL> """<STR_LIT>""" <EOL> return h2t ( value ) <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def box_plache ( diarys , user ) : <EOL> """<STR_LIT>""" <EOL> list = { } <EOL> paylist = { } <EOL> billable_hours = <NUM_LIT:0> <EOL> total_hours = <NUM_LIT:0> <EOL> sum = <NUM_LIT:0> <EOL> for o in diarys : <EOL> a = o . author . username <EOL> if a in list : <EOL> list [ a ] += o . length . hour <EOL> else : <EOL> list [ a ] = o . length . hour <EOL> paylist [ a ] = <NUM_LIT:0> <EOL> total_hours += o . length . hour <EOL> if ( ( o . task . id == <NUM_LIT> ) or ( o . task . id == <NUM_LIT> and o . event != None and ( o . event . require_technician or o . event . require_video ) ) ) : <EOL> paylist [ a ] += o . length . hour <EOL> billable_hours += o . length . hour <EOL> tariff = <NUM_LIT> <EOL> objects = [ ] <EOL> for o in list : <EOL> a = { } <EOL> a [ '<STR_LIT:name>' ] = o <EOL> a [ '<STR_LIT:time>' ] = list [ o ] <EOL> a [ '<STR_LIT>' ] = paylist [ o ] <EOL> a [ '<STR_LIT>' ] = paylist [ o ] * tariff <EOL> objects . append ( a ) <EOL> sum += ( paylist [ o ] * tariff ) <EOL> objects . sort ( lambda a , b : int ( b [ '<STR_LIT>' ] - a [ '<STR_LIT>' ] ) ) <EOL> return { '<STR_LIT>' : objects , <EOL> '<STR_LIT:user>' : user , <EOL> '<STR_LIT>' : billable_hours , <EOL> '<STR_LIT>' : total_hours , <EOL> '<STR_LIT>' : sum } <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def box_scratchpad ( user ) : <EOL> try : <EOL> scratchpad = Scratchpad . objects . latest ( '<STR_LIT:id>' ) <EOL> except ObjectDoesNotExist : <EOL> scratchpad = [ ] <EOL> return { '<STR_LIT:object>' : scratchpad } <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def print_diary ( context , obj ) : <EOL> context [ '<STR_LIT:object>' ] = obj <EOL> return context <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def print_event ( context , obj ) : <EOL> context . update ( { '<STR_LIT>' : obj } ) <EOL> return context <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def form_event ( form ) : <EOL> return { '<STR_LIT>' : form } <EOL> @ register . inclusion_tag ( '<STR_LIT>' ) <EOL> def box_reccurings ( form ) : <EOL> return { '<STR_LIT>' : form } <EOL> def parse ( args ) : <EOL> kwargs = { } <EOL> if args : <EOL> if '<STR_LIT:U+002C>' not in args : <EOL> args += '<STR_LIT:U+002C>' <EOL> for arg in args . split ( '<STR_LIT:U+002C>' ) : <EOL> arg = arg . strip ( ) <EOL> if arg == '<STR_LIT>' : <EOL> continue <EOL> kw , val = arg . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> kw = kw . lower ( ) <EOL> kwargs [ kw ] = val <EOL> return kwargs <EOL> class BoxListNode ( template . Node ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , object , queryset , params ) : <EOL> self . object = object <EOL> self . queryset = queryset <EOL> self . params = params <EOL> def render ( self , context ) : <EOL> kwargs = parse ( self . queryset ) <EOL> pargs = parse ( self . params ) <EOL> for i in kwargs : <EOL> if kwargs [ i ] == '<STR_LIT:False>' : <EOL> kwargs [ i ] = False <EOL> elif kwargs [ i ] == '<STR_LIT:True>' : <EOL> kwargs [ i ] = True <EOL> else : <EOL> kwargs [ i ] = resolve_variable ( kwargs [ i ] , context ) <EOL> kwargs = dict ( [ ( str ( x ) , kwargs [ x ] ) for x in kwargs . keys ( ) ] ) <EOL> new_queryset = self . object . objects . filter ( ** kwargs ) <EOL> if '<STR_LIT>' in pargs : <EOL> new_queryset = new_queryset . order_by ( pargs [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in pargs : <EOL> l = pargs [ '<STR_LIT>' ] <EOL> i = l . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] <EOL> if i : <EOL> i = int ( i ) <EOL> else : <EOL> i = <NUM_LIT:0> <EOL> j = l . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] <EOL> if j : <EOL> j = int ( j ) <EOL> else : <EOL> j = <NUM_LIT:0> <EOL> new_queryset = new_queryset [ i : j ] <EOL> if '<STR_LIT>' in pargs : <EOL> template_name = pargs [ '<STR_LIT>' ] <EOL> else : <EOL> model = new_queryset . model <EOL> template_name = "<STR_LIT>" % ( model . _meta . app_label , model . _meta . object_name . lower ( ) ) <EOL> context [ '<STR_LIT>' ] = new_queryset <EOL> context [ '<STR_LIT>' ] = datetime . date . today ( ) <EOL> return template . loader . get_template ( template_name ) . render ( context ) <EOL> @ register . tag ( name = '<STR_LIT>' ) <EOL> def box_list ( parser , token ) : <EOL> bits = token . split_contents ( ) <EOL> object_name = bits [ <NUM_LIT:1> ] <EOL> queryset = bits [ <NUM_LIT:2> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> if len ( bits ) > <NUM_LIT:3> : <EOL> params = bits [ <NUM_LIT:3> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> else : <EOL> params = '<STR_LIT>' <EOL> m = __import__ ( "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , object_name ) <EOL> object = getattr ( m , object_name ) <EOL> return BoxListNode ( object , queryset , params ) </s>
<s> import datetime <EOL> from south . db import db <EOL> from south . v2 import SchemaMigration <EOL> from django . db import models <EOL> class Migration ( SchemaMigration ) : <EOL> def forwards ( self , orm ) : <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> def backwards ( self , orm ) : <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> db . alter_column ( '<STR_LIT>' , '<STR_LIT>' , self . gf ( '<STR_LIT>' ) ( max_length = <NUM_LIT> , null = True ) ) <EOL> models = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:Meta>' : { '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT:object_name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:description>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT:id>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:primary_key>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:image>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT:100>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT:user>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:to>' : "<STR_LIT>" , '<STR_LIT>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:null>' : '<STR_LIT:True>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:Meta>' : { '<STR_LIT:object_name>' : '<STR_LIT>' } , <EOL> '<STR_LIT:id>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:primary_key>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:name>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT>' : '<STR_LIT:True>' , '<STR_LIT:max_length>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:to>' : "<STR_LIT>" , '<STR_LIT>' : '<STR_LIT:False>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:Meta>' : { '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT:object_name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT:100>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:to>' : "<STR_LIT>" } ) , <EOL> '<STR_LIT:id>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:primary_key>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:name>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' } ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:Meta>' : { '<STR_LIT:object_name>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT:email>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:to>' : "<STR_LIT>" , '<STR_LIT>' : '<STR_LIT:False>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:id>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:primary_key>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT:False>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:default>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:password>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:to>' : "<STR_LIT>" , '<STR_LIT>' : '<STR_LIT:False>' , '<STR_LIT:blank>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT:username>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT>' : '<STR_LIT:True>' , '<STR_LIT:max_length>' : '<STR_LIT>' } ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:Meta>' : { '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT:object_name>' : '<STR_LIT>' , '<STR_LIT>' : "<STR_LIT>" } , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT:100>' } ) , <EOL> '<STR_LIT:id>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:primary_key>' : '<STR_LIT:True>' } ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT:100>' } ) , <EOL> '<STR_LIT:name>' : ( '<STR_LIT>' , [ ] , { '<STR_LIT:max_length>' : '<STR_LIT:100>' } ) <EOL> } <EOL> } <EOL> complete_apps = [ '<STR_LIT>' ] </s>
<s> import os <EOL> import datetime <EOL> from zipfile import ZipFile <EOL> from cStringIO import StringIO <EOL> import requests <EOL> from django . template import Template , Context <EOL> from django . http import HttpResponse <EOL> from django . conf import settings <EOL> from intranet . org . models import Event <EOL> def _sablona_file ( fn ) : <EOL> return os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' , fn ) <EOL> def prepare_video_zip ( slug , title , date , person ) : <EOL> context = Context ( { <EOL> '<STR_LIT:date>' : title , <EOL> '<STR_LIT:title>' : date , <EOL> '<STR_LIT>' : person , <EOL> } ) <EOL> folder_title = slug <EOL> t = Template ( open ( _sablona_file ( '<STR_LIT>' ) ) . read ( ) ) <EOL> default_xml = t . render ( context ) . encode ( '<STR_LIT:utf-8>' ) <EOL> zipfile_file = StringIO ( ) <EOL> zipfile = ZipFile ( zipfile_file , "<STR_LIT:w>" ) <EOL> zipfile . writestr ( "<STR_LIT>" % folder_title , default_xml ) <EOL> for fn in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> zipfile . write ( _sablona_file ( fn ) , '<STR_LIT>' % ( folder_title , fn ) ) <EOL> zipfile . close ( ) <EOL> response = HttpResponse ( zipfile_file . getvalue ( ) , mimetype = "<STR_LIT>" ) <EOL> response [ '<STR_LIT>' ] = '<STR_LIT>' % folder_title <EOL> return response <EOL> def is_streaming ( ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( settings , '<STR_LIT>' , False ) : <EOL> return False <EOL> try : <EOL> r = requests . head ( settings . LIVE_STREAM_URL , timeout = <NUM_LIT:1> ) <EOL> except ( requests . ConnectionError , requests . Timeout ) : <EOL> return False <EOL> else : <EOL> return <NUM_LIT:200> <= r . status_code < <NUM_LIT> <EOL> def get_streaming_event ( ) : <EOL> try : <EOL> now = datetime . datetime . now ( ) <EOL> streaming_event = Event . objects . filter ( public = True , <EOL> start_date__lte = now ) . order_by ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> try : <EOL> next_event = streaming_event . get_next ( ) <EOL> except Event . DoesNotExist : <EOL> streaming_event = next_event <EOL> else : <EOL> td = next_event . start_date - now <EOL> if td . days == <NUM_LIT:0> and <NUM_LIT:0> < td . seconds < <NUM_LIT> : <EOL> streaming_event = next_event <EOL> except IndexError : <EOL> return <EOL> return streaming_event <EOL> def get_next_streaming_event ( ) : <EOL> now = datetime . datetime . now ( ) <EOL> q = Event . objects . filter ( public = True , <EOL> require_video = True , <EOL> start_date__gte = now ) <EOL> try : <EOL> return q . order_by ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> return </s>
<s> """<STR_LIT>""" <EOL> from statsite . aggregator import Aggregator <EOL> from statsite . collector import Collector <EOL> from statsite . metrics_store import MetricsStore <EOL> class DumbAggregator ( Aggregator ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( DumbAggregator , self ) . __init__ ( * args , ** kwargs ) <EOL> self . flushed = False <EOL> self . metrics = [ ] <EOL> def add_metrics ( self , metrics ) : <EOL> self . metrics . extend ( metrics ) <EOL> def flush ( self ) : <EOL> self . flushed = True <EOL> class DumbCollector ( Collector ) : <EOL> def __init__ ( self , host = None , port = None , aggregator = None ) : <EOL> super ( DumbCollector , self ) . __init__ ( aggregator ) <EOL> pass <EOL> class DumbMetricsStore ( MetricsStore ) : <EOL> def __init__ ( self , host = None , port = None , prefix = None ) : <EOL> self . data = [ ] <EOL> def flush ( self , data ) : <EOL> self . data . extend ( data ) <EOL> def statsite_settings ( settings ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( func ) : <EOL> func . func_dict [ "<STR_LIT>" ] = settings <EOL> return func <EOL> return decorator </s>
<s> import sys <EOL> import tidylib as tidy <EOL> from concurrent . futures import ThreadPoolExecutor <EOL> import os <EOL> try : <EOL> import jsbeautifier <EOL> except ImportError : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> import cssutils <EOL> except ImportError : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> tidy . BASE_OPTIONS = { } <EOL> tidy_options = { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : "<STR_LIT:utf8>" <EOL> } <EOL> class Cleanify ( ) : <EOL> def __init__ ( self , directory ) : <EOL> self . target = directory <EOL> self . dirstats = { } <EOL> self . htmlfiles = [ ] <EOL> self . jsfiles = [ ] <EOL> self . cssfiles = [ ] <EOL> def scan ( self ) : <EOL> os . chdir ( self . target ) <EOL> for root , dirs , files in os . walk ( '<STR_LIT>' ) : <EOL> for file in files : <EOL> if file . endswith ( '<STR_LIT>' ) : <EOL> self . htmlfiles . append ( os . path . join ( root , file ) ) <EOL> elif file . endswith ( '<STR_LIT>' ) : <EOL> self . jsfiles . append ( os . path . join ( root , file ) ) <EOL> elif file . endswith ( '<STR_LIT>' ) : <EOL> self . cssfiles . append ( os . path . join ( root , file ) ) <EOL> else : <EOL> pass <EOL> def clean_html ( self , htmlfile ) : <EOL> try : <EOL> reader = open ( htmlfile , '<STR_LIT:r>' ) <EOL> content = reader . read ( ) <EOL> reader . close ( ) <EOL> document , errors = tidy . tidy_document ( content , <EOL> options = tidy_options ) <EOL> if document : <EOL> writer = open ( htmlfile , '<STR_LIT:w>' ) <EOL> writer . write ( document ) <EOL> writer . close ( ) <EOL> print "<STR_LIT>" , htmlfile <EOL> except Exception , e : <EOL> print e <EOL> def clean_js ( self , jsfile ) : <EOL> try : <EOL> res = jsbeautifier . beautify_file ( jsfile ) <EOL> if res : <EOL> fileWriter = open ( jsfile , '<STR_LIT:w>' ) <EOL> fileWriter . write ( res ) <EOL> fileWriter . close ( ) <EOL> print "<STR_LIT>" , jsfile <EOL> except Exception , e : <EOL> print e <EOL> def clean_css ( self , cssfile ) : <EOL> try : <EOL> content = cssutils . parseFile ( cssfile ) <EOL> if content : <EOL> writer = open ( cssfile , '<STR_LIT:w>' ) <EOL> writer . write ( content ) <EOL> writer . close ( ) <EOL> print "<STR_LIT>" , cssfile <EOL> except Exception , e : <EOL> print e <EOL> def clean ( self ) : <EOL> self . scan ( ) <EOL> hlen = len ( self . htmlfiles ) <EOL> jlen = len ( self . jsfiles ) <EOL> clen = len ( self . cssfiles ) <EOL> if hlen > <NUM_LIT:0> or jlen > <NUM_LIT:0> or clen > <NUM_LIT:0> : <EOL> workers = <NUM_LIT:5> <EOL> print workers , "<STR_LIT>" <EOL> with ThreadPoolExecutor ( max_workers = workers ) as executor : <EOL> for hfile in self . htmlfiles : <EOL> executor . submit ( self . clean_html , hfile ) <EOL> for jfile in self . jsfiles : <EOL> executor . submit ( self . clean_js , jfile ) <EOL> for cfile in self . cssfiles : <EOL> executor . submit ( self . clean_css , cfile ) <EOL> executor . shutdown ( ) <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> if os . path . isdir ( sys . argv [ <NUM_LIT:1> ] ) : <EOL> project_dir = sys . argv [ <NUM_LIT:1> ] <EOL> cleanify = Cleanify ( project_dir ) <EOL> cleanify . clean ( ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) </s>
<s> from audiostream import get_output , AudioSample <EOL> from math import sin , pi <EOL> from struct import pack <EOL> from itertools import * <EOL> def sine_wave ( frequency = <NUM_LIT> , framerate = <NUM_LIT> , amplitude = <NUM_LIT:0.5> , index = <NUM_LIT:0> ) : <EOL> period = int ( framerate / frequency ) <EOL> if amplitude > <NUM_LIT:1.0> : amplitude = <NUM_LIT:1.0> <EOL> if amplitude < <NUM_LIT:0.0> : amplitude = <NUM_LIT:0.0> <EOL> lookup_table = [ float ( amplitude ) * sin ( <NUM_LIT> * pi * float ( frequency ) * ( float ( i % period ) / float ( framerate ) ) ) for i in xrange ( period ) ] <EOL> return ( lookup_table [ ( index + i ) % period ] for i in count ( <NUM_LIT:0> ) ) <EOL> from kivy . app import App <EOL> from kivy . uix . slider import Slider <EOL> from kivy . uix . gridlayout import GridLayout <EOL> from kivy . uix . button import Button <EOL> from functools import partial <EOL> class AudioApp ( App ) : <EOL> def build ( self ) : <EOL> root = GridLayout ( padding = <NUM_LIT:20> , spacing = <NUM_LIT:10> , cols = <NUM_LIT:4> ) <EOL> self . stream = get_output ( channels = <NUM_LIT:2> , buffersize = <NUM_LIT> ) <EOL> self . gens = { } <EOL> for x in xrange ( <NUM_LIT:20> ) : <EOL> sample = AudioSample ( partial ( self . audio_callback , x ) ) <EOL> self . stream . add_sample ( sample ) <EOL> btn = Button ( text = '<STR_LIT>' % x ) <EOL> btn . bind ( state = partial ( self . update_state , x ) ) <EOL> slider = Slider ( min = <NUM_LIT> , max = <NUM_LIT> , value = <NUM_LIT> ) <EOL> slider . bind ( value = partial ( self . update_freq , x ) ) <EOL> root . add_widget ( btn ) <EOL> root . add_widget ( slider ) <EOL> gen_left = sine_wave ( ) <EOL> gen_right = sine_wave ( frequency = <NUM_LIT> ) <EOL> self . gens [ x ] = [ sample , gen_left , gen_right , None , None ] <EOL> return root <EOL> def update_freq ( self , x , slider , value ) : <EOL> self . gens [ x ] [ <NUM_LIT:3> ] = value <EOL> self . gens [ x ] [ <NUM_LIT:4> ] = value / <NUM_LIT:2> <EOL> def update_state ( self , x , instance , value ) : <EOL> if value == '<STR_LIT>' : <EOL> self . gens [ x ] [ <NUM_LIT:0> ] . play ( ) <EOL> elif value == '<STR_LIT>' : <EOL> self . gens [ x ] [ <NUM_LIT:0> ] . stop ( ) <EOL> def audio_callback ( self , x , sample , index , bufsize ) : <EOL> buf = [ ] <EOL> f = ( <NUM_LIT:2> ** <NUM_LIT:16> ) / pi <EOL> lvl = lvr = None <EOL> g = self . gens [ x ] <EOL> gen_left , gen_right , next_freq_left , next_freq_right = g [ <NUM_LIT:1> : ] <EOL> while len ( buf ) < bufsize / <NUM_LIT:2> : <EOL> vl = int ( gen_left . next ( ) * f ) <EOL> vr = int ( gen_right . next ( ) * f ) <EOL> if next_freq_left and lvl == <NUM_LIT:0> and vl > <NUM_LIT:0> : <EOL> g [ <NUM_LIT:1> ] = gen_left = sine_wave ( frequency = next_freq_left ) <EOL> g [ <NUM_LIT:3> ] = next_freq_left = None <EOL> vl = int ( gen_left . next ( ) * f ) <EOL> if next_freq_right and lvr == <NUM_LIT:0> and vr > <NUM_LIT:0> : <EOL> g [ <NUM_LIT:2> ] = gen_right = sine_wave ( frequency = next_freq_right ) <EOL> g [ <NUM_LIT:4> ] = next_freq_right = None <EOL> vr = int ( gen_right . next ( ) * f ) <EOL> lvl = vl <EOL> lvr = vr <EOL> buf . append ( vl ) <EOL> buf . append ( vr ) <EOL> return pack ( '<STR_LIT:h>' * len ( buf ) , * buf ) <EOL> AudioApp ( ) . run ( ) </s>
<s> from toolchain import Recipe , shprint <EOL> from os . path import join <EOL> import sh <EOL> class FreetypeRecipe ( Recipe ) : <EOL> version = "<STR_LIT>" <EOL> url = "<STR_LIT>" <EOL> library = "<STR_LIT>" <EOL> include_dir = [ "<STR_LIT>" , ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> include_per_arch = True <EOL> def build_arch ( self , arch ) : <EOL> build_env = arch . get_env ( ) <EOL> configure = sh . Command ( join ( self . build_dir , "<STR_LIT>" ) ) <EOL> shprint ( configure , <EOL> "<STR_LIT>" . format ( build_env [ "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" . format ( build_env [ "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" . format ( build_env [ "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" . format ( build_env [ "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( arch . triple ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> shprint ( sh . make , "<STR_LIT>" ) <EOL> shprint ( sh . make ) <EOL> recipe = FreetypeRecipe ( ) </s>
<s> import os <EOL> import sys <EOL> import subprocess <EOL> cython = None <EOL> def resolve_cython ( ) : <EOL> global cython <EOL> for executable in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> for path in os . environ [ '<STR_LIT>' ] . split ( '<STR_LIT::>' ) : <EOL> if not os . path . exists ( path ) : <EOL> continue <EOL> if executable in os . listdir ( path ) : <EOL> cython = os . path . join ( path , executable ) <EOL> return <EOL> def do ( fn ) : <EOL> print ( '<STR_LIT>' , fn ) <EOL> parts = fn . split ( '<STR_LIT:/>' ) <EOL> assert ( parts [ - <NUM_LIT:1> ] . endswith ( '<STR_LIT>' ) ) <EOL> if parts [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> parts . pop ( <NUM_LIT:0> ) <EOL> modname = parts [ - <NUM_LIT:1> ] [ : - <NUM_LIT:4> ] <EOL> package = '<STR_LIT:_>' . join ( parts [ : - <NUM_LIT:1> ] ) <EOL> subprocess . Popen ( [ cython , fn ] , env = os . environ ) . communicate ( ) <EOL> if not package : <EOL> print ( '<STR_LIT>' , fn ) <EOL> else : <EOL> fn_c = fn [ : - <NUM_LIT:3> ] + '<STR_LIT:c>' <EOL> with open ( fn_c ) as fd : <EOL> data = fd . read ( ) <EOL> modname = modname . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] <EOL> pat1 = '<STR_LIT>' . format ( modname ) <EOL> sub1 = '<STR_LIT>' . format ( package , modname ) <EOL> pat2 = '<STR_LIT>' . format ( modname ) <EOL> sub2 = '<STR_LIT>' . format ( package , modname ) <EOL> pat3 = '<STR_LIT>' . format ( modname ) <EOL> sub3 = '<STR_LIT>' . format ( package , modname ) <EOL> pat4 = '<STR_LIT>' . format ( modname ) <EOL> sub4 = '<STR_LIT>' . format ( package , modname ) <EOL> print ( '<STR_LIT>' . format ( pat1 , sub1 ) ) <EOL> print ( '<STR_LIT>' . format ( pat2 , sub2 ) ) <EOL> print ( '<STR_LIT>' . format ( pat3 , sub3 ) ) <EOL> print ( '<STR_LIT>' . format ( pat4 , sub4 ) ) <EOL> data = data . replace ( pat1 , sub1 ) <EOL> data = data . replace ( pat2 , sub2 ) <EOL> data = data . replace ( pat3 , sub3 ) <EOL> data = data . replace ( pat4 , sub4 ) <EOL> print ( '<STR_LIT>' , fn_c ) <EOL> with open ( fn_c , '<STR_LIT:w>' ) as fd : <EOL> fd . write ( data ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print ( '<STR_LIT>' , sys . argv ) <EOL> resolve_cython ( ) <EOL> for fn in sys . argv [ <NUM_LIT:1> : ] : <EOL> do ( fn ) </s>
<s> '''<STR_LIT>''' <EOL> __version__ = '<STR_LIT>' <EOL> from kivy . app import App <EOL> from os . path import exists <EOL> from jnius import autoclass , cast <EOL> from android import activity <EOL> from functools import partial <EOL> from kivy . clock import Clock <EOL> from kivy . uix . scatter import Scatter <EOL> from kivy . properties import StringProperty <EOL> from PIL import Image <EOL> Intent = autoclass ( '<STR_LIT>' ) <EOL> PythonActivity = autoclass ( '<STR_LIT>' ) <EOL> MediaStore = autoclass ( '<STR_LIT>' ) <EOL> Uri = autoclass ( '<STR_LIT>' ) <EOL> Environment = autoclass ( '<STR_LIT>' ) <EOL> class Picture ( Scatter ) : <EOL> source = StringProperty ( None ) <EOL> class TakePictureApp ( App ) : <EOL> def build ( self ) : <EOL> self . index = <NUM_LIT:0> <EOL> activity . bind ( on_activity_result = self . on_activity_result ) <EOL> def get_filename ( self ) : <EOL> while True : <EOL> self . index += <NUM_LIT:1> <EOL> fn = ( Environment . getExternalStorageDirectory ( ) . getPath ( ) + <EOL> '<STR_LIT>' . format ( self . index ) ) <EOL> if not exists ( fn ) : <EOL> return fn <EOL> def take_picture ( self ) : <EOL> intent = Intent ( MediaStore . ACTION_IMAGE_CAPTURE ) <EOL> self . last_fn = self . get_filename ( ) <EOL> self . uri = Uri . parse ( '<STR_LIT>' + self . last_fn ) <EOL> self . uri = cast ( '<STR_LIT>' , self . uri ) <EOL> intent . putExtra ( MediaStore . EXTRA_OUTPUT , self . uri ) <EOL> PythonActivity . mActivity . startActivityForResult ( intent , <NUM_LIT> ) <EOL> def on_activity_result ( self , requestCode , resultCode , intent ) : <EOL> if requestCode == <NUM_LIT> : <EOL> Clock . schedule_once ( partial ( self . add_picture , self . last_fn ) , <NUM_LIT:0> ) <EOL> def add_picture ( self , fn , * args ) : <EOL> im = Image . open ( fn ) <EOL> width , height = im . size <EOL> im . thumbnail ( ( width / <NUM_LIT:4> , height / <NUM_LIT:4> ) , Image . ANTIALIAS ) <EOL> im . save ( fn , quality = <NUM_LIT> ) <EOL> self . root . add_widget ( Picture ( source = fn , center = self . root . center ) ) <EOL> def on_pause ( self ) : <EOL> return True <EOL> TakePictureApp ( ) . run ( ) </s>
<s> '''<STR_LIT>''' <EOL> import kivy <EOL> kivy . require ( '<STR_LIT>' ) <EOL> import os <EOL> import sys <EOL> from kivy . app import App <EOL> from kivy . factory import Factory <EOL> from kivy . lang import Builder , Parser , ParserException <EOL> from kivy . properties import ObjectProperty <EOL> from kivy . uix . boxlayout import BoxLayout <EOL> from kivy . uix . codeinput import CodeInput <EOL> from kivy . animation import Animation <EOL> from kivy . clock import Clock <EOL> CATALOG_ROOT = os . path . dirname ( __file__ ) <EOL> '''<STR_LIT>''' <EOL> CONTAINER_KVS = os . path . join ( CATALOG_ROOT , '<STR_LIT>' ) <EOL> CONTAINER_CLASSES = [ c [ : - <NUM_LIT:3> ] for c in os . listdir ( CONTAINER_KVS ) <EOL> if c . endswith ( '<STR_LIT>' ) ] <EOL> class Container ( BoxLayout ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( Container , self ) . __init__ ( ** kwargs ) <EOL> self . previous_text = open ( self . kv_file ) . read ( ) <EOL> parser = Parser ( content = self . previous_text ) <EOL> widget = Factory . get ( parser . root . name ) ( ) <EOL> Builder . _apply_rule ( widget , parser . root , parser . root ) <EOL> self . add_widget ( widget ) <EOL> @ property <EOL> def kv_file ( self ) : <EOL> '''<STR_LIT>''' <EOL> return os . path . join ( CONTAINER_KVS , self . __class__ . __name__ + '<STR_LIT>' ) <EOL> for class_name in CONTAINER_CLASSES : <EOL> globals ( ) [ class_name ] = type ( class_name , ( Container , ) , { } ) <EOL> class KivyRenderTextInput ( CodeInput ) : <EOL> def keyboard_on_key_down ( self , window , keycode , text , modifiers ) : <EOL> is_osx = sys . platform == '<STR_LIT>' <EOL> ctrl , cmd = <NUM_LIT:64> , <NUM_LIT> <EOL> key , key_str = keycode <EOL> if text and not key in ( list ( self . interesting_keys . keys ( ) ) + [ <NUM_LIT> ] ) : <EOL> if modifiers == [ '<STR_LIT>' ] or ( is_osx and modifiers == [ '<STR_LIT>' ] ) : <EOL> if key == ord ( '<STR_LIT:s>' ) : <EOL> self . catalog . change_kv ( True ) <EOL> return <EOL> return super ( KivyRenderTextInput , self ) . keyboard_on_key_down ( <EOL> window , keycode , text , modifiers ) <EOL> class Catalog ( BoxLayout ) : <EOL> '''<STR_LIT>''' <EOL> language_box = ObjectProperty ( ) <EOL> screen_manager = ObjectProperty ( ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . _previously_parsed_text = '<STR_LIT>' <EOL> super ( Catalog , self ) . __init__ ( ** kwargs ) <EOL> self . show_kv ( None , '<STR_LIT>' ) <EOL> self . carousel = None <EOL> def show_kv ( self , instance , value ) : <EOL> '''<STR_LIT>''' <EOL> self . screen_manager . current = value <EOL> child = self . screen_manager . current_screen . children [ <NUM_LIT:0> ] <EOL> with open ( child . kv_file , '<STR_LIT:rb>' ) as file : <EOL> self . language_box . text = file . read ( ) . decode ( '<STR_LIT:utf8>' ) <EOL> Clock . unschedule ( self . change_kv ) <EOL> self . change_kv ( ) <EOL> self . language_box . reset_undo ( ) <EOL> def schedule_reload ( self ) : <EOL> if self . auto_reload : <EOL> txt = self . language_box . text <EOL> child = self . screen_manager . current_screen . children [ <NUM_LIT:0> ] <EOL> if txt == child . previous_text : <EOL> return <EOL> child . previous_text = txt <EOL> Clock . unschedule ( self . change_kv ) <EOL> Clock . schedule_once ( self . change_kv , <NUM_LIT:2> ) <EOL> def change_kv ( self , * largs ) : <EOL> '''<STR_LIT>''' <EOL> txt = self . language_box . text <EOL> kv_container = self . screen_manager . current_screen . children [ <NUM_LIT:0> ] <EOL> try : <EOL> parser = Parser ( content = txt ) <EOL> kv_container . clear_widgets ( ) <EOL> widget = Factory . get ( parser . root . name ) ( ) <EOL> Builder . _apply_rule ( widget , parser . root , parser . root ) <EOL> kv_container . add_widget ( widget ) <EOL> except ( SyntaxError , ParserException ) as e : <EOL> self . show_error ( e ) <EOL> except Exception as e : <EOL> self . show_error ( e ) <EOL> def show_error ( self , e ) : <EOL> self . info_label . text = str ( e ) . encode ( '<STR_LIT:utf-8>' ) <EOL> self . anim = Animation ( top = <NUM_LIT> , opacity = <NUM_LIT:1> , d = <NUM_LIT:2> , t = '<STR_LIT>' ) + Animation ( top = <NUM_LIT> , d = <NUM_LIT:3> ) + Animation ( top = <NUM_LIT:0> , opacity = <NUM_LIT:0> , d = <NUM_LIT:2> ) <EOL> self . anim . start ( self . info_label ) <EOL> class KivyCatalogApp ( App ) : <EOL> '''<STR_LIT>''' <EOL> def build ( self ) : <EOL> return Catalog ( ) <EOL> def on_pause ( self ) : <EOL> return True <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> KivyCatalogApp ( ) . run ( ) </s>
<s> '''<STR_LIT>''' <EOL> import kivy <EOL> kivy . require ( '<STR_LIT>' ) <EOL> from kivy . app import App <EOL> from kivy . uix . boxlayout import BoxLayout <EOL> class RootWidget ( BoxLayout ) : <EOL> def first_function ( self , status ) : <EOL> print ( status ) <EOL> if self . ids . my_switch . active is True : <EOL> self . ids . my_label . text = '<STR_LIT>' <EOL> else : <EOL> self . ids . my_label . text = '<STR_LIT>' <EOL> class TestApp ( App ) : <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> TestApp ( ) . run ( ) </s>
<s> '''<STR_LIT>''' <EOL> from kivy . base import runTouchApp <EOL> from kivy . lang import Builder <EOL> from kivy . uix . effectwidget import EffectWidget , EffectBase <EOL> effect_string = '''<STR_LIT>''' <EOL> class DemoEffect ( EffectWidget ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> self . effect_reference = EffectBase ( glsl = effect_string ) <EOL> super ( DemoEffect , self ) . __init__ ( * args , ** kwargs ) <EOL> widget = Builder . load_string ( '''<STR_LIT>''' ) <EOL> runTouchApp ( widget ) </s>
<s> from kivy . uix . scatter import Scatter <EOL> from kivy . app import App <EOL> class MyScatter ( Scatter ) : <EOL> pass <EOL> class ScatterApp ( App ) : <EOL> def build ( self ) : <EOL> s = MyScatter ( size = ( <NUM_LIT> , <NUM_LIT> ) , size_hint = ( None , None ) ) <EOL> s . top = <NUM_LIT> <EOL> return s <EOL> ScatterApp ( ) . run ( ) </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from os import environ <EOL> from kivy . logger import Logger <EOL> from kivy . clock import Clock <EOL> class Cache ( object ) : <EOL> '''<STR_LIT>''' <EOL> _categories = { } <EOL> _objects = { } <EOL> @ staticmethod <EOL> def register ( category , limit = None , timeout = None ) : <EOL> '''<STR_LIT>''' <EOL> Cache . _categories [ category ] = { <EOL> '<STR_LIT>' : limit , <EOL> '<STR_LIT>' : timeout } <EOL> Cache . _objects [ category ] = { } <EOL> Logger . debug ( <EOL> '<STR_LIT>' % <EOL> ( category , str ( limit ) , str ( timeout ) ) ) <EOL> @ staticmethod <EOL> def append ( category , key , obj , timeout = None ) : <EOL> '''<STR_LIT>''' <EOL> if getattr ( obj , '<STR_LIT>' , False ) : <EOL> return <EOL> try : <EOL> cat = Cache . _categories [ category ] <EOL> except KeyError : <EOL> Logger . warning ( '<STR_LIT>' % category ) <EOL> return <EOL> timeout = timeout or cat [ '<STR_LIT>' ] <EOL> Cache . _objects [ category ] [ key ] = { <EOL> '<STR_LIT:object>' : obj , <EOL> '<STR_LIT>' : timeout , <EOL> '<STR_LIT>' : Clock . get_time ( ) , <EOL> '<STR_LIT>' : Clock . get_time ( ) } <EOL> @ staticmethod <EOL> def get ( category , key , default = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> Cache . _objects [ category ] [ key ] [ '<STR_LIT>' ] = Clock . get_time ( ) <EOL> return Cache . _objects [ category ] [ key ] [ '<STR_LIT:object>' ] <EOL> except Exception : <EOL> return default <EOL> @ staticmethod <EOL> def get_timestamp ( category , key , default = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> return Cache . _objects [ category ] [ key ] [ '<STR_LIT>' ] <EOL> except Exception : <EOL> return default <EOL> @ staticmethod <EOL> def get_lastaccess ( category , key , default = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> return Cache . _objects [ category ] [ key ] [ '<STR_LIT>' ] <EOL> except Exception : <EOL> return default <EOL> @ staticmethod <EOL> def remove ( category , key = None ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> if key is not None : <EOL> del Cache . _objects [ category ] [ key ] <EOL> else : <EOL> Cache . _objects [ category ] = { } <EOL> except Exception : <EOL> pass <EOL> @ staticmethod <EOL> def _purge_oldest ( category , maxpurge = <NUM_LIT:1> ) : <EOL> print ( '<STR_LIT>' , category ) <EOL> import heapq <EOL> heap_list = [ ] <EOL> for key in Cache . _objects [ category ] : <EOL> obj = Cache . _objects [ category ] [ key ] <EOL> if obj [ '<STR_LIT>' ] == obj [ '<STR_LIT>' ] : <EOL> continue <EOL> heapq . heappush ( heap_list , ( obj [ '<STR_LIT>' ] , key ) ) <EOL> print ( '<STR_LIT>' , obj [ '<STR_LIT>' ] ) <EOL> n = <NUM_LIT:0> <EOL> while n < maxpurge : <EOL> try : <EOL> lastaccess , key = heapq . heappop ( heap_list ) <EOL> print ( '<STR_LIT>' , key , lastaccess , Clock . get_time ( ) ) <EOL> except Exception : <EOL> return <EOL> del Cache . _objects [ category ] [ key ] <EOL> @ staticmethod <EOL> def _purge_by_timeout ( dt ) : <EOL> curtime = Clock . get_time ( ) <EOL> for category in Cache . _objects : <EOL> if category not in Cache . _categories : <EOL> continue <EOL> timeout = Cache . _categories [ category ] [ '<STR_LIT>' ] <EOL> if timeout is not None and dt > timeout : <EOL> timeout *= <NUM_LIT:2> <EOL> Cache . _categories [ category ] [ '<STR_LIT>' ] = timeout <EOL> continue <EOL> for key in list ( Cache . _objects [ category ] . keys ( ) ) [ : ] : <EOL> lastaccess = Cache . _objects [ category ] [ key ] [ '<STR_LIT>' ] <EOL> objtimeout = Cache . _objects [ category ] [ key ] [ '<STR_LIT>' ] <EOL> if objtimeout is not None : <EOL> timeout = objtimeout <EOL> if timeout is None : <EOL> continue <EOL> if curtime - lastaccess > timeout : <EOL> del Cache . _objects [ category ] [ key ] <EOL> @ staticmethod <EOL> def print_usage ( ) : <EOL> '''<STR_LIT>''' <EOL> print ( '<STR_LIT>' ) <EOL> for category in Cache . _categories : <EOL> print ( '<STR_LIT>' % ( <EOL> category . capitalize ( ) , <EOL> len ( Cache . _objects [ category ] ) , <EOL> str ( Cache . _categories [ category ] [ '<STR_LIT>' ] ) , <EOL> str ( Cache . _categories [ category ] [ '<STR_LIT>' ] ) ) ) <EOL> if '<STR_LIT>' not in environ : <EOL> Clock . schedule_interval ( Cache . _purge_by_timeout , <NUM_LIT:1> ) </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from kivy . utils import platform <EOL> from kivy . core . clipboard import ClipboardBase <EOL> if platform != '<STR_LIT>' : <EOL> raise SystemError ( '<STR_LIT>' ) <EOL> import ctypes <EOL> user32 = ctypes . windll . user32 <EOL> kernel32 = ctypes . windll . kernel32 <EOL> msvcrt = ctypes . cdll . msvcrt <EOL> c_char_p = ctypes . c_char_p <EOL> c_wchar_p = ctypes . c_wchar_p <EOL> class ClipboardWindows ( ClipboardBase ) : <EOL> def get ( self , mimetype = '<STR_LIT>' ) : <EOL> user32 . OpenClipboard ( <NUM_LIT:0> ) <EOL> pcontents = user32 . GetClipboardData ( <NUM_LIT> ) <EOL> if not pcontents : <EOL> return '<STR_LIT>' <EOL> data = c_wchar_p ( pcontents ) . value . encode ( self . _encoding ) <EOL> user32 . CloseClipboard ( ) <EOL> return data <EOL> def put ( self , text , mimetype = '<STR_LIT>' ) : <EOL> GMEM_DDESHARE = <NUM_LIT> <EOL> CF_UNICODETEXT = <NUM_LIT> <EOL> user32 . OpenClipboard ( None ) <EOL> user32 . EmptyClipboard ( ) <EOL> hCd = kernel32 . GlobalAlloc ( GMEM_DDESHARE , len ( text ) + <NUM_LIT:2> ) <EOL> pchData = kernel32 . GlobalLock ( hCd ) <EOL> msvcrt . wcscpy ( c_wchar_p ( pchData ) , text ) <EOL> kernel32 . GlobalUnlock ( hCd ) <EOL> user32 . SetClipboardData ( CF_UNICODETEXT , hCd ) <EOL> user32 . CloseClipboard ( ) <EOL> def get_types ( self ) : <EOL> return [ '<STR_LIT>' ] </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from time import time <EOL> from kivy . config import Config <EOL> from kivy . vector import Vector <EOL> class InputPostprocTripleTap ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : <EOL> dist = Config . getint ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . triple_tap_distance = dist / <NUM_LIT> <EOL> time = Config . getint ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . triple_tap_time = time / <NUM_LIT> <EOL> self . touches = { } <EOL> def find_triple_tap ( self , ref ) : <EOL> '''<STR_LIT>''' <EOL> ref_button = None <EOL> if '<STR_LIT>' in ref . profile : <EOL> ref_button = ref . button <EOL> for touchid in self . touches : <EOL> if ref . uid == touchid : <EOL> continue <EOL> etype , touch = self . touches [ touchid ] <EOL> if not touch . is_double_tap : <EOL> continue <EOL> if etype != '<STR_LIT:end>' : <EOL> continue <EOL> if touch . is_triple_tap : <EOL> continue <EOL> distance = Vector . distance ( <EOL> Vector ( ref . sx , ref . sy ) , <EOL> Vector ( touch . osx , touch . osy ) ) <EOL> if distance > self . triple_tap_distance : <EOL> continue <EOL> if touch . is_mouse_scrolling or ref . is_mouse_scrolling : <EOL> continue <EOL> touch_button = None <EOL> if '<STR_LIT>' in touch . profile : <EOL> touch_button = touch . button <EOL> if touch_button != ref_button : <EOL> continue <EOL> touch . triple_tap_distance = distance <EOL> return touch <EOL> return None <EOL> def process ( self , events ) : <EOL> if self . triple_tap_distance == <NUM_LIT:0> or self . triple_tap_time == <NUM_LIT:0> : <EOL> return events <EOL> for etype , touch in events : <EOL> if not touch . is_touch : <EOL> continue <EOL> if etype == '<STR_LIT>' : <EOL> triple_tap = self . find_triple_tap ( touch ) <EOL> if triple_tap : <EOL> touch . is_double_tap = False <EOL> touch . is_triple_tap = True <EOL> tap_time = touch . time_start - triple_tap . time_start <EOL> touch . triple_tap_time = tap_time <EOL> distance = triple_tap . triple_tap_distance <EOL> touch . triple_tap_distance = distance <EOL> self . touches [ touch . uid ] = ( etype , touch ) <EOL> time_current = time ( ) <EOL> to_delete = [ ] <EOL> for touchid in self . touches . keys ( ) : <EOL> etype , touch = self . touches [ touchid ] <EOL> if etype != '<STR_LIT:end>' : <EOL> continue <EOL> if time_current - touch . time_start < self . triple_tap_time : <EOL> continue <EOL> to_delete . append ( touchid ) <EOL> for touchid in to_delete : <EOL> del self . touches [ touchid ] <EOL> return events </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> from kivy import kivy_data_dir <EOL> from kivy . logger import Logger <EOL> from kivy . clock import Clock <EOL> from kivy . cache import Cache <EOL> from kivy . core . image import ImageLoader , Image <EOL> from kivy . compat import PY2 , string_types <EOL> from collections import deque <EOL> from time import sleep <EOL> from os . path import join <EOL> from os import write , close , unlink , environ <EOL> import threading <EOL> import mimetypes <EOL> Cache . register ( '<STR_LIT>' , limit = <NUM_LIT> , timeout = <NUM_LIT> ) <EOL> class ProxyImage ( Image ) : <EOL> '''<STR_LIT>''' <EOL> __events__ = ( '<STR_LIT>' , ) <EOL> def __init__ ( self , arg , ** kwargs ) : <EOL> loaded = kwargs . pop ( '<STR_LIT>' , False ) <EOL> super ( ProxyImage , self ) . __init__ ( arg , ** kwargs ) <EOL> self . loaded = loaded <EOL> def on_load ( self ) : <EOL> pass <EOL> class LoaderBase ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : <EOL> self . _loading_image = None <EOL> self . _error_image = None <EOL> self . _num_workers = <NUM_LIT:2> <EOL> self . _max_upload_per_frame = <NUM_LIT:2> <EOL> self . _paused = False <EOL> self . _resume_cond = threading . Condition ( ) <EOL> self . _q_load = deque ( ) <EOL> self . _q_done = deque ( ) <EOL> self . _client = [ ] <EOL> self . _running = False <EOL> self . _start_wanted = False <EOL> self . _trigger_update = Clock . create_trigger ( self . _update ) <EOL> def __del__ ( self ) : <EOL> try : <EOL> Clock . unschedule ( self . _update ) <EOL> except Exception : <EOL> pass <EOL> def _set_num_workers ( self , num ) : <EOL> if num < <NUM_LIT:2> : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . _num_workers = num <EOL> def _get_num_workers ( self ) : <EOL> return self . _num_workers <EOL> num_workers = property ( _get_num_workers , _set_num_workers ) <EOL> '''<STR_LIT>''' <EOL> def _set_max_upload_per_frame ( self , num ) : <EOL> if num is not None and num < <NUM_LIT:1> : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . _max_upload_per_frame = num <EOL> def _get_max_upload_per_frame ( self ) : <EOL> return self . _max_upload_per_frame <EOL> max_upload_per_frame = property ( _get_max_upload_per_frame , <EOL> _set_max_upload_per_frame ) <EOL> '''<STR_LIT>''' <EOL> def _get_loading_image ( self ) : <EOL> if not self . _loading_image : <EOL> loading_png_fn = join ( kivy_data_dir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _loading_image = ImageLoader . load ( filename = loading_png_fn ) <EOL> return self . _loading_image <EOL> def _set_loading_image ( self , image ) : <EOL> if isinstance ( image , string_types ) : <EOL> self . _loading_image = ImageLoader . load ( filename = image ) <EOL> else : <EOL> self . _loading_image = image <EOL> loading_image = property ( _get_loading_image , _set_loading_image ) <EOL> '''<STR_LIT>''' <EOL> def _get_error_image ( self ) : <EOL> if not self . _error_image : <EOL> error_png_fn = join ( <EOL> '<STR_LIT>' ) <EOL> self . _error_image = ImageLoader . load ( filename = error_png_fn ) <EOL> return self . _error_image <EOL> def _set_error_image ( self , image ) : <EOL> if isinstance ( image , string_types ) : <EOL> self . _error_image = ImageLoader . load ( filename = image ) <EOL> else : <EOL> self . _error_image = image <EOL> error_image = property ( _get_error_image , _set_error_image ) <EOL> '''<STR_LIT>''' <EOL> def start ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . _running = True <EOL> def run ( self , * largs ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def stop ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . _running = False <EOL> def pause ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . _paused = True <EOL> def resume ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . _paused = False <EOL> self . _resume_cond . acquire ( ) <EOL> self . _resume_cond . notify_all ( ) <EOL> self . _resume_cond . release ( ) <EOL> def _wait_for_resume ( self ) : <EOL> while self . _running and self . _paused : <EOL> self . _resume_cond . acquire ( ) <EOL> self . _resume_cond . wait ( <NUM_LIT> ) <EOL> self . _resume_cond . release ( ) <EOL> def _load ( self , kwargs ) : <EOL> '''<STR_LIT>''' <EOL> while len ( self . _q_done ) >= ( <EOL> self . max_upload_per_frame * self . _num_workers ) : <EOL> sleep ( <NUM_LIT:0.1> ) <EOL> self . _wait_for_resume ( ) <EOL> filename = kwargs [ '<STR_LIT:filename>' ] <EOL> load_callback = kwargs [ '<STR_LIT>' ] <EOL> post_callback = kwargs [ '<STR_LIT>' ] <EOL> try : <EOL> proto = filename . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> except : <EOL> return <EOL> if load_callback is not None : <EOL> data = load_callback ( filename ) <EOL> elif proto in ( '<STR_LIT:http>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> data = self . _load_urllib ( filename , kwargs [ '<STR_LIT>' ] ) <EOL> else : <EOL> data = self . _load_local ( filename , kwargs [ '<STR_LIT>' ] ) <EOL> if post_callback : <EOL> data = post_callback ( data ) <EOL> self . _q_done . appendleft ( ( filename , data ) ) <EOL> self . _trigger_update ( ) <EOL> def _load_local ( self , filename , kwargs ) : <EOL> '''<STR_LIT>''' <EOL> return ImageLoader . load ( filename , keep_data = True , ** kwargs ) <EOL> def _load_urllib ( self , filename , kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if PY2 : <EOL> import urllib2 as urllib_request <EOL> def gettype ( info ) : <EOL> return info . gettype ( ) <EOL> else : <EOL> import urllib . request as urllib_request <EOL> def gettype ( info ) : <EOL> return info . get_content_type ( ) <EOL> proto = filename . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> if proto == '<STR_LIT>' : <EOL> try : <EOL> from smb . SMBHandler import SMBHandler <EOL> except ImportError : <EOL> Logger . warning ( <EOL> '<STR_LIT>' ) <EOL> return <EOL> import tempfile <EOL> data = fd = _out_osfd = None <EOL> try : <EOL> _out_filename = '<STR_LIT>' <EOL> if proto == '<STR_LIT>' : <EOL> fd = urllib_request . build_opener ( SMBHandler ) . open ( filename ) <EOL> else : <EOL> fd = urllib_request . urlopen ( filename ) <EOL> if '<STR_LIT>' in filename : <EOL> suffix = '<STR_LIT:.>' + filename . split ( '<STR_LIT>' ) [ - <NUM_LIT:1> ] <EOL> else : <EOL> ctype = gettype ( fd . info ( ) ) <EOL> suffix = mimetypes . guess_extension ( ctype ) <EOL> if not suffix : <EOL> parts = filename . split ( '<STR_LIT:?>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> : ] <EOL> while len ( parts ) > <NUM_LIT:1> and not parts [ <NUM_LIT:0> ] : <EOL> parts = parts [ <NUM_LIT:1> : ] <EOL> if len ( parts ) > <NUM_LIT:1> and '<STR_LIT:.>' in parts [ - <NUM_LIT:1> ] : <EOL> suffix = '<STR_LIT:.>' + parts [ - <NUM_LIT:1> ] . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] <EOL> _out_osfd , _out_filename = tempfile . mkstemp ( <EOL> prefix = '<STR_LIT>' , suffix = suffix ) <EOL> idata = fd . read ( ) <EOL> fd . close ( ) <EOL> fd = None <EOL> write ( _out_osfd , idata ) <EOL> close ( _out_osfd ) <EOL> _out_osfd = None <EOL> data = self . _load_local ( _out_filename , kwargs ) <EOL> for imdata in data . _data : <EOL> imdata . source = filename <EOL> except Exception : <EOL> Logger . exception ( '<STR_LIT>' % filename ) <EOL> try : <EOL> close ( _out_osfd ) <EOL> except OSError : <EOL> pass <EOL> return self . error_image <EOL> finally : <EOL> if fd : <EOL> fd . close ( ) <EOL> if _out_osfd : <EOL> close ( _out_osfd ) <EOL> if _out_filename != '<STR_LIT>' : <EOL> unlink ( _out_filename ) <EOL> return data <EOL> def _update ( self , * largs ) : <EOL> '''<STR_LIT>''' <EOL> if self . _start_wanted : <EOL> if not self . _running : <EOL> self . start ( ) <EOL> self . _start_wanted = False <EOL> if self . _paused : <EOL> self . _trigger_update ( ) <EOL> return <EOL> for x in range ( self . max_upload_per_frame ) : <EOL> try : <EOL> filename , data = self . _q_done . pop ( ) <EOL> except IndexError : <EOL> return <EOL> image = data <EOL> if not image . nocache : <EOL> Cache . append ( '<STR_LIT>' , filename , image ) <EOL> for c_filename , client in self . _client [ : ] : <EOL> if filename != c_filename : <EOL> continue <EOL> client . image = image <EOL> client . loaded = True <EOL> client . dispatch ( '<STR_LIT>' ) <EOL> self . _client . remove ( ( c_filename , client ) ) <EOL> self . _trigger_update ( ) <EOL> def image ( self , filename , load_callback = None , post_callback = None , <EOL> ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> data = Cache . get ( '<STR_LIT>' , filename ) <EOL> if data not in ( None , False ) : <EOL> return ProxyImage ( data , <EOL> loading_image = self . loading_image , <EOL> loaded = True , ** kwargs ) <EOL> client = ProxyImage ( self . loading_image , <EOL> loading_image = self . loading_image , ** kwargs ) <EOL> self . _client . append ( ( filename , client ) ) <EOL> if data is None : <EOL> self . _q_load . appendleft ( { <EOL> '<STR_LIT:filename>' : filename , <EOL> '<STR_LIT>' : load_callback , <EOL> '<STR_LIT>' : post_callback , <EOL> '<STR_LIT>' : kwargs } ) <EOL> if not kwargs . get ( '<STR_LIT>' , False ) : <EOL> Cache . append ( '<STR_LIT>' , filename , False ) <EOL> self . _start_wanted = True <EOL> self . _trigger_update ( ) <EOL> else : <EOL> pass <EOL> return client <EOL> if '<STR_LIT>' in environ : <EOL> Loader = None <EOL> else : <EOL> from kivy . compat import queue <EOL> from threading import Thread <EOL> class _Worker ( Thread ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , pool , tasks ) : <EOL> Thread . __init__ ( self ) <EOL> self . tasks = tasks <EOL> self . daemon = True <EOL> self . pool = pool <EOL> self . start ( ) <EOL> def run ( self ) : <EOL> while self . pool . running : <EOL> func , args , kargs = self . tasks . get ( ) <EOL> try : <EOL> func ( * args , ** kargs ) <EOL> except Exception as e : <EOL> print ( e ) <EOL> self . tasks . task_done ( ) <EOL> class _ThreadPool ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , num_threads ) : <EOL> super ( _ThreadPool , self ) . __init__ ( ) <EOL> self . running = True <EOL> self . tasks = queue . Queue ( ) <EOL> for _ in range ( num_threads ) : <EOL> _Worker ( self , self . tasks ) <EOL> def add_task ( self , func , * args , ** kargs ) : <EOL> '''<STR_LIT>''' <EOL> self . tasks . put ( ( func , args , kargs ) ) <EOL> def stop ( self ) : <EOL> self . running = False <EOL> self . tasks . join ( ) <EOL> class LoaderThreadPool ( LoaderBase ) : <EOL> def __init__ ( self ) : <EOL> super ( LoaderThreadPool , self ) . __init__ ( ) <EOL> self . pool = None <EOL> def start ( self ) : <EOL> super ( LoaderThreadPool , self ) . start ( ) <EOL> self . pool = _ThreadPool ( self . _num_workers ) <EOL> Clock . schedule_interval ( self . run , <NUM_LIT:0> ) <EOL> def stop ( self ) : <EOL> super ( LoaderThreadPool , self ) . stop ( ) <EOL> Clock . unschedule ( self . run ) <EOL> self . pool . stop ( ) <EOL> def run ( self , * largs ) : <EOL> while self . _running : <EOL> try : <EOL> parameters = self . _q_load . pop ( ) <EOL> except : <EOL> return <EOL> self . pool . add_task ( self . _load , parameters ) <EOL> Loader = LoaderThreadPool ( ) <EOL> Logger . info ( '<STR_LIT>' . format ( <EOL> Loader . num_workers ) ) </s>
<s> '''<STR_LIT>''' <EOL> import unittest <EOL> import os <EOL> SAMPLE_FILE = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> SAMPLE_LENGTH = <NUM_LIT> <EOL> DELTA = SAMPLE_LENGTH * <NUM_LIT> <EOL> DELAY = <NUM_LIT> <EOL> class AudioTestCase ( unittest . TestCase ) : <EOL> def get_sound ( self ) : <EOL> import os <EOL> assert os . path . exists ( SAMPLE_FILE ) <EOL> from kivy . core import audio <EOL> return audio . SoundLoader . load ( SAMPLE_FILE ) <EOL> def test_length_simple ( self ) : <EOL> sound = self . get_sound ( ) <EOL> volume = sound . volume = <NUM_LIT> <EOL> length = sound . length <EOL> self . assertAlmostEqual ( SAMPLE_LENGTH , length , delta = DELTA ) <EOL> assert volume == sound . volume <EOL> def test_length_playing ( self ) : <EOL> import time <EOL> sound = self . get_sound ( ) <EOL> sound . play ( ) <EOL> try : <EOL> time . sleep ( DELAY ) <EOL> length = sound . length <EOL> self . assertAlmostEqual ( SAMPLE_LENGTH , length , delta = DELTA ) <EOL> finally : <EOL> sound . stop ( ) <EOL> self . assertAlmostEqual ( SAMPLE_LENGTH , length , delta = DELTA ) <EOL> def test_length_stopped ( self ) : <EOL> import time <EOL> sound = self . get_sound ( ) <EOL> sound . play ( ) <EOL> try : <EOL> time . sleep ( DELAY ) <EOL> finally : <EOL> sound . stop ( ) <EOL> length = sound . length <EOL> self . assertAlmostEqual ( SAMPLE_LENGTH , length , delta = DELTA ) <EOL> class AudioGstreamerTestCase ( AudioTestCase ) : <EOL> def make_sound ( self , source ) : <EOL> from kivy . core . audio import audio_gstreamer <EOL> return audio_gstreamer . SoundGstreamer ( source ) <EOL> class AudioPygameTestCase ( AudioTestCase ) : <EOL> def make_sound ( self , source ) : <EOL> from kivy . core . audio import audio_pygame <EOL> return audio_pygame . SoundPygame ( source ) </s>
<s> '''<STR_LIT>''' <EOL> import unittest <EOL> from kivy . uix . textinput import TextInput <EOL> class TextInputTest ( unittest . TestCase ) : <EOL> def test_focusable_when_disabled ( self ) : <EOL> ti = TextInput ( ) <EOL> ti . disabled = True <EOL> ti . focused = True <EOL> ti . bind ( focus = self . on_focused ) <EOL> def on_focused ( self , instance , value ) : <EOL> self . assertTrue ( instance . focused , value ) </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from kivy . uix . layout import Layout <EOL> from kivy . properties import OptionProperty , VariableListProperty <EOL> class AnchorLayout ( Layout ) : <EOL> '''<STR_LIT>''' <EOL> padding = VariableListProperty ( [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> '''<STR_LIT>''' <EOL> anchor_x = OptionProperty ( '<STR_LIT>' , options = ( <EOL> '<STR_LIT:left>' , '<STR_LIT>' , '<STR_LIT:right>' ) ) <EOL> '''<STR_LIT>''' <EOL> anchor_y = OptionProperty ( '<STR_LIT>' , options = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( AnchorLayout , self ) . __init__ ( ** kwargs ) <EOL> fbind = self . fbind <EOL> update = self . _trigger_layout <EOL> fbind ( '<STR_LIT>' , update ) <EOL> fbind ( '<STR_LIT>' , update ) <EOL> fbind ( '<STR_LIT>' , update ) <EOL> fbind ( '<STR_LIT>' , update ) <EOL> fbind ( '<STR_LIT>' , update ) <EOL> fbind ( '<STR_LIT:size>' , update ) <EOL> fbind ( '<STR_LIT>' , update ) <EOL> def do_layout ( self , * largs ) : <EOL> _x , _y = self . pos <EOL> width = self . width <EOL> height = self . height <EOL> anchor_x = self . anchor_x <EOL> anchor_y = self . anchor_y <EOL> padding = self . padding <EOL> for c in self . children : <EOL> x , y = _x , _y <EOL> w , h = c . size <EOL> if c . size_hint [ <NUM_LIT:0> ] is not None : <EOL> w = c . size_hint [ <NUM_LIT:0> ] * width - ( padding [ <NUM_LIT:0> ] + padding [ <NUM_LIT:2> ] ) <EOL> if c . size_hint [ <NUM_LIT:1> ] is not None : <EOL> h = c . size_hint [ <NUM_LIT:1> ] * height - ( padding [ <NUM_LIT:1> ] + padding [ <NUM_LIT:3> ] ) <EOL> if anchor_x == '<STR_LIT:left>' : <EOL> x = x + padding [ <NUM_LIT:0> ] <EOL> if anchor_x == '<STR_LIT:right>' : <EOL> x = x + width - ( w + padding [ <NUM_LIT:2> ] ) <EOL> if self . anchor_x == '<STR_LIT>' : <EOL> x = x + ( width / <NUM_LIT:2> ) - ( w / <NUM_LIT:2> ) <EOL> if anchor_y == '<STR_LIT>' : <EOL> y = y + padding [ <NUM_LIT:1> ] <EOL> if anchor_y == '<STR_LIT>' : <EOL> y = y + height - ( h + padding [ <NUM_LIT:3> ] ) <EOL> if anchor_y == '<STR_LIT>' : <EOL> y = y + ( height / <NUM_LIT:2> ) - ( h / <NUM_LIT:2> ) <EOL> c . x = x <EOL> c . y = y <EOL> c . width = w <EOL> c . height = h </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> from kivy . event import EventDispatcher <EOL> from kivy . clock import Clock <EOL> from kivy . compat import PY2 <EOL> from kivy . uix . widget import Widget <EOL> from kivy . uix . button import Button <EOL> from kivy . uix . label import Label <EOL> from kivy . uix . boxlayout import BoxLayout <EOL> from kivy . adapters . simplelistadapter import SimpleListAdapter <EOL> from kivy . uix . abstractview import AbstractView <EOL> from kivy . uix . selectableview import SelectableView <EOL> from kivy . properties import ObjectProperty , DictProperty , NumericProperty , ListProperty , BooleanProperty <EOL> from kivy . lang import Builder <EOL> from math import ceil , floor <EOL> class ListItemReprMixin ( Label ) : <EOL> '''<STR_LIT>''' <EOL> if PY2 : <EOL> def __repr__ ( self ) : <EOL> text = self . text . encode ( '<STR_LIT:utf-8>' ) if isinstance ( self . text , unicode ) else self . text <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , text ) <EOL> else : <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , self . text ) <EOL> class ListItemButton ( ListItemReprMixin , SelectableView , Button ) : <EOL> '''<STR_LIT>''' <EOL> selected_color = ListProperty ( [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> deselected_color = ListProperty ( [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( ListItemButton , self ) . __init__ ( ** kwargs ) <EOL> self . background_color = self . deselected_color <EOL> def select ( self , * args ) : <EOL> self . background_color = self . selected_color <EOL> if isinstance ( self . parent , CompositeListItem ) : <EOL> self . parent . select_from_child ( self , * args ) <EOL> def deselect ( self , * args ) : <EOL> self . background_color = self . deselected_color <EOL> if isinstance ( self . parent , CompositeListItem ) : <EOL> self . parent . deselect_from_child ( self , * args ) <EOL> def select_from_composite ( self , * args ) : <EOL> self . background_color = self . selected_color <EOL> def deselect_from_composite ( self , * args ) : <EOL> self . background_color = self . deselected_color <EOL> class ListItemLabel ( ListItemReprMixin , SelectableView , Label ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( ListItemLabel , self ) . __init__ ( ** kwargs ) <EOL> def select ( self , * args ) : <EOL> self . bold = True <EOL> if isinstance ( self . parent , CompositeListItem ) : <EOL> self . parent . select_from_child ( self , * args ) <EOL> def deselect ( self , * args ) : <EOL> self . bold = False <EOL> if isinstance ( self . parent , CompositeListItem ) : <EOL> self . parent . deselect_from_child ( self , * args ) <EOL> def select_from_composite ( self , * args ) : <EOL> self . bold = True <EOL> def deselect_from_composite ( self , * args ) : <EOL> self . bold = False <EOL> class CompositeListItem ( SelectableView , BoxLayout ) : <EOL> '''<STR_LIT>''' <EOL> background_color = ListProperty ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> selected_color = ListProperty ( [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> deselected_color = ListProperty ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> representing_cls = ObjectProperty ( None ) <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , ** kwargs ) : <EOL> cls_dicts = kwargs . pop ( '<STR_LIT>' ) <EOL> text = kwargs . pop ( '<STR_LIT:text>' , None ) <EOL> index = kwargs [ '<STR_LIT:index>' ] <EOL> super ( CompositeListItem , self ) . __init__ ( ** kwargs ) <EOL> for cls_dict in cls_dicts : <EOL> cls = cls_dict [ '<STR_LIT>' ] <EOL> cls_kwargs = cls_dict . get ( '<STR_LIT>' , None ) <EOL> if cls_kwargs : <EOL> cls_kwargs [ '<STR_LIT:index>' ] = index <EOL> if '<STR_LIT:text>' not in cls_kwargs and text : <EOL> cls_kwargs [ '<STR_LIT:text>' ] = text <EOL> if '<STR_LIT>' in cls_kwargs : <EOL> del cls_kwargs [ '<STR_LIT>' ] <EOL> self . representing_cls = cls <EOL> self . add_widget ( cls ( ** cls_kwargs ) ) <EOL> else : <EOL> cls_kwargs = { } <EOL> cls_kwargs [ '<STR_LIT:index>' ] = index <EOL> if text is not None : <EOL> cls_kwargs [ '<STR_LIT:text>' ] = text <EOL> self . add_widget ( cls ( ** cls_kwargs ) ) <EOL> def select ( self , * args ) : <EOL> self . background_color = self . selected_color <EOL> def deselect ( self , * args ) : <EOL> self . background_color = self . deselected_color <EOL> def select_from_child ( self , child , * args ) : <EOL> for c in self . children : <EOL> if c is not child : <EOL> c . select_from_composite ( * args ) <EOL> def deselect_from_child ( self , child , * args ) : <EOL> for c in self . children : <EOL> if c is not child : <EOL> c . deselect_from_composite ( * args ) <EOL> def __repr__ ( self ) : <EOL> if self . representing_cls is not None : <EOL> return '<STR_LIT>' % ( <EOL> self . representing_cls , self . __class__ . __name__ ) <EOL> else : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ ) <EOL> Builder . load_string ( '''<STR_LIT>''' ) <EOL> class ListView ( AbstractView , EventDispatcher ) : <EOL> '''<STR_LIT>''' <EOL> divider = ObjectProperty ( None ) <EOL> '''<STR_LIT>''' <EOL> divider_height = NumericProperty ( <NUM_LIT:2> ) <EOL> '''<STR_LIT>''' <EOL> container = ObjectProperty ( None ) <EOL> '''<STR_LIT>''' <EOL> row_height = NumericProperty ( None ) <EOL> '''<STR_LIT>''' <EOL> item_strings = ListProperty ( [ ] ) <EOL> '''<STR_LIT>''' <EOL> scrolling = BooleanProperty ( False ) <EOL> '''<STR_LIT>''' <EOL> _index = NumericProperty ( <NUM_LIT:0> ) <EOL> _sizes = DictProperty ( { } ) <EOL> _count = NumericProperty ( <NUM_LIT:0> ) <EOL> _wstart = NumericProperty ( <NUM_LIT:0> ) <EOL> _wend = NumericProperty ( - <NUM_LIT:1> ) <EOL> __events__ = ( '<STR_LIT>' , ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> if '<STR_LIT>' not in kwargs : <EOL> if '<STR_LIT>' not in kwargs : <EOL> list_adapter = SimpleListAdapter ( data = [ ] , <EOL> cls = Label ) <EOL> else : <EOL> list_adapter = SimpleListAdapter ( data = kwargs [ '<STR_LIT>' ] , <EOL> cls = Label ) <EOL> kwargs [ '<STR_LIT>' ] = list_adapter <EOL> super ( ListView , self ) . __init__ ( ** kwargs ) <EOL> populate = self . _trigger_populate = Clock . create_trigger ( <EOL> self . _spopulate , - <NUM_LIT:1> ) <EOL> self . _trigger_reset_populate = Clock . create_trigger ( self . _reset_spopulate , - <NUM_LIT:1> ) <EOL> fbind = self . fbind <EOL> fbind ( '<STR_LIT:size>' , populate ) <EOL> fbind ( '<STR_LIT>' , populate ) <EOL> fbind ( '<STR_LIT>' , self . item_strings_changed ) <EOL> fbind ( '<STR_LIT>' , populate ) <EOL> bind_adapter = self . _trigger_bind_adapter = Clock . create_trigger ( <EOL> lambda dt : self . adapter . bind_triggers_to_view ( <EOL> self . _trigger_reset_populate ) , <EOL> - <NUM_LIT:1> ) <EOL> fbind ( '<STR_LIT>' , bind_adapter ) <EOL> bind_adapter ( ) <EOL> def item_strings_changed ( self , * args ) : <EOL> self . adapter . data = self . item_strings <EOL> def _scroll ( self , scroll_y ) : <EOL> if self . row_height is None : <EOL> return <EOL> self . _scroll_y = scroll_y <EOL> scroll_y = <NUM_LIT:1> - min ( <NUM_LIT:1> , max ( scroll_y , <NUM_LIT:0> ) ) <EOL> container = self . container <EOL> mstart = ( container . height - self . height ) * scroll_y <EOL> mend = mstart + self . height <EOL> rh = self . row_height <EOL> istart = int ( ceil ( mstart / rh ) ) <EOL> iend = int ( floor ( mend / rh ) ) <EOL> istart = max ( <NUM_LIT:0> , istart - <NUM_LIT:1> ) <EOL> iend = max ( <NUM_LIT:0> , iend - <NUM_LIT:1> ) <EOL> if istart < self . _wstart : <EOL> rstart = max ( <NUM_LIT:0> , istart - <NUM_LIT:10> ) <EOL> self . populate ( rstart , iend ) <EOL> self . _wstart = rstart <EOL> self . _wend = iend <EOL> elif iend > self . _wend : <EOL> self . populate ( istart , iend + <NUM_LIT:10> ) <EOL> self . _wstart = istart <EOL> self . _wend = iend + <NUM_LIT:10> <EOL> def _spopulate ( self , * args ) : <EOL> self . populate ( ) <EOL> def _reset_spopulate ( self , * args ) : <EOL> self . _wend = - <NUM_LIT:1> <EOL> self . populate ( ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> self . _scroll ( self . _scroll_y ) <EOL> def populate ( self , istart = None , iend = None ) : <EOL> container = self . container <EOL> sizes = self . _sizes <EOL> rh = self . row_height <EOL> if istart is None : <EOL> istart = self . _wstart <EOL> iend = self . _wend <EOL> container . clear_widgets ( ) <EOL> if iend is not None and iend != - <NUM_LIT:1> : <EOL> fh = <NUM_LIT:0> <EOL> for x in range ( istart ) : <EOL> fh += sizes [ x ] if x in sizes else rh <EOL> container . add_widget ( Widget ( size_hint_y = None , height = fh ) ) <EOL> index = istart <EOL> while index <= iend : <EOL> item_view = self . adapter . get_view ( index ) <EOL> index += <NUM_LIT:1> <EOL> if item_view is None : <EOL> continue <EOL> sizes [ index ] = item_view . height <EOL> container . add_widget ( item_view ) <EOL> else : <EOL> available_height = self . height <EOL> real_height = <NUM_LIT:0> <EOL> index = self . _index <EOL> count = <NUM_LIT:0> <EOL> while available_height > <NUM_LIT:0> : <EOL> item_view = self . adapter . get_view ( index ) <EOL> if item_view is None : <EOL> break <EOL> sizes [ index ] = item_view . height <EOL> index += <NUM_LIT:1> <EOL> count += <NUM_LIT:1> <EOL> container . add_widget ( item_view ) <EOL> available_height -= item_view . height <EOL> real_height += item_view . height <EOL> self . _count = count <EOL> if count : <EOL> container . height = real_height / count * self . adapter . get_count ( ) <EOL> if self . row_height is None : <EOL> self . row_height = real_height / count <EOL> def scroll_to ( self , index = <NUM_LIT:0> ) : <EOL> if not self . scrolling : <EOL> self . scrolling = True <EOL> self . _index = index <EOL> self . populate ( ) <EOL> self . dispatch ( '<STR_LIT>' ) <EOL> def on_scroll_complete ( self , * args ) : <EOL> self . scrolling = False </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from kivy . uix . button import Button <EOL> from kivy . uix . behaviors import ToggleButtonBehavior <EOL> class ToggleButton ( ToggleButtonBehavior , Button ) : <EOL> '''<STR_LIT>''' <EOL> pass </s>
<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> from plyer . facades . accelerometer import Accelerometer <EOL> from plyer . facades . audio import Audio <EOL> from plyer . facades . battery import Battery <EOL> from plyer . facades . call import Call <EOL> from plyer . facades . camera import Camera <EOL> from plyer . facades . compass import Compass <EOL> from plyer . facades . email import Email <EOL> from plyer . facades . filechooser import FileChooser <EOL> from plyer . facades . gps import GPS <EOL> from plyer . facades . gyroscope import Gyroscope <EOL> from plyer . facades . irblaster import IrBlaster <EOL> from plyer . facades . orientation import Orientation <EOL> from plyer . facades . notification import Notification <EOL> from plyer . facades . sms import Sms <EOL> from plyer . facades . tts import TTS <EOL> from plyer . facades . uniqueid import UniqueID <EOL> from plyer . facades . vibrator import Vibrator <EOL> from plyer . facades . flash import Flash </s>
<s> '''<STR_LIT>''' <EOL> from plyer . facades import GPS <EOL> from plyer . platforms . android import activity <EOL> from jnius import autoclass , java_method , PythonJavaClass <EOL> Looper = autoclass ( '<STR_LIT>' ) <EOL> LocationManager = autoclass ( '<STR_LIT>' ) <EOL> Context = autoclass ( '<STR_LIT>' ) <EOL> class _LocationListener ( PythonJavaClass ) : <EOL> __javainterfaces__ = [ '<STR_LIT>' ] <EOL> def __init__ ( self , root ) : <EOL> self . root = root <EOL> super ( _LocationListener , self ) . __init__ ( ) <EOL> @ java_method ( '<STR_LIT>' ) <EOL> def onLocationChanged ( self , location ) : <EOL> self . root . on_location ( <EOL> lat = location . getLatitude ( ) , <EOL> lon = location . getLongitude ( ) , <EOL> speed = location . getSpeed ( ) , <EOL> bearing = location . getBearing ( ) , <EOL> altitude = location . getAltitude ( ) , <EOL> accuracy = location . getAccuracy ( ) ) <EOL> @ java_method ( '<STR_LIT>' ) <EOL> def onProviderEnabled ( self , status ) : <EOL> if self . root . on_status : <EOL> self . root . on_status ( '<STR_LIT>' , status ) <EOL> @ java_method ( '<STR_LIT>' ) <EOL> def onProviderDisabled ( self , status ) : <EOL> if self . root . on_status : <EOL> self . root . on_status ( '<STR_LIT>' , status ) <EOL> @ java_method ( '<STR_LIT>' ) <EOL> def onStatusChanged ( self , provider , status , extras ) : <EOL> if self . root . on_status : <EOL> s_status = '<STR_LIT>' <EOL> if status == <NUM_LIT> : <EOL> s_status = '<STR_LIT>' <EOL> elif status == <NUM_LIT> : <EOL> s_status = '<STR_LIT>' <EOL> elif status == <NUM_LIT> : <EOL> s_status = '<STR_LIT>' <EOL> self . root . on_status ( '<STR_LIT>' , '<STR_LIT>' . format ( <EOL> provider , s_status ) ) <EOL> class AndroidGPS ( GPS ) : <EOL> def _configure ( self ) : <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _location_manager = activity . getSystemService ( <EOL> Context . LOCATION_SERVICE ) <EOL> self . _location_listener = _LocationListener ( self ) <EOL> def _start ( self ) : <EOL> providers = self . _location_manager . getProviders ( False ) . toArray ( ) <EOL> for provider in providers : <EOL> self . _location_manager . requestLocationUpdates ( <EOL> provider , <EOL> <NUM_LIT:1000> , <EOL> <NUM_LIT:1> , <EOL> self . _location_listener , <EOL> Looper . getMainLooper ( ) ) <EOL> def _stop ( self ) : <EOL> self . _location_manager . removeUpdates ( self . _location_listener ) <EOL> def instance ( ) : <EOL> return AndroidGPS ( ) </s>
<s> from subprocess import Popen , PIPE <EOL> from plyer . facades import Battery <EOL> from plyer . utils import whereis_exe <EOL> from os import environ <EOL> class OSXBattery ( Battery ) : <EOL> def _get_state ( self ) : <EOL> old_lang = environ . get ( '<STR_LIT>' ) <EOL> environ [ '<STR_LIT>' ] = '<STR_LIT:C>' <EOL> status = { "<STR_LIT>" : None , "<STR_LIT>" : None } <EOL> ioreg_process = Popen ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> stdout = PIPE ) <EOL> output = ioreg_process . communicate ( ) [ <NUM_LIT:0> ] <EOL> environ [ '<STR_LIT>' ] = old_lang <EOL> if not output : <EOL> return status <EOL> IsCharging = MaxCapacity = CurrentCapacity = None <EOL> for l in output . splitlines ( ) : <EOL> if '<STR_LIT>' in l : <EOL> IsCharging = l . rpartition ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . strip ( ) <EOL> if '<STR_LIT>' in l : <EOL> MaxCapacity = float ( l . rpartition ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . strip ( ) ) <EOL> if '<STR_LIT>' in l : <EOL> CurrentCapacity = float ( l . rpartition ( '<STR_LIT:=>' ) [ - <NUM_LIT:1> ] . strip ( ) ) <EOL> if ( IsCharging ) : <EOL> status [ '<STR_LIT>' ] = IsCharging == "<STR_LIT>" <EOL> if ( CurrentCapacity and MaxCapacity ) : <EOL> status [ '<STR_LIT>' ] = <NUM_LIT> * CurrentCapacity / MaxCapacity <EOL> return status <EOL> def instance ( ) : <EOL> import sys <EOL> if whereis_exe ( '<STR_LIT>' ) : <EOL> return OSXBattery ( ) <EOL> sys . stderr . write ( "<STR_LIT>" ) <EOL> return Battery ( ) </s>
<s> from __future__ import print_function <EOL> from __future__ import division <EOL> from __future__ import absolute_import <EOL> import unittest <EOL> from jnius import JavaException , JavaClass <EOL> from jnius . reflect import autoclass <EOL> class BadDeclarationTest ( unittest . TestCase ) : <EOL> def test_class_not_found ( self ) : <EOL> pass <EOL> def test_invalid_attribute ( self ) : <EOL> Stack = autoclass ( '<STR_LIT>' ) <EOL> self . assertRaises ( AttributeError , getattr , Stack , '<STR_LIT>' ) <EOL> def test_invalid_static_call ( self ) : <EOL> Stack = autoclass ( '<STR_LIT>' ) <EOL> self . assertRaises ( JavaException , Stack . push , '<STR_LIT:hello>' ) <EOL> def test_with_too_much_arguments ( self ) : <EOL> Stack = autoclass ( '<STR_LIT>' ) <EOL> stack = Stack ( ) <EOL> self . assertRaises ( JavaException , stack . push , '<STR_LIT:hello>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> def test_java_exception_handling ( self ) : <EOL> Stack = autoclass ( '<STR_LIT>' ) <EOL> stack = Stack ( ) <EOL> try : <EOL> stack . pop ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except JavaException as je : <EOL> self . assertEquals ( "<STR_LIT>" , je . classname ) <EOL> def test_java_exception_chaining ( self ) : <EOL> BasicsTest = autoclass ( '<STR_LIT>' ) <EOL> basics = BasicsTest ( ) <EOL> try : <EOL> basics . methodExceptionChained ( ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except JavaException as je : <EOL> self . assertEquals ( "<STR_LIT>" , je . classname ) <EOL> self . assertEquals ( "<STR_LIT>" , je . innermessage ) <EOL> self . assertIn ( "<STR_LIT>" , je . stacktrace ) <EOL> self . assertEquals ( <NUM_LIT:11> , len ( je . stacktrace ) ) </s>
<s> from os . path import dirname , join , isfile , realpath , relpath , split <EOL> from zipfile import ZipFile <EOL> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> from fnmatch import fnmatch <EOL> import tarfile <EOL> import os <EOL> import shutil <EOL> import subprocess <EOL> import time <EOL> import jinja2 <EOL> if os . name == '<STR_LIT>' : <EOL> ANDROID = '<STR_LIT>' <EOL> ANT = '<STR_LIT>' <EOL> else : <EOL> ANDROID = '<STR_LIT>' <EOL> ANT = '<STR_LIT>' <EOL> ANDROIDSDK = os . environ . get ( '<STR_LIT>' ) <EOL> if ANDROIDSDK : <EOL> ANDROID = os . path . join ( ANDROIDSDK , '<STR_LIT>' , ANDROID ) <EOL> curdir = dirname ( __file__ ) <EOL> PYTHON = join ( curdir , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> BLACKLIST_PATTERNS = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> WHITELIST_PATTERNS = [ ] <EOL> python_files = [ ] <EOL> environment = jinja2 . Environment ( loader = jinja2 . FileSystemLoader ( <EOL> join ( curdir , '<STR_LIT>' ) ) ) <EOL> def render ( template , dest , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> template = environment . get_template ( template ) <EOL> text = template . render ( ** kwargs ) <EOL> f = open ( dest , '<STR_LIT:wb>' ) <EOL> f . write ( text . encode ( '<STR_LIT:utf-8>' ) ) <EOL> f . close ( ) <EOL> def compile_dir ( dfn ) : <EOL> '''<STR_LIT>''' <EOL> subprocess . call ( [ PYTHON , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , dfn ] ) <EOL> def is_whitelist ( name ) : <EOL> return match_filename ( WHITELIST_PATTERNS , name ) <EOL> def is_blacklist ( name ) : <EOL> if is_whitelist ( name ) : <EOL> return False <EOL> return match_filename ( BLACKLIST_PATTERNS , name ) <EOL> def match_filename ( pattern_list , name ) : <EOL> for pattern in pattern_list : <EOL> if pattern . startswith ( '<STR_LIT>' ) : <EOL> pattern = pattern [ <NUM_LIT:1> : ] <EOL> else : <EOL> pattern = '<STR_LIT>' + pattern <EOL> if fnmatch ( name , pattern ) : <EOL> return True <EOL> def listfiles ( d ) : <EOL> basedir = d <EOL> subdirlist = [ ] <EOL> for item in os . listdir ( d ) : <EOL> fn = join ( d , item ) <EOL> if isfile ( fn ) : <EOL> yield fn <EOL> else : <EOL> subdirlist . append ( os . path . join ( basedir , item ) ) <EOL> for subdir in subdirlist : <EOL> for fn in listfiles ( subdir ) : <EOL> yield fn <EOL> def make_pythonzip ( ) : <EOL> '''<STR_LIT>''' <EOL> global python_files <EOL> d = realpath ( join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def select ( fn ) : <EOL> if is_blacklist ( fn ) : <EOL> return False <EOL> fn = realpath ( fn ) <EOL> assert ( fn . startswith ( d ) ) <EOL> fn = fn [ len ( d ) : ] <EOL> if ( fn . startswith ( '<STR_LIT>' ) or <EOL> fn . startswith ( '<STR_LIT>' ) or <EOL> fn . startswith ( '<STR_LIT>' ) or <EOL> fn . startswith ( '<STR_LIT>' ) ) : <EOL> return False <EOL> return fn <EOL> python_files = [ x for x in listfiles ( d ) if select ( x ) ] <EOL> zfn = join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> zf = ZipFile ( zfn , '<STR_LIT:w>' ) <EOL> for fn in python_files : <EOL> afn = fn [ len ( d ) : ] <EOL> zf . write ( fn , afn ) <EOL> zf . close ( ) <EOL> def make_tar ( tfn , source_dirs , ignore_path = [ ] ) : <EOL> '''<STR_LIT>''' <EOL> def select ( fn ) : <EOL> rfn = realpath ( fn ) <EOL> for p in ignore_path : <EOL> if p . endswith ( '<STR_LIT:/>' ) : <EOL> p = p [ : - <NUM_LIT:1> ] <EOL> if rfn . startswith ( p ) : <EOL> return False <EOL> if rfn in python_files : <EOL> return False <EOL> return not is_blacklist ( fn ) <EOL> files = [ ] <EOL> for sd in source_dirs : <EOL> sd = realpath ( sd ) <EOL> compile_dir ( sd ) <EOL> files += [ ( x , relpath ( realpath ( x ) , sd ) ) for x in listfiles ( sd ) <EOL> if select ( x ) ] <EOL> tf = tarfile . open ( tfn , '<STR_LIT>' , format = tarfile . USTAR_FORMAT ) <EOL> dirs = [ ] <EOL> for fn , afn in files : <EOL> dn = dirname ( afn ) <EOL> if dn not in dirs : <EOL> d = '<STR_LIT>' <EOL> for component in split ( dn ) : <EOL> d = join ( d , component ) <EOL> if d . startswith ( '<STR_LIT:/>' ) : <EOL> d = d [ <NUM_LIT:1> : ] <EOL> if d == '<STR_LIT>' or d in dirs : <EOL> continue <EOL> dirs . append ( d ) <EOL> tinfo = tarfile . TarInfo ( d ) <EOL> tinfo . type = tarfile . DIRTYPE <EOL> tf . addfile ( tinfo ) <EOL> tf . add ( fn , afn ) <EOL> tf . close ( ) <EOL> def make_package ( args ) : <EOL> version_code = <NUM_LIT:0> <EOL> manifest_extra = [ '<STR_LIT>' ] <EOL> for filename in args . manifest_extra : <EOL> with open ( filename , "<STR_LIT:r>" ) as fd : <EOL> content = fd . read ( ) <EOL> manifest_extra . append ( content ) <EOL> manifest_extra = '<STR_LIT:\n>' . join ( manifest_extra ) <EOL> url_scheme = '<STR_LIT>' <EOL> default_icon = '<STR_LIT>' <EOL> default_presplash = '<STR_LIT>' <EOL> default_ouya_icon = '<STR_LIT>' <EOL> if not args . numeric_version : <EOL> for i in args . version . split ( '<STR_LIT:.>' ) : <EOL> version_code *= <NUM_LIT:100> <EOL> version_code += int ( i ) <EOL> args . numeric_version = str ( version_code ) <EOL> versioned_name = ( args . name . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) + <EOL> '<STR_LIT:->' + args . version ) <EOL> build_tpl = '<STR_LIT>' <EOL> if not args . icon_name : <EOL> args . icon_name = args . name <EOL> args . name = args . name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> args . icon_name = args . icon_name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> private_version = str ( time . time ( ) ) <EOL> if args . dir : <EOL> public_version = private_version <EOL> else : <EOL> public_version = None <EOL> if args . intent_filters : <EOL> intent_filters = open ( args . intent_filters ) . read ( ) <EOL> else : <EOL> intent_filters = '<STR_LIT>' <EOL> service = False <EOL> directory = args . dir if public_version else args . private <EOL> if directory : <EOL> service_main = join ( realpath ( directory ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> if os . path . exists ( service_main ) or os . path . exists ( service_main + '<STR_LIT:o>' ) : <EOL> service = True <EOL> if args . ouya_category : <EOL> args . ouya_category = args . ouya_category . upper ( ) <EOL> if args . ouya_category not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> render ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> args = args , <EOL> service = service , <EOL> url_scheme = url_scheme , <EOL> intent_filters = intent_filters , <EOL> manifest_extra = manifest_extra , <EOL> ) <EOL> render ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> args = args ) <EOL> render ( <EOL> build_tpl , <EOL> '<STR_LIT>' , <EOL> args = args , <EOL> versioned_name = versioned_name ) <EOL> render ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> public_version = public_version , <EOL> private_version = private_version , <EOL> url_scheme = url_scheme , <EOL> args = args ) <EOL> try : <EOL> subprocess . call ( [ ANDROID , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:.>' , '<STR_LIT>' , <EOL> '<STR_LIT>' . format ( args . sdk_version ) ] ) <EOL> except ( OSError , IOError ) : <EOL> print ( '<STR_LIT>' , ANDROID , '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> if os . path . exists ( '<STR_LIT>' ) : <EOL> os . unlink ( '<STR_LIT>' ) <EOL> if os . path . exists ( '<STR_LIT>' ) : <EOL> os . unlink ( '<STR_LIT>' ) <EOL> make_pythonzip ( ) <EOL> if args . private : <EOL> make_tar ( '<STR_LIT>' , [ '<STR_LIT>' , args . private ] , args . ignore_path ) <EOL> else : <EOL> make_tar ( '<STR_LIT>' , [ '<STR_LIT>' ] ) <EOL> if args . dir : <EOL> make_tar ( '<STR_LIT>' , [ args . dir ] , args . ignore_path ) <EOL> shutil . copy ( args . icon or default_icon , '<STR_LIT>' ) <EOL> shutil . copy ( args . presplash or default_presplash , <EOL> '<STR_LIT>' ) <EOL> if args . ouya_category : <EOL> if not os . path . isdir ( '<STR_LIT>' ) : <EOL> os . mkdir ( '<STR_LIT>' ) <EOL> shutil . copy ( args . ouya_icon or default_ouya_icon , <EOL> '<STR_LIT>' ) <EOL> if args . add_jar : <EOL> for jarname in args . add_jar : <EOL> if not os . path . exists ( jarname ) : <EOL> print ( '<STR_LIT>' . format ( jarname ) ) <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> shutil . copy ( jarname , '<STR_LIT>' ) <EOL> try : <EOL> for arg in args . command : <EOL> subprocess . check_call ( [ ANT , arg ] ) <EOL> except ( OSError , IOError ) : <EOL> print ( '<STR_LIT>' , ANT ) <EOL> print ( '<STR_LIT>' ) <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> def parse_args ( args = None ) : <EOL> import argparse <EOL> android_api = os . environ . get ( '<STR_LIT>' , <NUM_LIT:8> ) <EOL> ap = argparse . ArgumentParser ( description = '''<STR_LIT>''' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> required = True ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:name>' , <EOL> help = ( '<STR_LIT>' ) , <EOL> required = True ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT:version>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> required = True ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = join ( curdir , '<STR_LIT>' ) , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = join ( curdir , '<STR_LIT>' ) , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , default = android_api , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , default = android_api , <EOL> type = int , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , nargs = '<STR_LIT:*>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> ap . add_argument ( '<STR_LIT>' , dest = '<STR_LIT>' , action = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> if args is None : <EOL> args = sys . argv [ <NUM_LIT:1> : ] <EOL> args = ap . parse_args ( args ) <EOL> if not args . dir and not args . private and not args . launcher : <EOL> ap . error ( '<STR_LIT>' ) <EOL> if args . permissions is None : <EOL> args . permissions = [ ] <EOL> if args . ignore_path is None : <EOL> args . ignore_path = [ ] <EOL> if args . meta_data is None : <EOL> args . meta_data = [ ] <EOL> if args . resource is None : <EOL> args . resource = [ ] <EOL> if args . manifest_extra is None : <EOL> args . manifest_extra = [ ] <EOL> if args . compile_pyo : <EOL> if PYTHON is None : <EOL> ap . error ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> global BLACKLIST_PATTERNS <EOL> BLACKLIST_PATTERNS += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if args . blacklist : <EOL> with open ( args . blacklist ) as fd : <EOL> patterns = [ x . strip ( ) for x in fd . read ( ) . splitlines ( ) if x . strip ( ) <EOL> and not x . startswith ( '<STR_LIT:#>' ) ] <EOL> BLACKLIST_PATTERNS += patterns <EOL> if args . whitelist : <EOL> with open ( args . whitelist ) as fd : <EOL> patterns = [ x . strip ( ) for x in fd . read ( ) . splitlines ( ) if x . strip ( ) <EOL> and not x . startswith ( '<STR_LIT:#>' ) ] <EOL> global WHITELIST_PATTERNS <EOL> WHITELIST_PATTERNS += patterns <EOL> make_package ( args ) <EOL> return args <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> parse_args ( ) </s>
<s> from pythonforandroid . toolchain import PythonRecipe <EOL> class Enum34Recipe ( PythonRecipe ) : <EOL> version = '<STR_LIT>' <EOL> url = '<STR_LIT>' <EOL> depends = [ '<STR_LIT>' ] <EOL> site_packages_name = '<STR_LIT>' <EOL> recipe = Enum34Recipe ( ) </s>
<s> from pythonforandroid . recipe import PythonRecipe <EOL> class PycparserRecipe ( PythonRecipe ) : <EOL> name = '<STR_LIT>' <EOL> version = '<STR_LIT>' <EOL> url = '<STR_LIT>' <EOL> depends = [ ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ] <EOL> call_hostpython_via_targetpython = False <EOL> install_in_hostpython = True <EOL> recipe = PycparserRecipe ( ) </s>
<s> from pythonforandroid . toolchain import Recipe , current_directory <EOL> from pythonforandroid . logger import info , debug , shprint , warning <EOL> from os . path import exists , join <EOL> from os import environ <EOL> import sh <EOL> from colorama import Fore , Style <EOL> class VlcRecipe ( Recipe ) : <EOL> version = '<STR_LIT>' <EOL> url = None <EOL> name = '<STR_LIT>' <EOL> depends = [ ] <EOL> port_git = '<STR_LIT>' <EOL> vlc_git = '<STR_LIT>' <EOL> ENV_LIBVLC_AAR = '<STR_LIT>' <EOL> aars = { } <EOL> def prebuild_arch ( self , arch ) : <EOL> super ( VlcRecipe , self ) . prebuild_arch ( arch ) <EOL> build_dir = self . get_build_dir ( arch . arch ) <EOL> port_dir = join ( build_dir , '<STR_LIT>' ) <EOL> if self . ENV_LIBVLC_AAR in environ : <EOL> self . aars [ arch ] = aar = environ . get ( self . ENV_LIBVLC_AAR ) <EOL> if not exists ( aar ) : <EOL> warning ( "<STR_LIT>" "<STR_LIT>" . format ( aar ) ) <EOL> info ( "<STR_LIT>" . format ( self . ENV_LIBVLC_AAR ) ) <EOL> exit ( <NUM_LIT:1> ) <EOL> else : <EOL> aar_path = join ( port_dir , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . aars [ arch ] = aar = join ( aar_path , '<STR_LIT>' . format ( self . version ) ) <EOL> warning ( "<STR_LIT>" "<STR_LIT>" . format ( self . ENV_LIBVLC_AAR ) ) <EOL> info ( "<STR_LIT>" "<STR_LIT>" . format ( port_dir ) ) <EOL> if not exists ( join ( port_dir , '<STR_LIT>' ) ) : <EOL> info ( "<STR_LIT>" . format ( <EOL> self . port_git ) ) <EOL> shprint ( sh . git , '<STR_LIT>' , self . port_git , port_dir , <EOL> _tail = <NUM_LIT:20> , _critical = True ) <EOL> vlc_dir = join ( port_dir , '<STR_LIT>' ) <EOL> if not exists ( join ( vlc_dir , '<STR_LIT>' ) ) : <EOL> info ( "<STR_LIT>" . format ( self . vlc_git ) ) <EOL> shprint ( sh . git , '<STR_LIT>' , self . vlc_git , vlc_dir , <EOL> _tail = <NUM_LIT:20> , _critical = True ) <EOL> def build_arch ( self , arch ) : <EOL> super ( VlcRecipe , self ) . build_arch ( arch ) <EOL> build_dir = self . get_build_dir ( arch . arch ) <EOL> port_dir = join ( build_dir , '<STR_LIT>' ) <EOL> aar = self . aars [ arch ] <EOL> if not exists ( aar ) : <EOL> with current_directory ( port_dir ) : <EOL> env = dict ( environ ) <EOL> env . update ( { <EOL> '<STR_LIT>' : arch . arch , <EOL> '<STR_LIT>' : self . ctx . ndk_dir , <EOL> '<STR_LIT>' : self . ctx . sdk_dir , <EOL> } ) <EOL> info ( "<STR_LIT>" ) <EOL> debug ( "<STR_LIT>" . format ( env ) ) <EOL> if not exists ( join ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> shprint ( sh . Command ( '<STR_LIT>' ) , _env = env , <EOL> _tail = <NUM_LIT:50> , _critical = True ) <EOL> shprint ( sh . Command ( '<STR_LIT>' ) , _env = env , <EOL> _tail = <NUM_LIT:50> , _critical = True ) <EOL> shprint ( sh . cp , '<STR_LIT>' , aar , self . ctx . aars_dir ) <EOL> recipe = VlcRecipe ( ) </s>
<s> import sys <EOL> if sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:0> ) : <EOL> import testcase <EOL> else : <EOL> from . import testcase <EOL> class TestLevelChars ( testcase . TestCase ) : <EOL> title = "<STR_LIT>" <EOL> def test_level_chars ( self ) : <EOL> self . set_text ( self . _test_text1 ( ) ) <EOL> self . set_settings ( { '<STR_LIT>' : '<STR_LIT:#>' } ) <EOL> self . run_plugin ( ) <EOL> self . find ( '<STR_LIT>' ) <EOL> self . set_text ( self . _test_text2 ( ) ) <EOL> self . set_settings ( { '<STR_LIT>' : '<STR_LIT:->' } ) <EOL> self . run_plugin ( ) <EOL> self . find ( '<STR_LIT>' ) <EOL> self . set_text ( self . _test_text3 ( ) ) <EOL> self . set_settings ( { '<STR_LIT>' : '<STR_LIT::>' } ) <EOL> self . run_plugin ( ) <EOL> self . find ( '<STR_LIT>' ) <EOL> def _test_text1 ( self ) : <EOL> return """<STR_LIT>""" <EOL> def _test_text2 ( self ) : <EOL> return """<STR_LIT>""" <EOL> def _test_text3 ( self ) : <EOL> return """<STR_LIT>""" </s>
<s> from Crypto . Random import random <EOL> import os , sys , argparse <EOL> from clint import textui <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , type = int , action = "<STR_LIT:store>" , required = True ) <EOL> parser . add_argument ( '<STR_LIT>' , type = int , nargs = <NUM_LIT:1> , required = True ) <EOL> parser . add_argument ( '<STR_LIT>' , action = "<STR_LIT:store>" , required = True ) <EOL> args = parser . parse_args ( ) <EOL> if os . path . exists ( args . characterset ) : <EOL> args . characterset = open ( args . characterset , "<STR_LIT:r>" ) . read ( ) . strip ( ) <EOL> sys . stderr . write ( "<STR_LIT>" . format ( pow ( len ( args . characterset ) , args . keylen ) ) ) <EOL> keylen = args . keylen <EOL> for i in textui . progress . bar ( xrange ( args . numkeys [ <NUM_LIT:0> ] ) ) : <EOL> key = '<STR_LIT>' . join ( random . sample ( args . characterset , keylen ) ) <EOL> key = '<STR_LIT:->' . join ( [ key [ i : i + <NUM_LIT:4> ] for i in xrange ( <NUM_LIT:0> , keylen , <NUM_LIT:4> ) ] ) <EOL> print key </s>
<s> """<STR_LIT>""" <EOL> import re , time <EOL> from cookielib import ( _warn_unhandled_exception , FileCookieJar , LoadError , <EOL> Cookie , MISSING_FILENAME_TEXT ) <EOL> class MozillaCookieJar ( FileCookieJar ) : <EOL> """<STR_LIT>""" <EOL> magic_re = "<STR_LIT>" <EOL> header = """<STR_LIT>""" <EOL> def _really_load ( self , f , filename , ignore_discard , ignore_expires ) : <EOL> now = time . time ( ) <EOL> magic = f . readline ( ) <EOL> if not re . search ( self . magic_re , magic ) : <EOL> f . close ( ) <EOL> raise LoadError ( <EOL> "<STR_LIT>" % <EOL> filename ) <EOL> try : <EOL> while <NUM_LIT:1> : <EOL> line = f . readline ( ) <EOL> if line == "<STR_LIT>" : break <EOL> if line . endswith ( "<STR_LIT:\n>" ) : line = line [ : - <NUM_LIT:1> ] <EOL> if ( line . strip ( ) . startswith ( ( "<STR_LIT:#>" , "<STR_LIT:$>" ) ) or <EOL> line . strip ( ) == "<STR_LIT>" ) : <EOL> continue <EOL> domain , domain_specified , path , secure , expires , name , value = line . split ( "<STR_LIT:\t>" ) <EOL> secure = ( secure == "<STR_LIT>" ) <EOL> domain_specified = ( domain_specified == "<STR_LIT>" ) <EOL> if name == "<STR_LIT>" : <EOL> name = value <EOL> value = None <EOL> initial_dot = domain . startswith ( "<STR_LIT:.>" ) <EOL> assert domain_specified == initial_dot <EOL> discard = False <EOL> if expires == "<STR_LIT>" : <EOL> expires = None <EOL> discard = True <EOL> c = Cookie ( <NUM_LIT:0> , name , value , <EOL> None , False , <EOL> domain , domain_specified , initial_dot , <EOL> path , False , <EOL> secure , <EOL> expires , <EOL> discard , <EOL> None , <EOL> None , <EOL> { } ) <EOL> if not ignore_discard and c . discard : <EOL> continue <EOL> if not ignore_expires and c . is_expired ( now ) : <EOL> continue <EOL> self . set_cookie ( c ) <EOL> except IOError : <EOL> raise <EOL> except Exception : <EOL> _warn_unhandled_exception ( ) <EOL> raise LoadError ( "<STR_LIT>" % <EOL> ( filename , line ) ) <EOL> def save ( self , filename = None , ignore_discard = False , ignore_expires = False ) : <EOL> if filename is None : <EOL> if self . filename is not None : filename = self . filename <EOL> else : raise ValueError ( MISSING_FILENAME_TEXT ) <EOL> f = open ( filename , "<STR_LIT:w>" ) <EOL> try : <EOL> f . write ( self . header ) <EOL> now = time . time ( ) <EOL> for cookie in self : <EOL> if not ignore_discard and cookie . discard : <EOL> continue <EOL> if not ignore_expires and cookie . is_expired ( now ) : <EOL> continue <EOL> if cookie . secure : secure = "<STR_LIT>" <EOL> else : secure = "<STR_LIT>" <EOL> if cookie . domain . startswith ( "<STR_LIT:.>" ) : initial_dot = "<STR_LIT>" <EOL> else : initial_dot = "<STR_LIT>" <EOL> if cookie . expires is not None : <EOL> expires = str ( cookie . expires ) <EOL> else : <EOL> expires = "<STR_LIT>" <EOL> if cookie . value is None : <EOL> name = "<STR_LIT>" <EOL> value = cookie . name <EOL> else : <EOL> name = cookie . name <EOL> value = cookie . value <EOL> f . write ( <EOL> "<STR_LIT:\t>" . join ( [ cookie . domain , initial_dot , cookie . path , <EOL> secure , expires , name , value ] ) + <EOL> "<STR_LIT:\n>" ) <EOL> finally : <EOL> f . close ( ) </s>
<s> from time import sleep as _sleep <EOL> import sys <EOL> absolute_import = ( sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> ) <EOL> if absolute_import : <EOL> exec ( "<STR_LIT>" ) <EOL> else : <EOL> import db <EOL> _deadlock_MinSleepTime = <NUM_LIT:1.0> / <NUM_LIT> <EOL> _deadlock_MaxSleepTime = <NUM_LIT> <EOL> _deadlock_VerboseFile = None <EOL> def DeadlockWrap ( function , * _args , ** _kwargs ) : <EOL> """<STR_LIT>""" <EOL> sleeptime = _deadlock_MinSleepTime <EOL> max_retries = _kwargs . get ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> if '<STR_LIT>' in _kwargs : <EOL> del _kwargs [ '<STR_LIT>' ] <EOL> while True : <EOL> try : <EOL> return function ( * _args , ** _kwargs ) <EOL> except db . DBLockDeadlockError : <EOL> if _deadlock_VerboseFile : <EOL> _deadlock_VerboseFile . write ( <EOL> '<STR_LIT>' % sleeptime ) <EOL> _sleep ( sleeptime ) <EOL> sleeptime *= <NUM_LIT:2> <EOL> if sleeptime > _deadlock_MaxSleepTime : <EOL> sleeptime = _deadlock_MaxSleepTime <EOL> max_retries -= <NUM_LIT:1> <EOL> if max_retries == - <NUM_LIT:1> : <EOL> raise </s>
<s> """<STR_LIT>""" <EOL> from types import ClassType as _ClassType <EOL> __all__ = [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> dispatch_table = { } <EOL> def pickle ( ob_type , pickle_function , constructor_ob = None ) : <EOL> if type ( ob_type ) is _ClassType : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> if not hasattr ( pickle_function , '<STR_LIT>' ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> dispatch_table [ ob_type ] = pickle_function <EOL> if constructor_ob is not None : <EOL> constructor ( constructor_ob ) <EOL> def constructor ( object ) : <EOL> if not hasattr ( object , '<STR_LIT>' ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> try : <EOL> complex <EOL> except NameError : <EOL> pass <EOL> else : <EOL> def pickle_complex ( c ) : <EOL> return complex , ( c . real , c . imag ) <EOL> pickle ( complex , pickle_complex , complex ) <EOL> def _reconstructor ( cls , base , state ) : <EOL> if base is object : <EOL> obj = object . __new__ ( cls ) <EOL> else : <EOL> obj = base . __new__ ( cls , state ) <EOL> if base . __init__ != object . __init__ : <EOL> base . __init__ ( obj , state ) <EOL> return obj <EOL> _HEAPTYPE = <NUM_LIT:1> << <NUM_LIT:9> <EOL> def _reduce_ex ( self , proto ) : <EOL> assert proto < <NUM_LIT:2> <EOL> for base in self . __class__ . __mro__ : <EOL> if hasattr ( base , '<STR_LIT>' ) and not base . __flags__ & _HEAPTYPE : <EOL> break <EOL> else : <EOL> base = object <EOL> if base is object : <EOL> state = None <EOL> else : <EOL> if base is self . __class__ : <EOL> raise TypeError , "<STR_LIT>" % base . __name__ <EOL> state = base ( self ) <EOL> args = ( self . __class__ , base , state ) <EOL> try : <EOL> getstate = self . __getstate__ <EOL> except AttributeError : <EOL> if getattr ( self , "<STR_LIT>" , None ) : <EOL> raise TypeError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> try : <EOL> dict = self . __dict__ <EOL> except AttributeError : <EOL> dict = None <EOL> else : <EOL> dict = getstate ( ) <EOL> if dict : <EOL> return _reconstructor , args , dict <EOL> else : <EOL> return _reconstructor , args <EOL> def __newobj__ ( cls , * args ) : <EOL> return cls . __new__ ( cls , * args ) <EOL> def _slotnames ( cls ) : <EOL> """<STR_LIT>""" <EOL> names = cls . __dict__ . get ( "<STR_LIT>" ) <EOL> if names is not None : <EOL> return names <EOL> names = [ ] <EOL> if not hasattr ( cls , "<STR_LIT>" ) : <EOL> pass <EOL> else : <EOL> for c in cls . __mro__ : <EOL> if "<STR_LIT>" in c . __dict__ : <EOL> slots = c . __dict__ [ '<STR_LIT>' ] <EOL> if isinstance ( slots , basestring ) : <EOL> slots = ( slots , ) <EOL> for name in slots : <EOL> if name in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> continue <EOL> elif name . startswith ( '<STR_LIT>' ) and not name . endswith ( '<STR_LIT>' ) : <EOL> names . append ( '<STR_LIT>' % ( c . __name__ , name ) ) <EOL> else : <EOL> names . append ( name ) <EOL> try : <EOL> cls . __slotnames__ = names <EOL> except : <EOL> pass <EOL> return names <EOL> _extension_registry = { } <EOL> _inverted_registry = { } <EOL> _extension_cache = { } <EOL> def add_extension ( module , name , code ) : <EOL> """<STR_LIT>""" <EOL> code = int ( code ) <EOL> if not <NUM_LIT:1> <= code <= <NUM_LIT> : <EOL> raise ValueError , "<STR_LIT>" <EOL> key = ( module , name ) <EOL> if ( _extension_registry . get ( key ) == code and <EOL> _inverted_registry . get ( code ) == key ) : <EOL> return <EOL> if key in _extension_registry : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> ( key , _extension_registry [ key ] ) ) <EOL> if code in _inverted_registry : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> ( code , _inverted_registry [ code ] ) ) <EOL> _extension_registry [ key ] = code <EOL> _inverted_registry [ code ] = key <EOL> def remove_extension ( module , name , code ) : <EOL> """<STR_LIT>""" <EOL> key = ( module , name ) <EOL> if ( _extension_registry . get ( key ) != code or <EOL> _inverted_registry . get ( code ) != key ) : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> ( key , code ) ) <EOL> del _extension_registry [ key ] <EOL> del _inverted_registry [ code ] <EOL> if code in _extension_cache : <EOL> del _extension_cache [ code ] <EOL> def clear_extension_cache ( ) : <EOL> _extension_cache . clear ( ) </s>
<s> """<STR_LIT>""" <EOL> from sys import modules as sys_modules <EOL> import dummy_thread <EOL> holding_thread = False <EOL> holding_threading = False <EOL> holding__threading_local = False <EOL> try : <EOL> if '<STR_LIT>' in sys_modules : <EOL> held_thread = sys_modules [ '<STR_LIT>' ] <EOL> holding_thread = True <EOL> sys_modules [ '<STR_LIT>' ] = sys_modules [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in sys_modules : <EOL> held_threading = sys_modules [ '<STR_LIT>' ] <EOL> holding_threading = True <EOL> del sys_modules [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in sys_modules : <EOL> held__threading_local = sys_modules [ '<STR_LIT>' ] <EOL> holding__threading_local = True <EOL> del sys_modules [ '<STR_LIT>' ] <EOL> import threading <EOL> sys_modules [ '<STR_LIT>' ] = sys_modules [ '<STR_LIT>' ] <EOL> del sys_modules [ '<STR_LIT>' ] <EOL> sys_modules [ '<STR_LIT>' ] = sys_modules [ '<STR_LIT>' ] <EOL> del sys_modules [ '<STR_LIT>' ] <EOL> from _dummy_threading import * <EOL> from _dummy_threading import __all__ <EOL> finally : <EOL> if holding_threading : <EOL> sys_modules [ '<STR_LIT>' ] = held_threading <EOL> del held_threading <EOL> del holding_threading <EOL> if holding__threading_local : <EOL> sys_modules [ '<STR_LIT>' ] = held__threading_local <EOL> del held__threading_local <EOL> del holding__threading_local <EOL> if holding_thread : <EOL> sys_modules [ '<STR_LIT>' ] = held_thread <EOL> del held_thread <EOL> else : <EOL> del sys_modules [ '<STR_LIT>' ] <EOL> del holding_thread <EOL> del dummy_thread <EOL> del sys_modules </s>
<s> """<STR_LIT>""" <EOL> import codecs , base64 <EOL> def base64_encode ( input , errors = '<STR_LIT:strict>' ) : <EOL> """<STR_LIT>""" <EOL> assert errors == '<STR_LIT:strict>' <EOL> output = base64 . encodestring ( input ) <EOL> return ( output , len ( input ) ) <EOL> def base64_decode ( input , errors = '<STR_LIT:strict>' ) : <EOL> """<STR_LIT>""" <EOL> assert errors == '<STR_LIT:strict>' <EOL> output = base64 . decodestring ( input ) <EOL> return ( output , len ( input ) ) <EOL> class Codec ( codecs . Codec ) : <EOL> def encode ( self , input , errors = '<STR_LIT:strict>' ) : <EOL> return base64_encode ( input , errors ) <EOL> def decode ( self , input , errors = '<STR_LIT:strict>' ) : <EOL> return base64_decode ( input , errors ) <EOL> class IncrementalEncoder ( codecs . IncrementalEncoder ) : <EOL> def encode ( self , input , final = False ) : <EOL> assert self . errors == '<STR_LIT:strict>' <EOL> return base64 . encodestring ( input ) <EOL> class IncrementalDecoder ( codecs . IncrementalDecoder ) : <EOL> def decode ( self , input , final = False ) : <EOL> assert self . errors == '<STR_LIT:strict>' <EOL> return base64 . decodestring ( input ) <EOL> class StreamWriter ( Codec , codecs . StreamWriter ) : <EOL> pass <EOL> class StreamReader ( Codec , codecs . StreamReader ) : <EOL> pass <EOL> def getregentry ( ) : <EOL> return codecs . CodecInfo ( <EOL> name = '<STR_LIT>' , <EOL> encode = base64_encode , <EOL> decode = base64_decode , <EOL> incrementalencoder = IncrementalEncoder , <EOL> incrementaldecoder = IncrementalDecoder , <EOL> streamwriter = StreamWriter , <EOL> streamreader = StreamReader , <EOL> ) </s>
<s> import _codecs_iso2022 , codecs <EOL> import _multibytecodec as mbc <EOL> codec = _codecs_iso2022 . getcodec ( '<STR_LIT>' ) <EOL> class Codec ( codecs . Codec ) : <EOL> encode = codec . encode <EOL> decode = codec . decode <EOL> class IncrementalEncoder ( mbc . MultibyteIncrementalEncoder , <EOL> codecs . IncrementalEncoder ) : <EOL> codec = codec <EOL> class IncrementalDecoder ( mbc . MultibyteIncrementalDecoder , <EOL> codecs . IncrementalDecoder ) : <EOL> codec = codec <EOL> class StreamReader ( Codec , mbc . MultibyteStreamReader , codecs . StreamReader ) : <EOL> codec = codec <EOL> class StreamWriter ( Codec , mbc . MultibyteStreamWriter , codecs . StreamWriter ) : <EOL> codec = codec <EOL> def getregentry ( ) : <EOL> return codecs . CodecInfo ( <EOL> name = '<STR_LIT>' , <EOL> encode = Codec ( ) . encode , <EOL> decode = Codec ( ) . decode , <EOL> incrementalencoder = IncrementalEncoder , <EOL> incrementaldecoder = IncrementalDecoder , <EOL> streamreader = StreamReader , <EOL> streamwriter = StreamWriter , <EOL> ) </s>
<s> """<STR_LIT>""" <EOL> import codecs <EOL> encode = codecs . utf_32_be_encode <EOL> def decode ( input , errors = '<STR_LIT:strict>' ) : <EOL> return codecs . utf_32_be_decode ( input , errors , True ) <EOL> class IncrementalEncoder ( codecs . IncrementalEncoder ) : <EOL> def encode ( self , input , final = False ) : <EOL> return codecs . utf_32_be_encode ( input , self . errors ) [ <NUM_LIT:0> ] <EOL> class IncrementalDecoder ( codecs . BufferedIncrementalDecoder ) : <EOL> _buffer_decode = codecs . utf_32_be_decode <EOL> class StreamWriter ( codecs . StreamWriter ) : <EOL> encode = codecs . utf_32_be_encode <EOL> class StreamReader ( codecs . StreamReader ) : <EOL> decode = codecs . utf_32_be_decode <EOL> def getregentry ( ) : <EOL> return codecs . CodecInfo ( <EOL> name = '<STR_LIT>' , <EOL> encode = encode , <EOL> decode = decode , <EOL> incrementalencoder = IncrementalEncoder , <EOL> incrementaldecoder = IncrementalDecoder , <EOL> streamreader = StreamReader , <EOL> streamwriter = StreamWriter , <EOL> ) </s>
<s> """<STR_LIT>""" <EOL> name2codepoint = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT:image>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT:int>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> codepoint2name = { } <EOL> entitydefs = { } <EOL> for ( name , codepoint ) in name2codepoint . iteritems ( ) : <EOL> codepoint2name [ codepoint ] = name <EOL> if codepoint <= <NUM_LIT> : <EOL> entitydefs [ name ] = chr ( codepoint ) <EOL> else : <EOL> entitydefs [ name ] = '<STR_LIT>' % codepoint <EOL> del name , codepoint </s>