Handles the list-basis-sets subcommand
425952
def _bse_cli_list_basis_sets(args):
    ''''''
    metadata = api.filter_basis_sets(args.substr, args.family, args.role, args.data_dir)

    if args.no_description:
        liststr = metadata.keys()
    else:
        liststr = format_columns([(k, v['description']) for k, v in metadata.items()])

    return '\n'.join(liststr)
1231906
def _whole_basis_types(basis):
    '''
    

    '''

    all_types = set()

    for v in basis['elements'].values():
        if 'electron_shells' in v:
            for sh in v['electron_shells']:
                all_types.add(sh['function_type'])

        if 'ecp_potentials' in v:
            for pot in v['ecp_potentials']:
                all_types.add(pot['ecp_type'])

    return sorted(list(all_types))
961743
def basis(self, n):
        
        if n == 0:
            return self(np.array([1.]))
        vals = np.ones(n+1)
        vals[1::2] = -1
        return self(vals)
147260
def params(self):
        
        paramlist = [b.params for b in self.bases if b.params.has_value]

        if len(paramlist) == 0:
            return Parameter()
        else:
            return paramlist if len(paramlist) > 1 else paramlist[0]
584260
def apply_command_list_template(command_list, in_path, out_path, args):
    '''
    
    '''
    replacements = {
        '$IN': in_path,
        '$OUT': out_path,
    }

    # Add in positional arguments ($0, $1, etc)
    for i, arg in enumerate(args):
        replacements['$' + str(i)] = arg

    results = [replacements.get(arg, arg) for arg in command_list]

    # Returns list of truthy replaced arguments in command
    return [item for item in results if item]
284834
def handle(self, *args, **options):
        
        if options["sub_command"] == "add":
            self.handle_add(options)
        elif options["sub_command"] == "update":
            self.handle_update(options)
        elif options["sub_command"] == "details":
            self.handle_details(options["username"])
        elif options["sub_command"] == "list":
            self.handle_list(options["all"], options["csv"])
337200
def _list(self, args):
        '''
        
        '''
        args.pop(0)
        command = args[0]
        if command == 'packages':
            self._list_packages(args)
        elif command == 'files':
            self._list_files(args)
        elif command == 'repos':
            self._repo_list(args)
        else:
            raise SPMInvocationError('Invalid list command \'{0}\''.format(command))
255994
def p_lconst_list(self, p):
        ''''''
        if len(p) == 4:
            p[1].append(p[3])
            p[0] = p[1]
        elif len(p) == 2:
            p[0] = [p[1]]
679266
def process_list_arg(arg):
    
    if isinstance(arg, list):
        return arg
    elif isinstance(arg, basestring):
        args = []
        for part in arg.split(","):
            args.append(part.strip())
        return args
20251
def as_list(self, decode=False):
        
        items = self.database.lrange(self.key, 0, -1)
        return [_decode(item) for item in items] if decode else items
187620
def index(self, sub, *args):
        '''
        
        '''
        if isinstance(sub, int):
            if len(args) == 0:
                start, end = 0, len(self)
            elif len(args) == 1:
                start = args[0]
            elif len(args) == 2:
                start, end = args
            else:
                raise TypeError('takes at most 3 arguments')
            return list(self)[start:end].index(sub)
        if not isinstance(sub, bytes):
            try:
                sub = self.__class__(sub)
            except (TypeError, ValueError):
                raise TypeError("can't convert sub to bytes")
        try:
            return super(newbytes, self).index(sub, *args)
        except ValueError:
            raise ValueError('substring not found')
1364663
def issubset(list1, list2):
    
    n = len(list1)
    for startpos in range(len(list2) - n + 1):
        if list2[startpos:startpos+n] == list1:
            return True
    return False
875698
def p_list_terminator(p):
    ''''''
    if p[1] == ';':
        p[0] = ast.node(kind='operator', op=';', pos=p.lexspan(1))
661368
def _initialize_lists(model_class, name, bases, attrs):
    """"""
    model_class._lists = {}
    for k, v in attrs.iteritems():
        if isinstance(v, ListField):
            model_class._lists[k] = v
            v.name = v.name or k
559473
def p_commands_list(p):
    """"""
    p[0] = p[1]

    # section 3.2: REQUIRE command must come before any other commands
    if p[2].RULE_IDENTIFIER == 'REQUIRE':
        if any(command.RULE_IDENTIFIER != 'REQUIRE'
               for command in p[0].commands):
            print("REQUIRE command on line %d must come before any "
                  "other non-REQUIRE commands" % p.lineno(2))
            raise SyntaxError

    # section 3.1: ELSIF and ELSE must follow IF or another ELSIF
    elif p[2].RULE_IDENTIFIER in ('ELSIF', 'ELSE'):
        if p[0].commands[-1].RULE_IDENTIFIER not in ('IF', 'ELSIF'):
            print("ELSIF/ELSE command on line %d must follow an IF/ELSIF "
                  "command" % p.lineno(2))
            raise SyntaxError

    p[0].commands.append(p[2])
1073138
def get_atom_type_symbol(cls,calc,**kwargs):
        
        parameters = calc.out.output
        dictionary = parameters.get_dict()
        if 'basis_set' not in dictionary.keys():
            return None
        return sorted(dictionary['basis_set'].keys())
491544
def _cli_check_family(family, data_dir):
    ''''''

    if family is None:
        return None

    family = family.lower()
    if not family in api.get_families(data_dir):
        errstr = "Basis set family '" + family + "' does not exist.\n"
        errstr += "For a complete list of families, use the 'bse list-families' command"
        raise RuntimeError(errstr)

    return family