我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用builtins.Exception()。
def getCaemlDict_Recursive(self) -> dict: aCaemlDict = dict([(x, copy.deepcopy(y)) for x, y in self.__dict__.items() if ( not x.startswith('_') and not x.startswith('parent')) or x.startswith('_id')]) if 'caemlType' in aCaemlDict: raise Exception('caemlType is reserved and cannot be used in a caeml serializable obj') else: aCaemlDict['caemlType'] = [t.__module__ + '.' + t.__name__ for t in type(self).mro()] for k, v in aCaemlDict.items(): if type(v) in [dict]: for k2, v2 in v.items(): if isinstance(v2, caemlBaseObj): aCaemlDict[k][k2] = v2.getCaemlDict_Recursive() if type(v) in [list]: for i, v2 in enumerate(v): if isinstance(v2, caemlBaseObj): aCaemlDict[k][i] = v2.getCaemlDict_Recursive() elif isinstance(v, caemlBaseObj): aCaemlDict[k] = v.getCaemlDict_Recursive() else: pass # keep entry return aCaemlDict
def constructCaemlObj_fromCaemlDict(aDict: dict) -> caemlBaseObj: """Constructs a object of caeml.base from a dict if caeml knows how to contruct, else aDict is returned.""" if not 'caemlType' in aDict: raise ValueError('aDict must include a CAEMl type') aClassName = aDict.pop('caemlType') if not type(aClassName) is list: aClassName = [aClassName] logging.getLogger('system').debug('Building object of type' + aClassName[0]) aClass = locate(aClassName[0]) # TODO manager autocomplete, TODO: manager if (not aClass): raise Exception('No ctor found for ' + aClassName[0]) try: if 'name' in aDict: aObject = aClass(**aDict) # TODO: maybe validate parent<-> child relationships here: else: aObject = aClass(**aDict) return aObject except Exception as e: raise Exception('Ctor of {} raised {}'.format(aClassName[0], str(e)))
def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except __builtin__.Exception: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def __init__(self, resource_filename, model_str): this = _snowboydetect.new_SnowboyDetect(resource_filename, model_str) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, nelements: 'size_t'): this = _YASHE.new_intArray(nelements) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _YASHE.new_ciphertext(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _YASHE.new_secret_key(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _YASHE.new_public_key(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): this = _YASHE.new_key_gen() try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _YASHE.new_pari_GEN(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): this = _YASHE.new_parameters() try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): this = _YASHE.new_key_pair() try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, name: 'std::string const &', problem_type: 'operations_research::MPSolver::OptimizationProblemType'): this = _pywraplp.new_Solver(name, problem_type) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): this = _pywraplp.new_MPSolverParameters() try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _pywrapknapsack_solver.new_KnapsackSolver(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): this = _pywrapcp.new_DefaultPhaseParameters() try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): this = _pywrapcp.new_Solver(*args) try: self.this.append(this) except __builtin__.Exception: self.this = this self.__python_constraints = []
def __init__(self): if self.__class__ == BaseObject: _self = None else: _self = self this = _pywrapcp.new_BaseObject(_self, ) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, s: 'Solver'): if self.__class__ == PropagationBaseObject: _self = None else: _self = self this = _pywrapcp.new_PropagationBaseObject(_self, s) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): if self.__class__ == Decision: _self = None else: _self = self this = _pywrapcp.new_Decision(_self, ) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self): if self.__class__ == Demon: _self = None else: _self = self this = _pywrapcp.new_Demon(_self, ) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, solver: 'Solver'): if self.__class__ == Constraint: _self = None else: _self = self this = _pywrapcp.new_Constraint(_self, solver) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, s: 'Solver'): if self.__class__ == SearchMonitor: _self = None else: _self = self this = _pywrapcp.new_SearchMonitor(_self, s) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, val: 'long long const &'): this = _pywrapcp.new_RevInteger(val) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, val: 'long long const &'): this = _pywrapcp.new_NumericalRevInteger(val) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, *args): if self.__class__ == IntVarLocalSearchOperator: _self = None else: _self = self this = _pywrapcp.new_IntVarLocalSearchOperator(_self, *args) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, vars: 'std::vector< operations_research::IntVar *,std::allocator< operations_research::IntVar * > > const &'): if self.__class__ == BaseLns: _self = None else: _self = self this = _pywrapcp.new_BaseLns(_self, vars) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, vars: 'std::vector< operations_research::IntVar *,std::allocator< operations_research::IntVar * > > const &'): if self.__class__ == ChangeValue: _self = None else: _self = self this = _pywrapcp.new_ChangeValue(_self, vars) try: self.this.append(this) except __builtin__.Exception: self.this = this
def __init__(self, vars: 'std::vector< operations_research::IntVar *,std::allocator< operations_research::IntVar * > > const &'): if self.__class__ == IntVarLocalSearchFilter: _self = None else: _self = self this = _pywrapcp.new_IntVarLocalSearchFilter(_self, vars) try: self.this.append(this) except __builtin__.Exception: self.this = this