Skip to content

Commit

Permalink
Docs: I.e., E.g.
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Aug 3, 2016
1 parent 29530fc commit 68d003a
Show file tree
Hide file tree
Showing 68 changed files with 227 additions and 216 deletions.
2 changes: 1 addition & 1 deletion celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def maybe_patch_concurrency(argv=sys.argv,
"""With short and long opt alternatives that specify the command line
option to set the pool, this makes sure that anything that needs
to be patched is completed as early as possible.
(e.g. eventlet/gevent monkey patches)."""
(e.g., eventlet/gevent monkey patches)."""
try:
pool = _find_option_with_arg(argv, short_opts, long_opts)
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion celery/app/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class AMQP(object):
_producer_pool = None

# Exchange class/function used when defining automatic queues.
# E.g. you can use ``autoexchange = lambda n: None`` to use the
# For example, you can use ``autoexchange = lambda n: None`` to use the
# AMQP default exchange: a shortcut to bypass routing
# and instead send directly to the queue named in the routing key.
autoexchange = None
Expand Down
11 changes: 6 additions & 5 deletions celery/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class to use. Default is :class:`celery.loaders.app.AppLoader`.
set_as_current (bool): Make this the global current app.
tasks (str, type): A task registry or the name of a registry class.
include (List[str]): List of modules every worker should import.
fixups (List[str]): List of fix-up plug-ins (see e.g.
fixups (List[str]): List of fix-up plug-ins (e.g., see
:mod:`celery.fixups.django`).
autofinalize (bool): If set to False a :exc:`RuntimeError`
will be raised if the task registry or tasks are used before
Expand Down Expand Up @@ -550,7 +550,7 @@ def autodiscover_tasks(self, packages=None,
"""Try to auto-discover and import modules with a specific name (by
default 'tasks').
If the name is empty, this will be delegated to fix-ups (e.g. Django).
If the name is empty, this will be delegated to fix-ups (e.g., Django).
For example if you have an directory layout like this:
Expand Down Expand Up @@ -619,7 +619,7 @@ def send_task(self, name, args=None, kwargs=None, countdown=None,
Supports the same arguments as :meth:`@-Task.apply_async`.
Arguments:
name (str): Name of task to call (e.g. `"tasks.add"`).
name (str): Name of task to call (e.g., `"tasks.add"`).
result_cls (~@AsyncResult): Specify custom result class.
"""
parent = have_parent = None
Expand Down Expand Up @@ -905,7 +905,7 @@ def subclass_with_self(self, Class, name=None, attribute='app',
to be this app instance.
App-compatible means that the class has a class attribute that
provides the default app it should use, e.g.
provides the default app it should use, for example:
``class Foo: app = None``.
Arguments:
Expand All @@ -914,7 +914,8 @@ def subclass_with_self(self, Class, name=None, attribute='app',
attribute (str): Name of the attribute holding the app,
Default is 'app'.
reverse (str): Reverse path to this object used for pickling
purposes. E.g. for ``app.AsyncResult`` use ``"AsyncResult"``.
purposes. For example, to get ``app.AsyncResult``,
use ``"AsyncResult"``.
keep_reduce (bool): If enabled a custom ``__reduce__``
implementation won't be provided.
"""
Expand Down
2 changes: 1 addition & 1 deletion celery/app/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Task(object):

#: Even if :attr:`acks_late` is enabled, the worker will
#: acknowledge tasks when the worker process executing them abruptly
#: exits or is signaled (e.g. :sig:`KILL`/:sig:`INT`, etc).
#: exits or is signaled (e.g., :sig:`KILL`/:sig:`INT`, etc).
#:
#: Setting this to true allows the message to be re-queued instead,
#: so that the task will execute again by the same worker, or another
Expand Down
2 changes: 1 addition & 1 deletion celery/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def detect_settings(conf, preconf={}, ignore_keys=set(), prefix=None,
info, left = _settings_info, set()

# only raise error for keys that the user didn't provide two keys
# for (e.g. both ``result_expires`` and ``CELERY_TASK_RESULT_EXPIRES``).
# for (e.g., both ``result_expires`` and ``CELERY_TASK_RESULT_EXPIRES``).
really_left = {key for key in left if info.convert[key] not in have}
if really_left:
# user is mixing old/new, or new/old settings, give renaming
Expand Down
2 changes: 1 addition & 1 deletion celery/apps/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def on_start(self):
app = self.app
WorkController.on_start(self)

# this signal can be used to e.g. change queues after
# this signal can be used to, for example, change queues after
# the -Q option has been applied.
signals.celeryd_after_setup.send(
sender=self.hostname, instance=self, conf=app.conf,
Expand Down
3 changes: 1 addition & 2 deletions celery/bin/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def coerce(self, index, value):
def str_args_to_python(self, arglist):
"""Process list of string arguments to values according to spec.
e.g::
Example:
>>> spec = Spec([('queue', str), ('if_unused', bool)])
>>> spec.str_args_to_python('pobox', 'true')
('pobox', True)
Expand Down
4 changes: 2 additions & 2 deletions celery/bin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ def with_pool_option(self, argv):
supports a pool argument, and used to monkey patch eventlet/gevent
environments as early as possible.
E.g::
has_pool_option = (['-P'], ['--pool'])
Example:
>>> has_pool_option = (['-P'], ['--pool'])
"""
pass

Expand Down
4 changes: 2 additions & 2 deletions celery/bin/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.. cmdoption:: -A, --app
app instance to use (e.g. ``module.attr_name``)
app instance to use (e.g., ``module.attr_name``)
.. cmdoption:: -b, --broker
Expand Down Expand Up @@ -994,7 +994,7 @@ def _backup(self, filename, suffix='.orig'):
return lines

def _to_new_key(self, line, keyfilter=pass1, source=defaults._TO_NEW_KEY):
# sort by length to avoid e.g. broker_transport overriding
# sort by length to avoid, for example, broker_transport overriding
# broker_transport_options.
for old_key in reversed(sorted(source, key=lambda x: len(x))):
new_line = line.replace(old_key, keyfilter(source[old_key]))
Expand Down
2 changes: 1 addition & 1 deletion celery/bin/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.. cmdoption:: -r, --maxrate
Camera: Optional shutter rate limit (e.g. 10/m).
Camera: Optional shutter rate limit (e.g., 10/m).
.. cmdoption:: -l, --loglevel
Expand Down
2 changes: 1 addition & 1 deletion celery/bin/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
.. cmdoption:: -n, --hostname
Set custom hostname, e.g. 'w1.%h'. Expands: %h (hostname),
Set custom hostname (e.g., 'w1@%h'). Expands: %h (hostname),
%n (name) and %d, (domain).
.. cmdoption:: -B, --beat
Expand Down
2 changes: 1 addition & 1 deletion celery/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def set(self, immutable=None, **options):
Returns:
Signature: This is a chaining method call
(i.e. it will return ``self``).
(i.e., it will return ``self``).
"""
if immutable is not None:
self.set_immutable(immutable)
Expand Down
2 changes: 1 addition & 1 deletion celery/concurrency/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Import from kombu directly as it's used
# early in the import stage, where celery.utils loads
# too much (e.g. for eventlet patching)
# too much (e.g., for eventlet patching)
from kombu.utils.imports import symbol_by_name

__all__ = ['get_implementation']
Expand Down
2 changes: 1 addition & 1 deletion celery/concurrency/asynpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def schedule_writes(ready_fds, total_write_count=[0]):
# with many processes, and also leans more towards fairness
# in write stats when used with many processes
# [XXX On macOS, this may vary depending
# on event loop implementation (i.e select vs epoll), so
# on event loop implementation (i.e, select/poll vs epoll), so
# have to test further]
num_ready = len(ready_fds)

Expand Down
3 changes: 1 addition & 2 deletions celery/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def Event(type, _fields=None, __dict__=dict, __now__=time.time, **fields):
def group_from(type):
"""Get the group part of an event type name.
E.g.::
Example:
>>> group_from('task-sent')
'task'
Expand Down
6 changes: 3 additions & 3 deletions celery/events/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Snapshots (:mod:`celery.events.snapshot`) can be used to
take "pictures" of this state at regular intervals
to e.g. store that in a database.
to for example, store that in a database.
"""
from __future__ import absolute_import, unicode_literals

Expand Down Expand Up @@ -260,7 +260,7 @@ class Task(object):
__slots__ = ('__dict__', '__weakref__')

#: How to merge out of order events.
#: Disorder is detected by logical ordering (e.g. :event:`task-received`
#: Disorder is detected by logical ordering (e.g., :event:`task-received`
#: must've happened before a :event:`task-failed` event).
#:
#: A merge rule consists of a state and a list of fields to keep from
Expand Down Expand Up @@ -304,7 +304,7 @@ def event(self, type_, timestamp=None, local_received=None, fields=None,
# using .get is faster than catching KeyError in this case.
state = task_event_to_state(type_)
if state is not None:
# sets e.g. self.succeeded to the timestamp.
# sets, for example, self.succeeded to the timestamp.
setattr(self, type_, timestamp)
else:
state = type_.upper() # custom state
Expand Down
2 changes: 1 addition & 1 deletion celery/five.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def fun_of_method(method): # noqa

def getappattr(path):
"""Gets attribute from the current_app recursively,
e.g. getappattr('amqp.get_task_consumer')``."""
(e.g., ``getappattr('amqp.get_task_consumer')``."""
from celery import current_app
return current_app._rgetattr(path)

Expand Down
6 changes: 3 additions & 3 deletions celery/loaders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def config_from_object(self, obj, silent=False):
def _smart_import(self, path, imp=None):
imp = self.import_module if imp is None else imp
if ':' in path:
# Path includes attribute so can just jump here.
# e.g. ``os.path:abspath``.
# Path includes attribute so can just jump
# here (e.g., ``os.path:abspath``).
return symbol_by_name(path, imp=imp)

# Not sure if path is just a module name or if it includes an
# attribute name (e.g. ``os.path``, vs, ``os.path.abspath``).
# attribute name (e.g., ``os.path``, vs, ``os.path.abspath``).
try:
return imp(path)
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion celery/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def set_mp_process_title(progname, info=None, hostname=None): # noqa


def get_errno_name(n):
"""Get errno for string, e.g. ``ENOENT``."""
"""Get errno for string (e.g., ``ENOENT``)."""
if isinstance(n, string_t):
return getattr(errno, n)
return n
Expand Down
2 changes: 1 addition & 1 deletion celery/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def join(self, timeout=None, propagate=True, interval=0.5,
Note:
This can be an expensive operation for result store
backends that must resort to polling (e.g. database).
backends that must resort to polling (e.g., database).
You should consider using :meth:`join_native` if your backend
supports it.
Expand Down
4 changes: 2 additions & 2 deletions celery/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def is_due(self, last_run_at):
.. admonition:: Scheduler max interval variance
The default max loop interval may vary for different schedulers.
For the default scheduler the value is 5 minutes, but for e.g.
For the default scheduler the value is 5 minutes, but for example
the :pypi:`django-celery` database scheduler the value
is 5 seconds.
"""
Expand Down Expand Up @@ -728,7 +728,7 @@ def __repr__(self):

def remaining_estimate(self, last_run_at):
"""Returns when the periodic task should run next as a
:class:`~datetime.timedelta`, or if it shouldn't run today (e.g.
:class:`~datetime.timedelta`, or if it shouldn't run today (e.g.,
the sun does not rise today), returns the time when the next check
should take place."""
last_run_at = self.maybe_make_aware(last_run_at)
Expand Down
2 changes: 1 addition & 1 deletion celery/task/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Task(BaseTask):
)

# In old Celery the @task decorator didn't exist, so one would create
# classes instead and use them directly (e.g. MyTask.apply_async()).
# classes instead and use them directly (e.g., MyTask.apply_async()).
# the use of classmethods was a hack so that it was not necessary
# to instantiate the class before using it, but it has only
# given us pain (like all magic).
Expand Down
6 changes: 2 additions & 4 deletions celery/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ def move_to_end(self, key, last=True):


class AttributeDictMixin(object):
"""Augment classes with a Mapping interface by adding attribute access.
I.e. `d.key -> d[key]`.
"""
"""Augment classes with a Mapping interface by adding attribute
access (i.e., `d.key -> d[key]`)."""

def __getattr__(self, k):
"""`d.key -> d[key]`"""
Expand Down
4 changes: 2 additions & 2 deletions celery/utils/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def memdump(samples=10, file=None): # pragma: no cover
def sample(x, n, k=0):
"""Given a list `x` a sample of length ``n`` of that list is returned.
E.g. if `n` is 10, and `x` has 100 items, a list of every tenth.
For example, if `n` is 10, and `x` has 100 items, a list of every tenth.
item is returned.
``k`` can be used as offset.
Expand All @@ -132,7 +132,7 @@ def hfloat(f, p=5):


def humanbytes(s):
"""Convert bytes to human-readable form (e.g. KB, MB)."""
"""Convert bytes to human-readable form (e.g., KB, MB)."""
return next(
'{0}{1}'.format(hfloat(s / div if div else s), unit)
for div, unit in UNITS if s >= div
Expand Down
8 changes: 4 additions & 4 deletions celery/utils/dispatch/saferef.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BoundMethodWeakref(object): # pragma: no cover
deletion_methods (Sequence[Callable]): Callables taking
single argument, a reference to this object which
will be called when *either* the target object or
target function is garbage collected (i.e. when
target function is garbage collected (i.e., when
this object becomes invalid). These are specified
as the on_delete parameters of :func:`safe_ref` calls.
Expand Down Expand Up @@ -122,7 +122,7 @@ def __init__(self, target, on_delete=None):
on_delete (Callable): Optional callback which will be called
when this weak reference ceases to be valid
(i.e. either the object or the function is garbage
(i.e., either the object or the function is garbage
collected). Should take a single argument,
which will be passed a pointer to this object.
"""
Expand Down Expand Up @@ -222,7 +222,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref): # pragma: no cover
>>> A.bar = foo
This shouldn't be a common use case. So, on platforms where methods
aren't descriptors (e.g. Jython) this implementation has the
aren't descriptors (e.g., Jython) this implementation has the
advantage of working in the most cases.
"""
def __init__(self, target, on_delete=None):
Expand All @@ -239,7 +239,7 @@ def __init__(self, target, on_delete=None):
on_delete (Callable): Optional callback which will be called
when this weak reference ceases to be valid
(i.e. either the object or the function is garbage
(i.e., either the object or the function is garbage
collected). Should take a single argument,
which will be passed a pointer to this object.
"""
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/nodenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def worker_direct(hostname):
Arguments:
hostname (str, ~kombu.Queue): The fully qualified node name of
a worker (e.g. ``[email protected]``). If passed a
a worker (e.g., ``[email protected]``). If passed a
:class:`kombu.Queue` instance it will simply return
that instead.
"""
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def find_pickleable_exception(exc, loads=pickle.loads,
dumps=pickle.dumps):
"""With an exception instance, iterate over its super classes (by MRO)
and find the first super exception that's pickleable. It does
not go below :exc:`Exception` (i.e. it skips :exc:`Exception`,
not go below :exc:`Exception` (i.e., it skips :exc:`Exception`,
:class:`BaseException` and :class:`object`). If that happens
you should use :exc:`UnpickleableException` instead.
Expand Down
12 changes: 6 additions & 6 deletions celery/utils/timeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ def remaining(start, ends_in, now=None, relative=False):
"""Calculate the remaining time for a start date and a
:class:`~datetime.timedelta`.
e.g. "how many seconds left for 30 seconds after start?"
For example, "how many seconds left for 30 seconds after start?"
Arguments:
start (~datetime.datetime): Starting date.
ends_in (~datetime.timedelta): The end delta.
relative (bool): If enabled the end time will be calculated
using :func:`delta_resolution` (i.e. rounded to the
using :func:`delta_resolution` (i.e., rounded to the
resolution of `ends_in`).
now (Callable): Function returning the current time and date.
Defaults to :func:`datetime.utcnow`.
Expand Down Expand Up @@ -244,12 +244,12 @@ def weekday(name):


def humanize_seconds(secs, prefix='', sep='', now='now', microseconds=False):
"""Show seconds in human form, e.g. 60 is "1 minute", 7200 is "2
hours".
"""Show seconds in human form (e.g., 60 is "1 minute", 7200 is "2
hours").
Arguments:
prefix (str): can be used to add a preposition to the output,
e.g. 'in' will give 'in 1 second', but add nothing to 'now'.
prefix (str): can be used to add a preposition to the output
(e.g., 'in' will give 'in 1 second', but add nothing to 'now').
now (str): Literal 'now'.
microseconds (bool): Include microseconds.
"""
Expand Down
Loading

0 comments on commit 68d003a

Please sign in to comment.