def finish_processing(self): self._clean() self._create_dummy_wrappers() if self.is_root(): self._add_predefined_symbols() Registry.sort_out() if self.processing_done_listener: self.processing_done_listener.on_processing_done(self)
def _expose_shadowed_non_virtuals(self): assert self.allows_subclassing() # Expose non-virtual methods shadowed by their virtual peers # overrode in the helper class concise_vm = set([vm.name for vm in self.virtual_members]) for overloads in self.methods.methods.values(): for m in overloads: if not m.virtual and m.name in concise_vm: self.protected_nonvirtual_members.add( "using %s::%s;" % (self.full_name, m.name )) if m.access == Access.PUBLIC: self.public_nonvirtual_methods.append({ "DECL": "using %s::%s;" % (self.full_name, m.name), "REF": m }) # Supplement with bases' shadowed public methods for bname in self.direct_bases: base = Registry.get_class(bname) for mm in base.public_nonvirtual_methods: # Subclass don't override this virtual member. Skip it. if mm["REF"].name in self.methods.methods: self.protected_nonvirtual_members.add(mm["DECL"]) self.methods.methods[mm["REF"].name].append(mm["REF"]) self.public_nonvirtual_methods += base.public_nonvirtual_methods
def collect_virtual_members(self): if not self.base_vm_collected and self.allows_subclassing(): virtual_members = [] private_non_pure_virtuals = [] for vm in self.virtual_members: if vm.access == Access.PRIVATE and not vm.pure_virtual: private_non_pure_virtuals.append(vm) elif not vm.final: virtual_members.append(vm) signitures = {vm.sig() for vm in self.virtual_members} for bname in self.direct_bases: for vm in Registry.get_class(bname).collect_virtual_members(): if vm.sig() not in signitures: virtual_members.append(vm) self.virtual_members = virtual_members self.base_vm_collected = True self.methods.remove_private_non_pure_virtuals(private_non_pure_virtuals) self._expose_shadowed_non_virtuals() return self.virtual_members
def _create_dummy_wrappers(self): assert self.header_decl is None namespace = self._get_cxx_namespace() down = False for ddef in self.blacklist.dummy_classes.values(): if Registry.get_class(ddef.full_name): continue if ddef.namespace != namespace: down = True continue cls = Class.Class(self.root, None, self, ddef) if ddef.header: cls.set_header(ddef.header) self.register_class(cls) self.modified = True if down: for submodule in self.submodules: # noinspection PyProtectedMember submodule._create_dummy_wrappers()
def _register_classes(self, block, outdir, ext): assert self.is_root() modules = set() declarations = [] invoke = [] for cls in Registry.get_sorted(): if cls.mod != 'm': modules.add("extern PyObject *%s;" % cls.mod) register = self.namer.class_register(cls.full_name) declarations.append("void %s(PyObject *m);" % register) invoke.append("%s(%s);" % (register, cls.mod)) pyside = self.namer.to_python(cls.full_name) path = "%s%s%s.py%s" % (outdir, os.path.sep, pyside, ext) if cls.modified or not os.path.exists(path): cls.generate() content = cls.block.flush() content = self.blacklist.hook_write(cls.full_name, content) Util.smart_write(path, content) for lines in (declarations, modules, invoke): if len(lines) > 0: block.write_lines(lines) block.append_blank_line()
def is_derived_from(self, base): if base in self.direct_bases: return True for b in self.direct_bases: if Registry.get_class(b).is_derived_from(base): return True return False
def get_class(self): try: cls = Registry.get_class(self.intrinsic_type()) assert cls is not None return cls except: from logging import exception exception("Class `%s` not found in the registry", self.intrinsic_type()) raise
def collect_all_bases(self): if self.all_bases is None: self.all_bases = set(self.direct_bases) self.master_bases = set() if len(self.direct_bases) > 0: self.master_bases.add(self.direct_bases[0]) for index, base_name in enumerate(self.direct_bases): base = Registry.get_class(base_name) base.collect_all_bases() self.all_bases |= base.all_bases if index == 0: self.master_bases |= base.master_bases
result = eval(script, globals(), locals()) except SyntaxError: exec(script, globals(), locals()) # Check if the evaluation was successful and if so report it in the results field # Add the results to the environment if result is not None: message = str(result) self.environment['_'] = message print(message) except: # Get the traceback information and add the formatted output to the results field import traceback, sys exceptionType, exception, tb = sys.exc_info() entries = traceback.extract_tb(tb) entries.pop(0) # Build and print a list containing the error report lines = [] if entries: lines += traceback.format_list(entries) lines += traceback.format_exception_only(exceptionType, exception) for line in lines: print line # Register Ops Registry.registerOp('Python Script', Python)
atLocation=attrs['cameraLocations'], default=False) if self.mats is None or updateMats: self.mats = [] for i in xrange(img_count): self.mats.append( Calibrate.makeUninitialisedMat(i, (vheight, vwidth))) interface.setAttr('updateMats', False, atLocation=attrs['cameraLocations']) self.camAttrs = { 'vheight': [vheight] * img_count, 'vwidth': [vwidth] * img_count, 'camera_ids': range(img_count), 'mats': self.mats, 'updateImage': True, 'jpegimgs': imgs, 'updateMats': updateMats } for k, v in self.camAttrs.iteritems(): interface.setAttr(k, v) # Register Ops import Registry Registry.registerOp('Video Sequence', Sequence) Registry.registerOp('Video Capture', Capture)
def register_class(self, cls): self.classes[cls.full_name] = cls Registry.add_class(cls)
def discovery_auto(): d = Registry.AutoDiscovery(registry, fsk_router)
def discovery_ask(ask_fn): d = Registry.ConfirmedDiscovery(registry, fsk_router, ask_fn)
def discovery_autojoin(): d = Registry.JoinAutoDiscovery(registry, fsk_router)
def addOpMenu(self, win): # Add ops to the menu in alphabetical order registeredOps = Registry.getRegisteredOps() opNames = registeredOps.keys() opNames.sort() for opName in opNames: win.addMenuItem({ 'menu': '&Add Op', 'item': opName, 'tip': '', 'cmd': self._addOp, 'args': [registeredOps[opName], win] }) editMenu = win.getOrCreateMenu('&Edit') editMenu.addSeparator() win.addMenuItem({ 'menu': '&Edit', 'item': 'Flush', 'shortcut': 'Ctrl+F', 'tip': 'Flushes state and interface (cooked) data, and layers', 'cmd': self.flush, 'args': [True] }) win.addMenuItem({ 'menu': '&Edit', 'item': 'Soft Flush', 'tip': 'Retains cooked data', 'cmd': self.flush, 'args': [False] }) win.addMenuItem({ 'menu': '&Edit', 'item': 'Refresh', 'tip': 'Refresh', 'cmd': self.refresh, 'args': [] }) editMenu.addSeparator() win.addMenuItem({ 'menu': '&Edit', 'item': 'Load Cache..', 'tip': 'Load Op Interface Cache', 'cmd': self.loadCache, 'args': [] }) win.addMenuItem({ 'menu': '&Edit', 'item': 'Save Cache..', 'tip': 'Save Op Interface Cache', 'cmd': self.saveCache, 'args': [] }) win.addMenuItem({ 'menu': '&Edit', 'item': 'Disable Cache', 'tip': 'Disable Cache', 'cmd': self.setUseCache, 'args': [False] }) win.addMenuItem({ 'menu': '&Edit', 'item': 'Enable Cache', 'tip': 'Enable Cache', 'cmd': self.setUseCache, 'args': [True] })
def registeredComponentsInCategory(category): global _registry return _registry.types.get(category) or [] def componentfactory(category, type): global _registry return _registry.getFactory(category, type) def componentinfo(category, type): global _registry return _registry.getInfo(category, type) def registercomponent(category, type, factory): global _registry _registry.register(category, type, factory) return import Registry from Registry import Registry _registry = Registry() del Registry # version __id__ = "$Id$" # End of file
def Registry(self): return registry.Registry(self.contract, self.contract.address)
def discovery_askjoin(ask_fn): d = Registry.JoinConfirmedDiscovery(registry, fsk_router, ask_fn)
else: labels[rayIndices[goodRays]] = labelForPointReconstruction if useNewLabel: labelPositions[currentLabel] = clusterMean labelsAdded.append(currentLabel) goldStandardLabels = np.where(labels != -1)[0] if len(np.where(labels != -1)[0]) == 0: return np.array([]), np.array([]), np.array([]), rawData, labelsAdded # x3ds_means, x3ds_labels, _, _ = Recon.solve_x3ds(x2ds, splits, labels, Ps) x3ds_means, x3ds_labels, x3ds_normals, _, _ = Recon.solve_x3ds_normals( x2ds, splits, labels, Ps, rays) # x2d_threshold = 30. / 2000. # clouds = ISCV.HashCloud2DList(x2ds, splits, x2d_threshold) # _, labels, _ = clouds.project_assign_visibility(x3ds_means, None, Ps, x2d_threshold, visibility) labellingData.labels = labels usedLabels = np.array(np.where(labels != -1)[0], dtype=np.int32) return x3ds_means, x3ds_labels, x3ds_normals, rawData, labelsAdded # Register Ops import Registry Registry.registerOp('Reconstruct 3D from Dets', PointsFromDetections) Registry.registerOp('Reconstruct 3D from Dets (all)', PointsFromDetectionsAll)
help="Interface to listen on for http connections") config.add_option("HTTPSERVER_PORT", default=8000, type='int', help="TCP Port to listen on for http connections") if __name__ == "__main__": ## Parse the command line args: config.set_usage(usage="The main PyFlag HTTP Server.") ## make sure all the modules were parsed to ensure that all the ## options are collected import Registry Registry.Init() config.add_option( "info", default=False, action='store_true', help="Print information about this pyflag installation and exit") ## Parse all the command line options: config.parse_options() if config.info: print Framework.print_info() sys.exit(0) try:
""" stub.py - a program that does nothing by C.J. Steele <*****@*****.**> """ import sys, os sys.path.append(os.getcwd()) from Registry import * from Plugins import * from Logger import * reg = Registry() conf = [] conf = reg.getScope("global.%") logger = Logger(["f", conf['global.logfile']]) logger.setLevel(conf['global.loglevel']) logger.debug("__BEGIN__") # put your code here. # end your code here logger.debug("__END__") #__EOF__
def Registry(self): return registry.Registry(self.contract, self.account)
class SkeletonJoints(Op.Op): def __init__(self, name='/Collect_Skeleton_Joints', locations='', frameRange='', exportRule='', exportPath=''): fields = [ ('name', 'Name', 'Name', 'string', name, {}), ('locations', 'Skeleton locations', 'locations', 'string', locations, {}), ('frameRange', 'Frame range', 'Frame range', 'string', frameRange, {}), ('exportRule', 'Export on frames', 'Export on frames', 'string', exportRule, {}), ('exportPath', 'Export path', 'Export path', 'string', exportPath, {}) ] super(self.__class__, self).__init__(name, fields) self.jointChannelFrames = [] def cook(self, location, interface, attrs): if not self.useFrame(interface.frame(), attrs['frameRange']): return skelDict = interface.attr('skelDict') if not skelDict: return self.jointChannelFrames.append(skelDict['chanValues'].copy()) if attrs['exportRule'] and self.useFrame(interface.frame(), attrs['exportRule']): from IO import IO exportPath = self.resolvePath(attrs['exportPath']) IO.save(exportPath, self.jointChannelFrames) # Register Ops import Registry Registry.registerOp('Collect 2D and 3D', WandDetectionsAnd3Ds)