Try and find a container in a variety of methods
776710
def _setup_container(container_name):
    
    for meth in (database.load_container,
                 load_new_labware,
                 _load_weird_container):
        log.debug(
            f"Trying to load container {container_name} via {meth.__name__}")
        try:
            container = meth(container_name)
            if meth == _load_weird_container:
                container.properties['type'] = container_name
            log.info(f"Loaded {container_name} from {meth.__name__}")
            break
        except (ValueError, KeyError):
            log.info(f"{container_name} not in {meth.__name__}")
    else:
        raise KeyError(f"Unknown labware {container_name}")

    container_x, container_y, container_z = container._coordinates

    # infer z from height
    if container_z == 0 and 'height' in container[0].properties:
        container_z = container[0].properties['height']

    from opentrons.util.vector import Vector
    container._coordinates = Vector(
        container_x,
        container_y,
        container_z)

    return container
1095598
def method_missing(m, *args, &block)
      if block = ChefSpec.matchers[resource_name(m.to_sym)]
        instance_exec(args.first, &block)
      else
        super
      end
    end
829340
function(cid) {

    // Find a generic container.
    return findGenericContainer(cid)
    .then(function(container) {
      if (container) {
        // Map container id to a docker container.
        return dockerInstance().call('getContainer', container.id);
      } else {
        return undefined;
      }
    });

  }
618930
function methodMatch(part) {
    let maxMatch = null
    let maxMatchCount = 0

    // Go through each mapper and check if the name matches. Then, take the highest match to avoid matching
    // 'any', if 'any character' was given, and so on.
    Object.keys(mapper).forEach((key) => {
        const regex = new RegExp(`^(${key.replace(' ', ') (')})`, 'i')
        const matches = part.match(regex)

        const count = matches ? matches.length : 0

        if (count > maxMatchCount) {
            maxMatchCount = count
            maxMatch = key
        }
    })

    if (maxMatch) {
        // We've got a match. Create the desired object and populate it.
        const item = mapper[maxMatch]
        return new item['class'](maxMatch, item.method, buildQuery)
    }

    throw new SyntaxException(`Invalid method: ${part}`)
}
576764
function (container) {
        var matches = [], i, l, selectors = this._selectors;

        function collect(items, selector, index) {
          var i, l, fi, fl, item, filters = selector[index];

          for (i = 0, l = items.length; i < l; i++) {
            item = items[i];

            // Run each filter against the item
            for (fi = 0, fl = filters.length; fi < fl; fi++) {
              if (!filters[fi](item, i, l)) {
                fi = fl + 1;
                break;
              }
            }

            // All filters matched the item
            if (fi === fl) {
              // Matched item is on the last expression like: panel toolbar [button]
              if (index == selector.length - 1) {
                matches.push(item);
              } else {
                // Collect next expression type
                if (item.items) {
                  collect(item.items(), selector, index + 1);
                }
              }
            } else if (filters.direct) {
              return;
            }

            // Collect child items
            if (item.items) {
              collect(item.items(), selector, index);
            }
          }
        }

        if (container.items) {
          for (i = 0, l = selectors.length; i < l; i++) {
            collect(container.items(), selectors[i], 0);
          }

          // Unique the matches if needed
          if (l > 1) {
            matches = unique(matches);
          }
        }

        // Fix for circular reference
        if (!Collection) {
          // TODO: Fix me!
          Collection = Selector.Collection;
        }

        return new Collection(matches);
      }
590802
def _container_getitem(instance, elts, index, context=None):
    """"""
    try:
        if isinstance(index, Slice):
            index_slice = _infer_slice(index, context=context)
            new_cls = instance.__class__()
            new_cls.elts = elts[index_slice]
            new_cls.parent = instance.parent
            return new_cls
        if isinstance(index, Const):
            return elts[index.value]
    except IndexError as exc:
        raise exceptions.AstroidIndexError(
            message="Index {index!s} out of range",
            node=instance,
            index=index,
            context=context,
        ) from exc
    except TypeError as exc:
        raise exceptions.AstroidTypeError(
            message="Type error {error!r}", node=instance, index=index, context=context
        ) from exc

    raise exceptions.AstroidTypeError("Could not use %s as subscript index" % index)
967224
public static Method findMethod(Class<?> type, String name,
			Class<?>... parameterTypes) {
		while (type != null) {
			try {
				return type.getDeclaredMethod(name, parameterTypes);
			} catch (Exception e) {
			}
			type = type.getSuperclass();
		}
		return null;
	}
269840
def _lookup_parameter(self, container, key, common_type=None):
        
        if not container.get('container', {}).get('docker', {}).get('parameters'):
            return
        params = container['container']['docker']['parameters']

        # Super hacky - log-opt is a sub option of the logging directive of everything else
        if key == 'log-driver':
            return [
                p
                for p
                in params
                if p['key'] in ['log-opt', 'log-driver']]

        matching_params = [
            p['value']
            for p
            in params
            if p['key'] == key]

        if matching_params:
            if common_type == list:
                return matching_params
            else:
                return matching_params[0]
1284236
public static MethodHandle findMethodHandle(Object target,String methodName,Class<?> ...ptypes)
	{
		MethodHandle mh=null;
		MethodHandles.Lookup lookup = MethodHandles.lookup();
	    try {
	    	MethodType type = MethodType.methodType(target.getClass(),ptypes);
	    	mh = lookup.findVirtual(target.getClass(),methodName, type);
		} catch (Throwable e) {
		}
		return mh;
	}
1374253
function() {
            var container;
            //first, try get it by `containerDataName`
            if(this.containerDataName) {
                if(container = this.$element.data(this.containerDataName)) {
                    return container;
                }
            }
            //second, try `containerName`
            container = this.$element.data(this.containerName);
            return container;
        }
750500
function locate (methods) {
  var found = []
  var i = -1

  while (++i < methods.length) {
    if (methods[i] && methods[i].match(/FrontMatter$/)) {
      found.push(methods[i])
    }
  }

  return found
}
141530
def find(self, *args, **kwargs):
        
        wrapper = kwargs.pop('wrapper', False)
        if wrapper is True:
            return self._wrapper_find(*args, **kwargs)

        return self.__collect.find(*args, **kwargs)
1307691
private Map<StandardMethod, UnderrideLevel> findUnderriddenMethods(
      Iterable<ExecutableElement> methods) {
    Map<StandardMethod, ExecutableElement> standardMethods = new LinkedHashMap<>();
    for (ExecutableElement method : methods) {
      Optional<StandardMethod> standardMethod = maybeStandardMethod(method);
      if (standardMethod.isPresent() && isUnderride(method)) {
        standardMethods.put(standardMethod.get(), method);
      }
    }
    if (standardMethods.containsKey(StandardMethod.EQUALS)
        != standardMethods.containsKey(StandardMethod.HASH_CODE)) {
      ExecutableElement underriddenMethod = standardMethods.containsKey(StandardMethod.EQUALS)
          ? standardMethods.get(StandardMethod.EQUALS)
          : standardMethods.get(StandardMethod.HASH_CODE);
      messager.printMessage(ERROR,
          "hashCode and equals must be implemented together on FreeBuilder types",
          underriddenMethod);
    }
    ImmutableMap.Builder<StandardMethod, UnderrideLevel> result = ImmutableMap.builder();
    for (StandardMethod standardMethod : standardMethods.keySet()) {
      if (standardMethods.get(standardMethod).getModifiers().contains(Modifier.FINAL)) {
        result.put(standardMethod, UnderrideLevel.FINAL);
      } else {
        result.put(standardMethod, UnderrideLevel.OVERRIDEABLE);
      }
    }
    return result.build();
  }
350444
def method_missing(method, *args, &block)
      return super unless method =~ /^find_(all_|last_|or_(initialize_|create_))?by_/

      result = object_class.send(method, *args, &block)
      options = args.extract_options!

      if method =~ /^find_all/
        decorate_collection(result, options)
      else
        decorate(result, options)
      end
    end
258589
function findMethod(source, nameExpr, data) {
    var method = source;

    for (var i = 0; method != null && i < nameExpr.paths.length; i++) {
        method = method[evalExpr(nameExpr.paths[i], data)];
    }

    return method;
}
1101523
def runContainer(image, **kwargs):
    '''
    '''
    container = None
    try:
        container = client.containers.run(image, **kwargs)
        if "name" in kwargs.keys():
          print("Container", kwargs["name"], "is now running.")
    except ContainerError as exc:
        eprint("Failed to run container")
        raise exc
    except ImageNotFound as exc:
        eprint("Failed to find image to run as a docker container")
        raise exc
    except APIError as exc:
        eprint("Unhandled error")
        raise exc

    return container
681345
def _get_container(self, path):
        """"""
        cont = self.native_conn.get_container(path)
        return self.cont_cls(self,
                             cont.name,
                             cont.object_count,
                             cont.size_used)