id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
54,300
Fantomas42/django-emoticons
emoticons/templatetags/emoticons_tags.py
replace_emoticons
def replace_emoticons(content, excluded_markups): """ Replace the emoticons string by HTML images. If some markups should be excluded from replacement, BeautifulSoup will be used. """ if not excluded_markups: return regexp_replace_emoticons(content) excluded_markups = excluded_marku...
python
def replace_emoticons(content, excluded_markups): """ Replace the emoticons string by HTML images. If some markups should be excluded from replacement, BeautifulSoup will be used. """ if not excluded_markups: return regexp_replace_emoticons(content) excluded_markups = excluded_marku...
[ "def", "replace_emoticons", "(", "content", ",", "excluded_markups", ")", ":", "if", "not", "excluded_markups", ":", "return", "regexp_replace_emoticons", "(", "content", ")", "excluded_markups", "=", "excluded_markups", ".", "split", "(", "','", ")", "+", "[", ...
Replace the emoticons string by HTML images. If some markups should be excluded from replacement, BeautifulSoup will be used.
[ "Replace", "the", "emoticons", "string", "by", "HTML", "images", ".", "If", "some", "markups", "should", "be", "excluded", "from", "replacement", "BeautifulSoup", "will", "be", "used", "." ]
14a9895505874dfdd28e74d563a5fc521e3a315f
https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/templatetags/emoticons_tags.py#L25-L43
54,301
Fantomas42/django-emoticons
emoticons/templatetags/emoticons_tags.py
emoticons_tag
def emoticons_tag(parser, token): """ Tag for rendering emoticons. """ exclude = '' args = token.split_contents() if len(args) == 2: exclude = args[1] elif len(args) > 2: raise template.TemplateSyntaxError( 'emoticons tag has only one optional argument') node...
python
def emoticons_tag(parser, token): """ Tag for rendering emoticons. """ exclude = '' args = token.split_contents() if len(args) == 2: exclude = args[1] elif len(args) > 2: raise template.TemplateSyntaxError( 'emoticons tag has only one optional argument') node...
[ "def", "emoticons_tag", "(", "parser", ",", "token", ")", ":", "exclude", "=", "''", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", "==", "2", ":", "exclude", "=", "args", "[", "1", "]", "elif", "len", "(", ...
Tag for rendering emoticons.
[ "Tag", "for", "rendering", "emoticons", "." ]
14a9895505874dfdd28e74d563a5fc521e3a315f
https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/templatetags/emoticons_tags.py#L70-L84
54,302
Fantomas42/django-emoticons
emoticons/templatetags/emoticons_tags.py
emoticons_filter
def emoticons_filter(content, exclude='', autoescape=None): """ Filter for rendering emoticons. """ esc = autoescape and conditional_escape or (lambda x: x) content = mark_safe(replace_emoticons(esc(content), exclude)) return content
python
def emoticons_filter(content, exclude='', autoescape=None): """ Filter for rendering emoticons. """ esc = autoescape and conditional_escape or (lambda x: x) content = mark_safe(replace_emoticons(esc(content), exclude)) return content
[ "def", "emoticons_filter", "(", "content", ",", "exclude", "=", "''", ",", "autoescape", "=", "None", ")", ":", "esc", "=", "autoescape", "and", "conditional_escape", "or", "(", "lambda", "x", ":", "x", ")", "content", "=", "mark_safe", "(", "replace_emoti...
Filter for rendering emoticons.
[ "Filter", "for", "rendering", "emoticons", "." ]
14a9895505874dfdd28e74d563a5fc521e3a315f
https://github.com/Fantomas42/django-emoticons/blob/14a9895505874dfdd28e74d563a5fc521e3a315f/emoticons/templatetags/emoticons_tags.py#L88-L94
54,303
caseyjlaw/rtpipe
rtpipe/nbpipeline.py
state.save
def save(self, obj, label, format='text'): """ Save or update obj as pkl file with name label format can be 'text' or 'pickle'. """ # initialize hidden state directory objloc = '{0}/{1}'.format(self.statedir, label) with open(objloc, 'w') as fp: if format...
python
def save(self, obj, label, format='text'): """ Save or update obj as pkl file with name label format can be 'text' or 'pickle'. """ # initialize hidden state directory objloc = '{0}/{1}'.format(self.statedir, label) with open(objloc, 'w') as fp: if format...
[ "def", "save", "(", "self", ",", "obj", ",", "label", ",", "format", "=", "'text'", ")", ":", "# initialize hidden state directory", "objloc", "=", "'{0}/{1}'", ".", "format", "(", "self", ".", "statedir", ",", "label", ")", "with", "open", "(", "objloc", ...
Save or update obj as pkl file with name label format can be 'text' or 'pickle'.
[ "Save", "or", "update", "obj", "as", "pkl", "file", "with", "name", "label" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/nbpipeline.py#L24-L42
54,304
caseyjlaw/rtpipe
rtpipe/nbpipeline.py
state.load
def load(self, label): """ Load obj with give label from hidden state directory """ objloc = '{0}/{1}'.format(self.statedir, label) try: obj = pickle.load(open(objloc, 'r')) except (KeyError, IndexError, EOFError): obj = open(objloc, 'r').read() try...
python
def load(self, label): """ Load obj with give label from hidden state directory """ objloc = '{0}/{1}'.format(self.statedir, label) try: obj = pickle.load(open(objloc, 'r')) except (KeyError, IndexError, EOFError): obj = open(objloc, 'r').read() try...
[ "def", "load", "(", "self", ",", "label", ")", ":", "objloc", "=", "'{0}/{1}'", ".", "format", "(", "self", ".", "statedir", ",", "label", ")", "try", ":", "obj", "=", "pickle", ".", "load", "(", "open", "(", "objloc", ",", "'r'", ")", ")", "exce...
Load obj with give label from hidden state directory
[ "Load", "obj", "with", "give", "label", "from", "hidden", "state", "directory" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/nbpipeline.py#L45-L61
54,305
caseyjlaw/rtpipe
rtpipe/FDMT.py
FDMT_params
def FDMT_params(f_min, f_max, maxDT, inttime): """ Summarize DM grid and other parameters. """ maxDM = inttime*maxDT/(4.1488e-3 * (1/f_min**2 - 1/f_max**2)) logger.info('Freqs from {0}-{1}, MaxDT {2}, Int time {3} => maxDM {4}'.format(f_min, f_max, maxDT, inttime, maxDM))
python
def FDMT_params(f_min, f_max, maxDT, inttime): """ Summarize DM grid and other parameters. """ maxDM = inttime*maxDT/(4.1488e-3 * (1/f_min**2 - 1/f_max**2)) logger.info('Freqs from {0}-{1}, MaxDT {2}, Int time {3} => maxDM {4}'.format(f_min, f_max, maxDT, inttime, maxDM))
[ "def", "FDMT_params", "(", "f_min", ",", "f_max", ",", "maxDT", ",", "inttime", ")", ":", "maxDM", "=", "inttime", "*", "maxDT", "/", "(", "4.1488e-3", "*", "(", "1", "/", "f_min", "**", "2", "-", "1", "/", "f_max", "**", "2", ")", ")", "logger",...
Summarize DM grid and other parameters.
[ "Summarize", "DM", "grid", "and", "other", "parameters", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/FDMT.py#L62-L68
54,306
caseyjlaw/rtpipe
rtpipe/FDMT.py
dmtoind
def dmtoind(dm, f_min, f_max, nchan0, inttime, it): """ Given FDMT state, return indices to slice partial FDMT solution and sump to a given DM """ # maxDT = dmtodt(dm) # need to write if it>0: correction = dF/2. else: correction = 0 shift = [] nchan = nchan0/2**(iterati...
python
def dmtoind(dm, f_min, f_max, nchan0, inttime, it): """ Given FDMT state, return indices to slice partial FDMT solution and sump to a given DM """ # maxDT = dmtodt(dm) # need to write if it>0: correction = dF/2. else: correction = 0 shift = [] nchan = nchan0/2**(iterati...
[ "def", "dmtoind", "(", "dm", ",", "f_min", ",", "f_max", ",", "nchan0", ",", "inttime", ",", "it", ")", ":", "# maxDT = dmtodt(dm) # need to write", "if", "it", ">", "0", ":", "correction", "=", "dF", "/", "2.", "else", ":", "correction", "=", "0", ...
Given FDMT state, return indices to slice partial FDMT solution and sump to a given DM
[ "Given", "FDMT", "state", "return", "indices", "to", "slice", "partial", "FDMT", "solution", "and", "sump", "to", "a", "given", "DM" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/FDMT.py#L71-L94
54,307
limpyd/redis-limpyd
limpyd/utils.py
unique_key
def unique_key(connection): """ Generate a unique keyname that does not exists is the connection keyspace. """ while 1: key = str(uuid.uuid4().hex) if not connection.exists(key): break return key
python
def unique_key(connection): """ Generate a unique keyname that does not exists is the connection keyspace. """ while 1: key = str(uuid.uuid4().hex) if not connection.exists(key): break return key
[ "def", "unique_key", "(", "connection", ")", ":", "while", "1", ":", "key", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ".", "hex", ")", "if", "not", "connection", ".", "exists", "(", "key", ")", ":", "break", "return", "key" ]
Generate a unique keyname that does not exists is the connection keyspace.
[ "Generate", "a", "unique", "keyname", "that", "does", "not", "exists", "is", "the", "connection", "keyspace", "." ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/utils.py#L16-L25
54,308
limpyd/redis-limpyd
limpyd/utils.py
normalize
def normalize(value): """ Simple method to always have the same kind of value """ if value and isinstance(value, bytes): value = value.decode('utf-8') return value
python
def normalize(value): """ Simple method to always have the same kind of value """ if value and isinstance(value, bytes): value = value.decode('utf-8') return value
[ "def", "normalize", "(", "value", ")", ":", "if", "value", "and", "isinstance", "(", "value", ",", "bytes", ")", ":", "value", "=", "value", ".", "decode", "(", "'utf-8'", ")", "return", "value" ]
Simple method to always have the same kind of value
[ "Simple", "method", "to", "always", "have", "the", "same", "kind", "of", "value" ]
3c745dde1390a0bd09690b77a089dcc08c6c7e43
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/utils.py#L28-L34
54,309
Zaeb0s/epoll-socket-server
esockets/socket_server.py
SocketServer._mainthread_accept_clients
def _mainthread_accept_clients(self): """Accepts new clients and sends them to the to _handle_accepted within a subthread """ try: if self._accept_selector.select(timeout=self.block_time): client = self._server_socket.accept() logging.info('Client conn...
python
def _mainthread_accept_clients(self): """Accepts new clients and sends them to the to _handle_accepted within a subthread """ try: if self._accept_selector.select(timeout=self.block_time): client = self._server_socket.accept() logging.info('Client conn...
[ "def", "_mainthread_accept_clients", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_accept_selector", ".", "select", "(", "timeout", "=", "self", ".", "block_time", ")", ":", "client", "=", "self", ".", "_server_socket", ".", "accept", "(", ")", ...
Accepts new clients and sends them to the to _handle_accepted within a subthread
[ "Accepts", "new", "clients", "and", "sends", "them", "to", "the", "to", "_handle_accepted", "within", "a", "subthread" ]
0b8c8b3c368f8948777579ea1e89e75ab5899372
https://github.com/Zaeb0s/epoll-socket-server/blob/0b8c8b3c368f8948777579ea1e89e75ab5899372/esockets/socket_server.py#L103-L114
54,310
Zaeb0s/epoll-socket-server
esockets/socket_server.py
SocketServer._mainthread_poll_readable
def _mainthread_poll_readable(self): """Searches for readable client sockets. These sockets are then put in a subthread to be handled by _handle_readable """ events = self._recv_selector.select(self.block_time) for key, mask in events: if mask == selectors.EVENT_READ:...
python
def _mainthread_poll_readable(self): """Searches for readable client sockets. These sockets are then put in a subthread to be handled by _handle_readable """ events = self._recv_selector.select(self.block_time) for key, mask in events: if mask == selectors.EVENT_READ:...
[ "def", "_mainthread_poll_readable", "(", "self", ")", ":", "events", "=", "self", ".", "_recv_selector", ".", "select", "(", "self", ".", "block_time", ")", "for", "key", ",", "mask", "in", "events", ":", "if", "mask", "==", "selectors", ".", "EVENT_READ",...
Searches for readable client sockets. These sockets are then put in a subthread to be handled by _handle_readable
[ "Searches", "for", "readable", "client", "sockets", ".", "These", "sockets", "are", "then", "put", "in", "a", "subthread", "to", "be", "handled", "by", "_handle_readable" ]
0b8c8b3c368f8948777579ea1e89e75ab5899372
https://github.com/Zaeb0s/epoll-socket-server/blob/0b8c8b3c368f8948777579ea1e89e75ab5899372/esockets/socket_server.py#L117-L127
54,311
Zaeb0s/epoll-socket-server
esockets/socket_server.py
SocketServer._subthread_handle_accepted
def _subthread_handle_accepted(self, client): """Gets accepted clients from the queue object and sets up the client socket. The client can then be found in the clients dictionary with the socket object as the key. """ conn, addr = client if self.handle_incoming(conn, add...
python
def _subthread_handle_accepted(self, client): """Gets accepted clients from the queue object and sets up the client socket. The client can then be found in the clients dictionary with the socket object as the key. """ conn, addr = client if self.handle_incoming(conn, add...
[ "def", "_subthread_handle_accepted", "(", "self", ",", "client", ")", ":", "conn", ",", "addr", "=", "client", "if", "self", ".", "handle_incoming", "(", "conn", ",", "addr", ")", ":", "logging", ".", "info", "(", "'Accepted connection from client: {}'", ".", ...
Gets accepted clients from the queue object and sets up the client socket. The client can then be found in the clients dictionary with the socket object as the key.
[ "Gets", "accepted", "clients", "from", "the", "queue", "object", "and", "sets", "up", "the", "client", "socket", ".", "The", "client", "can", "then", "be", "found", "in", "the", "clients", "dictionary", "with", "the", "socket", "object", "as", "the", "key"...
0b8c8b3c368f8948777579ea1e89e75ab5899372
https://github.com/Zaeb0s/epoll-socket-server/blob/0b8c8b3c368f8948777579ea1e89e75ab5899372/esockets/socket_server.py#L130-L144
54,312
Zaeb0s/epoll-socket-server
esockets/socket_server.py
SocketServer._subthread_handle_readable
def _subthread_handle_readable(self, conn): """Handles readable client sockets. Calls the user modified handle_readable with the client socket as the only variable. If the handle_readable function returns true the client is again registered to the selector object otherwise the client is ...
python
def _subthread_handle_readable(self, conn): """Handles readable client sockets. Calls the user modified handle_readable with the client socket as the only variable. If the handle_readable function returns true the client is again registered to the selector object otherwise the client is ...
[ "def", "_subthread_handle_readable", "(", "self", ",", "conn", ")", ":", "if", "self", ".", "handle_readable", "(", "conn", ")", ":", "self", ".", "register", "(", "conn", ")", "else", ":", "self", ".", "disconnect", "(", "conn", ")" ]
Handles readable client sockets. Calls the user modified handle_readable with the client socket as the only variable. If the handle_readable function returns true the client is again registered to the selector object otherwise the client is disconnected.
[ "Handles", "readable", "client", "sockets", ".", "Calls", "the", "user", "modified", "handle_readable", "with", "the", "client", "socket", "as", "the", "only", "variable", ".", "If", "the", "handle_readable", "function", "returns", "true", "the", "client", "is",...
0b8c8b3c368f8948777579ea1e89e75ab5899372
https://github.com/Zaeb0s/epoll-socket-server/blob/0b8c8b3c368f8948777579ea1e89e75ab5899372/esockets/socket_server.py#L147-L157
54,313
caseyjlaw/rtpipe
rtpipe/RT.py
meantsubpool
def meantsubpool(d, data_read): """ Wrapper for mean visibility subtraction in time. Doesn't work when called from pipeline using multiprocessing pool. """ logger.info('Subtracting mean visibility in time...') data_read = numpyview(data_read_mem, 'complex64', datashape(d)) tsubpart = partial(rt...
python
def meantsubpool(d, data_read): """ Wrapper for mean visibility subtraction in time. Doesn't work when called from pipeline using multiprocessing pool. """ logger.info('Subtracting mean visibility in time...') data_read = numpyview(data_read_mem, 'complex64', datashape(d)) tsubpart = partial(rt...
[ "def", "meantsubpool", "(", "d", ",", "data_read", ")", ":", "logger", ".", "info", "(", "'Subtracting mean visibility in time...'", ")", "data_read", "=", "numpyview", "(", "data_read_mem", ",", "'complex64'", ",", "datashape", "(", "d", ")", ")", "tsubpart", ...
Wrapper for mean visibility subtraction in time. Doesn't work when called from pipeline using multiprocessing pool.
[ "Wrapper", "for", "mean", "visibility", "subtraction", "in", "time", ".", "Doesn", "t", "work", "when", "called", "from", "pipeline", "using", "multiprocessing", "pool", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L317-L328
54,314
caseyjlaw/rtpipe
rtpipe/RT.py
dataflag
def dataflag(d, data_read): """ Flagging data in single process """ for flag in d['flaglist']: mode, sig, conv = flag # resultlist = [] # with closing(mp.Pool(4, initializer=initreadonly, initargs=(data_read_mem,))) as flagpool: for ss in d['spw']: chans = n.arang...
python
def dataflag(d, data_read): """ Flagging data in single process """ for flag in d['flaglist']: mode, sig, conv = flag # resultlist = [] # with closing(mp.Pool(4, initializer=initreadonly, initargs=(data_read_mem,))) as flagpool: for ss in d['spw']: chans = n.arang...
[ "def", "dataflag", "(", "d", ",", "data_read", ")", ":", "for", "flag", "in", "d", "[", "'flaglist'", "]", ":", "mode", ",", "sig", ",", "conv", "=", "flag", "# resultlist = []", "# with closing(mp.Pool(4, initializer=initreadonly, initargs=(data_read_me...
Flagging data in single process
[ "Flagging", "data", "in", "single", "process" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L331-L359
54,315
caseyjlaw/rtpipe
rtpipe/RT.py
dataflagatom
def dataflagatom(chans, pol, d, sig, mode, conv): """ Wrapper function to get shared memory as numpy array into pool Assumes data_mem is global mps.Array """ data = numpyview(data_mem, 'complex64', datashape(d)) # data = n.ma.masked_array(data, data==0j) # this causes massive overflagging on 14sep0...
python
def dataflagatom(chans, pol, d, sig, mode, conv): """ Wrapper function to get shared memory as numpy array into pool Assumes data_mem is global mps.Array """ data = numpyview(data_mem, 'complex64', datashape(d)) # data = n.ma.masked_array(data, data==0j) # this causes massive overflagging on 14sep0...
[ "def", "dataflagatom", "(", "chans", ",", "pol", ",", "d", ",", "sig", ",", "mode", ",", "conv", ")", ":", "data", "=", "numpyview", "(", "data_mem", ",", "'complex64'", ",", "datashape", "(", "d", ")", ")", "# data = n.ma.masked_array(data, data==0j) # ...
Wrapper function to get shared memory as numpy array into pool Assumes data_mem is global mps.Array
[ "Wrapper", "function", "to", "get", "shared", "memory", "as", "numpy", "array", "into", "pool", "Assumes", "data_mem", "is", "global", "mps", ".", "Array" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L362-L370
54,316
caseyjlaw/rtpipe
rtpipe/RT.py
runreproduce
def runreproduce(d, data_mem, data_resamp_mem, u, v, w, dmind, dtind, candint=-1, lm=None, twindow=30): """ Reproduce function, much like search. Returns image and rephased data for given candint. If no candint is given, it returns resampled data by default. Optionally rephases to lm=(l, m) coordinates. ...
python
def runreproduce(d, data_mem, data_resamp_mem, u, v, w, dmind, dtind, candint=-1, lm=None, twindow=30): """ Reproduce function, much like search. Returns image and rephased data for given candint. If no candint is given, it returns resampled data by default. Optionally rephases to lm=(l, m) coordinates. ...
[ "def", "runreproduce", "(", "d", ",", "data_mem", ",", "data_resamp_mem", ",", "u", ",", "v", ",", "w", ",", "dmind", ",", "dtind", ",", "candint", "=", "-", "1", ",", "lm", "=", "None", ",", "twindow", "=", "30", ")", ":", "data_resamp", "=", "n...
Reproduce function, much like search. Returns image and rephased data for given candint. If no candint is given, it returns resampled data by default. Optionally rephases to lm=(l, m) coordinates.
[ "Reproduce", "function", "much", "like", "search", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L472-L521
54,317
caseyjlaw/rtpipe
rtpipe/RT.py
make_transient
def make_transient(std, DMmax, Amin=6., Amax=20., rmax=20., rmin=0., DMmin=0.): """ Produce a mock transient pulse source for the purposes of characterizing the detection success of the current pipeline. Assumes - Code to inject the transients does so by inserting at an array index - Noise lev...
python
def make_transient(std, DMmax, Amin=6., Amax=20., rmax=20., rmin=0., DMmin=0.): """ Produce a mock transient pulse source for the purposes of characterizing the detection success of the current pipeline. Assumes - Code to inject the transients does so by inserting at an array index - Noise lev...
[ "def", "make_transient", "(", "std", ",", "DMmax", ",", "Amin", "=", "6.", ",", "Amax", "=", "20.", ",", "rmax", "=", "20.", ",", "rmin", "=", "0.", ",", "DMmin", "=", "0.", ")", ":", "rad_arcmin", "=", "math", ".", "pi", "/", "(", "180", "*", ...
Produce a mock transient pulse source for the purposes of characterizing the detection success of the current pipeline. Assumes - Code to inject the transients does so by inserting at an array index - Noise level at the center of the data array is characteristic of the noise level throughout...
[ "Produce", "a", "mock", "transient", "pulse", "source", "for", "the", "purposes", "of", "characterizing", "the", "detection", "success", "of", "the", "current", "pipeline", ".", "Assumes", "-", "Code", "to", "inject", "the", "transients", "does", "so", "by", ...
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L541-L581
54,318
caseyjlaw/rtpipe
rtpipe/RT.py
calc_nfalse
def calc_nfalse(d): """ Calculate the number of thermal-noise false positives per segment. """ dtfactor = n.sum([1./i for i in d['dtarr']]) # assumes dedisperse-all algorithm ntrials = d['readints'] * dtfactor * len(d['dmarr']) * d['npixx'] * d['npixy'] qfrac = 1 - (erf(d['sigma_image1']/n.sqrt(...
python
def calc_nfalse(d): """ Calculate the number of thermal-noise false positives per segment. """ dtfactor = n.sum([1./i for i in d['dtarr']]) # assumes dedisperse-all algorithm ntrials = d['readints'] * dtfactor * len(d['dmarr']) * d['npixx'] * d['npixy'] qfrac = 1 - (erf(d['sigma_image1']/n.sqrt(...
[ "def", "calc_nfalse", "(", "d", ")", ":", "dtfactor", "=", "n", ".", "sum", "(", "[", "1.", "/", "i", "for", "i", "in", "d", "[", "'dtarr'", "]", "]", ")", "# assumes dedisperse-all algorithm", "ntrials", "=", "d", "[", "'readints'", "]", "*", "dtfac...
Calculate the number of thermal-noise false positives per segment.
[ "Calculate", "the", "number", "of", "thermal", "-", "noise", "false", "positives", "per", "segment", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L961-L969
54,319
caseyjlaw/rtpipe
rtpipe/RT.py
calc_segment_times
def calc_segment_times(d): """ Helper function for set_pipeline to define segmenttimes list, given nsegments definition """ # this casts to int (flooring) to avoid 0.5 int rounding issue. stopdts = n.linspace(d['nskip']+d['t_overlap']/d['inttime'], d['nints'], d['nsegments']+1)[1:] # nseg+1 assures ...
python
def calc_segment_times(d): """ Helper function for set_pipeline to define segmenttimes list, given nsegments definition """ # this casts to int (flooring) to avoid 0.5 int rounding issue. stopdts = n.linspace(d['nskip']+d['t_overlap']/d['inttime'], d['nints'], d['nsegments']+1)[1:] # nseg+1 assures ...
[ "def", "calc_segment_times", "(", "d", ")", ":", "# this casts to int (flooring) to avoid 0.5 int rounding issue. ", "stopdts", "=", "n", ".", "linspace", "(", "d", "[", "'nskip'", "]", "+", "d", "[", "'t_overlap'", "]", "/", "d", "[", "'inttime'", "]", ",", "...
Helper function for set_pipeline to define segmenttimes list, given nsegments definition
[ "Helper", "function", "for", "set_pipeline", "to", "define", "segmenttimes", "list", "given", "nsegments", "definition" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L972-L988
54,320
caseyjlaw/rtpipe
rtpipe/RT.py
calc_fringetime
def calc_fringetime(d): """ Estimate largest time span of a "segment". A segment is the maximal time span that can be have a single bg fringe subtracted and uv grid definition. Max fringe window estimated for 5% amp loss at first null averaged over all baselines. Assumes dec=+90, which is conservative. ...
python
def calc_fringetime(d): """ Estimate largest time span of a "segment". A segment is the maximal time span that can be have a single bg fringe subtracted and uv grid definition. Max fringe window estimated for 5% amp loss at first null averaged over all baselines. Assumes dec=+90, which is conservative. ...
[ "def", "calc_fringetime", "(", "d", ")", ":", "maxbl", "=", "d", "[", "'uvres'", "]", "*", "d", "[", "'npix'", "]", "/", "2", "# fringe time for imaged data only", "fringetime", "=", "0.5", "*", "(", "24", "*", "3600", ")", "/", "(", "2", "*", "n", ...
Estimate largest time span of a "segment". A segment is the maximal time span that can be have a single bg fringe subtracted and uv grid definition. Max fringe window estimated for 5% amp loss at first null averaged over all baselines. Assumes dec=+90, which is conservative. Returns time in seconds that def...
[ "Estimate", "largest", "time", "span", "of", "a", "segment", ".", "A", "segment", "is", "the", "maximal", "time", "span", "that", "can", "be", "have", "a", "single", "bg", "fringe", "subtracted", "and", "uv", "grid", "definition", ".", "Max", "fringe", "...
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1015-L1024
54,321
caseyjlaw/rtpipe
rtpipe/RT.py
correct_dm
def correct_dm(d, dm, blrange): """ Dedisperses data into data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time. """ data = numpyview(data_mem, 'complex64', datashape(d)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) bl0,bl1 = blrange ...
python
def correct_dm(d, dm, blrange): """ Dedisperses data into data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time. """ data = numpyview(data_mem, 'complex64', datashape(d)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) bl0,bl1 = blrange ...
[ "def", "correct_dm", "(", "d", ",", "dm", ",", "blrange", ")", ":", "data", "=", "numpyview", "(", "data_mem", ",", "'complex64'", ",", "datashape", "(", "d", ")", ")", "data_resamp", "=", "numpyview", "(", "data_resamp_mem", ",", "'complex64'", ",", "da...
Dedisperses data into data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time.
[ "Dedisperses", "data", "into", "data_resamp", "Drops", "edges", "since", "it", "assumes", "that", "data", "is", "read", "with", "overlapping", "chunks", "in", "time", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1039-L1048
54,322
caseyjlaw/rtpipe
rtpipe/RT.py
correct_dt
def correct_dt(d, dt, blrange): """ Resamples data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time. """ data = numpyview(data_mem, 'complex64', datashape(d)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) bl0,bl1 = blrange rtlib.re...
python
def correct_dt(d, dt, blrange): """ Resamples data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time. """ data = numpyview(data_mem, 'complex64', datashape(d)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) bl0,bl1 = blrange rtlib.re...
[ "def", "correct_dt", "(", "d", ",", "dt", ",", "blrange", ")", ":", "data", "=", "numpyview", "(", "data_mem", ",", "'complex64'", ",", "datashape", "(", "d", ")", ")", "data_resamp", "=", "numpyview", "(", "data_resamp_mem", ",", "'complex64'", ",", "da...
Resamples data_resamp Drops edges, since it assumes that data is read with overlapping chunks in time.
[ "Resamples", "data_resamp", "Drops", "edges", "since", "it", "assumes", "that", "data", "is", "read", "with", "overlapping", "chunks", "in", "time", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1051-L1059
54,323
caseyjlaw/rtpipe
rtpipe/RT.py
move_phasecenter
def move_phasecenter(d, l1, m1, u, v): """ Handler function for phaseshift_threaded """ logger.info('Rephasing data to (l, m)=(%.4f, %.4f).' % (l1, m1)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) rtlib.phaseshift_threaded(data_resamp, d, l1, m1, u, v)
python
def move_phasecenter(d, l1, m1, u, v): """ Handler function for phaseshift_threaded """ logger.info('Rephasing data to (l, m)=(%.4f, %.4f).' % (l1, m1)) data_resamp = numpyview(data_resamp_mem, 'complex64', datashape(d)) rtlib.phaseshift_threaded(data_resamp, d, l1, m1, u, v)
[ "def", "move_phasecenter", "(", "d", ",", "l1", ",", "m1", ",", "u", ",", "v", ")", ":", "logger", ".", "info", "(", "'Rephasing data to (l, m)=(%.4f, %.4f).'", "%", "(", "l1", ",", "m1", ")", ")", "data_resamp", "=", "numpyview", "(", "data_resamp_mem", ...
Handler function for phaseshift_threaded
[ "Handler", "function", "for", "phaseshift_threaded" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1089-L1095
54,324
caseyjlaw/rtpipe
rtpipe/RT.py
calc_dmgrid
def calc_dmgrid(d, maxloss=0.05, dt=3000., mindm=0., maxdm=0.): """ Function to calculate the DM values for a given maximum sensitivity loss. maxloss is sensitivity loss tolerated by dm bin width. dt is assumed pulse width in microsec. """ # parameters tsamp = d['inttime']*1e6 # in microsec k ...
python
def calc_dmgrid(d, maxloss=0.05, dt=3000., mindm=0., maxdm=0.): """ Function to calculate the DM values for a given maximum sensitivity loss. maxloss is sensitivity loss tolerated by dm bin width. dt is assumed pulse width in microsec. """ # parameters tsamp = d['inttime']*1e6 # in microsec k ...
[ "def", "calc_dmgrid", "(", "d", ",", "maxloss", "=", "0.05", ",", "dt", "=", "3000.", ",", "mindm", "=", "0.", ",", "maxdm", "=", "0.", ")", ":", "# parameters", "tsamp", "=", "d", "[", "'inttime'", "]", "*", "1e6", "# in microsec", "k", "=", "8.3"...
Function to calculate the DM values for a given maximum sensitivity loss. maxloss is sensitivity loss tolerated by dm bin width. dt is assumed pulse width in microsec.
[ "Function", "to", "calculate", "the", "DM", "values", "for", "a", "given", "maximum", "sensitivity", "loss", ".", "maxloss", "is", "sensitivity", "loss", "tolerated", "by", "dm", "bin", "width", ".", "dt", "is", "assumed", "pulse", "width", "in", "microsec",...
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1098-L1128
54,325
caseyjlaw/rtpipe
rtpipe/RT.py
sample_image
def sample_image(d, data, u, v, w, i=-1, verbose=0, imager='xy', wres=100): """ Samples one integration and returns image i is integration to image. Default is mid int. """ if i == -1: i = len(data)/2 if imager == 'xy': image = rtlib.imgonefullxy(n.outer(u, d['freq']/d['freq_orig']...
python
def sample_image(d, data, u, v, w, i=-1, verbose=0, imager='xy', wres=100): """ Samples one integration and returns image i is integration to image. Default is mid int. """ if i == -1: i = len(data)/2 if imager == 'xy': image = rtlib.imgonefullxy(n.outer(u, d['freq']/d['freq_orig']...
[ "def", "sample_image", "(", "d", ",", "data", ",", "u", ",", "v", ",", "w", ",", "i", "=", "-", "1", ",", "verbose", "=", "0", ",", "imager", "=", "'xy'", ",", "wres", "=", "100", ")", ":", "if", "i", "==", "-", "1", ":", "i", "=", "len",...
Samples one integration and returns image i is integration to image. Default is mid int.
[ "Samples", "one", "integration", "and", "returns", "image", "i", "is", "integration", "to", "image", ".", "Default", "is", "mid", "int", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1414-L1432
54,326
caseyjlaw/rtpipe
rtpipe/RT.py
estimate_noiseperbl
def estimate_noiseperbl(data): """ Takes large data array and sigma clips it to find noise per bl for input to detect_bispectra. Takes mean across pols and channels for now, as in detect_bispectra. """ # define noise per baseline for data seen by detect_bispectra or image datamean = data.mean(a...
python
def estimate_noiseperbl(data): """ Takes large data array and sigma clips it to find noise per bl for input to detect_bispectra. Takes mean across pols and channels for now, as in detect_bispectra. """ # define noise per baseline for data seen by detect_bispectra or image datamean = data.mean(a...
[ "def", "estimate_noiseperbl", "(", "data", ")", ":", "# define noise per baseline for data seen by detect_bispectra or image", "datamean", "=", "data", ".", "mean", "(", "axis", "=", "2", ")", ".", "imag", "# use imaginary part to estimate noise without calibrated, on-axis sign...
Takes large data array and sigma clips it to find noise per bl for input to detect_bispectra. Takes mean across pols and channels for now, as in detect_bispectra.
[ "Takes", "large", "data", "array", "and", "sigma", "clips", "it", "to", "find", "noise", "per", "bl", "for", "input", "to", "detect_bispectra", ".", "Takes", "mean", "across", "pols", "and", "channels", "for", "now", "as", "in", "detect_bispectra", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1435-L1446
54,327
caseyjlaw/rtpipe
rtpipe/RT.py
noisepickle
def noisepickle(d, data, u, v, w, chunk=200): """ Calculates noise properties and saves values to pickle. chunk defines window for measurement. at least one measurement always made. """ if d['savenoise']: noisefile = getnoisefile(d) if os.path.exists(noisefile): logger.warn...
python
def noisepickle(d, data, u, v, w, chunk=200): """ Calculates noise properties and saves values to pickle. chunk defines window for measurement. at least one measurement always made. """ if d['savenoise']: noisefile = getnoisefile(d) if os.path.exists(noisefile): logger.warn...
[ "def", "noisepickle", "(", "d", ",", "data", ",", "u", ",", "v", ",", "w", ",", "chunk", "=", "200", ")", ":", "if", "d", "[", "'savenoise'", "]", ":", "noisefile", "=", "getnoisefile", "(", "d", ")", "if", "os", ".", "path", ".", "exists", "("...
Calculates noise properties and saves values to pickle. chunk defines window for measurement. at least one measurement always made.
[ "Calculates", "noise", "properties", "and", "saves", "values", "to", "pickle", ".", "chunk", "defines", "window", "for", "measurement", ".", "at", "least", "one", "measurement", "always", "made", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1449-L1475
54,328
caseyjlaw/rtpipe
rtpipe/RT.py
savecands
def savecands(d, cands, domock=False): """ Save all candidates in pkl file for later aggregation and filtering. domock is option to save simulated cands file """ with open(getcandsfile(d, domock=domock), 'w') as pkl: pickle.dump(d, pkl) pickle.dump(cands, pkl)
python
def savecands(d, cands, domock=False): """ Save all candidates in pkl file for later aggregation and filtering. domock is option to save simulated cands file """ with open(getcandsfile(d, domock=domock), 'w') as pkl: pickle.dump(d, pkl) pickle.dump(cands, pkl)
[ "def", "savecands", "(", "d", ",", "cands", ",", "domock", "=", "False", ")", ":", "with", "open", "(", "getcandsfile", "(", "d", ",", "domock", "=", "domock", ")", ",", "'w'", ")", "as", "pkl", ":", "pickle", ".", "dump", "(", "d", ",", "pkl", ...
Save all candidates in pkl file for later aggregation and filtering. domock is option to save simulated cands file
[ "Save", "all", "candidates", "in", "pkl", "file", "for", "later", "aggregation", "and", "filtering", ".", "domock", "is", "option", "to", "save", "simulated", "cands", "file" ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1478-L1485
54,329
caseyjlaw/rtpipe
rtpipe/RT.py
numpyview
def numpyview(arr, datatype, shape, raw=False): """ Takes mp shared array and returns numpy array with given shape. """ if raw: return n.frombuffer(arr, dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape) # for shared mps.RawArray else: return n.frombuffer(arr.get_obj(), d...
python
def numpyview(arr, datatype, shape, raw=False): """ Takes mp shared array and returns numpy array with given shape. """ if raw: return n.frombuffer(arr, dtype=n.dtype(datatype)).view(n.dtype(datatype)).reshape(shape) # for shared mps.RawArray else: return n.frombuffer(arr.get_obj(), d...
[ "def", "numpyview", "(", "arr", ",", "datatype", ",", "shape", ",", "raw", "=", "False", ")", ":", "if", "raw", ":", "return", "n", ".", "frombuffer", "(", "arr", ",", "dtype", "=", "n", ".", "dtype", "(", "datatype", ")", ")", ".", "view", "(", ...
Takes mp shared array and returns numpy array with given shape.
[ "Takes", "mp", "shared", "array", "and", "returns", "numpy", "array", "with", "given", "shape", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L1496-L1503
54,330
olt/scriptine
scriptine/_path.py
path.relpath
def relpath(self): """ Return this path as a relative path, based from the current working directory. """ cwd = self.__class__(os.getcwd()) return cwd.relpathto(self)
python
def relpath(self): """ Return this path as a relative path, based from the current working directory. """ cwd = self.__class__(os.getcwd()) return cwd.relpathto(self)
[ "def", "relpath", "(", "self", ")", ":", "cwd", "=", "self", ".", "__class__", "(", "os", ".", "getcwd", "(", ")", ")", "return", "cwd", ".", "relpathto", "(", "self", ")" ]
Return this path as a relative path, based from the current working directory.
[ "Return", "this", "path", "as", "a", "relative", "path", "based", "from", "the", "current", "working", "directory", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L281-L286
54,331
olt/scriptine
scriptine/_path.py
path.relpathto
def relpathto(self, dest): """ Return a relative path from self to dest. If there is no relative path from self to dest, for example if they reside on different drives in Windows, then this returns dest.abspath(). """ origin = self.abspath() dest = self.__class__...
python
def relpathto(self, dest): """ Return a relative path from self to dest. If there is no relative path from self to dest, for example if they reside on different drives in Windows, then this returns dest.abspath(). """ origin = self.abspath() dest = self.__class__...
[ "def", "relpathto", "(", "self", ",", "dest", ")", ":", "origin", "=", "self", ".", "abspath", "(", ")", "dest", "=", "self", ".", "__class__", "(", "dest", ")", ".", "abspath", "(", ")", "orig_list", "=", "origin", ".", "normcase", "(", ")", ".", ...
Return a relative path from self to dest. If there is no relative path from self to dest, for example if they reside on different drives in Windows, then this returns dest.abspath().
[ "Return", "a", "relative", "path", "from", "self", "to", "dest", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L288-L324
54,332
olt/scriptine
scriptine/_path.py
path.glob
def glob(self, pattern): """ Return a list of path objects that match the pattern. pattern - a path relative to this directory, with wildcards. For example, ``path('/users').glob('*/bin/*')`` returns a list of all the files users have in their bin directories. """ cls =...
python
def glob(self, pattern): """ Return a list of path objects that match the pattern. pattern - a path relative to this directory, with wildcards. For example, ``path('/users').glob('*/bin/*')`` returns a list of all the files users have in their bin directories. """ cls =...
[ "def", "glob", "(", "self", ",", "pattern", ")", ":", "cls", "=", "self", ".", "__class__", "return", "[", "cls", "(", "s", ")", "for", "s", "in", "glob", ".", "glob", "(", "_base", "(", "self", "/", "pattern", ")", ")", "]" ]
Return a list of path objects that match the pattern. pattern - a path relative to this directory, with wildcards. For example, ``path('/users').glob('*/bin/*')`` returns a list of all the files users have in their bin directories.
[ "Return", "a", "list", "of", "path", "objects", "that", "match", "the", "pattern", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L515-L524
54,333
olt/scriptine
scriptine/_path.py
path.read_md5
def read_md5(self, hex=False): """ Calculate the md5 hash for this file. hex - Return the digest as hex string. This reads through the entire file. """ f = self.open('rb') try: m = hashlib.md5() while True: d = f.read(8192) ...
python
def read_md5(self, hex=False): """ Calculate the md5 hash for this file. hex - Return the digest as hex string. This reads through the entire file. """ f = self.open('rb') try: m = hashlib.md5() while True: d = f.read(8192) ...
[ "def", "read_md5", "(", "self", ",", "hex", "=", "False", ")", ":", "f", "=", "self", ".", "open", "(", "'rb'", ")", "try", ":", "m", "=", "hashlib", ".", "md5", "(", ")", "while", "True", ":", "d", "=", "f", ".", "read", "(", "8192", ")", ...
Calculate the md5 hash for this file. hex - Return the digest as hex string. This reads through the entire file.
[ "Calculate", "the", "md5", "hash", "for", "this", "file", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L778-L798
54,334
olt/scriptine
scriptine/_path.py
path.owner
def owner(self): r""" Return the name of the owner of this file or directory. This follows symbolic links. On Windows, this returns a name of the form ur'DOMAIN\User Name'. On Windows, a group can own a file or directory. """ if os.name == 'nt': if win32secu...
python
def owner(self): r""" Return the name of the owner of this file or directory. This follows symbolic links. On Windows, this returns a name of the form ur'DOMAIN\User Name'. On Windows, a group can own a file or directory. """ if os.name == 'nt': if win32secu...
[ "def", "owner", "(", "self", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "if", "win32security", "is", "None", ":", "raise", "Exception", "(", "\"path.owner requires win32all to be installed\"", ")", "desc", "=", "win32security", ".", "GetFileSecurity",...
r""" Return the name of the owner of this file or directory. This follows symbolic links. On Windows, this returns a name of the form ur'DOMAIN\User Name'. On Windows, a group can own a file or directory.
[ "r", "Return", "the", "name", "of", "the", "owner", "of", "this", "file", "or", "directory", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L841-L861
54,335
olt/scriptine
scriptine/_path.py
path.ensure_dir
def ensure_dir(self, mode=0777): """ Make sure the directory exists, create if necessary. """ if not self.exists() or not self.isdir(): os.makedirs(self, mode)
python
def ensure_dir(self, mode=0777): """ Make sure the directory exists, create if necessary. """ if not self.exists() or not self.isdir(): os.makedirs(self, mode)
[ "def", "ensure_dir", "(", "self", ",", "mode", "=", "0777", ")", ":", "if", "not", "self", ".", "exists", "(", ")", "or", "not", "self", ".", "isdir", "(", ")", ":", "os", ".", "makedirs", "(", "self", ",", "mode", ")" ]
Make sure the directory exists, create if necessary.
[ "Make", "sure", "the", "directory", "exists", "create", "if", "necessary", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L914-L919
54,336
olt/scriptine
scriptine/_path.py
path.install
def install(self, to, chmod=0644): """ Copy data and set mode to 'chmod'. """ self.copy(to) path(to).chmod(chmod)
python
def install(self, to, chmod=0644): """ Copy data and set mode to 'chmod'. """ self.copy(to) path(to).chmod(chmod)
[ "def", "install", "(", "self", ",", "to", ",", "chmod", "=", "0644", ")", ":", "self", ".", "copy", "(", "to", ")", "path", "(", "to", ")", ".", "chmod", "(", "chmod", ")" ]
Copy data and set mode to 'chmod'.
[ "Copy", "data", "and", "set", "mode", "to", "chmod", "." ]
f4cfea939f2f3ad352b24c5f6410f79e78723d0e
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L999-L1004
54,337
caseyjlaw/rtpipe
rtpipe/parseparams.py
Params.parse
def parse(self, paramfile): """ Read parameter file and set parameter values. File should have python-like syntax. Full file name needed. """ with open(paramfile, 'r') as f: for line in f.readlines(): line_clean = line.rstrip('\n').split('#')[0] # trim out ...
python
def parse(self, paramfile): """ Read parameter file and set parameter values. File should have python-like syntax. Full file name needed. """ with open(paramfile, 'r') as f: for line in f.readlines(): line_clean = line.rstrip('\n').split('#')[0] # trim out ...
[ "def", "parse", "(", "self", ",", "paramfile", ")", ":", "with", "open", "(", "paramfile", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ".", "readlines", "(", ")", ":", "line_clean", "=", "line", ".", "rstrip", "(", "'\\n'", ")", "....
Read parameter file and set parameter values. File should have python-like syntax. Full file name needed.
[ "Read", "parameter", "file", "and", "set", "parameter", "values", ".", "File", "should", "have", "python", "-", "like", "syntax", ".", "Full", "file", "name", "needed", "." ]
ac33e4332cf215091a63afbb3137850876d73ec0
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parseparams.py#L37-L52
54,338
PedalPi/PluginsManager
pluginsmanager/observer/autosaver/index_file.py
IndexFile.load
def load(self, indexables): """ Load the index file and reorder the banks based in order listed in index :param list[Indexable] indexables: Banks that will be reordered based in index file :return list[Bank]: Banks reordered """ try: data = Persistence.read(s...
python
def load(self, indexables): """ Load the index file and reorder the banks based in order listed in index :param list[Indexable] indexables: Banks that will be reordered based in index file :return list[Bank]: Banks reordered """ try: data = Persistence.read(s...
[ "def", "load", "(", "self", ",", "indexables", ")", ":", "try", ":", "data", "=", "Persistence", ".", "read", "(", "self", ".", "path", ",", "create_file", "=", "True", ")", "except", "ValueError", ":", "data", "=", "{", "}", "return", "self", ".", ...
Load the index file and reorder the banks based in order listed in index :param list[Indexable] indexables: Banks that will be reordered based in index file :return list[Bank]: Banks reordered
[ "Load", "the", "index", "file", "and", "reorder", "the", "banks", "based", "in", "order", "listed", "in", "index" ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/observer/autosaver/index_file.py#L26-L38
54,339
PedalPi/PluginsManager
pluginsmanager/banks_manager.py
BanksManager.register
def register(self, observer): """ Register an observer for it be notified when occurs changes. For more details, see :class:`.UpdatesObserver` :param UpdatesObserver observer: Observer that will be notified then occurs changes """ self.observer_manager.append(observer) ...
python
def register(self, observer): """ Register an observer for it be notified when occurs changes. For more details, see :class:`.UpdatesObserver` :param UpdatesObserver observer: Observer that will be notified then occurs changes """ self.observer_manager.append(observer) ...
[ "def", "register", "(", "self", ",", "observer", ")", ":", "self", ".", "observer_manager", ".", "append", "(", "observer", ")", "observer", ".", "manager", "=", "self" ]
Register an observer for it be notified when occurs changes. For more details, see :class:`.UpdatesObserver` :param UpdatesObserver observer: Observer that will be notified then occurs changes
[ "Register", "an", "observer", "for", "it", "be", "notified", "when", "occurs", "changes", "." ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/banks_manager.py#L58-L67
54,340
PedalPi/PluginsManager
pluginsmanager/banks_manager.py
BanksManager.unregister
def unregister(self, observer): """ Remove the observers of the observers list. It will not receive any more notifications when occurs changes. :param UpdatesObserver observer: Observer you will not receive any more notifications then occurs chan...
python
def unregister(self, observer): """ Remove the observers of the observers list. It will not receive any more notifications when occurs changes. :param UpdatesObserver observer: Observer you will not receive any more notifications then occurs chan...
[ "def", "unregister", "(", "self", ",", "observer", ")", ":", "self", ".", "observer_manager", ".", "observers", ".", "remove", "(", "observer", ")", "observer", ".", "manager", "=", "None" ]
Remove the observers of the observers list. It will not receive any more notifications when occurs changes. :param UpdatesObserver observer: Observer you will not receive any more notifications then occurs changes.
[ "Remove", "the", "observers", "of", "the", "observers", "list", ".", "It", "will", "not", "receive", "any", "more", "notifications", "when", "occurs", "changes", "." ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/banks_manager.py#L69-L78
54,341
mushkevych/scheduler
synergy/system/system_logger.py
get_logger
def get_logger(process_name, append_to_console=None, redirect_stdstream=None): """ method returns initiated logger""" if append_to_console is None: append_to_console = settings.settings['under_test'] if redirect_stdstream is None: redirect_stdstream=not settings.settings['under_test'] i...
python
def get_logger(process_name, append_to_console=None, redirect_stdstream=None): """ method returns initiated logger""" if append_to_console is None: append_to_console = settings.settings['under_test'] if redirect_stdstream is None: redirect_stdstream=not settings.settings['under_test'] i...
[ "def", "get_logger", "(", "process_name", ",", "append_to_console", "=", "None", ",", "redirect_stdstream", "=", "None", ")", ":", "if", "append_to_console", "is", "None", ":", "append_to_console", "=", "settings", ".", "settings", "[", "'under_test'", "]", "if"...
method returns initiated logger
[ "method", "returns", "initiated", "logger" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/system_logger.py#L76-L89
54,342
mushkevych/scheduler
synergy/system/system_logger.py
get_log_tag
def get_log_tag(process_name): """method returns tag that all messages will be preceded with""" process_obj = context.process_context[process_name] if isinstance(process_obj, FreerunProcessEntry): return str(process_obj.token) elif isinstance(process_obj, ManagedProcessEntry): return str...
python
def get_log_tag(process_name): """method returns tag that all messages will be preceded with""" process_obj = context.process_context[process_name] if isinstance(process_obj, FreerunProcessEntry): return str(process_obj.token) elif isinstance(process_obj, ManagedProcessEntry): return str...
[ "def", "get_log_tag", "(", "process_name", ")", ":", "process_obj", "=", "context", ".", "process_context", "[", "process_name", "]", "if", "isinstance", "(", "process_obj", ",", "FreerunProcessEntry", ")", ":", "return", "str", "(", "process_obj", ".", "token",...
method returns tag that all messages will be preceded with
[ "method", "returns", "tag", "that", "all", "messages", "will", "be", "preceded", "with" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/system_logger.py#L97-L107
54,343
mushkevych/scheduler
synergy/system/system_logger.py
Logger.write
def write(self, msg, level=logging.INFO): """ method implements stream write interface, allowing to redirect stdout to logger """ if msg is not None and len(msg.strip()) > 0: self.logger.log(level, msg)
python
def write(self, msg, level=logging.INFO): """ method implements stream write interface, allowing to redirect stdout to logger """ if msg is not None and len(msg.strip()) > 0: self.logger.log(level, msg)
[ "def", "write", "(", "self", ",", "msg", ",", "level", "=", "logging", ".", "INFO", ")", ":", "if", "msg", "is", "not", "None", "and", "len", "(", "msg", ".", "strip", "(", ")", ")", ">", "0", ":", "self", ".", "logger", ".", "log", "(", "lev...
method implements stream write interface, allowing to redirect stdout to logger
[ "method", "implements", "stream", "write", "interface", "allowing", "to", "redirect", "stdout", "to", "logger" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/system_logger.py#L53-L56
54,344
kmerkmer/pymer
pymer/base.py
BaseCounter.consume
def consume(self, seq): '''Counts all k-mers in sequence.''' for kmer in iter_kmers(seq, self.k, canonical=self.canonical): self._incr(kmer)
python
def consume(self, seq): '''Counts all k-mers in sequence.''' for kmer in iter_kmers(seq, self.k, canonical=self.canonical): self._incr(kmer)
[ "def", "consume", "(", "self", ",", "seq", ")", ":", "for", "kmer", "in", "iter_kmers", "(", "seq", ",", "self", ".", "k", ",", "canonical", "=", "self", ".", "canonical", ")", ":", "self", ".", "_incr", "(", "kmer", ")" ]
Counts all k-mers in sequence.
[ "Counts", "all", "k", "-", "mers", "in", "sequence", "." ]
c22802436b3756a2e92829c9b234bde6217b683a
https://github.com/kmerkmer/pymer/blob/c22802436b3756a2e92829c9b234bde6217b683a/pymer/base.py#L27-L30
54,345
kmerkmer/pymer
pymer/base.py
BaseCounter.unconsume
def unconsume(self, seq): '''Subtracts all k-mers in sequence.''' for kmer in iter_kmers(seq, self.k, canonical=self.canonical): self._decr(kmer)
python
def unconsume(self, seq): '''Subtracts all k-mers in sequence.''' for kmer in iter_kmers(seq, self.k, canonical=self.canonical): self._decr(kmer)
[ "def", "unconsume", "(", "self", ",", "seq", ")", ":", "for", "kmer", "in", "iter_kmers", "(", "seq", ",", "self", ".", "k", ",", "canonical", "=", "self", ".", "canonical", ")", ":", "self", ".", "_decr", "(", "kmer", ")" ]
Subtracts all k-mers in sequence.
[ "Subtracts", "all", "k", "-", "mers", "in", "sequence", "." ]
c22802436b3756a2e92829c9b234bde6217b683a
https://github.com/kmerkmer/pymer/blob/c22802436b3756a2e92829c9b234bde6217b683a/pymer/base.py#L38-L41
54,346
PedalPi/PluginsManager
pluginsmanager/model/lv2/lv2_effect_builder.py
Lv2EffectBuilder.reload
def reload(self, metadata, ignore_unsupported_plugins=True): """ Loads the metadata. They will be used so that it is possible to generate lv2 audio plugins. :param list metadata: lv2 audio plugins metadata :param bool ignore_unsupported_plugins: Not allows instantiation of uninstalled o...
python
def reload(self, metadata, ignore_unsupported_plugins=True): """ Loads the metadata. They will be used so that it is possible to generate lv2 audio plugins. :param list metadata: lv2 audio plugins metadata :param bool ignore_unsupported_plugins: Not allows instantiation of uninstalled o...
[ "def", "reload", "(", "self", ",", "metadata", ",", "ignore_unsupported_plugins", "=", "True", ")", ":", "supported_plugins", "=", "self", ".", "_supported_plugins", "for", "plugin", "in", "metadata", ":", "if", "not", "ignore_unsupported_plugins", "or", "plugin",...
Loads the metadata. They will be used so that it is possible to generate lv2 audio plugins. :param list metadata: lv2 audio plugins metadata :param bool ignore_unsupported_plugins: Not allows instantiation of uninstalled or unrecognized audio plugins?
[ "Loads", "the", "metadata", ".", "They", "will", "be", "used", "so", "that", "it", "is", "possible", "to", "generate", "lv2", "audio", "plugins", "." ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/model/lv2/lv2_effect_builder.py#L56-L68
54,347
konstantint/intervaltree-bio
intervaltree_bio/__init__.py
_fix
def _fix(interval): ''' Helper function for ``GenomeIntervalTree.from_bed and ``.from_table``. Data tables may contain intervals with begin >= end. Such intervals lead to infinite recursions and other unpleasant behaviour, so something has to be done about them. We 'fix' them by simply setting end = be...
python
def _fix(interval): ''' Helper function for ``GenomeIntervalTree.from_bed and ``.from_table``. Data tables may contain intervals with begin >= end. Such intervals lead to infinite recursions and other unpleasant behaviour, so something has to be done about them. We 'fix' them by simply setting end = be...
[ "def", "_fix", "(", "interval", ")", ":", "if", "interval", ".", "begin", ">=", "interval", ".", "end", ":", "warnings", ".", "warn", "(", "\"Interval with reversed coordinates (begin >= end) detected when reading data. Interval was automatically fixed to point interval [begin,...
Helper function for ``GenomeIntervalTree.from_bed and ``.from_table``. Data tables may contain intervals with begin >= end. Such intervals lead to infinite recursions and other unpleasant behaviour, so something has to be done about them. We 'fix' them by simply setting end = begin+1.
[ "Helper", "function", "for", "GenomeIntervalTree", ".", "from_bed", "and", ".", "from_table", "." ]
2d0bea6b534f9588c60ae7b6c30584138433c14b
https://github.com/konstantint/intervaltree-bio/blob/2d0bea6b534f9588c60ae7b6c30584138433c14b/intervaltree_bio/__init__.py#L68-L79
54,348
disqus/durabledict
durabledict/zookeeper.py
validate_key
def validate_key(func): """ Decorator to validate a key for zookeeper. """ @wraps(func) def wrapper(self, key, *args, **kwargs): if posixpath.sep in key: raise ValueError('Keys cannot contains slashes') return func(self, key, *args, **kwargs) return wrapper
python
def validate_key(func): """ Decorator to validate a key for zookeeper. """ @wraps(func) def wrapper(self, key, *args, **kwargs): if posixpath.sep in key: raise ValueError('Keys cannot contains slashes') return func(self, key, *args, **kwargs) return wrapper
[ "def", "validate_key", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "key", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "posixpath", ".", "sep", "in", "key", ":", "raise", "ValueError", ...
Decorator to validate a key for zookeeper.
[ "Decorator", "to", "validate", "a", "key", "for", "zookeeper", "." ]
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L7-L19
54,349
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict.persist
def persist(self, key, value): """ Encode and save ``value`` at ``key``. :param key: Key to store ``value`` at in Zookeeper. :type key: string :param value: Value to store. Encoded before being stored. :type value: value """ encoded = self.encoding.encode...
python
def persist(self, key, value): """ Encode and save ``value`` at ``key``. :param key: Key to store ``value`` at in Zookeeper. :type key: string :param value: Value to store. Encoded before being stored. :type value: value """ encoded = self.encoding.encode...
[ "def", "persist", "(", "self", ",", "key", ",", "value", ")", ":", "encoded", "=", "self", ".", "encoding", ".", "encode", "(", "value", ")", "self", ".", "__set_or_create", "(", "key", ",", "encoded", ")", "self", ".", "__increment_last_updated", "(", ...
Encode and save ``value`` at ``key``. :param key: Key to store ``value`` at in Zookeeper. :type key: string :param value: Value to store. Encoded before being stored. :type value: value
[ "Encode", "and", "save", "value", "at", "key", "." ]
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L154-L165
54,350
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict.depersist
def depersist(self, key): """ Remove ``key`` from dictionary. :param key: Key to remove from Zookeeper. :type key: string """ self.connection.retry(self.connection.delete, self.__path_of(key)) self.__increment_last_updated()
python
def depersist(self, key): """ Remove ``key`` from dictionary. :param key: Key to remove from Zookeeper. :type key: string """ self.connection.retry(self.connection.delete, self.__path_of(key)) self.__increment_last_updated()
[ "def", "depersist", "(", "self", ",", "key", ")", ":", "self", ".", "connection", ".", "retry", "(", "self", ".", "connection", ".", "delete", ",", "self", ".", "__path_of", "(", "key", ")", ")", "self", ".", "__increment_last_updated", "(", ")" ]
Remove ``key`` from dictionary. :param key: Key to remove from Zookeeper. :type key: string
[ "Remove", "key", "from", "dictionary", "." ]
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L168-L176
54,351
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict.durables
def durables(self): """ Dictionary of all keys and their values in Zookeeper. """ results = dict() for child in self.connection.retry(self.connection.get_children, self.keyspace): value, _ = self.connection.retry( self.connection.get, ...
python
def durables(self): """ Dictionary of all keys and their values in Zookeeper. """ results = dict() for child in self.connection.retry(self.connection.get_children, self.keyspace): value, _ = self.connection.retry( self.connection.get, ...
[ "def", "durables", "(", "self", ")", ":", "results", "=", "dict", "(", ")", "for", "child", "in", "self", ".", "connection", ".", "retry", "(", "self", ".", "connection", ".", "get_children", ",", "self", ".", "keyspace", ")", ":", "value", ",", "_",...
Dictionary of all keys and their values in Zookeeper.
[ "Dictionary", "of", "all", "keys", "and", "their", "values", "in", "Zookeeper", "." ]
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L178-L192
54,352
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict._pop
def _pop(self, key, default=None): """ If ``key`` is present in Zookeeper, removes it from Zookeeper and returns the value. If key is not in Zookeper and ``default`` argument is provided, ``default`` is returned. If ``default`` argument is not provided, ``KeyError`` is raised. ...
python
def _pop(self, key, default=None): """ If ``key`` is present in Zookeeper, removes it from Zookeeper and returns the value. If key is not in Zookeper and ``default`` argument is provided, ``default`` is returned. If ``default`` argument is not provided, ``KeyError`` is raised. ...
[ "def", "_pop", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "path", "=", "self", ".", "__path_of", "(", "key", ")", "value", "=", "None", "try", ":", "# We need to both delete and return the value that was in ZK here.", "raw_value", ",", "_"...
If ``key`` is present in Zookeeper, removes it from Zookeeper and returns the value. If key is not in Zookeper and ``default`` argument is provided, ``default`` is returned. If ``default`` argument is not provided, ``KeyError`` is raised. :param key: Key to remove from Zookeeper ...
[ "If", "key", "is", "present", "in", "Zookeeper", "removes", "it", "from", "Zookeeper", "and", "returns", "the", "value", ".", "If", "key", "is", "not", "in", "Zookeper", "and", "default", "argument", "is", "provided", "default", "is", "returned", ".", "If"...
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L195-L232
54,353
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict._setdefault
def _setdefault(self, key, default=None): """ If ``key`` is not present, set it as ``default`` and return it. If ``key`` is present, return its value. :param key: Key to add to Zookeeper :type key: string :param default: Default object to return if ``key`` is present. ...
python
def _setdefault(self, key, default=None): """ If ``key`` is not present, set it as ``default`` and return it. If ``key`` is present, return its value. :param key: Key to add to Zookeeper :type key: string :param default: Default object to return if ``key`` is present. ...
[ "def", "_setdefault", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "return", "self", ".", "connection", ".", "retry", "(", "self", ".", "__inner_set_default", ",", "key", ",", "default", ")" ]
If ``key`` is not present, set it as ``default`` and return it. If ``key`` is present, return its value. :param key: Key to add to Zookeeper :type key: string :param default: Default object to return if ``key`` is present. :type default: object Will retry trying to get...
[ "If", "key", "is", "not", "present", "set", "it", "as", "default", "and", "return", "it", ".", "If", "key", "is", "present", "return", "its", "value", "." ]
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L235-L248
54,354
disqus/durabledict
durabledict/zookeeper.py
ZookeeperDict.__inner_set_default
def __inner_set_default(self, key, value): """ Tries to return the value at key. If the key does not exist, attempts to create it with the value. If the node is created in the mean time, a ``NodeExistsError`` will be raised. """ path = self.__path_of(key) try: ...
python
def __inner_set_default(self, key, value): """ Tries to return the value at key. If the key does not exist, attempts to create it with the value. If the node is created in the mean time, a ``NodeExistsError`` will be raised. """ path = self.__path_of(key) try: ...
[ "def", "__inner_set_default", "(", "self", ",", "key", ",", "value", ")", ":", "path", "=", "self", ".", "__path_of", "(", "key", ")", "try", ":", "# Try to get and return the existing node with its data", "value", ",", "_", "=", "self", ".", "connection", "."...
Tries to return the value at key. If the key does not exist, attempts to create it with the value. If the node is created in the mean time, a ``NodeExistsError`` will be raised.
[ "Tries", "to", "return", "the", "value", "at", "key", ".", "If", "the", "key", "does", "not", "exist", "attempts", "to", "create", "it", "with", "the", "value", ".", "If", "the", "node", "is", "created", "in", "the", "mean", "time", "a", "NodeExistsErr...
17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc
https://github.com/disqus/durabledict/blob/17dfccdcee18da4df7c9dbc0557dc27a4ea6f3cc/durabledict/zookeeper.py#L264-L280
54,355
kmerkmer/pymer
pymer/count.py
ExactKmerCounter.print_table
def print_table(self, sparse=False, file=None, sep='\t'): ''' Prints a table of k-mer counts Parameters ---------- sparse: bool Print only observed kmers file: IO object Print to `file` sep: str Separate k-mers and their counts...
python
def print_table(self, sparse=False, file=None, sep='\t'): ''' Prints a table of k-mer counts Parameters ---------- sparse: bool Print only observed kmers file: IO object Print to `file` sep: str Separate k-mers and their counts...
[ "def", "print_table", "(", "self", ",", "sparse", "=", "False", ",", "file", "=", "None", ",", "sep", "=", "'\\t'", ")", ":", "for", "kmer", ",", "count", "in", "sorted", "(", "self", ".", "to_dict", "(", "sparse", "=", "sparse", ")", ".", "items",...
Prints a table of k-mer counts Parameters ---------- sparse: bool Print only observed kmers file: IO object Print to `file` sep: str Separate k-mers and their counts with `sep`
[ "Prints", "a", "table", "of", "k", "-", "mer", "counts" ]
c22802436b3756a2e92829c9b234bde6217b683a
https://github.com/kmerkmer/pymer/blob/c22802436b3756a2e92829c9b234bde6217b683a/pymer/count.py#L92-L107
54,356
mushkevych/scheduler
synergy/scheduler/tree.py
AbstractTree.unregister_dependent_on
def unregister_dependent_on(self, tree): """unregistering tree that we are dependent on""" if tree in self.dependent_on: self.dependent_on.remove(tree)
python
def unregister_dependent_on(self, tree): """unregistering tree that we are dependent on""" if tree in self.dependent_on: self.dependent_on.remove(tree)
[ "def", "unregister_dependent_on", "(", "self", ",", "tree", ")", ":", "if", "tree", "in", "self", ".", "dependent_on", ":", "self", ".", "dependent_on", ".", "remove", "(", "tree", ")" ]
unregistering tree that we are dependent on
[ "unregistering", "tree", "that", "we", "are", "dependent", "on" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L27-L30
54,357
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree._get_next_parent_node
def _get_next_parent_node(self, parent): """ Used by _get_next_child_node, this method is called to find next possible parent. For example if timeperiod 2011010200 has all children processed, but is not yet processed itself then it makes sense to look in 2011010300 for hourly nodes """ ...
python
def _get_next_parent_node(self, parent): """ Used by _get_next_child_node, this method is called to find next possible parent. For example if timeperiod 2011010200 has all children processed, but is not yet processed itself then it makes sense to look in 2011010300 for hourly nodes """ ...
[ "def", "_get_next_parent_node", "(", "self", ",", "parent", ")", ":", "grandparent", "=", "parent", ".", "parent", "if", "grandparent", "is", "None", ":", "# here, we work at yearly/linear level", "return", "None", "parent_siblings", "=", "list", "(", "grandparent",...
Used by _get_next_child_node, this method is called to find next possible parent. For example if timeperiod 2011010200 has all children processed, but is not yet processed itself then it makes sense to look in 2011010300 for hourly nodes
[ "Used", "by", "_get_next_child_node", "this", "method", "is", "called", "to", "find", "next", "possible", "parent", ".", "For", "example", "if", "timeperiod", "2011010200", "has", "all", "children", "processed", "but", "is", "not", "yet", "processed", "itself", ...
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L61-L76
54,358
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree._get_next_child_node
def _get_next_child_node(self, parent): """ Iterates among children of the given parent and looks for a suitable node to process In case given parent has no suitable nodes, a younger parent will be found and the logic will be repeated for him """ children_keys...
python
def _get_next_child_node(self, parent): """ Iterates among children of the given parent and looks for a suitable node to process In case given parent has no suitable nodes, a younger parent will be found and the logic will be repeated for him """ children_keys...
[ "def", "_get_next_child_node", "(", "self", ",", "parent", ")", ":", "children_keys", "=", "list", "(", "parent", ".", "children", ")", "sorted_keys", "=", "sorted", "(", "children_keys", ")", "for", "key", "in", "sorted_keys", ":", "node", "=", "parent", ...
Iterates among children of the given parent and looks for a suitable node to process In case given parent has no suitable nodes, a younger parent will be found and the logic will be repeated for him
[ "Iterates", "among", "children", "of", "the", "given", "parent", "and", "looks", "for", "a", "suitable", "node", "to", "process", "In", "case", "given", "parent", "has", "no", "suitable", "nodes", "a", "younger", "parent", "will", "be", "found", "and", "th...
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L78-L106
54,359
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree.build_tree
def build_tree(self, rebuild=False): """ method builds tree by iterating from the synergy_start_timeperiod to the current time and inserting corresponding nodes """ time_qualifier = self.process_hierarchy.bottom_process.time_qualifier process_name = self.process_hierarchy.bottom_pro...
python
def build_tree(self, rebuild=False): """ method builds tree by iterating from the synergy_start_timeperiod to the current time and inserting corresponding nodes """ time_qualifier = self.process_hierarchy.bottom_process.time_qualifier process_name = self.process_hierarchy.bottom_pro...
[ "def", "build_tree", "(", "self", ",", "rebuild", "=", "False", ")", ":", "time_qualifier", "=", "self", ".", "process_hierarchy", ".", "bottom_process", ".", "time_qualifier", "process_name", "=", "self", ".", "process_hierarchy", ".", "bottom_process", ".", "p...
method builds tree by iterating from the synergy_start_timeperiod to the current time and inserting corresponding nodes
[ "method", "builds", "tree", "by", "iterating", "from", "the", "synergy_start_timeperiod", "to", "the", "current", "time", "and", "inserting", "corresponding", "nodes" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L171-L189
54,360
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree.update_node
def update_node(self, job_record): """ Updates job record property for a tree node associated with the given Job """ if job_record.process_name not in self.process_hierarchy: raise ValueError('unable to update the node due to unknown process: {0}'.format(job_record.process_name)) ti...
python
def update_node(self, job_record): """ Updates job record property for a tree node associated with the given Job """ if job_record.process_name not in self.process_hierarchy: raise ValueError('unable to update the node due to unknown process: {0}'.format(job_record.process_name)) ti...
[ "def", "update_node", "(", "self", ",", "job_record", ")", ":", "if", "job_record", ".", "process_name", "not", "in", "self", ".", "process_hierarchy", ":", "raise", "ValueError", "(", "'unable to update the node due to unknown process: {0}'", ".", "format", "(", "j...
Updates job record property for a tree node associated with the given Job
[ "Updates", "job", "record", "property", "for", "a", "tree", "node", "associated", "with", "the", "given", "Job" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L199-L206
54,361
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree.get_node
def get_node(self, process_name, timeperiod): """ Method retrieves a tree node identified by the time_qualifier and the timeperiod """ if process_name not in self.process_hierarchy: raise ValueError('unable to retrieve the node due to unknown process: {0}'.format(process_name)) time...
python
def get_node(self, process_name, timeperiod): """ Method retrieves a tree node identified by the time_qualifier and the timeperiod """ if process_name not in self.process_hierarchy: raise ValueError('unable to retrieve the node due to unknown process: {0}'.format(process_name)) time...
[ "def", "get_node", "(", "self", ",", "process_name", ",", "timeperiod", ")", ":", "if", "process_name", "not", "in", "self", ".", "process_hierarchy", ":", "raise", "ValueError", "(", "'unable to retrieve the node due to unknown process: {0}'", ".", "format", "(", "...
Method retrieves a tree node identified by the time_qualifier and the timeperiod
[ "Method", "retrieves", "a", "tree", "node", "identified", "by", "the", "time_qualifier", "and", "the", "timeperiod" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L208-L214
54,362
mushkevych/scheduler
synergy/scheduler/tree.py
MultiLevelTree.validate
def validate(self): """ method starts validation of the tree. @see TreeNode.validate """ for timeperiod, child in self.root.children.items(): child.validate() self.validation_timestamp = datetime.utcnow()
python
def validate(self): """ method starts validation of the tree. @see TreeNode.validate """ for timeperiod, child in self.root.children.items(): child.validate() self.validation_timestamp = datetime.utcnow()
[ "def", "validate", "(", "self", ")", ":", "for", "timeperiod", ",", "child", "in", "self", ".", "root", ".", "children", ".", "items", "(", ")", ":", "child", ".", "validate", "(", ")", "self", ".", "validation_timestamp", "=", "datetime", ".", "utcnow...
method starts validation of the tree. @see TreeNode.validate
[ "method", "starts", "validation", "of", "the", "tree", "." ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/scheduler/tree.py#L216-L221
54,363
helium/helium-python
helium/exceptions.py
error_for
def error_for(response): """Return the appropriate initialized exception class for a response.""" klass = error_classes.get(response.status) if klass is None: if 400 <= response.status < 500: klass = ClientError if 500 <= response.status < 600: klass = ServerError # ...
python
def error_for(response): """Return the appropriate initialized exception class for a response.""" klass = error_classes.get(response.status) if klass is None: if 400 <= response.status < 500: klass = ClientError if 500 <= response.status < 600: klass = ServerError # ...
[ "def", "error_for", "(", "response", ")", ":", "klass", "=", "error_classes", ".", "get", "(", "response", ".", "status", ")", "if", "klass", "is", "None", ":", "if", "400", "<=", "response", ".", "status", "<", "500", ":", "klass", "=", "ClientError",...
Return the appropriate initialized exception class for a response.
[ "Return", "the", "appropriate", "initialized", "exception", "class", "for", "a", "response", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/exceptions.py#L58-L66
54,364
epio/mantrid
mantrid/socketmeld.py
SocketMelder.piper
def piper(self, in_sock, out_sock, out_addr, onkill): "Worker thread for data reading" try: while True: written = in_sock.recv(32768) if not written: try: out_sock.shutdown(socket.SHUT_WR) except ...
python
def piper(self, in_sock, out_sock, out_addr, onkill): "Worker thread for data reading" try: while True: written = in_sock.recv(32768) if not written: try: out_sock.shutdown(socket.SHUT_WR) except ...
[ "def", "piper", "(", "self", ",", "in_sock", ",", "out_sock", ",", "out_addr", ",", "onkill", ")", ":", "try", ":", "while", "True", ":", "written", "=", "in_sock", ".", "recv", "(", "32768", ")", "if", "not", "written", ":", "try", ":", "out_sock", ...
Worker thread for data reading
[ "Worker", "thread", "for", "data", "reading" ]
1c699f1a4b33888b533c19cb6d025173f2160576
https://github.com/epio/mantrid/blob/1c699f1a4b33888b533c19cb6d025173f2160576/mantrid/socketmeld.py#L16-L33
54,365
mushkevych/scheduler
synergy/db/model/timetable_tree_entry.py
timetable_tree_entry
def timetable_tree_entry(tree_name, enclosed_processes, dependent_on=None, mx_name=None, mx_page=None): """ creates timetable context entry """ assert enclosed_processes is not None and not isinstance(enclosed_pr...
python
def timetable_tree_entry(tree_name, enclosed_processes, dependent_on=None, mx_name=None, mx_page=None): """ creates timetable context entry """ assert enclosed_processes is not None and not isinstance(enclosed_pr...
[ "def", "timetable_tree_entry", "(", "tree_name", ",", "enclosed_processes", ",", "dependent_on", "=", "None", ",", "mx_name", "=", "None", ",", "mx_page", "=", "None", ")", ":", "assert", "enclosed_processes", "is", "not", "None", "and", "not", "isinstance", "...
creates timetable context entry
[ "creates", "timetable", "context", "entry" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/model/timetable_tree_entry.py#L32-L46
54,366
helium/helium-python
helium/device.py
Device.device_configuration
def device_configuration(self, pending=False, use_included=False): """Get a specific device configuration. A device can have at most one loaded and one pending device configuration. This returns that device_configuration based on a given flag. Keyword Args: pending...
python
def device_configuration(self, pending=False, use_included=False): """Get a specific device configuration. A device can have at most one loaded and one pending device configuration. This returns that device_configuration based on a given flag. Keyword Args: pending...
[ "def", "device_configuration", "(", "self", ",", "pending", "=", "False", ",", "use_included", "=", "False", ")", ":", "device_configs", "=", "self", ".", "device_configurations", "(", "use_included", "=", "use_included", ")", "for", "device_config", "in", "devi...
Get a specific device configuration. A device can have at most one loaded and one pending device configuration. This returns that device_configuration based on a given flag. Keyword Args: pending(bool): Fetch the pending configuration or return the loaded o...
[ "Get", "a", "specific", "device", "configuration", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/device.py#L15-L40
54,367
mushkevych/scheduler
launch.py
get_python
def get_python(): """Determine the path to the virtualenv python""" if sys.platform == 'win32': python = path.join(VE_ROOT, 'Scripts', 'python.exe') else: python = path.join(VE_ROOT, 'bin', 'python') return python
python
def get_python(): """Determine the path to the virtualenv python""" if sys.platform == 'win32': python = path.join(VE_ROOT, 'Scripts', 'python.exe') else: python = path.join(VE_ROOT, 'bin', 'python') return python
[ "def", "get_python", "(", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "python", "=", "path", ".", "join", "(", "VE_ROOT", ",", "'Scripts'", ",", "'python.exe'", ")", "else", ":", "python", "=", "path", ".", "join", "(", "VE_ROOT", "...
Determine the path to the virtualenv python
[ "Determine", "the", "path", "to", "the", "virtualenv", "python" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L95-L101
54,368
mushkevych/scheduler
launch.py
install_virtualenv_p2
def install_virtualenv_p2(root, python_version): """ Install virtual environment for Python 2.7+; removing the old one if it exists """ try: import virtualenv except ImportError: sys.stdout.write('Installing virtualenv into global interpreter \n') ret_code = subprocess.call([VE_GLOBA...
python
def install_virtualenv_p2(root, python_version): """ Install virtual environment for Python 2.7+; removing the old one if it exists """ try: import virtualenv except ImportError: sys.stdout.write('Installing virtualenv into global interpreter \n') ret_code = subprocess.call([VE_GLOBA...
[ "def", "install_virtualenv_p2", "(", "root", ",", "python_version", ")", ":", "try", ":", "import", "virtualenv", "except", "ImportError", ":", "sys", ".", "stdout", ".", "write", "(", "'Installing virtualenv into global interpreter \\n'", ")", "ret_code", "=", "sub...
Install virtual environment for Python 2.7+; removing the old one if it exists
[ "Install", "virtual", "environment", "for", "Python", "2", ".", "7", "+", ";", "removing", "the", "old", "one", "if", "it", "exists" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L121-L136
54,369
mushkevych/scheduler
launch.py
install_virtualenv_p3
def install_virtualenv_p3(root, python_version): """ Install virtual environment for Python 3.3+; removing the old one if it exists """ import venv builder = venv.EnvBuilder(system_site_packages=False, clear=True, symlinks=False, upgrade=False) builder.create(root) ret_code = subprocess.call([VE_SCR...
python
def install_virtualenv_p3(root, python_version): """ Install virtual environment for Python 3.3+; removing the old one if it exists """ import venv builder = venv.EnvBuilder(system_site_packages=False, clear=True, symlinks=False, upgrade=False) builder.create(root) ret_code = subprocess.call([VE_SCR...
[ "def", "install_virtualenv_p3", "(", "root", ",", "python_version", ")", ":", "import", "venv", "builder", "=", "venv", ".", "EnvBuilder", "(", "system_site_packages", "=", "False", ",", "clear", "=", "True", ",", "symlinks", "=", "False", ",", "upgrade", "=...
Install virtual environment for Python 3.3+; removing the old one if it exists
[ "Install", "virtual", "environment", "for", "Python", "3", ".", "3", "+", ";", "removing", "the", "old", "one", "if", "it", "exists" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L139-L145
54,370
mushkevych/scheduler
launch.py
install_virtualenv
def install_virtualenv(parser_args): """ Installs virtual environment """ python_version = '.'.join(str(v) for v in sys.version_info[:2]) sys.stdout.write('Installing Python {0} virtualenv into {1} \n'.format(python_version, VE_ROOT)) if sys.version_info < (3, 3): install_virtualenv_p2(VE_ROOT, ...
python
def install_virtualenv(parser_args): """ Installs virtual environment """ python_version = '.'.join(str(v) for v in sys.version_info[:2]) sys.stdout.write('Installing Python {0} virtualenv into {1} \n'.format(python_version, VE_ROOT)) if sys.version_info < (3, 3): install_virtualenv_p2(VE_ROOT, ...
[ "def", "install_virtualenv", "(", "parser_args", ")", ":", "python_version", "=", "'.'", ".", "join", "(", "str", "(", "v", ")", "for", "v", "in", "sys", ".", "version_info", "[", ":", "2", "]", ")", "sys", ".", "stdout", ".", "write", "(", "'Install...
Installs virtual environment
[ "Installs", "virtual", "environment" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L148-L155
54,371
mushkevych/scheduler
launch.py
query_configuration
def query_configuration(parser_args): """ Queries process state """ from synergy.system import process_helper from synergy.conf import context process_names = [parser_args.process_name] if parser_args.process_name else list(context.process_context) for process_name in process_names: process...
python
def query_configuration(parser_args): """ Queries process state """ from synergy.system import process_helper from synergy.conf import context process_names = [parser_args.process_name] if parser_args.process_name else list(context.process_context) for process_name in process_names: process...
[ "def", "query_configuration", "(", "parser_args", ")", ":", "from", "synergy", ".", "system", "import", "process_helper", "from", "synergy", ".", "conf", "import", "context", "process_names", "=", "[", "parser_args", ".", "process_name", "]", "if", "parser_args", ...
Queries process state
[ "Queries", "process", "state" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L158-L166
54,372
mushkevych/scheduler
launch.py
db_command
def db_command(parser_args): """ Manages Synergy DB state """ from synergy.db.manager import db_manager if parser_args.reset: db_manager.reset_db() # initialize DB with the context.process_context entries parser_args.update = True if parser_args.update: db_manager.updat...
python
def db_command(parser_args): """ Manages Synergy DB state """ from synergy.db.manager import db_manager if parser_args.reset: db_manager.reset_db() # initialize DB with the context.process_context entries parser_args.update = True if parser_args.update: db_manager.updat...
[ "def", "db_command", "(", "parser_args", ")", ":", "from", "synergy", ".", "db", ".", "manager", "import", "db_manager", "if", "parser_args", ".", "reset", ":", "db_manager", ".", "reset_db", "(", ")", "# initialize DB with the context.process_context entries", "par...
Manages Synergy DB state
[ "Manages", "Synergy", "DB", "state" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L169-L179
54,373
mushkevych/scheduler
launch.py
supervisor_command
def supervisor_command(parser_args): """ Supervisor-related commands """ import logging from synergy.supervisor.supervisor_configurator import SupervisorConfigurator, set_box_id if parser_args.boxid: set_box_id(logging, parser_args.argument) return sc = SupervisorConfigurator() ...
python
def supervisor_command(parser_args): """ Supervisor-related commands """ import logging from synergy.supervisor.supervisor_configurator import SupervisorConfigurator, set_box_id if parser_args.boxid: set_box_id(logging, parser_args.argument) return sc = SupervisorConfigurator() ...
[ "def", "supervisor_command", "(", "parser_args", ")", ":", "import", "logging", "from", "synergy", ".", "supervisor", ".", "supervisor_configurator", "import", "SupervisorConfigurator", ",", "set_box_id", "if", "parser_args", ".", "boxid", ":", "set_box_id", "(", "l...
Supervisor-related commands
[ "Supervisor", "-", "related", "commands" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L182-L202
54,374
mushkevych/scheduler
launch.py
start_process
def start_process(parser_args): """ Start up specific daemon """ import psutil import process_starter from synergy.system import process_helper try: pid = process_helper.get_process_pid(parser_args.process_name) if pid is not None: if psutil.pid_exists(pid): ...
python
def start_process(parser_args): """ Start up specific daemon """ import psutil import process_starter from synergy.system import process_helper try: pid = process_helper.get_process_pid(parser_args.process_name) if pid is not None: if psutil.pid_exists(pid): ...
[ "def", "start_process", "(", "parser_args", ")", ":", "import", "psutil", "import", "process_starter", "from", "synergy", ".", "system", "import", "process_helper", "try", ":", "pid", "=", "process_helper", ".", "get_process_pid", "(", "parser_args", ".", "process...
Start up specific daemon
[ "Start", "up", "specific", "daemon" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L205-L226
54,375
videntity/django-djmongo
djmongo/decorators.py
ip_verification_required
def ip_verification_required(func): """ Put this decorator before your view to check if the function is coming from an IP on file """ def wrapper(request, *args, **kwargs): slug = kwargs.get('slug', "") if not slug: return kickoutt_404("Not found.", content_type="applic...
python
def ip_verification_required(func): """ Put this decorator before your view to check if the function is coming from an IP on file """ def wrapper(request, *args, **kwargs): slug = kwargs.get('slug', "") if not slug: return kickoutt_404("Not found.", content_type="applic...
[ "def", "ip_verification_required", "(", "func", ")", ":", "def", "wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "slug", "=", "kwargs", ".", "get", "(", "'slug'", ",", "\"\"", ")", "if", "not", "slug", ":", "return", ...
Put this decorator before your view to check if the function is coming from an IP on file
[ "Put", "this", "decorator", "before", "your", "view", "to", "check", "if", "the", "function", "is", "coming", "from", "an", "IP", "on", "file" ]
7534e0981a2bc12634cf3f1ed03353623dc57565
https://github.com/videntity/django-djmongo/blob/7534e0981a2bc12634cf3f1ed03353623dc57565/djmongo/decorators.py#L52-L77
54,376
mushkevych/scheduler
synergy/db/dao/base_dao.py
build_db_query
def build_db_query(fields_names, field_values): """ method builds query dictionary by zipping together DB field names with the field values """ if isinstance(field_values, string_types): field_values = [field_values] if len(fields_names) != len(field_values): raise ValueError('Error: unable...
python
def build_db_query(fields_names, field_values): """ method builds query dictionary by zipping together DB field names with the field values """ if isinstance(field_values, string_types): field_values = [field_values] if len(fields_names) != len(field_values): raise ValueError('Error: unable...
[ "def", "build_db_query", "(", "fields_names", ",", "field_values", ")", ":", "if", "isinstance", "(", "field_values", ",", "string_types", ")", ":", "field_values", "=", "[", "field_values", "]", "if", "len", "(", "fields_names", ")", "!=", "len", "(", "fiel...
method builds query dictionary by zipping together DB field names with the field values
[ "method", "builds", "query", "dictionary", "by", "zipping", "together", "DB", "field", "names", "with", "the", "field", "values" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/dao/base_dao.py#L12-L25
54,377
mushkevych/scheduler
synergy/db/dao/base_dao.py
BaseDao.get_one
def get_one(self, key): """ method finds single record base on the given primary key and returns it to the caller""" query = build_db_query(self.primary_key, key) collection = self.ds.connection(self.collection_name) document = collection.find_one(query) if document is None: ...
python
def get_one(self, key): """ method finds single record base on the given primary key and returns it to the caller""" query = build_db_query(self.primary_key, key) collection = self.ds.connection(self.collection_name) document = collection.find_one(query) if document is None: ...
[ "def", "get_one", "(", "self", ",", "key", ")", ":", "query", "=", "build_db_query", "(", "self", ".", "primary_key", ",", "key", ")", "collection", "=", "self", ".", "ds", ".", "connection", "(", "self", ".", "collection_name", ")", "document", "=", "...
method finds single record base on the given primary key and returns it to the caller
[ "method", "finds", "single", "record", "base", "on", "the", "given", "primary", "key", "and", "returns", "it", "to", "the", "caller" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/dao/base_dao.py#L42-L50
54,378
mushkevych/scheduler
synergy/db/dao/base_dao.py
BaseDao.run_query
def run_query(self, query): """ method runs query on a specified collection and return a list of filtered Model records """ collection = self.ds.connection(self.collection_name) cursor = collection.find(query) if cursor.count() == 0: raise LookupError('Collection {0} has no ...
python
def run_query(self, query): """ method runs query on a specified collection and return a list of filtered Model records """ collection = self.ds.connection(self.collection_name) cursor = collection.find(query) if cursor.count() == 0: raise LookupError('Collection {0} has no ...
[ "def", "run_query", "(", "self", ",", "query", ")", ":", "collection", "=", "self", ".", "ds", ".", "connection", "(", "self", ".", "collection_name", ")", "cursor", "=", "collection", ".", "find", "(", "query", ")", "if", "cursor", ".", "count", "(", ...
method runs query on a specified collection and return a list of filtered Model records
[ "method", "runs", "query", "on", "a", "specified", "collection", "and", "return", "a", "list", "of", "filtered", "Model", "records" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/dao/base_dao.py#L53-L61
54,379
mushkevych/scheduler
synergy/db/manager/ds_manager.py
BaseManager.cursor_fine
def cursor_fine(self, table_name, start_id_obj, end_id_obj, iteration, start_timeperiod, end_timeperiod): """ method returns DB cursor based on precise boundaries """ raise NotImplemen...
python
def cursor_fine(self, table_name, start_id_obj, end_id_obj, iteration, start_timeperiod, end_timeperiod): """ method returns DB cursor based on precise boundaries """ raise NotImplemen...
[ "def", "cursor_fine", "(", "self", ",", "table_name", ",", "start_id_obj", ",", "end_id_obj", ",", "iteration", ",", "start_timeperiod", ",", "end_timeperiod", ")", ":", "raise", "NotImplementedError", "(", "'method cursor_fine must be implemented by {0}'", ".", "format...
method returns DB cursor based on precise boundaries
[ "method", "returns", "DB", "cursor", "based", "on", "precise", "boundaries" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/manager/ds_manager.py#L81-L89
54,380
mushkevych/scheduler
synergy/db/manager/ds_manager.py
BaseManager.cursor_batch
def cursor_batch(self, table_name, start_timeperiod, end_timeperiod): """ method returns batched DB cursor """ raise NotImplementedError('method cursor_batch must be implemented by {0}'.format(self.__class__.__name__))
python
def cursor_batch(self, table_name, start_timeperiod, end_timeperiod): """ method returns batched DB cursor """ raise NotImplementedError('method cursor_batch must be implemented by {0}'.format(self.__class__.__name__))
[ "def", "cursor_batch", "(", "self", ",", "table_name", ",", "start_timeperiod", ",", "end_timeperiod", ")", ":", "raise", "NotImplementedError", "(", "'method cursor_batch must be implemented by {0}'", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ")"...
method returns batched DB cursor
[ "method", "returns", "batched", "DB", "cursor" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/manager/ds_manager.py#L91-L96
54,381
mushkevych/scheduler
synergy/db/manager/ds_manager.py
MongoDbManager.update
def update(self, table_name, primary_key, instance): """ replaces document identified by the primary_key or creates one if a matching document does not exist""" assert isinstance(primary_key, dict) assert isinstance(instance, BaseDocument) collection = self._db[table_name] # wor...
python
def update(self, table_name, primary_key, instance): """ replaces document identified by the primary_key or creates one if a matching document does not exist""" assert isinstance(primary_key, dict) assert isinstance(instance, BaseDocument) collection = self._db[table_name] # wor...
[ "def", "update", "(", "self", ",", "table_name", ",", "primary_key", ",", "instance", ")", ":", "assert", "isinstance", "(", "primary_key", ",", "dict", ")", "assert", "isinstance", "(", "instance", ",", "BaseDocument", ")", "collection", "=", "self", ".", ...
replaces document identified by the primary_key or creates one if a matching document does not exist
[ "replaces", "document", "identified", "by", "the", "primary_key", "or", "creates", "one", "if", "a", "matching", "document", "does", "not", "exist" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/manager/ds_manager.py#L151-L166
54,382
PedalPi/PluginsManager
pluginsmanager/model/effect.py
Effect.index
def index(self): """ Returns the first occurrence of the effect in your pedalboard """ if self.pedalboard is None: raise IndexError('Effect not contains a pedalboard') return self.pedalboard.effects.index(self)
python
def index(self): """ Returns the first occurrence of the effect in your pedalboard """ if self.pedalboard is None: raise IndexError('Effect not contains a pedalboard') return self.pedalboard.effects.index(self)
[ "def", "index", "(", "self", ")", ":", "if", "self", ".", "pedalboard", "is", "None", ":", "raise", "IndexError", "(", "'Effect not contains a pedalboard'", ")", "return", "self", ".", "pedalboard", ".", "effects", ".", "index", "(", "self", ")" ]
Returns the first occurrence of the effect in your pedalboard
[ "Returns", "the", "first", "occurrence", "of", "the", "effect", "in", "your", "pedalboard" ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/model/effect.py#L160-L167
54,383
fish-ball/django-fullclean
django_fullclean/__init__.py
pre_save_full_clean_handler
def pre_save_full_clean_handler(sender, instance, *args, **kwargs): """ Force all models to call full_clean before save """ from django.contrib.sessions.models import Session if sender != Session: instance.full_clean()
python
def pre_save_full_clean_handler(sender, instance, *args, **kwargs): """ Force all models to call full_clean before save """ from django.contrib.sessions.models import Session if sender != Session: instance.full_clean()
[ "def", "pre_save_full_clean_handler", "(", "sender", ",", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "contrib", ".", "sessions", ".", "models", "import", "Session", "if", "sender", "!=", "Session", ":", "instanc...
Force all models to call full_clean before save
[ "Force", "all", "models", "to", "call", "full_clean", "before", "save" ]
272b53284529bd452d3a5dfaf9c3f17bf2536761
https://github.com/fish-ball/django-fullclean/blob/272b53284529bd452d3a5dfaf9c3f17bf2536761/django_fullclean/__init__.py#L6-L10
54,384
mushkevych/scheduler
synergy/conf/__init__.py
LazySettings._setup
def _setup(self): """ Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually. """ settings_module = os.environ.get(ENVIRONMENT_SETTINGS_VARIA...
python
def _setup(self): """ Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually. """ settings_module = os.environ.get(ENVIRONMENT_SETTINGS_VARIA...
[ "def", "_setup", "(", "self", ")", ":", "settings_module", "=", "os", ".", "environ", ".", "get", "(", "ENVIRONMENT_SETTINGS_VARIABLE", ",", "'settings'", ")", "if", "not", "settings_module", ":", "raise", "ImproperlyConfigured", "(", "'Requested settings module poi...
Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually.
[ "Load", "the", "settings", "module", "pointed", "to", "by", "the", "environment", "variable", ".", "This", "is", "used", "the", "first", "time", "we", "need", "any", "settings", "at", "all", "if", "the", "user", "has", "not", "previously", "configured", "t...
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/conf/__init__.py#L133-L147
54,385
mushkevych/scheduler
synergy/conf/__init__.py
LazyContext._setup
def _setup(self): """ Load the context module pointed to by the environment variable. This is used the first time we need the context at all, if the user has not previously configured the context manually. """ context_module = os.environ.get(ENVIRONMENT_CONTEXT_VARIABLE, ...
python
def _setup(self): """ Load the context module pointed to by the environment variable. This is used the first time we need the context at all, if the user has not previously configured the context manually. """ context_module = os.environ.get(ENVIRONMENT_CONTEXT_VARIABLE, ...
[ "def", "_setup", "(", "self", ")", ":", "context_module", "=", "os", ".", "environ", ".", "get", "(", "ENVIRONMENT_CONTEXT_VARIABLE", ",", "'context'", ")", "if", "not", "context_module", ":", "raise", "ImproperlyConfigured", "(", "'Requested context points to an em...
Load the context module pointed to by the environment variable. This is used the first time we need the context at all, if the user has not previously configured the context manually.
[ "Load", "the", "context", "module", "pointed", "to", "by", "the", "environment", "variable", ".", "This", "is", "used", "the", "first", "time", "we", "need", "the", "context", "at", "all", "if", "the", "user", "has", "not", "previously", "configured", "the...
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/conf/__init__.py#L157-L171
54,386
PedalPi/PluginsManager
pluginsmanager/observer/autosaver/persistence.py
Persistence.read
def read(path, create_file=False): """ Reads the json data in path :param Path path: Path that json data will be readed :param create_file: Creates the file if it isn't exists :return: json data """ if create_file: with open(str(path), 'a+') as data_...
python
def read(path, create_file=False): """ Reads the json data in path :param Path path: Path that json data will be readed :param create_file: Creates the file if it isn't exists :return: json data """ if create_file: with open(str(path), 'a+') as data_...
[ "def", "read", "(", "path", ",", "create_file", "=", "False", ")", ":", "if", "create_file", ":", "with", "open", "(", "str", "(", "path", ")", ",", "'a+'", ")", "as", "data_file", ":", "data_file", ".", "seek", "(", "0", ")", "return", "json", "."...
Reads the json data in path :param Path path: Path that json data will be readed :param create_file: Creates the file if it isn't exists :return: json data
[ "Reads", "the", "json", "data", "in", "path" ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/observer/autosaver/persistence.py#L23-L39
54,387
PedalPi/PluginsManager
pluginsmanager/observer/autosaver/persistence.py
Persistence.save
def save(path, json_data): """ Saves json_data in path :param Path path: Path that json_data will be persisted :param json_data: Data that will be persisted """ try: loop = asyncio.get_event_loop() if loop.is_running(): asyncio.run...
python
def save(path, json_data): """ Saves json_data in path :param Path path: Path that json_data will be persisted :param json_data: Data that will be persisted """ try: loop = asyncio.get_event_loop() if loop.is_running(): asyncio.run...
[ "def", "save", "(", "path", ",", "json_data", ")", ":", "try", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "if", "loop", ".", "is_running", "(", ")", ":", "asyncio", ".", "run_coroutine_threadsafe", "(", "Persistence", ".", "_save", "("...
Saves json_data in path :param Path path: Path that json_data will be persisted :param json_data: Data that will be persisted
[ "Saves", "json_data", "in", "path" ]
2dcc9f6a79b48e9c9be82efffd855352fa15c5c7
https://github.com/PedalPi/PluginsManager/blob/2dcc9f6a79b48e9c9be82efffd855352fa15c5c7/pluginsmanager/observer/autosaver/persistence.py#L42-L56
54,388
LPgenerator/django-mmc
mmc/mixins.py
BaseCommandMixin.run_at_subprocess
def run_at_subprocess(self, use_subprocess, foo, *args, **kwrags): """ This method for run some function at subprocess. Very useful when you have a problem with memory leaks. """ if use_subprocess is False: return foo(*args, **kwrags) child_pid = os.fork() ...
python
def run_at_subprocess(self, use_subprocess, foo, *args, **kwrags): """ This method for run some function at subprocess. Very useful when you have a problem with memory leaks. """ if use_subprocess is False: return foo(*args, **kwrags) child_pid = os.fork() ...
[ "def", "run_at_subprocess", "(", "self", ",", "use_subprocess", ",", "foo", ",", "*", "args", ",", "*", "*", "kwrags", ")", ":", "if", "use_subprocess", "is", "False", ":", "return", "foo", "(", "*", "args", ",", "*", "*", "kwrags", ")", "child_pid", ...
This method for run some function at subprocess. Very useful when you have a problem with memory leaks.
[ "This", "method", "for", "run", "some", "function", "at", "subprocess", ".", "Very", "useful", "when", "you", "have", "a", "problem", "with", "memory", "leaks", "." ]
3b6d3c9d1721c4428177277c1bb1ca24512127de
https://github.com/LPgenerator/django-mmc/blob/3b6d3c9d1721c4428177277c1bb1ca24512127de/mmc/mixins.py#L111-L123
54,389
mushkevych/scheduler
synergy/db/dao/managed_process_dao.py
ManagedProcessDao.clear
def clear(self): """ removes all documents in this collection """ collection = self.ds.connection(COLLECTION_MANAGED_PROCESS) return collection.delete_many(filter={})
python
def clear(self): """ removes all documents in this collection """ collection = self.ds.connection(COLLECTION_MANAGED_PROCESS) return collection.delete_many(filter={})
[ "def", "clear", "(", "self", ")", ":", "collection", "=", "self", ".", "ds", ".", "connection", "(", "COLLECTION_MANAGED_PROCESS", ")", "return", "collection", ".", "delete_many", "(", "filter", "=", "{", "}", ")" ]
removes all documents in this collection
[ "removes", "all", "documents", "in", "this", "collection" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/db/dao/managed_process_dao.py#L19-L22
54,390
mushkevych/scheduler
synergy/system/utils.py
compute_gzip_md5
def compute_gzip_md5(file_name): """ method traverses compressed file and calculates its MD5 checksum """ md5 = hashlib.md5() file_obj = gzip.open(file_name, 'rb') for chunk in iter(lambda: file_obj.read(8192), ''): md5.update(chunk) file_obj.close() return md5.hexdigest()
python
def compute_gzip_md5(file_name): """ method traverses compressed file and calculates its MD5 checksum """ md5 = hashlib.md5() file_obj = gzip.open(file_name, 'rb') for chunk in iter(lambda: file_obj.read(8192), ''): md5.update(chunk) file_obj.close() return md5.hexdigest()
[ "def", "compute_gzip_md5", "(", "file_name", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "file_obj", "=", "gzip", ".", "open", "(", "file_name", ",", "'rb'", ")", "for", "chunk", "in", "iter", "(", "lambda", ":", "file_obj", ".", "read", "...
method traverses compressed file and calculates its MD5 checksum
[ "method", "traverses", "compressed", "file", "and", "calculates", "its", "MD5", "checksum" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/utils.py#L41-L49
54,391
mushkevych/scheduler
synergy/system/utils.py
copy_and_sum_families
def copy_and_sum_families(family_source, family_target): """ methods iterates thru source family and copies its entries to target family in case key already exists in both families - then the values are added""" for every in family_source: if every not in family_target: family_target[eve...
python
def copy_and_sum_families(family_source, family_target): """ methods iterates thru source family and copies its entries to target family in case key already exists in both families - then the values are added""" for every in family_source: if every not in family_target: family_target[eve...
[ "def", "copy_and_sum_families", "(", "family_source", ",", "family_target", ")", ":", "for", "every", "in", "family_source", ":", "if", "every", "not", "in", "family_target", ":", "family_target", "[", "every", "]", "=", "family_source", "[", "every", "]", "el...
methods iterates thru source family and copies its entries to target family in case key already exists in both families - then the values are added
[ "methods", "iterates", "thru", "source", "family", "and", "copies", "its", "entries", "to", "target", "family", "in", "case", "key", "already", "exists", "in", "both", "families", "-", "then", "the", "values", "are", "added" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/utils.py#L65-L72
54,392
mushkevych/scheduler
synergy/system/utils.py
remove_pid_file
def remove_pid_file(process_name): """ removes pid file """ pid_filename = get_pid_filename(process_name) try: os.remove(pid_filename) print('Removed pid file at: {0}'.format(pid_filename), file=sys.stdout) except Exception as e: print('Unable to remove pid file at: {0}, because ...
python
def remove_pid_file(process_name): """ removes pid file """ pid_filename = get_pid_filename(process_name) try: os.remove(pid_filename) print('Removed pid file at: {0}'.format(pid_filename), file=sys.stdout) except Exception as e: print('Unable to remove pid file at: {0}, because ...
[ "def", "remove_pid_file", "(", "process_name", ")", ":", "pid_filename", "=", "get_pid_filename", "(", "process_name", ")", "try", ":", "os", ".", "remove", "(", "pid_filename", ")", "print", "(", "'Removed pid file at: {0}'", ".", "format", "(", "pid_filename", ...
removes pid file
[ "removes", "pid", "file" ]
6740331360f49083c208085fb5a60ce80ebf418b
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/utils.py#L91-L99
54,393
epio/mantrid
mantrid/management.py
ManagementApp.host_errors
def host_errors(self, hostname, details): """ Validates the format of a host entry Returns an error string, or None if it is valid. """ if not hostname or not isinstance(hostname, basestring): return "hostname_invalid" if not isinstance(details, list): ...
python
def host_errors(self, hostname, details): """ Validates the format of a host entry Returns an error string, or None if it is valid. """ if not hostname or not isinstance(hostname, basestring): return "hostname_invalid" if not isinstance(details, list): ...
[ "def", "host_errors", "(", "self", ",", "hostname", ",", "details", ")", ":", "if", "not", "hostname", "or", "not", "isinstance", "(", "hostname", ",", "basestring", ")", ":", "return", "\"hostname_invalid\"", "if", "not", "isinstance", "(", "details", ",", ...
Validates the format of a host entry Returns an error string, or None if it is valid.
[ "Validates", "the", "format", "of", "a", "host", "entry", "Returns", "an", "error", "string", "or", "None", "if", "it", "is", "valid", "." ]
1c699f1a4b33888b533c19cb6d025173f2160576
https://github.com/epio/mantrid/blob/1c699f1a4b33888b533c19cb6d025173f2160576/mantrid/management.py#L97-L114
54,394
epio/mantrid
mantrid/management.py
ManagementApp.set_all
def set_all(self, path, body): "Replaces the hosts list with the provided input" # Do some error checking if not isinstance(body, dict): raise HttpBadRequest("body_not_a_dict") for hostname, details in body.items(): error = self.host_errors(hostname, details) ...
python
def set_all(self, path, body): "Replaces the hosts list with the provided input" # Do some error checking if not isinstance(body, dict): raise HttpBadRequest("body_not_a_dict") for hostname, details in body.items(): error = self.host_errors(hostname, details) ...
[ "def", "set_all", "(", "self", ",", "path", ",", "body", ")", ":", "# Do some error checking", "if", "not", "isinstance", "(", "body", ",", "dict", ")", ":", "raise", "HttpBadRequest", "(", "\"body_not_a_dict\"", ")", "for", "hostname", ",", "details", "in",...
Replaces the hosts list with the provided input
[ "Replaces", "the", "hosts", "list", "with", "the", "provided", "input" ]
1c699f1a4b33888b533c19cb6d025173f2160576
https://github.com/epio/mantrid/blob/1c699f1a4b33888b533c19cb6d025173f2160576/mantrid/management.py#L119-L140
54,395
helium/helium-python
helium/session.py
CB.boolean
def boolean(cls, true_code, false_code=None): """Callback to validate a response code. The returned callback checks whether a given response has a ``status_code`` that is considered good (``true_code``) and raise an appropriate error if not. The optional ``false_code`` allows f...
python
def boolean(cls, true_code, false_code=None): """Callback to validate a response code. The returned callback checks whether a given response has a ``status_code`` that is considered good (``true_code``) and raise an appropriate error if not. The optional ``false_code`` allows f...
[ "def", "boolean", "(", "cls", ",", "true_code", ",", "false_code", "=", "None", ")", ":", "def", "func", "(", "response", ")", ":", "if", "response", "is", "not", "None", ":", "status_code", "=", "response", ".", "status", "if", "status_code", "==", "t...
Callback to validate a response code. The returned callback checks whether a given response has a ``status_code`` that is considered good (``true_code``) and raise an appropriate error if not. The optional ``false_code`` allows for a non-successful status code to return False i...
[ "Callback", "to", "validate", "a", "response", "code", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/session.py#L27-L63
54,396
helium/helium-python
helium/session.py
CB.json
def json(cls, status_code, process): """Callback to validate and extract a JSON object. The returned callback checks a given response for the given status_code using :function:`response_boolean`. On success the response JSON is parsed and returned. Args: status_cod...
python
def json(cls, status_code, process): """Callback to validate and extract a JSON object. The returned callback checks a given response for the given status_code using :function:`response_boolean`. On success the response JSON is parsed and returned. Args: status_cod...
[ "def", "json", "(", "cls", ",", "status_code", ",", "process", ")", ":", "def", "func", "(", "response", ")", ":", "ret", "=", "None", "if", "cls", ".", "boolean", "(", "status_code", ")", "(", "response", ")", ":", "ret", "=", "response", ".", "js...
Callback to validate and extract a JSON object. The returned callback checks a given response for the given status_code using :function:`response_boolean`. On success the response JSON is parsed and returned. Args: status_code(int): The http status code to consider a succe...
[ "Callback", "to", "validate", "and", "extract", "a", "JSON", "object", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/session.py#L66-L89
54,397
helium/helium-python
helium/session.py
Session.get
def get(self, url, callback, params=None, json=None, headers=None): """Get a URL. Args: callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json(dict): JSON body for the request he...
python
def get(self, url, callback, params=None, json=None, headers=None): """Get a URL. Args: callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json(dict): JSON body for the request he...
[ "def", "get", "(", "self", ",", "url", ",", "callback", ",", "params", "=", "None", ",", "json", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "adapter", ".", "get", "(", "url", ",", "callback", ",", "params", "=", "p...
Get a URL. Args: callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json(dict): JSON body for the request headers(dict): Additional headers for the request Returns: The result o...
[ "Get", "a", "URL", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/session.py#L135-L158
54,398
helium/helium-python
helium/session.py
Session.put
def put(self, url, callback, params=None, json=None, headers=None): """Put to a URL. Args: url(string): URL for the request callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json...
python
def put(self, url, callback, params=None, json=None, headers=None): """Put to a URL. Args: url(string): URL for the request callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json...
[ "def", "put", "(", "self", ",", "url", ",", "callback", ",", "params", "=", "None", ",", "json", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "adapter", ".", "put", "(", "url", ",", "callback", ",", "params", "=", "p...
Put to a URL. Args: url(string): URL for the request callback(func): The response callback function Keyword Args: params(dict): Parameters for the request json(dict): JSON body for the request headers(dict): HTTP headers for the request ...
[ "Put", "to", "a", "URL", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/session.py#L160-L184
54,399
helium/helium-python
helium/session.py
Session.patch
def patch(self, url, callback, params=None, json=None, headers=None): """Patch a URL. Args: url(string): URL for the request callback(func): The response callback function headers(dict): HTTP headers for the request Keyword Args: ...
python
def patch(self, url, callback, params=None, json=None, headers=None): """Patch a URL. Args: url(string): URL for the request callback(func): The response callback function headers(dict): HTTP headers for the request Keyword Args: ...
[ "def", "patch", "(", "self", ",", "url", ",", "callback", ",", "params", "=", "None", ",", "json", "=", "None", ",", "headers", "=", "None", ")", ":", "return", "self", ".", "adapter", ".", "patch", "(", "url", ",", "callback", ",", "params", "=", ...
Patch a URL. Args: url(string): URL for the request callback(func): The response callback function headers(dict): HTTP headers for the request Keyword Args: params(dict): Parameters for the request json(dict): JSON body for the request ...
[ "Patch", "a", "URL", "." ]
db73480b143da4fc48e95c4414bd69c576a3a390
https://github.com/helium/helium-python/blob/db73480b143da4fc48e95c4414bd69c576a3a390/helium/session.py#L214-L239