repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
numirias/firefed | firefed/feature/feature.py | FeatureHelpersMixin.load_json | def load_json(self, path):
"""Load a JSON file from the user profile."""
with open(self.profile_path(path, must_exist=True),
encoding='utf-8') as f:
data = json.load(f)
return data | python | def load_json(self, path):
"""Load a JSON file from the user profile."""
with open(self.profile_path(path, must_exist=True),
encoding='utf-8') as f:
data = json.load(f)
return data | [
"def",
"load_json",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"self",
".",
"profile_path",
"(",
"path",
",",
"must_exist",
"=",
"True",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"data",
"=",
"json",
".",
"load",
"(",... | Load a JSON file from the user profile. | [
"Load",
"a",
"JSON",
"file",
"from",
"the",
"user",
"profile",
"."
] | 908114fe3a1506dcaafb23ce49e99f171e5e329d | https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L102-L107 | train | 60,100 |
numirias/firefed | firefed/feature/feature.py | FeatureHelpersMixin.load_mozlz4 | def load_mozlz4(self, path):
"""Load a Mozilla LZ4 file from the user profile.
Mozilla LZ4 is regular LZ4 with a custom string prefix.
"""
with open(self.profile_path(path, must_exist=True), 'rb') as f:
if f.read(8) != b'mozLz40\0':
raise NotMozLz4Error('Not ... | python | def load_mozlz4(self, path):
"""Load a Mozilla LZ4 file from the user profile.
Mozilla LZ4 is regular LZ4 with a custom string prefix.
"""
with open(self.profile_path(path, must_exist=True), 'rb') as f:
if f.read(8) != b'mozLz40\0':
raise NotMozLz4Error('Not ... | [
"def",
"load_mozlz4",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"self",
".",
"profile_path",
"(",
"path",
",",
"must_exist",
"=",
"True",
")",
",",
"'rb'",
")",
"as",
"f",
":",
"if",
"f",
".",
"read",
"(",
"8",
")",
"!=",
"b'mozLz4... | Load a Mozilla LZ4 file from the user profile.
Mozilla LZ4 is regular LZ4 with a custom string prefix. | [
"Load",
"a",
"Mozilla",
"LZ4",
"file",
"from",
"the",
"user",
"profile",
"."
] | 908114fe3a1506dcaafb23ce49e99f171e5e329d | https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L109-L118 | train | 60,101 |
numirias/firefed | firefed/feature/feature.py | FeatureHelpersMixin.csv_from_items | def csv_from_items(items, stream=None):
"""Write a list of items to stream in CSV format.
The items need to be attrs-decorated.
"""
items = iter(items)
first = next(items)
cls = first.__class__
if stream is None:
stream = sys.stdout
fields = [... | python | def csv_from_items(items, stream=None):
"""Write a list of items to stream in CSV format.
The items need to be attrs-decorated.
"""
items = iter(items)
first = next(items)
cls = first.__class__
if stream is None:
stream = sys.stdout
fields = [... | [
"def",
"csv_from_items",
"(",
"items",
",",
"stream",
"=",
"None",
")",
":",
"items",
"=",
"iter",
"(",
"items",
")",
"first",
"=",
"next",
"(",
"items",
")",
"cls",
"=",
"first",
".",
"__class__",
"if",
"stream",
"is",
"None",
":",
"stream",
"=",
... | Write a list of items to stream in CSV format.
The items need to be attrs-decorated. | [
"Write",
"a",
"list",
"of",
"items",
"to",
"stream",
"in",
"CSV",
"format",
"."
] | 908114fe3a1506dcaafb23ce49e99f171e5e329d | https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L132-L146 | train | 60,102 |
numirias/firefed | firefed/feature/feature.py | FeatureHelpersMixin.profile_path | def profile_path(self, path, must_exist=False):
"""Return path from current profile."""
full_path = self.session.profile / path
if must_exist and not full_path.exists():
raise FileNotFoundError(
errno.ENOENT,
os.strerror(errno.ENOENT),
... | python | def profile_path(self, path, must_exist=False):
"""Return path from current profile."""
full_path = self.session.profile / path
if must_exist and not full_path.exists():
raise FileNotFoundError(
errno.ENOENT,
os.strerror(errno.ENOENT),
... | [
"def",
"profile_path",
"(",
"self",
",",
"path",
",",
"must_exist",
"=",
"False",
")",
":",
"full_path",
"=",
"self",
".",
"session",
".",
"profile",
"/",
"path",
"if",
"must_exist",
"and",
"not",
"full_path",
".",
"exists",
"(",
")",
":",
"raise",
"Fi... | Return path from current profile. | [
"Return",
"path",
"from",
"current",
"profile",
"."
] | 908114fe3a1506dcaafb23ce49e99f171e5e329d | https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/feature/feature.py#L148-L157 | train | 60,103 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.make_rpc_call | def make_rpc_call(self, rpc_command):
"""
Allow a user to query a device directly using XML-requests.
:param rpc_command: (str) rpc command such as:
<Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>
"""
# ~~~ hack: ~~~
... | python | def make_rpc_call(self, rpc_command):
"""
Allow a user to query a device directly using XML-requests.
:param rpc_command: (str) rpc command such as:
<Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get>
"""
# ~~~ hack: ~~~
... | [
"def",
"make_rpc_call",
"(",
"self",
",",
"rpc_command",
")",
":",
"# ~~~ hack: ~~~",
"if",
"not",
"self",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"close",
"(",
")",
"# force close for safety",
"self",
".",
"open",
"(",
")",
"# reopen",
"# ~~~ end hack ... | Allow a user to query a device directly using XML-requests.
:param rpc_command: (str) rpc command such as:
<Get><Operational><LLDP><NodeTable></NodeTable></LLDP></Operational></Get> | [
"Allow",
"a",
"user",
"to",
"query",
"a",
"device",
"directly",
"using",
"XML",
"-",
"requests",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L139-L152 | train | 60,104 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.open | def open(self):
"""
Open a connection to an IOS-XR device.
Connects to the device using SSH and drops into XML mode.
"""
try:
self.device = ConnectHandler(device_type='cisco_xr',
ip=self.hostname,
... | python | def open(self):
"""
Open a connection to an IOS-XR device.
Connects to the device using SSH and drops into XML mode.
"""
try:
self.device = ConnectHandler(device_type='cisco_xr',
ip=self.hostname,
... | [
"def",
"open",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"device",
"=",
"ConnectHandler",
"(",
"device_type",
"=",
"'cisco_xr'",
",",
"ip",
"=",
"self",
".",
"hostname",
",",
"port",
"=",
"self",
".",
"port",
",",
"username",
"=",
"self",
".",
... | Open a connection to an IOS-XR device.
Connects to the device using SSH and drops into XML mode. | [
"Open",
"a",
"connection",
"to",
"an",
"IOS",
"-",
"XR",
"device",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L154-L175 | train | 60,105 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR._execute_show | def _execute_show(self, show_command):
"""
Executes an operational show-type command.
"""
rpc_command = '<CLI><Exec>{show_command}</Exec></CLI>'.format(
show_command=escape_xml(show_command)
)
response = self._execute_rpc(rpc_command)
raw_response = re... | python | def _execute_show(self, show_command):
"""
Executes an operational show-type command.
"""
rpc_command = '<CLI><Exec>{show_command}</Exec></CLI>'.format(
show_command=escape_xml(show_command)
)
response = self._execute_rpc(rpc_command)
raw_response = re... | [
"def",
"_execute_show",
"(",
"self",
",",
"show_command",
")",
":",
"rpc_command",
"=",
"'<CLI><Exec>{show_command}</Exec></CLI>'",
".",
"format",
"(",
"show_command",
"=",
"escape_xml",
"(",
"show_command",
")",
")",
"response",
"=",
"self",
".",
"_execute_rpc",
... | Executes an operational show-type command. | [
"Executes",
"an",
"operational",
"show",
"-",
"type",
"command",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L432-L441 | train | 60,106 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR._execute_config_show | def _execute_config_show(self, show_command, delay_factor=.1):
"""
Executes a configuration show-type command.
"""
rpc_command = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format(
show_command=escape_xml(show_command)
)
response = self._execute... | python | def _execute_config_show(self, show_command, delay_factor=.1):
"""
Executes a configuration show-type command.
"""
rpc_command = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format(
show_command=escape_xml(show_command)
)
response = self._execute... | [
"def",
"_execute_config_show",
"(",
"self",
",",
"show_command",
",",
"delay_factor",
"=",
".1",
")",
":",
"rpc_command",
"=",
"'<CLI><Configuration>{show_command}</Configuration></CLI>'",
".",
"format",
"(",
"show_command",
"=",
"escape_xml",
"(",
"show_command",
")",
... | Executes a configuration show-type command. | [
"Executes",
"a",
"configuration",
"show",
"-",
"type",
"command",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L444-L453 | train | 60,107 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.close | def close(self):
"""
Close the connection to the IOS-XR device.
Clean up after you are done and explicitly close the router connection.
"""
if self.lock_on_connect or self.locked:
self.unlock() # this refers to the config DB
self._unlock_xml_agent() # this ... | python | def close(self):
"""
Close the connection to the IOS-XR device.
Clean up after you are done and explicitly close the router connection.
"""
if self.lock_on_connect or self.locked:
self.unlock() # this refers to the config DB
self._unlock_xml_agent() # this ... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"lock_on_connect",
"or",
"self",
".",
"locked",
":",
"self",
".",
"unlock",
"(",
")",
"# this refers to the config DB",
"self",
".",
"_unlock_xml_agent",
"(",
")",
"# this refers to the XML agent",
"if",
... | Close the connection to the IOS-XR device.
Clean up after you are done and explicitly close the router connection. | [
"Close",
"the",
"connection",
"to",
"the",
"IOS",
"-",
"XR",
"device",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L455-L465 | train | 60,108 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.lock | def lock(self):
"""
Lock the config database.
Use if Locking/Unlocking is not performaed automatically by lock=False
"""
if not self.locked:
rpc_command = '<Lock/>'
try:
self._execute_rpc(rpc_command)
except XMLCLIError:
... | python | def lock(self):
"""
Lock the config database.
Use if Locking/Unlocking is not performaed automatically by lock=False
"""
if not self.locked:
rpc_command = '<Lock/>'
try:
self._execute_rpc(rpc_command)
except XMLCLIError:
... | [
"def",
"lock",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"locked",
":",
"rpc_command",
"=",
"'<Lock/>'",
"try",
":",
"self",
".",
"_execute_rpc",
"(",
"rpc_command",
")",
"except",
"XMLCLIError",
":",
"raise",
"LockError",
"(",
"'Unable to enter in co... | Lock the config database.
Use if Locking/Unlocking is not performaed automatically by lock=False | [
"Lock",
"the",
"config",
"database",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L467-L479 | train | 60,109 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.unlock | def unlock(self):
"""
Unlock the IOS-XR device config.
Use if Locking/Unlocking is not performaed automatically by lock=False
"""
if self.locked:
rpc_command = '<Unlock/>'
try:
self._execute_rpc(rpc_command)
except XMLCLIError:... | python | def unlock(self):
"""
Unlock the IOS-XR device config.
Use if Locking/Unlocking is not performaed automatically by lock=False
"""
if self.locked:
rpc_command = '<Unlock/>'
try:
self._execute_rpc(rpc_command)
except XMLCLIError:... | [
"def",
"unlock",
"(",
"self",
")",
":",
"if",
"self",
".",
"locked",
":",
"rpc_command",
"=",
"'<Unlock/>'",
"try",
":",
"self",
".",
"_execute_rpc",
"(",
"rpc_command",
")",
"except",
"XMLCLIError",
":",
"raise",
"UnlockError",
"(",
"'Unable to unlock the con... | Unlock the IOS-XR device config.
Use if Locking/Unlocking is not performaed automatically by lock=False | [
"Unlock",
"the",
"IOS",
"-",
"XR",
"device",
"config",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L481-L493 | train | 60,110 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.load_candidate_config | def load_candidate_config(self, filename=None, config=None):
"""
Load candidate confguration.
Populate the attribute candidate_config with the desired
configuration and loads it into the router. You can populate it from
a file or from a string. If you send both a filename and a ... | python | def load_candidate_config(self, filename=None, config=None):
"""
Load candidate confguration.
Populate the attribute candidate_config with the desired
configuration and loads it into the router. You can populate it from
a file or from a string. If you send both a filename and a ... | [
"def",
"load_candidate_config",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"configuration",
"=",
"''",
"if",
"filename",
"is",
"None",
":",
"configuration",
"=",
"config",
"else",
":",
"with",
"open",
"(",
"filename",
... | Load candidate confguration.
Populate the attribute candidate_config with the desired
configuration and loads it into the router. You can populate it from
a file or from a string. If you send both a filename and a string
containing the configuration, the file takes precedence.
... | [
"Load",
"candidate",
"confguration",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L495-L524 | train | 60,111 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.get_candidate_config | def get_candidate_config(self, merge=False, formal=False):
"""
Retrieve the configuration loaded as candidate config in your configuration session.
:param merge: Merge candidate config with running config to return
the complete configuration including all changed
... | python | def get_candidate_config(self, merge=False, formal=False):
"""
Retrieve the configuration loaded as candidate config in your configuration session.
:param merge: Merge candidate config with running config to return
the complete configuration including all changed
... | [
"def",
"get_candidate_config",
"(",
"self",
",",
"merge",
"=",
"False",
",",
"formal",
"=",
"False",
")",
":",
"command",
"=",
"\"show configuration\"",
"if",
"merge",
":",
"command",
"+=",
"\" merge\"",
"if",
"formal",
":",
"command",
"+=",
"\" formal\"",
"... | Retrieve the configuration loaded as candidate config in your configuration session.
:param merge: Merge candidate config with running config to return
the complete configuration including all changed
:param formal: Return configuration in IOS-XR formal config format | [
"Retrieve",
"the",
"configuration",
"loaded",
"as",
"candidate",
"config",
"in",
"your",
"configuration",
"session",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L526-L545 | train | 60,112 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.compare_config | def compare_config(self):
"""
Compare configuration to be merged with the one on the device.
Compare executed candidate config with the running config and
return a diff, assuming the loaded config will be merged with the
existing one.
:return: Config diff.
"""
... | python | def compare_config(self):
"""
Compare configuration to be merged with the one on the device.
Compare executed candidate config with the running config and
return a diff, assuming the loaded config will be merged with the
existing one.
:return: Config diff.
"""
... | [
"def",
"compare_config",
"(",
"self",
")",
":",
"_show_merge",
"=",
"self",
".",
"_execute_config_show",
"(",
"'show configuration merge'",
")",
"_show_run",
"=",
"self",
".",
"_execute_config_show",
"(",
"'show running-config'",
")",
"diff",
"=",
"difflib",
".",
... | Compare configuration to be merged with the one on the device.
Compare executed candidate config with the running config and
return a diff, assuming the loaded config will be merged with the
existing one.
:return: Config diff. | [
"Compare",
"configuration",
"to",
"be",
"merged",
"with",
"the",
"one",
"on",
"the",
"device",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L547-L561 | train | 60,113 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.commit_config | def commit_config(self, label=None, comment=None, confirmed=None):
"""
Commit the candidate config.
:param label: Commit comment, displayed in the commit entry on the device.
:param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters)
... | python | def commit_config(self, label=None, comment=None, confirmed=None):
"""
Commit the candidate config.
:param label: Commit comment, displayed in the commit entry on the device.
:param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters)
... | [
"def",
"commit_config",
"(",
"self",
",",
"label",
"=",
"None",
",",
"comment",
"=",
"None",
",",
"confirmed",
"=",
"None",
")",
":",
"rpc_command",
"=",
"'<Commit'",
"if",
"label",
":",
"rpc_command",
"+=",
"' Label=\"%s\"'",
"%",
"label",
"if",
"comment"... | Commit the candidate config.
:param label: Commit comment, displayed in the commit entry on the device.
:param comment: Commit label, displayed instead of the commit ID on the device. (Max 60 characters)
:param confirmed: Commit with auto-rollback if new commit is not made in 30 to 300 se... | [
"Commit",
"the",
"candidate",
"config",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L577-L597 | train | 60,114 |
fooelisa/pyiosxr | pyIOSXR/iosxr.py | IOSXR.rollback | def rollback(self, rb_id=1):
"""
Rollback the last committed configuration.
:param rb_id: Rollback a specific number of steps. Default: 1
"""
rpc_command = '<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'.format(rb_id=rb_id)
self._execute_rpc(rpc_comma... | python | def rollback(self, rb_id=1):
"""
Rollback the last committed configuration.
:param rb_id: Rollback a specific number of steps. Default: 1
"""
rpc_command = '<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'.format(rb_id=rb_id)
self._execute_rpc(rpc_comma... | [
"def",
"rollback",
"(",
"self",
",",
"rb_id",
"=",
"1",
")",
":",
"rpc_command",
"=",
"'<Unlock/><Rollback><Previous>{rb_id}</Previous></Rollback><Lock/>'",
".",
"format",
"(",
"rb_id",
"=",
"rb_id",
")",
"self",
".",
"_execute_rpc",
"(",
"rpc_command",
")"
] | Rollback the last committed configuration.
:param rb_id: Rollback a specific number of steps. Default: 1 | [
"Rollback",
"the",
"last",
"committed",
"configuration",
"."
] | 2bc11797013f1c29d2d338c32edb95068ebdf524 | https://github.com/fooelisa/pyiosxr/blob/2bc11797013f1c29d2d338c32edb95068ebdf524/pyIOSXR/iosxr.py#L629-L636 | train | 60,115 |
sinch/python-sinch-sms | sinchsms.py | _main | def _main():
""" A simple demo to be used from command line. """
import sys
def log(message):
print(message)
def print_usage():
log('usage: %s <application key> <application secret> send <number> <message> <from_number>' % sys.argv[0])
log(' %s <application key> <applicat... | python | def _main():
""" A simple demo to be used from command line. """
import sys
def log(message):
print(message)
def print_usage():
log('usage: %s <application key> <application secret> send <number> <message> <from_number>' % sys.argv[0])
log(' %s <application key> <applicat... | [
"def",
"_main",
"(",
")",
":",
"import",
"sys",
"def",
"log",
"(",
"message",
")",
":",
"print",
"(",
"message",
")",
"def",
"print_usage",
"(",
")",
":",
"log",
"(",
"'usage: %s <application key> <application secret> send <number> <message> <from_number>'",
"%",
... | A simple demo to be used from command line. | [
"A",
"simple",
"demo",
"to",
"be",
"used",
"from",
"command",
"line",
"."
] | 8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2 | https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L97-L123 | train | 60,116 |
sinch/python-sinch-sms | sinchsms.py | SinchSMS._request | def _request(self, url, values=None):
""" Send a request and read response.
Sends a get request if values are None, post request otherwise.
"""
if values:
json_data = json.dumps(values)
request = urllib2.Request(url, json_data.encode())
request.ad... | python | def _request(self, url, values=None):
""" Send a request and read response.
Sends a get request if values are None, post request otherwise.
"""
if values:
json_data = json.dumps(values)
request = urllib2.Request(url, json_data.encode())
request.ad... | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"values",
"=",
"None",
")",
":",
"if",
"values",
":",
"json_data",
"=",
"json",
".",
"dumps",
"(",
"values",
")",
"request",
"=",
"urllib2",
".",
"Request",
"(",
"url",
",",
"json_data",
".",
"encode",... | Send a request and read response.
Sends a get request if values are None, post request otherwise. | [
"Send",
"a",
"request",
"and",
"read",
"response",
"."
] | 8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2 | https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L30-L55 | train | 60,117 |
sinch/python-sinch-sms | sinchsms.py | SinchSMS.send_message | def send_message(self, to_number, message, from_number=None):
""" Send a message to the specified number and return a response dictionary.
The numbers must be specified in international format starting with a '+'.
Returns a dictionary that contains a 'MessageId' key with the sent messag... | python | def send_message(self, to_number, message, from_number=None):
""" Send a message to the specified number and return a response dictionary.
The numbers must be specified in international format starting with a '+'.
Returns a dictionary that contains a 'MessageId' key with the sent messag... | [
"def",
"send_message",
"(",
"self",
",",
"to_number",
",",
"message",
",",
"from_number",
"=",
"None",
")",
":",
"values",
"=",
"{",
"'Message'",
":",
"message",
"}",
"if",
"from_number",
"is",
"not",
"None",
":",
"values",
"[",
"'From'",
"]",
"=",
"fr... | Send a message to the specified number and return a response dictionary.
The numbers must be specified in international format starting with a '+'.
Returns a dictionary that contains a 'MessageId' key with the sent message id value or
contains 'errorCode' and 'message' on error.
... | [
"Send",
"a",
"message",
"to",
"the",
"specified",
"number",
"and",
"return",
"a",
"response",
"dictionary",
"."
] | 8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2 | https://github.com/sinch/python-sinch-sms/blob/8bb8bb9ca044ee915c8e4ca0d628d28f057d6bd2/sinchsms.py#L57-L79 | train | 60,118 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.convert_descriptor | def convert_descriptor(self, descriptor):
"""Convert descriptor to BigQuery
"""
# Fields
fields = []
fallbacks = []
schema = tableschema.Schema(descriptor)
for index, field in enumerate(schema.fields):
converted_type = self.convert_type(field.type)
... | python | def convert_descriptor(self, descriptor):
"""Convert descriptor to BigQuery
"""
# Fields
fields = []
fallbacks = []
schema = tableschema.Schema(descriptor)
for index, field in enumerate(schema.fields):
converted_type = self.convert_type(field.type)
... | [
"def",
"convert_descriptor",
"(",
"self",
",",
"descriptor",
")",
":",
"# Fields",
"fields",
"=",
"[",
"]",
"fallbacks",
"=",
"[",
"]",
"schema",
"=",
"tableschema",
".",
"Schema",
"(",
"descriptor",
")",
"for",
"index",
",",
"field",
"in",
"enumerate",
... | Convert descriptor to BigQuery | [
"Convert",
"descriptor",
"to",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L30-L57 | train | 60,119 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.convert_row | def convert_row(self, row, schema, fallbacks):
"""Convert row to BigQuery
"""
for index, field in enumerate(schema.fields):
value = row[index]
if index in fallbacks:
value = _uncast_value(value, field=field)
else:
value = field.... | python | def convert_row(self, row, schema, fallbacks):
"""Convert row to BigQuery
"""
for index, field in enumerate(schema.fields):
value = row[index]
if index in fallbacks:
value = _uncast_value(value, field=field)
else:
value = field.... | [
"def",
"convert_row",
"(",
"self",
",",
"row",
",",
"schema",
",",
"fallbacks",
")",
":",
"for",
"index",
",",
"field",
"in",
"enumerate",
"(",
"schema",
".",
"fields",
")",
":",
"value",
"=",
"row",
"[",
"index",
"]",
"if",
"index",
"in",
"fallbacks... | Convert row to BigQuery | [
"Convert",
"row",
"to",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L59-L69 | train | 60,120 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.convert_type | def convert_type(self, type):
"""Convert type to BigQuery
"""
# Mapping
mapping = {
'any': 'STRING',
'array': None,
'boolean': 'BOOLEAN',
'date': 'DATE',
'datetime': 'DATETIME',
'duration': None,
'geojso... | python | def convert_type(self, type):
"""Convert type to BigQuery
"""
# Mapping
mapping = {
'any': 'STRING',
'array': None,
'boolean': 'BOOLEAN',
'date': 'DATE',
'datetime': 'DATETIME',
'duration': None,
'geojso... | [
"def",
"convert_type",
"(",
"self",
",",
"type",
")",
":",
"# Mapping",
"mapping",
"=",
"{",
"'any'",
":",
"'STRING'",
",",
"'array'",
":",
"None",
",",
"'boolean'",
":",
"'BOOLEAN'",
",",
"'date'",
":",
"'DATE'",
",",
"'datetime'",
":",
"'DATETIME'",
",... | Convert type to BigQuery | [
"Convert",
"type",
"to",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L71-L99 | train | 60,121 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.restore_descriptor | def restore_descriptor(self, converted_descriptor):
"""Restore descriptor rom BigQuery
"""
# Convert
fields = []
for field in converted_descriptor['fields']:
field_type = self.restore_type(field['type'])
resfield = {
'name': field['name'],... | python | def restore_descriptor(self, converted_descriptor):
"""Restore descriptor rom BigQuery
"""
# Convert
fields = []
for field in converted_descriptor['fields']:
field_type = self.restore_type(field['type'])
resfield = {
'name': field['name'],... | [
"def",
"restore_descriptor",
"(",
"self",
",",
"converted_descriptor",
")",
":",
"# Convert",
"fields",
"=",
"[",
"]",
"for",
"field",
"in",
"converted_descriptor",
"[",
"'fields'",
"]",
":",
"field_type",
"=",
"self",
".",
"restore_type",
"(",
"field",
"[",
... | Restore descriptor rom BigQuery | [
"Restore",
"descriptor",
"rom",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L108-L125 | train | 60,122 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.restore_row | def restore_row(self, row, schema):
"""Restore row from BigQuery
"""
for index, field in enumerate(schema.fields):
if field.type == 'datetime':
row[index] = parse(row[index])
if field.type == 'date':
row[index] = parse(row[index]).date()
... | python | def restore_row(self, row, schema):
"""Restore row from BigQuery
"""
for index, field in enumerate(schema.fields):
if field.type == 'datetime':
row[index] = parse(row[index])
if field.type == 'date':
row[index] = parse(row[index]).date()
... | [
"def",
"restore_row",
"(",
"self",
",",
"row",
",",
"schema",
")",
":",
"for",
"index",
",",
"field",
"in",
"enumerate",
"(",
"schema",
".",
"fields",
")",
":",
"if",
"field",
".",
"type",
"==",
"'datetime'",
":",
"row",
"[",
"index",
"]",
"=",
"pa... | Restore row from BigQuery | [
"Restore",
"row",
"from",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L127-L137 | train | 60,123 |
frictionlessdata/tableschema-bigquery-py | tableschema_bigquery/mapper.py | Mapper.restore_type | def restore_type(self, type):
"""Restore type from BigQuery
"""
# Mapping
mapping = {
'BOOLEAN': 'boolean',
'DATE': 'date',
'DATETIME': 'datetime',
'INTEGER': 'integer',
'FLOAT': 'number',
'STRING': 'string',
... | python | def restore_type(self, type):
"""Restore type from BigQuery
"""
# Mapping
mapping = {
'BOOLEAN': 'boolean',
'DATE': 'date',
'DATETIME': 'datetime',
'INTEGER': 'integer',
'FLOAT': 'number',
'STRING': 'string',
... | [
"def",
"restore_type",
"(",
"self",
",",
"type",
")",
":",
"# Mapping",
"mapping",
"=",
"{",
"'BOOLEAN'",
":",
"'boolean'",
",",
"'DATE'",
":",
"'date'",
",",
"'DATETIME'",
":",
"'datetime'",
",",
"'INTEGER'",
":",
"'integer'",
",",
"'FLOAT'",
":",
"'numbe... | Restore type from BigQuery | [
"Restore",
"type",
"from",
"BigQuery"
] | aec6f0530ba5a0a08499f5e7a10f2c179c500285 | https://github.com/frictionlessdata/tableschema-bigquery-py/blob/aec6f0530ba5a0a08499f5e7a10f2c179c500285/tableschema_bigquery/mapper.py#L139-L159 | train | 60,124 |
bastikr/boolean.py | boolean/boolean.py | BooleanAlgebra._start_operation | def _start_operation(self, ast, operation, precedence):
"""
Returns an AST where all operations of lower precedence are finalized.
"""
if TRACE_PARSE:
print(' start_operation:', repr(operation), 'AST:', ast)
op_prec = precedence[operation]
while True:
... | python | def _start_operation(self, ast, operation, precedence):
"""
Returns an AST where all operations of lower precedence are finalized.
"""
if TRACE_PARSE:
print(' start_operation:', repr(operation), 'AST:', ast)
op_prec = precedence[operation]
while True:
... | [
"def",
"_start_operation",
"(",
"self",
",",
"ast",
",",
"operation",
",",
"precedence",
")",
":",
"if",
"TRACE_PARSE",
":",
"print",
"(",
"' start_operation:'",
",",
"repr",
"(",
"operation",
")",
",",
"'AST:'",
",",
"ast",
")",
"op_prec",
"=",
"precede... | Returns an AST where all operations of lower precedence are finalized. | [
"Returns",
"an",
"AST",
"where",
"all",
"operations",
"of",
"lower",
"precedence",
"are",
"finalized",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L346-L388 | train | 60,125 |
bastikr/boolean.py | boolean/boolean.py | BooleanAlgebra.tokenize | def tokenize(self, expr):
"""
Return an iterable of 3-tuple describing each token given an expression
unicode string.
This 3-tuple contains (token, token string, position):
- token: either a Symbol instance or one of TOKEN_* token types.
- token string: the original toke... | python | def tokenize(self, expr):
"""
Return an iterable of 3-tuple describing each token given an expression
unicode string.
This 3-tuple contains (token, token string, position):
- token: either a Symbol instance or one of TOKEN_* token types.
- token string: the original toke... | [
"def",
"tokenize",
"(",
"self",
",",
"expr",
")",
":",
"if",
"not",
"isinstance",
"(",
"expr",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"'expr must be string but it is %s.'",
"%",
"type",
"(",
"expr",
")",
")",
"# mapping of lowercase token string... | Return an iterable of 3-tuple describing each token given an expression
unicode string.
This 3-tuple contains (token, token string, position):
- token: either a Symbol instance or one of TOKEN_* token types.
- token string: the original token unicode string.
- position: some sim... | [
"Return",
"an",
"iterable",
"of",
"3",
"-",
"tuple",
"describing",
"each",
"token",
"given",
"an",
"expression",
"unicode",
"string",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L390-L480 | train | 60,126 |
bastikr/boolean.py | boolean/boolean.py | BooleanAlgebra._rdistributive | def _rdistributive(self, expr, op_example):
"""
Recursively flatten the `expr` expression for the `op_example`
AND or OR operation instance exmaple.
"""
if expr.isliteral:
return expr
expr_class = expr.__class__
args = (self._rdistributive(arg, op_ex... | python | def _rdistributive(self, expr, op_example):
"""
Recursively flatten the `expr` expression for the `op_example`
AND or OR operation instance exmaple.
"""
if expr.isliteral:
return expr
expr_class = expr.__class__
args = (self._rdistributive(arg, op_ex... | [
"def",
"_rdistributive",
"(",
"self",
",",
"expr",
",",
"op_example",
")",
":",
"if",
"expr",
".",
"isliteral",
":",
"return",
"expr",
"expr_class",
"=",
"expr",
".",
"__class__",
"args",
"=",
"(",
"self",
".",
"_rdistributive",
"(",
"arg",
",",
"op_exam... | Recursively flatten the `expr` expression for the `op_example`
AND or OR operation instance exmaple. | [
"Recursively",
"flatten",
"the",
"expr",
"expression",
"for",
"the",
"op_example",
"AND",
"or",
"OR",
"operation",
"instance",
"exmaple",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L483-L503 | train | 60,127 |
bastikr/boolean.py | boolean/boolean.py | BooleanAlgebra.normalize | def normalize(self, expr, operation):
"""
Return a normalized expression transformed to its normal form in the
given AND or OR operation.
The new expression arguments will satisfy these conditions:
- operation(*args) == expr (here mathematical equality is meant)
- the op... | python | def normalize(self, expr, operation):
"""
Return a normalized expression transformed to its normal form in the
given AND or OR operation.
The new expression arguments will satisfy these conditions:
- operation(*args) == expr (here mathematical equality is meant)
- the op... | [
"def",
"normalize",
"(",
"self",
",",
"expr",
",",
"operation",
")",
":",
"# ensure that the operation is not NOT",
"assert",
"operation",
"in",
"(",
"self",
".",
"AND",
",",
"self",
".",
"OR",
",",
")",
"# Move NOT inwards.",
"expr",
"=",
"expr",
".",
"lite... | Return a normalized expression transformed to its normal form in the
given AND or OR operation.
The new expression arguments will satisfy these conditions:
- operation(*args) == expr (here mathematical equality is meant)
- the operation does not occur in any of its arg.
- NOT is... | [
"Return",
"a",
"normalized",
"expression",
"transformed",
"to",
"its",
"normal",
"form",
"in",
"the",
"given",
"AND",
"or",
"OR",
"operation",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L505-L527 | train | 60,128 |
bastikr/boolean.py | boolean/boolean.py | Expression.get_literals | def get_literals(self):
"""
Return a list of all the literals contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates.
"""
if self.isliteral:
return [self]
if not self.args:
return []
retur... | python | def get_literals(self):
"""
Return a list of all the literals contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates.
"""
if self.isliteral:
return [self]
if not self.args:
return []
retur... | [
"def",
"get_literals",
"(",
"self",
")",
":",
"if",
"self",
".",
"isliteral",
":",
"return",
"[",
"self",
"]",
"if",
"not",
"self",
".",
"args",
":",
"return",
"[",
"]",
"return",
"list",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"ar... | Return a list of all the literals contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"literals",
"contained",
"in",
"this",
"expression",
".",
"Include",
"recursively",
"subexpressions",
"symbols",
".",
"This",
"includes",
"duplicates",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L576-L586 | train | 60,129 |
bastikr/boolean.py | boolean/boolean.py | Expression.literalize | def literalize(self):
"""
Return an expression where NOTs are only occurring as literals.
Applied recursively to subexpressions.
"""
if self.isliteral:
return self
args = tuple(arg.literalize() for arg in self.args)
if all(arg is self.args[i] for i, ar... | python | def literalize(self):
"""
Return an expression where NOTs are only occurring as literals.
Applied recursively to subexpressions.
"""
if self.isliteral:
return self
args = tuple(arg.literalize() for arg in self.args)
if all(arg is self.args[i] for i, ar... | [
"def",
"literalize",
"(",
"self",
")",
":",
"if",
"self",
".",
"isliteral",
":",
"return",
"self",
"args",
"=",
"tuple",
"(",
"arg",
".",
"literalize",
"(",
")",
"for",
"arg",
"in",
"self",
".",
"args",
")",
"if",
"all",
"(",
"arg",
"is",
"self",
... | Return an expression where NOTs are only occurring as literals.
Applied recursively to subexpressions. | [
"Return",
"an",
"expression",
"where",
"NOTs",
"are",
"only",
"occurring",
"as",
"literals",
".",
"Applied",
"recursively",
"to",
"subexpressions",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L596-L607 | train | 60,130 |
bastikr/boolean.py | boolean/boolean.py | Expression.get_symbols | def get_symbols(self):
"""
Return a list of all the symbols contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates.
"""
return [s if isinstance(s, Symbol) else s.args[0] for s in self.get_literals()] | python | def get_symbols(self):
"""
Return a list of all the symbols contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates.
"""
return [s if isinstance(s, Symbol) else s.args[0] for s in self.get_literals()] | [
"def",
"get_symbols",
"(",
"self",
")",
":",
"return",
"[",
"s",
"if",
"isinstance",
"(",
"s",
",",
"Symbol",
")",
"else",
"s",
".",
"args",
"[",
"0",
"]",
"for",
"s",
"in",
"self",
".",
"get_literals",
"(",
")",
"]"
] | Return a list of all the symbols contained in this expression.
Include recursively subexpressions symbols.
This includes duplicates. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"symbols",
"contained",
"in",
"this",
"expression",
".",
"Include",
"recursively",
"subexpressions",
"symbols",
".",
"This",
"includes",
"duplicates",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L609-L615 | train | 60,131 |
bastikr/boolean.py | boolean/boolean.py | Symbol.pretty | def pretty(self, indent=0, debug=False):
"""
Return a pretty formatted representation of self.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscanonical)
obj = "'%s'" % self.obj if isinstance(self.o... | python | def pretty(self, indent=0, debug=False):
"""
Return a pretty formatted representation of self.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscanonical)
obj = "'%s'" % self.obj if isinstance(self.o... | [
"def",
"pretty",
"(",
"self",
",",
"indent",
"=",
"0",
",",
"debug",
"=",
"False",
")",
":",
"debug_details",
"=",
"''",
"if",
"debug",
":",
"debug_details",
"+=",
"'<isliteral=%r, iscanonical=%r>'",
"%",
"(",
"self",
".",
"isliteral",
",",
"self",
".",
... | Return a pretty formatted representation of self. | [
"Return",
"a",
"pretty",
"formatted",
"representation",
"of",
"self",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L910-L919 | train | 60,132 |
bastikr/boolean.py | boolean/boolean.py | Function.pretty | def pretty(self, indent=0, debug=False):
"""
Return a pretty formatted representation of self as an indented tree.
If debug is True, also prints debug information for each expression arg.
For example:
>>> print Expression().parse(u'not a and not b and not (a and ba and c) and c... | python | def pretty(self, indent=0, debug=False):
"""
Return a pretty formatted representation of self as an indented tree.
If debug is True, also prints debug information for each expression arg.
For example:
>>> print Expression().parse(u'not a and not b and not (a and ba and c) and c... | [
"def",
"pretty",
"(",
"self",
",",
"indent",
"=",
"0",
",",
"debug",
"=",
"False",
")",
":",
"debug_details",
"=",
"''",
"if",
"debug",
":",
"debug_details",
"+=",
"'<isliteral=%r, iscanonical=%r'",
"%",
"(",
"self",
".",
"isliteral",
",",
"self",
".",
"... | Return a pretty formatted representation of self as an indented tree.
If debug is True, also prints debug information for each expression arg.
For example:
>>> print Expression().parse(u'not a and not b and not (a and ba and c) and c or c').pretty()
OR(
AND(
NOT(S... | [
"Return",
"a",
"pretty",
"formatted",
"representation",
"of",
"self",
"as",
"an",
"indented",
"tree",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L960-L1004 | train | 60,133 |
bastikr/boolean.py | boolean/boolean.py | NOT.literalize | def literalize(self):
"""
Return an expression where NOTs are only occurring as literals.
"""
expr = self.demorgan()
if isinstance(expr, self.__class__):
return expr
return expr.literalize() | python | def literalize(self):
"""
Return an expression where NOTs are only occurring as literals.
"""
expr = self.demorgan()
if isinstance(expr, self.__class__):
return expr
return expr.literalize() | [
"def",
"literalize",
"(",
"self",
")",
":",
"expr",
"=",
"self",
".",
"demorgan",
"(",
")",
"if",
"isinstance",
"(",
"expr",
",",
"self",
".",
"__class__",
")",
":",
"return",
"expr",
"return",
"expr",
".",
"literalize",
"(",
")"
] | Return an expression where NOTs are only occurring as literals. | [
"Return",
"an",
"expression",
"where",
"NOTs",
"are",
"only",
"occurring",
"as",
"literals",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1031-L1038 | train | 60,134 |
bastikr/boolean.py | boolean/boolean.py | NOT.simplify | def simplify(self):
"""
Return a simplified expr in canonical form.
This means double negations are canceled out and all contained boolean
objects are in their canonical form.
"""
if self.iscanonical:
return self
expr = self.cancel()
if not i... | python | def simplify(self):
"""
Return a simplified expr in canonical form.
This means double negations are canceled out and all contained boolean
objects are in their canonical form.
"""
if self.iscanonical:
return self
expr = self.cancel()
if not i... | [
"def",
"simplify",
"(",
"self",
")",
":",
"if",
"self",
".",
"iscanonical",
":",
"return",
"self",
"expr",
"=",
"self",
".",
"cancel",
"(",
")",
"if",
"not",
"isinstance",
"(",
"expr",
",",
"self",
".",
"__class__",
")",
":",
"return",
"expr",
".",
... | Return a simplified expr in canonical form.
This means double negations are canceled out and all contained boolean
objects are in their canonical form. | [
"Return",
"a",
"simplified",
"expr",
"in",
"canonical",
"form",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1040-L1059 | train | 60,135 |
bastikr/boolean.py | boolean/boolean.py | NOT.cancel | def cancel(self):
"""
Cancel itself and following NOTs as far as possible.
Returns the simplified expression.
"""
expr = self
while True:
arg = expr.args[0]
if not isinstance(arg, self.__class__):
return expr
expr = arg.... | python | def cancel(self):
"""
Cancel itself and following NOTs as far as possible.
Returns the simplified expression.
"""
expr = self
while True:
arg = expr.args[0]
if not isinstance(arg, self.__class__):
return expr
expr = arg.... | [
"def",
"cancel",
"(",
"self",
")",
":",
"expr",
"=",
"self",
"while",
"True",
":",
"arg",
"=",
"expr",
".",
"args",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"return",
"expr",
"expr",
"=",
"arg... | Cancel itself and following NOTs as far as possible.
Returns the simplified expression. | [
"Cancel",
"itself",
"and",
"following",
"NOTs",
"as",
"far",
"as",
"possible",
".",
"Returns",
"the",
"simplified",
"expression",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1061-L1073 | train | 60,136 |
bastikr/boolean.py | boolean/boolean.py | NOT.demorgan | def demorgan(self):
"""
Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws.
"""
expr = self.cancel()
if expr.isliteral or not isinstance(expr, self.NOT):
return expr
op = expr.args[0... | python | def demorgan(self):
"""
Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws.
"""
expr = self.cancel()
if expr.isliteral or not isinstance(expr, self.NOT):
return expr
op = expr.args[0... | [
"def",
"demorgan",
"(",
"self",
")",
":",
"expr",
"=",
"self",
".",
"cancel",
"(",
")",
"if",
"expr",
".",
"isliteral",
"or",
"not",
"isinstance",
"(",
"expr",
",",
"self",
".",
"NOT",
")",
":",
"return",
"expr",
"op",
"=",
"expr",
".",
"args",
"... | Return a expr where the NOT function is moved inward.
This is achieved by canceling double NOTs and using De Morgan laws. | [
"Return",
"a",
"expr",
"where",
"the",
"NOT",
"function",
"is",
"moved",
"inward",
".",
"This",
"is",
"achieved",
"by",
"canceling",
"double",
"NOTs",
"and",
"using",
"De",
"Morgan",
"laws",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1075-L1084 | train | 60,137 |
bastikr/boolean.py | boolean/boolean.py | NOT.pretty | def pretty(self, indent=1, debug=False):
"""
Return a pretty formatted representation of self.
Include additional debug details if `debug` is True.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscan... | python | def pretty(self, indent=1, debug=False):
"""
Return a pretty formatted representation of self.
Include additional debug details if `debug` is True.
"""
debug_details = ''
if debug:
debug_details += '<isliteral=%r, iscanonical=%r>' % (self.isliteral, self.iscan... | [
"def",
"pretty",
"(",
"self",
",",
"indent",
"=",
"1",
",",
"debug",
"=",
"False",
")",
":",
"debug_details",
"=",
"''",
"if",
"debug",
":",
"debug_details",
"+=",
"'<isliteral=%r, iscanonical=%r>'",
"%",
"(",
"self",
".",
"isliteral",
",",
"self",
".",
... | Return a pretty formatted representation of self.
Include additional debug details if `debug` is True. | [
"Return",
"a",
"pretty",
"formatted",
"representation",
"of",
"self",
".",
"Include",
"additional",
"debug",
"details",
"if",
"debug",
"is",
"True",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1089-L1101 | train | 60,138 |
bastikr/boolean.py | boolean/boolean.py | DualBase.simplify | def simplify(self):
"""
Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilati... | python | def simplify(self):
"""
Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilati... | [
"def",
"simplify",
"(",
"self",
")",
":",
"# TODO: Refactor DualBase.simplify into different \"sub-evals\".",
"# If self is already canonical do nothing.",
"if",
"self",
".",
"iscanonical",
":",
"return",
"self",
"# Otherwise bring arguments into canonical form.",
"args",
"=",
"[... | Return a new simplified expression in canonical form from this
expression.
For simplification of AND and OR fthe ollowing rules are used
recursively bottom up:
- Associativity (output does not contain same operations nested)
- Annihilation
- Idempotence
- Ide... | [
"Return",
"a",
"new",
"simplified",
"expression",
"in",
"canonical",
"form",
"from",
"this",
"expression",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1138-L1262 | train | 60,139 |
bastikr/boolean.py | boolean/boolean.py | DualBase.flatten | def flatten(self):
"""
Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C.
"""
args = list(self.args)
i = 0
for arg in self.args:
if isinstance(arg, self.__class__... | python | def flatten(self):
"""
Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C.
"""
args = list(self.args)
i = 0
for arg in self.args:
if isinstance(arg, self.__class__... | [
"def",
"flatten",
"(",
"self",
")",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"i",
"=",
"0",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"args",
"[",
"i",... | Return a new expression where nested terms of this expression are
flattened as far as possible.
E.g. A & (B & C) becomes A & B & C. | [
"Return",
"a",
"new",
"expression",
"where",
"nested",
"terms",
"of",
"this",
"expression",
"are",
"flattened",
"as",
"far",
"as",
"possible",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1264-L1280 | train | 60,140 |
bastikr/boolean.py | boolean/boolean.py | DualBase.absorb | def absorb(self, args):
"""
Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A |... | python | def absorb(self, args):
"""
Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A |... | [
"def",
"absorb",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"if",
"not",
"args",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"args",
")",
":",
"absorbe... | Given an `args` sequence of expressions, return a new list of expression
applying absorption and negative absorption.
See https://en.wikipedia.org/wiki/Absorption_law
Absorption: A & (A | B) = A, A | (A & B) = A
Negative absorption: A & (~A | B) = A & B, A | (~A & B) = A | B | [
"Given",
"an",
"args",
"sequence",
"of",
"expressions",
"return",
"a",
"new",
"list",
"of",
"expression",
"applying",
"absorption",
"and",
"negative",
"absorption",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1282-L1349 | train | 60,141 |
bastikr/boolean.py | boolean/boolean.py | DualBase.subtract | def subtract(self, expr, simplify):
"""
Return a new expression where the `expr` expression has been removed
from this expression if it exists.
"""
args = self.args
if expr in self.args:
args = list(self.args)
args.remove(expr)
elif isinsta... | python | def subtract(self, expr, simplify):
"""
Return a new expression where the `expr` expression has been removed
from this expression if it exists.
"""
args = self.args
if expr in self.args:
args = list(self.args)
args.remove(expr)
elif isinsta... | [
"def",
"subtract",
"(",
"self",
",",
"expr",
",",
"simplify",
")",
":",
"args",
"=",
"self",
".",
"args",
"if",
"expr",
"in",
"self",
".",
"args",
":",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"args",
".",
"remove",
"(",
"expr",
")",
... | Return a new expression where the `expr` expression has been removed
from this expression if it exists. | [
"Return",
"a",
"new",
"expression",
"where",
"the",
"expr",
"expression",
"has",
"been",
"removed",
"from",
"this",
"expression",
"if",
"it",
"exists",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1351-L1371 | train | 60,142 |
bastikr/boolean.py | boolean/boolean.py | DualBase.distributive | def distributive(self):
"""
Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C)
"""
dual = self.dual
args = list(self.args)
for i... | python | def distributive(self):
"""
Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C)
"""
dual = self.dual
args = list(self.args)
for i... | [
"def",
"distributive",
"(",
"self",
")",
":",
"dual",
"=",
"self",
".",
"dual",
"args",
"=",
"list",
"(",
"self",
".",
"args",
")",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"args",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dual",
")"... | Return a term where the leading AND or OR terms are switched.
This is done by applying the distributive laws:
A & (B|C) = (A&B) | (A&C)
A | (B&C) = (A|B) & (A|C) | [
"Return",
"a",
"term",
"where",
"the",
"leading",
"AND",
"or",
"OR",
"terms",
"are",
"switched",
"."
] | e984df480afc60605e9501a0d3d54d667e8f7dbf | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L1373-L1395 | train | 60,143 |
IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.ages | def ages(self):
"""The age range that the user is interested in."""
match = self._ages_re.match(self.raw_fields.get('ages'))
if not match:
match = self._ages_re2.match(self.raw_fields.get('ages'))
return self.Ages(int(match.group(1)),int(match.group(1)))
return se... | python | def ages(self):
"""The age range that the user is interested in."""
match = self._ages_re.match(self.raw_fields.get('ages'))
if not match:
match = self._ages_re2.match(self.raw_fields.get('ages'))
return self.Ages(int(match.group(1)),int(match.group(1)))
return se... | [
"def",
"ages",
"(",
"self",
")",
":",
"match",
"=",
"self",
".",
"_ages_re",
".",
"match",
"(",
"self",
".",
"raw_fields",
".",
"get",
"(",
"'ages'",
")",
")",
"if",
"not",
"match",
":",
"match",
"=",
"self",
".",
"_ages_re2",
".",
"match",
"(",
... | The age range that the user is interested in. | [
"The",
"age",
"range",
"that",
"the",
"user",
"is",
"interested",
"in",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L68-L74 | train | 60,144 |
IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.single | def single(self):
"""Whether or not the user is only interested in people that are single.
"""
return 'display: none;' not in self._looking_for_xpb.li(id='ajax_single').\
one_(self._profile.profile_tree).attrib['style'] | python | def single(self):
"""Whether or not the user is only interested in people that are single.
"""
return 'display: none;' not in self._looking_for_xpb.li(id='ajax_single').\
one_(self._profile.profile_tree).attrib['style'] | [
"def",
"single",
"(",
"self",
")",
":",
"return",
"'display: none;'",
"not",
"in",
"self",
".",
"_looking_for_xpb",
".",
"li",
"(",
"id",
"=",
"'ajax_single'",
")",
".",
"one_",
"(",
"self",
".",
"_profile",
".",
"profile_tree",
")",
".",
"attrib",
"[",
... | Whether or not the user is only interested in people that are single. | [
"Whether",
"or",
"not",
"the",
"user",
"is",
"only",
"interested",
"in",
"people",
"that",
"are",
"single",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L77-L81 | train | 60,145 |
IvanMalison/okcupyd | okcupyd/looking_for.py | LookingFor.update | def update(self, ages=None, single=None, near_me=None, kinds=None,
gentation=None):
"""Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only... | python | def update(self, ages=None, single=None, near_me=None, kinds=None,
gentation=None):
"""Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only... | [
"def",
"update",
"(",
"self",
",",
"ages",
"=",
"None",
",",
"single",
"=",
"None",
",",
"near_me",
"=",
"None",
",",
"kinds",
"=",
"None",
",",
"gentation",
"=",
"None",
")",
":",
"ages",
"=",
"ages",
"or",
"self",
".",
"ages",
"single",
"=",
"s... | Update the looking for attributes of the logged in user.
:param ages: The ages that the logged in user is interested in.
:type ages: tuple
:param single: Whether or not the user is only interested in people that
are single.
:type single: bool
:param near_m... | [
"Update",
"the",
"looking",
"for",
"attributes",
"of",
"the",
"logged",
"in",
"user",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/looking_for.py#L95-L140 | train | 60,146 |
IvanMalison/okcupyd | okcupyd/photo.py | PhotoUploader.upload_and_confirm | def upload_and_confirm(self, incoming, **kwargs):
"""Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If... | python | def upload_and_confirm(self, incoming, **kwargs):
"""Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If... | [
"def",
"upload_and_confirm",
"(",
"self",
",",
"incoming",
",",
"*",
"*",
"kwargs",
")",
":",
"response_dict",
"=",
"self",
".",
"upload",
"(",
"incoming",
")",
"if",
"'error'",
"in",
"response_dict",
":",
"log",
".",
"warning",
"(",
"'Failed to upload photo... | Upload the file to okcupid and confirm, among other things, its
thumbnail position.
:param incoming: A filepath string, :class:`.Info` object or
a file like object to upload to okcupid.com.
If an info object is provided, its thumbnail
... | [
"Upload",
"the",
"file",
"to",
"okcupid",
"and",
"confirm",
"among",
"other",
"things",
"its",
"thumbnail",
"position",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/photo.py#L99-L125 | train | 60,147 |
IvanMalison/okcupyd | okcupyd/photo.py | PhotoUploader.delete | def delete(self, photo_id, album_id=0):
"""Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo.
"""
if isinstance(photo_id, Info):
photo_id = photo_id.id
... | python | def delete(self, photo_id, album_id=0):
"""Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo.
"""
if isinstance(photo_id, Info):
photo_id = photo_id.id
... | [
"def",
"delete",
"(",
"self",
",",
"photo_id",
",",
"album_id",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"photo_id",
",",
"Info",
")",
":",
"photo_id",
"=",
"photo_id",
".",
"id",
"return",
"self",
".",
"_session",
".",
"okc_post",
"(",
"'photouplo... | Delete a photo from the logged in users account.
:param photo_id: The okcupid id of the photo to delete.
:param album_id: The album from which to delete the photo. | [
"Delete",
"a",
"photo",
"from",
"the",
"logged",
"in",
"users",
"account",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/photo.py#L127-L140 | train | 60,148 |
aaugustin/django-pymssql | sqlserver_pymssql/base.py | DatabaseWrapper.__get_dbms_version | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True.
"""
if not self.connection and make_connection:
... | python | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True.
"""
if not self.connection and make_connection:
... | [
"def",
"__get_dbms_version",
"(",
"self",
",",
"make_connection",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"connection",
"and",
"make_connection",
":",
"self",
".",
"connect",
"(",
")",
"with",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
... | Returns the 'DBMS Version' string, or ''. If a connection to the
database has not already been established, a connection will be made
when `make_connection` is True. | [
"Returns",
"the",
"DBMS",
"Version",
"string",
"or",
".",
"If",
"a",
"connection",
"to",
"the",
"database",
"has",
"not",
"already",
"been",
"established",
"a",
"connection",
"will",
"be",
"made",
"when",
"make_connection",
"is",
"True",
"."
] | a99ca2f63fd67bc6855340ecb51dbe4f35f6bd06 | https://github.com/aaugustin/django-pymssql/blob/a99ca2f63fd67bc6855340ecb51dbe4f35f6bd06/sqlserver_pymssql/base.py#L136-L146 | train | 60,149 |
IvanMalison/okcupyd | okcupyd/question.py | Questions.respond_from_user_question | def respond_from_user_question(self, user_question, importance):
"""Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The ... | python | def respond_from_user_question(self, user_question, importance):
"""Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The ... | [
"def",
"respond_from_user_question",
"(",
"self",
",",
"user_question",
",",
"importance",
")",
":",
"user_response_ids",
"=",
"[",
"option",
".",
"id",
"for",
"option",
"in",
"user_question",
".",
"answer_options",
"if",
"option",
".",
"is_users",
"]",
"match_r... | Respond to a question in exactly the way that is described by
the given user_question.
:param user_question: The user question to respond with.
:type user_question: :class:`.UserQuestion`
:param importance: The importance that should be used in responding to
t... | [
"Respond",
"to",
"a",
"question",
"in",
"exactly",
"the",
"way",
"that",
"is",
"described",
"by",
"the",
"given",
"user_question",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/question.py#L298-L318 | train | 60,150 |
IvanMalison/okcupyd | okcupyd/question.py | Questions.respond_from_question | def respond_from_question(self, question, user_question, importance):
"""Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
... | python | def respond_from_question(self, question, user_question, importance):
"""Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
... | [
"def",
"respond_from_question",
"(",
"self",
",",
"question",
",",
"user_question",
",",
"importance",
")",
":",
"option_index",
"=",
"user_question",
".",
"answer_text_to_option",
"[",
"question",
".",
"their_answer",
"]",
".",
"id",
"self",
".",
"respond",
"("... | Copy the answer given in `question` to the logged in user's
profile.
:param question: A :class:`~.Question` instance to copy.
:param user_question: An instance of :class:`~.UserQuestion` that
corresponds to the same question as `question`.
... | [
"Copy",
"the",
"answer",
"given",
"in",
"question",
"to",
"the",
"logged",
"in",
"user",
"s",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/question.py#L320-L335 | train | 60,151 |
IvanMalison/okcupyd | okcupyd/user.py | User.message | def message(self, username, message_text):
"""Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
... | python | def message(self, username, message_text):
"""Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
... | [
"def",
"message",
"(",
"self",
",",
"username",
",",
"message_text",
")",
":",
"# Try to reply to an existing thread.",
"if",
"not",
"isinstance",
"(",
"username",
",",
"six",
".",
"string_types",
")",
":",
"username",
"=",
"username",
".",
"username",
"for",
... | Message an okcupid user. If an existing conversation between the
logged in user and the target user can be found, reply to that thread
instead of starting a new one.
:param username: The username of the user to which the message should
be sent.
:type username: s... | [
"Message",
"an",
"okcupid",
"user",
".",
"If",
"an",
"existing",
"conversation",
"between",
"the",
"logged",
"in",
"user",
"and",
"the",
"target",
"user",
"can",
"be",
"found",
"reply",
"to",
"that",
"thread",
"instead",
"of",
"starting",
"a",
"new",
"one"... | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/user.py#L117-L137 | train | 60,152 |
IvanMalison/okcupyd | okcupyd/user.py | User.get_question_answer_id | def get_question_answer_id(self, question, fast=False,
bust_questions_cache=False):
"""Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:pa... | python | def get_question_answer_id(self, question, fast=False,
bust_questions_cache=False):
"""Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:pa... | [
"def",
"get_question_answer_id",
"(",
"self",
",",
"question",
",",
"fast",
"=",
"False",
",",
"bust_questions_cache",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"question",
",",
"'answer_id'",
")",
":",
"# Guard to handle incoming user_question.",
"return",
"q... | Get the index of the answer that was given to `question`
See the documentation for :meth:`~.get_user_question` for important
caveats about the use of this function.
:param question: The question whose `answer_id` should be retrieved.
:type question: :class:`~okcupyd.question.BaseQuesti... | [
"Get",
"the",
"index",
"of",
"the",
"answer",
"that",
"was",
"given",
"to",
"question"
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/user.py#L243-L272 | train | 60,153 |
IvanMalison/okcupyd | okcupyd/helpers.py | update_looking_for | def update_looking_for(profile_tree, looking_for):
"""
Update looking_for attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'what_i_want']")[0]
looking_for['gentation'] = div.xpath(".//li[@id = 'ajax_gentation']/text()")[0].strip()
looking_for['ages'] = replace_chars(div.xpath(".... | python | def update_looking_for(profile_tree, looking_for):
"""
Update looking_for attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'what_i_want']")[0]
looking_for['gentation'] = div.xpath(".//li[@id = 'ajax_gentation']/text()")[0].strip()
looking_for['ages'] = replace_chars(div.xpath(".... | [
"def",
"update_looking_for",
"(",
"profile_tree",
",",
"looking_for",
")",
":",
"div",
"=",
"profile_tree",
".",
"xpath",
"(",
"\"//div[@id = 'what_i_want']\"",
")",
"[",
"0",
"]",
"looking_for",
"[",
"'gentation'",
"]",
"=",
"div",
".",
"xpath",
"(",
"\".//li... | Update looking_for attribute of a Profile. | [
"Update",
"looking_for",
"attribute",
"of",
"a",
"Profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L237-L249 | train | 60,154 |
IvanMalison/okcupyd | okcupyd/helpers.py | update_details | def update_details(profile_tree, details):
"""
Update details attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'profile_details']")[0]
for dl in div.iter('dl'):
title = dl.find('dt').text
item = dl.find('dd')
if title == 'Last Online' and item.find('span') is... | python | def update_details(profile_tree, details):
"""
Update details attribute of a Profile.
"""
div = profile_tree.xpath("//div[@id = 'profile_details']")[0]
for dl in div.iter('dl'):
title = dl.find('dt').text
item = dl.find('dd')
if title == 'Last Online' and item.find('span') is... | [
"def",
"update_details",
"(",
"profile_tree",
",",
"details",
")",
":",
"div",
"=",
"profile_tree",
".",
"xpath",
"(",
"\"//div[@id = 'profile_details']\"",
")",
"[",
"0",
"]",
"for",
"dl",
"in",
"div",
".",
"iter",
"(",
"'dl'",
")",
":",
"title",
"=",
"... | Update details attribute of a Profile. | [
"Update",
"details",
"attribute",
"of",
"a",
"Profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L252-L266 | train | 60,155 |
IvanMalison/okcupyd | okcupyd/helpers.py | get_default_gentation | def get_default_gentation(gender, orientation):
"""Return the default gentation for the given gender and orientation."""
gender = gender.lower()[0]
orientation = orientation.lower()
return gender_to_orientation_to_gentation[gender][orientation] | python | def get_default_gentation(gender, orientation):
"""Return the default gentation for the given gender and orientation."""
gender = gender.lower()[0]
orientation = orientation.lower()
return gender_to_orientation_to_gentation[gender][orientation] | [
"def",
"get_default_gentation",
"(",
"gender",
",",
"orientation",
")",
":",
"gender",
"=",
"gender",
".",
"lower",
"(",
")",
"[",
"0",
"]",
"orientation",
"=",
"orientation",
".",
"lower",
"(",
")",
"return",
"gender_to_orientation_to_gentation",
"[",
"gender... | Return the default gentation for the given gender and orientation. | [
"Return",
"the",
"default",
"gentation",
"for",
"the",
"given",
"gender",
"and",
"orientation",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/helpers.py#L288-L292 | train | 60,156 |
IvanMalison/okcupyd | okcupyd/db/mailbox.py | Sync.update_mailbox | def update_mailbox(self, mailbox_name='inbox'):
"""Update the mailbox associated with the given mailbox name.
"""
with txn() as session:
last_updated_name = '{0}_last_updated'.format(mailbox_name)
okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter(
... | python | def update_mailbox(self, mailbox_name='inbox'):
"""Update the mailbox associated with the given mailbox name.
"""
with txn() as session:
last_updated_name = '{0}_last_updated'.format(mailbox_name)
okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter(
... | [
"def",
"update_mailbox",
"(",
"self",
",",
"mailbox_name",
"=",
"'inbox'",
")",
":",
"with",
"txn",
"(",
")",
"as",
"session",
":",
"last_updated_name",
"=",
"'{0}_last_updated'",
".",
"format",
"(",
"mailbox_name",
")",
"okcupyd_user",
"=",
"session",
".",
... | Update the mailbox associated with the given mailbox name. | [
"Update",
"the",
"mailbox",
"associated",
"with",
"the",
"given",
"mailbox",
"name",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/db/mailbox.py#L25-L49 | train | 60,157 |
IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.photos | def photos(self):
"""Copy photos to the destination user."""
# Reverse because pictures appear in inverse chronological order.
for photo_info in self.dest_user.profile.photo_infos:
self.dest_user.photo.delete(photo_info)
return [self.dest_user.photo.upload_and_confirm(info)
... | python | def photos(self):
"""Copy photos to the destination user."""
# Reverse because pictures appear in inverse chronological order.
for photo_info in self.dest_user.profile.photo_infos:
self.dest_user.photo.delete(photo_info)
return [self.dest_user.photo.upload_and_confirm(info)
... | [
"def",
"photos",
"(",
"self",
")",
":",
"# Reverse because pictures appear in inverse chronological order.",
"for",
"photo_info",
"in",
"self",
".",
"dest_user",
".",
"profile",
".",
"photo_infos",
":",
"self",
".",
"dest_user",
".",
"photo",
".",
"delete",
"(",
"... | Copy photos to the destination user. | [
"Copy",
"photos",
"to",
"the",
"destination",
"user",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L107-L113 | train | 60,158 |
IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.essays | def essays(self):
"""Copy essays from the source profile to the destination profile."""
for essay_name in self.dest_user.profile.essays.essay_names:
setattr(self.dest_user.profile.essays, essay_name,
getattr(self.source_profile.essays, essay_name)) | python | def essays(self):
"""Copy essays from the source profile to the destination profile."""
for essay_name in self.dest_user.profile.essays.essay_names:
setattr(self.dest_user.profile.essays, essay_name,
getattr(self.source_profile.essays, essay_name)) | [
"def",
"essays",
"(",
"self",
")",
":",
"for",
"essay_name",
"in",
"self",
".",
"dest_user",
".",
"profile",
".",
"essays",
".",
"essay_names",
":",
"setattr",
"(",
"self",
".",
"dest_user",
".",
"profile",
".",
"essays",
",",
"essay_name",
",",
"getattr... | Copy essays from the source profile to the destination profile. | [
"Copy",
"essays",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L115-L119 | train | 60,159 |
IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.looking_for | def looking_for(self):
"""Copy looking for attributes from the source profile to the
destination profile.
"""
looking_for = self.source_profile.looking_for
return self.dest_user.profile.looking_for.update(
gentation=looking_for.gentation,
single=looking_fo... | python | def looking_for(self):
"""Copy looking for attributes from the source profile to the
destination profile.
"""
looking_for = self.source_profile.looking_for
return self.dest_user.profile.looking_for.update(
gentation=looking_for.gentation,
single=looking_fo... | [
"def",
"looking_for",
"(",
"self",
")",
":",
"looking_for",
"=",
"self",
".",
"source_profile",
".",
"looking_for",
"return",
"self",
".",
"dest_user",
".",
"profile",
".",
"looking_for",
".",
"update",
"(",
"gentation",
"=",
"looking_for",
".",
"gentation",
... | Copy looking for attributes from the source profile to the
destination profile. | [
"Copy",
"looking",
"for",
"attributes",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L121-L132 | train | 60,160 |
IvanMalison/okcupyd | okcupyd/profile_copy.py | Copy.details | def details(self):
"""Copy details from the source profile to the destination profile."""
return self.dest_user.profile.details.convert_and_update(
self.source_profile.details.as_dict
) | python | def details(self):
"""Copy details from the source profile to the destination profile."""
return self.dest_user.profile.details.convert_and_update(
self.source_profile.details.as_dict
) | [
"def",
"details",
"(",
"self",
")",
":",
"return",
"self",
".",
"dest_user",
".",
"profile",
".",
"details",
".",
"convert_and_update",
"(",
"self",
".",
"source_profile",
".",
"details",
".",
"as_dict",
")"
] | Copy details from the source profile to the destination profile. | [
"Copy",
"details",
"from",
"the",
"source",
"profile",
"to",
"the",
"destination",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile_copy.py#L134-L138 | train | 60,161 |
IvanMalison/okcupyd | okcupyd/profile.py | Profile.message | def message(self, message, thread_id=None):
"""Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any.
"""
return_value = helpers.Messager(self._session).send(
self... | python | def message(self, message, thread_id=None):
"""Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any.
"""
return_value = helpers.Messager(self._session).send(
self... | [
"def",
"message",
"(",
"self",
",",
"message",
",",
"thread_id",
"=",
"None",
")",
":",
"return_value",
"=",
"helpers",
".",
"Messager",
"(",
"self",
".",
"_session",
")",
".",
"send",
"(",
"self",
".",
"username",
",",
"message",
",",
"self",
".",
"... | Message the user associated with this profile.
:param message: The message to send to this user.
:param thread_id: The id of the thread to respond to, if any. | [
"Message",
"the",
"user",
"associated",
"with",
"this",
"profile",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile.py#L284-L294 | train | 60,162 |
IvanMalison/okcupyd | okcupyd/profile.py | Profile.rate | def rate(self, rating):
"""Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user.
"""
parameters = {
'voterid': self._current_user_id,
'target_userid': self.id... | python | def rate(self, rating):
"""Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user.
"""
parameters = {
'voterid': self._current_user_id,
'target_userid': self.id... | [
"def",
"rate",
"(",
"self",
",",
"rating",
")",
":",
"parameters",
"=",
"{",
"'voterid'",
":",
"self",
".",
"_current_user_id",
",",
"'target_userid'",
":",
"self",
".",
"id",
",",
"'type'",
":",
"'vote'",
",",
"'cf'",
":",
"'profile2'",
",",
"'target_ob... | Rate this profile as the user that was logged in with the session
that this object was instantiated with.
:param rating: The rating to give this user. | [
"Rate",
"this",
"profile",
"as",
"the",
"user",
"that",
"was",
"logged",
"in",
"with",
"the",
"session",
"that",
"this",
"object",
"was",
"instantiated",
"with",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/profile.py#L318-L341 | train | 60,163 |
IvanMalison/okcupyd | okcupyd/util/currying.py | curry.arity_evaluation_checker | def arity_evaluation_checker(function):
"""Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for.
"""
is_class = inspect.isclass(function)
if is_class:
function = function.__init__
functio... | python | def arity_evaluation_checker(function):
"""Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for.
"""
is_class = inspect.isclass(function)
if is_class:
function = function.__init__
functio... | [
"def",
"arity_evaluation_checker",
"(",
"function",
")",
":",
"is_class",
"=",
"inspect",
".",
"isclass",
"(",
"function",
")",
"if",
"is_class",
":",
"function",
"=",
"function",
".",
"__init__",
"function_info",
"=",
"inspect",
".",
"getargspec",
"(",
"funct... | Build an evaluation checker that will return True when it is
guaranteed that all positional arguments have been accounted for. | [
"Build",
"an",
"evaluation",
"checker",
"that",
"will",
"return",
"True",
"when",
"it",
"is",
"guaranteed",
"that",
"all",
"positional",
"arguments",
"have",
"been",
"accounted",
"for",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/okcupyd/util/currying.py#L90-L119 | train | 60,164 |
IvanMalison/okcupyd | tasks.py | rerecord | def rerecord(ctx, rest):
"""Rerecord tests."""
run('tox -e py27 -- --cassette-mode all --record --credentials {0} -s'
.format(rest), pty=True)
run('tox -e py27 -- --resave --scrub --credentials test_credentials {0} -s'
.format(rest), pty=True) | python | def rerecord(ctx, rest):
"""Rerecord tests."""
run('tox -e py27 -- --cassette-mode all --record --credentials {0} -s'
.format(rest), pty=True)
run('tox -e py27 -- --resave --scrub --credentials test_credentials {0} -s'
.format(rest), pty=True) | [
"def",
"rerecord",
"(",
"ctx",
",",
"rest",
")",
":",
"run",
"(",
"'tox -e py27 -- --cassette-mode all --record --credentials {0} -s'",
".",
"format",
"(",
"rest",
")",
",",
"pty",
"=",
"True",
")",
"run",
"(",
"'tox -e py27 -- --resave --scrub --credentials test_creden... | Rerecord tests. | [
"Rerecord",
"tests",
"."
] | 46f4eaa9419098f6c299738ce148af55c64deb64 | https://github.com/IvanMalison/okcupyd/blob/46f4eaa9419098f6c299738ce148af55c64deb64/tasks.py#L31-L36 | train | 60,165 |
dixudx/rtcclient | rtcclient/query.py | Query.runSavedQueryByUrl | def runSavedQueryByUrl(self, saved_query_url, returned_properties=None):
"""Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more ... | python | def runSavedQueryByUrl(self, saved_query_url, returned_properties=None):
"""Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more ... | [
"def",
"runSavedQueryByUrl",
"(",
"self",
",",
"saved_query_url",
",",
"returned_properties",
"=",
"None",
")",
":",
"try",
":",
"if",
"\"=\"",
"not",
"in",
"saved_query_url",
":",
"raise",
"exception",
".",
"BadValue",
"(",
")",
"saved_query_id",
"=",
"saved_... | Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`list` that contains the queried
... | [
"Query",
"workitems",
"using",
"the",
"saved",
"query",
"url"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/query.py#L184-L206 | train | 60,166 |
dixudx/rtcclient | rtcclient/query.py | Query.runSavedQueryByID | def runSavedQueryByID(self, saved_query_id, returned_properties=None):
"""Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
... | python | def runSavedQueryByID(self, saved_query_id, returned_properties=None):
"""Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
... | [
"def",
"runSavedQueryByID",
"(",
"self",
",",
"saved_query_id",
",",
"returned_properties",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"saved_query_id",
",",
"six",
".",
"string_types",
")",
"or",
"not",
"saved_query_id",
":",
"excp_msg",
"=",
"\"P... | Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
https://myrtc:9443/jazz/web/xxx#action=xxxx%id=_mGYe0CWgEeGofp83pg),
w... | [
"Query",
"workitems",
"using",
"the",
"saved",
"query",
"id"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/query.py#L208-L234 | train | 60,167 |
dixudx/rtcclient | rtcclient/base.py | RTCBase.put | def put(self, url, data=None, verify=False,
headers=None, proxies=None, timeout=60, **kwargs):
"""Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
sen... | python | def put(self, url, data=None, verify=False,
headers=None, proxies=None, timeout=60, **kwargs):
"""Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
sen... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"verify",
"=",
"False",
",",
"headers",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"timeout",
"=",
"60",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
".",
"debu... | Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
send in the body of the :class:`Request`.
:param verify: (optional) if ``True``, the SSL cert will be verified.
... | [
"Sends",
"a",
"PUT",
"request",
".",
"Refactor",
"from",
"requests",
"module"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L127-L159 | train | 60,168 |
dixudx/rtcclient | rtcclient/base.py | RTCBase.validate_url | def validate_url(cls, url):
"""Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string
"""
if url is None:
return None
url = url.strip()
while url.endswith('/'):
url = ... | python | def validate_url(cls, url):
"""Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string
"""
if url is None:
return None
url = url.strip()
while url.endswith('/'):
url = ... | [
"def",
"validate_url",
"(",
"cls",
",",
"url",
")",
":",
"if",
"url",
"is",
"None",
":",
"return",
"None",
"url",
"=",
"url",
".",
"strip",
"(",
")",
"while",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
":",
"-",
"1",
... | Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string | [
"Strip",
"and",
"trailing",
"slash",
"to",
"validate",
"a",
"url"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L198-L212 | train | 60,169 |
dixudx/rtcclient | rtcclient/base.py | FieldBase._initialize | def _initialize(self):
"""Initialize the object from the request"""
self.log.debug("Start initializing data from %s",
self.url)
resp = self.get(self.url,
verify=False,
proxies=self.rtc_obj.proxies,
he... | python | def _initialize(self):
"""Initialize the object from the request"""
self.log.debug("Start initializing data from %s",
self.url)
resp = self.get(self.url,
verify=False,
proxies=self.rtc_obj.proxies,
he... | [
"def",
"_initialize",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Start initializing data from %s\"",
",",
"self",
".",
"url",
")",
"resp",
"=",
"self",
".",
"get",
"(",
"self",
".",
"url",
",",
"verify",
"=",
"False",
",",
"proxie... | Initialize the object from the request | [
"Initialize",
"the",
"object",
"from",
"the",
"request"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L236-L247 | train | 60,170 |
dixudx/rtcclient | rtcclient/base.py | FieldBase.__initialize | def __initialize(self, resp):
"""Initialize from the response"""
raw_data = xmltodict.parse(resp.content)
root_key = list(raw_data.keys())[0]
self.raw_data = raw_data.get(root_key)
self.__initializeFromRaw() | python | def __initialize(self, resp):
"""Initialize from the response"""
raw_data = xmltodict.parse(resp.content)
root_key = list(raw_data.keys())[0]
self.raw_data = raw_data.get(root_key)
self.__initializeFromRaw() | [
"def",
"__initialize",
"(",
"self",
",",
"resp",
")",
":",
"raw_data",
"=",
"xmltodict",
".",
"parse",
"(",
"resp",
".",
"content",
")",
"root_key",
"=",
"list",
"(",
"raw_data",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"self",
".",
"raw_data",
"... | Initialize from the response | [
"Initialize",
"from",
"the",
"response"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/base.py#L249-L255 | train | 60,171 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.getTemplate | def getTemplate(self, copied_from, template_name=None,
template_folder=None, keep=False, encoding="UTF-8"):
"""Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate`
"""
return self.templ... | python | def getTemplate(self, copied_from, template_name=None,
template_folder=None, keep=False, encoding="UTF-8"):
"""Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate`
"""
return self.templ... | [
"def",
"getTemplate",
"(",
"self",
",",
"copied_from",
",",
"template_name",
"=",
"None",
",",
"template_folder",
"=",
"None",
",",
"keep",
"=",
"False",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
":",
"return",
"self",
".",
"templater",
".",
"getTemplate",
"... | Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate` | [
"Get",
"template",
"from",
"some",
"to",
"-",
"be",
"-",
"copied",
"workitems"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L824-L836 | train | 60,172 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.getTemplates | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8"):
"""Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please r... | python | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8"):
"""Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please r... | [
"def",
"getTemplates",
"(",
"self",
",",
"workitems",
",",
"template_folder",
"=",
"None",
",",
"template_names",
"=",
"None",
",",
"keep",
"=",
"False",
",",
"encoding",
"=",
"\"UTF-8\"",
")",
":",
"self",
".",
"templater",
".",
"getTemplates",
"(",
"work... | Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please refer to
:class:`rtcclient.template.Templater.getTemplates` | [
"Get",
"templates",
"from",
"a",
"group",
"of",
"to",
"-",
"be",
"-",
"copied",
"workitems",
"and",
"write",
"them",
"to",
"files",
"named",
"after",
"the",
"names",
"in",
"template_names",
"respectively",
"."
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L838-L852 | train | 60,173 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.listFieldsFromWorkitem | def listFieldsFromWorkitem(self, copied_from, keep=False):
"""List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem`
"""
return self.templater.listFields... | python | def listFieldsFromWorkitem(self, copied_from, keep=False):
"""List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem`
"""
return self.templater.listFields... | [
"def",
"listFieldsFromWorkitem",
"(",
"self",
",",
"copied_from",
",",
"keep",
"=",
"False",
")",
":",
"return",
"self",
".",
"templater",
".",
"listFieldsFromWorkitem",
"(",
"copied_from",
",",
"keep",
"=",
"keep",
")"
] | List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem` | [
"List",
"all",
"the",
"attributes",
"to",
"be",
"rendered",
"directly",
"from",
"some",
"to",
"-",
"be",
"-",
"copied",
"workitems"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L870-L879 | train | 60,174 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.createWorkitem | def createWorkitem(self, item_type, title, description=None,
projectarea_id=None, projectarea_name=None,
template=None, copied_from=None, keep=False,
**kwargs):
"""Create a workitem
:param item_type: the type of the workitem
... | python | def createWorkitem(self, item_type, title, description=None,
projectarea_id=None, projectarea_name=None,
template=None, copied_from=None, keep=False,
**kwargs):
"""Create a workitem
:param item_type: the type of the workitem
... | [
"def",
"createWorkitem",
"(",
"self",
",",
"item_type",
",",
"title",
",",
"description",
"=",
"None",
",",
"projectarea_id",
"=",
"None",
",",
"projectarea_name",
"=",
"None",
",",
"template",
"=",
"None",
",",
"copied_from",
"=",
"None",
",",
"keep",
"="... | Create a workitem
:param item_type: the type of the workitem
(e.g. task/defect/issue)
:param title: the title of the new created workitem
:param description: the description of the new created workitem
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
... | [
"Create",
"a",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1002-L1073 | train | 60,175 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.copyWorkitem | def copyWorkitem(self, copied_from, title=None, description=None,
prefix=None):
"""Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a t... | python | def copyWorkitem(self, copied_from, title=None, description=None,
prefix=None):
"""Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a t... | [
"def",
"copyWorkitem",
"(",
"self",
",",
"copied_from",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"copied_wi",
"=",
"self",
".",
"getWorkitem",
"(",
"copied_from",
")",
"if",
"title",
"is",
"None",
... | Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a to-be-copied workitem
:param description: the new workitem description.
If `None`, will copy ... | [
"Create",
"a",
"workitem",
"by",
"copying",
"from",
"an",
"existing",
"one"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1075-L1113 | train | 60,176 |
dixudx/rtcclient | rtcclient/client.py | RTCClient._checkMissingParams | def _checkMissingParams(self, template, **kwargs):
"""Check the missing parameters for rendering from the template file
"""
parameters = self.listFields(template)
self._findMissingParams(parameters, **kwargs) | python | def _checkMissingParams(self, template, **kwargs):
"""Check the missing parameters for rendering from the template file
"""
parameters = self.listFields(template)
self._findMissingParams(parameters, **kwargs) | [
"def",
"_checkMissingParams",
"(",
"self",
",",
"template",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"self",
".",
"listFields",
"(",
"template",
")",
"self",
".",
"_findMissingParams",
"(",
"parameters",
",",
"*",
"*",
"kwargs",
")"
] | Check the missing parameters for rendering from the template file | [
"Check",
"the",
"missing",
"parameters",
"for",
"rendering",
"from",
"the",
"template",
"file"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1136-L1141 | train | 60,177 |
dixudx/rtcclient | rtcclient/client.py | RTCClient._checkMissingParamsFromWorkitem | def _checkMissingParamsFromWorkitem(self, copied_from, keep=False,
**kwargs):
"""Check the missing parameters for rendering directly from the
copied workitem
"""
parameters = self.listFieldsFromWorkitem(copied_from,
... | python | def _checkMissingParamsFromWorkitem(self, copied_from, keep=False,
**kwargs):
"""Check the missing parameters for rendering directly from the
copied workitem
"""
parameters = self.listFieldsFromWorkitem(copied_from,
... | [
"def",
"_checkMissingParamsFromWorkitem",
"(",
"self",
",",
"copied_from",
",",
"keep",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"self",
".",
"listFieldsFromWorkitem",
"(",
"copied_from",
",",
"keep",
"=",
"keep",
")",
"self",
".",... | Check the missing parameters for rendering directly from the
copied workitem | [
"Check",
"the",
"missing",
"parameters",
"for",
"rendering",
"directly",
"from",
"the",
"copied",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1143-L1151 | train | 60,178 |
dixudx/rtcclient | rtcclient/client.py | RTCClient.queryWorkitems | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False):
"""Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given... | python | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False):
"""Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given... | [
"def",
"queryWorkitems",
"(",
"self",
",",
"query_str",
",",
"projectarea_id",
"=",
"None",
",",
"projectarea_name",
"=",
"None",
",",
"returned_properties",
"=",
"None",
",",
"archived",
"=",
"False",
")",
":",
"rp",
"=",
"returned_properties",
"return",
"sel... | Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given
:param query_str: a valid query string
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the ... | [
"Query",
"workitems",
"with",
"the",
"query",
"string",
"in",
"a",
"certain",
"project",
"area"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L1486-L1510 | train | 60,179 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addComment | def addComment(self, msg=None):
"""Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment
"""
origin_comment = '''
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-... | python | def addComment(self, msg=None):
"""Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment
"""
origin_comment = '''
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-... | [
"def",
"addComment",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"origin_comment",
"=",
"'''\n<rdf:RDF\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n xmlns:rtc_ext=\"http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/\"\n xmlns:rtc_cm=\"http://jazz.net/xmlns/prod/jazz/rt... | Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment | [
"Add",
"a",
"comment",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L79-L137 | train | 60,180 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addSubscriber | def addSubscriber(self, email):
"""Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
existed_flag, raw_data = sel... | python | def addSubscriber(self, email):
"""Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
existed_flag, raw_data = sel... | [
"def",
"addSubscriber",
"(",
"self",
",",
"email",
")",
":",
"headers",
",",
"raw_data",
"=",
"self",
".",
"_perform_subscribe",
"(",
")",
"existed_flag",
",",
"raw_data",
"=",
"self",
".",
"_add_subscriber",
"(",
"email",
",",
"raw_data",
")",
"if",
"exis... | Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email | [
"Add",
"a",
"subscriber",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L139-L155 | train | 60,181 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addSubscribers | def addSubscribers(self, emails_list):
"""Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | python | def addSubscribers(self, emails_list):
"""Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | [
"def",
"addSubscribers",
"(",
"self",
",",
"emails_list",
")",
":",
"if",
"not",
"hasattr",
"(",
"emails_list",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'emails_list' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg"... | Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | [
"Add",
"subscribers",
"to",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L157-L185 | train | 60,182 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeSubscriber | def removeSubscriber(self, email):
"""Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
missing_flag, raw_data =... | python | def removeSubscriber(self, email):
"""Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email
"""
headers, raw_data = self._perform_subscribe()
missing_flag, raw_data =... | [
"def",
"removeSubscriber",
"(",
"self",
",",
"email",
")",
":",
"headers",
",",
"raw_data",
"=",
"self",
".",
"_perform_subscribe",
"(",
")",
"missing_flag",
",",
"raw_data",
"=",
"self",
".",
"_remove_subscriber",
"(",
"email",
",",
"raw_data",
")",
"if",
... | Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email | [
"Remove",
"a",
"subscriber",
"from",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L187-L203 | train | 60,183 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeSubscribers | def removeSubscribers(self, emails_list):
"""Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | python | def removeSubscribers(self, emails_list):
"""Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails
"""
... | [
"def",
"removeSubscribers",
"(",
"self",
",",
"emails_list",
")",
":",
"if",
"not",
"hasattr",
"(",
"emails_list",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'emails_list' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_m... | Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | [
"Remove",
"subscribers",
"from",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L205-L233 | train | 60,184 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.getParent | def getParent(self, returned_properties=None):
"""Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :... | python | def getParent(self, returned_properties=None):
"""Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :... | [
"def",
"getParent",
"(",
"self",
",",
"returned_properties",
"=",
"None",
")",
":",
"parent_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.workitem.linktype.\"",
"\"parentworkitem.parent\"",
")",
"rp",
"=",
"returned_properties",
"parent",
"=",
"(",
"self",
".",
"rtc_obj",
... | Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
:rtype:... | [
"Get",
"the",
"parent",
"workitem",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L454-L479 | train | 60,185 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.getChildren | def getChildren(self, returned_properties=None):
"""Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:... | python | def getChildren(self, returned_properties=None):
"""Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:... | [
"def",
"getChildren",
"(",
"self",
",",
"returned_properties",
"=",
"None",
")",
":",
"children_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.workitem.linktype.\"",
"\"parentworkitem.children\"",
")",
"rp",
"=",
"returned_properties",
"return",
"(",
"self",
".",
"rtc_obj",
"... | Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
... | [
"Get",
"all",
"the",
"children",
"workitems",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L481-L500 | train | 60,186 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.getChangeSets | def getChangeSets(self):
"""Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list
"""
changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems."
"change_s... | python | def getChangeSets(self):
"""Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list
"""
changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems."
"change_s... | [
"def",
"getChangeSets",
"(",
"self",
")",
":",
"changeset_tag",
"=",
"(",
"\"rtc_cm:com.ibm.team.filesystem.workitems.\"",
"\"change_set.com.ibm.team.scm.ChangeSet\"",
")",
"return",
"(",
"self",
".",
"rtc_obj",
".",
"_get_paged_resources",
"(",
"\"ChangeSet\"",
",",
"wor... | Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list | [
"Get",
"all",
"the",
"ChangeSets",
"of",
"this",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L502-L516 | train | 60,187 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addParent | def addParent(self, parent_id):
"""Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string)
"""
if isinstance(... | python | def addParent(self, parent_id):
"""Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string)
"""
if isinstance(... | [
"def",
"addParent",
"(",
"self",
",",
"parent_id",
")",
":",
"if",
"isinstance",
"(",
"parent_id",
",",
"bool",
")",
":",
"raise",
"exception",
".",
"BadValue",
"(",
"\"Please input a valid workitem id\"",
")",
"if",
"isinstance",
"(",
"parent_id",
",",
"six",... | Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string) | [
"Add",
"a",
"parent",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L518-L561 | train | 60,188 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addChild | def addChild(self, child_id):
"""Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to add a child <Workitem %s> to current "
"<Workitem %s>",
chi... | python | def addChild(self, child_id):
"""Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to add a child <Workitem %s> to current "
"<Workitem %s>",
chi... | [
"def",
"addChild",
"(",
"self",
",",
"child_id",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to add a child <Workitem %s> to current \"",
"\"<Workitem %s>\"",
",",
"child_id",
",",
"self",
")",
"self",
".",
"_addChildren",
"(",
"[",
"child_id",
"]",
... | Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | [
"Add",
"a",
"child",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L563-L578 | train | 60,189 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addChildren | def addChildren(self, child_ids):
"""Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is... | python | def addChildren(self, child_ids):
"""Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is... | [
"def",
"addChildren",
"(",
"self",
",",
"child_ids",
")",
":",
"if",
"not",
"hasattr",
"(",
"child_ids",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'child_ids' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg",
")",
... | Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | [
"Add",
"children",
"to",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L580-L600 | train | 60,190 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeParent | def removeParent(self):
"""Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
"""
self.log.debug("Try to remove the parent workitem from current "
"<Workitem %s>",
... | python | def removeParent(self):
"""Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
"""
self.log.debug("Try to remove the parent workitem from current "
"<Workitem %s>",
... | [
"def",
"removeParent",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to remove the parent workitem from current \"",
"\"<Workitem %s>\"",
",",
"self",
")",
"headers",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"rtc_obj",
".",
"headers... | Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified | [
"Remove",
"the",
"parent",
"workitem",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L660-L689 | train | 60,191 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeChild | def removeChild(self, child_id):
"""Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to remove a child <Workitem %s> from current "
"<Workitem %s>",
... | python | def removeChild(self, child_id):
"""Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string)
"""
self.log.debug("Try to remove a child <Workitem %s> from current "
"<Workitem %s>",
... | [
"def",
"removeChild",
"(",
"self",
",",
"child_id",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Try to remove a child <Workitem %s> from current \"",
"\"<Workitem %s>\"",
",",
"child_id",
",",
"self",
")",
"self",
".",
"_removeChildren",
"(",
"[",
"child_i... | Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | [
"Remove",
"a",
"child",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L691-L706 | train | 60,192 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.removeChildren | def removeChildren(self, child_ids):
"""Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child... | python | def removeChildren(self, child_ids):
"""Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string)
"""
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child... | [
"def",
"removeChildren",
"(",
"self",
",",
"child_ids",
")",
":",
"if",
"not",
"hasattr",
"(",
"child_ids",
",",
"\"__iter__\"",
")",
":",
"error_msg",
"=",
"\"Input parameter 'child_ids' is not iterable\"",
"self",
".",
"log",
".",
"error",
"(",
"error_msg",
")... | Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | [
"Remove",
"children",
"from",
"current",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L708-L728 | train | 60,193 |
dixudx/rtcclient | rtcclient/workitem.py | Workitem.addAttachment | def addAttachment(self, filepath):
"""Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment
"""
proj_id = self.contextId
fa = self.rtc_obj.getFiledA... | python | def addAttachment(self, filepath):
"""Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment
"""
proj_id = self.contextId
fa = self.rtc_obj.getFiledA... | [
"def",
"addAttachment",
"(",
"self",
",",
"filepath",
")",
":",
"proj_id",
"=",
"self",
".",
"contextId",
"fa",
"=",
"self",
".",
"rtc_obj",
".",
"getFiledAgainst",
"(",
"self",
".",
"filedAgainst",
",",
"projectarea_id",
"=",
"proj_id",
")",
"fa_id",
"=",... | Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment | [
"Upload",
"attachment",
"to",
"a",
"workitem"
] | 1721dd0b047478f5bdd6359b07a2c503cfafd86f | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L760-L797 | train | 60,194 |
lxc/python2-lxc | lxc/__init__.py | list_containers | def list_containers(active=True, defined=True,
as_object=False, config_path=None):
"""
List the containers on the system.
"""
if config_path:
if not os.path.exists(config_path):
return tuple()
try:
entries = _lxc.list_containers(active=act... | python | def list_containers(active=True, defined=True,
as_object=False, config_path=None):
"""
List the containers on the system.
"""
if config_path:
if not os.path.exists(config_path):
return tuple()
try:
entries = _lxc.list_containers(active=act... | [
"def",
"list_containers",
"(",
"active",
"=",
"True",
",",
"defined",
"=",
"True",
",",
"as_object",
"=",
"False",
",",
"config_path",
"=",
"None",
")",
":",
"if",
"config_path",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
"... | List the containers on the system. | [
"List",
"the",
"containers",
"on",
"the",
"system",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L426-L449 | train | 60,195 |
lxc/python2-lxc | lxc/__init__.py | attach_run_command | def attach_run_command(cmd):
"""
Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container.
"""
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
el... | python | def attach_run_command(cmd):
"""
Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container.
"""
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
el... | [
"def",
"attach_run_command",
"(",
"cmd",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"tuple",
")",
":",
"return",
"_lxc",
".",
"attach_run_command",
"(",
"cmd",
")",
"elif",
"isinstance",
"(",
"cmd",
",",
"list",
")",
":",
"return",
"_lxc",
".",
"at... | Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container. | [
"Run",
"a",
"command",
"when",
"attaching"
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L452-L465 | train | 60,196 |
lxc/python2-lxc | lxc/__init__.py | arch_to_personality | def arch_to_personality(arch):
"""
Determine the process personality corresponding to the architecture
"""
if isinstance(arch, bytes):
arch = unicode(arch)
return _lxc.arch_to_personality(arch) | python | def arch_to_personality(arch):
"""
Determine the process personality corresponding to the architecture
"""
if isinstance(arch, bytes):
arch = unicode(arch)
return _lxc.arch_to_personality(arch) | [
"def",
"arch_to_personality",
"(",
"arch",
")",
":",
"if",
"isinstance",
"(",
"arch",
",",
"bytes",
")",
":",
"arch",
"=",
"unicode",
"(",
"arch",
")",
"return",
"_lxc",
".",
"arch_to_personality",
"(",
"arch",
")"
] | Determine the process personality corresponding to the architecture | [
"Determine",
"the",
"process",
"personality",
"corresponding",
"to",
"the",
"architecture"
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L479-L485 | train | 60,197 |
lxc/python2-lxc | lxc/__init__.py | Container.add_device_net | def add_device_net(self, name, destname=None):
"""
Add network device to running container.
"""
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
... | python | def add_device_net(self, name, destname=None):
"""
Add network device to running container.
"""
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
... | [
"def",
"add_device_net",
"(",
"self",
",",
"name",
",",
"destname",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"return",
"False",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"\"/sys/class/net/%s/phy80211/name\"",
"%",
"name",
")",
... | Add network device to running container. | [
"Add",
"network",
"device",
"to",
"running",
"container",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L157-L194 | train | 60,198 |
lxc/python2-lxc | lxc/__init__.py | Container.append_config_item | def append_config_item(self, key, value):
"""
Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'.
"""
return _lxc.Container.set_config_item(self, key, value) | python | def append_config_item(self, key, value):
"""
Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'.
"""
return _lxc.Container.set_config_item(self, key, value) | [
"def",
"append_config_item",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"return",
"_lxc",
".",
"Container",
".",
"set_config_item",
"(",
"self",
",",
"key",
",",
"value",
")"
] | Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'. | [
"Append",
"value",
"to",
"key",
"assuming",
"key",
"is",
"a",
"list",
".",
"If",
"key",
"isn",
"t",
"a",
"list",
"value",
"will",
"be",
"set",
"as",
"the",
"value",
"of",
"key",
"."
] | b7ec757d2bea1e5787c3e65b1359b8893491ef90 | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L196-L202 | train | 60,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.