about summary refs log tree commit diff stats
path: root/commands/quit.go
Commit message (Collapse)AuthorAgeFilesLines
* Implement basic tab completion supportGregory Mullen2019-06-291-2/+12
| | | | | Tab completion currently only works on commands. Contextual completion will be added in the future.
* s/aerc2/aerc/gDrew DeVault2019-05-171-1/+1
|
* Add context-specific commandsDrew DeVault2019-03-211-2/+2
|
* Add :quit commandDrew DeVault2019-03-151-0/+24
3461d7a810cafb528515191307'>^
b953eb51 ^
0fd1c723 ^
5603e0fa ^





0fd1c723 ^

b953eb51 ^
0fd1c723 ^



b6d4e3e5 ^







5603e0fa ^




b6d4e3e5 ^





5603e0fa ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
                                                                       
                                                                        
 

                             



                            
                                                                          
                                       





                                           

                        
                                                               



                                                     







                                                                        




                                                           





                                                 



                          
# Copyright (C) 2009, 2010, 2011  Roman Zimbelmann <romanz@lavabit.com>
# This software is distributed under the terms of the GNU GPL version 3.

from collections import deque

def flatten(lst):
	"""
	Flatten an iterable.

	All contained tuples, lists, deques and sets are replaced by their
	elements and flattened as well.

	>>> l = [1, 2, [3, [4], [5, 6]], 7]
	>>> list(flatten(l))
	[1, 2, 3, 4, 5, 6, 7]
	>>> list(flatten(()))
	[]
	"""
	for elem in lst:
		if isinstance(elem, (tuple, list, set, deque)):
			for subelem in flatten(elem):
				yield subelem
		else:
			yield elem

def unique(iterable):
	"""
	Return an iterable of the same type which contains unique items.

	This function assumes that:
	type(iterable)(list(iterable)) == iterable
	which is true for tuples, lists and deques (but not for strings)

	>>> unique([1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 1, 1, 2])
	[1, 2, 3, 4]
	>>> unique(('w', 't', 't', 'f', 't', 'w'))
	('w', 't', 'f')
	"""
	already_seen = []
	for item in iterable:
		if item not in already_seen:
			already_seen.append(item)
	return type(iterable)(already_seen)

if __name__ == '__main__':
	import doctest
	doctest.testmod()