ulauncher.util package

Submodules

ulauncher.util.AutostartPreference module

ulauncher.util.Path module

exception ulauncher.util.Path.InvalidPathError

Bases: exceptions.RuntimeError

class ulauncher.util.Path.Path(path)

Bases: object

exists()
get_abs_path()
get_basename()
get_dirname()
get_existing_dir()

Example (assuming foo & bar do not exist):

>>> p = Path('/home/aleksandr/projects/foo/bar')
>>> p.get_existing_dir() == '/home/aleksandr/projects'
Returns:path to the last dir that exists in the user’s query
get_ext()
get_search_part()
Returns:remaining part of the query that goes after get_existing_dir()
get_user_path()
is_dir()
is_exe()

ulauncher.util.Router module

exception ulauncher.util.Router.RouteNotFound

Bases: ulauncher.util.Router.RouterError

exception ulauncher.util.Router.RoutePathEmpty

Bases: ulauncher.util.Router.RouterError

class ulauncher.util.Router.Router

Bases: object

Usage:

>>> rt = Router()
>>>
>>> class App(object):
>>>
>>>     @rt.route('get/user')
>>>     def get_user(self, url_params):
>>>         ...
>>>         return userObject
>>>
>>>     def on_request(self, url):
>>>         result = rt.dispatch(self, url) # will return userObject for /get/user path
dispatch(context, url)
route(path)
exception ulauncher.util.Router.RouterError

Bases: exceptions.RuntimeError

ulauncher.util.Router.get_url_params(url)

ulauncher.util.Settings module

ulauncher.util.SimpleWebSocketServer module

The MIT License (MIT) Copyright (c) 2013 Dave P.

class ulauncher.util.SimpleWebSocketServer.WebSocket(server, sock, address)

Bases: object

close(status=1000, reason=u'')

Send Close frame to the client. The underlying socket is only closed when the client acknowledges the Close frame.

status is the closing identifier. reason is the reason for the close.

handleClose()

Called when a websocket server gets a Close frame from a client.

handleConnected()

Called when a websocket client connects to the server.

handleMessage()

Called when websocket frame is received. To access the frame data call self.data.

If the frame is Text then self.data is a unicode object. If the frame is Binary then self.data is a bytearray object.

sendFragment(data)

see sendFragmentStart()

If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary.

sendFragmentEnd(data)

see sendFragmentEnd()

If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary.

sendFragmentStart(data)

Send the start of a data fragment stream to a websocket client. Subsequent data should be sent using sendFragment(). A fragment stream is completed when sendFragmentEnd() is called.

If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary.

sendMessage(data)

Send websocket data frame to the client.

If data is a unicode object then the frame is sent as Text. If the data is a bytearray object then the frame is sent as Binary.

class ulauncher.util.SimpleWebSocketServer.SimpleWebSocketServer(host, port, websocketclass, selectInterval=0.1)

Bases: object

close()
serveforever()
class ulauncher.util.SimpleWebSocketServer.SimpleSSLWebSocketServer(host, port, websocketclass, certfile, keyfile, version=3, selectInterval=0.1)

Bases: ulauncher.util.SimpleWebSocketServer.SimpleWebSocketServer

close()
serveforever()

ulauncher.util.SortedCollection module

class ulauncher.util.SortedCollection.SortedCollection(iterable=(), key=None)

Bases: object

Sequence sorted by a key function.

SortedCollection() is much easier to work with than using bisect() directly. It supports key functions like those use in sorted(), min(), and max(). The result of the key function call is saved so that keys can be searched efficiently.

Instead of returning an insertion-point which can be hard to interpret, the five find-methods return a specific item in the sequence. They can scan for exact matches, the last item less-than-or-equal to a key, or the first item greater-than-or-equal to a key.

Once found, an item’s ordinal position can be located with the index() method. New items can be added with the insert() and insert_right() methods. Old items can be deleted with the remove() method.

The usual sequence methods are provided to support indexing, slicing, length lookup, clearing, copying, forward and reverse iteration, contains checking, item counts, item removal, and a nice looking repr.

Finding and indexing are O(log n) operations while iteration and insertion are O(n). The initial sort is O(n log n).

The key function is stored in the ‘key’ attibute for easy introspection or so that you can assign a new key function (triggering an automatic re-sort).

In short, the class was designed to handle all of the common use cases for bisect but with a simpler API and support for key functions.

>>> from pprint import pprint
>>> from operator import itemgetter
>>> s = SortedCollection(key=itemgetter(2))
>>> for record in [
...         ('roger', 'young', 30),
...         ('angela', 'jones', 28),
...         ('bill', 'smith', 22),
...         ('david', 'thomas', 32)]:
...     s.insert(record)
>>> pprint(list(s))         # show records sorted by age
[('bill', 'smith', 22),
 ('angela', 'jones', 28),
 ('roger', 'young', 30),
 ('david', 'thomas', 32)]
>>> s.find_le(29)           # find oldest person aged 29 or younger
('angela', 'jones', 28)
>>> s.find_lt(28)           # find oldest person under 28
('bill', 'smith', 22)
>>> s.find_gt(28)           # find youngest person over 28
('roger', 'young', 30)
>>> r = s.find_ge(32)       # find youngest person aged 32 or older
>>> s.index(r)              # get the index of their record
3
>>> s[3]                    # fetch the record at that index
('david', 'thomas', 32)
>>> s.key = itemgetter(0)   # now sort by first name
>>> pprint(list(s))
[('angela', 'jones', 28),
 ('bill', 'smith', 22),
 ('david', 'thomas', 32),
 ('roger', 'young', 30)]
clear()
copy()
count(item)

Return number of occurrences of item

find(k)

Return first item with a key == k. Raise ValueError if not found.

find_ge(k)

Return first item with a key >= equal to k. Raise ValueError if not found

find_gt(k)

Return first item with a key > k. Raise ValueError if not found

find_le(k)

Return last item with a key <= k. Raise ValueError if not found.

find_lt(k)

Return last item with a key < k. Raise ValueError if not found.

index(item)

Find the position of an item. Raise ValueError if not found.

insert(item)

Insert a new item. If equal keys are found, add to the left

insert_right(item)

Insert a new item. If equal keys are found, add to the right

key

key function

pop(index=-1)
remove(item)

Remove first occurence of item. Raise ValueError if not found

ulauncher.util.display module

ulauncher.util.file_finder module

ulauncher.util.file_finder.find_files(directory, pattern=None, filter_fn=None)

Search files in directory filter_fn takes two arguments: directory, filename. If return value is False, file will be ignored

ulauncher.util.fuzzy_search module

ulauncher.util.image_loader module

ulauncher.util.setup_logging module

ulauncher.util.string module

ulauncher.util.string.force_unicode(text)
ulauncher.util.string.split_camel_case(text, sep='_')

ulauncher.util.text_highlighter module

ulauncher.util.version_cmp module

Module contents