id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
246,100 | daknuett/py_register_machine2 | core/processor.py | Processor.interrupt | def interrupt(self, address):
"""
Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack.
"""
if(self.push_pc):
self.memory_bus.write_word(self.sp, self.pc)
self._set_sp(self.sp - 1)
self._set_pc(address) | python | def interrupt(self, address):
"""
Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack.
"""
if(self.push_pc):
self.memory_bus.write_word(self.sp, self.pc)
self._set_sp(self.sp - 1)
self._set_pc(address) | [
"def",
"interrupt",
"(",
"self",
",",
"address",
")",
":",
"if",
"(",
"self",
".",
"push_pc",
")",
":",
"self",
".",
"memory_bus",
".",
"write_word",
"(",
"self",
".",
"sp",
",",
"self",
".",
"pc",
")",
"self",
".",
"_set_sp",
"(",
"self",
".",
"... | Interrupts the Processor and forces him to jump to ``address``.
If ``push_pc`` is enabled this will push the PC to the stack. | [
"Interrupts",
"the",
"Processor",
"and",
"forces",
"him",
"to",
"jump",
"to",
"address",
".",
"If",
"push_pc",
"is",
"enabled",
"this",
"will",
"push",
"the",
"PC",
"to",
"the",
"stack",
"."
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/processor.py#L218-L226 |
246,101 | jamieleshaw/lurklib | lurklib/core.py | _Core._raw_recv | def _raw_recv(self):
""" Return the next available IRC message in the buffer. """
with self.lock:
if self._index >= len(self._buffer):
self._mcon()
if self._index >= 199:
self._resetbuffer()
self._mcon()
msg = self._buff... | python | def _raw_recv(self):
""" Return the next available IRC message in the buffer. """
with self.lock:
if self._index >= len(self._buffer):
self._mcon()
if self._index >= 199:
self._resetbuffer()
self._mcon()
msg = self._buff... | [
"def",
"_raw_recv",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"_index",
">=",
"len",
"(",
"self",
".",
"_buffer",
")",
":",
"self",
".",
"_mcon",
"(",
")",
"if",
"self",
".",
"_index",
">=",
"199",
":",
"self",
... | Return the next available IRC message in the buffer. | [
"Return",
"the",
"next",
"available",
"IRC",
"message",
"in",
"the",
"buffer",
"."
] | a861f35d880140422103dd78ec3239814e85fd7e | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/core.py#L146-L164 |
246,102 | jut-io/jut-python-tools | jut/commands/upload.py | post | def post(json_data,
url,
dry_run=False):
"""
POST json data to the url provided and verify the requests was successful
"""
if dry_run:
info('POST: %s' % json.dumps(json_data, indent=4))
else:
response = SESSION.post(url,
data=json.d... | python | def post(json_data,
url,
dry_run=False):
"""
POST json data to the url provided and verify the requests was successful
"""
if dry_run:
info('POST: %s' % json.dumps(json_data, indent=4))
else:
response = SESSION.post(url,
data=json.d... | [
"def",
"post",
"(",
"json_data",
",",
"url",
",",
"dry_run",
"=",
"False",
")",
":",
"if",
"dry_run",
":",
"info",
"(",
"'POST: %s'",
"%",
"json",
".",
"dumps",
"(",
"json_data",
",",
"indent",
"=",
"4",
")",
")",
"else",
":",
"response",
"=",
"SES... | POST json data to the url provided and verify the requests was successful | [
"POST",
"json",
"data",
"to",
"the",
"url",
"provided",
"and",
"verify",
"the",
"requests",
"was",
"successful"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/commands/upload.py#L19-L36 |
246,103 | jut-io/jut-python-tools | jut/commands/upload.py | push_json_file | def push_json_file(json_file,
url,
dry_run=False,
batch_size=100,
anonymize_fields=[],
remove_fields=[],
rename_fields=[]):
"""
read the json file provided and POST in batches no bigger than the
... | python | def push_json_file(json_file,
url,
dry_run=False,
batch_size=100,
anonymize_fields=[],
remove_fields=[],
rename_fields=[]):
"""
read the json file provided and POST in batches no bigger than the
... | [
"def",
"push_json_file",
"(",
"json_file",
",",
"url",
",",
"dry_run",
"=",
"False",
",",
"batch_size",
"=",
"100",
",",
"anonymize_fields",
"=",
"[",
"]",
",",
"remove_fields",
"=",
"[",
"]",
",",
"rename_fields",
"=",
"[",
"]",
")",
":",
"batch",
"="... | read the json file provided and POST in batches no bigger than the
batch_size specified to the specified url. | [
"read",
"the",
"json",
"file",
"provided",
"and",
"POST",
"in",
"batches",
"no",
"bigger",
"than",
"the",
"batch_size",
"specified",
"to",
"the",
"specified",
"url",
"."
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/commands/upload.py#L43-L93 |
246,104 | jmgilman/Neolib | neolib/shop/MainShop.py | MainShop.load | def load(self):
""" Loads the shop name and inventory
"""
pg = self.usr.getPage("http://www.neopets.com/objects.phtml?type=shop&obj_type=" + self.id)
self.name = pg.find("td", "contentModuleHeader").text.strip()
self.inventory = MainShopInventory(self.usr, self.id) | python | def load(self):
""" Loads the shop name and inventory
"""
pg = self.usr.getPage("http://www.neopets.com/objects.phtml?type=shop&obj_type=" + self.id)
self.name = pg.find("td", "contentModuleHeader").text.strip()
self.inventory = MainShopInventory(self.usr, self.id) | [
"def",
"load",
"(",
"self",
")",
":",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/objects.phtml?type=shop&obj_type=\"",
"+",
"self",
".",
"id",
")",
"self",
".",
"name",
"=",
"pg",
".",
"find",
"(",
"\"td\"",
",",
"\"conte... | Loads the shop name and inventory | [
"Loads",
"the",
"shop",
"name",
"and",
"inventory"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/shop/MainShop.py#L48-L54 |
246,105 | alfred82santa/aio-service-client | service_client/utils.py | random_token | def random_token(length=10):
"""
Builds a random string.
:param length: Token length. **Default:** 10
:type length: int
:return: str
"""
return ''.join(random.choice(string.ascii_uppercase + string.digits)
for _ in range(length)) | python | def random_token(length=10):
"""
Builds a random string.
:param length: Token length. **Default:** 10
:type length: int
:return: str
"""
return ''.join(random.choice(string.ascii_uppercase + string.digits)
for _ in range(length)) | [
"def",
"random_token",
"(",
"length",
"=",
"10",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
")"
] | Builds a random string.
:param length: Token length. **Default:** 10
:type length: int
:return: str | [
"Builds",
"a",
"random",
"string",
"."
] | dd9ad49e23067b22178534915aa23ba24f6ff39b | https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/utils.py#L43-L52 |
246,106 | sci-bots/mpm | mpm/commands.py | get_plugins_directory | def get_plugins_directory(config_path=None, microdrop_user_root=None):
'''
Resolve plugins directory.
Plugins directory is resolved as follows, highest-priority first:
1. ``plugins`` directory specified in provided :data:`config_path`.
2. ``plugins`` sub-directory of specified MicroDrop profile ... | python | def get_plugins_directory(config_path=None, microdrop_user_root=None):
'''
Resolve plugins directory.
Plugins directory is resolved as follows, highest-priority first:
1. ``plugins`` directory specified in provided :data:`config_path`.
2. ``plugins`` sub-directory of specified MicroDrop profile ... | [
"def",
"get_plugins_directory",
"(",
"config_path",
"=",
"None",
",",
"microdrop_user_root",
"=",
"None",
")",
":",
"RESOLVED_BY_NONE",
"=",
"'default'",
"RESOLVED_BY_CONFIG_ARG",
"=",
"'config_path argument'",
"RESOLVED_BY_PROFILE_ARG",
"=",
"'microdrop_user_root argument'",... | Resolve plugins directory.
Plugins directory is resolved as follows, highest-priority first:
1. ``plugins`` directory specified in provided :data:`config_path`.
2. ``plugins`` sub-directory of specified MicroDrop profile path (i.e.,
:data:`microdrop_user_root`)
3. ``plugins`` sub-directory ... | [
"Resolve",
"plugins",
"directory",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L45-L123 |
246,107 | sci-bots/mpm | mpm/commands.py | plugin_request | def plugin_request(plugin_str):
'''
Extract plugin name and version specifiers from plugin descriptor string.
.. versionchanged:: 0.25.2
Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_.
.. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5
'''
from pip_hel... | python | def plugin_request(plugin_str):
'''
Extract plugin name and version specifiers from plugin descriptor string.
.. versionchanged:: 0.25.2
Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_.
.. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5
'''
from pip_hel... | [
"def",
"plugin_request",
"(",
"plugin_str",
")",
":",
"from",
"pip_helpers",
"import",
"CRE_PACKAGE",
"match",
"=",
"CRE_PACKAGE",
".",
"match",
"(",
"plugin_str",
")",
"if",
"not",
"match",
":",
"raise",
"ValueError",
"(",
"'Invalid plugin descriptor. Must be like ... | Extract plugin name and version specifiers from plugin descriptor string.
.. versionchanged:: 0.25.2
Import from `pip_helpers` locally to avoid error `sci-bots/mpm#5`_.
.. _sci-bots/mpm#5: https://github.com/sci-bots/mpm/issues/5 | [
"Extract",
"plugin",
"name",
"and",
"version",
"specifiers",
"from",
"plugin",
"descriptor",
"string",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/commands.py#L126-L141 |
246,108 | billyoverton/tweetqueue | tweetqueue/__main__.py | tweetqueue | def tweetqueue(ctx, dry_run, config):
"""A command line tool for time-delaying your tweets."""
ctx.obj = {}
ctx.obj['DRYRUN'] = dry_run
# If the subcommand is "config", bypass all setup code
if ctx.invoked_subcommand == 'config':
return
# If the config file wasn't provided, attempt to ... | python | def tweetqueue(ctx, dry_run, config):
"""A command line tool for time-delaying your tweets."""
ctx.obj = {}
ctx.obj['DRYRUN'] = dry_run
# If the subcommand is "config", bypass all setup code
if ctx.invoked_subcommand == 'config':
return
# If the config file wasn't provided, attempt to ... | [
"def",
"tweetqueue",
"(",
"ctx",
",",
"dry_run",
",",
"config",
")",
":",
"ctx",
".",
"obj",
"=",
"{",
"}",
"ctx",
".",
"obj",
"[",
"'DRYRUN'",
"]",
"=",
"dry_run",
"# If the subcommand is \"config\", bypass all setup code",
"if",
"ctx",
".",
"invoked_subcomma... | A command line tool for time-delaying your tweets. | [
"A",
"command",
"line",
"tool",
"for",
"time",
"-",
"delaying",
"your",
"tweets",
"."
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L19-L73 |
246,109 | billyoverton/tweetqueue | tweetqueue/__main__.py | tweet | def tweet(ctx, message):
"""Sends a tweet directly to your timeline"""
if not valid_tweet(message):
click.echo("Message is too long for twitter.")
click.echo("Message:" + message)
ctx.exit(2)
if not ctx.obj['DRYRUN']:
ctx.obj['TWEEPY_API'].update_status(message)
else:
... | python | def tweet(ctx, message):
"""Sends a tweet directly to your timeline"""
if not valid_tweet(message):
click.echo("Message is too long for twitter.")
click.echo("Message:" + message)
ctx.exit(2)
if not ctx.obj['DRYRUN']:
ctx.obj['TWEEPY_API'].update_status(message)
else:
... | [
"def",
"tweet",
"(",
"ctx",
",",
"message",
")",
":",
"if",
"not",
"valid_tweet",
"(",
"message",
")",
":",
"click",
".",
"echo",
"(",
"\"Message is too long for twitter.\"",
")",
"click",
".",
"echo",
"(",
"\"Message:\"",
"+",
"message",
")",
"ctx",
".",
... | Sends a tweet directly to your timeline | [
"Sends",
"a",
"tweet",
"directly",
"to",
"your",
"timeline"
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L78-L88 |
246,110 | billyoverton/tweetqueue | tweetqueue/__main__.py | queue | def queue(ctx, message):
"""Adds a message to your twitter queue"""
if not valid_tweet(message):
click.echo("Message is too long for twitter.")
click.echo("Message: " + message)
ctx.exit(2)
if ctx.obj['DRYRUN']:
click.echo("Message not queue due to dry-run mode.")
ct... | python | def queue(ctx, message):
"""Adds a message to your twitter queue"""
if not valid_tweet(message):
click.echo("Message is too long for twitter.")
click.echo("Message: " + message)
ctx.exit(2)
if ctx.obj['DRYRUN']:
click.echo("Message not queue due to dry-run mode.")
ct... | [
"def",
"queue",
"(",
"ctx",
",",
"message",
")",
":",
"if",
"not",
"valid_tweet",
"(",
"message",
")",
":",
"click",
".",
"echo",
"(",
"\"Message is too long for twitter.\"",
")",
"click",
".",
"echo",
"(",
"\"Message: \"",
"+",
"message",
")",
"ctx",
".",... | Adds a message to your twitter queue | [
"Adds",
"a",
"message",
"to",
"your",
"twitter",
"queue"
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L93-L104 |
246,111 | billyoverton/tweetqueue | tweetqueue/__main__.py | dequeue | def dequeue(ctx):
"""Sends a tweet from the queue"""
tweet =ctx.obj['TWEETLIST'].peek()
if tweet is None:
click.echo("Nothing to dequeue.")
ctx.exit(1)
if ctx.obj['DRYRUN']:
click.echo(tweet)
else:
tweet = ctx.obj['TWEETLIST'].pop()
ctx.obj['TWEEPY_API'].upd... | python | def dequeue(ctx):
"""Sends a tweet from the queue"""
tweet =ctx.obj['TWEETLIST'].peek()
if tweet is None:
click.echo("Nothing to dequeue.")
ctx.exit(1)
if ctx.obj['DRYRUN']:
click.echo(tweet)
else:
tweet = ctx.obj['TWEETLIST'].pop()
ctx.obj['TWEEPY_API'].upd... | [
"def",
"dequeue",
"(",
"ctx",
")",
":",
"tweet",
"=",
"ctx",
".",
"obj",
"[",
"'TWEETLIST'",
"]",
".",
"peek",
"(",
")",
"if",
"tweet",
"is",
"None",
":",
"click",
".",
"echo",
"(",
"\"Nothing to dequeue.\"",
")",
"ctx",
".",
"exit",
"(",
"1",
")",... | Sends a tweet from the queue | [
"Sends",
"a",
"tweet",
"from",
"the",
"queue"
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L108-L120 |
246,112 | billyoverton/tweetqueue | tweetqueue/__main__.py | config | def config(ctx):
"""Creates a tweetqueue configuration file"""
home_directory = os.path.expanduser('~')
default_config_file = os.path.join(home_directory, '.tweetqueue')
default_database_file = os.path.join(home_directory, '.tweetqueue.db')
config = {}
config['API_KEY'] = click.prompt('API Key... | python | def config(ctx):
"""Creates a tweetqueue configuration file"""
home_directory = os.path.expanduser('~')
default_config_file = os.path.join(home_directory, '.tweetqueue')
default_database_file = os.path.join(home_directory, '.tweetqueue.db')
config = {}
config['API_KEY'] = click.prompt('API Key... | [
"def",
"config",
"(",
"ctx",
")",
":",
"home_directory",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"default_config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"home_directory",
",",
"'.tweetqueue'",
")",
"default_database_file",
"=",
... | Creates a tweetqueue configuration file | [
"Creates",
"a",
"tweetqueue",
"configuration",
"file"
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L124-L143 |
246,113 | billyoverton/tweetqueue | tweetqueue/__main__.py | delete | def delete(ctx,tweet):
"""Deletes a tweet from the queue with a given ID"""
if not ctx.obj['DRYRUN']:
try:
ctx.obj['TWEETLIST'].delete(tweet)
except ValueError as e:
click.echo("Now tweet was found with that id.")
ctx.exit(1)
else:
click.echo("Not ... | python | def delete(ctx,tweet):
"""Deletes a tweet from the queue with a given ID"""
if not ctx.obj['DRYRUN']:
try:
ctx.obj['TWEETLIST'].delete(tweet)
except ValueError as e:
click.echo("Now tweet was found with that id.")
ctx.exit(1)
else:
click.echo("Not ... | [
"def",
"delete",
"(",
"ctx",
",",
"tweet",
")",
":",
"if",
"not",
"ctx",
".",
"obj",
"[",
"'DRYRUN'",
"]",
":",
"try",
":",
"ctx",
".",
"obj",
"[",
"'TWEETLIST'",
"]",
".",
"delete",
"(",
"tweet",
")",
"except",
"ValueError",
"as",
"e",
":",
"cli... | Deletes a tweet from the queue with a given ID | [
"Deletes",
"a",
"tweet",
"from",
"the",
"queue",
"with",
"a",
"given",
"ID"
] | e54972a0137ea2a21b2357b81408d9d4c92fdd61 | https://github.com/billyoverton/tweetqueue/blob/e54972a0137ea2a21b2357b81408d9d4c92fdd61/tweetqueue/__main__.py#L148-L157 |
246,114 | unionbilling/union-python | union/client.py | UnionClient.make_request | def make_request(self, model, action, url_params={}, post_data=None):
'''
Send request to API then validate, parse, and return the response
'''
url = self._create_url(model, **url_params)
headers = self._headers(action)
try:
response = requests.request(action... | python | def make_request(self, model, action, url_params={}, post_data=None):
'''
Send request to API then validate, parse, and return the response
'''
url = self._create_url(model, **url_params)
headers = self._headers(action)
try:
response = requests.request(action... | [
"def",
"make_request",
"(",
"self",
",",
"model",
",",
"action",
",",
"url_params",
"=",
"{",
"}",
",",
"post_data",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_create_url",
"(",
"model",
",",
"*",
"*",
"url_params",
")",
"headers",
"=",
"self"... | Send request to API then validate, parse, and return the response | [
"Send",
"request",
"to",
"API",
"then",
"validate",
"parse",
"and",
"return",
"the",
"response"
] | 551e4fc1a0b395b632781d80527a3660a7c67c0c | https://github.com/unionbilling/union-python/blob/551e4fc1a0b395b632781d80527a3660a7c67c0c/union/client.py#L98-L113 |
246,115 | ramrod-project/database-brain | schema/brain/queries/writes.py | insert_jobs | def insert_jobs(jobs, verify_jobs=True, conn=None):
"""
insert_jobs function inserts data into Brain.Jobs table
jobs must be in Job format
:param jobs: <list> of Jobs
:param verify_jobs: <bool>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict> rethinkdb insert response value
"... | python | def insert_jobs(jobs, verify_jobs=True, conn=None):
"""
insert_jobs function inserts data into Brain.Jobs table
jobs must be in Job format
:param jobs: <list> of Jobs
:param verify_jobs: <bool>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict> rethinkdb insert response value
"... | [
"def",
"insert_jobs",
"(",
"jobs",
",",
"verify_jobs",
"=",
"True",
",",
"conn",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"jobs",
",",
"list",
")",
"if",
"verify_jobs",
"and",
"not",
"verify",
"(",
"{",
"Jobs",
".",
"DESCRIPTOR",
".",
"name"... | insert_jobs function inserts data into Brain.Jobs table
jobs must be in Job format
:param jobs: <list> of Jobs
:param verify_jobs: <bool>
:param conn: <rethinkdb.DefaultConnection>
:return: <dict> rethinkdb insert response value | [
"insert_jobs",
"function",
"inserts",
"data",
"into",
"Brain",
".",
"Jobs",
"table"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L74-L90 |
246,116 | ramrod-project/database-brain | schema/brain/queries/writes.py | update_job_status | def update_job_status(job_id, status, conn=None):
"""Updates a job to a new status
:param job_id: <str> the id of the job
:param status: <str> new status
:param conn: <connection> a database connection (default: {None})
:return: <dict> the update dicts for the job and the output
"""
if sta... | python | def update_job_status(job_id, status, conn=None):
"""Updates a job to a new status
:param job_id: <str> the id of the job
:param status: <str> new status
:param conn: <connection> a database connection (default: {None})
:return: <dict> the update dicts for the job and the output
"""
if sta... | [
"def",
"update_job_status",
"(",
"job_id",
",",
"status",
",",
"conn",
"=",
"None",
")",
":",
"if",
"status",
"not",
"in",
"VALID_STATES",
":",
"raise",
"ValueError",
"(",
"\"Invalid status\"",
")",
"job_update",
"=",
"RBJ",
".",
"get",
"(",
"job_id",
")",... | Updates a job to a new status
:param job_id: <str> the id of the job
:param status: <str> new status
:param conn: <connection> a database connection (default: {None})
:return: <dict> the update dicts for the job and the output | [
"Updates",
"a",
"job",
"to",
"a",
"new",
"status"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L95-L117 |
246,117 | ramrod-project/database-brain | schema/brain/queries/writes.py | write_output | def write_output(job_id, content, conn=None):
"""writes output to the output table
:param job_id: <str> id of the job
:param content: <str> output to write
:param conn:
"""
output_job = get_job_by_id(job_id, conn)
results = {}
if output_job is not None:
entry = {
OUT... | python | def write_output(job_id, content, conn=None):
"""writes output to the output table
:param job_id: <str> id of the job
:param content: <str> output to write
:param conn:
"""
output_job = get_job_by_id(job_id, conn)
results = {}
if output_job is not None:
entry = {
OUT... | [
"def",
"write_output",
"(",
"job_id",
",",
"content",
",",
"conn",
"=",
"None",
")",
":",
"output_job",
"=",
"get_job_by_id",
"(",
"job_id",
",",
"conn",
")",
"results",
"=",
"{",
"}",
"if",
"output_job",
"is",
"not",
"None",
":",
"entry",
"=",
"{",
... | writes output to the output table
:param job_id: <str> id of the job
:param content: <str> output to write
:param conn: | [
"writes",
"output",
"to",
"the",
"output",
"table"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/writes.py#L122-L137 |
246,118 | Pringley/rw | rw/__init__.py | generate_words | def generate_words(numberofwords, wordlist, secure=None):
"""Generate a list of random words from wordlist."""
if not secure:
chooser = random.choice
else:
chooser = random.SystemRandom().choice
return [chooser(wordlist) for _ in range(numberofwords)] | python | def generate_words(numberofwords, wordlist, secure=None):
"""Generate a list of random words from wordlist."""
if not secure:
chooser = random.choice
else:
chooser = random.SystemRandom().choice
return [chooser(wordlist) for _ in range(numberofwords)] | [
"def",
"generate_words",
"(",
"numberofwords",
",",
"wordlist",
",",
"secure",
"=",
"None",
")",
":",
"if",
"not",
"secure",
":",
"chooser",
"=",
"random",
".",
"choice",
"else",
":",
"chooser",
"=",
"random",
".",
"SystemRandom",
"(",
")",
".",
"choice"... | Generate a list of random words from wordlist. | [
"Generate",
"a",
"list",
"of",
"random",
"words",
"from",
"wordlist",
"."
] | 0d1d9933030621c60e051a8bea3b5f520aa33efd | https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L28-L34 |
246,119 | Pringley/rw | rw/__init__.py | load_stream | def load_stream(filename):
"""Load a file stream from the package resources."""
rawfile = pkg_resources.resource_stream(__name__, filename)
if six.PY2:
return rawfile
return io.TextIOWrapper(rawfile, 'utf-8') | python | def load_stream(filename):
"""Load a file stream from the package resources."""
rawfile = pkg_resources.resource_stream(__name__, filename)
if six.PY2:
return rawfile
return io.TextIOWrapper(rawfile, 'utf-8') | [
"def",
"load_stream",
"(",
"filename",
")",
":",
"rawfile",
"=",
"pkg_resources",
".",
"resource_stream",
"(",
"__name__",
",",
"filename",
")",
"if",
"six",
".",
"PY2",
":",
"return",
"rawfile",
"return",
"io",
".",
"TextIOWrapper",
"(",
"rawfile",
",",
"... | Load a file stream from the package resources. | [
"Load",
"a",
"file",
"stream",
"from",
"the",
"package",
"resources",
"."
] | 0d1d9933030621c60e051a8bea3b5f520aa33efd | https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L40-L45 |
246,120 | Pringley/rw | rw/__init__.py | cli | def cli():
"""Run the command line interface."""
args = docopt.docopt(__doc__, version=__VERSION__)
secure = args['--secure']
numberofwords = int(args['<numberofwords>'])
dictpath = args['--dict']
if dictpath is not None:
dictfile = open(dictpath)
else:
dictfile = load_strea... | python | def cli():
"""Run the command line interface."""
args = docopt.docopt(__doc__, version=__VERSION__)
secure = args['--secure']
numberofwords = int(args['<numberofwords>'])
dictpath = args['--dict']
if dictpath is not None:
dictfile = open(dictpath)
else:
dictfile = load_strea... | [
"def",
"cli",
"(",
")",
":",
"args",
"=",
"docopt",
".",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"__VERSION__",
")",
"secure",
"=",
"args",
"[",
"'--secure'",
"]",
"numberofwords",
"=",
"int",
"(",
"args",
"[",
"'<numberofwords>'",
"]",
")",
"di... | Run the command line interface. | [
"Run",
"the",
"command",
"line",
"interface",
"."
] | 0d1d9933030621c60e051a8bea3b5f520aa33efd | https://github.com/Pringley/rw/blob/0d1d9933030621c60e051a8bea3b5f520aa33efd/rw/__init__.py#L47-L62 |
246,121 | minhhoit/yacms | yacms/pages/page_processors.py | processor_for | def processor_for(content_model_or_slug, exact_page=False):
"""
Decorator that registers the decorated function as a page
processor for the given content model or slug.
When a page exists that forms the prefix of custom urlpatterns
in a project (eg: the blog page and app), the page will be
adde... | python | def processor_for(content_model_or_slug, exact_page=False):
"""
Decorator that registers the decorated function as a page
processor for the given content model or slug.
When a page exists that forms the prefix of custom urlpatterns
in a project (eg: the blog page and app), the page will be
adde... | [
"def",
"processor_for",
"(",
"content_model_or_slug",
",",
"exact_page",
"=",
"False",
")",
":",
"content_model",
"=",
"None",
"slug",
"=",
"\"\"",
"if",
"isinstance",
"(",
"content_model_or_slug",
",",
"(",
"str",
",",
"_str",
")",
")",
":",
"try",
":",
"... | Decorator that registers the decorated function as a page
processor for the given content model or slug.
When a page exists that forms the prefix of custom urlpatterns
in a project (eg: the blog page and app), the page will be
added to the template context. Passing in ``True`` for the
``exact_page`... | [
"Decorator",
"that",
"registers",
"the",
"decorated",
"function",
"as",
"a",
"page",
"processor",
"for",
"the",
"given",
"content",
"model",
"or",
"slug",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/page_processors.py#L17-L53 |
246,122 | minhhoit/yacms | yacms/pages/page_processors.py | autodiscover | def autodiscover():
"""
Taken from ``django.contrib.admin.autodiscover`` and used to run
any calls to the ``processor_for`` decorator.
"""
global LOADED
if LOADED:
return
LOADED = True
for app in get_app_name_list():
try:
module = import_module(app)
ex... | python | def autodiscover():
"""
Taken from ``django.contrib.admin.autodiscover`` and used to run
any calls to the ``processor_for`` decorator.
"""
global LOADED
if LOADED:
return
LOADED = True
for app in get_app_name_list():
try:
module = import_module(app)
ex... | [
"def",
"autodiscover",
"(",
")",
":",
"global",
"LOADED",
"if",
"LOADED",
":",
"return",
"LOADED",
"=",
"True",
"for",
"app",
"in",
"get_app_name_list",
"(",
")",
":",
"try",
":",
"module",
"=",
"import_module",
"(",
"app",
")",
"except",
"ImportError",
... | Taken from ``django.contrib.admin.autodiscover`` and used to run
any calls to the ``processor_for`` decorator. | [
"Taken",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"autodiscover",
"and",
"used",
"to",
"run",
"any",
"calls",
"to",
"the",
"processor_for",
"decorator",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/page_processors.py#L59-L78 |
246,123 | praekelt/jmbo-poll | poll/models.py | Poll.can_vote_on_poll | def can_vote_on_poll(self, request):
"""Based on jmbo.models.can_vote."""
# can't vote if liking is closed
if self.votes_closed:
return False, 'closed'
# can't vote if liking is disabled
if not self.votes_enabled:
return False, 'disabled'
# anon... | python | def can_vote_on_poll(self, request):
"""Based on jmbo.models.can_vote."""
# can't vote if liking is closed
if self.votes_closed:
return False, 'closed'
# can't vote if liking is disabled
if not self.votes_enabled:
return False, 'disabled'
# anon... | [
"def",
"can_vote_on_poll",
"(",
"self",
",",
"request",
")",
":",
"# can't vote if liking is closed",
"if",
"self",
".",
"votes_closed",
":",
"return",
"False",
",",
"'closed'",
"# can't vote if liking is disabled",
"if",
"not",
"self",
".",
"votes_enabled",
":",
"r... | Based on jmbo.models.can_vote. | [
"Based",
"on",
"jmbo",
".",
"models",
".",
"can_vote",
"."
] | 322cd398372139e9db74a37cb2ce8ab1c2ef17fd | https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L30-L54 |
246,124 | praekelt/jmbo-poll | poll/models.py | Poll.vote_count | def vote_count(self):
"""
Returns the total number of votes cast across all the
poll's options.
"""
return Vote.objects.filter(
content_type=ContentType.objects.get(app_label='poll', model='polloption'),
object_id__in=[o.id for o in self.polloption_set.all... | python | def vote_count(self):
"""
Returns the total number of votes cast across all the
poll's options.
"""
return Vote.objects.filter(
content_type=ContentType.objects.get(app_label='poll', model='polloption'),
object_id__in=[o.id for o in self.polloption_set.all... | [
"def",
"vote_count",
"(",
"self",
")",
":",
"return",
"Vote",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get",
"(",
"app_label",
"=",
"'poll'",
",",
"model",
"=",
"'polloption'",
")",
",",
"object_id__in",... | Returns the total number of votes cast across all the
poll's options. | [
"Returns",
"the",
"total",
"number",
"of",
"votes",
"cast",
"across",
"all",
"the",
"poll",
"s",
"options",
"."
] | 322cd398372139e9db74a37cb2ce8ab1c2ef17fd | https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L58-L66 |
246,125 | praekelt/jmbo-poll | poll/models.py | PollOption.vote_count | def vote_count(self):
"""
Returns the total number of votes cast for this
poll options.
"""
return Vote.objects.filter(
content_type=ContentType.objects.get_for_model(self),
object_id=self.id
).aggregate(Sum('vote'))['vote__sum'] or 0 | python | def vote_count(self):
"""
Returns the total number of votes cast for this
poll options.
"""
return Vote.objects.filter(
content_type=ContentType.objects.get_for_model(self),
object_id=self.id
).aggregate(Sum('vote'))['vote__sum'] or 0 | [
"def",
"vote_count",
"(",
"self",
")",
":",
"return",
"Vote",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
")",
",",
"object_id",
"=",
"self",
".",
"id",
")",
".",
"aggregate",... | Returns the total number of votes cast for this
poll options. | [
"Returns",
"the",
"total",
"number",
"of",
"votes",
"cast",
"for",
"this",
"poll",
"options",
"."
] | 322cd398372139e9db74a37cb2ce8ab1c2ef17fd | https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L82-L90 |
246,126 | praekelt/jmbo-poll | poll/models.py | PollOption.percentage | def percentage(self):
"""
Returns the percentage of votes cast for this poll option in
relation to all of its poll's other options.
"""
total_vote_count = self.poll.vote_count
if total_vote_count:
return self.vote_count * 100.0 / total_vote_count
retur... | python | def percentage(self):
"""
Returns the percentage of votes cast for this poll option in
relation to all of its poll's other options.
"""
total_vote_count = self.poll.vote_count
if total_vote_count:
return self.vote_count * 100.0 / total_vote_count
retur... | [
"def",
"percentage",
"(",
"self",
")",
":",
"total_vote_count",
"=",
"self",
".",
"poll",
".",
"vote_count",
"if",
"total_vote_count",
":",
"return",
"self",
".",
"vote_count",
"*",
"100.0",
"/",
"total_vote_count",
"return",
"0"
] | Returns the percentage of votes cast for this poll option in
relation to all of its poll's other options. | [
"Returns",
"the",
"percentage",
"of",
"votes",
"cast",
"for",
"this",
"poll",
"option",
"in",
"relation",
"to",
"all",
"of",
"its",
"poll",
"s",
"other",
"options",
"."
] | 322cd398372139e9db74a37cb2ce8ab1c2ef17fd | https://github.com/praekelt/jmbo-poll/blob/322cd398372139e9db74a37cb2ce8ab1c2ef17fd/poll/models.py#L92-L100 |
246,127 | ECESeniorDesign/lazy_record | lazy_record/query.py | does_not_mutate | def does_not_mutate(func):
"""Prevents methods from mutating the receiver"""
def wrapper(self, *args, **kwargs):
new = self.copy()
return func(new, *args, **kwargs)
wrapper.__name__ = func.__name__
wrapper.__doc__ = func.__doc__
return wrapper | python | def does_not_mutate(func):
"""Prevents methods from mutating the receiver"""
def wrapper(self, *args, **kwargs):
new = self.copy()
return func(new, *args, **kwargs)
wrapper.__name__ = func.__name__
wrapper.__doc__ = func.__doc__
return wrapper | [
"def",
"does_not_mutate",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new",
"=",
"self",
".",
"copy",
"(",
")",
"return",
"func",
"(",
"new",
",",
"*",
"args",
",",
"*",
"*",
"kwar... | Prevents methods from mutating the receiver | [
"Prevents",
"methods",
"from",
"mutating",
"the",
"receiver"
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L10-L17 |
246,128 | ECESeniorDesign/lazy_record | lazy_record/query.py | Query.find_by | def find_by(self, **kwargs):
"""
Find first record subject to restrictions in +kwargs+, raising
RecordNotFound if no such record exists.
"""
result = self.where(**kwargs).first()
if result:
return result
else:
raise RecordNotFound(kwargs) | python | def find_by(self, **kwargs):
"""
Find first record subject to restrictions in +kwargs+, raising
RecordNotFound if no such record exists.
"""
result = self.where(**kwargs).first()
if result:
return result
else:
raise RecordNotFound(kwargs) | [
"def",
"find_by",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"self",
".",
"where",
"(",
"*",
"*",
"kwargs",
")",
".",
"first",
"(",
")",
"if",
"result",
":",
"return",
"result",
"else",
":",
"raise",
"RecordNotFound",
"(",
"kwar... | Find first record subject to restrictions in +kwargs+, raising
RecordNotFound if no such record exists. | [
"Find",
"first",
"record",
"subject",
"to",
"restrictions",
"in",
"+",
"kwargs",
"+",
"raising",
"RecordNotFound",
"if",
"no",
"such",
"record",
"exists",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L68-L77 |
246,129 | ECESeniorDesign/lazy_record | lazy_record/query.py | Query.where | def where(self, *custom_restrictions, **restrictions):
"""
Restricts the records to the query subject to the passed
+restrictions+. Analog to "WHERE" in SQL. Can pass multiple
restrictions, and can invoke this method multiple times per query.
"""
for attr, value in restri... | python | def where(self, *custom_restrictions, **restrictions):
"""
Restricts the records to the query subject to the passed
+restrictions+. Analog to "WHERE" in SQL. Can pass multiple
restrictions, and can invoke this method multiple times per query.
"""
for attr, value in restri... | [
"def",
"where",
"(",
"self",
",",
"*",
"custom_restrictions",
",",
"*",
"*",
"restrictions",
")",
":",
"for",
"attr",
",",
"value",
"in",
"restrictions",
".",
"items",
"(",
")",
":",
"self",
".",
"where_query",
"[",
"attr",
"]",
"=",
"value",
"if",
"... | Restricts the records to the query subject to the passed
+restrictions+. Analog to "WHERE" in SQL. Can pass multiple
restrictions, and can invoke this method multiple times per query. | [
"Restricts",
"the",
"records",
"to",
"the",
"query",
"subject",
"to",
"the",
"passed",
"+",
"restrictions",
"+",
".",
"Analog",
"to",
"WHERE",
"in",
"SQL",
".",
"Can",
"pass",
"multiple",
"restrictions",
"and",
"can",
"invoke",
"this",
"method",
"multiple",
... | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L130-L140 |
246,130 | ECESeniorDesign/lazy_record | lazy_record/query.py | Query.joins | def joins(self, table):
"""
Analog to "INNER JOIN" in SQL on the passed +table+. Use only once
per query.
"""
def do_join(table, model):
while model is not associations.model_from_name(table):
# ex) Category -> Forum -> Thread -> Post
... | python | def joins(self, table):
"""
Analog to "INNER JOIN" in SQL on the passed +table+. Use only once
per query.
"""
def do_join(table, model):
while model is not associations.model_from_name(table):
# ex) Category -> Forum -> Thread -> Post
... | [
"def",
"joins",
"(",
"self",
",",
"table",
")",
":",
"def",
"do_join",
"(",
"table",
",",
"model",
")",
":",
"while",
"model",
"is",
"not",
"associations",
".",
"model_from_name",
"(",
"table",
")",
":",
"# ex) Category -> Forum -> Thread -> Post",
"# Category... | Analog to "INNER JOIN" in SQL on the passed +table+. Use only once
per query. | [
"Analog",
"to",
"INNER",
"JOIN",
"in",
"SQL",
"on",
"the",
"passed",
"+",
"table",
"+",
".",
"Use",
"only",
"once",
"per",
"query",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L143-L193 |
246,131 | ECESeniorDesign/lazy_record | lazy_record/query.py | Query.create | def create(self, **attributes):
"""
Creates a new record suject to the restructions in the query and with
the passed +attributes+. Operates using `build`.
"""
record = self.build(**attributes)
record.save()
return record | python | def create(self, **attributes):
"""
Creates a new record suject to the restructions in the query and with
the passed +attributes+. Operates using `build`.
"""
record = self.build(**attributes)
record.save()
return record | [
"def",
"create",
"(",
"self",
",",
"*",
"*",
"attributes",
")",
":",
"record",
"=",
"self",
".",
"build",
"(",
"*",
"*",
"attributes",
")",
"record",
".",
"save",
"(",
")",
"return",
"record"
] | Creates a new record suject to the restructions in the query and with
the passed +attributes+. Operates using `build`. | [
"Creates",
"a",
"new",
"record",
"suject",
"to",
"the",
"restructions",
"in",
"the",
"query",
"and",
"with",
"the",
"passed",
"+",
"attributes",
"+",
".",
"Operates",
"using",
"build",
"."
] | 929d3cc7c2538b0f792365c0d2b0e0d41084c2dd | https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L259-L266 |
246,132 | polysquare/polysquare-generic-file-linter | polysquarelinter/technical_words_dictionary.py | create | def create(technical_terms_filename, spellchecker_cache_path):
"""Create a Dictionary at spellchecker_cache_path with technical words."""
user_dictionary = os.path.join(os.getcwd(), "DICTIONARY")
user_words = read_dictionary_file(user_dictionary)
technical_terms_set = set(user_words)
if technical_... | python | def create(technical_terms_filename, spellchecker_cache_path):
"""Create a Dictionary at spellchecker_cache_path with technical words."""
user_dictionary = os.path.join(os.getcwd(), "DICTIONARY")
user_words = read_dictionary_file(user_dictionary)
technical_terms_set = set(user_words)
if technical_... | [
"def",
"create",
"(",
"technical_terms_filename",
",",
"spellchecker_cache_path",
")",
":",
"user_dictionary",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"\"DICTIONARY\"",
")",
"user_words",
"=",
"read_dictionary_file",
"(",
... | Create a Dictionary at spellchecker_cache_path with technical words. | [
"Create",
"a",
"Dictionary",
"at",
"spellchecker_cache_path",
"with",
"technical",
"words",
"."
] | cfc88771acd3d5551c28fa5d917bb0aeb584c4cc | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/technical_words_dictionary.py#L15-L30 |
246,133 | jjangsangy/kan | kan/structures.py | GoogleBooksAPIClient.connect | def connect(self, agent='Python'):
"""
Context manager for HTTP Connection state and ensures proper handling
of network sockets, sends a GET request.
Exception is raised at the yield statement.
:yield request: FileIO<Socket>
"""
headers = {'User-Agent': agent}
... | python | def connect(self, agent='Python'):
"""
Context manager for HTTP Connection state and ensures proper handling
of network sockets, sends a GET request.
Exception is raised at the yield statement.
:yield request: FileIO<Socket>
"""
headers = {'User-Agent': agent}
... | [
"def",
"connect",
"(",
"self",
",",
"agent",
"=",
"'Python'",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"agent",
"}",
"request",
"=",
"urlopen",
"(",
"Request",
"(",
"self",
".",
"url",
",",
"headers",
"=",
"headers",
")",
")",
"try",
":",
... | Context manager for HTTP Connection state and ensures proper handling
of network sockets, sends a GET request.
Exception is raised at the yield statement.
:yield request: FileIO<Socket> | [
"Context",
"manager",
"for",
"HTTP",
"Connection",
"state",
"and",
"ensures",
"proper",
"handling",
"of",
"network",
"sockets",
"sends",
"a",
"GET",
"request",
"."
] | 7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6 | https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L118-L132 |
246,134 | jjangsangy/kan | kan/structures.py | GoogleBooksAPIClient.reader | def reader(self):
"""
Reads raw text from the connection stream.
Ensures proper exception handling.
:return bytes: request
"""
request_stream = ''
with self.connect() as request:
if request.msg != 'OK':
raise HTTPError
requ... | python | def reader(self):
"""
Reads raw text from the connection stream.
Ensures proper exception handling.
:return bytes: request
"""
request_stream = ''
with self.connect() as request:
if request.msg != 'OK':
raise HTTPError
requ... | [
"def",
"reader",
"(",
"self",
")",
":",
"request_stream",
"=",
"''",
"with",
"self",
".",
"connect",
"(",
")",
"as",
"request",
":",
"if",
"request",
".",
"msg",
"!=",
"'OK'",
":",
"raise",
"HTTPError",
"request_stream",
"=",
"request",
".",
"read",
"(... | Reads raw text from the connection stream.
Ensures proper exception handling.
:return bytes: request | [
"Reads",
"raw",
"text",
"from",
"the",
"connection",
"stream",
".",
"Ensures",
"proper",
"exception",
"handling",
"."
] | 7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6 | https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L135-L147 |
246,135 | jjangsangy/kan | kan/structures.py | GoogleBooksAPIClient.json | def json(self):
"""
Serializes json text stream into python dictionary.
:return dict: json
"""
_json = json.loads(self.reader)
if _json.get('error', None):
raise HTTPError(_json['error']['errors'])
return _json | python | def json(self):
"""
Serializes json text stream into python dictionary.
:return dict: json
"""
_json = json.loads(self.reader)
if _json.get('error', None):
raise HTTPError(_json['error']['errors'])
return _json | [
"def",
"json",
"(",
"self",
")",
":",
"_json",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"reader",
")",
"if",
"_json",
".",
"get",
"(",
"'error'",
",",
"None",
")",
":",
"raise",
"HTTPError",
"(",
"_json",
"[",
"'error'",
"]",
"[",
"'errors'",
... | Serializes json text stream into python dictionary.
:return dict: json | [
"Serializes",
"json",
"text",
"stream",
"into",
"python",
"dictionary",
"."
] | 7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6 | https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L150-L159 |
246,136 | alfred82santa/dirty-loader | dirty_loader/__init__.py | import_class | def import_class(classpath, package=None):
"""
Load and return a class
"""
if '.' in classpath:
module, classname = classpath.rsplit('.', 1)
if package and not module.startswith('.'):
module = '.{0}'.format(module)
mod = import_module(module, package)
else:
... | python | def import_class(classpath, package=None):
"""
Load and return a class
"""
if '.' in classpath:
module, classname = classpath.rsplit('.', 1)
if package and not module.startswith('.'):
module = '.{0}'.format(module)
mod = import_module(module, package)
else:
... | [
"def",
"import_class",
"(",
"classpath",
",",
"package",
"=",
"None",
")",
":",
"if",
"'.'",
"in",
"classpath",
":",
"module",
",",
"classname",
"=",
"classpath",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"if",
"package",
"and",
"not",
"module",
".",
... | Load and return a class | [
"Load",
"and",
"return",
"a",
"class"
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L423-L436 |
246,137 | alfred82santa/dirty-loader | dirty_loader/__init__.py | Loader.register_module | def register_module(self, module, idx=-1):
"""
Register a module. You could indicate position inside inner list.
:param module: must be a string or a module object to register.
:type module: str
:param idx: position where you want to insert new module. By default it is inserted ... | python | def register_module(self, module, idx=-1):
"""
Register a module. You could indicate position inside inner list.
:param module: must be a string or a module object to register.
:type module: str
:param idx: position where you want to insert new module. By default it is inserted ... | [
"def",
"register_module",
"(",
"self",
",",
"module",
",",
"idx",
"=",
"-",
"1",
")",
":",
"if",
"module",
"in",
"self",
".",
"_modules",
":",
"raise",
"AlreadyRegisteredError",
"(",
"\"Module '{0}' is already registered on loader.\"",
".",
"format",
"(",
"modul... | Register a module. You could indicate position inside inner list.
:param module: must be a string or a module object to register.
:type module: str
:param idx: position where you want to insert new module. By default it is inserted at the end.
:type idx: int | [
"Register",
"a",
"module",
".",
"You",
"could",
"indicate",
"position",
"inside",
"inner",
"list",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L40-L56 |
246,138 | alfred82santa/dirty-loader | dirty_loader/__init__.py | Loader.load_class | def load_class(self, classname):
"""
Loads a class looking for it in each module registered.
:param classname: Class name you want to load.
:type classname: str
:return: Class object
:rtype: type
"""
module_list = self._get_module_list()
for mod... | python | def load_class(self, classname):
"""
Loads a class looking for it in each module registered.
:param classname: Class name you want to load.
:type classname: str
:return: Class object
:rtype: type
"""
module_list = self._get_module_list()
for mod... | [
"def",
"load_class",
"(",
"self",
",",
"classname",
")",
":",
"module_list",
"=",
"self",
".",
"_get_module_list",
"(",
")",
"for",
"module",
"in",
"module_list",
":",
"try",
":",
"return",
"import_class",
"(",
"classname",
",",
"module",
".",
"__name__",
... | Loads a class looking for it in each module registered.
:param classname: Class name you want to load.
:type classname: str
:return: Class object
:rtype: type | [
"Loads",
"a",
"class",
"looking",
"for",
"it",
"in",
"each",
"module",
"registered",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L81-L99 |
246,139 | alfred82santa/dirty-loader | dirty_loader/__init__.py | Loader.factory | def factory(self, classname, *args, **kwargs):
"""
Creates an instance of class looking for it in each module registered. You can
add needed params to instance the class.
:param classname: Class name you want to create an instance.
:type classname: str
:return: An instan... | python | def factory(self, classname, *args, **kwargs):
"""
Creates an instance of class looking for it in each module registered. You can
add needed params to instance the class.
:param classname: Class name you want to create an instance.
:type classname: str
:return: An instan... | [
"def",
"factory",
"(",
"self",
",",
"classname",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"klass",
"=",
"self",
".",
"load_class",
"(",
"classname",
")",
"return",
"self",
".",
"get_factory_by_class",
"(",
"klass",
")",
"(",
"*",
"args",
... | Creates an instance of class looking for it in each module registered. You can
add needed params to instance the class.
:param classname: Class name you want to create an instance.
:type classname: str
:return: An instance of classname
:rtype: object | [
"Creates",
"an",
"instance",
"of",
"class",
"looking",
"for",
"it",
"in",
"each",
"module",
"registered",
".",
"You",
"can",
"add",
"needed",
"params",
"to",
"instance",
"the",
"class",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L105-L118 |
246,140 | alfred82santa/dirty-loader | dirty_loader/__init__.py | Loader.get_factory_by_class | def get_factory_by_class(self, klass):
"""
Returns a custom factory for class. By default it will return the class itself.
:param klass: Class type
:type klass: type
:return: Class factory
:rtype: callable
"""
for check, factory in self._factories.items()... | python | def get_factory_by_class(self, klass):
"""
Returns a custom factory for class. By default it will return the class itself.
:param klass: Class type
:type klass: type
:return: Class factory
:rtype: callable
"""
for check, factory in self._factories.items()... | [
"def",
"get_factory_by_class",
"(",
"self",
",",
"klass",
")",
":",
"for",
"check",
",",
"factory",
"in",
"self",
".",
"_factories",
".",
"items",
"(",
")",
":",
"if",
"klass",
"is",
"check",
":",
"return",
"factory",
"(",
"self",
",",
"klass",
")",
... | Returns a custom factory for class. By default it will return the class itself.
:param klass: Class type
:type klass: type
:return: Class factory
:rtype: callable | [
"Returns",
"a",
"custom",
"factory",
"for",
"class",
".",
"By",
"default",
"it",
"will",
"return",
"the",
"class",
"itself",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L120-L135 |
246,141 | alfred82santa/dirty-loader | dirty_loader/__init__.py | LoaderNamespace.register_module | def register_module(self, module, namespace=None):
"""
Register a module.
:param module: must be a string or a module object to register.
:type module: str
:param namespace: Namespace tag. If it is None module will be used as namespace tag
:type namespace: str
""... | python | def register_module(self, module, namespace=None):
"""
Register a module.
:param module: must be a string or a module object to register.
:type module: str
:param namespace: Namespace tag. If it is None module will be used as namespace tag
:type namespace: str
""... | [
"def",
"register_module",
"(",
"self",
",",
"module",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"namespace",
"if",
"namespace",
"is",
"not",
"None",
"else",
"module",
"if",
"isinstance",
"(",
"module",
",",
"str",
")",
"else",
"module",
... | Register a module.
:param module: must be a string or a module object to register.
:type module: str
:param namespace: Namespace tag. If it is None module will be used as namespace tag
:type namespace: str | [
"Register",
"a",
"module",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L262-L273 |
246,142 | alfred82santa/dirty-loader | dirty_loader/__init__.py | LoaderNamespace.register_namespace | def register_namespace(self, namespace, module):
"""
Register a namespace.
:param namespace: Namespace tag.
:type namespace: str
:param module: must be a string or a module object to register.
:type module: str
"""
if namespace in self._namespaces:
... | python | def register_namespace(self, namespace, module):
"""
Register a namespace.
:param namespace: Namespace tag.
:type namespace: str
:param module: must be a string or a module object to register.
:type module: str
"""
if namespace in self._namespaces:
... | [
"def",
"register_namespace",
"(",
"self",
",",
"namespace",
",",
"module",
")",
":",
"if",
"namespace",
"in",
"self",
".",
"_namespaces",
":",
"raise",
"AlreadyRegisteredError",
"(",
"\"Namespace '{0}' is already registered on loader.\"",
".",
"format",
"(",
"namespac... | Register a namespace.
:param namespace: Namespace tag.
:type namespace: str
:param module: must be a string or a module object to register.
:type module: str | [
"Register",
"a",
"namespace",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L275-L287 |
246,143 | alfred82santa/dirty-loader | dirty_loader/__init__.py | LoaderNamespace.unregister_namespace | def unregister_namespace(self, namespace):
"""
Unregister a namespace.
:param namespace: Namespace tag.
:type namespace: str
"""
if namespace not in self._namespaces:
raise NoRegisteredError("Namespace '{0}' is not registered on loader.".format(namespace))
... | python | def unregister_namespace(self, namespace):
"""
Unregister a namespace.
:param namespace: Namespace tag.
:type namespace: str
"""
if namespace not in self._namespaces:
raise NoRegisteredError("Namespace '{0}' is not registered on loader.".format(namespace))
... | [
"def",
"unregister_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"if",
"namespace",
"not",
"in",
"self",
".",
"_namespaces",
":",
"raise",
"NoRegisteredError",
"(",
"\"Namespace '{0}' is not registered on loader.\"",
".",
"format",
"(",
"namespace",
")",
")",... | Unregister a namespace.
:param namespace: Namespace tag.
:type namespace: str | [
"Unregister",
"a",
"namespace",
"."
] | 0d7895e3c84a0c197d804ce31305c5cba4c512e4 | https://github.com/alfred82santa/dirty-loader/blob/0d7895e3c84a0c197d804ce31305c5cba4c512e4/dirty_loader/__init__.py#L303-L313 |
246,144 | alfred82santa/aio-service-client | service_client/__init__.py | ServiceClient.close | def close(self):
"""
Close service client and its plugins.
"""
self._execute_plugin_hooks_sync(hook='close')
if not self.session.closed:
ensure_future(self.session.close(), loop=self.loop) | python | def close(self):
"""
Close service client and its plugins.
"""
self._execute_plugin_hooks_sync(hook='close')
if not self.session.closed:
ensure_future(self.session.close(), loop=self.loop) | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_execute_plugin_hooks_sync",
"(",
"hook",
"=",
"'close'",
")",
"if",
"not",
"self",
".",
"session",
".",
"closed",
":",
"ensure_future",
"(",
"self",
".",
"session",
".",
"close",
"(",
")",
",",
"loo... | Close service client and its plugins. | [
"Close",
"service",
"client",
"and",
"its",
"plugins",
"."
] | dd9ad49e23067b22178534915aa23ba24f6ff39b | https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/__init__.py#L222-L229 |
246,145 | gabrielfalcao/dominic | dominic/xpath/__init__.py | api | def api(f):
"""Decorator for functions and methods that are part of the external
module API and that can throw XPathError exceptions.
The call stack for these exceptions can be very large, and not very
interesting to the user. This decorator rethrows XPathErrors to
trim the stack.
"""
def... | python | def api(f):
"""Decorator for functions and methods that are part of the external
module API and that can throw XPathError exceptions.
The call stack for these exceptions can be very large, and not very
interesting to the user. This decorator rethrows XPathErrors to
trim the stack.
"""
def... | [
"def",
"api",
"(",
"f",
")",
":",
"def",
"api_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"XPathError",
",",
"e",
":",
"raise",
"e",
"api_f... | Decorator for functions and methods that are part of the external
module API and that can throw XPathError exceptions.
The call stack for these exceptions can be very large, and not very
interesting to the user. This decorator rethrows XPathErrors to
trim the stack. | [
"Decorator",
"for",
"functions",
"and",
"methods",
"that",
"are",
"part",
"of",
"the",
"external",
"module",
"API",
"and",
"that",
"can",
"throw",
"XPathError",
"exceptions",
"."
] | a42f418fc288f3b70cb95847b405eaf7b83bb3a0 | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/__init__.py#L10-L26 |
246,146 | tomokinakamaru/mapletree | mapletree/defaults/routings/routetree.py | RouteTree.get | def get(self, path, strict):
""" Gets the item for `path`. If `strict` is true, this method
returns `None` when matching path is not found.
Otherwise, this returns the result item of prefix searching.
:param path: Path to get
:param strict: Searching mode
:type path: lis... | python | def get(self, path, strict):
""" Gets the item for `path`. If `strict` is true, this method
returns `None` when matching path is not found.
Otherwise, this returns the result item of prefix searching.
:param path: Path to get
:param strict: Searching mode
:type path: lis... | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"strict",
")",
":",
"item",
",",
"pathinfo",
"=",
"self",
".",
"_get",
"(",
"path",
",",
"strict",
")",
"if",
"item",
"is",
"None",
":",
"if",
"strict",
":",
"return",
"None",
",",
"pathinfo",
"else",
... | Gets the item for `path`. If `strict` is true, this method
returns `None` when matching path is not found.
Otherwise, this returns the result item of prefix searching.
:param path: Path to get
:param strict: Searching mode
:type path: list
:type strict: bool | [
"Gets",
"the",
"item",
"for",
"path",
".",
"If",
"strict",
"is",
"true",
"this",
"method",
"returns",
"None",
"when",
"matching",
"path",
"is",
"not",
"found",
".",
"Otherwise",
"this",
"returns",
"the",
"result",
"item",
"of",
"prefix",
"searching",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/routings/routetree.py#L25-L45 |
246,147 | tomokinakamaru/mapletree | mapletree/defaults/routings/routetree.py | RouteTree.set | def set(self, path, item, replace):
""" Sets item for `path` and returns the item.
Replaces existing item with `item` when `replace` is true
:param path: Path for item
:param item: New item
:param replace: Updating mode
:type path: list
:type item: object
... | python | def set(self, path, item, replace):
""" Sets item for `path` and returns the item.
Replaces existing item with `item` when `replace` is true
:param path: Path for item
:param item: New item
:param replace: Updating mode
:type path: list
:type item: object
... | [
"def",
"set",
"(",
"self",
",",
"path",
",",
"item",
",",
"replace",
")",
":",
"if",
"len",
"(",
"path",
")",
"==",
"0",
":",
"if",
"self",
".",
"_item",
"is",
"None",
"or",
"replace",
":",
"self",
".",
"_item",
"=",
"item",
"return",
"self",
"... | Sets item for `path` and returns the item.
Replaces existing item with `item` when `replace` is true
:param path: Path for item
:param item: New item
:param replace: Updating mode
:type path: list
:type item: object
:type replace: bool | [
"Sets",
"item",
"for",
"path",
"and",
"returns",
"the",
"item",
".",
"Replaces",
"existing",
"item",
"with",
"item",
"when",
"replace",
"is",
"true"
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/routings/routetree.py#L47-L74 |
246,148 | knagra/farnsworth | events/ajax.py | build_ajax_rsvps | def build_ajax_rsvps(event, user_profile):
"""Return link and list strings for a given event."""
if user_profile in event.rsvps.all():
link_string = True
else:
link_string = False
if not event.rsvps.all().count():
list_string = 'No RSVPs.'
else:
list_string = 'RSVPs:... | python | def build_ajax_rsvps(event, user_profile):
"""Return link and list strings for a given event."""
if user_profile in event.rsvps.all():
link_string = True
else:
link_string = False
if not event.rsvps.all().count():
list_string = 'No RSVPs.'
else:
list_string = 'RSVPs:... | [
"def",
"build_ajax_rsvps",
"(",
"event",
",",
"user_profile",
")",
":",
"if",
"user_profile",
"in",
"event",
".",
"rsvps",
".",
"all",
"(",
")",
":",
"link_string",
"=",
"True",
"else",
":",
"link_string",
"=",
"False",
"if",
"not",
"event",
".",
"rsvps"... | Return link and list strings for a given event. | [
"Return",
"link",
"and",
"list",
"strings",
"for",
"a",
"given",
"event",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/events/ajax.py#L12-L37 |
246,149 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RequestWrapper.setResponse | def setResponse(self, response):
"""
A response has been received by the gateway
"""
self.response = response
self.result = self.response.body
if isinstance(self.result, remoting.ErrorFault):
self.result.raiseException() | python | def setResponse(self, response):
"""
A response has been received by the gateway
"""
self.response = response
self.result = self.response.body
if isinstance(self.result, remoting.ErrorFault):
self.result.raiseException() | [
"def",
"setResponse",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"response",
"=",
"response",
"self",
".",
"result",
"=",
"self",
".",
"response",
".",
"body",
"if",
"isinstance",
"(",
"self",
".",
"result",
",",
"remoting",
".",
"ErrorFault",
... | A response has been received by the gateway | [
"A",
"response",
"has",
"been",
"received",
"by",
"the",
"gateway"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L152-L160 |
246,150 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.addHeader | def addHeader(self, name, value, must_understand=False):
"""
Sets a persistent header to send with each request.
@param name: Header name.
"""
self.headers[name] = value
self.headers.set_required(name, must_understand) | python | def addHeader(self, name, value, must_understand=False):
"""
Sets a persistent header to send with each request.
@param name: Header name.
"""
self.headers[name] = value
self.headers.set_required(name, must_understand) | [
"def",
"addHeader",
"(",
"self",
",",
"name",
",",
"value",
",",
"must_understand",
"=",
"False",
")",
":",
"self",
".",
"headers",
"[",
"name",
"]",
"=",
"value",
"self",
".",
"headers",
".",
"set_required",
"(",
"name",
",",
"must_understand",
")"
] | Sets a persistent header to send with each request.
@param name: Header name. | [
"Sets",
"a",
"persistent",
"header",
"to",
"send",
"with",
"each",
"request",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L253-L260 |
246,151 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.getRequest | def getRequest(self, id_):
"""
Gets a request based on the id.
:raise LookupError: Request not found.
"""
for request in self.requests:
if request.id == id_:
return request
raise LookupError("Request %r not found" % (id_,)) | python | def getRequest(self, id_):
"""
Gets a request based on the id.
:raise LookupError: Request not found.
"""
for request in self.requests:
if request.id == id_:
return request
raise LookupError("Request %r not found" % (id_,)) | [
"def",
"getRequest",
"(",
"self",
",",
"id_",
")",
":",
"for",
"request",
"in",
"self",
".",
"requests",
":",
"if",
"request",
".",
"id",
"==",
"id_",
":",
"return",
"request",
"raise",
"LookupError",
"(",
"\"Request %r not found\"",
"%",
"(",
"id_",
","... | Gets a request based on the id.
:raise LookupError: Request not found. | [
"Gets",
"a",
"request",
"based",
"on",
"the",
"id",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L286-L296 |
246,152 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.addRequest | def addRequest(self, service, *args):
"""
Adds a request to be sent to the remoting gateway.
"""
wrapper = RequestWrapper(self, '/%d' % self.request_number,
service, *args)
self.request_number += 1
self.requests.append(wrapper)
if self.logger:
... | python | def addRequest(self, service, *args):
"""
Adds a request to be sent to the remoting gateway.
"""
wrapper = RequestWrapper(self, '/%d' % self.request_number,
service, *args)
self.request_number += 1
self.requests.append(wrapper)
if self.logger:
... | [
"def",
"addRequest",
"(",
"self",
",",
"service",
",",
"*",
"args",
")",
":",
"wrapper",
"=",
"RequestWrapper",
"(",
"self",
",",
"'/%d'",
"%",
"self",
".",
"request_number",
",",
"service",
",",
"*",
"args",
")",
"self",
".",
"request_number",
"+=",
"... | Adds a request to be sent to the remoting gateway. | [
"Adds",
"a",
"request",
"to",
"be",
"sent",
"to",
"the",
"remoting",
"gateway",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L298-L311 |
246,153 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.removeRequest | def removeRequest(self, service, *args):
"""
Removes a request from the pending request list.
"""
if isinstance(service, RequestWrapper):
if self.logger:
self.logger.debug('Removing request: %s',
self.requests[self.requests.index(service)]... | python | def removeRequest(self, service, *args):
"""
Removes a request from the pending request list.
"""
if isinstance(service, RequestWrapper):
if self.logger:
self.logger.debug('Removing request: %s',
self.requests[self.requests.index(service)]... | [
"def",
"removeRequest",
"(",
"self",
",",
"service",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"service",
",",
"RequestWrapper",
")",
":",
"if",
"self",
".",
"logger",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Removing request: %s'",
",... | Removes a request from the pending request list. | [
"Removes",
"a",
"request",
"from",
"the",
"pending",
"request",
"list",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L313-L335 |
246,154 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.execute_single | def execute_single(self, request):
"""
Builds, sends and handles the response to a single request, returning
the response.
"""
if self.logger:
self.logger.debug('Executing single request: %s', request)
self.removeRequest(request)
body = remoting.enco... | python | def execute_single(self, request):
"""
Builds, sends and handles the response to a single request, returning
the response.
"""
if self.logger:
self.logger.debug('Executing single request: %s', request)
self.removeRequest(request)
body = remoting.enco... | [
"def",
"execute_single",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"logger",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Executing single request: %s'",
",",
"request",
")",
"self",
".",
"removeRequest",
"(",
"request",
")",
"body",
"=... | Builds, sends and handles the response to a single request, returning
the response. | [
"Builds",
"sends",
"and",
"handles",
"the",
"response",
"to",
"a",
"single",
"request",
"returning",
"the",
"response",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L370-L390 |
246,155 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService._getResponse | def _getResponse(self, http_request):
"""
Gets and handles the HTTP response from the remote gateway.
"""
if self.logger:
self.logger.debug('Sending POST request to %s', self._root_url)
try:
fbh = self.opener(http_request)
except urllib2.URLError,... | python | def _getResponse(self, http_request):
"""
Gets and handles the HTTP response from the remote gateway.
"""
if self.logger:
self.logger.debug('Sending POST request to %s', self._root_url)
try:
fbh = self.opener(http_request)
except urllib2.URLError,... | [
"def",
"_getResponse",
"(",
"self",
",",
"http_request",
")",
":",
"if",
"self",
".",
"logger",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Sending POST request to %s'",
",",
"self",
".",
"_root_url",
")",
"try",
":",
"fbh",
"=",
"self",
".",
"opene... | Gets and handles the HTTP response from the remote gateway. | [
"Gets",
"and",
"handles",
"the",
"HTTP",
"response",
"from",
"the",
"remote",
"gateway",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L415-L487 |
246,156 | jmgilman/Neolib | neolib/pyamf/remoting/client/__init__.py | RemotingService.setCredentials | def setCredentials(self, username, password):
"""
Sets authentication credentials for accessing the remote gateway.
"""
self.addHeader('Credentials', dict(userid=username.decode('utf-8'),
password=password.decode('utf-8')), True) | python | def setCredentials(self, username, password):
"""
Sets authentication credentials for accessing the remote gateway.
"""
self.addHeader('Credentials', dict(userid=username.decode('utf-8'),
password=password.decode('utf-8')), True) | [
"def",
"setCredentials",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"addHeader",
"(",
"'Credentials'",
",",
"dict",
"(",
"userid",
"=",
"username",
".",
"decode",
"(",
"'utf-8'",
")",
",",
"password",
"=",
"password",
".",
"dec... | Sets authentication credentials for accessing the remote gateway. | [
"Sets",
"authentication",
"credentials",
"for",
"accessing",
"the",
"remote",
"gateway",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/client/__init__.py#L489-L494 |
246,157 | neuroticnerd/armory | armory/gevent.py | patch_gevent_hub | def patch_gevent_hub():
""" This patches the error handler in the gevent Hub object. """
from gevent.hub import Hub
def patched_handle_error(self, context, etype, value, tb):
""" Patched to not print KeyboardInterrupt exceptions. """
if isinstance(value, str):
value = etype(valu... | python | def patch_gevent_hub():
""" This patches the error handler in the gevent Hub object. """
from gevent.hub import Hub
def patched_handle_error(self, context, etype, value, tb):
""" Patched to not print KeyboardInterrupt exceptions. """
if isinstance(value, str):
value = etype(valu... | [
"def",
"patch_gevent_hub",
"(",
")",
":",
"from",
"gevent",
".",
"hub",
"import",
"Hub",
"def",
"patched_handle_error",
"(",
"self",
",",
"context",
",",
"etype",
",",
"value",
",",
"tb",
")",
":",
"\"\"\" Patched to not print KeyboardInterrupt exceptions. \"\"\"",
... | This patches the error handler in the gevent Hub object. | [
"This",
"patches",
"the",
"error",
"handler",
"in",
"the",
"gevent",
"Hub",
"object",
"."
] | d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1 | https://github.com/neuroticnerd/armory/blob/d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1/armory/gevent.py#L15-L31 |
246,158 | abe-winter/pg13-py | pg13/scope.py | col2name | def col2name(col_item):
"helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name"
if isinstance(col_item, sqparse2.NameX): return col_item.name
elif isinstance(col_item, sqparse2.AliasX): return col_item.alias
else: raise TypeError(type(col_item), col_item) | python | def col2name(col_item):
"helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name"
if isinstance(col_item, sqparse2.NameX): return col_item.name
elif isinstance(col_item, sqparse2.AliasX): return col_item.alias
else: raise TypeError(type(col_item), col_item) | [
"def",
"col2name",
"(",
"col_item",
")",
":",
"if",
"isinstance",
"(",
"col_item",
",",
"sqparse2",
".",
"NameX",
")",
":",
"return",
"col_item",
".",
"name",
"elif",
"isinstance",
"(",
"col_item",
",",
"sqparse2",
".",
"AliasX",
")",
":",
"return",
"col... | helper for SyntheticTable.columns. takes something from SelectX.cols, returns a string column name | [
"helper",
"for",
"SyntheticTable",
".",
"columns",
".",
"takes",
"something",
"from",
"SelectX",
".",
"cols",
"returns",
"a",
"string",
"column",
"name"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L9-L13 |
246,159 | abe-winter/pg13-py | pg13/scope.py | Scope.add | def add(self, name, target):
"target should be a Table or SyntheticTable"
if not isinstance(target, (table.Table, SyntheticTable)):
raise TypeError(type(target), target)
if name in self:
# note: this is critical for avoiding cycles
raise ScopeCollisionError('scope already has', name)
s... | python | def add(self, name, target):
"target should be a Table or SyntheticTable"
if not isinstance(target, (table.Table, SyntheticTable)):
raise TypeError(type(target), target)
if name in self:
# note: this is critical for avoiding cycles
raise ScopeCollisionError('scope already has', name)
s... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"target",
")",
":",
"if",
"not",
"isinstance",
"(",
"target",
",",
"(",
"table",
".",
"Table",
",",
"SyntheticTable",
")",
")",
":",
"raise",
"TypeError",
"(",
"type",
"(",
"target",
")",
",",
"target",
... | target should be a Table or SyntheticTable | [
"target",
"should",
"be",
"a",
"Table",
"or",
"SyntheticTable"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/scope.py#L34-L41 |
246,160 | Tinche/django-bower-cache | registry/views.py | PackagesRetrieveView.clone_from_upstream | def clone_from_upstream(pkg_name, repo_url):
"""Clone a non-existent package using the upstream registry."""
msg = "Spawning a cloning task for %s from upstream due to API req."
LOG.info(msg % pkg_name)
upstream_url = settings.UPSTREAM_BOWER_REGISTRY
upstream_pkg = bowerlib.get_... | python | def clone_from_upstream(pkg_name, repo_url):
"""Clone a non-existent package using the upstream registry."""
msg = "Spawning a cloning task for %s from upstream due to API req."
LOG.info(msg % pkg_name)
upstream_url = settings.UPSTREAM_BOWER_REGISTRY
upstream_pkg = bowerlib.get_... | [
"def",
"clone_from_upstream",
"(",
"pkg_name",
",",
"repo_url",
")",
":",
"msg",
"=",
"\"Spawning a cloning task for %s from upstream due to API req.\"",
"LOG",
".",
"info",
"(",
"msg",
"%",
"pkg_name",
")",
"upstream_url",
"=",
"settings",
".",
"UPSTREAM_BOWER_REGISTRY... | Clone a non-existent package using the upstream registry. | [
"Clone",
"a",
"non",
"-",
"existent",
"package",
"using",
"the",
"upstream",
"registry",
"."
] | 5245b2ee80c33c09d85ce0bf8f047825d9df2118 | https://github.com/Tinche/django-bower-cache/blob/5245b2ee80c33c09d85ce0bf8f047825d9df2118/registry/views.py#L79-L97 |
246,161 | testing-cabal/systemfixtures | systemfixtures/executable.py | allocate_port | def allocate_port():
"""Allocate an unused port.
There is a small race condition here (between the time we allocate the
port, and the time it actually gets used), but for the purposes for which
this function gets used it isn't a problem in practice.
"""
sock = socket.socket()
try:
s... | python | def allocate_port():
"""Allocate an unused port.
There is a small race condition here (between the time we allocate the
port, and the time it actually gets used), but for the purposes for which
this function gets used it isn't a problem in practice.
"""
sock = socket.socket()
try:
s... | [
"def",
"allocate_port",
"(",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
")",
"try",
":",
"sock",
".",
"bind",
"(",
"(",
"\"localhost\"",
",",
"0",
")",
")",
"return",
"get_port",
"(",
"sock",
")",
"finally",
":",
"sock",
".",
"close",
"("... | Allocate an unused port.
There is a small race condition here (between the time we allocate the
port, and the time it actually gets used), but for the purposes for which
this function gets used it isn't a problem in practice. | [
"Allocate",
"an",
"unused",
"port",
"."
] | adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4 | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/executable.py#L115-L127 |
246,162 | testing-cabal/systemfixtures | systemfixtures/executable.py | FakeExecutable.spawn | def spawn(self):
"""Spawn the fake executable using subprocess.Popen."""
self._process = subprocess.Popen(
[self.path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.addCleanup(self._process_kill) | python | def spawn(self):
"""Spawn the fake executable using subprocess.Popen."""
self._process = subprocess.Popen(
[self.path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.addCleanup(self._process_kill) | [
"def",
"spawn",
"(",
"self",
")",
":",
"self",
".",
"_process",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"self",
".",
"path",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"self",
".",
"... | Spawn the fake executable using subprocess.Popen. | [
"Spawn",
"the",
"fake",
"executable",
"using",
"subprocess",
".",
"Popen",
"."
] | adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4 | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/executable.py#L34-L38 |
246,163 | testing-cabal/systemfixtures | systemfixtures/executable.py | FakeExecutable.listen | def listen(self, port=None):
"""Make the fake executable listen to the specified port.
Possible values for 'port' are:
- None: Allocate immediately a free port and instruct the fake
executable to use it when it's invoked. This is subject to
a race condition, if that port th... | python | def listen(self, port=None):
"""Make the fake executable listen to the specified port.
Possible values for 'port' are:
- None: Allocate immediately a free port and instruct the fake
executable to use it when it's invoked. This is subject to
a race condition, if that port th... | [
"def",
"listen",
"(",
"self",
",",
"port",
"=",
"None",
")",
":",
"if",
"port",
"is",
"None",
":",
"port",
"=",
"allocate_port",
"(",
")",
"self",
".",
"port",
"=",
"port",
"self",
".",
"line",
"(",
"\"import socket\"",
")",
"self",
".",
"line",
"(... | Make the fake executable listen to the specified port.
Possible values for 'port' are:
- None: Allocate immediately a free port and instruct the fake
executable to use it when it's invoked. This is subject to
a race condition, if that port that was free when listen() was
... | [
"Make",
"the",
"fake",
"executable",
"listen",
"to",
"the",
"specified",
"port",
"."
] | adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4 | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/executable.py#L59-L81 |
246,164 | testing-cabal/systemfixtures | systemfixtures/executable.py | FakeExecutable._process_kill | def _process_kill(self):
"""Kill the fake executable process if it's still running."""
if self._process.poll() is None: # pragma: no cover
self._process.kill()
self._process.wait(timeout=5) | python | def _process_kill(self):
"""Kill the fake executable process if it's still running."""
if self._process.poll() is None: # pragma: no cover
self._process.kill()
self._process.wait(timeout=5) | [
"def",
"_process_kill",
"(",
"self",
")",
":",
"if",
"self",
".",
"_process",
".",
"poll",
"(",
")",
"is",
"None",
":",
"# pragma: no cover",
"self",
".",
"_process",
".",
"kill",
"(",
")",
"self",
".",
"_process",
".",
"wait",
"(",
"timeout",
"=",
"... | Kill the fake executable process if it's still running. | [
"Kill",
"the",
"fake",
"executable",
"process",
"if",
"it",
"s",
"still",
"running",
"."
] | adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4 | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/executable.py#L87-L91 |
246,165 | testing-cabal/systemfixtures | systemfixtures/executable.py | FakeExecutable._process_info | def _process_info(self):
"""Return details about the fake process."""
if not self._process:
return []
output, error = self._process.communicate(timeout=5)
if error is None:
error = b""
output = output.decode("utf-8").strip()
error = error.decode("... | python | def _process_info(self):
"""Return details about the fake process."""
if not self._process:
return []
output, error = self._process.communicate(timeout=5)
if error is None:
error = b""
output = output.decode("utf-8").strip()
error = error.decode("... | [
"def",
"_process_info",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_process",
":",
"return",
"[",
"]",
"output",
",",
"error",
"=",
"self",
".",
"_process",
".",
"communicate",
"(",
"timeout",
"=",
"5",
")",
"if",
"error",
"is",
"None",
":",
... | Return details about the fake process. | [
"Return",
"details",
"about",
"the",
"fake",
"process",
"."
] | adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4 | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/executable.py#L93-L106 |
246,166 | aganezov/gos | gos/tasks.py | TaskLoader.load_tasks_from_file | def load_tasks_from_file(self, file_path):
""" Imports specified python module and returns subclasses of BaseTask from it
:param file_path: a fully qualified file path for a python module to import CustomTasks from
:type file_path: `str`
:return: a dict of CustomTasks, where key is Cust... | python | def load_tasks_from_file(self, file_path):
""" Imports specified python module and returns subclasses of BaseTask from it
:param file_path: a fully qualified file path for a python module to import CustomTasks from
:type file_path: `str`
:return: a dict of CustomTasks, where key is Cust... | [
"def",
"load_tasks_from_file",
"(",
"self",
",",
"file_path",
")",
":",
"file_name",
",",
"module_path",
",",
"objects",
"=",
"Loader",
".",
"import_custom_python_file",
"(",
"file_path",
")",
"result",
"=",
"{",
"}",
"for",
"entry",
"in",
"objects",
":",
"t... | Imports specified python module and returns subclasses of BaseTask from it
:param file_path: a fully qualified file path for a python module to import CustomTasks from
:type file_path: `str`
:return: a dict of CustomTasks, where key is CustomTask.name, and value is a CustomClass task itself
... | [
"Imports",
"specified",
"python",
"module",
"and",
"returns",
"subclasses",
"of",
"BaseTask",
"from",
"it"
] | fb4d210284f3037c5321250cb95f3901754feb6b | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/tasks.py#L18-L38 |
246,167 | aganezov/gos | gos/tasks.py | TaskLoader.load_tasks_from_dir | def load_tasks_from_dir(self, dir_path, propagate_exceptions=False):
""" Imports all python modules in specified directories and returns subclasses of BaseTask from them
:param propagate_exceptions: a flag that indicates if exceptions from single file import shall be raised during the
whole... | python | def load_tasks_from_dir(self, dir_path, propagate_exceptions=False):
""" Imports all python modules in specified directories and returns subclasses of BaseTask from them
:param propagate_exceptions: a flag that indicates if exceptions from single file import shall be raised during the
whole... | [
"def",
"load_tasks_from_dir",
"(",
"self",
",",
"dir_path",
",",
"propagate_exceptions",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir_path",
")",
":",
"raise",
"GOSTaskException",
"(",
")",
"if",
"os",
".",
"path",
"."... | Imports all python modules in specified directories and returns subclasses of BaseTask from them
:param propagate_exceptions: a flag that indicates if exceptions from single file import shall be raised during the
whole directory lookup
:param dir_path: fully qualified directory path, where ... | [
"Imports",
"all",
"python",
"modules",
"in",
"specified",
"directories",
"and",
"returns",
"subclasses",
"of",
"BaseTask",
"from",
"them"
] | fb4d210284f3037c5321250cb95f3901754feb6b | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/tasks.py#L40-L62 |
246,168 | aganezov/gos | gos/tasks.py | TaskLoader.load_tasks | def load_tasks(self, paths, propagate_exception=False):
""" Loads all subclasses of BaseTask from modules that are contained in supplied directory paths or direct module paths
:param propagate_exception: a flag that indicates if exceptions from single file import shall be raised during the
... | python | def load_tasks(self, paths, propagate_exception=False):
""" Loads all subclasses of BaseTask from modules that are contained in supplied directory paths or direct module paths
:param propagate_exception: a flag that indicates if exceptions from single file import shall be raised during the
... | [
"def",
"load_tasks",
"(",
"self",
",",
"paths",
",",
"propagate_exception",
"=",
"False",
")",
":",
"try",
":",
"result",
"=",
"{",
"}",
"for",
"path",
"in",
"paths",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
... | Loads all subclasses of BaseTask from modules that are contained in supplied directory paths or direct module paths
:param propagate_exception: a flag that indicates if exceptions from single file import shall be raised during the
whole directory lookup
:param paths: an iterable of fully qu... | [
"Loads",
"all",
"subclasses",
"of",
"BaseTask",
"from",
"modules",
"that",
"are",
"contained",
"in",
"supplied",
"directory",
"paths",
"or",
"direct",
"module",
"paths"
] | fb4d210284f3037c5321250cb95f3901754feb6b | https://github.com/aganezov/gos/blob/fb4d210284f3037c5321250cb95f3901754feb6b/gos/tasks.py#L64-L87 |
246,169 | relekang/rmoq | rmoq/base.py | Mock.activate | def activate(self, prefix=None, backend=None):
"""
A decorator used to activate the mocker.
:param prefix:
:param backend: An instance of a storage backend.
"""
if isinstance(prefix, compat.string_types):
self.prefix = prefix
if isinstance(backend, R... | python | def activate(self, prefix=None, backend=None):
"""
A decorator used to activate the mocker.
:param prefix:
:param backend: An instance of a storage backend.
"""
if isinstance(prefix, compat.string_types):
self.prefix = prefix
if isinstance(backend, R... | [
"def",
"activate",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"backend",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"prefix",
",",
"compat",
".",
"string_types",
")",
":",
"self",
".",
"prefix",
"=",
"prefix",
"if",
"isinstance",
"(",
"backend"... | A decorator used to activate the mocker.
:param prefix:
:param backend: An instance of a storage backend. | [
"A",
"decorator",
"used",
"to",
"activate",
"the",
"mocker",
"."
] | 61fd2a221e247b7aca87492f10c3bc3894536260 | https://github.com/relekang/rmoq/blob/61fd2a221e247b7aca87492f10c3bc3894536260/rmoq/base.py#L38-L61 |
246,170 | roaet/wafflehaus.neutron | wafflehaus/neutron/nova_interaction/__init__.py | NovaInteraction._process_call | def _process_call(self, req, resource):
"""This is were all callbacks are made and the req is processed."""
if resource == "ports":
if req.method.upper() in ('PUT', 'POST'):
# Pass the request back to be processed by other filters
# and Neutron first
... | python | def _process_call(self, req, resource):
"""This is were all callbacks are made and the req is processed."""
if resource == "ports":
if req.method.upper() in ('PUT', 'POST'):
# Pass the request back to be processed by other filters
# and Neutron first
... | [
"def",
"_process_call",
"(",
"self",
",",
"req",
",",
"resource",
")",
":",
"if",
"resource",
"==",
"\"ports\"",
":",
"if",
"req",
".",
"method",
".",
"upper",
"(",
")",
"in",
"(",
"'PUT'",
",",
"'POST'",
")",
":",
"# Pass the request back to be processed ... | This is were all callbacks are made and the req is processed. | [
"This",
"is",
"were",
"all",
"callbacks",
"are",
"made",
"and",
"the",
"req",
"is",
"processed",
"."
] | 01f6d69ae759ec2f24f2f7cf9dcfa4a4734f7e1c | https://github.com/roaet/wafflehaus.neutron/blob/01f6d69ae759ec2f24f2f7cf9dcfa4a4734f7e1c/wafflehaus/neutron/nova_interaction/__init__.py#L42-L130 |
246,171 | kalekundert/nonstdlib | nonstdlib/io.py | keep_on_one_line | def keep_on_one_line():
"""
Keep all the output generated within a with-block on one line. Whenever a
new line would be printed, instead reset the cursor to the beginning of the
line and print the new line without a line break.
"""
class CondensedStream:
def __init__(self):
... | python | def keep_on_one_line():
"""
Keep all the output generated within a with-block on one line. Whenever a
new line would be printed, instead reset the cursor to the beginning of the
line and print the new line without a line break.
"""
class CondensedStream:
def __init__(self):
... | [
"def",
"keep_on_one_line",
"(",
")",
":",
"class",
"CondensedStream",
":",
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"sys_stdout",
"=",
"sys",
".",
"stdout",
"def",
"write",
"(",
"self",
",",
"string",
")",
":",
"with",
"swap_streams",
"(",
... | Keep all the output generated within a with-block on one line. Whenever a
new line would be printed, instead reset the cursor to the beginning of the
line and print the new line without a line break. | [
"Keep",
"all",
"the",
"output",
"generated",
"within",
"a",
"with",
"-",
"block",
"on",
"one",
"line",
".",
"Whenever",
"a",
"new",
"line",
"would",
"be",
"printed",
"instead",
"reset",
"the",
"cursor",
"to",
"the",
"beginning",
"of",
"the",
"line",
"and... | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/io.py#L113-L138 |
246,172 | kalekundert/nonstdlib | nonstdlib/io.py | write_color | def write_color(string, name, style='normal', when='auto'):
""" Write the given colored string to standard out. """
write(color(string, name, style, when)) | python | def write_color(string, name, style='normal', when='auto'):
""" Write the given colored string to standard out. """
write(color(string, name, style, when)) | [
"def",
"write_color",
"(",
"string",
",",
"name",
",",
"style",
"=",
"'normal'",
",",
"when",
"=",
"'auto'",
")",
":",
"write",
"(",
"color",
"(",
"string",
",",
"name",
",",
"style",
",",
"when",
")",
")"
] | Write the given colored string to standard out. | [
"Write",
"the",
"given",
"colored",
"string",
"to",
"standard",
"out",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/io.py#L149-L151 |
246,173 | kalekundert/nonstdlib | nonstdlib/io.py | update_color | def update_color(string, name, style='normal', when='auto'):
""" Replace the existing line with the given colored string. """
clear()
write_color(string, name, style, when) | python | def update_color(string, name, style='normal', when='auto'):
""" Replace the existing line with the given colored string. """
clear()
write_color(string, name, style, when) | [
"def",
"update_color",
"(",
"string",
",",
"name",
",",
"style",
"=",
"'normal'",
",",
"when",
"=",
"'auto'",
")",
":",
"clear",
"(",
")",
"write_color",
"(",
"string",
",",
"name",
",",
"style",
",",
"when",
")"
] | Replace the existing line with the given colored string. | [
"Replace",
"the",
"existing",
"line",
"with",
"the",
"given",
"colored",
"string",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/io.py#L158-L161 |
246,174 | kalekundert/nonstdlib | nonstdlib/io.py | progress_color | def progress_color(current, total, name, style='normal', when='auto'):
""" Display a simple, colored progress report. """
update_color('[%d/%d] ' % (current, total), name, style, when) | python | def progress_color(current, total, name, style='normal', when='auto'):
""" Display a simple, colored progress report. """
update_color('[%d/%d] ' % (current, total), name, style, when) | [
"def",
"progress_color",
"(",
"current",
",",
"total",
",",
"name",
",",
"style",
"=",
"'normal'",
",",
"when",
"=",
"'auto'",
")",
":",
"update_color",
"(",
"'[%d/%d] '",
"%",
"(",
"current",
",",
"total",
")",
",",
"name",
",",
"style",
",",
"when",
... | Display a simple, colored progress report. | [
"Display",
"a",
"simple",
"colored",
"progress",
"report",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/io.py#L167-L169 |
246,175 | kalekundert/nonstdlib | nonstdlib/io.py | color | def color(string, name, style='normal', when='auto'):
""" Change the color of the given string. """
if name not in colors:
from .text import oxford_comma
raise ValueError("unknown color '{}'.\nknown colors are: {}".format(
name, oxford_comma(["'{}'".format(x) for x in sorted(colors)]... | python | def color(string, name, style='normal', when='auto'):
""" Change the color of the given string. """
if name not in colors:
from .text import oxford_comma
raise ValueError("unknown color '{}'.\nknown colors are: {}".format(
name, oxford_comma(["'{}'".format(x) for x in sorted(colors)]... | [
"def",
"color",
"(",
"string",
",",
"name",
",",
"style",
"=",
"'normal'",
",",
"when",
"=",
"'auto'",
")",
":",
"if",
"name",
"not",
"in",
"colors",
":",
"from",
".",
"text",
"import",
"oxford_comma",
"raise",
"ValueError",
"(",
"\"unknown color '{}'.\\nk... | Change the color of the given string. | [
"Change",
"the",
"color",
"of",
"the",
"given",
"string",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/io.py#L171-L194 |
246,176 | fstab50/metal | metal/chkrootkit.py | download | def download(objects):
"""
Retrieve remote file object
"""
def exists(object):
if os.path.exists(TMPDIR + '/' + filename):
return True
else:
msg = 'File object %s failed to download to %s. Exit' % (filename, TMPDIR)
logger.warning(msg)
stdo... | python | def download(objects):
"""
Retrieve remote file object
"""
def exists(object):
if os.path.exists(TMPDIR + '/' + filename):
return True
else:
msg = 'File object %s failed to download to %s. Exit' % (filename, TMPDIR)
logger.warning(msg)
stdo... | [
"def",
"download",
"(",
"objects",
")",
":",
"def",
"exists",
"(",
"object",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"TMPDIR",
"+",
"'/'",
"+",
"filename",
")",
":",
"return",
"True",
"else",
":",
"msg",
"=",
"'File object %s failed to d... | Retrieve remote file object | [
"Retrieve",
"remote",
"file",
"object"
] | 0488bbdd516a508909267cc44191f632e21156ba | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chkrootkit.py#L73-L96 |
246,177 | fstab50/metal | metal/chkrootkit.py | precheck | def precheck():
"""
Pre-run dependency check
"""
binaries = ['make']
for bin in binaries:
if not which(bin):
msg = 'Dependency fail -- Unable to locate rquired binary: '
stdout_message('%s: %s' % (msg, ACCENT + bin + RESET))
return False
elif not r... | python | def precheck():
"""
Pre-run dependency check
"""
binaries = ['make']
for bin in binaries:
if not which(bin):
msg = 'Dependency fail -- Unable to locate rquired binary: '
stdout_message('%s: %s' % (msg, ACCENT + bin + RESET))
return False
elif not r... | [
"def",
"precheck",
"(",
")",
":",
"binaries",
"=",
"[",
"'make'",
"]",
"for",
"bin",
"in",
"binaries",
":",
"if",
"not",
"which",
"(",
"bin",
")",
":",
"msg",
"=",
"'Dependency fail -- Unable to locate rquired binary: '",
"stdout_message",
"(",
"'%s: %s'",
"%"... | Pre-run dependency check | [
"Pre",
"-",
"run",
"dependency",
"check"
] | 0488bbdd516a508909267cc44191f632e21156ba | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/chkrootkit.py#L189-L201 |
246,178 | knagra/farnsworth | workshift/views.py | start_semester_view | def start_semester_view(request):
"""
Initiates a semester"s worth of workshift, with the option to copy
workshift types from the previous semester.
"""
page_name = "Start Semester"
year, season = utils.get_year_season()
start_date, end_date = utils.get_semester_start_end(year, season)
... | python | def start_semester_view(request):
"""
Initiates a semester"s worth of workshift, with the option to copy
workshift types from the previous semester.
"""
page_name = "Start Semester"
year, season = utils.get_year_season()
start_date, end_date = utils.get_semester_start_end(year, season)
... | [
"def",
"start_semester_view",
"(",
"request",
")",
":",
"page_name",
"=",
"\"Start Semester\"",
"year",
",",
"season",
"=",
"utils",
".",
"get_year_season",
"(",
")",
"start_date",
",",
"end_date",
"=",
"utils",
".",
"get_semester_start_end",
"(",
"year",
",",
... | Initiates a semester"s worth of workshift, with the option to copy
workshift types from the previous semester. | [
"Initiates",
"a",
"semester",
"s",
"worth",
"of",
"workshift",
"with",
"the",
"option",
"to",
"copy",
"workshift",
"types",
"from",
"the",
"previous",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L196-L249 |
246,179 | knagra/farnsworth | workshift/views.py | _is_preferred | def _is_preferred(instance, profile):
"""
Check if a user has marked an instance's workshift type as preferred.
"""
if not instance.weekly_workshift:
return False
if profile and profile.ratings.filter(
workshift_type=instance.weekly_workshift.workshift_type,
rating=Wo... | python | def _is_preferred(instance, profile):
"""
Check if a user has marked an instance's workshift type as preferred.
"""
if not instance.weekly_workshift:
return False
if profile and profile.ratings.filter(
workshift_type=instance.weekly_workshift.workshift_type,
rating=Wo... | [
"def",
"_is_preferred",
"(",
"instance",
",",
"profile",
")",
":",
"if",
"not",
"instance",
".",
"weekly_workshift",
":",
"return",
"False",
"if",
"profile",
"and",
"profile",
".",
"ratings",
".",
"filter",
"(",
"workshift_type",
"=",
"instance",
".",
"weekl... | Check if a user has marked an instance's workshift type as preferred. | [
"Check",
"if",
"a",
"user",
"has",
"marked",
"an",
"instance",
"s",
"workshift",
"type",
"as",
"preferred",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L540-L551 |
246,180 | knagra/farnsworth | workshift/views.py | profile_view | def profile_view(request, semester, targetUsername, profile=None):
"""
Show the user their workshift history for the current semester as well as
upcoming shifts.
"""
wprofile = get_object_or_404(
WorkshiftProfile,
user__username=targetUsername,
semester=semester
)
if ... | python | def profile_view(request, semester, targetUsername, profile=None):
"""
Show the user their workshift history for the current semester as well as
upcoming shifts.
"""
wprofile = get_object_or_404(
WorkshiftProfile,
user__username=targetUsername,
semester=semester
)
if ... | [
"def",
"profile_view",
"(",
"request",
",",
"semester",
",",
"targetUsername",
",",
"profile",
"=",
"None",
")",
":",
"wprofile",
"=",
"get_object_or_404",
"(",
"WorkshiftProfile",
",",
"user__username",
"=",
"targetUsername",
",",
"semester",
"=",
"semester",
"... | Show the user their workshift history for the current semester as well as
upcoming shifts. | [
"Show",
"the",
"user",
"their",
"workshift",
"history",
"for",
"the",
"current",
"semester",
"as",
"well",
"as",
"upcoming",
"shifts",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L651-L703 |
246,181 | knagra/farnsworth | workshift/views.py | preferences_view | def preferences_view(request, semester, targetUsername, profile=None):
"""
Show the user their preferences for the given semester.
"""
# TODO: Change template to show descriptions in tooltip / ajax show box?
wprofile = get_object_or_404(
WorkshiftProfile,
user__username=targetUsernam... | python | def preferences_view(request, semester, targetUsername, profile=None):
"""
Show the user their preferences for the given semester.
"""
# TODO: Change template to show descriptions in tooltip / ajax show box?
wprofile = get_object_or_404(
WorkshiftProfile,
user__username=targetUsernam... | [
"def",
"preferences_view",
"(",
"request",
",",
"semester",
",",
"targetUsername",
",",
"profile",
"=",
"None",
")",
":",
"# TODO: Change template to show descriptions in tooltip / ajax show box?",
"wprofile",
"=",
"get_object_or_404",
"(",
"WorkshiftProfile",
",",
"user__u... | Show the user their preferences for the given semester. | [
"Show",
"the",
"user",
"their",
"preferences",
"for",
"the",
"given",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L707-L784 |
246,182 | knagra/farnsworth | workshift/views.py | adjust_hours_view | def adjust_hours_view(request, semester):
"""
Adjust members' workshift hours requirements.
"""
page_name = "Adjust Hours"
pools = WorkshiftPool.objects.filter(semester=semester).order_by(
"-is_primary", "title",
)
workshifters = WorkshiftProfile.objects.filter(semester=semester)
... | python | def adjust_hours_view(request, semester):
"""
Adjust members' workshift hours requirements.
"""
page_name = "Adjust Hours"
pools = WorkshiftPool.objects.filter(semester=semester).order_by(
"-is_primary", "title",
)
workshifters = WorkshiftProfile.objects.filter(semester=semester)
... | [
"def",
"adjust_hours_view",
"(",
"request",
",",
"semester",
")",
":",
"page_name",
"=",
"\"Adjust Hours\"",
"pools",
"=",
"WorkshiftPool",
".",
"objects",
".",
"filter",
"(",
"semester",
"=",
"semester",
")",
".",
"order_by",
"(",
"\"-is_primary\"",
",",
"\"t... | Adjust members' workshift hours requirements. | [
"Adjust",
"members",
"workshift",
"hours",
"requirements",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1025-L1069 |
246,183 | knagra/farnsworth | workshift/views.py | add_workshifter_view | def add_workshifter_view(request, semester):
"""
Add a new member workshift profile, for people who join mid-semester.
"""
page_name = "Add Workshifter"
existing = [
i.user.pk for i in WorkshiftProfile.objects.filter(semester=semester)
]
users = User.objects.exclude(
Q(pk__i... | python | def add_workshifter_view(request, semester):
"""
Add a new member workshift profile, for people who join mid-semester.
"""
page_name = "Add Workshifter"
existing = [
i.user.pk for i in WorkshiftProfile.objects.filter(semester=semester)
]
users = User.objects.exclude(
Q(pk__i... | [
"def",
"add_workshifter_view",
"(",
"request",
",",
"semester",
")",
":",
"page_name",
"=",
"\"Add Workshifter\"",
"existing",
"=",
"[",
"i",
".",
"user",
".",
"pk",
"for",
"i",
"in",
"WorkshiftProfile",
".",
"objects",
".",
"filter",
"(",
"semester",
"=",
... | Add a new member workshift profile, for people who join mid-semester. | [
"Add",
"a",
"new",
"member",
"workshift",
"profile",
"for",
"people",
"who",
"join",
"mid",
"-",
"semester",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1074-L1116 |
246,184 | knagra/farnsworth | workshift/views.py | fill_shifts_view | def fill_shifts_view(request, semester):
"""
Allows managers to quickly fill in the default workshifts for a few given
workshift pools.
"""
page_name = "Fill Shifts"
fill_regular_shifts_form = None
fill_social_shifts_form = None
fill_humor_shifts_form = None
fill_bathroom_shifts_for... | python | def fill_shifts_view(request, semester):
"""
Allows managers to quickly fill in the default workshifts for a few given
workshift pools.
"""
page_name = "Fill Shifts"
fill_regular_shifts_form = None
fill_social_shifts_form = None
fill_humor_shifts_form = None
fill_bathroom_shifts_for... | [
"def",
"fill_shifts_view",
"(",
"request",
",",
"semester",
")",
":",
"page_name",
"=",
"\"Fill Shifts\"",
"fill_regular_shifts_form",
"=",
"None",
"fill_social_shifts_form",
"=",
"None",
"fill_humor_shifts_form",
"=",
"None",
"fill_bathroom_shifts_form",
"=",
"None",
"... | Allows managers to quickly fill in the default workshifts for a few given
workshift pools. | [
"Allows",
"managers",
"to",
"quickly",
"fill",
"in",
"the",
"default",
"workshifts",
"for",
"a",
"few",
"given",
"workshift",
"pools",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1151-L1228 |
246,185 | knagra/farnsworth | workshift/views.py | add_shift_view | def add_shift_view(request, semester):
"""
View for the workshift manager to create new types of workshifts.
"""
page_name = "Add Workshift"
any_management = utils.can_manage(request.user, semester, any_pool=True)
if not any_management:
messages.add_message(
request,
... | python | def add_shift_view(request, semester):
"""
View for the workshift manager to create new types of workshifts.
"""
page_name = "Add Workshift"
any_management = utils.can_manage(request.user, semester, any_pool=True)
if not any_management:
messages.add_message(
request,
... | [
"def",
"add_shift_view",
"(",
"request",
",",
"semester",
")",
":",
"page_name",
"=",
"\"Add Workshift\"",
"any_management",
"=",
"utils",
".",
"can_manage",
"(",
"request",
".",
"user",
",",
"semester",
",",
"any_pool",
"=",
"True",
")",
"if",
"not",
"any_m... | View for the workshift manager to create new types of workshifts. | [
"View",
"for",
"the",
"workshift",
"manager",
"to",
"create",
"new",
"types",
"of",
"workshifts",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1233-L1292 |
246,186 | knagra/farnsworth | workshift/views.py | shift_view | def shift_view(request, semester, pk, profile=None):
"""
View the details of a particular RegularWorkshift.
"""
shift = get_object_or_404(RegularWorkshift, pk=pk)
page_name = shift.workshift_type.title
if shift.is_manager_shift:
president = Manager.objects.filter(
incumbent_... | python | def shift_view(request, semester, pk, profile=None):
"""
View the details of a particular RegularWorkshift.
"""
shift = get_object_or_404(RegularWorkshift, pk=pk)
page_name = shift.workshift_type.title
if shift.is_manager_shift:
president = Manager.objects.filter(
incumbent_... | [
"def",
"shift_view",
"(",
"request",
",",
"semester",
",",
"pk",
",",
"profile",
"=",
"None",
")",
":",
"shift",
"=",
"get_object_or_404",
"(",
"RegularWorkshift",
",",
"pk",
"=",
"pk",
")",
"page_name",
"=",
"shift",
".",
"workshift_type",
".",
"title",
... | View the details of a particular RegularWorkshift. | [
"View",
"the",
"details",
"of",
"a",
"particular",
"RegularWorkshift",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1440-L1487 |
246,187 | knagra/farnsworth | workshift/views.py | edit_shift_view | def edit_shift_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular RegularWorkshift.
"""
shift = get_object_or_404(RegularWorkshift, pk=pk)
if shift.is_manager_shift:
# XXX: Bad way of doing this, we should make manager_shift point to
... | python | def edit_shift_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular RegularWorkshift.
"""
shift = get_object_or_404(RegularWorkshift, pk=pk)
if shift.is_manager_shift:
# XXX: Bad way of doing this, we should make manager_shift point to
... | [
"def",
"edit_shift_view",
"(",
"request",
",",
"semester",
",",
"pk",
",",
"profile",
"=",
"None",
")",
":",
"shift",
"=",
"get_object_or_404",
"(",
"RegularWorkshift",
",",
"pk",
"=",
"pk",
")",
"if",
"shift",
".",
"is_manager_shift",
":",
"# XXX: Bad way o... | View for a manager to edit the details of a particular RegularWorkshift. | [
"View",
"for",
"a",
"manager",
"to",
"edit",
"the",
"details",
"of",
"a",
"particular",
"RegularWorkshift",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1491-L1538 |
246,188 | knagra/farnsworth | workshift/views.py | instance_view | def instance_view(request, semester, pk, profile=None):
"""
View the details of a particular WorkshiftInstance.
"""
instance = get_object_or_404(WorkshiftInstance, pk=pk)
page_name = instance.title
management = utils.can_manage(
request.user,
semester=semester,
pool=insta... | python | def instance_view(request, semester, pk, profile=None):
"""
View the details of a particular WorkshiftInstance.
"""
instance = get_object_or_404(WorkshiftInstance, pk=pk)
page_name = instance.title
management = utils.can_manage(
request.user,
semester=semester,
pool=insta... | [
"def",
"instance_view",
"(",
"request",
",",
"semester",
",",
"pk",
",",
"profile",
"=",
"None",
")",
":",
"instance",
"=",
"get_object_or_404",
"(",
"WorkshiftInstance",
",",
"pk",
"=",
"pk",
")",
"page_name",
"=",
"instance",
".",
"title",
"management",
... | View the details of a particular WorkshiftInstance. | [
"View",
"the",
"details",
"of",
"a",
"particular",
"WorkshiftInstance",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1542-L1609 |
246,189 | knagra/farnsworth | workshift/views.py | edit_instance_view | def edit_instance_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular WorkshiftInstance.
"""
instance = get_object_or_404(WorkshiftInstance, pk=pk)
if instance.weekly_workshift and instance.weekly_workshift.is_manager_shift:
president = Mana... | python | def edit_instance_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular WorkshiftInstance.
"""
instance = get_object_or_404(WorkshiftInstance, pk=pk)
if instance.weekly_workshift and instance.weekly_workshift.is_manager_shift:
president = Mana... | [
"def",
"edit_instance_view",
"(",
"request",
",",
"semester",
",",
"pk",
",",
"profile",
"=",
"None",
")",
":",
"instance",
"=",
"get_object_or_404",
"(",
"WorkshiftInstance",
",",
"pk",
"=",
"pk",
")",
"if",
"instance",
".",
"weekly_workshift",
"and",
"inst... | View for a manager to edit the details of a particular WorkshiftInstance. | [
"View",
"for",
"a",
"manager",
"to",
"edit",
"the",
"details",
"of",
"a",
"particular",
"WorkshiftInstance",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1613-L1659 |
246,190 | knagra/farnsworth | workshift/views.py | edit_type_view | def edit_type_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular WorkshiftType.
"""
wtype = get_object_or_404(WorkshiftType, pk=pk)
full_management = utils.can_manage(request.user, semester)
any_management = utils.can_manage(request.user, semest... | python | def edit_type_view(request, semester, pk, profile=None):
"""
View for a manager to edit the details of a particular WorkshiftType.
"""
wtype = get_object_or_404(WorkshiftType, pk=pk)
full_management = utils.can_manage(request.user, semester)
any_management = utils.can_manage(request.user, semest... | [
"def",
"edit_type_view",
"(",
"request",
",",
"semester",
",",
"pk",
",",
"profile",
"=",
"None",
")",
":",
"wtype",
"=",
"get_object_or_404",
"(",
"WorkshiftType",
",",
"pk",
"=",
"pk",
")",
"full_management",
"=",
"utils",
".",
"can_manage",
"(",
"reques... | View for a manager to edit the details of a particular WorkshiftType. | [
"View",
"for",
"a",
"manager",
"to",
"edit",
"the",
"details",
"of",
"a",
"particular",
"WorkshiftType",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/views.py#L1719-L1783 |
246,191 | xtrementl/focus | focus/environment/__init__.py | _import_modules | def _import_modules(dir_path):
""" Attempts to import modules in the specified directory path.
`dir_path`
Base directory path to attempt to import modules.
"""
def _import_module(module):
""" Imports the specified module.
"""
# already loaded, skip
... | python | def _import_modules(dir_path):
""" Attempts to import modules in the specified directory path.
`dir_path`
Base directory path to attempt to import modules.
"""
def _import_module(module):
""" Imports the specified module.
"""
# already loaded, skip
... | [
"def",
"_import_modules",
"(",
"dir_path",
")",
":",
"def",
"_import_module",
"(",
"module",
")",
":",
"\"\"\" Imports the specified module.\n \"\"\"",
"# already loaded, skip",
"if",
"module",
"in",
"mods_loaded",
":",
"return",
"False",
"__import__",
"(",
"... | Attempts to import modules in the specified directory path.
`dir_path`
Base directory path to attempt to import modules. | [
"Attempts",
"to",
"import",
"modules",
"in",
"the",
"specified",
"directory",
"path",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/__init__.py#L22-L62 |
246,192 | xtrementl/focus | focus/environment/__init__.py | Environment._setup_directories | def _setup_directories(self):
""" Creates data directory structure.
* Raises a ``DirectorySetupFail`` exception if error occurs
while creating directories.
"""
dirs = [self._data_dir]
dirs += [os.path.join(self._data_dir, name) for name
in ... | python | def _setup_directories(self):
""" Creates data directory structure.
* Raises a ``DirectorySetupFail`` exception if error occurs
while creating directories.
"""
dirs = [self._data_dir]
dirs += [os.path.join(self._data_dir, name) for name
in ... | [
"def",
"_setup_directories",
"(",
"self",
")",
":",
"dirs",
"=",
"[",
"self",
".",
"_data_dir",
"]",
"dirs",
"+=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_data_dir",
",",
"name",
")",
"for",
"name",
"in",
"self",
".",
"DATA_SUBDIRS",... | Creates data directory structure.
* Raises a ``DirectorySetupFail`` exception if error occurs
while creating directories. | [
"Creates",
"data",
"directory",
"structure",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/__init__.py#L104-L123 |
246,193 | xtrementl/focus | focus/environment/__init__.py | Environment._setup_task | def _setup_task(self, load):
""" Sets up the ``Task`` object and loads active file for task.
`load`
Set to ``True`` to load task after setup.
"""
if not self._task:
self._task = Task(self._data_dir)
if load:
self._task.load() | python | def _setup_task(self, load):
""" Sets up the ``Task`` object and loads active file for task.
`load`
Set to ``True`` to load task after setup.
"""
if not self._task:
self._task = Task(self._data_dir)
if load:
self._task.load() | [
"def",
"_setup_task",
"(",
"self",
",",
"load",
")",
":",
"if",
"not",
"self",
".",
"_task",
":",
"self",
".",
"_task",
"=",
"Task",
"(",
"self",
".",
"_data_dir",
")",
"if",
"load",
":",
"self",
".",
"_task",
".",
"load",
"(",
")"
] | Sets up the ``Task`` object and loads active file for task.
`load`
Set to ``True`` to load task after setup. | [
"Sets",
"up",
"the",
"Task",
"object",
"and",
"loads",
"active",
"file",
"for",
"task",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/__init__.py#L125-L136 |
246,194 | xtrementl/focus | focus/environment/__init__.py | Environment._load_plugins | def _load_plugins(self):
""" Attempts to load plugin modules according to the order of available
plugin directories.
"""
# import base plugin modules
try:
__import__('focus.plugin.modules')
#import focus.plugin.modules
except ImportError a... | python | def _load_plugins(self):
""" Attempts to load plugin modules according to the order of available
plugin directories.
"""
# import base plugin modules
try:
__import__('focus.plugin.modules')
#import focus.plugin.modules
except ImportError a... | [
"def",
"_load_plugins",
"(",
"self",
")",
":",
"# import base plugin modules",
"try",
":",
"__import__",
"(",
"'focus.plugin.modules'",
")",
"#import focus.plugin.modules",
"except",
"ImportError",
"as",
"exc",
":",
"raise",
"errors",
".",
"PluginImport",
"(",
"unicod... | Attempts to load plugin modules according to the order of available
plugin directories. | [
"Attempts",
"to",
"load",
"plugin",
"modules",
"according",
"to",
"the",
"order",
"of",
"available",
"plugin",
"directories",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/__init__.py#L138-L156 |
246,195 | xtrementl/focus | focus/environment/__init__.py | Environment.load | def load(self):
""" Loads in resources needed for this environment, including loading a
new or existing task, establishing directory structures, and
importing plugin modules.
"""
self._setup_directories()
self._load_plugins()
self._setup_task(load=Tru... | python | def load(self):
""" Loads in resources needed for this environment, including loading a
new or existing task, establishing directory structures, and
importing plugin modules.
"""
self._setup_directories()
self._load_plugins()
self._setup_task(load=Tru... | [
"def",
"load",
"(",
"self",
")",
":",
"self",
".",
"_setup_directories",
"(",
")",
"self",
".",
"_load_plugins",
"(",
")",
"self",
".",
"_setup_task",
"(",
"load",
"=",
"True",
")",
"self",
".",
"_loaded",
"=",
"True"
] | Loads in resources needed for this environment, including loading a
new or existing task, establishing directory structures, and
importing plugin modules. | [
"Loads",
"in",
"resources",
"needed",
"for",
"this",
"environment",
"including",
"loading",
"a",
"new",
"or",
"existing",
"task",
"establishing",
"directory",
"structures",
"and",
"importing",
"plugin",
"modules",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/environment/__init__.py#L158-L167 |
246,196 | zakdoek/django-simple-resizer | simple_resizer/templatetags/simple_resizer.py | resize | def resize(image, width=None, height=None, crop=False, namespace="resized"):
"""
Returns the url of the resized image
"""
return resize_lazy(image=image, width=width, height=height, crop=crop,
namespace=namespace, as_url=True) | python | def resize(image, width=None, height=None, crop=False, namespace="resized"):
"""
Returns the url of the resized image
"""
return resize_lazy(image=image, width=width, height=height, crop=crop,
namespace=namespace, as_url=True) | [
"def",
"resize",
"(",
"image",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"crop",
"=",
"False",
",",
"namespace",
"=",
"\"resized\"",
")",
":",
"return",
"resize_lazy",
"(",
"image",
"=",
"image",
",",
"width",
"=",
"width",
",",
"he... | Returns the url of the resized image | [
"Returns",
"the",
"url",
"of",
"the",
"resized",
"image"
] | 5614eb1717948c65d179c3d1567439a8c90a4d44 | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/templatetags/simple_resizer.py#L13-L18 |
246,197 | zakdoek/django-simple-resizer | simple_resizer/templatetags/simple_resizer.py | conditional_resize | def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
namespace="resized"):
"""
Crop the image based on a ratio
If upcrop is true, crops the images that have a higher ratio than the given
ratio, if false crops the images that have a lower ratio
"""
as... | python | def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
namespace="resized"):
"""
Crop the image based on a ratio
If upcrop is true, crops the images that have a higher ratio than the given
ratio, if false crops the images that have a lower ratio
"""
as... | [
"def",
"conditional_resize",
"(",
"image",
",",
"ratio",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"upcrop",
"=",
"True",
",",
"namespace",
"=",
"\"resized\"",
")",
":",
"aspect",
"=",
"float",
"(",
"image",
".",
"width",
")",
"/",
... | Crop the image based on a ratio
If upcrop is true, crops the images that have a higher ratio than the given
ratio, if false crops the images that have a lower ratio | [
"Crop",
"the",
"image",
"based",
"on",
"a",
"ratio"
] | 5614eb1717948c65d179c3d1567439a8c90a4d44 | https://github.com/zakdoek/django-simple-resizer/blob/5614eb1717948c65d179c3d1567439a8c90a4d44/simple_resizer/templatetags/simple_resizer.py#L23-L38 |
246,198 | thomasballinger/trellocardupdate | trellocardupdate/cli.py | choose | def choose(s, possibilities, threshold=.6):
"""
Returns the closest match to string s if exceeds threshold, else returns None
"""
if not possibilities: return None
if s in possibilities: return s
if s == '': return None
startswith = [x for x in possibilities if x.lower().startswith(s.lower()... | python | def choose(s, possibilities, threshold=.6):
"""
Returns the closest match to string s if exceeds threshold, else returns None
"""
if not possibilities: return None
if s in possibilities: return s
if s == '': return None
startswith = [x for x in possibilities if x.lower().startswith(s.lower()... | [
"def",
"choose",
"(",
"s",
",",
"possibilities",
",",
"threshold",
"=",
".6",
")",
":",
"if",
"not",
"possibilities",
":",
"return",
"None",
"if",
"s",
"in",
"possibilities",
":",
"return",
"s",
"if",
"s",
"==",
"''",
":",
"return",
"None",
"startswith... | Returns the closest match to string s if exceeds threshold, else returns None | [
"Returns",
"the",
"closest",
"match",
"to",
"string",
"s",
"if",
"exceeds",
"threshold",
"else",
"returns",
"None"
] | 16a648fa15efef144c07cd56fcdb1d8920fac889 | https://github.com/thomasballinger/trellocardupdate/blob/16a648fa15efef144c07cd56fcdb1d8920fac889/trellocardupdate/cli.py#L17-L32 |
246,199 | ryanjdillon/pyotelem | pyotelem/dsp.py | normalized | def normalized(a, axis=-1, order=2):
'''Return normalized vector for arbitrary axis
Args
----
a: ndarray (n,3)
Tri-axial vector data
axis: int
Axis index to overwhich to normalize
order: int
Order of nomalization to calculate
Notes
-----
This function was ad... | python | def normalized(a, axis=-1, order=2):
'''Return normalized vector for arbitrary axis
Args
----
a: ndarray (n,3)
Tri-axial vector data
axis: int
Axis index to overwhich to normalize
order: int
Order of nomalization to calculate
Notes
-----
This function was ad... | [
"def",
"normalized",
"(",
"a",
",",
"axis",
"=",
"-",
"1",
",",
"order",
"=",
"2",
")",
":",
"import",
"numpy",
"l2",
"=",
"numpy",
".",
"atleast_1d",
"(",
"numpy",
".",
"linalg",
".",
"norm",
"(",
"a",
",",
"order",
",",
"axis",
")",
")",
"l2"... | Return normalized vector for arbitrary axis
Args
----
a: ndarray (n,3)
Tri-axial vector data
axis: int
Axis index to overwhich to normalize
order: int
Order of nomalization to calculate
Notes
-----
This function was adapted from the following StackOverflow answe... | [
"Return",
"normalized",
"vector",
"for",
"arbitrary",
"axis"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L2-L24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.