Encapsulates an argument in a list, if it's not already iterable.
358179
def _AsList(arg):
    """"""
    if (isinstance(arg, string_types) or
        not isinstance(arg, collections.Iterable)):
      return [arg]
    else:
      return list(arg)
569101
def takes(*type_list):
    
    def inner(f):
        if enabled:
            # deal with the real function, not a wrapper
            f = getattr(f, 'wrapped_fn', f)

            # need to check if 'self' is the first arg,
            # since @pre doesn't want the self param
            member_function = is_member_function(f)

            # need metadata for defaults check
            method_args, method_defaults = inspect.getargspec(f)[0::3]
            if member_function:
                method_args = method_args[member_function:]

            def check_condition(args, kwargs):
                if method_defaults is not None and len(method_defaults) > 0 \
                and len(method_args) - len(method_defaults) <= len(args) < len(method_args):
                    args += method_defaults[len(args) - len(method_args):]

                for i, (arg, t) in enumerate(zip(args[member_function:], type_list)):
                    method_arg = method_args[i]
                    if method_arg not in kwargs and not check_type(t, arg):
                        raise AssertionError('Precondition failure, wrong type for argument')

                for kwarg in kwargs:
                    arg_position = method_args.index(kwarg)
                    if arg_position < len(type_list):
                        t = type_list[arg_position]
                        if not check_type(t, kwargs.get(kwarg)):
                            raise AssertionError('Precondition failure, wrong type for argument %s' % kwarg)

            # append to the rest of the postconditions attached to this method
            if not hasattr(f, 'preconditions'):
                f.preconditions = []
            f.preconditions.append(check_condition)

            return check(f)
        else:
            return f

    return inner
117650
def __wrap_accepted_val(self, value):
        
        if isinstance(value, tuple):
            value = list(value)
        elif not isinstance(value, list):
            value = [value]
        return value
138724
def listify(x, none_value=[]):
    """"""

    if isinstance(x, list):
        return x
    elif isinstance(x, tuple):
        return list(x)
    elif x is None:
        return none_value
    else:
        return [x]
188421
def arguments_not_none(func):
    """"""
    def wrapper(*args, **kwargs):
        for arg in args:
            if arg is None:
                raise NullArgument()
        for arg, val in kwargs.items():
            if val is None:
                raise NullArgument()
        try:
            return func(*args, **kwargs)
        except TypeError as ex:
            if any(statement in ex.args[0] for statement in ['takes exactly',
                                                             'required positional argument']):
                raise NullArgument('Wrong number of arguments provided: ' + str(ex.args[0]))
            else:
                raise
    return wrapper
210266
def extend(self, iterable):
        
        with self.lock:
            for item in iterable:
                self.append(item)
1195343
def list_from_args(args):
    
    # Empty args
    if not args:
        return []

    # Get argument type
    arg_type = type(args[0])
    is_list = arg_type in LIST_TYPES

    # Check that the arguments are uniforn (of same type)
    same_type = all([
        isinstance(arg, arg_type)
        for arg in args
    ])

    if not same_type:
        raise Exception('Expected uniform arguments of same type !')

    # Flatten iterables
    # ['x', 'y'], ...
    if is_list:
        args_lists = map(list, args)
        flattened_args = sum(args_lists, [])
        return flattened_args
    # Flatten set
    # 'x', 'y'
    return list(args)
527485
def flatten(l: Iterable) -> List:
    
    rval = []
    for e in l:
        if not isinstance(e, str) and isinstance(e, Iterable):
            if len(list(e)):
                rval += flatten(e)
        else:
            rval.append(e)
    return rval
440739
def _iterable_to_varargs_method(func):
    """"""
    def wrapped(self, *args, **kwargs):
        return func(self, args, **kwargs)
    return wrapped
1160454
def iscontainer(*items):
    
    return all(isinstance(i, Iterable) and not isinstance(i, basestring)
               for i in items)
986676
def start_with(self, x):
        

        _args = []

        for arg in self.all:
            if _is_collection(x):
                for _x in x:
                    if arg.startswith(x):
                        _args.append(arg)
                        break
            else:
                if arg.startswith(x):
                    _args.append(arg)

        return ArgsList(_args, no_argv=True)
467928
function (list, func, args) {
				var out = [];
				for (var i = 0, j = list.length; i < j; i++) {
					out.push([ list[i][func].apply(list[i], args), list[i] ]);
				}
				return out;
			}
1277679
def from_iterable(cls, iterable: Iterable) -> 'List':
        """"""

        iterator = iter(iterable)

        def recurse() -> List:
            try:
                value = next(iterator)
            except StopIteration:

                return List.empty()
            return List.unit(value).append(recurse())
        return List.empty().append(recurse())
1156337
def coerce(value):
        
        if isinstance(value, ListCell):
            return value
        elif isinstance(value, (list)):
            return ListCell(value)
        else:
            return ListCell([value])
493614
def p_encaps_list_string(p):
    ''
    if p[1] == '':
        p[0] = p[2].decode('string_escape')
    else:
        p[0] = ast.BinaryOp('.', p[1], p[2].decode('string_escape'),
                            lineno=p.lineno(2))
207127
def as_list(callable):
    """"""
    @wraps(callable)
    def wrapper(value_iter):
        return [callable(value) for value in value_iter]

    return wrapper
1035963
def wrap(cls, value):
        ''' 

        '''
        if isinstance(value, list):
            if isinstance(value, PropertyValueList):
                return value
            else:
                return PropertyValueList(value)
        else:
            return value