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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
40,100 | numberoverzero/accordian | accordian.py | Dispatch._task | async def _task(self):
""" Main queue processor """
if self._handlers.values():
start_tasks = [h.start() for h in self._handlers.values()]
await asyncio.wait(start_tasks, loop=self.loop)
while self.running:
if self.events:
event, kwargs = awa... | python | async def _task(self):
""" Main queue processor """
if self._handlers.values():
start_tasks = [h.start() for h in self._handlers.values()]
await asyncio.wait(start_tasks, loop=self.loop)
while self.running:
if self.events:
event, kwargs = awa... | [
"async",
"def",
"_task",
"(",
"self",
")",
":",
"if",
"self",
".",
"_handlers",
".",
"values",
"(",
")",
":",
"start_tasks",
"=",
"[",
"h",
".",
"start",
"(",
")",
"for",
"h",
"in",
"self",
".",
"_handlers",
".",
"values",
"(",
")",
"]",
"await",... | Main queue processor | [
"Main",
"queue",
"processor"
] | f1fe44dc9c646006418017bbf70f597b180c8b97 | https://github.com/numberoverzero/accordian/blob/f1fe44dc9c646006418017bbf70f597b180c8b97/accordian.py#L148-L172 |
40,101 | Titan-C/slaveparticles | examples/spins/plot_deg_2orb_fill.py | restriction | def restriction(lam, mu, orbitals, U, beta):
"""Equation that determines the restriction on lagrange multipier"""
return 2*orbitals*fermi_dist(-(mu + lam), beta) - expected_filling(-1*lam, orbitals, U, beta) | python | def restriction(lam, mu, orbitals, U, beta):
"""Equation that determines the restriction on lagrange multipier"""
return 2*orbitals*fermi_dist(-(mu + lam), beta) - expected_filling(-1*lam, orbitals, U, beta) | [
"def",
"restriction",
"(",
"lam",
",",
"mu",
",",
"orbitals",
",",
"U",
",",
"beta",
")",
":",
"return",
"2",
"*",
"orbitals",
"*",
"fermi_dist",
"(",
"-",
"(",
"mu",
"+",
"lam",
")",
",",
"beta",
")",
"-",
"expected_filling",
"(",
"-",
"1",
"*",... | Equation that determines the restriction on lagrange multipier | [
"Equation",
"that",
"determines",
"the",
"restriction",
"on",
"lagrange",
"multipier"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/spins/plot_deg_2orb_fill.py#L29-L31 |
40,102 | Titan-C/slaveparticles | examples/spins/plot_deg_2orb_fill.py | pressision_try | def pressision_try(orbitals, U, beta, step):
"""perform a better initial guess of lambda
no improvement"""
mu, lam = main(orbitals, U, beta, step)
mu2, lam2 = linspace(0, U*orbitals, step), zeros(step)
for i in range(99):
lam2[i+1] = fsolve(restriction, lam2[i], (mu2[i+1], orbitals, U, be... | python | def pressision_try(orbitals, U, beta, step):
"""perform a better initial guess of lambda
no improvement"""
mu, lam = main(orbitals, U, beta, step)
mu2, lam2 = linspace(0, U*orbitals, step), zeros(step)
for i in range(99):
lam2[i+1] = fsolve(restriction, lam2[i], (mu2[i+1], orbitals, U, be... | [
"def",
"pressision_try",
"(",
"orbitals",
",",
"U",
",",
"beta",
",",
"step",
")",
":",
"mu",
",",
"lam",
"=",
"main",
"(",
"orbitals",
",",
"U",
",",
"beta",
",",
"step",
")",
"mu2",
",",
"lam2",
"=",
"linspace",
"(",
"0",
",",
"U",
"*",
"orbi... | perform a better initial guess of lambda
no improvement | [
"perform",
"a",
"better",
"initial",
"guess",
"of",
"lambda",
"no",
"improvement"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/spins/plot_deg_2orb_fill.py#L46-L54 |
40,103 | Titan-C/slaveparticles | slaveparticles/quantum/spinmatrices.py | spin_z | def spin_z(particles, index):
"""Generates the spin_z projection operator for a system of
N=particles and for the selected spin index name. where index=0..N-1"""
mat = np.zeros((2**particles, 2**particles))
for i in range(2**particles):
ispin = btest(i, index)
if ispin == 1:
... | python | def spin_z(particles, index):
"""Generates the spin_z projection operator for a system of
N=particles and for the selected spin index name. where index=0..N-1"""
mat = np.zeros((2**particles, 2**particles))
for i in range(2**particles):
ispin = btest(i, index)
if ispin == 1:
... | [
"def",
"spin_z",
"(",
"particles",
",",
"index",
")",
":",
"mat",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
"**",
"particles",
",",
"2",
"**",
"particles",
")",
")",
"for",
"i",
"in",
"range",
"(",
"2",
"**",
"particles",
")",
":",
"ispin",
"=",
... | Generates the spin_z projection operator for a system of
N=particles and for the selected spin index name. where index=0..N-1 | [
"Generates",
"the",
"spin_z",
"projection",
"operator",
"for",
"a",
"system",
"of",
"N",
"=",
"particles",
"and",
"for",
"the",
"selected",
"spin",
"index",
"name",
".",
"where",
"index",
"=",
"0",
"..",
"N",
"-",
"1"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/spinmatrices.py#L14-L25 |
40,104 | Titan-C/slaveparticles | slaveparticles/quantum/spinmatrices.py | spin_gen | def spin_gen(particles, index, gauge=1):
"""Generates the generic spin operator in z basis for a system of
N=particles and for the selected spin index name. where index=0..N-1
The gauge term sets the behavoir for a system away from half-filling"""
mat = np.zeros((2**particles, 2**particles))
... | python | def spin_gen(particles, index, gauge=1):
"""Generates the generic spin operator in z basis for a system of
N=particles and for the selected spin index name. where index=0..N-1
The gauge term sets the behavoir for a system away from half-filling"""
mat = np.zeros((2**particles, 2**particles))
... | [
"def",
"spin_gen",
"(",
"particles",
",",
"index",
",",
"gauge",
"=",
"1",
")",
":",
"mat",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
"**",
"particles",
",",
"2",
"**",
"particles",
")",
")",
"flipper",
"=",
"2",
"**",
"index",
"for",
"i",
"in",
... | Generates the generic spin operator in z basis for a system of
N=particles and for the selected spin index name. where index=0..N-1
The gauge term sets the behavoir for a system away from half-filling | [
"Generates",
"the",
"generic",
"spin",
"operator",
"in",
"z",
"basis",
"for",
"a",
"system",
"of",
"N",
"=",
"particles",
"and",
"for",
"the",
"selected",
"spin",
"index",
"name",
".",
"where",
"index",
"=",
"0",
"..",
"N",
"-",
"1",
"The",
"gauge",
... | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/spinmatrices.py#L27-L40 |
40,105 | chrlie/shorten | shorten/redis_store.py | RedisStore.revoke | def revoke(self, token, pipe=None):
"""\
Revokes the key associated with the given revokation token.
If the token does not exist, a :class:`KeyError <KeyError>` is thrown.
Otherwise `None` is returned.
If `pipe` is given, then a :class:`RevokeError <shorten.RevokeError>`
will not... | python | def revoke(self, token, pipe=None):
"""\
Revokes the key associated with the given revokation token.
If the token does not exist, a :class:`KeyError <KeyError>` is thrown.
Otherwise `None` is returned.
If `pipe` is given, then a :class:`RevokeError <shorten.RevokeError>`
will not... | [
"def",
"revoke",
"(",
"self",
",",
"token",
",",
"pipe",
"=",
"None",
")",
":",
"p",
"=",
"self",
".",
"redis",
".",
"pipeline",
"(",
")",
"if",
"pipe",
"is",
"None",
"else",
"pipe",
"formatted_token",
"=",
"self",
".",
"format_token",
"(",
"token",
... | \
Revokes the key associated with the given revokation token.
If the token does not exist, a :class:`KeyError <KeyError>` is thrown.
Otherwise `None` is returned.
If `pipe` is given, then a :class:`RevokeError <shorten.RevokeError>`
will not be thrown if the key does not exist. The n-t... | [
"\\",
"Revokes",
"the",
"key",
"associated",
"with",
"the",
"given",
"revokation",
"token",
"."
] | fb762a199979aefaa28c88fa035e88ea8ce4d639 | https://github.com/chrlie/shorten/blob/fb762a199979aefaa28c88fa035e88ea8ce4d639/shorten/redis_store.py#L163-L213 |
40,106 | klen/muffin-oauth | example/app.py | oauth | async def oauth(request):
"""Oauth example."""
provider = request.match_info.get('provider')
client, _ = await app.ps.oauth.login(provider, request)
user, data = await client.user_info()
response = (
"<a href='/'>back</a><br/><br/>"
"<ul>"
"<li>ID: {u.id}</li>"
"<li>U... | python | async def oauth(request):
"""Oauth example."""
provider = request.match_info.get('provider')
client, _ = await app.ps.oauth.login(provider, request)
user, data = await client.user_info()
response = (
"<a href='/'>back</a><br/><br/>"
"<ul>"
"<li>ID: {u.id}</li>"
"<li>U... | [
"async",
"def",
"oauth",
"(",
"request",
")",
":",
"provider",
"=",
"request",
".",
"match_info",
".",
"get",
"(",
"'provider'",
")",
"client",
",",
"_",
"=",
"await",
"app",
".",
"ps",
".",
"oauth",
".",
"login",
"(",
"provider",
",",
"request",
")"... | Oauth example. | [
"Oauth",
"example",
"."
] | 2d169840e2d08b9ba4a2f0915f99344c5f2c4aa6 | https://github.com/klen/muffin-oauth/blob/2d169840e2d08b9ba4a2f0915f99344c5f2c4aa6/example/app.py#L57-L75 |
40,107 | nuSTORM/gnomon | gnomon/EventAction.py | EventAction.BeginOfEventAction | def BeginOfEventAction(self, event):
"""Save event number"""
self.log.info("Simulating event %s", event.GetEventID())
self.sd.setEventNumber(event.GetEventID()) | python | def BeginOfEventAction(self, event):
"""Save event number"""
self.log.info("Simulating event %s", event.GetEventID())
self.sd.setEventNumber(event.GetEventID()) | [
"def",
"BeginOfEventAction",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Simulating event %s\"",
",",
"event",
".",
"GetEventID",
"(",
")",
")",
"self",
".",
"sd",
".",
"setEventNumber",
"(",
"event",
".",
"GetEventID",
... | Save event number | [
"Save",
"event",
"number"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/EventAction.py#L32-L35 |
40,108 | nuSTORM/gnomon | gnomon/EventAction.py | EventAction.EndOfEventAction | def EndOfEventAction(self, event):
"""At the end of an event, grab sensitive detector hits then run processor loop"""
self.log.debug('Processesing simulated event %d', event.GetEventID())
docs = self.sd.getDocs()
self.sd.clearDocs()
for processor in self.processors:
... | python | def EndOfEventAction(self, event):
"""At the end of an event, grab sensitive detector hits then run processor loop"""
self.log.debug('Processesing simulated event %d', event.GetEventID())
docs = self.sd.getDocs()
self.sd.clearDocs()
for processor in self.processors:
... | [
"def",
"EndOfEventAction",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Processesing simulated event %d'",
",",
"event",
".",
"GetEventID",
"(",
")",
")",
"docs",
"=",
"self",
".",
"sd",
".",
"getDocs",
"(",
")",
"self",
... | At the end of an event, grab sensitive detector hits then run processor loop | [
"At",
"the",
"end",
"of",
"an",
"event",
"grab",
"sensitive",
"detector",
"hits",
"then",
"run",
"processor",
"loop"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/EventAction.py#L43-L54 |
40,109 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_handler | def generate_handler():
"""Create the Blockade user and give them permissions."""
logger.debug("[#] Setting up user, group and permissions")
client = boto3.client("iam", region_name=PRIMARY_REGION)
# Create the user
try:
response = client.create_user(
UserName=BLOCKADE_USER
... | python | def generate_handler():
"""Create the Blockade user and give them permissions."""
logger.debug("[#] Setting up user, group and permissions")
client = boto3.client("iam", region_name=PRIMARY_REGION)
# Create the user
try:
response = client.create_user(
UserName=BLOCKADE_USER
... | [
"def",
"generate_handler",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up user, group and permissions\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"\"iam\"",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"# Create the user",
"try",
":",
"r... | Create the Blockade user and give them permissions. | [
"Create",
"the",
"Blockade",
"user",
"and",
"give",
"them",
"permissions",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L389-L461 |
40,110 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | remove_handler | def remove_handler():
"""Remove the user, group and policies for Blockade."""
logger.debug("[#] Removing user, group and permissions for Blockade")
client = boto3.client("iam", region_name=PRIMARY_REGION)
iam = boto3.resource('iam')
account_id = iam.CurrentUser().arn.split(':')[4]
try:
... | python | def remove_handler():
"""Remove the user, group and policies for Blockade."""
logger.debug("[#] Removing user, group and permissions for Blockade")
client = boto3.client("iam", region_name=PRIMARY_REGION)
iam = boto3.resource('iam')
account_id = iam.CurrentUser().arn.split(':')[4]
try:
... | [
"def",
"remove_handler",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Removing user, group and permissions for Blockade\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"\"iam\"",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"iam",
"=",
"boto3",
".",
... | Remove the user, group and policies for Blockade. | [
"Remove",
"the",
"user",
"group",
"and",
"policies",
"for",
"Blockade",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L464-L527 |
40,111 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_s3_bucket | def generate_s3_bucket():
"""Create the blockade bucket if not already there."""
logger.debug("[#] Setting up S3 bucket")
client = boto3.client("s3", region_name=PRIMARY_REGION)
buckets = client.list_buckets()
matches = [x for x in buckets.get('Buckets', list())
if x['Name'].startswit... | python | def generate_s3_bucket():
"""Create the blockade bucket if not already there."""
logger.debug("[#] Setting up S3 bucket")
client = boto3.client("s3", region_name=PRIMARY_REGION)
buckets = client.list_buckets()
matches = [x for x in buckets.get('Buckets', list())
if x['Name'].startswit... | [
"def",
"generate_s3_bucket",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up S3 bucket\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"\"s3\"",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"buckets",
"=",
"client",
".",
"list_buckets",
"... | Create the blockade bucket if not already there. | [
"Create",
"the",
"blockade",
"bucket",
"if",
"not",
"already",
"there",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L530-L549 |
40,112 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | remove_s3_bucket | def remove_s3_bucket():
"""Remove the Blockade bucket."""
logger.debug("[#] Removing S3 bucket")
client = boto3.client("s3", region_name=PRIMARY_REGION)
buckets = client.list_buckets()
matches = [x for x in buckets.get('Buckets', list())
if x['Name'].startswith(S3_BUCKET_NAME)]
if... | python | def remove_s3_bucket():
"""Remove the Blockade bucket."""
logger.debug("[#] Removing S3 bucket")
client = boto3.client("s3", region_name=PRIMARY_REGION)
buckets = client.list_buckets()
matches = [x for x in buckets.get('Buckets', list())
if x['Name'].startswith(S3_BUCKET_NAME)]
if... | [
"def",
"remove_s3_bucket",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Removing S3 bucket\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"\"s3\"",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"buckets",
"=",
"client",
".",
"list_buckets",
"(",
... | Remove the Blockade bucket. | [
"Remove",
"the",
"Blockade",
"bucket",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L552-L589 |
40,113 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_dynamodb_tables | def generate_dynamodb_tables():
"""Create the Blockade DynamoDB tables."""
logger.debug("[#] Setting up DynamoDB tables")
client = boto3.client('dynamodb', region_name=PRIMARY_REGION)
existing_tables = client.list_tables()['TableNames']
responses = list()
for label in DYNAMODB_TABLES:
i... | python | def generate_dynamodb_tables():
"""Create the Blockade DynamoDB tables."""
logger.debug("[#] Setting up DynamoDB tables")
client = boto3.client('dynamodb', region_name=PRIMARY_REGION)
existing_tables = client.list_tables()['TableNames']
responses = list()
for label in DYNAMODB_TABLES:
i... | [
"def",
"generate_dynamodb_tables",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up DynamoDB tables\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'dynamodb'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"existing_tables",
"=",
"client",
".... | Create the Blockade DynamoDB tables. | [
"Create",
"the",
"Blockade",
"DynamoDB",
"tables",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L592-L617 |
40,114 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | remove_dynamodb_tables | def remove_dynamodb_tables():
"""Remove the Blockade DynamoDB tables."""
logger.debug("[#] Removing DynamoDB tables")
client = boto3.client('dynamodb', region_name=PRIMARY_REGION)
responses = list()
for label in DYNAMODB_TABLES:
logger.debug("[*] Removing %s table" % (label))
try:
... | python | def remove_dynamodb_tables():
"""Remove the Blockade DynamoDB tables."""
logger.debug("[#] Removing DynamoDB tables")
client = boto3.client('dynamodb', region_name=PRIMARY_REGION)
responses = list()
for label in DYNAMODB_TABLES:
logger.debug("[*] Removing %s table" % (label))
try:
... | [
"def",
"remove_dynamodb_tables",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Removing DynamoDB tables\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'dynamodb'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"responses",
"=",
"list",
"(",
")",
... | Remove the Blockade DynamoDB tables. | [
"Remove",
"the",
"Blockade",
"DynamoDB",
"tables",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L620-L639 |
40,115 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_lambda_functions | def generate_lambda_functions():
"""Create the Blockade lambda functions."""
logger.debug("[#] Setting up the Lambda functions")
aws_lambda = boto3.client('lambda', region_name=PRIMARY_REGION)
functions = aws_lambda.list_functions().get('Functions')
existing_funcs = [x['FunctionName'] for x in funct... | python | def generate_lambda_functions():
"""Create the Blockade lambda functions."""
logger.debug("[#] Setting up the Lambda functions")
aws_lambda = boto3.client('lambda', region_name=PRIMARY_REGION)
functions = aws_lambda.list_functions().get('Functions')
existing_funcs = [x['FunctionName'] for x in funct... | [
"def",
"generate_lambda_functions",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up the Lambda functions\"",
")",
"aws_lambda",
"=",
"boto3",
".",
"client",
"(",
"'lambda'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"functions",
"=",
"aws_lambda"... | Create the Blockade lambda functions. | [
"Create",
"the",
"Blockade",
"lambda",
"functions",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L642-L677 |
40,116 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | remove_lambda_functions | def remove_lambda_functions():
"""Remove the Blockade Lambda functions."""
logger.debug("[#] Removing the Lambda functions")
client = boto3.client('lambda', region_name=PRIMARY_REGION)
responses = list()
for label in LAMBDA_FUNCTIONS:
try:
response = client.delete_function(
... | python | def remove_lambda_functions():
"""Remove the Blockade Lambda functions."""
logger.debug("[#] Removing the Lambda functions")
client = boto3.client('lambda', region_name=PRIMARY_REGION)
responses = list()
for label in LAMBDA_FUNCTIONS:
try:
response = client.delete_function(
... | [
"def",
"remove_lambda_functions",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Removing the Lambda functions\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'lambda'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"responses",
"=",
"list",
"(",
")"... | Remove the Blockade Lambda functions. | [
"Remove",
"the",
"Blockade",
"Lambda",
"functions",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L680-L698 |
40,117 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_api_gateway | def generate_api_gateway():
"""Create the Blockade API Gateway REST service."""
logger.debug("[#] Setting up the API Gateway")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
... | python | def generate_api_gateway():
"""Create the Blockade API Gateway REST service."""
logger.debug("[#] Setting up the API Gateway")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
... | [
"def",
"generate_api_gateway",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up the API Gateway\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'apigateway'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"matches",
"=",
"[",
"x",
"for",
"... | Create the Blockade API Gateway REST service. | [
"Create",
"the",
"Blockade",
"API",
"Gateway",
"REST",
"service",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L701-L717 |
40,118 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | generate_admin_resource | def generate_admin_resource():
"""Create the Blockade admin resource for the REST services."""
logger.debug("[#] Setting up the admin resource")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
existing = get_api_gateway_resource("admin")
if existing:
logger.debug("[#] API adm... | python | def generate_admin_resource():
"""Create the Blockade admin resource for the REST services."""
logger.debug("[#] Setting up the admin resource")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
existing = get_api_gateway_resource("admin")
if existing:
logger.debug("[#] API adm... | [
"def",
"generate_admin_resource",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Setting up the admin resource\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'apigateway'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"existing",
"=",
"get_api_gateway_... | Create the Blockade admin resource for the REST services. | [
"Create",
"the",
"Blockade",
"admin",
"resource",
"for",
"the",
"REST",
"services",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L720-L739 |
40,119 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | get_api_gateway_resource | def get_api_gateway_resource(name):
"""Get the resource associated with our gateway."""
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
match = matches.pop()
resources = clie... | python | def get_api_gateway_resource(name):
"""Get the resource associated with our gateway."""
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
match = matches.pop()
resources = clie... | [
"def",
"get_api_gateway_resource",
"(",
"name",
")",
":",
"client",
"=",
"boto3",
".",
"client",
"(",
"'apigateway'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"matches",
"=",
"[",
"x",
"for",
"x",
"in",
"client",
".",
"get_rest_apis",
"(",
")",
".",... | Get the resource associated with our gateway. | [
"Get",
"the",
"resource",
"associated",
"with",
"our",
"gateway",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L742-L754 |
40,120 | blockadeio/analyst_toolbench | blockade/cli/aws_serverless.py | remove_api_gateway | def remove_api_gateway():
"""Remove the Blockade REST API service."""
logger.debug("[#] Removing API Gateway")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
if len(matches)... | python | def remove_api_gateway():
"""Remove the Blockade REST API service."""
logger.debug("[#] Removing API Gateway")
client = boto3.client('apigateway', region_name=PRIMARY_REGION)
matches = [x for x in client.get_rest_apis().get('items', list())
if x['name'] == API_GATEWAY]
if len(matches)... | [
"def",
"remove_api_gateway",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"\"[#] Removing API Gateway\"",
")",
"client",
"=",
"boto3",
".",
"client",
"(",
"'apigateway'",
",",
"region_name",
"=",
"PRIMARY_REGION",
")",
"matches",
"=",
"[",
"x",
"for",
"x",
"i... | Remove the Blockade REST API service. | [
"Remove",
"the",
"Blockade",
"REST",
"API",
"service",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L863-L878 |
40,121 | Julian/Minion | minion/traversal.py | method_delegate | def method_delegate(**methods):
"""
Construct a renderer that delegates based on the request's HTTP method.
"""
methods = {k.upper(): v for k, v in iteritems(methods)}
if PY3:
methods = {k.encode("utf-8"): v for k, v in iteritems(methods)}
def render(request):
renderer = meth... | python | def method_delegate(**methods):
"""
Construct a renderer that delegates based on the request's HTTP method.
"""
methods = {k.upper(): v for k, v in iteritems(methods)}
if PY3:
methods = {k.encode("utf-8"): v for k, v in iteritems(methods)}
def render(request):
renderer = meth... | [
"def",
"method_delegate",
"(",
"*",
"*",
"methods",
")",
":",
"methods",
"=",
"{",
"k",
".",
"upper",
"(",
")",
":",
"v",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"methods",
")",
"}",
"if",
"PY3",
":",
"methods",
"=",
"{",
"k",
".",
"encod... | Construct a renderer that delegates based on the request's HTTP method. | [
"Construct",
"a",
"renderer",
"that",
"delegates",
"based",
"on",
"the",
"request",
"s",
"HTTP",
"method",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/traversal.py#L45-L61 |
40,122 | Julian/Minion | minion/traversal.py | traverse | def traverse(path, request, resource):
"""
Traverse a root resource, retrieving the appropriate child for the request.
"""
path = path.lstrip(b"/")
for component in path and path.split(b"/"):
if getattr(resource, "is_leaf", False):
break
resource = resource.get_child(na... | python | def traverse(path, request, resource):
"""
Traverse a root resource, retrieving the appropriate child for the request.
"""
path = path.lstrip(b"/")
for component in path and path.split(b"/"):
if getattr(resource, "is_leaf", False):
break
resource = resource.get_child(na... | [
"def",
"traverse",
"(",
"path",
",",
"request",
",",
"resource",
")",
":",
"path",
"=",
"path",
".",
"lstrip",
"(",
"b\"/\"",
")",
"for",
"component",
"in",
"path",
"and",
"path",
".",
"split",
"(",
"b\"/\"",
")",
":",
"if",
"getattr",
"(",
"resource... | Traverse a root resource, retrieving the appropriate child for the request. | [
"Traverse",
"a",
"root",
"resource",
"retrieving",
"the",
"appropriate",
"child",
"for",
"the",
"request",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/traversal.py#L64-L75 |
40,123 | inveniosoftware-attic/invenio-utils | invenio_utils/shell.py | escape_shell_arg | def escape_shell_arg(shell_arg):
"""Escape shell argument shell_arg by placing it within
single-quotes. Any single quotes found within the shell argument
string will be escaped.
@param shell_arg: The shell argument to be escaped.
@type shell_arg: string
@return: The single-quote-escaped value ... | python | def escape_shell_arg(shell_arg):
"""Escape shell argument shell_arg by placing it within
single-quotes. Any single quotes found within the shell argument
string will be escaped.
@param shell_arg: The shell argument to be escaped.
@type shell_arg: string
@return: The single-quote-escaped value ... | [
"def",
"escape_shell_arg",
"(",
"shell_arg",
")",
":",
"if",
"isinstance",
"(",
"shell_arg",
",",
"six",
".",
"text_type",
")",
":",
"msg",
"=",
"\"ERROR: escape_shell_arg() expected string argument but \"",
"\"got '%s' of type '%s'.\"",
"%",
"(",
"repr",
"(",
"shell_... | Escape shell argument shell_arg by placing it within
single-quotes. Any single quotes found within the shell argument
string will be escaped.
@param shell_arg: The shell argument to be escaped.
@type shell_arg: string
@return: The single-quote-escaped value of the shell argument.
@rtype: strin... | [
"Escape",
"shell",
"argument",
"shell_arg",
"by",
"placing",
"it",
"within",
"single",
"-",
"quotes",
".",
"Any",
"single",
"quotes",
"found",
"within",
"the",
"shell",
"argument",
"string",
"will",
"be",
"escaped",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/shell.py#L309-L327 |
40,124 | inveniosoftware-attic/invenio-utils | invenio_utils/shell.py | retry_mkstemp | def retry_mkstemp(suffix='', prefix='tmp', directory=None, max_retries=3):
"""
Make mkstemp more robust against AFS glitches.
"""
if directory is None:
directory = current_app.config['CFG_TMPSHAREDDIR']
for retry_count in range(1, max_retries + 1):
try:
tmp_file_fd, tmp_f... | python | def retry_mkstemp(suffix='', prefix='tmp', directory=None, max_retries=3):
"""
Make mkstemp more robust against AFS glitches.
"""
if directory is None:
directory = current_app.config['CFG_TMPSHAREDDIR']
for retry_count in range(1, max_retries + 1):
try:
tmp_file_fd, tmp_f... | [
"def",
"retry_mkstemp",
"(",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"'tmp'",
",",
"directory",
"=",
"None",
",",
"max_retries",
"=",
"3",
")",
":",
"if",
"directory",
"is",
"None",
":",
"directory",
"=",
"current_app",
".",
"config",
"[",
"'CFG_TMPSHAR... | Make mkstemp more robust against AFS glitches. | [
"Make",
"mkstemp",
"more",
"robust",
"against",
"AFS",
"glitches",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/shell.py#L330-L349 |
40,125 | freevoid/django-datafilters | datafilters/declarative.py | declarative_fields | def declarative_fields(cls_filter, meta_base=type, extra_attr_name='base_fields'):
"""
Metaclass that converts Field attributes to a dictionary called
'base_fields', taking into account parent class 'cls_filter'.
"""
def __new__(cls, name, bases, attrs):
attrs[extra_attr_name] = fields = get... | python | def declarative_fields(cls_filter, meta_base=type, extra_attr_name='base_fields'):
"""
Metaclass that converts Field attributes to a dictionary called
'base_fields', taking into account parent class 'cls_filter'.
"""
def __new__(cls, name, bases, attrs):
attrs[extra_attr_name] = fields = get... | [
"def",
"declarative_fields",
"(",
"cls_filter",
",",
"meta_base",
"=",
"type",
",",
"extra_attr_name",
"=",
"'base_fields'",
")",
":",
"def",
"__new__",
"(",
"cls",
",",
"name",
",",
"bases",
",",
"attrs",
")",
":",
"attrs",
"[",
"extra_attr_name",
"]",
"=... | Metaclass that converts Field attributes to a dictionary called
'base_fields', taking into account parent class 'cls_filter'. | [
"Metaclass",
"that",
"converts",
"Field",
"attributes",
"to",
"a",
"dictionary",
"called",
"base_fields",
"taking",
"into",
"account",
"parent",
"class",
"cls_filter",
"."
] | 99051b3b3e97946981c0e9697576b0100093287c | https://github.com/freevoid/django-datafilters/blob/99051b3b3e97946981c0e9697576b0100093287c/datafilters/declarative.py#L40-L52 |
40,126 | CodyKochmann/generators | generators/started.py | started | def started(generator_function):
""" starts a generator when created """
@wraps(generator_function)
def wrapper(*args, **kwargs):
g = generator_function(*args, **kwargs)
next(g)
return g
return wrapper | python | def started(generator_function):
""" starts a generator when created """
@wraps(generator_function)
def wrapper(*args, **kwargs):
g = generator_function(*args, **kwargs)
next(g)
return g
return wrapper | [
"def",
"started",
"(",
"generator_function",
")",
":",
"@",
"wraps",
"(",
"generator_function",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"g",
"=",
"generator_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | starts a generator when created | [
"starts",
"a",
"generator",
"when",
"created"
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/started.py#L11-L18 |
40,127 | trevisanj/a99 | a99/gui/_logpart.py | _LogPart.add_log_error | def add_log_error(self, x, flag_also_show=False, E=None):
"""Sets text of labelError."""
if len(x) == 0:
x = "(empty error)"
tb.print_stack()
x_ = x
if E is not None:
a99.get_python_logger().exception(x_)
else:
a99.get_pyth... | python | def add_log_error(self, x, flag_also_show=False, E=None):
"""Sets text of labelError."""
if len(x) == 0:
x = "(empty error)"
tb.print_stack()
x_ = x
if E is not None:
a99.get_python_logger().exception(x_)
else:
a99.get_pyth... | [
"def",
"add_log_error",
"(",
"self",
",",
"x",
",",
"flag_also_show",
"=",
"False",
",",
"E",
"=",
"None",
")",
":",
"if",
"len",
"(",
"x",
")",
"==",
"0",
":",
"x",
"=",
"\"(empty error)\"",
"tb",
".",
"print_stack",
"(",
")",
"x_",
"=",
"x",
"i... | Sets text of labelError. | [
"Sets",
"text",
"of",
"labelError",
"."
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/_logpart.py#L24-L38 |
40,128 | ThomasChiroux/attowiki | src/attowiki/views.py | check_user | def check_user(user, password):
"""check the auth for user and password."""
return ((user == attowiki.user or attowiki.user is None) and
(password == attowiki.password or attowiki.password is None)) | python | def check_user(user, password):
"""check the auth for user and password."""
return ((user == attowiki.user or attowiki.user is None) and
(password == attowiki.password or attowiki.password is None)) | [
"def",
"check_user",
"(",
"user",
",",
"password",
")",
":",
"return",
"(",
"(",
"user",
"==",
"attowiki",
".",
"user",
"or",
"attowiki",
".",
"user",
"is",
"None",
")",
"and",
"(",
"password",
"==",
"attowiki",
".",
"password",
"or",
"attowiki",
".",
... | check the auth for user and password. | [
"check",
"the",
"auth",
"for",
"user",
"and",
"password",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L55-L58 |
40,129 | ThomasChiroux/attowiki | src/attowiki/views.py | view_meta_index | def view_meta_index():
"""List all the available .rst files in the directory.
view_meta_index is called by the 'meta' url : /__index__
"""
rst_files = [filename[2:-4] for filename in sorted(glob.glob("./*.rst"))]
rst_files.reverse()
return template('index',
type="view",
... | python | def view_meta_index():
"""List all the available .rst files in the directory.
view_meta_index is called by the 'meta' url : /__index__
"""
rst_files = [filename[2:-4] for filename in sorted(glob.glob("./*.rst"))]
rst_files.reverse()
return template('index',
type="view",
... | [
"def",
"view_meta_index",
"(",
")",
":",
"rst_files",
"=",
"[",
"filename",
"[",
"2",
":",
"-",
"4",
"]",
"for",
"filename",
"in",
"sorted",
"(",
"glob",
".",
"glob",
"(",
"\"./*.rst\"",
")",
")",
"]",
"rst_files",
".",
"reverse",
"(",
")",
"return",... | List all the available .rst files in the directory.
view_meta_index is called by the 'meta' url : /__index__ | [
"List",
"all",
"the",
"available",
".",
"rst",
"files",
"in",
"the",
"directory",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L68-L82 |
40,130 | ThomasChiroux/attowiki | src/attowiki/views.py | view_cancel_edit | def view_cancel_edit(name=None):
"""Cancel the edition of an existing page.
Then render the last modification status
.. note:: this is a bottle view
if no page name is given, do nothing (it may leave some .tmp. files in
the directory).
Keyword Arguments:
:name: (str) -- name of the p... | python | def view_cancel_edit(name=None):
"""Cancel the edition of an existing page.
Then render the last modification status
.. note:: this is a bottle view
if no page name is given, do nothing (it may leave some .tmp. files in
the directory).
Keyword Arguments:
:name: (str) -- name of the p... | [
"def",
"view_cancel_edit",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"redirect",
"(",
"'/'",
")",
"else",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"\"{0}.rst\"",
".",
"format",
"(",
"name",
")",
")",
"if",
"... | Cancel the edition of an existing page.
Then render the last modification status
.. note:: this is a bottle view
if no page name is given, do nothing (it may leave some .tmp. files in
the directory).
Keyword Arguments:
:name: (str) -- name of the page (OPTIONAL)
Returns:
bot... | [
"Cancel",
"the",
"edition",
"of",
"an",
"existing",
"page",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L211-L235 |
40,131 | ThomasChiroux/attowiki | src/attowiki/views.py | view_edit | def view_edit(name=None):
"""Edit or creates a new page.
.. note:: this is a bottle view
if no page name is given, creates a new page.
Keyword Arguments:
:name: (str) -- name of the page (OPTIONAL)
Returns:
bottle response object
"""
response.set_header('Cache-control', '... | python | def view_edit(name=None):
"""Edit or creates a new page.
.. note:: this is a bottle view
if no page name is given, creates a new page.
Keyword Arguments:
:name: (str) -- name of the page (OPTIONAL)
Returns:
bottle response object
"""
response.set_header('Cache-control', '... | [
"def",
"view_edit",
"(",
"name",
"=",
"None",
")",
":",
"response",
".",
"set_header",
"(",
"'Cache-control'",
",",
"'no-cache'",
")",
"response",
".",
"set_header",
"(",
"'Pragma'",
",",
"'no-cache'",
")",
"if",
"name",
"is",
"None",
":",
"# new page",
"r... | Edit or creates a new page.
.. note:: this is a bottle view
if no page name is given, creates a new page.
Keyword Arguments:
:name: (str) -- name of the page (OPTIONAL)
Returns:
bottle response object | [
"Edit",
"or",
"creates",
"a",
"new",
"page",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L239-L279 |
40,132 | ThomasChiroux/attowiki | src/attowiki/views.py | view_pdf | def view_pdf(name=None):
"""Render a pdf file based on the given page.
.. note:: this is a bottle view
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst extension)
MANDATORY
"""
if name is None:
return view_meta_index()
files = ... | python | def view_pdf(name=None):
"""Render a pdf file based on the given page.
.. note:: this is a bottle view
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst extension)
MANDATORY
"""
if name is None:
return view_meta_index()
files = ... | [
"def",
"view_pdf",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"view_meta_index",
"(",
")",
"files",
"=",
"glob",
".",
"glob",
"(",
"\"{0}.rst\"",
".",
"format",
"(",
"name",
")",
")",
"if",
"len",
"(",
"files",
"... | Render a pdf file based on the given page.
.. note:: this is a bottle view
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst extension)
MANDATORY | [
"Render",
"a",
"pdf",
"file",
"based",
"on",
"the",
"given",
"page",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L283-L310 |
40,133 | ThomasChiroux/attowiki | src/attowiki/views.py | view_page | def view_page(name=None):
"""Serve a page name.
.. note:: this is a bottle view
* if the view is called with the POST method, write the new page
content to the file, commit the modification and then display the
html rendering of the restructured text file
* if the view is called with the ... | python | def view_page(name=None):
"""Serve a page name.
.. note:: this is a bottle view
* if the view is called with the POST method, write the new page
content to the file, commit the modification and then display the
html rendering of the restructured text file
* if the view is called with the ... | [
"def",
"view_page",
"(",
"name",
"=",
"None",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"if",
"name",
"is",
"None",
":",
"# new file",
"if",
"len",
"(",
"request",
".",
"forms",
".",
"filename",
")",
">",
"0",
":",
"name",
"=",... | Serve a page name.
.. note:: this is a bottle view
* if the view is called with the POST method, write the new page
content to the file, commit the modification and then display the
html rendering of the restructured text file
* if the view is called with the GET method, directly display the ... | [
"Serve",
"a",
"page",
"name",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L314-L378 |
40,134 | ThomasChiroux/attowiki | src/attowiki/views.py | view_quick_save_page | def view_quick_save_page(name=None):
"""Quick save a page.
.. note:: this is a bottle view
* this view must be called with the PUT method
write the new page content to the file, and not not commit or redirect
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst ext... | python | def view_quick_save_page(name=None):
"""Quick save a page.
.. note:: this is a bottle view
* this view must be called with the PUT method
write the new page content to the file, and not not commit or redirect
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst ext... | [
"def",
"view_quick_save_page",
"(",
"name",
"=",
"None",
")",
":",
"response",
".",
"set_header",
"(",
"'Cache-control'",
",",
"'no-cache'",
")",
"response",
".",
"set_header",
"(",
"'Pragma'",
",",
"'no-cache'",
")",
"if",
"request",
".",
"method",
"==",
"'... | Quick save a page.
.. note:: this is a bottle view
* this view must be called with the PUT method
write the new page content to the file, and not not commit or redirect
Keyword Arguments:
:name: (str) -- name of the rest file (without the .rst extension)
Returns:
bottle respons... | [
"Quick",
"save",
"a",
"page",
"."
] | 6c93c420305490d324fdc95a7b40b2283a222183 | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L508-L539 |
40,135 | trevisanj/f311 | f311/hapi.py | getHelp | def getHelp(arg=None):
"""
This function provides interactive manuals and tutorials.
"""
if arg==None:
print('--------------------------------------------------------------')
print('Hello, this is an interactive help system of HITRANonline API.')
print('--------------------------... | python | def getHelp(arg=None):
"""
This function provides interactive manuals and tutorials.
"""
if arg==None:
print('--------------------------------------------------------------')
print('Hello, this is an interactive help system of HITRANonline API.')
print('--------------------------... | [
"def",
"getHelp",
"(",
"arg",
"=",
"None",
")",
":",
"if",
"arg",
"==",
"None",
":",
"print",
"(",
"'--------------------------------------------------------------'",
")",
"print",
"(",
"'Hello, this is an interactive help system of HITRANonline API.'",
")",
"print",
"(",... | This function provides interactive manuals and tutorials. | [
"This",
"function",
"provides",
"interactive",
"manuals",
"and",
"tutorials",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/hapi.py#L4956-L5049 |
40,136 | trevisanj/f311 | f311/hapi.py | convolveSpectrumSame | def convolveSpectrumSame(Omega,CrossSection,Resolution=0.1,AF_wing=10.,
SlitFunction=SLIT_RECTANGULAR):
"""
Convolves cross section with a slit function with given parameters.
"""
step = Omega[1]-Omega[0]
x = arange(-AF_wing,AF_wing+step,step)
slit = SlitFunction(x,Resol... | python | def convolveSpectrumSame(Omega,CrossSection,Resolution=0.1,AF_wing=10.,
SlitFunction=SLIT_RECTANGULAR):
"""
Convolves cross section with a slit function with given parameters.
"""
step = Omega[1]-Omega[0]
x = arange(-AF_wing,AF_wing+step,step)
slit = SlitFunction(x,Resol... | [
"def",
"convolveSpectrumSame",
"(",
"Omega",
",",
"CrossSection",
",",
"Resolution",
"=",
"0.1",
",",
"AF_wing",
"=",
"10.",
",",
"SlitFunction",
"=",
"SLIT_RECTANGULAR",
")",
":",
"step",
"=",
"Omega",
"[",
"1",
"]",
"-",
"Omega",
"[",
"0",
"]",
"x",
... | Convolves cross section with a slit function with given parameters. | [
"Convolves",
"cross",
"section",
"with",
"a",
"slit",
"function",
"with",
"given",
"parameters",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/hapi.py#L11918-L11933 |
40,137 | nuSTORM/gnomon | gnomon/processors/DataManager.py | CouchManager.setup_db | def setup_db(self, couch, dbname):
"""Setup and configure DB
"""
# Avoid race condition of two creating db
my_db = None
self.log.debug('Setting up DB: %s' % dbname)
if dbname not in couch:
self.log.info("DB doesn't exist so creating DB: %s", dbname)
... | python | def setup_db(self, couch, dbname):
"""Setup and configure DB
"""
# Avoid race condition of two creating db
my_db = None
self.log.debug('Setting up DB: %s' % dbname)
if dbname not in couch:
self.log.info("DB doesn't exist so creating DB: %s", dbname)
... | [
"def",
"setup_db",
"(",
"self",
",",
"couch",
",",
"dbname",
")",
":",
"# Avoid race condition of two creating db",
"my_db",
"=",
"None",
"self",
".",
"log",
".",
"debug",
"(",
"'Setting up DB: %s'",
"%",
"dbname",
")",
"if",
"dbname",
"not",
"in",
"couch",
... | Setup and configure DB | [
"Setup",
"and",
"configure",
"DB"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/DataManager.py#L62-L101 |
40,138 | nuSTORM/gnomon | gnomon/processors/DataManager.py | CouchManager.commit | def commit(self, force=False):
"""Commit data to couchdb
Compared to threshold (unless forced) then sends data to couch
"""
self.log.debug('Bulk commit requested')
size = sys.getsizeof(self.docs)
self.log.debug('Size of docs in KB: %d', size)
if size > self.comm... | python | def commit(self, force=False):
"""Commit data to couchdb
Compared to threshold (unless forced) then sends data to couch
"""
self.log.debug('Bulk commit requested')
size = sys.getsizeof(self.docs)
self.log.debug('Size of docs in KB: %d', size)
if size > self.comm... | [
"def",
"commit",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Bulk commit requested'",
")",
"size",
"=",
"sys",
".",
"getsizeof",
"(",
"self",
".",
"docs",
")",
"self",
".",
"log",
".",
"debug",
"(",
"... | Commit data to couchdb
Compared to threshold (unless forced) then sends data to couch | [
"Commit",
"data",
"to",
"couchdb"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/DataManager.py#L103-L115 |
40,139 | nuSTORM/gnomon | gnomon/processors/DataManager.py | CouchManager.save | def save(self, doc):
"""Save a doc to cache
"""
self.log.debug('save()')
self.docs.append(doc)
self.commit() | python | def save(self, doc):
"""Save a doc to cache
"""
self.log.debug('save()')
self.docs.append(doc)
self.commit() | [
"def",
"save",
"(",
"self",
",",
"doc",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'save()'",
")",
"self",
".",
"docs",
".",
"append",
"(",
"doc",
")",
"self",
".",
"commit",
"(",
")"
] | Save a doc to cache | [
"Save",
"a",
"doc",
"to",
"cache"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/DataManager.py#L117-L122 |
40,140 | mixer/beam-interactive-python | beam_interactive/helpers.py | start | def start(address, channel, key, loop=None):
"""Starts a new Interactive client.
Takes the remote address of the Tetris robot, as well as the
channel number and auth key to use. Additionally, it takes
a list of handler. This should be a dict of protobuf wire
IDs to handler functions (from the .prot... | python | def start(address, channel, key, loop=None):
"""Starts a new Interactive client.
Takes the remote address of the Tetris robot, as well as the
channel number and auth key to use. Additionally, it takes
a list of handler. This should be a dict of protobuf wire
IDs to handler functions (from the .prot... | [
"def",
"start",
"(",
"address",
",",
"channel",
",",
"key",
",",
"loop",
"=",
"None",
")",
":",
"if",
"loop",
"is",
"None",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"socket",
"=",
"yield",
"from",
"websockets",
".",
"connect",
"(... | Starts a new Interactive client.
Takes the remote address of the Tetris robot, as well as the
channel number and auth key to use. Additionally, it takes
a list of handler. This should be a dict of protobuf wire
IDs to handler functions (from the .proto package). | [
"Starts",
"a",
"new",
"Interactive",
"client",
"."
] | e035bc45515dea9315b77648a24b5ae8685aa5cf | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/helpers.py#L8-L25 |
40,141 | mixer/beam-interactive-python | beam_interactive/helpers.py | _create_handshake | def _create_handshake(channel, key):
"""
Creates and returns a Handshake packet that authenticates
on the channel with the given stream key.
"""
hsk = Handshake()
hsk.channel = channel
hsk.streamKey = key
return hsk | python | def _create_handshake(channel, key):
"""
Creates and returns a Handshake packet that authenticates
on the channel with the given stream key.
"""
hsk = Handshake()
hsk.channel = channel
hsk.streamKey = key
return hsk | [
"def",
"_create_handshake",
"(",
"channel",
",",
"key",
")",
":",
"hsk",
"=",
"Handshake",
"(",
")",
"hsk",
".",
"channel",
"=",
"channel",
"hsk",
".",
"streamKey",
"=",
"key",
"return",
"hsk"
] | Creates and returns a Handshake packet that authenticates
on the channel with the given stream key. | [
"Creates",
"and",
"returns",
"a",
"Handshake",
"packet",
"that",
"authenticates",
"on",
"the",
"channel",
"with",
"the",
"given",
"stream",
"key",
"."
] | e035bc45515dea9315b77648a24b5ae8685aa5cf | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/helpers.py#L28-L36 |
40,142 | bogdanvuk/pygears-tools | pygears_tools/utils.py | shell_source | def shell_source(script):
"""Sometime you want to emulate the action of "source" in bash,
settings some environment variables. Here is a way to do it."""
pipe = subprocess.Popen(
". %s; env" % script, stdout=subprocess.PIPE, shell=True)
output = pipe.communicate()[0].decode()
env = {}
fo... | python | def shell_source(script):
"""Sometime you want to emulate the action of "source" in bash,
settings some environment variables. Here is a way to do it."""
pipe = subprocess.Popen(
". %s; env" % script, stdout=subprocess.PIPE, shell=True)
output = pipe.communicate()[0].decode()
env = {}
fo... | [
"def",
"shell_source",
"(",
"script",
")",
":",
"pipe",
"=",
"subprocess",
".",
"Popen",
"(",
"\". %s; env\"",
"%",
"script",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"shell",
"=",
"True",
")",
"output",
"=",
"pipe",
".",
"communicate",
"(",
... | Sometime you want to emulate the action of "source" in bash,
settings some environment variables. Here is a way to do it. | [
"Sometime",
"you",
"want",
"to",
"emulate",
"the",
"action",
"of",
"source",
"in",
"bash",
"settings",
"some",
"environment",
"variables",
".",
"Here",
"is",
"a",
"way",
"to",
"do",
"it",
"."
] | 47e3287add1cbc5d2efc9e35aa55fce69e440dc9 | https://github.com/bogdanvuk/pygears-tools/blob/47e3287add1cbc5d2efc9e35aa55fce69e440dc9/pygears_tools/utils.py#L170-L184 |
40,143 | jkitzes/macroeco | macroeco/compare/_compare.py | nll | def nll(data, model):
"""
Negative log likelihood given data and a model
Parameters
----------
{0}
{1}
Returns
-------
float
Negative log likelihood
Examples
---------
>>> import macroeco.models as md
>>> import macroeco.compare as comp
>>> # Generate... | python | def nll(data, model):
"""
Negative log likelihood given data and a model
Parameters
----------
{0}
{1}
Returns
-------
float
Negative log likelihood
Examples
---------
>>> import macroeco.models as md
>>> import macroeco.compare as comp
>>> # Generate... | [
"def",
"nll",
"(",
"data",
",",
"model",
")",
":",
"try",
":",
"log_lik_vals",
"=",
"model",
".",
"logpmf",
"(",
"data",
")",
"except",
":",
"log_lik_vals",
"=",
"model",
".",
"logpdf",
"(",
"data",
")",
"return",
"-",
"np",
".",
"sum",
"(",
"log_l... | Negative log likelihood given data and a model
Parameters
----------
{0}
{1}
Returns
-------
float
Negative log likelihood
Examples
---------
>>> import macroeco.models as md
>>> import macroeco.compare as comp
>>> # Generate random data
>>> rand_samp = m... | [
"Negative",
"log",
"likelihood",
"given",
"data",
"and",
"a",
"model"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L27-L65 |
40,144 | jkitzes/macroeco | macroeco/compare/_compare.py | lrt | def lrt(data, model_full, model_reduced, df=None):
"""
Compare two nested models using a likelihood ratio test
Parameters
----------
{0}
model_full : obj
A frozen scipy distribution object representing the full model
(more complex model).
model_reduced : scipy distribution o... | python | def lrt(data, model_full, model_reduced, df=None):
"""
Compare two nested models using a likelihood ratio test
Parameters
----------
{0}
model_full : obj
A frozen scipy distribution object representing the full model
(more complex model).
model_reduced : scipy distribution o... | [
"def",
"lrt",
"(",
"data",
",",
"model_full",
",",
"model_reduced",
",",
"df",
"=",
"None",
")",
":",
"# Calculate G^2 statistic",
"ll_full",
"=",
"nll",
"(",
"data",
",",
"model_full",
")",
"*",
"-",
"1",
"ll_reduced",
"=",
"nll",
"(",
"data",
",",
"m... | Compare two nested models using a likelihood ratio test
Parameters
----------
{0}
model_full : obj
A frozen scipy distribution object representing the full model
(more complex model).
model_reduced : scipy distribution object
A frozen scipy distribution object representing t... | [
"Compare",
"two",
"nested",
"models",
"using",
"a",
"likelihood",
"ratio",
"test"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L69-L139 |
40,145 | jkitzes/macroeco | macroeco/compare/_compare.py | AIC | def AIC(data, model, params=None, corrected=True):
"""
Akaike Information Criteria given data and a model
Parameters
----------
{0}
{1}
params : int
Number of parameters in the model. If None, calculated from model
object.
corrected : bool
If True, calculates the... | python | def AIC(data, model, params=None, corrected=True):
"""
Akaike Information Criteria given data and a model
Parameters
----------
{0}
{1}
params : int
Number of parameters in the model. If None, calculated from model
object.
corrected : bool
If True, calculates the... | [
"def",
"AIC",
"(",
"data",
",",
"model",
",",
"params",
"=",
"None",
",",
"corrected",
"=",
"True",
")",
":",
"n",
"=",
"len",
"(",
"data",
")",
"# Number of observations",
"L",
"=",
"nll",
"(",
"data",
",",
"model",
")",
"if",
"not",
"params",
":"... | Akaike Information Criteria given data and a model
Parameters
----------
{0}
{1}
params : int
Number of parameters in the model. If None, calculated from model
object.
corrected : bool
If True, calculates the small-sample size correct AICC. Default True.
Returns
... | [
"Akaike",
"Information",
"Criteria",
"given",
"data",
"and",
"a",
"model"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L143-L221 |
40,146 | jkitzes/macroeco | macroeco/compare/_compare.py | AIC_compare | def AIC_compare(aic_list):
"""
Calculates delta AIC and AIC weights from a list of AIC values
Parameters
-----------------
aic_list : iterable
AIC values from set of candidat models
Returns
-------------
tuple
First element contains the delta AIC values, second element ... | python | def AIC_compare(aic_list):
"""
Calculates delta AIC and AIC weights from a list of AIC values
Parameters
-----------------
aic_list : iterable
AIC values from set of candidat models
Returns
-------------
tuple
First element contains the delta AIC values, second element ... | [
"def",
"AIC_compare",
"(",
"aic_list",
")",
":",
"aic_values",
"=",
"np",
".",
"array",
"(",
"aic_list",
")",
"minimum",
"=",
"np",
".",
"min",
"(",
"aic_values",
")",
"delta",
"=",
"aic_values",
"-",
"minimum",
"values",
"=",
"np",
".",
"exp",
"(",
... | Calculates delta AIC and AIC weights from a list of AIC values
Parameters
-----------------
aic_list : iterable
AIC values from set of candidat models
Returns
-------------
tuple
First element contains the delta AIC values, second element contains
the relative AIC weigh... | [
"Calculates",
"delta",
"AIC",
"and",
"AIC",
"weights",
"from",
"a",
"list",
"of",
"AIC",
"values"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L224-L278 |
40,147 | jkitzes/macroeco | macroeco/compare/_compare.py | sum_of_squares | def sum_of_squares(obs, pred):
"""
Sum of squares between observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
Returns
-------
float
Sum of squares
Notes
-----
The length of observed and p... | python | def sum_of_squares(obs, pred):
"""
Sum of squares between observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
Returns
-------
float
Sum of squares
Notes
-----
The length of observed and p... | [
"def",
"sum_of_squares",
"(",
"obs",
",",
"pred",
")",
":",
"return",
"np",
".",
"sum",
"(",
"(",
"np",
".",
"array",
"(",
"obs",
")",
"-",
"np",
".",
"array",
"(",
"pred",
")",
")",
"**",
"2",
")"
] | Sum of squares between observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
Returns
-------
float
Sum of squares
Notes
-----
The length of observed and predicted data must match. | [
"Sum",
"of",
"squares",
"between",
"observed",
"and",
"predicted",
"data"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L281-L303 |
40,148 | jkitzes/macroeco | macroeco/compare/_compare.py | r_squared | def r_squared(obs, pred, one_to_one=False, log_trans=False):
"""
R^2 value for a regression of observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
one_to_one : bool
If True, calculates the R^2 based on the one... | python | def r_squared(obs, pred, one_to_one=False, log_trans=False):
"""
R^2 value for a regression of observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
one_to_one : bool
If True, calculates the R^2 based on the one... | [
"def",
"r_squared",
"(",
"obs",
",",
"pred",
",",
"one_to_one",
"=",
"False",
",",
"log_trans",
"=",
"False",
")",
":",
"if",
"log_trans",
":",
"obs",
"=",
"np",
".",
"log",
"(",
"obs",
")",
"pred",
"=",
"np",
".",
"log",
"(",
"pred",
")",
"if",
... | R^2 value for a regression of observed and predicted data
Parameters
----------
obs : iterable
Observed data
pred : iterable
Predicted data
one_to_one : bool
If True, calculates the R^2 based on the one-to-one line (see [#]_),
and if False, calculates the standard R^... | [
"R^2",
"value",
"for",
"a",
"regression",
"of",
"observed",
"and",
"predicted",
"data"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L306-L384 |
40,149 | jkitzes/macroeco | macroeco/compare/_compare.py | preston_bin | def preston_bin(data, max_num):
"""
Bins data on base 2 using Preston's method
Parameters
----------
data : array-like
Data to be binned
max_num : float
The maximum upper value of the data
Returns
-------
tuple
(binned_data, bin_edges)
Notes
-----
... | python | def preston_bin(data, max_num):
"""
Bins data on base 2 using Preston's method
Parameters
----------
data : array-like
Data to be binned
max_num : float
The maximum upper value of the data
Returns
-------
tuple
(binned_data, bin_edges)
Notes
-----
... | [
"def",
"preston_bin",
"(",
"data",
",",
"max_num",
")",
":",
"log_ub",
"=",
"np",
".",
"ceil",
"(",
"np",
".",
"log2",
"(",
"max_num",
")",
")",
"# Make an exclusive lower bound in keeping with Preston",
"if",
"log_ub",
"==",
"0",
":",
"boundaries",
"=",
"np... | Bins data on base 2 using Preston's method
Parameters
----------
data : array-like
Data to be binned
max_num : float
The maximum upper value of the data
Returns
-------
tuple
(binned_data, bin_edges)
Notes
-----
Uses Preston's method of binning, which ... | [
"Bins",
"data",
"on",
"base",
"2",
"using",
"Preston",
"s",
"method"
] | ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/compare/_compare.py#L386-L440 |
40,150 | consbio/parserutils | parserutils/urls.py | url_to_parts | def url_to_parts(url):
""" Split url urlsplit style, but return path as a list and query as a dict """
if not url:
return None
scheme, netloc, path, query, fragment = _urlsplit(url)
if not path or path == '/':
path = []
else:
path = path.strip('/').split('/')
if not q... | python | def url_to_parts(url):
""" Split url urlsplit style, but return path as a list and query as a dict """
if not url:
return None
scheme, netloc, path, query, fragment = _urlsplit(url)
if not path or path == '/':
path = []
else:
path = path.strip('/').split('/')
if not q... | [
"def",
"url_to_parts",
"(",
"url",
")",
":",
"if",
"not",
"url",
":",
"return",
"None",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"_urlsplit",
"(",
"url",
")",
"if",
"not",
"path",
"or",
"path",
"==",
"'/'",
":",
"pa... | Split url urlsplit style, but return path as a list and query as a dict | [
"Split",
"url",
"urlsplit",
"style",
"but",
"return",
"path",
"as",
"a",
"list",
"and",
"query",
"as",
"a",
"dict"
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/urls.py#L59-L77 |
40,151 | flashashen/flange | flange/cfg.py | Cfg.__visit_index_model_instance | def __visit_index_model_instance(self, models, p, k, v):
"""
Called during model research on merged data
"""
# print 'model visit {} on {}'.format(model, v)
cp = p + (k,)
for model in models:
try:
if model.validator(v):
... | python | def __visit_index_model_instance(self, models, p, k, v):
"""
Called during model research on merged data
"""
# print 'model visit {} on {}'.format(model, v)
cp = p + (k,)
for model in models:
try:
if model.validator(v):
... | [
"def",
"__visit_index_model_instance",
"(",
"self",
",",
"models",
",",
"p",
",",
"k",
",",
"v",
")",
":",
"# print 'model visit {} on {}'.format(model, v)",
"cp",
"=",
"p",
"+",
"(",
"k",
",",
")",
"for",
"model",
"in",
"models",
":",
"try",
":",
"if",
... | Called during model research on merged data | [
"Called",
"during",
"model",
"research",
"on",
"merged",
"data"
] | 67ebaf70e39887f65ce1163168d182a8e4c2774a | https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/cfg.py#L530-L547 |
40,152 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.compute_edge_reduction | def compute_edge_reduction(self) -> float:
"""Compute the edge reduction. Costly computation"""
nb_init_edge = self.init_edge_number()
nb_poweredge = self.edge_number()
return (nb_init_edge - nb_poweredge) / (nb_init_edge) | python | def compute_edge_reduction(self) -> float:
"""Compute the edge reduction. Costly computation"""
nb_init_edge = self.init_edge_number()
nb_poweredge = self.edge_number()
return (nb_init_edge - nb_poweredge) / (nb_init_edge) | [
"def",
"compute_edge_reduction",
"(",
"self",
")",
"->",
"float",
":",
"nb_init_edge",
"=",
"self",
".",
"init_edge_number",
"(",
")",
"nb_poweredge",
"=",
"self",
".",
"edge_number",
"(",
")",
"return",
"(",
"nb_init_edge",
"-",
"nb_poweredge",
")",
"/",
"(... | Compute the edge reduction. Costly computation | [
"Compute",
"the",
"edge",
"reduction",
".",
"Costly",
"computation"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L30-L34 |
40,153 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.init_edge_number | def init_edge_number(self) -> int:
"""Return the number of edges present in the non-compressed graph"""
return len(frozenset(frozenset(edge) for edge in self.initial_edges())) | python | def init_edge_number(self) -> int:
"""Return the number of edges present in the non-compressed graph"""
return len(frozenset(frozenset(edge) for edge in self.initial_edges())) | [
"def",
"init_edge_number",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"frozenset",
"(",
"frozenset",
"(",
"edge",
")",
"for",
"edge",
"in",
"self",
".",
"initial_edges",
"(",
")",
")",
")"
] | Return the number of edges present in the non-compressed graph | [
"Return",
"the",
"number",
"of",
"edges",
"present",
"in",
"the",
"non",
"-",
"compressed",
"graph"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L36-L38 |
40,154 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.assert_powernode | def assert_powernode(self, name:str) -> None or ValueError:
"""Do nothing if given name refers to a powernode in given graph.
Raise a ValueError in any other case.
"""
if name not in self.inclusions:
raise ValueError("Powernode '{}' does not exists.".format(name))
if... | python | def assert_powernode(self, name:str) -> None or ValueError:
"""Do nothing if given name refers to a powernode in given graph.
Raise a ValueError in any other case.
"""
if name not in self.inclusions:
raise ValueError("Powernode '{}' does not exists.".format(name))
if... | [
"def",
"assert_powernode",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
"or",
"ValueError",
":",
"if",
"name",
"not",
"in",
"self",
".",
"inclusions",
":",
"raise",
"ValueError",
"(",
"\"Powernode '{}' does not exists.\"",
".",
"format",
"(",
"na... | Do nothing if given name refers to a powernode in given graph.
Raise a ValueError in any other case. | [
"Do",
"nothing",
"if",
"given",
"name",
"refers",
"to",
"a",
"powernode",
"in",
"given",
"graph",
".",
"Raise",
"a",
"ValueError",
"in",
"any",
"other",
"case",
"."
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L99-L107 |
40,155 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.powernode_data | def powernode_data(self, name:str) -> Powernode:
"""Return a Powernode object describing the given powernode"""
self.assert_powernode(name)
contained_nodes = frozenset(self.nodes_in(name))
return Powernode(
size=len(contained_nodes),
contained=frozenset(self.all_i... | python | def powernode_data(self, name:str) -> Powernode:
"""Return a Powernode object describing the given powernode"""
self.assert_powernode(name)
contained_nodes = frozenset(self.nodes_in(name))
return Powernode(
size=len(contained_nodes),
contained=frozenset(self.all_i... | [
"def",
"powernode_data",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"Powernode",
":",
"self",
".",
"assert_powernode",
"(",
"name",
")",
"contained_nodes",
"=",
"frozenset",
"(",
"self",
".",
"nodes_in",
"(",
"name",
")",
")",
"return",
"Powernode",
... | Return a Powernode object describing the given powernode | [
"Return",
"a",
"Powernode",
"object",
"describing",
"the",
"given",
"powernode"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L110-L119 |
40,156 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.node_number | def node_number(self, *, count_pnode=True) -> int:
"""Return the number of node"""
return (sum(1 for n in self.nodes())
+ (sum(1 for n in self.powernodes()) if count_pnode else 0)) | python | def node_number(self, *, count_pnode=True) -> int:
"""Return the number of node"""
return (sum(1 for n in self.nodes())
+ (sum(1 for n in self.powernodes()) if count_pnode else 0)) | [
"def",
"node_number",
"(",
"self",
",",
"*",
",",
"count_pnode",
"=",
"True",
")",
"->",
"int",
":",
"return",
"(",
"sum",
"(",
"1",
"for",
"n",
"in",
"self",
".",
"nodes",
"(",
")",
")",
"+",
"(",
"sum",
"(",
"1",
"for",
"n",
"in",
"self",
"... | Return the number of node | [
"Return",
"the",
"number",
"of",
"node"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L122-L125 |
40,157 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.write_bubble | def write_bubble(self, filename:str):
"""Write in given filename the lines of bubble describing this instance"""
from bubbletools import converter
converter.tree_to_bubble(self, filename) | python | def write_bubble(self, filename:str):
"""Write in given filename the lines of bubble describing this instance"""
from bubbletools import converter
converter.tree_to_bubble(self, filename) | [
"def",
"write_bubble",
"(",
"self",
",",
"filename",
":",
"str",
")",
":",
"from",
"bubbletools",
"import",
"converter",
"converter",
".",
"tree_to_bubble",
"(",
"self",
",",
"filename",
")"
] | Write in given filename the lines of bubble describing this instance | [
"Write",
"in",
"given",
"filename",
"the",
"lines",
"of",
"bubble",
"describing",
"this",
"instance"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L193-L196 |
40,158 | Aluriak/bubble-tools | bubbletools/bbltree.py | BubbleTree.from_bubble_file | def from_bubble_file(bblfile:str, oriented:bool=False,
symmetric_edges:bool=True) -> 'BubbleTree':
"""Extract data from given bubble file,
then call from_bubble_data method
"""
return BubbleTree.from_bubble_data(utils.data_from_bubble(bblfile),
... | python | def from_bubble_file(bblfile:str, oriented:bool=False,
symmetric_edges:bool=True) -> 'BubbleTree':
"""Extract data from given bubble file,
then call from_bubble_data method
"""
return BubbleTree.from_bubble_data(utils.data_from_bubble(bblfile),
... | [
"def",
"from_bubble_file",
"(",
"bblfile",
":",
"str",
",",
"oriented",
":",
"bool",
"=",
"False",
",",
"symmetric_edges",
":",
"bool",
"=",
"True",
")",
"->",
"'BubbleTree'",
":",
"return",
"BubbleTree",
".",
"from_bubble_data",
"(",
"utils",
".",
"data_fro... | Extract data from given bubble file,
then call from_bubble_data method | [
"Extract",
"data",
"from",
"given",
"bubble",
"file",
"then",
"call",
"from_bubble_data",
"method"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/bbltree.py#L200-L207 |
40,159 | Aluriak/bubble-tools | bubbletools/comparers.py | set_from_tree | def set_from_tree(root:str, graph:dict) -> frozenset:
"""Return a recursive structure describing given tree"""
Node = namedtuple('Node', 'id succs')
succs = graph[root]
if succs:
return (len(succs), sorted(tuple(set_from_tree(succ, graph) for succ in succs)))
else:
return 0, () | python | def set_from_tree(root:str, graph:dict) -> frozenset:
"""Return a recursive structure describing given tree"""
Node = namedtuple('Node', 'id succs')
succs = graph[root]
if succs:
return (len(succs), sorted(tuple(set_from_tree(succ, graph) for succ in succs)))
else:
return 0, () | [
"def",
"set_from_tree",
"(",
"root",
":",
"str",
",",
"graph",
":",
"dict",
")",
"->",
"frozenset",
":",
"Node",
"=",
"namedtuple",
"(",
"'Node'",
",",
"'id succs'",
")",
"succs",
"=",
"graph",
"[",
"root",
"]",
"if",
"succs",
":",
"return",
"(",
"le... | Return a recursive structure describing given tree | [
"Return",
"a",
"recursive",
"structure",
"describing",
"given",
"tree"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/comparers.py#L27-L34 |
40,160 | trevisanj/f311 | f311/collaboration.py | get_suitable_vis_classes | def get_suitable_vis_classes(obj):
"""Retuns a list of Vis classes that can handle obj."""
ret = []
for class_ in classes_vis():
if isinstance(obj, class_.input_classes):
ret.append(class_)
return ret | python | def get_suitable_vis_classes(obj):
"""Retuns a list of Vis classes that can handle obj."""
ret = []
for class_ in classes_vis():
if isinstance(obj, class_.input_classes):
ret.append(class_)
return ret | [
"def",
"get_suitable_vis_classes",
"(",
"obj",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"class_",
"in",
"classes_vis",
"(",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"class_",
".",
"input_classes",
")",
":",
"ret",
".",
"append",
"(",
"class_",
")",... | Retuns a list of Vis classes that can handle obj. | [
"Retuns",
"a",
"list",
"of",
"Vis",
"classes",
"that",
"can",
"handle",
"obj",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/collaboration.py#L51-L58 |
40,161 | trevisanj/f311 | f311/collaboration.py | get_suitable_vis_list_classes | def get_suitable_vis_list_classes(objs):
"""Retuns a list of VisList classes that can handle a list of objects."""
from f311 import explorer as ex
ret = []
for class_ in classes_vis():
if isinstance(class_, ex.VisList):
flag_can = True
for obj in objs:
i... | python | def get_suitable_vis_list_classes(objs):
"""Retuns a list of VisList classes that can handle a list of objects."""
from f311 import explorer as ex
ret = []
for class_ in classes_vis():
if isinstance(class_, ex.VisList):
flag_can = True
for obj in objs:
i... | [
"def",
"get_suitable_vis_list_classes",
"(",
"objs",
")",
":",
"from",
"f311",
"import",
"explorer",
"as",
"ex",
"ret",
"=",
"[",
"]",
"for",
"class_",
"in",
"classes_vis",
"(",
")",
":",
"if",
"isinstance",
"(",
"class_",
",",
"ex",
".",
"VisList",
")",... | Retuns a list of VisList classes that can handle a list of objects. | [
"Retuns",
"a",
"list",
"of",
"VisList",
"classes",
"that",
"can",
"handle",
"a",
"list",
"of",
"objects",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/collaboration.py#L61-L76 |
40,162 | trevisanj/f311 | f311/collaboration.py | _get_programs_dict | def _get_programs_dict():
"""
Builds and returns programs dictionary
This will have to import the packages in COLLABORATORS_S in order to get their absolute path.
Returns:
dictionary: {"packagename": [ExeInfo0, ...], ...}
"packagename" examples: "f311.explorer", "numpy"
"""
global... | python | def _get_programs_dict():
"""
Builds and returns programs dictionary
This will have to import the packages in COLLABORATORS_S in order to get their absolute path.
Returns:
dictionary: {"packagename": [ExeInfo0, ...], ...}
"packagename" examples: "f311.explorer", "numpy"
"""
global... | [
"def",
"_get_programs_dict",
"(",
")",
":",
"global",
"__programs_dict",
"if",
"__programs_dict",
"is",
"not",
"None",
":",
"return",
"__programs_dict",
"d",
"=",
"__programs_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"pkgname",
"in",
"COLLABORATORS_S",
":",
"t... | Builds and returns programs dictionary
This will have to import the packages in COLLABORATORS_S in order to get their absolute path.
Returns:
dictionary: {"packagename": [ExeInfo0, ...], ...}
"packagename" examples: "f311.explorer", "numpy" | [
"Builds",
"and",
"returns",
"programs",
"dictionary"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/collaboration.py#L216-L245 |
40,163 | seyriz/taiga-contrib-google-auth | back/taiga_contrib_google_auth/connector.py | _build_url | def _build_url(*args, **kwargs) -> str:
"""
Return a valid url.
"""
resource_url = API_RESOURCES_URLS
for key in args:
resource_url = resource_url[key]
if kwargs:
resource_url = resource_url.format(**kwargs)
return urljoin(URL, resource_url) | python | def _build_url(*args, **kwargs) -> str:
"""
Return a valid url.
"""
resource_url = API_RESOURCES_URLS
for key in args:
resource_url = resource_url[key]
if kwargs:
resource_url = resource_url.format(**kwargs)
return urljoin(URL, resource_url) | [
"def",
"_build_url",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"resource_url",
"=",
"API_RESOURCES_URLS",
"for",
"key",
"in",
"args",
":",
"resource_url",
"=",
"resource_url",
"[",
"key",
"]",
"if",
"kwargs",
":",
"resource_url",
... | Return a valid url. | [
"Return",
"a",
"valid",
"url",
"."
] | e9fb5d062027a055e09f7614aa2e48eab7a8604b | https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L64-L75 |
40,164 | seyriz/taiga-contrib-google-auth | back/taiga_contrib_google_auth/connector.py | _get | def _get(url:str, headers:dict) -> dict:
"""
Make a GET call.
"""
response = requests.get(url, headers=headers)
data = response.json()
if response.status_code != 200:
raise GoogleApiError({"status_code": response.status_code,
"error": data.get("error", ... | python | def _get(url:str, headers:dict) -> dict:
"""
Make a GET call.
"""
response = requests.get(url, headers=headers)
data = response.json()
if response.status_code != 200:
raise GoogleApiError({"status_code": response.status_code,
"error": data.get("error", ... | [
"def",
"_get",
"(",
"url",
":",
"str",
",",
"headers",
":",
"dict",
")",
"->",
"dict",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"headers",
")",
"data",
"=",
"response",
".",
"json",
"(",
")",
"if",
"response",
... | Make a GET call. | [
"Make",
"a",
"GET",
"call",
"."
] | e9fb5d062027a055e09f7614aa2e48eab7a8604b | https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L78-L88 |
40,165 | seyriz/taiga-contrib-google-auth | back/taiga_contrib_google_auth/connector.py | _post | def _post(url:str, params:dict, headers:dict) -> dict:
"""
Make a POST call.
"""
response = requests.post(url, params=params, headers=headers)
data = response.json()
if response.status_code != 200 or "error" in data:
raise GoogleApiError({"status_code": response.status_code,
... | python | def _post(url:str, params:dict, headers:dict) -> dict:
"""
Make a POST call.
"""
response = requests.post(url, params=params, headers=headers)
data = response.json()
if response.status_code != 200 or "error" in data:
raise GoogleApiError({"status_code": response.status_code,
... | [
"def",
"_post",
"(",
"url",
":",
"str",
",",
"params",
":",
"dict",
",",
"headers",
":",
"dict",
")",
"->",
"dict",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
")",
"data"... | Make a POST call. | [
"Make",
"a",
"POST",
"call",
"."
] | e9fb5d062027a055e09f7614aa2e48eab7a8604b | https://github.com/seyriz/taiga-contrib-google-auth/blob/e9fb5d062027a055e09f7614aa2e48eab7a8604b/back/taiga_contrib_google_auth/connector.py#L91-L100 |
40,166 | pcattori/deep-blue-talks | kasparobot/__init__.py | MoveAnalyzer.dims_knight | def dims_knight(self, move):
'''Knight on the rim is dim'''
if self.board.piece_type_at(move.from_square) == chess.KNIGHT:
rim = SquareSet(
chess.BB_RANK_1 | \
chess.BB_RANK_8 | \
chess.BB_FILE_A | \
chess.BB_FILE_H)
return move.to_square in rim | python | def dims_knight(self, move):
'''Knight on the rim is dim'''
if self.board.piece_type_at(move.from_square) == chess.KNIGHT:
rim = SquareSet(
chess.BB_RANK_1 | \
chess.BB_RANK_8 | \
chess.BB_FILE_A | \
chess.BB_FILE_H)
return move.to_square in rim | [
"def",
"dims_knight",
"(",
"self",
",",
"move",
")",
":",
"if",
"self",
".",
"board",
".",
"piece_type_at",
"(",
"move",
".",
"from_square",
")",
"==",
"chess",
".",
"KNIGHT",
":",
"rim",
"=",
"SquareSet",
"(",
"chess",
".",
"BB_RANK_1",
"|",
"chess",
... | Knight on the rim is dim | [
"Knight",
"on",
"the",
"rim",
"is",
"dim"
] | 7af7c740e8ec03dd30f1291ecf174078890eec89 | https://github.com/pcattori/deep-blue-talks/blob/7af7c740e8ec03dd30f1291ecf174078890eec89/kasparobot/__init__.py#L95-L103 |
40,167 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_comment_collection | def get_comment_collection(cmt_id):
"""
Extract the collection where the comment is written
"""
query = """SELECT id_bibrec FROM "cmtRECORDCOMMENT" WHERE id=%s"""
recid = run_sql(query, (cmt_id,))
record_primary_collection = guess_primary_collection_of_a_record(
recid[0][0])
return r... | python | def get_comment_collection(cmt_id):
"""
Extract the collection where the comment is written
"""
query = """SELECT id_bibrec FROM "cmtRECORDCOMMENT" WHERE id=%s"""
recid = run_sql(query, (cmt_id,))
record_primary_collection = guess_primary_collection_of_a_record(
recid[0][0])
return r... | [
"def",
"get_comment_collection",
"(",
"cmt_id",
")",
":",
"query",
"=",
"\"\"\"SELECT id_bibrec FROM \"cmtRECORDCOMMENT\" WHERE id=%s\"\"\"",
"recid",
"=",
"run_sql",
"(",
"query",
",",
"(",
"cmt_id",
",",
")",
")",
"record_primary_collection",
"=",
"guess_primary_collect... | Extract the collection where the comment is written | [
"Extract",
"the",
"collection",
"where",
"the",
"comment",
"is",
"written"
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L487-L495 |
40,168 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_collection_moderators | def get_collection_moderators(collection):
"""
Return the list of comment moderators for the given collection.
"""
from invenio_access.engine import acc_get_authorized_emails
res = list(
acc_get_authorized_emails(
'moderatecomments',
collection=collection))
if no... | python | def get_collection_moderators(collection):
"""
Return the list of comment moderators for the given collection.
"""
from invenio_access.engine import acc_get_authorized_emails
res = list(
acc_get_authorized_emails(
'moderatecomments',
collection=collection))
if no... | [
"def",
"get_collection_moderators",
"(",
"collection",
")",
":",
"from",
"invenio_access",
".",
"engine",
"import",
"acc_get_authorized_emails",
"res",
"=",
"list",
"(",
"acc_get_authorized_emails",
"(",
"'moderatecomments'",
",",
"collection",
"=",
"collection",
")",
... | Return the list of comment moderators for the given collection. | [
"Return",
"the",
"list",
"of",
"comment",
"moderators",
"for",
"the",
"given",
"collection",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L498-L510 |
40,169 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_reply_order_cache_data | def get_reply_order_cache_data(comid):
"""
Prepare a representation of the comment ID given as parameter so
that it is suitable for byte ordering in MySQL.
"""
return "%s%s%s%s" % (chr((comid >> 24) % 256), chr((comid >> 16) % 256),
chr((comid >> 8) % 256), chr(comid % 256)) | python | def get_reply_order_cache_data(comid):
"""
Prepare a representation of the comment ID given as parameter so
that it is suitable for byte ordering in MySQL.
"""
return "%s%s%s%s" % (chr((comid >> 24) % 256), chr((comid >> 16) % 256),
chr((comid >> 8) % 256), chr(comid % 256)) | [
"def",
"get_reply_order_cache_data",
"(",
"comid",
")",
":",
"return",
"\"%s%s%s%s\"",
"%",
"(",
"chr",
"(",
"(",
"comid",
">>",
"24",
")",
"%",
"256",
")",
",",
"chr",
"(",
"(",
"comid",
">>",
"16",
")",
"%",
"256",
")",
",",
"chr",
"(",
"(",
"c... | Prepare a representation of the comment ID given as parameter so
that it is suitable for byte ordering in MySQL. | [
"Prepare",
"a",
"representation",
"of",
"the",
"comment",
"ID",
"given",
"as",
"parameter",
"so",
"that",
"it",
"is",
"suitable",
"for",
"byte",
"ordering",
"in",
"MySQL",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L945-L951 |
40,170 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | move_attached_files_to_storage | def move_attached_files_to_storage(attached_files, recID, comid):
"""
Move the files that were just attached to a new comment to their
final location.
:param attached_files: the mappings of desired filename to attach
and path where to find the original file
:type attached... | python | def move_attached_files_to_storage(attached_files, recID, comid):
"""
Move the files that were just attached to a new comment to their
final location.
:param attached_files: the mappings of desired filename to attach
and path where to find the original file
:type attached... | [
"def",
"move_attached_files_to_storage",
"(",
"attached_files",
",",
"recID",
",",
"comid",
")",
":",
"for",
"filename",
",",
"filepath",
"in",
"iteritems",
"(",
"attached_files",
")",
":",
"dest_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CFG_COMMENTSDIR... | Move the files that were just attached to a new comment to their
final location.
:param attached_files: the mappings of desired filename to attach
and path where to find the original file
:type attached_files: dict {filename, filepath}
:param recID: the record ID to which we ... | [
"Move",
"the",
"files",
"that",
"were",
"just",
"attached",
"to",
"a",
"new",
"comment",
"to",
"their",
"final",
"location",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1124-L1143 |
40,171 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | subscribe_user_to_discussion | def subscribe_user_to_discussion(recID, uid):
"""
Subscribe a user to a discussion, so the she receives by emails
all new new comments for this record.
:param recID: record ID corresponding to the discussion we want to
subscribe the user
:param uid: user id
"""
query = """... | python | def subscribe_user_to_discussion(recID, uid):
"""
Subscribe a user to a discussion, so the she receives by emails
all new new comments for this record.
:param recID: record ID corresponding to the discussion we want to
subscribe the user
:param uid: user id
"""
query = """... | [
"def",
"subscribe_user_to_discussion",
"(",
"recID",
",",
"uid",
")",
":",
"query",
"=",
"\"\"\"INSERT INTO \"cmtSUBSCRIPTION\" (id_bibrec, id_user, creation_time)\n VALUES (%s, %s, %s)\"\"\"",
"params",
"=",
"(",
"recID",
",",
"uid",
",",
"convert_datestruct_t... | Subscribe a user to a discussion, so the she receives by emails
all new new comments for this record.
:param recID: record ID corresponding to the discussion we want to
subscribe the user
:param uid: user id | [
"Subscribe",
"a",
"user",
"to",
"a",
"discussion",
"so",
"the",
"she",
"receives",
"by",
"emails",
"all",
"new",
"new",
"comments",
"for",
"this",
"record",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1177-L1193 |
40,172 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | unsubscribe_user_from_discussion | def unsubscribe_user_from_discussion(recID, uid):
"""
Unsubscribe users from a discussion.
:param recID: record ID corresponding to the discussion we want to
unsubscribe the user
:param uid: user id
:return 1 if successful, 0 if not
"""
query = """DELETE FROM "cmtSUBSCRIPT... | python | def unsubscribe_user_from_discussion(recID, uid):
"""
Unsubscribe users from a discussion.
:param recID: record ID corresponding to the discussion we want to
unsubscribe the user
:param uid: user id
:return 1 if successful, 0 if not
"""
query = """DELETE FROM "cmtSUBSCRIPT... | [
"def",
"unsubscribe_user_from_discussion",
"(",
"recID",
",",
"uid",
")",
":",
"query",
"=",
"\"\"\"DELETE FROM \"cmtSUBSCRIPTION\"\n WHERE id_bibrec=%s AND id_user=%s\"\"\"",
"params",
"=",
"(",
"recID",
",",
"uid",
")",
"try",
":",
"res",
"=",
"run_s... | Unsubscribe users from a discussion.
:param recID: record ID corresponding to the discussion we want to
unsubscribe the user
:param uid: user id
:return 1 if successful, 0 if not | [
"Unsubscribe",
"users",
"from",
"a",
"discussion",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1196-L1214 |
40,173 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_users_subscribed_to_discussion | def get_users_subscribed_to_discussion(recID, check_authorizations=True):
"""
Returns the lists of users subscribed to a given discussion.
Two lists are returned: the first one is the list of emails for
users who can unsubscribe from the discussion, the second list
contains the emails of users who ... | python | def get_users_subscribed_to_discussion(recID, check_authorizations=True):
"""
Returns the lists of users subscribed to a given discussion.
Two lists are returned: the first one is the list of emails for
users who can unsubscribe from the discussion, the second list
contains the emails of users who ... | [
"def",
"get_users_subscribed_to_discussion",
"(",
"recID",
",",
"check_authorizations",
"=",
"True",
")",
":",
"subscribers_emails",
"=",
"{",
"}",
"# Get users that have subscribed to this discussion",
"query",
"=",
"\"\"\"SELECT id_user FROM \"cmtSUBSCRIPTION\" WHERE id_bibrec=%s... | Returns the lists of users subscribed to a given discussion.
Two lists are returned: the first one is the list of emails for
users who can unsubscribe from the discussion, the second list
contains the emails of users who cannot unsubscribe (for eg. author
of the document, etc).
Users appear in onl... | [
"Returns",
"the",
"lists",
"of",
"users",
"subscribed",
"to",
"a",
"given",
"discussion",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1241-L1302 |
40,174 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_record_status | def get_record_status(recid):
"""
Returns the current status of the record, i.e. current restriction to apply for newly submitted
comments, and current commenting round.
The restriction to apply can be found in the record metadata, in
field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD.... | python | def get_record_status(recid):
"""
Returns the current status of the record, i.e. current restriction to apply for newly submitted
comments, and current commenting round.
The restriction to apply can be found in the record metadata, in
field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD.... | [
"def",
"get_record_status",
"(",
"recid",
")",
":",
"collections_with_rounds",
"=",
"CFG_WEBCOMMENT_ROUND_DATAFIELD",
".",
"keys",
"(",
")",
"commenting_round",
"=",
"\"\"",
"for",
"collection",
"in",
"collections_with_rounds",
":",
"# Find the first collection defines roun... | Returns the current status of the record, i.e. current restriction to apply for newly submitted
comments, and current commenting round.
The restriction to apply can be found in the record metadata, in
field(s) defined by config CFG_WEBCOMMENT_RESTRICTION_DATAFIELD. The restriction is empty string ""
in... | [
"Returns",
"the",
"current",
"status",
"of",
"the",
"record",
"i",
".",
"e",
".",
"current",
"restriction",
"to",
"apply",
"for",
"newly",
"submitted",
"comments",
"and",
"current",
"commenting",
"round",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1430-L1475 |
40,175 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | group_comments_by_round | def group_comments_by_round(comments, ranking=0):
"""
Group comments by the round to which they belong
"""
comment_rounds = {}
ordered_comment_round_names = []
for comment in comments:
comment_round_name = ranking and comment[11] or comment[7]
if comment_round_name not in comment... | python | def group_comments_by_round(comments, ranking=0):
"""
Group comments by the round to which they belong
"""
comment_rounds = {}
ordered_comment_round_names = []
for comment in comments:
comment_round_name = ranking and comment[11] or comment[7]
if comment_round_name not in comment... | [
"def",
"group_comments_by_round",
"(",
"comments",
",",
"ranking",
"=",
"0",
")",
":",
"comment_rounds",
"=",
"{",
"}",
"ordered_comment_round_names",
"=",
"[",
"]",
"for",
"comment",
"in",
"comments",
":",
"comment_round_name",
"=",
"ranking",
"and",
"comment",... | Group comments by the round to which they belong | [
"Group",
"comments",
"by",
"the",
"round",
"to",
"which",
"they",
"belong"
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L1680-L1693 |
40,176 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_mini_reviews | def get_mini_reviews(recid, ln=CFG_SITE_LANG):
"""
Returns the web controls to add reviews to a record from the
detailed record pages mini-panel.
:param recid: the id of the displayed record
:param ln: the user's language
"""
if CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS:
action = 'SUBMIT'
... | python | def get_mini_reviews(recid, ln=CFG_SITE_LANG):
"""
Returns the web controls to add reviews to a record from the
detailed record pages mini-panel.
:param recid: the id of the displayed record
:param ln: the user's language
"""
if CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS:
action = 'SUBMIT'
... | [
"def",
"get_mini_reviews",
"(",
"recid",
",",
"ln",
"=",
"CFG_SITE_LANG",
")",
":",
"if",
"CFG_WEBCOMMENT_ALLOW_SHORT_REVIEWS",
":",
"action",
"=",
"'SUBMIT'",
"else",
":",
"action",
"=",
"'DISPLAY'",
"reviews",
"=",
"query_retrieve_comments_or_remarks",
"(",
"recid... | Returns the web controls to add reviews to a record from the
detailed record pages mini-panel.
:param recid: the id of the displayed record
:param ln: the user's language | [
"Returns",
"the",
"web",
"controls",
"to",
"add",
"reviews",
"to",
"a",
"record",
"from",
"the",
"detailed",
"record",
"pages",
"mini",
"-",
"panel",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2252-L2272 |
40,177 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | check_user_can_view_comments | def check_user_can_view_comments(user_info, recid):
"""Check if the user is authorized to view comments for given
recid.
Returns the same type as acc_authorize_action
"""
# Check user can view the record itself first
(auth_code, auth_msg) = check_user_can_view_record(user_info, recid)
if au... | python | def check_user_can_view_comments(user_info, recid):
"""Check if the user is authorized to view comments for given
recid.
Returns the same type as acc_authorize_action
"""
# Check user can view the record itself first
(auth_code, auth_msg) = check_user_can_view_record(user_info, recid)
if au... | [
"def",
"check_user_can_view_comments",
"(",
"user_info",
",",
"recid",
")",
":",
"# Check user can view the record itself first",
"(",
"auth_code",
",",
"auth_msg",
")",
"=",
"check_user_can_view_record",
"(",
"user_info",
",",
"recid",
")",
"if",
"auth_code",
":",
"r... | Check if the user is authorized to view comments for given
recid.
Returns the same type as acc_authorize_action | [
"Check",
"if",
"the",
"user",
"is",
"authorized",
"to",
"view",
"comments",
"for",
"given",
"recid",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2275-L2294 |
40,178 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | check_user_can_view_comment | def check_user_can_view_comment(user_info, comid, restriction=None):
"""Check if the user is authorized to view a particular comment,
given the comment restriction. Note that this function does not
check if the record itself is restricted to the user, which would
mean that the user should not see the co... | python | def check_user_can_view_comment(user_info, comid, restriction=None):
"""Check if the user is authorized to view a particular comment,
given the comment restriction. Note that this function does not
check if the record itself is restricted to the user, which would
mean that the user should not see the co... | [
"def",
"check_user_can_view_comment",
"(",
"user_info",
",",
"comid",
",",
"restriction",
"=",
"None",
")",
":",
"if",
"restriction",
"is",
"None",
":",
"comment",
"=",
"query_get_comment",
"(",
"comid",
")",
"if",
"comment",
":",
"restriction",
"=",
"comment"... | Check if the user is authorized to view a particular comment,
given the comment restriction. Note that this function does not
check if the record itself is restricted to the user, which would
mean that the user should not see the comment.
You can omit 'comid' if you already know the 'restriction'
... | [
"Check",
"if",
"the",
"user",
"is",
"authorized",
"to",
"view",
"a",
"particular",
"comment",
"given",
"the",
"comment",
"restriction",
".",
"Note",
"that",
"this",
"function",
"does",
"not",
"check",
"if",
"the",
"record",
"itself",
"is",
"restricted",
"to"... | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2297-L2320 |
40,179 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | check_user_can_send_comments | def check_user_can_send_comments(user_info, recid):
"""Check if the user is authorized to comment the given
recid. This function does not check that user can view the record
or view the comments
Returns the same type as acc_authorize_action
"""
# First can we find an authorization for this case... | python | def check_user_can_send_comments(user_info, recid):
"""Check if the user is authorized to comment the given
recid. This function does not check that user can view the record
or view the comments
Returns the same type as acc_authorize_action
"""
# First can we find an authorization for this case... | [
"def",
"check_user_can_send_comments",
"(",
"user_info",
",",
"recid",
")",
":",
"# First can we find an authorization for this case, action + collection",
"record_primary_collection",
"=",
"guess_primary_collection_of_a_record",
"(",
"recid",
")",
"return",
"acc_authorize_action",
... | Check if the user is authorized to comment the given
recid. This function does not check that user can view the record
or view the comments
Returns the same type as acc_authorize_action | [
"Check",
"if",
"the",
"user",
"is",
"authorized",
"to",
"comment",
"the",
"given",
"recid",
".",
"This",
"function",
"does",
"not",
"check",
"that",
"user",
"can",
"view",
"the",
"record",
"or",
"view",
"the",
"comments"
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2323-L2336 |
40,180 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | check_user_can_attach_file_to_comments | def check_user_can_attach_file_to_comments(user_info, recid):
"""Check if the user is authorized to attach a file to comments
for given recid. This function does not check that user can view
the comments or send comments.
Returns the same type as acc_authorize_action
"""
# First can we find an ... | python | def check_user_can_attach_file_to_comments(user_info, recid):
"""Check if the user is authorized to attach a file to comments
for given recid. This function does not check that user can view
the comments or send comments.
Returns the same type as acc_authorize_action
"""
# First can we find an ... | [
"def",
"check_user_can_attach_file_to_comments",
"(",
"user_info",
",",
"recid",
")",
":",
"# First can we find an authorization for this case action, for",
"# this collection?",
"record_primary_collection",
"=",
"guess_primary_collection_of_a_record",
"(",
"recid",
")",
"return",
... | Check if the user is authorized to attach a file to comments
for given recid. This function does not check that user can view
the comments or send comments.
Returns the same type as acc_authorize_action | [
"Check",
"if",
"the",
"user",
"is",
"authorized",
"to",
"attach",
"a",
"file",
"to",
"comments",
"for",
"given",
"recid",
".",
"This",
"function",
"does",
"not",
"check",
"that",
"user",
"can",
"view",
"the",
"comments",
"or",
"send",
"comments",
"."
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2356-L2370 |
40,181 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | get_user_collapsed_comments_for_record | def get_user_collapsed_comments_for_record(uid, recid):
"""
Get the comments collapsed for given user on given recid page
"""
# Collapsed state is not an attribute of cmtRECORDCOMMENT table
# (vary per user) so it cannot be found when querying for the
# comment. We must therefore provide a effic... | python | def get_user_collapsed_comments_for_record(uid, recid):
"""
Get the comments collapsed for given user on given recid page
"""
# Collapsed state is not an attribute of cmtRECORDCOMMENT table
# (vary per user) so it cannot be found when querying for the
# comment. We must therefore provide a effic... | [
"def",
"get_user_collapsed_comments_for_record",
"(",
"uid",
",",
"recid",
")",
":",
"# Collapsed state is not an attribute of cmtRECORDCOMMENT table",
"# (vary per user) so it cannot be found when querying for the",
"# comment. We must therefore provide a efficient way to retrieve",
"# the co... | Get the comments collapsed for given user on given recid page | [
"Get",
"the",
"comments",
"collapsed",
"for",
"given",
"user",
"on",
"given",
"recid",
"page"
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2417-L2427 |
40,182 | inveniosoftware-attic/invenio-comments | invenio_comments/api.py | is_comment_deleted | def is_comment_deleted(comid):
"""
Return True of the comment is deleted. Else False
:param comid: ID of comment to check
"""
query = """SELECT status from "cmtRECORDCOMMENT" WHERE id=%s"""
params = (comid,)
res = run_sql(query, params)
if res and res[0][0] != 'ok':
return True
... | python | def is_comment_deleted(comid):
"""
Return True of the comment is deleted. Else False
:param comid: ID of comment to check
"""
query = """SELECT status from "cmtRECORDCOMMENT" WHERE id=%s"""
params = (comid,)
res = run_sql(query, params)
if res and res[0][0] != 'ok':
return True
... | [
"def",
"is_comment_deleted",
"(",
"comid",
")",
":",
"query",
"=",
"\"\"\"SELECT status from \"cmtRECORDCOMMENT\" WHERE id=%s\"\"\"",
"params",
"=",
"(",
"comid",
",",
")",
"res",
"=",
"run_sql",
"(",
"query",
",",
"params",
")",
"if",
"res",
"and",
"res",
"[",
... | Return True of the comment is deleted. Else False
:param comid: ID of comment to check | [
"Return",
"True",
"of",
"the",
"comment",
"is",
"deleted",
".",
"Else",
"False"
] | 62bb6e07c146baf75bf8de80b5896ab2a01a8423 | https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/api.py#L2430-L2442 |
40,183 | openstack/stacktach-winchester | winchester/trigger_manager.py | EventCondenser._fix_time | def _fix_time(self, dt):
"""Stackdistiller converts all times to utc.
We store timestamps as utc datetime. However, the explicit
UTC timezone on incoming datetimes causes comparison issues
deep in sqlalchemy. We fix this by converting all datetimes
to naive utc timestamps
... | python | def _fix_time(self, dt):
"""Stackdistiller converts all times to utc.
We store timestamps as utc datetime. However, the explicit
UTC timezone on incoming datetimes causes comparison issues
deep in sqlalchemy. We fix this by converting all datetimes
to naive utc timestamps
... | [
"def",
"_fix_time",
"(",
"self",
",",
"dt",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
":",
"dt",
"=",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"return",
"dt"
] | Stackdistiller converts all times to utc.
We store timestamps as utc datetime. However, the explicit
UTC timezone on incoming datetimes causes comparison issues
deep in sqlalchemy. We fix this by converting all datetimes
to naive utc timestamps | [
"Stackdistiller",
"converts",
"all",
"times",
"to",
"utc",
"."
] | 54f3ffc4a8fd84b6fb29ad9b65adb018e8927956 | https://github.com/openstack/stacktach-winchester/blob/54f3ffc4a8fd84b6fb29ad9b65adb018e8927956/winchester/trigger_manager.py#L64-L74 |
40,184 | Cecca/lydoc | lydoc/collector.py | strip_leading_comments | def strip_leading_comments(text):
"""Strips the leading whitespaces and % from the given text.
Adapted from textwrap.dedent
"""
# Look for the longest leading string of spaces and tabs common to
# all lines.
margin = None
text = _whitespace_only_re.sub('', text)
indents = _leading_white... | python | def strip_leading_comments(text):
"""Strips the leading whitespaces and % from the given text.
Adapted from textwrap.dedent
"""
# Look for the longest leading string of spaces and tabs common to
# all lines.
margin = None
text = _whitespace_only_re.sub('', text)
indents = _leading_white... | [
"def",
"strip_leading_comments",
"(",
"text",
")",
":",
"# Look for the longest leading string of spaces and tabs common to",
"# all lines.",
"margin",
"=",
"None",
"text",
"=",
"_whitespace_only_re",
".",
"sub",
"(",
"''",
",",
"text",
")",
"indents",
"=",
"_leading_wh... | Strips the leading whitespaces and % from the given text.
Adapted from textwrap.dedent | [
"Strips",
"the",
"leading",
"whitespaces",
"and",
"%",
"from",
"the",
"given",
"text",
"."
] | cd01dd5ed902b2574fb412c55bdc684276a88505 | https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/collector.py#L23-L61 |
40,185 | Cecca/lydoc | lydoc/collector.py | parse | def parse(target, trace=False, **kwargs):
"""Parse the given target. If it is a file-like object, then parse its
contents. If given a string, perform one of the following actions
- If the string is a valid file path, then open and parse it
- If the string is a valid directory path, then recursively l... | python | def parse(target, trace=False, **kwargs):
"""Parse the given target. If it is a file-like object, then parse its
contents. If given a string, perform one of the following actions
- If the string is a valid file path, then open and parse it
- If the string is a valid directory path, then recursively l... | [
"def",
"parse",
"(",
"target",
",",
"trace",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Beware! This function, that actually is the core of all the",
"# business, is written to minimize the responsibilities of each",
"# chunk of code, keeping things simple. Performance may d... | Parse the given target. If it is a file-like object, then parse its
contents. If given a string, perform one of the following actions
- If the string is a valid file path, then open and parse it
- If the string is a valid directory path, then recursively look for
files ending in .ly or .ily
-... | [
"Parse",
"the",
"given",
"target",
".",
"If",
"it",
"is",
"a",
"file",
"-",
"like",
"object",
"then",
"parse",
"its",
"contents",
".",
"If",
"given",
"a",
"string",
"perform",
"one",
"of",
"the",
"following",
"actions"
] | cd01dd5ed902b2574fb412c55bdc684276a88505 | https://github.com/Cecca/lydoc/blob/cd01dd5ed902b2574fb412c55bdc684276a88505/lydoc/collector.py#L127-L189 |
40,186 | concordusapps/flask-components | src/flask_components/utils.py | find | def find(name, app=None, components=None, raw=False):
"""
Discover any named attributes, modules, or packages and coalesces the
results.
Looks in any module or package declared in the the 'COMPONENTS' key
in the application config.
Order of found results are persisted from the order that the
... | python | def find(name, app=None, components=None, raw=False):
"""
Discover any named attributes, modules, or packages and coalesces the
results.
Looks in any module or package declared in the the 'COMPONENTS' key
in the application config.
Order of found results are persisted from the order that the
... | [
"def",
"find",
"(",
"name",
",",
"app",
"=",
"None",
",",
"components",
"=",
"None",
",",
"raw",
"=",
"False",
")",
":",
"if",
"components",
"is",
"None",
":",
"if",
"app",
"is",
"None",
":",
"from",
"flask",
"import",
"current_app",
"as",
"app",
"... | Discover any named attributes, modules, or packages and coalesces the
results.
Looks in any module or package declared in the the 'COMPONENTS' key
in the application config.
Order of found results are persisted from the order that the
component was declared in.
@param[in] components
A... | [
"Discover",
"any",
"named",
"attributes",
"modules",
"or",
"packages",
"and",
"coalesces",
"the",
"results",
"."
] | 99d798cbc77147649651eda6e386de2c10f293e2 | https://github.com/concordusapps/flask-components/blob/99d798cbc77147649651eda6e386de2c10f293e2/src/flask_components/utils.py#L11-L64 |
40,187 | tradenity/python-sdk | tradenity/resources/cart_settings.py | CartSettings.auto_clear_shopping_cart | def auto_clear_shopping_cart(self, auto_clear_shopping_cart):
"""Sets the auto_clear_shopping_cart of this CartSettings.
:param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings.
:type: str
"""
allowed_values = ["never", "orderCreated", "orderCompleted... | python | def auto_clear_shopping_cart(self, auto_clear_shopping_cart):
"""Sets the auto_clear_shopping_cart of this CartSettings.
:param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings.
:type: str
"""
allowed_values = ["never", "orderCreated", "orderCompleted... | [
"def",
"auto_clear_shopping_cart",
"(",
"self",
",",
"auto_clear_shopping_cart",
")",
":",
"allowed_values",
"=",
"[",
"\"never\"",
",",
"\"orderCreated\"",
",",
"\"orderCompleted\"",
"]",
"# noqa: E501",
"if",
"auto_clear_shopping_cart",
"is",
"not",
"None",
"and",
"... | Sets the auto_clear_shopping_cart of this CartSettings.
:param auto_clear_shopping_cart: The auto_clear_shopping_cart of this CartSettings.
:type: str | [
"Sets",
"the",
"auto_clear_shopping_cart",
"of",
"this",
"CartSettings",
"."
] | d13fbe23f4d6ff22554c6d8d2deaf209371adaf1 | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/cart_settings.py#L52-L66 |
40,188 | nuSTORM/gnomon | gnomon/SensitiveDetector.py | ScintSD.getView | def getView(self, lv):
"""Determine the detector view starting with a G4LogicalVolume"""
view = None
if str(lv.GetName())[-1] == 'X':
return 'X'
elif str(lv.GetName())[-1] == 'Y':
return 'Y'
self.log.error('Cannot determine view for %s', lv.GetName())
... | python | def getView(self, lv):
"""Determine the detector view starting with a G4LogicalVolume"""
view = None
if str(lv.GetName())[-1] == 'X':
return 'X'
elif str(lv.GetName())[-1] == 'Y':
return 'Y'
self.log.error('Cannot determine view for %s', lv.GetName())
... | [
"def",
"getView",
"(",
"self",
",",
"lv",
")",
":",
"view",
"=",
"None",
"if",
"str",
"(",
"lv",
".",
"GetName",
"(",
")",
")",
"[",
"-",
"1",
"]",
"==",
"'X'",
":",
"return",
"'X'",
"elif",
"str",
"(",
"lv",
".",
"GetName",
"(",
")",
")",
... | Determine the detector view starting with a G4LogicalVolume | [
"Determine",
"the",
"detector",
"view",
"starting",
"with",
"a",
"G4LogicalVolume"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/SensitiveDetector.py#L78-L88 |
40,189 | trevisanj/a99 | a99/gui/parameter.py | Parameter.RenderWidget | def RenderWidget(self):
"""Returns a QWidget subclass instance. Exact class depends on self.type"""
t = self.type
if t == int:
ret = QSpinBox()
ret.setMaximum(999999999)
ret.setValue(self.value)
elif t == float:
ret = QLineEdit()
... | python | def RenderWidget(self):
"""Returns a QWidget subclass instance. Exact class depends on self.type"""
t = self.type
if t == int:
ret = QSpinBox()
ret.setMaximum(999999999)
ret.setValue(self.value)
elif t == float:
ret = QLineEdit()
... | [
"def",
"RenderWidget",
"(",
"self",
")",
":",
"t",
"=",
"self",
".",
"type",
"if",
"t",
"==",
"int",
":",
"ret",
"=",
"QSpinBox",
"(",
")",
"ret",
".",
"setMaximum",
"(",
"999999999",
")",
"ret",
".",
"setValue",
"(",
"self",
".",
"value",
")",
"... | Returns a QWidget subclass instance. Exact class depends on self.type | [
"Returns",
"a",
"QWidget",
"subclass",
"instance",
".",
"Exact",
"class",
"depends",
"on",
"self",
".",
"type"
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/parameter.py#L123-L144 |
40,190 | dbuscher/pois | pois/PhaseScreen.py | ScreenGenerator | def ScreenGenerator(nfft, r0, nx, ny):
"""Generate an infinite series of rectangular phase screens
Uses an FFT screen generator to make a large screen and then
returns non-overlapping subsections of it"""
while 1:
layers = GenerateTwoScreens(nfft, r0)
for iLayer in range(2):
... | python | def ScreenGenerator(nfft, r0, nx, ny):
"""Generate an infinite series of rectangular phase screens
Uses an FFT screen generator to make a large screen and then
returns non-overlapping subsections of it"""
while 1:
layers = GenerateTwoScreens(nfft, r0)
for iLayer in range(2):
... | [
"def",
"ScreenGenerator",
"(",
"nfft",
",",
"r0",
",",
"nx",
",",
"ny",
")",
":",
"while",
"1",
":",
"layers",
"=",
"GenerateTwoScreens",
"(",
"nfft",
",",
"r0",
")",
"for",
"iLayer",
"in",
"range",
"(",
"2",
")",
":",
"for",
"iy",
"in",
"range",
... | Generate an infinite series of rectangular phase screens
Uses an FFT screen generator to make a large screen and then
returns non-overlapping subsections of it | [
"Generate",
"an",
"infinite",
"series",
"of",
"rectangular",
"phase",
"screens",
"Uses",
"an",
"FFT",
"screen",
"generator",
"to",
"make",
"a",
"large",
"screen",
"and",
"then",
"returns",
"non",
"-",
"overlapping",
"subsections",
"of",
"it"
] | bb9d9a932e716b5d385221768027384691803aa3 | https://github.com/dbuscher/pois/blob/bb9d9a932e716b5d385221768027384691803aa3/pois/PhaseScreen.py#L5-L14 |
40,191 | consbio/parserutils | parserutils/dates.py | parse_dates | def parse_dates(d, default='today'):
""" Parses one or more dates from d """
if default == 'today':
default = datetime.datetime.today()
if d is None:
return default
elif isinstance(d, _parsed_date_types):
return d
elif is_number(d):
# Treat as milliseconds since 1... | python | def parse_dates(d, default='today'):
""" Parses one or more dates from d """
if default == 'today':
default = datetime.datetime.today()
if d is None:
return default
elif isinstance(d, _parsed_date_types):
return d
elif is_number(d):
# Treat as milliseconds since 1... | [
"def",
"parse_dates",
"(",
"d",
",",
"default",
"=",
"'today'",
")",
":",
"if",
"default",
"==",
"'today'",
":",
"default",
"=",
"datetime",
".",
"datetime",
".",
"today",
"(",
")",
"if",
"d",
"is",
"None",
":",
"return",
"default",
"elif",
"isinstance... | Parses one or more dates from d | [
"Parses",
"one",
"or",
"more",
"dates",
"from",
"d"
] | f13f80db99ed43479336b116e38512e3566e4623 | https://github.com/consbio/parserutils/blob/f13f80db99ed43479336b116e38512e3566e4623/parserutils/dates.py#L9-L40 |
40,192 | trevisanj/f311 | f311/util.py | load_with_classes | def load_with_classes(filename, classes):
"""Attempts to load file by trial-and-error using a given list of classes.
Arguments:
filename -- full path to file
classes -- list of classes having a load() method
Returns: DataFile object if loaded successfully, or None if not.
Note: it will st... | python | def load_with_classes(filename, classes):
"""Attempts to load file by trial-and-error using a given list of classes.
Arguments:
filename -- full path to file
classes -- list of classes having a load() method
Returns: DataFile object if loaded successfully, or None if not.
Note: it will st... | [
"def",
"load_with_classes",
"(",
"filename",
",",
"classes",
")",
":",
"ok",
"=",
"False",
"for",
"class_",
"in",
"classes",
":",
"obj",
"=",
"class_",
"(",
")",
"try",
":",
"obj",
".",
"load",
"(",
"filename",
")",
"ok",
"=",
"True",
"# # cannot let I... | Attempts to load file by trial-and-error using a given list of classes.
Arguments:
filename -- full path to file
classes -- list of classes having a load() method
Returns: DataFile object if loaded successfully, or None if not.
Note: it will stop at the first successful load.
Attention: ... | [
"Attempts",
"to",
"load",
"file",
"by",
"trial",
"-",
"and",
"-",
"error",
"using",
"a",
"given",
"list",
"of",
"classes",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L32-L71 |
40,193 | trevisanj/f311 | f311/util.py | load_any_file | def load_any_file(filename):
"""
Attempts to load filename by trial-and-error
Returns:
file: A DataFile descendant, whose specific class depends on the file format detected, or None
if the file canonot be loaded
"""
import f311
# Splits attempts using ((binary X text) file) cri... | python | def load_any_file(filename):
"""
Attempts to load filename by trial-and-error
Returns:
file: A DataFile descendant, whose specific class depends on the file format detected, or None
if the file canonot be loaded
"""
import f311
# Splits attempts using ((binary X text) file) cri... | [
"def",
"load_any_file",
"(",
"filename",
")",
":",
"import",
"f311",
"# Splits attempts using ((binary X text) file) criterion",
"if",
"a99",
".",
"is_text_file",
"(",
"filename",
")",
":",
"return",
"load_with_classes",
"(",
"filename",
",",
"f311",
".",
"classes_txt... | Attempts to load filename by trial-and-error
Returns:
file: A DataFile descendant, whose specific class depends on the file format detected, or None
if the file canonot be loaded | [
"Attempts",
"to",
"load",
"filename",
"by",
"trial",
"-",
"and",
"-",
"error"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L74-L88 |
40,194 | trevisanj/f311 | f311/util.py | load_spectrum | def load_spectrum(filename):
"""
Attempts to load spectrum as one of the supported types.
Returns:
a Spectrum, or None
"""
import f311
f = load_with_classes(filename, f311.classes_sp())
if f:
return f.spectrum
return None | python | def load_spectrum(filename):
"""
Attempts to load spectrum as one of the supported types.
Returns:
a Spectrum, or None
"""
import f311
f = load_with_classes(filename, f311.classes_sp())
if f:
return f.spectrum
return None | [
"def",
"load_spectrum",
"(",
"filename",
")",
":",
"import",
"f311",
"f",
"=",
"load_with_classes",
"(",
"filename",
",",
"f311",
".",
"classes_sp",
"(",
")",
")",
"if",
"f",
":",
"return",
"f",
".",
"spectrum",
"return",
"None"
] | Attempts to load spectrum as one of the supported types.
Returns:
a Spectrum, or None | [
"Attempts",
"to",
"load",
"spectrum",
"as",
"one",
"of",
"the",
"supported",
"types",
"."
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L107-L119 |
40,195 | trevisanj/f311 | f311/util.py | load_spectrum_fits_messed_x | def load_spectrum_fits_messed_x(filename, sp_ref=None):
"""Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum"""
import f311.filetypes as ft
# First tries to load as usual
f = load_with_classes(filename, (ft.FileSpectrumFits,))
if f is not None:
ret = f.spec... | python | def load_spectrum_fits_messed_x(filename, sp_ref=None):
"""Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum"""
import f311.filetypes as ft
# First tries to load as usual
f = load_with_classes(filename, (ft.FileSpectrumFits,))
if f is not None:
ret = f.spec... | [
"def",
"load_spectrum_fits_messed_x",
"(",
"filename",
",",
"sp_ref",
"=",
"None",
")",
":",
"import",
"f311",
".",
"filetypes",
"as",
"ft",
"# First tries to load as usual",
"f",
"=",
"load_with_classes",
"(",
"filename",
",",
"(",
"ft",
".",
"FileSpectrumFits",
... | Loads FITS file spectrum that does not have the proper headers. Returns a Spectrum | [
"Loads",
"FITS",
"file",
"spectrum",
"that",
"does",
"not",
"have",
"the",
"proper",
"headers",
".",
"Returns",
"a",
"Spectrum"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L122-L152 |
40,196 | trevisanj/f311 | f311/util.py | get_filetypes_info | def get_filetypes_info(editor_quote="`", flag_leaf=True):
"""
Reports available data types
Args:
editor_quote: character to enclose the name of the editor script between.
flag_leaf: see tabulate_filetypes_rest()
Returns:
list: list of FileTypeInfo
"""
NONE_REPL = ""
... | python | def get_filetypes_info(editor_quote="`", flag_leaf=True):
"""
Reports available data types
Args:
editor_quote: character to enclose the name of the editor script between.
flag_leaf: see tabulate_filetypes_rest()
Returns:
list: list of FileTypeInfo
"""
NONE_REPL = ""
... | [
"def",
"get_filetypes_info",
"(",
"editor_quote",
"=",
"\"`\"",
",",
"flag_leaf",
"=",
"True",
")",
":",
"NONE_REPL",
"=",
"\"\"",
"import",
"f311",
"data",
"=",
"[",
"]",
"# [FileTypeInfo, ...]",
"for",
"attr",
"in",
"f311",
".",
"classes_file",
"(",
"flag_... | Reports available data types
Args:
editor_quote: character to enclose the name of the editor script between.
flag_leaf: see tabulate_filetypes_rest()
Returns:
list: list of FileTypeInfo | [
"Reports",
"available",
"data",
"types"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L160-L191 |
40,197 | trevisanj/f311 | f311/util.py | tabulate_filetypes_rest | def tabulate_filetypes_rest(attrnames=None, header=None, flag_wrap_description=True,
description_width=40, flag_leaf=True):
"""
Generates a reST multirow table
Args:
attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS).
Defaults to all att... | python | def tabulate_filetypes_rest(attrnames=None, header=None, flag_wrap_description=True,
description_width=40, flag_leaf=True):
"""
Generates a reST multirow table
Args:
attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS).
Defaults to all att... | [
"def",
"tabulate_filetypes_rest",
"(",
"attrnames",
"=",
"None",
",",
"header",
"=",
"None",
",",
"flag_wrap_description",
"=",
"True",
",",
"description_width",
"=",
"40",
",",
"flag_leaf",
"=",
"True",
")",
":",
"infos",
"=",
"get_filetypes_info",
"(",
"edit... | Generates a reST multirow table
Args:
attrnames: list of attribute names (keys of FILE_TYPE_INFO_ATTRS).
Defaults to all attributes
header: list of strings containing headers. If not passed, uses default names
flag_wrap_description: whether to wrap the description text
... | [
"Generates",
"a",
"reST",
"multirow",
"table"
] | 9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7 | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/util.py#L246-L266 |
40,198 | tradenity/python-sdk | tradenity/resources/return_settings.py | ReturnSettings.return_action | def return_action(self, return_action):
"""Sets the return_action of this ReturnSettings.
:param return_action: The return_action of this ReturnSettings.
:type: str
"""
allowed_values = ["refund", "storeCredit"] # noqa: E501
if return_action is not None and return_acti... | python | def return_action(self, return_action):
"""Sets the return_action of this ReturnSettings.
:param return_action: The return_action of this ReturnSettings.
:type: str
"""
allowed_values = ["refund", "storeCredit"] # noqa: E501
if return_action is not None and return_acti... | [
"def",
"return_action",
"(",
"self",
",",
"return_action",
")",
":",
"allowed_values",
"=",
"[",
"\"refund\"",
",",
"\"storeCredit\"",
"]",
"# noqa: E501",
"if",
"return_action",
"is",
"not",
"None",
"and",
"return_action",
"not",
"in",
"allowed_values",
":",
"r... | Sets the return_action of this ReturnSettings.
:param return_action: The return_action of this ReturnSettings.
:type: str | [
"Sets",
"the",
"return_action",
"of",
"this",
"ReturnSettings",
"."
] | d13fbe23f4d6ff22554c6d8d2deaf209371adaf1 | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/return_settings.py#L88-L102 |
40,199 | blockadeio/analyst_toolbench | blockade/cli/config.py | show_config | def show_config(config):
"""Show the current configuration."""
print("\nCurrent Configuration:\n")
for k, v in sorted(config.config.items()):
print("{0:15}: {1}".format(k, v)) | python | def show_config(config):
"""Show the current configuration."""
print("\nCurrent Configuration:\n")
for k, v in sorted(config.config.items()):
print("{0:15}: {1}".format(k, v)) | [
"def",
"show_config",
"(",
"config",
")",
":",
"print",
"(",
"\"\\nCurrent Configuration:\\n\"",
")",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"config",
".",
"config",
".",
"items",
"(",
")",
")",
":",
"print",
"(",
"\"{0:15}: {1}\"",
".",
"format",
"(... | Show the current configuration. | [
"Show",
"the",
"current",
"configuration",
"."
] | 159b6f8cf8a91c5ff050f1579636ea90ab269863 | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/config.py#L10-L14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.