content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# -*- coding: utf-8 -*- # (c)2010-2012 Chris Pressey, Cat's Eye Technologies. # All rights reserved. Released under a BSD-style license (see LICENSE). """ Abstract Syntax Trees for the Unlikely programming language. $Id: ast.py 318 2010-01-07 01:49:38Z cpressey $ """ class ArtefactExistsError(Exception): """An exception indicating that a proposed artefact (class, method, property, ...) already exists. """ pass class ArtefactNotFoundError(Exception): """An exception indicating that a needed artefact (class, method, property, ...) does not exist. """ pass class BadModifierError(Exception): """An exception indicating that a specified modifier is not valid.""" pass class IncompatibleTypeError(Exception): """An exception indicating that the types of two connected subexpressions are not compatible. """ pass class ClassRelationshipError(Exception): """An exception indicating that the specified relationship between two classes is illegal. """ pass class AST: """Class representing nodes in an abstract syntax tree.""" pass class ClassBase(AST): """A collection of Unlikely class definitions.""" def __init__(self): self.class_defn_map = {} def __str__(self): s = "" for class_name in self.class_defn_map: s = s + str(self.class_defn_map[class_name]) + " " return "ClassBase { " + s + "}" def add_class_defn_by_name(self, class_name, superclass_name=None, modifiers=None): """A factory method. Call this instead of ClassDefn(). If a class was declared forward, this will return the stub. The third and fourth arguments are conveniences for stdlib. """ if class_name in self.class_defn_map: class_defn = self.class_defn_map[class_name] else: class_defn = ClassDefn(self, class_name) self.class_defn_map[class_name] = class_defn if modifiers is not None: for modifier in modifiers: class_defn.add_modifier(modifier) if superclass_name is not None: class_defn.set_superclass_by_name(superclass_name) return class_defn def lookup_class_defn(self, class_name): if class_name in self.class_defn_map: return self.class_defn_map[class_name] raise ArtefactNotFoundError("class " + class_name) class ClassDefn(AST): """ A definition of an Unlikely class. Really, only ClassBase should be allowed to call this constructor. Everyone else should use the factory methods on ClassBase. """ def __init__(self, classbase, class_name): assert isinstance(classbase, ClassBase) self.classbase = classbase self.name = class_name self.superclass = None self.dependant_map = {} self.dependant_names = [] self.prop_defn_map = {} self.method_defn_map = {} self.modifiers = [] def __str__(self): c = "class " + self.name + "(" d = "" for class_name in self.dependant_map: if d == "": d = d + class_name else: d = d + "," + class_name c = c + d + ") " if self.superclass is not None: c = c + "extends " + self.superclass.name + " " c = c + "{ " for prop_name in self.prop_defn_map: prop_defn = self.prop_defn_map[prop_name] c = c + str(prop_defn) + " " for method_name in self.method_defn_map: method_defn = self.method_defn_map[method_name] c = c + str(method_defn) + " " return c + "}" def set_superclass_by_name(self, superclass_name): """ Sets the superclass of this class. """ superclass = self.classbase.lookup_class_defn(superclass_name) if not self.has_modifier("forcible"): if superclass.has_modifier("final"): raise ClassRelationshipError("cannot inherit from final " + superclass_name) if (self.superclass is not None and self.superclass.name != superclass_name): raise ClassRelationshipError("class " + self.name + " already has superclass " + self.superclass.name) self.superclass = superclass if len(self.dependant_names) == 0: for dependant_name in superclass.dependant_names: self.dependant_names.append(dependant_name) self.dependant_map[dependant_name] = \ superclass.dependant_map[dependant_name] return superclass def add_dependant_by_name(self, dependant_name): if dependant_name in self.dependant_map: raise ClassRelationshipError("dependant " + dependant_name + " already declared") dependant = self.classbase.lookup_class_defn(dependant_name) self.dependant_map[dependant.name] = dependant self.dependant_names.append(dependant.name) def get_dependant_by_index(self, index): return self.dependant_map[self.dependant_names[index]] def add_prop_defn_by_name(self, prop_name, type_class_name): """ Factory method. Call this instead of PropDefn(). """ try: prop_defn = self.lookup_prop_defn(prop_name) except ArtefactNotFoundError: prop_defn = PropDefn(self, prop_name) self.prop_defn_map[prop_name] = prop_defn prop_defn.type_class_defn = self.lookup_class_defn(type_class_name) return prop_defn raise ArtefactExistsError("property " + prop_defn.name) def add_method_defn_by_name(self, method_name): """ Factory method. Call this instead of MethodDefn(). """ if method_name in self.method_defn_map: raise ArtefactExistsError("method " + method_name) try: overridden_method_defn = self.lookup_method_defn(method_name) except ArtefactNotFoundError: overridden_method_defn = None if (self.is_saturated() and overridden_method_defn is None and self.superclass is not None): raise ClassRelationshipError("new method " + method_name + " not allowed on saturated " + self.name) method_defn = MethodDefn(self, method_name) self.method_defn_map[method_defn.name] = method_defn return method_defn def add_modifier(self, modifier): if modifier not in ["final", "saturated", "abstract", "forcible"]: raise BadModifierError(modifier) self.modifiers.append(modifier) def has_modifier(self, modifier): return modifier in self.modifiers def must_be_injected(self): if self.has_modifier("final"): return False return True def lookup_class_defn(self, class_name): """Note that this first looks up the class definition in the dependant classes of this class: all classes referred to by a class *must* be injected! And then the dependants of the superclass of this class. This doesn't apply for final classes, since injecting them doesn't make any sense. """ if class_name[0].isdigit(): class_defn = self.classbase.add_class_defn_by_name(class_name) class_defn.add_modifier("final") class_defn.add_modifier("forcible") class_defn.set_superclass_by_name("Integer") return class_defn if class_name[0] == "\"": class_defn = self.classbase.add_class_defn_by_name(class_name) class_defn.add_modifier("final") class_defn.add_modifier("forcible") class_defn.set_superclass_by_name("String") return class_defn if class_name in self.dependant_map: return self.dependant_map[class_name] if self.superclass is not None: return self.superclass.lookup_class_defn(class_name) class_defn = self.classbase.lookup_class_defn(class_name) if class_defn is not None and not class_defn.must_be_injected(): return class_defn raise ArtefactNotFoundError("dependant class " + class_name) def lookup_prop_defn(self, prop_name): if prop_name in self.prop_defn_map: return self.prop_defn_map[prop_name] if self.superclass is not None: return self.superclass.lookup_prop_defn(prop_name) raise ArtefactNotFoundError("property " + prop_name) def lookup_method_defn(self, method_name): if method_name in self.method_defn_map: return self.method_defn_map[method_name] if self.superclass is not None: return self.superclass.lookup_method_defn(method_name) raise ArtefactNotFoundError("method " + method_name) def is_subclass_of(self, class_defn): if self == class_defn: return True if self.superclass is None: return False return self.superclass.is_subclass_of(class_defn) def is_saturated(self): if self.has_modifier("saturated"): return True if self.superclass is None: return False return self.superclass.is_saturated() def find_all_method_defns(self, map=None): """ Returns all methods defined and inherited by this class, in the form of a map from method name to method definition object. """ if map is None: map = {} for method_defn_name in self.method_defn_map: if method_defn_name not in map: map[method_defn_name] = self.method_defn_map[method_defn_name] if self.superclass is not None: self.superclass.find_all_method_defns(map) return map def typecheck(self): map = self.find_all_method_defns() if not self.has_modifier("abstract"): for method_defn_name in map: if map[method_defn_name].has_modifier("abstract"): message = ("concrete class " + self.name + " does not implement abstract method " + method_defn_name) raise ClassRelationshipError(message) else: all_concrete = True for method_defn_name in map: if map[method_defn_name].has_modifier("abstract"): all_concrete = False if all_concrete: raise ClassRelationshipError("abstract class " + self.name + " has no abstract methods") class PropDefn(AST): """ Definition of a property on an Unlikely class. """ def __init__(self, class_defn, name): assert isinstance(class_defn, ClassDefn) self.class_defn = class_defn self.name = name self.type_class_defn = None def __str__(self): return self.type_class_defn.name + " " + self.name def lookup_class_defn(self, class_name): return self.class_defn.lookup_class_defn(class_name) class MethodDefn(AST): """ Definition of a method on an Unlikely class. """ def __init__(self, class_defn, name): assert isinstance(class_defn, ClassDefn) self.class_defn = class_defn self.name = name self.param_decl_map = {} self.param_names = [] self.assignments = [] self.modifiers = [] self.continue_ = None def __str__(self): c = "method " + self.name + "(" d = "" for param_name in self.param_names: p = str(self.param_decl_map[param_name]) if d == "": d = d + p else: d = d + "," + p c = c + d + ")" return c def add_param_decl_by_name(self, param_name, type_class_name): """ Factory method. Call this instead of ParamDecl(). """ if param_name in self.param_decl_map: raise ArtefactExistsError("param " + param_name) prop_defn = self.lookup_prop_defn(param_name) type_class_defn = self.lookup_class_defn(type_class_name) if prop_defn.type_class_defn != type_class_defn: raise IncompatibleTypeError(param_name + " param is a " + type_class_name + " but property is a " + prop_defn.type_class_defn.name) param_decl = ParamDecl(self, param_name, type_class_defn) self.param_decl_map[param_name] = param_decl self.param_names.append(param_name) return param_decl def add_assignment(self): """ Factory method. Call this instead of Assignment(). """ assignment = Assignment(self) self.assignments.append(assignment) return assignment def add_modifier(self, modifier): if modifier not in ["abstract"]: raise BadModifierError(modifier) self.modifiers.append(modifier) def has_modifier(self, modifier): return modifier in self.modifiers def add_continue(self): """ Factory method. Call this instead of Continue(). """ assert self.continue_ == None continue_ = Continue(self) self.continue_ = continue_ return continue_ def lookup_class_defn(self, class_name): return self.class_defn.lookup_class_defn(class_name) def lookup_prop_defn(self, prop_name): return self.class_defn.lookup_prop_defn(prop_name) def get_param_decl_by_index(self, index): param_name = self.param_names[index] param_decl = self.param_decl_map[param_name] return param_decl class ParamDecl(AST): """ Definition of a formal parameter to an Unlikely method. """ def __init__(self, method_defn, name, type_class_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.name = name self.type_class_defn = type_class_defn def __str__(self): return self.type_class_defn.name + " " + self.name class Assignment(AST): """ An Unlikely assignment statement. """ def __init__(self, method_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.lhs = None self.rhs = None def add_qual_name(self): qual_name = QualName(self) if self.lhs is None: self.lhs = qual_name else: assert self.rhs is None self.rhs = qual_name return qual_name def add_construction(self, type_class_name): construction = Construction(self, type_class_name) assert self.rhs is None self.rhs = construction return construction class Continue(AST): """ An Unlikely continue ("goto") statement. """ def __init__(self, method_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.prop_defn = None self.method_name = None self.param_exprs = [] def set_prop_defn_by_name(self, prop_name): self.prop_defn = self.method_defn.lookup_prop_defn(prop_name) assert isinstance(self.prop_defn, PropDefn) def set_method_defn_by_name(self, method_name): type_class_defn = self.prop_defn.type_class_defn self.method_defn = type_class_defn.lookup_method_defn(method_name) assert isinstance(self.method_defn, MethodDefn) def add_qual_name(self): qual_name = QualName(self) self.param_exprs.append(qual_name) return qual_name def add_construction(self, type_class_name): construction = Construction(self, type_class_name) self.param_exprs.append(construction) return construction def typecheck(self): if len(self.param_exprs) != len(self.method_defn.param_names): message = ("continue provides " + str(len(self.param_exprs)) + " params, " + str(len(self.method_defn.param_names)) + " needed") raise IncompatibleTypeError(message) i = 0 for param_expr in self.param_exprs: param_decl = self.method_defn.get_param_decl_by_index(i) arg_type_class_defn = param_expr.get_type_class_defn() param_type_class_defn = param_decl.type_class_defn if not arg_type_class_defn.is_subclass_of(param_type_class_defn): message = (arg_type_class_defn.name + " not a subclass of " + param_type_class_defn.name) raise IncompatibleTypeError(message) i += 1 class Construction(AST): """ An Unlikely construction ("new") expression. """ def __init__(self, parent, type_class_name): assert isinstance(parent, Assignment) or isinstance(parent, Continue) self.parent = parent self.type_class_defn = \ self.parent.method_defn.lookup_class_defn(type_class_name) self.dependencies = [] def add_dependency_by_name(self, class_name): dependency = self.parent.method_defn.lookup_class_defn(class_name) self.dependencies.append(dependency) return dependency def get_type_class_defn(self): return self.type_class_defn def typecheck(self): if len(self.dependencies) != len(self.type_class_defn.dependant_names): message = ("instantiation specifies " + str(len(self.dependencies)) + " classes, " + str(len(self.type_class_defn.dependant_names)) + " needed (" + ",".join(self.type_class_defn.dependant_names) + ")") raise IncompatibleTypeError(message) i = 0 for dependency in self.dependencies: dependant_class_defn = \ self.type_class_defn.get_dependant_by_index(i) if not dependency.is_subclass_of(dependant_class_defn): message = (dependency.name + " not a subclass of " + dependant_class_defn.name) raise IncompatibleTypeError(message) i += 1 class QualName(AST): """ An Unlikely qualified name (property reference) expression. """ def __init__(self, parent): assert isinstance(parent, Assignment) or isinstance(parent, Continue) self.parent = parent self.prop_defns = [] self.scope_class_defn = self.parent.method_defn.class_defn def add_prop_defn_by_name(self, prop_name): prop_defn = self.scope_class_defn.lookup_prop_defn(prop_name) self.prop_defns.append(prop_defn) self.scope_class_defn = prop_defn.type_class_defn return prop_defn def get_type_class_defn(self): return self.scope_class_defn def get_prop_defn_by_index(self, index): return self.prop_defns[index]
""" Abstract Syntax Trees for the Unlikely programming language. $Id: ast.py 318 2010-01-07 01:49:38Z cpressey $ """ class Artefactexistserror(Exception): """An exception indicating that a proposed artefact (class, method, property, ...) already exists. """ pass class Artefactnotfounderror(Exception): """An exception indicating that a needed artefact (class, method, property, ...) does not exist. """ pass class Badmodifiererror(Exception): """An exception indicating that a specified modifier is not valid.""" pass class Incompatibletypeerror(Exception): """An exception indicating that the types of two connected subexpressions are not compatible. """ pass class Classrelationshiperror(Exception): """An exception indicating that the specified relationship between two classes is illegal. """ pass class Ast: """Class representing nodes in an abstract syntax tree.""" pass class Classbase(AST): """A collection of Unlikely class definitions.""" def __init__(self): self.class_defn_map = {} def __str__(self): s = '' for class_name in self.class_defn_map: s = s + str(self.class_defn_map[class_name]) + ' ' return 'ClassBase { ' + s + '}' def add_class_defn_by_name(self, class_name, superclass_name=None, modifiers=None): """A factory method. Call this instead of ClassDefn(). If a class was declared forward, this will return the stub. The third and fourth arguments are conveniences for stdlib. """ if class_name in self.class_defn_map: class_defn = self.class_defn_map[class_name] else: class_defn = class_defn(self, class_name) self.class_defn_map[class_name] = class_defn if modifiers is not None: for modifier in modifiers: class_defn.add_modifier(modifier) if superclass_name is not None: class_defn.set_superclass_by_name(superclass_name) return class_defn def lookup_class_defn(self, class_name): if class_name in self.class_defn_map: return self.class_defn_map[class_name] raise artefact_not_found_error('class ' + class_name) class Classdefn(AST): """ A definition of an Unlikely class. Really, only ClassBase should be allowed to call this constructor. Everyone else should use the factory methods on ClassBase. """ def __init__(self, classbase, class_name): assert isinstance(classbase, ClassBase) self.classbase = classbase self.name = class_name self.superclass = None self.dependant_map = {} self.dependant_names = [] self.prop_defn_map = {} self.method_defn_map = {} self.modifiers = [] def __str__(self): c = 'class ' + self.name + '(' d = '' for class_name in self.dependant_map: if d == '': d = d + class_name else: d = d + ',' + class_name c = c + d + ') ' if self.superclass is not None: c = c + 'extends ' + self.superclass.name + ' ' c = c + '{ ' for prop_name in self.prop_defn_map: prop_defn = self.prop_defn_map[prop_name] c = c + str(prop_defn) + ' ' for method_name in self.method_defn_map: method_defn = self.method_defn_map[method_name] c = c + str(method_defn) + ' ' return c + '}' def set_superclass_by_name(self, superclass_name): """ Sets the superclass of this class. """ superclass = self.classbase.lookup_class_defn(superclass_name) if not self.has_modifier('forcible'): if superclass.has_modifier('final'): raise class_relationship_error('cannot inherit from final ' + superclass_name) if self.superclass is not None and self.superclass.name != superclass_name: raise class_relationship_error('class ' + self.name + ' already has superclass ' + self.superclass.name) self.superclass = superclass if len(self.dependant_names) == 0: for dependant_name in superclass.dependant_names: self.dependant_names.append(dependant_name) self.dependant_map[dependant_name] = superclass.dependant_map[dependant_name] return superclass def add_dependant_by_name(self, dependant_name): if dependant_name in self.dependant_map: raise class_relationship_error('dependant ' + dependant_name + ' already declared') dependant = self.classbase.lookup_class_defn(dependant_name) self.dependant_map[dependant.name] = dependant self.dependant_names.append(dependant.name) def get_dependant_by_index(self, index): return self.dependant_map[self.dependant_names[index]] def add_prop_defn_by_name(self, prop_name, type_class_name): """ Factory method. Call this instead of PropDefn(). """ try: prop_defn = self.lookup_prop_defn(prop_name) except ArtefactNotFoundError: prop_defn = prop_defn(self, prop_name) self.prop_defn_map[prop_name] = prop_defn prop_defn.type_class_defn = self.lookup_class_defn(type_class_name) return prop_defn raise artefact_exists_error('property ' + prop_defn.name) def add_method_defn_by_name(self, method_name): """ Factory method. Call this instead of MethodDefn(). """ if method_name in self.method_defn_map: raise artefact_exists_error('method ' + method_name) try: overridden_method_defn = self.lookup_method_defn(method_name) except ArtefactNotFoundError: overridden_method_defn = None if self.is_saturated() and overridden_method_defn is None and (self.superclass is not None): raise class_relationship_error('new method ' + method_name + ' not allowed on saturated ' + self.name) method_defn = method_defn(self, method_name) self.method_defn_map[method_defn.name] = method_defn return method_defn def add_modifier(self, modifier): if modifier not in ['final', 'saturated', 'abstract', 'forcible']: raise bad_modifier_error(modifier) self.modifiers.append(modifier) def has_modifier(self, modifier): return modifier in self.modifiers def must_be_injected(self): if self.has_modifier('final'): return False return True def lookup_class_defn(self, class_name): """Note that this first looks up the class definition in the dependant classes of this class: all classes referred to by a class *must* be injected! And then the dependants of the superclass of this class. This doesn't apply for final classes, since injecting them doesn't make any sense. """ if class_name[0].isdigit(): class_defn = self.classbase.add_class_defn_by_name(class_name) class_defn.add_modifier('final') class_defn.add_modifier('forcible') class_defn.set_superclass_by_name('Integer') return class_defn if class_name[0] == '"': class_defn = self.classbase.add_class_defn_by_name(class_name) class_defn.add_modifier('final') class_defn.add_modifier('forcible') class_defn.set_superclass_by_name('String') return class_defn if class_name in self.dependant_map: return self.dependant_map[class_name] if self.superclass is not None: return self.superclass.lookup_class_defn(class_name) class_defn = self.classbase.lookup_class_defn(class_name) if class_defn is not None and (not class_defn.must_be_injected()): return class_defn raise artefact_not_found_error('dependant class ' + class_name) def lookup_prop_defn(self, prop_name): if prop_name in self.prop_defn_map: return self.prop_defn_map[prop_name] if self.superclass is not None: return self.superclass.lookup_prop_defn(prop_name) raise artefact_not_found_error('property ' + prop_name) def lookup_method_defn(self, method_name): if method_name in self.method_defn_map: return self.method_defn_map[method_name] if self.superclass is not None: return self.superclass.lookup_method_defn(method_name) raise artefact_not_found_error('method ' + method_name) def is_subclass_of(self, class_defn): if self == class_defn: return True if self.superclass is None: return False return self.superclass.is_subclass_of(class_defn) def is_saturated(self): if self.has_modifier('saturated'): return True if self.superclass is None: return False return self.superclass.is_saturated() def find_all_method_defns(self, map=None): """ Returns all methods defined and inherited by this class, in the form of a map from method name to method definition object. """ if map is None: map = {} for method_defn_name in self.method_defn_map: if method_defn_name not in map: map[method_defn_name] = self.method_defn_map[method_defn_name] if self.superclass is not None: self.superclass.find_all_method_defns(map) return map def typecheck(self): map = self.find_all_method_defns() if not self.has_modifier('abstract'): for method_defn_name in map: if map[method_defn_name].has_modifier('abstract'): message = 'concrete class ' + self.name + ' does not implement abstract method ' + method_defn_name raise class_relationship_error(message) else: all_concrete = True for method_defn_name in map: if map[method_defn_name].has_modifier('abstract'): all_concrete = False if all_concrete: raise class_relationship_error('abstract class ' + self.name + ' has no abstract methods') class Propdefn(AST): """ Definition of a property on an Unlikely class. """ def __init__(self, class_defn, name): assert isinstance(class_defn, ClassDefn) self.class_defn = class_defn self.name = name self.type_class_defn = None def __str__(self): return self.type_class_defn.name + ' ' + self.name def lookup_class_defn(self, class_name): return self.class_defn.lookup_class_defn(class_name) class Methoddefn(AST): """ Definition of a method on an Unlikely class. """ def __init__(self, class_defn, name): assert isinstance(class_defn, ClassDefn) self.class_defn = class_defn self.name = name self.param_decl_map = {} self.param_names = [] self.assignments = [] self.modifiers = [] self.continue_ = None def __str__(self): c = 'method ' + self.name + '(' d = '' for param_name in self.param_names: p = str(self.param_decl_map[param_name]) if d == '': d = d + p else: d = d + ',' + p c = c + d + ')' return c def add_param_decl_by_name(self, param_name, type_class_name): """ Factory method. Call this instead of ParamDecl(). """ if param_name in self.param_decl_map: raise artefact_exists_error('param ' + param_name) prop_defn = self.lookup_prop_defn(param_name) type_class_defn = self.lookup_class_defn(type_class_name) if prop_defn.type_class_defn != type_class_defn: raise incompatible_type_error(param_name + ' param is a ' + type_class_name + ' but property is a ' + prop_defn.type_class_defn.name) param_decl = param_decl(self, param_name, type_class_defn) self.param_decl_map[param_name] = param_decl self.param_names.append(param_name) return param_decl def add_assignment(self): """ Factory method. Call this instead of Assignment(). """ assignment = assignment(self) self.assignments.append(assignment) return assignment def add_modifier(self, modifier): if modifier not in ['abstract']: raise bad_modifier_error(modifier) self.modifiers.append(modifier) def has_modifier(self, modifier): return modifier in self.modifiers def add_continue(self): """ Factory method. Call this instead of Continue(). """ assert self.continue_ == None continue_ = continue(self) self.continue_ = continue_ return continue_ def lookup_class_defn(self, class_name): return self.class_defn.lookup_class_defn(class_name) def lookup_prop_defn(self, prop_name): return self.class_defn.lookup_prop_defn(prop_name) def get_param_decl_by_index(self, index): param_name = self.param_names[index] param_decl = self.param_decl_map[param_name] return param_decl class Paramdecl(AST): """ Definition of a formal parameter to an Unlikely method. """ def __init__(self, method_defn, name, type_class_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.name = name self.type_class_defn = type_class_defn def __str__(self): return self.type_class_defn.name + ' ' + self.name class Assignment(AST): """ An Unlikely assignment statement. """ def __init__(self, method_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.lhs = None self.rhs = None def add_qual_name(self): qual_name = qual_name(self) if self.lhs is None: self.lhs = qual_name else: assert self.rhs is None self.rhs = qual_name return qual_name def add_construction(self, type_class_name): construction = construction(self, type_class_name) assert self.rhs is None self.rhs = construction return construction class Continue(AST): """ An Unlikely continue ("goto") statement. """ def __init__(self, method_defn): assert isinstance(method_defn, MethodDefn) self.method_defn = method_defn self.prop_defn = None self.method_name = None self.param_exprs = [] def set_prop_defn_by_name(self, prop_name): self.prop_defn = self.method_defn.lookup_prop_defn(prop_name) assert isinstance(self.prop_defn, PropDefn) def set_method_defn_by_name(self, method_name): type_class_defn = self.prop_defn.type_class_defn self.method_defn = type_class_defn.lookup_method_defn(method_name) assert isinstance(self.method_defn, MethodDefn) def add_qual_name(self): qual_name = qual_name(self) self.param_exprs.append(qual_name) return qual_name def add_construction(self, type_class_name): construction = construction(self, type_class_name) self.param_exprs.append(construction) return construction def typecheck(self): if len(self.param_exprs) != len(self.method_defn.param_names): message = 'continue provides ' + str(len(self.param_exprs)) + ' params, ' + str(len(self.method_defn.param_names)) + ' needed' raise incompatible_type_error(message) i = 0 for param_expr in self.param_exprs: param_decl = self.method_defn.get_param_decl_by_index(i) arg_type_class_defn = param_expr.get_type_class_defn() param_type_class_defn = param_decl.type_class_defn if not arg_type_class_defn.is_subclass_of(param_type_class_defn): message = arg_type_class_defn.name + ' not a subclass of ' + param_type_class_defn.name raise incompatible_type_error(message) i += 1 class Construction(AST): """ An Unlikely construction ("new") expression. """ def __init__(self, parent, type_class_name): assert isinstance(parent, Assignment) or isinstance(parent, Continue) self.parent = parent self.type_class_defn = self.parent.method_defn.lookup_class_defn(type_class_name) self.dependencies = [] def add_dependency_by_name(self, class_name): dependency = self.parent.method_defn.lookup_class_defn(class_name) self.dependencies.append(dependency) return dependency def get_type_class_defn(self): return self.type_class_defn def typecheck(self): if len(self.dependencies) != len(self.type_class_defn.dependant_names): message = 'instantiation specifies ' + str(len(self.dependencies)) + ' classes, ' + str(len(self.type_class_defn.dependant_names)) + ' needed (' + ','.join(self.type_class_defn.dependant_names) + ')' raise incompatible_type_error(message) i = 0 for dependency in self.dependencies: dependant_class_defn = self.type_class_defn.get_dependant_by_index(i) if not dependency.is_subclass_of(dependant_class_defn): message = dependency.name + ' not a subclass of ' + dependant_class_defn.name raise incompatible_type_error(message) i += 1 class Qualname(AST): """ An Unlikely qualified name (property reference) expression. """ def __init__(self, parent): assert isinstance(parent, Assignment) or isinstance(parent, Continue) self.parent = parent self.prop_defns = [] self.scope_class_defn = self.parent.method_defn.class_defn def add_prop_defn_by_name(self, prop_name): prop_defn = self.scope_class_defn.lookup_prop_defn(prop_name) self.prop_defns.append(prop_defn) self.scope_class_defn = prop_defn.type_class_defn return prop_defn def get_type_class_defn(self): return self.scope_class_defn def get_prop_defn_by_index(self, index): return self.prop_defns[index]
del_items(0x800A0FE4) SetType(0x800A0FE4, "void VID_OpenModule__Fv()") del_items(0x800A10A4) SetType(0x800A10A4, "void InitScreens__Fv()") del_items(0x800A1194) SetType(0x800A1194, "void MEM_SetupMem__Fv()") del_items(0x800A11C0) SetType(0x800A11C0, "void SetupWorkRam__Fv()") del_items(0x800A1250) SetType(0x800A1250, "void SYSI_Init__Fv()") del_items(0x800A135C) SetType(0x800A135C, "void GM_Open__Fv()") del_items(0x800A1380) SetType(0x800A1380, "void PA_Open__Fv()") del_items(0x800A13B8) SetType(0x800A13B8, "void PAD_Open__Fv()") del_items(0x800A13FC) SetType(0x800A13FC, "void OVR_Open__Fv()") del_items(0x800A141C) SetType(0x800A141C, "void SCR_Open__Fv()") del_items(0x800A144C) SetType(0x800A144C, "void DEC_Open__Fv()") del_items(0x800A16C0) SetType(0x800A16C0, "char *GetVersionString__FPc(char *VersionString2)") del_items(0x800A1794) SetType(0x800A1794, "char *GetWord__FPc(char *VStr)")
del_items(2148143076) set_type(2148143076, 'void VID_OpenModule__Fv()') del_items(2148143268) set_type(2148143268, 'void InitScreens__Fv()') del_items(2148143508) set_type(2148143508, 'void MEM_SetupMem__Fv()') del_items(2148143552) set_type(2148143552, 'void SetupWorkRam__Fv()') del_items(2148143696) set_type(2148143696, 'void SYSI_Init__Fv()') del_items(2148143964) set_type(2148143964, 'void GM_Open__Fv()') del_items(2148144000) set_type(2148144000, 'void PA_Open__Fv()') del_items(2148144056) set_type(2148144056, 'void PAD_Open__Fv()') del_items(2148144124) set_type(2148144124, 'void OVR_Open__Fv()') del_items(2148144156) set_type(2148144156, 'void SCR_Open__Fv()') del_items(2148144204) set_type(2148144204, 'void DEC_Open__Fv()') del_items(2148144832) set_type(2148144832, 'char *GetVersionString__FPc(char *VersionString2)') del_items(2148145044) set_type(2148145044, 'char *GetWord__FPc(char *VStr)')
def arithmetic_arranger(problems, count_start=False): line_1 = "" line_2 = "" line_3 = "" line_4 = "" for i, problem in enumerate(problems): a, b, c = problem.split() d = max(len(a), len(c)) if len(problems) > 5: return "Error: Too many problems." if len(a) > 4 or len(c) > 4: return "Error: Numbers cannot be more than four digits." if b == "+" or b == "-": try: a = int(a) c = int(c) if b == "+": result = a + c else: result = a - c line_1 = line_1 + f'{a:>{d+2}}' line_2 = line_2 + b + f'{c:>{d+1}}' line_3 = line_3 + ''.rjust(d + 2, '-') line_4 = line_4 + str(result).rjust(d + 2) except ValueError: return "Error: Numbers must only contain digits." else: return "Error: Operator must be '+' or '-'." if i < len(problems) - 1: line_1 += " " line_2 += " " line_3 += " " line_4 += " " if count_start: arranged_problems = line_1 + '\n' + line_2 + '\n' + line_3 + '\n' + line_4 else: arranged_problems = line_1 + '\n' + line_2 + '\n' + line_3 return arranged_problems
def arithmetic_arranger(problems, count_start=False): line_1 = '' line_2 = '' line_3 = '' line_4 = '' for (i, problem) in enumerate(problems): (a, b, c) = problem.split() d = max(len(a), len(c)) if len(problems) > 5: return 'Error: Too many problems.' if len(a) > 4 or len(c) > 4: return 'Error: Numbers cannot be more than four digits.' if b == '+' or b == '-': try: a = int(a) c = int(c) if b == '+': result = a + c else: result = a - c line_1 = line_1 + f'{a:>{d + 2}}' line_2 = line_2 + b + f'{c:>{d + 1}}' line_3 = line_3 + ''.rjust(d + 2, '-') line_4 = line_4 + str(result).rjust(d + 2) except ValueError: return 'Error: Numbers must only contain digits.' else: return "Error: Operator must be '+' or '-'." if i < len(problems) - 1: line_1 += ' ' line_2 += ' ' line_3 += ' ' line_4 += ' ' if count_start: arranged_problems = line_1 + '\n' + line_2 + '\n' + line_3 + '\n' + line_4 else: arranged_problems = line_1 + '\n' + line_2 + '\n' + line_3 return arranged_problems
# Copyright (c) 2019 The Bazel Utils Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. def runtime_library(): return [ "_WINDOWS", "WIN32", ] def winver(): return [ "_WIN32_WINNT=0x0A00", "WINVER=0x0A00", ] def unicode(): return ["_UNICODE", "UNICODE"] def lean_and_mean(): return ["WIN32_LEAN_AND_MEAN"]
def runtime_library(): return ['_WINDOWS', 'WIN32'] def winver(): return ['_WIN32_WINNT=0x0A00', 'WINVER=0x0A00'] def unicode(): return ['_UNICODE', 'UNICODE'] def lean_and_mean(): return ['WIN32_LEAN_AND_MEAN']
def arithmetic_arranger(problems, solution=False): # Limit of 4 problems per call if len(problems) > 5: return "Error: Too many problems." # Declaring list to organise problems summa1 = [] summa2 = [] operator = [] # Organising problems in right list for problem in problems: prob_list = problem.split() summa1.append(prob_list[0]) summa2.append(prob_list[2]) operator.append(prob_list[1]) # Checking operator for char in operator: if char != "+" and char != "-": return "Error: Operator must be '+' or '-'." # Checking digits summa_total = [] summa_total = summa1 + summa2 for num in summa_total: if not num.isdigit(): return "Error: Numbers must only contain digits." # Checking length of digits for num in summa_total: if len(num) > 4: return "Error: Numbers cannot be more than four digits." # Solution for summa1, summa. divider and divider solution_1 = [] solution_2 = [] divider = [] answer = [] # solution_1 for i in range(len(summa1)): if len(summa1[i]) > len(summa2[i]): solution_1.append(" " * 2 + summa1[i]) else: solution_1.append(" " * (len(summa2[i]) - len(summa1[i])+2) + summa1[i]) # solution_2 for i in range(len(summa2)): if len(summa2[i]) > len(summa1[i]): solution_2.append(operator[i] + " " + summa2[i]) else: solution_2.append(operator[i] + " " * (len(summa1[i]) - len(summa2[i]) + 1) + summa2[i]) # divider for i in range(len(summa1)): divider.append("-" * (max(len(summa1[i]), len(summa2[i])) + 2)) # If solution equals True if solution: for i in range(len(summa1)): if operator[i] == "+": sol = str(int(summa1[i]) + int(summa2[i])) else: sol = str(int(summa1[i]) - int(summa2[i])) if len(sol) > max(len(summa1[i]), len(summa2[i])): answer.append(" " + sol) else: answer.append(" " * (max(len(summa1[i]), len(summa2[i])) - len(sol) + 2) + sol) arranged_problems = " ".join(solution_1) + "\n" + " ".join(solution_2) + "\n" + " ".join(divider) + "\n" + " ".join(answer) else: arranged_problems = " ".join(solution_1) + "\n" + " ".join(solution_2) + "\n" + " ".join( divider) return arranged_problems
def arithmetic_arranger(problems, solution=False): if len(problems) > 5: return 'Error: Too many problems.' summa1 = [] summa2 = [] operator = [] for problem in problems: prob_list = problem.split() summa1.append(prob_list[0]) summa2.append(prob_list[2]) operator.append(prob_list[1]) for char in operator: if char != '+' and char != '-': return "Error: Operator must be '+' or '-'." summa_total = [] summa_total = summa1 + summa2 for num in summa_total: if not num.isdigit(): return 'Error: Numbers must only contain digits.' for num in summa_total: if len(num) > 4: return 'Error: Numbers cannot be more than four digits.' solution_1 = [] solution_2 = [] divider = [] answer = [] for i in range(len(summa1)): if len(summa1[i]) > len(summa2[i]): solution_1.append(' ' * 2 + summa1[i]) else: solution_1.append(' ' * (len(summa2[i]) - len(summa1[i]) + 2) + summa1[i]) for i in range(len(summa2)): if len(summa2[i]) > len(summa1[i]): solution_2.append(operator[i] + ' ' + summa2[i]) else: solution_2.append(operator[i] + ' ' * (len(summa1[i]) - len(summa2[i]) + 1) + summa2[i]) for i in range(len(summa1)): divider.append('-' * (max(len(summa1[i]), len(summa2[i])) + 2)) if solution: for i in range(len(summa1)): if operator[i] == '+': sol = str(int(summa1[i]) + int(summa2[i])) else: sol = str(int(summa1[i]) - int(summa2[i])) if len(sol) > max(len(summa1[i]), len(summa2[i])): answer.append(' ' + sol) else: answer.append(' ' * (max(len(summa1[i]), len(summa2[i])) - len(sol) + 2) + sol) arranged_problems = ' '.join(solution_1) + '\n' + ' '.join(solution_2) + '\n' + ' '.join(divider) + '\n' + ' '.join(answer) else: arranged_problems = ' '.join(solution_1) + '\n' + ' '.join(solution_2) + '\n' + ' '.join(divider) return arranged_problems
""" Azure concepts """ def Graphic_shape(): return "egg" def Graphic_colorfill(): return "#CCCC33" def Graphic_colorbg(): return "#CCCC33" def Graphic_border(): return 0 def Graphic_is_rounded(): return True
""" Azure concepts """ def graphic_shape(): return 'egg' def graphic_colorfill(): return '#CCCC33' def graphic_colorbg(): return '#CCCC33' def graphic_border(): return 0 def graphic_is_rounded(): return True
class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ letters = [0 for i in range(256)] for i in range(len(s)): letters[ord(s[i])] += 1 for i in range(len(t)): letters[ord(t[i])] -= 1 for i in range(len(letters)): if letters[i] != 0: return False return True
class Solution(object): def is_anagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ letters = [0 for i in range(256)] for i in range(len(s)): letters[ord(s[i])] += 1 for i in range(len(t)): letters[ord(t[i])] -= 1 for i in range(len(letters)): if letters[i] != 0: return False return True
''' PURPOSE The function capital_indexes takes a single parameter, which is a string. It returns a list of all the indexes in the string that have capital letters. EXAMPLE Calling capital_indexes("HeLlO") should return the list [0, 2, 4]. ''' def capital_indexes(input_str): try: input_str_len = len(input_str) # initialise list index_list = [] # loop through each character for x in range(input_str_len): # check whether the character is a capital if input_str[x].isupper(): # uncomment this line to manually check the string's capitals # print('character {} is a capital ({})'.format(x, input_str[x])) index_list.append(x) return index_list except TypeError: print('ERROR Input must be a string') except Exception as e: print("ERROR", e.__class__, "occurred.") # get input string input_str = "HeLlO" # submit string to function capital_index_list = capital_indexes(input_str) # print capital_index_list if not empty if capital_index_list: print(capital_index_list)
""" PURPOSE The function capital_indexes takes a single parameter, which is a string. It returns a list of all the indexes in the string that have capital letters. EXAMPLE Calling capital_indexes("HeLlO") should return the list [0, 2, 4]. """ def capital_indexes(input_str): try: input_str_len = len(input_str) index_list = [] for x in range(input_str_len): if input_str[x].isupper(): index_list.append(x) return index_list except TypeError: print('ERROR Input must be a string') except Exception as e: print('ERROR', e.__class__, 'occurred.') input_str = 'HeLlO' capital_index_list = capital_indexes(input_str) if capital_index_list: print(capital_index_list)
n,m = map(int, input().split()) arr = list(map(int, input().split())) a = set(map(int, input().split())) b = set(map(int,input().split())) print(n,m) print(arr) print(a) print(b) c = 0 for i in arr: if i in a: c = c +1 if i in b: c = c-1 print(c)
(n, m) = map(int, input().split()) arr = list(map(int, input().split())) a = set(map(int, input().split())) b = set(map(int, input().split())) print(n, m) print(arr) print(a) print(b) c = 0 for i in arr: if i in a: c = c + 1 if i in b: c = c - 1 print(c)
# Road to the Mine 1 (931060030) | Xenon 3rd Job lackey = 2159397 gelimer = 2154009 goon = 9300643 sm.lockInGameUI(True) sm.spawnNpc(lackey, 648, 28) # TO DO: Figure out why the lackey doesn't move and just spazes in place (initial start x: 1188) # sm.moveCamera(100, 738, ground) # sm.sendDelay(1000) # sm.moveCameraBack(100) # sm.moveNpcByTemplateId(lackey, True, 540, 60) # sm.sendDelay(4000) sm.removeEscapeButton() sm.setSpeakerID(lackey) sm.sendNext("Hey, what're you doing out here? And where did that other guy go? " "You don't look familiar...") sm.setPlayerAsSpeaker() sm.sendSay("I am a Black Wing.") sm.setSpeakerID(lackey) sm.sendSay("Are you now? Let me see here... I think I've seen your face before. " "I think I saw you in some orders I got from #p" + str(gelimer) + "#.") sm.setPlayerAsSpeaker() sm.sendSay("You are mistaken.") sm.setSpeakerID(lackey) sm.sendSay("I am? Maybe I'd better check with #p" + str(gelimer) + "#. " "I don't want to get into hot water. Come along!") sm.setPlayerAsSpeaker() sm.sendSay("Maybe I should have just taken this guy out...") sm.removeNpc(lackey) sm.spawnMob(goon, 648, 28, False) sm.chatScript("Defeat the Black Wings.") sm.lockInGameUI(False)
lackey = 2159397 gelimer = 2154009 goon = 9300643 sm.lockInGameUI(True) sm.spawnNpc(lackey, 648, 28) sm.removeEscapeButton() sm.setSpeakerID(lackey) sm.sendNext("Hey, what're you doing out here? And where did that other guy go? You don't look familiar...") sm.setPlayerAsSpeaker() sm.sendSay('I am a Black Wing.') sm.setSpeakerID(lackey) sm.sendSay("Are you now? Let me see here... I think I've seen your face before. I think I saw you in some orders I got from #p" + str(gelimer) + '#.') sm.setPlayerAsSpeaker() sm.sendSay('You are mistaken.') sm.setSpeakerID(lackey) sm.sendSay("I am? Maybe I'd better check with #p" + str(gelimer) + "#. I don't want to get into hot water. Come along!") sm.setPlayerAsSpeaker() sm.sendSay('Maybe I should have just taken this guy out...') sm.removeNpc(lackey) sm.spawnMob(goon, 648, 28, False) sm.chatScript('Defeat the Black Wings.') sm.lockInGameUI(False)
PWR_MGMT_1 = 0x6b ACCEL_CONFIG = 0x1C ACCEL_XOUT_H = 0x3B ACCEL_XOUT_L = 0x3C ACCEL_YOUT_H = 0x3D ACCEL_YOUT_L = 0x3E ACCEL_ZOUT_H = 0x3F ACCEL_ZOUT_L = 0x40 GYRO_CONFIG = 0x1B GYRO_XOUT_H = 0x43 GYRO_XOUT_L = 0x44 GYRO_YOUT_H = 0x45 GYRO_YOUT_L = 0x46 GYRO_ZOUT_H = 0x47 GYRO_ZOUT_L = 0x48 TEMP_H = 0x41 TEMP_L = 0x42
pwr_mgmt_1 = 107 accel_config = 28 accel_xout_h = 59 accel_xout_l = 60 accel_yout_h = 61 accel_yout_l = 62 accel_zout_h = 63 accel_zout_l = 64 gyro_config = 27 gyro_xout_h = 67 gyro_xout_l = 68 gyro_yout_h = 69 gyro_yout_l = 70 gyro_zout_h = 71 gyro_zout_l = 72 temp_h = 65 temp_l = 66
""" __init__.py Created by lmarvaud on 31/01/2019 """
""" __init__.py Created by lmarvaud on 31/01/2019 """
### ### Week 2: Before Class ### ## Make a list of the words one two three o'clock four o'clock rock words = ["one", "two", "three", "o'clock", "four", "o'clock", 'rock'] ## Pick out the first word as a string words[0] ## Pick out the first word as a list words[0:1] ## Pick out the last word as a string words[-1] ## Show how many words there are in the list len(words) ## Transform the list into a new list that only has numbers in it ## take as many steps as you need [len(w) for w in words] ## Count how many times o'clock appears in the list words.count("o'clock") print("No output for this")
words = ['one', 'two', 'three', "o'clock", 'four', "o'clock", 'rock'] words[0] words[0:1] words[-1] len(words) [len(w) for w in words] words.count("o'clock") print('No output for this')
word1 = input("Enter a word: ") word2 = input("Enter another word: ") word1 = word1.lower() word2 = word2.lower() dic1 = {} dic2 = {} for elm in word1: if elm in dic1.keys(): count = dic1[elm] count += 1 dic1[elm] = count else: dic1[elm] = 1 for elm in word2: if elm in dic2.keys(): count = dic2[elm] count += 1 dic2[elm] = count else: dic2[elm] = 1 if dic1 == dic2 and word1 != word2: print("Those strings are anagrams.") else: print("Those strings are not anagrams.")
word1 = input('Enter a word: ') word2 = input('Enter another word: ') word1 = word1.lower() word2 = word2.lower() dic1 = {} dic2 = {} for elm in word1: if elm in dic1.keys(): count = dic1[elm] count += 1 dic1[elm] = count else: dic1[elm] = 1 for elm in word2: if elm in dic2.keys(): count = dic2[elm] count += 1 dic2[elm] = count else: dic2[elm] = 1 if dic1 == dic2 and word1 != word2: print('Those strings are anagrams.') else: print('Those strings are not anagrams.')
S = input() if S[-2:] == 'ai': print(S[:-2] + 'AI') else: print(S + '-AI')
s = input() if S[-2:] == 'ai': print(S[:-2] + 'AI') else: print(S + '-AI')
def words(digit): for i in digit: num = int(i) if num == 1: print("One") if num == 2: print("Two") if num == 3: print("Three") if num == 4: print("Four") if num == 5: print("Five") if num == 6: print("Six") if num == 7: print("Seven") if num == 8: print("Eight") if num == 9: print("Nine") if num == 0: print("Zero") while True: try: digit = input("Enter a digit: ") words(digit) break except ValueError: print("Please enter a digit!!!")
def words(digit): for i in digit: num = int(i) if num == 1: print('One') if num == 2: print('Two') if num == 3: print('Three') if num == 4: print('Four') if num == 5: print('Five') if num == 6: print('Six') if num == 7: print('Seven') if num == 8: print('Eight') if num == 9: print('Nine') if num == 0: print('Zero') while True: try: digit = input('Enter a digit: ') words(digit) break except ValueError: print('Please enter a digit!!!')
class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ n = len(numbers) left, right = 0, n-1 while left < right: if numbers[left]+numbers[right]==target: return [left+1, right+1] if numbers[left]+numbers[right] < target: left += 1 if numbers[left]+numbers[right] > target: right -= 1 class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ n = len(numbers) i, j = 0, n-1 res = [0, 0] while i < j: cur_sum = numbers[i]+numbers[j] if cur_sum == target: return [i+1, j+1] elif cur_sum > target: j -= 1 else: i += 1 return res
class Solution: def two_sum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ n = len(numbers) (left, right) = (0, n - 1) while left < right: if numbers[left] + numbers[right] == target: return [left + 1, right + 1] if numbers[left] + numbers[right] < target: left += 1 if numbers[left] + numbers[right] > target: right -= 1 class Solution: def two_sum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ n = len(numbers) (i, j) = (0, n - 1) res = [0, 0] while i < j: cur_sum = numbers[i] + numbers[j] if cur_sum == target: return [i + 1, j + 1] elif cur_sum > target: j -= 1 else: i += 1 return res
test_data = """ 939 7,13,x,x,59,x,31,19 """.strip() data = """ 1001612 19,x,x,x,x,x,x,x,x,41,x,x,x,37,x,x,x,x,x,821,x,x,x,x,x,x,x,x,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,463,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23 """.strip() def test_aoc13_p1t(): time, schedule = test_data.splitlines() time = int(time) schedule = [int(bus) for bus in schedule.split(",") if bus != "x"] print(time) print(schedule) departures = [] for bus in schedule: departure = (bus - (time % bus)) if time % bus else 0 departures.append((departure, bus)) departures.sort() print(departures[0]) print(departures[0][0] * departures[0][1]) assert departures[0][0] * departures[0][1] == 295 def test_aoc13_p1(): time, schedule = data.splitlines() time = int(time) schedule = [int(bus) for bus in schedule.split(",") if bus != "x"] print(time) print(schedule) departures = [] for bus in schedule: departure = (bus - (time % bus)) if time % bus else 0 departures.append((departure, bus)) departures.sort() print(departures[0]) print(departures[0][0] * departures[0][1]) assert departures[0][0] * departures[0][1] == 6568 def find_common(offset, a, b): print() print(offset, a, b) for i in range(2000): print( f"a = {a}, n = {offset + a * i} remainder {(offset + a * i) % b}" ) if (offset + a * i) % b == b - 1: return offset + a * i + 1, a * b def test_find_common(): assert find_common(0, 3, 7) == (7, 21) assert find_common(0, 7, 3) == (15, 21) assert find_common(7, 21, 13) == (260, 21 * 13) assert find_common(7, 21, 1) == (8, 21) def get_timestamp(departures): print("-" * 100) print(departures) schedule = [1 if bus == "x" else int(bus) for bus in departures.split(",")] offset = 0 a = schedule[0] for b in schedule[1:]: offset, a = find_common(offset, a, b) return offset - len(schedule) + 1 def test_part2(): assert get_timestamp("3,7,13") == 258 assert get_timestamp("3,7,13") == 258 assert get_timestamp("17,x,13") == 102 assert get_timestamp(test_data.splitlines()[1]) == 1068781 assert get_timestamp("17,x,13,19") == 3417 assert get_timestamp("67,7,59,61") == 754018 assert get_timestamp("67,x,7,59,61") == 779210 assert get_timestamp("67,7,x,59,61") == 1261476 assert get_timestamp("1789,37,47,1889") == 1202161486 assert get_timestamp(data.splitlines()[1]) == 554865447501099
test_data = '\n939\n7,13,x,x,59,x,31,19\n'.strip() data = '\n1001612\n19,x,x,x,x,x,x,x,x,41,x,x,x,37,x,x,x,x,x,821,x,x,x,x,x,x,x,x,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,463,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,23\n'.strip() def test_aoc13_p1t(): (time, schedule) = test_data.splitlines() time = int(time) schedule = [int(bus) for bus in schedule.split(',') if bus != 'x'] print(time) print(schedule) departures = [] for bus in schedule: departure = bus - time % bus if time % bus else 0 departures.append((departure, bus)) departures.sort() print(departures[0]) print(departures[0][0] * departures[0][1]) assert departures[0][0] * departures[0][1] == 295 def test_aoc13_p1(): (time, schedule) = data.splitlines() time = int(time) schedule = [int(bus) for bus in schedule.split(',') if bus != 'x'] print(time) print(schedule) departures = [] for bus in schedule: departure = bus - time % bus if time % bus else 0 departures.append((departure, bus)) departures.sort() print(departures[0]) print(departures[0][0] * departures[0][1]) assert departures[0][0] * departures[0][1] == 6568 def find_common(offset, a, b): print() print(offset, a, b) for i in range(2000): print(f'a = {a}, n = {offset + a * i} remainder {(offset + a * i) % b}') if (offset + a * i) % b == b - 1: return (offset + a * i + 1, a * b) def test_find_common(): assert find_common(0, 3, 7) == (7, 21) assert find_common(0, 7, 3) == (15, 21) assert find_common(7, 21, 13) == (260, 21 * 13) assert find_common(7, 21, 1) == (8, 21) def get_timestamp(departures): print('-' * 100) print(departures) schedule = [1 if bus == 'x' else int(bus) for bus in departures.split(',')] offset = 0 a = schedule[0] for b in schedule[1:]: (offset, a) = find_common(offset, a, b) return offset - len(schedule) + 1 def test_part2(): assert get_timestamp('3,7,13') == 258 assert get_timestamp('3,7,13') == 258 assert get_timestamp('17,x,13') == 102 assert get_timestamp(test_data.splitlines()[1]) == 1068781 assert get_timestamp('17,x,13,19') == 3417 assert get_timestamp('67,7,59,61') == 754018 assert get_timestamp('67,x,7,59,61') == 779210 assert get_timestamp('67,7,x,59,61') == 1261476 assert get_timestamp('1789,37,47,1889') == 1202161486 assert get_timestamp(data.splitlines()[1]) == 554865447501099
class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ x = 0 y = 0 xx = len(matrix) - 1 yy = len(matrix[0]) - 1 rows = xx + 1 cols = yy + 1 while True: row = matrix[x][y : yy + 1] py = bisect.bisect_left(row, target) if py < len(row) and row[py] == target: return True if py == 0: return False col = [matrix[r][y] for r in range(x, xx + 1)] px = bisect.bisect_left(col, target) if px < len(col) and col[px] == target: return True if px == 0: return False xx = x + px - 1 yy = y + py - 1 x = x + 1 y = y + 1 if x > xx or y > yy: return False
class Solution(object): def search_matrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ x = 0 y = 0 xx = len(matrix) - 1 yy = len(matrix[0]) - 1 rows = xx + 1 cols = yy + 1 while True: row = matrix[x][y:yy + 1] py = bisect.bisect_left(row, target) if py < len(row) and row[py] == target: return True if py == 0: return False col = [matrix[r][y] for r in range(x, xx + 1)] px = bisect.bisect_left(col, target) if px < len(col) and col[px] == target: return True if px == 0: return False xx = x + px - 1 yy = y + py - 1 x = x + 1 y = y + 1 if x > xx or y > yy: return False
# Sanitize a dependency so that it works correctly from code that includes # QCraft as a submodule. def clean_dep(dep): return str(Label(dep))
def clean_dep(dep): return str(label(dep))
def unatrag(s): if len(s)==0: return s else: return unatrag(s[1:]) + s[0] s=input("Unesite rijec: ") print(unatrag(s))
def unatrag(s): if len(s) == 0: return s else: return unatrag(s[1:]) + s[0] s = input('Unesite rijec: ') print(unatrag(s))
file_obj = open("squares.txt", "w") #Usar w de writing for number in range (13): square = number * number file_obj.write(str(square)) file_obj.write('\n') file_obj.close()
file_obj = open('squares.txt', 'w') for number in range(13): square = number * number file_obj.write(str(square)) file_obj.write('\n') file_obj.close()
# Exercise 4: Assume that we execute the following assignment statements: # width = 17 # height = 12.0 # For each of the following expressions, write the value of the expression and the type (of the value of the expression). # 1. width//2 # 2. width/2.0 # 3. height/3 # 4. 1 + 2 * 5 width = 17; height = 12.0; one = width//2; # result: 8 - type: int two = width/2.0; # result: 8.5 - type: float three = height/3; # result: 4.0 - type: float four = 1 + 2 * 5; # result: 11 - type: int print(four, type(four))
width = 17 height = 12.0 one = width // 2 two = width / 2.0 three = height / 3 four = 1 + 2 * 5 print(four, type(four))
altitude = int(input("Enter Altitude in ft:")) if altitude<=1000: print("Safe to land") elif altitude< 5000: print("Bring down to 1000") else: print("Turn Around and Try Again")
altitude = int(input('Enter Altitude in ft:')) if altitude <= 1000: print('Safe to land') elif altitude < 5000: print('Bring down to 1000') else: print('Turn Around and Try Again')
# -*- coding: utf-8 -*- def test_dummy(cmd, initproj, monkeypatch): monkeypatch.delenv(str("TOXENV"), raising=False) path = initproj( 'envreport_123', filedefs={ 'tox.ini': """ [tox] envlist = a [testenv] deps=tox-envreport commands=echo "yehaaa" """ }) assert path result = cmd('all') assert result
def test_dummy(cmd, initproj, monkeypatch): monkeypatch.delenv(str('TOXENV'), raising=False) path = initproj('envreport_123', filedefs={'tox.ini': '\n [tox]\n envlist = a\n [testenv]\n deps=tox-envreport\n commands=echo "yehaaa"\n '}) assert path result = cmd('all') assert result
# -*- coding: utf-8 -*- ''' File name: code\comfortable_distance\sol_364.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #364 :: Comfortable distance # # For more information see: # https://projecteuler.net/problem=364 # Problem Statement ''' There are N seats in a row. N people come after each other to fill the seats according to the following rules: If there is any seat whose adjacent seat(s) are not occupied take such a seat. If there is no such seat and there is any seat for which only one adjacent seat is occupied take such a seat. Otherwise take one of the remaining available seats. Let T(N) be the number of possibilities that N seats are occupied by N people with the given rules. The following figure shows T(4)=8. We can verify that T(10) = 61632 and T(1 000) mod 100 000 007 = 47255094. Find T(1 000 000) mod 100 000 007. ''' # Solution # Solution Approach ''' '''
""" File name: code\\comfortable_distance\\sol_364.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x """ '\nThere are N seats in a row. N people come after each other to fill the seats according to the following rules:\nIf there is any seat whose adjacent seat(s) are not occupied take such a seat.\nIf there is no such seat and there is any seat for which only one adjacent seat is occupied take such a seat.\nOtherwise take one of the remaining available seats. \n\nLet T(N) be the number of possibilities that N seats are occupied by N people with the given rules. The following figure shows T(4)=8.\n\n\n\n\n\nWe can verify that T(10) = 61632 and T(1 000) mod 100 000 007 = 47255094.\nFind T(1 000 000) mod 100 000 007.\n' '\n'
class Water(): regions = None outline_points = None def __init__(self): self.regions = [] self.outline_points = []
class Water: regions = None outline_points = None def __init__(self): self.regions = [] self.outline_points = []
1 "test" "equality" == "equality" 1.5 * 10 int
1 'test' 'equality' == 'equality' 1.5 * 10 int
class Classe: atributo_da_classe = 0 print(Classe.atributo_da_classe) Classe.atributo_da_classe = 5 print(Classe.atributo_da_classe)
class Classe: atributo_da_classe = 0 print(Classe.atributo_da_classe) Classe.atributo_da_classe = 5 print(Classe.atributo_da_classe)
# 917. Reverse Only Letters def reverseOnlyLetters(S): def isLetter(c): if (ord(c) >= 65 and ord(c) < 91) or (ord(c) >= 97 and ord(c) < 123): return True return False A = list(S) i, j = 0, len(A) - 1 while i < j: if isLetter(A[i]) and isLetter(A[j]): A[i], A[j] = A[j], A[i] i = i + 1 j = j - 1 if not isLetter(A[i]): i = i + 1 if not isLetter(A[j]): j = j - 1 return ''.join(A) print(reverseOnlyLetters("a-bC-dEf-ghIj")) def reverseOnlyLetters2(S): letter = [c for c in S if c.isalpha()] ans = [] for c in S: if c.isalpha(): ans.append(letter.pop()) else: ans.append(c) return ''.join(ans) def reverseOnlyLetters3(S): ans = [] j = len(S) - 1 for i, c in enumerate(S): if c.isalpha(): while not S[j].isalpha(): j -= 1 ans.append(S[j]) j -= 1 else: ans.append(c) return ''.join(ans)
def reverse_only_letters(S): def is_letter(c): if ord(c) >= 65 and ord(c) < 91 or (ord(c) >= 97 and ord(c) < 123): return True return False a = list(S) (i, j) = (0, len(A) - 1) while i < j: if is_letter(A[i]) and is_letter(A[j]): (A[i], A[j]) = (A[j], A[i]) i = i + 1 j = j - 1 if not is_letter(A[i]): i = i + 1 if not is_letter(A[j]): j = j - 1 return ''.join(A) print(reverse_only_letters('a-bC-dEf-ghIj')) def reverse_only_letters2(S): letter = [c for c in S if c.isalpha()] ans = [] for c in S: if c.isalpha(): ans.append(letter.pop()) else: ans.append(c) return ''.join(ans) def reverse_only_letters3(S): ans = [] j = len(S) - 1 for (i, c) in enumerate(S): if c.isalpha(): while not S[j].isalpha(): j -= 1 ans.append(S[j]) j -= 1 else: ans.append(c) return ''.join(ans)
a=str(input('Enter string')) if(a==a[::-1]): print('palindrome') else: print('not a palindrome')
a = str(input('Enter string')) if a == a[::-1]: print('palindrome') else: print('not a palindrome')
# # PySNMP MIB module CTRON-SSR-SMI-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-SSR-SMI-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:15:44 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint") cabletron, = mibBuilder.importSymbols("CTRON-OIDS", "cabletron") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, iso, Gauge32, Bits, Unsigned32, ObjectIdentity, NotificationType, TimeTicks, Counter64, IpAddress, Integer32, MibIdentifier = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "iso", "Gauge32", "Bits", "Unsigned32", "ObjectIdentity", "NotificationType", "TimeTicks", "Counter64", "IpAddress", "Integer32", "MibIdentifier") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") ssr = ModuleIdentity((1, 3, 6, 1, 4, 1, 52, 2501)) ssr.setRevisions(('2000-07-15 00:00',)) if mibBuilder.loadTexts: ssr.setLastUpdated('200007150000Z') if mibBuilder.loadTexts: ssr.setOrganization('Cabletron Systems, Inc') ssrMibs = ObjectIdentity((1, 3, 6, 1, 4, 1, 52, 2501, 1)) if mibBuilder.loadTexts: ssrMibs.setStatus('current') ssrTraps = ObjectIdentity((1, 3, 6, 1, 4, 1, 52, 2501, 10)) if mibBuilder.loadTexts: ssrTraps.setStatus('current') mibBuilder.exportSymbols("CTRON-SSR-SMI-MIB", PYSNMP_MODULE_ID=ssr, ssr=ssr, ssrTraps=ssrTraps, ssrMibs=ssrMibs)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ValueSizeConstraint') (cabletron,) = mibBuilder.importSymbols('CTRON-OIDS', 'cabletron') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (counter32, mib_scalar, mib_table, mib_table_row, mib_table_column, module_identity, iso, gauge32, bits, unsigned32, object_identity, notification_type, time_ticks, counter64, ip_address, integer32, mib_identifier) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ModuleIdentity', 'iso', 'Gauge32', 'Bits', 'Unsigned32', 'ObjectIdentity', 'NotificationType', 'TimeTicks', 'Counter64', 'IpAddress', 'Integer32', 'MibIdentifier') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') ssr = module_identity((1, 3, 6, 1, 4, 1, 52, 2501)) ssr.setRevisions(('2000-07-15 00:00',)) if mibBuilder.loadTexts: ssr.setLastUpdated('200007150000Z') if mibBuilder.loadTexts: ssr.setOrganization('Cabletron Systems, Inc') ssr_mibs = object_identity((1, 3, 6, 1, 4, 1, 52, 2501, 1)) if mibBuilder.loadTexts: ssrMibs.setStatus('current') ssr_traps = object_identity((1, 3, 6, 1, 4, 1, 52, 2501, 10)) if mibBuilder.loadTexts: ssrTraps.setStatus('current') mibBuilder.exportSymbols('CTRON-SSR-SMI-MIB', PYSNMP_MODULE_ID=ssr, ssr=ssr, ssrTraps=ssrTraps, ssrMibs=ssrMibs)
PROCESSOR_VERSION = "0.7.0" # Entities AREAS = "areas" CAMERAS = "cameras" ALL_AREAS = "ALL" # Metrics OCCUPANCY = "occupancy" SOCIAL_DISTANCING = "social-distancing" FACEMASK_USAGE = "facemask-usage" IN_OUT = "in-out" DWELL_TIME = "dwell-time"
processor_version = '0.7.0' areas = 'areas' cameras = 'cameras' all_areas = 'ALL' occupancy = 'occupancy' social_distancing = 'social-distancing' facemask_usage = 'facemask-usage' in_out = 'in-out' dwell_time = 'dwell-time'
class Solution(object): def climbStairs(self, n): """ :type n: int :rtype: int """ if n == 1: return 1 if n == 2: return 2 a = 1 b = 2 for i in range(3, n + 1): c = a + b a = b b = c return c
class Solution(object): def climb_stairs(self, n): """ :type n: int :rtype: int """ if n == 1: return 1 if n == 2: return 2 a = 1 b = 2 for i in range(3, n + 1): c = a + b a = b b = c return c
''' URL: https://leetcode.com/problems/delete-columns-to-make-sorted/ Difficulty: Easy Description: Delete Columns to Make Sorted We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"]. (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]). Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order. Return the minimum possible value of D.length. Example 1: Input: A = ["cba","daf","ghi"] Output: 1 Explanation: After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order. If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order. Example 2: Input: A = ["a","b"] Output: 0 Explanation: D = {} Example 3: Input: A = ["zyx","wvu","tsr"] Output: 3 Explanation: D = {0, 1, 2} Constraints: 1 <= A.length <= 100 1 <= A[i].length <= 1000 ''' class Solution: def minDeletionSize(self, A): if len(A[0]) == 1: return 0 count = 0 for i in range(len(A[0])): for j in range(len(A)-1): if A[j][i] > A[j+1][i]: count += 1 break return count
""" URL: https://leetcode.com/problems/delete-columns-to-make-sorted/ Difficulty: Easy Description: Delete Columns to Make Sorted We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"], and ["f","z"]. (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]]). Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order. Return the minimum possible value of D.length. Example 1: Input: A = ["cba","daf","ghi"] Output: 1 Explanation: After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order. If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order. Example 2: Input: A = ["a","b"] Output: 0 Explanation: D = {} Example 3: Input: A = ["zyx","wvu","tsr"] Output: 3 Explanation: D = {0, 1, 2} Constraints: 1 <= A.length <= 100 1 <= A[i].length <= 1000 """ class Solution: def min_deletion_size(self, A): if len(A[0]) == 1: return 0 count = 0 for i in range(len(A[0])): for j in range(len(A) - 1): if A[j][i] > A[j + 1][i]: count += 1 break return count
ACTIVE_CLASS = 'active' SELECTED_CLASS = 'selected' class MenuItem: def __init__(self, label, url, css_classes='', submenu=None): self.label = label self.url = url self.css_classes = css_classes self.submenu = submenu def status_class(self, request): css_class = '' if self.url == request.path: css_class = ACTIVE_CLASS if ( self.url != '/' and self.url in request.path and not self.url == request.path ): css_class = SELECTED_CLASS return css_class def get_css_classes(self): return self.css_classes def get_all_css_classes(self, request): return '%s %s' % \ (self.get_css_classes(), self.status_class(request))
active_class = 'active' selected_class = 'selected' class Menuitem: def __init__(self, label, url, css_classes='', submenu=None): self.label = label self.url = url self.css_classes = css_classes self.submenu = submenu def status_class(self, request): css_class = '' if self.url == request.path: css_class = ACTIVE_CLASS if self.url != '/' and self.url in request.path and (not self.url == request.path): css_class = SELECTED_CLASS return css_class def get_css_classes(self): return self.css_classes def get_all_css_classes(self, request): return '%s %s' % (self.get_css_classes(), self.status_class(request))
class Hyparams: user_count= 192403 item_count= 63001 cate_count= 801 predict_batch_size = 120 predict_ads_num = 100 batch_size = 128 hidden_units = 64 train_batch_size = 32 test_batch_size = 512 predict_batch_size = 32 predict_users_num = 1000 predict_ads_num = 100 save_dir = './save_path_fancy'
class Hyparams: user_count = 192403 item_count = 63001 cate_count = 801 predict_batch_size = 120 predict_ads_num = 100 batch_size = 128 hidden_units = 64 train_batch_size = 32 test_batch_size = 512 predict_batch_size = 32 predict_users_num = 1000 predict_ads_num = 100 save_dir = './save_path_fancy'
''' Created on 1.12.2016 @author: Darren '''''' Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tree, 1 / \ 2 3 / \ \ 4 5 7 After calling your function, the tree should look like: 1 -> NULL / \ 2 -> 3 -> NULL / \ \ 4-> 5 -> 7 -> NULL " '''
""" Created on 1.12.2016 @author: Darren Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tree, 1 / 2 3 / \\ 4 5 7 After calling your function, the tree should look like: 1 -> NULL / 2 -> 3 -> NULL / \\ 4-> 5 -> 7 -> NULL " """
def set_template(args): # task category args.task = 'VideoBDE' # network parameters args.n_feat = 32 # loss args.loss = '1*L1+2*HEM' # learning rata strategy args.lr = 1e-4 args.lr_decay = 100 args.gamma = 0.1 # data parameters args.data_train = 'SDR4K' args.data_test = 'SDR4K' args.n_sequence = 3 args.n_frames_per_video = 100 args.rgb_range = 65535 args.size_must_mode = 4 args.patch_size = 256 args.dir_data = "/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/train/" args.dir_data_test = "/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/val/" args.lbd = 4 args.hbd = 16 # train args.epochs = 500 # test args.test_every = 1000 args.print_every = 10 if args.template == 'CDVD_TSP': args.model = "CDVD_TSP" args.n_sequence = 5 args.n_resblock = 3 args.lr_decay = 200 elif args.template == 'VBDE': args.model = 'VBDE' args.n_resblock = 2 elif args.template == 'VBDE_DOWNFLOW': args.model = 'VBDE_DOWNFLOW' args.n_resblock = 3 args.lr_decay = 200 elif args.template == 'VBDE_QM': args.model = 'VBDE_QM' args.n_resblock = 3 args.lr_decay = 200 # bit-depth parameters args.low_bitdepth = 4 args.high_bitdepth = 16 elif args.template == 'VBDE_LAP': args.model = 'VBDE_LAP' args.n_resblock = 3 args.lr_decay = 50 elif args.template == 'MOTION_NET': args.task = 'OpticalFlow' args.model = 'MOTION_NET' args.n_sequence = 2 args.size_must_mode = 32 args.loss = '1*MNL' # small learning rate for training optical flow args.lr = 1e-5 args.lr_decay = 200 args.gamma = 0.5 args.data_train = 'SDR4K_FLOW' args.data_test = 'SDR4K_FLOW' args.video_samples = 500 elif args.template == 'C3D': args.task = 'VideoBDE' args.model = 'C3D' args.n_resblock = 3 args.loss = '1*L1+2*HEM+0.1*QCC' elif args.template == 'HYBRID_C3D': args.model = 'HYBRID_C3D' args.n_resblock = 4 args.scheduler = 'plateau' else: raise NotImplementedError('Template [{:s}] is not found'.format(args.template))
def set_template(args): args.task = 'VideoBDE' args.n_feat = 32 args.loss = '1*L1+2*HEM' args.lr = 0.0001 args.lr_decay = 100 args.gamma = 0.1 args.data_train = 'SDR4K' args.data_test = 'SDR4K' args.n_sequence = 3 args.n_frames_per_video = 100 args.rgb_range = 65535 args.size_must_mode = 4 args.patch_size = 256 args.dir_data = '/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/train/' args.dir_data_test = '/home/medialab/workspace/hdd/zhen/EDVR/datasets/SDR4k/val/' args.lbd = 4 args.hbd = 16 args.epochs = 500 args.test_every = 1000 args.print_every = 10 if args.template == 'CDVD_TSP': args.model = 'CDVD_TSP' args.n_sequence = 5 args.n_resblock = 3 args.lr_decay = 200 elif args.template == 'VBDE': args.model = 'VBDE' args.n_resblock = 2 elif args.template == 'VBDE_DOWNFLOW': args.model = 'VBDE_DOWNFLOW' args.n_resblock = 3 args.lr_decay = 200 elif args.template == 'VBDE_QM': args.model = 'VBDE_QM' args.n_resblock = 3 args.lr_decay = 200 args.low_bitdepth = 4 args.high_bitdepth = 16 elif args.template == 'VBDE_LAP': args.model = 'VBDE_LAP' args.n_resblock = 3 args.lr_decay = 50 elif args.template == 'MOTION_NET': args.task = 'OpticalFlow' args.model = 'MOTION_NET' args.n_sequence = 2 args.size_must_mode = 32 args.loss = '1*MNL' args.lr = 1e-05 args.lr_decay = 200 args.gamma = 0.5 args.data_train = 'SDR4K_FLOW' args.data_test = 'SDR4K_FLOW' args.video_samples = 500 elif args.template == 'C3D': args.task = 'VideoBDE' args.model = 'C3D' args.n_resblock = 3 args.loss = '1*L1+2*HEM+0.1*QCC' elif args.template == 'HYBRID_C3D': args.model = 'HYBRID_C3D' args.n_resblock = 4 args.scheduler = 'plateau' else: raise not_implemented_error('Template [{:s}] is not found'.format(args.template))
""" Write a program by the following: 1. Define a function that accepts a string and prints every other word 2. Define a function that accepts a string and translates it into pig latin 3. If time, implement them into a main loop """
""" Write a program by the following: 1. Define a function that accepts a string and prints every other word 2. Define a function that accepts a string and translates it into pig latin 3. If time, implement them into a main loop """
# # PySNMP MIB module UNCDZ-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/UNCDZ-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:28:43 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion") NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") sysName, sysContact, sysLocation = mibBuilder.importSymbols("SNMPv2-MIB", "sysName", "sysContact", "sysLocation") iso, NotificationType, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, MibIdentifier, Integer32, Counter64, TimeTicks, Unsigned32, enterprises, Gauge32, ModuleIdentity, ObjectIdentity, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "iso", "NotificationType", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "MibIdentifier", "Integer32", "Counter64", "TimeTicks", "Unsigned32", "enterprises", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Counter32") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") uncdz_MIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 9839, 2, 1)).setLabel("uncdz-MIB") uncdz_MIB.setRevisions(('2004-08-12 15:52',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: uncdz_MIB.setRevisionsDescriptions(('This is the original version of the MIB.',)) if mibBuilder.loadTexts: uncdz_MIB.setLastUpdated('200408121552Z') if mibBuilder.loadTexts: uncdz_MIB.setOrganization('CAREL SpA') if mibBuilder.loadTexts: uncdz_MIB.setContactInfo(" Simone Ravazzolo Carel SpA Via dell'Industria, 11 35020 Brugine (PD) Italy Tel: +39 049 9716611 E-mail: [email protected] ") if mibBuilder.loadTexts: uncdz_MIB.setDescription('This is the MIB module for the UNIFLAIR UNCDZ device.') carel = MibIdentifier((1, 3, 6, 1, 4, 1, 9839)) systm = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 1)) agentRelease = MibScalar((1, 3, 6, 1, 4, 1, 9839, 1, 1), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: agentRelease.setStatus('current') if mibBuilder.loadTexts: agentRelease.setDescription('Release of the Agent.') agentCode = MibScalar((1, 3, 6, 1, 4, 1, 9839, 1, 2), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: agentCode.setStatus('current') if mibBuilder.loadTexts: agentCode.setDescription('Code of the Agent. 2=pCOWeb.') instruments = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2)) pCOWebInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0)) pCOStatusgroup = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10)) pCOId1_Status = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10, 1), Integer32()).setLabel("pCOId1-Status").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: pCOId1_Status.setStatus('current') if mibBuilder.loadTexts: pCOId1_Status.setDescription('Status of pCOId1. 0=Offline, 1=Init, 2=Online') pCOErrorsNumbergroup = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11)) pCOId1_ErrorsNumber = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11, 1), Integer32()).setLabel("pCOId1-ErrorsNumber").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setStatus('current') if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setDescription('Number of Communication Errors from pCOId1 to pCOWeb.') digitalObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1)) vent_on = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 1), Integer32()).setLabel("vent-on").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: vent_on.setStatus('current') if mibBuilder.loadTexts: vent_on.setDescription('System On (Fan)') compressore1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 2), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: compressore1.setStatus('current') if mibBuilder.loadTexts: compressore1.setDescription('Compressor 1') compressore2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 3), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: compressore2.setStatus('current') if mibBuilder.loadTexts: compressore2.setDescription('Compressor 2') compressore3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 4), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: compressore3.setStatus('current') if mibBuilder.loadTexts: compressore3.setDescription('Compressor 3') compressore4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 5), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: compressore4.setStatus('current') if mibBuilder.loadTexts: compressore4.setDescription('Compressor 4') out_h1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 6), Integer32()).setLabel("out-h1").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: out_h1.setStatus('current') if mibBuilder.loadTexts: out_h1.setDescription('Heating 1') out_h2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 7), Integer32()).setLabel("out-h2").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: out_h2.setStatus('current') if mibBuilder.loadTexts: out_h2.setDescription('Heating 2') out_h3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 8), Integer32()).setLabel("out-h3").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: out_h3.setStatus('current') if mibBuilder.loadTexts: out_h3.setDescription('Heating 3') gas_caldo_on = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 9), Integer32()).setLabel("gas-caldo-on").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: gas_caldo_on.setStatus('current') if mibBuilder.loadTexts: gas_caldo_on.setDescription('Hot Gas Coil') on_deum = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 10), Integer32()).setLabel("on-deum").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: on_deum.setStatus('current') if mibBuilder.loadTexts: on_deum.setDescription('Dehumidification') power = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 11), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: power.setStatus('current') if mibBuilder.loadTexts: power.setDescription('Humidification') mal_access = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 12), Integer32()).setLabel("mal-access").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_access.setStatus('current') if mibBuilder.loadTexts: mal_access.setDescription('Tampering Alarm') mal_ata = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 13), Integer32()).setLabel("mal-ata").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ata.setStatus('current') if mibBuilder.loadTexts: mal_ata.setDescription('Alarm: Room High Temperature') mal_bta = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 14), Integer32()).setLabel("mal-bta").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_bta.setStatus('current') if mibBuilder.loadTexts: mal_bta.setDescription('Alarm: Room Low Temperature') mal_aua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 15), Integer32()).setLabel("mal-aua").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_aua.setStatus('current') if mibBuilder.loadTexts: mal_aua.setDescription('Alarm: Room High Humidity') mal_bua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 16), Integer32()).setLabel("mal-bua").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_bua.setStatus('current') if mibBuilder.loadTexts: mal_bua.setDescription('Alarm: Room Low Humidity') mal_eap = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 17), Integer32()).setLabel("mal-eap").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_eap.setStatus('current') if mibBuilder.loadTexts: mal_eap.setDescription('Alarm: Room High/Low Temp./Humid.(Ext. Devices)') mal_filter = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 18), Integer32()).setLabel("mal-filter").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_filter.setStatus('current') if mibBuilder.loadTexts: mal_filter.setDescription('Alarm: Clogged Filter') mal_flood = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 19), Integer32()).setLabel("mal-flood").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_flood.setStatus('current') if mibBuilder.loadTexts: mal_flood.setDescription('Alarm: Water Leakage Detected') mal_flux = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 20), Integer32()).setLabel("mal-flux").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_flux.setStatus('current') if mibBuilder.loadTexts: mal_flux.setDescription('Alarm: Loss of Air Flow') mal_heater = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 21), Integer32()).setLabel("mal-heater").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_heater.setStatus('current') if mibBuilder.loadTexts: mal_heater.setDescription('Alarm: Heater Overheating') mal_hp1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 22), Integer32()).setLabel("mal-hp1").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_hp1.setStatus('current') if mibBuilder.loadTexts: mal_hp1.setDescription('Alarm: High Pressure 1') mal_hp2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 23), Integer32()).setLabel("mal-hp2").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_hp2.setStatus('current') if mibBuilder.loadTexts: mal_hp2.setDescription('Alarm: High Pressure 2') mal_lp1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 24), Integer32()).setLabel("mal-lp1").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_lp1.setStatus('current') if mibBuilder.loadTexts: mal_lp1.setDescription('Alarm: Low Pressure 1') mal_lp2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 25), Integer32()).setLabel("mal-lp2").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_lp2.setStatus('current') if mibBuilder.loadTexts: mal_lp2.setDescription('Alarm: Low Pressure 2') mal_phase = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 26), Integer32()).setLabel("mal-phase").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_phase.setStatus('current') if mibBuilder.loadTexts: mal_phase.setDescription('Alarm: Wrong phase sequence') mal_smoke = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 27), Integer32()).setLabel("mal-smoke").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_smoke.setStatus('current') if mibBuilder.loadTexts: mal_smoke.setDescription('Alarm: SMOKE-FIRE DETECTED') mal_lan = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 28), Integer32()).setLabel("mal-lan").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_lan.setStatus('current') if mibBuilder.loadTexts: mal_lan.setDescription('Alarm: Interrupted LAN') mal_hcurr = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 29), Integer32()).setLabel("mal-hcurr").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_hcurr.setStatus('current') if mibBuilder.loadTexts: mal_hcurr.setDescription('Humidifier Alarm: High Current') mal_nopower = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 30), Integer32()).setLabel("mal-nopower").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_nopower.setStatus('current') if mibBuilder.loadTexts: mal_nopower.setDescription('Humidifier Alarm: Power Loss') mal_nowater = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 31), Integer32()).setLabel("mal-nowater").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_nowater.setStatus('current') if mibBuilder.loadTexts: mal_nowater.setDescription('Humidifier Alarm: Water Loss') mal_cw_dh = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 32), Integer32()).setLabel("mal-cw-dh").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_cw_dh.setStatus('current') if mibBuilder.loadTexts: mal_cw_dh.setDescription('Alarm: Chilled Water Temp. too High for Dehumidification') mal_tc_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 33), Integer32()).setLabel("mal-tc-cw").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_tc_cw.setStatus('current') if mibBuilder.loadTexts: mal_tc_cw.setDescription('Alarm: CW Valve Failure or Water Flow too Low') mal_wflow = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 34), Integer32()).setLabel("mal-wflow").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_wflow.setStatus('current') if mibBuilder.loadTexts: mal_wflow.setDescription('Alarm: Loss of Water flow') mal_wht = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 35), Integer32()).setLabel("mal-wht").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_wht.setStatus('current') if mibBuilder.loadTexts: mal_wht.setDescription('Alarm: High chilled water temp.') mal_sonda_ta = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 36), Integer32()).setLabel("mal-sonda-ta").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_ta.setStatus('current') if mibBuilder.loadTexts: mal_sonda_ta.setDescription('Alarm: Room air Sensor Failure/Disconnected') mal_sonda_tac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 37), Integer32()).setLabel("mal-sonda-tac").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_tac.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tac.setDescription('Alarm: Hot water Sensor Failure/Disconnected') mal_sonda_tc = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 38), Integer32()).setLabel("mal-sonda-tc").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_tc.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tc.setDescription('Alarm: Condensing water Sensor Failure/Disconnect.') mal_sonda_te = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 39), Integer32()).setLabel("mal-sonda-te").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_te.setStatus('current') if mibBuilder.loadTexts: mal_sonda_te.setDescription('Alarm: Outdoor temp. Sensor Failure/Disconnected') mal_sonda_tm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 40), Integer32()).setLabel("mal-sonda-tm").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_tm.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tm.setDescription('Alarm: Delivery temp. Sensor Failure/Disconnected') mal_sonda_ua = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 41), Integer32()).setLabel("mal-sonda-ua").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_sonda_ua.setStatus('current') if mibBuilder.loadTexts: mal_sonda_ua.setDescription('Alarm: Rel. Humidity Sensor Failure/Disconnected') mal_ore_compr1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 42), Integer32()).setLabel("mal-ore-compr1").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_compr1.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr1.setDescription('Service Alarm: Compressor 1 hour counter threshold') mal_ore_compr2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 43), Integer32()).setLabel("mal-ore-compr2").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_compr2.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr2.setDescription('Service Alarm: Compressor 2 hour counter threshold') mal_ore_compr3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 44), Integer32()).setLabel("mal-ore-compr3").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_compr3.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr3.setDescription('Service Alarm: Compressor 3 hour counter threshold') mal_ore_compr4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 45), Integer32()).setLabel("mal-ore-compr4").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_compr4.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr4.setDescription('Service Alarm: Compressor 4 hour counter threshold') mal_ore_filtro = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 46), Integer32()).setLabel("mal-ore-filtro").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_filtro.setStatus('current') if mibBuilder.loadTexts: mal_ore_filtro.setDescription('Service Alarm: Air Filter hour counter threshold') mal_ore_risc1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 47), Integer32()).setLabel("mal-ore-risc1").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_risc1.setStatus('current') if mibBuilder.loadTexts: mal_ore_risc1.setDescription('Service Alarm: Heater 1 hour counter threshold') mal_ore_risc2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 48), Integer32()).setLabel("mal-ore-risc2").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_risc2.setStatus('current') if mibBuilder.loadTexts: mal_ore_risc2.setDescription('Service Alarm: Heater 2 hour counter threshold') mal_ore_umid = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 49), Integer32()).setLabel("mal-ore-umid").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_umid.setStatus('current') if mibBuilder.loadTexts: mal_ore_umid.setDescription('Service Alarm: Humidifier hour counter threshold') mal_ore_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 50), Integer32()).setLabel("mal-ore-unit").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: mal_ore_unit.setStatus('current') if mibBuilder.loadTexts: mal_ore_unit.setDescription('Service Alarm: Unit hour counter threshold') glb_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 51), Integer32()).setLabel("glb-al").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: glb_al.setStatus('current') if mibBuilder.loadTexts: glb_al.setDescription('General Alarm') or_al_2lev = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 52), Integer32()).setLabel("or-al-2lev").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: or_al_2lev.setStatus('current') if mibBuilder.loadTexts: or_al_2lev.setDescription('2nd Level Alarm') range_t_ext = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 53), Integer32()).setLabel("range-t-ext").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: range_t_ext.setStatus('current') if mibBuilder.loadTexts: range_t_ext.setDescription('Outdoor Temp. Sensor Fitted') range_t_circ = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 54), Integer32()).setLabel("range-t-circ").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: range_t_circ.setStatus('current') if mibBuilder.loadTexts: range_t_circ.setDescription('Closed Circuit (or Chilled) Water Temperature Sensor Fitted') range_t_man = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 55), Integer32()).setLabel("range-t-man").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: range_t_man.setStatus('current') if mibBuilder.loadTexts: range_t_man.setDescription('Delivery Temp. Sensor Fitted') range_t_ac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 56), Integer32()).setLabel("range-t-ac").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: range_t_ac.setStatus('current') if mibBuilder.loadTexts: range_t_ac.setDescription('Hot water temp. Sensor Fitted') umid_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 57), Integer32()).setLabel("umid-al").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: umid_al.setStatus('current') if mibBuilder.loadTexts: umid_al.setDescription('Humidifier general alarm') range_u_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 58), Integer32()).setLabel("range-u-amb").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: range_u_amb.setStatus('current') if mibBuilder.loadTexts: range_u_amb.setDescription('Relative Humidity Sensor Fitted') k_syson = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 60), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("k-syson").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: k_syson.setStatus('current') if mibBuilder.loadTexts: k_syson.setDescription('Unit Remote Switch-On/Off Control') xs_res_al = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 61), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("xs-res-al").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: xs_res_al.setStatus('current') if mibBuilder.loadTexts: xs_res_al.setDescription('Buzzer and Alarm Remote Reset Control') sleep_mode = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 63), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("sleep-mode").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: sleep_mode.setStatus('current') if mibBuilder.loadTexts: sleep_mode.setDescription('Set Back Mode (Sleep Mode)') test_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 64), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("test-sm").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: test_sm.setStatus('current') if mibBuilder.loadTexts: test_sm.setDescription('Set Back mode: Cyclical Start of Fan') ab_mediath = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 65), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("ab-mediath").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: ab_mediath.setStatus('current') if mibBuilder.loadTexts: ab_mediath.setDescription('Usage of T+ H Values: Local (0) / Mean (1)') ustdby1_2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 66), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1))).setLabel("ustdby1-2").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: ustdby1_2.setStatus('current') if mibBuilder.loadTexts: ustdby1_2.setDescription('No. Of Stand-by Units: one (0) / two (1)') emerg = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 67), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: emerg.setStatus('current') if mibBuilder.loadTexts: emerg.setDescription('Unit in Emergency operation') analogObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2)) temp_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 1), Integer32()).setLabel("temp-amb").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: temp_amb.setStatus('current') if mibBuilder.loadTexts: temp_amb.setDescription('Room Temperature') temp_ext = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 2), Integer32()).setLabel("temp-ext").setUnits('deg.C x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: temp_ext.setStatus('current') if mibBuilder.loadTexts: temp_ext.setDescription('Outdoor Temperature') temp_mand = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 3), Integer32()).setLabel("temp-mand").setUnits('deg.C x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: temp_mand.setStatus('current') if mibBuilder.loadTexts: temp_mand.setDescription('Delivery Air Temperature') temp_circ = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 4), Integer32()).setLabel("temp-circ").setUnits('deg.C x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: temp_circ.setStatus('current') if mibBuilder.loadTexts: temp_circ.setDescription('Closed Circuit (or Chilled) Water Temperature') temp_ac = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 5), Integer32()).setLabel("temp-ac").setUnits('deg.C x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: temp_ac.setStatus('current') if mibBuilder.loadTexts: temp_ac.setDescription('Hot Water Temperature') umid_amb = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 6), Integer32()).setLabel("umid-amb").setUnits('rH% x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: umid_amb.setStatus('current') if mibBuilder.loadTexts: umid_amb.setDescription('Room Relative Humidity') t_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set").setUnits('deg.C x 10').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set.setStatus('current') if mibBuilder.loadTexts: t_set.setDescription('Cooling Set Point') t_diff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-diff").setUnits('deg.C x 10').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_diff.setStatus('current') if mibBuilder.loadTexts: t_diff.setDescription('Cooling Prop.Band') t_set_c = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-c").setUnits('deg.C x 10').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set_c.setStatus('current') if mibBuilder.loadTexts: t_set_c.setDescription('Heating Set point') t_diff_c = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-diff-c").setUnits('deg.C x 10').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_diff_c.setStatus('current') if mibBuilder.loadTexts: t_diff_c.setDescription('Heating Prop.Band') ht_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("ht-set").setUnits('deg.C').setMaxAccess("readwrite") if mibBuilder.loadTexts: ht_set.setStatus('current') if mibBuilder.loadTexts: ht_set.setDescription('Room High Temp. Alarm Threshold') lt_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lt-set").setUnits('deg.C').setMaxAccess("readwrite") if mibBuilder.loadTexts: lt_set.setStatus('current') if mibBuilder.loadTexts: lt_set.setDescription('Room Low Temp. Alarm Threshold') t_set_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-sm").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set_sm.setStatus('current') if mibBuilder.loadTexts: t_set_sm.setDescription('Setback Mode: Cooling Set Point') t_set_c_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-c-sm").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set_c_sm.setStatus('current') if mibBuilder.loadTexts: t_set_c_sm.setDescription('Setback Mode: Heating Set Point') t_cw_dh = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-cw-dh").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_cw_dh.setStatus('current') if mibBuilder.loadTexts: t_cw_dh.setDescription('CW Set Point to Start Dehumidification Cycle') htset_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("htset-cw").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: htset_cw.setStatus('current') if mibBuilder.loadTexts: htset_cw.setDescription('CW High Temperature Alarm Threshold') t_set_cw = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-cw").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set_cw.setStatus('current') if mibBuilder.loadTexts: t_set_cw.setDescription('CW Set Point to Start CW Operating Mode (TC only)') t_rc_es = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-rc-es").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_rc_es.setStatus('current') if mibBuilder.loadTexts: t_rc_es.setDescription('Rad-cooler Set Point in E.S. Mode (ES Only)') t_rc_est = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-rc-est").setUnits('N/A').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_rc_est.setStatus('current') if mibBuilder.loadTexts: t_rc_est.setDescription('Rad-cooler Set Point in DX Mode (ES Only)') rampa_valv = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 20), Integer32()).setLabel("rampa-valv").setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: rampa_valv.setStatus('current') if mibBuilder.loadTexts: rampa_valv.setDescription('0-10V Ramp 1 Value (CW Valve Ramp)') anaout2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 21), Integer32()).setUnits('N/A').setMaxAccess("readonly") if mibBuilder.loadTexts: anaout2.setStatus('current') if mibBuilder.loadTexts: anaout2.setDescription('0-10V Ramp 2 Value (HW Valve/Rad Cooler Ramp)') steam_production = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 22), Integer32()).setLabel("steam-production").setUnits('kg/h x 10').setMaxAccess("readonly") if mibBuilder.loadTexts: steam_production.setStatus('current') if mibBuilder.loadTexts: steam_production.setDescription('Humidifier: steam capacity') t_set_lm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-set-lm").setUnits('deg.C').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_set_lm.setStatus('current') if mibBuilder.loadTexts: t_set_lm.setDescription('Delivery Air Temperature Limit Set Point ') delta_lm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("delta-lm").setUnits('deg.C x 10').setMaxAccess("readwrite") if mibBuilder.loadTexts: delta_lm.setStatus('current') if mibBuilder.loadTexts: delta_lm.setDescription('T+H Values: Mean/Local Diff. (aut. Changeover)') integerObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3)) ore_filtro = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 1), Integer32()).setLabel("ore-filtro").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_filtro.setStatus('current') if mibBuilder.loadTexts: ore_filtro.setDescription('Air Filter Working Houres') ore_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 2), Integer32()).setLabel("ore-unit").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_unit.setStatus('current') if mibBuilder.loadTexts: ore_unit.setDescription('Unit Working Houres') ore_compr1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 3), Integer32()).setLabel("ore-compr1").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_compr1.setStatus('current') if mibBuilder.loadTexts: ore_compr1.setDescription('Compressor 1 Working Houres') ore_compr2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 4), Integer32()).setLabel("ore-compr2").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_compr2.setStatus('current') if mibBuilder.loadTexts: ore_compr2.setDescription('Compressor 2 Working Houres') ore_compr3 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 5), Integer32()).setLabel("ore-compr3").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_compr3.setStatus('current') if mibBuilder.loadTexts: ore_compr3.setDescription('Compressor 3 Working Houres') ore_compr4 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 6), Integer32()).setLabel("ore-compr4").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_compr4.setStatus('current') if mibBuilder.loadTexts: ore_compr4.setDescription('Compressor 4 Working Houres') ore_heat1 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 7), Integer32()).setLabel("ore-heat1").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_heat1.setStatus('current') if mibBuilder.loadTexts: ore_heat1.setDescription('Heater 1 Working Houres') ore_heat2 = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 8), Integer32()).setLabel("ore-heat2").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_heat2.setStatus('current') if mibBuilder.loadTexts: ore_heat2.setDescription('Heater 2 Working Houres') ore_umid = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 9), Integer32()).setLabel("ore-umid").setUnits('h').setMaxAccess("readonly") if mibBuilder.loadTexts: ore_umid.setStatus('current') if mibBuilder.loadTexts: ore_umid.setDescription('Humidifier Working Houres') hdiff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hdiff.setStatus('current') if mibBuilder.loadTexts: hdiff.setDescription('Dehumidification Proportional Band') hu_diff = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-diff").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hu_diff.setStatus('current') if mibBuilder.loadTexts: hu_diff.setDescription('Humidification Proportional Band') hh_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hh-set").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hh_set.setStatus('current') if mibBuilder.loadTexts: hh_set.setDescription('High Relative Humidity Alarm Threshold') lh_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lh-set").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: lh_set.setStatus('current') if mibBuilder.loadTexts: lh_set.setDescription('Low Relative Humidity Alarm Threshold') hset = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hset.setStatus('current') if mibBuilder.loadTexts: hset.setDescription('Dehumidification Set Point') hset_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hset-sm").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hset_sm.setStatus('current') if mibBuilder.loadTexts: hset_sm.setDescription('Setback Mode: Dehumidification Set Point') hu_set = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-set").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hu_set.setStatus('current') if mibBuilder.loadTexts: hu_set.setDescription('Humidification Set Point') hu_set_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("hu-set-sm").setUnits('rH%').setMaxAccess("readwrite") if mibBuilder.loadTexts: hu_set_sm.setStatus('current') if mibBuilder.loadTexts: hu_set_sm.setDescription('Setback Mode: Humidification Set Point') restart_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("restart-delay").setUnits('sec').setMaxAccess("readwrite") if mibBuilder.loadTexts: restart_delay.setStatus('current') if mibBuilder.loadTexts: restart_delay.setDescription('Restart Delay') regul_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 21), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("regul-delay").setUnits('sec').setMaxAccess("readwrite") if mibBuilder.loadTexts: regul_delay.setStatus('current') if mibBuilder.loadTexts: regul_delay.setDescription('Regulation Start Transitory ') time_lowp = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 22), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("time-lowp").setUnits('sec').setMaxAccess("readwrite") if mibBuilder.loadTexts: time_lowp.setStatus('current') if mibBuilder.loadTexts: time_lowp.setDescription('Low Pressure Delay') alarm_delay = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("alarm-delay").setUnits('m').setMaxAccess("readwrite") if mibBuilder.loadTexts: alarm_delay.setStatus('current') if mibBuilder.loadTexts: alarm_delay.setDescription('Room T+H Alarm Delay') exc_time = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("exc-time").setUnits('m').setMaxAccess("readwrite") if mibBuilder.loadTexts: exc_time.setStatus('current') if mibBuilder.loadTexts: exc_time.setDescription('Anti-Hunting Constant of Room Regulation ') t_std_by = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("t-std-by").setUnits('h').setMaxAccess("readwrite") if mibBuilder.loadTexts: t_std_by.setStatus('current') if mibBuilder.loadTexts: t_std_by.setDescription('Stand-by Cycle Base Time') lan_unit = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 27), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("lan-unit").setUnits('n').setMaxAccess("readwrite") if mibBuilder.loadTexts: lan_unit.setStatus('current') if mibBuilder.loadTexts: lan_unit.setDescription('Total of units connected in LAN') ciclo_sm = MibScalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 28), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-32767, 32767))).setLabel("ciclo-sm").setUnits('m').setMaxAccess("readwrite") if mibBuilder.loadTexts: ciclo_sm.setStatus('current') if mibBuilder.loadTexts: ciclo_sm.setDescription('Set Back Mode: Fan Cyclical Start Interval') mibBuilder.exportSymbols("UNCDZ-MIB", ore_compr3=ore_compr3, out_h3=out_h3, mal_smoke=mal_smoke, hset_sm=hset_sm, mal_lp1=mal_lp1, regul_delay=regul_delay, vent_on=vent_on, ore_umid=ore_umid, hset=hset, k_syson=k_syson, t_set_cw=t_set_cw, compressore1=compressore1, lh_set=lh_set, ore_filtro=ore_filtro, out_h2=out_h2, sleep_mode=sleep_mode, mal_sonda_tac=mal_sonda_tac, hu_set=hu_set, umid_al=umid_al, pCOStatusgroup=pCOStatusgroup, mal_wht=mal_wht, ore_compr4=ore_compr4, emerg=emerg, steam_production=steam_production, temp_ac=temp_ac, mal_ore_umid=mal_ore_umid, temp_mand=temp_mand, mal_hp2=mal_hp2, mal_ore_compr3=mal_ore_compr3, pCOId1_ErrorsNumber=pCOId1_ErrorsNumber, temp_circ=temp_circ, mal_aua=mal_aua, mal_cw_dh=mal_cw_dh, mal_ore_unit=mal_ore_unit, t_std_by=t_std_by, mal_ore_compr1=mal_ore_compr1, compressore3=compressore3, range_t_ac=range_t_ac, mal_flux=mal_flux, compressore2=compressore2, mal_sonda_ua=mal_sonda_ua, temp_amb=temp_amb, htset_cw=htset_cw, mal_ore_compr4=mal_ore_compr4, ciclo_sm=ciclo_sm, hh_set=hh_set, out_h1=out_h1, pCOId1_Status=pCOId1_Status, mal_eap=mal_eap, time_lowp=time_lowp, mal_phase=mal_phase, pCOWebInfo=pCOWebInfo, t_diff_c=t_diff_c, power=power, ustdby1_2=ustdby1_2, t_diff=t_diff, mal_flood=mal_flood, mal_sonda_tc=mal_sonda_tc, uncdz_MIB=uncdz_MIB, mal_nopower=mal_nopower, ore_heat2=ore_heat2, mal_tc_cw=mal_tc_cw, t_set_c=t_set_c, integerObjects=integerObjects, ore_compr1=ore_compr1, t_set=t_set, t_rc_est=t_rc_est, compressore4=compressore4, carel=carel, t_set_c_sm=t_set_c_sm, ht_set=ht_set, mal_ore_risc2=mal_ore_risc2, hu_diff=hu_diff, mal_access=mal_access, mal_ore_compr2=mal_ore_compr2, digitalObjects=digitalObjects, pCOErrorsNumbergroup=pCOErrorsNumbergroup, alarm_delay=alarm_delay, mal_heater=mal_heater, on_deum=on_deum, mal_lp2=mal_lp2, rampa_valv=rampa_valv, agentCode=agentCode, t_set_lm=t_set_lm, ore_compr2=ore_compr2, mal_hp1=mal_hp1, mal_ata=mal_ata, ab_mediath=ab_mediath, analogObjects=analogObjects, delta_lm=delta_lm, anaout2=anaout2, mal_lan=mal_lan, gas_caldo_on=gas_caldo_on, exc_time=exc_time, mal_ore_filtro=mal_ore_filtro, test_sm=test_sm, systm=systm, umid_amb=umid_amb, PYSNMP_MODULE_ID=uncdz_MIB, mal_bua=mal_bua, hu_set_sm=hu_set_sm, mal_ore_risc1=mal_ore_risc1, ore_unit=ore_unit, lt_set=lt_set, agentRelease=agentRelease, mal_sonda_ta=mal_sonda_ta, ore_heat1=ore_heat1, range_u_amb=range_u_amb, xs_res_al=xs_res_al, glb_al=glb_al, or_al_2lev=or_al_2lev, mal_bta=mal_bta, t_set_sm=t_set_sm, range_t_man=range_t_man, temp_ext=temp_ext, mal_hcurr=mal_hcurr, mal_wflow=mal_wflow, hdiff=hdiff, lan_unit=lan_unit, restart_delay=restart_delay, mal_nowater=mal_nowater, t_cw_dh=t_cw_dh, mal_filter=mal_filter, range_t_circ=range_t_circ, range_t_ext=range_t_ext, mal_sonda_te=mal_sonda_te, mal_sonda_tm=mal_sonda_tm, instruments=instruments, t_rc_es=t_rc_es)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsUnion') (notification_group, module_compliance, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance', 'ObjectGroup') (sys_name, sys_contact, sys_location) = mibBuilder.importSymbols('SNMPv2-MIB', 'sysName', 'sysContact', 'sysLocation') (iso, notification_type, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, ip_address, mib_identifier, integer32, counter64, time_ticks, unsigned32, enterprises, gauge32, module_identity, object_identity, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'iso', 'NotificationType', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'IpAddress', 'MibIdentifier', 'Integer32', 'Counter64', 'TimeTicks', 'Unsigned32', 'enterprises', 'Gauge32', 'ModuleIdentity', 'ObjectIdentity', 'Counter32') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') uncdz_mib = module_identity((1, 3, 6, 1, 4, 1, 9839, 2, 1)).setLabel('uncdz-MIB') uncdz_MIB.setRevisions(('2004-08-12 15:52',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: uncdz_MIB.setRevisionsDescriptions(('This is the original version of the MIB.',)) if mibBuilder.loadTexts: uncdz_MIB.setLastUpdated('200408121552Z') if mibBuilder.loadTexts: uncdz_MIB.setOrganization('CAREL SpA') if mibBuilder.loadTexts: uncdz_MIB.setContactInfo(" Simone Ravazzolo Carel SpA Via dell'Industria, 11 35020 Brugine (PD) Italy Tel: +39 049 9716611 E-mail: [email protected] ") if mibBuilder.loadTexts: uncdz_MIB.setDescription('This is the MIB module for the UNIFLAIR UNCDZ device.') carel = mib_identifier((1, 3, 6, 1, 4, 1, 9839)) systm = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 1)) agent_release = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 1, 1), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: agentRelease.setStatus('current') if mibBuilder.loadTexts: agentRelease.setDescription('Release of the Agent.') agent_code = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 1, 2), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: agentCode.setStatus('current') if mibBuilder.loadTexts: agentCode.setDescription('Code of the Agent. 2=pCOWeb.') instruments = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2)) p_co_web_info = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 0)) p_co_statusgroup = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10)) p_co_id1__status = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 10, 1), integer32()).setLabel('pCOId1-Status').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: pCOId1_Status.setStatus('current') if mibBuilder.loadTexts: pCOId1_Status.setDescription('Status of pCOId1. 0=Offline, 1=Init, 2=Online') p_co_errors_numbergroup = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11)) p_co_id1__errors_number = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 0, 11, 1), integer32()).setLabel('pCOId1-ErrorsNumber').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setStatus('current') if mibBuilder.loadTexts: pCOId1_ErrorsNumber.setDescription('Number of Communication Errors from pCOId1 to pCOWeb.') digital_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1)) vent_on = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 1), integer32()).setLabel('vent-on').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: vent_on.setStatus('current') if mibBuilder.loadTexts: vent_on.setDescription('System On (Fan)') compressore1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 2), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: compressore1.setStatus('current') if mibBuilder.loadTexts: compressore1.setDescription('Compressor 1') compressore2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 3), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: compressore2.setStatus('current') if mibBuilder.loadTexts: compressore2.setDescription('Compressor 2') compressore3 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 4), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: compressore3.setStatus('current') if mibBuilder.loadTexts: compressore3.setDescription('Compressor 3') compressore4 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 5), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: compressore4.setStatus('current') if mibBuilder.loadTexts: compressore4.setDescription('Compressor 4') out_h1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 6), integer32()).setLabel('out-h1').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: out_h1.setStatus('current') if mibBuilder.loadTexts: out_h1.setDescription('Heating 1') out_h2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 7), integer32()).setLabel('out-h2').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: out_h2.setStatus('current') if mibBuilder.loadTexts: out_h2.setDescription('Heating 2') out_h3 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 8), integer32()).setLabel('out-h3').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: out_h3.setStatus('current') if mibBuilder.loadTexts: out_h3.setDescription('Heating 3') gas_caldo_on = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 9), integer32()).setLabel('gas-caldo-on').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: gas_caldo_on.setStatus('current') if mibBuilder.loadTexts: gas_caldo_on.setDescription('Hot Gas Coil') on_deum = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 10), integer32()).setLabel('on-deum').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: on_deum.setStatus('current') if mibBuilder.loadTexts: on_deum.setDescription('Dehumidification') power = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 11), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: power.setStatus('current') if mibBuilder.loadTexts: power.setDescription('Humidification') mal_access = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 12), integer32()).setLabel('mal-access').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_access.setStatus('current') if mibBuilder.loadTexts: mal_access.setDescription('Tampering Alarm') mal_ata = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 13), integer32()).setLabel('mal-ata').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ata.setStatus('current') if mibBuilder.loadTexts: mal_ata.setDescription('Alarm: Room High Temperature') mal_bta = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 14), integer32()).setLabel('mal-bta').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_bta.setStatus('current') if mibBuilder.loadTexts: mal_bta.setDescription('Alarm: Room Low Temperature') mal_aua = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 15), integer32()).setLabel('mal-aua').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_aua.setStatus('current') if mibBuilder.loadTexts: mal_aua.setDescription('Alarm: Room High Humidity') mal_bua = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 16), integer32()).setLabel('mal-bua').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_bua.setStatus('current') if mibBuilder.loadTexts: mal_bua.setDescription('Alarm: Room Low Humidity') mal_eap = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 17), integer32()).setLabel('mal-eap').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_eap.setStatus('current') if mibBuilder.loadTexts: mal_eap.setDescription('Alarm: Room High/Low Temp./Humid.(Ext. Devices)') mal_filter = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 18), integer32()).setLabel('mal-filter').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_filter.setStatus('current') if mibBuilder.loadTexts: mal_filter.setDescription('Alarm: Clogged Filter') mal_flood = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 19), integer32()).setLabel('mal-flood').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_flood.setStatus('current') if mibBuilder.loadTexts: mal_flood.setDescription('Alarm: Water Leakage Detected') mal_flux = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 20), integer32()).setLabel('mal-flux').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_flux.setStatus('current') if mibBuilder.loadTexts: mal_flux.setDescription('Alarm: Loss of Air Flow') mal_heater = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 21), integer32()).setLabel('mal-heater').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_heater.setStatus('current') if mibBuilder.loadTexts: mal_heater.setDescription('Alarm: Heater Overheating') mal_hp1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 22), integer32()).setLabel('mal-hp1').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_hp1.setStatus('current') if mibBuilder.loadTexts: mal_hp1.setDescription('Alarm: High Pressure 1') mal_hp2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 23), integer32()).setLabel('mal-hp2').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_hp2.setStatus('current') if mibBuilder.loadTexts: mal_hp2.setDescription('Alarm: High Pressure 2') mal_lp1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 24), integer32()).setLabel('mal-lp1').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_lp1.setStatus('current') if mibBuilder.loadTexts: mal_lp1.setDescription('Alarm: Low Pressure 1') mal_lp2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 25), integer32()).setLabel('mal-lp2').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_lp2.setStatus('current') if mibBuilder.loadTexts: mal_lp2.setDescription('Alarm: Low Pressure 2') mal_phase = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 26), integer32()).setLabel('mal-phase').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_phase.setStatus('current') if mibBuilder.loadTexts: mal_phase.setDescription('Alarm: Wrong phase sequence') mal_smoke = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 27), integer32()).setLabel('mal-smoke').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_smoke.setStatus('current') if mibBuilder.loadTexts: mal_smoke.setDescription('Alarm: SMOKE-FIRE DETECTED') mal_lan = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 28), integer32()).setLabel('mal-lan').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_lan.setStatus('current') if mibBuilder.loadTexts: mal_lan.setDescription('Alarm: Interrupted LAN') mal_hcurr = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 29), integer32()).setLabel('mal-hcurr').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_hcurr.setStatus('current') if mibBuilder.loadTexts: mal_hcurr.setDescription('Humidifier Alarm: High Current') mal_nopower = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 30), integer32()).setLabel('mal-nopower').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_nopower.setStatus('current') if mibBuilder.loadTexts: mal_nopower.setDescription('Humidifier Alarm: Power Loss') mal_nowater = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 31), integer32()).setLabel('mal-nowater').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_nowater.setStatus('current') if mibBuilder.loadTexts: mal_nowater.setDescription('Humidifier Alarm: Water Loss') mal_cw_dh = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 32), integer32()).setLabel('mal-cw-dh').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_cw_dh.setStatus('current') if mibBuilder.loadTexts: mal_cw_dh.setDescription('Alarm: Chilled Water Temp. too High for Dehumidification') mal_tc_cw = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 33), integer32()).setLabel('mal-tc-cw').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_tc_cw.setStatus('current') if mibBuilder.loadTexts: mal_tc_cw.setDescription('Alarm: CW Valve Failure or Water Flow too Low') mal_wflow = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 34), integer32()).setLabel('mal-wflow').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_wflow.setStatus('current') if mibBuilder.loadTexts: mal_wflow.setDescription('Alarm: Loss of Water flow') mal_wht = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 35), integer32()).setLabel('mal-wht').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_wht.setStatus('current') if mibBuilder.loadTexts: mal_wht.setDescription('Alarm: High chilled water temp.') mal_sonda_ta = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 36), integer32()).setLabel('mal-sonda-ta').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_ta.setStatus('current') if mibBuilder.loadTexts: mal_sonda_ta.setDescription('Alarm: Room air Sensor Failure/Disconnected') mal_sonda_tac = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 37), integer32()).setLabel('mal-sonda-tac').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_tac.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tac.setDescription('Alarm: Hot water Sensor Failure/Disconnected') mal_sonda_tc = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 38), integer32()).setLabel('mal-sonda-tc').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_tc.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tc.setDescription('Alarm: Condensing water Sensor Failure/Disconnect.') mal_sonda_te = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 39), integer32()).setLabel('mal-sonda-te').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_te.setStatus('current') if mibBuilder.loadTexts: mal_sonda_te.setDescription('Alarm: Outdoor temp. Sensor Failure/Disconnected') mal_sonda_tm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 40), integer32()).setLabel('mal-sonda-tm').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_tm.setStatus('current') if mibBuilder.loadTexts: mal_sonda_tm.setDescription('Alarm: Delivery temp. Sensor Failure/Disconnected') mal_sonda_ua = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 41), integer32()).setLabel('mal-sonda-ua').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_sonda_ua.setStatus('current') if mibBuilder.loadTexts: mal_sonda_ua.setDescription('Alarm: Rel. Humidity Sensor Failure/Disconnected') mal_ore_compr1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 42), integer32()).setLabel('mal-ore-compr1').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_compr1.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr1.setDescription('Service Alarm: Compressor 1 hour counter threshold') mal_ore_compr2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 43), integer32()).setLabel('mal-ore-compr2').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_compr2.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr2.setDescription('Service Alarm: Compressor 2 hour counter threshold') mal_ore_compr3 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 44), integer32()).setLabel('mal-ore-compr3').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_compr3.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr3.setDescription('Service Alarm: Compressor 3 hour counter threshold') mal_ore_compr4 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 45), integer32()).setLabel('mal-ore-compr4').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_compr4.setStatus('current') if mibBuilder.loadTexts: mal_ore_compr4.setDescription('Service Alarm: Compressor 4 hour counter threshold') mal_ore_filtro = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 46), integer32()).setLabel('mal-ore-filtro').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_filtro.setStatus('current') if mibBuilder.loadTexts: mal_ore_filtro.setDescription('Service Alarm: Air Filter hour counter threshold') mal_ore_risc1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 47), integer32()).setLabel('mal-ore-risc1').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_risc1.setStatus('current') if mibBuilder.loadTexts: mal_ore_risc1.setDescription('Service Alarm: Heater 1 hour counter threshold') mal_ore_risc2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 48), integer32()).setLabel('mal-ore-risc2').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_risc2.setStatus('current') if mibBuilder.loadTexts: mal_ore_risc2.setDescription('Service Alarm: Heater 2 hour counter threshold') mal_ore_umid = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 49), integer32()).setLabel('mal-ore-umid').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_umid.setStatus('current') if mibBuilder.loadTexts: mal_ore_umid.setDescription('Service Alarm: Humidifier hour counter threshold') mal_ore_unit = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 50), integer32()).setLabel('mal-ore-unit').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: mal_ore_unit.setStatus('current') if mibBuilder.loadTexts: mal_ore_unit.setDescription('Service Alarm: Unit hour counter threshold') glb_al = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 51), integer32()).setLabel('glb-al').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: glb_al.setStatus('current') if mibBuilder.loadTexts: glb_al.setDescription('General Alarm') or_al_2lev = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 52), integer32()).setLabel('or-al-2lev').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: or_al_2lev.setStatus('current') if mibBuilder.loadTexts: or_al_2lev.setDescription('2nd Level Alarm') range_t_ext = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 53), integer32()).setLabel('range-t-ext').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: range_t_ext.setStatus('current') if mibBuilder.loadTexts: range_t_ext.setDescription('Outdoor Temp. Sensor Fitted') range_t_circ = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 54), integer32()).setLabel('range-t-circ').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: range_t_circ.setStatus('current') if mibBuilder.loadTexts: range_t_circ.setDescription('Closed Circuit (or Chilled) Water Temperature Sensor Fitted') range_t_man = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 55), integer32()).setLabel('range-t-man').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: range_t_man.setStatus('current') if mibBuilder.loadTexts: range_t_man.setDescription('Delivery Temp. Sensor Fitted') range_t_ac = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 56), integer32()).setLabel('range-t-ac').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: range_t_ac.setStatus('current') if mibBuilder.loadTexts: range_t_ac.setDescription('Hot water temp. Sensor Fitted') umid_al = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 57), integer32()).setLabel('umid-al').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: umid_al.setStatus('current') if mibBuilder.loadTexts: umid_al.setDescription('Humidifier general alarm') range_u_amb = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 58), integer32()).setLabel('range-u-amb').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: range_u_amb.setStatus('current') if mibBuilder.loadTexts: range_u_amb.setDescription('Relative Humidity Sensor Fitted') k_syson = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 60), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('k-syson').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: k_syson.setStatus('current') if mibBuilder.loadTexts: k_syson.setDescription('Unit Remote Switch-On/Off Control') xs_res_al = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 61), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('xs-res-al').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: xs_res_al.setStatus('current') if mibBuilder.loadTexts: xs_res_al.setDescription('Buzzer and Alarm Remote Reset Control') sleep_mode = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 63), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('sleep-mode').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: sleep_mode.setStatus('current') if mibBuilder.loadTexts: sleep_mode.setDescription('Set Back Mode (Sleep Mode)') test_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 64), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('test-sm').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: test_sm.setStatus('current') if mibBuilder.loadTexts: test_sm.setDescription('Set Back mode: Cyclical Start of Fan') ab_mediath = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 65), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('ab-mediath').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: ab_mediath.setStatus('current') if mibBuilder.loadTexts: ab_mediath.setDescription('Usage of T+ H Values: Local (0) / Mean (1)') ustdby1_2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 66), integer32().subtype(subtypeSpec=value_range_constraint(0, 1))).setLabel('ustdby1-2').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: ustdby1_2.setStatus('current') if mibBuilder.loadTexts: ustdby1_2.setDescription('No. Of Stand-by Units: one (0) / two (1)') emerg = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 1, 67), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: emerg.setStatus('current') if mibBuilder.loadTexts: emerg.setDescription('Unit in Emergency operation') analog_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2)) temp_amb = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 1), integer32()).setLabel('temp-amb').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: temp_amb.setStatus('current') if mibBuilder.loadTexts: temp_amb.setDescription('Room Temperature') temp_ext = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 2), integer32()).setLabel('temp-ext').setUnits('deg.C x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: temp_ext.setStatus('current') if mibBuilder.loadTexts: temp_ext.setDescription('Outdoor Temperature') temp_mand = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 3), integer32()).setLabel('temp-mand').setUnits('deg.C x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: temp_mand.setStatus('current') if mibBuilder.loadTexts: temp_mand.setDescription('Delivery Air Temperature') temp_circ = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 4), integer32()).setLabel('temp-circ').setUnits('deg.C x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: temp_circ.setStatus('current') if mibBuilder.loadTexts: temp_circ.setDescription('Closed Circuit (or Chilled) Water Temperature') temp_ac = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 5), integer32()).setLabel('temp-ac').setUnits('deg.C x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: temp_ac.setStatus('current') if mibBuilder.loadTexts: temp_ac.setDescription('Hot Water Temperature') umid_amb = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 6), integer32()).setLabel('umid-amb').setUnits('rH% x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: umid_amb.setStatus('current') if mibBuilder.loadTexts: umid_amb.setDescription('Room Relative Humidity') t_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 7), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set').setUnits('deg.C x 10').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set.setStatus('current') if mibBuilder.loadTexts: t_set.setDescription('Cooling Set Point') t_diff = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 8), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-diff').setUnits('deg.C x 10').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_diff.setStatus('current') if mibBuilder.loadTexts: t_diff.setDescription('Cooling Prop.Band') t_set_c = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 9), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set-c').setUnits('deg.C x 10').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set_c.setStatus('current') if mibBuilder.loadTexts: t_set_c.setDescription('Heating Set point') t_diff_c = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 10), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-diff-c').setUnits('deg.C x 10').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_diff_c.setStatus('current') if mibBuilder.loadTexts: t_diff_c.setDescription('Heating Prop.Band') ht_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 11), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('ht-set').setUnits('deg.C').setMaxAccess('readwrite') if mibBuilder.loadTexts: ht_set.setStatus('current') if mibBuilder.loadTexts: ht_set.setDescription('Room High Temp. Alarm Threshold') lt_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 12), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('lt-set').setUnits('deg.C').setMaxAccess('readwrite') if mibBuilder.loadTexts: lt_set.setStatus('current') if mibBuilder.loadTexts: lt_set.setDescription('Room Low Temp. Alarm Threshold') t_set_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 13), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set-sm').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set_sm.setStatus('current') if mibBuilder.loadTexts: t_set_sm.setDescription('Setback Mode: Cooling Set Point') t_set_c_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 14), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set-c-sm').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set_c_sm.setStatus('current') if mibBuilder.loadTexts: t_set_c_sm.setDescription('Setback Mode: Heating Set Point') t_cw_dh = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 15), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-cw-dh').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_cw_dh.setStatus('current') if mibBuilder.loadTexts: t_cw_dh.setDescription('CW Set Point to Start Dehumidification Cycle') htset_cw = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 16), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('htset-cw').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: htset_cw.setStatus('current') if mibBuilder.loadTexts: htset_cw.setDescription('CW High Temperature Alarm Threshold') t_set_cw = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 17), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set-cw').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set_cw.setStatus('current') if mibBuilder.loadTexts: t_set_cw.setDescription('CW Set Point to Start CW Operating Mode (TC only)') t_rc_es = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 18), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-rc-es').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_rc_es.setStatus('current') if mibBuilder.loadTexts: t_rc_es.setDescription('Rad-cooler Set Point in E.S. Mode (ES Only)') t_rc_est = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 19), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-rc-est').setUnits('N/A').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_rc_est.setStatus('current') if mibBuilder.loadTexts: t_rc_est.setDescription('Rad-cooler Set Point in DX Mode (ES Only)') rampa_valv = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 20), integer32()).setLabel('rampa-valv').setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: rampa_valv.setStatus('current') if mibBuilder.loadTexts: rampa_valv.setDescription('0-10V Ramp 1 Value (CW Valve Ramp)') anaout2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 21), integer32()).setUnits('N/A').setMaxAccess('readonly') if mibBuilder.loadTexts: anaout2.setStatus('current') if mibBuilder.loadTexts: anaout2.setDescription('0-10V Ramp 2 Value (HW Valve/Rad Cooler Ramp)') steam_production = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 22), integer32()).setLabel('steam-production').setUnits('kg/h x 10').setMaxAccess('readonly') if mibBuilder.loadTexts: steam_production.setStatus('current') if mibBuilder.loadTexts: steam_production.setDescription('Humidifier: steam capacity') t_set_lm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 23), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-set-lm').setUnits('deg.C').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_set_lm.setStatus('current') if mibBuilder.loadTexts: t_set_lm.setDescription('Delivery Air Temperature Limit Set Point ') delta_lm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 2, 24), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('delta-lm').setUnits('deg.C x 10').setMaxAccess('readwrite') if mibBuilder.loadTexts: delta_lm.setStatus('current') if mibBuilder.loadTexts: delta_lm.setDescription('T+H Values: Mean/Local Diff. (aut. Changeover)') integer_objects = mib_identifier((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3)) ore_filtro = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 1), integer32()).setLabel('ore-filtro').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_filtro.setStatus('current') if mibBuilder.loadTexts: ore_filtro.setDescription('Air Filter Working Houres') ore_unit = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 2), integer32()).setLabel('ore-unit').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_unit.setStatus('current') if mibBuilder.loadTexts: ore_unit.setDescription('Unit Working Houres') ore_compr1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 3), integer32()).setLabel('ore-compr1').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_compr1.setStatus('current') if mibBuilder.loadTexts: ore_compr1.setDescription('Compressor 1 Working Houres') ore_compr2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 4), integer32()).setLabel('ore-compr2').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_compr2.setStatus('current') if mibBuilder.loadTexts: ore_compr2.setDescription('Compressor 2 Working Houres') ore_compr3 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 5), integer32()).setLabel('ore-compr3').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_compr3.setStatus('current') if mibBuilder.loadTexts: ore_compr3.setDescription('Compressor 3 Working Houres') ore_compr4 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 6), integer32()).setLabel('ore-compr4').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_compr4.setStatus('current') if mibBuilder.loadTexts: ore_compr4.setDescription('Compressor 4 Working Houres') ore_heat1 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 7), integer32()).setLabel('ore-heat1').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_heat1.setStatus('current') if mibBuilder.loadTexts: ore_heat1.setDescription('Heater 1 Working Houres') ore_heat2 = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 8), integer32()).setLabel('ore-heat2').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_heat2.setStatus('current') if mibBuilder.loadTexts: ore_heat2.setDescription('Heater 2 Working Houres') ore_umid = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 9), integer32()).setLabel('ore-umid').setUnits('h').setMaxAccess('readonly') if mibBuilder.loadTexts: ore_umid.setStatus('current') if mibBuilder.loadTexts: ore_umid.setDescription('Humidifier Working Houres') hdiff = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 12), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hdiff.setStatus('current') if mibBuilder.loadTexts: hdiff.setDescription('Dehumidification Proportional Band') hu_diff = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 13), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('hu-diff').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hu_diff.setStatus('current') if mibBuilder.loadTexts: hu_diff.setDescription('Humidification Proportional Band') hh_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 14), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('hh-set').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hh_set.setStatus('current') if mibBuilder.loadTexts: hh_set.setDescription('High Relative Humidity Alarm Threshold') lh_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 15), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('lh-set').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: lh_set.setStatus('current') if mibBuilder.loadTexts: lh_set.setDescription('Low Relative Humidity Alarm Threshold') hset = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 16), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hset.setStatus('current') if mibBuilder.loadTexts: hset.setDescription('Dehumidification Set Point') hset_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 17), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('hset-sm').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hset_sm.setStatus('current') if mibBuilder.loadTexts: hset_sm.setDescription('Setback Mode: Dehumidification Set Point') hu_set = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 18), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('hu-set').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hu_set.setStatus('current') if mibBuilder.loadTexts: hu_set.setDescription('Humidification Set Point') hu_set_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 19), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('hu-set-sm').setUnits('rH%').setMaxAccess('readwrite') if mibBuilder.loadTexts: hu_set_sm.setStatus('current') if mibBuilder.loadTexts: hu_set_sm.setDescription('Setback Mode: Humidification Set Point') restart_delay = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 20), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('restart-delay').setUnits('sec').setMaxAccess('readwrite') if mibBuilder.loadTexts: restart_delay.setStatus('current') if mibBuilder.loadTexts: restart_delay.setDescription('Restart Delay') regul_delay = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 21), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('regul-delay').setUnits('sec').setMaxAccess('readwrite') if mibBuilder.loadTexts: regul_delay.setStatus('current') if mibBuilder.loadTexts: regul_delay.setDescription('Regulation Start Transitory ') time_lowp = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 22), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('time-lowp').setUnits('sec').setMaxAccess('readwrite') if mibBuilder.loadTexts: time_lowp.setStatus('current') if mibBuilder.loadTexts: time_lowp.setDescription('Low Pressure Delay') alarm_delay = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 23), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('alarm-delay').setUnits('m').setMaxAccess('readwrite') if mibBuilder.loadTexts: alarm_delay.setStatus('current') if mibBuilder.loadTexts: alarm_delay.setDescription('Room T+H Alarm Delay') exc_time = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 24), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('exc-time').setUnits('m').setMaxAccess('readwrite') if mibBuilder.loadTexts: exc_time.setStatus('current') if mibBuilder.loadTexts: exc_time.setDescription('Anti-Hunting Constant of Room Regulation ') t_std_by = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 25), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('t-std-by').setUnits('h').setMaxAccess('readwrite') if mibBuilder.loadTexts: t_std_by.setStatus('current') if mibBuilder.loadTexts: t_std_by.setDescription('Stand-by Cycle Base Time') lan_unit = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 27), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('lan-unit').setUnits('n').setMaxAccess('readwrite') if mibBuilder.loadTexts: lan_unit.setStatus('current') if mibBuilder.loadTexts: lan_unit.setDescription('Total of units connected in LAN') ciclo_sm = mib_scalar((1, 3, 6, 1, 4, 1, 9839, 2, 1, 3, 28), integer32().subtype(subtypeSpec=value_range_constraint(-32767, 32767))).setLabel('ciclo-sm').setUnits('m').setMaxAccess('readwrite') if mibBuilder.loadTexts: ciclo_sm.setStatus('current') if mibBuilder.loadTexts: ciclo_sm.setDescription('Set Back Mode: Fan Cyclical Start Interval') mibBuilder.exportSymbols('UNCDZ-MIB', ore_compr3=ore_compr3, out_h3=out_h3, mal_smoke=mal_smoke, hset_sm=hset_sm, mal_lp1=mal_lp1, regul_delay=regul_delay, vent_on=vent_on, ore_umid=ore_umid, hset=hset, k_syson=k_syson, t_set_cw=t_set_cw, compressore1=compressore1, lh_set=lh_set, ore_filtro=ore_filtro, out_h2=out_h2, sleep_mode=sleep_mode, mal_sonda_tac=mal_sonda_tac, hu_set=hu_set, umid_al=umid_al, pCOStatusgroup=pCOStatusgroup, mal_wht=mal_wht, ore_compr4=ore_compr4, emerg=emerg, steam_production=steam_production, temp_ac=temp_ac, mal_ore_umid=mal_ore_umid, temp_mand=temp_mand, mal_hp2=mal_hp2, mal_ore_compr3=mal_ore_compr3, pCOId1_ErrorsNumber=pCOId1_ErrorsNumber, temp_circ=temp_circ, mal_aua=mal_aua, mal_cw_dh=mal_cw_dh, mal_ore_unit=mal_ore_unit, t_std_by=t_std_by, mal_ore_compr1=mal_ore_compr1, compressore3=compressore3, range_t_ac=range_t_ac, mal_flux=mal_flux, compressore2=compressore2, mal_sonda_ua=mal_sonda_ua, temp_amb=temp_amb, htset_cw=htset_cw, mal_ore_compr4=mal_ore_compr4, ciclo_sm=ciclo_sm, hh_set=hh_set, out_h1=out_h1, pCOId1_Status=pCOId1_Status, mal_eap=mal_eap, time_lowp=time_lowp, mal_phase=mal_phase, pCOWebInfo=pCOWebInfo, t_diff_c=t_diff_c, power=power, ustdby1_2=ustdby1_2, t_diff=t_diff, mal_flood=mal_flood, mal_sonda_tc=mal_sonda_tc, uncdz_MIB=uncdz_MIB, mal_nopower=mal_nopower, ore_heat2=ore_heat2, mal_tc_cw=mal_tc_cw, t_set_c=t_set_c, integerObjects=integerObjects, ore_compr1=ore_compr1, t_set=t_set, t_rc_est=t_rc_est, compressore4=compressore4, carel=carel, t_set_c_sm=t_set_c_sm, ht_set=ht_set, mal_ore_risc2=mal_ore_risc2, hu_diff=hu_diff, mal_access=mal_access, mal_ore_compr2=mal_ore_compr2, digitalObjects=digitalObjects, pCOErrorsNumbergroup=pCOErrorsNumbergroup, alarm_delay=alarm_delay, mal_heater=mal_heater, on_deum=on_deum, mal_lp2=mal_lp2, rampa_valv=rampa_valv, agentCode=agentCode, t_set_lm=t_set_lm, ore_compr2=ore_compr2, mal_hp1=mal_hp1, mal_ata=mal_ata, ab_mediath=ab_mediath, analogObjects=analogObjects, delta_lm=delta_lm, anaout2=anaout2, mal_lan=mal_lan, gas_caldo_on=gas_caldo_on, exc_time=exc_time, mal_ore_filtro=mal_ore_filtro, test_sm=test_sm, systm=systm, umid_amb=umid_amb, PYSNMP_MODULE_ID=uncdz_MIB, mal_bua=mal_bua, hu_set_sm=hu_set_sm, mal_ore_risc1=mal_ore_risc1, ore_unit=ore_unit, lt_set=lt_set, agentRelease=agentRelease, mal_sonda_ta=mal_sonda_ta, ore_heat1=ore_heat1, range_u_amb=range_u_amb, xs_res_al=xs_res_al, glb_al=glb_al, or_al_2lev=or_al_2lev, mal_bta=mal_bta, t_set_sm=t_set_sm, range_t_man=range_t_man, temp_ext=temp_ext, mal_hcurr=mal_hcurr, mal_wflow=mal_wflow, hdiff=hdiff, lan_unit=lan_unit, restart_delay=restart_delay, mal_nowater=mal_nowater, t_cw_dh=t_cw_dh, mal_filter=mal_filter, range_t_circ=range_t_circ, range_t_ext=range_t_ext, mal_sonda_te=mal_sonda_te, mal_sonda_tm=mal_sonda_tm, instruments=instruments, t_rc_es=t_rc_es)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat May 23 17:49:24 2020 @author: ahmad """ x = [5, 9, 8, -8, 7, 8, 10] #print(x[4]) #for i in range(0,len(x)): # print(x[i]) # write a code to show the sum og the numbers in the Array sum = 0 for i in range(0,len(x)): sum += x[i] print("array sum = " + str(sum)) # write a code to print the max number in the array max = x[0] for i in range(1, len(x)): if max < x[i]: max = x[i] print("array max = " + str(max)) # homework # write a code to print the min number in the array # write a code to print the array avg
""" Created on Sat May 23 17:49:24 2020 @author: ahmad """ x = [5, 9, 8, -8, 7, 8, 10] sum = 0 for i in range(0, len(x)): sum += x[i] print('array sum = ' + str(sum)) max = x[0] for i in range(1, len(x)): if max < x[i]: max = x[i] print('array max = ' + str(max))
"""State: Abstract class that defines the desired state of inventory in a target system""" class State(object): def __init__(self): self.logger = None self.verify_connectivity() def verify_connectivity(self): raise NotImplementedError def set_logger(self): raise NotImplementedError def debug_log(self, log_string): """Pass positional logger arguments to a logger.debug method if a logger instance was instantiated""" if self.logger is not None: self.logger.debug(log_string) def info_log(self, log_string): """Pass positional logger arguments to a loger.info method if a logger instance was instantiated""" if self.logger is not None: self.logger.info(log_string) def __eq__(self, other): raise NotImplementedError("Method not properly implemented") def __ne__(self, other): raise NotImplementedError("Method not properly implemented") def set_state_from_source(self): """Set this state of this instance based on the actual configuration of the target.""" raise NotImplementedError("Method not properly implemented") def set_state_from_config_object(other): """Set the state of this instance and the actual configuration at a target based on a another config object as a model.""" raise NotImplementedError("Method not properly implemented")
"""State: Abstract class that defines the desired state of inventory in a target system""" class State(object): def __init__(self): self.logger = None self.verify_connectivity() def verify_connectivity(self): raise NotImplementedError def set_logger(self): raise NotImplementedError def debug_log(self, log_string): """Pass positional logger arguments to a logger.debug method if a logger instance was instantiated""" if self.logger is not None: self.logger.debug(log_string) def info_log(self, log_string): """Pass positional logger arguments to a loger.info method if a logger instance was instantiated""" if self.logger is not None: self.logger.info(log_string) def __eq__(self, other): raise not_implemented_error('Method not properly implemented') def __ne__(self, other): raise not_implemented_error('Method not properly implemented') def set_state_from_source(self): """Set this state of this instance based on the actual configuration of the target.""" raise not_implemented_error('Method not properly implemented') def set_state_from_config_object(other): """Set the state of this instance and the actual configuration at a target based on a another config object as a model.""" raise not_implemented_error('Method not properly implemented')
class BaseBuilding(object): """ boilder-plate class used to initiale the various building in municipality """ def __init__(self, location=None, land_rate=500): if not isinstance(location, str) and location is not None: raise TypeError("Location should be of type str") if not isinstance(land_rate, (float, int, long)): raise TypeError("Land rate should be of type numeric") self.__location = location self.__land_rate = land_rate def set_location(self, location): if not isinstance(location, str): raise TypeError("Location should be of type str") self.__location = location def set_land_rate(self, land_rate): if not isinstance(land_rate, (float, int, long)): raise TypeError("Land rate should be of type numeric") self.__land_rate = land_rate def get_location(self): return self.__location def get_land_rate(self): return self.__land_rate class CommercialBuilding(BaseBuilding): """ This building provides space for offices and warehouses Land rate is based on the available floor space """ def __init__(self, location=None, floor_space=0): if not isinstance(floor_space, (float, int, long)): raise TypeError("Floor Space should be of type numeric") super(self.__class__, self).__init__(location) self.__floor_space = floor_space def set_floor_space(self, floor_space): self.__floor_space = floor_space def get_floor_space(self): return self.__floor_space def get_land_rate(self): return self.__floor_space * 30 class ResidentialBuilding(BaseBuilding): """ This building that provide space for housing Land rate depends on the numver of availabe units """ def __init__(self, location=None, num_units=0): if not isinstance(num_units, (float, int, long)): raise TypeError("Land rate should be of type numeric") super(self.__class__, self).__init__(location) self.__num_units = num_units def set_num_units(self, num_units): self.__num_units == num_units def get_num_units(self): return self.__num_units def get_land_rate(self): """land rate = num_unit * 20""" return self.__num_units * 20 class Utilities(BaseBuilding): """ This building are owned by the municipality hence pay no land rate """ def __init__(self, location=None, utility_name=None): if not isinstance(utility_name, str) and utility_name is not None: raise TypeError("Utlity hould be of type str") super(self.__class__, self).__init__(location) self.__utility_name = utility_name def set_land_rate(self, land_rate): raise NotImplementedError("Utility Building owned pay no land rate") def set_utility(self, utility_name): self.__utility_name = utility_name def get_utility(self): return self.__utility_name def get_land_rate(self): return 0
class Basebuilding(object): """ boilder-plate class used to initiale the various building in municipality """ def __init__(self, location=None, land_rate=500): if not isinstance(location, str) and location is not None: raise type_error('Location should be of type str') if not isinstance(land_rate, (float, int, long)): raise type_error('Land rate should be of type numeric') self.__location = location self.__land_rate = land_rate def set_location(self, location): if not isinstance(location, str): raise type_error('Location should be of type str') self.__location = location def set_land_rate(self, land_rate): if not isinstance(land_rate, (float, int, long)): raise type_error('Land rate should be of type numeric') self.__land_rate = land_rate def get_location(self): return self.__location def get_land_rate(self): return self.__land_rate class Commercialbuilding(BaseBuilding): """ This building provides space for offices and warehouses Land rate is based on the available floor space """ def __init__(self, location=None, floor_space=0): if not isinstance(floor_space, (float, int, long)): raise type_error('Floor Space should be of type numeric') super(self.__class__, self).__init__(location) self.__floor_space = floor_space def set_floor_space(self, floor_space): self.__floor_space = floor_space def get_floor_space(self): return self.__floor_space def get_land_rate(self): return self.__floor_space * 30 class Residentialbuilding(BaseBuilding): """ This building that provide space for housing Land rate depends on the numver of availabe units """ def __init__(self, location=None, num_units=0): if not isinstance(num_units, (float, int, long)): raise type_error('Land rate should be of type numeric') super(self.__class__, self).__init__(location) self.__num_units = num_units def set_num_units(self, num_units): self.__num_units == num_units def get_num_units(self): return self.__num_units def get_land_rate(self): """land rate = num_unit * 20""" return self.__num_units * 20 class Utilities(BaseBuilding): """ This building are owned by the municipality hence pay no land rate """ def __init__(self, location=None, utility_name=None): if not isinstance(utility_name, str) and utility_name is not None: raise type_error('Utlity hould be of type str') super(self.__class__, self).__init__(location) self.__utility_name = utility_name def set_land_rate(self, land_rate): raise not_implemented_error('Utility Building owned pay no land rate') def set_utility(self, utility_name): self.__utility_name = utility_name def get_utility(self): return self.__utility_name def get_land_rate(self): return 0
"""adds Buffer functionality to Loader""" class BufferMixin(object): """stuff""" def __init__(self, *args, **kwargs): """initializes base data loader""" super(BufferMixin, self).__init__(*args, **kwargs) self._buffered_values = None #set _buffered_values self._reset_buffered_values() def load_buffered(self): """runs load for BufferedMixin""" raise NotImplementedError def flush_buffer(self): """helper method to run statement with set buffered values""" #run statement if there are buffered_values if self._buffered_values: self.load_buffered() self._reset_buffered_values() def write_to_buffer(self, next_values): """appends to buffered values and writes to db when _buffer_size is reached""" self._buffered_values.append(next_values) if len(self._buffered_values) >= self.config.get_buffer_size(): self.flush_buffer() def _reset_buffered_values(self): """resets values to empty tuple""" self._buffered_values = list()
"""adds Buffer functionality to Loader""" class Buffermixin(object): """stuff""" def __init__(self, *args, **kwargs): """initializes base data loader""" super(BufferMixin, self).__init__(*args, **kwargs) self._buffered_values = None self._reset_buffered_values() def load_buffered(self): """runs load for BufferedMixin""" raise NotImplementedError def flush_buffer(self): """helper method to run statement with set buffered values""" if self._buffered_values: self.load_buffered() self._reset_buffered_values() def write_to_buffer(self, next_values): """appends to buffered values and writes to db when _buffer_size is reached""" self._buffered_values.append(next_values) if len(self._buffered_values) >= self.config.get_buffer_size(): self.flush_buffer() def _reset_buffered_values(self): """resets values to empty tuple""" self._buffered_values = list()
NB_GRADER_CONFIG_TEMPLATE = """ c = get_config() c.CourseDirectory.root = '/home/{grader_name}/{course_id}' c.CourseDirectory.course_id = '{course_id}' """
nb_grader_config_template = "\nc = get_config()\n\nc.CourseDirectory.root = '/home/{grader_name}/{course_id}'\nc.CourseDirectory.course_id = '{course_id}'\n"
class Settings: def __init__( self, workdir: str, outdir: str, threads: int, debug: bool): self.workdir = workdir self.outdir = outdir self.threads = threads self.debug = debug class Logger: def __init__(self, name: str): self.name = name def info(self, msg: str): print(msg, flush=True) class Processor: settings: Settings workdir: str outdir: str threads: int debug: bool logger: Logger def __init__(self, settings: Settings): self.settings = settings self.workdir = settings.workdir self.outdir = settings.outdir self.threads = settings.threads self.debug = settings.debug self.logger = Logger(name=self.__class__.__name__)
class Settings: def __init__(self, workdir: str, outdir: str, threads: int, debug: bool): self.workdir = workdir self.outdir = outdir self.threads = threads self.debug = debug class Logger: def __init__(self, name: str): self.name = name def info(self, msg: str): print(msg, flush=True) class Processor: settings: Settings workdir: str outdir: str threads: int debug: bool logger: Logger def __init__(self, settings: Settings): self.settings = settings self.workdir = settings.workdir self.outdir = settings.outdir self.threads = settings.threads self.debug = settings.debug self.logger = logger(name=self.__class__.__name__)
# -*- coding: utf-8 -*- """ Created on Mon Jan 15 01:40:25 2018 @author: kennedy """ #sample --> 'kennedy':'ify1', 'andy': 'best56', 'great': 'op3' #create new user system = {} #database system option = "" def newusers(): uname= input("Enter a username: ") if uname in system: print("User already exit: Create new user") else: pw = input("Enter password: ") system[uname] = pw print("\nUser created: welcome to the network") #login for old users def oldusers(): uname = input("Enter your username:") pw = input("Enter your password: ") if uname in system and system[uname] == pw: print(uname, 'Welcome back') else: print('Login incorrect') #login def login(): #option = {'New': 1, 'Old': 2, 'Exit': 3} option = input("Enter an option: N --> New User, O-->OldUser,E-->Exit ") if option == "N": newusers() elif option == "O": oldusers() elif option == "E": exit #we call the main function if __name__ == "__main__": login()
""" Created on Mon Jan 15 01:40:25 2018 @author: kennedy """ system = {} option = '' def newusers(): uname = input('Enter a username: ') if uname in system: print('User already exit: Create new user') else: pw = input('Enter password: ') system[uname] = pw print('\nUser created: welcome to the network') def oldusers(): uname = input('Enter your username:') pw = input('Enter your password: ') if uname in system and system[uname] == pw: print(uname, 'Welcome back') else: print('Login incorrect') def login(): option = input('Enter an option: N --> New User, O-->OldUser,E-->Exit ') if option == 'N': newusers() elif option == 'O': oldusers() elif option == 'E': exit if __name__ == '__main__': login()
"""Cached evaluation of integrals of monomials over the unit simplex. """ # Integrals of all monomial basis polynomials for the space P_r(R^n) over the n-dimensional unit simplex, # given as a list. monomial_integrals_unit_simplex_all_cache = { # (n, r) = (1, 1) (1, 1): [ 1, 1 / 2 ], # (n, r) = (1, 2) (1, 2): [ 1, 1 / 2, 1 / 3 ], # (n, r) = (1, 3) (1, 3): [ 1, 1 / 2, 1 / 3, 1 / 4 ], # (n, r) = (1, 4) (1, 4): [ 1, 1 / 2, 1 / 3, 1 / 4, 1 / 5 ], # (n, r) = (1, 5) (1, 5): [ 1, 1 / 2, 1 / 3, 1 / 4, 1 / 5, 1 / 6 ], # (n, r) = (1, 6) (1, 6): [ 1, 1 / 2, 1 / 3, 1 / 4, 1 / 5, 1 / 6, 1 / 7 ], # (n, r) = (2, 1) (2, 1): [ 1 / 2, 1 / 6, 1 / 6 ], # (n, r) = (2, 2) (2, 2): [ 1 / 2, 1 / 6, 1 / 12, 1 / 6, 1 / 24, 1 / 12 ], # (n, r) = (2, 3) (2, 3): [ 1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 6, 1 / 24, 1 / 60, 1 / 12, 1 / 60, 1 / 20 ], # (n, r) = (2, 4) (2, 4): [ 1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 12, 1 / 60, 1 / 180, 1 / 20, 1 / 120, 1 / 30 ], # (n, r) = (2, 5) (2, 5): [ 1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 42, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 12, 1 / 60, 1 / 180, 1 / 420, 1 / 20, 1 / 120, 1 / 420, 1 / 30, 1 / 210, 1 / 42 ], # (n, r) = (2, 6) (2, 6): [ 1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 42, 1 / 56, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 12, 1 / 60, 1 / 180, 1 / 420, 1 / 840, 1 / 20, 1 / 120, 1 / 420, 1 / 1120, 1 / 30, 1 / 210, 1 / 840, 1 / 42, 1 / 336, 1 / 56 ], # (n, r) = (3, 1) (3, 1): [ 1 / 6, 1 / 24, 1 / 24, 1 / 24 ], # (n, r) = (3, 2) (3, 2): [ 1 / 6, 1 / 24, 1 / 60, 1 / 24, 1 / 120, 1 / 60, 1 / 24, 1 / 120, 1 / 120, 1 / 60 ], # (n, r) = (3, 3) (3, 3): [ 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 24, 1 / 120, 1 / 360, 1 / 60, 1 / 360, 1 / 120, 1 / 24, 1 / 120, 1 / 360, 1 / 120, 1 / 720, 1 / 360, 1 / 60, 1 / 360, 1 / 360, 1 / 120 ], # (n, r) = (3, 4) (3, 4): [ 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 60, 1 / 360, 1 / 1260, 1 / 120, 1 / 840, 1 / 210, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 120, 1 / 720, 1 / 2520, 1 / 360, 1 / 2520, 1 / 840, 1 / 60, 1 / 360, 1 / 1260, 1 / 360, 1 / 2520, 1 / 1260, 1 / 120, 1 / 840, 1 / 840, 1 / 210 ], # (n, r) = (3, 5) (3, 5): [ 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 120, 1 / 840, 1 / 3360, 1 / 210, 1 / 1680, 1 / 336, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 120, 1 / 720, 1 / 2520, 1 / 6720, 1 / 360, 1 / 2520, 1 / 10080, 1 / 840, 1 / 6720, 1 / 1680, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 360, 1 / 2520, 1 / 10080, 1 / 1260, 1 / 10080, 1 / 3360, 1 / 120, 1 / 840, 1 / 3360, 1 / 840, 1 / 6720, 1 / 3360, 1 / 210, 1 / 1680, 1 / 1680, 1 / 336 ], # (n, r) = (3, 6) (3, 6): [ 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 504, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 3024, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 7560, 1 / 120, 1 / 840, 1 / 3360, 1 / 10080, 1 / 210, 1 / 1680, 1 / 7560, 1 / 336, 1 / 3024, 1 / 504, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 3024, 1 / 120, 1 / 720, 1 / 2520, 1 / 6720, 1 / 15120, 1 / 360, 1 / 2520, 1 / 10080, 1 / 30240, 1 / 840, 1 / 6720, 1 / 30240, 1 / 1680, 1 / 15120, 1 / 3024, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 7560, 1 / 360, 1 / 2520, 1 / 10080, 1 / 30240, 1 / 1260, 1 / 10080, 1 / 45360, 1 / 3360, 1 / 30240, 1 / 7560, 1 / 120, 1 / 840, 1 / 3360, 1 / 10080, 1 / 840, 1 / 6720, 1 / 30240, 1 / 3360, 1 / 30240, 1 / 10080, 1 / 210, 1 / 1680, 1 / 7560, 1 / 1680, 1 / 15120, 1 / 7560, 1 / 336, 1 / 3024, 1 / 3024, 1 / 504 ] } # Integrals of monomial basis polynomials for the space P_r(R^n) over the n-dimensional unit simplex, # given as a dictionary with monomial exponent as key. monomial_integrals_unit_simplex_individual_cache = { # (n, r) = (1, 1) (1, 1): { (0,): 1, (1,): 1 / 2 }, # (n, r) = (1, 2) (1, 2): { (0,): 1, (1,): 1 / 2, (2,): 1 / 3 }, # (n, r) = (1, 3) (1, 3): { (0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4 }, # (n, r) = (1, 4) (1, 4): { (0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5 }, # (n, r) = (1, 5) (1, 5): { (0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5, (5,): 1 / 6 }, # (n, r) = (1, 6) (1, 6): { (0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5, (5,): 1 / 6, (6,): 1 / 7 }, # (n, r) = (2, 1) (2, 1): { (0, 0): 1 / 2, (1, 0): 1 / 6, (0, 1): 1 / 6 }, # (n, r) = (2, 2) (2, 2): { (0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (0, 1): 1 / 6, (1, 1): 1 / 24, (0, 2): 1 / 12 }, # (n, r) = (2, 3) (2, 3): { (0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (0, 2): 1 / 12, (1, 2): 1 / 60, (0, 3): 1 / 20 }, # (n, r) = (2, 4) (2, 4): { (0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (0, 3): 1 / 20, (1, 3): 1 / 120, (0, 4): 1 / 30 }, # (n, r) = (2, 5) (2, 5): { (0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (5, 0): 1 / 42, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (4, 1): 1 / 210, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (3, 2): 1 / 420, (0, 3): 1 / 20, (1, 3): 1 / 120, (2, 3): 1 / 420, (0, 4): 1 / 30, (1, 4): 1 / 210, (0, 5): 1 / 42 }, # (n, r) = (2, 6) (2, 6): { (0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (5, 0): 1 / 42, (6, 0): 1 / 56, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (4, 1): 1 / 210, (5, 1): 1 / 336, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (3, 2): 1 / 420, (4, 2): 1 / 840, (0, 3): 1 / 20, (1, 3): 1 / 120, (2, 3): 1 / 420, (3, 3): 1 / 1120, (0, 4): 1 / 30, (1, 4): 1 / 210, (2, 4): 1 / 840, (0, 5): 1 / 42, (1, 5): 1 / 336, (0, 6): 1 / 56 }, # (n, r) = (3, 1) (3, 1): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (0, 1, 0): 1 / 24, (0, 0, 1): 1 / 24 }, # (n, r) = (3, 2) (3, 2): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (0, 2, 0): 1 / 60, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (0, 1, 1): 1 / 120, (0, 0, 2): 1 / 60 }, # (n, r) = (3, 3) (3, 3): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (0, 3, 0): 1 / 120, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (0, 2, 1): 1 / 360, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (0, 1, 2): 1 / 360, (0, 0, 3): 1 / 120 }, # (n, r) = (3, 4) (3, 4): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (0, 4, 0): 1 / 210, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (0, 3, 1): 1 / 840, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (0, 2, 2): 1 / 1260, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (0, 1, 3): 1 / 840, (0, 0, 4): 1 / 210 }, # (n, r) = (3, 5) (3, 5): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (5, 0, 0): 1 / 336, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (4, 1, 0): 1 / 1680, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (3, 2, 0): 1 / 3360, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (2, 3, 0): 1 / 3360, (0, 4, 0): 1 / 210, (1, 4, 0): 1 / 1680, (0, 5, 0): 1 / 336, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (4, 0, 1): 1 / 1680, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (3, 1, 1): 1 / 6720, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (2, 2, 1): 1 / 10080, (0, 3, 1): 1 / 840, (1, 3, 1): 1 / 6720, (0, 4, 1): 1 / 1680, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (3, 0, 2): 1 / 3360, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (2, 1, 2): 1 / 10080, (0, 2, 2): 1 / 1260, (1, 2, 2): 1 / 10080, (0, 3, 2): 1 / 3360, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (2, 0, 3): 1 / 3360, (0, 1, 3): 1 / 840, (1, 1, 3): 1 / 6720, (0, 2, 3): 1 / 3360, (0, 0, 4): 1 / 210, (1, 0, 4): 1 / 1680, (0, 1, 4): 1 / 1680, (0, 0, 5): 1 / 336 }, # (n, r) = (3, 6) (3, 6): { (0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (5, 0, 0): 1 / 336, (6, 0, 0): 1 / 504, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (4, 1, 0): 1 / 1680, (5, 1, 0): 1 / 3024, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (3, 2, 0): 1 / 3360, (4, 2, 0): 1 / 7560, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (2, 3, 0): 1 / 3360, (3, 3, 0): 1 / 10080, (0, 4, 0): 1 / 210, (1, 4, 0): 1 / 1680, (2, 4, 0): 1 / 7560, (0, 5, 0): 1 / 336, (1, 5, 0): 1 / 3024, (0, 6, 0): 1 / 504, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (4, 0, 1): 1 / 1680, (5, 0, 1): 1 / 3024, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (3, 1, 1): 1 / 6720, (4, 1, 1): 1 / 15120, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (2, 2, 1): 1 / 10080, (3, 2, 1): 1 / 30240, (0, 3, 1): 1 / 840, (1, 3, 1): 1 / 6720, (2, 3, 1): 1 / 30240, (0, 4, 1): 1 / 1680, (1, 4, 1): 1 / 15120, (0, 5, 1): 1 / 3024, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (3, 0, 2): 1 / 3360, (4, 0, 2): 1 / 7560, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (2, 1, 2): 1 / 10080, (3, 1, 2): 1 / 30240, (0, 2, 2): 1 / 1260, (1, 2, 2): 1 / 10080, (2, 2, 2): 1 / 45360, (0, 3, 2): 1 / 3360, (1, 3, 2): 1 / 30240, (0, 4, 2): 1 / 7560, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (2, 0, 3): 1 / 3360, (3, 0, 3): 1 / 10080, (0, 1, 3): 1 / 840, (1, 1, 3): 1 / 6720, (2, 1, 3): 1 / 30240, (0, 2, 3): 1 / 3360, (1, 2, 3): 1 / 30240, (0, 3, 3): 1 / 10080, (0, 0, 4): 1 / 210, (1, 0, 4): 1 / 1680, (2, 0, 4): 1 / 7560, (0, 1, 4): 1 / 1680, (1, 1, 4): 1 / 15120, (0, 2, 4): 1 / 7560, (0, 0, 5): 1 / 336, (1, 0, 5): 1 / 3024, (0, 1, 5): 1 / 3024, (0, 0, 6): 1 / 504 } }
"""Cached evaluation of integrals of monomials over the unit simplex. """ monomial_integrals_unit_simplex_all_cache = {(1, 1): [1, 1 / 2], (1, 2): [1, 1 / 2, 1 / 3], (1, 3): [1, 1 / 2, 1 / 3, 1 / 4], (1, 4): [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5], (1, 5): [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5, 1 / 6], (1, 6): [1, 1 / 2, 1 / 3, 1 / 4, 1 / 5, 1 / 6, 1 / 7], (2, 1): [1 / 2, 1 / 6, 1 / 6], (2, 2): [1 / 2, 1 / 6, 1 / 12, 1 / 6, 1 / 24, 1 / 12], (2, 3): [1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 6, 1 / 24, 1 / 60, 1 / 12, 1 / 60, 1 / 20], (2, 4): [1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 12, 1 / 60, 1 / 180, 1 / 20, 1 / 120, 1 / 30], (2, 5): [1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 42, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 12, 1 / 60, 1 / 180, 1 / 420, 1 / 20, 1 / 120, 1 / 420, 1 / 30, 1 / 210, 1 / 42], (2, 6): [1 / 2, 1 / 6, 1 / 12, 1 / 20, 1 / 30, 1 / 42, 1 / 56, 1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 12, 1 / 60, 1 / 180, 1 / 420, 1 / 840, 1 / 20, 1 / 120, 1 / 420, 1 / 1120, 1 / 30, 1 / 210, 1 / 840, 1 / 42, 1 / 336, 1 / 56], (3, 1): [1 / 6, 1 / 24, 1 / 24, 1 / 24], (3, 2): [1 / 6, 1 / 24, 1 / 60, 1 / 24, 1 / 120, 1 / 60, 1 / 24, 1 / 120, 1 / 120, 1 / 60], (3, 3): [1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 24, 1 / 120, 1 / 360, 1 / 60, 1 / 360, 1 / 120, 1 / 24, 1 / 120, 1 / 360, 1 / 120, 1 / 720, 1 / 360, 1 / 60, 1 / 360, 1 / 360, 1 / 120], (3, 4): [1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 60, 1 / 360, 1 / 1260, 1 / 120, 1 / 840, 1 / 210, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 120, 1 / 720, 1 / 2520, 1 / 360, 1 / 2520, 1 / 840, 1 / 60, 1 / 360, 1 / 1260, 1 / 360, 1 / 2520, 1 / 1260, 1 / 120, 1 / 840, 1 / 840, 1 / 210], (3, 5): [1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 120, 1 / 840, 1 / 3360, 1 / 210, 1 / 1680, 1 / 336, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 120, 1 / 720, 1 / 2520, 1 / 6720, 1 / 360, 1 / 2520, 1 / 10080, 1 / 840, 1 / 6720, 1 / 1680, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 360, 1 / 2520, 1 / 10080, 1 / 1260, 1 / 10080, 1 / 3360, 1 / 120, 1 / 840, 1 / 3360, 1 / 840, 1 / 6720, 1 / 3360, 1 / 210, 1 / 1680, 1 / 1680, 1 / 336], (3, 6): [1 / 6, 1 / 24, 1 / 60, 1 / 120, 1 / 210, 1 / 336, 1 / 504, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 3024, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 7560, 1 / 120, 1 / 840, 1 / 3360, 1 / 10080, 1 / 210, 1 / 1680, 1 / 7560, 1 / 336, 1 / 3024, 1 / 504, 1 / 24, 1 / 120, 1 / 360, 1 / 840, 1 / 1680, 1 / 3024, 1 / 120, 1 / 720, 1 / 2520, 1 / 6720, 1 / 15120, 1 / 360, 1 / 2520, 1 / 10080, 1 / 30240, 1 / 840, 1 / 6720, 1 / 30240, 1 / 1680, 1 / 15120, 1 / 3024, 1 / 60, 1 / 360, 1 / 1260, 1 / 3360, 1 / 7560, 1 / 360, 1 / 2520, 1 / 10080, 1 / 30240, 1 / 1260, 1 / 10080, 1 / 45360, 1 / 3360, 1 / 30240, 1 / 7560, 1 / 120, 1 / 840, 1 / 3360, 1 / 10080, 1 / 840, 1 / 6720, 1 / 30240, 1 / 3360, 1 / 30240, 1 / 10080, 1 / 210, 1 / 1680, 1 / 7560, 1 / 1680, 1 / 15120, 1 / 7560, 1 / 336, 1 / 3024, 1 / 3024, 1 / 504]} monomial_integrals_unit_simplex_individual_cache = {(1, 1): {(0,): 1, (1,): 1 / 2}, (1, 2): {(0,): 1, (1,): 1 / 2, (2,): 1 / 3}, (1, 3): {(0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4}, (1, 4): {(0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5}, (1, 5): {(0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5, (5,): 1 / 6}, (1, 6): {(0,): 1, (1,): 1 / 2, (2,): 1 / 3, (3,): 1 / 4, (4,): 1 / 5, (5,): 1 / 6, (6,): 1 / 7}, (2, 1): {(0, 0): 1 / 2, (1, 0): 1 / 6, (0, 1): 1 / 6}, (2, 2): {(0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (0, 1): 1 / 6, (1, 1): 1 / 24, (0, 2): 1 / 12}, (2, 3): {(0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (0, 2): 1 / 12, (1, 2): 1 / 60, (0, 3): 1 / 20}, (2, 4): {(0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (0, 3): 1 / 20, (1, 3): 1 / 120, (0, 4): 1 / 30}, (2, 5): {(0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (5, 0): 1 / 42, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (4, 1): 1 / 210, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (3, 2): 1 / 420, (0, 3): 1 / 20, (1, 3): 1 / 120, (2, 3): 1 / 420, (0, 4): 1 / 30, (1, 4): 1 / 210, (0, 5): 1 / 42}, (2, 6): {(0, 0): 1 / 2, (1, 0): 1 / 6, (2, 0): 1 / 12, (3, 0): 1 / 20, (4, 0): 1 / 30, (5, 0): 1 / 42, (6, 0): 1 / 56, (0, 1): 1 / 6, (1, 1): 1 / 24, (2, 1): 1 / 60, (3, 1): 1 / 120, (4, 1): 1 / 210, (5, 1): 1 / 336, (0, 2): 1 / 12, (1, 2): 1 / 60, (2, 2): 1 / 180, (3, 2): 1 / 420, (4, 2): 1 / 840, (0, 3): 1 / 20, (1, 3): 1 / 120, (2, 3): 1 / 420, (3, 3): 1 / 1120, (0, 4): 1 / 30, (1, 4): 1 / 210, (2, 4): 1 / 840, (0, 5): 1 / 42, (1, 5): 1 / 336, (0, 6): 1 / 56}, (3, 1): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (0, 1, 0): 1 / 24, (0, 0, 1): 1 / 24}, (3, 2): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (0, 2, 0): 1 / 60, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (0, 1, 1): 1 / 120, (0, 0, 2): 1 / 60}, (3, 3): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (0, 3, 0): 1 / 120, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (0, 2, 1): 1 / 360, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (0, 1, 2): 1 / 360, (0, 0, 3): 1 / 120}, (3, 4): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (0, 4, 0): 1 / 210, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (0, 3, 1): 1 / 840, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (0, 2, 2): 1 / 1260, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (0, 1, 3): 1 / 840, (0, 0, 4): 1 / 210}, (3, 5): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (5, 0, 0): 1 / 336, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (4, 1, 0): 1 / 1680, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (3, 2, 0): 1 / 3360, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (2, 3, 0): 1 / 3360, (0, 4, 0): 1 / 210, (1, 4, 0): 1 / 1680, (0, 5, 0): 1 / 336, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (4, 0, 1): 1 / 1680, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (3, 1, 1): 1 / 6720, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (2, 2, 1): 1 / 10080, (0, 3, 1): 1 / 840, (1, 3, 1): 1 / 6720, (0, 4, 1): 1 / 1680, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (3, 0, 2): 1 / 3360, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (2, 1, 2): 1 / 10080, (0, 2, 2): 1 / 1260, (1, 2, 2): 1 / 10080, (0, 3, 2): 1 / 3360, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (2, 0, 3): 1 / 3360, (0, 1, 3): 1 / 840, (1, 1, 3): 1 / 6720, (0, 2, 3): 1 / 3360, (0, 0, 4): 1 / 210, (1, 0, 4): 1 / 1680, (0, 1, 4): 1 / 1680, (0, 0, 5): 1 / 336}, (3, 6): {(0, 0, 0): 1 / 6, (1, 0, 0): 1 / 24, (2, 0, 0): 1 / 60, (3, 0, 0): 1 / 120, (4, 0, 0): 1 / 210, (5, 0, 0): 1 / 336, (6, 0, 0): 1 / 504, (0, 1, 0): 1 / 24, (1, 1, 0): 1 / 120, (2, 1, 0): 1 / 360, (3, 1, 0): 1 / 840, (4, 1, 0): 1 / 1680, (5, 1, 0): 1 / 3024, (0, 2, 0): 1 / 60, (1, 2, 0): 1 / 360, (2, 2, 0): 1 / 1260, (3, 2, 0): 1 / 3360, (4, 2, 0): 1 / 7560, (0, 3, 0): 1 / 120, (1, 3, 0): 1 / 840, (2, 3, 0): 1 / 3360, (3, 3, 0): 1 / 10080, (0, 4, 0): 1 / 210, (1, 4, 0): 1 / 1680, (2, 4, 0): 1 / 7560, (0, 5, 0): 1 / 336, (1, 5, 0): 1 / 3024, (0, 6, 0): 1 / 504, (0, 0, 1): 1 / 24, (1, 0, 1): 1 / 120, (2, 0, 1): 1 / 360, (3, 0, 1): 1 / 840, (4, 0, 1): 1 / 1680, (5, 0, 1): 1 / 3024, (0, 1, 1): 1 / 120, (1, 1, 1): 1 / 720, (2, 1, 1): 1 / 2520, (3, 1, 1): 1 / 6720, (4, 1, 1): 1 / 15120, (0, 2, 1): 1 / 360, (1, 2, 1): 1 / 2520, (2, 2, 1): 1 / 10080, (3, 2, 1): 1 / 30240, (0, 3, 1): 1 / 840, (1, 3, 1): 1 / 6720, (2, 3, 1): 1 / 30240, (0, 4, 1): 1 / 1680, (1, 4, 1): 1 / 15120, (0, 5, 1): 1 / 3024, (0, 0, 2): 1 / 60, (1, 0, 2): 1 / 360, (2, 0, 2): 1 / 1260, (3, 0, 2): 1 / 3360, (4, 0, 2): 1 / 7560, (0, 1, 2): 1 / 360, (1, 1, 2): 1 / 2520, (2, 1, 2): 1 / 10080, (3, 1, 2): 1 / 30240, (0, 2, 2): 1 / 1260, (1, 2, 2): 1 / 10080, (2, 2, 2): 1 / 45360, (0, 3, 2): 1 / 3360, (1, 3, 2): 1 / 30240, (0, 4, 2): 1 / 7560, (0, 0, 3): 1 / 120, (1, 0, 3): 1 / 840, (2, 0, 3): 1 / 3360, (3, 0, 3): 1 / 10080, (0, 1, 3): 1 / 840, (1, 1, 3): 1 / 6720, (2, 1, 3): 1 / 30240, (0, 2, 3): 1 / 3360, (1, 2, 3): 1 / 30240, (0, 3, 3): 1 / 10080, (0, 0, 4): 1 / 210, (1, 0, 4): 1 / 1680, (2, 0, 4): 1 / 7560, (0, 1, 4): 1 / 1680, (1, 1, 4): 1 / 15120, (0, 2, 4): 1 / 7560, (0, 0, 5): 1 / 336, (1, 0, 5): 1 / 3024, (0, 1, 5): 1 / 3024, (0, 0, 6): 1 / 504}}
#import base64 # #data = "abc123!?$*&()'-=@~" # ## Standard Base64 Encoding #encodedBytes = base64.b64encode(data.encode("utf-8")) #encodedStr = str(encodedBytes, "utf-8") # #print(encodedStr) # l = [x for x in range(10)] for x in range(10): l.pop(0) print(l)
l = [x for x in range(10)] for x in range(10): l.pop(0) print(l)
load(":collection_results.bzl", "collection_results") load(":collect_module_members.bzl", "collect_module_members") load(":declarations.bzl", "declarations") load(":errors.bzl", "errors") load(":tokens.bzl", "tokens", rws = "reserved_words", tts = "token_types") # MARK: - Attribute Collection def _collect_attribute(parsed_tokens): """Collect a module attribute. Spec: https://clang.llvm.org/docs/Modules.html#attributes Syntax: attributes: attribute attributesopt attribute: '[' identifier ']' Args: parsed_tokens: A `list` of tokens. Returns: A `tuple` where the first item is the collection result and the second is an error `struct` as returned from errors.create(). """ tlen = len(parsed_tokens) open_token, err = tokens.get_as(parsed_tokens, 0, tts.square_bracket_open, count = tlen) if err != None: return None, err attrib_token, err = tokens.get_as(parsed_tokens, 1, tts.identifier, count = tlen) if err != None: return None, err open_token, err = tokens.get_as(parsed_tokens, 2, tts.square_bracket_close, count = tlen) if err != None: return None, err return collection_results.new([attrib_token.value], 3), None # MARK: - Module Collection def collect_module(parsed_tokens, is_submodule = False, prefix_tokens = []): """Collect a module declaration. Spec: https://clang.llvm.org/docs/Modules.html#module-declaration Syntax: explicitopt frameworkopt module module-id attributesopt '{' module-member* '}' Args: parsed_tokens: A `list` of tokens. is_submodule: A `bool` that designates whether the module is a child of another module. prefix_tokens: A `list` of tokens that have already been collected, but not applied. Returns: A `tuple` where the first item is the collection result and the second is an error `struct` as returned from errors.create(). """ explicit = False framework = False attributes = [] members = [] consumed_count = 0 tlen = len(parsed_tokens) # Process the prefix tokens for token in prefix_tokens: if token.type == tts.reserved and token.value == rws.explicit: if not is_submodule: return None, errors.new("The explicit qualifier can only exist on submodules.") explicit = True elif token.type == tts.reserved and token.value == rws.framework: framework = True else: return None, errors.new( "Unexpected prefix token collecting module declaration. token: %s" % (token), ) module_token, err = tokens.get_as(parsed_tokens, 0, tts.reserved, rws.module, count = tlen) if err != None: return None, err consumed_count += 1 module_id_token, err = tokens.get_as(parsed_tokens, 1, tts.identifier, count = tlen) if err != None: return None, err consumed_count += 1 # Collect the attributes and module members skip_ahead = 0 collect_result = None for idx in range(consumed_count, tlen - consumed_count): consumed_count += 1 if skip_ahead > 0: skip_ahead -= 1 continue collect_result = None err = None # Get next token token, err = tokens.get(parsed_tokens, idx, count = tlen) if err != None: return None, err # Process the token if tokens.is_a(token, tts.curly_bracket_open): collect_result, err = collect_module_members(parsed_tokens[idx:]) if err != None: return None, err members.extend(collect_result.declarations) elif tokens.is_a(token, tts.square_bracket_open): collect_result, err = _collect_attribute(parsed_tokens[idx:]) if err != None: return None, err attributes.extend(collect_result.declarations) else: return None, errors.new( "Unexpected token collecting attributes and module members. token: %s" % (token), ) # Handle index advancement. if collect_result: skip_ahead = collect_result.count - 1 # Create the declaration decl = declarations.module( module_id = module_id_token.value, explicit = explicit, framework = framework, attributes = attributes, members = members, ) return collection_results.new([decl], consumed_count), None
load(':collection_results.bzl', 'collection_results') load(':collect_module_members.bzl', 'collect_module_members') load(':declarations.bzl', 'declarations') load(':errors.bzl', 'errors') load(':tokens.bzl', 'tokens', rws='reserved_words', tts='token_types') def _collect_attribute(parsed_tokens): """Collect a module attribute. Spec: https://clang.llvm.org/docs/Modules.html#attributes Syntax: attributes: attribute attributesopt attribute: '[' identifier ']' Args: parsed_tokens: A `list` of tokens. Returns: A `tuple` where the first item is the collection result and the second is an error `struct` as returned from errors.create(). """ tlen = len(parsed_tokens) (open_token, err) = tokens.get_as(parsed_tokens, 0, tts.square_bracket_open, count=tlen) if err != None: return (None, err) (attrib_token, err) = tokens.get_as(parsed_tokens, 1, tts.identifier, count=tlen) if err != None: return (None, err) (open_token, err) = tokens.get_as(parsed_tokens, 2, tts.square_bracket_close, count=tlen) if err != None: return (None, err) return (collection_results.new([attrib_token.value], 3), None) def collect_module(parsed_tokens, is_submodule=False, prefix_tokens=[]): """Collect a module declaration. Spec: https://clang.llvm.org/docs/Modules.html#module-declaration Syntax: explicitopt frameworkopt module module-id attributesopt '{' module-member* '}' Args: parsed_tokens: A `list` of tokens. is_submodule: A `bool` that designates whether the module is a child of another module. prefix_tokens: A `list` of tokens that have already been collected, but not applied. Returns: A `tuple` where the first item is the collection result and the second is an error `struct` as returned from errors.create(). """ explicit = False framework = False attributes = [] members = [] consumed_count = 0 tlen = len(parsed_tokens) for token in prefix_tokens: if token.type == tts.reserved and token.value == rws.explicit: if not is_submodule: return (None, errors.new('The explicit qualifier can only exist on submodules.')) explicit = True elif token.type == tts.reserved and token.value == rws.framework: framework = True else: return (None, errors.new('Unexpected prefix token collecting module declaration. token: %s' % token)) (module_token, err) = tokens.get_as(parsed_tokens, 0, tts.reserved, rws.module, count=tlen) if err != None: return (None, err) consumed_count += 1 (module_id_token, err) = tokens.get_as(parsed_tokens, 1, tts.identifier, count=tlen) if err != None: return (None, err) consumed_count += 1 skip_ahead = 0 collect_result = None for idx in range(consumed_count, tlen - consumed_count): consumed_count += 1 if skip_ahead > 0: skip_ahead -= 1 continue collect_result = None err = None (token, err) = tokens.get(parsed_tokens, idx, count=tlen) if err != None: return (None, err) if tokens.is_a(token, tts.curly_bracket_open): (collect_result, err) = collect_module_members(parsed_tokens[idx:]) if err != None: return (None, err) members.extend(collect_result.declarations) elif tokens.is_a(token, tts.square_bracket_open): (collect_result, err) = _collect_attribute(parsed_tokens[idx:]) if err != None: return (None, err) attributes.extend(collect_result.declarations) else: return (None, errors.new('Unexpected token collecting attributes and module members. token: %s' % token)) if collect_result: skip_ahead = collect_result.count - 1 decl = declarations.module(module_id=module_id_token.value, explicit=explicit, framework=framework, attributes=attributes, members=members) return (collection_results.new([decl], consumed_count), None)
f = open('input.txt') adapters = [] for line in f: adapters.append(int(line[:-1])) adapters.sort() adapters.append(adapters[-1] + 3) differences = {} previous = 0 for adapter in adapters: current_difference = adapter - previous if not current_difference in differences: differences[current_difference] = 0 differences[current_difference] += 1 previous = adapter print(differences[1] * differences[3])
f = open('input.txt') adapters = [] for line in f: adapters.append(int(line[:-1])) adapters.sort() adapters.append(adapters[-1] + 3) differences = {} previous = 0 for adapter in adapters: current_difference = adapter - previous if not current_difference in differences: differences[current_difference] = 0 differences[current_difference] += 1 previous = adapter print(differences[1] * differences[3])
class Solution: def peakIndexInMountainArray(self, A): """ :type A: List[int] :rtype: int """ A_new = sorted(A) return A.index(A_new[-1]) # # other solutions # # 1. # class Solution: # def peakIndexInMountainArray(self, A): # """ # :type A: List[int] # :rtype: int # """ # for i in range(len(A)-1): # if A[i]>A[i+1]: # return i # # # # # 2. binary search # class Solution: # def peakIndexInMountainArray(self, A): # """ # :type A: List[int] # :rtype: int # """ # l=0 # r=len(A)-1 # while l<r: # mid = int((l+r)/2) # if A[mid-1]>A[mid]: # r = mid # elif A[mid]<A[mid+1]: # l = mid # else: # return mid # # # # 3. one line python # class Solution: # def peakIndexInMountainArray(self, A): # """ # :type A: List[int] # :rtype: int # """ # return A.index(max(A)) A = [0, 1, 0] A = [0, 2, 1, 0] sol = Solution() res = sol.peakIndexInMountainArray(A) print(res)
class Solution: def peak_index_in_mountain_array(self, A): """ :type A: List[int] :rtype: int """ a_new = sorted(A) return A.index(A_new[-1]) a = [0, 1, 0] a = [0, 2, 1, 0] sol = solution() res = sol.peakIndexInMountainArray(A) print(res)
# LinkNode/Marker ID Table # -1: Unassigned (Temporary) # 0 ~ 50: Reserved for Joint ID # FRAME_ID = 'viz_frame'
frame_id = 'viz_frame'
""" strategy_observer.py Copyright 2015 Andres Riancho This file is part of w3af, http://w3af.org/ . w3af is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License. w3af is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with w3af; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ class StrategyObserver(object): """ When you want to listen to the activity inside the CoreStrategy simply inherit from this class and call CoreStrategy.add_observer(). When the scan runs the methods in this class are called. """ def crawl(self, craw_consumer, fuzzable_request): pass def audit(self, audit_consumer, fuzzable_request): pass def bruteforce(self, bruteforce_consumer, fuzzable_request): pass def grep(self, grep_consumer, request, response): pass def end(self): """ Called when the strategy is about to end, useful for clearing memory, removing temp files, stopping threads, etc. :return: None """ pass
""" strategy_observer.py Copyright 2015 Andres Riancho This file is part of w3af, http://w3af.org/ . w3af is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License. w3af is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with w3af; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ class Strategyobserver(object): """ When you want to listen to the activity inside the CoreStrategy simply inherit from this class and call CoreStrategy.add_observer(). When the scan runs the methods in this class are called. """ def crawl(self, craw_consumer, fuzzable_request): pass def audit(self, audit_consumer, fuzzable_request): pass def bruteforce(self, bruteforce_consumer, fuzzable_request): pass def grep(self, grep_consumer, request, response): pass def end(self): """ Called when the strategy is about to end, useful for clearing memory, removing temp files, stopping threads, etc. :return: None """ pass
VBA = \ r""" Function ExecuteCmdSync(targetPath As String) 'Run a shell command, returning the output as a string' ' Using a hidden window, pipe the output of the command to the CLIP.EXE utility... ' Necessary because normal usage with oShell.Exec("cmd.exe /C " & sCmd) always pops a windows Dim instruction As String instruction = "cmd.exe /c " & targetPath & " | clip" On Error Resume Next Err.Clear CreateObject("WScript.Shell").Run instruction, 0, True On Error Goto 0 ' Read the clipboard text using htmlfile object ExecuteCmdSync = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text") End Function """
vba = '\n\nFunction ExecuteCmdSync(targetPath As String)\n \'Run a shell command, returning the output as a string\'\n \' Using a hidden window, pipe the output of the command to the CLIP.EXE utility...\n \' Necessary because normal usage with oShell.Exec("cmd.exe /C " & sCmd) always pops a windows\n Dim instruction As String\n instruction = "cmd.exe /c " & targetPath & " | clip"\n \n On Error Resume Next\n Err.Clear\n CreateObject("WScript.Shell").Run instruction, 0, True\n On Error Goto 0\n \n \' Read the clipboard text using htmlfile object\n ExecuteCmdSync = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")\n\nEnd Function\n\n\n'
''' Statement Given a list of numbers, find and print the elements that appear in it only once. Such elements should be printed in the order in which they occur in the original list. Example input 4 3 5 2 5 1 3 5 Example output 4 2 1 ''' arr = input().split() for i in arr: if arr.count(i) == 1: print(i, end=" ")
""" Statement Given a list of numbers, find and print the elements that appear in it only once. Such elements should be printed in the order in which they occur in the original list. Example input 4 3 5 2 5 1 3 5 Example output 4 2 1 """ arr = input().split() for i in arr: if arr.count(i) == 1: print(i, end=' ')
class Source: pass class URL(Source): def __init__(self, url, method="GET", data=None): self.url = url self.method = method self.data = data def get_data(self, scraper): return scraper.request(method=self.method, url=self.url, data=self.data).content def __str__(self): return self.url class NullSource(Source): def get_data(self, scraper): return None def __str__(self): return self.__class__.__name__
class Source: pass class Url(Source): def __init__(self, url, method='GET', data=None): self.url = url self.method = method self.data = data def get_data(self, scraper): return scraper.request(method=self.method, url=self.url, data=self.data).content def __str__(self): return self.url class Nullsource(Source): def get_data(self, scraper): return None def __str__(self): return self.__class__.__name__
fs = 44100. dt = 1. / fs def rawsco_to_ndf(rawsco): clock, rate, nsamps, score = rawsco if rate == 44100: ar = True else: ar = False max_i = score.shape[0] samp = 0 t = 0. # ('apu', ch, func, func_val, natoms, offset) ndf = [ ('clock', int(clock)), ('apu', 'ch', 'p1', 0, 0, 0), ('apu', 'ch', 'p2', 0, 0, 0), ('apu', 'ch', 'tr', 0, 0, 0), ('apu', 'ch', 'no', 0, 0, 0), ('apu', 'p1', 'du', 0, 1, 0), ('apu', 'p1', 'lh', 1, 1, 0), ('apu', 'p1', 'cv', 1, 1, 0), ('apu', 'p1', 'vo', 0, 1, 0), ('apu', 'p1', 'ss', 7, 2, 1), # This is necessary to prevent channel silence for low notes ('apu', 'p2', 'du', 0, 3, 0), ('apu', 'p2', 'lh', 1, 3, 0), ('apu', 'p2', 'cv', 1, 3, 0), ('apu', 'p2', 'vo', 0, 3, 0), ('apu', 'p2', 'ss', 7, 4, 1), # This is necessary to prevent channel silence for low notes ('apu', 'tr', 'lh', 1, 5, 0), ('apu', 'tr', 'lr', 127, 5, 0), ('apu', 'no', 'lh', 1, 6, 0), ('apu', 'no', 'cv', 1, 6, 0), ('apu', 'no', 'vo', 0, 6, 0), ] ch_to_last_tl = {ch:0 for ch in ['p1', 'p2']} ch_to_last_th = {ch:0 for ch in ['p1', 'p2']} ch_to_last_timer = {ch:0 for ch in ['p1', 'p2', 'tr']} ch_to_last_du = {ch:0 for ch in ['p1', 'p2']} ch_to_last_volume = {ch:0 for ch in ['p1', 'p2', 'no']} last_no_np = 0 last_no_nl = 0 for i in range(max_i): for j, ch in enumerate(['p1', 'p2']): th, tl, volume, du = score[i, j] timer = (th << 8) + tl last_timer = ch_to_last_timer[ch] # NOTE: This will never be perfect reconstruction because phase is not incremented when the channel is off retrigger = False if last_timer == 0 and timer != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) retrigger = True elif last_timer != 0 and timer == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if du != ch_to_last_du[ch]: ndf.append(('apu', ch, 'du', du, 0, 0)) ch_to_last_du[ch] = du if volume > 0 and volume != ch_to_last_volume[ch]: ndf.append(('apu', ch, 'vo', volume, 0, 0)) ch_to_last_volume[ch] = volume if tl != ch_to_last_tl[ch]: ndf.append(('apu', ch, 'tl', tl, 0, 2)) ch_to_last_tl[ch] = tl if retrigger or th != ch_to_last_th[ch]: ndf.append(('apu', ch, 'th', th, 0, 3)) ch_to_last_th[ch] = th ch_to_last_timer[ch] = timer j = 2 ch = 'tr' th, tl, _, _ = score[i, j] timer = (th << 8) + tl last_timer = ch_to_last_timer[ch] if last_timer == 0 and timer != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) elif last_timer != 0 and timer == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if timer != last_timer: ndf.append(('apu', ch, 'tl', tl, 0, 2)) ndf.append(('apu', ch, 'th', th, 0, 3)) ch_to_last_timer[ch] = timer j = 3 ch = 'no' _, np, volume, nl = score[i, j] if last_no_np == 0 and np != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) elif last_no_np != 0 and np == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if volume > 0 and volume != ch_to_last_volume[ch]: ndf.append(('apu', ch, 'vo', volume, 0, 0)) ch_to_last_volume[ch] = volume if nl != last_no_nl: ndf.append(('apu', ch, 'nl', nl, 0, 2)) last_no_nl = nl if np > 0 and np != last_no_np: ndf.append(('apu', ch, 'np', 16 - np, 0, 2)) ndf.append(('apu', ch, 'll', 0, 0, 3)) last_no_np = np if ar: wait_amt = 1 else: t += 1. / rate wait_amt = min(int(fs * t) - samp, nsamps - samp) ndf.append(('wait', wait_amt)) samp += wait_amt remaining = nsamps - samp assert remaining >= 0 if remaining > 0: ndf.append(('wait', remaining)) return ndf
fs = 44100.0 dt = 1.0 / fs def rawsco_to_ndf(rawsco): (clock, rate, nsamps, score) = rawsco if rate == 44100: ar = True else: ar = False max_i = score.shape[0] samp = 0 t = 0.0 ndf = [('clock', int(clock)), ('apu', 'ch', 'p1', 0, 0, 0), ('apu', 'ch', 'p2', 0, 0, 0), ('apu', 'ch', 'tr', 0, 0, 0), ('apu', 'ch', 'no', 0, 0, 0), ('apu', 'p1', 'du', 0, 1, 0), ('apu', 'p1', 'lh', 1, 1, 0), ('apu', 'p1', 'cv', 1, 1, 0), ('apu', 'p1', 'vo', 0, 1, 0), ('apu', 'p1', 'ss', 7, 2, 1), ('apu', 'p2', 'du', 0, 3, 0), ('apu', 'p2', 'lh', 1, 3, 0), ('apu', 'p2', 'cv', 1, 3, 0), ('apu', 'p2', 'vo', 0, 3, 0), ('apu', 'p2', 'ss', 7, 4, 1), ('apu', 'tr', 'lh', 1, 5, 0), ('apu', 'tr', 'lr', 127, 5, 0), ('apu', 'no', 'lh', 1, 6, 0), ('apu', 'no', 'cv', 1, 6, 0), ('apu', 'no', 'vo', 0, 6, 0)] ch_to_last_tl = {ch: 0 for ch in ['p1', 'p2']} ch_to_last_th = {ch: 0 for ch in ['p1', 'p2']} ch_to_last_timer = {ch: 0 for ch in ['p1', 'p2', 'tr']} ch_to_last_du = {ch: 0 for ch in ['p1', 'p2']} ch_to_last_volume = {ch: 0 for ch in ['p1', 'p2', 'no']} last_no_np = 0 last_no_nl = 0 for i in range(max_i): for (j, ch) in enumerate(['p1', 'p2']): (th, tl, volume, du) = score[i, j] timer = (th << 8) + tl last_timer = ch_to_last_timer[ch] retrigger = False if last_timer == 0 and timer != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) retrigger = True elif last_timer != 0 and timer == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if du != ch_to_last_du[ch]: ndf.append(('apu', ch, 'du', du, 0, 0)) ch_to_last_du[ch] = du if volume > 0 and volume != ch_to_last_volume[ch]: ndf.append(('apu', ch, 'vo', volume, 0, 0)) ch_to_last_volume[ch] = volume if tl != ch_to_last_tl[ch]: ndf.append(('apu', ch, 'tl', tl, 0, 2)) ch_to_last_tl[ch] = tl if retrigger or th != ch_to_last_th[ch]: ndf.append(('apu', ch, 'th', th, 0, 3)) ch_to_last_th[ch] = th ch_to_last_timer[ch] = timer j = 2 ch = 'tr' (th, tl, _, _) = score[i, j] timer = (th << 8) + tl last_timer = ch_to_last_timer[ch] if last_timer == 0 and timer != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) elif last_timer != 0 and timer == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if timer != last_timer: ndf.append(('apu', ch, 'tl', tl, 0, 2)) ndf.append(('apu', ch, 'th', th, 0, 3)) ch_to_last_timer[ch] = timer j = 3 ch = 'no' (_, np, volume, nl) = score[i, j] if last_no_np == 0 and np != 0: ndf.append(('apu', 'ch', ch, 1, 0, 0)) elif last_no_np != 0 and np == 0: ndf.append(('apu', 'ch', ch, 0, 0, 0)) if volume > 0 and volume != ch_to_last_volume[ch]: ndf.append(('apu', ch, 'vo', volume, 0, 0)) ch_to_last_volume[ch] = volume if nl != last_no_nl: ndf.append(('apu', ch, 'nl', nl, 0, 2)) last_no_nl = nl if np > 0 and np != last_no_np: ndf.append(('apu', ch, 'np', 16 - np, 0, 2)) ndf.append(('apu', ch, 'll', 0, 0, 3)) last_no_np = np if ar: wait_amt = 1 else: t += 1.0 / rate wait_amt = min(int(fs * t) - samp, nsamps - samp) ndf.append(('wait', wait_amt)) samp += wait_amt remaining = nsamps - samp assert remaining >= 0 if remaining > 0: ndf.append(('wait', remaining)) return ndf
#Write a program to input a string and check if it is a palindrome or not. #This solution is in python programing language str = input("Enter the string: ") if str == str[::-1]: print("String is Palindrome") else: print("String is not Palindrome")
str = input('Enter the string: ') if str == str[::-1]: print('String is Palindrome') else: print('String is not Palindrome')
buddy= "extremely loyal and cute" print(len(buddy)) print(buddy[0]) print(buddy[0:10]) print(buddy[0:]) print(buddy[:15]) print(buddy[:]) # len gives you the length or number of characters of the string. # So (len(buddy)) when printed = 24 as even spaces are counted. # [] these brackets help to dissect the components of the string. # so (buddy[0]) = e # so (buddy[0:10]) = extremely # so (buddy[0:]) = extremely loyal and cute # so (buddy[:15]) = extremely loyal # so (buddy[:]) = extremely loyal and print(buddy[-1]) # so print(buddy[-1]) = e print(buddy[-2]) print(buddy[-5:2]) # so print(buddy[-2]) = t
buddy = 'extremely loyal and cute' print(len(buddy)) print(buddy[0]) print(buddy[0:10]) print(buddy[0:]) print(buddy[:15]) print(buddy[:]) print(buddy[-1]) print(buddy[-2]) print(buddy[-5:2])
class Secret: # Dajngo secret key SECRET_KEY = '' # Amazone S3 AWS_STORAGE_BUCKET_NAME = '' AWS_ACCESS_KEY_ID = '' AWS_SECRET_ACCESS_KEY = ''
class Secret: secret_key = '' aws_storage_bucket_name = '' aws_access_key_id = '' aws_secret_access_key = ''
""" leetcode 232 Stack implementation Queue """ def __init__(self): self.instack = [] self.outstack = [] def push(self, x: int) -> None: self.instack.append(x) def pop(self) -> int: if not self.outstack: while self.instack: self.outstack.append(self.instack.pop()) return self.outstack.pop() def peek(self) -> int: if not self.outstack: while self.instack: self.outstack.append(self.instack.pop()) return self.outstack[-1] def empty(self) -> bool: if not self.instack and not self.outstack: return True return False
""" leetcode 232 Stack implementation Queue """ def __init__(self): self.instack = [] self.outstack = [] def push(self, x: int) -> None: self.instack.append(x) def pop(self) -> int: if not self.outstack: while self.instack: self.outstack.append(self.instack.pop()) return self.outstack.pop() def peek(self) -> int: if not self.outstack: while self.instack: self.outstack.append(self.instack.pop()) return self.outstack[-1] def empty(self) -> bool: if not self.instack and (not self.outstack): return True return False
class MessageHandler: def __init__(self, name: str): self.name = name self.broker = None def process_message(self, data: bytes): pass
class Messagehandler: def __init__(self, name: str): self.name = name self.broker = None def process_message(self, data: bytes): pass
self.description = "Sysupgrade with same version, different epochs" sp = pmpkg("dummy", "2:2.0-1") sp.files = ["bin/dummynew"] self.addpkg2db("sync", sp) lp = pmpkg("dummy", "1:2.0-1") lp.files = ["bin/dummyold"] self.addpkg2db("local", lp) self.args = "-Su" self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=dummy|2:2.0-1") self.addrule("FILE_EXIST=bin/dummynew") self.addrule("!FILE_EXIST=bin/dummyold")
self.description = 'Sysupgrade with same version, different epochs' sp = pmpkg('dummy', '2:2.0-1') sp.files = ['bin/dummynew'] self.addpkg2db('sync', sp) lp = pmpkg('dummy', '1:2.0-1') lp.files = ['bin/dummyold'] self.addpkg2db('local', lp) self.args = '-Su' self.addrule('PACMAN_RETCODE=0') self.addrule('PKG_VERSION=dummy|2:2.0-1') self.addrule('FILE_EXIST=bin/dummynew') self.addrule('!FILE_EXIST=bin/dummyold')
def commonCharacterCount(s1, s2): dic1 = {} dic2 = {} sums = 0 for letter in s1: dic1[letter] = dic1.get(letter,0) + 1 for letter in s2: dic2[letter] = dic2.get(letter,0) + 1 for letter in dic1: if letter in dic2: sums = sums + min(dic1[letter],dic2[letter]) return sums
def common_character_count(s1, s2): dic1 = {} dic2 = {} sums = 0 for letter in s1: dic1[letter] = dic1.get(letter, 0) + 1 for letter in s2: dic2[letter] = dic2.get(letter, 0) + 1 for letter in dic1: if letter in dic2: sums = sums + min(dic1[letter], dic2[letter]) return sums
class QuickReplyButton: def __init__(self, title: str, payload: str): if not isinstance(title, str): raise TypeError("QuickReplyButton.title must be an instance of str") if not isinstance(payload, str): raise TypeError("QuickReplyButton.payload must be an instance of str") self.title = title self.payload = payload def to_dict(self): return { "content_type": "text", "title": self.title, "payload": self.payload } class QuickReply: def __init__(self): self.buttons = [] def add(self, button: QuickReplyButton): if not isinstance(button, QuickReplyButton): raise TypeError("button must be an instance of QuickReplyButton") self.buttons.append(button) def to_dict(self): return [button.to_dict() for button in self.buttons] class Button: def __init__(self, type: str, title: str, **kwargs): if not isinstance(title, str): raise TypeError("Button.title must be an instance of str") if not isinstance(type, str): raise TypeError("Button.type must be an instance of str") self.title = title self.type = type for k in kwargs: setattr(self, k, kwargs[k]) def to_dict(self): return dict(vars(self)) class Template: def __init__(self, type: str, text: str, **kwargs): if not isinstance(type, str): raise TypeError("Template.type must be an instance of str") if not isinstance(text, str): raise TypeError("Template.text must be an instance of str") self.type = type self.text = text for k in kwargs: setattr(self, k, kwargs[k]) def to_dict(self): res = { "type": "template", "payload": { "template_type": self.type, "text": self.text } } if hasattr(self, 'buttons'): res['payload'].update({"buttons": [b.to_dict() for b in self.buttons]}) return res class Message: def __init__(self, text: str = None, quick_reply: QuickReply = None, attachment=None): if text and not isinstance(text, str): raise TypeError("Message.text must be an instance of str") if quick_reply and not isinstance(quick_reply, QuickReply): raise TypeError("Message.quick_reply must be an instance of QuickReply") self.text = text self.quick_reply = quick_reply self.attachment = attachment def set_quick_reply(self, quick_reply): if not isinstance(quick_reply, QuickReply): raise TypeError("Message.quick_reply must be an instance of QuickReply") self.quick_reply = quick_reply def to_dict(self): msg = {} if self.text: msg['text'] = self.text if self.quick_reply: msg['quick_replies'] = self.quick_reply.to_dict() if self.attachment: msg['attachment'] = self.attachment.to_dict() return msg
class Quickreplybutton: def __init__(self, title: str, payload: str): if not isinstance(title, str): raise type_error('QuickReplyButton.title must be an instance of str') if not isinstance(payload, str): raise type_error('QuickReplyButton.payload must be an instance of str') self.title = title self.payload = payload def to_dict(self): return {'content_type': 'text', 'title': self.title, 'payload': self.payload} class Quickreply: def __init__(self): self.buttons = [] def add(self, button: QuickReplyButton): if not isinstance(button, QuickReplyButton): raise type_error('button must be an instance of QuickReplyButton') self.buttons.append(button) def to_dict(self): return [button.to_dict() for button in self.buttons] class Button: def __init__(self, type: str, title: str, **kwargs): if not isinstance(title, str): raise type_error('Button.title must be an instance of str') if not isinstance(type, str): raise type_error('Button.type must be an instance of str') self.title = title self.type = type for k in kwargs: setattr(self, k, kwargs[k]) def to_dict(self): return dict(vars(self)) class Template: def __init__(self, type: str, text: str, **kwargs): if not isinstance(type, str): raise type_error('Template.type must be an instance of str') if not isinstance(text, str): raise type_error('Template.text must be an instance of str') self.type = type self.text = text for k in kwargs: setattr(self, k, kwargs[k]) def to_dict(self): res = {'type': 'template', 'payload': {'template_type': self.type, 'text': self.text}} if hasattr(self, 'buttons'): res['payload'].update({'buttons': [b.to_dict() for b in self.buttons]}) return res class Message: def __init__(self, text: str=None, quick_reply: QuickReply=None, attachment=None): if text and (not isinstance(text, str)): raise type_error('Message.text must be an instance of str') if quick_reply and (not isinstance(quick_reply, QuickReply)): raise type_error('Message.quick_reply must be an instance of QuickReply') self.text = text self.quick_reply = quick_reply self.attachment = attachment def set_quick_reply(self, quick_reply): if not isinstance(quick_reply, QuickReply): raise type_error('Message.quick_reply must be an instance of QuickReply') self.quick_reply = quick_reply def to_dict(self): msg = {} if self.text: msg['text'] = self.text if self.quick_reply: msg['quick_replies'] = self.quick_reply.to_dict() if self.attachment: msg['attachment'] = self.attachment.to_dict() return msg
class EnigmaException(Exception): pass class PlugboardException(EnigmaException): pass class ReflectorException(EnigmaException): pass class RotorException(EnigmaException): pass
class Enigmaexception(Exception): pass class Plugboardexception(EnigmaException): pass class Reflectorexception(EnigmaException): pass class Rotorexception(EnigmaException): pass
def checks_in_string(string, check_list): for check in check_list: if check in string: return True return False
def checks_in_string(string, check_list): for check in check_list: if check in string: return True return False
def find_strongest_eggs(*args): eggs = args[0] div = args[1] res = [] strongest = [] is_strong = True n = div for _ in range(n): res.append([]) for i in range(1): if div == 1: res.append(eggs) break else: for j in range(len(eggs)): if j % 2 == 0: res[0].append(eggs[j]) else: res[1].append(eggs[j]) if div == 1: middle = len(res[1]) // 2 mid = res[1][middle] left = list(res[1][:middle]) right = list(reversed(res[1][middle + 1:])) while left and right: is_strong = True l = left.pop() r = right.pop() if mid <= l or mid <= r or r <= l: is_strong = False break if is_strong: strongest.append(mid) else: for el in res: middle = len(el) // 2 mid = el[middle] left = list(el[:middle]) right = list(reversed(el[middle+1:])) while left and right: is_strong = True l = left.pop() r = right.pop() if mid <= l or mid <= r or r <= l: is_strong = False break if is_strong: strongest.append(mid) return strongest test = ([-1, 7, 3, 15, 2, 12], 2) print(find_strongest_eggs(*test))
def find_strongest_eggs(*args): eggs = args[0] div = args[1] res = [] strongest = [] is_strong = True n = div for _ in range(n): res.append([]) for i in range(1): if div == 1: res.append(eggs) break else: for j in range(len(eggs)): if j % 2 == 0: res[0].append(eggs[j]) else: res[1].append(eggs[j]) if div == 1: middle = len(res[1]) // 2 mid = res[1][middle] left = list(res[1][:middle]) right = list(reversed(res[1][middle + 1:])) while left and right: is_strong = True l = left.pop() r = right.pop() if mid <= l or mid <= r or r <= l: is_strong = False break if is_strong: strongest.append(mid) else: for el in res: middle = len(el) // 2 mid = el[middle] left = list(el[:middle]) right = list(reversed(el[middle + 1:])) while left and right: is_strong = True l = left.pop() r = right.pop() if mid <= l or mid <= r or r <= l: is_strong = False break if is_strong: strongest.append(mid) return strongest test = ([-1, 7, 3, 15, 2, 12], 2) print(find_strongest_eggs(*test))
##PUT ALL INFO BETWEEN QUOTES BELOW AND RENAME THIS FILE TO 'creds.py' #Twilio API Account info ACCOUNT_SID = "" AUTH_TOKEN = "" # your cell phone number below (must begin with '+', example: "+15555555555") TO_PHONE = "" # your Twilio phone number below (must begin with '+', example: "+15555555555") FROM_PHONE = "" # Imgur ID CLIENT_ID = ""
account_sid = '' auth_token = '' to_phone = '' from_phone = '' client_id = ''
class ModeException(Exception): def __init__(self, message: str): super().__init__(message) class SizeException(Exception): def __init__(self, message: str): super().__init__(message) class PaddingException(Exception): def __init__(self, message: str): super().__init__(message) class ReshapingException(Exception): def __init__(self, message: str): super().__init__(message) class ShapeMismatch(Exception): def __init__(self, message: str): super().__init__(message)
class Modeexception(Exception): def __init__(self, message: str): super().__init__(message) class Sizeexception(Exception): def __init__(self, message: str): super().__init__(message) class Paddingexception(Exception): def __init__(self, message: str): super().__init__(message) class Reshapingexception(Exception): def __init__(self, message: str): super().__init__(message) class Shapemismatch(Exception): def __init__(self, message: str): super().__init__(message)
#!/usr/bin/env python """ Aluguel de carro Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo usuario, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preco a pagar, sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado. """ def pay(km, days): return (days*60 + km*0.15) if __name__ == "__main__": km = float (input(" The value of Km: ")) days = int (input(" Amount of days: ")) print("The value pay is: ", pay(km,days))
""" Aluguel de carro Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo usuario, assim como a quantidade de dias pelos quais o carro foi alugado. Calcule o preco a pagar, sabendo que o carro custa R$ 60,00 por dia e R$ 0,15 por km rodado. """ def pay(km, days): return days * 60 + km * 0.15 if __name__ == '__main__': km = float(input(' The value of Km: ')) days = int(input(' Amount of days: ')) print('The value pay is: ', pay(km, days))
def function(a): pass function(10)
def function(a): pass function(10)
class NullAttributeException(Exception): """Raised when the attribute which is not nullable is missing.""" pass class ItemNotFoundException(Exception): """Raised when the item is not found""" pass class ConditionNotRecognizedException(Exception): """Raised when the condition is not found""" pass
class Nullattributeexception(Exception): """Raised when the attribute which is not nullable is missing.""" pass class Itemnotfoundexception(Exception): """Raised when the item is not found""" pass class Conditionnotrecognizedexception(Exception): """Raised when the condition is not found""" pass
class Base1: def __init__(self, *args): print("Base1.__init__",args) class Clist1(Base1, list): pass class Ctuple1(Base1, tuple): pass a = Clist1() print(len(a)) a = Clist1([1, 2, 3]) print(len(a)) a = Ctuple1() print(len(a)) a = Ctuple1([1, 2, 3]) # TODO: Faults #print(len(a)) print("---") class Clist2(list, Base1): pass class Ctuple2(tuple, Base1): pass a = Clist2() print(len(a)) a = Clist2([1, 2, 3]) print(len(a)) #a = Ctuple2() #print(len(a)) #a = Ctuple2([1, 2, 3]) #print(len(a))
class Base1: def __init__(self, *args): print('Base1.__init__', args) class Clist1(Base1, list): pass class Ctuple1(Base1, tuple): pass a = clist1() print(len(a)) a = clist1([1, 2, 3]) print(len(a)) a = ctuple1() print(len(a)) a = ctuple1([1, 2, 3]) print('---') class Clist2(list, Base1): pass class Ctuple2(tuple, Base1): pass a = clist2() print(len(a)) a = clist2([1, 2, 3]) print(len(a))
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. _credential_properties = { 'blob': { 'type': 'string' }, 'project_id': { 'type': 'string' }, 'type': { 'type': 'string' }, 'user_id': { 'type': 'string' } } credential_create = { 'type': 'object', 'properties': _credential_properties, 'additionalProperties': True, 'oneOf': [ { 'title': 'ec2 credential requires project_id', 'required': ['blob', 'type', 'user_id', 'project_id'], 'properties': { 'type': { 'enum': ['ec2'] } } }, { 'title': 'non-ec2 credential does not require project_id', 'required': ['blob', 'type', 'user_id'], 'properties': { 'type': { 'not': { 'enum': ['ec2'] } } } } ] } credential_update = { 'type': 'object', 'properties': _credential_properties, 'minProperties': 1, 'additionalProperties': True }
_credential_properties = {'blob': {'type': 'string'}, 'project_id': {'type': 'string'}, 'type': {'type': 'string'}, 'user_id': {'type': 'string'}} credential_create = {'type': 'object', 'properties': _credential_properties, 'additionalProperties': True, 'oneOf': [{'title': 'ec2 credential requires project_id', 'required': ['blob', 'type', 'user_id', 'project_id'], 'properties': {'type': {'enum': ['ec2']}}}, {'title': 'non-ec2 credential does not require project_id', 'required': ['blob', 'type', 'user_id'], 'properties': {'type': {'not': {'enum': ['ec2']}}}}]} credential_update = {'type': 'object', 'properties': _credential_properties, 'minProperties': 1, 'additionalProperties': True}
def hash_function(s=b''): a, b, c, d = 0xa0, 0xb1, 0x11, 0x4d for byte in bytearray(s): a ^= byte b = b ^ a ^ 0x55 c = b ^ 0x94 d = c ^ byte ^ 0x74 return format(d << 24 | c << 16 | a << 8 | b, '08x')
def hash_function(s=b''): (a, b, c, d) = (160, 177, 17, 77) for byte in bytearray(s): a ^= byte b = b ^ a ^ 85 c = b ^ 148 d = c ^ byte ^ 116 return format(d << 24 | c << 16 | a << 8 | b, '08x')
# -*- coding: utf-8 -*- """ lswifi.constants ~~~~~~~~~~~~~~~~ define app constant values """ APNAMEACKFILE = "apnames.ack" APNAMEJSONFILE = "apnames.json" CIPHER_SUITE_DICT = { 0: "Use group cipher suite", 1: "WEP-40", # WEP 2: "TKIP", # WPA-Personal (TKIP is limited to 54 Mbps) 3: "Reserved", 4: "AES", # CCMP-128 WPA2-Enterprise 00-0F-AC:4 / WPA2-Personal 00-0F-AC:4 5: "WEP-104", 6: "BIP-CMAC-128", 7: "Group addressed traffic not allowed", 8: "GCMP-128", 9: "GCMP-256", # WPA3-Enterprise 00-0F-AC:9 / WPA3-Personal 00-0F-AC:9 10: "CMAC-256", 11: "BIP-GMAC-128", 12: "BIP-GMAC-256", 13: "BIP-CMAC-256", 14: "Reserved", 15: "Reserved", } AKM_SUITE_DICT = { 0: "Reserved", 1: "802.1X", 2: "PSK", 3: "FT-802.1X", 4: "FT-PSK", 5: "802.1X", 6: "PSK", 7: "TDLS", 8: "SAE", 9: "FT-SAE", 10: "APPeerKey", 11: "802.1X-Suite-B-SHA-256", 12: "802.1X 192-bit", # WPA3 - Enterprise 13: "FT-802.1X-SHA-384", 18: "OWE", } INTERWORKING_NETWORK_TYPE = { 0: "Private network", 1: "Private network with guest access", 2: "Chargeable public network", 3: "Free public network", 4: "Personal device network", 5: "Emergency services only network", 6: "Reserved", 7: "Reserved", 8: "Reserved", 9: "Reserved", 10: "Reserved", 11: "Reserved", 12: "Reserved", 13: "Reserved", 14: "Test or experimental", 15: "Wildcard", } IE_DICT = { 0: "SSID", 1: "Supported Rates", 2: "Reserved", 3: "DSSS Parameter Set", 4: "Reserved", 5: "Traffic Indication Map", 6: "IBSS", 7: "Country", # 802.11d 10: "Request", 11: "BSS Load", # 802.11e 12: "EDCA", 13: "TSPEC", 32: "Power Constraint", # 802.11h 33: "Power Capability", 34: "TPC Request", 35: "TPC Report", # 802.11h 36: "Supported Channels", 37: "Channel Switch Announcement", 38: "Measurement Request", 39: "Measurement Report", 40: "Quiet Element", # 802.11h 41: "IBSS DFS", 42: "ERP", 45: "HT Capabilities", 47: "Reserved", 48: "RSN Information", 50: "Extended Supported Rates", 51: "AP Channel Report", 54: "Mobility Domain", 55: "FTE", 59: "Supported Operating Classes", 61: "HT Operation", 62: "Secondary Channel Offest", 66: "Measurement Pilot Transmission", 67: "BSS Available Admission Capacity", 69: "Time Advertisement", 70: "RM Enabled Capabilities", # 802.11r 71: "Multiple BSSID", 72: "20/40 BSS Coexistence", 74: "Overlapping BSS Scan Parameters", 84: "SSID List", 107: "Interworking", 108: "Advertisement Protocol", 111: "Roaming Consortium", 113: "Mesh Configuration", # 802.11s 114: "Mesh ID", 127: "Extended Capabilities", 133: "Cisco CCX1 CKIP + Device Name", 148: "DMG Capabilities", 149: "Cisco Unknown 95", 150: "Cisco", 151: "DMG Operation", 158: "Multi-band", 159: "ADDBA Extension", 173: "Symbol Proprietary", 191: "VHT Capabilities", 192: "VHT Operation", 193: "Extended BSS Load", 195: "Tx Power Envelope", 197: "AID", 198: "Quiet Channel", 201: "Reduced Neighbor Report", 202: "TVHT Operation", 216: "TWT", 221: "Vendor", 244: "RSN eXtension", 255: "Extension", } VENDOR_SPECIFIC_DICT = { "00-0B-86": ["Aruba", "Aruba Networks Inc."], "00-50-F2": ["Microsoft", "Microsoft Corporation"], "00-03-7F": ["Atheros", "Atheros Communications Inc."], "00-10-18": ["Broadcom", "Broadcom"], "00-17-F2": ["Apple", "Apple Inc."], "00-15-6D": ["Ubiquiti", "Ubiquiti Networks Inc."], "00-26-86": ["Quantenna", "Quantenna"], } EXTENSION_IE_DICT = { 35: "(35) HE Capabilities", 36: "(36) HE Operation", 37: "(37) UORA Parameter Set", 38: "(38) MU EDCA Parameter Set", 39: "(39) Spatial Reuse Parameter", 41: "(41) NDP Feedback Report", 42: "(42) BSS Color Change Announcement", 43: "(43) Quiet Time Period Setup", 45: "(45) ESS Report", 46: "(46) OPS", 47: "(47) HE BSS Load", 55: "(55) Multiple BSSID Configuration", 57: "(57) Known BSSID", 58: "(58) Short SSID List", 59: "(59) HE 6 GHz Band Capabilities", 60: "(60) UL MU Power Capabilities", } _40MHZ_CHANNEL_LIST = { "13-": ["13", "(9)"], "9+": ["9", "(13)"], "12-": ["12", "(8)"], "8+": ["8", "(12)"], "11-": ["11", "(7)"], "7+": ["7", "(11)"], "10-": ["10", "(6)"], "6+": ["6", "(10)"], "9-": ["9", "(5)"], "5+": ["5", "(9)"], "8-": ["8", "(4)"], "4+": ["4", "(8)"], "7-": ["7", "(3)"], "3+": ["3", "(7)"], "6-": ["6", "(2)"], "2+": ["2", "(6)"], "5-": ["5", "(1)"], "1+": ["1", "(5)"], "32+": ["32", "(36)"], "36-": ["36", "(32)"], "36+": ["36", "(40)"], "40-": ["40", "(36)"], "44+": ["44", "(48)"], "48-": ["48", "(44)"], "52+": ["52", "(56)"], "56-": ["56", "(52)"], "60+": ["60", "(64)"], "64-": ["64", "(60)"], "100+": ["100", "(104)"], "104-": ["104", "(100)"], "108+": ["108", "(112)"], "112-": ["112", "(108)"], "116+": ["116", "(120)"], "120-": ["120", "(116)"], "124+": ["124", "(128)"], "128-": ["128", "(124)"], "132+": ["132", "(136)"], "136-": ["136", "(132)"], "140+": ["140", "(144)"], "144-": ["144", "(140)"], "149+": ["149", "(153)"], "153-": ["153", "(149)"], "157+": ["157", "(161)"], "161-": ["161", "(157)"], } _80MHZ_CHANNEL_LIST = { "42": ["36", "40", "44", "48"], "58": ["52", "56", "60", "64"], "106": ["100", "104", "108", "112"], "122": ["116", "120", "124", "128"], "138": ["132", "136", "140", "144"], "155": ["149", "153", "157", "161"], } _160MHZ_CHANNEL_LIST = { "50": ["36", "40", "44", "48", "52", "56", "60", "64"], "114": ["100", "104", "108", "112", "116", "120", "124", "128"], } _20MHZ_CHANNEL_LIST = { "2412": "1", "2417": "2", "2422": "3", "2427": "4", "2432": "5", "2437": "6", "2442": "7", "2447": "8", "2452": "9", "2457": "10", "2462": "11", "2467": "12", "2472": "13", "2484": "14", "5160": "32", "5170": "34", "5180": "36", "5190": "38", "5200": "40", "5210": "42", "5220": "44", "5230": "46", "5240": "48", "5250": "50", "5260": "52", "5270": "54", "5280": "56", "5290": "58", "5300": "60", "5310": "62", "5320": "64", "5340": "68", "5480": "96", "5500": "100", "5510": "102", "5520": "104", "5530": "106", "5540": "108", "5550": "110", "5560": "112", "5570": "114", "5580": "116", "5590": "118", "5600": "120", "5610": "122", "5620": "124", "5630": "126", "5640": "128", "5660": "132", "5670": "134", "5680": "136", "5700": "140", "5710": "142", "5720": "144", "5745": "149", "5755": "151", "5765": "153", "5775": "155", "5785": "157", "5795": "159", "5805": "161", "5825": "165", "5845": "169", "5865": "173", "4915": "183", "4920": "184", "4925": "185", "4935": "187", "4940": "188", "4945": "189", "4960": "192", "4980": "196", "5955": "1", "5975": "5", "5995": "9", "6015": "13", "6035": "17", "6055": "21", "6075": "25", "6095": "29", "6115": "33", "6135": "37", "6155": "41", "6175": "45", "6195": "49", "6215": "53", "6235": "57", "6255": "61", "6275": "65", "6295": "69", "6315": "73", "6335": "77", "6355": "81", "6375": "85", "6395": "89", "6415": "93", "6435": "97", "6455": "101", "6475": "105", "6495": "109", "6515": "113", "6535": "117", "6555": "121", "6575": "125", "6595": "129", "6615": "133", "6635": "137", "6655": "141", "6675": "145", "6695": "149", "6715": "153", "6735": "157", "6755": "161", "6775": "165", "6795": "169", "6815": "173", "6835": "177", "6855": "181", "6875": "185", "6895": "189", "6915": "193", "6935": "197", "6955": "201", "6975": "205", "6995": "209", "7015": "213", "7035": "217", "7055": "221", "7075": "225", "7095": "229", "7115": "233", }
""" lswifi.constants ~~~~~~~~~~~~~~~~ define app constant values """ apnameackfile = 'apnames.ack' apnamejsonfile = 'apnames.json' cipher_suite_dict = {0: 'Use group cipher suite', 1: 'WEP-40', 2: 'TKIP', 3: 'Reserved', 4: 'AES', 5: 'WEP-104', 6: 'BIP-CMAC-128', 7: 'Group addressed traffic not allowed', 8: 'GCMP-128', 9: 'GCMP-256', 10: 'CMAC-256', 11: 'BIP-GMAC-128', 12: 'BIP-GMAC-256', 13: 'BIP-CMAC-256', 14: 'Reserved', 15: 'Reserved'} akm_suite_dict = {0: 'Reserved', 1: '802.1X', 2: 'PSK', 3: 'FT-802.1X', 4: 'FT-PSK', 5: '802.1X', 6: 'PSK', 7: 'TDLS', 8: 'SAE', 9: 'FT-SAE', 10: 'APPeerKey', 11: '802.1X-Suite-B-SHA-256', 12: '802.1X 192-bit', 13: 'FT-802.1X-SHA-384', 18: 'OWE'} interworking_network_type = {0: 'Private network', 1: 'Private network with guest access', 2: 'Chargeable public network', 3: 'Free public network', 4: 'Personal device network', 5: 'Emergency services only network', 6: 'Reserved', 7: 'Reserved', 8: 'Reserved', 9: 'Reserved', 10: 'Reserved', 11: 'Reserved', 12: 'Reserved', 13: 'Reserved', 14: 'Test or experimental', 15: 'Wildcard'} ie_dict = {0: 'SSID', 1: 'Supported Rates', 2: 'Reserved', 3: 'DSSS Parameter Set', 4: 'Reserved', 5: 'Traffic Indication Map', 6: 'IBSS', 7: 'Country', 10: 'Request', 11: 'BSS Load', 12: 'EDCA', 13: 'TSPEC', 32: 'Power Constraint', 33: 'Power Capability', 34: 'TPC Request', 35: 'TPC Report', 36: 'Supported Channels', 37: 'Channel Switch Announcement', 38: 'Measurement Request', 39: 'Measurement Report', 40: 'Quiet Element', 41: 'IBSS DFS', 42: 'ERP', 45: 'HT Capabilities', 47: 'Reserved', 48: 'RSN Information', 50: 'Extended Supported Rates', 51: 'AP Channel Report', 54: 'Mobility Domain', 55: 'FTE', 59: 'Supported Operating Classes', 61: 'HT Operation', 62: 'Secondary Channel Offest', 66: 'Measurement Pilot Transmission', 67: 'BSS Available Admission Capacity', 69: 'Time Advertisement', 70: 'RM Enabled Capabilities', 71: 'Multiple BSSID', 72: '20/40 BSS Coexistence', 74: 'Overlapping BSS Scan Parameters', 84: 'SSID List', 107: 'Interworking', 108: 'Advertisement Protocol', 111: 'Roaming Consortium', 113: 'Mesh Configuration', 114: 'Mesh ID', 127: 'Extended Capabilities', 133: 'Cisco CCX1 CKIP + Device Name', 148: 'DMG Capabilities', 149: 'Cisco Unknown 95', 150: 'Cisco', 151: 'DMG Operation', 158: 'Multi-band', 159: 'ADDBA Extension', 173: 'Symbol Proprietary', 191: 'VHT Capabilities', 192: 'VHT Operation', 193: 'Extended BSS Load', 195: 'Tx Power Envelope', 197: 'AID', 198: 'Quiet Channel', 201: 'Reduced Neighbor Report', 202: 'TVHT Operation', 216: 'TWT', 221: 'Vendor', 244: 'RSN eXtension', 255: 'Extension'} vendor_specific_dict = {'00-0B-86': ['Aruba', 'Aruba Networks Inc.'], '00-50-F2': ['Microsoft', 'Microsoft Corporation'], '00-03-7F': ['Atheros', 'Atheros Communications Inc.'], '00-10-18': ['Broadcom', 'Broadcom'], '00-17-F2': ['Apple', 'Apple Inc.'], '00-15-6D': ['Ubiquiti', 'Ubiquiti Networks Inc.'], '00-26-86': ['Quantenna', 'Quantenna']} extension_ie_dict = {35: '(35) HE Capabilities', 36: '(36) HE Operation', 37: '(37) UORA Parameter Set', 38: '(38) MU EDCA Parameter Set', 39: '(39) Spatial Reuse Parameter', 41: '(41) NDP Feedback Report', 42: '(42) BSS Color Change Announcement', 43: '(43) Quiet Time Period Setup', 45: '(45) ESS Report', 46: '(46) OPS', 47: '(47) HE BSS Load', 55: '(55) Multiple BSSID Configuration', 57: '(57) Known BSSID', 58: '(58) Short SSID List', 59: '(59) HE 6 GHz Band Capabilities', 60: '(60) UL MU Power Capabilities'} _40_mhz_channel_list = {'13-': ['13', '(9)'], '9+': ['9', '(13)'], '12-': ['12', '(8)'], '8+': ['8', '(12)'], '11-': ['11', '(7)'], '7+': ['7', '(11)'], '10-': ['10', '(6)'], '6+': ['6', '(10)'], '9-': ['9', '(5)'], '5+': ['5', '(9)'], '8-': ['8', '(4)'], '4+': ['4', '(8)'], '7-': ['7', '(3)'], '3+': ['3', '(7)'], '6-': ['6', '(2)'], '2+': ['2', '(6)'], '5-': ['5', '(1)'], '1+': ['1', '(5)'], '32+': ['32', '(36)'], '36-': ['36', '(32)'], '36+': ['36', '(40)'], '40-': ['40', '(36)'], '44+': ['44', '(48)'], '48-': ['48', '(44)'], '52+': ['52', '(56)'], '56-': ['56', '(52)'], '60+': ['60', '(64)'], '64-': ['64', '(60)'], '100+': ['100', '(104)'], '104-': ['104', '(100)'], '108+': ['108', '(112)'], '112-': ['112', '(108)'], '116+': ['116', '(120)'], '120-': ['120', '(116)'], '124+': ['124', '(128)'], '128-': ['128', '(124)'], '132+': ['132', '(136)'], '136-': ['136', '(132)'], '140+': ['140', '(144)'], '144-': ['144', '(140)'], '149+': ['149', '(153)'], '153-': ['153', '(149)'], '157+': ['157', '(161)'], '161-': ['161', '(157)']} _80_mhz_channel_list = {'42': ['36', '40', '44', '48'], '58': ['52', '56', '60', '64'], '106': ['100', '104', '108', '112'], '122': ['116', '120', '124', '128'], '138': ['132', '136', '140', '144'], '155': ['149', '153', '157', '161']} _160_mhz_channel_list = {'50': ['36', '40', '44', '48', '52', '56', '60', '64'], '114': ['100', '104', '108', '112', '116', '120', '124', '128']} _20_mhz_channel_list = {'2412': '1', '2417': '2', '2422': '3', '2427': '4', '2432': '5', '2437': '6', '2442': '7', '2447': '8', '2452': '9', '2457': '10', '2462': '11', '2467': '12', '2472': '13', '2484': '14', '5160': '32', '5170': '34', '5180': '36', '5190': '38', '5200': '40', '5210': '42', '5220': '44', '5230': '46', '5240': '48', '5250': '50', '5260': '52', '5270': '54', '5280': '56', '5290': '58', '5300': '60', '5310': '62', '5320': '64', '5340': '68', '5480': '96', '5500': '100', '5510': '102', '5520': '104', '5530': '106', '5540': '108', '5550': '110', '5560': '112', '5570': '114', '5580': '116', '5590': '118', '5600': '120', '5610': '122', '5620': '124', '5630': '126', '5640': '128', '5660': '132', '5670': '134', '5680': '136', '5700': '140', '5710': '142', '5720': '144', '5745': '149', '5755': '151', '5765': '153', '5775': '155', '5785': '157', '5795': '159', '5805': '161', '5825': '165', '5845': '169', '5865': '173', '4915': '183', '4920': '184', '4925': '185', '4935': '187', '4940': '188', '4945': '189', '4960': '192', '4980': '196', '5955': '1', '5975': '5', '5995': '9', '6015': '13', '6035': '17', '6055': '21', '6075': '25', '6095': '29', '6115': '33', '6135': '37', '6155': '41', '6175': '45', '6195': '49', '6215': '53', '6235': '57', '6255': '61', '6275': '65', '6295': '69', '6315': '73', '6335': '77', '6355': '81', '6375': '85', '6395': '89', '6415': '93', '6435': '97', '6455': '101', '6475': '105', '6495': '109', '6515': '113', '6535': '117', '6555': '121', '6575': '125', '6595': '129', '6615': '133', '6635': '137', '6655': '141', '6675': '145', '6695': '149', '6715': '153', '6735': '157', '6755': '161', '6775': '165', '6795': '169', '6815': '173', '6835': '177', '6855': '181', '6875': '185', '6895': '189', '6915': '193', '6935': '197', '6955': '201', '6975': '205', '6995': '209', '7015': '213', '7035': '217', '7055': '221', '7075': '225', '7095': '229', '7115': '233'}
#!/usr/bin/env python3 # coding: utf8 """ constants.py Date: 08-21-2019 Description: Defines the codes required for ansi code generation """ START = "\033[" END = "\033[0m" COLOR_CODES = { "k": "black", "b": "blue", "r": "red", "g": "green", "p": "purple", "y": "yellow", "c": "cyan", "w": "white", "lg": "light green", "dg": "dark gray", "lr": "light red", "ly": "light yellow", "lb": "light blue", "lm": "light magenta", "lc": "light cyan", "n": "none", "db": "dodger blue" } COLORS = { "black": ("30m", "40;"), "red": ("31m", "41;"), "green": ("32m", "42;"), "yellow": ("33m", "43;"), "blue": ("34m", "44;"), "purple": ("35m", "45;"), "cyan": ("36m", "46;"), "light gray": ("37m", "47;"), "dark gray": ("90m", "100;"), "light red": ("91m", "101;"), "light green": ("92m", "102;"), "light yellow": ("93m", "103;"), "light blue": ("94m", "104;"), "light purple": ("95m", "105;"), "light cyan": ("96m", "106;"), "white": ("97m", "107;"), "none": ("39m", "49;"), "dodger blue": ("38;5;33m", "48;5;33m") } STYLES = { "NONE": "0;", "BOLD": "1;", "FADE": "2;", "UNDERLINE": "4;", "BLINK": "5;", } if __name__ == "__main__": pass
""" constants.py Date: 08-21-2019 Description: Defines the codes required for ansi code generation """ start = '\x1b[' end = '\x1b[0m' color_codes = {'k': 'black', 'b': 'blue', 'r': 'red', 'g': 'green', 'p': 'purple', 'y': 'yellow', 'c': 'cyan', 'w': 'white', 'lg': 'light green', 'dg': 'dark gray', 'lr': 'light red', 'ly': 'light yellow', 'lb': 'light blue', 'lm': 'light magenta', 'lc': 'light cyan', 'n': 'none', 'db': 'dodger blue'} colors = {'black': ('30m', '40;'), 'red': ('31m', '41;'), 'green': ('32m', '42;'), 'yellow': ('33m', '43;'), 'blue': ('34m', '44;'), 'purple': ('35m', '45;'), 'cyan': ('36m', '46;'), 'light gray': ('37m', '47;'), 'dark gray': ('90m', '100;'), 'light red': ('91m', '101;'), 'light green': ('92m', '102;'), 'light yellow': ('93m', '103;'), 'light blue': ('94m', '104;'), 'light purple': ('95m', '105;'), 'light cyan': ('96m', '106;'), 'white': ('97m', '107;'), 'none': ('39m', '49;'), 'dodger blue': ('38;5;33m', '48;5;33m')} styles = {'NONE': '0;', 'BOLD': '1;', 'FADE': '2;', 'UNDERLINE': '4;', 'BLINK': '5;'} if __name__ == '__main__': pass
def buy_card(n: int, p: list): d = [0]*(n+1) for i in range(1, n+1): for j in range(1, i+1): d[i] = max(d[i], d[i-j] + p[j-1]) return d[n] def test_buy_card(): assert buy_card(4, [1, 5, 6, 7]) == 10 assert buy_card(5, [10, 9, 8, 7, 6]) == 50 assert buy_card(10, [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 55 assert buy_card(10, [5, 10, 11, 12, 13, 30, 35, 40, 45, 47]) == 50 assert buy_card(4, [5, 2, 8, 10]) == 20 assert buy_card(4, [3, 5, 15, 16]) == 18 if __name__ == "__main__": n = int(input()) p = list(map(int, input().split(' '))) print(buy_card(n, p))
def buy_card(n: int, p: list): d = [0] * (n + 1) for i in range(1, n + 1): for j in range(1, i + 1): d[i] = max(d[i], d[i - j] + p[j - 1]) return d[n] def test_buy_card(): assert buy_card(4, [1, 5, 6, 7]) == 10 assert buy_card(5, [10, 9, 8, 7, 6]) == 50 assert buy_card(10, [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 55 assert buy_card(10, [5, 10, 11, 12, 13, 30, 35, 40, 45, 47]) == 50 assert buy_card(4, [5, 2, 8, 10]) == 20 assert buy_card(4, [3, 5, 15, 16]) == 18 if __name__ == '__main__': n = int(input()) p = list(map(int, input().split(' '))) print(buy_card(n, p))
class Item: item_id = 1 def __init__(self, name): self.name = name self.item_id = Item.item_id Item.item_id += 1 tv = Item('LG 42') computer = Item('Dell XPS') print(tv.item_id) print(computer.item_id) # prints: # 1 # 2
class Item: item_id = 1 def __init__(self, name): self.name = name self.item_id = Item.item_id Item.item_id += 1 tv = item('LG 42') computer = item('Dell XPS') print(tv.item_id) print(computer.item_id)
#!/usr/bin/env python3 """Remove vowels and whitespace from a string and put the vowels at the end. Title: Disemvoweler Description: Make a program that removes every vowel and whitespace found in a string. It should output the resulting disemvoweled string with the removed vowels concatenated to the end of it. For example 'Hello world' outputs 'Hllwrld eoo'. """ VOWELS = ("a", "e", "i", "o", "u") def disemvowel(string: str) -> str: """Return disemvoweled version of string.""" new_string = "" extra_chars = " " for char in string: if char.lower() in VOWELS: extra_chars += char elif char.isspace(): pass else: new_string += char new_string += extra_chars return new_string def _start_interactively(): """Start the program interactively through the command line.""" while True: string = input("Please input a string: ") print(disemvowel(string) + "\n") if __name__ == "__main__": _start_interactively()
"""Remove vowels and whitespace from a string and put the vowels at the end. Title: Disemvoweler Description: Make a program that removes every vowel and whitespace found in a string. It should output the resulting disemvoweled string with the removed vowels concatenated to the end of it. For example 'Hello world' outputs 'Hllwrld eoo'. """ vowels = ('a', 'e', 'i', 'o', 'u') def disemvowel(string: str) -> str: """Return disemvoweled version of string.""" new_string = '' extra_chars = ' ' for char in string: if char.lower() in VOWELS: extra_chars += char elif char.isspace(): pass else: new_string += char new_string += extra_chars return new_string def _start_interactively(): """Start the program interactively through the command line.""" while True: string = input('Please input a string: ') print(disemvowel(string) + '\n') if __name__ == '__main__': _start_interactively()
# Dit is weer een encoder, dus gebruik instellinen die daarbij horen. real_encoder = tf.keras.models.Sequential([ tf.keras.layers.Dense(784, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(2, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(784, activation=tf.nn.relu) ]) real_encoder.compile(loss=tf.keras.losses.mean_squared_error, optimizer=tf.keras.optimizers.RMSprop(lr=0.0001, rho=0.9, epsilon=None, decay=0.0), metrics = ['accuracy']) # Dus ook: trainen op de input. real_encoder.fit(xtr, xtr, epochs=10, batch_size=256) print("Training performance:", real_encoder.evaluate(xtr, xtr)) # Zoals wellicht verwacht wanneer er niet wordt getraind op de labels, # is het veel moeilijker de verschillend gelabelde plaatjes te onderscheiden # in de bottleneck-laag. De performance van het model lijkt ook heel laag. # Dit is echter niet zo'n betekenisvol getal: het is een maat voor hoe goed # afzonderlijke pixels worden gereconstrueerd, en voor het eventueel kunnen # herkennen van een plaatje kunnen die nog behoorlijk anders zijn, zoals we # hieronder zullen zien. # Predict de output, gegeven de input en laat ze beiden naast elkaar zien. real_constructed = real_encoder.predict(xtr) imsize = 28 aantal_im = len(xtr) deze = np.random.randint(0, aantal_im) plt.figure(figsize=(12, 24)) pp = plt.subplot(121) number = np.reshape(real_constructed[deze], [imsize, imsize]) pp.imshow(number, cmap='Greys') pp.set_xticklabels([]) pp.set_yticklabels([]) pp.set_title("Gereconstrueerd") pp = plt.subplot(122) number = np.reshape(xtr[deze], [imsize, imsize]) pp.imshow(number, cmap='Greys') pp.set_xticklabels([]) pp.set_yticklabels([]) pp.set_title("Oorspronkelijke digit"); print("Nog lang zo slecht niet!")
real_encoder = tf.keras.models.Sequential([tf.keras.layers.Dense(784, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(2, activation=tf.nn.relu), tf.keras.layers.Dense(128, activation=tf.nn.relu), tf.keras.layers.Dense(784, activation=tf.nn.relu)]) real_encoder.compile(loss=tf.keras.losses.mean_squared_error, optimizer=tf.keras.optimizers.RMSprop(lr=0.0001, rho=0.9, epsilon=None, decay=0.0), metrics=['accuracy']) real_encoder.fit(xtr, xtr, epochs=10, batch_size=256) print('Training performance:', real_encoder.evaluate(xtr, xtr)) real_constructed = real_encoder.predict(xtr) imsize = 28 aantal_im = len(xtr) deze = np.random.randint(0, aantal_im) plt.figure(figsize=(12, 24)) pp = plt.subplot(121) number = np.reshape(real_constructed[deze], [imsize, imsize]) pp.imshow(number, cmap='Greys') pp.set_xticklabels([]) pp.set_yticklabels([]) pp.set_title('Gereconstrueerd') pp = plt.subplot(122) number = np.reshape(xtr[deze], [imsize, imsize]) pp.imshow(number, cmap='Greys') pp.set_xticklabels([]) pp.set_yticklabels([]) pp.set_title('Oorspronkelijke digit') print('Nog lang zo slecht niet!')
SLOTS = [ [ 0, 5460, ["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"], ["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"], ], [ 9995, 9995, ["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"], ["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"], ], [ 12182, 12182, ["172.17.0.2", 7000, "cf0da23bbea0ac65fd93d272358b59cd7ce3af25"], ["172.17.0.2", 7003, "ab35b1210fcae1010a463c65e1616b51d3d7a00b"], ], [ 5461, 9994, ["172.17.0.2", 7001, "d0299b606a9f2634ddbfc321e4164c1fc1601dc4"], ["172.17.0.2", 7004, "8e691f344dbf1b398792a7bca48ec7f012a2cc35"], ], [ 9996, 10922, ["172.17.0.2", 7001, "d0299b606a9f2634ddbfc321e4164c1fc1601dc4"], ["172.17.0.2", 7004, "8e691f344dbf1b398792a7bca48ec7f012a2cc35"], ], [10923, 12181, ["172.17.0.2", 7002, "c80666a77621a0061a3af77a1fda46c94c2abcb9"]], [12183, 16383, ["172.17.0.2", 7002, "c80666a77621a0061a3af77a1fda46c94c2abcb9"]], ] INFO = { "cluster_state": "ok", "cluster_current_epoch": "1", "cluster_slots_assigned": "16384", "cluster_slots_ok": "16384", "cluster_slots_pfail": "0", "cluster_slots_fail": "0", "cluster_known_nodes": "6", "cluster_size": "3", "cluster_current_epoch": "1", "cluster_my_epoch": "1", }
slots = [[0, 5460, ['172.17.0.2', 7000, 'cf0da23bbea0ac65fd93d272358b59cd7ce3af25'], ['172.17.0.2', 7003, 'ab35b1210fcae1010a463c65e1616b51d3d7a00b']], [9995, 9995, ['172.17.0.2', 7000, 'cf0da23bbea0ac65fd93d272358b59cd7ce3af25'], ['172.17.0.2', 7003, 'ab35b1210fcae1010a463c65e1616b51d3d7a00b']], [12182, 12182, ['172.17.0.2', 7000, 'cf0da23bbea0ac65fd93d272358b59cd7ce3af25'], ['172.17.0.2', 7003, 'ab35b1210fcae1010a463c65e1616b51d3d7a00b']], [5461, 9994, ['172.17.0.2', 7001, 'd0299b606a9f2634ddbfc321e4164c1fc1601dc4'], ['172.17.0.2', 7004, '8e691f344dbf1b398792a7bca48ec7f012a2cc35']], [9996, 10922, ['172.17.0.2', 7001, 'd0299b606a9f2634ddbfc321e4164c1fc1601dc4'], ['172.17.0.2', 7004, '8e691f344dbf1b398792a7bca48ec7f012a2cc35']], [10923, 12181, ['172.17.0.2', 7002, 'c80666a77621a0061a3af77a1fda46c94c2abcb9']], [12183, 16383, ['172.17.0.2', 7002, 'c80666a77621a0061a3af77a1fda46c94c2abcb9']]] info = {'cluster_state': 'ok', 'cluster_current_epoch': '1', 'cluster_slots_assigned': '16384', 'cluster_slots_ok': '16384', 'cluster_slots_pfail': '0', 'cluster_slots_fail': '0', 'cluster_known_nodes': '6', 'cluster_size': '3', 'cluster_current_epoch': '1', 'cluster_my_epoch': '1'}
def emulate_catchup(replica, ppSeqNo=100): if replica.isMaster: replica.caught_up_till_3pc((replica.viewNo, ppSeqNo)) else: replica.catchup_clear_for_backup() def emulate_select_primaries(replica): replica.primaryName = 'SomeAnotherNode' replica._setup_for_non_master_after_view_change(replica.viewNo)
def emulate_catchup(replica, ppSeqNo=100): if replica.isMaster: replica.caught_up_till_3pc((replica.viewNo, ppSeqNo)) else: replica.catchup_clear_for_backup() def emulate_select_primaries(replica): replica.primaryName = 'SomeAnotherNode' replica._setup_for_non_master_after_view_change(replica.viewNo)
# this is the module which i will be #calling and using again and again def kolar(): print("I am a new module which will work i am call") # this file save with same python path with new file name
def kolar(): print('I am a new module which will work i am call')
f = open('Log-A.strace') lines = f.readlines() term = ' read(' term2 = 'pipe' term3 = 'tty' def extract_name(line, start_delimiter, end_delimiter): name_start = line.find(start_delimiter) name_end = line.find(end_delimiter, name_start + 1) name = line[name_start + 1 : name_end] return name names = [] counts = [] for line in lines: if 'read(' in line and 'pipe' not in line and 'tty' not in line: name = extract_name(line, '<', '>') if name not in names: names.append(name) counts.append(1) else: idx = names.index(name) counts[idx] += 1 for i in range(len(names)): name = names[i] count = counts[i] #print(name, count) print(name + '\t' + str(count)) # example output # ('/lib/x86_64-linux-gnu/libc-2.23.so', 4) # ('/etc/nsswitch.conf', 4) # ('/lib/x86_64-linux-gnu/libnss_compat-2.23.so', 2) # ('/lib/x86_64-linux-gnu/libnsl-2.23.so', 2) # ('/lib/x86_64-linux-gnu/libnss_nis-2.23.so', 2) # ('/lib/x86_64-linux-gnu/libnss_files-2.23.so', 2) # ('/lib/x86_64-linux-gnu/libselinux.so.1', 1) # ('/lib/x86_64-linux-gnu/libpcre.so.3.13.2', 1) # ('/lib/x86_64-linux-gnu/libdl-2.23.so', 1) # ('/lib/x86_64-linux-gnu/libpthread-2.23.so', 1) # ('/proc/filesystems', 2) # ('/etc/locale.alias', 2) # ('/proc/sys/kernel/ngroups_max', 2)
f = open('Log-A.strace') lines = f.readlines() term = ' read(' term2 = 'pipe' term3 = 'tty' def extract_name(line, start_delimiter, end_delimiter): name_start = line.find(start_delimiter) name_end = line.find(end_delimiter, name_start + 1) name = line[name_start + 1:name_end] return name names = [] counts = [] for line in lines: if 'read(' in line and 'pipe' not in line and ('tty' not in line): name = extract_name(line, '<', '>') if name not in names: names.append(name) counts.append(1) else: idx = names.index(name) counts[idx] += 1 for i in range(len(names)): name = names[i] count = counts[i] print(name + '\t' + str(count))
TEMPLATE_SOURCE_TYPE = "TemplateSourceType" # stairlight.yaml STAIRLIGHT_CONFIG_FILE_PREFIX = "stairlight" STAIRLIGHT_CONFIG_INCLUDE_SECTION = "Include" STAIRLIGHT_CONFIG_EXCLUDE_SECTION = "Exclude" STAIRLIGHT_CONFIG_SETTING_SECTION = "Settings" DEFAULT_TABLE_PREFIX = "DefaultTablePrefix" FILE_SYSTEM_PATH = "FileSystemPath" REGEX = "Regex" # mapping.yaml MAPPING_CONFIG_FILE_PREFIX = "mapping" MAPPING_CONFIG_GLOBAL_SECTION = "Global" MAPPING_CONFIG_MAPPING_SECTION = "Mapping" MAPPING_CONFIG_METADATA_SECTION = "Metadata" FILE_SUFFIX = "FileSuffix" LABELS = "Labels" MAPPING_PREFIX = "MappingPrefix" PARAMETERS = "Parameters" TABLE_NAME = "TableName" TABLES = "Tables" # GCS BUCKET_NAME = "BucketName" PROJECT_ID = "ProjectId" URI = "Uri" # Redash DATABASE_URL_ENVIRONMENT_VARIABLE = "DatabaseUrlEnvironmentVariable" DATA_SOURCE_NAME = "DataSourceName" QUERY_IDS = "QueryIds" QUERY_ID = "QueryId"
template_source_type = 'TemplateSourceType' stairlight_config_file_prefix = 'stairlight' stairlight_config_include_section = 'Include' stairlight_config_exclude_section = 'Exclude' stairlight_config_setting_section = 'Settings' default_table_prefix = 'DefaultTablePrefix' file_system_path = 'FileSystemPath' regex = 'Regex' mapping_config_file_prefix = 'mapping' mapping_config_global_section = 'Global' mapping_config_mapping_section = 'Mapping' mapping_config_metadata_section = 'Metadata' file_suffix = 'FileSuffix' labels = 'Labels' mapping_prefix = 'MappingPrefix' parameters = 'Parameters' table_name = 'TableName' tables = 'Tables' bucket_name = 'BucketName' project_id = 'ProjectId' uri = 'Uri' database_url_environment_variable = 'DatabaseUrlEnvironmentVariable' data_source_name = 'DataSourceName' query_ids = 'QueryIds' query_id = 'QueryId'
# # @lc app=leetcode id=696 lang=python3 # # [696] Count Binary Substrings # # https://leetcode.com/problems/count-binary-substrings/description/ # # algorithms # Easy (61.31%) # Total Accepted: 81.6K # Total Submissions: 132.8K # Testcase Example: '"00110011"' # # Give a binary string s, return the number of non-empty substrings that have # the same number of 0's and 1's, and all the 0's and all the 1's in these # substrings are grouped consecutively. # # Substrings that occur multiple times are counted the number of times they # occur. # # # Example 1: # # # Input: s = "00110011" # Output: 6 # Explanation: There are 6 substrings that have equal number of consecutive 1's # and 0's: "0011", "01", "1100", "10", "0011", and "01". # Notice that some of these substrings repeat and are counted the number of # times they occur. # Also, "00110011" is not a valid substring because all the 0's (and 1's) are # not grouped together. # # # Example 2: # # # Input: s = "10101" # Output: 4 # Explanation: There are 4 substrings: "10", "01", "10", "01" that have equal # number of consecutive 1's and 0's. # # # # Constraints: # # # 1 <= s.length <= 10^5 # s[i] is either '0' or '1'. # # # class Solution: def countBinarySubstrings(self, s: str) -> int: temp = [] current_length = 1 for i in range(1, len(s)): if s[i] != s[i - 1]: temp.append(current_length) current_length = 1 else: current_length += 1 temp.append(current_length) total = 0 for i in range(1, len(temp)): total += min(temp[i], temp[i - 1]) return total if __name__ == '__main__': print(Solution().countBinarySubstrings('10101'))
class Solution: def count_binary_substrings(self, s: str) -> int: temp = [] current_length = 1 for i in range(1, len(s)): if s[i] != s[i - 1]: temp.append(current_length) current_length = 1 else: current_length += 1 temp.append(current_length) total = 0 for i in range(1, len(temp)): total += min(temp[i], temp[i - 1]) return total if __name__ == '__main__': print(solution().countBinarySubstrings('10101'))
def reverse(s): target = list(s) for i in range(int(len(s) / 2)): swap = target[i] target[i] = target[len(s) - i - 1] target[len(s) - i - 1] = swap return ''.join(target) if __name__ == '__main__': s = 'abcdef' print(reverse(s)) print(s[::-1])
def reverse(s): target = list(s) for i in range(int(len(s) / 2)): swap = target[i] target[i] = target[len(s) - i - 1] target[len(s) - i - 1] = swap return ''.join(target) if __name__ == '__main__': s = 'abcdef' print(reverse(s)) print(s[::-1])
# -*- coding: utf-8 -*- def bubble_sort(arr): """ Sorts the input array using the bubble sort method. The idea is to raise each value to it's final position through successive swaps. Complexity: O(n^2) in time, O(n) in space (sorting is done in place) Args: arr: list of keys to sort Return: list """ for i in range(len(arr) - 1, 0, -1): for j in range(i): if arr[j] > arr[j+1]: (arr[j], arr[j+1]) = (arr[j+1], arr[j])
def bubble_sort(arr): """ Sorts the input array using the bubble sort method. The idea is to raise each value to it's final position through successive swaps. Complexity: O(n^2) in time, O(n) in space (sorting is done in place) Args: arr: list of keys to sort Return: list """ for i in range(len(arr) - 1, 0, -1): for j in range(i): if arr[j] > arr[j + 1]: (arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
### Build String ### class Solution1: def backspaceCompare(self, S: str, T: str) -> bool: def check(S): S_new = [] for w in S: if w != "#": S_new.append(w) elif len(S_new): S_new.pop() return S_new return check(S) == check(T) ### Two Pointer ###
class Solution1: def backspace_compare(self, S: str, T: str) -> bool: def check(S): s_new = [] for w in S: if w != '#': S_new.append(w) elif len(S_new): S_new.pop() return S_new return check(S) == check(T)
class DiGraph: def __init__(self): self.nodes = dict() self.edges = [] def copy(self): H_ = __class__() H_.add_edges_from(self.edges) return H_ def __eq__(self, other): return len(set(self.edges) ^ set(other.edges)) == 0 def __str__(self): return str(self.edges) __repr__ = __str__ def maximal_non_branching_paths(self): # return list of paths (made up of graph nodes) paths = [] visited_edges = set() for node in self.nodes: if not self.is_1_in_1_out(node): if self.out_degree(node) > 0: out_edges = self.nodes[node]['out_edges'] for edge in out_edges: visited_edges.add(edge) to_node = edge.node_b non_branching_path = [edge] while self.is_1_in_1_out(to_node): out_edge = self.nodes[to_node]['out_edges'][0] non_branching_path.append(out_edge) visited_edges.add(out_edge) to_node = out_edge.node_b paths.append(non_branching_path) # everything left must be in a cycle cycle_edges = set( filter( lambda edge: edge not in visited_edges, self.edges)) while len(cycle_edges) > 0: edge = cycle_edges.pop() non_branching_path = [edge] start_node = edge.node_a to_node = edge.node_b while to_node != start_node: out_edge = self.nodes[to_node]['out_edges'][0] non_branching_path.append(out_edge) cycle_edges.remove(out_edge) visited_edges.add(out_edge) to_node = out_edge.node_b paths.append(non_branching_path) return paths def neighbor_graphs(self, sub_graph, super_graph, k): # generator for the k-plus neighbors if k >= 0: yield sub_graph for neighbor in sub_graph.plus_neighbors(super_graph): yield from neighbor.neighbor_graphs(neighbor, super_graph, k - 1) def adjacent_graphs(self, sub_graph, super_graph, k): if k >= 0: yield sub_graph for neighbor in sub_graph.plus_neighbors(super_graph): yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1) for neighbor in sub_graph.minus_neighbors(): yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1) def plus_neighbor_edges(self, super_graph): # TODO this is ugly, make neater paths = list() # first generate paths for edge in self.edges: from_, to = edge.node_a, edge.node_b from_super_edges = super_graph.nodes[to]['out_edges'] to_super_edges = super_graph.nodes[from_]['in_edges'] def not_in_H(edge): return edge not in self.edges from_super_edges = filter(not_in_H, from_super_edges) to_super_edges = filter(not_in_H, to_super_edges) paths.extend(from_super_edges) paths.extend(to_super_edges) from_super_edges = super_graph.nodes[from_]['out_edges'] to_super_edges = super_graph.nodes[to]['in_edges'] def not_in_H(edge): return edge not in self.edges from_super_edges = filter(not_in_H, from_super_edges) to_super_edges = filter(not_in_H, to_super_edges) paths.extend(from_super_edges) paths.extend(to_super_edges) paths = set(paths) return paths def plus_neighbors(self, super_graph): paths = self.plus_neighbor_edges(super_graph) # then generate a graph for each unique path for path in paths: H_ = self.copy() H_.add_edge(path) yield H_ def minus_neighbors(self): for edge in self.edges: H_ = self.copy() H_.remove_edge(edge) yield H_ def add_edge(self, edge): node_a, node_b = edge.node_a, edge.node_b self.add_node(node_a) self.add_node(node_b) self.nodes[node_a]['out_edges'].append(edge) self.nodes[node_b]['in_edges'].append(edge) self.edges.append(edge) def add_node(self, node): if node not in self.nodes: self.nodes[node] = {'in_edges': [], 'out_edges': []} def in_degree(self, node): return len(self.nodes[node]['in_edges']) def out_degree(self, node): return len(self.nodes[node]['out_edges']) def is_1_in_1_out(self, node): return self.in_degree(node) == 1 and self.out_degree(node) == 1 def add_edges_from(self, edges): for edge in edges: self.add_edge(edge) def add_nodes_from(self, nodes): for node in nodes: self.add_node(node) def remove_edge(self, edge): node_a, node_b = edge.node_a, edge.node_b self.nodes[node_a]['out_edges'].remove(edge) self.nodes[node_b]['in_edges'].remove(edge) self.edges.remove(edge) if len(self.nodes[node_a]['out_edges']) + \ len(self.nodes[node_a]['in_edges']) == 0: self.nodes.pop(node_a) if len(self.nodes[node_b]['out_edges']) + \ len(self.nodes[node_b]['in_edges']) == 0: self.nodes.pop(node_b) def remove_node(self, node): for edge in self.nodes[node]['in_edges']: self.remove_edge(edge) for edge in self.nodes[node]['out_edges']: self.remove_edge(edge) assert node not in self.nodes def remove_edges_from(self, edges): for edge in edges: self.remove_edge(edge) def remove_nodes_from(self, nodes): for node in nodes: self.remove_node(node) def subgraph_from_edgelist(self, edges): # TODO assert edges are in graph pass class RedBlueDiGraph(DiGraph): RED = 'red' BLUE = 'blue' def __init__(self): super(RedBlueDiGraph, self).__init__() self.coverage = 0 self.color = dict() def __str__(self): return str([(edge, self.color[edge]) for edge in self.edges]) def copy(self): H_ = __class__() colors = [self.color[edge] for edge in self.edges] H_.add_edges_from(self.edges, colors=colors) H_.coverage = self.coverage #H_.color = dict(self.color) return H_ def score(self, alpha): paths = self.maximal_non_branching_paths() total_path_length = sum([len(path) for path in paths]) avg_path_length = total_path_length / \ len(paths) if len(paths) > 0 else 0 return alpha * self.coverage + (1 - alpha) * avg_path_length def add_edge(self, edge, color): super(RedBlueDiGraph, self).add_edge(edge) if color == self.RED: self.color[edge] = self.RED self.coverage += 1 else: self.coverage -= 1 self.color[edge] = self.BLUE def add_edges_from(self, edges, colors=None): if colors is not None: assert len(colors) == len(edges) for i, edge in enumerate(edges): self.add_edge(edge, color=colors[i]) else: super(RedBlueDiGraph, self).add_edges_from(edges) def plus_neighbors(self, super_graph): paths = self.plus_neighbor_edges(super_graph) # then generate a graph for each unique path for path in paths: H_ = self.copy() H_.add_edge(path, color=super_graph.color[path]) yield H_ def calculate_coverage(self): return self.coverage def remove_edge(self, edge): if self.color[edge] == self.RED: self.coverage -= 1 else: self.coverage += 1 super(RedBlueDiGraph, self).remove_edge(edge) if edge not in self.edges: self.color.pop(edge)
class Digraph: def __init__(self): self.nodes = dict() self.edges = [] def copy(self): h_ = __class__() H_.add_edges_from(self.edges) return H_ def __eq__(self, other): return len(set(self.edges) ^ set(other.edges)) == 0 def __str__(self): return str(self.edges) __repr__ = __str__ def maximal_non_branching_paths(self): paths = [] visited_edges = set() for node in self.nodes: if not self.is_1_in_1_out(node): if self.out_degree(node) > 0: out_edges = self.nodes[node]['out_edges'] for edge in out_edges: visited_edges.add(edge) to_node = edge.node_b non_branching_path = [edge] while self.is_1_in_1_out(to_node): out_edge = self.nodes[to_node]['out_edges'][0] non_branching_path.append(out_edge) visited_edges.add(out_edge) to_node = out_edge.node_b paths.append(non_branching_path) cycle_edges = set(filter(lambda edge: edge not in visited_edges, self.edges)) while len(cycle_edges) > 0: edge = cycle_edges.pop() non_branching_path = [edge] start_node = edge.node_a to_node = edge.node_b while to_node != start_node: out_edge = self.nodes[to_node]['out_edges'][0] non_branching_path.append(out_edge) cycle_edges.remove(out_edge) visited_edges.add(out_edge) to_node = out_edge.node_b paths.append(non_branching_path) return paths def neighbor_graphs(self, sub_graph, super_graph, k): if k >= 0: yield sub_graph for neighbor in sub_graph.plus_neighbors(super_graph): yield from neighbor.neighbor_graphs(neighbor, super_graph, k - 1) def adjacent_graphs(self, sub_graph, super_graph, k): if k >= 0: yield sub_graph for neighbor in sub_graph.plus_neighbors(super_graph): yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1) for neighbor in sub_graph.minus_neighbors(): yield from neighbor.adjacent_graphs(neighbor, super_graph, k - 1) def plus_neighbor_edges(self, super_graph): paths = list() for edge in self.edges: (from_, to) = (edge.node_a, edge.node_b) from_super_edges = super_graph.nodes[to]['out_edges'] to_super_edges = super_graph.nodes[from_]['in_edges'] def not_in_h(edge): return edge not in self.edges from_super_edges = filter(not_in_H, from_super_edges) to_super_edges = filter(not_in_H, to_super_edges) paths.extend(from_super_edges) paths.extend(to_super_edges) from_super_edges = super_graph.nodes[from_]['out_edges'] to_super_edges = super_graph.nodes[to]['in_edges'] def not_in_h(edge): return edge not in self.edges from_super_edges = filter(not_in_H, from_super_edges) to_super_edges = filter(not_in_H, to_super_edges) paths.extend(from_super_edges) paths.extend(to_super_edges) paths = set(paths) return paths def plus_neighbors(self, super_graph): paths = self.plus_neighbor_edges(super_graph) for path in paths: h_ = self.copy() H_.add_edge(path) yield H_ def minus_neighbors(self): for edge in self.edges: h_ = self.copy() H_.remove_edge(edge) yield H_ def add_edge(self, edge): (node_a, node_b) = (edge.node_a, edge.node_b) self.add_node(node_a) self.add_node(node_b) self.nodes[node_a]['out_edges'].append(edge) self.nodes[node_b]['in_edges'].append(edge) self.edges.append(edge) def add_node(self, node): if node not in self.nodes: self.nodes[node] = {'in_edges': [], 'out_edges': []} def in_degree(self, node): return len(self.nodes[node]['in_edges']) def out_degree(self, node): return len(self.nodes[node]['out_edges']) def is_1_in_1_out(self, node): return self.in_degree(node) == 1 and self.out_degree(node) == 1 def add_edges_from(self, edges): for edge in edges: self.add_edge(edge) def add_nodes_from(self, nodes): for node in nodes: self.add_node(node) def remove_edge(self, edge): (node_a, node_b) = (edge.node_a, edge.node_b) self.nodes[node_a]['out_edges'].remove(edge) self.nodes[node_b]['in_edges'].remove(edge) self.edges.remove(edge) if len(self.nodes[node_a]['out_edges']) + len(self.nodes[node_a]['in_edges']) == 0: self.nodes.pop(node_a) if len(self.nodes[node_b]['out_edges']) + len(self.nodes[node_b]['in_edges']) == 0: self.nodes.pop(node_b) def remove_node(self, node): for edge in self.nodes[node]['in_edges']: self.remove_edge(edge) for edge in self.nodes[node]['out_edges']: self.remove_edge(edge) assert node not in self.nodes def remove_edges_from(self, edges): for edge in edges: self.remove_edge(edge) def remove_nodes_from(self, nodes): for node in nodes: self.remove_node(node) def subgraph_from_edgelist(self, edges): pass class Redbluedigraph(DiGraph): red = 'red' blue = 'blue' def __init__(self): super(RedBlueDiGraph, self).__init__() self.coverage = 0 self.color = dict() def __str__(self): return str([(edge, self.color[edge]) for edge in self.edges]) def copy(self): h_ = __class__() colors = [self.color[edge] for edge in self.edges] H_.add_edges_from(self.edges, colors=colors) H_.coverage = self.coverage return H_ def score(self, alpha): paths = self.maximal_non_branching_paths() total_path_length = sum([len(path) for path in paths]) avg_path_length = total_path_length / len(paths) if len(paths) > 0 else 0 return alpha * self.coverage + (1 - alpha) * avg_path_length def add_edge(self, edge, color): super(RedBlueDiGraph, self).add_edge(edge) if color == self.RED: self.color[edge] = self.RED self.coverage += 1 else: self.coverage -= 1 self.color[edge] = self.BLUE def add_edges_from(self, edges, colors=None): if colors is not None: assert len(colors) == len(edges) for (i, edge) in enumerate(edges): self.add_edge(edge, color=colors[i]) else: super(RedBlueDiGraph, self).add_edges_from(edges) def plus_neighbors(self, super_graph): paths = self.plus_neighbor_edges(super_graph) for path in paths: h_ = self.copy() H_.add_edge(path, color=super_graph.color[path]) yield H_ def calculate_coverage(self): return self.coverage def remove_edge(self, edge): if self.color[edge] == self.RED: self.coverage -= 1 else: self.coverage += 1 super(RedBlueDiGraph, self).remove_edge(edge) if edge not in self.edges: self.color.pop(edge)
''' Problem 34 @author: Kevin Ji ''' FACTORIALS = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800] def factorial(number): return FACTORIALS[number] def is_curious_num(number): temp_num = number curious_sum = 0 while temp_num > 0: curious_sum += factorial(temp_num % 10) temp_num //= 10 return number == curious_sum # Tests #print(is_curious_num(145)) # True #print(is_curious_num(100)) # False cur_sum = 0 for num in range(3, 1000000): if is_curious_num(num): cur_sum += num print(cur_sum)
""" Problem 34 @author: Kevin Ji """ factorials = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800] def factorial(number): return FACTORIALS[number] def is_curious_num(number): temp_num = number curious_sum = 0 while temp_num > 0: curious_sum += factorial(temp_num % 10) temp_num //= 10 return number == curious_sum cur_sum = 0 for num in range(3, 1000000): if is_curious_num(num): cur_sum += num print(cur_sum)
n= int(input("Digite o valor de n: ")) sub = n - 1 fat = n while n != 0: while sub != 1: fat = fat * sub sub = sub -1 print(fat)
n = int(input('Digite o valor de n: ')) sub = n - 1 fat = n while n != 0: while sub != 1: fat = fat * sub sub = sub - 1 print(fat)
class Neuron: # TODO: Create abstraction of generic unsupervised neuron pass
class Neuron: pass
expected_output = { 'switch': { "1": { 'system_temperature_state': 'ok', } } }
expected_output = {'switch': {'1': {'system_temperature_state': 'ok'}}}
def addition(x: int, y: int) -> int: """Adds two integers together and returns the result.""" return x + y if __name__ == '__main__': a, b = 1, 2 result = addition(a, b) print(result)
def addition(x: int, y: int) -> int: """Adds two integers together and returns the result.""" return x + y if __name__ == '__main__': (a, b) = (1, 2) result = addition(a, b) print(result)
"""6.1.3 Circular Definition of Product ID For each new defined Product ID (type /$defs/product_id_t) in items of relationships (/product_tree/relationships) it must be tested that the product_id does not end up in a cirle. The relevant path for this test is: /product_tree/relationships[]/full_product_name/product_id As this can be quite complex a program for large CSAF documents, a program could check first whether a Product ID defined in a relationship item is used as product_reference or relates_to_product_reference. Only for those which fulfill this condition it is necessary to run the full check following the references. Example 42 which fails the test: "product_tree": { "full_product_names": [ { "product_id": "CSAFPID-9080700", "name": "Product A" } ], "relationships": [ { "category": "installed_on", "full_product_name": { "name": "Product B", "product_id": "CSAFPID-9080701" }, "product_reference": "CSAFPID-9080700", "relates_to_product_reference": "CSAFPID-9080701" } ] } CSAFPID-9080701 refers to itself - this is a circular definition. """ ID = (6, 1, 3) TOPIC = 'Circular Definition of Product ID' PATHS = ('/product_tree/relationships[]/full_product_name/product_id',)
"""6.1.3 Circular Definition of Product ID For each new defined Product ID (type /$defs/product_id_t) in items of relationships (/product_tree/relationships) it must be tested that the product_id does not end up in a cirle. The relevant path for this test is: /product_tree/relationships[]/full_product_name/product_id As this can be quite complex a program for large CSAF documents, a program could check first whether a Product ID defined in a relationship item is used as product_reference or relates_to_product_reference. Only for those which fulfill this condition it is necessary to run the full check following the references. Example 42 which fails the test: "product_tree": { "full_product_names": [ { "product_id": "CSAFPID-9080700", "name": "Product A" } ], "relationships": [ { "category": "installed_on", "full_product_name": { "name": "Product B", "product_id": "CSAFPID-9080701" }, "product_reference": "CSAFPID-9080700", "relates_to_product_reference": "CSAFPID-9080701" } ] } CSAFPID-9080701 refers to itself - this is a circular definition. """ id = (6, 1, 3) topic = 'Circular Definition of Product ID' paths = ('/product_tree/relationships[]/full_product_name/product_id',)