Return calculator name

    The calculator name is obtained from command option arguments where
    argparse is used. The argument attribute name has to be
    "{calculator}_mode". Then this method returns {calculator}.
765236
def get_interface_mode(args):
    

    calculator_list = ['wien2k', 'abinit', 'qe', 'elk', 'siesta', 'cp2k',
                       'crystal', 'vasp', 'dftbp', 'turbomole']
    for calculator in calculator_list:
        mode = "%s_mode" % calculator
        if mode in args and args.__dict__[mode]:
            return calculator
    return None
564698
def name(self):
        """"""
        for arg in self.args:
            if arg.startswith("--"):
                return arg[2:].replace("-", "_")
            elif arg.startswith("-"):
                continue
            else:
                return arg.replace("-", "_")
415652
def resolve_name(name):
    

    parts = name.split('.')
    cursor = len(parts) - 1
    module_name = parts[:cursor]
    attr_name = parts[-1]

    while cursor > 0:
        try:
            ret = __import__('.'.join(module_name), fromlist=[attr_name])
            break
        except ImportError:
            if cursor == 0:
                raise
            cursor -= 1
            module_name = parts[:cursor]
            attr_name = parts[cursor]
            ret = ''

    for part in parts[cursor:]:
        try:
            ret = getattr(ret, part)
        except AttributeError:
            raise ImportError(name)

    return ret
780110
function getOptionName (arg) {
  if (re.short.test(arg)) {
    return arg.match(re.short)[1]
  } else if (isLongOption(arg)) {
    return arg.match(re.long)[1]
  } else if (isOptionEqualsNotation(arg)) {
    return arg.match(re.optEquals)[1].replace(/^--/, '')
  } else {
    return null
  }
}
490608
def get_args_kwargs(foo):
    
    spec = inspect.signature(foo)
    params = spec.parameters
    args,args_with_def=[],[]
    for n,p in params.items():
        if p.default is p.empty:
            args.append(n)
        else:
            args_with_def.append(n)
    return args,args_with_def
1247880
def _get_args_name_from_parser(parser):
    
    # Retrieve the 'action' destination of the method parser i.e. its
    # argument name. The HelpAction is ignored.
    return [action.dest for action in parser._actions if not
            isinstance(action, argparse._HelpAction)]
50837
def get_args_names(method)
      args = method.args
      args_names = ' '
      args.each_with_index { |a, i|args_names << "${#{i + 1}:#{a}}, " }
      args_names.chop!.chop! unless args.empty?
    end
827076
def __get_dynamic_attr(self, attname, arg, default=None):
        
        try:
            attr = getattr(self, attname)
        except AttributeError:
            return default
        if callable(attr):
            # Check func_code.co_argcount rather than try/excepting the
            # function and catching the TypeError, because something inside
            # the function may raise the TypeError. This technique is more
            # accurate.
            if hasattr(attr, 'func_code'):
                argcount = attr.func_code.co_argcount
            else:
                argcount = attr.__call__.func_code.co_argcount
            if argcount == 2: # one argument is 'self'
                return attr(arg)
            else:
                return attr()
        return attr
1105378
public static Name getFirstArgumentAsName(Object[] args) {
        Assert.notEmpty(args);

        Object firstArg = args[0];
        return getArgumentAsName(firstArg);
    }
242809
def get_filename(self, **kwargs):
        
        if self.filename_parser is None:
            raise RuntimeError("No filename pattern or specific filename provided")
        output_filename = self.filename_parser.compose(kwargs)
        dirname = os.path.dirname(output_filename)
        if dirname and not os.path.isdir(dirname):
            LOG.info("Creating output directory: {}".format(dirname))
            os.makedirs(dirname)
        return output_filename
507159
def get_command_line_arguments():
    

    parser = argparse.ArgumentParser(add_help=False)

    parser.add_argument("-h",
                        "--help",
                        action="help",
                        help="'Displays this help message and exit.'")

    parser.add_argument("-t",
                        "--title",
                        type=unicode,
                        dest="title",
                        help="'Package title.'")

    parser.add_argument("-i",
                        "--input",
                        type=unicode,
                        dest="input",
                        help="'Input file to convert.'")

    parser.add_argument("-o",
                        "--output",
                        type=unicode,
                        dest="output",
                        help="'Output file.'")

    parser.add_argument("-c",
                        "--content_directory",
                        type=unicode,
                        dest="content_directory",
                        help="'Content directory.'")

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    return parser.parse_args()
1298090
def _arg_varname(self, wire):
        
        if isinstance(wire, (Input, Register)):
            return 'd[' + repr(wire.name) + ']'  # passed in
        elif isinstance(wire, Const):
            return str(wire.val)  # hardcoded
        else:
            return self._varname(wire)
506066
def getPythonVarName(name):
    
    return SUB_REGEX.sub('', name.replace('+', '_').replace('-', '_').replace('.', '_').replace(' ', '').replace('/', '_')).upper()
8215
def _expected_argument_string(self):
        

        if self.args is _any and self.kwargs is _any:
            return 'any args'
        elif self._custom_matcher:
            return "custom matcher: '{}'".format(self._custom_matcher.__name__)
        else:
            return build_argument_repr_string(self.args, self.kwargs)
565281
def get_command_str(args):
    
    single_quote = "'"
    double_quote = '"'
    for i, value in enumerate(args):
        if " " in value and double_quote not in value:
            args[i] = '"%s"' % value
        elif " " in value and single_quote not in value:
            args[i] = "'%s'" % value
    return " ".join(args)
886883
def _get_function_name(self, fn, default="None"):
        
        if fn is None:
            fn_name = default
        else:
            fn_name = fn.__name__
        return fn_name
1011628
def name(self):
    
    base_str = 'd{}{}_'.format(self.derivative_count if
                               self.derivative_count > 1 else '', self.expr)
    for var, count in self.variable_count:
        base_str += 'd{}{}'.format(var,  count if count > 1 else '')
    return base_str