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 |
|---|---|---|---|---|---|---|---|---|---|---|
shoppimon/figcan | figcan/figcan.py | _create_flat_pointers | def _create_flat_pointers(dct, key_stack=()):
# type: (Dict[str, Any], Tuple[str, ...]) -> Generator[Tuple[Tuple[str, ...], Dict[str, Any], str], None, None]
"""Create a flattened dictionary of "key stacks" -> (value container, key)
"""
for k in dct.keys():
current_key = key_stack + (k,)
... | python | def _create_flat_pointers(dct, key_stack=()):
# type: (Dict[str, Any], Tuple[str, ...]) -> Generator[Tuple[Tuple[str, ...], Dict[str, Any], str], None, None]
"""Create a flattened dictionary of "key stacks" -> (value container, key)
"""
for k in dct.keys():
current_key = key_stack + (k,)
... | [
"def",
"_create_flat_pointers",
"(",
"dct",
",",
"key_stack",
"=",
"(",
")",
")",
":",
"# type: (Dict[str, Any], Tuple[str, ...]) -> Generator[Tuple[Tuple[str, ...], Dict[str, Any], str], None, None]",
"for",
"k",
"in",
"dct",
".",
"keys",
"(",
")",
":",
"current_key",
"=... | Create a flattened dictionary of "key stacks" -> (value container, key) | [
"Create",
"a",
"flattened",
"dictionary",
"of",
"key",
"stacks",
"-",
">",
"(",
"value",
"container",
"key",
")"
] | train | https://github.com/shoppimon/figcan/blob/bdfa59ceed33277c060fc009fbf44c41b9852681/figcan/figcan.py#L133-L143 |
shoppimon/figcan | figcan/figcan.py | Configuration.apply | def apply(self, config, raise_on_unknown_key=True):
# type: (Dict[str, Any], bool) -> None
"""Apply additional configuration from a dictionary
This will look for dictionary items that exist in the base_config any apply their values on the current
configuration object
"""
... | python | def apply(self, config, raise_on_unknown_key=True):
# type: (Dict[str, Any], bool) -> None
"""Apply additional configuration from a dictionary
This will look for dictionary items that exist in the base_config any apply their values on the current
configuration object
"""
... | [
"def",
"apply",
"(",
"self",
",",
"config",
",",
"raise_on_unknown_key",
"=",
"True",
")",
":",
"# type: (Dict[str, Any], bool) -> None",
"_recursive_merge",
"(",
"self",
".",
"_data",
",",
"config",
",",
"raise_on_unknown_key",
")"
] | Apply additional configuration from a dictionary
This will look for dictionary items that exist in the base_config any apply their values on the current
configuration object | [
"Apply",
"additional",
"configuration",
"from",
"a",
"dictionary"
] | train | https://github.com/shoppimon/figcan/blob/bdfa59ceed33277c060fc009fbf44c41b9852681/figcan/figcan.py#L35-L42 |
shoppimon/figcan | figcan/figcan.py | Configuration.apply_object | def apply_object(self, config_obj, apply_on=None):
# type: (object, Optional[Tuple[str, ...]]) -> None
"""Apply additional configuration from any Python object
This will look for object attributes that exist in the base_config and apply their values on the current
configuration object
... | python | def apply_object(self, config_obj, apply_on=None):
# type: (object, Optional[Tuple[str, ...]]) -> None
"""Apply additional configuration from any Python object
This will look for object attributes that exist in the base_config and apply their values on the current
configuration object
... | [
"def",
"apply_object",
"(",
"self",
",",
"config_obj",
",",
"apply_on",
"=",
"None",
")",
":",
"# type: (object, Optional[Tuple[str, ...]]) -> None",
"self",
".",
"_init_flat_pointers",
"(",
")",
"try",
":",
"config_obj_keys",
"=",
"vars",
"(",
"config_obj",
")",
... | Apply additional configuration from any Python object
This will look for object attributes that exist in the base_config and apply their values on the current
configuration object | [
"Apply",
"additional",
"configuration",
"from",
"any",
"Python",
"object"
] | train | https://github.com/shoppimon/figcan/blob/bdfa59ceed33277c060fc009fbf44c41b9852681/figcan/figcan.py#L44-L65 |
shoppimon/figcan | figcan/figcan.py | Configuration.apply_flat | def apply_flat(self, config, namespace_separator='_', prefix=''):
# type: (Dict[str, Any], str, str) -> None
"""Apply additional configuration from a flattened dictionary
This will look for dictionary items that match flattened keys from base_config and apply their values on the
current... | python | def apply_flat(self, config, namespace_separator='_', prefix=''):
# type: (Dict[str, Any], str, str) -> None
"""Apply additional configuration from a flattened dictionary
This will look for dictionary items that match flattened keys from base_config and apply their values on the
current... | [
"def",
"apply_flat",
"(",
"self",
",",
"config",
",",
"namespace_separator",
"=",
"'_'",
",",
"prefix",
"=",
"''",
")",
":",
"# type: (Dict[str, Any], str, str) -> None",
"self",
".",
"_init_flat_pointers",
"(",
")",
"for",
"key_stack",
",",
"(",
"container",
",... | Apply additional configuration from a flattened dictionary
This will look for dictionary items that match flattened keys from base_config and apply their values on the
current configuration object.
This can be useful for applying configuration from environment variables and flat configuration ... | [
"Apply",
"additional",
"configuration",
"from",
"a",
"flattened",
"dictionary"
] | train | https://github.com/shoppimon/figcan/blob/bdfa59ceed33277c060fc009fbf44c41b9852681/figcan/figcan.py#L67-L81 |
databuild/databuild | databuild/functions/data.py | cross | def cross(environment, book, row, sheet_source, column_source, column_key):
"""
Returns a single value from a column from a different dataset, matching by the key.
"""
a = book.sheets[sheet_source]
return environment.copy(a.get(**{column_key: row[column_key]})[column_source]) | python | def cross(environment, book, row, sheet_source, column_source, column_key):
"""
Returns a single value from a column from a different dataset, matching by the key.
"""
a = book.sheets[sheet_source]
return environment.copy(a.get(**{column_key: row[column_key]})[column_source]) | [
"def",
"cross",
"(",
"environment",
",",
"book",
",",
"row",
",",
"sheet_source",
",",
"column_source",
",",
"column_key",
")",
":",
"a",
"=",
"book",
".",
"sheets",
"[",
"sheet_source",
"]",
"return",
"environment",
".",
"copy",
"(",
"a",
".",
"get",
... | Returns a single value from a column from a different dataset, matching by the key. | [
"Returns",
"a",
"single",
"value",
"from",
"a",
"column",
"from",
"a",
"different",
"dataset",
"matching",
"by",
"the",
"key",
"."
] | train | https://github.com/databuild/databuild/blob/4c8ee04fad1748f5b966753057ac05efbc289b10/databuild/functions/data.py#L1-L7 |
databuild/databuild | databuild/functions/data.py | column | def column(environment, book, sheet_name, sheet_source, column_source, column_key):
"""
Returns an array of values from column from a different dataset, ordered as the key.
"""
a = book.sheets[sheet_source]
b = book.sheets[sheet_name]
return environment.copy([a.get(**{column_key: row[column_key... | python | def column(environment, book, sheet_name, sheet_source, column_source, column_key):
"""
Returns an array of values from column from a different dataset, ordered as the key.
"""
a = book.sheets[sheet_source]
b = book.sheets[sheet_name]
return environment.copy([a.get(**{column_key: row[column_key... | [
"def",
"column",
"(",
"environment",
",",
"book",
",",
"sheet_name",
",",
"sheet_source",
",",
"column_source",
",",
"column_key",
")",
":",
"a",
"=",
"book",
".",
"sheets",
"[",
"sheet_source",
"]",
"b",
"=",
"book",
".",
"sheets",
"[",
"sheet_name",
"]... | Returns an array of values from column from a different dataset, ordered as the key. | [
"Returns",
"an",
"array",
"of",
"values",
"from",
"column",
"from",
"a",
"different",
"dataset",
"ordered",
"as",
"the",
"key",
"."
] | train | https://github.com/databuild/databuild/blob/4c8ee04fad1748f5b966753057ac05efbc289b10/databuild/functions/data.py#L10-L17 |
hyperknot/image2leaflet | image2leaflet/cli.py | main | def main(input_file, output, format):
"""Converts an image file to a Leaflet map."""
try:
process_image(input_file, subfolder=output, ext=format)
except Exception as e:
sys.exit(e) | python | def main(input_file, output, format):
"""Converts an image file to a Leaflet map."""
try:
process_image(input_file, subfolder=output, ext=format)
except Exception as e:
sys.exit(e) | [
"def",
"main",
"(",
"input_file",
",",
"output",
",",
"format",
")",
":",
"try",
":",
"process_image",
"(",
"input_file",
",",
"subfolder",
"=",
"output",
",",
"ext",
"=",
"format",
")",
"except",
"Exception",
"as",
"e",
":",
"sys",
".",
"exit",
"(",
... | Converts an image file to a Leaflet map. | [
"Converts",
"an",
"image",
"file",
"to",
"a",
"Leaflet",
"map",
"."
] | train | https://github.com/hyperknot/image2leaflet/blob/b89bef03b8ac99227386a2a9fa12e2998a508d64/image2leaflet/cli.py#L11-L17 |
rackerlabs/silverberg | silverberg/lock.py | with_lock | def with_lock(lock, func, *args, **kwargs):
"""A 'context manager' for performing operations requiring a lock.
:param lock: A BasicLock instance
:type lock: silverberg.lock.BasicLock
:param func: A callable to execute while the lock is held.
:type func: function
"""
d = lock.acquire()
... | python | def with_lock(lock, func, *args, **kwargs):
"""A 'context manager' for performing operations requiring a lock.
:param lock: A BasicLock instance
:type lock: silverberg.lock.BasicLock
:param func: A callable to execute while the lock is held.
:type func: function
"""
d = lock.acquire()
... | [
"def",
"with_lock",
"(",
"lock",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"d",
"=",
"lock",
".",
"acquire",
"(",
")",
"def",
"release_lock",
"(",
"result",
")",
":",
"deferred",
"=",
"lock",
".",
"release",
"(",
")",
"ret... | A 'context manager' for performing operations requiring a lock.
:param lock: A BasicLock instance
:type lock: silverberg.lock.BasicLock
:param func: A callable to execute while the lock is held.
:type func: function | [
"A",
"context",
"manager",
"for",
"performing",
"operations",
"requiring",
"a",
"lock",
"."
] | train | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/lock.py#L217-L236 |
rackerlabs/silverberg | silverberg/lock.py | BasicLock.ensure_schema | def ensure_schema(client, table_name):
"""
Create the table/columnfamily if it doesn't already exist.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: ... | python | def ensure_schema(client, table_name):
"""
Create the table/columnfamily if it doesn't already exist.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: ... | [
"def",
"ensure_schema",
"(",
"client",
",",
"table_name",
")",
":",
"query",
"=",
"''",
".",
"join",
"(",
"[",
"'CREATE TABLE {cf} '",
",",
"'(\"lockId\" ascii, \"claimId\" timeuuid, PRIMARY KEY(\"lockId\", \"claimId\"));'",
"]",
")",
"def",
"errback",
"(",
"failure",
... | Create the table/columnfamily if it doesn't already exist.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: str | [
"Create",
"the",
"table",
"/",
"columnfamily",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | train | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/lock.py#L119-L137 |
rackerlabs/silverberg | silverberg/lock.py | BasicLock.drop_schema | def drop_schema(client, table_name):
"""
Delete the table/columnfamily.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: str
"""
query ... | python | def drop_schema(client, table_name):
"""
Delete the table/columnfamily.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: str
"""
query ... | [
"def",
"drop_schema",
"(",
"client",
",",
"table_name",
")",
":",
"query",
"=",
"'DROP TABLE {cf}'",
"return",
"client",
".",
"execute",
"(",
"query",
".",
"format",
"(",
"cf",
"=",
"table_name",
")",
",",
"{",
"}",
",",
"ConsistencyLevel",
".",
"QUORUM",
... | Delete the table/columnfamily.
:param client: A Cassandra CQL client
:type client: silverberg.client.CQLClient
:param lock_table: A table/columnfamily table name for holding locks.
:type lock_table: str | [
"Delete",
"the",
"table",
"/",
"columnfamily",
"."
] | train | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/lock.py#L140-L152 |
rackerlabs/silverberg | silverberg/lock.py | BasicLock.release | def release(self):
"""
Release the lock.
"""
query = 'DELETE FROM {cf} WHERE "lockId"=:lockId AND "claimId"=:claimId;'
d = self._client.execute(query.format(cf=self._lock_table),
{'lockId': self._lock_id, 'claimId': self._claim_id},
... | python | def release(self):
"""
Release the lock.
"""
query = 'DELETE FROM {cf} WHERE "lockId"=:lockId AND "claimId"=:claimId;'
d = self._client.execute(query.format(cf=self._lock_table),
{'lockId': self._lock_id, 'claimId': self._claim_id},
... | [
"def",
"release",
"(",
"self",
")",
":",
"query",
"=",
"'DELETE FROM {cf} WHERE \"lockId\"=:lockId AND \"claimId\"=:claimId;'",
"d",
"=",
"self",
".",
"_client",
".",
"execute",
"(",
"query",
".",
"format",
"(",
"cf",
"=",
"self",
".",
"_lock_table",
")",
",",
... | Release the lock. | [
"Release",
"the",
"lock",
"."
] | train | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/lock.py#L154-L170 |
rackerlabs/silverberg | silverberg/lock.py | BasicLock.acquire | def acquire(self):
"""
Acquire the lock.
If the lock can't be acquired immediately, retry a specified number of
times, with a specified wait time.
"""
retries = [0]
self._acquire_start_seconds = self._reactor.seconds()
def log_lock_acquired(result):
... | python | def acquire(self):
"""
Acquire the lock.
If the lock can't be acquired immediately, retry a specified number of
times, with a specified wait time.
"""
retries = [0]
self._acquire_start_seconds = self._reactor.seconds()
def log_lock_acquired(result):
... | [
"def",
"acquire",
"(",
"self",
")",
":",
"retries",
"=",
"[",
"0",
"]",
"self",
".",
"_acquire_start_seconds",
"=",
"self",
".",
"_reactor",
".",
"seconds",
"(",
")",
"def",
"log_lock_acquired",
"(",
"result",
")",
":",
"self",
".",
"_lock_acquired_seconds... | Acquire the lock.
If the lock can't be acquired immediately, retry a specified number of
times, with a specified wait time. | [
"Acquire",
"the",
"lock",
"."
] | train | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/lock.py#L172-L214 |
fedora-infra/fmn.rules | fmn/rules/buildsys.py | koji_instance | def koji_instance(config, message, instance=None, *args, **kw):
""" Particular koji instances
You may not have even known it, but we have multiple instances of the koji
build system. There is the **primary** buildsystem at
`koji.fedoraproject.org <http://koji.fedoraproject.org>`_ and also
secondar... | python | def koji_instance(config, message, instance=None, *args, **kw):
""" Particular koji instances
You may not have even known it, but we have multiple instances of the koji
build system. There is the **primary** buildsystem at
`koji.fedoraproject.org <http://koji.fedoraproject.org>`_ and also
secondar... | [
"def",
"koji_instance",
"(",
"config",
",",
"message",
",",
"instance",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"instance",
"=",
"kw",
".",
"get",
"(",
"'instance'",
",",
"instance",
")",
"if",
"not",
"instance",
":",
"return",
... | Particular koji instances
You may not have even known it, but we have multiple instances of the koji
build system. There is the **primary** buildsystem at
`koji.fedoraproject.org <http://koji.fedoraproject.org>`_ and also
secondary instances for `ppc <http://ppc.koji.fedoraproject.org>`_, `arm
<ht... | [
"Particular",
"koji",
"instances"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/buildsys.py#L17-L42 |
kervi/kervi-core | kervi/values/value_list.py | ValueList.add | def add(self, value_id, name, value_class):
"""
Factory function that creates a value.
:param value_id: id of the value, used to reference the value within this list.BaseException
:param value_class: The class of the value that should be created with this function.
"""
... | python | def add(self, value_id, name, value_class):
"""
Factory function that creates a value.
:param value_id: id of the value, used to reference the value within this list.BaseException
:param value_class: The class of the value that should be created with this function.
"""
... | [
"def",
"add",
"(",
"self",
",",
"value_id",
",",
"name",
",",
"value_class",
")",
":",
"item",
"=",
"value_class",
"(",
"name",
",",
"value_id",
"=",
"self",
".",
"controller",
".",
"component_id",
"+",
"\".\"",
"+",
"value_id",
",",
"is_input",
"=",
"... | Factory function that creates a value.
:param value_id: id of the value, used to reference the value within this list.BaseException
:param value_class: The class of the value that should be created with this function. | [
"Factory",
"function",
"that",
"creates",
"a",
"value",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/values/value_list.py#L20-L44 |
bmweiner/skillful | skillful/controller.py | Skill.register | def register(self, name):
"""Decorator for registering a named function in the sesion logic.
Args:
name: str. Function name.
func: obj. Parameterless function to register.
The following named functions must be registered:
'LaunchRequest' - logic for launch r... | python | def register(self, name):
"""Decorator for registering a named function in the sesion logic.
Args:
name: str. Function name.
func: obj. Parameterless function to register.
The following named functions must be registered:
'LaunchRequest' - logic for launch r... | [
"def",
"register",
"(",
"self",
",",
"name",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"Inner decorator, not used directly.\n\n Args:\n func: obj. Parameterless function to register.\n\n Returns:\n func: decorated funct... | Decorator for registering a named function in the sesion logic.
Args:
name: str. Function name.
func: obj. Parameterless function to register.
The following named functions must be registered:
'LaunchRequest' - logic for launch request.
'SessionEndedRequ... | [
"Decorator",
"for",
"registering",
"a",
"named",
"function",
"in",
"the",
"sesion",
"logic",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/controller.py#L49-L81 |
bmweiner/skillful | skillful/controller.py | Skill.pass_session_attributes | def pass_session_attributes(self):
"""Copies request attributes to response"""
for key, value in six.iteritems(self.request.session.attributes):
self.response.sessionAttributes[key] = value | python | def pass_session_attributes(self):
"""Copies request attributes to response"""
for key, value in six.iteritems(self.request.session.attributes):
self.response.sessionAttributes[key] = value | [
"def",
"pass_session_attributes",
"(",
"self",
")",
":",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"request",
".",
"session",
".",
"attributes",
")",
":",
"self",
".",
"response",
".",
"sessionAttributes",
"[",
"key",
"... | Copies request attributes to response | [
"Copies",
"request",
"attributes",
"to",
"response"
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/controller.py#L83-L86 |
bmweiner/skillful | skillful/controller.py | Skill.dispatch | def dispatch(self):
"""Calls the matching logic function by request type or intent name."""
if self.request.request.type == 'IntentRequest':
name = self.request.request.intent.name
else:
name = self.request.request.type
if name in self.logic:
self.lo... | python | def dispatch(self):
"""Calls the matching logic function by request type or intent name."""
if self.request.request.type == 'IntentRequest':
name = self.request.request.intent.name
else:
name = self.request.request.type
if name in self.logic:
self.lo... | [
"def",
"dispatch",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
".",
"request",
".",
"type",
"==",
"'IntentRequest'",
":",
"name",
"=",
"self",
".",
"request",
".",
"request",
".",
"intent",
".",
"name",
"else",
":",
"name",
"=",
"self",
".",... | Calls the matching logic function by request type or intent name. | [
"Calls",
"the",
"matching",
"logic",
"function",
"by",
"request",
"type",
"or",
"intent",
"name",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/controller.py#L92-L104 |
bmweiner/skillful | skillful/controller.py | Skill.process | def process(self, body, url=None, sig=None):
"""Process request body given skill logic.
To validate a request, both, url and sig are required.
Attributes received through body will be automatically added to the
response.
Args:
body: str. HTTP request body.
... | python | def process(self, body, url=None, sig=None):
"""Process request body given skill logic.
To validate a request, both, url and sig are required.
Attributes received through body will be automatically added to the
response.
Args:
body: str. HTTP request body.
... | [
"def",
"process",
"(",
"self",
",",
"body",
",",
"url",
"=",
"None",
",",
"sig",
"=",
"None",
")",
":",
"self",
".",
"request",
"=",
"RequestBody",
"(",
")",
"self",
".",
"response",
"=",
"ResponseBody",
"(",
")",
"self",
".",
"request",
".",
"pars... | Process request body given skill logic.
To validate a request, both, url and sig are required.
Attributes received through body will be automatically added to the
response.
Args:
body: str. HTTP request body.
url: str. SignatureCertChainUrl header value sen... | [
"Process",
"request",
"body",
"given",
"skill",
"logic",
"."
] | train | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/controller.py#L106-L142 |
hkff/FodtlMon | fodtlmon/ltl/ltl.py | B3 | def B3(formula):
"""
Rewrite formula eval result into Boolean3
:param formula:
:return: Boolean3
"""
if isinstance(formula, true) or formula is True or formula == Boolean3.Top.name or formula == Boolean3.Top.value:
return Boolean3.Top
if isinstance(formula, false) or formula is False... | python | def B3(formula):
"""
Rewrite formula eval result into Boolean3
:param formula:
:return: Boolean3
"""
if isinstance(formula, true) or formula is True or formula == Boolean3.Top.name or formula == Boolean3.Top.value:
return Boolean3.Top
if isinstance(formula, false) or formula is False... | [
"def",
"B3",
"(",
"formula",
")",
":",
"if",
"isinstance",
"(",
"formula",
",",
"true",
")",
"or",
"formula",
"is",
"True",
"or",
"formula",
"==",
"Boolean3",
".",
"Top",
".",
"name",
"or",
"formula",
"==",
"Boolean3",
".",
"Top",
".",
"value",
":",
... | Rewrite formula eval result into Boolean3
:param formula:
:return: Boolean3 | [
"Rewrite",
"formula",
"eval",
"result",
"into",
"Boolean3",
":",
"param",
"formula",
":",
":",
"return",
":",
"Boolean3"
] | train | https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/ltl/ltl.py#L626-L637 |
hkff/FodtlMon | fodtlmon/ltl/ltl.py | Formula.walk | def walk(self, filters: str=None, filter_type: type=None, pprint=False, depth=-1):
"""
Iterate tree in pre-order wide-first search order
:param filters: filter by python expression
:param filter_type: Filter by class
:return:
"""
children = self.children()
... | python | def walk(self, filters: str=None, filter_type: type=None, pprint=False, depth=-1):
"""
Iterate tree in pre-order wide-first search order
:param filters: filter by python expression
:param filter_type: Filter by class
:return:
"""
children = self.children()
... | [
"def",
"walk",
"(",
"self",
",",
"filters",
":",
"str",
"=",
"None",
",",
"filter_type",
":",
"type",
"=",
"None",
",",
"pprint",
"=",
"False",
",",
"depth",
"=",
"-",
"1",
")",
":",
"children",
"=",
"self",
".",
"children",
"(",
")",
"if",
"chil... | Iterate tree in pre-order wide-first search order
:param filters: filter by python expression
:param filter_type: Filter by class
:return: | [
"Iterate",
"tree",
"in",
"pre",
"-",
"order",
"wide",
"-",
"first",
"search",
"order"
] | train | https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/ltl/ltl.py#L73-L113 |
knagra/farnsworth | workshift/redirects.py | red_workshift | def red_workshift(request, message=None):
'''
Redirects to the base workshift page for users who are logged in
'''
if message:
messages.add_message(request, messages.ERROR, message)
return HttpResponseRedirect(reverse('workshift:view_semester')) | python | def red_workshift(request, message=None):
'''
Redirects to the base workshift page for users who are logged in
'''
if message:
messages.add_message(request, messages.ERROR, message)
return HttpResponseRedirect(reverse('workshift:view_semester')) | [
"def",
"red_workshift",
"(",
"request",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
":",
"messages",
".",
"add_message",
"(",
"request",
",",
"messages",
".",
"ERROR",
",",
"message",
")",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
... | Redirects to the base workshift page for users who are logged in | [
"Redirects",
"to",
"the",
"base",
"workshift",
"page",
"for",
"users",
"who",
"are",
"logged",
"in"
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/redirects.py#L6-L12 |
raphendyr/django-settingsdict | django_settingsdict/__init__.py | SettingsDict._user_settings | def _user_settings(self):
"""
Resolve settings dict from django settings module.
Validate that all the required keys are present and also that none of
the removed keys do.
Result is cached.
"""
user_settings = getattr(settings, self._name, {})
if not user_... | python | def _user_settings(self):
"""
Resolve settings dict from django settings module.
Validate that all the required keys are present and also that none of
the removed keys do.
Result is cached.
"""
user_settings = getattr(settings, self._name, {})
if not user_... | [
"def",
"_user_settings",
"(",
"self",
")",
":",
"user_settings",
"=",
"getattr",
"(",
"settings",
",",
"self",
".",
"_name",
",",
"{",
"}",
")",
"if",
"not",
"user_settings",
"and",
"self",
".",
"_required",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"Se... | Resolve settings dict from django settings module.
Validate that all the required keys are present and also that none of
the removed keys do.
Result is cached. | [
"Resolve",
"settings",
"dict",
"from",
"django",
"settings",
"module",
".",
"Validate",
"that",
"all",
"the",
"required",
"keys",
"are",
"present",
"and",
"also",
"that",
"none",
"of",
"the",
"removed",
"keys",
"do",
".",
"Result",
"is",
"cached",
"."
] | train | https://github.com/raphendyr/django-settingsdict/blob/655f8e86b0af46ee6a5615fdbeeaf81ae7ec8e0f/django_settingsdict/__init__.py#L18-L38 |
MickaelRigault/propobject | propobject/baseobject.py | BaseObject.copy | def copy(self, empty=False):
"""returns an independent copy of the current object."""
# Create an empty object
newobject = self.__new__(self.__class__)
if empty:
return
# And fill it !
for prop in ["_properties","_side_properties",
... | python | def copy(self, empty=False):
"""returns an independent copy of the current object."""
# Create an empty object
newobject = self.__new__(self.__class__)
if empty:
return
# And fill it !
for prop in ["_properties","_side_properties",
... | [
"def",
"copy",
"(",
"self",
",",
"empty",
"=",
"False",
")",
":",
"# Create an empty object",
"newobject",
"=",
"self",
".",
"__new__",
"(",
"self",
".",
"__class__",
")",
"if",
"empty",
":",
"return",
"# And fill it !",
"for",
"prop",
"in",
"[",
"\"_prope... | returns an independent copy of the current object. | [
"returns",
"an",
"independent",
"copy",
"of",
"the",
"current",
"object",
"."
] | train | https://github.com/MickaelRigault/propobject/blob/e58614f85e2df9811012807836a7b3c5f3b267f2/propobject/baseobject.py#L97-L119 |
Gwildor/Pyromancer | pyromancer/objects.py | Match.msg | def msg(self, message, *args, **kwargs):
"""Shortcut to send a message through the connection.
This function sends the input message through the connection. A target
can be defined, else it will send it to the channel or user from the
input Line, effectively responding on whatever trigg... | python | def msg(self, message, *args, **kwargs):
"""Shortcut to send a message through the connection.
This function sends the input message through the connection. A target
can be defined, else it will send it to the channel or user from the
input Line, effectively responding on whatever trigg... | [
"def",
"msg",
"(",
"self",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"target",
"=",
"kwargs",
".",
"pop",
"(",
"'target'",
",",
"None",
")",
"raw",
"=",
"kwargs",
".",
"pop",
"(",
"'raw'",
",",
"False",
")",
"if",
"no... | Shortcut to send a message through the connection.
This function sends the input message through the connection. A target
can be defined, else it will send it to the channel or user from the
input Line, effectively responding on whatever triggered the command
which calls this function t... | [
"Shortcut",
"to",
"send",
"a",
"message",
"through",
"the",
"connection",
"."
] | train | https://github.com/Gwildor/Pyromancer/blob/250a83ad4b6e87560bea8f2e0526ad0bba678f3d/pyromancer/objects.py#L313-L353 |
spookey/photon | photon/util/system.py | shell_notify | def shell_notify(msg, state=False, more=None, exitcode=None, verbose=True):
'''
A pretty long wrapper for a :py:func:`print` function.
But this :py:func:`print` is the only one in Photon.
.. note:: |use_photon_m|
:param msg:
The message to show
:param state:
The message will be... | python | def shell_notify(msg, state=False, more=None, exitcode=None, verbose=True):
'''
A pretty long wrapper for a :py:func:`print` function.
But this :py:func:`print` is the only one in Photon.
.. note:: |use_photon_m|
:param msg:
The message to show
:param state:
The message will be... | [
"def",
"shell_notify",
"(",
"msg",
",",
"state",
"=",
"False",
",",
"more",
"=",
"None",
",",
"exitcode",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"state",
"is",
"True",
":",
"state",
"=",
"'[FATAL]'",
"exitcode",
"=",
"23",
"elif",
... | A pretty long wrapper for a :py:func:`print` function.
But this :py:func:`print` is the only one in Photon.
.. note:: |use_photon_m|
:param msg:
The message to show
:param state:
The message will be prefixed with [`state`]
* If ``False`` (default): Prefixed with ~
* I... | [
"A",
"pretty",
"long",
"wrapper",
"for",
"a",
":",
"py",
":",
"func",
":",
"print",
"function",
".",
"But",
"this",
":",
"py",
":",
"func",
":",
"print",
"is",
"the",
"only",
"one",
"in",
"Photon",
"."
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/system.py#L15-L72 |
spookey/photon | photon/util/system.py | shell_run | def shell_run(cmd,
cin=None, cwd=None, timeout=10, critical=True, verbose=True):
'''
Runs a shell command within a controlled environment.
.. note:: |use_photon_m|
:param cmd: The command to run
* A string one would type into a console like \
:command:`git push -u origin... | python | def shell_run(cmd,
cin=None, cwd=None, timeout=10, critical=True, verbose=True):
'''
Runs a shell command within a controlled environment.
.. note:: |use_photon_m|
:param cmd: The command to run
* A string one would type into a console like \
:command:`git push -u origin... | [
"def",
"shell_run",
"(",
"cmd",
",",
"cin",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"timeout",
"=",
"10",
",",
"critical",
"=",
"True",
",",
"verbose",
"=",
"True",
")",
":",
"res",
"=",
"dict",
"(",
"command",
"=",
"cmd",
")",
"if",
"cin",
... | Runs a shell command within a controlled environment.
.. note:: |use_photon_m|
:param cmd: The command to run
* A string one would type into a console like \
:command:`git push -u origin master`.
* Will be split using :py:func:`shlex.split`.
* It is possible to use a list he... | [
"Runs",
"a",
"shell",
"command",
"within",
"a",
"controlled",
"environment",
"."
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/system.py#L75-L180 |
spookey/photon | photon/util/system.py | get_timestamp | def get_timestamp(time=True, precice=False):
'''
What time is it?
:param time:
Append ``-%H.%M.%S`` to the final string.
:param precice:
Append ``-%f`` to the final string.
Is only recognized when `time` is set to ``True``
:returns:
A timestamp string of now in the f... | python | def get_timestamp(time=True, precice=False):
'''
What time is it?
:param time:
Append ``-%H.%M.%S`` to the final string.
:param precice:
Append ``-%f`` to the final string.
Is only recognized when `time` is set to ``True``
:returns:
A timestamp string of now in the f... | [
"def",
"get_timestamp",
"(",
"time",
"=",
"True",
",",
"precice",
"=",
"False",
")",
":",
"f",
"=",
"'%Y.%m.%d'",
"if",
"time",
":",
"f",
"+=",
"'-%H.%M.%S'",
"if",
"precice",
":",
"f",
"+=",
"'-%f'",
"return",
"_datetime",
".",
"now",
"(",
")",
".",... | What time is it?
:param time:
Append ``-%H.%M.%S`` to the final string.
:param precice:
Append ``-%f`` to the final string.
Is only recognized when `time` is set to ``True``
:returns:
A timestamp string of now in the format ``%Y.%m.%d-%H.%M.%S-%f``
.. seealso:: `strftim... | [
"What",
"time",
"is",
"it?"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/system.py#L183-L203 |
spookey/photon | photon/util/system.py | get_hostname | def get_hostname():
'''
Determines the current hostname by probing ``uname -n``.
Falls back to ``hostname`` in case of problems.
|appteardown| if both failed (usually they don't but consider
this if you are debugging weird problems..)
:returns:
The hostname as string. Domain parts wil... | python | def get_hostname():
'''
Determines the current hostname by probing ``uname -n``.
Falls back to ``hostname`` in case of problems.
|appteardown| if both failed (usually they don't but consider
this if you are debugging weird problems..)
:returns:
The hostname as string. Domain parts wil... | [
"def",
"get_hostname",
"(",
")",
":",
"h",
"=",
"shell_run",
"(",
"'uname -n'",
",",
"critical",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
"if",
"not",
"h",
":",
"h",
"=",
"shell_run",
"(",
"'hostname'",
",",
"critical",
"=",
"False",
",",
"ve... | Determines the current hostname by probing ``uname -n``.
Falls back to ``hostname`` in case of problems.
|appteardown| if both failed (usually they don't but consider
this if you are debugging weird problems..)
:returns:
The hostname as string. Domain parts will be split off | [
"Determines",
"the",
"current",
"hostname",
"by",
"probing",
"uname",
"-",
"n",
".",
"Falls",
"back",
"to",
"hostname",
"in",
"case",
"of",
"problems",
"."
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/util/system.py#L206-L223 |
alexhayes/django-toolkit | django_toolkit/font_awesome.py | Stack.render | def render(self):
"""
Render the icon stack.
For example:
<span class="icon-stack">
<i class="icon-check-empty icon-stack-base"></i>
<i class="icon-twitter"></i>
</span>
<span class="icon-stack">
<i class="icon-circle icon-stack-base... | python | def render(self):
"""
Render the icon stack.
For example:
<span class="icon-stack">
<i class="icon-check-empty icon-stack-base"></i>
<i class="icon-twitter"></i>
</span>
<span class="icon-stack">
<i class="icon-circle icon-stack-base... | [
"def",
"render",
"(",
"self",
")",
":",
"return",
"'<span class=\"icon-stack\">%s</span>'",
"%",
"(",
"''",
".",
"join",
"(",
"[",
"item",
".",
"render",
"(",
"[",
"'icon-stack-base'",
"]",
"if",
"i",
"==",
"0",
"else",
"[",
"]",
")",
"for",
"(",
"i",
... | Render the icon stack.
For example:
<span class="icon-stack">
<i class="icon-check-empty icon-stack-base"></i>
<i class="icon-twitter"></i>
</span>
<span class="icon-stack">
<i class="icon-circle icon-stack-base"></i>
<i class="icon-flag i... | [
"Render",
"the",
"icon",
"stack",
".",
"For",
"example",
":",
"<span",
"class",
"=",
"icon",
"-",
"stack",
">",
"<i",
"class",
"=",
"icon",
"-",
"check",
"-",
"empty",
"icon",
"-",
"stack",
"-",
"base",
">",
"<",
"/",
"i",
">",
"<i",
"class",
"="... | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/font_awesome.py#L37-L61 |
alexhayes/django-toolkit | django_toolkit/font_awesome.py | Button.render | def render(self):
"""
<a class="btn" href="#"><i class="icon-repeat"></i> Reload</a>
or..
<button type="button" class="btn"><i class="icon-repeat"></i> Reload</button>
"""
html = ''
href = self.view if self.view is not None else self.href
... | python | def render(self):
"""
<a class="btn" href="#"><i class="icon-repeat"></i> Reload</a>
or..
<button type="button" class="btn"><i class="icon-repeat"></i> Reload</button>
"""
html = ''
href = self.view if self.view is not None else self.href
... | [
"def",
"render",
"(",
"self",
")",
":",
"html",
"=",
"''",
"href",
"=",
"self",
".",
"view",
"if",
"self",
".",
"view",
"is",
"not",
"None",
"else",
"self",
".",
"href",
"attrs",
"=",
"copy",
"(",
"self",
".",
"attrs",
")",
"if",
"self",
".",
"... | <a class="btn" href="#"><i class="icon-repeat"></i> Reload</a>
or..
<button type="button" class="btn"><i class="icon-repeat"></i> Reload</button> | [
"<a",
"class",
"=",
"btn",
"href",
"=",
"#",
">",
"<i",
"class",
"=",
"icon",
"-",
"repeat",
">",
"<",
"/",
"i",
">",
"Reload<",
"/",
"a",
">",
"or",
"..",
"<button",
"type",
"=",
"button",
"class",
"=",
"btn",
">",
"<i",
"class",
"=",
"icon",
... | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/font_awesome.py#L110-L173 |
coumbole/mailscanner | mailscanner/reader.py | ImapReader.open_connection | def open_connection(self, verbose=False):
""" Initializes a new IMAP4_SSL connection to an email server."""
# Connect to server
hostname = self.configs.get('IMAP', 'hostname')
if verbose:
print('Connecting to ' + hostname)
connection = imaplib.IMAP4_SSL(hostname)
... | python | def open_connection(self, verbose=False):
""" Initializes a new IMAP4_SSL connection to an email server."""
# Connect to server
hostname = self.configs.get('IMAP', 'hostname')
if verbose:
print('Connecting to ' + hostname)
connection = imaplib.IMAP4_SSL(hostname)
... | [
"def",
"open_connection",
"(",
"self",
",",
"verbose",
"=",
"False",
")",
":",
"# Connect to server",
"hostname",
"=",
"self",
".",
"configs",
".",
"get",
"(",
"'IMAP'",
",",
"'hostname'",
")",
"if",
"verbose",
":",
"print",
"(",
"'Connecting to '",
"+",
"... | Initializes a new IMAP4_SSL connection to an email server. | [
"Initializes",
"a",
"new",
"IMAP4_SSL",
"connection",
"to",
"an",
"email",
"server",
"."
] | train | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/reader.py#L16-L32 |
coumbole/mailscanner | mailscanner/reader.py | ImapReader.get_body | def get_body(self, msg):
""" Extracts and returns the decoded body from an EmailMessage object"""
body = ""
charset = ""
if msg.is_multipart():
for part in msg.walk():
ctype = part.get_content_type()
cdispo = str(part.get('Content-Disposition... | python | def get_body(self, msg):
""" Extracts and returns the decoded body from an EmailMessage object"""
body = ""
charset = ""
if msg.is_multipart():
for part in msg.walk():
ctype = part.get_content_type()
cdispo = str(part.get('Content-Disposition... | [
"def",
"get_body",
"(",
"self",
",",
"msg",
")",
":",
"body",
"=",
"\"\"",
"charset",
"=",
"\"\"",
"if",
"msg",
".",
"is_multipart",
"(",
")",
":",
"for",
"part",
"in",
"msg",
".",
"walk",
"(",
")",
":",
"ctype",
"=",
"part",
".",
"get_content_type... | Extracts and returns the decoded body from an EmailMessage object | [
"Extracts",
"and",
"returns",
"the",
"decoded",
"body",
"from",
"an",
"EmailMessage",
"object"
] | train | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/reader.py#L35-L57 |
coumbole/mailscanner | mailscanner/reader.py | ImapReader.get_subject | def get_subject(self, msg):
"""Extracts the subject line from an EmailMessage object."""
text, encoding = decode_header(msg['subject'])[-1]
try:
text = text.decode(encoding)
# If it's already decoded, ignore error
except AttributeError:
pass
re... | python | def get_subject(self, msg):
"""Extracts the subject line from an EmailMessage object."""
text, encoding = decode_header(msg['subject'])[-1]
try:
text = text.decode(encoding)
# If it's already decoded, ignore error
except AttributeError:
pass
re... | [
"def",
"get_subject",
"(",
"self",
",",
"msg",
")",
":",
"text",
",",
"encoding",
"=",
"decode_header",
"(",
"msg",
"[",
"'subject'",
"]",
")",
"[",
"-",
"1",
"]",
"try",
":",
"text",
"=",
"text",
".",
"decode",
"(",
"encoding",
")",
"# If it's alrea... | Extracts the subject line from an EmailMessage object. | [
"Extracts",
"the",
"subject",
"line",
"from",
"an",
"EmailMessage",
"object",
"."
] | train | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/reader.py#L60-L72 |
coumbole/mailscanner | mailscanner/reader.py | ImapReader.fetch_all_messages | def fetch_all_messages(self, conn, directory, readonly):
""" Fetches all messages at @conn from @directory.
Params:
conn IMAP4_SSL connection
directory The IMAP directory to look for
readonly readonly mode, true or false
Return... | python | def fetch_all_messages(self, conn, directory, readonly):
""" Fetches all messages at @conn from @directory.
Params:
conn IMAP4_SSL connection
directory The IMAP directory to look for
readonly readonly mode, true or false
Return... | [
"def",
"fetch_all_messages",
"(",
"self",
",",
"conn",
",",
"directory",
",",
"readonly",
")",
":",
"conn",
".",
"select",
"(",
"directory",
",",
"readonly",
")",
"message_data",
"=",
"[",
"]",
"typ",
",",
"data",
"=",
"conn",
".",
"search",
"(",
"None... | Fetches all messages at @conn from @directory.
Params:
conn IMAP4_SSL connection
directory The IMAP directory to look for
readonly readonly mode, true or false
Returns:
List of subject-body tuples | [
"Fetches",
"all",
"messages",
"at",
"@conn",
"from",
"@directory",
"."
] | train | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/reader.py#L75-L111 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/action_plugins/async.py | ActionModule.run | def run(self, conn, tmp, module_name, module_args, inject):
''' transfer the given module name, plus the async module, then run it '''
# shell and command module are the same
if module_name == 'shell':
module_name = 'command'
module_args += " #USE_SHELL"
(module... | python | def run(self, conn, tmp, module_name, module_args, inject):
''' transfer the given module name, plus the async module, then run it '''
# shell and command module are the same
if module_name == 'shell':
module_name = 'command'
module_args += " #USE_SHELL"
(module... | [
"def",
"run",
"(",
"self",
",",
"conn",
",",
"tmp",
",",
"module_name",
",",
"module_args",
",",
"inject",
")",
":",
"# shell and command module are the same",
"if",
"module_name",
"==",
"'shell'",
":",
"module_name",
"=",
"'command'",
"module_args",
"+=",
"\" #... | transfer the given module name, plus the async module, then run it | [
"transfer",
"the",
"given",
"module",
"name",
"plus",
"the",
"async",
"module",
"then",
"run",
"it"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/action_plugins/async.py#L23-L39 |
b3j0f/conf | b3j0f/conf/model/cat.py | Category.getparams | def getparams(self, param):
"""Get parameters which match with input param.
:param Parameter param: parameter to compare with this parameters.
:rtype: list
"""
return list(cparam for cparam in self.values() if cparam == param) | python | def getparams(self, param):
"""Get parameters which match with input param.
:param Parameter param: parameter to compare with this parameters.
:rtype: list
"""
return list(cparam for cparam in self.values() if cparam == param) | [
"def",
"getparams",
"(",
"self",
",",
"param",
")",
":",
"return",
"list",
"(",
"cparam",
"for",
"cparam",
"in",
"self",
".",
"values",
"(",
")",
"if",
"cparam",
"==",
"param",
")"
] | Get parameters which match with input param.
:param Parameter param: parameter to compare with this parameters.
:rtype: list | [
"Get",
"parameters",
"which",
"match",
"with",
"input",
"param",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/model/cat.py#L52-L59 |
mattimck/python-exist | exist/cli.py | main | def main():
""" Parse the arguments and use them to create a ExistCli object """
version = 'Python Exist %s' % __version__
arguments = docopt(__doc__, version=version)
ExistCli(arguments) | python | def main():
""" Parse the arguments and use them to create a ExistCli object """
version = 'Python Exist %s' % __version__
arguments = docopt(__doc__, version=version)
ExistCli(arguments) | [
"def",
"main",
"(",
")",
":",
"version",
"=",
"'Python Exist %s'",
"%",
"__version__",
"arguments",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"version",
")",
"ExistCli",
"(",
"arguments",
")"
] | Parse the arguments and use them to create a ExistCli object | [
"Parse",
"the",
"arguments",
"and",
"use",
"them",
"to",
"create",
"a",
"ExistCli",
"object"
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L210-L214 |
mattimck/python-exist | exist/cli.py | ExistCli.read_config | def read_config(self):
""" Read credentials from the config file """
with open(self.config_file) as cfg:
try:
self.config.read_file(cfg)
except AttributeError:
self.config.readfp(cfg)
self.client_id = self.config.get('exist', 'client_id')
... | python | def read_config(self):
""" Read credentials from the config file """
with open(self.config_file) as cfg:
try:
self.config.read_file(cfg)
except AttributeError:
self.config.readfp(cfg)
self.client_id = self.config.get('exist', 'client_id')
... | [
"def",
"read_config",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"config_file",
")",
"as",
"cfg",
":",
"try",
":",
"self",
".",
"config",
".",
"read_file",
"(",
"cfg",
")",
"except",
"AttributeError",
":",
"self",
".",
"config",
".",
"r... | Read credentials from the config file | [
"Read",
"credentials",
"from",
"the",
"config",
"file"
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L86-L96 |
mattimck/python-exist | exist/cli.py | ExistCli.write_config | def write_config(self, access_token):
""" Write credentials to the config file """
self.config.add_section('exist')
# TODO: config is reading 'None' as string during authorization, so clearing this out
# if no id or secret is set - need to fix this later
if self.client_id:
... | python | def write_config(self, access_token):
""" Write credentials to the config file """
self.config.add_section('exist')
# TODO: config is reading 'None' as string during authorization, so clearing this out
# if no id or secret is set - need to fix this later
if self.client_id:
... | [
"def",
"write_config",
"(",
"self",
",",
"access_token",
")",
":",
"self",
".",
"config",
".",
"add_section",
"(",
"'exist'",
")",
"# TODO: config is reading 'None' as string during authorization, so clearing this out",
"# if no id or secret is set - need to fix this later",
"if"... | Write credentials to the config file | [
"Write",
"credentials",
"to",
"the",
"config",
"file"
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L98-L118 |
mattimck/python-exist | exist/cli.py | ExistCli.get_resource | def get_resource(self, arguments):
""" Gets the resource requested in the arguments """
attribute_name = arguments['<attribute_name>']
limit = arguments['--limit']
page = arguments['--page']
date_min = arguments['--date_min']
date_max = arguments['--date_max']
# ... | python | def get_resource(self, arguments):
""" Gets the resource requested in the arguments """
attribute_name = arguments['<attribute_name>']
limit = arguments['--limit']
page = arguments['--page']
date_min = arguments['--date_min']
date_max = arguments['--date_max']
# ... | [
"def",
"get_resource",
"(",
"self",
",",
"arguments",
")",
":",
"attribute_name",
"=",
"arguments",
"[",
"'<attribute_name>'",
"]",
"limit",
"=",
"arguments",
"[",
"'--limit'",
"]",
"page",
"=",
"arguments",
"[",
"'--page'",
"]",
"date_min",
"=",
"arguments",
... | Gets the resource requested in the arguments | [
"Gets",
"the",
"resource",
"requested",
"in",
"the",
"arguments"
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L120-L159 |
mattimck/python-exist | exist/cli.py | ExistCli.authorize | def authorize(self, api_token=None, username=None, password=None):
"""
Authorize a user using the browser and a CherryPy server, and write
the resulting credentials to a config file.
"""
access_token = None
if username and password:
# if we have a username a... | python | def authorize(self, api_token=None, username=None, password=None):
"""
Authorize a user using the browser and a CherryPy server, and write
the resulting credentials to a config file.
"""
access_token = None
if username and password:
# if we have a username a... | [
"def",
"authorize",
"(",
"self",
",",
"api_token",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"access_token",
"=",
"None",
"if",
"username",
"and",
"password",
":",
"# if we have a username and password, go and collect a tok... | Authorize a user using the browser and a CherryPy server, and write
the resulting credentials to a config file. | [
"Authorize",
"a",
"user",
"using",
"the",
"browser",
"and",
"a",
"CherryPy",
"server",
"and",
"write",
"the",
"resulting",
"credentials",
"to",
"a",
"config",
"file",
"."
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L161-L190 |
mattimck/python-exist | exist/cli.py | ExistCli.refresh_token | def refresh_token(self, arguments):
"""
Refresh a user's access token, using existing the refresh token previously
received in the auth flow.
"""
new_access_token = None
auth = ExistAuth(self.client_id, self.client_secret)
resp = auth.refresh_token(self.access_t... | python | def refresh_token(self, arguments):
"""
Refresh a user's access token, using existing the refresh token previously
received in the auth flow.
"""
new_access_token = None
auth = ExistAuth(self.client_id, self.client_secret)
resp = auth.refresh_token(self.access_t... | [
"def",
"refresh_token",
"(",
"self",
",",
"arguments",
")",
":",
"new_access_token",
"=",
"None",
"auth",
"=",
"ExistAuth",
"(",
"self",
".",
"client_id",
",",
"self",
".",
"client_secret",
")",
"resp",
"=",
"auth",
".",
"refresh_token",
"(",
"self",
".",
... | Refresh a user's access token, using existing the refresh token previously
received in the auth flow. | [
"Refresh",
"a",
"user",
"s",
"access",
"token",
"using",
"existing",
"the",
"refresh",
"token",
"previously",
"received",
"in",
"the",
"auth",
"flow",
"."
] | train | https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/cli.py#L192-L207 |
jthacker/terseparse | terseparse/utils.py | rep | def rep(obj, *attrs, **kwargs):
"""Create a repr of a property based class quickly
Args:
obj -- instance of class
*attrs -- list of attrs to add to the representation
**kwargs -- Extra arguments to add that are not captured as attributes
Returns: A string representing the cla... | python | def rep(obj, *attrs, **kwargs):
"""Create a repr of a property based class quickly
Args:
obj -- instance of class
*attrs -- list of attrs to add to the representation
**kwargs -- Extra arguments to add that are not captured as attributes
Returns: A string representing the cla... | [
"def",
"rep",
"(",
"obj",
",",
"*",
"attrs",
",",
"*",
"*",
"kwargs",
")",
":",
"s",
"=",
"obj",
".",
"__class__",
".",
"__name__",
"args",
"=",
"chain",
"(",
"(",
"(",
"attr",
",",
"getattr",
"(",
"obj",
",",
"attr",
")",
")",
"for",
"attr",
... | Create a repr of a property based class quickly
Args:
obj -- instance of class
*attrs -- list of attrs to add to the representation
**kwargs -- Extra arguments to add that are not captured as attributes
Returns: A string representing the class | [
"Create",
"a",
"repr",
"of",
"a",
"property",
"based",
"class",
"quickly",
"Args",
":",
"obj",
"--",
"instance",
"of",
"class",
"*",
"attrs",
"--",
"list",
"of",
"attrs",
"to",
"add",
"to",
"the",
"representation",
"**",
"kwargs",
"--",
"Extra",
"argumen... | train | https://github.com/jthacker/terseparse/blob/236a31faf819f3ae9019a545613b8e7a6808f7b2/terseparse/utils.py#L20-L32 |
eisensheng/kaviar | tasks.py | _version_find_existing | def _version_find_existing():
"""Returns set of existing versions in this repository. This
information is backed by previously used version tags in git.
Available tags are pulled from origin repository before.
:return:
available versions
:rtype:
set
"""
_tool_run('git fetch... | python | def _version_find_existing():
"""Returns set of existing versions in this repository. This
information is backed by previously used version tags in git.
Available tags are pulled from origin repository before.
:return:
available versions
:rtype:
set
"""
_tool_run('git fetch... | [
"def",
"_version_find_existing",
"(",
")",
":",
"_tool_run",
"(",
"'git fetch origin -t'",
")",
"git_tags",
"=",
"[",
"x",
"for",
"x",
"in",
"(",
"y",
".",
"strip",
"(",
")",
"for",
"y",
"in",
"(",
"_tool_run",
"(",
"'git tag -l'",
")",
".",
"stdout",
... | Returns set of existing versions in this repository. This
information is backed by previously used version tags in git.
Available tags are pulled from origin repository before.
:return:
available versions
:rtype:
set | [
"Returns",
"set",
"of",
"existing",
"versions",
"in",
"this",
"repository",
".",
"This",
"information",
"is",
"backed",
"by",
"previously",
"used",
"version",
"tags",
"in",
"git",
".",
"Available",
"tags",
"are",
"pulled",
"from",
"origin",
"repository",
"befo... | train | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/tasks.py#L34-L48 |
eisensheng/kaviar | tasks.py | _git_enable_branch | def _git_enable_branch(desired_branch):
"""Enable desired branch name."""
preserved_branch = _git_get_current_branch()
try:
if preserved_branch != desired_branch:
_tool_run('git checkout ' + desired_branch)
yield
finally:
if preserved_branch and preserved_branch != de... | python | def _git_enable_branch(desired_branch):
"""Enable desired branch name."""
preserved_branch = _git_get_current_branch()
try:
if preserved_branch != desired_branch:
_tool_run('git checkout ' + desired_branch)
yield
finally:
if preserved_branch and preserved_branch != de... | [
"def",
"_git_enable_branch",
"(",
"desired_branch",
")",
":",
"preserved_branch",
"=",
"_git_get_current_branch",
"(",
")",
"try",
":",
"if",
"preserved_branch",
"!=",
"desired_branch",
":",
"_tool_run",
"(",
"'git checkout '",
"+",
"desired_branch",
")",
"yield",
"... | Enable desired branch name. | [
"Enable",
"desired",
"branch",
"name",
"."
] | train | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/tasks.py#L98-L107 |
eisensheng/kaviar | tasks.py | mk_travis_config | def mk_travis_config():
"""Generate configuration for travis."""
t = dedent("""\
language: python
python: 3.4
env:
{jobs}
install:
- pip install -r requirements/ci.txt
script:
- invoke ci_run_job $TOX_JOB
after_success:
... | python | def mk_travis_config():
"""Generate configuration for travis."""
t = dedent("""\
language: python
python: 3.4
env:
{jobs}
install:
- pip install -r requirements/ci.txt
script:
- invoke ci_run_job $TOX_JOB
after_success:
... | [
"def",
"mk_travis_config",
"(",
")",
":",
"t",
"=",
"dedent",
"(",
"\"\"\"\\\n language: python\n python: 3.4\n env:\n {jobs}\n install:\n - pip install -r requirements/ci.txt\n script:\n - invoke ci_run_job $TOX_JOB\n after_su... | Generate configuration for travis. | [
"Generate",
"configuration",
"for",
"travis",
"."
] | train | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/tasks.py#L160-L178 |
eisensheng/kaviar | tasks.py | mkrelease | def mkrelease(finish='yes', version=''):
"""Allocates the next version number and marks current develop branch
state as a new release with the allocated version number.
Syncs new state with origin repository.
"""
if not version:
version = _version_format(_version_guess_next())
if _git_g... | python | def mkrelease(finish='yes', version=''):
"""Allocates the next version number and marks current develop branch
state as a new release with the allocated version number.
Syncs new state with origin repository.
"""
if not version:
version = _version_format(_version_guess_next())
if _git_g... | [
"def",
"mkrelease",
"(",
"finish",
"=",
"'yes'",
",",
"version",
"=",
"''",
")",
":",
"if",
"not",
"version",
":",
"version",
"=",
"_version_format",
"(",
"_version_guess_next",
"(",
")",
")",
"if",
"_git_get_current_branch",
"(",
")",
"!=",
"'release/'",
... | Allocates the next version number and marks current develop branch
state as a new release with the allocated version number.
Syncs new state with origin repository. | [
"Allocates",
"the",
"next",
"version",
"number",
"and",
"marks",
"current",
"develop",
"branch",
"state",
"as",
"a",
"new",
"release",
"with",
"the",
"allocated",
"version",
"number",
".",
"Syncs",
"new",
"state",
"with",
"origin",
"repository",
"."
] | train | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/tasks.py#L193-L216 |
sternoru/goscalecms | goscale/decorators.py | cache_func | def cache_func(func, duration=conf.GOSCALE_CACHE_DURATION, cache_key=None):
"""Django cache decorator for functions
Basic ideas got from:
- http://djangosnippets.org/snippets/492/
- http://djangosnippets.org/snippets/564/
Example usage:
Example 1:
- providing a cache key and a duratio... | python | def cache_func(func, duration=conf.GOSCALE_CACHE_DURATION, cache_key=None):
"""Django cache decorator for functions
Basic ideas got from:
- http://djangosnippets.org/snippets/492/
- http://djangosnippets.org/snippets/564/
Example usage:
Example 1:
- providing a cache key and a duratio... | [
"def",
"cache_func",
"(",
"func",
",",
"duration",
"=",
"conf",
".",
"GOSCALE_CACHE_DURATION",
",",
"cache_key",
"=",
"None",
")",
":",
"def",
"do_cache",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"alternative_cache_key",
"=",
"'%s.%s'",
"%",
... | Django cache decorator for functions
Basic ideas got from:
- http://djangosnippets.org/snippets/492/
- http://djangosnippets.org/snippets/564/
Example usage:
Example 1:
- providing a cache key and a duration
class MenuItem(models.Model):
@classmethod
@cache_func(, 3600... | [
"Django",
"cache",
"decorator",
"for",
"functions",
"Basic",
"ideas",
"got",
"from",
":",
"-",
"http",
":",
"//",
"djangosnippets",
".",
"org",
"/",
"snippets",
"/",
"492",
"/",
"-",
"http",
":",
"//",
"djangosnippets",
".",
"org",
"/",
"snippets",
"/",
... | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/decorators.py#L22-L65 |
sternoru/goscalecms | goscale/decorators.py | get_cache_key | def get_cache_key(cache_key, alternative_cache_key, *func_args, **func_kwargs):
"""Not a decorator, but a helper function to retrieve the cache
key for a cached function with its arguments or keyword arguments.
Also used to create the cache key in the first place (cache_func decorator).
Args:
- ... | python | def get_cache_key(cache_key, alternative_cache_key, *func_args, **func_kwargs):
"""Not a decorator, but a helper function to retrieve the cache
key for a cached function with its arguments or keyword arguments.
Also used to create the cache key in the first place (cache_func decorator).
Args:
- ... | [
"def",
"get_cache_key",
"(",
"cache_key",
",",
"alternative_cache_key",
",",
"*",
"func_args",
",",
"*",
"*",
"func_kwargs",
")",
":",
"if",
"not",
"cache_key",
":",
"key",
"=",
"hashlib",
".",
"sha1",
"(",
"'%s.%s.%s'",
"%",
"(",
"alternative_cache_key",
",... | Not a decorator, but a helper function to retrieve the cache
key for a cached function with its arguments or keyword arguments.
Also used to create the cache key in the first place (cache_func decorator).
Args:
- cache_key: if there was a specific cache key used to cache the
function, it sho... | [
"Not",
"a",
"decorator",
"but",
"a",
"helper",
"function",
"to",
"retrieve",
"the",
"cache",
"key",
"for",
"a",
"cached",
"function",
"with",
"its",
"arguments",
"or",
"keyword",
"arguments",
".",
"Also",
"used",
"to",
"create",
"the",
"cache",
"key",
"in"... | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/decorators.py#L67-L89 |
sternoru/goscalecms | goscale/decorators.py | get_cached_item | def get_cached_item(cache_key, alternative_cache_key, *func_args, **func_kwargs):
"""Not a decorator, but a helper function to retrieve the cached
item for a key created via get_cache_key.
Args:
- cache_key: if there was a specific cache key used to cache the
function, it should be provided ... | python | def get_cached_item(cache_key, alternative_cache_key, *func_args, **func_kwargs):
"""Not a decorator, but a helper function to retrieve the cached
item for a key created via get_cache_key.
Args:
- cache_key: if there was a specific cache key used to cache the
function, it should be provided ... | [
"def",
"get_cached_item",
"(",
"cache_key",
",",
"alternative_cache_key",
",",
"*",
"func_args",
",",
"*",
"*",
"func_kwargs",
")",
":",
"key",
"=",
"get_cache_key",
"(",
"cache_key",
",",
"func",
",",
"*",
"func_args",
",",
"*",
"*",
"func_kwargs",
")",
"... | Not a decorator, but a helper function to retrieve the cached
item for a key created via get_cache_key.
Args:
- cache_key: if there was a specific cache key used to cache the
function, it should be provided here. If not this should be None
- func: the function which was cache
- *... | [
"Not",
"a",
"decorator",
"but",
"a",
"helper",
"function",
"to",
"retrieve",
"the",
"cached",
"item",
"for",
"a",
"key",
"created",
"via",
"get_cache_key",
".",
"Args",
":",
"-",
"cache_key",
":",
"if",
"there",
"was",
"a",
"specific",
"cache",
"key",
"u... | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/decorators.py#L91-L102 |
developersociety/django-glitter-news | glitter_news/views.py | PostDetailView.get_allow_future | def get_allow_future(self):
"""
Only superusers and users with the permission can edit the post.
"""
qs = self.get_queryset()
post_edit_permission = '{}.edit_{}'.format(
qs.model._meta.app_label, qs.model._meta.model_name
)
if self.request.user.has_per... | python | def get_allow_future(self):
"""
Only superusers and users with the permission can edit the post.
"""
qs = self.get_queryset()
post_edit_permission = '{}.edit_{}'.format(
qs.model._meta.app_label, qs.model._meta.model_name
)
if self.request.user.has_per... | [
"def",
"get_allow_future",
"(",
"self",
")",
":",
"qs",
"=",
"self",
".",
"get_queryset",
"(",
")",
"post_edit_permission",
"=",
"'{}.edit_{}'",
".",
"format",
"(",
"qs",
".",
"model",
".",
"_meta",
".",
"app_label",
",",
"qs",
".",
"model",
".",
"_meta"... | Only superusers and users with the permission can edit the post. | [
"Only",
"superusers",
"and",
"users",
"with",
"the",
"permission",
"can",
"edit",
"the",
"post",
"."
] | train | https://github.com/developersociety/django-glitter-news/blob/e3c7f9932b3225549c444048b4866263357de58e/glitter_news/views.py#L67-L77 |
minhhoit/yacms | yacms/project_template/fabfile.py | update_changed_requirements | def update_changed_requirements():
"""
Checks for changes in the requirements file across an update,
and gets new requirements if changes have occurred.
"""
reqs_path = join(env.proj_path, env.reqs_path)
get_reqs = lambda: run("cat %s" % reqs_path, show=False)
old_reqs = get_reqs() if env.re... | python | def update_changed_requirements():
"""
Checks for changes in the requirements file across an update,
and gets new requirements if changes have occurred.
"""
reqs_path = join(env.proj_path, env.reqs_path)
get_reqs = lambda: run("cat %s" % reqs_path, show=False)
old_reqs = get_reqs() if env.re... | [
"def",
"update_changed_requirements",
"(",
")",
":",
"reqs_path",
"=",
"join",
"(",
"env",
".",
"proj_path",
",",
"env",
".",
"reqs_path",
")",
"get_reqs",
"=",
"lambda",
":",
"run",
"(",
"\"cat %s\"",
"%",
"reqs_path",
",",
"show",
"=",
"False",
")",
"o... | Checks for changes in the requirements file across an update,
and gets new requirements if changes have occurred. | [
"Checks",
"for",
"changes",
"in",
"the",
"requirements",
"file",
"across",
"an",
"update",
"and",
"gets",
"new",
"requirements",
"if",
"changes",
"have",
"occurred",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L140-L165 |
minhhoit/yacms | yacms/project_template/fabfile.py | run | def run(command, show=True, *args, **kwargs):
"""
Runs a shell comand on the remote server.
"""
if show:
print_command(command)
with hide("running"):
return _run(command, *args, **kwargs) | python | def run(command, show=True, *args, **kwargs):
"""
Runs a shell comand on the remote server.
"""
if show:
print_command(command)
with hide("running"):
return _run(command, *args, **kwargs) | [
"def",
"run",
"(",
"command",
",",
"show",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"show",
":",
"print_command",
"(",
"command",
")",
"with",
"hide",
"(",
"\"running\"",
")",
":",
"return",
"_run",
"(",
"command",
",... | Runs a shell comand on the remote server. | [
"Runs",
"a",
"shell",
"comand",
"on",
"the",
"remote",
"server",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L185-L192 |
minhhoit/yacms | yacms/project_template/fabfile.py | sudo | def sudo(command, show=True, *args, **kwargs):
"""
Runs a command as sudo on the remote server.
"""
if show:
print_command(command)
with hide("running"):
return _sudo(command, *args, **kwargs) | python | def sudo(command, show=True, *args, **kwargs):
"""
Runs a command as sudo on the remote server.
"""
if show:
print_command(command)
with hide("running"):
return _sudo(command, *args, **kwargs) | [
"def",
"sudo",
"(",
"command",
",",
"show",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"show",
":",
"print_command",
"(",
"command",
")",
"with",
"hide",
"(",
"\"running\"",
")",
":",
"return",
"_sudo",
"(",
"command",
... | Runs a command as sudo on the remote server. | [
"Runs",
"a",
"command",
"as",
"sudo",
"on",
"the",
"remote",
"server",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L196-L203 |
minhhoit/yacms | yacms/project_template/fabfile.py | get_templates | def get_templates():
"""
Returns each of the templates with env vars injected.
"""
injected = {}
for name, data in templates.items():
injected[name] = dict([(k, v % env) for k, v in data.items()])
return injected | python | def get_templates():
"""
Returns each of the templates with env vars injected.
"""
injected = {}
for name, data in templates.items():
injected[name] = dict([(k, v % env) for k, v in data.items()])
return injected | [
"def",
"get_templates",
"(",
")",
":",
"injected",
"=",
"{",
"}",
"for",
"name",
",",
"data",
"in",
"templates",
".",
"items",
"(",
")",
":",
"injected",
"[",
"name",
"]",
"=",
"dict",
"(",
"[",
"(",
"k",
",",
"v",
"%",
"env",
")",
"for",
"k",
... | Returns each of the templates with env vars injected. | [
"Returns",
"each",
"of",
"the",
"templates",
"with",
"env",
"vars",
"injected",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L215-L222 |
minhhoit/yacms | yacms/project_template/fabfile.py | upload_template_and_reload | def upload_template_and_reload(name):
"""
Uploads a template only if it has changed, and if so, reload the
related service.
"""
template = get_templates()[name]
local_path = template["local_path"]
if not os.path.exists(local_path):
project_root = os.path.dirname(os.path.abspath(__fil... | python | def upload_template_and_reload(name):
"""
Uploads a template only if it has changed, and if so, reload the
related service.
"""
template = get_templates()[name]
local_path = template["local_path"]
if not os.path.exists(local_path):
project_root = os.path.dirname(os.path.abspath(__fil... | [
"def",
"upload_template_and_reload",
"(",
"name",
")",
":",
"template",
"=",
"get_templates",
"(",
")",
"[",
"name",
"]",
"local_path",
"=",
"template",
"[",
"\"local_path\"",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"local_path",
")",
":",... | Uploads a template only if it has changed, and if so, reload the
related service. | [
"Uploads",
"a",
"template",
"only",
"if",
"it",
"has",
"changed",
"and",
"if",
"so",
"reload",
"the",
"related",
"service",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L225-L259 |
minhhoit/yacms | yacms/project_template/fabfile.py | rsync_upload | def rsync_upload():
"""
Uploads the project with rsync excluding some files and folders.
"""
excludes = ["*.pyc", "*.pyo", "*.db", ".DS_Store", ".coverage",
"local_settings.py", "/static", "/.git", "/.hg"]
local_dir = os.getcwd() + os.sep
return rsync_project(remote_dir=env.proj_... | python | def rsync_upload():
"""
Uploads the project with rsync excluding some files and folders.
"""
excludes = ["*.pyc", "*.pyo", "*.db", ".DS_Store", ".coverage",
"local_settings.py", "/static", "/.git", "/.hg"]
local_dir = os.getcwd() + os.sep
return rsync_project(remote_dir=env.proj_... | [
"def",
"rsync_upload",
"(",
")",
":",
"excludes",
"=",
"[",
"\"*.pyc\"",
",",
"\"*.pyo\"",
",",
"\"*.db\"",
",",
"\".DS_Store\"",
",",
"\".coverage\"",
",",
"\"local_settings.py\"",
",",
"\"/static\"",
",",
"\"/.git\"",
",",
"\"/.hg\"",
"]",
"local_dir",
"=",
... | Uploads the project with rsync excluding some files and folders. | [
"Uploads",
"the",
"project",
"with",
"rsync",
"excluding",
"some",
"files",
"and",
"folders",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L262-L270 |
minhhoit/yacms | yacms/project_template/fabfile.py | vcs_upload | def vcs_upload():
"""
Uploads the project with the selected VCS tool.
"""
if env.deploy_tool == "git":
remote_path = "ssh://%s@%s%s" % (env.user, env.host_string,
env.repo_path)
if not exists(env.repo_path):
run("mkdir -p %s" % env.rep... | python | def vcs_upload():
"""
Uploads the project with the selected VCS tool.
"""
if env.deploy_tool == "git":
remote_path = "ssh://%s@%s%s" % (env.user, env.host_string,
env.repo_path)
if not exists(env.repo_path):
run("mkdir -p %s" % env.rep... | [
"def",
"vcs_upload",
"(",
")",
":",
"if",
"env",
".",
"deploy_tool",
"==",
"\"git\"",
":",
"remote_path",
"=",
"\"ssh://%s@%s%s\"",
"%",
"(",
"env",
".",
"user",
",",
"env",
".",
"host_string",
",",
"env",
".",
"repo_path",
")",
"if",
"not",
"exists",
... | Uploads the project with the selected VCS tool. | [
"Uploads",
"the",
"project",
"with",
"the",
"selected",
"VCS",
"tool",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L273-L299 |
minhhoit/yacms | yacms/project_template/fabfile.py | postgres | def postgres(command):
"""
Runs the given command as the postgres user.
"""
show = not command.startswith("psql")
return sudo(command, show=show, user="postgres") | python | def postgres(command):
"""
Runs the given command as the postgres user.
"""
show = not command.startswith("psql")
return sudo(command, show=show, user="postgres") | [
"def",
"postgres",
"(",
"command",
")",
":",
"show",
"=",
"not",
"command",
".",
"startswith",
"(",
"\"psql\"",
")",
"return",
"sudo",
"(",
"command",
",",
"show",
"=",
"show",
",",
"user",
"=",
"\"postgres\"",
")"
] | Runs the given command as the postgres user. | [
"Runs",
"the",
"given",
"command",
"as",
"the",
"postgres",
"user",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L328-L333 |
minhhoit/yacms | yacms/project_template/fabfile.py | psql | def psql(sql, show=True):
"""
Runs SQL against the project's database.
"""
out = postgres('psql -c "%s"' % sql)
if show:
print_command(sql)
return out | python | def psql(sql, show=True):
"""
Runs SQL against the project's database.
"""
out = postgres('psql -c "%s"' % sql)
if show:
print_command(sql)
return out | [
"def",
"psql",
"(",
"sql",
",",
"show",
"=",
"True",
")",
":",
"out",
"=",
"postgres",
"(",
"'psql -c \"%s\"'",
"%",
"sql",
")",
"if",
"show",
":",
"print_command",
"(",
"sql",
")",
"return",
"out"
] | Runs SQL against the project's database. | [
"Runs",
"SQL",
"against",
"the",
"project",
"s",
"database",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L337-L344 |
minhhoit/yacms | yacms/project_template/fabfile.py | backup | def backup(filename):
"""
Backs up the project database.
"""
tmp_file = "/tmp/%s" % filename
# We dump to /tmp because user "postgres" can't write to other user folders
# We cd to / because user "postgres" might not have read permissions
# elsewhere.
with cd("/"):
postgres("pg_du... | python | def backup(filename):
"""
Backs up the project database.
"""
tmp_file = "/tmp/%s" % filename
# We dump to /tmp because user "postgres" can't write to other user folders
# We cd to / because user "postgres" might not have read permissions
# elsewhere.
with cd("/"):
postgres("pg_du... | [
"def",
"backup",
"(",
"filename",
")",
":",
"tmp_file",
"=",
"\"/tmp/%s\"",
"%",
"filename",
"# We dump to /tmp because user \"postgres\" can't write to other user folders",
"# We cd to / because user \"postgres\" might not have read permissions",
"# elsewhere.",
"with",
"cd",
"(",
... | Backs up the project database. | [
"Backs",
"up",
"the",
"project",
"database",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L348-L359 |
minhhoit/yacms | yacms/project_template/fabfile.py | python | def python(code, show=True):
"""
Runs Python code in the project's virtual environment, with Django loaded.
"""
setup = "import os;" \
"os.environ[\'DJANGO_SETTINGS_MODULE\']=\'%s.settings\';" \
"import django;" \
"django.setup();" % env.proj_app
full_code = 'pyth... | python | def python(code, show=True):
"""
Runs Python code in the project's virtual environment, with Django loaded.
"""
setup = "import os;" \
"os.environ[\'DJANGO_SETTINGS_MODULE\']=\'%s.settings\';" \
"import django;" \
"django.setup();" % env.proj_app
full_code = 'pyth... | [
"def",
"python",
"(",
"code",
",",
"show",
"=",
"True",
")",
":",
"setup",
"=",
"\"import os;\"",
"\"os.environ[\\'DJANGO_SETTINGS_MODULE\\']=\\'%s.settings\\';\"",
"\"import django;\"",
"\"django.setup();\"",
"%",
"env",
".",
"proj_app",
"full_code",
"=",
"'python -c \"%... | Runs Python code in the project's virtual environment, with Django loaded. | [
"Runs",
"Python",
"code",
"in",
"the",
"project",
"s",
"virtual",
"environment",
"with",
"Django",
"loaded",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L371-L384 |
minhhoit/yacms | yacms/project_template/fabfile.py | secure | def secure(new_user=env.user):
"""
Minimal security steps for brand new servers.
Installs system updates, creates new user (with sudo privileges) for future
usage, and disables root login via SSH.
"""
run("apt-get update -q")
run("apt-get upgrade -y -q")
run("adduser --gecos '' %s" % new... | python | def secure(new_user=env.user):
"""
Minimal security steps for brand new servers.
Installs system updates, creates new user (with sudo privileges) for future
usage, and disables root login via SSH.
"""
run("apt-get update -q")
run("apt-get upgrade -y -q")
run("adduser --gecos '' %s" % new... | [
"def",
"secure",
"(",
"new_user",
"=",
"env",
".",
"user",
")",
":",
"run",
"(",
"\"apt-get update -q\"",
")",
"run",
"(",
"\"apt-get upgrade -y -q\"",
")",
"run",
"(",
"\"adduser --gecos '' %s\"",
"%",
"new_user",
")",
"run",
"(",
"\"usermod -G sudo %s\"",
"%",... | Minimal security steps for brand new servers.
Installs system updates, creates new user (with sudo privileges) for future
usage, and disables root login via SSH. | [
"Minimal",
"security",
"steps",
"for",
"brand",
"new",
"servers",
".",
"Installs",
"system",
"updates",
"creates",
"new",
"user",
"(",
"with",
"sudo",
"privileges",
")",
"for",
"future",
"usage",
"and",
"disables",
"root",
"login",
"via",
"SSH",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L410-L423 |
minhhoit/yacms | yacms/project_template/fabfile.py | install | def install():
"""
Installs the base system and Python requirements for the entire server.
"""
# Install system requirements
sudo("apt-get update -y -q")
apt("nginx libjpeg-dev python-dev python-setuptools git-core "
"postgresql libpq-dev memcached supervisor python-pip")
run("mkdir ... | python | def install():
"""
Installs the base system and Python requirements for the entire server.
"""
# Install system requirements
sudo("apt-get update -y -q")
apt("nginx libjpeg-dev python-dev python-setuptools git-core "
"postgresql libpq-dev memcached supervisor python-pip")
run("mkdir ... | [
"def",
"install",
"(",
")",
":",
"# Install system requirements",
"sudo",
"(",
"\"apt-get update -y -q\"",
")",
"apt",
"(",
"\"nginx libjpeg-dev python-dev python-setuptools git-core \"",
"\"postgresql libpq-dev memcached supervisor python-pip\"",
")",
"run",
"(",
"\"mkdir -p /home... | Installs the base system and Python requirements for the entire server. | [
"Installs",
"the",
"base",
"system",
"and",
"Python",
"requirements",
"for",
"the",
"entire",
"server",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L432-L452 |
minhhoit/yacms | yacms/project_template/fabfile.py | create | def create():
"""
Creates the environment needed to host the project.
The environment consists of: system locales, virtualenv, database, project
files, SSL certificate, and project-specific Python requirements.
"""
# Generate project locale
locale = env.locale.replace("UTF-8", "utf8")
wi... | python | def create():
"""
Creates the environment needed to host the project.
The environment consists of: system locales, virtualenv, database, project
files, SSL certificate, and project-specific Python requirements.
"""
# Generate project locale
locale = env.locale.replace("UTF-8", "utf8")
wi... | [
"def",
"create",
"(",
")",
":",
"# Generate project locale",
"locale",
"=",
"env",
".",
"locale",
".",
"replace",
"(",
"\"UTF-8\"",
",",
"\"utf8\"",
")",
"with",
"hide",
"(",
"\"stdout\"",
")",
":",
"if",
"locale",
"not",
"in",
"run",
"(",
"\"locale -a\"",... | Creates the environment needed to host the project.
The environment consists of: system locales, virtualenv, database, project
files, SSL certificate, and project-specific Python requirements. | [
"Creates",
"the",
"environment",
"needed",
"to",
"host",
"the",
"project",
".",
"The",
"environment",
"consists",
"of",
":",
"system",
"locales",
"virtualenv",
"database",
"project",
"files",
"SSL",
"certificate",
"and",
"project",
"-",
"specific",
"Python",
"re... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L457-L551 |
minhhoit/yacms | yacms/project_template/fabfile.py | remove | def remove():
"""
Blow away the current project.
"""
if exists(env.venv_path):
run("rm -rf %s" % env.venv_path)
if exists(env.proj_path):
run("rm -rf %s" % env.proj_path)
for template in get_templates().values():
remote_path = template["remote_path"]
if exists(rem... | python | def remove():
"""
Blow away the current project.
"""
if exists(env.venv_path):
run("rm -rf %s" % env.venv_path)
if exists(env.proj_path):
run("rm -rf %s" % env.proj_path)
for template in get_templates().values():
remote_path = template["remote_path"]
if exists(rem... | [
"def",
"remove",
"(",
")",
":",
"if",
"exists",
"(",
"env",
".",
"venv_path",
")",
":",
"run",
"(",
"\"rm -rf %s\"",
"%",
"env",
".",
"venv_path",
")",
"if",
"exists",
"(",
"env",
".",
"proj_path",
")",
":",
"run",
"(",
"\"rm -rf %s\"",
"%",
"env",
... | Blow away the current project. | [
"Blow",
"away",
"the",
"current",
"project",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L556-L572 |
minhhoit/yacms | yacms/project_template/fabfile.py | deploy | def deploy():
"""
Deploy latest version of the project.
Backup current version of the project, push latest version of the project
via version control or rsync, install new requirements, sync and migrate
the database, collect any new static assets, and restart gunicorn's worker
processes for the ... | python | def deploy():
"""
Deploy latest version of the project.
Backup current version of the project, push latest version of the project
via version control or rsync, install new requirements, sync and migrate
the database, collect any new static assets, and restart gunicorn's worker
processes for the ... | [
"def",
"deploy",
"(",
")",
":",
"if",
"not",
"exists",
"(",
"env",
".",
"proj_path",
")",
":",
"if",
"confirm",
"(",
"\"Project does not exist in host server: %s\"",
"\"\\nWould you like to create it?\"",
"%",
"env",
".",
"proj_name",
")",
":",
"create",
"(",
")... | Deploy latest version of the project.
Backup current version of the project, push latest version of the project
via version control or rsync, install new requirements, sync and migrate
the database, collect any new static assets, and restart gunicorn's worker
processes for the project. | [
"Deploy",
"latest",
"version",
"of",
"the",
"project",
".",
"Backup",
"current",
"version",
"of",
"the",
"project",
"push",
"latest",
"version",
"of",
"the",
"project",
"via",
"version",
"control",
"or",
"rsync",
"install",
"new",
"requirements",
"sync",
"and"... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L595-L642 |
minhhoit/yacms | yacms/project_template/fabfile.py | rollback | def rollback():
"""
Reverts project state to the last deploy.
When a deploy is performed, the current state of the project is
backed up. This includes the project files, the database, and all static
files. Calling rollback will revert all of these to their state prior to
the last deploy.
"""... | python | def rollback():
"""
Reverts project state to the last deploy.
When a deploy is performed, the current state of the project is
backed up. This includes the project files, the database, and all static
files. Calling rollback will revert all of these to their state prior to
the last deploy.
"""... | [
"def",
"rollback",
"(",
")",
":",
"with",
"update_changed_requirements",
"(",
")",
":",
"if",
"env",
".",
"deploy_tool",
"in",
"env",
".",
"vcs_tools",
":",
"with",
"cd",
"(",
"env",
".",
"repo_path",
")",
":",
"if",
"env",
".",
"deploy_tool",
"==",
"\... | Reverts project state to the last deploy.
When a deploy is performed, the current state of the project is
backed up. This includes the project files, the database, and all static
files. Calling rollback will revert all of these to their state prior to
the last deploy. | [
"Reverts",
"project",
"state",
"to",
"the",
"last",
"deploy",
".",
"When",
"a",
"deploy",
"is",
"performed",
"the",
"current",
"state",
"of",
"the",
"project",
"is",
"backed",
"up",
".",
"This",
"includes",
"the",
"project",
"files",
"the",
"database",
"an... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/project_template/fabfile.py#L647-L672 |
FlaskGuys/Flask-Imagine-AzureAdapter | flask_imagine_azure_adapter/__init__.py | FlaskImagineAzureAdapter.get_item | def get_item(self, path):
"""
Get resource item
:param path: string
:return: Image
"""
try:
f = tempfile.NamedTemporaryFile()
self.blob_service.get_blob_to_path(self.container_name, path, f.name)
f.seek(0)
image = Image.open... | python | def get_item(self, path):
"""
Get resource item
:param path: string
:return: Image
"""
try:
f = tempfile.NamedTemporaryFile()
self.blob_service.get_blob_to_path(self.container_name, path, f.name)
f.seek(0)
image = Image.open... | [
"def",
"get_item",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"f",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"self",
".",
"blob_service",
".",
"get_blob_to_path",
"(",
"self",
".",
"container_name",
",",
"path",
",",
"f",
".",
"name",
... | Get resource item
:param path: string
:return: Image | [
"Get",
"resource",
"item",
":",
"param",
"path",
":",
"string",
":",
"return",
":",
"Image"
] | train | https://github.com/FlaskGuys/Flask-Imagine-AzureAdapter/blob/1ca83fb040602ba1be983a7d1cfd052323a86f1a/flask_imagine_azure_adapter/__init__.py#L34-L49 |
FlaskGuys/Flask-Imagine-AzureAdapter | flask_imagine_azure_adapter/__init__.py | FlaskImagineAzureAdapter.create_cached_item | def create_cached_item(self, path, content):
"""
Create cached resource item
:param path: str
:param content: PIL.Image
:return: str
"""
if isinstance(content, Image.Image):
f = tempfile.NamedTemporaryFile()
content.save(f.name, format=cont... | python | def create_cached_item(self, path, content):
"""
Create cached resource item
:param path: str
:param content: PIL.Image
:return: str
"""
if isinstance(content, Image.Image):
f = tempfile.NamedTemporaryFile()
content.save(f.name, format=cont... | [
"def",
"create_cached_item",
"(",
"self",
",",
"path",
",",
"content",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"Image",
".",
"Image",
")",
":",
"f",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"content",
".",
"save",
"(",
"f",
".",... | Create cached resource item
:param path: str
:param content: PIL.Image
:return: str | [
"Create",
"cached",
"resource",
"item",
":",
"param",
"path",
":",
"str",
":",
"param",
"content",
":",
"PIL",
".",
"Image",
":",
"return",
":",
"str"
] | train | https://github.com/FlaskGuys/Flask-Imagine-AzureAdapter/blob/1ca83fb040602ba1be983a7d1cfd052323a86f1a/flask_imagine_azure_adapter/__init__.py#L51-L71 |
FlaskGuys/Flask-Imagine-AzureAdapter | flask_imagine_azure_adapter/__init__.py | FlaskImagineAzureAdapter.get_cached_item | def get_cached_item(self, path):
"""
Get cached resource item
:param path: str
:return: PIL.Image
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
try:
f = tempfile.NamedTemporaryFile()
... | python | def get_cached_item(self, path):
"""
Get cached resource item
:param path: str
:return: PIL.Image
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
try:
f = tempfile.NamedTemporaryFile()
... | [
"def",
"get_cached_item",
"(",
"self",
",",
"path",
")",
":",
"item_path",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"cache_folder",
",",
"path",
".",
"strip",
"(",
"'/'",
")",
")",
"try",
":",
"f",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
... | Get cached resource item
:param path: str
:return: PIL.Image | [
"Get",
"cached",
"resource",
"item",
":",
"param",
"path",
":",
"str",
":",
"return",
":",
"PIL",
".",
"Image"
] | train | https://github.com/FlaskGuys/Flask-Imagine-AzureAdapter/blob/1ca83fb040602ba1be983a7d1cfd052323a86f1a/flask_imagine_azure_adapter/__init__.py#L73-L93 |
FlaskGuys/Flask-Imagine-AzureAdapter | flask_imagine_azure_adapter/__init__.py | FlaskImagineAzureAdapter.check_cached_item | def check_cached_item(self, path):
"""
Check for cached resource item exists
:param path: str
:return: bool
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
if self.blob_service.exists(self.container_nam... | python | def check_cached_item(self, path):
"""
Check for cached resource item exists
:param path: str
:return: bool
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
if self.blob_service.exists(self.container_nam... | [
"def",
"check_cached_item",
"(",
"self",
",",
"path",
")",
":",
"item_path",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"cache_folder",
",",
"path",
".",
"strip",
"(",
"'/'",
")",
")",
"if",
"self",
".",
"blob_service",
".",
"exists",
"(",
"self",
".",
"... | Check for cached resource item exists
:param path: str
:return: bool | [
"Check",
"for",
"cached",
"resource",
"item",
"exists",
":",
"param",
"path",
":",
"str",
":",
"return",
":",
"bool"
] | train | https://github.com/FlaskGuys/Flask-Imagine-AzureAdapter/blob/1ca83fb040602ba1be983a7d1cfd052323a86f1a/flask_imagine_azure_adapter/__init__.py#L95-L109 |
FlaskGuys/Flask-Imagine-AzureAdapter | flask_imagine_azure_adapter/__init__.py | FlaskImagineAzureAdapter.remove_cached_item | def remove_cached_item(self, path):
"""
Remove cached resource item
:param path: str
:return: PIL.Image
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
self.blob_service.delete_blob(self.container_name,... | python | def remove_cached_item(self, path):
"""
Remove cached resource item
:param path: str
:return: PIL.Image
"""
item_path = '%s/%s' % (
self.cache_folder,
path.strip('/')
)
self.blob_service.delete_blob(self.container_name,... | [
"def",
"remove_cached_item",
"(",
"self",
",",
"path",
")",
":",
"item_path",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"cache_folder",
",",
"path",
".",
"strip",
"(",
"'/'",
")",
")",
"self",
".",
"blob_service",
".",
"delete_blob",
"(",
"self",
".",
"co... | Remove cached resource item
:param path: str
:return: PIL.Image | [
"Remove",
"cached",
"resource",
"item",
":",
"param",
"path",
":",
"str",
":",
"return",
":",
"PIL",
".",
"Image"
] | train | https://github.com/FlaskGuys/Flask-Imagine-AzureAdapter/blob/1ca83fb040602ba1be983a7d1cfd052323a86f1a/flask_imagine_azure_adapter/__init__.py#L111-L127 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/delete/__init__.py | cli | def cli(ctx, dname, site, delete_code, no_prompt):
"""
Deletes a single site if both <domain> and <site> are specified, or ALL sites under a domain if only the <domain>
is specified.
"""
assert isinstance(ctx, Context)
# Get the domain
dname = domain_parse(dname)
domain = Domain.get(dna... | python | def cli(ctx, dname, site, delete_code, no_prompt):
"""
Deletes a single site if both <domain> and <site> are specified, or ALL sites under a domain if only the <domain>
is specified.
"""
assert isinstance(ctx, Context)
# Get the domain
dname = domain_parse(dname)
domain = Domain.get(dna... | [
"def",
"cli",
"(",
"ctx",
",",
"dname",
",",
"site",
",",
"delete_code",
",",
"no_prompt",
")",
":",
"assert",
"isinstance",
"(",
"ctx",
",",
"Context",
")",
"# Get the domain",
"dname",
"=",
"domain_parse",
"(",
"dname",
")",
"domain",
"=",
"Domain",
".... | Deletes a single site if both <domain> and <site> are specified, or ALL sites under a domain if only the <domain>
is specified. | [
"Deletes",
"a",
"single",
"site",
"if",
"both",
"<domain",
">",
"and",
"<site",
">",
"are",
"specified",
"or",
"ALL",
"sites",
"under",
"a",
"domain",
"if",
"only",
"the",
"<domain",
">",
"is",
"specified",
"."
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/delete/__init__.py#L18-L44 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/delete/__init__.py | delete_single | def delete_single(site, domain, delete_code=False, no_prompt=False):
"""
Delete a single site
@type site: Site
@type domain: Domain
@type delete_code: bool
@type no_prompt: bool
"""
click.secho('Deleting installation "{sn}" hosted on the domain {dn}'.for... | python | def delete_single(site, domain, delete_code=False, no_prompt=False):
"""
Delete a single site
@type site: Site
@type domain: Domain
@type delete_code: bool
@type no_prompt: bool
"""
click.secho('Deleting installation "{sn}" hosted on the domain {dn}'.for... | [
"def",
"delete_single",
"(",
"site",
",",
"domain",
",",
"delete_code",
"=",
"False",
",",
"no_prompt",
"=",
"False",
")",
":",
"click",
".",
"secho",
"(",
"'Deleting installation \"{sn}\" hosted on the domain {dn}'",
".",
"format",
"(",
"sn",
"=",
"site",
".",
... | Delete a single site
@type site: Site
@type domain: Domain
@type delete_code: bool
@type no_prompt: bool | [
"Delete",
"a",
"single",
"site"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/delete/__init__.py#L47-L92 |
FujiMakoto/IPS-Vagrant | ips_vagrant/commands/delete/__init__.py | _remove_code | def _remove_code(site):
"""
Delete project files
@type site: Site
"""
def handle_error(function, path, excinfo):
click.secho('Failed to remove path ({em}): {p}'.format(em=excinfo.message, p=path), err=True, fg='red')
if os.path.exists(site.root):
shutil.rmtree(site.root, one... | python | def _remove_code(site):
"""
Delete project files
@type site: Site
"""
def handle_error(function, path, excinfo):
click.secho('Failed to remove path ({em}): {p}'.format(em=excinfo.message, p=path), err=True, fg='red')
if os.path.exists(site.root):
shutil.rmtree(site.root, one... | [
"def",
"_remove_code",
"(",
"site",
")",
":",
"def",
"handle_error",
"(",
"function",
",",
"path",
",",
"excinfo",
")",
":",
"click",
".",
"secho",
"(",
"'Failed to remove path ({em}): {p}'",
".",
"format",
"(",
"em",
"=",
"excinfo",
".",
"message",
",",
"... | Delete project files
@type site: Site | [
"Delete",
"project",
"files"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/delete/__init__.py#L145-L154 |
pydsigner/taskit | taskit/backend.py | build_backend | def build_backend(tasks, default_host=('127.0.0.1', DEFAULT_PORT), *args,
**kw):
"""
Most of these args are passed directly to BackEnd(). However, default_host
is used a bit differently. It should be a (host, port) pair, and may be
overridden with cmdline args:
file.py localho... | python | def build_backend(tasks, default_host=('127.0.0.1', DEFAULT_PORT), *args,
**kw):
"""
Most of these args are passed directly to BackEnd(). However, default_host
is used a bit differently. It should be a (host, port) pair, and may be
overridden with cmdline args:
file.py localho... | [
"def",
"build_backend",
"(",
"tasks",
",",
"default_host",
"=",
"(",
"'127.0.0.1'",
",",
"DEFAULT_PORT",
")",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"host",
",",
"port",
"=",
"default_host",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
">",
... | Most of these args are passed directly to BackEnd(). However, default_host
is used a bit differently. It should be a (host, port) pair, and may be
overridden with cmdline args:
file.py localhost
file.py localhost 54545 | [
"Most",
"of",
"these",
"args",
"are",
"passed",
"directly",
"to",
"BackEnd",
"()",
".",
"However",
"default_host",
"is",
"used",
"a",
"bit",
"differently",
".",
"It",
"should",
"be",
"a",
"(",
"host",
"port",
")",
"pair",
"and",
"may",
"be",
"overridden"... | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L26-L41 |
pydsigner/taskit | taskit/backend.py | BackEnd._handler | def _handler(self, conn):
"""
Connection handler thread. Takes care of communication with the client
and running the proper task or applying a signal.
"""
incoming = self.recv(conn)
self.log(DEBUG, incoming)
try:
# E.g. ['twister', [7, 'invert'], {'gu... | python | def _handler(self, conn):
"""
Connection handler thread. Takes care of communication with the client
and running the proper task or applying a signal.
"""
incoming = self.recv(conn)
self.log(DEBUG, incoming)
try:
# E.g. ['twister', [7, 'invert'], {'gu... | [
"def",
"_handler",
"(",
"self",
",",
"conn",
")",
":",
"incoming",
"=",
"self",
".",
"recv",
"(",
"conn",
")",
"self",
".",
"log",
"(",
"DEBUG",
",",
"incoming",
")",
"try",
":",
"# E.g. ['twister', [7, 'invert'], {'guess_type': True}]",
"task",
",",
"args",... | Connection handler thread. Takes care of communication with the client
and running the proper task or applying a signal. | [
"Connection",
"handler",
"thread",
".",
"Takes",
"care",
"of",
"communication",
"with",
"the",
"client",
"and",
"running",
"the",
"proper",
"task",
"or",
"applying",
"a",
"signal",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L125-L161 |
pydsigner/taskit | taskit/backend.py | BackEnd.subtask | def subtask(self, func, *args, **kw):
"""
Helper function for tasks needing to run subthreads. Takes care of
remembering that the subtask is running, and of cleaning up after it.
Example starting a simple.Task():
backend.subtask(task.ignore, 1, 'a', verbose=False)
... | python | def subtask(self, func, *args, **kw):
"""
Helper function for tasks needing to run subthreads. Takes care of
remembering that the subtask is running, and of cleaning up after it.
Example starting a simple.Task():
backend.subtask(task.ignore, 1, 'a', verbose=False)
... | [
"def",
"subtask",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"started_task",
"(",
")",
"try",
":",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"except",
"Exception",
":",
"self",
".",
"log",
... | Helper function for tasks needing to run subthreads. Takes care of
remembering that the subtask is running, and of cleaning up after it.
Example starting a simple.Task():
backend.subtask(task.ignore, 1, 'a', verbose=False)
*args and **kw will be propagated to `func`. | [
"Helper",
"function",
"for",
"tasks",
"needing",
"to",
"run",
"subthreads",
".",
"Takes",
"care",
"of",
"remembering",
"that",
"the",
"subtask",
"is",
"running",
"and",
"of",
"cleaning",
"up",
"after",
"it",
".",
"Example",
"starting",
"a",
"simple",
".",
... | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L163-L178 |
pydsigner/taskit | taskit/backend.py | BackEnd.stop_server | def stop_server(self):
"""
Stop receiving connections, wait for all tasks to end, and then
terminate the server.
"""
self.stop = True
while self.task_count:
time.sleep(END_RESP)
self.terminate = True | python | def stop_server(self):
"""
Stop receiving connections, wait for all tasks to end, and then
terminate the server.
"""
self.stop = True
while self.task_count:
time.sleep(END_RESP)
self.terminate = True | [
"def",
"stop_server",
"(",
"self",
")",
":",
"self",
".",
"stop",
"=",
"True",
"while",
"self",
".",
"task_count",
":",
"time",
".",
"sleep",
"(",
"END_RESP",
")",
"self",
".",
"terminate",
"=",
"True"
] | Stop receiving connections, wait for all tasks to end, and then
terminate the server. | [
"Stop",
"receiving",
"connections",
"wait",
"for",
"all",
"tasks",
"to",
"end",
"and",
"then",
"terminate",
"the",
"server",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L198-L206 |
pydsigner/taskit | taskit/backend.py | BackEnd.main | def main(self):
"""
Runs the mainloop. Blocks. Can be halted with over a network, or by
with either stop_server() or terminate_server().
"""
try:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.bind((self.host, self.port))
... | python | def main(self):
"""
Runs the mainloop. Blocks. Can be halted with over a network, or by
with either stop_server() or terminate_server().
"""
try:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.bind((self.host, self.port))
... | [
"def",
"main",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"self",
".",
"sock",
".",
"bind",
"(",
"(",
"self",
".",
"host",
",",
"sel... | Runs the mainloop. Blocks. Can be halted with over a network, or by
with either stop_server() or terminate_server(). | [
"Runs",
"the",
"mainloop",
".",
"Blocks",
".",
"Can",
"be",
"halted",
"with",
"over",
"a",
"network",
"or",
"by",
"with",
"either",
"stop_server",
"()",
"or",
"terminate_server",
"()",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/backend.py#L215-L245 |
pjuren/pyokit | src/pyokit/io/fastqIterators.py | fastqIteratorSimple | def fastqIteratorSimple(fn, verbose=False, allowNameMissmatch=False):
"""
A generator function that yields FastqSequence objects read from a
fastq-format stream or filename. This is iterator requires that all
sequence and quality data is provided on a single line -- put another way,
it cannot parse fa... | python | def fastqIteratorSimple(fn, verbose=False, allowNameMissmatch=False):
"""
A generator function that yields FastqSequence objects read from a
fastq-format stream or filename. This is iterator requires that all
sequence and quality data is provided on a single line -- put another way,
it cannot parse fa... | [
"def",
"fastqIteratorSimple",
"(",
"fn",
",",
"verbose",
"=",
"False",
",",
"allowNameMissmatch",
"=",
"False",
")",
":",
"fh",
"=",
"fn",
"if",
"type",
"(",
"fh",
")",
".",
"__name__",
"==",
"\"str\"",
":",
"fh",
"=",
"open",
"(",
"fh",
")",
"# try ... | A generator function that yields FastqSequence objects read from a
fastq-format stream or filename. This is iterator requires that all
sequence and quality data is provided on a single line -- put another way,
it cannot parse fastq files with newline characters interspersed in the
sequence and/or qualit... | [
"A",
"generator",
"function",
"that",
"yields",
"FastqSequence",
"objects",
"read",
"from",
"a",
"fastq",
"-",
"format",
"stream",
"or",
"filename",
".",
"This",
"is",
"iterator",
"requires",
"that",
"all",
"sequence",
"and",
"quality",
"data",
"is",
"provided... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastqIterators.py#L79-L151 |
pjuren/pyokit | src/pyokit/io/fastqIterators.py | fastqIterator | def fastqIterator(fn, verbose=False, allowNameMissmatch=False):
"""
A generator function which yields FastqSequence objects read from a file or
stream. This is a general function which wraps fastqIteratorSimple. In
future releases, we may allow dynamic switching of which base iterator is
used.
:p... | python | def fastqIterator(fn, verbose=False, allowNameMissmatch=False):
"""
A generator function which yields FastqSequence objects read from a file or
stream. This is a general function which wraps fastqIteratorSimple. In
future releases, we may allow dynamic switching of which base iterator is
used.
:p... | [
"def",
"fastqIterator",
"(",
"fn",
",",
"verbose",
"=",
"False",
",",
"allowNameMissmatch",
"=",
"False",
")",
":",
"it",
"=",
"fastqIteratorSimple",
"(",
"fn",
",",
"verbose",
"=",
"verbose",
",",
"allowNameMissmatch",
"=",
"allowNameMissmatch",
")",
"for",
... | A generator function which yields FastqSequence objects read from a file or
stream. This is a general function which wraps fastqIteratorSimple. In
future releases, we may allow dynamic switching of which base iterator is
used.
:param fn: A file-like stream or a string; if this is a
... | [
"A",
"generator",
"function",
"which",
"yields",
"FastqSequence",
"objects",
"read",
"from",
"a",
"file",
"or",
"stream",
".",
"This",
"is",
"a",
"general",
"function",
"which",
"wraps",
"fastqIteratorSimple",
".",
"In",
"future",
"releases",
"we",
"may",
"all... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastqIterators.py#L154-L182 |
pjuren/pyokit | src/pyokit/io/fastqIterators.py | fastqIteratorComplex | def fastqIteratorComplex(fn, useMutableString=False, verbose=False):
"""
A generator function which yields FastqSequence objects read from a file or
stream. This iterator can handle fastq files that have their sequence
and/or their quality data split across multiple lines (i.e. there are
newline chara... | python | def fastqIteratorComplex(fn, useMutableString=False, verbose=False):
"""
A generator function which yields FastqSequence objects read from a file or
stream. This iterator can handle fastq files that have their sequence
and/or their quality data split across multiple lines (i.e. there are
newline chara... | [
"def",
"fastqIteratorComplex",
"(",
"fn",
",",
"useMutableString",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"fh",
"=",
"fn",
"if",
"type",
"(",
"fh",
")",
".",
"__name__",
"==",
"\"str\"",
":",
"fh",
"=",
"open",
"(",
"fh",
")",
"prevLin... | A generator function which yields FastqSequence objects read from a file or
stream. This iterator can handle fastq files that have their sequence
and/or their quality data split across multiple lines (i.e. there are
newline characters in the sequence and quality strings).
:param fn: A f... | [
"A",
"generator",
"function",
"which",
"yields",
"FastqSequence",
"objects",
"read",
"from",
"a",
"file",
"or",
"stream",
".",
"This",
"iterator",
"can",
"handle",
"fastq",
"files",
"that",
"have",
"their",
"sequence",
"and",
"/",
"or",
"their",
"quality",
"... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/fastqIterators.py#L235-L298 |
dacut/meterer | meterer/s3.py | S3Meterer.resource_to_bucket_and_key | def resource_to_bucket_and_key(resource_name):
"""
S3Meterer.resource_to_bucket_and_key(resource_name) -> (str, str)
Convert an S3 resource name in the form 's3://bucket/key' to a tuple
of ('bucket', 'key').
"""
if not resource_name.startswith(S3Meterer.s3_url_prefix):
... | python | def resource_to_bucket_and_key(resource_name):
"""
S3Meterer.resource_to_bucket_and_key(resource_name) -> (str, str)
Convert an S3 resource name in the form 's3://bucket/key' to a tuple
of ('bucket', 'key').
"""
if not resource_name.startswith(S3Meterer.s3_url_prefix):
... | [
"def",
"resource_to_bucket_and_key",
"(",
"resource_name",
")",
":",
"if",
"not",
"resource_name",
".",
"startswith",
"(",
"S3Meterer",
".",
"s3_url_prefix",
")",
":",
"raise",
"ValueError",
"(",
"\"Expected resource_name to start with %s\"",
"%",
"S3Meterer",
".",
"s... | S3Meterer.resource_to_bucket_and_key(resource_name) -> (str, str)
Convert an S3 resource name in the form 's3://bucket/key' to a tuple
of ('bucket', 'key'). | [
"S3Meterer",
".",
"resource_to_bucket_and_key",
"(",
"resource_name",
")",
"-",
">",
"(",
"str",
"str",
")"
] | train | https://github.com/dacut/meterer/blob/441e7f021e3302597f56876948a40fe8799a3375/meterer/s3.py#L57-L78 |
b3j0f/task | b3j0f/task/condition.py | during | def during(rrule, duration=None, timestamp=None, **kwargs):
"""
Check if input timestamp is in rrule+duration period
:param rrule: rrule to check
:type rrule: str or dict
(freq, dtstart, interval, count, wkst, until, bymonth, byminute, etc.)
:param dict duration: time duration from rrule st... | python | def during(rrule, duration=None, timestamp=None, **kwargs):
"""
Check if input timestamp is in rrule+duration period
:param rrule: rrule to check
:type rrule: str or dict
(freq, dtstart, interval, count, wkst, until, bymonth, byminute, etc.)
:param dict duration: time duration from rrule st... | [
"def",
"during",
"(",
"rrule",
",",
"duration",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"False",
"# if rrule is a string expression",
"if",
"isinstance",
"(",
"rrule",
",",
"string_types",
")",
":",
"rr... | Check if input timestamp is in rrule+duration period
:param rrule: rrule to check
:type rrule: str or dict
(freq, dtstart, interval, count, wkst, until, bymonth, byminute, etc.)
:param dict duration: time duration from rrule step. Ex:{'minutes': 60}
:param float timestamp: timestamp to check be... | [
"Check",
"if",
"input",
"timestamp",
"is",
"in",
"rrule",
"+",
"duration",
"period"
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L43-L84 |
b3j0f/task | b3j0f/task/condition.py | _any | def _any(confs=None, **kwargs):
"""
True iif at least one input condition is equivalent to True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if at least one condition is checked (compared to True, but
not an st... | python | def _any(confs=None, **kwargs):
"""
True iif at least one input condition is equivalent to True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if at least one condition is checked (compared to True, but
not an st... | [
"def",
"_any",
"(",
"confs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"False",
"if",
"confs",
"is",
"not",
"None",
":",
"# ensure confs is a list",
"if",
"isinstance",
"(",
"confs",
",",
"string_types",
")",
"or",
"isinstance",
"(",... | True iif at least one input condition is equivalent to True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if at least one condition is checked (compared to True, but
not an strict equivalence to True). False otherwise.
... | [
"True",
"iif",
"at",
"least",
"one",
"input",
"condition",
"is",
"equivalent",
"to",
"True",
"."
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L88-L112 |
b3j0f/task | b3j0f/task/condition.py | _all | def _all(confs=None, **kwargs):
"""
True iif all input confs are True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if all conditions are checked. False otherwise.
:rtype: bool
"""
result = False
if confs ... | python | def _all(confs=None, **kwargs):
"""
True iif all input confs are True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if all conditions are checked. False otherwise.
:rtype: bool
"""
result = False
if confs ... | [
"def",
"_all",
"(",
"confs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"False",
"if",
"confs",
"is",
"not",
"None",
":",
"# ensure confs is a list",
"if",
"isinstance",
"(",
"confs",
",",
"string_types",
")",
"or",
"isinstance",
"(",... | True iif all input confs are True.
:param confs: confs to check.
:type confs: list or dict or str
:param kwargs: additional task kwargs.
:return: True if all conditions are checked. False otherwise.
:rtype: bool | [
"True",
"iif",
"all",
"input",
"confs",
"are",
"True",
"."
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L116-L142 |
b3j0f/task | b3j0f/task/condition.py | _not | def _not(condition=None, **kwargs):
"""
Return the opposite of input condition.
:param condition: condition to process.
:result: not condition.
:rtype: bool
"""
result = True
if condition is not None:
result = not run(condition, **kwargs)
return result | python | def _not(condition=None, **kwargs):
"""
Return the opposite of input condition.
:param condition: condition to process.
:result: not condition.
:rtype: bool
"""
result = True
if condition is not None:
result = not run(condition, **kwargs)
return result | [
"def",
"_not",
"(",
"condition",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"True",
"if",
"condition",
"is",
"not",
"None",
":",
"result",
"=",
"not",
"run",
"(",
"condition",
",",
"*",
"*",
"kwargs",
")",
"return",
"result"
] | Return the opposite of input condition.
:param condition: condition to process.
:result: not condition.
:rtype: bool | [
"Return",
"the",
"opposite",
"of",
"input",
"condition",
"."
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L149-L164 |
b3j0f/task | b3j0f/task/condition.py | condition | def condition(condition=None, statement=None, _else=None, **kwargs):
"""
Run an statement if input condition is checked and return statement result.
:param condition: condition to check.
:type condition: str or dict
:param statement: statement to process if condition is checked.
:type statement... | python | def condition(condition=None, statement=None, _else=None, **kwargs):
"""
Run an statement if input condition is checked and return statement result.
:param condition: condition to check.
:type condition: str or dict
:param statement: statement to process if condition is checked.
:type statement... | [
"def",
"condition",
"(",
"condition",
"=",
"None",
",",
"statement",
"=",
"None",
",",
"_else",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"None",
"checked",
"=",
"False",
"if",
"condition",
"is",
"not",
"None",
":",
"checked",
"=... | Run an statement if input condition is checked and return statement result.
:param condition: condition to check.
:type condition: str or dict
:param statement: statement to process if condition is checked.
:type statement: str or dict
:param _else: else statement.
:type _else: str or dict
... | [
"Run",
"an",
"statement",
"if",
"input",
"condition",
"is",
"checked",
"and",
"return",
"statement",
"result",
"."
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L168-L197 |
b3j0f/task | b3j0f/task/condition.py | switch | def switch(
confs=None, remain=False, all_checked=False, _default=None, **kwargs
):
"""
Execute first statement among conf where task result is True.
If remain, process all statements conf starting from the first checked
conf.
:param confs: task confs to check. Each one may contain a task a... | python | def switch(
confs=None, remain=False, all_checked=False, _default=None, **kwargs
):
"""
Execute first statement among conf where task result is True.
If remain, process all statements conf starting from the first checked
conf.
:param confs: task confs to check. Each one may contain a task a... | [
"def",
"switch",
"(",
"confs",
"=",
"None",
",",
"remain",
"=",
"False",
",",
"all_checked",
"=",
"False",
",",
"_default",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# init result",
"result",
"=",
"[",
"]",
"if",
"remain",
"else",
"None",
"# c... | Execute first statement among conf where task result is True.
If remain, process all statements conf starting from the first checked
conf.
:param confs: task confs to check. Each one may contain a task action at
the key 'action' in conf.
:type confs: str or dict or list
:param bool remain: ... | [
"Execute",
"first",
"statement",
"among",
"conf",
"where",
"task",
"result",
"is",
"True",
".",
"If",
"remain",
"process",
"all",
"statements",
"conf",
"starting",
"from",
"the",
"first",
"checked",
"conf",
"."
] | train | https://github.com/b3j0f/task/blob/3e3e48633b1c9a52911c19df3a44fba4b744f60e/b3j0f/task/condition.py#L201-L277 |
jthacker/terseparse | terseparse/root_parser.py | RootParser.error | def error(self, message):
"""Overrides error to control printing output"""
if self._debug:
import pdb
_, _, tb = sys.exc_info()
if tb:
pdb.post_mortem(tb)
else:
pdb.set_trace()
self.print_usage(sys.stderr)
se... | python | def error(self, message):
"""Overrides error to control printing output"""
if self._debug:
import pdb
_, _, tb = sys.exc_info()
if tb:
pdb.post_mortem(tb)
else:
pdb.set_trace()
self.print_usage(sys.stderr)
se... | [
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"if",
"self",
".",
"_debug",
":",
"import",
"pdb",
"_",
",",
"_",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"tb",
":",
"pdb",
".",
"post_mortem",
"(",
"tb",
")",
"else",
":",
... | Overrides error to control printing output | [
"Overrides",
"error",
"to",
"control",
"printing",
"output"
] | train | https://github.com/jthacker/terseparse/blob/236a31faf819f3ae9019a545613b8e7a6808f7b2/terseparse/root_parser.py#L108-L118 |
jthacker/terseparse | terseparse/root_parser.py | RootParser.format_help | def format_help(self):
"""Overrides format_help to not print subparsers"""
formatter = self._get_formatter()
# usage
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
# description
formatter.add_text(self.descrip... | python | def format_help(self):
"""Overrides format_help to not print subparsers"""
formatter = self._get_formatter()
# usage
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
# description
formatter.add_text(self.descrip... | [
"def",
"format_help",
"(",
"self",
")",
":",
"formatter",
"=",
"self",
".",
"_get_formatter",
"(",
")",
"# usage",
"formatter",
".",
"add_usage",
"(",
"self",
".",
"usage",
",",
"self",
".",
"_actions",
",",
"self",
".",
"_mutually_exclusive_groups",
")",
... | Overrides format_help to not print subparsers | [
"Overrides",
"format_help",
"to",
"not",
"print",
"subparsers"
] | train | https://github.com/jthacker/terseparse/blob/236a31faf819f3ae9019a545613b8e7a6808f7b2/terseparse/root_parser.py#L120-L144 |
OpenGov/python_data_wrap | datawrap/savable.py | AttributeSavable.open_attributes_file | def open_attributes_file(self):
'''
Called during initialization. Only needs to be explicitly
called if save_and_close_attributes is explicitly called
beforehand.
'''
if not self.saveable():
raise AttributeError("Cannot open attribute file without a valid file... | python | def open_attributes_file(self):
'''
Called during initialization. Only needs to be explicitly
called if save_and_close_attributes is explicitly called
beforehand.
'''
if not self.saveable():
raise AttributeError("Cannot open attribute file without a valid file... | [
"def",
"open_attributes_file",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"saveable",
"(",
")",
":",
"raise",
"AttributeError",
"(",
"\"Cannot open attribute file without a valid file\"",
")",
"if",
"self",
".",
"_db_closed",
":",
"self",
".",
"_fd",
"=",
... | Called during initialization. Only needs to be explicitly
called if save_and_close_attributes is explicitly called
beforehand. | [
"Called",
"during",
"initialization",
".",
"Only",
"needs",
"to",
"be",
"explicitly",
"called",
"if",
"save_and_close_attributes",
"is",
"explicitly",
"called",
"beforehand",
"."
] | train | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/savable.py#L46-L59 |
OpenGov/python_data_wrap | datawrap/savable.py | AttributeSavable.save_attributes | def save_attributes(self):
'''
Saves the attributes without closing the attributes file.
This should probably be called after the attribute holder
sets/overrides the attributes in initialization as the del
method is not guaranteed to be called.
'''
if not self.sav... | python | def save_attributes(self):
'''
Saves the attributes without closing the attributes file.
This should probably be called after the attribute holder
sets/overrides the attributes in initialization as the del
method is not guaranteed to be called.
'''
if not self.sav... | [
"def",
"save_attributes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"saveable",
"(",
")",
":",
"raise",
"AttributeError",
"(",
"\"Cannot save attribute file without a valid file\"",
")",
"if",
"self",
".",
"_read_only",
":",
"raise",
"AttributeError",
"(",
... | Saves the attributes without closing the attributes file.
This should probably be called after the attribute holder
sets/overrides the attributes in initialization as the del
method is not guaranteed to be called. | [
"Saves",
"the",
"attributes",
"without",
"closing",
"the",
"attributes",
"file",
".",
"This",
"should",
"probably",
"be",
"called",
"after",
"the",
"attribute",
"holder",
"sets",
"/",
"overrides",
"the",
"attributes",
"in",
"initialization",
"as",
"the",
"del",
... | train | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/savable.py#L61-L75 |
OpenGov/python_data_wrap | datawrap/savable.py | AttributeSavable.save_and_close_attributes | def save_and_close_attributes(self):
'''
Performs the same function as save_attributes but also closes
the attribute file.
'''
if not self.saveable():
raise AttributeError("Cannot save attribute file without a valid file")
if not self._db_closed:
s... | python | def save_and_close_attributes(self):
'''
Performs the same function as save_attributes but also closes
the attribute file.
'''
if not self.saveable():
raise AttributeError("Cannot save attribute file without a valid file")
if not self._db_closed:
s... | [
"def",
"save_and_close_attributes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"saveable",
"(",
")",
":",
"raise",
"AttributeError",
"(",
"\"Cannot save attribute file without a valid file\"",
")",
"if",
"not",
"self",
".",
"_db_closed",
":",
"self",
".",
... | Performs the same function as save_attributes but also closes
the attribute file. | [
"Performs",
"the",
"same",
"function",
"as",
"save_attributes",
"but",
"also",
"closes",
"the",
"attribute",
"file",
"."
] | train | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/savable.py#L77-L88 |
hmartiniano/faz | faz/parser.py | split_task_parameters | def split_task_parameters(line):
""" Split a string of comma separated words."""
if line is None:
result = []
else:
result = [parameter.strip() for parameter in line.split(",")]
return result | python | def split_task_parameters(line):
""" Split a string of comma separated words."""
if line is None:
result = []
else:
result = [parameter.strip() for parameter in line.split(",")]
return result | [
"def",
"split_task_parameters",
"(",
"line",
")",
":",
"if",
"line",
"is",
"None",
":",
"result",
"=",
"[",
"]",
"else",
":",
"result",
"=",
"[",
"parameter",
".",
"strip",
"(",
")",
"for",
"parameter",
"in",
"line",
".",
"split",
"(",
"\",\"",
")",
... | Split a string of comma separated words. | [
"Split",
"a",
"string",
"of",
"comma",
"separated",
"words",
"."
] | train | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/parser.py#L18-L24 |
hmartiniano/faz | faz/parser.py | find_tasks | def find_tasks(lines):
"""
Find task lines and corresponding line numbers in a list of lines.
"""
tasks = []
linenumbers = []
pattern = re.compile(TASK_PATTERN)
for n, line in enumerate(lines):
if "#" in line and "<-" in line:
m = pattern.match(line)
if m is n... | python | def find_tasks(lines):
"""
Find task lines and corresponding line numbers in a list of lines.
"""
tasks = []
linenumbers = []
pattern = re.compile(TASK_PATTERN)
for n, line in enumerate(lines):
if "#" in line and "<-" in line:
m = pattern.match(line)
if m is n... | [
"def",
"find_tasks",
"(",
"lines",
")",
":",
"tasks",
"=",
"[",
"]",
"linenumbers",
"=",
"[",
"]",
"pattern",
"=",
"re",
".",
"compile",
"(",
"TASK_PATTERN",
")",
"for",
"n",
",",
"line",
"in",
"enumerate",
"(",
"lines",
")",
":",
"if",
"\"#\"",
"i... | Find task lines and corresponding line numbers in a list of lines. | [
"Find",
"task",
"lines",
"and",
"corresponding",
"line",
"numbers",
"in",
"a",
"list",
"of",
"lines",
"."
] | train | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/parser.py#L35-L54 |
hmartiniano/faz | faz/parser.py | create_environment | def create_environment(preamble):
"""
Create a dictionary of variables obtained from the preamble of
the task file and the environment the program is running on.
"""
environment = copy.deepcopy(os.environ)
for line in preamble:
logging.debug(line)
if "=" in line and not line.star... | python | def create_environment(preamble):
"""
Create a dictionary of variables obtained from the preamble of
the task file and the environment the program is running on.
"""
environment = copy.deepcopy(os.environ)
for line in preamble:
logging.debug(line)
if "=" in line and not line.star... | [
"def",
"create_environment",
"(",
"preamble",
")",
":",
"environment",
"=",
"copy",
".",
"deepcopy",
"(",
"os",
".",
"environ",
")",
"for",
"line",
"in",
"preamble",
":",
"logging",
".",
"debug",
"(",
"line",
")",
"if",
"\"=\"",
"in",
"line",
"and",
"n... | Create a dictionary of variables obtained from the preamble of
the task file and the environment the program is running on. | [
"Create",
"a",
"dictionary",
"of",
"variables",
"obtained",
"from",
"the",
"preamble",
"of",
"the",
"task",
"file",
"and",
"the",
"environment",
"the",
"program",
"is",
"running",
"on",
"."
] | train | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/parser.py#L57-L73 |
hmartiniano/faz | faz/parser.py | parse_input_file | def parse_input_file(text, variables=None):
""" Parser for a file with syntax somewhat similar to Drake."""
text = find_includes(text)
lines = text.splitlines()
tasks, linenumbers = find_tasks(lines)
preamble = [line for line in lines[:linenumbers[0]]]
logging.debug("Preamble:\n{}".format("\n".j... | python | def parse_input_file(text, variables=None):
""" Parser for a file with syntax somewhat similar to Drake."""
text = find_includes(text)
lines = text.splitlines()
tasks, linenumbers = find_tasks(lines)
preamble = [line for line in lines[:linenumbers[0]]]
logging.debug("Preamble:\n{}".format("\n".j... | [
"def",
"parse_input_file",
"(",
"text",
",",
"variables",
"=",
"None",
")",
":",
"text",
"=",
"find_includes",
"(",
"text",
")",
"lines",
"=",
"text",
".",
"splitlines",
"(",
")",
"tasks",
",",
"linenumbers",
"=",
"find_tasks",
"(",
"lines",
")",
"preamb... | Parser for a file with syntax somewhat similar to Drake. | [
"Parser",
"for",
"a",
"file",
"with",
"syntax",
"somewhat",
"similar",
"to",
"Drake",
"."
] | train | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/parser.py#L76-L95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.