repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
bmweiner/skillful | skillful/validate.py | Valid.application_id | def application_id(self, app_id):
"""Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise.
"""
... | python | def application_id(self, app_id):
"""Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise.
"""
... | [
"def",
"application_id",
"(",
"self",
",",
"app_id",
")",
":",
"if",
"self",
".",
"app_id",
"!=",
"app_id",
":",
"warnings",
".",
"warn",
"(",
"'Application ID is invalid.'",
")",
"return",
"False",
"return",
"True"
] | Validate request application id matches true application id.
Verifying the Application ID matches: https://goo.gl/qAdqe4.
Args:
app_id: str. Request application_id.
Returns:
bool: True if valid, False otherwise. | [
"Validate",
"request",
"application",
"id",
"matches",
"true",
"application",
"id",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L204-L218 |
bmweiner/skillful | skillful/validate.py | Valid.sender | def sender(self, body, stamp, url, sig):
"""Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
... | python | def sender(self, body, stamp, url, sig):
"""Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
... | [
"def",
"sender",
"(",
"self",
",",
"body",
",",
"stamp",
",",
"url",
",",
"sig",
")",
":",
"if",
"not",
"timestamp",
"(",
"stamp",
")",
":",
"return",
"False",
"if",
"self",
".",
"url",
"!=",
"url",
":",
"if",
"not",
"signature_cert_chain_url",
"(",
... | Validate request is from Alexa.
Verifying that the Request was Sent by Alexa: https://goo.gl/AcrzB5.
Checking the Signature of the Request: https://goo.gl/FDkjBN.
Checking the Timestamp of the Request: https://goo.gl/Z5JhqZ
Args:
body: str. HTTPS request body.
s... | [
"Validate",
"request",
"is",
"from",
"Alexa",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L220-L258 |
bmweiner/skillful | skillful/validate.py | Valid.request | def request(self, app_id=None, body=None, stamp=None, url=None, sig=None):
"""Validate application ID and request is from Alexa."""
if self.app_id:
if not self.application_id(app_id):
return False
if (url or sig):
if not (body and stamp and url and sig):
... | python | def request(self, app_id=None, body=None, stamp=None, url=None, sig=None):
"""Validate application ID and request is from Alexa."""
if self.app_id:
if not self.application_id(app_id):
return False
if (url or sig):
if not (body and stamp and url and sig):
... | [
"def",
"request",
"(",
"self",
",",
"app_id",
"=",
"None",
",",
"body",
"=",
"None",
",",
"stamp",
"=",
"None",
",",
"url",
"=",
"None",
",",
"sig",
"=",
"None",
")",
":",
"if",
"self",
".",
"app_id",
":",
"if",
"not",
"self",
".",
"application_i... | Validate application ID and request is from Alexa. | [
"Validate",
"application",
"ID",
"and",
"request",
"is",
"from",
"Alexa",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/validate.py#L260-L273 |
evetrivia/thanatos | thanatos/database/db_utils.py | get_stored_procs | def get_stored_procs(db_connection):
"""
:param db_connection:
:return:
"""
sql = "SHOW PROCEDURE STATUS;"
procs = execute_sql(sql, db_connection)
return [x[1] for x in procs] | python | def get_stored_procs(db_connection):
"""
:param db_connection:
:return:
"""
sql = "SHOW PROCEDURE STATUS;"
procs = execute_sql(sql, db_connection)
return [x[1] for x in procs] | [
"def",
"get_stored_procs",
"(",
"db_connection",
")",
":",
"sql",
"=",
"\"SHOW PROCEDURE STATUS;\"",
"procs",
"=",
"execute_sql",
"(",
"sql",
",",
"db_connection",
")",
"return",
"[",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"procs",
"]"
] | :param db_connection:
:return: | [
":",
"param",
"db_connection",
":",
":",
"return",
":"
] | train | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L37-L46 |
evetrivia/thanatos | thanatos/database/db_utils.py | load_tables_from_files | def load_tables_from_files(db_connection):
""" Looks in the current working directory for all required tables. """
_log.info('Loading tables from disk to DB.')
sde_dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sde')
for sde_file_name in os.listdir(sde_dir_path):
_log.i... | python | def load_tables_from_files(db_connection):
""" Looks in the current working directory for all required tables. """
_log.info('Loading tables from disk to DB.')
sde_dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sde')
for sde_file_name in os.listdir(sde_dir_path):
_log.i... | [
"def",
"load_tables_from_files",
"(",
"db_connection",
")",
":",
"_log",
".",
"info",
"(",
"'Loading tables from disk to DB.'",
")",
"sde_dir_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"... | Looks in the current working directory for all required tables. | [
"Looks",
"in",
"the",
"current",
"working",
"directory",
"for",
"all",
"required",
"tables",
"."
] | train | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L84-L100 |
evetrivia/thanatos | thanatos/database/db_utils.py | get_connection | def get_connection(connection_details=None):
""" Creates a connection to the MySQL DB. """
if connection_details is None:
connection_details = get_default_connection_details()
return MySQLdb.connect(
connection_details['host'],
connection_details['user'],
connection_details... | python | def get_connection(connection_details=None):
""" Creates a connection to the MySQL DB. """
if connection_details is None:
connection_details = get_default_connection_details()
return MySQLdb.connect(
connection_details['host'],
connection_details['user'],
connection_details... | [
"def",
"get_connection",
"(",
"connection_details",
"=",
"None",
")",
":",
"if",
"connection_details",
"is",
"None",
":",
"connection_details",
"=",
"get_default_connection_details",
"(",
")",
"return",
"MySQLdb",
".",
"connect",
"(",
"connection_details",
"[",
"'ho... | Creates a connection to the MySQL DB. | [
"Creates",
"a",
"connection",
"to",
"the",
"MySQL",
"DB",
"."
] | train | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L103-L114 |
evetrivia/thanatos | thanatos/database/db_utils.py | get_default_connection_details | def get_default_connection_details():
""" Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict
"""
return {
'host': os.environ.get('MYSQL_HOST', '127.0.0.1'),
'user': os.environ.get('MY... | python | def get_default_connection_details():
""" Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict
"""
return {
'host': os.environ.get('MYSQL_HOST', '127.0.0.1'),
'user': os.environ.get('MY... | [
"def",
"get_default_connection_details",
"(",
")",
":",
"return",
"{",
"'host'",
":",
"os",
".",
"environ",
".",
"get",
"(",
"'MYSQL_HOST'",
",",
"'127.0.0.1'",
")",
",",
"'user'",
":",
"os",
".",
"environ",
".",
"get",
"(",
"'MYSQL_USER'",
",",
"'vagrant'... | Gets the connection details based on environment vars or Thanatos default settings.
:return: Returns a dictionary of connection details.
:rtype: dict | [
"Gets",
"the",
"connection",
"details",
"based",
"on",
"environment",
"vars",
"or",
"Thanatos",
"default",
"settings",
"."
] | train | https://github.com/evetrivia/thanatos/blob/664c12a8ccf4d27ab0e06e0969bbb6381f74789c/thanatos/database/db_utils.py#L117-L129 |
MaT1g3R/option | option/option_.py | Option.maybe | def maybe(cls, val: Optional[T]) -> 'Option[T]':
"""
Shortcut method to return ``Some`` or :py:data:`NONE` based on ``val``.
Args:
val: Some value.
Returns:
``Some(val)`` if the ``val`` is not None, otherwise :py:data:`NONE`.
Examples:
>>> O... | python | def maybe(cls, val: Optional[T]) -> 'Option[T]':
"""
Shortcut method to return ``Some`` or :py:data:`NONE` based on ``val``.
Args:
val: Some value.
Returns:
``Some(val)`` if the ``val`` is not None, otherwise :py:data:`NONE`.
Examples:
>>> O... | [
"def",
"maybe",
"(",
"cls",
",",
"val",
":",
"Optional",
"[",
"T",
"]",
")",
"->",
"'Option[T]'",
":",
"return",
"cast",
"(",
"'Option[T]'",
",",
"NONE",
")",
"if",
"val",
"is",
"None",
"else",
"cls",
".",
"Some",
"(",
"val",
")"
] | Shortcut method to return ``Some`` or :py:data:`NONE` based on ``val``.
Args:
val: Some value.
Returns:
``Some(val)`` if the ``val`` is not None, otherwise :py:data:`NONE`.
Examples:
>>> Option.maybe(0)
Some(0)
>>> Option.maybe(None)... | [
"Shortcut",
"method",
"to",
"return",
"Some",
"or",
":",
"py",
":",
"data",
":",
"NONE",
"based",
"on",
"val",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L85-L101 |
MaT1g3R/option | option/option_.py | Option.expect | def expect(self, msg) -> T:
"""
Unwraps the option. Raises an exception if the value is :py:data:`NONE`.
Args:
msg: The exception message.
Returns:
The wrapped value.
Raises:
``ValueError`` with message provided by ``msg`` if the value is :p... | python | def expect(self, msg) -> T:
"""
Unwraps the option. Raises an exception if the value is :py:data:`NONE`.
Args:
msg: The exception message.
Returns:
The wrapped value.
Raises:
``ValueError`` with message provided by ``msg`` if the value is :p... | [
"def",
"expect",
"(",
"self",
",",
"msg",
")",
"->",
"T",
":",
"if",
"self",
".",
"_is_some",
":",
"return",
"self",
".",
"_val",
"raise",
"ValueError",
"(",
"msg",
")"
] | Unwraps the option. Raises an exception if the value is :py:data:`NONE`.
Args:
msg: The exception message.
Returns:
The wrapped value.
Raises:
``ValueError`` with message provided by ``msg`` if the value is :py:data:`NONE`.
Examples:
>>... | [
"Unwraps",
"the",
"option",
".",
"Raises",
"an",
"exception",
"if",
"the",
"value",
"is",
":",
"py",
":",
"data",
":",
"NONE",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L144-L168 |
MaT1g3R/option | option/option_.py | Option.unwrap_or | def unwrap_or(self, default: U) -> Union[T, U]:
"""
Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
I... | python | def unwrap_or(self, default: U) -> Union[T, U]:
"""
Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
I... | [
"def",
"unwrap_or",
"(",
"self",
",",
"default",
":",
"U",
")",
"->",
"Union",
"[",
"T",
",",
"U",
"]",
":",
"return",
"self",
".",
"unwrap_or_else",
"(",
"lambda",
":",
"default",
")"
] | Returns the contained value or ``default``.
Args:
default: The default value.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``default``.
Notes:
If you wish to use a result of a function call as the default,
... | [
"Returns",
"the",
"contained",
"value",
"or",
"default",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L198-L219 |
MaT1g3R/option | option/option_.py | Option.unwrap_or_else | def unwrap_or_else(self, callback: Callable[[], U]) -> Union[T, U]:
"""
Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherw... | python | def unwrap_or_else(self, callback: Callable[[], U]) -> Union[T, U]:
"""
Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherw... | [
"def",
"unwrap_or_else",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"]",
",",
"U",
"]",
")",
"->",
"Union",
"[",
"T",
",",
"U",
"]",
":",
"return",
"self",
".",
"_val",
"if",
"self",
".",
"_is_some",
"else",
"callback",
"(",
")"
] | Returns the contained value or computes it from ``callback``.
Args:
callback: The the default callback.
Returns:
The contained value if the :py:class:`Option` is ``Some``,
otherwise ``callback()``.
Examples:
>>> Some(0).unwrap_or_else(lambda: 11... | [
"Returns",
"the",
"contained",
"value",
"or",
"computes",
"it",
"from",
"callback",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L221-L238 |
MaT1g3R/option | option/option_.py | Option.map | def map(self, callback: Callable[[T], U]) -> 'Option[U]':
"""
Applies the ``callback`` with the contained value as its argument or
returns :py:data:`NONE`.
Args:
callback: The callback to apply to the contained value.
Returns:
The ``callback`` result wra... | python | def map(self, callback: Callable[[T], U]) -> 'Option[U]':
"""
Applies the ``callback`` with the contained value as its argument or
returns :py:data:`NONE`.
Args:
callback: The callback to apply to the contained value.
Returns:
The ``callback`` result wra... | [
"def",
"map",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"U",
"]",
")",
"->",
"'Option[U]'",
":",
"return",
"self",
".",
"_type",
".",
"Some",
"(",
"callback",
"(",
"self",
".",
"_val",
")",
")",
"if",
"self",
".",
... | Applies the ``callback`` with the contained value as its argument or
returns :py:data:`NONE`.
Args:
callback: The callback to apply to the contained value.
Returns:
The ``callback`` result wrapped in an :class:`Option` if the
contained value is ``Some``, oth... | [
"Applies",
"the",
"callback",
"with",
"the",
"contained",
"value",
"as",
"its",
"argument",
"or",
"returns",
":",
"py",
":",
"data",
":",
"NONE",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L240-L258 |
MaT1g3R/option | option/option_.py | Option.map_or | def map_or(self, callback: Callable[[T], U], default: A) -> Union[U, A]:
"""
Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
Th... | python | def map_or(self, callback: Callable[[T], U], default: A) -> Union[U, A]:
"""
Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
Th... | [
"def",
"map_or",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"U",
"]",
",",
"default",
":",
"A",
")",
"->",
"Union",
"[",
"U",
",",
"A",
"]",
":",
"return",
"callback",
"(",
"self",
".",
"_val",
")",
"if",
"self",
... | Applies the ``callback`` to the contained value or returns ``default``.
Args:
callback: The callback to apply to the contained value.
default: The default value.
Returns:
The ``callback`` result if the contained value is ``Some``,
otherwise ``default``.
... | [
"Applies",
"the",
"callback",
"to",
"the",
"contained",
"value",
"or",
"returns",
"default",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L260-L282 |
MaT1g3R/option | option/option_.py | Option.flatmap | def flatmap(self, callback: 'Callable[[T], Option[U]]') -> 'Option[U]':
"""
Applies the callback to the contained value if the option
is not :py:data:`NONE`.
This is different than :py:meth:`Option.map` because the result
of the callback isn't wrapped in a new :py:class:`Option`... | python | def flatmap(self, callback: 'Callable[[T], Option[U]]') -> 'Option[U]':
"""
Applies the callback to the contained value if the option
is not :py:data:`NONE`.
This is different than :py:meth:`Option.map` because the result
of the callback isn't wrapped in a new :py:class:`Option`... | [
"def",
"flatmap",
"(",
"self",
",",
"callback",
":",
"'Callable[[T], Option[U]]'",
")",
"->",
"'Option[U]'",
":",
"return",
"callback",
"(",
"self",
".",
"_val",
")",
"if",
"self",
".",
"_is_some",
"else",
"cast",
"(",
"'Option[U]'",
",",
"NONE",
")"
] | Applies the callback to the contained value if the option
is not :py:data:`NONE`.
This is different than :py:meth:`Option.map` because the result
of the callback isn't wrapped in a new :py:class:`Option`
Args:
callback: The callback to apply to the contained value.
... | [
"Applies",
"the",
"callback",
"to",
"the",
"contained",
"value",
"if",
"the",
"option",
"is",
"not",
":",
"py",
":",
"data",
":",
"NONE",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L305-L334 |
MaT1g3R/option | option/option_.py | Option.filter | def filter(self, predicate: Callable[[T], bool]) -> 'Option[T]':
"""
Returns :py:data:`NONE` if the :py:class:`Option` is :py:data:`NONE`,
otherwise filter the contained value by ``predicate``.
Args:
predicate: The fitler function.
Returns:
:py:data:`NON... | python | def filter(self, predicate: Callable[[T], bool]) -> 'Option[T]':
"""
Returns :py:data:`NONE` if the :py:class:`Option` is :py:data:`NONE`,
otherwise filter the contained value by ``predicate``.
Args:
predicate: The fitler function.
Returns:
:py:data:`NON... | [
"def",
"filter",
"(",
"self",
",",
"predicate",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"bool",
"]",
")",
"->",
"'Option[T]'",
":",
"if",
"self",
".",
"_is_some",
"and",
"predicate",
"(",
"self",
".",
"_val",
")",
":",
"return",
"self",
"return",
... | Returns :py:data:`NONE` if the :py:class:`Option` is :py:data:`NONE`,
otherwise filter the contained value by ``predicate``.
Args:
predicate: The fitler function.
Returns:
:py:data:`NONE` if the contained value is :py:data:`NONE`, otherwise:
* The option... | [
"Returns",
":",
"py",
":",
"data",
":",
"NONE",
"if",
"the",
":",
"py",
":",
"class",
":",
"Option",
"is",
":",
"py",
":",
"data",
":",
"NONE",
"otherwise",
"filter",
"the",
"contained",
"value",
"by",
"predicate",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L336-L359 |
MaT1g3R/option | option/option_.py | Option.get | def get(
self: 'Option[Mapping[K,V]]',
key: K,
default=None
) -> 'Option[V]':
"""
Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The ... | python | def get(
self: 'Option[Mapping[K,V]]',
key: K,
default=None
) -> 'Option[V]':
"""
Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The ... | [
"def",
"get",
"(",
"self",
":",
"'Option[Mapping[K,V]]'",
",",
"key",
":",
"K",
",",
"default",
"=",
"None",
")",
"->",
"'Option[V]'",
":",
"if",
"self",
".",
"_is_some",
":",
"return",
"self",
".",
"_type",
".",
"maybe",
"(",
"self",
".",
"_val",
".... | Gets a mapping value by key in the contained value or returns
``default`` if the key doesn't exist.
Args:
key: The mapping key.
default: The defauilt value.
Returns:
* ``Some`` variant of the mapping value if the key exists
and the value is no... | [
"Gets",
"a",
"mapping",
"value",
"by",
"key",
"in",
"the",
"contained",
"value",
"or",
"returns",
"default",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"."
] | train | https://github.com/MaT1g3R/option/blob/37c954e6e74273d48649b3236bc881a1286107d6/option/option_.py#L361-L392 |
miquelo/resort | packages/resort/component/docker.py | Image.insert | def insert(self, context):
"""
Build the image.
:param resort.engine.execution.Context context:
Current execution context.
"""
try:
current_dir = os.getcwd()
os.chdir(os.path.join(context.profile_dir(), self.__base_dir))
args = [
"packer",
"build",
self.__template_path
]
... | python | def insert(self, context):
"""
Build the image.
:param resort.engine.execution.Context context:
Current execution context.
"""
try:
current_dir = os.getcwd()
os.chdir(os.path.join(context.profile_dir(), self.__base_dir))
args = [
"packer",
"build",
self.__template_path
]
... | [
"def",
"insert",
"(",
"self",
",",
"context",
")",
":",
"try",
":",
"current_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"context",
".",
"profile_dir",
"(",
")",
",",
"self",
".",
"__bas... | Build the image.
:param resort.engine.execution.Context context:
Current execution context. | [
"Build",
"the",
"image",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/docker.py#L58-L78 |
joar/mig | mig/__init__.py | assure_migrations_table_setup | def assure_migrations_table_setup(db):
"""
Make sure the migrations table is set up in the database.
"""
from mig.models import MigrationData
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__]) | python | def assure_migrations_table_setup(db):
"""
Make sure the migrations table is set up in the database.
"""
from mig.models import MigrationData
if not MigrationData.__table__.exists(db.bind):
MigrationData.metadata.create_all(
db.bind, tables=[MigrationData.__table__]) | [
"def",
"assure_migrations_table_setup",
"(",
"db",
")",
":",
"from",
"mig",
".",
"models",
"import",
"MigrationData",
"if",
"not",
"MigrationData",
".",
"__table__",
".",
"exists",
"(",
"db",
".",
"bind",
")",
":",
"MigrationData",
".",
"metadata",
".",
"cre... | Make sure the migrations table is set up in the database. | [
"Make",
"sure",
"the",
"migrations",
"table",
"is",
"set",
"up",
"in",
"the",
"database",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L280-L288 |
joar/mig | mig/__init__.py | MigrationManager.sorted_migrations | def sorted_migrations(self):
"""
Sort migrations if necessary and store in self._sorted_migrations
"""
if not self._sorted_migrations:
self._sorted_migrations = sorted(
self.migration_registry.items(),
# sort on the key... the migration number
... | python | def sorted_migrations(self):
"""
Sort migrations if necessary and store in self._sorted_migrations
"""
if not self._sorted_migrations:
self._sorted_migrations = sorted(
self.migration_registry.items(),
# sort on the key... the migration number
... | [
"def",
"sorted_migrations",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sorted_migrations",
":",
"self",
".",
"_sorted_migrations",
"=",
"sorted",
"(",
"self",
".",
"migration_registry",
".",
"items",
"(",
")",
",",
"# sort on the key... the migration numbe... | Sort migrations if necessary and store in self._sorted_migrations | [
"Sort",
"migrations",
"if",
"necessary",
"and",
"store",
"in",
"self",
".",
"_sorted_migrations"
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L75-L85 |
joar/mig | mig/__init__.py | MigrationManager.migration_data | def migration_data(self):
"""
Get the migration row associated with this object, if any.
"""
return self.session.query(
self.migration_model).filter_by(name=self.name).first() | python | def migration_data(self):
"""
Get the migration row associated with this object, if any.
"""
return self.session.query(
self.migration_model).filter_by(name=self.name).first() | [
"def",
"migration_data",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"self",
".",
"migration_model",
")",
".",
"filter_by",
"(",
"name",
"=",
"self",
".",
"name",
")",
".",
"first",
"(",
")"
] | Get the migration row associated with this object, if any. | [
"Get",
"the",
"migration",
"row",
"associated",
"with",
"this",
"object",
"if",
"any",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L88-L93 |
joar/mig | mig/__init__.py | MigrationManager.database_current_migration | def database_current_migration(self):
"""
Return the current migration in the database.
"""
# If the table doesn't even exist, return None.
if not self.migration_table.exists(self.session.bind):
return None
# Also return None if self.migration_data is None.
... | python | def database_current_migration(self):
"""
Return the current migration in the database.
"""
# If the table doesn't even exist, return None.
if not self.migration_table.exists(self.session.bind):
return None
# Also return None if self.migration_data is None.
... | [
"def",
"database_current_migration",
"(",
"self",
")",
":",
"# If the table doesn't even exist, return None.",
"if",
"not",
"self",
".",
"migration_table",
".",
"exists",
"(",
"self",
".",
"session",
".",
"bind",
")",
":",
"return",
"None",
"# Also return None if self... | Return the current migration in the database. | [
"Return",
"the",
"current",
"migration",
"in",
"the",
"database",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L108-L120 |
joar/mig | mig/__init__.py | MigrationManager.set_current_migration | def set_current_migration(self, migration_number=None):
"""
Set the migration in the database to migration_number
(or, the latest available)
"""
self.migration_data.version = migration_number or self.latest_migration
self.session.commit() | python | def set_current_migration(self, migration_number=None):
"""
Set the migration in the database to migration_number
(or, the latest available)
"""
self.migration_data.version = migration_number or self.latest_migration
self.session.commit() | [
"def",
"set_current_migration",
"(",
"self",
",",
"migration_number",
"=",
"None",
")",
":",
"self",
".",
"migration_data",
".",
"version",
"=",
"migration_number",
"or",
"self",
".",
"latest_migration",
"self",
".",
"session",
".",
"commit",
"(",
")"
] | Set the migration in the database to migration_number
(or, the latest available) | [
"Set",
"the",
"migration",
"in",
"the",
"database",
"to",
"migration_number",
"(",
"or",
"the",
"latest",
"available",
")"
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L122-L128 |
joar/mig | mig/__init__.py | MigrationManager.migrations_to_run | def migrations_to_run(self):
"""
Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class!
"""
assert self.database_current_migration is not None
db_current_migration = self.database_current_migration
... | python | def migrations_to_run(self):
"""
Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class!
"""
assert self.database_current_migration is not None
db_current_migration = self.database_current_migration
... | [
"def",
"migrations_to_run",
"(",
"self",
")",
":",
"assert",
"self",
".",
"database_current_migration",
"is",
"not",
"None",
"db_current_migration",
"=",
"self",
".",
"database_current_migration",
"return",
"[",
"(",
"migration_number",
",",
"migration_func",
")",
"... | Get a list of migrations to run still, if any.
Note that this will fail if there's no migration record for
this class! | [
"Get",
"a",
"list",
"of",
"migrations",
"to",
"run",
"still",
"if",
"any",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L130-L144 |
joar/mig | mig/__init__.py | MigrationManager.init_tables | def init_tables(self):
"""
Create all tables relative to this package
"""
# sanity check before we proceed, none of these should be created
for model in self.models:
# Maybe in the future just print out a "Yikes!" or something?
_log.debug('Checking for tab... | python | def init_tables(self):
"""
Create all tables relative to this package
"""
# sanity check before we proceed, none of these should be created
for model in self.models:
# Maybe in the future just print out a "Yikes!" or something?
_log.debug('Checking for tab... | [
"def",
"init_tables",
"(",
"self",
")",
":",
"# sanity check before we proceed, none of these should be created",
"for",
"model",
"in",
"self",
".",
"models",
":",
"# Maybe in the future just print out a \"Yikes!\" or something?",
"_log",
".",
"debug",
"(",
"'Checking for table... | Create all tables relative to this package | [
"Create",
"all",
"tables",
"relative",
"to",
"this",
"package"
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L146-L159 |
joar/mig | mig/__init__.py | MigrationManager.create_new_migration_record | def create_new_migration_record(self):
"""
Create a new migration record for this migration set
"""
migration_record = self.migration_model(
name=self.name,
version=self.latest_migration)
self.session.add(migration_record)
self.session.commit() | python | def create_new_migration_record(self):
"""
Create a new migration record for this migration set
"""
migration_record = self.migration_model(
name=self.name,
version=self.latest_migration)
self.session.add(migration_record)
self.session.commit() | [
"def",
"create_new_migration_record",
"(",
"self",
")",
":",
"migration_record",
"=",
"self",
".",
"migration_model",
"(",
"name",
"=",
"self",
".",
"name",
",",
"version",
"=",
"self",
".",
"latest_migration",
")",
"self",
".",
"session",
".",
"add",
"(",
... | Create a new migration record for this migration set | [
"Create",
"a",
"new",
"migration",
"record",
"for",
"this",
"migration",
"set"
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L161-L169 |
joar/mig | mig/__init__.py | MigrationManager.dry_run | def dry_run(self):
"""
Print out a dry run of what we would have upgraded.
"""
if self.database_current_migration is None:
self.printer(
u'~> Woulda initialized: %s\n' % self.name_for_printing())
return u'inited'
migrations_to_run = se... | python | def dry_run(self):
"""
Print out a dry run of what we would have upgraded.
"""
if self.database_current_migration is None:
self.printer(
u'~> Woulda initialized: %s\n' % self.name_for_printing())
return u'inited'
migrations_to_run = se... | [
"def",
"dry_run",
"(",
"self",
")",
":",
"if",
"self",
".",
"database_current_migration",
"is",
"None",
":",
"self",
".",
"printer",
"(",
"u'~> Woulda initialized: %s\\n'",
"%",
"self",
".",
"name_for_printing",
"(",
")",
")",
"return",
"u'inited'",
"migrations_... | Print out a dry run of what we would have upgraded. | [
"Print",
"out",
"a",
"dry",
"run",
"of",
"what",
"we",
"would",
"have",
"upgraded",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L171-L190 |
joar/mig | mig/__init__.py | MigrationManager.init_or_migrate | def init_or_migrate(self):
"""
Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None)
"""
assure_migrations_table_setup(self.session)
# Find out what mig... | python | def init_or_migrate(self):
"""
Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None)
"""
assure_migrations_table_setup(self.session)
# Find out what mig... | [
"def",
"init_or_migrate",
"(",
"self",
")",
":",
"assure_migrations_table_setup",
"(",
"self",
".",
"session",
")",
"# Find out what migration number, if any, this database data is at,",
"# and what the latest is.",
"migration_number",
"=",
"self",
".",
"database_current_migratio... | Initialize the database or migrate if appropriate.
Returns information about whether or not we initialized
('inited'), migrated ('migrated'), or did nothing (None) | [
"Initialize",
"the",
"database",
"or",
"migrate",
"if",
"appropriate",
"."
] | train | https://github.com/joar/mig/blob/e1a7a8b9ea5941a05a27d5afbb5952965bb20ae5/mig/__init__.py#L199-L247 |
kejbaly2/members | members/github_repo.py | _logins | def _logins(users, user_attrs=None):
'''
FIXME: DOCS...
'''
# FIXME: check for support attrs
# Supported attrs:
# login # DEFAULT, no auth required
# email
# bio
# company
# created_at
# hireable
# location
# updated_at
# url
# 'login' will be the dict ... | python | def _logins(users, user_attrs=None):
'''
FIXME: DOCS...
'''
# FIXME: check for support attrs
# Supported attrs:
# login # DEFAULT, no auth required
# email
# bio
# company
# created_at
# hireable
# location
# updated_at
# url
# 'login' will be the dict ... | [
"def",
"_logins",
"(",
"users",
",",
"user_attrs",
"=",
"None",
")",
":",
"# FIXME: check for support attrs",
"# Supported attrs:",
"# login # DEFAULT, no auth required",
"# email",
"# bio",
"# company",
"# created_at",
"# hireable",
"# location",
"# updated_at",
"# url",
... | FIXME: DOCS... | [
"FIXME",
":",
"DOCS",
"..."
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/github_repo.py#L29-L61 |
kejbaly2/members | members/github_repo.py | extract | def extract(repo_url=None, target=None, user=None, password=None, token=None,
user_attrs=None):
'''
FIXME: DOCS...
'''
if not repo_url:
raise RuntimeError("URI must be specified")
if target not in TARGETS.keys():
raise RuntimeError("Unknown members target [{}]".format(ta... | python | def extract(repo_url=None, target=None, user=None, password=None, token=None,
user_attrs=None):
'''
FIXME: DOCS...
'''
if not repo_url:
raise RuntimeError("URI must be specified")
if target not in TARGETS.keys():
raise RuntimeError("Unknown members target [{}]".format(ta... | [
"def",
"extract",
"(",
"repo_url",
"=",
"None",
",",
"target",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"token",
"=",
"None",
",",
"user_attrs",
"=",
"None",
")",
":",
"if",
"not",
"repo_url",
":",
"raise",
"RuntimeEr... | FIXME: DOCS... | [
"FIXME",
":",
"DOCS",
"..."
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/github_repo.py#L64-L110 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/setup/__init__.py | cli | def cli(ctx):
"""
Run setup after a fresh Vagrant installation.
"""
log = logging.getLogger('ipsv.setup')
assert isinstance(ctx, Context)
lock_path = os.path.join(ctx.config.get('Paths', 'Data'), 'setup.lck')
if os.path.exists(lock_path):
raise Exception('Setup is locked, please rem... | python | def cli(ctx):
"""
Run setup after a fresh Vagrant installation.
"""
log = logging.getLogger('ipsv.setup')
assert isinstance(ctx, Context)
lock_path = os.path.join(ctx.config.get('Paths', 'Data'), 'setup.lck')
if os.path.exists(lock_path):
raise Exception('Setup is locked, please rem... | [
"def",
"cli",
"(",
"ctx",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'ipsv.setup'",
")",
"assert",
"isinstance",
"(",
"ctx",
",",
"Context",
")",
"lock_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"ctx",
".",
"config",
".",
"get",
... | Run setup after a fresh Vagrant installation. | [
"Run",
"setup",
"after",
"a",
"fresh",
"Vagrant",
"installation",
"."
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/setup/__init__.py#L20-L201 |
jmgilman/Neolib | neolib/pyamf/remoting/amf0.py | build_fault | def build_fault(cls, e, tb, include_traceback=False):
"""
Builds a L{ErrorFault<pyamf.remoting.ErrorFault>} object based on the last
exception raised.
If include_traceback is C{False} then the traceback will not be added to
the L{remoting.ErrorFault}.
"""
if hasattr(cls, '_amf_code'):
... | python | def build_fault(cls, e, tb, include_traceback=False):
"""
Builds a L{ErrorFault<pyamf.remoting.ErrorFault>} object based on the last
exception raised.
If include_traceback is C{False} then the traceback will not be added to
the L{remoting.ErrorFault}.
"""
if hasattr(cls, '_amf_code'):
... | [
"def",
"build_fault",
"(",
"cls",
",",
"e",
",",
"tb",
",",
"include_traceback",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"'_amf_code'",
")",
":",
"code",
"=",
"cls",
".",
"_amf_code",
"else",
":",
"code",
"=",
"cls",
".",
"__name__"... | Builds a L{ErrorFault<pyamf.remoting.ErrorFault>} object based on the last
exception raised.
If include_traceback is C{False} then the traceback will not be added to
the L{remoting.ErrorFault}. | [
"Builds",
"a",
"L",
"{",
"ErrorFault<pyamf",
".",
"remoting",
".",
"ErrorFault",
">",
"}",
"object",
"based",
"on",
"the",
"last",
"exception",
"raised",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/amf0.py#L117-L135 |
jmgilman/Neolib | neolib/pyamf/remoting/amf0.py | RequestProcessor.authenticateRequest | def authenticateRequest(self, request, service_request, *args, **kwargs):
"""
Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
"""
username = password = None
if 'Credentials' in requ... | python | def authenticateRequest(self, request, service_request, *args, **kwargs):
"""
Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
"""
username = password = None
if 'Credentials' in requ... | [
"def",
"authenticateRequest",
"(",
"self",
",",
"request",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"username",
"=",
"password",
"=",
"None",
"if",
"'Credentials'",
"in",
"request",
".",
"headers",
":",
"cred",
"=",
"r... | Authenticates the request against the service.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>} | [
"Authenticates",
"the",
"request",
"against",
"the",
"service",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/amf0.py#L21-L37 |
jmgilman/Neolib | neolib/pyamf/remoting/amf0.py | RequestProcessor.buildErrorResponse | def buildErrorResponse(self, request, error=None):
"""
Builds an error response.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
@return: The AMF response
@rtype: L{Response<pyamf.remoting.Response>}
"""
if error is not N... | python | def buildErrorResponse(self, request, error=None):
"""
Builds an error response.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
@return: The AMF response
@rtype: L{Response<pyamf.remoting.Response>}
"""
if error is not N... | [
"def",
"buildErrorResponse",
"(",
"self",
",",
"request",
",",
"error",
"=",
"None",
")",
":",
"if",
"error",
"is",
"not",
"None",
":",
"cls",
",",
"e",
",",
"tb",
"=",
"error",
"else",
":",
"cls",
",",
"e",
",",
"tb",
"=",
"sys",
".",
"exc_info"... | Builds an error response.
@param request: The AMF request
@type request: L{Request<pyamf.remoting.Request>}
@return: The AMF response
@rtype: L{Response<pyamf.remoting.Response>} | [
"Builds",
"an",
"error",
"response",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/amf0.py#L39-L54 |
KnowledgeLinks/rdfframework | rdfframework/utilities/debug.py | dumpable_obj | def dumpable_obj(obj):
''' takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading'''
if isinstance(obj, list):
_return_list = []
for item in obj:
if isinsta... | python | def dumpable_obj(obj):
''' takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading'''
if isinstance(obj, list):
_return_list = []
for item in obj:
if isinsta... | [
"def",
"dumpable_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"_return_list",
"=",
"[",
"]",
"for",
"item",
"in",
"obj",
":",
"if",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"_return_list",
".",
"append",... | takes an object that fails with json.dumps and converts it to
a json.dumps dumpable object. This is useful for debuging code when
you want to dump an object for easy reading | [
"takes",
"an",
"object",
"that",
"fails",
"with",
"json",
".",
"dumps",
"and",
"converts",
"it",
"to",
"a",
"json",
".",
"dumps",
"dumpable",
"object",
".",
"This",
"is",
"useful",
"for",
"debuging",
"code",
"when",
"you",
"want",
"to",
"dump",
"an",
"... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/debug.py#L13-L57 |
moagstar/table2dicts | table2dicts.py | table2dicts | def table2dicts(html):
"""
Converts a html table to a list of dictionaries, for example:
>>> table2dicts('''
... <table>
... <thead>
... <tr><th>a</th><th>b</th><th>c</th></tr>
... </thead>
... <tbody>
... <tr><td>1</td><td>2</td><t... | python | def table2dicts(html):
"""
Converts a html table to a list of dictionaries, for example:
>>> table2dicts('''
... <table>
... <thead>
... <tr><th>a</th><th>b</th><th>c</th></tr>
... </thead>
... <tbody>
... <tr><td>1</td><td>2</td><t... | [
"def",
"table2dicts",
"(",
"html",
")",
":",
"def",
"_get_headers_and_values",
"(",
"soup",
")",
":",
"headers",
"=",
"[",
"x",
".",
"string",
"or",
"''",
"for",
"x",
"in",
"soup",
".",
"select",
"(",
"'table tr th'",
")",
"]",
"if",
"len",
"(",
"hea... | Converts a html table to a list of dictionaries, for example:
>>> table2dicts('''
... <table>
... <thead>
... <tr><th>a</th><th>b</th><th>c</th></tr>
... </thead>
... <tbody>
... <tr><td>1</td><td>2</td><td>3</td></tr>
... <... | [
"Converts",
"a",
"html",
"table",
"to",
"a",
"list",
"of",
"dictionaries",
"for",
"example",
":"
] | train | https://github.com/moagstar/table2dicts/blob/e02bcaa79e24587751f3ccb7124eeb2c38f49dc3/table2dicts.py#L10-L73 |
svasilev94/GraphLibrary | graphlibrary/paths.py | find_all_paths | def find_all_paths(G, start, end, path=[]):
"""
Find all paths between vertices start and end in graph.
"""
path = path + [start]
if start == end:
return [path]
if start not in G.vertices:
raise GraphInsertError("Vertex %s doesn't exist." % (start,))
if end not in G.... | python | def find_all_paths(G, start, end, path=[]):
"""
Find all paths between vertices start and end in graph.
"""
path = path + [start]
if start == end:
return [path]
if start not in G.vertices:
raise GraphInsertError("Vertex %s doesn't exist." % (start,))
if end not in G.... | [
"def",
"find_all_paths",
"(",
"G",
",",
"start",
",",
"end",
",",
"path",
"=",
"[",
"]",
")",
":",
"path",
"=",
"path",
"+",
"[",
"start",
"]",
"if",
"start",
"==",
"end",
":",
"return",
"[",
"path",
"]",
"if",
"start",
"not",
"in",
"G",
".",
... | Find all paths between vertices start and end in graph. | [
"Find",
"all",
"paths",
"between",
"vertices",
"start",
"and",
"end",
"in",
"graph",
"."
] | train | https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/paths.py#L6-L23 |
unixorn/haze | setup.py | system_call | def system_call(command):
"""Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7."""
p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
return p.stdout.read() | python | def system_call(command):
"""Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7."""
p = subprocess.Popen([command], stdout=subprocess.PIPE, shell=True)
return p.stdout.read() | [
"def",
"system_call",
"(",
"command",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"command",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"shell",
"=",
"True",
")",
"return",
"p",
".",
"stdout",
".",
"read",
"(",
")"
] | Run a command and return stdout.
Would be better to use subprocess.check_output, but this works on 2.6,
which is still the system Python on CentOS 7. | [
"Run",
"a",
"command",
"and",
"return",
"stdout",
"."
] | train | https://github.com/unixorn/haze/blob/77692b18e6574ac356e3e16659b96505c733afff/setup.py#L30-L36 |
lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator.get_headers | def get_headers(self, session, **kwargs):
"""Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | python | def get_headers(self, session, **kwargs):
"""Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | [
"def",
"get_headers",
"(",
"self",
",",
"session",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"auth_token",
"is",
"None",
":",
"try",
":",
"self",
".",
"_refresh_tokens",
"(",
"session",
")",
"self",
".",
"_fetch_credentials",
"(",
"session",
... | Get the authentication header.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
queries.
:raises key... | [
"Get",
"the",
"authentication",
"header",
"."
] | train | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L66-L91 |
lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator.get_endpoint | def get_endpoint(self, session, **kwargs):
"""Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | python | def get_endpoint(self, session, **kwargs):
"""Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
... | [
"def",
"get_endpoint",
"(",
"self",
",",
"session",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"endpoint",
"is",
"None",
":",
"try",
":",
"self",
".",
"_refresh_tokens",
"(",
"session",
")",
"self",
".",
"_fetch_credentials",
"(",
"session",
... | Get the HubiC storage endpoint uri.
If the current session has not been authenticated, this will trigger a
new authentication to the HubiC OAuth service.
:param keystoneclient.Session session: The session object to use for
queries.
:raise... | [
"Get",
"the",
"HubiC",
"storage",
"endpoint",
"uri",
"."
] | train | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L94-L117 |
lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._refresh_tokens | def _refresh_tokens(self, session):
"""Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to ... | python | def _refresh_tokens(self, session):
"""Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to ... | [
"def",
"_refresh_tokens",
"(",
"self",
",",
"session",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"}",
"payload",
"=",
"{",
"'client_id'",
":",
"self",
".",
... | Request an access and a refresh token from the HubiC API.
Those tokens are mandatory and will be used for subsequent file
operations. They are not returned and will be stored internaly.
:param keystoneclient.Session session: The session object to use for
... | [
"Request",
"an",
"access",
"and",
"a",
"refresh",
"token",
"from",
"the",
"HubiC",
"API",
"."
] | train | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L141-L203 |
lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._fetch_credentials | def _fetch_credentials(self, session):
"""Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use f... | python | def _fetch_credentials(self, session):
"""Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use f... | [
"def",
"_fetch_credentials",
"(",
"self",
",",
"session",
")",
":",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer {0}'",
".",
"format",
"(",
"self",
".",
"access_token",
")",
",",
"}",
"r",
"=",
"session",
".",
"get",
"(",
"\"https://api.hubic.com/1.... | Fetch the endpoint URI and authorization token for this session.
Those two information are the basis for all future calls to the Swift
(OpenStack) API for the storage container.
:param keystoneclient.Session session: The session object to use for
... | [
"Fetch",
"the",
"endpoint",
"URI",
"and",
"authorization",
"token",
"for",
"this",
"session",
"."
] | train | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L206-L234 |
lduchesne/python-openstacksdk-hubic | hubic/hubic.py | HubiCAuthenticator._get_authorization_token | def _get_authorization_token(self, session):
"""Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.Au... | python | def _get_authorization_token(self, session):
"""Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.Au... | [
"def",
"_get_authorization_token",
"(",
"self",
",",
"session",
")",
":",
"request_scope",
"=",
"'account.r,credentials.r'",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'redirect_uri'",
":",
"self",
".",
"redirect_uri",
",",
"'response_... | Load the HubiC form, submit it and return an authorization token.
This will load the HTML form to accept if the application can access
the user account and submit the form using the user's credentials.
:raises keystoneclient.exceptions.AuthorizationFailure: if something
... | [
"Load",
"the",
"HubiC",
"form",
"submit",
"it",
"and",
"return",
"an",
"authorization",
"token",
"."
] | train | https://github.com/lduchesne/python-openstacksdk-hubic/blob/25e752f847613bb7e068c05e094a8abadaa7925a/hubic/hubic.py#L237-L314 |
jmgilman/Neolib | neolib/pyamf/codec.py | IndexedCollection.append | def append(self, obj):
"""
Appends C{obj} to this index.
@note: Uniqueness is not checked
@return: The reference to C{obj} in this index.
"""
h = self.func(obj)
self.list.append(obj)
idx = len(self.list) - 1
self.dict[h] = idx
return idx | python | def append(self, obj):
"""
Appends C{obj} to this index.
@note: Uniqueness is not checked
@return: The reference to C{obj} in this index.
"""
h = self.func(obj)
self.list.append(obj)
idx = len(self.list) - 1
self.dict[h] = idx
return idx | [
"def",
"append",
"(",
"self",
",",
"obj",
")",
":",
"h",
"=",
"self",
".",
"func",
"(",
"obj",
")",
"self",
".",
"list",
".",
"append",
"(",
"obj",
")",
"idx",
"=",
"len",
"(",
"self",
".",
"list",
")",
"-",
"1",
"self",
".",
"dict",
"[",
"... | Appends C{obj} to this index.
@note: Uniqueness is not checked
@return: The reference to C{obj} in this index. | [
"Appends",
"C",
"{",
"obj",
"}",
"to",
"this",
"index",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L80-L93 |
jmgilman/Neolib | neolib/pyamf/codec.py | Context.clear | def clear(self):
"""
Clears the context.
"""
self._objects.clear()
self._class_aliases = {}
self._unicodes = {}
self.extra = {} | python | def clear(self):
"""
Clears the context.
"""
self._objects.clear()
self._class_aliases = {}
self._unicodes = {}
self.extra = {} | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"_objects",
".",
"clear",
"(",
")",
"self",
".",
"_class_aliases",
"=",
"{",
"}",
"self",
".",
"_unicodes",
"=",
"{",
"}",
"self",
".",
"extra",
"=",
"{",
"}"
] | Clears the context. | [
"Clears",
"the",
"context",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L144-L151 |
jmgilman/Neolib | neolib/pyamf/codec.py | Context.getClassAlias | def getClassAlias(self, klass):
"""
Gets a class alias based on the supplied C{klass}. If one is not found
in the global context, one is created locally.
If you supply a string alias and the class is not registered,
L{pyamf.UnknownClassAlias} will be raised.
@param klas... | python | def getClassAlias(self, klass):
"""
Gets a class alias based on the supplied C{klass}. If one is not found
in the global context, one is created locally.
If you supply a string alias and the class is not registered,
L{pyamf.UnknownClassAlias} will be raised.
@param klas... | [
"def",
"getClassAlias",
"(",
"self",
",",
"klass",
")",
":",
"try",
":",
"return",
"self",
".",
"_class_aliases",
"[",
"klass",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"alias",
"=",
"self",
".",
"_class_aliases",
"[",
"klass",
"]",
"=",
"py... | Gets a class alias based on the supplied C{klass}. If one is not found
in the global context, one is created locally.
If you supply a string alias and the class is not registered,
L{pyamf.UnknownClassAlias} will be raised.
@param klass: A class object or string alias.
@return: ... | [
"Gets",
"a",
"class",
"alias",
"based",
"on",
"the",
"supplied",
"C",
"{",
"klass",
"}",
".",
"If",
"one",
"is",
"not",
"found",
"in",
"the",
"global",
"context",
"one",
"is",
"created",
"locally",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L180-L209 |
jmgilman/Neolib | neolib/pyamf/codec.py | Context.getStringForBytes | def getStringForBytes(self, s):
"""
Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6
"""
h = hash(s)
u = self._unicodes.get(h, None)
if u is not None:
return u
... | python | def getStringForBytes(self, s):
"""
Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6
"""
h = hash(s)
u = self._unicodes.get(h, None)
if u is not None:
return u
... | [
"def",
"getStringForBytes",
"(",
"self",
",",
"s",
")",
":",
"h",
"=",
"hash",
"(",
"s",
")",
"u",
"=",
"self",
".",
"_unicodes",
".",
"get",
"(",
"h",
",",
"None",
")",
"if",
"u",
"is",
"not",
"None",
":",
"return",
"u",
"u",
"=",
"self",
".... | Returns the corresponding string for the supplied utf-8 encoded bytes.
If there is no string object, one is created.
@since: 0.6 | [
"Returns",
"the",
"corresponding",
"string",
"for",
"the",
"supplied",
"utf",
"-",
"8",
"encoded",
"bytes",
".",
"If",
"there",
"is",
"no",
"string",
"object",
"one",
"is",
"created",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L211-L226 |
jmgilman/Neolib | neolib/pyamf/codec.py | Context.getBytesForString | def getBytesForString(self, u):
"""
Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6
"""
h = hash(u)
s = self._unicodes.get(h, None)
if s is not None:
return s
... | python | def getBytesForString(self, u):
"""
Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6
"""
h = hash(u)
s = self._unicodes.get(h, None)
if s is not None:
return s
... | [
"def",
"getBytesForString",
"(",
"self",
",",
"u",
")",
":",
"h",
"=",
"hash",
"(",
"u",
")",
"s",
"=",
"self",
".",
"_unicodes",
".",
"get",
"(",
"h",
",",
"None",
")",
"if",
"s",
"is",
"not",
"None",
":",
"return",
"s",
"s",
"=",
"self",
".... | Returns the corresponding utf-8 encoded string for a given unicode
object. If there is no string, one is encoded.
@since: 0.6 | [
"Returns",
"the",
"corresponding",
"utf",
"-",
"8",
"encoded",
"string",
"for",
"a",
"given",
"unicode",
"object",
".",
"If",
"there",
"is",
"no",
"string",
"one",
"is",
"encoded",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L228-L243 |
jmgilman/Neolib | neolib/pyamf/codec.py | Decoder.readElement | def readElement(self):
"""
Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode.
"""
pos = self.stream.tell()
try:
t = self.stream.read(1)
except IO... | python | def readElement(self):
"""
Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode.
"""
pos = self.stream.tell()
try:
t = self.stream.read(1)
except IO... | [
"def",
"readElement",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"stream",
".",
"tell",
"(",
")",
"try",
":",
"t",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"1",
")",
"except",
"IOError",
":",
"raise",
"pyamf",
".",
"EOStream",
"try",
":... | Reads an AMF3 element from the data stream.
@raise DecodeError: The ActionScript type is unsupported.
@raise EOStream: No more data left to decode. | [
"Reads",
"an",
"AMF3",
"element",
"from",
"the",
"data",
"stream",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L312-L342 |
jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.writeSequence | def writeSequence(self, iterable):
"""
Encodes an iterable. The default is to write If the iterable has an al
"""
try:
alias = self.context.getClassAlias(iterable.__class__)
except (AttributeError, pyamf.UnknownClassAlias):
self.writeList(iterable)
... | python | def writeSequence(self, iterable):
"""
Encodes an iterable. The default is to write If the iterable has an al
"""
try:
alias = self.context.getClassAlias(iterable.__class__)
except (AttributeError, pyamf.UnknownClassAlias):
self.writeList(iterable)
... | [
"def",
"writeSequence",
"(",
"self",
",",
"iterable",
")",
":",
"try",
":",
"alias",
"=",
"self",
".",
"context",
".",
"getClassAlias",
"(",
"iterable",
".",
"__class__",
")",
"except",
"(",
"AttributeError",
",",
"pyamf",
".",
"UnknownClassAlias",
")",
":... | Encodes an iterable. The default is to write If the iterable has an al | [
"Encodes",
"an",
"iterable",
".",
"The",
"default",
"is",
"to",
"write",
"If",
"the",
"iterable",
"has",
"an",
"al"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L391-L409 |
jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.writeGenerator | def writeGenerator(self, gen):
"""
Iterates over a generator object and encodes all that is returned.
"""
n = getattr(gen, 'next')
while True:
try:
self.writeElement(n())
except StopIteration:
break | python | def writeGenerator(self, gen):
"""
Iterates over a generator object and encodes all that is returned.
"""
n = getattr(gen, 'next')
while True:
try:
self.writeElement(n())
except StopIteration:
break | [
"def",
"writeGenerator",
"(",
"self",
",",
"gen",
")",
":",
"n",
"=",
"getattr",
"(",
"gen",
",",
"'next'",
")",
"while",
"True",
":",
"try",
":",
"self",
".",
"writeElement",
"(",
"n",
"(",
")",
")",
"except",
"StopIteration",
":",
"break"
] | Iterates over a generator object and encodes all that is returned. | [
"Iterates",
"over",
"a",
"generator",
"object",
"and",
"encodes",
"all",
"that",
"is",
"returned",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L411-L421 |
jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.getTypeFunc | def getTypeFunc(self, data):
"""
Returns a callable that will encode C{data} to C{self.stream}. If
C{data} is unencodable, then C{None} is returned.
"""
if data is None:
return self.writeNull
t = type(data)
# try types that we know will work
... | python | def getTypeFunc(self, data):
"""
Returns a callable that will encode C{data} to C{self.stream}. If
C{data} is unencodable, then C{None} is returned.
"""
if data is None:
return self.writeNull
t = type(data)
# try types that we know will work
... | [
"def",
"getTypeFunc",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"self",
".",
"writeNull",
"t",
"=",
"type",
"(",
"data",
")",
"# try types that we know will work",
"if",
"t",
"is",
"str",
"or",
"issubclass",
"(",
"t",... | Returns a callable that will encode C{data} to C{self.stream}. If
C{data} is unencodable, then C{None} is returned. | [
"Returns",
"a",
"callable",
"that",
"will",
"encode",
"C",
"{",
"data",
"}",
"to",
"C",
"{",
"self",
".",
"stream",
"}",
".",
"If",
"C",
"{",
"data",
"}",
"is",
"unencodable",
"then",
"C",
"{",
"None",
"}",
"is",
"returned",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L423-L478 |
jmgilman/Neolib | neolib/pyamf/codec.py | Encoder.writeElement | def writeElement(self, data):
"""
Encodes C{data} to AMF. If the data is not able to be matched to an AMF
type, then L{pyamf.EncodeError} will be raised.
"""
key = type(data)
func = None
try:
func = self._func_cache[key]
except KeyError:
... | python | def writeElement(self, data):
"""
Encodes C{data} to AMF. If the data is not able to be matched to an AMF
type, then L{pyamf.EncodeError} will be raised.
"""
key = type(data)
func = None
try:
func = self._func_cache[key]
except KeyError:
... | [
"def",
"writeElement",
"(",
"self",
",",
"data",
")",
":",
"key",
"=",
"type",
"(",
"data",
")",
"func",
"=",
"None",
"try",
":",
"func",
"=",
"self",
".",
"_func_cache",
"[",
"key",
"]",
"except",
"KeyError",
":",
"func",
"=",
"self",
".",
"getTyp... | Encodes C{data} to AMF. If the data is not able to be matched to an AMF
type, then L{pyamf.EncodeError} will be raised. | [
"Encodes",
"C",
"{",
"data",
"}",
"to",
"AMF",
".",
"If",
"the",
"data",
"is",
"not",
"able",
"to",
"be",
"matched",
"to",
"an",
"AMF",
"type",
"then",
"L",
"{",
"pyamf",
".",
"EncodeError",
"}",
"will",
"be",
"raised",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/codec.py#L480-L499 |
SmartDeveloperHub/agora-service-provider | agora/provider/jobs/collect.py | collect | def collect(tp, *args):
"""
Decorator to attach a collector function to a triple pattern
:param tp:
:param args:
:return:
"""
def decorator(f):
add_triple_pattern(tp, f, args)
return decorator | python | def collect(tp, *args):
"""
Decorator to attach a collector function to a triple pattern
:param tp:
:param args:
:return:
"""
def decorator(f):
add_triple_pattern(tp, f, args)
return decorator | [
"def",
"collect",
"(",
"tp",
",",
"*",
"args",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"add_triple_pattern",
"(",
"tp",
",",
"f",
",",
"args",
")",
"return",
"decorator"
] | Decorator to attach a collector function to a triple pattern
:param tp:
:param args:
:return: | [
"Decorator",
"to",
"attach",
"a",
"collector",
"function",
"to",
"a",
"triple",
"pattern",
":",
"param",
"tp",
":",
":",
"param",
"args",
":",
":",
"return",
":"
] | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/jobs/collect.py#L38-L49 |
SmartDeveloperHub/agora-service-provider | agora/provider/jobs/collect.py | add_triple_pattern | def add_triple_pattern(tp, collector, args):
"""0
Manage the relations between triple patterns and collector functions
:param tp:
:param collector:
:param args:
:return:
"""
tp_parts = [part.strip() for part in tp.strip().split(' ')]
tp = ' '.join(tp_parts)
if tp not in __triple_... | python | def add_triple_pattern(tp, collector, args):
"""0
Manage the relations between triple patterns and collector functions
:param tp:
:param collector:
:param args:
:return:
"""
tp_parts = [part.strip() for part in tp.strip().split(' ')]
tp = ' '.join(tp_parts)
if tp not in __triple_... | [
"def",
"add_triple_pattern",
"(",
"tp",
",",
"collector",
",",
"args",
")",
":",
"tp_parts",
"=",
"[",
"part",
".",
"strip",
"(",
")",
"for",
"part",
"in",
"tp",
".",
"strip",
"(",
")",
".",
"split",
"(",
"' '",
")",
"]",
"tp",
"=",
"' '",
".",
... | 0
Manage the relations between triple patterns and collector functions
:param tp:
:param collector:
:param args:
:return: | [
"0",
"Manage",
"the",
"relations",
"between",
"triple",
"patterns",
"and",
"collector",
"functions",
":",
"param",
"tp",
":",
":",
"param",
"collector",
":",
":",
"param",
"args",
":",
":",
"return",
":"
] | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/jobs/collect.py#L52-L65 |
SmartDeveloperHub/agora-service-provider | agora/provider/jobs/collect.py | __extract_pattern_nodes | def __extract_pattern_nodes(graph):
"""
Extract and bind the triple patterns contained in the search plan, so as to be able to identify
to which pattern is associated each triple of the fragment.
:return:
"""
tp_nodes = graph.subjects(RDF.type, AGORA.TriplePattern)
for tpn in tp_nodes:
... | python | def __extract_pattern_nodes(graph):
"""
Extract and bind the triple patterns contained in the search plan, so as to be able to identify
to which pattern is associated each triple of the fragment.
:return:
"""
tp_nodes = graph.subjects(RDF.type, AGORA.TriplePattern)
for tpn in tp_nodes:
... | [
"def",
"__extract_pattern_nodes",
"(",
"graph",
")",
":",
"tp_nodes",
"=",
"graph",
".",
"subjects",
"(",
"RDF",
".",
"type",
",",
"AGORA",
".",
"TriplePattern",
")",
"for",
"tpn",
"in",
"tp_nodes",
":",
"subject",
"=",
"list",
"(",
"graph",
".",
"object... | Extract and bind the triple patterns contained in the search plan, so as to be able to identify
to which pattern is associated each triple of the fragment.
:return: | [
"Extract",
"and",
"bind",
"the",
"triple",
"patterns",
"contained",
"in",
"the",
"search",
"plan",
"so",
"as",
"to",
"be",
"able",
"to",
"identify",
"to",
"which",
"pattern",
"is",
"associated",
"each",
"triple",
"of",
"the",
"fragment",
".",
":",
"return"... | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/jobs/collect.py#L68-L85 |
SmartDeveloperHub/agora-service-provider | agora/provider/jobs/collect.py | collect_fragment | def collect_fragment(event, agora_host):
"""
Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config
"""
agora = Agora(agora_host)
graph_pattern = ""
for tp in __triple_patterns:
graph_pattern += '{} . '.for... | python | def collect_fragment(event, agora_host):
"""
Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config
"""
agora = Agora(agora_host)
graph_pattern = ""
for tp in __triple_patterns:
graph_pattern += '{} . '.for... | [
"def",
"collect_fragment",
"(",
"event",
",",
"agora_host",
")",
":",
"agora",
"=",
"Agora",
"(",
"agora_host",
")",
"graph_pattern",
"=",
"\"\"",
"for",
"tp",
"in",
"__triple_patterns",
":",
"graph_pattern",
"+=",
"'{} . '",
".",
"format",
"(",
"tp",
")",
... | Execute a search plan for the declared graph pattern and sends all obtained triples to the corresponding
collector functions (config | [
"Execute",
"a",
"search",
"plan",
"for",
"the",
"declared",
"graph",
"pattern",
"and",
"sends",
"all",
"obtained",
"triples",
"to",
"the",
"corresponding",
"collector",
"functions",
"(",
"config"
] | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/jobs/collect.py#L88-L108 |
pjuren/pyokit | src/pyokit/io/david.py | david_results_iterator | def david_results_iterator(fn, verbose=False):
"""
Iterate over a DAVID result set and yeild GeneOntologyTerm objects
representing each of the terms reported. The expected format for a DAVID
result file is tab-seperated format. The following fields should be present:
=== =============== ========== =======... | python | def david_results_iterator(fn, verbose=False):
"""
Iterate over a DAVID result set and yeild GeneOntologyTerm objects
representing each of the terms reported. The expected format for a DAVID
result file is tab-seperated format. The following fields should be present:
=== =============== ========== =======... | [
"def",
"david_results_iterator",
"(",
"fn",
",",
"verbose",
"=",
"False",
")",
":",
"first",
"=",
"True",
"for",
"line",
"in",
"open",
"(",
"fn",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
"==",
"\"\"",
":",
"continue",
"i... | Iterate over a DAVID result set and yeild GeneOntologyTerm objects
representing each of the terms reported. The expected format for a DAVID
result file is tab-seperated format. The following fields should be present:
=== =============== ========== ====================================
Num Field ... | [
"Iterate",
"over",
"a",
"DAVID",
"result",
"set",
"and",
"yeild",
"GeneOntologyTerm",
"objects",
"representing",
"each",
"of",
"the",
"terms",
"reported",
".",
"The",
"expected",
"format",
"for",
"a",
"DAVID",
"result",
"file",
"is",
"tab",
"-",
"seperated",
... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/david.py#L41-L102 |
opinkerfi/nago | nago/extensions/settings.py | get | def get(key, section='main'):
""" Get a single option from """
return nago.settings.get_option(option_name=key, section_name=section) | python | def get(key, section='main'):
""" Get a single option from """
return nago.settings.get_option(option_name=key, section_name=section) | [
"def",
"get",
"(",
"key",
",",
"section",
"=",
"'main'",
")",
":",
"return",
"nago",
".",
"settings",
".",
"get_option",
"(",
"option_name",
"=",
"key",
",",
"section_name",
"=",
"section",
")"
] | Get a single option from | [
"Get",
"a",
"single",
"option",
"from"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/settings.py#L16-L18 |
alexhayes/django-toolkit | django_toolkit/templatetags/attr.py | getattribute | def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
if callable(getattr(value, arg)):
return str(getattr(value, arg)())
elif hasattr(value, str(arg)):
return getattr(value, arg)
elif hasattr(value, 'has_key') and value.has_key(arg):
... | python | def getattribute(value, arg):
"""Gets an attribute of an object dynamically from a string name"""
if callable(getattr(value, arg)):
return str(getattr(value, arg)())
elif hasattr(value, str(arg)):
return getattr(value, arg)
elif hasattr(value, 'has_key') and value.has_key(arg):
... | [
"def",
"getattribute",
"(",
"value",
",",
"arg",
")",
":",
"if",
"callable",
"(",
"getattr",
"(",
"value",
",",
"arg",
")",
")",
":",
"return",
"str",
"(",
"getattr",
"(",
"value",
",",
"arg",
")",
"(",
")",
")",
"elif",
"hasattr",
"(",
"value",
... | Gets an attribute of an object dynamically from a string name | [
"Gets",
"an",
"attribute",
"of",
"an",
"object",
"dynamically",
"from",
"a",
"string",
"name"
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/templatetags/attr.py#L9-L23 |
nicktgr15/sac | sac/methods/vad.py | Vad._read_wave | def _read_wave(self, path):
"""Reads a .wav file.
Takes the path, and returns (PCM audio data, sample rate).
"""
with contextlib.closing(wave.open(path, 'rb')) as wf:
num_channels = wf.getnchannels()
assert num_channels == 1
sample_width = wf.getsampwi... | python | def _read_wave(self, path):
"""Reads a .wav file.
Takes the path, and returns (PCM audio data, sample rate).
"""
with contextlib.closing(wave.open(path, 'rb')) as wf:
num_channels = wf.getnchannels()
assert num_channels == 1
sample_width = wf.getsampwi... | [
"def",
"_read_wave",
"(",
"self",
",",
"path",
")",
":",
"with",
"contextlib",
".",
"closing",
"(",
"wave",
".",
"open",
"(",
"path",
",",
"'rb'",
")",
")",
"as",
"wf",
":",
"num_channels",
"=",
"wf",
".",
"getnchannels",
"(",
")",
"assert",
"num_cha... | Reads a .wav file.
Takes the path, and returns (PCM audio data, sample rate). | [
"Reads",
"a",
".",
"wav",
"file",
".",
"Takes",
"the",
"path",
"and",
"returns",
"(",
"PCM",
"audio",
"data",
"sample",
"rate",
")",
"."
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/vad.py#L11-L23 |
nicktgr15/sac | sac/methods/vad.py | Vad._frame_generator | def _frame_generator(self, frame_duration_ms, audio, sample_rate):
"""Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration.
"""
n = int(sample_rate * (frame... | python | def _frame_generator(self, frame_duration_ms, audio, sample_rate):
"""Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration.
"""
n = int(sample_rate * (frame... | [
"def",
"_frame_generator",
"(",
"self",
",",
"frame_duration_ms",
",",
"audio",
",",
"sample_rate",
")",
":",
"n",
"=",
"int",
"(",
"sample_rate",
"*",
"(",
"frame_duration_ms",
"/",
"1000.0",
")",
"*",
"2",
")",
"offset",
"=",
"0",
"timestamp",
"=",
"0.... | Generates audio frames from PCM audio data.
Takes the desired frame duration in milliseconds, the PCM data, and
the sample rate.
Yields Frames of the requested duration. | [
"Generates",
"audio",
"frames",
"from",
"PCM",
"audio",
"data",
".",
"Takes",
"the",
"desired",
"frame",
"duration",
"in",
"milliseconds",
"the",
"PCM",
"data",
"and",
"the",
"sample",
"rate",
".",
"Yields",
"Frames",
"of",
"the",
"requested",
"duration",
".... | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/vad.py#L32-L45 |
nicktgr15/sac | sac/methods/vad.py | Vad._vad_collector | def _vad_collector(self, sample_rate, frame_duration_ms,
padding_duration_ms, vad, frames):
"""Filters out non-voiced audio frames.
Given a webrtcvad.Vad and a source of audio frames, yields only
the voiced audio.
Uses a padded, sliding window algorithm over the au... | python | def _vad_collector(self, sample_rate, frame_duration_ms,
padding_duration_ms, vad, frames):
"""Filters out non-voiced audio frames.
Given a webrtcvad.Vad and a source of audio frames, yields only
the voiced audio.
Uses a padded, sliding window algorithm over the au... | [
"def",
"_vad_collector",
"(",
"self",
",",
"sample_rate",
",",
"frame_duration_ms",
",",
"padding_duration_ms",
",",
"vad",
",",
"frames",
")",
":",
"num_padding_frames",
"=",
"int",
"(",
"padding_duration_ms",
"/",
"frame_duration_ms",
")",
"# We use a deque for our ... | Filters out non-voiced audio frames.
Given a webrtcvad.Vad and a source of audio frames, yields only
the voiced audio.
Uses a padded, sliding window algorithm over the audio frames.
When more than 90% of the frames in the window are voiced (as
reported by the VAD), the collector ... | [
"Filters",
"out",
"non",
"-",
"voiced",
"audio",
"frames",
".",
"Given",
"a",
"webrtcvad",
".",
"Vad",
"and",
"a",
"source",
"of",
"audio",
"frames",
"yields",
"only",
"the",
"voiced",
"audio",
".",
"Uses",
"a",
"padded",
"sliding",
"window",
"algorithm",
... | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/vad.py#L47-L109 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/twisted.py | TwistedGateway._finaliseRequest | def _finaliseRequest(self, request, status, content, mimetype='text/plain'):
"""
Finalises the request.
@param request: The HTTP Request.
@type request: C{http.Request}
@param status: The HTTP status code.
@type status: C{int}
@param content: The content of the r... | python | def _finaliseRequest(self, request, status, content, mimetype='text/plain'):
"""
Finalises the request.
@param request: The HTTP Request.
@type request: C{http.Request}
@param status: The HTTP status code.
@type status: C{int}
@param content: The content of the r... | [
"def",
"_finaliseRequest",
"(",
"self",
",",
"request",
",",
"status",
",",
"content",
",",
"mimetype",
"=",
"'text/plain'",
")",
":",
"request",
".",
"setResponseCode",
"(",
"status",
")",
"request",
".",
"setHeader",
"(",
"\"Content-Type\"",
",",
"mimetype",... | Finalises the request.
@param request: The HTTP Request.
@type request: C{http.Request}
@param status: The HTTP status code.
@type status: C{int}
@param content: The content of the response.
@type content: C{str}
@param mimetype: The MIME type of the request.
... | [
"Finalises",
"the",
"request",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/twisted.py#L216-L236 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/twisted.py | TwistedGateway.render_POST | def render_POST(self, request):
"""
Read remoting request from the client.
@type request: The HTTP Request.
@param request: C{twisted.web.http.Request}
"""
def handleDecodeError(failure):
"""
Return HTTP 400 Bad Request.
"""
... | python | def render_POST(self, request):
"""
Read remoting request from the client.
@type request: The HTTP Request.
@param request: C{twisted.web.http.Request}
"""
def handleDecodeError(failure):
"""
Return HTTP 400 Bad Request.
"""
... | [
"def",
"render_POST",
"(",
"self",
",",
"request",
")",
":",
"def",
"handleDecodeError",
"(",
"failure",
")",
":",
"\"\"\"\n Return HTTP 400 Bad Request.\n \"\"\"",
"errMesg",
"=",
"\"%s: %s\"",
"%",
"(",
"failure",
".",
"type",
",",
"failure",
... | Read remoting request from the client.
@type request: The HTTP Request.
@param request: C{twisted.web.http.Request} | [
"Read",
"remoting",
"request",
"from",
"the",
"client",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/twisted.py#L238-L281 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/twisted.py | TwistedGateway.getResponse | def getResponse(self, http_request, amf_request):
"""
Processes the AMF request, returning an AMF L{Response}.
@param http_request: The underlying HTTP Request
@type http_request: C{twisted.web.http.Request}
@param amf_request: The AMF Request.
@type amf_request: L{Envel... | python | def getResponse(self, http_request, amf_request):
"""
Processes the AMF request, returning an AMF L{Response}.
@param http_request: The underlying HTTP Request
@type http_request: C{twisted.web.http.Request}
@param amf_request: The AMF Request.
@type amf_request: L{Envel... | [
"def",
"getResponse",
"(",
"self",
",",
"http_request",
",",
"amf_request",
")",
":",
"response",
"=",
"remoting",
".",
"Envelope",
"(",
"amf_request",
".",
"amfVersion",
")",
"dl",
"=",
"[",
"]",
"def",
"cb",
"(",
"body",
",",
"name",
")",
":",
"respo... | Processes the AMF request, returning an AMF L{Response}.
@param http_request: The underlying HTTP Request
@type http_request: C{twisted.web.http.Request}
@param amf_request: The AMF Request.
@type amf_request: L{Envelope<pyamf.remoting.Envelope>} | [
"Processes",
"the",
"AMF",
"request",
"returning",
"an",
"AMF",
"L",
"{",
"Response",
"}",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/twisted.py#L325-L373 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/twisted.py | TwistedGateway.authenticateRequest | def authenticateRequest(self, service_request, username, password, **kwargs):
"""
Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: C{Deferred}.
@rtype: C{twisted.internet.defer.Deferred}
"""
authenticato... | python | def authenticateRequest(self, service_request, username, password, **kwargs):
"""
Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: C{Deferred}.
@rtype: C{twisted.internet.defer.Deferred}
"""
authenticato... | [
"def",
"authenticateRequest",
"(",
"self",
",",
"service_request",
",",
"username",
",",
"password",
",",
"*",
"*",
"kwargs",
")",
":",
"authenticator",
"=",
"self",
".",
"getAuthenticator",
"(",
"service_request",
")",
"if",
"self",
".",
"logger",
":",
"sel... | Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: C{Deferred}.
@rtype: C{twisted.internet.defer.Deferred} | [
"Processes",
"an",
"authentication",
"request",
".",
"If",
"no",
"authenticator",
"is",
"supplied",
"then",
"authentication",
"succeeds",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/twisted.py#L375-L397 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/twisted.py | TwistedGateway.preprocessRequest | def preprocessRequest(self, service_request, *args, **kwargs):
"""
Preprocesses a request.
"""
processor = self.getPreprocessor(service_request)
if self.logger:
self.logger.debug('Preprocessor expands to: %r' % processor)
if processor is None:
re... | python | def preprocessRequest(self, service_request, *args, **kwargs):
"""
Preprocesses a request.
"""
processor = self.getPreprocessor(service_request)
if self.logger:
self.logger.debug('Preprocessor expands to: %r' % processor)
if processor is None:
re... | [
"def",
"preprocessRequest",
"(",
"self",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"processor",
"=",
"self",
".",
"getPreprocessor",
"(",
"service_request",
")",
"if",
"self",
".",
"logger",
":",
"self",
".",
"logger",
... | Preprocesses a request. | [
"Preprocesses",
"a",
"request",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/twisted.py#L399-L417 |
kylemede/KMlogger | KMlogger/kmLogger.py | getLogger | def getLogger(name='generalLoggerName',dr='',lvl=20,addFH=True,addSH=True,):
"""This will either return the logging object already
instantiated, or instantiate a new one and return it.
**Use this function to both create and return any logger** to avoid
accidentally adding additional handlers by using... | python | def getLogger(name='generalLoggerName',dr='',lvl=20,addFH=True,addSH=True,):
"""This will either return the logging object already
instantiated, or instantiate a new one and return it.
**Use this function to both create and return any logger** to avoid
accidentally adding additional handlers by using... | [
"def",
"getLogger",
"(",
"name",
"=",
"'generalLoggerName'",
",",
"dr",
"=",
"''",
",",
"lvl",
"=",
"20",
",",
"addFH",
"=",
"True",
",",
"addSH",
"=",
"True",
",",
")",
":",
"log",
"=",
"False",
"try",
":",
"log",
"=",
"log_dict",
"[",
"name",
"... | This will either return the logging object already
instantiated, or instantiate a new one and return it.
**Use this function to both create and return any logger** to avoid
accidentally adding additional handlers by using the setUpLogger function
instead.
Args:
name (str): The name ... | [
"This",
"will",
"either",
"return",
"the",
"logging",
"object",
"already",
"instantiated",
"or",
"instantiate",
"a",
"new",
"one",
"and",
"return",
"it",
".",
"**",
"Use",
"this",
"function",
"to",
"both",
"create",
"and",
"return",
"any",
"logger",
"**",
... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L190-L217 |
kylemede/KMlogger | KMlogger/kmLogger.py | setUpLogger | def setUpLogger(name='generalLoggerName',dr='',lvl=20,addFH=True,addSH=True):
""" This function is utilized by getLogger to set up a new logging object.
It will have the default name 'generalLoggerName' and stream handler level
of 20 unless redefined in the function call.
NOTE:
If a file handler i... | python | def setUpLogger(name='generalLoggerName',dr='',lvl=20,addFH=True,addSH=True):
""" This function is utilized by getLogger to set up a new logging object.
It will have the default name 'generalLoggerName' and stream handler level
of 20 unless redefined in the function call.
NOTE:
If a file handler i... | [
"def",
"setUpLogger",
"(",
"name",
"=",
"'generalLoggerName'",
",",
"dr",
"=",
"''",
",",
"lvl",
"=",
"20",
",",
"addFH",
"=",
"True",
",",
"addSH",
"=",
"True",
")",
":",
"logging",
".",
"setLoggerClass",
"(",
"KMlogger",
")",
"log",
"=",
"logging",
... | This function is utilized by getLogger to set up a new logging object.
It will have the default name 'generalLoggerName' and stream handler level
of 20 unless redefined in the function call.
NOTE:
If a file handler is added, it will have the lowest severity level by
default (Currently no need for... | [
"This",
"function",
"is",
"utilized",
"by",
"getLogger",
"to",
"set",
"up",
"a",
"new",
"logging",
"object",
".",
"It",
"will",
"have",
"the",
"default",
"name",
"generalLoggerName",
"and",
"stream",
"handler",
"level",
"of",
"20",
"unless",
"redefined",
"in... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L219-L254 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.addNewLvls | def addNewLvls(self):
"""
+---------------------+----------------------+
| Standard Levels | New Levels |
+---------------+-----+----------------+-----+
| Name |Level| Name |Level|
+===============+=====+================+=====+
| ... | python | def addNewLvls(self):
"""
+---------------------+----------------------+
| Standard Levels | New Levels |
+---------------+-----+----------------+-----+
| Name |Level| Name |Level|
+===============+=====+================+=====+
| ... | [
"def",
"addNewLvls",
"(",
"self",
")",
":",
"# Level for raise message to print to file (File only)",
"RAISEMSG",
"=",
"99",
"logging",
".",
"addLevelName",
"(",
"RAISEMSG",
",",
"'RAISEMSG'",
")",
"def",
"raisemsg",
"(",
"self",
",",
"msg",
",",
"lvl",
"=",
"RA... | +---------------------+----------------------+
| Standard Levels | New Levels |
+---------------+-----+----------------+-----+
| Name |Level| Name |Level|
+===============+=====+================+=====+
| | |RAISEMSG | 99 ... | [
"+",
"---------------------",
"+",
"----------------------",
"+",
"|",
"Standard",
"Levels",
"|",
"New",
"Levels",
"|",
"+",
"---------------",
"+",
"-----",
"+",
"----------------",
"+",
"-----",
"+",
"|",
"Name",
"|Level|",
"Name",
"|Level|",
"+",
"===========... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L24-L67 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.setStreamLevel | def setStreamLevel(self,lvl=20):
"""
Set/change the level for the stream handler for a logging object.
Any file handlers will be left alone.
All messages of a higher severity level than 'lvl' will be printed
to the screen.
Args:
lvl (int): The se... | python | def setStreamLevel(self,lvl=20):
"""
Set/change the level for the stream handler for a logging object.
Any file handlers will be left alone.
All messages of a higher severity level than 'lvl' will be printed
to the screen.
Args:
lvl (int): The se... | [
"def",
"setStreamLevel",
"(",
"self",
",",
"lvl",
"=",
"20",
")",
":",
"# Kill off the old handlers and reset them with the setHandlers func",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"handlers",
")",
")",
":",
"h",
"=",
"self",
"."... | Set/change the level for the stream handler for a logging object.
Any file handlers will be left alone.
All messages of a higher severity level than 'lvl' will be printed
to the screen.
Args:
lvl (int): The severity level of messages printed to the screen with
... | [
"Set",
"/",
"change",
"the",
"level",
"for",
"the",
"stream",
"handler",
"for",
"a",
"logging",
"object",
".",
"Any",
"file",
"handlers",
"will",
"be",
"left",
"alone",
".",
"All",
"messages",
"of",
"a",
"higher",
"severity",
"level",
"than",
"lvl",
"wil... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L70-L87 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.getStreamLevel | def getStreamLevel(self):
"""
Get and return current stream handler's level.
"""
shlvl = 0
for i in range(0,len(self.handlers)):
h = self.handlers[i]
if isinstance(h,logging.StreamHandler):
shlvl = h.level
return shlvl | python | def getStreamLevel(self):
"""
Get and return current stream handler's level.
"""
shlvl = 0
for i in range(0,len(self.handlers)):
h = self.handlers[i]
if isinstance(h,logging.StreamHandler):
shlvl = h.level
return shlvl | [
"def",
"getStreamLevel",
"(",
"self",
")",
":",
"shlvl",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"handlers",
")",
")",
":",
"h",
"=",
"self",
".",
"handlers",
"[",
"i",
"]",
"if",
"isinstance",
"(",
"h",
","... | Get and return current stream handler's level. | [
"Get",
"and",
"return",
"current",
"stream",
"handler",
"s",
"level",
"."
] | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L89-L98 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.addFileHandler | def addFileHandler(self,filename='', dr='',lvl=1):
"""
This function will add a file handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the file with
the file handler, default = 1.
"""
... | python | def addFileHandler(self,filename='', dr='',lvl=1):
"""
This function will add a file handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the file with
the file handler, default = 1.
"""
... | [
"def",
"addFileHandler",
"(",
"self",
",",
"filename",
"=",
"''",
",",
"dr",
"=",
"''",
",",
"lvl",
"=",
"1",
")",
":",
"fname",
"=",
"self",
".",
"name",
"if",
"filename",
"!=",
"''",
":",
"fname",
"=",
"filename",
"if",
"'.'",
"not",
"in",
"fna... | This function will add a file handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the file with
the file handler, default = 1. | [
"This",
"function",
"will",
"add",
"a",
"file",
"handler",
"to",
"a",
"log",
"with",
"the",
"provided",
"level",
".",
"Args",
":",
"lvl",
"(",
"int",
")",
":",
"The",
"severity",
"level",
"of",
"messages",
"printed",
"to",
"the",
"file",
"with",
"the",... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L100-L118 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.addStreamHandler | def addStreamHandler(self,lvl=20):
"""
This function will add a stream handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
"""
sh = log... | python | def addStreamHandler(self,lvl=20):
"""
This function will add a stream handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
"""
sh = log... | [
"def",
"addStreamHandler",
"(",
"self",
",",
"lvl",
"=",
"20",
")",
":",
"sh",
"=",
"logging",
".",
"StreamHandler",
"(",
"sys",
".",
"stdout",
")",
"sh",
".",
"setLevel",
"(",
"lvl",
")",
"sFrmt",
"=",
"logging",
".",
"Formatter",
"(",
"'%(message)s'"... | This function will add a stream handler to a log with the provided level.
Args:
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20. | [
"This",
"function",
"will",
"add",
"a",
"stream",
"handler",
"to",
"a",
"log",
"with",
"the",
"provided",
"level",
".",
"Args",
":",
"lvl",
"(",
"int",
")",
":",
"The",
"severity",
"level",
"of",
"messages",
"printed",
"to",
"the",
"screen",
"with",
"t... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L120-L135 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.logSystemInfo | def logSystemInfo(self):
"""
A function to be called just after a logging object is instantiated
to load the log up with info about the computer it is
being ran on and the software version. This function utilizes the
psutil and platform libraries, so they must be install for... | python | def logSystemInfo(self):
"""
A function to be called just after a logging object is instantiated
to load the log up with info about the computer it is
being ran on and the software version. This function utilizes the
psutil and platform libraries, so they must be install for... | [
"def",
"logSystemInfo",
"(",
"self",
")",
":",
"t",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"infoStr",
"=",
"'Date KMlogger object instantiated: '",
"+",
"t",
".",
"strftime",
"(",
"'%b %d, %Y'",
")",
"+",
"'\\n\\n'",
"infoStr",
"+=",
"\"\\n\""... | A function to be called just after a logging object is instantiated
to load the log up with info about the computer it is
being ran on and the software version. This function utilizes the
psutil and platform libraries, so they must be install for it to work.
For clarity of the log,... | [
"A",
"function",
"to",
"be",
"called",
"just",
"after",
"a",
"logging",
"object",
"is",
"instantiated",
"to",
"load",
"the",
"log",
"up",
"with",
"info",
"about",
"the",
"computer",
"it",
"is",
"being",
"ran",
"on",
"and",
"the",
"software",
"version",
"... | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L137-L173 |
kylemede/KMlogger | KMlogger/kmLogger.py | KMlogger.logDict | def logDict(self,d):
"""
Log all Key=value for every key in a dictionary.
Args:
d (dictionary): A standard python dictionary.
"""
keys = list(d.keys())
keys.sort()
s = "\n"+"-"*78+"\n"+" "*20+"dictionary provided contains:\n"+"-"*78+"\n"
... | python | def logDict(self,d):
"""
Log all Key=value for every key in a dictionary.
Args:
d (dictionary): A standard python dictionary.
"""
keys = list(d.keys())
keys.sort()
s = "\n"+"-"*78+"\n"+" "*20+"dictionary provided contains:\n"+"-"*78+"\n"
... | [
"def",
"logDict",
"(",
"self",
",",
"d",
")",
":",
"keys",
"=",
"list",
"(",
"d",
".",
"keys",
"(",
")",
")",
"keys",
".",
"sort",
"(",
")",
"s",
"=",
"\"\\n\"",
"+",
"\"-\"",
"*",
"78",
"+",
"\"\\n\"",
"+",
"\" \"",
"*",
"20",
"+",
"\"dictio... | Log all Key=value for every key in a dictionary.
Args:
d (dictionary): A standard python dictionary. | [
"Log",
"all",
"Key",
"=",
"value",
"for",
"every",
"key",
"in",
"a",
"dictionary",
".",
"Args",
":",
"d",
"(",
"dictionary",
")",
":",
"A",
"standard",
"python",
"dictionary",
"."
] | train | https://github.com/kylemede/KMlogger/blob/c904f0aaf35b4aff259567f932b5ca678d7f8176/KMlogger/kmLogger.py#L175-L187 |
last-g/oauth_middleware | oauth_middleware/middleware.py | check_auth | def check_auth():
"""
Check are we authorised
:return: True if we authorised
False if no auth provided
exception if provided auth is wrong
"""
if get_oauth_token():
auth_info = get_auth_info()
if not auth_info:
raise MissingTokenInfoException("Could not ge... | python | def check_auth():
"""
Check are we authorised
:return: True if we authorised
False if no auth provided
exception if provided auth is wrong
"""
if get_oauth_token():
auth_info = get_auth_info()
if not auth_info:
raise MissingTokenInfoException("Could not ge... | [
"def",
"check_auth",
"(",
")",
":",
"if",
"get_oauth_token",
"(",
")",
":",
"auth_info",
"=",
"get_auth_info",
"(",
")",
"if",
"not",
"auth_info",
":",
"raise",
"MissingTokenInfoException",
"(",
"\"Could not get token info\"",
")",
"if",
"datetime",
".",
"now",
... | Check are we authorised
:return: True if we authorised
False if no auth provided
exception if provided auth is wrong | [
"Check",
"are",
"we",
"authorised",
":",
"return",
":",
"True",
"if",
"we",
"authorised",
"False",
"if",
"no",
"auth",
"provided",
"exception",
"if",
"provided",
"auth",
"is",
"wrong"
] | train | https://github.com/last-g/oauth_middleware/blob/695da7cd0e14271211c30b21404f881be84717e7/oauth_middleware/middleware.py#L198-L220 |
exekias/droplet | droplet/module.py | ModuleMeta.install_wrapper | def install_wrapper(cls, install, new_class):
"""
Wrap the install method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if self.installed:
raise AssertionError('Module %s is already installed'
... | python | def install_wrapper(cls, install, new_class):
"""
Wrap the install method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if self.installed:
raise AssertionError('Module %s is already installed'
... | [
"def",
"install_wrapper",
"(",
"cls",
",",
"install",
",",
"new_class",
")",
":",
"def",
"_wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"installed",
":",
"raise",
"AssertionError",
"(",
"'Module %s is alr... | Wrap the install method to call pre and post enable signals and update
module status | [
"Wrap",
"the",
"install",
"method",
"to",
"call",
"pre",
"and",
"post",
"enable",
"signals",
"and",
"update",
"module",
"status"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L70-L92 |
exekias/droplet | droplet/module.py | ModuleMeta.enable_wrapper | def enable_wrapper(cls, enable, new_class):
"""
Wrap the enable method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.installed:
raise AssertionError('Module %s cannot be enabled'
... | python | def enable_wrapper(cls, enable, new_class):
"""
Wrap the enable method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.installed:
raise AssertionError('Module %s cannot be enabled'
... | [
"def",
"enable_wrapper",
"(",
"cls",
",",
"enable",
",",
"new_class",
")",
":",
"def",
"_wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"installed",
":",
"raise",
"AssertionError",
"(",
"'Module %s... | Wrap the enable method to call pre and post enable signals and update
module status | [
"Wrap",
"the",
"enable",
"method",
"to",
"call",
"pre",
"and",
"post",
"enable",
"signals",
"and",
"update",
"module",
"status"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L95-L127 |
exekias/droplet | droplet/module.py | ModuleMeta.save_wrapper | def save_wrapper(cls, save, new_class):
"""
Wrap the save method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.installed:
raise AssertionError('Module %s is not installed' %
... | python | def save_wrapper(cls, save, new_class):
"""
Wrap the save method to call pre and post enable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.installed:
raise AssertionError('Module %s is not installed' %
... | [
"def",
"save_wrapper",
"(",
"cls",
",",
"save",
",",
"new_class",
")",
":",
"def",
"_wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"installed",
":",
"raise",
"AssertionError",
"(",
"'Module %s is ... | Wrap the save method to call pre and post enable signals and update
module status | [
"Wrap",
"the",
"save",
"method",
"to",
"call",
"pre",
"and",
"post",
"enable",
"signals",
"and",
"update",
"module",
"status"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L130-L148 |
exekias/droplet | droplet/module.py | ModuleMeta.disable_wrapper | def disable_wrapper(cls, disable, new_class):
"""
Wrap the disable method to call pre and post disable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.enabled:
raise AssertionError('Module %s is already disabled'
... | python | def disable_wrapper(cls, disable, new_class):
"""
Wrap the disable method to call pre and post disable signals and update
module status
"""
def _wrapped(self, *args, **kwargs):
if not self.enabled:
raise AssertionError('Module %s is already disabled'
... | [
"def",
"disable_wrapper",
"(",
"cls",
",",
"disable",
",",
"new_class",
")",
":",
"def",
"_wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"raise",
"AssertionError",
"(",
"'Module %s... | Wrap the disable method to call pre and post disable signals and update
module status | [
"Wrap",
"the",
"disable",
"method",
"to",
"call",
"pre",
"and",
"post",
"disable",
"signals",
"and",
"update",
"module",
"status"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L151-L178 |
exekias/droplet | droplet/module.py | Module._info | def _info(self):
"""
Module internal status representation
"""
name = self.__class__.__module__ + '.' + self.__class__.__name__
info, created = ModuleInfo.objects.get_or_create(name=name)
if created:
# Do not set as changed
info.commit()
re... | python | def _info(self):
"""
Module internal status representation
"""
name = self.__class__.__module__ + '.' + self.__class__.__name__
info, created = ModuleInfo.objects.get_or_create(name=name)
if created:
# Do not set as changed
info.commit()
re... | [
"def",
"_info",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"__class__",
".",
"__module__",
"+",
"'.'",
"+",
"self",
".",
"__class__",
".",
"__name__",
"info",
",",
"created",
"=",
"ModuleInfo",
".",
"objects",
".",
"get_or_create",
"(",
"name",
"... | Module internal status representation | [
"Module",
"internal",
"status",
"representation"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L266-L275 |
exekias/droplet | droplet/module.py | Module.changed | def changed(self):
"""
Tells if module configuration has been changed (it needs to be saved)
"""
# Not installed modules cannot issue a change to save
if not self.installed:
return False
# Check if module status changed
if self._info._changed:
... | python | def changed(self):
"""
Tells if module configuration has been changed (it needs to be saved)
"""
# Not installed modules cannot issue a change to save
if not self.installed:
return False
# Check if module status changed
if self._info._changed:
... | [
"def",
"changed",
"(",
"self",
")",
":",
"# Not installed modules cannot issue a change to save",
"if",
"not",
"self",
".",
"installed",
":",
"return",
"False",
"# Check if module status changed",
"if",
"self",
".",
"_info",
".",
"_changed",
":",
"return",
"True",
"... | Tells if module configuration has been changed (it needs to be saved) | [
"Tells",
"if",
"module",
"configuration",
"has",
"been",
"changed",
"(",
"it",
"needs",
"to",
"be",
"saved",
")"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L308-L327 |
exekias/droplet | droplet/module.py | Module.models | def models(self):
"""
Return all the models defined for this module
"""
app = get_app(self.__class__.__module__.split('.')[-2])
return get_models(app) | python | def models(self):
"""
Return all the models defined for this module
"""
app = get_app(self.__class__.__module__.split('.')[-2])
return get_models(app) | [
"def",
"models",
"(",
"self",
")",
":",
"app",
"=",
"get_app",
"(",
"self",
".",
"__class__",
".",
"__module__",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"2",
"]",
")",
"return",
"get_models",
"(",
"app",
")"
] | Return all the models defined for this module | [
"Return",
"all",
"the",
"models",
"defined",
"for",
"this",
"module"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L338-L343 |
exekias/droplet | droplet/module.py | Module.conf_files | def conf_files(self):
"""
List of configuration files for this module
"""
for attr in dir(self):
field = getattr(self, attr)
if isinstance(field, ConfFile):
yield field | python | def conf_files(self):
"""
List of configuration files for this module
"""
for attr in dir(self):
field = getattr(self, attr)
if isinstance(field, ConfFile):
yield field | [
"def",
"conf_files",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"self",
")",
":",
"field",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"if",
"isinstance",
"(",
"field",
",",
"ConfFile",
")",
":",
"yield",
"field"
] | List of configuration files for this module | [
"List",
"of",
"configuration",
"files",
"for",
"this",
"module"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L380-L387 |
exekias/droplet | droplet/module.py | Module.restart | def restart(self):
"""
Restart module
"""
# Call stop & start if any of them was overriden
if self.__class__.stop != Module.stop or \
self.__class__.start != Module.start:
self.stop()
self.start()
else:
# If not, restart is b... | python | def restart(self):
"""
Restart module
"""
# Call stop & start if any of them was overriden
if self.__class__.stop != Module.stop or \
self.__class__.start != Module.start:
self.stop()
self.start()
else:
# If not, restart is b... | [
"def",
"restart",
"(",
"self",
")",
":",
"# Call stop & start if any of them was overriden",
"if",
"self",
".",
"__class__",
".",
"stop",
"!=",
"Module",
".",
"stop",
"or",
"self",
".",
"__class__",
".",
"start",
"!=",
"Module",
".",
"start",
":",
"self",
".... | Restart module | [
"Restart",
"module"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L405-L417 |
exekias/droplet | droplet/module.py | Module.daemons | def daemons(self):
"""
List of daemons for this module
"""
for attr in dir(self):
field = getattr(self, attr)
if isinstance(field, Daemon):
yield field | python | def daemons(self):
"""
List of daemons for this module
"""
for attr in dir(self):
field = getattr(self, attr)
if isinstance(field, Daemon):
yield field | [
"def",
"daemons",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"self",
")",
":",
"field",
"=",
"getattr",
"(",
"self",
",",
"attr",
")",
"if",
"isinstance",
"(",
"field",
",",
"Daemon",
")",
":",
"yield",
"field"
] | List of daemons for this module | [
"List",
"of",
"daemons",
"for",
"this",
"module"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/module.py#L419-L426 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_endpoint_by_endpoint_id | def get_endpoint_by_endpoint_id(self, endpoint_id):
"""
Get an endpoint by endpoint id
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}".format(endpoint_id)
response = NWS_DAO().getURL(url, self._read_headers)
if response.status != 200:
... | python | def get_endpoint_by_endpoint_id(self, endpoint_id):
"""
Get an endpoint by endpoint id
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}".format(endpoint_id)
response = NWS_DAO().getURL(url, self._read_headers)
if response.status != 200:
... | [
"def",
"get_endpoint_by_endpoint_id",
"(",
"self",
",",
"endpoint_id",
")",
":",
"self",
".",
"_validate_uuid",
"(",
"endpoint_id",
")",
"url",
"=",
"\"/notification/v1/endpoint/{}\"",
".",
"format",
"(",
"endpoint_id",
")",
"response",
"=",
"NWS_DAO",
"(",
")",
... | Get an endpoint by endpoint id | [
"Get",
"an",
"endpoint",
"by",
"endpoint",
"id"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L46-L59 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_endpoint_by_subscriber_id_and_protocol | def get_endpoint_by_subscriber_id_and_protocol(
self, subscriber_id, protocol):
"""
Get an endpoint by subscriber_id and protocol
"""
self._validate_subscriber_id(subscriber_id)
self._validate_endpoint_protocol(protocol)
url = "/notification/v1/endpoint?subsc... | python | def get_endpoint_by_subscriber_id_and_protocol(
self, subscriber_id, protocol):
"""
Get an endpoint by subscriber_id and protocol
"""
self._validate_subscriber_id(subscriber_id)
self._validate_endpoint_protocol(protocol)
url = "/notification/v1/endpoint?subsc... | [
"def",
"get_endpoint_by_subscriber_id_and_protocol",
"(",
"self",
",",
"subscriber_id",
",",
"protocol",
")",
":",
"self",
".",
"_validate_subscriber_id",
"(",
"subscriber_id",
")",
"self",
".",
"_validate_endpoint_protocol",
"(",
"protocol",
")",
"url",
"=",
"\"/noti... | Get an endpoint by subscriber_id and protocol | [
"Get",
"an",
"endpoint",
"by",
"subscriber_id",
"and",
"protocol"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L61-L81 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_endpoint_by_address | def get_endpoint_by_address(self, endpoint_addr):
"""
Get an endpoint by address
"""
url = "/notification/v1/endpoint?endpoint_address={}".format(
endpoint_addr)
response = NWS_DAO().getURL(url, self._read_headers)
if response.status != 200:
rais... | python | def get_endpoint_by_address(self, endpoint_addr):
"""
Get an endpoint by address
"""
url = "/notification/v1/endpoint?endpoint_address={}".format(
endpoint_addr)
response = NWS_DAO().getURL(url, self._read_headers)
if response.status != 200:
rais... | [
"def",
"get_endpoint_by_address",
"(",
"self",
",",
"endpoint_addr",
")",
":",
"url",
"=",
"\"/notification/v1/endpoint?endpoint_address={}\"",
".",
"format",
"(",
"endpoint_addr",
")",
"response",
"=",
"NWS_DAO",
"(",
")",
".",
"getURL",
"(",
"url",
",",
"self",
... | Get an endpoint by address | [
"Get",
"an",
"endpoint",
"by",
"address"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L83-L99 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_endpoints_by_subscriber_id | def get_endpoints_by_subscriber_id(self, subscriber_id):
"""
Search for all endpoints by a given subscriber
"""
self._validate_subscriber_id(subscriber_id)
url = "/notification/v1/endpoint?subscriber_id={}".format(
subscriber_id)
response = NWS_DAO().getURL(... | python | def get_endpoints_by_subscriber_id(self, subscriber_id):
"""
Search for all endpoints by a given subscriber
"""
self._validate_subscriber_id(subscriber_id)
url = "/notification/v1/endpoint?subscriber_id={}".format(
subscriber_id)
response = NWS_DAO().getURL(... | [
"def",
"get_endpoints_by_subscriber_id",
"(",
"self",
",",
"subscriber_id",
")",
":",
"self",
".",
"_validate_subscriber_id",
"(",
"subscriber_id",
")",
"url",
"=",
"\"/notification/v1/endpoint?subscriber_id={}\"",
".",
"format",
"(",
"subscriber_id",
")",
"response",
"... | Search for all endpoints by a given subscriber | [
"Search",
"for",
"all",
"endpoints",
"by",
"a",
"given",
"subscriber"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L101-L120 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.resend_sms_endpoint_verification | def resend_sms_endpoint_verification(self, endpoint_id):
"""
Calls NWS function to resend verification message to endpoint's
phone number
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}/verification".format(endpoint_id)
response = NWS_DA... | python | def resend_sms_endpoint_verification(self, endpoint_id):
"""
Calls NWS function to resend verification message to endpoint's
phone number
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}/verification".format(endpoint_id)
response = NWS_DA... | [
"def",
"resend_sms_endpoint_verification",
"(",
"self",
",",
"endpoint_id",
")",
":",
"self",
".",
"_validate_uuid",
"(",
"endpoint_id",
")",
"url",
"=",
"\"/notification/v1/endpoint/{}/verification\"",
".",
"format",
"(",
"endpoint_id",
")",
"response",
"=",
"NWS_DAO... | Calls NWS function to resend verification message to endpoint's
phone number | [
"Calls",
"NWS",
"function",
"to",
"resend",
"verification",
"message",
"to",
"endpoint",
"s",
"phone",
"number"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L122-L135 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.delete_endpoint | def delete_endpoint(self, endpoint_id):
"""
Deleting an existing endpoint
:param endpoint_id: is the endpoint that the client wants to delete
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}".format(endpoint_id)
response = NWS_DAO().delete... | python | def delete_endpoint(self, endpoint_id):
"""
Deleting an existing endpoint
:param endpoint_id: is the endpoint that the client wants to delete
"""
self._validate_uuid(endpoint_id)
url = "/notification/v1/endpoint/{}".format(endpoint_id)
response = NWS_DAO().delete... | [
"def",
"delete_endpoint",
"(",
"self",
",",
"endpoint_id",
")",
":",
"self",
".",
"_validate_uuid",
"(",
"endpoint_id",
")",
"url",
"=",
"\"/notification/v1/endpoint/{}\"",
".",
"format",
"(",
"endpoint_id",
")",
"response",
"=",
"NWS_DAO",
"(",
")",
".",
"del... | Deleting an existing endpoint
:param endpoint_id: is the endpoint that the client wants to delete | [
"Deleting",
"an",
"existing",
"endpoint",
":",
"param",
"endpoint_id",
":",
"is",
"the",
"endpoint",
"that",
"the",
"client",
"wants",
"to",
"delete"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L137-L149 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.update_endpoint | def update_endpoint(self, endpoint):
"""
Update an existing endpoint
:param endpoint: is the updated endpoint the client wants to update
"""
self._validate_uuid(endpoint.endpoint_id)
self._validate_subscriber_id(endpoint.subscriber_id)
url = "/notification/v1/end... | python | def update_endpoint(self, endpoint):
"""
Update an existing endpoint
:param endpoint: is the updated endpoint the client wants to update
"""
self._validate_uuid(endpoint.endpoint_id)
self._validate_subscriber_id(endpoint.subscriber_id)
url = "/notification/v1/end... | [
"def",
"update_endpoint",
"(",
"self",
",",
"endpoint",
")",
":",
"self",
".",
"_validate_uuid",
"(",
"endpoint",
".",
"endpoint_id",
")",
"self",
".",
"_validate_subscriber_id",
"(",
"endpoint",
".",
"subscriber_id",
")",
"url",
"=",
"\"/notification/v1/endpoint/... | Update an existing endpoint
:param endpoint: is the updated endpoint the client wants to update | [
"Update",
"an",
"existing",
"endpoint",
":",
"param",
"endpoint",
":",
"is",
"the",
"updated",
"endpoint",
"the",
"client",
"wants",
"to",
"update"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L151-L165 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.create_endpoint | def create_endpoint(self, endpoint):
"""
Create a new endpoint
:param endpoint: is the new endpoint that the client wants to create
"""
self._validate_subscriber_id(endpoint.subscriber_id)
url = "/notification/v1/endpoint"
response = NWS_DAO().postURL(
... | python | def create_endpoint(self, endpoint):
"""
Create a new endpoint
:param endpoint: is the new endpoint that the client wants to create
"""
self._validate_subscriber_id(endpoint.subscriber_id)
url = "/notification/v1/endpoint"
response = NWS_DAO().postURL(
... | [
"def",
"create_endpoint",
"(",
"self",
",",
"endpoint",
")",
":",
"self",
".",
"_validate_subscriber_id",
"(",
"endpoint",
".",
"subscriber_id",
")",
"url",
"=",
"\"/notification/v1/endpoint\"",
"response",
"=",
"NWS_DAO",
"(",
")",
".",
"postURL",
"(",
"url",
... | Create a new endpoint
:param endpoint: is the new endpoint that the client wants to create | [
"Create",
"a",
"new",
"endpoint",
":",
"param",
"endpoint",
":",
"is",
"the",
"new",
"endpoint",
"that",
"the",
"client",
"wants",
"to",
"create"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L167-L180 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.delete_subscription | def delete_subscription(self, subscription_id):
"""
Deleting an existing subscription
:param subscription_id: is the subscription the client wants to delete
"""
self._validate_uuid(subscription_id)
url = "/notification/v1/subscription/{}".format(subscription_id)
... | python | def delete_subscription(self, subscription_id):
"""
Deleting an existing subscription
:param subscription_id: is the subscription the client wants to delete
"""
self._validate_uuid(subscription_id)
url = "/notification/v1/subscription/{}".format(subscription_id)
... | [
"def",
"delete_subscription",
"(",
"self",
",",
"subscription_id",
")",
":",
"self",
".",
"_validate_uuid",
"(",
"subscription_id",
")",
"url",
"=",
"\"/notification/v1/subscription/{}\"",
".",
"format",
"(",
"subscription_id",
")",
"response",
"=",
"NWS_DAO",
"(",
... | Deleting an existing subscription
:param subscription_id: is the subscription the client wants to delete | [
"Deleting",
"an",
"existing",
"subscription",
":",
"param",
"subscription_id",
":",
"is",
"the",
"subscription",
"the",
"client",
"wants",
"to",
"delete"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L185-L198 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.create_subscription | def create_subscription(self, subscription):
"""
Create a new subscription
:param subscription: the new subscription the client wants to create
"""
if subscription.subscription_id is not None:
self._validate_uuid(subscription.subscription_id)
if subscription.... | python | def create_subscription(self, subscription):
"""
Create a new subscription
:param subscription: the new subscription the client wants to create
"""
if subscription.subscription_id is not None:
self._validate_uuid(subscription.subscription_id)
if subscription.... | [
"def",
"create_subscription",
"(",
"self",
",",
"subscription",
")",
":",
"if",
"subscription",
".",
"subscription_id",
"is",
"not",
"None",
":",
"self",
".",
"_validate_uuid",
"(",
"subscription",
".",
"subscription_id",
")",
"if",
"subscription",
".",
"endpoin... | Create a new subscription
:param subscription: the new subscription the client wants to create | [
"Create",
"a",
"new",
"subscription",
":",
"param",
"subscription",
":",
"the",
"new",
"subscription",
"the",
"client",
"wants",
"to",
"create"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L200-L226 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_subscriptions_by_subscriber_id | def get_subscriptions_by_subscriber_id(
self, subscriber_id, max_results=10):
"""
Search for all subscriptions by a given subscriber
"""
return self.search_subscriptions(
subscriber_id=subscriber_id, max_results=max_results) | python | def get_subscriptions_by_subscriber_id(
self, subscriber_id, max_results=10):
"""
Search for all subscriptions by a given subscriber
"""
return self.search_subscriptions(
subscriber_id=subscriber_id, max_results=max_results) | [
"def",
"get_subscriptions_by_subscriber_id",
"(",
"self",
",",
"subscriber_id",
",",
"max_results",
"=",
"10",
")",
":",
"return",
"self",
".",
"search_subscriptions",
"(",
"subscriber_id",
"=",
"subscriber_id",
",",
"max_results",
"=",
"max_results",
")"
] | Search for all subscriptions by a given subscriber | [
"Search",
"for",
"all",
"subscriptions",
"by",
"a",
"given",
"subscriber"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L237-L243 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_subscriptions_by_channel_id_and_subscriber_id | def get_subscriptions_by_channel_id_and_subscriber_id(
self, channel_id, subscriber_id):
"""
Search for all subscriptions by a given channel and subscriber
"""
return self.search_subscriptions(
channel_id=channel_id, subscriber_id=subscriber_id) | python | def get_subscriptions_by_channel_id_and_subscriber_id(
self, channel_id, subscriber_id):
"""
Search for all subscriptions by a given channel and subscriber
"""
return self.search_subscriptions(
channel_id=channel_id, subscriber_id=subscriber_id) | [
"def",
"get_subscriptions_by_channel_id_and_subscriber_id",
"(",
"self",
",",
"channel_id",
",",
"subscriber_id",
")",
":",
"return",
"self",
".",
"search_subscriptions",
"(",
"channel_id",
"=",
"channel_id",
",",
"subscriber_id",
"=",
"subscriber_id",
")"
] | Search for all subscriptions by a given channel and subscriber | [
"Search",
"for",
"all",
"subscriptions",
"by",
"a",
"given",
"channel",
"and",
"subscriber"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L245-L251 |
uw-it-aca/uw-restclients-nws | uw_nws/__init__.py | NWS.get_subscriptions_by_channel_id_and_person_id | def get_subscriptions_by_channel_id_and_person_id(
self, channel_id, person_id):
"""
Search for all subscriptions by a given channel and person
"""
return self.search_subscriptions(
channel_id=channel_id, person_id=person_id) | python | def get_subscriptions_by_channel_id_and_person_id(
self, channel_id, person_id):
"""
Search for all subscriptions by a given channel and person
"""
return self.search_subscriptions(
channel_id=channel_id, person_id=person_id) | [
"def",
"get_subscriptions_by_channel_id_and_person_id",
"(",
"self",
",",
"channel_id",
",",
"person_id",
")",
":",
"return",
"self",
".",
"search_subscriptions",
"(",
"channel_id",
"=",
"channel_id",
",",
"person_id",
"=",
"person_id",
")"
] | Search for all subscriptions by a given channel and person | [
"Search",
"for",
"all",
"subscriptions",
"by",
"a",
"given",
"channel",
"and",
"person"
] | train | https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L253-L259 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.