repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
Clinical-Genomics/housekeeper | housekeeper/cli/add.py | file_cmd | def file_cmd(context, tags, archive, bundle_name, path):
"""Add a file to a bundle."""
bundle_obj = context.obj['db'].bundle(bundle_name)
if bundle_obj is None:
click.echo(click.style(f"unknown bundle: {bundle_name}", fg='red'))
context.abort()
version_obj = bundle_obj.versions[0]
ne... | python | def file_cmd(context, tags, archive, bundle_name, path):
"""Add a file to a bundle."""
bundle_obj = context.obj['db'].bundle(bundle_name)
if bundle_obj is None:
click.echo(click.style(f"unknown bundle: {bundle_name}", fg='red'))
context.abort()
version_obj = bundle_obj.versions[0]
ne... | [
"def",
"file_cmd",
"(",
"context",
",",
"tags",
",",
"archive",
",",
"bundle_name",
",",
"path",
")",
":",
"bundle_obj",
"=",
"context",
".",
"obj",
"[",
"'db'",
"]",
".",
"bundle",
"(",
"bundle_name",
")",
"if",
"bundle_obj",
"is",
"None",
":",
"click... | Add a file to a bundle. | [
"Add",
"a",
"file",
"to",
"a",
"bundle",
"."
] | train | https://github.com/Clinical-Genomics/housekeeper/blob/a7d10d327dc9f06274bdef5504ed1b9413f2c8c1/housekeeper/cli/add.py#L42-L57 |
Clinical-Genomics/housekeeper | housekeeper/cli/add.py | tag | def tag(context: click.Context, file_id: int, tags: List[str]):
"""Add tags to an existing file."""
file_obj = context.obj['db'].file_(file_id)
if file_obj is None:
print(click.style('unable to find file', fg='red'))
context.abort()
for tag_name in tags:
tag_obj = context.obj['db... | python | def tag(context: click.Context, file_id: int, tags: List[str]):
"""Add tags to an existing file."""
file_obj = context.obj['db'].file_(file_id)
if file_obj is None:
print(click.style('unable to find file', fg='red'))
context.abort()
for tag_name in tags:
tag_obj = context.obj['db... | [
"def",
"tag",
"(",
"context",
":",
"click",
".",
"Context",
",",
"file_id",
":",
"int",
",",
"tags",
":",
"List",
"[",
"str",
"]",
")",
":",
"file_obj",
"=",
"context",
".",
"obj",
"[",
"'db'",
"]",
".",
"file_",
"(",
"file_id",
")",
"if",
"file_... | Add tags to an existing file. | [
"Add",
"tags",
"to",
"an",
"existing",
"file",
"."
] | train | https://github.com/Clinical-Genomics/housekeeper/blob/a7d10d327dc9f06274bdef5504ed1b9413f2c8c1/housekeeper/cli/add.py#L64-L80 |
Clinical-Genomics/housekeeper | housekeeper/include.py | include_version | def include_version(global_root: str, version_obj: models.Version, hardlink:bool=True):
"""Include files in existing bundle version."""
global_root_dir = Path(global_root)
if version_obj.included_at:
raise VersionIncludedError(f"version included on {version_obj.included_at}")
# generate root di... | python | def include_version(global_root: str, version_obj: models.Version, hardlink:bool=True):
"""Include files in existing bundle version."""
global_root_dir = Path(global_root)
if version_obj.included_at:
raise VersionIncludedError(f"version included on {version_obj.included_at}")
# generate root di... | [
"def",
"include_version",
"(",
"global_root",
":",
"str",
",",
"version_obj",
":",
"models",
".",
"Version",
",",
"hardlink",
":",
"bool",
"=",
"True",
")",
":",
"global_root_dir",
"=",
"Path",
"(",
"global_root",
")",
"if",
"version_obj",
".",
"included_at"... | Include files in existing bundle version. | [
"Include",
"files",
"in",
"existing",
"bundle",
"version",
"."
] | train | https://github.com/Clinical-Genomics/housekeeper/blob/a7d10d327dc9f06274bdef5504ed1b9413f2c8c1/housekeeper/include.py#L14-L34 |
Clinical-Genomics/housekeeper | housekeeper/include.py | checksum | def checksum(path):
"""Calculcate checksum for a file."""
hasher = hashlib.sha1()
with open(path, 'rb') as stream:
buf = stream.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = stream.read(BLOCKSIZE)
return hasher.hexdigest() | python | def checksum(path):
"""Calculcate checksum for a file."""
hasher = hashlib.sha1()
with open(path, 'rb') as stream:
buf = stream.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = stream.read(BLOCKSIZE)
return hasher.hexdigest() | [
"def",
"checksum",
"(",
"path",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"stream",
":",
"buf",
"=",
"stream",
".",
"read",
"(",
"BLOCKSIZE",
")",
"while",
"len",
"(",
"buf",
"... | Calculcate checksum for a file. | [
"Calculcate",
"checksum",
"for",
"a",
"file",
"."
] | train | https://github.com/Clinical-Genomics/housekeeper/blob/a7d10d327dc9f06274bdef5504ed1b9413f2c8c1/housekeeper/include.py#L37-L45 |
adamchainz/kwargs-only | kwargs_only.py | kwargs_only | def kwargs_only(func):
"""
Make a function only accept keyword arguments.
This can be dropped in Python 3 in lieu of:
def foo(*, bar=default):
"""
if hasattr(inspect, 'signature'): # pragma: no cover
# Python 3
signature = inspect.signature(func)
first_arg_name = lis... | python | def kwargs_only(func):
"""
Make a function only accept keyword arguments.
This can be dropped in Python 3 in lieu of:
def foo(*, bar=default):
"""
if hasattr(inspect, 'signature'): # pragma: no cover
# Python 3
signature = inspect.signature(func)
first_arg_name = lis... | [
"def",
"kwargs_only",
"(",
"func",
")",
":",
"if",
"hasattr",
"(",
"inspect",
",",
"'signature'",
")",
":",
"# pragma: no cover",
"# Python 3",
"signature",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"first_arg_name",
"=",
"list",
"(",
"signature",
... | Make a function only accept keyword arguments.
This can be dropped in Python 3 in lieu of:
def foo(*, bar=default): | [
"Make",
"a",
"function",
"only",
"accept",
"keyword",
"arguments",
".",
"This",
"can",
"be",
"dropped",
"in",
"Python",
"3",
"in",
"lieu",
"of",
":",
"def",
"foo",
"(",
"*",
"bar",
"=",
"default",
")",
":"
] | train | https://github.com/adamchainz/kwargs-only/blob/a75246283358696a6112af3baf5002fa023f5336/kwargs_only.py#L10-L36 |
mpasternak/djorm-ext-filtered-contenttypes | filtered_contenttypes/fields.py | FilteredGenericForeignKey.get_prep_lookup | def get_prep_lookup(self, lookup_name, rhs):
"""
Perform preliminary non-db specific lookup checks and conversions
"""
if lookup_name == 'exact':
if not isinstance(rhs, Model):
raise FilteredGenericForeignKeyFilteringException(
"For exact l... | python | def get_prep_lookup(self, lookup_name, rhs):
"""
Perform preliminary non-db specific lookup checks and conversions
"""
if lookup_name == 'exact':
if not isinstance(rhs, Model):
raise FilteredGenericForeignKeyFilteringException(
"For exact l... | [
"def",
"get_prep_lookup",
"(",
"self",
",",
"lookup_name",
",",
"rhs",
")",
":",
"if",
"lookup_name",
"==",
"'exact'",
":",
"if",
"not",
"isinstance",
"(",
"rhs",
",",
"Model",
")",
":",
"raise",
"FilteredGenericForeignKeyFilteringException",
"(",
"\"For exact l... | Perform preliminary non-db specific lookup checks and conversions | [
"Perform",
"preliminary",
"non",
"-",
"db",
"specific",
"lookup",
"checks",
"and",
"conversions"
] | train | https://github.com/mpasternak/djorm-ext-filtered-contenttypes/blob/63fa209d13891282adcec92250ff78b6442f4cd3/filtered_contenttypes/fields.py#L49-L70 |
Robin8Put/pmes | storage/rpc_methods.py | getaccountbywallet | async def getaccountbywallet(**params):
"""Receives account by wallet
Accepts:
- public key hex or checksum format
"""
if params.get("message"):
params = json.loads(params.get("message"))
for coinid in coin_ids:
database = client[coinid]
wallet_collection = database[settings.WALLET]
wallet = await walle... | python | async def getaccountbywallet(**params):
"""Receives account by wallet
Accepts:
- public key hex or checksum format
"""
if params.get("message"):
params = json.loads(params.get("message"))
for coinid in coin_ids:
database = client[coinid]
wallet_collection = database[settings.WALLET]
wallet = await walle... | [
"async",
"def",
"getaccountbywallet",
"(",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
")",
")",
"for",
"coinid",
"in",
"c... | Receives account by wallet
Accepts:
- public key hex or checksum format | [
"Receives",
"account",
"by",
"wallet",
"Accepts",
":",
"-",
"public",
"key",
"hex",
"or",
"checksum",
"format"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L1241-L1264 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.create_account | async def create_account(self, **params):
"""Describes, validates data.
"""
logging.debug("\n\n[+] -- Create account debugging. ")
model = {
"unique": ["email", "public_key"],
"required": ("public_key",),
"default": {"count":len(settings.AVAILABLE_COIN_ID),
"level":2,
"news_count":0,
"em... | python | async def create_account(self, **params):
"""Describes, validates data.
"""
logging.debug("\n\n[+] -- Create account debugging. ")
model = {
"unique": ["email", "public_key"],
"required": ("public_key",),
"default": {"count":len(settings.AVAILABLE_COIN_ID),
"level":2,
"news_count":0,
"em... | [
"async",
"def",
"create_account",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"logging",
".",
"debug",
"(",
"\"\\n\\n[+] -- Create account debugging. \"",
")",
"model",
"=",
"{",
"\"unique\"",
":",
"[",
"\"email\"",
",",
"\"public_key\"",
"]",
",",
"\"requ... | Describes, validates data. | [
"Describes",
"validates",
"data",
"."
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L56-L106 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.find_recent_news | async def find_recent_news(self, **params):
"""Looking up recent news for account.
Accepts:
- public_key
Returns:
- list with dicts or empty
"""
# Check if params is not empty
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason... | python | async def find_recent_news(self, **params):
"""Looking up recent news for account.
Accepts:
- public_key
Returns:
- list with dicts or empty
"""
# Check if params is not empty
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason... | [
"async",
"def",
"find_recent_news",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"# Check if params is not empty",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\... | Looking up recent news for account.
Accepts:
- public_key
Returns:
- list with dicts or empty | [
"Looking",
"up",
"recent",
"news",
"for",
"account",
".",
"Accepts",
":",
"-",
"public_key",
"Returns",
":",
"-",
"list",
"with",
"dicts",
"or",
"empty"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L110-L148 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.insert_news | async def insert_news(self, **params):
"""Inserts news for account
Accepts:
- event_type
- cid
- access_string (of buyer)
- buyer_pubkey
- buyer address
- owner address
- price
- offer type
- coin ID
Returns:
- dict with result
"""
logging.debug("\n\n [+] -- Setting news debuggin... | python | async def insert_news(self, **params):
"""Inserts news for account
Accepts:
- event_type
- cid
- access_string (of buyer)
- buyer_pubkey
- buyer address
- owner address
- price
- offer type
- coin ID
Returns:
- dict with result
"""
logging.debug("\n\n [+] -- Setting news debuggin... | [
"async",
"def",
"insert_news",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"logging",
".",
"debug",
"(",
"\"\\n\\n [+] -- Setting news debugging. \"",
")",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
... | Inserts news for account
Accepts:
- event_type
- cid
- access_string (of buyer)
- buyer_pubkey
- buyer address
- owner address
- price
- offer type
- coin ID
Returns:
- dict with result | [
"Inserts",
"news",
"for",
"account",
"Accepts",
":",
"-",
"event_type",
"-",
"cid",
"-",
"access_string",
"(",
"of",
"buyer",
")",
"-",
"buyer_pubkey",
"-",
"buyer",
"address",
"-",
"owner",
"address",
"-",
"price",
"-",
"offer",
"type",
"-",
"coin",
"ID... | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L152-L253 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.insert_offer | async def insert_offer(self, **params):
"""Inserts new offer to database (related to buyers account)
Accepts:
- cid
- buyer address
- price
- access type
- transaction id
- owner public key
- owner address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message... | python | async def insert_offer(self, **params):
"""Inserts new offer to database (related to buyers account)
Accepts:
- cid
- buyer address
- price
- access type
- transaction id
- owner public key
- owner address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message... | [
"async",
"def",
"insert_offer",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"... | Inserts new offer to database (related to buyers account)
Accepts:
- cid
- buyer address
- price
- access type
- transaction id
- owner public key
- owner address
- coin ID | [
"Inserts",
"new",
"offer",
"to",
"database",
"(",
"related",
"to",
"buyers",
"account",
")",
"Accepts",
":",
"-",
"cid",
"-",
"buyer",
"address",
"-",
"price",
"-",
"access",
"type",
"-",
"transaction",
"id",
"-",
"owner",
"public",
"key",
"-",
"owner",
... | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L257-L287 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.get_offer | async def get_offer(self, **params):
"""Receives offer data if exists
Accepts:
- cid
- buyer address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields e... | python | async def get_offer(self, **params):
"""Receives offer data if exists
Accepts:
- cid
- buyer address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields e... | [
"async",
"def",
"get_offer",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if"... | Receives offer data if exists
Accepts:
- cid
- buyer address
- coin ID | [
"Receives",
"offer",
"data",
"if",
"exists",
"Accepts",
":",
"-",
"cid",
"-",
"buyer",
"address",
"-",
"coin",
"ID"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L291-L331 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.get_offers | async def get_offers(self, **params):
"""Receives all users input (by cid) or output offers
Accepts:
- public key
- cid (optional)
- coinid (optional)
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fi... | python | async def get_offers(self, **params):
"""Receives all users input (by cid) or output offers
Accepts:
- public key
- cid (optional)
- coinid (optional)
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fi... | [
"async",
"def",
"get_offers",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if... | Receives all users input (by cid) or output offers
Accepts:
- public key
- cid (optional)
- coinid (optional) | [
"Receives",
"all",
"users",
"input",
"(",
"by",
"cid",
")",
"or",
"output",
"offers",
"Accepts",
":",
"-",
"public",
"key",
"-",
"cid",
"(",
"optional",
")",
"-",
"coinid",
"(",
"optional",
")"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L335-L372 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.remove_offer | async def remove_offer(self, **params):
"""Receives offfer after have deal
Accepts:
- cid
- buyer address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fie... | python | async def remove_offer(self, **params):
"""Receives offfer after have deal
Accepts:
- cid
- buyer address
- coin ID
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fie... | [
"async",
"def",
"remove_offer",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"... | Receives offfer after have deal
Accepts:
- cid
- buyer address
- coin ID | [
"Receives",
"offfer",
"after",
"have",
"deal",
"Accepts",
":",
"-",
"cid",
"-",
"buyer",
"address",
"-",
"coin",
"ID"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L376-L414 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.update_offer | async def update_offer(self, **params):
"""Updates offer after transaction confirmation
Accepts:
- transaction id
- coinid
- confirmed (boolean flag)
"""
logging.debug("\n\n -- Update offer. ")
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return... | python | async def update_offer(self, **params):
"""Updates offer after transaction confirmation
Accepts:
- transaction id
- coinid
- confirmed (boolean flag)
"""
logging.debug("\n\n -- Update offer. ")
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return... | [
"async",
"def",
"update_offer",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"logging",
".",
"debug",
"(",
"\"\\n\\n -- Update offer. \"",
")",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params... | Updates offer after transaction confirmation
Accepts:
- transaction id
- coinid
- confirmed (boolean flag) | [
"Updates",
"offer",
"after",
"transaction",
"confirmation",
"Accepts",
":",
"-",
"transaction",
"id",
"-",
"coinid",
"-",
"confirmed",
"(",
"boolean",
"flag",
")"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L417-L457 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.mailed_confirm | async def mailed_confirm(self, **params):
"""Sends mail to user after offer receiveing
Accepts:
- cid
- buyer address
- price
- offer_type
- point
- coinid
"""
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields exists
cid = params.get("cid... | python | async def mailed_confirm(self, **params):
"""Sends mail to user after offer receiveing
Accepts:
- cid
- buyer address
- price
- offer_type
- point
- coinid
"""
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields exists
cid = params.get("cid... | [
"async",
"def",
"mailed_confirm",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"params",
":",
"return",
"{",
"\"error\"",
":",
"400",
",",
"\"reason\"",
":",
"\"Missed required fields\"",
"}",
"# Check if required fields exists",
"cid",
"=",
"p... | Sends mail to user after offer receiveing
Accepts:
- cid
- buyer address
- price
- offer_type
- point
- coinid | [
"Sends",
"mail",
"to",
"user",
"after",
"offer",
"receiveing",
"Accepts",
":",
"-",
"cid",
"-",
"buyer",
"address",
"-",
"price",
"-",
"offer_type",
"-",
"point",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L461-L530 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.get_contents | async def get_contents(self, **params):
"""Retrieves all users content
Accepts:
-public key
"""
logging.debug("[+] -- Get contents")
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params or not params.get("public_key"):
return {"error":400, "reason":"Missed requir... | python | async def get_contents(self, **params):
"""Retrieves all users content
Accepts:
-public key
"""
logging.debug("[+] -- Get contents")
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params or not params.get("public_key"):
return {"error":400, "reason":"Missed requir... | [
"async",
"def",
"get_contents",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"logging",
".",
"debug",
"(",
"\"[+] -- Get contents\"",
")",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
... | Retrieves all users content
Accepts:
-public key | [
"Retrieves",
"all",
"users",
"content",
"Accepts",
":",
"-",
"public",
"key"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L563-L589 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.set_contents | async def set_contents(self, **params):
"""Writes users content to database
Accepts:
- public key (required)
- content (required)
- description
- price
- address
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Miss... | python | async def set_contents(self, **params):
"""Writes users content to database
Accepts:
- public key (required)
- content (required)
- description
- price
- address
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Miss... | [
"async",
"def",
"set_contents",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"... | Writes users content to database
Accepts:
- public key (required)
- content (required)
- description
- price
- address | [
"Writes",
"users",
"content",
"to",
"database",
"Accepts",
":",
"-",
"public",
"key",
"(",
"required",
")",
"-",
"content",
"(",
"required",
")",
"-",
"description",
"-",
"price",
"-",
"address"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L592-L633 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.update_contents | async def update_contents(self, **params):
"""Updates users content row
Accepts:
- txid
- cid
- description
- write_price
- read_price
- confirmed
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed r... | python | async def update_contents(self, **params):
"""Updates users content row
Accepts:
- txid
- cid
- description
- write_price
- read_price
- confirmed
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed r... | [
"async",
"def",
"update_contents",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
... | Updates users content row
Accepts:
- txid
- cid
- description
- write_price
- read_price
- confirmed
- coinid | [
"Updates",
"users",
"content",
"row",
"Accepts",
":",
"-",
"txid",
"-",
"cid",
"-",
"description",
"-",
"write_price",
"-",
"read_price",
"-",
"confirmed",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L636-L681 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.set_access_string | async def set_access_string(self, **params):
"""Writes content access string to database
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
cid = int(params.get("cid", "0"))
seller_access_string = params.get("seller_access_string")
seller_pubkey = params.get("seller_pubkey")... | python | async def set_access_string(self, **params):
"""Writes content access string to database
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
cid = int(params.get("cid", "0"))
seller_access_string = params.get("seller_access_string")
seller_pubkey = params.get("seller_pubkey")... | [
"async",
"def",
"set_access_string",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")"... | Writes content access string to database | [
"Writes",
"content",
"access",
"string",
"to",
"database"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L685-L718 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.get_reviews | async def get_reviews(self, **params):
"""Receives all reviews by cid
Accepts:
- cid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
cid = params.get("cid", 0)
coinid = params.get("... | python | async def get_reviews(self, **params):
"""Receives all reviews by cid
Accepts:
- cid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
cid = params.get("cid", 0)
coinid = params.get("... | [
"async",
"def",
"get_reviews",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"i... | Receives all reviews by cid
Accepts:
- cid
- coinid | [
"Receives",
"all",
"reviews",
"by",
"cid",
"Accepts",
":",
"-",
"cid",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L723-L746 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.set_review | async def set_review(self, **params):
"""Writes review for content
Accepts:
- cid
- review
- public_key
- rating
- txid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
cid = i... | python | async def set_review(self, **params):
"""Writes review for content
Accepts:
- cid
- review
- public_key
- rating
- txid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
cid = i... | [
"async",
"def",
"set_review",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if... | Writes review for content
Accepts:
- cid
- review
- public_key
- rating
- txid
- coinid | [
"Writes",
"review",
"for",
"content",
"Accepts",
":",
"-",
"cid",
"-",
"review",
"-",
"public_key",
"-",
"rating",
"-",
"txid",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L750-L786 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.update_review | async def update_review(self, **params):
"""Update review after transaction confirmation
Accepts:
- txid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields... | python | async def update_review(self, **params):
"""Update review after transaction confirmation
Accepts:
- txid
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Check if required fields... | [
"async",
"def",
"update_review",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
... | Update review after transaction confirmation
Accepts:
- txid
- coinid | [
"Update",
"review",
"after",
"transaction",
"confirmation",
"Accepts",
":",
"-",
"txid",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L790-L826 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.write_deal | async def write_deal(self, **params):
"""Writes deal to database
Accepts:
- cid
- access_type
- buyer public key
- seller public key
- price
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed require... | python | async def write_deal(self, **params):
"""Writes deal to database
Accepts:
- cid
- access_type
- buyer public key
- seller public key
- price
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed require... | [
"async",
"def",
"write_deal",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if... | Writes deal to database
Accepts:
- cid
- access_type
- buyer public key
- seller public key
- price
- coinid | [
"Writes",
"deal",
"to",
"database",
"Accepts",
":",
"-",
"cid",
"-",
"access_type",
"-",
"buyer",
"public",
"key",
"-",
"seller",
"public",
"key",
"-",
"price",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L831-L874 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.update_description | async def update_description(self, **params):
"""Set description to unconfirmed status
after updating by user.
Accepts:
- cid
- description
- transaction id
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"... | python | async def update_description(self, **params):
"""Set description to unconfirmed status
after updating by user.
Accepts:
- cid
- description
- transaction id
- coinid
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"... | [
"async",
"def",
"update_description",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")... | Set description to unconfirmed status
after updating by user.
Accepts:
- cid
- description
- transaction id
- coinid | [
"Set",
"description",
"to",
"unconfirmed",
"status",
"after",
"updating",
"by",
"user",
".",
"Accepts",
":",
"-",
"cid",
"-",
"description",
"-",
"transaction",
"id",
"-",
"coinid"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L879-L928 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.get_deals | async def get_deals(self, **params):
"""Receives all users deals
Accepts:
- buyer public key
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
buyer = params.get("buyer")
if not buyer:
retur... | python | async def get_deals(self, **params):
"""Receives all users deals
Accepts:
- buyer public key
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
buyer = params.get("buyer")
if not buyer:
retur... | [
"async",
"def",
"get_deals",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if"... | Receives all users deals
Accepts:
- buyer public key | [
"Receives",
"all",
"users",
"deals",
"Accepts",
":",
"-",
"buyer",
"public",
"key"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L1075-L1098 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.log_source | async def log_source(self, **params):
""" Logging users request sources
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Insert new source if does not exists the one
database = client[settings.D... | python | async def log_source(self, **params):
""" Logging users request sources
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
# Insert new source if does not exists the one
database = client[settings.D... | [
"async",
"def",
"log_source",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
"if... | Logging users request sources | [
"Logging",
"users",
"request",
"sources"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L1101-L1118 |
Robin8Put/pmes | storage/rpc_methods.py | StorageTable.log_transaction | async def log_transaction(self, **params):
"""Writing transaction to database
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
coinid = params.get("coinid")
if not coinid in ["QTUM", "PUT"]:
re... | python | async def log_transaction(self, **params):
"""Writing transaction to database
"""
if params.get("message"):
params = json.loads(params.get("message", "{}"))
if not params:
return {"error":400, "reason":"Missed required fields"}
coinid = params.get("coinid")
if not coinid in ["QTUM", "PUT"]:
re... | [
"async",
"def",
"log_transaction",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"params",
".",
"get",
"(",
"\"message\"",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"params",
".",
"get",
"(",
"\"message\"",
",",
"\"{}\"",
")",
")",
... | Writing transaction to database | [
"Writing",
"transaction",
"to",
"database"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L1122-L1145 |
takluyver/astcheck | astcheck.py | _check_node_list | def _check_node_list(path, sample, template, start_enumerate=0):
"""Check a list of nodes, e.g. function body"""
if len(sample) != len(template):
raise ASTNodeListMismatch(path, sample, template)
for i, (sample_node, template_node) in enumerate(zip(sample, template), start=start_enumerate):
... | python | def _check_node_list(path, sample, template, start_enumerate=0):
"""Check a list of nodes, e.g. function body"""
if len(sample) != len(template):
raise ASTNodeListMismatch(path, sample, template)
for i, (sample_node, template_node) in enumerate(zip(sample, template), start=start_enumerate):
... | [
"def",
"_check_node_list",
"(",
"path",
",",
"sample",
",",
"template",
",",
"start_enumerate",
"=",
"0",
")",
":",
"if",
"len",
"(",
"sample",
")",
"!=",
"len",
"(",
"template",
")",
":",
"raise",
"ASTNodeListMismatch",
"(",
"path",
",",
"sample",
",",
... | Check a list of nodes, e.g. function body | [
"Check",
"a",
"list",
"of",
"nodes",
"e",
".",
"g",
".",
"function",
"body"
] | train | https://github.com/takluyver/astcheck/blob/8469da04debf4e2a4535c666929a134d53b7ac8a/astcheck.py#L147-L157 |
takluyver/astcheck | astcheck.py | assert_ast_like | def assert_ast_like(sample, template, _path=None):
"""Check that the sample AST matches the template.
Raises a suitable subclass of :exc:`ASTMismatch` if a difference is detected.
The ``_path`` parameter is used for recursion; you shouldn't normally pass it.
"""
if _path is None:
_... | python | def assert_ast_like(sample, template, _path=None):
"""Check that the sample AST matches the template.
Raises a suitable subclass of :exc:`ASTMismatch` if a difference is detected.
The ``_path`` parameter is used for recursion; you shouldn't normally pass it.
"""
if _path is None:
_... | [
"def",
"assert_ast_like",
"(",
"sample",
",",
"template",
",",
"_path",
"=",
"None",
")",
":",
"if",
"_path",
"is",
"None",
":",
"_path",
"=",
"[",
"'tree'",
"]",
"if",
"callable",
"(",
"template",
")",
":",
"# Checker function at the top level",
"return",
... | Check that the sample AST matches the template.
Raises a suitable subclass of :exc:`ASTMismatch` if a difference is detected.
The ``_path`` parameter is used for recursion; you shouldn't normally pass it. | [
"Check",
"that",
"the",
"sample",
"AST",
"matches",
"the",
"template",
".",
"Raises",
"a",
"suitable",
"subclass",
"of",
":",
"exc",
":",
"ASTMismatch",
"if",
"a",
"difference",
"is",
"detected",
".",
"The",
"_path",
"parameter",
"is",
"used",
"for",
"recu... | train | https://github.com/takluyver/astcheck/blob/8469da04debf4e2a4535c666929a134d53b7ac8a/astcheck.py#L159-L199 |
Robin8Put/pmes | pdms/views.py | AllContentHandler.get | async def get(self):
"""
Accepts:
without parameters
Returns:
list of dictionaries with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "cid" - int
- "owneraddr" - str
- "coinid" - str
Verified: False
"""
logging.debug("\n\n All Content ... | python | async def get(self):
"""
Accepts:
without parameters
Returns:
list of dictionaries with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "cid" - int
- "owneraddr" - str
- "coinid" - str
Verified: False
"""
logging.debug("\n\n All Content ... | [
"async",
"def",
"get",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"\\n\\n All Content debugging --- \"",
")",
"page",
"=",
"self",
".",
"get_query_argument",
"(",
"\"page\"",
",",
"1",
")",
"contents",
"=",
"[",
"]",
"coinids",
"=",
"list",
"("... | Accepts:
without parameters
Returns:
list of dictionaries with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "cid" - int
- "owneraddr" - str
- "coinid" - str
Verified: False | [
"Accepts",
":",
"without",
"parameters"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L40-L98 |
Robin8Put/pmes | pdms/views.py | ContentHandler.get | async def get(self, cid, coinid):
"""Receives content by content id and coin id
Accepts:
Query string arguments:
- "cid" - int
- "coinid" - str
Returns:
return dict with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "content" - str
- "ci... | python | async def get(self, cid, coinid):
"""Receives content by content id and coin id
Accepts:
Query string arguments:
- "cid" - int
- "coinid" - str
Returns:
return dict with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "content" - str
- "ci... | [
"async",
"def",
"get",
"(",
"self",
",",
"cid",
",",
"coinid",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"message",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"get_argument",
"(",
"\... | Receives content by content id and coin id
Accepts:
Query string arguments:
- "cid" - int
- "coinid" - str
Returns:
return dict with following fields:
- "description" - str
- "read_access" - int
- "write_access" - int
- "content" - str
- "cid" - int
- "owneraddr" - str
- ... | [
"Receives",
"content",
"by",
"content",
"id",
"and",
"coin",
"id"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L125-L193 |
Robin8Put/pmes | pdms/views.py | ContentHandler.post | async def post(self, public_key, coinid):
"""Writes content to blockchain
Accepts:
Query string args:
- "public_key" - str
- "coin id" - str
Request body arguments:
- message (signed dict as json):
- "cus" (content) - str
- "description" - str
- "read_access" (price for read access... | python | async def post(self, public_key, coinid):
"""Writes content to blockchain
Accepts:
Query string args:
- "public_key" - str
- "coin id" - str
Request body arguments:
- message (signed dict as json):
- "cus" (content) - str
- "description" - str
- "read_access" (price for read access... | [
"async",
"def",
"post",
"(",
"self",
",",
"public_key",
",",
"coinid",
")",
":",
"logging",
".",
"debug",
"(",
"\"[+] -- Post content debugging. \"",
")",
"#if settings.SIGNATURE_VERIFICATION:",
"#\tsuper().verify()",
"# Define genesis variables",
"if",
"coinid",
"in",
... | Writes content to blockchain
Accepts:
Query string args:
- "public_key" - str
- "coin id" - str
Request body arguments:
- message (signed dict as json):
- "cus" (content) - str
- "description" - str
- "read_access" (price for read access) - int
- "write_access" (price for write ... | [
"Writes",
"content",
"to",
"blockchain"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L196-L302 |
Robin8Put/pmes | pdms/views.py | DescriptionHandler.put | async def put(self, cid):
"""Update description for content
Accepts:
Query string args:
- "cid" - int
Request body parameters:
- message (signed dict):
- "description" - str
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "descrip... | python | async def put(self, cid):
"""Update description for content
Accepts:
Query string args:
- "cid" - int
Request body parameters:
- message (signed dict):
- "description" - str
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "descrip... | [
"async",
"def",
"put",
"(",
"self",
",",
"cid",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"try",
":",
"body",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body",
")"... | Update description for content
Accepts:
Query string args:
- "cid" - int
Request body parameters:
- message (signed dict):
- "description" - str
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "description" - str
- "content" - s... | [
"Update",
"description",
"for",
"content"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L329-L425 |
Robin8Put/pmes | pdms/views.py | PriceHandler.put | async def put(self, cid):
"""Update price of current content
Accepts:
Query string args:
- "cid" - int
Request body params:
- "access_type" - str
- "price" - int
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "description" - str
... | python | async def put(self, cid):
"""Update price of current content
Accepts:
Query string args:
- "cid" - int
Request body params:
- "access_type" - str
- "price" - int
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "description" - str
... | [
"async",
"def",
"put",
"(",
"self",
",",
"cid",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"try",
":",
"body",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body",
")"... | Update price of current content
Accepts:
Query string args:
- "cid" - int
Request body params:
- "access_type" - str
- "price" - int
- "coinid" - str
Returns:
dict with following fields:
- "confirmed": None
- "txid" - str
- "description" - str
- "content" - str
- "rea... | [
"Update",
"price",
"of",
"current",
"content"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L449-L545 |
Robin8Put/pmes | pdms/views.py | WriteAccessOfferHandler.put | async def put(self, public_key):
"""Reject offer and unfreeze balance
Accepts:
- cid
- buyer public key
- buyer address
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
# Check if message contains required data
try:
body = json.loads(self.request.body)
except:
self.set_status... | python | async def put(self, public_key):
"""Reject offer and unfreeze balance
Accepts:
- cid
- buyer public key
- buyer address
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
# Check if message contains required data
try:
body = json.loads(self.request.body)
except:
self.set_status... | [
"async",
"def",
"put",
"(",
"self",
",",
"public_key",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"# Check if message contains required data",
"try",
":",
"body",
"=",
"json",
".",
"loads",
"("... | Reject offer and unfreeze balance
Accepts:
- cid
- buyer public key
- buyer address | [
"Reject",
"offer",
"and",
"unfreeze",
"balance",
"Accepts",
":",
"-",
"cid",
"-",
"buyer",
"public",
"key",
"-",
"buyer",
"address"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L746-L832 |
Robin8Put/pmes | pdms/views.py | ReadAccessOfferHandler.post | async def post(self, public_key=None):
"""Creates new offer
Accepts:
- buyer public key
- cid
- buyer access string
Returns:
- offer parameters as dictionary
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
try:
body = json.loads(self.request.body)
except:
self.set_status(40... | python | async def post(self, public_key=None):
"""Creates new offer
Accepts:
- buyer public key
- cid
- buyer access string
Returns:
- offer parameters as dictionary
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
try:
body = json.loads(self.request.body)
except:
self.set_status(40... | [
"async",
"def",
"post",
"(",
"self",
",",
"public_key",
"=",
"None",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"try",
":",
"body",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"request... | Creates new offer
Accepts:
- buyer public key
- cid
- buyer access string
Returns:
- offer parameters as dictionary | [
"Creates",
"new",
"offer"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L853-L982 |
Robin8Put/pmes | pdms/views.py | DealHandler.post | async def post(self, public_key):
"""Accepting offer by buyer
Function accepts:
- cid
- buyer access string
- buyer public key
- seller public key
"""
logging.debug("[+] -- Deal debugging. ")
if settings.SIGNATURE_VERIFICATION:
super().verify()
# Check if message contains required data
tr... | python | async def post(self, public_key):
"""Accepting offer by buyer
Function accepts:
- cid
- buyer access string
- buyer public key
- seller public key
"""
logging.debug("[+] -- Deal debugging. ")
if settings.SIGNATURE_VERIFICATION:
super().verify()
# Check if message contains required data
tr... | [
"async",
"def",
"post",
"(",
"self",
",",
"public_key",
")",
":",
"logging",
".",
"debug",
"(",
"\"[+] -- Deal debugging. \"",
")",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"# Check if message contains req... | Accepting offer by buyer
Function accepts:
- cid
- buyer access string
- buyer public key
- seller public key | [
"Accepting",
"offer",
"by",
"buyer"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L1093-L1290 |
Robin8Put/pmes | pdms/views.py | ReviewsHandler.get | async def get(self, cid, coinid):
"""Receives all contents reviews
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
if coinid in settings.bridges.keys():
self.account.blockchain.setendpoint(settings.bridges[coinid])
reviews = await self.account.blockchain.getreviews(cid=cid)
if isinstance(r... | python | async def get(self, cid, coinid):
"""Receives all contents reviews
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
if coinid in settings.bridges.keys():
self.account.blockchain.setendpoint(settings.bridges[coinid])
reviews = await self.account.blockchain.getreviews(cid=cid)
if isinstance(r... | [
"async",
"def",
"get",
"(",
"self",
",",
"cid",
",",
"coinid",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"if",
"coinid",
"in",
"settings",
".",
"bridges",
".",
"keys",
"(",
")",
":",
... | Receives all contents reviews | [
"Receives",
"all",
"contents",
"reviews"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L1310-L1338 |
Robin8Put/pmes | pdms/views.py | ReviewHandler.post | async def post(self, public_key):
"""Writes contents review
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
try:
body = json.loads(self.request.body)
except:
self.set_status(400)
self.write({"error":400, "reason":"Unexpected data format. JSON required"})
raise tornado.web.Finish
... | python | async def post(self, public_key):
"""Writes contents review
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
try:
body = json.loads(self.request.body)
except:
self.set_status(400)
self.write({"error":400, "reason":"Unexpected data format. JSON required"})
raise tornado.web.Finish
... | [
"async",
"def",
"post",
"(",
"self",
",",
"public_key",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"try",
":",
"body",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body... | Writes contents review | [
"Writes",
"contents",
"review"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/pdms/views.py#L1359-L1399 |
Robin8Put/pmes | mail/email_new.py | sendmail | def sendmail(array):
"""function for read data in db and send mail
"""
username = 'root@robin8.io'
FROM = username
TO = [array["to"]]
SUBJECT = array["subject"]
# check on correct data in optional
if type(array["optional"]) == str and array["optional"]:
TEXT = array["optional"]
... | python | def sendmail(array):
"""function for read data in db and send mail
"""
username = 'root@robin8.io'
FROM = username
TO = [array["to"]]
SUBJECT = array["subject"]
# check on correct data in optional
if type(array["optional"]) == str and array["optional"]:
TEXT = array["optional"]
... | [
"def",
"sendmail",
"(",
"array",
")",
":",
"username",
"=",
"'root@robin8.io'",
"FROM",
"=",
"username",
"TO",
"=",
"[",
"array",
"[",
"\"to\"",
"]",
"]",
"SUBJECT",
"=",
"array",
"[",
"\"subject\"",
"]",
"# check on correct data in optional",
"if",
"type",
... | function for read data in db and send mail | [
"function",
"for",
"read",
"data",
"in",
"db",
"and",
"send",
"mail"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/mail/email_new.py#L16-L43 |
Robin8Put/pmes | ams/views.py | AMSHandler.post | async def post(self):
"""Creates new account
Accepts:
- message (signed dict):
- "device_id" - str
- "email" - str
- "phone" - str
- "public_key" - str
- "signature" - str
Returns:
dictionary with following fields:
- "device_id" - str
- "phone" - str
- "public_key" - str
... | python | async def post(self):
"""Creates new account
Accepts:
- message (signed dict):
- "device_id" - str
- "email" - str
- "phone" - str
- "public_key" - str
- "signature" - str
Returns:
dictionary with following fields:
- "device_id" - str
- "phone" - str
- "public_key" - str
... | [
"async",
"def",
"post",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"\\n\\n[+] -- Account debugging. \"",
")",
"# Include signature verification mechanism",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
... | Creates new account
Accepts:
- message (signed dict):
- "device_id" - str
- "email" - str
- "phone" - str
- "public_key" - str
- "signature" - str
Returns:
dictionary with following fields:
- "device_id" - str
- "phone" - str
- "public_key" - str
- "count" - int ( wallets ... | [
"Creates",
"new",
"account"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L96-L166 |
Robin8Put/pmes | ams/views.py | AccountHandler.get | async def get(self, public_key):
""" Receive account data
Accepts:
Query string:
- "public_key" - str
Query string params:
- message ( signed dictionary ):
- "timestamp" - str
Returns:
- "device_id" - str
- "phone" - str
- "public_key" - str
- "count" - int ( wallets amount ... | python | async def get(self, public_key):
""" Receive account data
Accepts:
Query string:
- "public_key" - str
Query string params:
- message ( signed dictionary ):
- "timestamp" - str
Returns:
- "device_id" - str
- "phone" - str
- "public_key" - str
- "count" - int ( wallets amount ... | [
"async",
"def",
"get",
"(",
"self",
",",
"public_key",
")",
":",
"# Signature verification",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"# Get users request source",
"compiler",
"=",
"re",
".",
"compile",
... | Receive account data
Accepts:
Query string:
- "public_key" - str
Query string params:
- message ( signed dictionary ):
- "timestamp" - str
Returns:
- "device_id" - str
- "phone" - str
- "public_key" - str
- "count" - int ( wallets amount )
- "level" - int (2 by default)
... | [
"Receive",
"account",
"data"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L193-L254 |
Robin8Put/pmes | ams/views.py | NewsHandler.get | async def get(self, public_key):
"""Receives public key, looking up document at storage,
sends document id to the balance server
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
response = await self.account.getnews(public_key=public_key)
# If we`ve got a empty or list with news
if isinstan... | python | async def get(self, public_key):
"""Receives public key, looking up document at storage,
sends document id to the balance server
"""
if settings.SIGNATURE_VERIFICATION:
super().verify()
response = await self.account.getnews(public_key=public_key)
# If we`ve got a empty or list with news
if isinstan... | [
"async",
"def",
"get",
"(",
"self",
",",
"public_key",
")",
":",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"response",
"=",
"await",
"self",
".",
"account",
".",
"getnews",
"(",
"public_key",
"=",
... | Receives public key, looking up document at storage,
sends document id to the balance server | [
"Receives",
"public",
"key",
"looking",
"up",
"document",
"at",
"storage",
"sends",
"document",
"id",
"to",
"the",
"balance",
"server"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L276-L299 |
Robin8Put/pmes | ams/views.py | OutputOffersHandler.get | async def get(self, public_key):
"""Retrieves all users input and output offers
Accepts:
- public key
"""
# Sign-verifying functional
#super().verify()
# Get coinid
account = await self.account.getaccountdata(public_key=public_key)
if "error" in account.keys():
self.set_status(account["error"])
... | python | async def get(self, public_key):
"""Retrieves all users input and output offers
Accepts:
- public key
"""
# Sign-verifying functional
#super().verify()
# Get coinid
account = await self.account.getaccountdata(public_key=public_key)
if "error" in account.keys():
self.set_status(account["error"])
... | [
"async",
"def",
"get",
"(",
"self",
",",
"public_key",
")",
":",
"# Sign-verifying functional",
"#super().verify()",
"# Get coinid",
"account",
"=",
"await",
"self",
".",
"account",
".",
"getaccountdata",
"(",
"public_key",
"=",
"public_key",
")",
"if",
"\"error\"... | Retrieves all users input and output offers
Accepts:
- public key | [
"Retrieves",
"all",
"users",
"input",
"and",
"output",
"offers",
"Accepts",
":",
"-",
"public",
"key"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L343-L382 |
Robin8Put/pmes | ams/views.py | InputOffersHandler.get | async def get(self, public_key):
"""Retrieves all users input and output offers
Accepts:
- public key
"""
# Sign-verifying functional
if settings.SIGNATURE_VERIFICATION:
super().verify()
logging.debug("\n\n -- Input offers debugging")
message = json.loads(self.get_argument("message"))
cid = mess... | python | async def get(self, public_key):
"""Retrieves all users input and output offers
Accepts:
- public key
"""
# Sign-verifying functional
if settings.SIGNATURE_VERIFICATION:
super().verify()
logging.debug("\n\n -- Input offers debugging")
message = json.loads(self.get_argument("message"))
cid = mess... | [
"async",
"def",
"get",
"(",
"self",
",",
"public_key",
")",
":",
"# Sign-verifying functional",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"logging",
".",
"debug",
"(",
"\"\\n\\n -- Input offers debugging\"",... | Retrieves all users input and output offers
Accepts:
- public key | [
"Retrieves",
"all",
"users",
"input",
"and",
"output",
"offers",
"Accepts",
":",
"-",
"public",
"key"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L402-L446 |
Robin8Put/pmes | ams/views.py | ContentsHandler.get | async def get(self, public_key):
"""Retrieves all users contents
Accepts:
- public key
"""
# Sign-verifying functional
if settings.SIGNATURE_VERIFICATION:
super().verify()
page = self.get_query_argument("page", 1)
cids = await self.account.getuserscontent(public_key=public_key)
logging.debug("\n... | python | async def get(self, public_key):
"""Retrieves all users contents
Accepts:
- public key
"""
# Sign-verifying functional
if settings.SIGNATURE_VERIFICATION:
super().verify()
page = self.get_query_argument("page", 1)
cids = await self.account.getuserscontent(public_key=public_key)
logging.debug("\n... | [
"async",
"def",
"get",
"(",
"self",
",",
"public_key",
")",
":",
"# Sign-verifying functional",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"page",
"=",
"self",
".",
"get_query_argument",
"(",
"\"page\"",
... | Retrieves all users contents
Accepts:
- public key | [
"Retrieves",
"all",
"users",
"contents",
"Accepts",
":",
"-",
"public",
"key"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L465-L529 |
Robin8Put/pmes | ams/views.py | WithdrawHandler.post | async def post(self):
"""
Funds from account to given address.
1. Verify signature
2. Freeze senders amount.
3. Request to withdraw server.
4. Call balances sub_frozen method.
Accepts:
- message [dict]:
- coinid [string]
- amount [integer]
- address [string]
- timestamp [float]
- r... | python | async def post(self):
"""
Funds from account to given address.
1. Verify signature
2. Freeze senders amount.
3. Request to withdraw server.
4. Call balances sub_frozen method.
Accepts:
- message [dict]:
- coinid [string]
- amount [integer]
- address [string]
- timestamp [float]
- r... | [
"async",
"def",
"post",
"(",
"self",
")",
":",
"# Sign-verifying functional",
"if",
"settings",
".",
"SIGNATURE_VERIFICATION",
":",
"super",
"(",
")",
".",
"verify",
"(",
")",
"logging",
".",
"debug",
"(",
"\"\\n\\n[+] -- Withdraw debugging\"",
")",
"# Get data fr... | Funds from account to given address.
1. Verify signature
2. Freeze senders amount.
3. Request to withdraw server.
4. Call balances sub_frozen method.
Accepts:
- message [dict]:
- coinid [string]
- amount [integer]
- address [string]
- timestamp [float]
- recvWindow [float]
- public_... | [
"Funds",
"from",
"account",
"to",
"given",
"address",
".",
"1",
".",
"Verify",
"signature",
"2",
".",
"Freeze",
"senders",
"amount",
".",
"3",
".",
"Request",
"to",
"withdraw",
"server",
".",
"4",
".",
"Call",
"balances",
"sub_frozen",
"method",
"."
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/views.py#L592-L718 |
Robin8Put/pmes | ams/utils/billing.py | upload_content_fee | async def upload_content_fee(*args, **kwargs):
"""Estimating uploading content
"""
cus = kwargs.get("cus")
owneraddr = kwargs.get("owneraddr")
description = kwargs.get("description")
coinid = kwargs.get("coinid", "PUT")
#Check if required fields exists
if not all([cus, owneraddr, description]):
return {"erro... | python | async def upload_content_fee(*args, **kwargs):
"""Estimating uploading content
"""
cus = kwargs.get("cus")
owneraddr = kwargs.get("owneraddr")
description = kwargs.get("description")
coinid = kwargs.get("coinid", "PUT")
#Check if required fields exists
if not all([cus, owneraddr, description]):
return {"erro... | [
"async",
"def",
"upload_content_fee",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cus",
"=",
"kwargs",
".",
"get",
"(",
"\"cus\"",
")",
"owneraddr",
"=",
"kwargs",
".",
"get",
"(",
"\"owneraddr\"",
")",
"description",
"=",
"kwargs",
".",
"get... | Estimating uploading content | [
"Estimating",
"uploading",
"content"
] | train | https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/ams/utils/billing.py#L23-L64 |
galaxyproject/gravity | gravity/process_manager/supervisor_manager.py | SupervisorProcessManager.__get_supervisor | def __get_supervisor(self):
""" Return the supervisor proxy object
Should probably use this more rather than supervisorctl directly
"""
options = supervisorctl.ClientOptions()
options.realize(args=['-c', self.supervisord_conf_path])
return supervisorctl.Controller(option... | python | def __get_supervisor(self):
""" Return the supervisor proxy object
Should probably use this more rather than supervisorctl directly
"""
options = supervisorctl.ClientOptions()
options.realize(args=['-c', self.supervisord_conf_path])
return supervisorctl.Controller(option... | [
"def",
"__get_supervisor",
"(",
"self",
")",
":",
"options",
"=",
"supervisorctl",
".",
"ClientOptions",
"(",
")",
"options",
".",
"realize",
"(",
"args",
"=",
"[",
"'-c'",
",",
"self",
".",
"supervisord_conf_path",
"]",
")",
"return",
"supervisorctl",
".",
... | Return the supervisor proxy object
Should probably use this more rather than supervisorctl directly | [
"Return",
"the",
"supervisor",
"proxy",
"object"
] | train | https://github.com/galaxyproject/gravity/blob/2f792497fc60874f881c9ef74a5905a286a9ce3e/gravity/process_manager/supervisor_manager.py#L148-L155 |
galaxyproject/gravity | gravity/process_manager/supervisor_manager.py | SupervisorProcessManager.update | def update(self):
""" Add newly defined servers, remove any that are no longer present
"""
configs, meta_changes = self.config_manager.determine_config_changes()
self._process_config_changes(configs, meta_changes)
self.supervisorctl('update') | python | def update(self):
""" Add newly defined servers, remove any that are no longer present
"""
configs, meta_changes = self.config_manager.determine_config_changes()
self._process_config_changes(configs, meta_changes)
self.supervisorctl('update') | [
"def",
"update",
"(",
"self",
")",
":",
"configs",
",",
"meta_changes",
"=",
"self",
".",
"config_manager",
".",
"determine_config_changes",
"(",
")",
"self",
".",
"_process_config_changes",
"(",
"configs",
",",
"meta_changes",
")",
"self",
".",
"supervisorctl",... | Add newly defined servers, remove any that are no longer present | [
"Add",
"newly",
"defined",
"servers",
"remove",
"any",
"that",
"are",
"no",
"longer",
"present"
] | train | https://github.com/galaxyproject/gravity/blob/2f792497fc60874f881c9ef74a5905a286a9ce3e/gravity/process_manager/supervisor_manager.py#L364-L369 |
SiLab-Bonn/online_monitor | online_monitor/receiver/receiver.py | DataWorker.receive_data | def receive_data(self): # pragma: no cover; no covered since qt event loop
''' Infinite loop via QObject.moveToThread(), does not block event loop
'''
while(not self._stop_readout.wait(0.01)): # use wait(), do not block
if self._send_data:
if self.socket_type != zmq... | python | def receive_data(self): # pragma: no cover; no covered since qt event loop
''' Infinite loop via QObject.moveToThread(), does not block event loop
'''
while(not self._stop_readout.wait(0.01)): # use wait(), do not block
if self._send_data:
if self.socket_type != zmq... | [
"def",
"receive_data",
"(",
"self",
")",
":",
"# pragma: no cover; no covered since qt event loop",
"while",
"(",
"not",
"self",
".",
"_stop_readout",
".",
"wait",
"(",
"0.01",
")",
")",
":",
"# use wait(), do not block",
"if",
"self",
".",
"_send_data",
":",
"if"... | Infinite loop via QObject.moveToThread(), does not block event loop | [
"Infinite",
"loop",
"via",
"QObject",
".",
"moveToThread",
"()",
"does",
"not",
"block",
"event",
"loop"
] | train | https://github.com/SiLab-Bonn/online_monitor/blob/113c7d33e9ea4bc18520cefa329462faa406cc08/online_monitor/receiver/receiver.py#L30-L47 |
mayfield/syndicate | syndicate/data.py | NormalJSONDecoder.parse_object | def parse_object(self, data):
""" Look for datetime looking strings. """
for key, value in data.items():
if isinstance(value, (str, type(u''))) and \
self.strict_iso_match.match(value):
data[key] = dateutil.parser.parse(value)
return data | python | def parse_object(self, data):
""" Look for datetime looking strings. """
for key, value in data.items():
if isinstance(value, (str, type(u''))) and \
self.strict_iso_match.match(value):
data[key] = dateutil.parser.parse(value)
return data | [
"def",
"parse_object",
"(",
"self",
",",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"type",
"(",
"u''",
")",
")",
")",
"and",
"self",
".",
"st... | Look for datetime looking strings. | [
"Look",
"for",
"datetime",
"looking",
"strings",
"."
] | train | https://github.com/mayfield/syndicate/blob/917af976dacb7377bdf0cb616f47e0df5afaff1a/syndicate/data.py#L40-L46 |
transmogrifier/pidigits | pidigits/pidigits_lambert.py | getPiLambert | def getPiLambert(n):
"""Returns a list containing first n digits of Pi
"""
mypi = piGenLambert()
result = []
if n > 0:
result += [next(mypi) for i in range(n)]
mypi.close()
return result | python | def getPiLambert(n):
"""Returns a list containing first n digits of Pi
"""
mypi = piGenLambert()
result = []
if n > 0:
result += [next(mypi) for i in range(n)]
mypi.close()
return result | [
"def",
"getPiLambert",
"(",
"n",
")",
":",
"mypi",
"=",
"piGenLambert",
"(",
")",
"result",
"=",
"[",
"]",
"if",
"n",
">",
"0",
":",
"result",
"+=",
"[",
"next",
"(",
"mypi",
")",
"for",
"i",
"in",
"range",
"(",
"n",
")",
"]",
"mypi",
".",
"c... | Returns a list containing first n digits of Pi | [
"Returns",
"a",
"list",
"containing",
"first",
"n",
"digits",
"of",
"Pi"
] | train | https://github.com/transmogrifier/pidigits/blob/b12081126a76d30fb69839aa586420c5bb04feb8/pidigits/pidigits_lambert.py#L74-L82 |
Photonios/pyasar | asar/archive.py | AsarArchive.extract | def extract(self, destination):
"""Extracts the contents of the archive to the specifed directory.
Args:
destination (str):
Path to an empty directory to extract the files to.
"""
if os.path.exists(destination):
raise OSError(20, 'Destination exi... | python | def extract(self, destination):
"""Extracts the contents of the archive to the specifed directory.
Args:
destination (str):
Path to an empty directory to extract the files to.
"""
if os.path.exists(destination):
raise OSError(20, 'Destination exi... | [
"def",
"extract",
"(",
"self",
",",
"destination",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"destination",
")",
":",
"raise",
"OSError",
"(",
"20",
",",
"'Destination exists'",
",",
"destination",
")",
"self",
".",
"__extract_directory",
"(",... | Extracts the contents of the archive to the specifed directory.
Args:
destination (str):
Path to an empty directory to extract the files to. | [
"Extracts",
"the",
"contents",
"of",
"the",
"archive",
"to",
"the",
"specifed",
"directory",
"."
] | train | https://github.com/Photonios/pyasar/blob/b723e1c2a642e98dc1944534f39be85fa8547902/asar/archive.py#L36-L51 |
Photonios/pyasar | asar/archive.py | AsarArchive.__extract_directory | def __extract_directory(self, path, files, destination):
"""Extracts a single directory to the specified directory on disk.
Args:
path (str):
Relative (to the root of the archive) path of the directory
to extract.
files (dict):
A ... | python | def __extract_directory(self, path, files, destination):
"""Extracts a single directory to the specified directory on disk.
Args:
path (str):
Relative (to the root of the archive) path of the directory
to extract.
files (dict):
A ... | [
"def",
"__extract_directory",
"(",
"self",
",",
"path",
",",
"files",
",",
"destination",
")",
":",
"# assures the destination directory exists",
"destination_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"destination",
",",
"path",
")",
"if",
"not",
"os",
... | Extracts a single directory to the specified directory on disk.
Args:
path (str):
Relative (to the root of the archive) path of the directory
to extract.
files (dict):
A dictionary of files from a *.asar file header.
destinat... | [
"Extracts",
"a",
"single",
"directory",
"to",
"the",
"specified",
"directory",
"on",
"disk",
"."
] | train | https://github.com/Photonios/pyasar/blob/b723e1c2a642e98dc1944534f39be85fa8547902/asar/archive.py#L53-L87 |
Photonios/pyasar | asar/archive.py | AsarArchive.__extract_file | def __extract_file(self, path, fileinfo, destination):
"""Extracts the specified file to the specified destination.
Args:
path (str):
Relative (to the root of the archive) path of the
file to extract.
fileinfo (dict):
Dictionary c... | python | def __extract_file(self, path, fileinfo, destination):
"""Extracts the specified file to the specified destination.
Args:
path (str):
Relative (to the root of the archive) path of the
file to extract.
fileinfo (dict):
Dictionary c... | [
"def",
"__extract_file",
"(",
"self",
",",
"path",
",",
"fileinfo",
",",
"destination",
")",
":",
"if",
"'offset'",
"not",
"in",
"fileinfo",
":",
"self",
".",
"__copy_extracted",
"(",
"path",
",",
"destination",
")",
"return",
"self",
".",
"asarfile",
".",... | Extracts the specified file to the specified destination.
Args:
path (str):
Relative (to the root of the archive) path of the
file to extract.
fileinfo (dict):
Dictionary containing the offset and size of the file
(Extract... | [
"Extracts",
"the",
"specified",
"file",
"to",
"the",
"specified",
"destination",
"."
] | train | https://github.com/Photonios/pyasar/blob/b723e1c2a642e98dc1944534f39be85fa8547902/asar/archive.py#L89-L123 |
Photonios/pyasar | asar/archive.py | AsarArchive.__copy_extracted | def __copy_extracted(self, path, destination):
"""Copies a file that was already extracted to the destination directory.
Args:
path (str):
Relative (to the root of the archive) of the file to copy.
destination (str):
Directory to extract the arch... | python | def __copy_extracted(self, path, destination):
"""Copies a file that was already extracted to the destination directory.
Args:
path (str):
Relative (to the root of the archive) of the file to copy.
destination (str):
Directory to extract the arch... | [
"def",
"__copy_extracted",
"(",
"self",
",",
"path",
",",
"destination",
")",
":",
"unpacked_dir",
"=",
"self",
".",
"filename",
"+",
"'.unpacked'",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"unpacked_dir",
")",
":",
"LOGGER",
".",
"warn",
"(",
... | Copies a file that was already extracted to the destination directory.
Args:
path (str):
Relative (to the root of the archive) of the file to copy.
destination (str):
Directory to extract the archive to. | [
"Copies",
"a",
"file",
"that",
"was",
"already",
"extracted",
"to",
"the",
"destination",
"directory",
"."
] | train | https://github.com/Photonios/pyasar/blob/b723e1c2a642e98dc1944534f39be85fa8547902/asar/archive.py#L125-L156 |
Photonios/pyasar | asar/archive.py | AsarArchive.open | def open(cls, filename):
"""Opens a *.asar file and constructs a new :see AsarArchive instance.
Args:
filename (str):
Path to the *.asar file to open for reading.
Returns (AsarArchive):
An insance of of the :AsarArchive class or None if reading failed.
... | python | def open(cls, filename):
"""Opens a *.asar file and constructs a new :see AsarArchive instance.
Args:
filename (str):
Path to the *.asar file to open for reading.
Returns (AsarArchive):
An insance of of the :AsarArchive class or None if reading failed.
... | [
"def",
"open",
"(",
"cls",
",",
"filename",
")",
":",
"asarfile",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"# uses google's pickle format, which prefixes each field",
"# with its total length, the first field is a 32-bit unsigned",
"# integer, thus 4 bytes, we know that, s... | Opens a *.asar file and constructs a new :see AsarArchive instance.
Args:
filename (str):
Path to the *.asar file to open for reading.
Returns (AsarArchive):
An insance of of the :AsarArchive class or None if reading failed. | [
"Opens",
"a",
"*",
".",
"asar",
"file",
"and",
"constructs",
"a",
"new",
":",
"see",
"AsarArchive",
"instance",
"."
] | train | https://github.com/Photonios/pyasar/blob/b723e1c2a642e98dc1944534f39be85fa8547902/asar/archive.py#L188-L220 |
jsoa/django-formfield | formfield/widgets.py | FormFieldWidget.value_from_datadict | def value_from_datadict(self, data, files, name):
"""Ensure the payload is a list of values. In the case of a sub
form, we need to ensure the data is returned as a list and not a
dictionary.
When a dict is found in the given data, we need to ensure the data
is converted to a lis... | python | def value_from_datadict(self, data, files, name):
"""Ensure the payload is a list of values. In the case of a sub
form, we need to ensure the data is returned as a list and not a
dictionary.
When a dict is found in the given data, we need to ensure the data
is converted to a lis... | [
"def",
"value_from_datadict",
"(",
"self",
",",
"data",
",",
"files",
",",
"name",
")",
":",
"if",
"name",
"in",
"data",
":",
"payload",
"=",
"data",
".",
"get",
"(",
"name",
")",
"if",
"isinstance",
"(",
"payload",
",",
"(",
"dict",
",",
")",
")",... | Ensure the payload is a list of values. In the case of a sub
form, we need to ensure the data is returned as a list and not a
dictionary.
When a dict is found in the given data, we need to ensure the data
is converted to a list perseving the field order. | [
"Ensure",
"the",
"payload",
"is",
"a",
"list",
"of",
"values",
".",
"In",
"the",
"case",
"of",
"a",
"sub",
"form",
"we",
"need",
"to",
"ensure",
"the",
"data",
"is",
"returned",
"as",
"a",
"list",
"and",
"not",
"a",
"dictionary",
"."
] | train | https://github.com/jsoa/django-formfield/blob/7fbe8e9aa3e587588a8ed80063e4692e7e0608fe/formfield/widgets.py#L17-L32 |
jsoa/django-formfield | formfield/widgets.py | FormFieldWidget.decompress | def decompress(self, value):
"""
Retreieve each field value or provide the initial values
"""
if value:
return [value.get(field.name, None) for field in self.fields]
return [field.field.initial for field in self.fields] | python | def decompress(self, value):
"""
Retreieve each field value or provide the initial values
"""
if value:
return [value.get(field.name, None) for field in self.fields]
return [field.field.initial for field in self.fields] | [
"def",
"decompress",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"return",
"[",
"value",
".",
"get",
"(",
"field",
".",
"name",
",",
"None",
")",
"for",
"field",
"in",
"self",
".",
"fields",
"]",
"return",
"[",
"field",
".",
"field",
... | Retreieve each field value or provide the initial values | [
"Retreieve",
"each",
"field",
"value",
"or",
"provide",
"the",
"initial",
"values"
] | train | https://github.com/jsoa/django-formfield/blob/7fbe8e9aa3e587588a8ed80063e4692e7e0608fe/formfield/widgets.py#L34-L40 |
jsoa/django-formfield | formfield/widgets.py | FormFieldWidget.format_label | def format_label(self, field, counter):
"""
Format the label for each field
"""
return '<label for="id_formfield_%s" %s>%s</label>' % (
counter, field.field.required and 'class="required"', field.label) | python | def format_label(self, field, counter):
"""
Format the label for each field
"""
return '<label for="id_formfield_%s" %s>%s</label>' % (
counter, field.field.required and 'class="required"', field.label) | [
"def",
"format_label",
"(",
"self",
",",
"field",
",",
"counter",
")",
":",
"return",
"'<label for=\"id_formfield_%s\" %s>%s</label>'",
"%",
"(",
"counter",
",",
"field",
".",
"field",
".",
"required",
"and",
"'class=\"required\"'",
",",
"field",
".",
"label",
"... | Format the label for each field | [
"Format",
"the",
"label",
"for",
"each",
"field"
] | train | https://github.com/jsoa/django-formfield/blob/7fbe8e9aa3e587588a8ed80063e4692e7e0608fe/formfield/widgets.py#L42-L47 |
jsoa/django-formfield | formfield/widgets.py | FormFieldWidget.format_output | def format_output(self, rendered_widgets):
"""
This output will yeild all widgets grouped in a un-ordered list
"""
ret = [u'<ul class="formfield">']
for i, field in enumerate(self.fields):
label = self.format_label(field, i)
help_text = self.format_help_te... | python | def format_output(self, rendered_widgets):
"""
This output will yeild all widgets grouped in a un-ordered list
"""
ret = [u'<ul class="formfield">']
for i, field in enumerate(self.fields):
label = self.format_label(field, i)
help_text = self.format_help_te... | [
"def",
"format_output",
"(",
"self",
",",
"rendered_widgets",
")",
":",
"ret",
"=",
"[",
"u'<ul class=\"formfield\">'",
"]",
"for",
"i",
",",
"field",
"in",
"enumerate",
"(",
"self",
".",
"fields",
")",
":",
"label",
"=",
"self",
".",
"format_label",
"(",
... | This output will yeild all widgets grouped in a un-ordered list | [
"This",
"output",
"will",
"yeild",
"all",
"widgets",
"grouped",
"in",
"a",
"un",
"-",
"ordered",
"list"
] | train | https://github.com/jsoa/django-formfield/blob/7fbe8e9aa3e587588a8ed80063e4692e7e0608fe/formfield/widgets.py#L55-L67 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Document.sentiment | def sentiment(self):
"""
Returns average sentiment of document. Must have sentiment enabled in XML output.
:getter: returns average sentiment of the document
:type: float
"""
if self._sentiment is None:
results = self._xml.xpath('/root/document/sentences')
... | python | def sentiment(self):
"""
Returns average sentiment of document. Must have sentiment enabled in XML output.
:getter: returns average sentiment of the document
:type: float
"""
if self._sentiment is None:
results = self._xml.xpath('/root/document/sentences')
... | [
"def",
"sentiment",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sentiment",
"is",
"None",
":",
"results",
"=",
"self",
".",
"_xml",
".",
"xpath",
"(",
"'/root/document/sentences'",
")",
"self",
".",
"_sentiment",
"=",
"float",
"(",
"results",
"[",
"0",
... | Returns average sentiment of document. Must have sentiment enabled in XML output.
:getter: returns average sentiment of the document
:type: float | [
"Returns",
"average",
"sentiment",
"of",
"document",
".",
"Must",
"have",
"sentiment",
"enabled",
"in",
"XML",
"output",
"."
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L30-L41 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Document._get_sentences_dict | def _get_sentences_dict(self):
"""
Returns sentence objects
:return: order dict of sentences
:rtype: collections.OrderedDict
"""
if self._sentences_dict is None:
sentences = [Sentence(element) for element in self._xml.xpath('/root/document/sentences/sentence... | python | def _get_sentences_dict(self):
"""
Returns sentence objects
:return: order dict of sentences
:rtype: collections.OrderedDict
"""
if self._sentences_dict is None:
sentences = [Sentence(element) for element in self._xml.xpath('/root/document/sentences/sentence... | [
"def",
"_get_sentences_dict",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sentences_dict",
"is",
"None",
":",
"sentences",
"=",
"[",
"Sentence",
"(",
"element",
")",
"for",
"element",
"in",
"self",
".",
"_xml",
".",
"xpath",
"(",
"'/root/document/sentences/s... | Returns sentence objects
:return: order dict of sentences
:rtype: collections.OrderedDict | [
"Returns",
"sentence",
"objects"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L43-L54 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Document.coreferences | def coreferences(self):
"""
Returns a list of Coreference classes
:getter: Returns a list of coreferences
:type: list of corenlp_xml.coreference.Coreference
"""
if self._coreferences is None:
coreferences = self._xml.xpath('/root/document/coreference/corefer... | python | def coreferences(self):
"""
Returns a list of Coreference classes
:getter: Returns a list of coreferences
:type: list of corenlp_xml.coreference.Coreference
"""
if self._coreferences is None:
coreferences = self._xml.xpath('/root/document/coreference/corefer... | [
"def",
"coreferences",
"(",
"self",
")",
":",
"if",
"self",
".",
"_coreferences",
"is",
"None",
":",
"coreferences",
"=",
"self",
".",
"_xml",
".",
"xpath",
"(",
"'/root/document/coreference/coreference'",
")",
"if",
"len",
"(",
"coreferences",
")",
">",
"0"... | Returns a list of Coreference classes
:getter: Returns a list of coreferences
:type: list of corenlp_xml.coreference.Coreference | [
"Returns",
"a",
"list",
"of",
"Coreference",
"classes"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L81-L93 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.id | def id(self):
"""
:return: the ID attribute of the sentence
:rtype: int
"""
if self._id is None:
self._id = int(self._element.get('id'))
return self._id | python | def id(self):
"""
:return: the ID attribute of the sentence
:rtype: int
"""
if self._id is None:
self._id = int(self._element.get('id'))
return self._id | [
"def",
"id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_id",
"is",
"None",
":",
"self",
".",
"_id",
"=",
"int",
"(",
"self",
".",
"_element",
".",
"get",
"(",
"'id'",
")",
")",
"return",
"self",
".",
"_id"
] | :return: the ID attribute of the sentence
:rtype: int | [
":",
"return",
":",
"the",
"ID",
"attribute",
"of",
"the",
"sentence",
":",
"rtype",
":",
"int"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L121-L129 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.sentiment | def sentiment(self):
"""
The sentiment of this sentence
:getter: Returns the sentiment value of this sentence
:type: int
"""
if self._sentiment is None:
self._sentiment = int(self._element.get('sentiment'))
return self._sentiment | python | def sentiment(self):
"""
The sentiment of this sentence
:getter: Returns the sentiment value of this sentence
:type: int
"""
if self._sentiment is None:
self._sentiment = int(self._element.get('sentiment'))
return self._sentiment | [
"def",
"sentiment",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sentiment",
"is",
"None",
":",
"self",
".",
"_sentiment",
"=",
"int",
"(",
"self",
".",
"_element",
".",
"get",
"(",
"'sentiment'",
")",
")",
"return",
"self",
".",
"_sentiment"
] | The sentiment of this sentence
:getter: Returns the sentiment value of this sentence
:type: int | [
"The",
"sentiment",
"of",
"this",
"sentence"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L132-L142 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence._get_tokens_dict | def _get_tokens_dict(self):
"""
Accesses tokens dict
:return: The ordered dict of the tokens
:rtype: collections.OrderedDict
"""
if self._tokens_dict is None:
tokens = [Token(element) for element in self._element.xpath('tokens/token')]
self._toke... | python | def _get_tokens_dict(self):
"""
Accesses tokens dict
:return: The ordered dict of the tokens
:rtype: collections.OrderedDict
"""
if self._tokens_dict is None:
tokens = [Token(element) for element in self._element.xpath('tokens/token')]
self._toke... | [
"def",
"_get_tokens_dict",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tokens_dict",
"is",
"None",
":",
"tokens",
"=",
"[",
"Token",
"(",
"element",
")",
"for",
"element",
"in",
"self",
".",
"_element",
".",
"xpath",
"(",
"'tokens/token'",
")",
"]",
"s... | Accesses tokens dict
:return: The ordered dict of the tokens
:rtype: collections.OrderedDict | [
"Accesses",
"tokens",
"dict"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L144-L155 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.subtrees_for_phrase | def subtrees_for_phrase(self, phrase_type):
"""
Returns subtrees corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of NLTK.Tree.Subtree instances
:rtype: list of NLTK.Tre... | python | def subtrees_for_phrase(self, phrase_type):
"""
Returns subtrees corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of NLTK.Tree.Subtree instances
:rtype: list of NLTK.Tre... | [
"def",
"subtrees_for_phrase",
"(",
"self",
",",
"phrase_type",
")",
":",
"return",
"[",
"subtree",
"for",
"subtree",
"in",
"self",
".",
"parse",
".",
"subtrees",
"(",
")",
"if",
"subtree",
".",
"node",
".",
"lower",
"(",
")",
"==",
"phrase_type",
".",
... | Returns subtrees corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of NLTK.Tree.Subtree instances
:rtype: list of NLTK.Tree.Subtree | [
"Returns",
"subtrees",
"corresponding",
"all",
"phrases",
"matching",
"a",
"given",
"phrase",
"type"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L181-L192 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.phrase_strings | def phrase_strings(self, phrase_type):
"""
Returns strings corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of strings representing those phrases
"""
return [u"... | python | def phrase_strings(self, phrase_type):
"""
Returns strings corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of strings representing those phrases
"""
return [u"... | [
"def",
"phrase_strings",
"(",
"self",
",",
"phrase_type",
")",
":",
"return",
"[",
"u\" \"",
".",
"join",
"(",
"subtree",
".",
"leaves",
"(",
")",
")",
"for",
"subtree",
"in",
"self",
".",
"subtrees_for_phrase",
"(",
"phrase_type",
")",
"]"
] | Returns strings corresponding all phrases matching a given phrase type
:param phrase_type: POS such as "NP", "VP", "det", etc.
:type phrase_type: str
:return: a list of strings representing those phrases | [
"Returns",
"strings",
"corresponding",
"all",
"phrases",
"matching",
"a",
"given",
"phrase",
"type"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L194-L204 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.parse_string | def parse_string(self):
"""
Accesses the S-Expression parse string stored on the XML document
:getter: Returns the parse string
:type: str
"""
if self._parse_string is None:
parse_text = self._element.xpath('parse/text()')
if len(parse_text) > 0:... | python | def parse_string(self):
"""
Accesses the S-Expression parse string stored on the XML document
:getter: Returns the parse string
:type: str
"""
if self._parse_string is None:
parse_text = self._element.xpath('parse/text()')
if len(parse_text) > 0:... | [
"def",
"parse_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parse_string",
"is",
"None",
":",
"parse_text",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'parse/text()'",
")",
"if",
"len",
"(",
"parse_text",
")",
">",
"0",
":",
"self",
".",
... | Accesses the S-Expression parse string stored on the XML document
:getter: Returns the parse string
:type: str | [
"Accesses",
"the",
"S",
"-",
"Expression",
"parse",
"string",
"stored",
"on",
"the",
"XML",
"document"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L218-L230 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.parse | def parse(self):
"""
Accesses the parse tree based on the S-expression parse string in the XML
:getter: Returns the NLTK parse tree
:type: nltk.Tree
"""
if self.parse_string is not None and self._parse is None:
self._parse = Tree.parse(self._parse_string)
... | python | def parse(self):
"""
Accesses the parse tree based on the S-expression parse string in the XML
:getter: Returns the NLTK parse tree
:type: nltk.Tree
"""
if self.parse_string is not None and self._parse is None:
self._parse = Tree.parse(self._parse_string)
... | [
"def",
"parse",
"(",
"self",
")",
":",
"if",
"self",
".",
"parse_string",
"is",
"not",
"None",
"and",
"self",
".",
"_parse",
"is",
"None",
":",
"self",
".",
"_parse",
"=",
"Tree",
".",
"parse",
"(",
"self",
".",
"_parse_string",
")",
"return",
"self"... | Accesses the parse tree based on the S-expression parse string in the XML
:getter: Returns the NLTK parse tree
:type: nltk.Tree | [
"Accesses",
"the",
"parse",
"tree",
"based",
"on",
"the",
"S",
"-",
"expression",
"parse",
"string",
"in",
"the",
"XML"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L233-L243 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.basic_dependencies | def basic_dependencies(self):
"""
Accesses basic dependencies from the XML output
:getter: Returns the dependency graph for basic dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
deps = self._element.xpath... | python | def basic_dependencies(self):
"""
Accesses basic dependencies from the XML output
:getter: Returns the dependency graph for basic dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
deps = self._element.xpath... | [
"def",
"basic_dependencies",
"(",
"self",
")",
":",
"if",
"self",
".",
"_basic_dependencies",
"is",
"None",
":",
"deps",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'dependencies[@type=\"basic-dependencies\"]'",
")",
"if",
"len",
"(",
"deps",
")",
">",
... | Accesses basic dependencies from the XML output
:getter: Returns the dependency graph for basic dependencies
:type: corenlp_xml.dependencies.DependencyGraph | [
"Accesses",
"basic",
"dependencies",
"from",
"the",
"XML",
"output"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L246-L258 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.collapsed_dependencies | def collapsed_dependencies(self):
"""
Accessess collapsed dependencies for this sentence
:getter: Returns the dependency graph for collapsed dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
deps = self._el... | python | def collapsed_dependencies(self):
"""
Accessess collapsed dependencies for this sentence
:getter: Returns the dependency graph for collapsed dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
deps = self._el... | [
"def",
"collapsed_dependencies",
"(",
"self",
")",
":",
"if",
"self",
".",
"_basic_dependencies",
"is",
"None",
":",
"deps",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'dependencies[@type=\"collapsed-dependencies\"]'",
")",
"if",
"len",
"(",
"deps",
")",
... | Accessess collapsed dependencies for this sentence
:getter: Returns the dependency graph for collapsed dependencies
:type: corenlp_xml.dependencies.DependencyGraph | [
"Accessess",
"collapsed",
"dependencies",
"for",
"this",
"sentence"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L261-L273 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Sentence.collapsed_ccprocessed_dependencies | def collapsed_ccprocessed_dependencies(self):
"""
Accesses collapsed, CC-processed dependencies
:getter: Returns the dependency graph for collapsed and cc processed dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
... | python | def collapsed_ccprocessed_dependencies(self):
"""
Accesses collapsed, CC-processed dependencies
:getter: Returns the dependency graph for collapsed and cc processed dependencies
:type: corenlp_xml.dependencies.DependencyGraph
"""
if self._basic_dependencies is None:
... | [
"def",
"collapsed_ccprocessed_dependencies",
"(",
"self",
")",
":",
"if",
"self",
".",
"_basic_dependencies",
"is",
"None",
":",
"deps",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'dependencies[@type=\"collapsed-ccprocessed-dependencies\"]'",
")",
"if",
"len",
... | Accesses collapsed, CC-processed dependencies
:getter: Returns the dependency graph for collapsed and cc processed dependencies
:type: corenlp_xml.dependencies.DependencyGraph | [
"Accesses",
"collapsed",
"CC",
"-",
"processed",
"dependencies"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L276-L288 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.word | def word(self):
"""
Lazy-loads word value
:getter: Returns the plain string value of the word
:type: str
"""
if self._word is None:
words = self._element.xpath('word/text()')
if len(words) > 0:
self._word = words[0]
return... | python | def word(self):
"""
Lazy-loads word value
:getter: Returns the plain string value of the word
:type: str
"""
if self._word is None:
words = self._element.xpath('word/text()')
if len(words) > 0:
self._word = words[0]
return... | [
"def",
"word",
"(",
"self",
")",
":",
"if",
"self",
".",
"_word",
"is",
"None",
":",
"words",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'word/text()'",
")",
"if",
"len",
"(",
"words",
")",
">",
"0",
":",
"self",
".",
"_word",
"=",
"words"... | Lazy-loads word value
:getter: Returns the plain string value of the word
:type: str | [
"Lazy",
"-",
"loads",
"word",
"value"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L356-L368 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.lemma | def lemma(self):
"""
Lazy-loads the lemma for this word
:getter: Returns the plain string value of the word lemma
:type: str
"""
if self._lemma is None:
lemmata = self._element.xpath('lemma/text()')
if len(lemmata) > 0:
self._lemm... | python | def lemma(self):
"""
Lazy-loads the lemma for this word
:getter: Returns the plain string value of the word lemma
:type: str
"""
if self._lemma is None:
lemmata = self._element.xpath('lemma/text()')
if len(lemmata) > 0:
self._lemm... | [
"def",
"lemma",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lemma",
"is",
"None",
":",
"lemmata",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'lemma/text()'",
")",
"if",
"len",
"(",
"lemmata",
")",
">",
"0",
":",
"self",
".",
"_lemma",
"=",
... | Lazy-loads the lemma for this word
:getter: Returns the plain string value of the word lemma
:type: str | [
"Lazy",
"-",
"loads",
"the",
"lemma",
"for",
"this",
"word"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L371-L383 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.character_offset_begin | def character_offset_begin(self):
"""
Lazy-loads character offset begin node
:getter: Returns the integer value of the beginning offset
:type: int
"""
if self._character_offset_begin is None:
offsets = self._element.xpath('CharacterOffsetBegin/text()')
... | python | def character_offset_begin(self):
"""
Lazy-loads character offset begin node
:getter: Returns the integer value of the beginning offset
:type: int
"""
if self._character_offset_begin is None:
offsets = self._element.xpath('CharacterOffsetBegin/text()')
... | [
"def",
"character_offset_begin",
"(",
"self",
")",
":",
"if",
"self",
".",
"_character_offset_begin",
"is",
"None",
":",
"offsets",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'CharacterOffsetBegin/text()'",
")",
"if",
"len",
"(",
"offsets",
")",
">",
... | Lazy-loads character offset begin node
:getter: Returns the integer value of the beginning offset
:type: int | [
"Lazy",
"-",
"loads",
"character",
"offset",
"begin",
"node"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L386-L398 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.character_offset_end | def character_offset_end(self):
"""
Lazy-loads character offset end node
:getter: Returns the integer value of the ending offset
:type: int
"""
if self._character_offset_end is None:
offsets = self._element.xpath('CharacterOffsetEnd/text()')
if l... | python | def character_offset_end(self):
"""
Lazy-loads character offset end node
:getter: Returns the integer value of the ending offset
:type: int
"""
if self._character_offset_end is None:
offsets = self._element.xpath('CharacterOffsetEnd/text()')
if l... | [
"def",
"character_offset_end",
"(",
"self",
")",
":",
"if",
"self",
".",
"_character_offset_end",
"is",
"None",
":",
"offsets",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'CharacterOffsetEnd/text()'",
")",
"if",
"len",
"(",
"offsets",
")",
">",
"0",
... | Lazy-loads character offset end node
:getter: Returns the integer value of the ending offset
:type: int | [
"Lazy",
"-",
"loads",
"character",
"offset",
"end",
"node"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L401-L413 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.pos | def pos(self):
"""
Lazy-loads the part of speech tag for this word
:getter: Returns the plain string value of the POS tag for the word
:type: str
"""
if self._pos is None:
poses = self._element.xpath('POS/text()')
if len(poses) > 0:
... | python | def pos(self):
"""
Lazy-loads the part of speech tag for this word
:getter: Returns the plain string value of the POS tag for the word
:type: str
"""
if self._pos is None:
poses = self._element.xpath('POS/text()')
if len(poses) > 0:
... | [
"def",
"pos",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pos",
"is",
"None",
":",
"poses",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'POS/text()'",
")",
"if",
"len",
"(",
"poses",
")",
">",
"0",
":",
"self",
".",
"_pos",
"=",
"poses",
... | Lazy-loads the part of speech tag for this word
:getter: Returns the plain string value of the POS tag for the word
:type: str | [
"Lazy",
"-",
"loads",
"the",
"part",
"of",
"speech",
"tag",
"for",
"this",
"word"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L416-L428 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.ner | def ner(self):
"""
Lazy-loads the NER for this word
:getter: Returns the plain string value of the NER tag for the word
:type: str
"""
if self._ner is None:
ners = self._element.xpath('NER/text()')
if len(ners) > 0:
self._ner = ne... | python | def ner(self):
"""
Lazy-loads the NER for this word
:getter: Returns the plain string value of the NER tag for the word
:type: str
"""
if self._ner is None:
ners = self._element.xpath('NER/text()')
if len(ners) > 0:
self._ner = ne... | [
"def",
"ner",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ner",
"is",
"None",
":",
"ners",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'NER/text()'",
")",
"if",
"len",
"(",
"ners",
")",
">",
"0",
":",
"self",
".",
"_ner",
"=",
"ners",
"["... | Lazy-loads the NER for this word
:getter: Returns the plain string value of the NER tag for the word
:type: str | [
"Lazy",
"-",
"loads",
"the",
"NER",
"for",
"this",
"word"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L431-L443 |
relwell/corenlp-xml-lib | corenlp_xml/document.py | Token.speaker | def speaker(self):
"""
Lazy-loads the speaker for this word
:getter: Returns the plain string value of the speaker tag for the word
:type: str
"""
if self._speaker is None:
speakers = self._element.xpath('Speaker/text()')
if len(speakers) > 0:
... | python | def speaker(self):
"""
Lazy-loads the speaker for this word
:getter: Returns the plain string value of the speaker tag for the word
:type: str
"""
if self._speaker is None:
speakers = self._element.xpath('Speaker/text()')
if len(speakers) > 0:
... | [
"def",
"speaker",
"(",
"self",
")",
":",
"if",
"self",
".",
"_speaker",
"is",
"None",
":",
"speakers",
"=",
"self",
".",
"_element",
".",
"xpath",
"(",
"'Speaker/text()'",
")",
"if",
"len",
"(",
"speakers",
")",
">",
"0",
":",
"self",
".",
"_speaker"... | Lazy-loads the speaker for this word
:getter: Returns the plain string value of the speaker tag for the word
:type: str | [
"Lazy",
"-",
"loads",
"the",
"speaker",
"for",
"this",
"word"
] | train | https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L446-L458 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_iam_role_policy | def _generate_iam_role_policy(self):
"""
Generate the policy for the IAM Role.
Terraform name: aws_iam_role.lambda_role
"""
endpoints = self.config.get('endpoints')
queue_arns = []
for ep in endpoints:
for qname in endpoints[ep]['queues']:
... | python | def _generate_iam_role_policy(self):
"""
Generate the policy for the IAM Role.
Terraform name: aws_iam_role.lambda_role
"""
endpoints = self.config.get('endpoints')
queue_arns = []
for ep in endpoints:
for qname in endpoints[ep]['queues']:
... | [
"def",
"_generate_iam_role_policy",
"(",
"self",
")",
":",
"endpoints",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'endpoints'",
")",
"queue_arns",
"=",
"[",
"]",
"for",
"ep",
"in",
"endpoints",
":",
"for",
"qname",
"in",
"endpoints",
"[",
"ep",
"]",
... | Generate the policy for the IAM Role.
Terraform name: aws_iam_role.lambda_role | [
"Generate",
"the",
"policy",
"for",
"the",
"IAM",
"Role",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L114-L172 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_iam_invoke_role_policy | def _generate_iam_invoke_role_policy(self):
"""
Generate the policy for the IAM role used by API Gateway to invoke
the lambda function.
Terraform name: aws_iam_role.invoke_role
"""
invoke_pol = {
"Version": "2012-10-17",
"Statement": [
... | python | def _generate_iam_invoke_role_policy(self):
"""
Generate the policy for the IAM role used by API Gateway to invoke
the lambda function.
Terraform name: aws_iam_role.invoke_role
"""
invoke_pol = {
"Version": "2012-10-17",
"Statement": [
... | [
"def",
"_generate_iam_invoke_role_policy",
"(",
"self",
")",
":",
"invoke_pol",
"=",
"{",
"\"Version\"",
":",
"\"2012-10-17\"",
",",
"\"Statement\"",
":",
"[",
"{",
"\"Effect\"",
":",
"\"Allow\"",
",",
"\"Resource\"",
":",
"[",
"\"*\"",
"]",
",",
"\"Action\"",
... | Generate the policy for the IAM role used by API Gateway to invoke
the lambda function.
Terraform name: aws_iam_role.invoke_role | [
"Generate",
"the",
"policy",
"for",
"the",
"IAM",
"role",
"used",
"by",
"API",
"Gateway",
"to",
"invoke",
"the",
"lambda",
"function",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L174-L195 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_iam_role | def _generate_iam_role(self):
"""
Generate the IAM Role needed by the Lambda function.
Terraform name: aws_iam_role.lambda_role
"""
pol = {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
... | python | def _generate_iam_role(self):
"""
Generate the IAM Role needed by the Lambda function.
Terraform name: aws_iam_role.lambda_role
"""
pol = {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
... | [
"def",
"_generate_iam_role",
"(",
"self",
")",
":",
"pol",
"=",
"{",
"\"Version\"",
":",
"\"2012-10-17\"",
",",
"\"Statement\"",
":",
"[",
"{",
"\"Action\"",
":",
"\"sts:AssumeRole\"",
",",
"\"Principal\"",
":",
"{",
"\"Service\"",
":",
"\"lambda.amazonaws.com\"",... | Generate the IAM Role needed by the Lambda function.
Terraform name: aws_iam_role.lambda_role | [
"Generate",
"the",
"IAM",
"Role",
"needed",
"by",
"the",
"Lambda",
"function",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L197-L227 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_iam_invoke_role | def _generate_iam_invoke_role(self):
"""
Generate the IAM Role for API Gateway to use to invoke the function.
Terraform name: aws_iam_role.invoke_role
:return:
"""
invoke_assume = {
"Version": "2012-10-17",
"Statement": [
{
... | python | def _generate_iam_invoke_role(self):
"""
Generate the IAM Role for API Gateway to use to invoke the function.
Terraform name: aws_iam_role.invoke_role
:return:
"""
invoke_assume = {
"Version": "2012-10-17",
"Statement": [
{
... | [
"def",
"_generate_iam_invoke_role",
"(",
"self",
")",
":",
"invoke_assume",
"=",
"{",
"\"Version\"",
":",
"\"2012-10-17\"",
",",
"\"Statement\"",
":",
"[",
"{",
"\"Action\"",
":",
"\"sts:AssumeRole\"",
",",
"\"Principal\"",
":",
"{",
"\"Service\"",
":",
"\"apigate... | Generate the IAM Role for API Gateway to use to invoke the function.
Terraform name: aws_iam_role.invoke_role
:return: | [
"Generate",
"the",
"IAM",
"Role",
"for",
"API",
"Gateway",
"to",
"use",
"to",
"invoke",
"the",
"function",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L229-L259 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_lambda | def _generate_lambda(self):
"""
Generate the lambda function and its IAM role, and add to self.tf_conf
"""
self.tf_conf['resource']['aws_lambda_function']['lambda_func'] = {
'filename': 'webhook2lambda2sqs_func.zip',
'function_name': self.resource_name,
... | python | def _generate_lambda(self):
"""
Generate the lambda function and its IAM role, and add to self.tf_conf
"""
self.tf_conf['resource']['aws_lambda_function']['lambda_func'] = {
'filename': 'webhook2lambda2sqs_func.zip',
'function_name': self.resource_name,
... | [
"def",
"_generate_lambda",
"(",
"self",
")",
":",
"self",
".",
"tf_conf",
"[",
"'resource'",
"]",
"[",
"'aws_lambda_function'",
"]",
"[",
"'lambda_func'",
"]",
"=",
"{",
"'filename'",
":",
"'webhook2lambda2sqs_func.zip'",
",",
"'function_name'",
":",
"self",
"."... | Generate the lambda function and its IAM role, and add to self.tf_conf | [
"Generate",
"the",
"lambda",
"function",
"and",
"its",
"IAM",
"role",
"and",
"add",
"to",
"self",
".",
"tf_conf"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L261-L278 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._set_account_info | def _set_account_info(self):
"""
Connect to the AWS IAM API via boto3 and run the GetUser operation
on the current user. Use this to set ``self.aws_account_id`` and
``self.aws_region``.
"""
if 'AWS_DEFAULT_REGION' in os.environ:
logger.debug('Connecting to IAM... | python | def _set_account_info(self):
"""
Connect to the AWS IAM API via boto3 and run the GetUser operation
on the current user. Use this to set ``self.aws_account_id`` and
``self.aws_region``.
"""
if 'AWS_DEFAULT_REGION' in os.environ:
logger.debug('Connecting to IAM... | [
"def",
"_set_account_info",
"(",
"self",
")",
":",
"if",
"'AWS_DEFAULT_REGION'",
"in",
"os",
".",
"environ",
":",
"logger",
".",
"debug",
"(",
"'Connecting to IAM with region_name=%s'",
",",
"os",
".",
"environ",
"[",
"'AWS_DEFAULT_REGION'",
"]",
")",
"kwargs",
... | Connect to the AWS IAM API via boto3 and run the GetUser operation
on the current user. Use this to set ``self.aws_account_id`` and
``self.aws_region``. | [
"Connect",
"to",
"the",
"AWS",
"IAM",
"API",
"via",
"boto3",
"and",
"run",
"the",
"GetUser",
"operation",
"on",
"the",
"current",
"user",
".",
"Use",
"this",
"to",
"set",
"self",
".",
"aws_account_id",
"and",
"self",
".",
"aws_region",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L280-L303 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_api_gateway | def _generate_api_gateway(self):
"""
Generate the full configuration for the API Gateway, and add to
self.tf_conf
"""
self.tf_conf['resource']['aws_api_gateway_rest_api']['rest_api'] = {
'name': self.resource_name,
'description': self.description
}... | python | def _generate_api_gateway(self):
"""
Generate the full configuration for the API Gateway, and add to
self.tf_conf
"""
self.tf_conf['resource']['aws_api_gateway_rest_api']['rest_api'] = {
'name': self.resource_name,
'description': self.description
}... | [
"def",
"_generate_api_gateway",
"(",
"self",
")",
":",
"self",
".",
"tf_conf",
"[",
"'resource'",
"]",
"[",
"'aws_api_gateway_rest_api'",
"]",
"[",
"'rest_api'",
"]",
"=",
"{",
"'name'",
":",
"self",
".",
"resource_name",
",",
"'description'",
":",
"self",
"... | Generate the full configuration for the API Gateway, and add to
self.tf_conf | [
"Generate",
"the",
"full",
"configuration",
"for",
"the",
"API",
"Gateway",
"and",
"add",
"to",
"self",
".",
"tf_conf"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L347-L378 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_api_gateway_deployment | def _generate_api_gateway_deployment(self):
"""
Generate the API Gateway Deployment/Stage, and add to self.tf_conf
"""
# finally, the deployment
# this resource MUST come last
dep_on = []
for rtype in sorted(self.tf_conf['resource'].keys()):
for rname ... | python | def _generate_api_gateway_deployment(self):
"""
Generate the API Gateway Deployment/Stage, and add to self.tf_conf
"""
# finally, the deployment
# this resource MUST come last
dep_on = []
for rtype in sorted(self.tf_conf['resource'].keys()):
for rname ... | [
"def",
"_generate_api_gateway_deployment",
"(",
"self",
")",
":",
"# finally, the deployment",
"# this resource MUST come last",
"dep_on",
"=",
"[",
"]",
"for",
"rtype",
"in",
"sorted",
"(",
"self",
".",
"tf_conf",
"[",
"'resource'",
"]",
".",
"keys",
"(",
")",
... | Generate the API Gateway Deployment/Stage, and add to self.tf_conf | [
"Generate",
"the",
"API",
"Gateway",
"Deployment",
"/",
"Stage",
"and",
"add",
"to",
"self",
".",
"tf_conf"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L380-L398 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._generate_endpoint | def _generate_endpoint(self, ep_name, ep_method):
"""
Generate configuration for a single endpoint (this is many resources)
Terraform Names:
- aws_api_gateway_resource: {ep_name}
- aws_api_gateway_method: {ep_name}_{ep_method}
:param ep_name: endpoint name (path compon... | python | def _generate_endpoint(self, ep_name, ep_method):
"""
Generate configuration for a single endpoint (this is many resources)
Terraform Names:
- aws_api_gateway_resource: {ep_name}
- aws_api_gateway_method: {ep_name}_{ep_method}
:param ep_name: endpoint name (path compon... | [
"def",
"_generate_endpoint",
"(",
"self",
",",
"ep_name",
",",
"ep_method",
")",
":",
"ep_method",
"=",
"ep_method",
".",
"upper",
"(",
")",
"self",
".",
"tf_conf",
"[",
"'resource'",
"]",
"[",
"'aws_api_gateway_resource'",
"]",
"[",
"ep_name",
"]",
"=",
"... | Generate configuration for a single endpoint (this is many resources)
Terraform Names:
- aws_api_gateway_resource: {ep_name}
- aws_api_gateway_method: {ep_name}_{ep_method}
:param ep_name: endpoint name (path component)
:type ep_name: str
:param ep_method: HTTP method ... | [
"Generate",
"configuration",
"for",
"a",
"single",
"endpoint",
"(",
"this",
"is",
"many",
"resources",
")"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L400-L507 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._get_config | def _get_config(self, func_src):
"""
Return the full terraform configuration as a JSON string
:param func_src: lambda function source
:type func_src: str
:return: terraform configuration
:rtype: str
"""
self._set_account_info()
self._generate_iam_... | python | def _get_config(self, func_src):
"""
Return the full terraform configuration as a JSON string
:param func_src: lambda function source
:type func_src: str
:return: terraform configuration
:rtype: str
"""
self._set_account_info()
self._generate_iam_... | [
"def",
"_get_config",
"(",
"self",
",",
"func_src",
")",
":",
"self",
".",
"_set_account_info",
"(",
")",
"self",
".",
"_generate_iam_role",
"(",
")",
"self",
".",
"_generate_iam_role_policy",
"(",
")",
"self",
".",
"_generate_iam_invoke_role",
"(",
")",
"self... | Return the full terraform configuration as a JSON string
:param func_src: lambda function source
:type func_src: str
:return: terraform configuration
:rtype: str | [
"Return",
"the",
"full",
"terraform",
"configuration",
"as",
"a",
"JSON",
"string"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L523-L542 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator._write_zip | def _write_zip(self, func_src, fpath):
"""
Write the function source to a zip file, suitable for upload to
Lambda.
Note there's a bit of undocumented magic going on here; Lambda needs
the execute bit set on the module with the handler in it (i.e. 0755
or 0555 permissions... | python | def _write_zip(self, func_src, fpath):
"""
Write the function source to a zip file, suitable for upload to
Lambda.
Note there's a bit of undocumented magic going on here; Lambda needs
the execute bit set on the module with the handler in it (i.e. 0755
or 0555 permissions... | [
"def",
"_write_zip",
"(",
"self",
",",
"func_src",
",",
"fpath",
")",
":",
"# get timestamp for file",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"zi_tup",
"=",
"(",
"now",
".",
"year",
",",
"now",
".",
"month",
",",
"now",
".",
"day",
",",
"now",... | Write the function source to a zip file, suitable for upload to
Lambda.
Note there's a bit of undocumented magic going on here; Lambda needs
the execute bit set on the module with the handler in it (i.e. 0755
or 0555 permissions). There doesn't seem to be *any* documentation on
... | [
"Write",
"the",
"function",
"source",
"to",
"a",
"zip",
"file",
"suitable",
"for",
"upload",
"to",
"Lambda",
"."
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L544-L576 |
jantman/webhook2lambda2sqs | webhook2lambda2sqs/tf_generator.py | TerraformGenerator.generate | def generate(self, func_src):
"""
Generate TF config and write to ./webhook2lambda2sqs.tf.json;
write the lambda function to ./webhook2lambda2sqs_func.py
:param func_src: lambda function source
:type func_src: str
"""
# write function source for reference
... | python | def generate(self, func_src):
"""
Generate TF config and write to ./webhook2lambda2sqs.tf.json;
write the lambda function to ./webhook2lambda2sqs_func.py
:param func_src: lambda function source
:type func_src: str
"""
# write function source for reference
... | [
"def",
"generate",
"(",
"self",
",",
"func_src",
")",
":",
"# write function source for reference",
"logger",
".",
"warning",
"(",
"'Writing lambda function source to: '",
"'./webhook2lambda2sqs_func.py'",
")",
"with",
"open",
"(",
"'./webhook2lambda2sqs_func.py'",
",",
"'w... | Generate TF config and write to ./webhook2lambda2sqs.tf.json;
write the lambda function to ./webhook2lambda2sqs_func.py
:param func_src: lambda function source
:type func_src: str | [
"Generate",
"TF",
"config",
"and",
"write",
"to",
".",
"/",
"webhook2lambda2sqs",
".",
"tf",
".",
"json",
";",
"write",
"the",
"lambda",
"function",
"to",
".",
"/",
"webhook2lambda2sqs_func",
".",
"py"
] | train | https://github.com/jantman/webhook2lambda2sqs/blob/c80c18d5a908ba8b8ee624dc3a977c633fba2b7c/webhook2lambda2sqs/tf_generator.py#L578-L603 |
TomAugspurger/DSADD | dsadd/checks.py | none_missing | def none_missing(df, columns=None):
"""
Asserts that there are no missing values (NaNs) in the DataFrame.
"""
if columns is None:
columns = df.columns
assert not df[columns].isnull().any().any()
return df | python | def none_missing(df, columns=None):
"""
Asserts that there are no missing values (NaNs) in the DataFrame.
"""
if columns is None:
columns = df.columns
assert not df[columns].isnull().any().any()
return df | [
"def",
"none_missing",
"(",
"df",
",",
"columns",
"=",
"None",
")",
":",
"if",
"columns",
"is",
"None",
":",
"columns",
"=",
"df",
".",
"columns",
"assert",
"not",
"df",
"[",
"columns",
"]",
".",
"isnull",
"(",
")",
".",
"any",
"(",
")",
".",
"an... | Asserts that there are no missing values (NaNs) in the DataFrame. | [
"Asserts",
"that",
"there",
"are",
"no",
"missing",
"values",
"(",
"NaNs",
")",
"in",
"the",
"DataFrame",
"."
] | train | https://github.com/TomAugspurger/DSADD/blob/d5a754449e0b6dc1a7bb201f8c9031e065f792c7/dsadd/checks.py#L14-L21 |
TomAugspurger/DSADD | dsadd/checks.py | within_set | def within_set(df, items=None):
"""
Assert that df is a subset of items
Parameters
==========
df : DataFrame
items : dict
mapping of columns (k) to array-like of values (v) that
``df[k]`` is expected to be a subset of
"""
for k, v in items.items():
if not df[k].... | python | def within_set(df, items=None):
"""
Assert that df is a subset of items
Parameters
==========
df : DataFrame
items : dict
mapping of columns (k) to array-like of values (v) that
``df[k]`` is expected to be a subset of
"""
for k, v in items.items():
if not df[k].... | [
"def",
"within_set",
"(",
"df",
",",
"items",
"=",
"None",
")",
":",
"for",
"k",
",",
"v",
"in",
"items",
".",
"items",
"(",
")",
":",
"if",
"not",
"df",
"[",
"k",
"]",
".",
"isin",
"(",
"v",
")",
".",
"all",
"(",
")",
":",
"raise",
"Assert... | Assert that df is a subset of items
Parameters
==========
df : DataFrame
items : dict
mapping of columns (k) to array-like of values (v) that
``df[k]`` is expected to be a subset of | [
"Assert",
"that",
"df",
"is",
"a",
"subset",
"of",
"items"
] | train | https://github.com/TomAugspurger/DSADD/blob/d5a754449e0b6dc1a7bb201f8c9031e065f792c7/dsadd/checks.py#L79-L94 |
TomAugspurger/DSADD | dsadd/checks.py | within_range | def within_range(df, items=None):
"""
Assert that a DataFrame is within a range.
Parameters
==========
df : DataFame
items : dict
mapping of columns (k) to a (low, high) tuple (v)
that ``df[k]`` is expected to be between.
"""
for k, (lower, upper) in items.items():
... | python | def within_range(df, items=None):
"""
Assert that a DataFrame is within a range.
Parameters
==========
df : DataFame
items : dict
mapping of columns (k) to a (low, high) tuple (v)
that ``df[k]`` is expected to be between.
"""
for k, (lower, upper) in items.items():
... | [
"def",
"within_range",
"(",
"df",
",",
"items",
"=",
"None",
")",
":",
"for",
"k",
",",
"(",
"lower",
",",
"upper",
")",
"in",
"items",
".",
"items",
"(",
")",
":",
"if",
"(",
"lower",
">",
"df",
"[",
"k",
"]",
")",
".",
"any",
"(",
")",
"o... | Assert that a DataFrame is within a range.
Parameters
==========
df : DataFame
items : dict
mapping of columns (k) to a (low, high) tuple (v)
that ``df[k]`` is expected to be between. | [
"Assert",
"that",
"a",
"DataFrame",
"is",
"within",
"a",
"range",
"."
] | train | https://github.com/TomAugspurger/DSADD/blob/d5a754449e0b6dc1a7bb201f8c9031e065f792c7/dsadd/checks.py#L96-L110 |
royi1000/py-libhdate | hdate/zmanim.py | Zmanim.zmanim | def zmanim(self):
"""Return a dictionary of the zmanim the object represents."""
return {key: self.utc_minute_timezone(value) for
key, value in self.get_utc_sun_time_full().items()} | python | def zmanim(self):
"""Return a dictionary of the zmanim the object represents."""
return {key: self.utc_minute_timezone(value) for
key, value in self.get_utc_sun_time_full().items()} | [
"def",
"zmanim",
"(",
"self",
")",
":",
"return",
"{",
"key",
":",
"self",
".",
"utc_minute_timezone",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"get_utc_sun_time_full",
"(",
")",
".",
"items",
"(",
")",
"}"
] | Return a dictionary of the zmanim the object represents. | [
"Return",
"a",
"dictionary",
"of",
"the",
"zmanim",
"the",
"object",
"represents",
"."
] | train | https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/zmanim.py#L66-L69 |
royi1000/py-libhdate | hdate/zmanim.py | Zmanim.candle_lighting | def candle_lighting(self):
"""Return the time for candle lighting, or None if not applicable."""
today = HDate(gdate=self.date, diaspora=self.location.diaspora)
tomorrow = HDate(gdate=self.date + dt.timedelta(days=1),
diaspora=self.location.diaspora)
# If today... | python | def candle_lighting(self):
"""Return the time for candle lighting, or None if not applicable."""
today = HDate(gdate=self.date, diaspora=self.location.diaspora)
tomorrow = HDate(gdate=self.date + dt.timedelta(days=1),
diaspora=self.location.diaspora)
# If today... | [
"def",
"candle_lighting",
"(",
"self",
")",
":",
"today",
"=",
"HDate",
"(",
"gdate",
"=",
"self",
".",
"date",
",",
"diaspora",
"=",
"self",
".",
"location",
".",
"diaspora",
")",
"tomorrow",
"=",
"HDate",
"(",
"gdate",
"=",
"self",
".",
"date",
"+"... | Return the time for candle lighting, or None if not applicable. | [
"Return",
"the",
"time",
"for",
"candle",
"lighting",
"or",
"None",
"if",
"not",
"applicable",
"."
] | train | https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/zmanim.py#L72-L90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.