body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def is_callback(func: Callable[(..., Any)]) -> bool:
'Check if function is safe to be called in the event loop.'
return (getattr(func, '_edge_callback', False) is True) | -7,553,714,258,499,277,000 | Check if function is safe to be called in the event loop. | merceedge/util/async_util.py | is_callback | hobo0cn/MerceEdge | python | def is_callback(func: Callable[(..., Any)]) -> bool:
return (getattr(func, '_edge_callback', False) is True) |
def _set_result_unless_cancelled(fut: Future, result: Any) -> None:
'Set the result only if the Future was not cancelled.'
if fut.cancelled():
return
fut.set_result(result) | -1,647,970,271,901,832,000 | Set the result only if the Future was not cancelled. | merceedge/util/async_util.py | _set_result_unless_cancelled | hobo0cn/MerceEdge | python | def _set_result_unless_cancelled(fut: Future, result: Any) -> None:
if fut.cancelled():
return
fut.set_result(result) |
def _set_concurrent_future_state(concurr: concurrent.futures.Future, source: Union[(concurrent.futures.Future, Future)]) -> None:
'Copy state from a future to a concurrent.futures.Future.'
assert source.done()
if source.cancelled():
concurr.cancel()
if (not concurr.set_running_or_notify_cancel()... | -3,110,793,826,072,417,000 | Copy state from a future to a concurrent.futures.Future. | merceedge/util/async_util.py | _set_concurrent_future_state | hobo0cn/MerceEdge | python | def _set_concurrent_future_state(concurr: concurrent.futures.Future, source: Union[(concurrent.futures.Future, Future)]) -> None:
assert source.done()
if source.cancelled():
concurr.cancel()
if (not concurr.set_running_or_notify_cancel()):
return
exception = source.exception()
i... |
def _copy_future_state(source: Union[(concurrent.futures.Future, Future)], dest: Union[(concurrent.futures.Future, Future)]) -> None:
'Copy state from another Future.\n\n The other Future may be a concurrent.futures.Future.\n '
assert source.done()
if dest.cancelled():
return
assert (not d... | -7,860,038,271,336,070,000 | Copy state from another Future.
The other Future may be a concurrent.futures.Future. | merceedge/util/async_util.py | _copy_future_state | hobo0cn/MerceEdge | python | def _copy_future_state(source: Union[(concurrent.futures.Future, Future)], dest: Union[(concurrent.futures.Future, Future)]) -> None:
'Copy state from another Future.\n\n The other Future may be a concurrent.futures.Future.\n '
assert source.done()
if dest.cancelled():
return
assert (not d... |
def _chain_future(source: Union[(concurrent.futures.Future, Future)], destination: Union[(concurrent.futures.Future, Future)]) -> None:
'Chain two futures so that when one completes, so does the other.\n\n The result (or exception) of source will be copied to destination.\n If destination is cancelled, source... | -464,260,178,128,809,500 | Chain two futures so that when one completes, so does the other.
The result (or exception) of source will be copied to destination.
If destination is cancelled, source gets cancelled too.
Compatible with both asyncio.Future and concurrent.futures.Future. | merceedge/util/async_util.py | _chain_future | hobo0cn/MerceEdge | python | def _chain_future(source: Union[(concurrent.futures.Future, Future)], destination: Union[(concurrent.futures.Future, Future)]) -> None:
'Chain two futures so that when one completes, so does the other.\n\n The result (or exception) of source will be copied to destination.\n If destination is cancelled, source... |
def run_coroutine_threadsafe(coro: Union[(Coroutine, Generator)], loop: AbstractEventLoop) -> concurrent.futures.Future:
'Submit a coroutine object to a given event loop.\n\n Return a concurrent.futures.Future to access the result.\n '
ident = loop.__dict__.get('_thread_ident')
if ((ident is not None)... | -8,966,409,045,454,131,000 | Submit a coroutine object to a given event loop.
Return a concurrent.futures.Future to access the result. | merceedge/util/async_util.py | run_coroutine_threadsafe | hobo0cn/MerceEdge | python | def run_coroutine_threadsafe(coro: Union[(Coroutine, Generator)], loop: AbstractEventLoop) -> concurrent.futures.Future:
'Submit a coroutine object to a given event loop.\n\n Return a concurrent.futures.Future to access the result.\n '
ident = loop.__dict__.get('_thread_ident')
if ((ident is not None)... |
def fire_coroutine_threadsafe(coro: Coroutine, loop: AbstractEventLoop) -> None:
'Submit a coroutine object to a given event loop.\n\n This method does not provide a way to retrieve the result and\n is intended for fire-and-forget use. This reduces the\n work involved to fire the function on the loop.\n ... | 5,010,027,783,280,364,000 | Submit a coroutine object to a given event loop.
This method does not provide a way to retrieve the result and
is intended for fire-and-forget use. This reduces the
work involved to fire the function on the loop. | merceedge/util/async_util.py | fire_coroutine_threadsafe | hobo0cn/MerceEdge | python | def fire_coroutine_threadsafe(coro: Coroutine, loop: AbstractEventLoop) -> None:
'Submit a coroutine object to a given event loop.\n\n This method does not provide a way to retrieve the result and\n is intended for fire-and-forget use. This reduces the\n work involved to fire the function on the loop.\n ... |
def run_callback_threadsafe(loop: AbstractEventLoop, callback: Callable, *args: Any) -> concurrent.futures.Future:
'Submit a callback object to a given event loop.\n\n Return a concurrent.futures.Future to access the result.\n\n NOTE: This code references home-assistant.\n '
ident = loop.__dict__.get('... | 1,413,469,190,202,463,000 | Submit a callback object to a given event loop.
Return a concurrent.futures.Future to access the result.
NOTE: This code references home-assistant. | merceedge/util/async_util.py | run_callback_threadsafe | hobo0cn/MerceEdge | python | def run_callback_threadsafe(loop: AbstractEventLoop, callback: Callable, *args: Any) -> concurrent.futures.Future:
'Submit a callback object to a given event loop.\n\n Return a concurrent.futures.Future to access the result.\n\n NOTE: This code references home-assistant.\n '
ident = loop.__dict__.get('... |
def as_dict(self) -> dict:
'Return a dictionary representation of the context.'
return {'id': self.id, 'user_id': self.user_id} | -5,950,560,538,002,860,000 | Return a dictionary representation of the context. | merceedge/util/async_util.py | as_dict | hobo0cn/MerceEdge | python | def as_dict(self) -> dict:
return {'id': self.id, 'user_id': self.user_id} |
def callback() -> None:
'Handle the call to the coroutine.'
try:
_chain_future(ensure_future(coro, loop=loop), future)
except Exception as exc:
if future.set_running_or_notify_cancel():
future.set_exception(exc)
else:
_LOGGER.warning('Exception on lost future:... | 6,314,385,836,826,053,000 | Handle the call to the coroutine. | merceedge/util/async_util.py | callback | hobo0cn/MerceEdge | python | def callback() -> None:
try:
_chain_future(ensure_future(coro, loop=loop), future)
except Exception as exc:
if future.set_running_or_notify_cancel():
future.set_exception(exc)
else:
_LOGGER.warning('Exception on lost future: ', exc_info=True) |
def callback() -> None:
'Handle the firing of a coroutine.'
ensure_future(coro, loop=loop) | 7,684,422,278,126,684,000 | Handle the firing of a coroutine. | merceedge/util/async_util.py | callback | hobo0cn/MerceEdge | python | def callback() -> None:
ensure_future(coro, loop=loop) |
def run_callback() -> None:
'Run callback and store result.'
try:
future.set_result(callback(*args))
except Exception as exc:
if future.set_running_or_notify_cancel():
future.set_exception(exc)
else:
_LOGGER.warning('Exception on lost future: ', exc_info=True) | -6,252,598,045,921,766,000 | Run callback and store result. | merceedge/util/async_util.py | run_callback | hobo0cn/MerceEdge | python | def run_callback() -> None:
try:
future.set_result(callback(*args))
except Exception as exc:
if future.set_running_or_notify_cancel():
future.set_exception(exc)
else:
_LOGGER.warning('Exception on lost future: ', exc_info=True) |
def asyncio_run(main: Awaitable[_T], *, debug: bool=False) -> _T:
'Minimal re-implementation of asyncio.run (since 3.7).'
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.set_debug(debug)
try:
return loop.run_until_complete(main)
finally:
print('loop final')
... | 5,285,841,334,932,499,000 | Minimal re-implementation of asyncio.run (since 3.7). | merceedge/util/async_util.py | asyncio_run | hobo0cn/MerceEdge | python | def asyncio_run(main: Awaitable[_T], *, debug: bool=False) -> _T:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.set_debug(debug)
try:
return loop.run_until_complete(main)
finally:
print('loop final')
asyncio.set_event_loop(None)
loop.close() |
def __init__(self, str_subject, template, template_params):
'string template과 딕셔너리형 template_params받아 MIME 메시지를 만든다'
assert isinstance(template, Template)
assert isinstance(template_params, dict)
self.msg = MIMEMultipart()
self.msg['Subject'] = str_subject
str_msg = template.safe_substitute(**te... | -4,368,756,389,393,821,000 | string template과 딕셔너리형 template_params받아 MIME 메시지를 만든다 | app/user/example.py | __init__ | Einsicht1/recipe-app-api | python | def __init__(self, str_subject, template, template_params):
assert isinstance(template, Template)
assert isinstance(template_params, dict)
self.msg = MIMEMultipart()
self.msg['Subject'] = str_subject
str_msg = template.safe_substitute(**template_params)
mime_msg = MIMEText(str_msg, 'html')
... |
def get_message(self, str_from_email_addr, str_to_email_addr):
'발신자, 수신자리스트를 이용하여 보낼메시지를 만든다 '
send_msg = copy.deepcopy(self.msg)
send_msg['From'] = str_from_email_addr
send_msg['To'] = str_to_email_addr
return send_msg | 3,965,988,359,583,012,400 | 발신자, 수신자리스트를 이용하여 보낼메시지를 만든다 | app/user/example.py | get_message | Einsicht1/recipe-app-api | python | def get_message(self, str_from_email_addr, str_to_email_addr):
' '
send_msg = copy.deepcopy(self.msg)
send_msg['From'] = str_from_email_addr
send_msg['To'] = str_to_email_addr
return send_msg |
def __init__(self, str_host, num_port):
'호스트와 포트번호로 SMTP로 연결한다 '
self.str_host = str_host
self.num_port = num_port
self.smtp_connect = smtplib.SMTP(host=str_host, port=num_port)
self.smtp_connect.starttls()
self.smtp_connect.login(EMAIL_ADDRESS, EMAIL_PASSWORD) | 7,523,257,613,259,052,000 | 호스트와 포트번호로 SMTP로 연결한다 | app/user/example.py | __init__ | Einsicht1/recipe-app-api | python | def __init__(self, str_host, num_port):
' '
self.str_host = str_host
self.num_port = num_port
self.smtp_connect = smtplib.SMTP(host=str_host, port=num_port)
self.smtp_connect.starttls()
self.smtp_connect.login(EMAIL_ADDRESS, EMAIL_PASSWORD) |
def send_message(self, emailContent, str_from_email_addr, str_to_email_addr):
'e메일을 발송한다 '
contents = emailContent.get_message(str_from_email_addr, str_to_email_addr)
self.smtp_connect.send_message(contents, from_addr=str_from_email_addr, to_addrs=str_to_email_addr)
del contents | -3,186,268,996,533,305,300 | e메일을 발송한다 | app/user/example.py | send_message | Einsicht1/recipe-app-api | python | def send_message(self, emailContent, str_from_email_addr, str_to_email_addr):
' '
contents = emailContent.get_message(str_from_email_addr, str_to_email_addr)
self.smtp_connect.send_message(contents, from_addr=str_from_email_addr, to_addrs=str_to_email_addr)
del contents |
def __init__(self, clip_min: float=(- 5.0), clip_max: float=5.0, name='observation_stats'):
'\n :param clip_min: The minimum value to allow after normalizing the observation\n :param clip_max: The maximum value to allow after normalizing the observation\n '
super().__init__()
self.clip_... | -3,725,733,070,058,041,000 | :param clip_min: The minimum value to allow after normalizing the observation
:param clip_max: The maximum value to allow after normalizing the observation | rl_coach/filters/observation/observation_normalization_filter.py | __init__ | AustinDeric/coach | python | def __init__(self, clip_min: float=(- 5.0), clip_max: float=5.0, name='observation_stats'):
'\n :param clip_min: The minimum value to allow after normalizing the observation\n :param clip_max: The maximum value to allow after normalizing the observation\n '
super().__init__()
self.clip_... |
def set_device(self, device, memory_backend_params=None, mode='numpy') -> None:
"\n An optional function that allows the filter to get the device if it is required to use tensorflow ops\n :param device: the device to use\n :memory_backend_params: if not None, holds params for a memory backend f... | 5,497,590,193,474,922,000 | An optional function that allows the filter to get the device if it is required to use tensorflow ops
:param device: the device to use
:memory_backend_params: if not None, holds params for a memory backend for sharing data (e.g. Redis)
:param mode: the arithmetic module to use {'tf' | 'numpy'}
:return: None | rl_coach/filters/observation/observation_normalization_filter.py | set_device | AustinDeric/coach | python | def set_device(self, device, memory_backend_params=None, mode='numpy') -> None:
"\n An optional function that allows the filter to get the device if it is required to use tensorflow ops\n :param device: the device to use\n :memory_backend_params: if not None, holds params for a memory backend f... |
def set_session(self, sess) -> None:
'\n An optional function that allows the filter to get the session if it is required to use tensorflow ops\n :param sess: the session\n :return: None\n '
self.running_observation_stats.set_session(sess) | 6,684,206,919,324,875,000 | An optional function that allows the filter to get the session if it is required to use tensorflow ops
:param sess: the session
:return: None | rl_coach/filters/observation/observation_normalization_filter.py | set_session | AustinDeric/coach | python | def set_session(self, sess) -> None:
'\n An optional function that allows the filter to get the session if it is required to use tensorflow ops\n :param sess: the session\n :return: None\n '
self.running_observation_stats.set_session(sess) |
def changed(self):
'all draft objects that have not been published yet'
return self.filter(Publishable.Q_CHANGED) | -2,284,062,380,157,862,400 | all draft objects that have not been published yet | publish/models.py | changed | team-35/django-publish | python | def changed(self):
return self.filter(Publishable.Q_CHANGED) |
def deleted(self):
'public objects that need deleting'
return self.filter(Publishable.Q_DELETED) | -8,045,970,957,518,090,000 | public objects that need deleting | publish/models.py | deleted | team-35/django-publish | python | def deleted(self):
return self.filter(Publishable.Q_DELETED) |
def draft(self):
'all draft objects'
return self.filter(Publishable.Q_DRAFT) | 2,715,094,798,063,293,000 | all draft objects | publish/models.py | draft | team-35/django-publish | python | def draft(self):
return self.filter(Publishable.Q_DRAFT) |
def published(self):
'all public/published objects'
return self.filter(Publishable.Q_PUBLISHED) | -5,068,784,696,173,575,000 | all public/published objects | publish/models.py | published | team-35/django-publish | python | def published(self):
return self.filter(Publishable.Q_PUBLISHED) |
def publish(self, all_published=None):
'publish all models in this queryset'
if (all_published is None):
all_published = NestedSet()
for p in self:
p.publish(all_published=all_published) | 2,130,694,998,165,031,400 | publish all models in this queryset | publish/models.py | publish | team-35/django-publish | python | def publish(self, all_published=None):
if (all_published is None):
all_published = NestedSet()
for p in self:
p.publish(all_published=all_published) |
def delete(self, mark_for_deletion=True):
'\n override delete so that we call delete on each object separately, as delete needs\n to set some flags etc\n '
for p in self:
p.delete(mark_for_deletion=mark_for_deletion) | 5,955,300,016,194,922,000 | override delete so that we call delete on each object separately, as delete needs
to set some flags etc | publish/models.py | delete | team-35/django-publish | python | def delete(self, mark_for_deletion=True):
'\n override delete so that we call delete on each object separately, as delete needs\n to set some flags etc\n '
for p in self:
p.delete(mark_for_deletion=mark_for_deletion) |
def changed(self):
'all draft objects that have not been published yet'
return self.get_query_set().changed() | 5,233,656,181,255,264,000 | all draft objects that have not been published yet | publish/models.py | changed | team-35/django-publish | python | def changed(self):
return self.get_query_set().changed() |
def deleted(self):
'public objects that need deleting'
return self.get_query_set().deleted() | 191,633,847,673,881,540 | public objects that need deleting | publish/models.py | deleted | team-35/django-publish | python | def deleted(self):
return self.get_query_set().deleted() |
def draft(self):
'all draft objects'
return self.get_query_set().draft() | 328,280,275,420,383,740 | all draft objects | publish/models.py | draft | team-35/django-publish | python | def draft(self):
return self.get_query_set().draft() |
def published(self):
'all public/published objects'
return self.get_query_set().published() | -2,110,702,919,340,123,000 | all public/published objects | publish/models.py | published | team-35/django-publish | python | def published(self):
return self.get_query_set().published() |
def publish(self, dry_run=False, all_published=None, parent=None):
'\n either publish changes or deletions, depending on\n whether this model is public or draft.\n \n public models will be examined to see if they need deleting\n and deleted if so.\n '
if self.is_public:
... | 5,369,444,120,397,917,000 | either publish changes or deletions, depending on
whether this model is public or draft.
public models will be examined to see if they need deleting
and deleted if so. | publish/models.py | publish | team-35/django-publish | python | def publish(self, dry_run=False, all_published=None, parent=None):
'\n either publish changes or deletions, depending on\n whether this model is public or draft.\n \n public models will be examined to see if they need deleting\n and deleted if so.\n '
if self.is_public:
... |
def unpublish(self, dry_run=False):
'\n unpublish models by deleting public model\n '
if self.is_public:
raise UnpublishException('Cannot unpublish a public model - unpublish should be called from draft model')
if (self.pk is None):
raise UnpublishException('Please save the mod... | -8,653,058,200,630,890,000 | unpublish models by deleting public model | publish/models.py | unpublish | team-35/django-publish | python | def unpublish(self, dry_run=False):
'\n \n '
if self.is_public:
raise UnpublishException('Cannot unpublish a public model - unpublish should be called from draft model')
if (self.pk is None):
raise UnpublishException('Please save the model before unpublishing')
public_model... |
def _get_through_model(self, field_object):
'\n Get the "through" model associated with this field.\n Need to handle things differently for Django1.1 vs Django1.2\n In 1.1 through is a string and through_model has class\n In 1.2 through is the class\n '
through = field_object.... | 6,883,625,740,727,871,000 | Get the "through" model associated with this field.
Need to handle things differently for Django1.1 vs Django1.2
In 1.1 through is a string and through_model has class
In 1.2 through is the class | publish/models.py | _get_through_model | team-35/django-publish | python | def _get_through_model(self, field_object):
'\n Get the "through" model associated with this field.\n Need to handle things differently for Django1.1 vs Django1.2\n In 1.1 through is a string and through_model has class\n In 1.2 through is the class\n '
through = field_object.... |
def publish_changes(self, dry_run=False, all_published=None, parent=None):
"\n publish changes to the model - basically copy all of it's content to another copy in the \n database.\n if you set dry_run=True nothing will be written to the database. combined with\n the all_published value... | 4,687,598,719,083,719,000 | publish changes to the model - basically copy all of it's content to another copy in the
database.
if you set dry_run=True nothing will be written to the database. combined with
the all_published value one can therefore get information about what other models
would be affected by this function | publish/models.py | publish_changes | team-35/django-publish | python | def publish_changes(self, dry_run=False, all_published=None, parent=None):
"\n publish changes to the model - basically copy all of it's content to another copy in the \n database.\n if you set dry_run=True nothing will be written to the database. combined with\n the all_published value... |
def publish_deletions(self, all_published=None, parent=None, dry_run=False):
'\n actually delete models that have been marked for deletion\n '
if (self.publish_state != Publishable.PUBLISH_DELETE):
return
if (all_published is None):
all_published = NestedSet()
if (self in a... | 2,755,846,888,489,863,000 | actually delete models that have been marked for deletion | publish/models.py | publish_deletions | team-35/django-publish | python | def publish_deletions(self, all_published=None, parent=None, dry_run=False):
'\n \n '
if (self.publish_state != Publishable.PUBLISH_DELETE):
return
if (all_published is None):
all_published = NestedSet()
if (self in all_published):
return
all_published.add(self,... |
@classmethod
def find_publish_function(cls, field_name, default_function):
'\n Search to see if there is a function to copy the given field over.\n Function should take same params as setattr()\n '
for clazz in cls.__mro__:
publish_functions = getattr(clazz, 'pub... | 6,173,340,320,263,965,000 | Search to see if there is a function to copy the given field over.
Function should take same params as setattr() | publish/models.py | find_publish_function | team-35/django-publish | python | @classmethod
def find_publish_function(cls, field_name, default_function):
'\n Search to see if there is a function to copy the given field over.\n Function should take same params as setattr()\n '
for clazz in cls.__mro__:
publish_functions = getattr(clazz, 'pub... |
@app.route('/verifyconn', methods=['GET'])
def verify_db_conn():
'\n Verifies the connection to the db.\n '
try:
labs_conn = psycopg2.connect(user=os.environ.get('aws_db_user'), password=os.environ.get('aws_db_password'), host=os.environ.get('aws_db_host'), port=os.environ.get('aws_db_port'), data... | 19,852,801,566,805,988 | Verifies the connection to the db. | routes.py | verify_db_conn | Minaramzey/Sauti-Africa-Market-Monitoring-DS | python | @app.route('/verifyconn', methods=['GET'])
def verify_db_conn():
'\n \n '
try:
labs_conn = psycopg2.connect(user=os.environ.get('aws_db_user'), password=os.environ.get('aws_db_password'), host=os.environ.get('aws_db_host'), port=os.environ.get('aws_db_port'), database=os.environ.get('aws_db_name')... |
def yield_result(value, output_name='result'):
"Explicitly yield a Output.\n\n Args:\n value (Any): The value of the Output to yield.\n output_name (Optional[str]): The name of the Output to yield. Default: 'result'.\n\n "
return MANAGER_FOR_NOTEBOOK_INSTANCE.yield_result(value, output_name) | 6,880,240,434,030,309,000 | Explicitly yield a Output.
Args:
value (Any): The value of the Output to yield.
output_name (Optional[str]): The name of the Output to yield. Default: 'result'. | python_modules/dagstermill/dagstermill/__init__.py | yield_result | atsuhiro/dagster | python | def yield_result(value, output_name='result'):
"Explicitly yield a Output.\n\n Args:\n value (Any): The value of the Output to yield.\n output_name (Optional[str]): The name of the Output to yield. Default: 'result'.\n\n "
return MANAGER_FOR_NOTEBOOK_INSTANCE.yield_result(value, output_name) |
def yield_event(dagster_event):
'Explicitly yield a dagster event such as a Materialization or ExpectationResult\n '
return MANAGER_FOR_NOTEBOOK_INSTANCE.yield_event(dagster_event) | -8,816,253,065,816,656,000 | Explicitly yield a dagster event such as a Materialization or ExpectationResult | python_modules/dagstermill/dagstermill/__init__.py | yield_event | atsuhiro/dagster | python | def yield_event(dagster_event):
'\n '
return MANAGER_FOR_NOTEBOOK_INSTANCE.yield_event(dagster_event) |
def get_undelete_queryset(self, layouts):
'\n Version trackers that have no references and whose content type is\n allowed by our field can be restored.\n '
VersionTracker = self.site.get_version_tracker_model()
return VersionTracker.objects.orphan().filter(working_copy__content_type_id... | 4,946,959,688,917,315,000 | Version trackers that have no references and whose content type is
allowed by our field can be restored. | widgy/contrib/widgy_mezzanine/admin.py | get_undelete_queryset | fusionbox/django-widgy | python | def get_undelete_queryset(self, layouts):
'\n Version trackers that have no references and whose content type is\n allowed by our field can be restored.\n '
VersionTracker = self.site.get_version_tracker_model()
return VersionTracker.objects.orphan().filter(working_copy__content_type_id... |
def initialize_locale():
'Set the locale to the users default setting\n and set ``_LOCALE_INITIALIZED`` to indicate whether\n ``get_text_width`` may run into trouble\n '
global _LOCALE_INITIALIZED, _LOCALE_INITIALIZATION_ERR
if (_LOCALE_INITIALIZED is False):
try:
locale.setloca... | -8,210,179,648,525,412,000 | Set the locale to the users default setting
and set ``_LOCALE_INITIALIZED`` to indicate whether
``get_text_width`` may run into trouble | dev/ref/display.py | initialize_locale | nrser/nansi.collections | python | def initialize_locale():
'Set the locale to the users default setting\n and set ``_LOCALE_INITIALIZED`` to indicate whether\n ``get_text_width`` may run into trouble\n '
global _LOCALE_INITIALIZED, _LOCALE_INITIALIZATION_ERR
if (_LOCALE_INITIALIZED is False):
try:
locale.setloca... |
def get_text_width(text):
"Function that utilizes ``wcswidth`` or ``wcwidth`` to determine the\n number of columns used to display a text string.\n\n We try first with ``wcswidth``, and fallback to iterating each\n character and using wcwidth individually, falling back to a value of 0\n for non-printabl... | -3,609,822,956,789,150,000 | Function that utilizes ``wcswidth`` or ``wcwidth`` to determine the
number of columns used to display a text string.
We try first with ``wcswidth``, and fallback to iterating each
character and using wcwidth individually, falling back to a value of 0
for non-printable wide characters
On Py2, this depends on ``locale.... | dev/ref/display.py | get_text_width | nrser/nansi.collections | python | def get_text_width(text):
"Function that utilizes ``wcswidth`` or ``wcwidth`` to determine the\n number of columns used to display a text string.\n\n We try first with ``wcswidth``, and fallback to iterating each\n character and using wcwidth individually, falling back to a value of 0\n for non-printabl... |
def display(self, msg, color=None, stderr=False, screen_only=False, log_only=False, newline=True):
' Display a message to the user\n\n Note: msg *must* be a unicode string to prevent UnicodeError tracebacks.\n '
nocolor = msg
if (not log_only):
has_newline = msg.endswith(u'\n')
... | 3,703,657,802,151,350,000 | Display a message to the user
Note: msg *must* be a unicode string to prevent UnicodeError tracebacks. | dev/ref/display.py | display | nrser/nansi.collections | python | def display(self, msg, color=None, stderr=False, screen_only=False, log_only=False, newline=True):
' Display a message to the user\n\n Note: msg *must* be a unicode string to prevent UnicodeError tracebacks.\n '
nocolor = msg
if (not log_only):
has_newline = msg.endswith(u'\n')
... |
def get_deprecation_message(self, msg, version=None, removed=False, date=None, collection_name=None):
' used to print out a deprecation message.'
msg = msg.strip()
if (msg and (msg[(- 1)] not in ['!', '?', '.'])):
msg += '.'
if (collection_name == 'ansible.builtin'):
collection_name = 'a... | 7,637,081,892,293,506,000 | used to print out a deprecation message. | dev/ref/display.py | get_deprecation_message | nrser/nansi.collections | python | def get_deprecation_message(self, msg, version=None, removed=False, date=None, collection_name=None):
' '
msg = msg.strip()
if (msg and (msg[(- 1)] not in ['!', '?', '.'])):
msg += '.'
if (collection_name == 'ansible.builtin'):
collection_name = 'ansible-base'
if removed:
hea... |
def banner(self, msg, color=None, cows=True):
'\n Prints a header-looking line with cowsay or stars with length depending on terminal width (3 minimum)\n '
msg = to_text(msg)
if (self.b_cowsay and cows):
try:
self.banner_cowsay(msg)
return
except OSError... | -4,591,131,243,943,156,700 | Prints a header-looking line with cowsay or stars with length depending on terminal width (3 minimum) | dev/ref/display.py | banner | nrser/nansi.collections | python | def banner(self, msg, color=None, cows=True):
'\n \n '
msg = to_text(msg)
if (self.b_cowsay and cows):
try:
self.banner_cowsay(msg)
return
except OSError:
self.warning('somebody cleverly deleted cowsay or something during the PB run. heh.')
... |
def load_data(filename: str):
'\n Load house prices dataset and preprocess data.\n Parameters\n ----------\n filename: str\n Path to house prices dataset\n\n Returns\n -------\n Design matrix and response vector (prices) - either as a single\n DataFrame or a Tuple[DataFrame, Series]\n... | -5,054,370,289,392,005,000 | Load house prices dataset and preprocess data.
Parameters
----------
filename: str
Path to house prices dataset
Returns
-------
Design matrix and response vector (prices) - either as a single
DataFrame or a Tuple[DataFrame, Series] | exercises/house_price_prediction.py | load_data | shahaf-shafirstein/IML.HUJI | python | def load_data(filename: str):
'\n Load house prices dataset and preprocess data.\n Parameters\n ----------\n filename: str\n Path to house prices dataset\n\n Returns\n -------\n Design matrix and response vector (prices) - either as a single\n DataFrame or a Tuple[DataFrame, Series]\n... |
def feature_evaluation(X: pd.DataFrame, y: pd.Series, output_path: str='.') -> NoReturn:
'\n Create scatter plot between each feature and the response.\n - Plot title specifies feature name\n - Plot title specifies Pearson Correlation between feature and response\n - Plot saved under given f... | -5,545,909,993,239,813,000 | Create scatter plot between each feature and the response.
- Plot title specifies feature name
- Plot title specifies Pearson Correlation between feature and response
- Plot saved under given folder with file name including feature name
Parameters
----------
X : DataFrame of shape (n_samples, n_features)
... | exercises/house_price_prediction.py | feature_evaluation | shahaf-shafirstein/IML.HUJI | python | def feature_evaluation(X: pd.DataFrame, y: pd.Series, output_path: str='.') -> NoReturn:
'\n Create scatter plot between each feature and the response.\n - Plot title specifies feature name\n - Plot title specifies Pearson Correlation between feature and response\n - Plot saved under given f... |
@router.post('/wage_trade_transport_viz/')
async def wage_trade_transport_viz(user_queried_citystates: list):
'\n ### Path Parameter (POST from front-end)\n list: A list of city-states the user queried in this format: ["Albany, NY", "San Francisco, CA", "Chicago, IL"]\n\n ### Response\n JSON string of a... | 2,200,486,331,255,627,000 | ### Path Parameter (POST from front-end)
list: A list of city-states the user queried in this format: ["Albany, NY", "San Francisco, CA", "Chicago, IL"]
### Response
JSON string of all figures to render with [react-plotly.js](https://plotly.com/javascript/react/) | project/app/api/wage_trade_transport_viz.py | wage_trade_transport_viz | Lambda-School-Labs/Labs26-Citrics-DS-TeamC | python | @router.post('/wage_trade_transport_viz/')
async def wage_trade_transport_viz(user_queried_citystates: list):
'\n ### Path Parameter (POST from front-end)\n list: A list of city-states the user queried in this format: ["Albany, NY", "San Francisco, CA", "Chicago, IL"]\n\n ### Response\n JSON string of a... |
def cc_json():
'\n Opens county_city.json file, converts to .json object and returns it\n '
with open(join_path('app', 'db', 'city-county.json')) as f:
data_to_encode = json.load(f)
encoded_json = jsonable_encoder(data_to_encode)
county_city_json = json.dumps(encoded_json)
retu... | 8,053,087,424,007,477,000 | Opens county_city.json file, converts to .json object and returns it | project/app/api/wage_trade_transport_viz.py | cc_json | Lambda-School-Labs/Labs26-Citrics-DS-TeamC | python | def cc_json():
'\n \n '
with open(join_path('app', 'db', 'city-county.json')) as f:
data_to_encode = json.load(f)
encoded_json = jsonable_encoder(data_to_encode)
county_city_json = json.dumps(encoded_json)
return county_city_json |
def sql_query(county_list):
"\n Create a SQL query to grab only the user queried cities' data from the covid table in the DB.\n Output: subset grouped DF by month and city with only queried cities\n "
list_length = len(county_list)
if (list_length == 1):
county1 = county_list[0]... | 1,893,549,275,785,273,600 | Create a SQL query to grab only the user queried cities' data from the covid table in the DB.
Output: subset grouped DF by month and city with only queried cities | project/app/api/wage_trade_transport_viz.py | sql_query | Lambda-School-Labs/Labs26-Citrics-DS-TeamC | python | def sql_query(county_list):
"\n Create a SQL query to grab only the user queried cities' data from the covid table in the DB.\n Output: subset grouped DF by month and city with only queried cities\n "
list_length = len(county_list)
if (list_length == 1):
county1 = county_list[0]... |
def route(self, rule, **options):
"A decorator that is used to register a view function for a\n given URL rule. This does the same thing as :meth:`add_url_rule`\n but is intended for decorator usage::\n @app.route('/')\n def index():\n return 'Hello World'\n ... | -9,106,071,299,253,898,000 | A decorator that is used to register a view function for a
given URL rule. This does the same thing as :meth:`add_url_rule`
but is intended for decorator usage::
@app.route('/')
def index():
return 'Hello World'
For more information refer to :ref:`url-route-registrations`.
:param rule: the URL rule as ... | telebot/__init__.py | route | KyleJamesWalker/telebot | python | def route(self, rule, **options):
"A decorator that is used to register a view function for a\n given URL rule. This does the same thing as :meth:`add_url_rule`\n but is intended for decorator usage::\n @app.route('/')\n def index():\n return 'Hello World'\n ... |
def _start(self):
'Requests bot information based on current api_key, and sets\n self.whoami to dictionary with username, first_name, and id of the\n configured bot.\n\n '
if (self.whoami is None):
me = self.get_me()
if me.get('ok', False):
self.whoami = me['resu... | 843,249,728,321,361,500 | Requests bot information based on current api_key, and sets
self.whoami to dictionary with username, first_name, and id of the
configured bot. | telebot/__init__.py | _start | KyleJamesWalker/telebot | python | def _start(self):
'Requests bot information based on current api_key, and sets\n self.whoami to dictionary with username, first_name, and id of the\n configured bot.\n\n '
if (self.whoami is None):
me = self.get_me()
if me.get('ok', False):
self.whoami = me['resu... |
def poll(self, offset=None, poll_timeout=600, cooldown=60, debug=False):
'These should also be in the config section, but some here for\n overrides\n\n '
if (self.config['api_key'] is None):
raise ValueError('config api_key is undefined')
if (offset or self.config.get('offset', None)):... | -5,501,767,654,285,255,000 | These should also be in the config section, but some here for
overrides | telebot/__init__.py | poll | KyleJamesWalker/telebot | python | def poll(self, offset=None, poll_timeout=600, cooldown=60, debug=False):
'These should also be in the config section, but some here for\n overrides\n\n '
if (self.config['api_key'] is None):
raise ValueError('config api_key is undefined')
if (offset or self.config.get('offset', None)):... |
def get_me(self):
"A simple method for testing your bot's auth token. Requires no\n parameters. Returns basic information about the bot in form of a `User\n object.\n\n "
return self._bot_cmd(requests.get, 'getMe') | 6,949,463,330,401,890,000 | A simple method for testing your bot's auth token. Requires no
parameters. Returns basic information about the bot in form of a `User
object. | telebot/__init__.py | get_me | KyleJamesWalker/telebot | python | def get_me(self):
"A simple method for testing your bot's auth token. Requires no\n parameters. Returns basic information about the bot in form of a `User\n object.\n\n "
return self._bot_cmd(requests.get, 'getMe') |
def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions]=None, end_ip_address: Optional[pulumi.Input[str]]=None, firewall_rule_name: Optional[pulumi.Input[str]]=None, resource_group_name: Optional[pulumi.Input[str]]=None, server_name: Optional[pulumi.Input[str]]=None, start_ip_address: Optional... | 7,559,605,642,026,564,000 | Represents a server firewall rule.
API Version: 2014-04-01.
:param str resource_name: The name of the resource.
:param pulumi.ResourceOptions opts: Options for the resource.
:param pulumi.Input[str] end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAd... | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | __init__ | pulumi/pulumi-azure-nextgen | python | def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions]=None, end_ip_address: Optional[pulumi.Input[str]]=None, firewall_rule_name: Optional[pulumi.Input[str]]=None, resource_group_name: Optional[pulumi.Input[str]]=None, server_name: Optional[pulumi.Input[str]]=None, start_ip_address: Optional... |
@staticmethod
def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions]=None) -> 'FirewallRule':
"\n Get an existing FirewallRule resource's state with the given name, id, and optional extra\n properties used to qualify the lookup.\n\n :param str resource_name: T... | 780,077,911,701,839,000 | Get an existing FirewallRule resource's state with the given name, id, and optional extra
properties used to qualify the lookup.
:param str resource_name: The unique name of the resulting resource.
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
:param pulumi.ResourceOptions opts: Option... | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | get | pulumi/pulumi-azure-nextgen | python | @staticmethod
def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions]=None) -> 'FirewallRule':
"\n Get an existing FirewallRule resource's state with the given name, id, and optional extra\n properties used to qualify the lookup.\n\n :param str resource_name: T... |
@property
@pulumi.getter(name='endIpAddress')
def end_ip_address(self) -> pulumi.Output[str]:
"\n The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. Use value '0.0.0.0' to represent all Azure-internal IP addresses.\n "
return pulumi.get(s... | -6,011,145,057,549,834,000 | The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. Use value '0.0.0.0' to represent all Azure-internal IP addresses. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | end_ip_address | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter(name='endIpAddress')
def end_ip_address(self) -> pulumi.Output[str]:
"\n \n "
return pulumi.get(self, 'end_ip_address') |
@property
@pulumi.getter
def kind(self) -> pulumi.Output[str]:
'\n Kind of server that contains this firewall rule.\n '
return pulumi.get(self, 'kind') | -2,483,314,717,807,780,400 | Kind of server that contains this firewall rule. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | kind | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter
def kind(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'kind') |
@property
@pulumi.getter
def location(self) -> pulumi.Output[str]:
'\n Location of the server that contains this firewall rule.\n '
return pulumi.get(self, 'location') | -5,386,521,884,093,667,000 | Location of the server that contains this firewall rule. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | location | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter
def location(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'location') |
@property
@pulumi.getter
def name(self) -> pulumi.Output[str]:
'\n Resource name.\n '
return pulumi.get(self, 'name') | 4,695,236,134,441,039,000 | Resource name. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | name | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter
def name(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'name') |
@property
@pulumi.getter(name='startIpAddress')
def start_ip_address(self) -> pulumi.Output[str]:
"\n The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' to represent all Azure-internal IP addresses.\n "
return pulumi.get(self, 'start_ip_address') | 5,789,904,896,928,772,000 | The start IP address of the firewall rule. Must be IPv4 format. Use value '0.0.0.0' to represent all Azure-internal IP addresses. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | start_ip_address | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter(name='startIpAddress')
def start_ip_address(self) -> pulumi.Output[str]:
"\n \n "
return pulumi.get(self, 'start_ip_address') |
@property
@pulumi.getter
def type(self) -> pulumi.Output[str]:
'\n Resource type.\n '
return pulumi.get(self, 'type') | 2,132,950,812,122,862,800 | Resource type. | sdk/python/pulumi_azure_nextgen/sql/firewall_rule.py | type | pulumi/pulumi-azure-nextgen | python | @property
@pulumi.getter
def type(self) -> pulumi.Output[str]:
'\n \n '
return pulumi.get(self, 'type') |
def test_reader_macro_error():
'Check if we get correct error with wrong disptach character'
try:
macroexpand(tokenize("(dispatch_reader_macro '- '())")[0], __name__)
except HyTypeError as e:
assert ('with the character `-`' in str(e)) | 2,269,334,320,623,377,400 | Check if we get correct error with wrong disptach character | tests/macros/test_reader_macros.py | test_reader_macro_error | ALSchwalm/hy | python | def test_reader_macro_error():
try:
macroexpand(tokenize("(dispatch_reader_macro '- '())")[0], __name__)
except HyTypeError as e:
assert ('with the character `-`' in str(e)) |
def testSize(self):
'StringStream.size()'
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.size(), 3) | -322,479,714,288,370,940 | StringStream.size() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testSize | MichaelReiter/CSC435 | python | def testSize(self):
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.size(), 3) |
def testIndex(self):
'StringStream.index()'
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.index(), 0) | -5,824,447,261,540,887,000 | StringStream.index() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testIndex | MichaelReiter/CSC435 | python | def testIndex(self):
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.index(), 0) |
def testConsume(self):
'StringStream.consume()'
stream = antlr3.StringStream('foo\nbar')
stream.consume()
self.failUnlessEqual(stream.index(), 1)
self.failUnlessEqual(stream.charPositionInLine, 1)
self.failUnlessEqual(stream.line, 1)
stream.consume()
self.failUnlessEqual(stream.index(), ... | 5,337,832,459,246,330,000 | StringStream.consume() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testConsume | MichaelReiter/CSC435 | python | def testConsume(self):
stream = antlr3.StringStream('foo\nbar')
stream.consume()
self.failUnlessEqual(stream.index(), 1)
self.failUnlessEqual(stream.charPositionInLine, 1)
self.failUnlessEqual(stream.line, 1)
stream.consume()
self.failUnlessEqual(stream.index(), 2)
self.failUnlessEq... |
def testReset(self):
'StringStream.reset()'
stream = antlr3.StringStream('foo')
stream.consume()
stream.consume()
stream.reset()
self.failUnlessEqual(stream.index(), 0)
self.failUnlessEqual(stream.line, 1)
self.failUnlessEqual(stream.charPositionInLine, 0)
self.failUnlessEqual(stream... | 2,610,206,022,317,359,000 | StringStream.reset() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testReset | MichaelReiter/CSC435 | python | def testReset(self):
stream = antlr3.StringStream('foo')
stream.consume()
stream.consume()
stream.reset()
self.failUnlessEqual(stream.index(), 0)
self.failUnlessEqual(stream.line, 1)
self.failUnlessEqual(stream.charPositionInLine, 0)
self.failUnlessEqual(stream.LA(1), 'f') |
def testLA(self):
'StringStream.LA()'
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.LA(1), 'f')
self.failUnlessEqual(stream.LA(2), 'o')
self.failUnlessEqual(stream.LA(3), 'o')
stream.consume()
stream.consume()
self.failUnlessEqual(stream.LA(1), 'o')
self.failUnlessE... | -1,285,289,739,290,805,000 | StringStream.LA() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLA | MichaelReiter/CSC435 | python | def testLA(self):
stream = antlr3.StringStream('foo')
self.failUnlessEqual(stream.LA(1), 'f')
self.failUnlessEqual(stream.LA(2), 'o')
self.failUnlessEqual(stream.LA(3), 'o')
stream.consume()
stream.consume()
self.failUnlessEqual(stream.LA(1), 'o')
self.failUnlessEqual(stream.LA(2), ... |
def testSubstring(self):
'StringStream.substring()'
stream = antlr3.StringStream('foobar')
self.failUnlessEqual(stream.substring(0, 0), 'f')
self.failUnlessEqual(stream.substring(0, 1), 'fo')
self.failUnlessEqual(stream.substring(0, 5), 'foobar')
self.failUnlessEqual(stream.substring(3, 5), 'bar... | 1,467,413,615,876,884,200 | StringStream.substring() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testSubstring | MichaelReiter/CSC435 | python | def testSubstring(self):
stream = antlr3.StringStream('foobar')
self.failUnlessEqual(stream.substring(0, 0), 'f')
self.failUnlessEqual(stream.substring(0, 1), 'fo')
self.failUnlessEqual(stream.substring(0, 5), 'foobar')
self.failUnlessEqual(stream.substring(3, 5), 'bar') |
def testSeekForward(self):
'StringStream.seek(): forward'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
self.failUnlessEqual(stream.index(), 4)
self.failUnlessEqual(stream.line, 2)
self.failUnlessEqual(stream.charPositionInLine, 0)
self.failUnlessEqual(stream.LA(1), 'b') | -6,447,231,333,538,386,000 | StringStream.seek(): forward | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testSeekForward | MichaelReiter/CSC435 | python | def testSeekForward(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
self.failUnlessEqual(stream.index(), 4)
self.failUnlessEqual(stream.line, 2)
self.failUnlessEqual(stream.charPositionInLine, 0)
self.failUnlessEqual(stream.LA(1), 'b') |
def testMark(self):
'StringStream.mark()'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker = stream.mark()
self.failUnlessEqual(marker, 1)
self.failUnlessEqual(stream.markDepth, 1)
stream.consume()
marker = stream.mark()
self.failUnlessEqual(marker, 2)
self.failUnle... | 6,075,229,385,085,667,000 | StringStream.mark() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testMark | MichaelReiter/CSC435 | python | def testMark(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker = stream.mark()
self.failUnlessEqual(marker, 1)
self.failUnlessEqual(stream.markDepth, 1)
stream.consume()
marker = stream.mark()
self.failUnlessEqual(marker, 2)
self.failUnlessEqual(stream.markDe... |
def testReleaseLast(self):
'StringStream.release(): last marker'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.release()
self.failUnlessEqual(stream.markDepth, 1)
stream.release()
self.failUnlessEqu... | 7,445,008,543,421,783,000 | StringStream.release(): last marker | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testReleaseLast | MichaelReiter/CSC435 | python | def testReleaseLast(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.release()
self.failUnlessEqual(stream.markDepth, 1)
stream.release()
self.failUnlessEqual(stream.markDepth, 1) |
def testReleaseNested(self):
'StringStream.release(): nested'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.consume()
marker3 = stream.mark()
stream.release(marker2)
self.failUnlessEqual(stream.mark... | -5,503,462,820,693,028,000 | StringStream.release(): nested | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testReleaseNested | MichaelReiter/CSC435 | python | def testReleaseNested(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.consume()
marker3 = stream.mark()
stream.release(marker2)
self.failUnlessEqual(stream.markDepth, 1) |
def testRewindLast(self):
'StringStream.rewind(): last marker'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker = stream.mark()
stream.consume()
stream.consume()
stream.rewind()
self.failUnlessEqual(stream.markDepth, 0)
self.failUnlessEqual(stream.index(), 4)
self.f... | 1,729,413,339,423,644,400 | StringStream.rewind(): last marker | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testRewindLast | MichaelReiter/CSC435 | python | def testRewindLast(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker = stream.mark()
stream.consume()
stream.consume()
stream.rewind()
self.failUnlessEqual(stream.markDepth, 0)
self.failUnlessEqual(stream.index(), 4)
self.failUnlessEqual(stream.line, 2)
s... |
def testRewindNested(self):
'StringStream.rewind(): nested'
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.consume()
marker3 = stream.mark()
stream.rewind(marker2)
self.failUnlessEqual(stream.markDep... | -7,967,589,814,892,422,000 | StringStream.rewind(): nested | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testRewindNested | MichaelReiter/CSC435 | python | def testRewindNested(self):
stream = antlr3.StringStream('foo\nbar')
stream.seek(4)
marker1 = stream.mark()
stream.consume()
marker2 = stream.mark()
stream.consume()
marker3 = stream.mark()
stream.rewind(marker2)
self.failUnlessEqual(stream.markDepth, 1)
self.failUnlessEqual... |
def setUp(self):
'Setup test fixure\n\n The constructor of CommonTokenStream needs a token source. This\n is a simple mock class providing just the nextToken() method.\n\n '
class MockSource(object):
def __init__(self):
self.tokens = []
def nextToken(self):
... | -2,530,157,666,490,650,600 | Setup test fixure
The constructor of CommonTokenStream needs a token source. This
is a simple mock class providing just the nextToken() method. | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | setUp | MichaelReiter/CSC435 | python | def setUp(self):
'Setup test fixure\n\n The constructor of CommonTokenStream needs a token source. This\n is a simple mock class providing just the nextToken() method.\n\n '
class MockSource(object):
def __init__(self):
self.tokens = []
def nextToken(self):
... |
def testInit(self):
'CommonTokenStream.__init__()'
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(stream.index(), (- 1)) | -4,199,622,006,587,378,000 | CommonTokenStream.__init__() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testInit | MichaelReiter/CSC435 | python | def testInit(self):
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(stream.index(), (- 1)) |
def testSetTokenSource(self):
'CommonTokenStream.setTokenSource()'
stream = antlr3.CommonTokenStream(None)
stream.setTokenSource(self.source)
self.failUnlessEqual(stream.index(), (- 1))
self.failUnlessEqual(stream.channel, antlr3.DEFAULT_CHANNEL) | 8,845,780,895,028,450,000 | CommonTokenStream.setTokenSource() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testSetTokenSource | MichaelReiter/CSC435 | python | def testSetTokenSource(self):
stream = antlr3.CommonTokenStream(None)
stream.setTokenSource(self.source)
self.failUnlessEqual(stream.index(), (- 1))
self.failUnlessEqual(stream.channel, antlr3.DEFAULT_CHANNEL) |
def testLTEmptySource(self):
'CommonTokenStream.LT(): EOF (empty source)'
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnlessEqual(lt1.type, antlr3.EOF) | -1,308,497,428,755,781,000 | CommonTokenStream.LT(): EOF (empty source) | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLTEmptySource | MichaelReiter/CSC435 | python | def testLTEmptySource(self):
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnlessEqual(lt1.type, antlr3.EOF) |
def testLT1(self):
'CommonTokenStream.LT(1)'
self.source.tokens.append(antlr3.CommonToken(type=12))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnlessEqual(lt1.type, 12) | 4,769,722,576,293,040,000 | CommonTokenStream.LT(1) | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLT1 | MichaelReiter/CSC435 | python | def testLT1(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnlessEqual(lt1.type, 12) |
def testLT1WithHidden(self):
'CommonTokenStream.LT(1): with hidden tokens'
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnles... | -1,167,620,246,653,067,800 | CommonTokenStream.LT(1): with hidden tokens | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLT1WithHidden | MichaelReiter/CSC435 | python | def testLT1WithHidden(self):
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(1)
self.failUnlessEqual(lt1.type, 13) |
def testLT2BeyondEnd(self):
'CommonTokenStream.LT(2): beyond end'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13, channel=antlr3.HIDDEN_CHANNEL))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(2)
self.failUnlessEqual(lt... | 5,829,866,680,724,612,000 | CommonTokenStream.LT(2): beyond end | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLT2BeyondEnd | MichaelReiter/CSC435 | python | def testLT2BeyondEnd(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13, channel=antlr3.HIDDEN_CHANNEL))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(2)
self.failUnlessEqual(lt1.type, antlr3.EOF) |
def testLTNegative(self):
'CommonTokenStream.LT(-1): look back'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuffer()
stream.consume()
lt1 = stream.LT((- 1))
self.fa... | 8,833,826,822,500,224,000 | CommonTokenStream.LT(-1): look back | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLTNegative | MichaelReiter/CSC435 | python | def testLTNegative(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuffer()
stream.consume()
lt1 = stream.LT((- 1))
self.failUnlessEqual(lt1.type, 12) |
def testLB1(self):
'CommonTokenStream.LB(1)'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuffer()
stream.consume()
self.failUnlessEqual(stream.LB(1).type, 12) | -3,394,678,491,536,926,700 | CommonTokenStream.LB(1) | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLB1 | MichaelReiter/CSC435 | python | def testLB1(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuffer()
stream.consume()
self.failUnlessEqual(stream.LB(1).type, 12) |
def testLTZero(self):
'CommonTokenStream.LT(0)'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(0)
self.failUnless((lt1 is None)) | -3,495,325,699,316,676,000 | CommonTokenStream.LT(0) | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLTZero | MichaelReiter/CSC435 | python | def testLTZero(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
stream = antlr3.CommonTokenStream(self.source)
lt1 = stream.LT(0)
self.failUnless((lt1 is None)) |
def testLBBeyondBegin(self):
'CommonTokenStream.LB(-1): beyond begin'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
sel... | 8,140,744,220,851,901,000 | CommonTokenStream.LB(-1): beyond begin | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testLBBeyondBegin | MichaelReiter/CSC435 | python | def testLBBeyondBegin(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
self.source.tokens.append(antlr3.CommonToken(type=12, channel=antlr3.HIDDEN_CHANNEL))
self.source.tokens.append(antlr3.CommonToke... |
def testFillBuffer(self):
'CommonTokenStream.fillBuffer()'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=14))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = ... | -3,472,367,152,560,268,000 | CommonTokenStream.fillBuffer() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testFillBuffer | MichaelReiter/CSC435 | python | def testFillBuffer(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=14))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.so... |
def testConsume(self):
'CommonTokenStream.consume()'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(st... | 6,766,146,186,820,755,000 | CommonTokenStream.consume() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testConsume | MichaelReiter/CSC435 | python | def testConsume(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(stream.LA(1), 12)
stream.co... |
def testSeek(self):
'CommonTokenStream.seek()'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(stream.L... | -4,544,802,292,615,620,000 | CommonTokenStream.seek() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testSeek | MichaelReiter/CSC435 | python | def testSeek(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
self.failUnlessEqual(stream.LA(1), 12)
stream.seek(... |
def testMarkRewind(self):
'CommonTokenStream.mark()/rewind()'
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuf... | -8,019,132,124,511,811,000 | CommonTokenStream.mark()/rewind() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testMarkRewind | MichaelReiter/CSC435 | python | def testMarkRewind(self):
self.source.tokens.append(antlr3.CommonToken(type=12))
self.source.tokens.append(antlr3.CommonToken(type=13))
self.source.tokens.append(antlr3.CommonToken(type=antlr3.EOF))
stream = antlr3.CommonTokenStream(self.source)
stream.fillBuffer()
stream.consume()
mark... |
def testToString(self):
'CommonTokenStream.toString()'
self.source.tokens.append(antlr3.CommonToken(type=12, text='foo'))
self.source.tokens.append(antlr3.CommonToken(type=13, text='bar'))
self.source.tokens.append(antlr3.CommonToken(type=14, text='gnurz'))
self.source.tokens.append(antlr3.CommonTok... | -7,940,443,880,603,264,000 | CommonTokenStream.toString() | libs/antlr-3.0.1/runtime/Python/unittests/teststreams.py | testToString | MichaelReiter/CSC435 | python | def testToString(self):
self.source.tokens.append(antlr3.CommonToken(type=12, text='foo'))
self.source.tokens.append(antlr3.CommonToken(type=13, text='bar'))
self.source.tokens.append(antlr3.CommonToken(type=14, text='gnurz'))
self.source.tokens.append(antlr3.CommonToken(type=15, text='blarz'))
... |
def __init__(self, version, account_sid, call_sid):
'\n Initialize the FeedbackList\n\n :param Version version: Version that contains the resource\n :param account_sid: The account_sid\n :param call_sid: A 34 character string that uniquely identifies this resource.\n\n :returns: t... | -6,445,122,197,132,084,000 | Initialize the FeedbackList
:param Version version: Version that contains the resource
:param account_sid: The account_sid
:param call_sid: A 34 character string that uniquely identifies this resource.
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackList
:rtype: twilio.rest.api.v2010.account.call.feedba... | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __init__ | Jason-Paprocki/hacknjit | python | def __init__(self, version, account_sid, call_sid):
'\n Initialize the FeedbackList\n\n :param Version version: Version that contains the resource\n :param account_sid: The account_sid\n :param call_sid: A 34 character string that uniquely identifies this resource.\n\n :returns: t... |
def get(self):
'\n Constructs a FeedbackContext\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n '
return FeedbackContext(self._version, account_sid=self._solution['account_sid'], call_si... | -5,516,110,987,726,009,000 | Constructs a FeedbackContext
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext
:rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | get | Jason-Paprocki/hacknjit | python | def get(self):
'\n Constructs a FeedbackContext\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n '
return FeedbackContext(self._version, account_sid=self._solution['account_sid'], call_si... |
def __call__(self):
'\n Constructs a FeedbackContext\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n '
return FeedbackContext(self._version, account_sid=self._solution['account_sid'], ca... | 8,107,067,688,638,152,000 | Constructs a FeedbackContext
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext
:rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __call__ | Jason-Paprocki/hacknjit | python | def __call__(self):
'\n Constructs a FeedbackContext\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackContext\n '
return FeedbackContext(self._version, account_sid=self._solution['account_sid'], ca... |
def __repr__(self):
'\n Provide a friendly representation\n\n :returns: Machine friendly representation\n :rtype: str\n '
return '<Twilio.Api.V2010.FeedbackList>' | 8,539,110,798,930,971,000 | Provide a friendly representation
:returns: Machine friendly representation
:rtype: str | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __repr__ | Jason-Paprocki/hacknjit | python | def __repr__(self):
'\n Provide a friendly representation\n\n :returns: Machine friendly representation\n :rtype: str\n '
return '<Twilio.Api.V2010.FeedbackList>' |
def __init__(self, version, response, solution):
'\n Initialize the FeedbackPage\n\n :param Version version: Version that contains the resource\n :param Response response: Response from the API\n :param account_sid: The account_sid\n :param call_sid: A 34 character string that uni... | -2,614,892,443,884,998,000 | Initialize the FeedbackPage
:param Version version: Version that contains the resource
:param Response response: Response from the API
:param account_sid: The account_sid
:param call_sid: A 34 character string that uniquely identifies this resource.
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackPage
:... | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __init__ | Jason-Paprocki/hacknjit | python | def __init__(self, version, response, solution):
'\n Initialize the FeedbackPage\n\n :param Version version: Version that contains the resource\n :param Response response: Response from the API\n :param account_sid: The account_sid\n :param call_sid: A 34 character string that uni... |
def get_instance(self, payload):
'\n Build an instance of FeedbackInstance\n\n :param dict payload: Payload response from the API\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance\n '
... | 4,555,122,512,957,802,500 | Build an instance of FeedbackInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance
:rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | get_instance | Jason-Paprocki/hacknjit | python | def get_instance(self, payload):
'\n Build an instance of FeedbackInstance\n\n :param dict payload: Payload response from the API\n\n :returns: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance\n :rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance\n '
... |
def __repr__(self):
'\n Provide a friendly representation\n\n :returns: Machine friendly representation\n :rtype: str\n '
return '<Twilio.Api.V2010.FeedbackPage>' | 2,946,648,061,124,807,000 | Provide a friendly representation
:returns: Machine friendly representation
:rtype: str | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __repr__ | Jason-Paprocki/hacknjit | python | def __repr__(self):
'\n Provide a friendly representation\n\n :returns: Machine friendly representation\n :rtype: str\n '
return '<Twilio.Api.V2010.FeedbackPage>' |
def __init__(self, version, account_sid, call_sid):
'\n Initialize the FeedbackContext\n\n :param Version version: Version that contains the resource\n :param account_sid: The account_sid\n :param call_sid: The call sid that uniquely identifies the call\n\n :returns: twilio.rest.a... | -7,519,640,124,503,953,000 | Initialize the FeedbackContext
:param Version version: Version that contains the resource
:param account_sid: The account_sid
:param call_sid: The call sid that uniquely identifies the call
:returns: twilio.rest.api.v2010.account.call.feedback.FeedbackContext
:rtype: twilio.rest.api.v2010.account.call.feedback.Feedba... | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | __init__ | Jason-Paprocki/hacknjit | python | def __init__(self, version, account_sid, call_sid):
'\n Initialize the FeedbackContext\n\n :param Version version: Version that contains the resource\n :param account_sid: The account_sid\n :param call_sid: The call sid that uniquely identifies the call\n\n :returns: twilio.rest.a... |
def create(self, quality_score, issue=values.unset):
'\n Create a new FeedbackInstance\n\n :param unicode quality_score: The quality_score\n :param FeedbackInstance.Issues issue: The issue\n\n :returns: Newly created FeedbackInstance\n :rtype: twilio.rest.api.v2010.account.call.fe... | 6,177,282,813,554,628,000 | Create a new FeedbackInstance
:param unicode quality_score: The quality_score
:param FeedbackInstance.Issues issue: The issue
:returns: Newly created FeedbackInstance
:rtype: twilio.rest.api.v2010.account.call.feedback.FeedbackInstance | lib/python2.7/site-packages/twilio/rest/api/v2010/account/call/feedback.py | create | Jason-Paprocki/hacknjit | python | def create(self, quality_score, issue=values.unset):
'\n Create a new FeedbackInstance\n\n :param unicode quality_score: The quality_score\n :param FeedbackInstance.Issues issue: The issue\n\n :returns: Newly created FeedbackInstance\n :rtype: twilio.rest.api.v2010.account.call.fe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.