Look up a vmeta based on an Anno
198850
def lookup_annotype_converter(cls, anno):
        # type: (Anno) -> Type[VMeta]
        """"""
        if hasattr(anno.typ, "__bases__"):
            # This is a proper type
            bases = inspect.getmro(anno.typ)
        else:
            # This is a numpy dtype
            bases = [anno.typ]
        for typ in bases:
            key = (typ, bool(anno.is_array), bool(anno.is_mapping))
            try:
                return cls._annotype_lookup[key]
            except KeyError:
                pass
        raise KeyError(anno)
654262
def _gorg(a):
    """"""
    assert isinstance(a, GenericMeta)
    while a.__origin__ is not None:
        a = a.__origin__
    return a
1280707
def _get_default_locs(self, vmin, vmax):
        ""

        if self.plot_obj.date_axis_info is None:
            self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq)

        locator = self.plot_obj.date_axis_info

        if self.isminor:
            return np.compress(locator['min'], locator['val'])
        return np.compress(locator['maj'], locator['val'])
128103
def lookup_facade(name, version):
    
    for _version in range(int(version), 0, -1):
        try:
            facade = getattr(CLIENTS[str(_version)], name)
            return facade
        except (KeyError, AttributeError):
            continue
    else:
        raise ImportError("No supported version for facade: "
                          "{}".format(name))
139009
def _IsMariaDB(cursor):
  """"""
  for variable in ["version", "version_comment"]:
    cursor.execute("SHOW VARIABLES LIKE %s;", (variable,))
    version = cursor.fetchone()
    if version and "MariaDB" in version[1]:
      return True
  return False
516922
def _get_vms_from_directory(self, directory):
        

        vmware_vms = []
        log.info('Searching for VMware VMs in directory "{}"'.format(directory))
        for path, _, filenames in os.walk(directory):
            for filename in filenames:
                if os.path.splitext(filename)[1] == ".vmx":
                    vmx_path = os.path.join(path, filename)
                    log.debug('Reading VMware VMX file "{}"'.format(vmx_path))
                    try:
                        pairs = self.parse_vmware_file(vmx_path)
                        if "displayname" in pairs:
                            log.debug('Found VM named "{}"'.format(pairs["displayname"]))
                            vmware_vms.append({"vmname": pairs["displayname"], "vmx_path": vmx_path})
                    except OSError as e:
                        log.warning('Could not read VMware VMX file "{}": {}'.format(vmx_path, e))
                        continue
        return vmware_vms
953777
def _get_vm_by_id(vmid, allDetails=False):
    '''
    
    '''
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=allDetails)):
        if six.text_type(vm_details['vmid']) == six.text_type(vmid):
            return vm_details

    log.info('VM with ID "%s" could not be found.', vmid)
    return False
936169
def anno_parser(func):
    ""
    p = ArgumentParser(description=func.__doc__)
    for k,v in inspect.signature(func).parameters.items():
        param = func.__annotations__.get(k, Param())
        kwargs = param.kwargs
        if v.default != inspect.Parameter.empty: kwargs['default'] = v.default
        p.add_argument(f"{param.pre}{k}", **kwargs)
    return p
854690
def get_content_metadata(id, version, cursor):
    """"""
    # Do the module lookup
    args = dict(id=id, version=version)
    # FIXME We are doing two queries here that can hopefully be
    #       condensed into one.
    cursor.execute(SQL['get-module-metadata'], args)
    try:
        result = cursor.fetchone()[0]
        # version is what we want to return, but in the sql we're using
        # current_version because otherwise there's a "column reference is
        # ambiguous" error
        result['version'] = result.pop('current_version')

        # FIXME We currently have legacy 'portal_type' names in the database.
        #       Future upgrades should replace the portal type with a mimetype
        #       of 'application/vnd.org.cnx.(module|collection|folder|<etc>)'.
        #       Until then we will do the replacement here.
        result['mediaType'] = portaltype_to_mimetype(result['mediaType'])

        return result
    except (TypeError, IndexError,):  # None returned
        raise httpexceptions.HTTPNotFound()
96216
def _vmomentsurfacemassGrid(self,n,m,grid):
        """"""
        if len(grid.df.shape) == 3: tlist= True
        else: tlist= False
        if tlist: 
            nt= grid.df.shape[2]
            out= []
            for ii in range(nt):
                out.append(nu.dot(grid.vRgrid**n,nu.dot(grid.df[:,:,ii],grid.vTgrid**m))*\
                    (grid.vRgrid[1]-grid.vRgrid[0])*(grid.vTgrid[1]-grid.vTgrid[0]))
            return nu.array(out)
        else:
            return nu.dot(grid.vRgrid**n,nu.dot(grid.df,grid.vTgrid**m))*\
                (grid.vRgrid[1]-grid.vRgrid[0])*(grid.vTgrid[1]-grid.vTgrid[0])
1029400
def vMh2_to_m2Lambda(v, Mh2, C, scale_high):
    """"""
    if C['phi'] == 0 and C['phiBox'] == 0 and C['phiD'] == 0:
        return _vMh2_to_m2Lambda_SM(v, Mh2)
    else:
        def f0(x):  # we want the root of this function
            m2, Lambda = x
            d = m2Lambda_to_vMh2(m2=m2.real, Lambda=Lambda.real,
                                 C=C, scale_high=scale_high)
            return np.array([d['v'] - v, d['Mh2'] - Mh2])
        dSM = _vMh2_to_m2Lambda_SM(v, Mh2)
        x0 = np.array([dSM['m2'], dSM['Lambda']])
        try:
            xres = scipy.optimize.newton_krylov(f0, x0)
        except scipy.optimize.nonlin.NoConvergence:
            raise ValueError("No solution for m^2 and Lambda found")
        return {'m2': xres[0], 'Lambda': xres[1]}
658772
def v2(self):
        """"""
        Vm = self.system.dae.y[self.v]
        Va = self.system.dae.y[self.a]
        return polar(Vm[self.a2], Va[self.a2])
1189286
def get_network_adapter_type(adapter_type):
    '''
    
    '''
    if adapter_type == 'vmxnet':
        return vim.vm.device.VirtualVmxnet()
    elif adapter_type == 'vmxnet2':
        return vim.vm.device.VirtualVmxnet2()
    elif adapter_type == 'vmxnet3':
        return vim.vm.device.VirtualVmxnet3()
    elif adapter_type == 'e1000':
        return vim.vm.device.VirtualE1000()
    elif adapter_type == 'e1000e':
        return vim.vm.device.VirtualE1000e()

    raise ValueError('An unknown network adapter object type name.')
210590
public static boolean areSameByClass(AnnotationMirror am, Class<? extends Annotation> anno) {
        return areSameByName(am, anno.getCanonicalName().intern());
    }
813521
def vb_get_manager():
    '''
    
    '''
    global _virtualboxManager
    if _virtualboxManager is None and HAS_LIBS:
        salt.utils.compat.reload(vboxapi)
        _virtualboxManager = vboxapi.VirtualBoxManager(None, None)

    return _virtualboxManager
774774
def get_vm(self, name, path=""):
        """"""
        if path:
            return self.get_obj([vim.VirtualMachine], name, path=path)
        else:
            return self.get_obj([vim.VirtualMachine], name)
799169
def getVoxelsScalar(self, vmin=None, vmax=None):
                
        nx, ny, nz = self.image.GetDimensions()
        
        voxdata = np.zeros([nx, ny, nz])
        lsx = range(nx)
        lsy = range(ny)
        lsz = range(nz)
        renorm = vmin is not None and vmax is not None
        for i in lsx:
            for j in lsy:
                for k in lsz:
                    s = self.image.GetScalarComponentAsFloat(i, j, k, 0)
                    if renorm:
                        s = (s - vmin) / (vmax - vmin)
                    voxdata[i, j, k] = s
        return voxdata