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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
teepark/greenhouse | greenhouse/util.py | Event.set | def set(self):
"""set the event to triggered
after calling this method, all greenlets waiting on the event will be
rescheduled, and calling :meth:`wait` will not block until
:meth:`clear` has been called
"""
self._is_set = True
scheduler.state.awoken_from_events.... | python | def set(self):
"""set the event to triggered
after calling this method, all greenlets waiting on the event will be
rescheduled, and calling :meth:`wait` will not block until
:meth:`clear` has been called
"""
self._is_set = True
scheduler.state.awoken_from_events.... | [
"def",
"set",
"(",
"self",
")",
":",
"self",
".",
"_is_set",
"=",
"True",
"scheduler",
".",
"state",
".",
"awoken_from_events",
".",
"update",
"(",
"self",
".",
"_waiters",
")",
"del",
"self",
".",
"_waiters",
"[",
":",
"]"
] | set the event to triggered
after calling this method, all greenlets waiting on the event will be
rescheduled, and calling :meth:`wait` will not block until
:meth:`clear` has been called | [
"set",
"the",
"event",
"to",
"triggered"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L35-L44 | train |
teepark/greenhouse | greenhouse/util.py | Event.wait | def wait(self, timeout=None):
"""pause the current coroutine until this event is set
.. note::
this method will block the current coroutine if :meth:`set` has not
been called.
:param timeout:
the maximum amount of time to block in seconds. the default of
... | python | def wait(self, timeout=None):
"""pause the current coroutine until this event is set
.. note::
this method will block the current coroutine if :meth:`set` has not
been called.
:param timeout:
the maximum amount of time to block in seconds. the default of
... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_is_set",
":",
"return",
"False",
"current",
"=",
"compat",
".",
"getcurrent",
"(",
")",
"# the waiting greenlet",
"waketime",
"=",
"None",
"if",
"timeout",
"is",
"Non... | pause the current coroutine until this event is set
.. note::
this method will block the current coroutine if :meth:`set` has not
been called.
:param timeout:
the maximum amount of time to block in seconds. the default of
``None`` allows indefinite bloc... | [
"pause",
"the",
"current",
"coroutine",
"until",
"this",
"event",
"is",
"set"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L54-L89 | train |
teepark/greenhouse | greenhouse/util.py | RLock.acquire | def acquire(self, blocking=True):
"""acquire ownership of the lock
if the lock is already owned by the calling greenlet, a counter simply
gets incremented. if it is owned by a different greenlet then it will
block until the lock becomes available.
.. note::
this me... | python | def acquire(self, blocking=True):
"""acquire ownership of the lock
if the lock is already owned by the calling greenlet, a counter simply
gets incremented. if it is owned by a different greenlet then it will
block until the lock becomes available.
.. note::
this me... | [
"def",
"acquire",
"(",
"self",
",",
"blocking",
"=",
"True",
")",
":",
"current",
"=",
"compat",
".",
"getcurrent",
"(",
")",
"if",
"self",
".",
"_owner",
"is",
"current",
":",
"self",
".",
"_count",
"+=",
"1",
"return",
"True",
"if",
"self",
".",
... | acquire ownership of the lock
if the lock is already owned by the calling greenlet, a counter simply
gets incremented. if it is owned by a different greenlet then it will
block until the lock becomes available.
.. note::
this method will block the current coroutine if the ... | [
"acquire",
"ownership",
"of",
"the",
"lock"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L186-L221 | train |
teepark/greenhouse | greenhouse/util.py | RLock.release | def release(self):
"""release one ownership of the lock
if the calling greenlet has :meth:`acquired <acquire>` the lock more
than once this will simply decrement the counter. if this is a final
release then a waiting greenlet is awoken
:raises:
`RuntimeError` if the... | python | def release(self):
"""release one ownership of the lock
if the calling greenlet has :meth:`acquired <acquire>` the lock more
than once this will simply decrement the counter. if this is a final
release then a waiting greenlet is awoken
:raises:
`RuntimeError` if the... | [
"def",
"release",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_locked",
"or",
"self",
".",
"_owner",
"is",
"not",
"compat",
".",
"getcurrent",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"cannot release un-acquired lock\"",
")",
"self",
".",
"_cou... | release one ownership of the lock
if the calling greenlet has :meth:`acquired <acquire>` the lock more
than once this will simply decrement the counter. if this is a final
release then a waiting greenlet is awoken
:raises:
`RuntimeError` if the calling greenlet is not the l... | [
"release",
"one",
"ownership",
"of",
"the",
"lock"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L223-L245 | train |
teepark/greenhouse | greenhouse/util.py | Condition.wait | def wait(self, timeout=None):
"""wait to be woken up by the condition
.. note::
this method will block the current coroutine until a :meth:`notify`
wakes it back up.
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Loc... | python | def wait(self, timeout=None):
"""wait to be woken up by the condition
.. note::
this method will block the current coroutine until a :meth:`notify`
wakes it back up.
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Loc... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_is_owned",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"cannot wait on un-acquired lock\"",
")",
"current",
"=",
"compat",
".",
"getcurrent",
"(",
")",
"waket... | wait to be woken up by the condition
.. note::
this method will block the current coroutine until a :meth:`notify`
wakes it back up.
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>` | [
"wait",
"to",
"be",
"woken",
"up",
"by",
"the",
"condition"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L274-L306 | train |
teepark/greenhouse | greenhouse/util.py | Condition.notify | def notify(self, num=1):
"""wake one or more waiting greenlets
:param num: the number of waiters to wake (default 1)
:type num: int
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>`
"""
if not self._is_own... | python | def notify(self, num=1):
"""wake one or more waiting greenlets
:param num: the number of waiters to wake (default 1)
:type num: int
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>`
"""
if not self._is_own... | [
"def",
"notify",
"(",
"self",
",",
"num",
"=",
"1",
")",
":",
"if",
"not",
"self",
".",
"_is_owned",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"cannot wait on un-acquired lock\"",
")",
"for",
"i",
"in",
"xrange",
"(",
"min",
"(",
"num",
",",
"len"... | wake one or more waiting greenlets
:param num: the number of waiters to wake (default 1)
:type num: int
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>` | [
"wake",
"one",
"or",
"more",
"waiting",
"greenlets"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L308-L321 | train |
teepark/greenhouse | greenhouse/util.py | Condition.notify_all | def notify_all(self):
"""wake all waiting greenlets
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>`
"""
if not self._is_owned():
raise RuntimeError("cannot wait on un-acquired lock")
scheduler.state.a... | python | def notify_all(self):
"""wake all waiting greenlets
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>`
"""
if not self._is_owned():
raise RuntimeError("cannot wait on un-acquired lock")
scheduler.state.a... | [
"def",
"notify_all",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_is_owned",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"cannot wait on un-acquired lock\"",
")",
"scheduler",
".",
"state",
".",
"awoken_from_events",
".",
"update",
"(",
"x",
"[",
"0... | wake all waiting greenlets
:raises:
`RuntimeError` if the underlying lock hasn't been
:meth:`acquired <Lock.acquire>` | [
"wake",
"all",
"waiting",
"greenlets"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L323-L333 | train |
teepark/greenhouse | greenhouse/util.py | Semaphore.acquire | def acquire(self, blocking=True):
"""decrement the counter, waiting if it is already at 0
.. note::
if the counter is already at 0, this method will block the current
coroutine until a :meth:`release` increments it again.
:param blocking:
whether or not to ... | python | def acquire(self, blocking=True):
"""decrement the counter, waiting if it is already at 0
.. note::
if the counter is already at 0, this method will block the current
coroutine until a :meth:`release` increments it again.
:param blocking:
whether or not to ... | [
"def",
"acquire",
"(",
"self",
",",
"blocking",
"=",
"True",
")",
":",
"if",
"self",
".",
"_value",
":",
"self",
".",
"_value",
"-=",
"1",
"return",
"True",
"if",
"not",
"blocking",
":",
"return",
"False",
"self",
".",
"_waiters",
".",
"append",
"(",... | decrement the counter, waiting if it is already at 0
.. note::
if the counter is already at 0, this method will block the current
coroutine until a :meth:`release` increments it again.
:param blocking:
whether or not to block if the counter is already at 0 (default... | [
"decrement",
"the",
"counter",
"waiting",
"if",
"it",
"is",
"already",
"at",
"0"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L351-L376 | train |
teepark/greenhouse | greenhouse/util.py | Semaphore.release | def release(self):
"increment the counter, waking up a waiter if there was any"
if self._waiters:
scheduler.state.awoken_from_events.add(self._waiters.popleft())
else:
self._value += 1 | python | def release(self):
"increment the counter, waking up a waiter if there was any"
if self._waiters:
scheduler.state.awoken_from_events.add(self._waiters.popleft())
else:
self._value += 1 | [
"def",
"release",
"(",
"self",
")",
":",
"if",
"self",
".",
"_waiters",
":",
"scheduler",
".",
"state",
".",
"awoken_from_events",
".",
"add",
"(",
"self",
".",
"_waiters",
".",
"popleft",
"(",
")",
")",
"else",
":",
"self",
".",
"_value",
"+=",
"1"
... | increment the counter, waking up a waiter if there was any | [
"increment",
"the",
"counter",
"waking",
"up",
"a",
"waiter",
"if",
"there",
"was",
"any"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L378-L383 | train |
teepark/greenhouse | greenhouse/util.py | Thread.start | def start(self):
"""schedule to start the greenlet that runs this thread's function
:raises: `RuntimeError` if the thread has already been started
"""
if self._started:
raise RuntimeError("thread already started")
def run():
try:
self.run... | python | def start(self):
"""schedule to start the greenlet that runs this thread's function
:raises: `RuntimeError` if the thread has already been started
"""
if self._started:
raise RuntimeError("thread already started")
def run():
try:
self.run... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_started",
":",
"raise",
"RuntimeError",
"(",
"\"thread already started\"",
")",
"def",
"run",
"(",
")",
":",
"try",
":",
"self",
".",
"run",
"(",
"*",
"self",
".",
"_args",
",",
"*",
"*",
... | schedule to start the greenlet that runs this thread's function
:raises: `RuntimeError` if the thread has already been started | [
"schedule",
"to",
"start",
"the",
"greenlet",
"that",
"runs",
"this",
"thread",
"s",
"function"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L512-L532 | train |
teepark/greenhouse | greenhouse/util.py | Thread.join | def join(self, timeout=None):
"""block until this thread terminates
.. note::
this method can block the calling coroutine if the thread has not
yet completed.
:param timeout:
the maximum time to wait. with the default of ``None``, waits
indefini... | python | def join(self, timeout=None):
"""block until this thread terminates
.. note::
this method can block the calling coroutine if the thread has not
yet completed.
:param timeout:
the maximum time to wait. with the default of ``None``, waits
indefini... | [
"def",
"join",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_started",
":",
"raise",
"RuntimeError",
"(",
"\"cannot join thread before it is started\"",
")",
"if",
"compat",
".",
"getcurrent",
"(",
")",
"is",
"self",
".",
... | block until this thread terminates
.. note::
this method can block the calling coroutine if the thread has not
yet completed.
:param timeout:
the maximum time to wait. with the default of ``None``, waits
indefinitely
:type timeout: int, float or... | [
"block",
"until",
"this",
"thread",
"terminates"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L542-L563 | train |
teepark/greenhouse | greenhouse/util.py | Timer.cancel | def cancel(self):
"""attempt to prevent the timer from ever running its function
:returns:
``True`` if it was successful, ``False`` if the timer had already
run or been cancelled
"""
done = self.finished.is_set()
self.finished.set()
return not don... | python | def cancel(self):
"""attempt to prevent the timer from ever running its function
:returns:
``True`` if it was successful, ``False`` if the timer had already
run or been cancelled
"""
done = self.finished.is_set()
self.finished.set()
return not don... | [
"def",
"cancel",
"(",
"self",
")",
":",
"done",
"=",
"self",
".",
"finished",
".",
"is_set",
"(",
")",
"self",
".",
"finished",
".",
"set",
"(",
")",
"return",
"not",
"done"
] | attempt to prevent the timer from ever running its function
:returns:
``True`` if it was successful, ``False`` if the timer had already
run or been cancelled | [
"attempt",
"to",
"prevent",
"the",
"timer",
"from",
"ever",
"running",
"its",
"function"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L655-L664 | train |
teepark/greenhouse | greenhouse/util.py | Timer.wrap | def wrap(cls, secs, args=(), kwargs=None):
"""a classmethod decorator to immediately turn a function into a timer
.. note::
you won't find this on `threading.Timer`, it is an extension to
that API
this is a function *returning a decorator*, so it is used like so:
... | python | def wrap(cls, secs, args=(), kwargs=None):
"""a classmethod decorator to immediately turn a function into a timer
.. note::
you won't find this on `threading.Timer`, it is an extension to
that API
this is a function *returning a decorator*, so it is used like so:
... | [
"def",
"wrap",
"(",
"cls",
",",
"secs",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"return",
"cls",
"(",
"secs",
",",
"func",
",",
"args",
",",
"kwargs",
")",
"return",
"decorator"... | a classmethod decorator to immediately turn a function into a timer
.. note::
you won't find this on `threading.Timer`, it is an extension to
that API
this is a function *returning a decorator*, so it is used like so:
>>> @Timer.wrap(5, args=("world",))
>>> de... | [
"a",
"classmethod",
"decorator",
"to",
"immediately",
"turn",
"a",
"function",
"into",
"a",
"timer"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L673-L700 | train |
teepark/greenhouse | greenhouse/util.py | Queue.get | def get(self, block=True, timeout=None):
"""get an item out of the queue
.. note::
if `block` is ``True`` (the default) and the queue is
:meth`empty`, this method will block the current coroutine until
something has been :meth:`put`.
:param block:
... | python | def get(self, block=True, timeout=None):
"""get an item out of the queue
.. note::
if `block` is ``True`` (the default) and the queue is
:meth`empty`, this method will block the current coroutine until
something has been :meth:`put`.
:param block:
... | [
"def",
"get",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_data",
":",
"if",
"not",
"block",
":",
"raise",
"Empty",
"(",
")",
"current",
"=",
"compat",
".",
"getcurrent",
"(",
")",
"wa... | get an item out of the queue
.. note::
if `block` is ``True`` (the default) and the queue is
:meth`empty`, this method will block the current coroutine until
something has been :meth:`put`.
:param block:
whether to block if there is no data yet availabl... | [
"get",
"an",
"item",
"out",
"of",
"the",
"queue"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L743-L789 | train |
teepark/greenhouse | greenhouse/util.py | Queue.put | def put(self, item, block=True, timeout=None):
"""put an item into the queue
.. note::
if the queue was created with a `maxsize` and it is currently
:meth:`full`, this method will block the calling coroutine until
another coroutine :meth:`get`\ s an item.
:... | python | def put(self, item, block=True, timeout=None):
"""put an item into the queue
.. note::
if the queue was created with a `maxsize` and it is currently
:meth:`full`, this method will block the calling coroutine until
another coroutine :meth:`get`\ s an item.
:... | [
"def",
"put",
"(",
"self",
",",
"item",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"full",
"(",
")",
":",
"if",
"not",
"block",
":",
"raise",
"Full",
"(",
")",
"current",
"=",
"compat",
".",
"getcurrent",... | put an item into the queue
.. note::
if the queue was created with a `maxsize` and it is currently
:meth:`full`, this method will block the calling coroutine until
another coroutine :meth:`get`\ s an item.
:param item: the object to put into the queue, can be any t... | [
"put",
"an",
"item",
"into",
"the",
"queue"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L803-L852 | train |
teepark/greenhouse | greenhouse/util.py | Counter.increment | def increment(self):
"increment the counter, and wake anyone waiting for the new value"
self._count += 1
waiters = self._waiters.pop(self._count, [])
if waiters:
scheduler.state.awoken_from_events.update(waiters) | python | def increment(self):
"increment the counter, and wake anyone waiting for the new value"
self._count += 1
waiters = self._waiters.pop(self._count, [])
if waiters:
scheduler.state.awoken_from_events.update(waiters) | [
"def",
"increment",
"(",
"self",
")",
":",
"self",
".",
"_count",
"+=",
"1",
"waiters",
"=",
"self",
".",
"_waiters",
".",
"pop",
"(",
"self",
".",
"_count",
",",
"[",
"]",
")",
"if",
"waiters",
":",
"scheduler",
".",
"state",
".",
"awoken_from_event... | increment the counter, and wake anyone waiting for the new value | [
"increment",
"the",
"counter",
"and",
"wake",
"anyone",
"waiting",
"for",
"the",
"new",
"value"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L952-L957 | train |
teepark/greenhouse | greenhouse/util.py | Counter.wait | def wait(self, until=0):
"""wait until the count has reached a particular number
.. note:: this method can block the current greenlet
:param until:
the number to wait for the count to get down (or up) to. default 0
:type until: int
"""
if self._count != unti... | python | def wait(self, until=0):
"""wait until the count has reached a particular number
.. note:: this method can block the current greenlet
:param until:
the number to wait for the count to get down (or up) to. default 0
:type until: int
"""
if self._count != unti... | [
"def",
"wait",
"(",
"self",
",",
"until",
"=",
"0",
")",
":",
"if",
"self",
".",
"_count",
"!=",
"until",
":",
"self",
".",
"_waiters",
".",
"setdefault",
"(",
"until",
",",
"[",
"]",
")",
".",
"append",
"(",
"compat",
".",
"getcurrent",
"(",
")"... | wait until the count has reached a particular number
.. note:: this method can block the current greenlet
:param until:
the number to wait for the count to get down (or up) to. default 0
:type until: int | [
"wait",
"until",
"the",
"count",
"has",
"reached",
"a",
"particular",
"number"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L976-L987 | train |
teepark/greenhouse | greenhouse/ext/psycopg2.py | wait_callback | def wait_callback(connection):
"""callback function suitable for ``psycopg2.set_wait_callback``
pass this function to ``psycopg2.extensions.set_wait_callack`` to force any
blocking operations from psycopg2 to only block the current coroutine,
rather than the entire thread or process
to undo the ch... | python | def wait_callback(connection):
"""callback function suitable for ``psycopg2.set_wait_callback``
pass this function to ``psycopg2.extensions.set_wait_callack`` to force any
blocking operations from psycopg2 to only block the current coroutine,
rather than the entire thread or process
to undo the ch... | [
"def",
"wait_callback",
"(",
"connection",
")",
":",
"while",
"1",
":",
"state",
"=",
"connection",
".",
"poll",
"(",
")",
"if",
"state",
"==",
"extensions",
".",
"POLL_OK",
":",
"break",
"elif",
"state",
"==",
"extensions",
".",
"POLL_READ",
":",
"descr... | callback function suitable for ``psycopg2.set_wait_callback``
pass this function to ``psycopg2.extensions.set_wait_callack`` to force any
blocking operations from psycopg2 to only block the current coroutine,
rather than the entire thread or process
to undo the change and return to normal blocking ope... | [
"callback",
"function",
"suitable",
"for",
"psycopg2",
".",
"set_wait_callback"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/ext/psycopg2.py#L12-L32 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/dependency.py | Cdependency_extractor.get_path_to_root | def get_path_to_root(self,termid):
"""
Returns the dependency path from the term to the root
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of dependency relations
"""
# Get the sentence for the term
root... | python | def get_path_to_root(self,termid):
"""
Returns the dependency path from the term to the root
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of dependency relations
"""
# Get the sentence for the term
root... | [
"def",
"get_path_to_root",
"(",
"self",
",",
"termid",
")",
":",
"# Get the sentence for the term",
"root",
"=",
"None",
"sentence",
"=",
"self",
".",
"sentence_for_termid",
".",
"get",
"(",
"termid",
")",
"if",
"sentence",
"is",
"None",
":",
"#try with the top ... | Returns the dependency path from the term to the root
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of dependency relations | [
"Returns",
"the",
"dependency",
"path",
"from",
"the",
"term",
"to",
"the",
"root"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/dependency.py#L307-L333 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/dependency.py | Cdependency_extractor.get_full_dependents | def get_full_dependents(self, term_id, relations, counter = 0):
"""
Returns the complete list of dependents and embedded dependents of a certain term.
"""
counter += 1
deps = self.relations_for_term
if term_id in deps and len(deps.get(term_id)) > 0:
for dep in... | python | def get_full_dependents(self, term_id, relations, counter = 0):
"""
Returns the complete list of dependents and embedded dependents of a certain term.
"""
counter += 1
deps = self.relations_for_term
if term_id in deps and len(deps.get(term_id)) > 0:
for dep in... | [
"def",
"get_full_dependents",
"(",
"self",
",",
"term_id",
",",
"relations",
",",
"counter",
"=",
"0",
")",
":",
"counter",
"+=",
"1",
"deps",
"=",
"self",
".",
"relations_for_term",
"if",
"term_id",
"in",
"deps",
"and",
"len",
"(",
"deps",
".",
"get",
... | Returns the complete list of dependents and embedded dependents of a certain term. | [
"Returns",
"the",
"complete",
"list",
"of",
"dependents",
"and",
"embedded",
"dependents",
"of",
"a",
"certain",
"term",
"."
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/dependency.py#L354-L370 | train |
nickpandolfi/Cyther | cyther/configuration.py | getDirsToInclude | def getDirsToInclude(string):
"""
Given a string of module names, it will return the 'include' directories
essential to their compilation as long as the module has the conventional
'get_include' function.
"""
dirs = []
a = string.strip()
obj = a.split('-')
if len(obj) == 1 and obj[0... | python | def getDirsToInclude(string):
"""
Given a string of module names, it will return the 'include' directories
essential to their compilation as long as the module has the conventional
'get_include' function.
"""
dirs = []
a = string.strip()
obj = a.split('-')
if len(obj) == 1 and obj[0... | [
"def",
"getDirsToInclude",
"(",
"string",
")",
":",
"dirs",
"=",
"[",
"]",
"a",
"=",
"string",
".",
"strip",
"(",
")",
"obj",
"=",
"a",
".",
"split",
"(",
"'-'",
")",
"if",
"len",
"(",
"obj",
")",
"==",
"1",
"and",
"obj",
"[",
"0",
"]",
":",
... | Given a string of module names, it will return the 'include' directories
essential to their compilation as long as the module has the conventional
'get_include' function. | [
"Given",
"a",
"string",
"of",
"module",
"names",
"it",
"will",
"return",
"the",
"include",
"directories",
"essential",
"to",
"their",
"compilation",
"as",
"long",
"as",
"the",
"module",
"has",
"the",
"conventional",
"get_include",
"function",
"."
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L42-L63 | train |
nickpandolfi/Cyther | cyther/configuration.py | purge_configs | def purge_configs():
"""
These will delete any configs found in either the current directory or the
user's home directory
"""
user_config = path(CONFIG_FILE_NAME, root=USER)
inplace_config = path(CONFIG_FILE_NAME)
if os.path.isfile(user_config):
os.remove(user_config)
if os.pat... | python | def purge_configs():
"""
These will delete any configs found in either the current directory or the
user's home directory
"""
user_config = path(CONFIG_FILE_NAME, root=USER)
inplace_config = path(CONFIG_FILE_NAME)
if os.path.isfile(user_config):
os.remove(user_config)
if os.pat... | [
"def",
"purge_configs",
"(",
")",
":",
"user_config",
"=",
"path",
"(",
"CONFIG_FILE_NAME",
",",
"root",
"=",
"USER",
")",
"inplace_config",
"=",
"path",
"(",
"CONFIG_FILE_NAME",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"user_config",
")",
":",
... | These will delete any configs found in either the current directory or the
user's home directory | [
"These",
"will",
"delete",
"any",
"configs",
"found",
"in",
"either",
"the",
"current",
"directory",
"or",
"the",
"user",
"s",
"home",
"directory"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L66-L78 | train |
nickpandolfi/Cyther | cyther/configuration.py | find_config_file | def find_config_file():
"""
Returns the path to the config file if found in either the current working
directory, or the user's home directory. If a config file is not found,
the function will return None.
"""
local_config_name = path(CONFIG_FILE_NAME)
if os.path.isfile(local_config_name):
... | python | def find_config_file():
"""
Returns the path to the config file if found in either the current working
directory, or the user's home directory. If a config file is not found,
the function will return None.
"""
local_config_name = path(CONFIG_FILE_NAME)
if os.path.isfile(local_config_name):
... | [
"def",
"find_config_file",
"(",
")",
":",
"local_config_name",
"=",
"path",
"(",
"CONFIG_FILE_NAME",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"local_config_name",
")",
":",
"return",
"local_config_name",
"else",
":",
"user_config_name",
"=",
"path",
"... | Returns the path to the config file if found in either the current working
directory, or the user's home directory. If a config file is not found,
the function will return None. | [
"Returns",
"the",
"path",
"to",
"the",
"config",
"file",
"if",
"found",
"in",
"either",
"the",
"current",
"working",
"directory",
"or",
"the",
"user",
"s",
"home",
"directory",
".",
"If",
"a",
"config",
"file",
"is",
"not",
"found",
"the",
"function",
"w... | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L95-L109 | train |
nickpandolfi/Cyther | cyther/configuration.py | make_config_data | def make_config_data(*, guided):
"""
Makes the data necessary to construct a functional config file
"""
config_data = {}
config_data[INCLUDE_DIRS_KEY] = _make_include_dirs(guided=guided)
config_data[RUNTIME_DIRS_KEY] = _make_runtime_dirs(guided=guided)
config_data[RUNTIME_KEY] = _make_runtim... | python | def make_config_data(*, guided):
"""
Makes the data necessary to construct a functional config file
"""
config_data = {}
config_data[INCLUDE_DIRS_KEY] = _make_include_dirs(guided=guided)
config_data[RUNTIME_DIRS_KEY] = _make_runtime_dirs(guided=guided)
config_data[RUNTIME_KEY] = _make_runtim... | [
"def",
"make_config_data",
"(",
"*",
",",
"guided",
")",
":",
"config_data",
"=",
"{",
"}",
"config_data",
"[",
"INCLUDE_DIRS_KEY",
"]",
"=",
"_make_include_dirs",
"(",
"guided",
"=",
"guided",
")",
"config_data",
"[",
"RUNTIME_DIRS_KEY",
"]",
"=",
"_make_runt... | Makes the data necessary to construct a functional config file | [
"Makes",
"the",
"data",
"necessary",
"to",
"construct",
"a",
"functional",
"config",
"file"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L308-L317 | train |
nickpandolfi/Cyther | cyther/configuration.py | generate_configurations | def generate_configurations(*, guided=False, fresh_start=False, save=False):
"""
If a config file is found in the standard locations, it will be loaded and
the config data would be retuned. If not found, then generate the data on
the fly, and return it
"""
if fresh_start:
purge_configs(... | python | def generate_configurations(*, guided=False, fresh_start=False, save=False):
"""
If a config file is found in the standard locations, it will be loaded and
the config data would be retuned. If not found, then generate the data on
the fly, and return it
"""
if fresh_start:
purge_configs(... | [
"def",
"generate_configurations",
"(",
"*",
",",
"guided",
"=",
"False",
",",
"fresh_start",
"=",
"False",
",",
"save",
"=",
"False",
")",
":",
"if",
"fresh_start",
":",
"purge_configs",
"(",
")",
"loaded_status",
",",
"loaded_data",
"=",
"get_config",
"(",
... | If a config file is found in the standard locations, it will be loaded and
the config data would be retuned. If not found, then generate the data on
the fly, and return it | [
"If",
"a",
"config",
"file",
"is",
"found",
"in",
"the",
"standard",
"locations",
"it",
"will",
"be",
"loaded",
"and",
"the",
"config",
"data",
"would",
"be",
"retuned",
".",
"If",
"not",
"found",
"then",
"generate",
"the",
"data",
"on",
"the",
"fly",
... | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/configuration.py#L333-L353 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.info | def info(self):
"""Execute an HTTP request to get details on a queue, and
return it.
"""
url = "queues/%s" % (self.name,)
result = self.client.get(url)
return result['body']['queue'] | python | def info(self):
"""Execute an HTTP request to get details on a queue, and
return it.
"""
url = "queues/%s" % (self.name,)
result = self.client.get(url)
return result['body']['queue'] | [
"def",
"info",
"(",
"self",
")",
":",
"url",
"=",
"\"queues/%s\"",
"%",
"(",
"self",
".",
"name",
",",
")",
"result",
"=",
"self",
".",
"client",
".",
"get",
"(",
"url",
")",
"return",
"result",
"[",
"'body'",
"]",
"[",
"'queue'",
"]"
] | Execute an HTTP request to get details on a queue, and
return it. | [
"Execute",
"an",
"HTTP",
"request",
"to",
"get",
"details",
"on",
"a",
"queue",
"and",
"return",
"it",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L33-L40 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.clear | def clear(self):
"""Executes an HTTP request to clear all contents of a queue."""
url = "queues/%s/messages" % self.name
result = self.client.delete(url = url,
body = json.dumps({}),
headers={'Content-Type': 'application/jso... | python | def clear(self):
"""Executes an HTTP request to clear all contents of a queue."""
url = "queues/%s/messages" % self.name
result = self.client.delete(url = url,
body = json.dumps({}),
headers={'Content-Type': 'application/jso... | [
"def",
"clear",
"(",
"self",
")",
":",
"url",
"=",
"\"queues/%s/messages\"",
"%",
"self",
".",
"name",
"result",
"=",
"self",
".",
"client",
".",
"delete",
"(",
"url",
"=",
"url",
",",
"body",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
",",
"... | Executes an HTTP request to clear all contents of a queue. | [
"Executes",
"an",
"HTTP",
"request",
"to",
"clear",
"all",
"contents",
"of",
"a",
"queue",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L54-L61 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.delete | def delete(self, message_id, reservation_id=None, subscriber_name=None):
"""Execute an HTTP request to delete a message from queue.
Arguments:
message_id -- The ID of the message to be deleted.
reservation_id -- Reservation Id of the message. Reserved message could not be deleted witho... | python | def delete(self, message_id, reservation_id=None, subscriber_name=None):
"""Execute an HTTP request to delete a message from queue.
Arguments:
message_id -- The ID of the message to be deleted.
reservation_id -- Reservation Id of the message. Reserved message could not be deleted witho... | [
"def",
"delete",
"(",
"self",
",",
"message_id",
",",
"reservation_id",
"=",
"None",
",",
"subscriber_name",
"=",
"None",
")",
":",
"url",
"=",
"\"queues/%s/messages/%s\"",
"%",
"(",
"self",
".",
"name",
",",
"message_id",
")",
"qitems",
"=",
"{",
"}",
"... | Execute an HTTP request to delete a message from queue.
Arguments:
message_id -- The ID of the message to be deleted.
reservation_id -- Reservation Id of the message. Reserved message could not be deleted without reservation Id.
subscriber_name -- This is required to acknowledge push af... | [
"Execute",
"an",
"HTTP",
"request",
"to",
"delete",
"a",
"message",
"from",
"queue",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L63-L82 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.delete_multiple | def delete_multiple(self, ids=None, messages=None):
"""Execute an HTTP request to delete messages from queue.
Arguments:
ids -- A list of messages id to be deleted from the queue.
messages -- Response to message reserving.
"""
url = "queues/%s/messages" % self.name
... | python | def delete_multiple(self, ids=None, messages=None):
"""Execute an HTTP request to delete messages from queue.
Arguments:
ids -- A list of messages id to be deleted from the queue.
messages -- Response to message reserving.
"""
url = "queues/%s/messages" % self.name
... | [
"def",
"delete_multiple",
"(",
"self",
",",
"ids",
"=",
"None",
",",
"messages",
"=",
"None",
")",
":",
"url",
"=",
"\"queues/%s/messages\"",
"%",
"self",
".",
"name",
"items",
"=",
"None",
"if",
"ids",
"is",
"None",
"and",
"messages",
"is",
"None",
":... | Execute an HTTP request to delete messages from queue.
Arguments:
ids -- A list of messages id to be deleted from the queue.
messages -- Response to message reserving. | [
"Execute",
"an",
"HTTP",
"request",
"to",
"delete",
"messages",
"from",
"queue",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L84-L106 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.post | def post(self, *messages):
"""Executes an HTTP request to create message on the queue.
Creates queue if not existed.
Arguments:
messages -- An array of messages to be added to the queue.
"""
url = "queues/%s/messages" % self.name
msgs = [{'body': msg} if isinsta... | python | def post(self, *messages):
"""Executes an HTTP request to create message on the queue.
Creates queue if not existed.
Arguments:
messages -- An array of messages to be added to the queue.
"""
url = "queues/%s/messages" % self.name
msgs = [{'body': msg} if isinsta... | [
"def",
"post",
"(",
"self",
",",
"*",
"messages",
")",
":",
"url",
"=",
"\"queues/%s/messages\"",
"%",
"self",
".",
"name",
"msgs",
"=",
"[",
"{",
"'body'",
":",
"msg",
"}",
"if",
"isinstance",
"(",
"msg",
",",
"basestring",
")",
"else",
"msg",
"for"... | Executes an HTTP request to create message on the queue.
Creates queue if not existed.
Arguments:
messages -- An array of messages to be added to the queue. | [
"Executes",
"an",
"HTTP",
"request",
"to",
"create",
"message",
"on",
"the",
"queue",
".",
"Creates",
"queue",
"if",
"not",
"existed",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L108-L124 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.reserve | def reserve(self, max=None, timeout=None, wait=None, delete=None):
"""Retrieves Messages from the queue and reserves it.
Arguments:
max -- The maximum number of messages to reserve. Defaults to 1.
timeout -- Timeout in seconds.
wait -- Time to long poll for messages, in seconds.... | python | def reserve(self, max=None, timeout=None, wait=None, delete=None):
"""Retrieves Messages from the queue and reserves it.
Arguments:
max -- The maximum number of messages to reserve. Defaults to 1.
timeout -- Timeout in seconds.
wait -- Time to long poll for messages, in seconds.... | [
"def",
"reserve",
"(",
"self",
",",
"max",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"wait",
"=",
"None",
",",
"delete",
"=",
"None",
")",
":",
"url",
"=",
"\"queues/%s/reservations\"",
"%",
"self",
".",
"name",
"qitems",
"=",
"{",
"}",
"if",
... | Retrieves Messages from the queue and reserves it.
Arguments:
max -- The maximum number of messages to reserve. Defaults to 1.
timeout -- Timeout in seconds.
wait -- Time to long poll for messages, in seconds. Max is 30 seconds. Default 0.
delete -- If true, do not put each mess... | [
"Retrieves",
"Messages",
"from",
"the",
"queue",
"and",
"reserves",
"it",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L136-L160 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.touch | def touch(self, message_id, reservation_id, timeout=None):
"""Touching a reserved message extends its timeout to the duration specified when the message was created.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
timeout -- Optio... | python | def touch(self, message_id, reservation_id, timeout=None):
"""Touching a reserved message extends its timeout to the duration specified when the message was created.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
timeout -- Optio... | [
"def",
"touch",
"(",
"self",
",",
"message_id",
",",
"reservation_id",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"\"queues/%s/messages/%s/touch\"",
"%",
"(",
"self",
".",
"name",
",",
"message_id",
")",
"qitems",
"=",
"{",
"'reservation_id'",
":",
... | Touching a reserved message extends its timeout to the duration specified when the message was created.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
timeout -- Optional. The timeout in seconds after which new reservation will expire. | [
"Touching",
"a",
"reserved",
"message",
"extends",
"its",
"timeout",
"to",
"the",
"duration",
"specified",
"when",
"the",
"message",
"was",
"created",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L177-L194 | train |
iron-io/iron_mq_python | iron_mq.py | Queue.release | def release(self, message_id, reservation_id, delay=0):
"""Release locked message after specified time. If there is no message with such id on the queue.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
delay -- The time after whic... | python | def release(self, message_id, reservation_id, delay=0):
"""Release locked message after specified time. If there is no message with such id on the queue.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
delay -- The time after whic... | [
"def",
"release",
"(",
"self",
",",
"message_id",
",",
"reservation_id",
",",
"delay",
"=",
"0",
")",
":",
"url",
"=",
"\"queues/%s/messages/%s/release\"",
"%",
"(",
"self",
".",
"name",
",",
"message_id",
")",
"body",
"=",
"{",
"'reservation_id'",
":",
"r... | Release locked message after specified time. If there is no message with such id on the queue.
Arguments:
message_id -- The ID of the message.
reservation_id -- Reservation Id of the message.
delay -- The time after which the message will be released. | [
"Release",
"locked",
"message",
"after",
"specified",
"time",
".",
"If",
"there",
"is",
"no",
"message",
"with",
"such",
"id",
"on",
"the",
"queue",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L196-L213 | train |
iron-io/iron_mq_python | iron_mq.py | IronMQ.queues | def queues(self, page=None, per_page=None, previous=None, prefix=None):
"""Execute an HTTP request to get a list of queues and return it.
Keyword arguments:
page -- The 0-based page to get queues from. Defaults to None, which
omits the parameter.
"""
options = {}... | python | def queues(self, page=None, per_page=None, previous=None, prefix=None):
"""Execute an HTTP request to get a list of queues and return it.
Keyword arguments:
page -- The 0-based page to get queues from. Defaults to None, which
omits the parameter.
"""
options = {}... | [
"def",
"queues",
"(",
"self",
",",
"page",
"=",
"None",
",",
"per_page",
"=",
"None",
",",
"previous",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"options",
"=",
"{",
"}",
"if",
"page",
"is",
"not",
"None",
":",
"raise",
"Exception",
"(",
... | Execute an HTTP request to get a list of queues and return it.
Keyword arguments:
page -- The 0-based page to get queues from. Defaults to None, which
omits the parameter. | [
"Execute",
"an",
"HTTP",
"request",
"to",
"get",
"a",
"list",
"of",
"queues",
"and",
"return",
"it",
"."
] | d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7 | https://github.com/iron-io/iron_mq_python/blob/d6a293f0d54b4ca2dca1c335f9867cd2310f6fc7/iron_mq.py#L318-L341 | train |
cltl/KafNafParserPy | KafNafParserPy/time_data.py | CtimeExpressions.get_timex | def get_timex(self, timex_id):
"""
Returns the timex object for the supplied identifier
@type timex_id: string
@param timex_id: timex identifier
"""
if timex_id in self.idx:
return Ctime(self.idx[timex_id])
else:
return None | python | def get_timex(self, timex_id):
"""
Returns the timex object for the supplied identifier
@type timex_id: string
@param timex_id: timex identifier
"""
if timex_id in self.idx:
return Ctime(self.idx[timex_id])
else:
return None | [
"def",
"get_timex",
"(",
"self",
",",
"timex_id",
")",
":",
"if",
"timex_id",
"in",
"self",
".",
"idx",
":",
"return",
"Ctime",
"(",
"self",
".",
"idx",
"[",
"timex_id",
"]",
")",
"else",
":",
"return",
"None"
] | Returns the timex object for the supplied identifier
@type timex_id: string
@param timex_id: timex identifier | [
"Returns",
"the",
"timex",
"object",
"for",
"the",
"supplied",
"identifier"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/time_data.py#L346-L355 | train |
cltl/KafNafParserPy | KafNafParserPy/time_data.py | CtimeExpressions.add_timex | def add_timex(self, timex_obj):
"""
Adds a timex object to the layer.
@type timex_obj: L{Ctime}
@param timex_obj: the timex object
"""
timex_id = timex_obj.get_id()
#check if id is not already present
if not timex_id in self.idx:
t... | python | def add_timex(self, timex_obj):
"""
Adds a timex object to the layer.
@type timex_obj: L{Ctime}
@param timex_obj: the timex object
"""
timex_id = timex_obj.get_id()
#check if id is not already present
if not timex_id in self.idx:
t... | [
"def",
"add_timex",
"(",
"self",
",",
"timex_obj",
")",
":",
"timex_id",
"=",
"timex_obj",
".",
"get_id",
"(",
")",
"#check if id is not already present",
"if",
"not",
"timex_id",
"in",
"self",
".",
"idx",
":",
"timex_node",
"=",
"timex_obj",
".",
"get_node",
... | Adds a timex object to the layer.
@type timex_obj: L{Ctime}
@param timex_obj: the timex object | [
"Adds",
"a",
"timex",
"object",
"to",
"the",
"layer",
"."
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/time_data.py#L367-L383 | train |
sio2project/filetracker | filetracker/scripts/recover.py | ensure_storage_format | def ensure_storage_format(root_dir):
"""Checks if the directory looks like a filetracker storage.
Exits with error if it doesn't.
"""
if not os.path.isdir(os.path.join(root_dir, 'blobs')):
print('"blobs/" directory not found')
sys.exit(1)
if not os.path.isdir(os.path.join(root_... | python | def ensure_storage_format(root_dir):
"""Checks if the directory looks like a filetracker storage.
Exits with error if it doesn't.
"""
if not os.path.isdir(os.path.join(root_dir, 'blobs')):
print('"blobs/" directory not found')
sys.exit(1)
if not os.path.isdir(os.path.join(root_... | [
"def",
"ensure_storage_format",
"(",
"root_dir",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root_dir",
",",
"'blobs'",
")",
")",
":",
"print",
"(",
"'\"blobs/\" directory not found'",
")",
"sys",
".... | Checks if the directory looks like a filetracker storage.
Exits with error if it doesn't. | [
"Checks",
"if",
"the",
"directory",
"looks",
"like",
"a",
"filetracker",
"storage",
".",
"Exits",
"with",
"error",
"if",
"it",
"doesn",
"t",
"."
] | 359b474850622e3d0c25ee2596d7242c02f84efb | https://github.com/sio2project/filetracker/blob/359b474850622e3d0c25ee2596d7242c02f84efb/filetracker/scripts/recover.py#L132-L147 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/constituency.py | Cconstituency_extractor.get_deepest_phrase_for_termid | def get_deepest_phrase_for_termid(self,termid):
"""
Returns the deepest phrase type for the term identifier and the list of subsumed by the same element
@type termid: string
@param termid: term identifier
@rtype: (string,list)
@return: the label and list of terms subsumed... | python | def get_deepest_phrase_for_termid(self,termid):
"""
Returns the deepest phrase type for the term identifier and the list of subsumed by the same element
@type termid: string
@param termid: term identifier
@rtype: (string,list)
@return: the label and list of terms subsumed... | [
"def",
"get_deepest_phrase_for_termid",
"(",
"self",
",",
"termid",
")",
":",
"terminal_id",
"=",
"self",
".",
"terminal_for_term",
".",
"get",
"(",
"termid",
")",
"label",
"=",
"None",
"subsumed",
"=",
"[",
"]",
"if",
"terminal_id",
"is",
"not",
"None",
"... | Returns the deepest phrase type for the term identifier and the list of subsumed by the same element
@type termid: string
@param termid: term identifier
@rtype: (string,list)
@return: the label and list of terms subsumed | [
"Returns",
"the",
"deepest",
"phrase",
"type",
"for",
"the",
"term",
"identifier",
"and",
"the",
"list",
"of",
"subsumed",
"by",
"the",
"same",
"element"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L89-L105 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/constituency.py | Cconstituency_extractor.get_least_common_subsumer | def get_least_common_subsumer(self,from_tid,to_tid):
"""
Returns the deepest common subsumer among two terms
@type from_tid: string
@param from_tid: one term id
@type to_tid: string
@param to_tid: another term id
@rtype: string
@return: the term identifier... | python | def get_least_common_subsumer(self,from_tid,to_tid):
"""
Returns the deepest common subsumer among two terms
@type from_tid: string
@param from_tid: one term id
@type to_tid: string
@param to_tid: another term id
@rtype: string
@return: the term identifier... | [
"def",
"get_least_common_subsumer",
"(",
"self",
",",
"from_tid",
",",
"to_tid",
")",
":",
"termid_from",
"=",
"self",
".",
"terminal_for_term",
".",
"get",
"(",
"from_tid",
")",
"termid_to",
"=",
"self",
".",
"terminal_for_term",
".",
"get",
"(",
"to_tid",
... | Returns the deepest common subsumer among two terms
@type from_tid: string
@param from_tid: one term id
@type to_tid: string
@param to_tid: another term id
@rtype: string
@return: the term identifier of the common subsumer | [
"Returns",
"the",
"deepest",
"common",
"subsumer",
"among",
"two",
"terms"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L108-L134 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/constituency.py | Cconstituency_extractor.get_deepest_subsumer | def get_deepest_subsumer(self,list_terms):
'''
Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided
'''
#To store with how many terms every nonterminal appears
count_per_no_terminal = defaultdict(int)
#To ... | python | def get_deepest_subsumer(self,list_terms):
'''
Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided
'''
#To store with how many terms every nonterminal appears
count_per_no_terminal = defaultdict(int)
#To ... | [
"def",
"get_deepest_subsumer",
"(",
"self",
",",
"list_terms",
")",
":",
"#To store with how many terms every nonterminal appears",
"count_per_no_terminal",
"=",
"defaultdict",
"(",
"int",
")",
"#To store the total deep of each noter for all the term ides (as we want the deepest)",
"... | Returns the labels of the deepest node that subsumes all the terms in the list of terms id's provided | [
"Returns",
"the",
"labels",
"of",
"the",
"deepest",
"node",
"that",
"subsumes",
"all",
"the",
"terms",
"in",
"the",
"list",
"of",
"terms",
"id",
"s",
"provided"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L218-L248 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/constituency.py | Cconstituency_extractor.get_chunks | def get_chunks(self,chunk_type):
"""
Returns the chunks for a certain type
@type chunk_type: string
@param chunk_type: type of the chunk
@rtype: list
@return: the chunks for that type
"""
for nonter,this_type in self.label_for_nonter.items():
i... | python | def get_chunks(self,chunk_type):
"""
Returns the chunks for a certain type
@type chunk_type: string
@param chunk_type: type of the chunk
@rtype: list
@return: the chunks for that type
"""
for nonter,this_type in self.label_for_nonter.items():
i... | [
"def",
"get_chunks",
"(",
"self",
",",
"chunk_type",
")",
":",
"for",
"nonter",
",",
"this_type",
"in",
"self",
".",
"label_for_nonter",
".",
"items",
"(",
")",
":",
"if",
"this_type",
"==",
"chunk_type",
":",
"subsumed",
"=",
"self",
".",
"terms_subsumed_... | Returns the chunks for a certain type
@type chunk_type: string
@param chunk_type: type of the chunk
@rtype: list
@return: the chunks for that type | [
"Returns",
"the",
"chunks",
"for",
"a",
"certain",
"type"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L270-L282 | train |
cltl/KafNafParserPy | KafNafParserPy/feature_extractor/constituency.py | Cconstituency_extractor.get_all_chunks_for_term | def get_all_chunks_for_term(self,termid):
"""
Returns all the chunks in which the term is contained
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of chunks
"""
terminal_id = self.terminal_for_term.get(termid)
pa... | python | def get_all_chunks_for_term(self,termid):
"""
Returns all the chunks in which the term is contained
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of chunks
"""
terminal_id = self.terminal_for_term.get(termid)
pa... | [
"def",
"get_all_chunks_for_term",
"(",
"self",
",",
"termid",
")",
":",
"terminal_id",
"=",
"self",
".",
"terminal_for_term",
".",
"get",
"(",
"termid",
")",
"paths",
"=",
"self",
".",
"paths_for_terminal",
"[",
"terminal_id",
"]",
"for",
"path",
"in",
"path... | Returns all the chunks in which the term is contained
@type termid: string
@param termid: the term identifier
@rtype: list
@return: list of chunks | [
"Returns",
"all",
"the",
"chunks",
"in",
"which",
"the",
"term",
"is",
"contained"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/feature_extractor/constituency.py#L331-L346 | train |
polysquare/cmake-ast | cmakeast/ast.py | _lookup_enum_in_ns | def _lookup_enum_in_ns(namespace, value):
"""Return the attribute of namespace corresponding to value."""
for attribute in dir(namespace):
if getattr(namespace, attribute) == value:
return attribute | python | def _lookup_enum_in_ns(namespace, value):
"""Return the attribute of namespace corresponding to value."""
for attribute in dir(namespace):
if getattr(namespace, attribute) == value:
return attribute | [
"def",
"_lookup_enum_in_ns",
"(",
"namespace",
",",
"value",
")",
":",
"for",
"attribute",
"in",
"dir",
"(",
"namespace",
")",
":",
"if",
"getattr",
"(",
"namespace",
",",
"attribute",
")",
"==",
"value",
":",
"return",
"attribute"
] | Return the attribute of namespace corresponding to value. | [
"Return",
"the",
"attribute",
"of",
"namespace",
"corresponding",
"to",
"value",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L88-L92 | train |
polysquare/cmake-ast | cmakeast/ast.py | _is_word_type | def _is_word_type(token_type):
"""Return true if this is a word-type token."""
return token_type in [TokenType.Word,
TokenType.QuotedLiteral,
TokenType.UnquotedLiteral,
TokenType.Number,
TokenType.Deref] | python | def _is_word_type(token_type):
"""Return true if this is a word-type token."""
return token_type in [TokenType.Word,
TokenType.QuotedLiteral,
TokenType.UnquotedLiteral,
TokenType.Number,
TokenType.Deref] | [
"def",
"_is_word_type",
"(",
"token_type",
")",
":",
"return",
"token_type",
"in",
"[",
"TokenType",
".",
"Word",
",",
"TokenType",
".",
"QuotedLiteral",
",",
"TokenType",
".",
"UnquotedLiteral",
",",
"TokenType",
".",
"Number",
",",
"TokenType",
".",
"Deref",... | Return true if this is a word-type token. | [
"Return",
"true",
"if",
"this",
"is",
"a",
"word",
"-",
"type",
"token",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L174-L180 | train |
polysquare/cmake-ast | cmakeast/ast.py | _is_in_comment_type | def _is_in_comment_type(token_type):
"""Return true if this kind of token can be inside a comment."""
return token_type in [TokenType.Comment,
TokenType.Newline,
TokenType.Whitespace,
TokenType.RST,
TokenType... | python | def _is_in_comment_type(token_type):
"""Return true if this kind of token can be inside a comment."""
return token_type in [TokenType.Comment,
TokenType.Newline,
TokenType.Whitespace,
TokenType.RST,
TokenType... | [
"def",
"_is_in_comment_type",
"(",
"token_type",
")",
":",
"return",
"token_type",
"in",
"[",
"TokenType",
".",
"Comment",
",",
"TokenType",
".",
"Newline",
",",
"TokenType",
".",
"Whitespace",
",",
"TokenType",
".",
"RST",
",",
"TokenType",
".",
"BeginRSTComm... | Return true if this kind of token can be inside a comment. | [
"Return",
"true",
"if",
"this",
"kind",
"of",
"token",
"can",
"be",
"inside",
"a",
"comment",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L183-L191 | train |
polysquare/cmake-ast | cmakeast/ast.py | _get_string_type_from_token | def _get_string_type_from_token(token_type):
"""Return 'Single' or 'Double' depending on what kind of string this is."""
return_value = None
if token_type in [TokenType.BeginSingleQuotedLiteral,
TokenType.EndSingleQuotedLiteral]:
return_value = "Single"
elif token_type in [... | python | def _get_string_type_from_token(token_type):
"""Return 'Single' or 'Double' depending on what kind of string this is."""
return_value = None
if token_type in [TokenType.BeginSingleQuotedLiteral,
TokenType.EndSingleQuotedLiteral]:
return_value = "Single"
elif token_type in [... | [
"def",
"_get_string_type_from_token",
"(",
"token_type",
")",
":",
"return_value",
"=",
"None",
"if",
"token_type",
"in",
"[",
"TokenType",
".",
"BeginSingleQuotedLiteral",
",",
"TokenType",
".",
"EndSingleQuotedLiteral",
"]",
":",
"return_value",
"=",
"\"Single\"",
... | Return 'Single' or 'Double' depending on what kind of string this is. | [
"Return",
"Single",
"or",
"Double",
"depending",
"on",
"what",
"kind",
"of",
"string",
"this",
"is",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L212-L223 | train |
polysquare/cmake-ast | cmakeast/ast.py | _make_header_body_handler | def _make_header_body_handler(end_body_regex,
node_factory,
has_footer=True):
"""Utility function to make a handler for header-body node.
A header-body node is any node which has a single function-call
header and a body of statements inside of it
... | python | def _make_header_body_handler(end_body_regex,
node_factory,
has_footer=True):
"""Utility function to make a handler for header-body node.
A header-body node is any node which has a single function-call
header and a body of statements inside of it
... | [
"def",
"_make_header_body_handler",
"(",
"end_body_regex",
",",
"node_factory",
",",
"has_footer",
"=",
"True",
")",
":",
"def",
"handler",
"(",
"tokens",
",",
"tokens_len",
",",
"body_index",
",",
"function_call",
")",
":",
"\"\"\"Handler function.\"\"\"",
"def",
... | Utility function to make a handler for header-body node.
A header-body node is any node which has a single function-call
header and a body of statements inside of it | [
"Utility",
"function",
"to",
"make",
"a",
"handler",
"for",
"header",
"-",
"body",
"node",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L248-L289 | train |
polysquare/cmake-ast | cmakeast/ast.py | _handle_if_block | def _handle_if_block(tokens, tokens_len, body_index, function_call):
"""Special handler for if-blocks.
If blocks are special because they can have multiple bodies and have
multiple terminating keywords for each of those sub-bodies
"""
# First handle the if statement and body
next_index, if_stat... | python | def _handle_if_block(tokens, tokens_len, body_index, function_call):
"""Special handler for if-blocks.
If blocks are special because they can have multiple bodies and have
multiple terminating keywords for each of those sub-bodies
"""
# First handle the if statement and body
next_index, if_stat... | [
"def",
"_handle_if_block",
"(",
"tokens",
",",
"tokens_len",
",",
"body_index",
",",
"function_call",
")",
":",
"# First handle the if statement and body",
"next_index",
",",
"if_statement",
"=",
"_IF_BLOCK_IF_HANDLER",
"(",
"tokens",
",",
"tokens_len",
",",
"body_index... | Special handler for if-blocks.
If blocks are special because they can have multiple bodies and have
multiple terminating keywords for each of those sub-bodies | [
"Special",
"handler",
"for",
"if",
"-",
"blocks",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L302-L355 | train |
polysquare/cmake-ast | cmakeast/ast.py | _handle_function_call | def _handle_function_call(tokens, tokens_len, index):
"""Handle function calls, which could include a control statement.
In CMake, all control flow statements are also function calls, so handle
the function call first and then direct tree construction to the
appropriate control flow statement construct... | python | def _handle_function_call(tokens, tokens_len, index):
"""Handle function calls, which could include a control statement.
In CMake, all control flow statements are also function calls, so handle
the function call first and then direct tree construction to the
appropriate control flow statement construct... | [
"def",
"_handle_function_call",
"(",
"tokens",
",",
"tokens_len",
",",
"index",
")",
":",
"def",
"_end_function_call",
"(",
"token_index",
",",
"tokens",
")",
":",
"\"\"\"Function call termination detector.\"\"\"",
"return",
"tokens",
"[",
"token_index",
"]",
".",
"... | Handle function calls, which could include a control statement.
In CMake, all control flow statements are also function calls, so handle
the function call first and then direct tree construction to the
appropriate control flow statement constructor found in
_FUNCTION_CALL_DISAMBIGUATE | [
"Handle",
"function",
"calls",
"which",
"could",
"include",
"a",
"control",
"statement",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L368-L400 | train |
polysquare/cmake-ast | cmakeast/ast.py | _ast_worker | def _ast_worker(tokens, tokens_len, index, term):
"""The main collector for all AST functions.
This function is called recursively to find both variable use and function
calls and returns a GenericBody with both those variables and function
calls hanging off of it. The caller can figure out what to do ... | python | def _ast_worker(tokens, tokens_len, index, term):
"""The main collector for all AST functions.
This function is called recursively to find both variable use and function
calls and returns a GenericBody with both those variables and function
calls hanging off of it. The caller can figure out what to do ... | [
"def",
"_ast_worker",
"(",
"tokens",
",",
"tokens_len",
",",
"index",
",",
"term",
")",
":",
"statements",
"=",
"[",
"]",
"arguments",
"=",
"[",
"]",
"while",
"index",
"<",
"tokens_len",
":",
"if",
"term",
":",
"if",
"term",
"(",
"index",
",",
"token... | The main collector for all AST functions.
This function is called recursively to find both variable use and function
calls and returns a GenericBody with both those variables and function
calls hanging off of it. The caller can figure out what to do with both of
those | [
"The",
"main",
"collector",
"for",
"all",
"AST",
"functions",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L403-L438 | train |
polysquare/cmake-ast | cmakeast/ast.py | _scan_for_tokens | def _scan_for_tokens(contents):
"""Scan a string for tokens and return immediate form tokens."""
# Regexes are in priority order. Changing the order may alter the
# behavior of the lexer
scanner = re.Scanner([
# Things inside quotes
(r"(?<![^\s\(])([\"\'])(?:(?=(\\?))\2.)*?\1(?![^\s\)])"... | python | def _scan_for_tokens(contents):
"""Scan a string for tokens and return immediate form tokens."""
# Regexes are in priority order. Changing the order may alter the
# behavior of the lexer
scanner = re.Scanner([
# Things inside quotes
(r"(?<![^\s\(])([\"\'])(?:(?=(\\?))\2.)*?\1(?![^\s\)])"... | [
"def",
"_scan_for_tokens",
"(",
"contents",
")",
":",
"# Regexes are in priority order. Changing the order may alter the",
"# behavior of the lexer",
"scanner",
"=",
"re",
".",
"Scanner",
"(",
"[",
"# Things inside quotes",
"(",
"r\"(?<![^\\s\\(])([\\\"\\'])(?:(?=(\\\\?))\\2.)*?\\1... | Scan a string for tokens and return immediate form tokens. | [
"Scan",
"a",
"string",
"for",
"tokens",
"and",
"return",
"immediate",
"form",
"tokens",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L441-L513 | train |
polysquare/cmake-ast | cmakeast/ast.py | _replace_token_range | def _replace_token_range(tokens, start, end, replacement):
"""For a range indicated from start to end, replace with replacement."""
tokens = tokens[:start] + replacement + tokens[end:]
return tokens | python | def _replace_token_range(tokens, start, end, replacement):
"""For a range indicated from start to end, replace with replacement."""
tokens = tokens[:start] + replacement + tokens[end:]
return tokens | [
"def",
"_replace_token_range",
"(",
"tokens",
",",
"start",
",",
"end",
",",
"replacement",
")",
":",
"tokens",
"=",
"tokens",
"[",
":",
"start",
"]",
"+",
"replacement",
"+",
"tokens",
"[",
"end",
":",
"]",
"return",
"tokens"
] | For a range indicated from start to end, replace with replacement. | [
"For",
"a",
"range",
"indicated",
"from",
"start",
"to",
"end",
"replace",
"with",
"replacement",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L516-L519 | train |
polysquare/cmake-ast | cmakeast/ast.py | _is_really_comment | def _is_really_comment(tokens, index):
"""Return true if the token at index is really a comment."""
if tokens[index].type == TokenType.Comment:
return True
# Really a comment in disguise!
try:
if tokens[index].content.lstrip()[0] == "#":
return True
except IndexError:
... | python | def _is_really_comment(tokens, index):
"""Return true if the token at index is really a comment."""
if tokens[index].type == TokenType.Comment:
return True
# Really a comment in disguise!
try:
if tokens[index].content.lstrip()[0] == "#":
return True
except IndexError:
... | [
"def",
"_is_really_comment",
"(",
"tokens",
",",
"index",
")",
":",
"if",
"tokens",
"[",
"index",
"]",
".",
"type",
"==",
"TokenType",
".",
"Comment",
":",
"return",
"True",
"# Really a comment in disguise!",
"try",
":",
"if",
"tokens",
"[",
"index",
"]",
... | Return true if the token at index is really a comment. | [
"Return",
"true",
"if",
"the",
"token",
"at",
"index",
"is",
"really",
"a",
"comment",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L522-L532 | train |
polysquare/cmake-ast | cmakeast/ast.py | _paste_tokens_line_by_line | def _paste_tokens_line_by_line(tokens, token_type, begin, end):
"""Return lines of tokens pasted together, line by line."""
block_index = begin
while block_index < end:
rst_line = tokens[block_index].line
line_traversal_index = block_index
pasted = ""
try:
while ... | python | def _paste_tokens_line_by_line(tokens, token_type, begin, end):
"""Return lines of tokens pasted together, line by line."""
block_index = begin
while block_index < end:
rst_line = tokens[block_index].line
line_traversal_index = block_index
pasted = ""
try:
while ... | [
"def",
"_paste_tokens_line_by_line",
"(",
"tokens",
",",
"token_type",
",",
"begin",
",",
"end",
")",
":",
"block_index",
"=",
"begin",
"while",
"block_index",
"<",
"end",
":",
"rst_line",
"=",
"tokens",
"[",
"block_index",
"]",
".",
"line",
"line_traversal_in... | Return lines of tokens pasted together, line by line. | [
"Return",
"lines",
"of",
"tokens",
"pasted",
"together",
"line",
"by",
"line",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L585-L611 | train |
polysquare/cmake-ast | cmakeast/ast.py | _find_recorder | def _find_recorder(recorder, tokens, index):
"""Given a current recorder and a token index, try to find a recorder."""
if recorder is None:
# See if we can start recording something
for recorder_factory in _RECORDERS:
recorder = recorder_factory.maybe_start_recording(tokens,
... | python | def _find_recorder(recorder, tokens, index):
"""Given a current recorder and a token index, try to find a recorder."""
if recorder is None:
# See if we can start recording something
for recorder_factory in _RECORDERS:
recorder = recorder_factory.maybe_start_recording(tokens,
... | [
"def",
"_find_recorder",
"(",
"recorder",
",",
"tokens",
",",
"index",
")",
":",
"if",
"recorder",
"is",
"None",
":",
"# See if we can start recording something",
"for",
"recorder_factory",
"in",
"_RECORDERS",
":",
"recorder",
"=",
"recorder_factory",
".",
"maybe_st... | Given a current recorder and a token index, try to find a recorder. | [
"Given",
"a",
"current",
"recorder",
"and",
"a",
"token",
"index",
"try",
"to",
"find",
"a",
"recorder",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L814-L824 | train |
polysquare/cmake-ast | cmakeast/ast.py | _compress_tokens | def _compress_tokens(tokens):
"""Paste multi-line strings, comments, RST etc together.
This function works by iterating over each over the _RECORDERS to determine
if we should start recording a token sequence for pasting together. If
it finds one, then we keep recording until that recorder is done and
... | python | def _compress_tokens(tokens):
"""Paste multi-line strings, comments, RST etc together.
This function works by iterating over each over the _RECORDERS to determine
if we should start recording a token sequence for pasting together. If
it finds one, then we keep recording until that recorder is done and
... | [
"def",
"_compress_tokens",
"(",
"tokens",
")",
":",
"recorder",
"=",
"None",
"def",
"_edge_case_stray_end_quoted",
"(",
"tokens",
",",
"index",
")",
":",
"\"\"\"Convert stray end_quoted_literals to unquoted_literals.\"\"\"",
"# In this case, \"tokenize\" the matched token into wh... | Paste multi-line strings, comments, RST etc together.
This function works by iterating over each over the _RECORDERS to determine
if we should start recording a token sequence for pasting together. If
it finds one, then we keep recording until that recorder is done and
returns a pasted together token s... | [
"Paste",
"multi",
"-",
"line",
"strings",
"comments",
"RST",
"etc",
"together",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L827-L880 | train |
polysquare/cmake-ast | cmakeast/ast.py | tokenize | def tokenize(contents):
"""Parse a string called contents for CMake tokens."""
tokens = _scan_for_tokens(contents)
tokens = _compress_tokens(tokens)
tokens = [token for token in tokens if token.type != TokenType.Whitespace]
return tokens | python | def tokenize(contents):
"""Parse a string called contents for CMake tokens."""
tokens = _scan_for_tokens(contents)
tokens = _compress_tokens(tokens)
tokens = [token for token in tokens if token.type != TokenType.Whitespace]
return tokens | [
"def",
"tokenize",
"(",
"contents",
")",
":",
"tokens",
"=",
"_scan_for_tokens",
"(",
"contents",
")",
"tokens",
"=",
"_compress_tokens",
"(",
"tokens",
")",
"tokens",
"=",
"[",
"token",
"for",
"token",
"in",
"tokens",
"if",
"token",
".",
"type",
"!=",
"... | Parse a string called contents for CMake tokens. | [
"Parse",
"a",
"string",
"called",
"contents",
"for",
"CMake",
"tokens",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L883-L888 | train |
polysquare/cmake-ast | cmakeast/ast.py | parse | def parse(contents, tokens=None):
"""Parse a string called contents for an AST and return it."""
# Shortcut for users who are interested in tokens
if tokens is None:
tokens = [t for t in tokenize(contents)]
token_index, body = _ast_worker(tokens, len(tokens), 0, None)
assert token_index ==... | python | def parse(contents, tokens=None):
"""Parse a string called contents for an AST and return it."""
# Shortcut for users who are interested in tokens
if tokens is None:
tokens = [t for t in tokenize(contents)]
token_index, body = _ast_worker(tokens, len(tokens), 0, None)
assert token_index ==... | [
"def",
"parse",
"(",
"contents",
",",
"tokens",
"=",
"None",
")",
":",
"# Shortcut for users who are interested in tokens",
"if",
"tokens",
"is",
"None",
":",
"tokens",
"=",
"[",
"t",
"for",
"t",
"in",
"tokenize",
"(",
"contents",
")",
"]",
"token_index",
",... | Parse a string called contents for an AST and return it. | [
"Parse",
"a",
"string",
"called",
"contents",
"for",
"an",
"AST",
"and",
"return",
"it",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L891-L902 | train |
polysquare/cmake-ast | cmakeast/ast.py | _CommentedLineRecorder.maybe_start_recording | def maybe_start_recording(tokens, index):
"""Return a new _CommentedLineRecorder when it is time to record."""
if _is_really_comment(tokens, index):
return _CommentedLineRecorder(index, tokens[index].line)
return None | python | def maybe_start_recording(tokens, index):
"""Return a new _CommentedLineRecorder when it is time to record."""
if _is_really_comment(tokens, index):
return _CommentedLineRecorder(index, tokens[index].line)
return None | [
"def",
"maybe_start_recording",
"(",
"tokens",
",",
"index",
")",
":",
"if",
"_is_really_comment",
"(",
"tokens",
",",
"index",
")",
":",
"return",
"_CommentedLineRecorder",
"(",
"index",
",",
"tokens",
"[",
"index",
"]",
".",
"line",
")",
"return",
"None"
] | Return a new _CommentedLineRecorder when it is time to record. | [
"Return",
"a",
"new",
"_CommentedLineRecorder",
"when",
"it",
"is",
"time",
"to",
"record",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L545-L550 | train |
polysquare/cmake-ast | cmakeast/ast.py | _RSTCommentBlockRecorder.maybe_start_recording | def maybe_start_recording(tokens, index):
"""Return a new _RSTCommentBlockRecorder when its time to record."""
if tokens[index].type == TokenType.BeginRSTComment:
return _RSTCommentBlockRecorder(index, tokens[index].line)
return None | python | def maybe_start_recording(tokens, index):
"""Return a new _RSTCommentBlockRecorder when its time to record."""
if tokens[index].type == TokenType.BeginRSTComment:
return _RSTCommentBlockRecorder(index, tokens[index].line)
return None | [
"def",
"maybe_start_recording",
"(",
"tokens",
",",
"index",
")",
":",
"if",
"tokens",
"[",
"index",
"]",
".",
"type",
"==",
"TokenType",
".",
"BeginRSTComment",
":",
"return",
"_RSTCommentBlockRecorder",
"(",
"index",
",",
"tokens",
"[",
"index",
"]",
".",
... | Return a new _RSTCommentBlockRecorder when its time to record. | [
"Return",
"a",
"new",
"_RSTCommentBlockRecorder",
"when",
"its",
"time",
"to",
"record",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L624-L629 | train |
polysquare/cmake-ast | cmakeast/ast.py | _InlineRSTRecorder.maybe_start_recording | def maybe_start_recording(tokens, index):
"""Return a new _InlineRSTRecorder when its time to record."""
if tokens[index].type == TokenType.BeginInlineRST:
return _InlineRSTRecorder(index) | python | def maybe_start_recording(tokens, index):
"""Return a new _InlineRSTRecorder when its time to record."""
if tokens[index].type == TokenType.BeginInlineRST:
return _InlineRSTRecorder(index) | [
"def",
"maybe_start_recording",
"(",
"tokens",
",",
"index",
")",
":",
"if",
"tokens",
"[",
"index",
"]",
".",
"type",
"==",
"TokenType",
".",
"BeginInlineRST",
":",
"return",
"_InlineRSTRecorder",
"(",
"index",
")"
] | Return a new _InlineRSTRecorder when its time to record. | [
"Return",
"a",
"new",
"_InlineRSTRecorder",
"when",
"its",
"time",
"to",
"record",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L666-L669 | train |
polysquare/cmake-ast | cmakeast/ast.py | _MultilineStringRecorder.maybe_start_recording | def maybe_start_recording(tokens, index):
"""Return a new _MultilineStringRecorder when its time to record."""
if _is_begin_quoted_type(tokens[index].type):
string_type = _get_string_type_from_token(tokens[index].type)
return _MultilineStringRecorder(index, string_type)
... | python | def maybe_start_recording(tokens, index):
"""Return a new _MultilineStringRecorder when its time to record."""
if _is_begin_quoted_type(tokens[index].type):
string_type = _get_string_type_from_token(tokens[index].type)
return _MultilineStringRecorder(index, string_type)
... | [
"def",
"maybe_start_recording",
"(",
"tokens",
",",
"index",
")",
":",
"if",
"_is_begin_quoted_type",
"(",
"tokens",
"[",
"index",
"]",
".",
"type",
")",
":",
"string_type",
"=",
"_get_string_type_from_token",
"(",
"tokens",
"[",
"index",
"]",
".",
"type",
"... | Return a new _MultilineStringRecorder when its time to record. | [
"Return",
"a",
"new",
"_MultilineStringRecorder",
"when",
"its",
"time",
"to",
"record",
"."
] | 431a32d595d76f1f8f993eb6ddcc79effbadff9d | https://github.com/polysquare/cmake-ast/blob/431a32d595d76f1f8f993eb6ddcc79effbadff9d/cmakeast/ast.py#L696-L702 | train |
vmonaco/pohmm | examples/keystroke.py | stratified_kfold | def stratified_kfold(df, n_folds):
"""
Create stratified k-folds from an indexed dataframe
"""
sessions = pd.DataFrame.from_records(list(df.index.unique())).groupby(0).apply(lambda x: x[1].unique())
sessions.apply(lambda x: np.random.shuffle(x))
folds = []
for i in range(n_folds):
id... | python | def stratified_kfold(df, n_folds):
"""
Create stratified k-folds from an indexed dataframe
"""
sessions = pd.DataFrame.from_records(list(df.index.unique())).groupby(0).apply(lambda x: x[1].unique())
sessions.apply(lambda x: np.random.shuffle(x))
folds = []
for i in range(n_folds):
id... | [
"def",
"stratified_kfold",
"(",
"df",
",",
"n_folds",
")",
":",
"sessions",
"=",
"pd",
".",
"DataFrame",
".",
"from_records",
"(",
"list",
"(",
"df",
".",
"index",
".",
"unique",
"(",
")",
")",
")",
".",
"groupby",
"(",
"0",
")",
".",
"apply",
"(",... | Create stratified k-folds from an indexed dataframe | [
"Create",
"stratified",
"k",
"-",
"folds",
"from",
"an",
"indexed",
"dataframe"
] | c00f8a62d3005a171d424549a55d46c421859ae9 | https://github.com/vmonaco/pohmm/blob/c00f8a62d3005a171d424549a55d46c421859ae9/examples/keystroke.py#L15-L26 | train |
vmonaco/pohmm | examples/keystroke.py | keystroke_model | def keystroke_model():
"""Generates a 2-state model with lognormal emissions and frequency smoothing"""
model = Pohmm(n_hidden_states=2,
init_spread=2,
emissions=['lognormal', 'lognormal'],
smoothing='freq',
init_method='obs',
... | python | def keystroke_model():
"""Generates a 2-state model with lognormal emissions and frequency smoothing"""
model = Pohmm(n_hidden_states=2,
init_spread=2,
emissions=['lognormal', 'lognormal'],
smoothing='freq',
init_method='obs',
... | [
"def",
"keystroke_model",
"(",
")",
":",
"model",
"=",
"Pohmm",
"(",
"n_hidden_states",
"=",
"2",
",",
"init_spread",
"=",
"2",
",",
"emissions",
"=",
"[",
"'lognormal'",
",",
"'lognormal'",
"]",
",",
"smoothing",
"=",
"'freq'",
",",
"init_method",
"=",
... | Generates a 2-state model with lognormal emissions and frequency smoothing | [
"Generates",
"a",
"2",
"-",
"state",
"model",
"with",
"lognormal",
"emissions",
"and",
"frequency",
"smoothing"
] | c00f8a62d3005a171d424549a55d46c421859ae9 | https://github.com/vmonaco/pohmm/blob/c00f8a62d3005a171d424549a55d46c421859ae9/examples/keystroke.py#L123-L131 | train |
teepark/greenhouse | greenhouse/backdoor.py | run_backdoor | def run_backdoor(address, namespace=None):
"""start a server that runs python interpreters on connections made to it
.. note::
this function blocks effectively indefinitely -- it runs the listening
socket loop in the current greenlet. to keep the current greenlet free,
:func:`schedule<... | python | def run_backdoor(address, namespace=None):
"""start a server that runs python interpreters on connections made to it
.. note::
this function blocks effectively indefinitely -- it runs the listening
socket loop in the current greenlet. to keep the current greenlet free,
:func:`schedule<... | [
"def",
"run_backdoor",
"(",
"address",
",",
"namespace",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"starting on %r\"",
"%",
"(",
"address",
",",
")",
")",
"serversock",
"=",
"io",
".",
"Socket",
"(",
")",
"serversock",
".",
"setsockopt",
"(",
"... | start a server that runs python interpreters on connections made to it
.. note::
this function blocks effectively indefinitely -- it runs the listening
socket loop in the current greenlet. to keep the current greenlet free,
:func:`schedule<greenhouse.scheduler.schedule>` this function.
... | [
"start",
"a",
"server",
"that",
"runs",
"python",
"interpreters",
"on",
"connections",
"made",
"to",
"it"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/backdoor.py#L40-L67 | train |
teepark/greenhouse | greenhouse/backdoor.py | backdoor_handler | def backdoor_handler(clientsock, namespace=None):
"""start an interactive python interpreter on an existing connection
.. note::
this function will block for as long as the connection remains alive.
:param sock: the socket on which to serve the interpreter
:type sock: :class:`Socket<greenhouse... | python | def backdoor_handler(clientsock, namespace=None):
"""start an interactive python interpreter on an existing connection
.. note::
this function will block for as long as the connection remains alive.
:param sock: the socket on which to serve the interpreter
:type sock: :class:`Socket<greenhouse... | [
"def",
"backdoor_handler",
"(",
"clientsock",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"{",
"}",
"if",
"namespace",
"is",
"None",
"else",
"namespace",
".",
"copy",
"(",
")",
"console",
"=",
"code",
".",
"InteractiveConsole",
"(",
"namespa... | start an interactive python interpreter on an existing connection
.. note::
this function will block for as long as the connection remains alive.
:param sock: the socket on which to serve the interpreter
:type sock: :class:`Socket<greenhouse.io.sockets.Socket>`
:param namespace:
the lo... | [
"start",
"an",
"interactive",
"python",
"interpreter",
"on",
"an",
"existing",
"connection"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/backdoor.py#L70-L112 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.prepare_params | def prepare_params(self):
"""
Prepare the parameters passed to the templatetag
"""
if self.options.resolve_fragment:
self.fragment_name = self.node.fragment_name.resolve(self.context)
else:
self.fragment_name = str(self.node.fragment_name)
# Re... | python | def prepare_params(self):
"""
Prepare the parameters passed to the templatetag
"""
if self.options.resolve_fragment:
self.fragment_name = self.node.fragment_name.resolve(self.context)
else:
self.fragment_name = str(self.node.fragment_name)
# Re... | [
"def",
"prepare_params",
"(",
"self",
")",
":",
"if",
"self",
".",
"options",
".",
"resolve_fragment",
":",
"self",
".",
"fragment_name",
"=",
"self",
".",
"node",
".",
"fragment_name",
".",
"resolve",
"(",
"self",
".",
"context",
")",
"else",
":",
"self... | Prepare the parameters passed to the templatetag | [
"Prepare",
"the",
"parameters",
"passed",
"to",
"the",
"templatetag"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L234-L256 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.get_expire_time | def get_expire_time(self):
"""
Return the expire time passed to the templatetag.
Must be None or an integer.
"""
try:
expire_time = self.node.expire_time.resolve(self.context)
except template.VariableDoesNotExist:
raise template.TemplateSyntaxError... | python | def get_expire_time(self):
"""
Return the expire time passed to the templatetag.
Must be None or an integer.
"""
try:
expire_time = self.node.expire_time.resolve(self.context)
except template.VariableDoesNotExist:
raise template.TemplateSyntaxError... | [
"def",
"get_expire_time",
"(",
"self",
")",
":",
"try",
":",
"expire_time",
"=",
"self",
".",
"node",
".",
"expire_time",
".",
"resolve",
"(",
"self",
".",
"context",
")",
"except",
"template",
".",
"VariableDoesNotExist",
":",
"raise",
"template",
".",
"T... | Return the expire time passed to the templatetag.
Must be None or an integer. | [
"Return",
"the",
"expire",
"time",
"passed",
"to",
"the",
"templatetag",
".",
"Must",
"be",
"None",
"or",
"an",
"integer",
"."
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L258-L281 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.get_version | def get_version(self):
"""
Return the stringified version passed to the templatetag.
"""
if not self.node.version:
return None
try:
version = smart_str('%s' % self.node.version.resolve(self.context))
except template.VariableDoesNotExist:
... | python | def get_version(self):
"""
Return the stringified version passed to the templatetag.
"""
if not self.node.version:
return None
try:
version = smart_str('%s' % self.node.version.resolve(self.context))
except template.VariableDoesNotExist:
... | [
"def",
"get_version",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"node",
".",
"version",
":",
"return",
"None",
"try",
":",
"version",
"=",
"smart_str",
"(",
"'%s'",
"%",
"self",
".",
"node",
".",
"version",
".",
"resolve",
"(",
"self",
".",
... | Return the stringified version passed to the templatetag. | [
"Return",
"the",
"stringified",
"version",
"passed",
"to",
"the",
"templatetag",
"."
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L283-L295 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.hash_args | def hash_args(self):
"""
Take all the arguments passed after the fragment name and return a
hashed version which will be used in the cache key
"""
return hashlib.md5(force_bytes(':'.join([urlquote(force_bytes(var)) for var in self.vary_on]))).hexdigest() | python | def hash_args(self):
"""
Take all the arguments passed after the fragment name and return a
hashed version which will be used in the cache key
"""
return hashlib.md5(force_bytes(':'.join([urlquote(force_bytes(var)) for var in self.vary_on]))).hexdigest() | [
"def",
"hash_args",
"(",
"self",
")",
":",
"return",
"hashlib",
".",
"md5",
"(",
"force_bytes",
"(",
"':'",
".",
"join",
"(",
"[",
"urlquote",
"(",
"force_bytes",
"(",
"var",
")",
")",
"for",
"var",
"in",
"self",
".",
"vary_on",
"]",
")",
")",
")",... | Take all the arguments passed after the fragment name and return a
hashed version which will be used in the cache key | [
"Take",
"all",
"the",
"arguments",
"passed",
"after",
"the",
"fragment",
"name",
"and",
"return",
"a",
"hashed",
"version",
"which",
"will",
"be",
"used",
"in",
"the",
"cache",
"key"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L297-L302 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.get_cache_key_args | def get_cache_key_args(self):
"""
Return the arguments to be passed to the base cache key returned by `get_base_cache_key`.
"""
cache_key_args = dict(
nodename=self.node.nodename,
name=self.fragment_name,
hash=self.hash_args(),
)
if sel... | python | def get_cache_key_args(self):
"""
Return the arguments to be passed to the base cache key returned by `get_base_cache_key`.
"""
cache_key_args = dict(
nodename=self.node.nodename,
name=self.fragment_name,
hash=self.hash_args(),
)
if sel... | [
"def",
"get_cache_key_args",
"(",
"self",
")",
":",
"cache_key_args",
"=",
"dict",
"(",
"nodename",
"=",
"self",
".",
"node",
".",
"nodename",
",",
"name",
"=",
"self",
".",
"fragment_name",
",",
"hash",
"=",
"self",
".",
"hash_args",
"(",
")",
",",
")... | Return the arguments to be passed to the base cache key returned by `get_base_cache_key`. | [
"Return",
"the",
"arguments",
"to",
"be",
"passed",
"to",
"the",
"base",
"cache",
"key",
"returned",
"by",
"get_base_cache_key",
"."
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L326-L338 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.cache_set | def cache_set(self, to_cache):
"""
Set content into the cache
"""
self.cache.set(self.cache_key, to_cache, self.expire_time) | python | def cache_set(self, to_cache):
"""
Set content into the cache
"""
self.cache.set(self.cache_key, to_cache, self.expire_time) | [
"def",
"cache_set",
"(",
"self",
",",
"to_cache",
")",
":",
"self",
".",
"cache",
".",
"set",
"(",
"self",
".",
"cache_key",
",",
"to_cache",
",",
"self",
".",
"expire_time",
")"
] | Set content into the cache | [
"Set",
"content",
"into",
"the",
"cache"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L362-L366 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.render_node | def render_node(self):
"""
Render the template and save the generated content
"""
self.content = self.node.nodelist.render(self.context) | python | def render_node(self):
"""
Render the template and save the generated content
"""
self.content = self.node.nodelist.render(self.context) | [
"def",
"render_node",
"(",
"self",
")",
":",
"self",
".",
"content",
"=",
"self",
".",
"node",
".",
"nodelist",
".",
"render",
"(",
"self",
".",
"context",
")"
] | Render the template and save the generated content | [
"Render",
"the",
"template",
"and",
"save",
"the",
"generated",
"content"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L421-L425 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.create_content | def create_content(self):
"""
Render the template, apply options on it, and save it to the cache.
"""
self.render_node()
if self.options.compress_spaces:
self.content = self.RE_SPACELESS.sub(' ', self.content)
if self.options.compress:
to_cache =... | python | def create_content(self):
"""
Render the template, apply options on it, and save it to the cache.
"""
self.render_node()
if self.options.compress_spaces:
self.content = self.RE_SPACELESS.sub(' ', self.content)
if self.options.compress:
to_cache =... | [
"def",
"create_content",
"(",
"self",
")",
":",
"self",
".",
"render_node",
"(",
")",
"if",
"self",
".",
"options",
".",
"compress_spaces",
":",
"self",
".",
"content",
"=",
"self",
".",
"RE_SPACELESS",
".",
"sub",
"(",
"' '",
",",
"self",
".",
"conten... | Render the template, apply options on it, and save it to the cache. | [
"Render",
"the",
"template",
"apply",
"options",
"on",
"it",
"and",
"save",
"it",
"to",
"the",
"cache",
"."
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L427-L448 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.get_templatetag_module | def get_templatetag_module(cls):
"""
Return the templatetags module name for which the current class is used.
It's used to render the nocache blocks by loading the correct module
"""
if cls not in CacheTag._templatetags_modules:
# find the library including the main t... | python | def get_templatetag_module(cls):
"""
Return the templatetags module name for which the current class is used.
It's used to render the nocache blocks by loading the correct module
"""
if cls not in CacheTag._templatetags_modules:
# find the library including the main t... | [
"def",
"get_templatetag_module",
"(",
"cls",
")",
":",
"if",
"cls",
"not",
"in",
"CacheTag",
".",
"_templatetags_modules",
":",
"# find the library including the main templatetag of the current class",
"all_tags",
"=",
"cls",
".",
"get_all_tags_and_filters_by_function",
"(",
... | Return the templatetags module name for which the current class is used.
It's used to render the nocache blocks by loading the correct module | [
"Return",
"the",
"templatetags",
"module",
"name",
"for",
"which",
"the",
"current",
"class",
"is",
"used",
".",
"It",
"s",
"used",
"to",
"render",
"the",
"nocache",
"blocks",
"by",
"loading",
"the",
"correct",
"module"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L562-L571 | train |
twidi/django-adv-cache-tag | adv_cache_tag/tag.py | CacheTag.render_nocache | def render_nocache(self):
"""
Render the `nocache` blocks of the content and return the whole
html
"""
tmpl = template.Template(''.join([
# start by loading the cache library
template.BLOCK_TAG_START,
'load %s' % self.get_templatetag_module(),
... | python | def render_nocache(self):
"""
Render the `nocache` blocks of the content and return the whole
html
"""
tmpl = template.Template(''.join([
# start by loading the cache library
template.BLOCK_TAG_START,
'load %s' % self.get_templatetag_module(),
... | [
"def",
"render_nocache",
"(",
"self",
")",
":",
"tmpl",
"=",
"template",
".",
"Template",
"(",
"''",
".",
"join",
"(",
"[",
"# start by loading the cache library",
"template",
".",
"BLOCK_TAG_START",
",",
"'load %s'",
"%",
"self",
".",
"get_templatetag_module",
... | Render the `nocache` blocks of the content and return the whole
html | [
"Render",
"the",
"nocache",
"blocks",
"of",
"the",
"content",
"and",
"return",
"the",
"whole",
"html"
] | 811f8db4dac73667c7d2fe0ea97a24969593eb8a | https://github.com/twidi/django-adv-cache-tag/blob/811f8db4dac73667c7d2fe0ea97a24969593eb8a/adv_cache_tag/tag.py#L573-L588 | train |
marchete/django-adldap-sync | adldap_sync/callbacks.py | user_active_directory_deactivate | def user_active_directory_deactivate(user, attributes, created, updated):
"""
Deactivate user accounts based on Active Directory's
userAccountControl flags. Requires 'userAccountControl'
to be included in LDAP_SYNC_USER_EXTRA_ATTRIBUTES.
"""
try:
user_account_control = int(attribu... | python | def user_active_directory_deactivate(user, attributes, created, updated):
"""
Deactivate user accounts based on Active Directory's
userAccountControl flags. Requires 'userAccountControl'
to be included in LDAP_SYNC_USER_EXTRA_ATTRIBUTES.
"""
try:
user_account_control = int(attribu... | [
"def",
"user_active_directory_deactivate",
"(",
"user",
",",
"attributes",
",",
"created",
",",
"updated",
")",
":",
"try",
":",
"user_account_control",
"=",
"int",
"(",
"attributes",
"[",
"'userAccountControl'",
"]",
"[",
"0",
"]",
")",
"if",
"user_account_cont... | Deactivate user accounts based on Active Directory's
userAccountControl flags. Requires 'userAccountControl'
to be included in LDAP_SYNC_USER_EXTRA_ATTRIBUTES. | [
"Deactivate",
"user",
"accounts",
"based",
"on",
"Active",
"Directory",
"s",
"userAccountControl",
"flags",
".",
"Requires",
"userAccountControl",
"to",
"be",
"included",
"in",
"LDAP_SYNC_USER_EXTRA_ATTRIBUTES",
"."
] | f6be226a4fb2a433d22e95043bd656ce902f8254 | https://github.com/marchete/django-adldap-sync/blob/f6be226a4fb2a433d22e95043bd656ce902f8254/adldap_sync/callbacks.py#L1-L12 | train |
nickpandolfi/Cyther | cyther/parser.py | _get_contents_between | def _get_contents_between(string, opener, closer):
"""
Get the contents of a string between two characters
"""
opener_location = string.index(opener)
closer_location = string.index(closer)
content = string[opener_location + 1:closer_location]
return content | python | def _get_contents_between(string, opener, closer):
"""
Get the contents of a string between two characters
"""
opener_location = string.index(opener)
closer_location = string.index(closer)
content = string[opener_location + 1:closer_location]
return content | [
"def",
"_get_contents_between",
"(",
"string",
",",
"opener",
",",
"closer",
")",
":",
"opener_location",
"=",
"string",
".",
"index",
"(",
"opener",
")",
"closer_location",
"=",
"string",
".",
"index",
"(",
"closer",
")",
"content",
"=",
"string",
"[",
"o... | Get the contents of a string between two characters | [
"Get",
"the",
"contents",
"of",
"a",
"string",
"between",
"two",
"characters"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L29-L36 | train |
nickpandolfi/Cyther | cyther/parser.py | _check_whitespace | def _check_whitespace(string):
"""
Make sure thre is no whitespace in the given string. Will raise a
ValueError if whitespace is detected
"""
if string.count(' ') + string.count('\t') + string.count('\n') > 0:
raise ValueError(INSTRUCTION_HAS_WHITESPACE) | python | def _check_whitespace(string):
"""
Make sure thre is no whitespace in the given string. Will raise a
ValueError if whitespace is detected
"""
if string.count(' ') + string.count('\t') + string.count('\n') > 0:
raise ValueError(INSTRUCTION_HAS_WHITESPACE) | [
"def",
"_check_whitespace",
"(",
"string",
")",
":",
"if",
"string",
".",
"count",
"(",
"' '",
")",
"+",
"string",
".",
"count",
"(",
"'\\t'",
")",
"+",
"string",
".",
"count",
"(",
"'\\n'",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"INSTRUCTIO... | Make sure thre is no whitespace in the given string. Will raise a
ValueError if whitespace is detected | [
"Make",
"sure",
"thre",
"is",
"no",
"whitespace",
"in",
"the",
"given",
"string",
".",
"Will",
"raise",
"a",
"ValueError",
"if",
"whitespace",
"is",
"detected"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L39-L45 | train |
nickpandolfi/Cyther | cyther/parser.py | _check_parameters | def _check_parameters(parameters, symbols):
"""
Checks that the parameters given are not empty. Ones with prefix symbols
can be denoted by including the prefix in symbols
"""
for param in parameters:
if not param:
raise ValueError(EMPTY_PARAMETER)
elif (param[0] in symbol... | python | def _check_parameters(parameters, symbols):
"""
Checks that the parameters given are not empty. Ones with prefix symbols
can be denoted by including the prefix in symbols
"""
for param in parameters:
if not param:
raise ValueError(EMPTY_PARAMETER)
elif (param[0] in symbol... | [
"def",
"_check_parameters",
"(",
"parameters",
",",
"symbols",
")",
":",
"for",
"param",
"in",
"parameters",
":",
"if",
"not",
"param",
":",
"raise",
"ValueError",
"(",
"EMPTY_PARAMETER",
")",
"elif",
"(",
"param",
"[",
"0",
"]",
"in",
"symbols",
")",
"a... | Checks that the parameters given are not empty. Ones with prefix symbols
can be denoted by including the prefix in symbols | [
"Checks",
"that",
"the",
"parameters",
"given",
"are",
"not",
"empty",
".",
"Ones",
"with",
"prefix",
"symbols",
"can",
"be",
"denoted",
"by",
"including",
"the",
"prefix",
"in",
"symbols"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L71-L81 | train |
nickpandolfi/Cyther | cyther/parser.py | _check_dependencies | def _check_dependencies(string):
"""
Checks the dependencies constructor. Looks to make sure that the
dependencies are the first things defined
"""
opener, closer = '(', ')'
_check_enclosing_characters(string, opener, closer)
if opener in string:
if string[0] != opener:
r... | python | def _check_dependencies(string):
"""
Checks the dependencies constructor. Looks to make sure that the
dependencies are the first things defined
"""
opener, closer = '(', ')'
_check_enclosing_characters(string, opener, closer)
if opener in string:
if string[0] != opener:
r... | [
"def",
"_check_dependencies",
"(",
"string",
")",
":",
"opener",
",",
"closer",
"=",
"'('",
",",
"')'",
"_check_enclosing_characters",
"(",
"string",
",",
"opener",
",",
"closer",
")",
"if",
"opener",
"in",
"string",
":",
"if",
"string",
"[",
"0",
"]",
"... | Checks the dependencies constructor. Looks to make sure that the
dependencies are the first things defined | [
"Checks",
"the",
"dependencies",
"constructor",
".",
"Looks",
"to",
"make",
"sure",
"that",
"the",
"dependencies",
"are",
"the",
"first",
"things",
"defined"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L84-L97 | train |
nickpandolfi/Cyther | cyther/parser.py | _check_building_options | def _check_building_options(string):
"""
Checks the building options to make sure that they are defined last,
after the task name and the dependencies
"""
opener, closer = '{', '}'
_check_enclosing_characters(string, opener, closer)
if opener in string:
if string[-1] != closer:
... | python | def _check_building_options(string):
"""
Checks the building options to make sure that they are defined last,
after the task name and the dependencies
"""
opener, closer = '{', '}'
_check_enclosing_characters(string, opener, closer)
if opener in string:
if string[-1] != closer:
... | [
"def",
"_check_building_options",
"(",
"string",
")",
":",
"opener",
",",
"closer",
"=",
"'{'",
",",
"'}'",
"_check_enclosing_characters",
"(",
"string",
",",
"opener",
",",
"closer",
")",
"if",
"opener",
"in",
"string",
":",
"if",
"string",
"[",
"-",
"1",... | Checks the building options to make sure that they are defined last,
after the task name and the dependencies | [
"Checks",
"the",
"building",
"options",
"to",
"make",
"sure",
"that",
"they",
"are",
"defined",
"last",
"after",
"the",
"task",
"name",
"and",
"the",
"dependencies"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L100-L113 | train |
nickpandolfi/Cyther | cyther/parser.py | _parse_dependencies | def _parse_dependencies(string):
"""
This function actually parses the dependencies are sorts them into
the buildable and given dependencies
"""
contents = _get_contents_between(string, '(', ')')
unsorted_dependencies = contents.split(',')
_check_parameters(unsorted_dependencies, ('?',))
... | python | def _parse_dependencies(string):
"""
This function actually parses the dependencies are sorts them into
the buildable and given dependencies
"""
contents = _get_contents_between(string, '(', ')')
unsorted_dependencies = contents.split(',')
_check_parameters(unsorted_dependencies, ('?',))
... | [
"def",
"_parse_dependencies",
"(",
"string",
")",
":",
"contents",
"=",
"_get_contents_between",
"(",
"string",
",",
"'('",
",",
"')'",
")",
"unsorted_dependencies",
"=",
"contents",
".",
"split",
"(",
"','",
")",
"_check_parameters",
"(",
"unsorted_dependencies",... | This function actually parses the dependencies are sorts them into
the buildable and given dependencies | [
"This",
"function",
"actually",
"parses",
"the",
"dependencies",
"are",
"sorts",
"them",
"into",
"the",
"buildable",
"and",
"given",
"dependencies"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L135-L153 | train |
nickpandolfi/Cyther | cyther/parser.py | parseString | def parseString(string):
"""
This function takes an entire instruction in the form of a string, and
will parse the entire string and return a dictionary of the fields
gathered from the parsing
"""
buildable_dependencies = []
given_dependencies = []
output_directory = None
output_form... | python | def parseString(string):
"""
This function takes an entire instruction in the form of a string, and
will parse the entire string and return a dictionary of the fields
gathered from the parsing
"""
buildable_dependencies = []
given_dependencies = []
output_directory = None
output_form... | [
"def",
"parseString",
"(",
"string",
")",
":",
"buildable_dependencies",
"=",
"[",
"]",
"given_dependencies",
"=",
"[",
"]",
"output_directory",
"=",
"None",
"output_format",
"=",
"None",
"building_directory",
"=",
"None",
"output_name",
"=",
"None",
"_check_white... | This function takes an entire instruction in the form of a string, and
will parse the entire string and return a dictionary of the fields
gathered from the parsing | [
"This",
"function",
"takes",
"an",
"entire",
"instruction",
"in",
"the",
"form",
"of",
"a",
"string",
"and",
"will",
"parse",
"the",
"entire",
"string",
"and",
"return",
"a",
"dictionary",
"of",
"the",
"fields",
"gathered",
"from",
"the",
"parsing"
] | 9fb0bd77af594008aa6ee8af460aa8c953abf5bc | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/parser.py#L195-L241 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/account.py | Account.GetAlias | def GetAlias(session=None):
"""Return specified alias or if none the alias associated with the provided credentials.
>>> clc.v2.Account.GetAlias()
u'BTDI'
"""
if session is not None:
return session['alias']
if not clc.ALIAS: clc.v2.API._Login()
retu... | python | def GetAlias(session=None):
"""Return specified alias or if none the alias associated with the provided credentials.
>>> clc.v2.Account.GetAlias()
u'BTDI'
"""
if session is not None:
return session['alias']
if not clc.ALIAS: clc.v2.API._Login()
retu... | [
"def",
"GetAlias",
"(",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"not",
"None",
":",
"return",
"session",
"[",
"'alias'",
"]",
"if",
"not",
"clc",
".",
"ALIAS",
":",
"clc",
".",
"v2",
".",
"API",
".",
"_Login",
"(",
")",
"return",
... | Return specified alias or if none the alias associated with the provided credentials.
>>> clc.v2.Account.GetAlias()
u'BTDI' | [
"Return",
"specified",
"alias",
"or",
"if",
"none",
"the",
"alias",
"associated",
"with",
"the",
"provided",
"credentials",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/account.py#L35-L45 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/account.py | Account.GetLocation | def GetLocation(session=None):
"""Return specified location or if none the default location associated with the provided credentials and alias.
>>> clc.v2.Account.GetLocation()
u'WA1'
"""
if session is not None:
return session['location']
if not clc.LOCATION... | python | def GetLocation(session=None):
"""Return specified location or if none the default location associated with the provided credentials and alias.
>>> clc.v2.Account.GetLocation()
u'WA1'
"""
if session is not None:
return session['location']
if not clc.LOCATION... | [
"def",
"GetLocation",
"(",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"not",
"None",
":",
"return",
"session",
"[",
"'location'",
"]",
"if",
"not",
"clc",
".",
"LOCATION",
":",
"clc",
".",
"v2",
".",
"API",
".",
"_Login",
"(",
")",
"r... | Return specified location or if none the default location associated with the provided credentials and alias.
>>> clc.v2.Account.GetLocation()
u'WA1' | [
"Return",
"specified",
"location",
"or",
"if",
"none",
"the",
"default",
"location",
"associated",
"with",
"the",
"provided",
"credentials",
"and",
"alias",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/account.py#L49-L59 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/account.py | Account.PrimaryDatacenter | def PrimaryDatacenter(self):
"""Returns the primary datacenter object associated with the account.
>>> clc.v2.Account(alias='BTDI').PrimaryDatacenter()
<clc.APIv2.datacenter.Datacenter instance at 0x10a45ce18>
>>> print _
WA1
"""
return(clc.v2.Datacenter(alias=... | python | def PrimaryDatacenter(self):
"""Returns the primary datacenter object associated with the account.
>>> clc.v2.Account(alias='BTDI').PrimaryDatacenter()
<clc.APIv2.datacenter.Datacenter instance at 0x10a45ce18>
>>> print _
WA1
"""
return(clc.v2.Datacenter(alias=... | [
"def",
"PrimaryDatacenter",
"(",
"self",
")",
":",
"return",
"(",
"clc",
".",
"v2",
".",
"Datacenter",
"(",
"alias",
"=",
"self",
".",
"alias",
",",
"location",
"=",
"self",
".",
"data",
"[",
"'primaryDataCenter'",
"]",
",",
"session",
"=",
"self",
"."... | Returns the primary datacenter object associated with the account.
>>> clc.v2.Account(alias='BTDI').PrimaryDatacenter()
<clc.APIv2.datacenter.Datacenter instance at 0x10a45ce18>
>>> print _
WA1 | [
"Returns",
"the",
"primary",
"datacenter",
"object",
"associated",
"with",
"the",
"account",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/account.py#L94-L104 | train |
sio2project/filetracker | filetracker/client/data_store.py | DataStore.add_file | def add_file(self, name, filename, compress_hint=True):
"""Saves the actual file in the store.
``compress_hint`` suggests whether the file should be compressed
before transfer
Works like :meth:`add_stream`, but ``filename`` is the name of
an existing file in the fil... | python | def add_file(self, name, filename, compress_hint=True):
"""Saves the actual file in the store.
``compress_hint`` suggests whether the file should be compressed
before transfer
Works like :meth:`add_stream`, but ``filename`` is the name of
an existing file in the fil... | [
"def",
"add_file",
"(",
"self",
",",
"name",
",",
"filename",
",",
"compress_hint",
"=",
"True",
")",
":",
"return",
"self",
".",
"add_stream",
"(",
"name",
",",
"open",
"(",
"filename",
",",
"'rb'",
")",
")"
] | Saves the actual file in the store.
``compress_hint`` suggests whether the file should be compressed
before transfer
Works like :meth:`add_stream`, but ``filename`` is the name of
an existing file in the filesystem. | [
"Saves",
"the",
"actual",
"file",
"in",
"the",
"store",
"."
] | 359b474850622e3d0c25ee2596d7242c02f84efb | https://github.com/sio2project/filetracker/blob/359b474850622e3d0c25ee2596d7242c02f84efb/filetracker/client/data_store.py#L38-L47 | train |
sio2project/filetracker | filetracker/client/data_store.py | DataStore.get_file | def get_file(self, name, filename):
"""Saves the content of file named ``name`` to ``filename``.
Works like :meth:`get_stream`, but ``filename`` is the name of
a file which will be created (or overwritten).
Returns the full versioned name of the retrieved file.
"""
... | python | def get_file(self, name, filename):
"""Saves the content of file named ``name`` to ``filename``.
Works like :meth:`get_stream`, but ``filename`` is the name of
a file which will be created (or overwritten).
Returns the full versioned name of the retrieved file.
"""
... | [
"def",
"get_file",
"(",
"self",
",",
"name",
",",
"filename",
")",
":",
"stream",
",",
"vname",
"=",
"self",
".",
"get_stream",
"(",
"name",
")",
"path",
",",
"version",
"=",
"split_name",
"(",
"vname",
")",
"dir_path",
"=",
"os",
".",
"path",
".",
... | Saves the content of file named ``name`` to ``filename``.
Works like :meth:`get_stream`, but ``filename`` is the name of
a file which will be created (or overwritten).
Returns the full versioned name of the retrieved file. | [
"Saves",
"the",
"content",
"of",
"file",
"named",
"name",
"to",
"filename",
"."
] | 359b474850622e3d0c25ee2596d7242c02f84efb | https://github.com/sio2project/filetracker/blob/359b474850622e3d0c25ee2596d7242c02f84efb/filetracker/client/data_store.py#L80-L98 | train |
cltl/KafNafParserPy | KafNafParserPy/temporal_data.py | CtemporalRelations.remove_this_tlink | def remove_this_tlink(self,tlink_id):
"""
Removes the tlink for the given tlink identifier
@type tlink_id: string
@param tlink_id: the tlink identifier to be removed
"""
for tlink in self.get_tlinks():
if tlink.get_id() == tlink_id:
self.node.r... | python | def remove_this_tlink(self,tlink_id):
"""
Removes the tlink for the given tlink identifier
@type tlink_id: string
@param tlink_id: the tlink identifier to be removed
"""
for tlink in self.get_tlinks():
if tlink.get_id() == tlink_id:
self.node.r... | [
"def",
"remove_this_tlink",
"(",
"self",
",",
"tlink_id",
")",
":",
"for",
"tlink",
"in",
"self",
".",
"get_tlinks",
"(",
")",
":",
"if",
"tlink",
".",
"get_id",
"(",
")",
"==",
"tlink_id",
":",
"self",
".",
"node",
".",
"remove",
"(",
"tlink",
".",
... | Removes the tlink for the given tlink identifier
@type tlink_id: string
@param tlink_id: the tlink identifier to be removed | [
"Removes",
"the",
"tlink",
"for",
"the",
"given",
"tlink",
"identifier"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/temporal_data.py#L344-L353 | train |
cltl/KafNafParserPy | KafNafParserPy/temporal_data.py | CtemporalRelations.remove_this_predicateAnchor | def remove_this_predicateAnchor(self,predAnch_id):
"""
Removes the predicate anchor for the given predicate anchor identifier
@type predAnch_id: string
@param predAnch_id: the predicate anchor identifier to be removed
"""
for predAnch in self.get_predicateAnchors():
... | python | def remove_this_predicateAnchor(self,predAnch_id):
"""
Removes the predicate anchor for the given predicate anchor identifier
@type predAnch_id: string
@param predAnch_id: the predicate anchor identifier to be removed
"""
for predAnch in self.get_predicateAnchors():
... | [
"def",
"remove_this_predicateAnchor",
"(",
"self",
",",
"predAnch_id",
")",
":",
"for",
"predAnch",
"in",
"self",
".",
"get_predicateAnchors",
"(",
")",
":",
"if",
"predAnch",
".",
"get_id",
"(",
")",
"==",
"predAnch_id",
":",
"self",
".",
"node",
".",
"re... | Removes the predicate anchor for the given predicate anchor identifier
@type predAnch_id: string
@param predAnch_id: the predicate anchor identifier to be removed | [
"Removes",
"the",
"predicate",
"anchor",
"for",
"the",
"given",
"predicate",
"anchor",
"identifier"
] | 9bc32e803c176404b255ba317479b8780ed5f569 | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/temporal_data.py#L363-L372 | train |
teepark/greenhouse | greenhouse/io/descriptor.py | wait_fds | def wait_fds(fd_events, inmask=1, outmask=2, timeout=None):
"""wait for the first of a number of file descriptors to have activity
.. note:: this method can block
it will return once there is relevant activity on the file descriptors,
or the timeout expires
:param fd_events:
two-t... | python | def wait_fds(fd_events, inmask=1, outmask=2, timeout=None):
"""wait for the first of a number of file descriptors to have activity
.. note:: this method can block
it will return once there is relevant activity on the file descriptors,
or the timeout expires
:param fd_events:
two-t... | [
"def",
"wait_fds",
"(",
"fd_events",
",",
"inmask",
"=",
"1",
",",
"outmask",
"=",
"2",
",",
"timeout",
"=",
"None",
")",
":",
"current",
"=",
"compat",
".",
"getcurrent",
"(",
")",
"activated",
"=",
"{",
"}",
"poll_regs",
"=",
"{",
"}",
"callback_re... | wait for the first of a number of file descriptors to have activity
.. note:: this method can block
it will return once there is relevant activity on the file descriptors,
or the timeout expires
:param fd_events:
two-tuples, each one a file descriptor and a mask made up of the inmask
... | [
"wait",
"for",
"the",
"first",
"of",
"a",
"number",
"of",
"file",
"descriptors",
"to",
"have",
"activity"
] | 8fd1be4f5443ba090346b5ec82fdbeb0a060d956 | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/io/descriptor.py#L13-L87 | train |
EVEprosper/ProsperCommon | setup.py | hack_find_packages | def hack_find_packages(include_str):
"""patches setuptools.find_packages issue
setuptools.find_packages(path='') doesn't work as intended
Returns:
list: append <include_str>. onto every element of setuptools.find_pacakges() call
"""
new_list = [include_str]
for element in find_package... | python | def hack_find_packages(include_str):
"""patches setuptools.find_packages issue
setuptools.find_packages(path='') doesn't work as intended
Returns:
list: append <include_str>. onto every element of setuptools.find_pacakges() call
"""
new_list = [include_str]
for element in find_package... | [
"def",
"hack_find_packages",
"(",
"include_str",
")",
":",
"new_list",
"=",
"[",
"include_str",
"]",
"for",
"element",
"in",
"find_packages",
"(",
"include_str",
")",
":",
"new_list",
".",
"append",
"(",
"include_str",
"+",
"'.'",
"+",
"element",
")",
"retur... | patches setuptools.find_packages issue
setuptools.find_packages(path='') doesn't work as intended
Returns:
list: append <include_str>. onto every element of setuptools.find_pacakges() call | [
"patches",
"setuptools",
".",
"find_packages",
"issue"
] | bcada3b25420099e1f204db8d55eb268e7b4dc27 | https://github.com/EVEprosper/ProsperCommon/blob/bcada3b25420099e1f204db8d55eb268e7b4dc27/setup.py#L30-L43 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/queue.py | Requests.WaitUntilComplete | def WaitUntilComplete(self,poll_freq=2,timeout=None):
"""Poll until all request objects have completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' then success
Else log as error
poll_freq option is in seconds
Returns an Int the number of unsuccessful requests. Th... | python | def WaitUntilComplete(self,poll_freq=2,timeout=None):
"""Poll until all request objects have completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' then success
Else log as error
poll_freq option is in seconds
Returns an Int the number of unsuccessful requests. Th... | [
"def",
"WaitUntilComplete",
"(",
"self",
",",
"poll_freq",
"=",
"2",
",",
"timeout",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"while",
"len",
"(",
"self",
".",
"requests",
")",
":",
"cur_requests",
"=",
"[",
"]",
"for"... | Poll until all request objects have completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' then success
Else log as error
poll_freq option is in seconds
Returns an Int the number of unsuccessful requests. This behavior is subject to change.
>>> clc.v2.Server(alia... | [
"Poll",
"until",
"all",
"request",
"objects",
"have",
"completed",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/queue.py#L119-L153 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/queue.py | Request.WaitUntilComplete | def WaitUntilComplete(self,poll_freq=2,timeout=None):
"""Poll until status is completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' return
Else raise exception
poll_freq option is in seconds
"""
start_time = time.time()
while not self.time_completed:
status... | python | def WaitUntilComplete(self,poll_freq=2,timeout=None):
"""Poll until status is completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' return
Else raise exception
poll_freq option is in seconds
"""
start_time = time.time()
while not self.time_completed:
status... | [
"def",
"WaitUntilComplete",
"(",
"self",
",",
"poll_freq",
"=",
"2",
",",
"timeout",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"time_completed",
":",
"status",
"=",
"self",
".",
"Status",
"(",... | Poll until status is completed.
If status is 'notStarted' or 'executing' continue polling.
If status is 'succeeded' return
Else raise exception
poll_freq option is in seconds | [
"Poll",
"until",
"status",
"is",
"completed",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/queue.py#L197-L222 | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv2/queue.py | Request.Server | def Server(self):
"""Return server associated with this request.
>>> d = clc.v2.Datacenter()
>>> q = clc.v2.Server.Create(name="api2",cpu=1,memory=1,group_id=d.Groups().Get("Default Group").id,template=d.Templates().Search("centos-6-64")[0].id,network_id=d.Networks().networks[0].id,ttl=4000)
>>> q.WaitUntilCom... | python | def Server(self):
"""Return server associated with this request.
>>> d = clc.v2.Datacenter()
>>> q = clc.v2.Server.Create(name="api2",cpu=1,memory=1,group_id=d.Groups().Get("Default Group").id,template=d.Templates().Search("centos-6-64")[0].id,network_id=d.Networks().networks[0].id,ttl=4000)
>>> q.WaitUntilCom... | [
"def",
"Server",
"(",
"self",
")",
":",
"if",
"self",
".",
"context_key",
"==",
"'newserver'",
":",
"server_id",
"=",
"clc",
".",
"v2",
".",
"API",
".",
"Call",
"(",
"'GET'",
",",
"self",
".",
"context_val",
",",
"session",
"=",
"self",
".",
"session... | Return server associated with this request.
>>> d = clc.v2.Datacenter()
>>> q = clc.v2.Server.Create(name="api2",cpu=1,memory=1,group_id=d.Groups().Get("Default Group").id,template=d.Templates().Search("centos-6-64")[0].id,network_id=d.Networks().networks[0].id,ttl=4000)
>>> q.WaitUntilComplete()
0
>>> q.suc... | [
"Return",
"server",
"associated",
"with",
"this",
"request",
"."
] | f4dba40c627cb08dd4b7d0d277e8d67578010b05 | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/queue.py#L225-L243 | train |
thilux/tvdb_client | tvdb_client/clients/ApiV2Client.py | ApiV2Client.login | def login(self):
"""
This method performs the login on TheTVDB given the api key, user name and account identifier.
:return: None
"""
auth_data = dict()
auth_data['apikey'] = self.api_key
auth_data['username'] = self.username
auth_data['userkey'] = self.a... | python | def login(self):
"""
This method performs the login on TheTVDB given the api key, user name and account identifier.
:return: None
"""
auth_data = dict()
auth_data['apikey'] = self.api_key
auth_data['username'] = self.username
auth_data['userkey'] = self.a... | [
"def",
"login",
"(",
"self",
")",
":",
"auth_data",
"=",
"dict",
"(",
")",
"auth_data",
"[",
"'apikey'",
"]",
"=",
"self",
".",
"api_key",
"auth_data",
"[",
"'username'",
"]",
"=",
"self",
".",
"username",
"auth_data",
"[",
"'userkey'",
"]",
"=",
"self... | This method performs the login on TheTVDB given the api key, user name and account identifier.
:return: None | [
"This",
"method",
"performs",
"the",
"login",
"on",
"TheTVDB",
"given",
"the",
"api",
"key",
"user",
"name",
"and",
"account",
"identifier",
"."
] | 2d5106f260367c0abe1284683697874df6343f78 | https://github.com/thilux/tvdb_client/blob/2d5106f260367c0abe1284683697874df6343f78/tvdb_client/clients/ApiV2Client.py#L79-L99 | train |
thilux/tvdb_client | tvdb_client/clients/ApiV2Client.py | ApiV2Client.search_series | def search_series(self, name=None, imdb_id=None, zap2it_id=None):
"""
Searchs for a series in TheTVDB by either its name, imdb_id or zap2it_id.
:param name: the name of the series to look for
:param imdb_id: the IMDB id of the series to look for
:param zap2it_id: the zap2it id o... | python | def search_series(self, name=None, imdb_id=None, zap2it_id=None):
"""
Searchs for a series in TheTVDB by either its name, imdb_id or zap2it_id.
:param name: the name of the series to look for
:param imdb_id: the IMDB id of the series to look for
:param zap2it_id: the zap2it id o... | [
"def",
"search_series",
"(",
"self",
",",
"name",
"=",
"None",
",",
"imdb_id",
"=",
"None",
",",
"zap2it_id",
"=",
"None",
")",
":",
"arguments",
"=",
"locals",
"(",
")",
"optional_parameters",
"=",
"{",
"'name'",
":",
"'name'",
",",
"'imdb_id'",
":",
... | Searchs for a series in TheTVDB by either its name, imdb_id or zap2it_id.
:param name: the name of the series to look for
:param imdb_id: the IMDB id of the series to look for
:param zap2it_id: the zap2it id of the series to look for.
:return: a python dictionary with either the result ... | [
"Searchs",
"for",
"a",
"series",
"in",
"TheTVDB",
"by",
"either",
"its",
"name",
"imdb_id",
"or",
"zap2it_id",
"."
] | 2d5106f260367c0abe1284683697874df6343f78 | https://github.com/thilux/tvdb_client/blob/2d5106f260367c0abe1284683697874df6343f78/tvdb_client/clients/ApiV2Client.py#L102-L120 | train |
thilux/tvdb_client | tvdb_client/clients/ApiV2Client.py | ApiV2Client.get_series_actors | def get_series_actors(self, series_id):
"""
Retrieves the information on the actors of a particular series, given its TheTVDB id.
:param series_id: the TheTVDB id of the series
:return: a python dictionary with either the result of the search or an error from TheTVDB.
"""
... | python | def get_series_actors(self, series_id):
"""
Retrieves the information on the actors of a particular series, given its TheTVDB id.
:param series_id: the TheTVDB id of the series
:return: a python dictionary with either the result of the search or an error from TheTVDB.
"""
... | [
"def",
"get_series_actors",
"(",
"self",
",",
"series_id",
")",
":",
"raw_response",
"=",
"requests_util",
".",
"run_request",
"(",
"'get'",
",",
"self",
".",
"API_BASE_URL",
"+",
"'/series/%d/actors'",
"%",
"series_id",
",",
"headers",
"=",
"self",
".",
"__ge... | Retrieves the information on the actors of a particular series, given its TheTVDB id.
:param series_id: the TheTVDB id of the series
:return: a python dictionary with either the result of the search or an error from TheTVDB. | [
"Retrieves",
"the",
"information",
"on",
"the",
"actors",
"of",
"a",
"particular",
"series",
"given",
"its",
"TheTVDB",
"id",
"."
] | 2d5106f260367c0abe1284683697874df6343f78 | https://github.com/thilux/tvdb_client/blob/2d5106f260367c0abe1284683697874df6343f78/tvdb_client/clients/ApiV2Client.py#L137-L148 | train |
thilux/tvdb_client | tvdb_client/clients/ApiV2Client.py | ApiV2Client.get_series_episodes | def get_series_episodes(self, series_id, page=1):
"""
Retrieves all episodes for a particular series given its TheTVDB id. It retrieves a maximum of 100 results per
page.
:param series_id: The TheTVDB id of the series.
:param page: The page number. If none is provided, 1 is used... | python | def get_series_episodes(self, series_id, page=1):
"""
Retrieves all episodes for a particular series given its TheTVDB id. It retrieves a maximum of 100 results per
page.
:param series_id: The TheTVDB id of the series.
:param page: The page number. If none is provided, 1 is used... | [
"def",
"get_series_episodes",
"(",
"self",
",",
"series_id",
",",
"page",
"=",
"1",
")",
":",
"raw_response",
"=",
"requests_util",
".",
"run_request",
"(",
"'get'",
",",
"self",
".",
"API_BASE_URL",
"+",
"'/series/%d/episodes?page=%d'",
"%",
"(",
"series_id",
... | Retrieves all episodes for a particular series given its TheTVDB id. It retrieves a maximum of 100 results per
page.
:param series_id: The TheTVDB id of the series.
:param page: The page number. If none is provided, 1 is used by default.
:return: a python dictionary with either the resu... | [
"Retrieves",
"all",
"episodes",
"for",
"a",
"particular",
"series",
"given",
"its",
"TheTVDB",
"id",
".",
"It",
"retrieves",
"a",
"maximum",
"of",
"100",
"results",
"per",
"page",
"."
] | 2d5106f260367c0abe1284683697874df6343f78 | https://github.com/thilux/tvdb_client/blob/2d5106f260367c0abe1284683697874df6343f78/tvdb_client/clients/ApiV2Client.py#L151-L164 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.