Extract values out from Functions

init=functionName1('parameter':'value','parameter2':'value2'),functionName1('parameter':'value','parameter2':'value2')
769218
public Object getFunctionsValue(String parameter, String function){
        
        Object value=null;
        return value;
    }
403893
def _extract_parameters(
    params: Sequence[ExtensionParameter], *, is_server: bool
) -> Tuple[bool, bool, Optional[int], Optional[Union[int, bool]]]:
    
    server_no_context_takeover: bool = False
    client_no_context_takeover: bool = False
    server_max_window_bits: Optional[int] = None
    client_max_window_bits: Optional[Union[int, bool]] = None

    for name, value in params:

        if name == "server_no_context_takeover":
            if server_no_context_takeover:
                raise DuplicateParameter(name)
            if value is None:
                server_no_context_takeover = True
            else:
                raise InvalidParameterValue(name, value)

        elif name == "client_no_context_takeover":
            if client_no_context_takeover:
                raise DuplicateParameter(name)
            if value is None:
                client_no_context_takeover = True
            else:
                raise InvalidParameterValue(name, value)

        elif name == "server_max_window_bits":
            if server_max_window_bits is not None:
                raise DuplicateParameter(name)
            if value in _MAX_WINDOW_BITS_VALUES:
                server_max_window_bits = int(value)
            else:
                raise InvalidParameterValue(name, value)

        elif name == "client_max_window_bits":
            if client_max_window_bits is not None:
                raise DuplicateParameter(name)
            if is_server and value is None:  # only in handshake requests
                client_max_window_bits = True
            elif value in _MAX_WINDOW_BITS_VALUES:
                client_max_window_bits = int(value)
            else:
                raise InvalidParameterValue(name, value)

        else:
            raise InvalidParameterName(name)

    return (
        server_no_context_takeover,
        client_no_context_takeover,
        server_max_window_bits,
        client_max_window_bits,
    )
556945
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        $params = $functionParameters;
        switch ( $functionName )
        {
            case $this->BlockName:
            {
                $viewMode = "full";
                $name = $currentNamespace;
                // Read ini file
                $toolbarIni = eZINI::instance( "toolbar.ini" );

                if ( isset( $functionParameters["view"] ) )
                {
                    $viewMode = $tpl->elementValue( $functionParameters["view"], $rootNamespace, $currentNamespace, $functionPlacement );
                }

                if ( isset( $functionParameters["name"] ) )
                {
                    reset( $params );
                    $whatParamsShouldBeUnset = array();
                    $whatParamsShouldBeReplaced = array();
                    while ( ( $key = key( $params ) ) !== null )
                    {
                        $item =& $params[$key];
                        switch ( $key )
                        {
                            case "name":
                            case "view":
                                break;

                            default:
                            {
                                if ( !$tpl->hasVariable( $key, $name ) )
                                {
                                    $whatParamsShouldBeUnset[] = $key; // Tpl vars should be removed after including
                                }
                                else
                                {
                                    $whatParamsShouldBeReplaced[$key] = $tpl->variable( $key, $name ); // Tpl vars should be replaced after including
                                }

                                $item_value = $tpl->elementValue( $item, $rootNamespace, $currentNamespace, $functionPlacement );
                                $tpl->setVariable( $key, $item_value, $name );
                            } break;
                        }
                        next( $params );
                    }
                    $toolbarPosition = $tpl->elementValue( $functionParameters["name"], $rootNamespace, $currentNamespace, $functionPlacement );
                    $definedVariables = array();
                    $toolbarName = "Toolbar_" . $toolbarPosition;
                    $toolArray = $toolbarIni->variable( $toolbarName, 'Tool' );

                    if ( !is_array( $toolArray ) )
                        $toolArray = array();

                    $actionParameters = array();
                    foreach ( array_keys( $toolArray ) as $toolKey )
                    {
                        $definedVariables = array();
                        $tool = $toolArray[$toolKey];
                        $placement = $toolKey + 1;
                        if ( $toolbarIni->hasGroup( "Tool_" . $tool ) )
                        {
                            $actionParameters = $toolbarIni->group( "Tool_" . $tool );
                        }
                        if ( $toolbarIni->hasGroup( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) )
                        {
                            $actionParameters = array_merge( $actionParameters, $toolbarIni->group( "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement ) );
                        }
                        foreach ( array_keys( $actionParameters ) as $key )
                        {
                            $itemValue = $actionParameters[$key];
                            $tpl->setVariable( $key, $itemValue, $name );
                            $definedVariables[] = $key;
                        }
                        $toolIDValue =  "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement;
                        $tpl->setVariable( "tool_id", $toolIDValue, $name );
                        $definedVariables[] = "tool_id";
                        $toolOffset = $placement;
                        $tpl->setVariable( "offset", $toolOffset, $name );
                        $definedVariables[] = "offset";
                        $uri = "design:toolbar/$viewMode/$tool.tpl";

                        if ( $placement == 1 )
                        {
                            if ( count( $toolArray ) == 1 )
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", true );
                                $tpl->setVariable( "placement", "last" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                            else
                            {
                                $tpl->setVariable( "first", true );
                                $tpl->setVariable( "last", false );
                                $tpl->setVariable( "placement", "first" );
                                $definedVariables[] = "first";
                                $definedVariables[] = "last";
                                $definedVariables[] = "placement";
                            }
                        }
                        else if ( $placement == count( $toolArray ) )
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last", true );
                            $tpl->setVariable( "placement", "last" );
                            $definedVariables[] = "first";
                            $definedVariables[] = "last";
                            $definedVariables[] = "placement";
                        }
                        else
                        {
                            $tpl->setVariable( "first", false );
                            $tpl->setVariable( "last",  false );
                            $tpl->setVariable( "placement", "" );
                            $definedVariables[] = "placement";
                        }
                        $tpl->processURI( $uri, true, $extraParameters, $textElements, $name, $name );
                        // unset var
                        foreach ( $whatParamsShouldBeUnset as $key )
                        {
                            $tpl->unsetVariable( $key, $name );
                        }
                        // replace var
                        foreach ( $whatParamsShouldBeReplaced as $key => $item_value )
                        {
                            $tpl->setVariable( $key, $item_value, $name );
                        }
                    }
                }
            }
        }
    }
298287
function restoreFunctionNames(ast) {
  const functionNames = [];

  t.traverse(ast, {
    FunctionNameMetadata({ node }) {
      functionNames.push({
        name: node.value,
        index: node.index
      });
    }
  });

  if (functionNames.length === 0) {
    return;
  }

  t.traverse(ast, {
    Func({ node }: NodePath<Func>) {
      // $FlowIgnore
      const nodeName: Identifier = node.name;
      const indexBasedFunctionName = nodeName.value;
      const index = Number(indexBasedFunctionName.replace("func_", ""));
      const functionName = functionNames.find(f => f.index === index);
      if (functionName) {
        const oldValue = nodeName.value;

        nodeName.value = functionName.name;
        nodeName.numeric = oldValue;

        // $FlowIgnore
        delete nodeName.raw;
      }
    }
1052522
private function extractExtendedParametersInfo(): void
  {
    $key = array_search('begin', $this->routineSourceCodeLines);

    if ($key!==false)
    {
      for ($i = 1; $i<$key; $i++)
      {
        $k = preg_match('/^\s*--\s+param:(?:\s*(\w+)\s+(\w+)(?:(?:\s+([^\s-])\s+([^\s-])\s+([^\s-])\s*$)|(?:\s*$)))?/',
                        $this->routineSourceCodeLines[$key - $i + 1],
                        $matches);

        if ($k==1)
        {
          $count = count($matches);
          if ($count==3 || $count==6)
          {
            $parameter_name = $matches[1];
            $data_type      = $matches[2];

            if ($count==6)
            {
              $list_delimiter = $matches[3];
              $list_enclosure = $matches[4];
              $list_escape    = $matches[5];
            }
            else
            {
              $list_delimiter = ',';
              $list_enclosure = '"';
              $list_escape    = '\\';
            }

            if (!isset($this->extendedParameters[$parameter_name]))
            {
              $this->extendedParameters[$parameter_name] = ['name'      => $parameter_name,
                                                            'data_type' => $data_type,
                                                            'delimiter' => $list_delimiter,
                                                            'enclosure' => $list_enclosure,
                                                            'escape'    => $list_escape];
            }
            else
            {
              throw new RoutineLoaderException("Duplicate parameter '%s'", $parameter_name);
            }
          }
          else
          {
            throw new RoutineLoaderException('Error: Expected: -- param: <field_name> <type_of_list> [delimiter enclosure escape]');
          }
        }
      }
    }
  }
1230545
def _expr2code(self, arg_list, expr):
        """"""
        code = lambdastr(arg_list, expr)
        function_code = code.split(':')[1].strip()
        #for arg in arg_list:
        #    function_code = function_code.replace(arg.name, 'self.'+arg.name)

        return function_code
905652
def get_function_call_repr(fn, args, kwargs):
    """"""

    result = get_full_name(fn) + "("
    first = True
    for v in args:
        if first:
            first = False
        else:
            result += ","
        result += repr(v)
    for k, v in kwargs.items():
        if first:
            first = False
        else:
            result += ","
        result += str(k) + "=" + repr(v)
    result += ")"
    return result
844900
private void processFunctions(String name, String text, String type,
      List<MtasCRMParserFunctionOutput> functionOutputList) {
    if (functions.containsKey(type) && functions.get(type).containsKey(name)
        && text != null) {
      MtasCRMParserFunction function = functions.get(type).get(name);
      String[] value;
      if (function.split != null) {
        value = text.split(Pattern.quote(function.split));
      } else {
        value = new String[] { text };
      }
      for (int c = 0; c < value.length; c++) {
        boolean checkedEmpty = false;
        if (value[c].equals("")) {
          checkedEmpty = true;
        }
        if (function.output.containsKey(value[c])) {
          ArrayList<MtasCRMParserFunctionOutput> list = function.output
              .get(value[c]);
          for (MtasCRMParserFunctionOutput listItem : list) {
            functionOutputList.add(listItem.create(value[c]));
          }
        }
        if (!checkedEmpty && function.output.containsKey("")) {
          ArrayList<MtasCRMParserFunctionOutput> list = function.output.get("");
          for (MtasCRMParserFunctionOutput listItem : list) {
            functionOutputList.add(listItem.create(value[c]));
          }
        }
      }
    }
  }
32779
def _get_unique_function_name(function_type, functions):
    '''
    '''
    function_name = function_name_base = function_type
    count = 2
    while function_name in functions:
        function_name = '{}_{}'.format(function_name_base, count)
        count += 1
    return function_name
1203415
public static String[] getParameters(String function){
        if(function==null){return new String[]{};}
        function = function.substring(function.indexOf("(",5)+1, function.indexOf(")",1));
        return function.split(",");
    }
816944
def _get_params(func, *args, **kwargs):
    
    params = dict(zip(func.func_code.co_varnames[:len(args)], args))
    if func.func_defaults:
        params.update(dict(zip(
            func.func_code.co_varnames[-len(func.func_defaults):],
            func.func_defaults)))
    params.update(kwargs)

    return params
1182298
def arguments(function, extra_arguments=0):
    """"""
    if not hasattr(function, '__code__'):
        return ()

    return function.__code__.co_varnames[:function.__code__.co_argcount + extra_arguments]
1364428
def _format_function_arguments(self, opts):
        """"""
        params = [self.Parameters[x] for x in opts]
        return ', '.join(filter(None, map(str, params)))
387589
function(values, func) {
        "use strict";
        if (values.forEach) {
            return values.forEach(func);
        } else {
            for (var i=0, len=values.length; i < len; i++) {
                func(values[i], i, values);
            }
        }
    }
179716
function extractPageValues(outerWindow, currentPage, pageStartAtValue, pageEndAtValue) {
  let pageValues = [];
  pageValues.push(pageStartAtValue);
  pageValues.push(pageEndAtValue);

  let addPageValue = function(page) {
    pageValues.push(page);
  };

  if (outerWindow > 0) {
    let leftOuterWindowStartAtValue = pageStartAtValue + 1;
    let leftOuterWindowEndAtValue = pageStartAtValue + outerWindow;

    let rightOuterWindowStartAtValue = pageEndAtValue - 1 - outerWindow;
    let rightOuterWindowEndAtValue = pageEndAtValue - 1;

    createRange(leftOuterWindowStartAtValue, leftOuterWindowEndAtValue).forEach(addPageValue);
    createRange(rightOuterWindowStartAtValue, rightOuterWindowEndAtValue).forEach(addPageValue);
  }

  // add / subtract 2 for the dots display for the inner window
  // to handle exactly this use case (if 100 is current page): ... 99 100 101 ...
  let innerWindowStartAtValue = currentPage - 2;
  let innerWindowEndAtValue = currentPage + 2;
  createRange(innerWindowStartAtValue, innerWindowEndAtValue).forEach(addPageValue);

  let takeUnique = function(page, idx, array) {
    return array.indexOf(page) === idx;
  };

  return pageValues
          .sort((a, b) => a - b)
          .filter((page) => page >= pageStartAtValue && page <= pageEndAtValue)
          .filter(takeUnique);

}
817194
def extract_params(params):
    
    values = []
    if isinstance(params, dict):
        for key, value in params.items():
            values.extend(extract_params(value))
    elif isinstance(params, list):
        for value in params:
            values.extend(extract_params(value))
    else:
        values.append(params)
    return values
841294
def extract_func_data(self, func):
        
        code = func.__code__

        # extract all global ref's
        func_global_refs = self.extract_code_globals(code)

        # process all variables referenced by global environment
        f_globals = {}
        for var in func_global_refs:
            if var in func.__globals__:
                f_globals[var] = func.__globals__[var]

        # defaults requires no processing
        defaults = func.__defaults__

        # process closure
        closure = (
            list(map(_get_cell_contents, func.__closure__))
            if func.__closure__ is not None
            else None
        )

        # save the dict
        dct = func.__dict__

        base_globals = self.globals_ref.get(id(func.__globals__), None)
        if base_globals is None:
            # For functions defined in a well behaved module use
            # vars(func.__module__) for base_globals. This is necessary to
            # share the global variables across multiple pickled functions from
            # this module.
            if hasattr(func, '__module__') and func.__module__ is not None:
                base_globals = func.__module__
            else:
                base_globals = {}
        self.globals_ref[id(func.__globals__)] = base_globals

        return (code, f_globals, defaults, closure, dct, base_globals)