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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pbrisk/timewave | timewave/consumers.py | ConsumerConsumer.finalize_path | def finalize_path(self, path_num=None):
"""finalize path and populate result for ConsumerConsumer"""
for c in self.consumers:
c.finalize_path(path_num)
self.result = [c.result for c in self.consumers] | python | def finalize_path(self, path_num=None):
"""finalize path and populate result for ConsumerConsumer"""
for c in self.consumers:
c.finalize_path(path_num)
self.result = [c.result for c in self.consumers] | [
"def",
"finalize_path",
"(",
"self",
",",
"path_num",
"=",
"None",
")",
":",
"for",
"c",
"in",
"self",
".",
"consumers",
":",
"c",
".",
"finalize_path",
"(",
"path_num",
")",
"self",
".",
"result",
"=",
"[",
"c",
".",
"result",
"for",
"c",
"in",
"s... | finalize path and populate result for ConsumerConsumer | [
"finalize",
"path",
"and",
"populate",
"result",
"for",
"ConsumerConsumer"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/consumers.py#L170-L174 | train | 57,700 |
pbrisk/timewave | timewave/consumers.py | ConsumerConsumer.finalize | def finalize(self):
"""finalize for ConsumerConsumer"""
for c in self.consumers:
c.finalize()
self.result = [c.result for c in self.consumers] | python | def finalize(self):
"""finalize for ConsumerConsumer"""
for c in self.consumers:
c.finalize()
self.result = [c.result for c in self.consumers] | [
"def",
"finalize",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"consumers",
":",
"c",
".",
"finalize",
"(",
")",
"self",
".",
"result",
"=",
"[",
"c",
".",
"result",
"for",
"c",
"in",
"self",
".",
"consumers",
"]"
] | finalize for ConsumerConsumer | [
"finalize",
"for",
"ConsumerConsumer"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/consumers.py#L176-L180 | train | 57,701 |
pbrisk/timewave | timewave/consumers.py | ConsumerConsumer.get | def get(self, queue_get):
"""
get to given consumer states.
This function is used for merging of results of parallelized MC.
The first state is used for merging in place. The states must be disjoint.
:param object queue_get: second consumer state
"""
for (c, cs) ... | python | def get(self, queue_get):
"""
get to given consumer states.
This function is used for merging of results of parallelized MC.
The first state is used for merging in place. The states must be disjoint.
:param object queue_get: second consumer state
"""
for (c, cs) ... | [
"def",
"get",
"(",
"self",
",",
"queue_get",
")",
":",
"for",
"(",
"c",
",",
"cs",
")",
"in",
"izip",
"(",
"self",
".",
"consumers",
",",
"queue_get",
")",
":",
"c",
".",
"get",
"(",
"cs",
")",
"self",
".",
"result",
"=",
"[",
"c",
".",
"resu... | get to given consumer states.
This function is used for merging of results of parallelized MC.
The first state is used for merging in place. The states must be disjoint.
:param object queue_get: second consumer state | [
"get",
"to",
"given",
"consumer",
"states",
".",
"This",
"function",
"is",
"used",
"for",
"merging",
"of",
"results",
"of",
"parallelized",
"MC",
".",
"The",
"first",
"state",
"is",
"used",
"for",
"merging",
"in",
"place",
".",
"The",
"states",
"must",
"... | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/consumers.py#L182-L192 | train | 57,702 |
pbrisk/timewave | timewave/consumers.py | TransposedConsumer.finalize | def finalize(self):
"""finalize for PathConsumer"""
super(TransposedConsumer, self).finalize()
self.result = map(list, zip(*self.result)) | python | def finalize(self):
"""finalize for PathConsumer"""
super(TransposedConsumer, self).finalize()
self.result = map(list, zip(*self.result)) | [
"def",
"finalize",
"(",
"self",
")",
":",
"super",
"(",
"TransposedConsumer",
",",
"self",
")",
".",
"finalize",
"(",
")",
"self",
".",
"result",
"=",
"map",
"(",
"list",
",",
"zip",
"(",
"*",
"self",
".",
"result",
")",
")"
] | finalize for PathConsumer | [
"finalize",
"for",
"PathConsumer"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/consumers.py#L206-L209 | train | 57,703 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/ntfs/mft_entry.py | MftEntry._get_attribute | def _get_attribute(self, offset):
"""Determines attribute type at the offset and returns \
initialized attribute object.
Returns:
MftAttr: One of the attribute objects \
(eg. :class:`~.mft_attribute.MftAttrFilename`).
None: If atttribute type does not mach an... | python | def _get_attribute(self, offset):
"""Determines attribute type at the offset and returns \
initialized attribute object.
Returns:
MftAttr: One of the attribute objects \
(eg. :class:`~.mft_attribute.MftAttrFilename`).
None: If atttribute type does not mach an... | [
"def",
"_get_attribute",
"(",
"self",
",",
"offset",
")",
":",
"attr_type",
"=",
"self",
".",
"get_uint_le",
"(",
"offset",
")",
"# Attribute length is in header @ offset 0x4",
"length",
"=",
"self",
".",
"get_uint_le",
"(",
"offset",
"+",
"0x04",
")",
"data",
... | Determines attribute type at the offset and returns \
initialized attribute object.
Returns:
MftAttr: One of the attribute objects \
(eg. :class:`~.mft_attribute.MftAttrFilename`).
None: If atttribute type does not mach any one of the supported \
attribut... | [
"Determines",
"attribute",
"type",
"at",
"the",
"offset",
"and",
"returns",
"\\",
"initialized",
"attribute",
"object",
"."
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/mft_entry.py#L96-L111 | train | 57,704 |
tylucaskelley/licenser | licenser/licenser.py | find_in_matrix_2d | def find_in_matrix_2d(val, matrix):
'''
Returns a tuple representing the index of an item in a 2D matrix.
Arguments:
- val (str) Value to look for
- matrix (list) 2D matrix to search for val in
Returns:
- (tuple) Ordered pair representing location of val
'''
dim = len(... | python | def find_in_matrix_2d(val, matrix):
'''
Returns a tuple representing the index of an item in a 2D matrix.
Arguments:
- val (str) Value to look for
- matrix (list) 2D matrix to search for val in
Returns:
- (tuple) Ordered pair representing location of val
'''
dim = len(... | [
"def",
"find_in_matrix_2d",
"(",
"val",
",",
"matrix",
")",
":",
"dim",
"=",
"len",
"(",
"matrix",
"[",
"0",
"]",
")",
"item_index",
"=",
"0",
"for",
"row",
"in",
"matrix",
":",
"for",
"i",
"in",
"row",
":",
"if",
"i",
"==",
"val",
":",
"break",
... | Returns a tuple representing the index of an item in a 2D matrix.
Arguments:
- val (str) Value to look for
- matrix (list) 2D matrix to search for val in
Returns:
- (tuple) Ordered pair representing location of val | [
"Returns",
"a",
"tuple",
"representing",
"the",
"index",
"of",
"an",
"item",
"in",
"a",
"2D",
"matrix",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L21-L46 | train | 57,705 |
tylucaskelley/licenser | licenser/licenser.py | compute_distance | def compute_distance(a, b):
'''
Computes a modified Levenshtein distance between two strings, comparing the
lowercase versions of each string and accounting for QWERTY distance.
Arguments:
- a (str) String to compare to 'b'
- b (str) String to compare to 'a'
Returns:
- (int... | python | def compute_distance(a, b):
'''
Computes a modified Levenshtein distance between two strings, comparing the
lowercase versions of each string and accounting for QWERTY distance.
Arguments:
- a (str) String to compare to 'b'
- b (str) String to compare to 'a'
Returns:
- (int... | [
"def",
"compute_distance",
"(",
"a",
",",
"b",
")",
":",
"# check simple cases first",
"if",
"not",
"a",
":",
"return",
"len",
"(",
"b",
")",
"if",
"not",
"b",
":",
"return",
"len",
"(",
"a",
")",
"if",
"a",
"==",
"b",
"or",
"str",
".",
"lower",
... | Computes a modified Levenshtein distance between two strings, comparing the
lowercase versions of each string and accounting for QWERTY distance.
Arguments:
- a (str) String to compare to 'b'
- b (str) String to compare to 'a'
Returns:
- (int) Number representing closeness of 'a' a... | [
"Computes",
"a",
"modified",
"Levenshtein",
"distance",
"between",
"two",
"strings",
"comparing",
"the",
"lowercase",
"versions",
"of",
"each",
"string",
"and",
"accounting",
"for",
"QWERTY",
"distance",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L95-L139 | train | 57,706 |
tylucaskelley/licenser | licenser/licenser.py | get_defaults | def get_defaults(path):
'''
Reads file for configuration defaults.
Arguments:
- path (str) Absolute filepath (usually ~/.licenser)
Returns:
- (dict) Defaults for name, email, license, .txt extension
'''
defaults = {}
if os.path.isfile(path):
with open(path) as f:
... | python | def get_defaults(path):
'''
Reads file for configuration defaults.
Arguments:
- path (str) Absolute filepath (usually ~/.licenser)
Returns:
- (dict) Defaults for name, email, license, .txt extension
'''
defaults = {}
if os.path.isfile(path):
with open(path) as f:
... | [
"def",
"get_defaults",
"(",
"path",
")",
":",
"defaults",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
... | Reads file for configuration defaults.
Arguments:
- path (str) Absolute filepath (usually ~/.licenser)
Returns:
- (dict) Defaults for name, email, license, .txt extension | [
"Reads",
"file",
"for",
"configuration",
"defaults",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L142-L169 | train | 57,707 |
tylucaskelley/licenser | licenser/licenser.py | get_license | def get_license(name):
'''
Returns the closest match to the requested license.
Arguments:
- name (str) License to use
Returns:
- (str) License that most closely matches the 'name' parameter
'''
filenames = os.listdir(cwd + licenses_loc)
licenses = dict(zip(filenames, [-1] ... | python | def get_license(name):
'''
Returns the closest match to the requested license.
Arguments:
- name (str) License to use
Returns:
- (str) License that most closely matches the 'name' parameter
'''
filenames = os.listdir(cwd + licenses_loc)
licenses = dict(zip(filenames, [-1] ... | [
"def",
"get_license",
"(",
"name",
")",
":",
"filenames",
"=",
"os",
".",
"listdir",
"(",
"cwd",
"+",
"licenses_loc",
")",
"licenses",
"=",
"dict",
"(",
"zip",
"(",
"filenames",
",",
"[",
"-",
"1",
"]",
"*",
"len",
"(",
"filenames",
")",
")",
")",
... | Returns the closest match to the requested license.
Arguments:
- name (str) License to use
Returns:
- (str) License that most closely matches the 'name' parameter | [
"Returns",
"the",
"closest",
"match",
"to",
"the",
"requested",
"license",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L172-L189 | train | 57,708 |
tylucaskelley/licenser | licenser/licenser.py | get_args | def get_args(path):
'''
Parse command line args & override defaults.
Arguments:
- path (str) Absolute filepath
Returns:
- (tuple) Name, email, license, project, ext, year
'''
defaults = get_defaults(path)
licenses = ', '.join(os.listdir(cwd + licenses_loc))
p = parser(... | python | def get_args(path):
'''
Parse command line args & override defaults.
Arguments:
- path (str) Absolute filepath
Returns:
- (tuple) Name, email, license, project, ext, year
'''
defaults = get_defaults(path)
licenses = ', '.join(os.listdir(cwd + licenses_loc))
p = parser(... | [
"def",
"get_args",
"(",
"path",
")",
":",
"defaults",
"=",
"get_defaults",
"(",
"path",
")",
"licenses",
"=",
"', '",
".",
"join",
"(",
"os",
".",
"listdir",
"(",
"cwd",
"+",
"licenses_loc",
")",
")",
"p",
"=",
"parser",
"(",
"description",
"=",
"'to... | Parse command line args & override defaults.
Arguments:
- path (str) Absolute filepath
Returns:
- (tuple) Name, email, license, project, ext, year | [
"Parse",
"command",
"line",
"args",
"&",
"override",
"defaults",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L192-L227 | train | 57,709 |
tylucaskelley/licenser | licenser/licenser.py | generate_license | def generate_license(args):
'''
Creates a LICENSE or LICENSE.txt file in the current directory. Reads from
the 'assets' folder and looks for placeholders enclosed in curly braces.
Arguments:
- (tuple) Name, email, license, project, ext, year
'''
with open(cwd + licenses_loc + args[2]) ... | python | def generate_license(args):
'''
Creates a LICENSE or LICENSE.txt file in the current directory. Reads from
the 'assets' folder and looks for placeholders enclosed in curly braces.
Arguments:
- (tuple) Name, email, license, project, ext, year
'''
with open(cwd + licenses_loc + args[2]) ... | [
"def",
"generate_license",
"(",
"args",
")",
":",
"with",
"open",
"(",
"cwd",
"+",
"licenses_loc",
"+",
"args",
"[",
"2",
"]",
")",
"as",
"f",
":",
"license",
"=",
"f",
".",
"read",
"(",
")",
"license",
"=",
"license",
".",
"format",
"(",
"name",
... | Creates a LICENSE or LICENSE.txt file in the current directory. Reads from
the 'assets' folder and looks for placeholders enclosed in curly braces.
Arguments:
- (tuple) Name, email, license, project, ext, year | [
"Creates",
"a",
"LICENSE",
"or",
"LICENSE",
".",
"txt",
"file",
"in",
"the",
"current",
"directory",
".",
"Reads",
"from",
"the",
"assets",
"folder",
"and",
"looks",
"for",
"placeholders",
"enclosed",
"in",
"curly",
"braces",
"."
] | 6b7394fdaab7707c4c33201c4d023097452b46bc | https://github.com/tylucaskelley/licenser/blob/6b7394fdaab7707c4c33201c4d023097452b46bc/licenser/licenser.py#L230-L250 | train | 57,710 |
AtomHash/evernode | evernode/scripts/sendemail.py | SendEmail.parse | def parse(self):
""" parses args json """
data = json.loads(sys.argv[1])
self.config_path = self.decode(data['config_path'])
self.subject = self.decode(data['subject'])
self.text = self.decode(data['text'])
self.html = self.decode(data['html'])
self.send_as... | python | def parse(self):
""" parses args json """
data = json.loads(sys.argv[1])
self.config_path = self.decode(data['config_path'])
self.subject = self.decode(data['subject'])
self.text = self.decode(data['text'])
self.html = self.decode(data['html'])
self.send_as... | [
"def",
"parse",
"(",
"self",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"sys",
".",
"argv",
"[",
"1",
"]",
")",
"self",
".",
"config_path",
"=",
"self",
".",
"decode",
"(",
"data",
"[",
"'config_path'",
"]",
")",
"self",
".",
"subject",
"=... | parses args json | [
"parses",
"args",
"json"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/scripts/sendemail.py#L47-L61 | train | 57,711 |
AtomHash/evernode | evernode/scripts/sendemail.py | SendEmail.construct_message | def construct_message(self, email=None):
""" construct the email message """
# add subject, from and to
self.multipart['Subject'] = self.subject
self.multipart['From'] = self.config['EMAIL']
self.multipart['Date'] = formatdate(localtime=True)
if email is None and se... | python | def construct_message(self, email=None):
""" construct the email message """
# add subject, from and to
self.multipart['Subject'] = self.subject
self.multipart['From'] = self.config['EMAIL']
self.multipart['Date'] = formatdate(localtime=True)
if email is None and se... | [
"def",
"construct_message",
"(",
"self",
",",
"email",
"=",
"None",
")",
":",
"# add subject, from and to\r",
"self",
".",
"multipart",
"[",
"'Subject'",
"]",
"=",
"self",
".",
"subject",
"self",
".",
"multipart",
"[",
"'From'",
"]",
"=",
"self",
".",
"con... | construct the email message | [
"construct",
"the",
"email",
"message"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/scripts/sendemail.py#L81-L100 | train | 57,712 |
AtomHash/evernode | evernode/scripts/sendemail.py | SendEmail.send | def send(self, email=None):
""" send email message """
if email is None and self.send_as_one:
self.smtp.send_message(
self.multipart, self.config['EMAIL'], self.addresses)
elif email is not None and self.send_as_one is False:
self.smtp.send_message(
... | python | def send(self, email=None):
""" send email message """
if email is None and self.send_as_one:
self.smtp.send_message(
self.multipart, self.config['EMAIL'], self.addresses)
elif email is not None and self.send_as_one is False:
self.smtp.send_message(
... | [
"def",
"send",
"(",
"self",
",",
"email",
"=",
"None",
")",
":",
"if",
"email",
"is",
"None",
"and",
"self",
".",
"send_as_one",
":",
"self",
".",
"smtp",
".",
"send_message",
"(",
"self",
".",
"multipart",
",",
"self",
".",
"config",
"[",
"'EMAIL'",... | send email message | [
"send",
"email",
"message"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/scripts/sendemail.py#L109-L117 | train | 57,713 |
AtomHash/evernode | evernode/scripts/sendemail.py | SendEmail.create_email | def create_email(self):
""" main function to construct and send email """
self.connect()
if self.send_as_one:
self.construct_message()
self.send()
elif self.send_as_one is False:
for email in self.addresses:
self.construct_messa... | python | def create_email(self):
""" main function to construct and send email """
self.connect()
if self.send_as_one:
self.construct_message()
self.send()
elif self.send_as_one is False:
for email in self.addresses:
self.construct_messa... | [
"def",
"create_email",
"(",
"self",
")",
":",
"self",
".",
"connect",
"(",
")",
"if",
"self",
".",
"send_as_one",
":",
"self",
".",
"construct_message",
"(",
")",
"self",
".",
"send",
"(",
")",
"elif",
"self",
".",
"send_as_one",
"is",
"False",
":",
... | main function to construct and send email | [
"main",
"function",
"to",
"construct",
"and",
"send",
"email"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/scripts/sendemail.py#L119-L129 | train | 57,714 |
ylogx/definition | definition/definition.py | get_definition | def get_definition(query):
"""Returns dictionary of id, first names of people who posted on my wall
between start and end time"""
try:
return get_definition_api(query)
except:
raise
# http://api.wordnik.com:80/v4/word.json/discrimination/definitions?limit=200&includeRelated=true&sou... | python | def get_definition(query):
"""Returns dictionary of id, first names of people who posted on my wall
between start and end time"""
try:
return get_definition_api(query)
except:
raise
# http://api.wordnik.com:80/v4/word.json/discrimination/definitions?limit=200&includeRelated=true&sou... | [
"def",
"get_definition",
"(",
"query",
")",
":",
"try",
":",
"return",
"get_definition_api",
"(",
"query",
")",
"except",
":",
"raise",
"# http://api.wordnik.com:80/v4/word.json/discrimination/definitions?limit=200&includeRelated=true&sourceDictionaries=all&useCanonical=false&include... | Returns dictionary of id, first names of people who posted on my wall
between start and end time | [
"Returns",
"dictionary",
"of",
"id",
"first",
"names",
"of",
"people",
"who",
"posted",
"on",
"my",
"wall",
"between",
"start",
"and",
"end",
"time"
] | 3699670b33b3a345297b0035fcc1f5aa15959f71 | https://github.com/ylogx/definition/blob/3699670b33b3a345297b0035fcc1f5aa15959f71/definition/definition.py#L187-L203 | train | 57,715 |
ponty/confduino | confduino/version.py | intversion | def intversion(text=None):
"""return version as int.
0022 -> 22
0022ubuntu0.1 -> 22
0023 -> 23
1.0 -> 100
1.0.3 -> 103
1:1.0.5+dfsg2-2 -> 105
"""
try:
s = text
if not s:
s = version()
s = s.split('ubuntu')[0]
s = s.split(':')[-1]
... | python | def intversion(text=None):
"""return version as int.
0022 -> 22
0022ubuntu0.1 -> 22
0023 -> 23
1.0 -> 100
1.0.3 -> 103
1:1.0.5+dfsg2-2 -> 105
"""
try:
s = text
if not s:
s = version()
s = s.split('ubuntu')[0]
s = s.split(':')[-1]
... | [
"def",
"intversion",
"(",
"text",
"=",
"None",
")",
":",
"try",
":",
"s",
"=",
"text",
"if",
"not",
"s",
":",
"s",
"=",
"version",
"(",
")",
"s",
"=",
"s",
".",
"split",
"(",
"'ubuntu'",
")",
"[",
"0",
"]",
"s",
"=",
"s",
".",
"split",
"(",... | return version as int.
0022 -> 22
0022ubuntu0.1 -> 22
0023 -> 23
1.0 -> 100
1.0.3 -> 103
1:1.0.5+dfsg2-2 -> 105 | [
"return",
"version",
"as",
"int",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/version.py#L24-L56 | train | 57,716 |
AtomHash/evernode | evernode/classes/session.py | Session.set_current_session | def set_current_session(session_id) -> bool:
""" Add session_id to flask globals for current request """
try:
g.session_id = session_id
return True
except (Exception, BaseException) as error:
# catch all on config update
if current_app.confi... | python | def set_current_session(session_id) -> bool:
""" Add session_id to flask globals for current request """
try:
g.session_id = session_id
return True
except (Exception, BaseException) as error:
# catch all on config update
if current_app.confi... | [
"def",
"set_current_session",
"(",
"session_id",
")",
"->",
"bool",
":",
"try",
":",
"g",
".",
"session_id",
"=",
"session_id",
"return",
"True",
"except",
"(",
"Exception",
",",
"BaseException",
")",
"as",
"error",
":",
"# catch all on config update\r",
"if",
... | Add session_id to flask globals for current request | [
"Add",
"session_id",
"to",
"flask",
"globals",
"for",
"current",
"request"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/session.py#L18-L27 | train | 57,717 |
helixyte/everest | everest/representers/traversal.py | ResourceDataVisitor.visit_member | def visit_member(self, attribute_key, attribute, member_node, member_data,
is_link_node, parent_data, index=None):
"""
Visits a member node in a resource data tree.
:param tuple attribute_key: tuple containing the attribute tokens
identifying the member node's pos... | python | def visit_member(self, attribute_key, attribute, member_node, member_data,
is_link_node, parent_data, index=None):
"""
Visits a member node in a resource data tree.
:param tuple attribute_key: tuple containing the attribute tokens
identifying the member node's pos... | [
"def",
"visit_member",
"(",
"self",
",",
"attribute_key",
",",
"attribute",
",",
"member_node",
",",
"member_data",
",",
"is_link_node",
",",
"parent_data",
",",
"index",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Abstract method.'",
")"
] | Visits a member node in a resource data tree.
:param tuple attribute_key: tuple containing the attribute tokens
identifying the member node's position in the resource data tree.
:param attribute: mapped attribute holding information about the
member node's name (in the parent) and t... | [
"Visits",
"a",
"member",
"node",
"in",
"a",
"resource",
"data",
"tree",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/traversal.py#L53-L76 | train | 57,718 |
helixyte/everest | everest/representers/traversal.py | DataElementDataTraversalProxy.get_relationship | def get_relationship(self, attribute):
"""
Returns the domain relationship object for the given resource
attribute.
"""
rel = self.__relationships.get(attribute.entity_attr)
if rel is None:
rel = LazyDomainRelationship(self, attribute,
... | python | def get_relationship(self, attribute):
"""
Returns the domain relationship object for the given resource
attribute.
"""
rel = self.__relationships.get(attribute.entity_attr)
if rel is None:
rel = LazyDomainRelationship(self, attribute,
... | [
"def",
"get_relationship",
"(",
"self",
",",
"attribute",
")",
":",
"rel",
"=",
"self",
".",
"__relationships",
".",
"get",
"(",
"attribute",
".",
"entity_attr",
")",
"if",
"rel",
"is",
"None",
":",
"rel",
"=",
"LazyDomainRelationship",
"(",
"self",
",",
... | Returns the domain relationship object for the given resource
attribute. | [
"Returns",
"the",
"domain",
"relationship",
"object",
"for",
"the",
"given",
"resource",
"attribute",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/traversal.py#L438-L449 | train | 57,719 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/rabbitmq/rabbitmq_util.py | simple_notification | def simple_notification(connection, queue_name, exchange_name, routing_key, text_body):
"""
Publishes a simple notification.
Inputs: - connection: A rabbitmq connection object.
- queue_name: The name of the queue to be checked or created.
- exchange_name: The name of the notificatio... | python | def simple_notification(connection, queue_name, exchange_name, routing_key, text_body):
"""
Publishes a simple notification.
Inputs: - connection: A rabbitmq connection object.
- queue_name: The name of the queue to be checked or created.
- exchange_name: The name of the notificatio... | [
"def",
"simple_notification",
"(",
"connection",
",",
"queue_name",
",",
"exchange_name",
",",
"routing_key",
",",
"text_body",
")",
":",
"channel",
"=",
"connection",
".",
"channel",
"(",
")",
"try",
":",
"channel",
".",
"queue_declare",
"(",
"queue_name",
",... | Publishes a simple notification.
Inputs: - connection: A rabbitmq connection object.
- queue_name: The name of the queue to be checked or created.
- exchange_name: The name of the notification exchange.
- routing_key: The routing key for the exchange-queue binding.
-... | [
"Publishes",
"a",
"simple",
"notification",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/rabbitmq/rabbitmq_util.py#L74-L96 | train | 57,720 |
callowayproject/Calloway | calloway/menu.py | DefaultMenu.get_url | def get_url(self, url_or_dict):
"""
Returns the reversed url given a string or dict and prints errors if MENU_DEBUG is enabled
"""
if isinstance(url_or_dict, basestring):
url_or_dict = {'viewname': url_or_dict}
try:
return reverse(**url_or_dict)
ex... | python | def get_url(self, url_or_dict):
"""
Returns the reversed url given a string or dict and prints errors if MENU_DEBUG is enabled
"""
if isinstance(url_or_dict, basestring):
url_or_dict = {'viewname': url_or_dict}
try:
return reverse(**url_or_dict)
ex... | [
"def",
"get_url",
"(",
"self",
",",
"url_or_dict",
")",
":",
"if",
"isinstance",
"(",
"url_or_dict",
",",
"basestring",
")",
":",
"url_or_dict",
"=",
"{",
"'viewname'",
":",
"url_or_dict",
"}",
"try",
":",
"return",
"reverse",
"(",
"*",
"*",
"url_or_dict",... | Returns the reversed url given a string or dict and prints errors if MENU_DEBUG is enabled | [
"Returns",
"the",
"reversed",
"url",
"given",
"a",
"string",
"or",
"dict",
"and",
"prints",
"errors",
"if",
"MENU_DEBUG",
"is",
"enabled"
] | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/menu.py#L47-L57 | train | 57,721 |
RI-imaging/qpformat | qpformat/file_formats/single_tif_holo.py | SingleTifHolo.get_time | def get_time(self):
"""Time of the TIFF file
Currently, only the file modification time is supported.
Note that the modification time of the TIFF file is
dependent on the file system and may have temporal
resolution as low as 3 seconds.
"""
if isinstance(self.pat... | python | def get_time(self):
"""Time of the TIFF file
Currently, only the file modification time is supported.
Note that the modification time of the TIFF file is
dependent on the file system and may have temporal
resolution as low as 3 seconds.
"""
if isinstance(self.pat... | [
"def",
"get_time",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"path",
",",
"pathlib",
".",
"Path",
")",
":",
"thetime",
"=",
"self",
".",
"path",
".",
"stat",
"(",
")",
".",
"st_mtime",
"else",
":",
"thetime",
"=",
"np",
".",
"n... | Time of the TIFF file
Currently, only the file modification time is supported.
Note that the modification time of the TIFF file is
dependent on the file system and may have temporal
resolution as low as 3 seconds. | [
"Time",
"of",
"the",
"TIFF",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_tif_holo.py#L26-L38 | train | 57,722 |
RI-imaging/qpformat | qpformat/file_formats/single_tif_holo.py | SingleTifHolo.verify | def verify(path):
"""Verify that `path` is a valid TIFF file"""
valid = False
try:
tf = SingleTifHolo._get_tif(path)
except (ValueError, IsADirectoryError):
pass
else:
if len(tf) == 1:
valid = True
return valid | python | def verify(path):
"""Verify that `path` is a valid TIFF file"""
valid = False
try:
tf = SingleTifHolo._get_tif(path)
except (ValueError, IsADirectoryError):
pass
else:
if len(tf) == 1:
valid = True
return valid | [
"def",
"verify",
"(",
"path",
")",
":",
"valid",
"=",
"False",
"try",
":",
"tf",
"=",
"SingleTifHolo",
".",
"_get_tif",
"(",
"path",
")",
"except",
"(",
"ValueError",
",",
"IsADirectoryError",
")",
":",
"pass",
"else",
":",
"if",
"len",
"(",
"tf",
")... | Verify that `path` is a valid TIFF file | [
"Verify",
"that",
"path",
"is",
"a",
"valid",
"TIFF",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/single_tif_holo.py#L57-L67 | train | 57,723 |
danbradham/scrim | scrim/__main__.py | add | def add(entry_point, all_entry_points, auto_write, scripts_path):
'''Add Scrim scripts for a python project'''
click.echo()
if not entry_point and not all_entry_points:
raise click.UsageError(
'Missing required option: --entry_point or --all_entry_points'
)
if not os.path.ex... | python | def add(entry_point, all_entry_points, auto_write, scripts_path):
'''Add Scrim scripts for a python project'''
click.echo()
if not entry_point and not all_entry_points:
raise click.UsageError(
'Missing required option: --entry_point or --all_entry_points'
)
if not os.path.ex... | [
"def",
"add",
"(",
"entry_point",
",",
"all_entry_points",
",",
"auto_write",
",",
"scripts_path",
")",
":",
"click",
".",
"echo",
"(",
")",
"if",
"not",
"entry_point",
"and",
"not",
"all_entry_points",
":",
"raise",
"click",
".",
"UsageError",
"(",
"'Missin... | Add Scrim scripts for a python project | [
"Add",
"Scrim",
"scripts",
"for",
"a",
"python",
"project"
] | 982a5db1db6e4ef40267f15642af2c7ea0e803ae | https://github.com/danbradham/scrim/blob/982a5db1db6e4ef40267f15642af2c7ea0e803ae/scrim/__main__.py#L20-L89 | train | 57,724 |
andy29485/embypy | embypy/objects/folders.py | Playlist.songs | async def songs(self):
'''list of songs in the playlist
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Audio`
'''
items = []
for i in await self.items:
if i.type == 'Audio':
items.append(i)
elif hasattr(i, 'songs'):
items.exten... | python | async def songs(self):
'''list of songs in the playlist
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Audio`
'''
items = []
for i in await self.items:
if i.type == 'Audio':
items.append(i)
elif hasattr(i, 'songs'):
items.exten... | [
"async",
"def",
"songs",
"(",
"self",
")",
":",
"items",
"=",
"[",
"]",
"for",
"i",
"in",
"await",
"self",
".",
"items",
":",
"if",
"i",
".",
"type",
"==",
"'Audio'",
":",
"items",
".",
"append",
"(",
"i",
")",
"elif",
"hasattr",
"(",
"i",
",",... | list of songs in the playlist
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Audio` | [
"list",
"of",
"songs",
"in",
"the",
"playlist"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/folders.py#L82-L100 | train | 57,725 |
andy29485/embypy | embypy/objects/folders.py | Playlist.add_items | async def add_items(self, *items):
'''append items to the playlist
|coro|
Parameters
----------
items : array_like
list of items to add(or their ids)
See Also
--------
remove_items :
'''
items = [item.id for item in await self.process(items)]
if not items:
re... | python | async def add_items(self, *items):
'''append items to the playlist
|coro|
Parameters
----------
items : array_like
list of items to add(or their ids)
See Also
--------
remove_items :
'''
items = [item.id for item in await self.process(items)]
if not items:
re... | [
"async",
"def",
"add_items",
"(",
"self",
",",
"*",
"items",
")",
":",
"items",
"=",
"[",
"item",
".",
"id",
"for",
"item",
"in",
"await",
"self",
".",
"process",
"(",
"items",
")",
"]",
"if",
"not",
"items",
":",
"return",
"await",
"self",
".",
... | append items to the playlist
|coro|
Parameters
----------
items : array_like
list of items to add(or their ids)
See Also
--------
remove_items : | [
"append",
"items",
"to",
"the",
"playlist"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/folders.py#L129-L149 | train | 57,726 |
andy29485/embypy | embypy/objects/folders.py | Playlist.remove_items | async def remove_items(self, *items):
'''remove items from the playlist
|coro|
Parameters
----------
items : array_like
list of items to remove(or their ids)
See Also
--------
add_items :
'''
items = [i.id for i in (await self.process(items)) if i in self.items]
if... | python | async def remove_items(self, *items):
'''remove items from the playlist
|coro|
Parameters
----------
items : array_like
list of items to remove(or their ids)
See Also
--------
add_items :
'''
items = [i.id for i in (await self.process(items)) if i in self.items]
if... | [
"async",
"def",
"remove_items",
"(",
"self",
",",
"*",
"items",
")",
":",
"items",
"=",
"[",
"i",
".",
"id",
"for",
"i",
"in",
"(",
"await",
"self",
".",
"process",
"(",
"items",
")",
")",
"if",
"i",
"in",
"self",
".",
"items",
"]",
"if",
"not"... | remove items from the playlist
|coro|
Parameters
----------
items : array_like
list of items to remove(or their ids)
See Also
--------
add_items : | [
"remove",
"items",
"from",
"the",
"playlist"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/folders.py#L154-L176 | train | 57,727 |
andy29485/embypy | embypy/objects/folders.py | BoxSet.movies | async def movies(self):
'''list of movies in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Movie`
'''
items = []
for i in await self.items:
if i.type == 'Movie':
items.append(i)
elif hasattr(i, 'movies'):
items.... | python | async def movies(self):
'''list of movies in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Movie`
'''
items = []
for i in await self.items:
if i.type == 'Movie':
items.append(i)
elif hasattr(i, 'movies'):
items.... | [
"async",
"def",
"movies",
"(",
"self",
")",
":",
"items",
"=",
"[",
"]",
"for",
"i",
"in",
"await",
"self",
".",
"items",
":",
"if",
"i",
".",
"type",
"==",
"'Movie'",
":",
"items",
".",
"append",
"(",
"i",
")",
"elif",
"hasattr",
"(",
"i",
","... | list of movies in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Movie` | [
"list",
"of",
"movies",
"in",
"the",
"collection"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/folders.py#L196-L214 | train | 57,728 |
andy29485/embypy | embypy/objects/folders.py | BoxSet.series | async def series(self):
'''list of series in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Series`
'''
items = []
for i in await self.items:
if i.type == 'Series':
items.append(i)
elif hasattr(i, 'series'):
item... | python | async def series(self):
'''list of series in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Series`
'''
items = []
for i in await self.items:
if i.type == 'Series':
items.append(i)
elif hasattr(i, 'series'):
item... | [
"async",
"def",
"series",
"(",
"self",
")",
":",
"items",
"=",
"[",
"]",
"for",
"i",
"in",
"await",
"self",
".",
"items",
":",
"if",
"i",
".",
"type",
"==",
"'Series'",
":",
"items",
".",
"append",
"(",
"i",
")",
"elif",
"hasattr",
"(",
"i",
",... | list of series in the collection
|force|
|coro|
Returns
-------
list
of type :class:`embypy.objects.Series` | [
"list",
"of",
"series",
"in",
"the",
"collection"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/folders.py#L243-L261 | train | 57,729 |
tBaxter/activity-monitor | activity_monitor/models.py | Activity.save | def save(self, *args, **kwargs):
"""
Store a string representation of content_object as target
and actor name for fast retrieval and sorting.
"""
if not self.target:
self.target = str(self.content_object)
if not self.actor_name:
self.actor_name = s... | python | def save(self, *args, **kwargs):
"""
Store a string representation of content_object as target
and actor name for fast retrieval and sorting.
"""
if not self.target:
self.target = str(self.content_object)
if not self.actor_name:
self.actor_name = s... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"target",
":",
"self",
".",
"target",
"=",
"str",
"(",
"self",
".",
"content_object",
")",
"if",
"not",
"self",
".",
"actor_name",
":",
"se... | Store a string representation of content_object as target
and actor name for fast retrieval and sorting. | [
"Store",
"a",
"string",
"representation",
"of",
"content_object",
"as",
"target",
"and",
"actor",
"name",
"for",
"fast",
"retrieval",
"and",
"sorting",
"."
] | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/models.py#L43-L52 | train | 57,730 |
pwaller/__autoversion__ | __autoversion__.py | version_from_frame | def version_from_frame(frame):
"""
Given a ``frame``, obtain the version number of the module running there.
"""
module = getmodule(frame)
if module is None:
s = "<unknown from {0}:{1}>"
return s.format(frame.f_code.co_filename, frame.f_lineno)
module_name = module.__name__
... | python | def version_from_frame(frame):
"""
Given a ``frame``, obtain the version number of the module running there.
"""
module = getmodule(frame)
if module is None:
s = "<unknown from {0}:{1}>"
return s.format(frame.f_code.co_filename, frame.f_lineno)
module_name = module.__name__
... | [
"def",
"version_from_frame",
"(",
"frame",
")",
":",
"module",
"=",
"getmodule",
"(",
"frame",
")",
"if",
"module",
"is",
"None",
":",
"s",
"=",
"\"<unknown from {0}:{1}>\"",
"return",
"s",
".",
"format",
"(",
"frame",
".",
"f_code",
".",
"co_filename",
",... | Given a ``frame``, obtain the version number of the module running there. | [
"Given",
"a",
"frame",
"obtain",
"the",
"version",
"number",
"of",
"the",
"module",
"running",
"there",
"."
] | caaaff2c5a758388cdd6117fed0847fb4cd103f5 | https://github.com/pwaller/__autoversion__/blob/caaaff2c5a758388cdd6117fed0847fb4cd103f5/__autoversion__.py#L104-L133 | train | 57,731 |
pwaller/__autoversion__ | __autoversion__.py | try_fix_num | def try_fix_num(n):
"""
Return ``n`` as an integer if it is numeric, otherwise return the input
"""
if not n.isdigit():
return n
if n.startswith("0"):
n = n.lstrip("0")
if not n:
n = "0"
return int(n) | python | def try_fix_num(n):
"""
Return ``n`` as an integer if it is numeric, otherwise return the input
"""
if not n.isdigit():
return n
if n.startswith("0"):
n = n.lstrip("0")
if not n:
n = "0"
return int(n) | [
"def",
"try_fix_num",
"(",
"n",
")",
":",
"if",
"not",
"n",
".",
"isdigit",
"(",
")",
":",
"return",
"n",
"if",
"n",
".",
"startswith",
"(",
"\"0\"",
")",
":",
"n",
"=",
"n",
".",
"lstrip",
"(",
"\"0\"",
")",
"if",
"not",
"n",
":",
"n",
"=",
... | Return ``n`` as an integer if it is numeric, otherwise return the input | [
"Return",
"n",
"as",
"an",
"integer",
"if",
"it",
"is",
"numeric",
"otherwise",
"return",
"the",
"input"
] | caaaff2c5a758388cdd6117fed0847fb4cd103f5 | https://github.com/pwaller/__autoversion__/blob/caaaff2c5a758388cdd6117fed0847fb4cd103f5/__autoversion__.py#L136-L146 | train | 57,732 |
pwaller/__autoversion__ | __autoversion__.py | tupleize_version | def tupleize_version(version):
"""
Split ``version`` into a lexicographically comparable tuple.
"1.0.3" -> ((1, 0, 3),)
"1.0.3-dev" -> ((1, 0, 3), ("dev",))
"1.0.3-rc-5" -> ((1, 0, 3), ("rc",), (5,))
"""
if version is None:
return (("unknown",),)
if version.startswith("<unknow... | python | def tupleize_version(version):
"""
Split ``version`` into a lexicographically comparable tuple.
"1.0.3" -> ((1, 0, 3),)
"1.0.3-dev" -> ((1, 0, 3), ("dev",))
"1.0.3-rc-5" -> ((1, 0, 3), ("rc",), (5,))
"""
if version is None:
return (("unknown",),)
if version.startswith("<unknow... | [
"def",
"tupleize_version",
"(",
"version",
")",
":",
"if",
"version",
"is",
"None",
":",
"return",
"(",
"(",
"\"unknown\"",
",",
")",
",",
")",
"if",
"version",
".",
"startswith",
"(",
"\"<unknown\"",
")",
":",
"return",
"(",
"(",
"\"unknown\"",
",",
"... | Split ``version`` into a lexicographically comparable tuple.
"1.0.3" -> ((1, 0, 3),)
"1.0.3-dev" -> ((1, 0, 3), ("dev",))
"1.0.3-rc-5" -> ((1, 0, 3), ("rc",), (5,)) | [
"Split",
"version",
"into",
"a",
"lexicographically",
"comparable",
"tuple",
"."
] | caaaff2c5a758388cdd6117fed0847fb4cd103f5 | https://github.com/pwaller/__autoversion__/blob/caaaff2c5a758388cdd6117fed0847fb4cd103f5/__autoversion__.py#L149-L172 | train | 57,733 |
pwaller/__autoversion__ | __autoversion__.py | Git.get_version | def get_version(cls, path, memo={}):
"""
Return a string describing the version of the repository at ``path`` if
possible, otherwise throws ``subprocess.CalledProcessError``.
(Note: memoizes the result in the ``memo`` parameter)
"""
if path not in memo:
memo[... | python | def get_version(cls, path, memo={}):
"""
Return a string describing the version of the repository at ``path`` if
possible, otherwise throws ``subprocess.CalledProcessError``.
(Note: memoizes the result in the ``memo`` parameter)
"""
if path not in memo:
memo[... | [
"def",
"get_version",
"(",
"cls",
",",
"path",
",",
"memo",
"=",
"{",
"}",
")",
":",
"if",
"path",
"not",
"in",
"memo",
":",
"memo",
"[",
"path",
"]",
"=",
"subprocess",
".",
"check_output",
"(",
"\"git describe --tags --dirty 2> /dev/null\"",
",",
"shell"... | Return a string describing the version of the repository at ``path`` if
possible, otherwise throws ``subprocess.CalledProcessError``.
(Note: memoizes the result in the ``memo`` parameter) | [
"Return",
"a",
"string",
"describing",
"the",
"version",
"of",
"the",
"repository",
"at",
"path",
"if",
"possible",
"otherwise",
"throws",
"subprocess",
".",
"CalledProcessError",
"."
] | caaaff2c5a758388cdd6117fed0847fb4cd103f5 | https://github.com/pwaller/__autoversion__/blob/caaaff2c5a758388cdd6117fed0847fb4cd103f5/__autoversion__.py#L41-L59 | train | 57,734 |
pwaller/__autoversion__ | __autoversion__.py | Git.is_repo_instance | def is_repo_instance(cls, path):
"""
Return ``True`` if ``path`` is a source controlled repository.
"""
try:
cls.get_version(path)
return True
except subprocess.CalledProcessError:
# Git returns non-zero status
return False
... | python | def is_repo_instance(cls, path):
"""
Return ``True`` if ``path`` is a source controlled repository.
"""
try:
cls.get_version(path)
return True
except subprocess.CalledProcessError:
# Git returns non-zero status
return False
... | [
"def",
"is_repo_instance",
"(",
"cls",
",",
"path",
")",
":",
"try",
":",
"cls",
".",
"get_version",
"(",
"path",
")",
"return",
"True",
"except",
"subprocess",
".",
"CalledProcessError",
":",
"# Git returns non-zero status",
"return",
"False",
"except",
"OSErro... | Return ``True`` if ``path`` is a source controlled repository. | [
"Return",
"True",
"if",
"path",
"is",
"a",
"source",
"controlled",
"repository",
"."
] | caaaff2c5a758388cdd6117fed0847fb4cd103f5 | https://github.com/pwaller/__autoversion__/blob/caaaff2c5a758388cdd6117fed0847fb4cd103f5/__autoversion__.py#L62-L74 | train | 57,735 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | _sort_modules | def _sort_modules(mods):
""" Always sort `index` or `README` as first filename in list. """
def compare(x, y):
x = x[1]
y = y[1]
if x == y:
return 0
if y.stem == "__init__.py":
return 1
if x.stem == "__init__.py" or x < y:
return -1
... | python | def _sort_modules(mods):
""" Always sort `index` or `README` as first filename in list. """
def compare(x, y):
x = x[1]
y = y[1]
if x == y:
return 0
if y.stem == "__init__.py":
return 1
if x.stem == "__init__.py" or x < y:
return -1
... | [
"def",
"_sort_modules",
"(",
"mods",
")",
":",
"def",
"compare",
"(",
"x",
",",
"y",
")",
":",
"x",
"=",
"x",
"[",
"1",
"]",
"y",
"=",
"y",
"[",
"1",
"]",
"if",
"x",
"==",
"y",
":",
"return",
"0",
"if",
"y",
".",
"stem",
"==",
"\"__init__.p... | Always sort `index` or `README` as first filename in list. | [
"Always",
"sort",
"index",
"or",
"README",
"as",
"first",
"filename",
"in",
"list",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L28-L42 | train | 57,736 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | refs_section | def refs_section(doc):
"""
Generate a References section.
Parameters
----------
doc : dict
Dictionary produced by numpydoc
Returns
-------
list of str
Markdown for references section
"""
lines = []
if "References" in doc and len(doc["References"]) > 0:
... | python | def refs_section(doc):
"""
Generate a References section.
Parameters
----------
doc : dict
Dictionary produced by numpydoc
Returns
-------
list of str
Markdown for references section
"""
lines = []
if "References" in doc and len(doc["References"]) > 0:
... | [
"def",
"refs_section",
"(",
"doc",
")",
":",
"lines",
"=",
"[",
"]",
"if",
"\"References\"",
"in",
"doc",
"and",
"len",
"(",
"doc",
"[",
"\"References\"",
"]",
")",
">",
"0",
":",
"# print(\"Found refs\")",
"for",
"ref",
"in",
"doc",
"[",
"\"References\"... | Generate a References section.
Parameters
----------
doc : dict
Dictionary produced by numpydoc
Returns
-------
list of str
Markdown for references section | [
"Generate",
"a",
"References",
"section",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L231-L256 | train | 57,737 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | examples_section | def examples_section(doc, header_level):
"""
Generate markdown for Examples section.
Parameters
----------
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
Markdown for examples section
"""
... | python | def examples_section(doc, header_level):
"""
Generate markdown for Examples section.
Parameters
----------
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
Markdown for examples section
"""
... | [
"def",
"examples_section",
"(",
"doc",
",",
"header_level",
")",
":",
"lines",
"=",
"[",
"]",
"if",
"\"Examples\"",
"in",
"doc",
"and",
"len",
"(",
"doc",
"[",
"\"Examples\"",
"]",
")",
">",
"0",
":",
"lines",
".",
"append",
"(",
"f\"{'#'*(header_level+1... | Generate markdown for Examples section.
Parameters
----------
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
Markdown for examples section | [
"Generate",
"markdown",
"for",
"Examples",
"section",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L259-L280 | train | 57,738 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | returns_section | def returns_section(thing, doc, header_level):
"""
Generate markdown for Returns section.
Parameters
----------
thing : function
Function to produce returns for
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------... | python | def returns_section(thing, doc, header_level):
"""
Generate markdown for Returns section.
Parameters
----------
thing : function
Function to produce returns for
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------... | [
"def",
"returns_section",
"(",
"thing",
",",
"doc",
",",
"header_level",
")",
":",
"lines",
"=",
"[",
"]",
"return_type",
"=",
"None",
"try",
":",
"return_type",
"=",
"thing",
".",
"__annotations__",
"[",
"\"return\"",
"]",
"except",
"AttributeError",
":",
... | Generate markdown for Returns section.
Parameters
----------
thing : function
Function to produce returns for
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
Markdown for examples section | [
"Generate",
"markdown",
"for",
"Returns",
"section",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L283-L357 | train | 57,739 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | summary | def summary(doc):
"""
Generate markdown for summary section.
Parameters
----------
doc : dict
Output from numpydoc
Returns
-------
list of str
Markdown strings
"""
lines = []
if "Summary" in doc and len(doc["Summary"]) > 0:
lines.append(fix_footnotes... | python | def summary(doc):
"""
Generate markdown for summary section.
Parameters
----------
doc : dict
Output from numpydoc
Returns
-------
list of str
Markdown strings
"""
lines = []
if "Summary" in doc and len(doc["Summary"]) > 0:
lines.append(fix_footnotes... | [
"def",
"summary",
"(",
"doc",
")",
":",
"lines",
"=",
"[",
"]",
"if",
"\"Summary\"",
"in",
"doc",
"and",
"len",
"(",
"doc",
"[",
"\"Summary\"",
"]",
")",
">",
"0",
":",
"lines",
".",
"append",
"(",
"fix_footnotes",
"(",
"\" \"",
".",
"join",
"(",
... | Generate markdown for summary section.
Parameters
----------
doc : dict
Output from numpydoc
Returns
-------
list of str
Markdown strings | [
"Generate",
"markdown",
"for",
"summary",
"section",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L360-L381 | train | 57,740 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | params_section | def params_section(thing, doc, header_level):
"""
Generate markdown for Parameters section.
Parameters
----------
thing : functuon
Function to produce parameters from
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-... | python | def params_section(thing, doc, header_level):
"""
Generate markdown for Parameters section.
Parameters
----------
thing : functuon
Function to produce parameters from
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-... | [
"def",
"params_section",
"(",
"thing",
",",
"doc",
",",
"header_level",
")",
":",
"lines",
"=",
"[",
"]",
"class_doc",
"=",
"doc",
"[",
"\"Parameters\"",
"]",
"return",
"type_list",
"(",
"inspect",
".",
"signature",
"(",
"thing",
")",
",",
"class_doc",
"... | Generate markdown for Parameters section.
Parameters
----------
thing : functuon
Function to produce parameters from
doc : dict
Dict from numpydoc
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
Markdown for examples secti... | [
"Generate",
"markdown",
"for",
"Parameters",
"section",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L384-L409 | train | 57,741 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | string_annotation | def string_annotation(typ, default):
"""
Construct a string representation of a type annotation.
Parameters
----------
typ : type
Type to turn into a string
default : any
Default value (if any) of the type
Returns
-------
str
String version of the type annot... | python | def string_annotation(typ, default):
"""
Construct a string representation of a type annotation.
Parameters
----------
typ : type
Type to turn into a string
default : any
Default value (if any) of the type
Returns
-------
str
String version of the type annot... | [
"def",
"string_annotation",
"(",
"typ",
",",
"default",
")",
":",
"try",
":",
"type_string",
"=",
"(",
"f\"`{typ.__name__}`\"",
"if",
"typ",
".",
"__module__",
"==",
"\"builtins\"",
"else",
"f\"`{typ.__module__}.{typ.__name__}`\"",
")",
"except",
"AttributeError",
"... | Construct a string representation of a type annotation.
Parameters
----------
typ : type
Type to turn into a string
default : any
Default value (if any) of the type
Returns
-------
str
String version of the type annotation | [
"Construct",
"a",
"string",
"representation",
"of",
"a",
"type",
"annotation",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L519-L549 | train | 57,742 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | type_list | def type_list(signature, doc, header):
"""
Construct a list of types, preferring type annotations to
docstrings if they are available.
Parameters
----------
signature : Signature
Signature of thing
doc : list of tuple
Numpydoc's type list section
Returns
-------
... | python | def type_list(signature, doc, header):
"""
Construct a list of types, preferring type annotations to
docstrings if they are available.
Parameters
----------
signature : Signature
Signature of thing
doc : list of tuple
Numpydoc's type list section
Returns
-------
... | [
"def",
"type_list",
"(",
"signature",
",",
"doc",
",",
"header",
")",
":",
"lines",
"=",
"[",
"]",
"docced",
"=",
"set",
"(",
")",
"lines",
".",
"append",
"(",
"header",
")",
"try",
":",
"for",
"names",
",",
"types",
",",
"description",
"in",
"doc"... | Construct a list of types, preferring type annotations to
docstrings if they are available.
Parameters
----------
signature : Signature
Signature of thing
doc : list of tuple
Numpydoc's type list section
Returns
-------
list of str
Markdown formatted type list | [
"Construct",
"a",
"list",
"of",
"types",
"preferring",
"type",
"annotations",
"to",
"docstrings",
"if",
"they",
"are",
"available",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L552-L612 | train | 57,743 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | attributes_section | def attributes_section(thing, doc, header_level):
"""
Generate an attributes section for classes.
Prefers type annotations, if they are present.
Parameters
----------
thing : class
Class to document
doc : dict
Numpydoc output
header_level : int
Number of `#`s to... | python | def attributes_section(thing, doc, header_level):
"""
Generate an attributes section for classes.
Prefers type annotations, if they are present.
Parameters
----------
thing : class
Class to document
doc : dict
Numpydoc output
header_level : int
Number of `#`s to... | [
"def",
"attributes_section",
"(",
"thing",
",",
"doc",
",",
"header_level",
")",
":",
"# Get Attributes",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"thing",
")",
":",
"return",
"[",
"]",
"props",
",",
"class_doc",
"=",
"_split_props",
"(",
"thing",
",",... | Generate an attributes section for classes.
Prefers type annotations, if they are present.
Parameters
----------
thing : class
Class to document
doc : dict
Numpydoc output
header_level : int
Number of `#`s to use for header
Returns
-------
list of str
... | [
"Generate",
"an",
"attributes",
"section",
"for",
"classes",
"."
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L635-L666 | train | 57,744 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | enum_doc | def enum_doc(name, enum, header_level, source_location):
"""
Generate markdown for an enum
Parameters
----------
name : str
Name of the thing being documented
enum : EnumMeta
Enum to document
header_level : int
Heading level
source_location : str
URL of r... | python | def enum_doc(name, enum, header_level, source_location):
"""
Generate markdown for an enum
Parameters
----------
name : str
Name of the thing being documented
enum : EnumMeta
Enum to document
header_level : int
Heading level
source_location : str
URL of r... | [
"def",
"enum_doc",
"(",
"name",
",",
"enum",
",",
"header_level",
",",
"source_location",
")",
":",
"lines",
"=",
"[",
"f\"{'#'*header_level} Enum **{name}**\\n\\n\"",
"]",
"lines",
".",
"append",
"(",
"f\"```python\\n{name}\\n```\\n\"",
")",
"lines",
".",
"append",... | Generate markdown for an enum
Parameters
----------
name : str
Name of the thing being documented
enum : EnumMeta
Enum to document
header_level : int
Heading level
source_location : str
URL of repo containing source code | [
"Generate",
"markdown",
"for",
"an",
"enum"
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L669-L695 | train | 57,745 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | to_doc | def to_doc(name, thing, header_level, source_location):
"""
Generate markdown for a class or function
Parameters
----------
name : str
Name of the thing being documented
thing : class or function
Class or function to document
header_level : int
Heading level
sour... | python | def to_doc(name, thing, header_level, source_location):
"""
Generate markdown for a class or function
Parameters
----------
name : str
Name of the thing being documented
thing : class or function
Class or function to document
header_level : int
Heading level
sour... | [
"def",
"to_doc",
"(",
"name",
",",
"thing",
",",
"header_level",
",",
"source_location",
")",
":",
"if",
"type",
"(",
"thing",
")",
"is",
"enum",
".",
"EnumMeta",
":",
"return",
"enum_doc",
"(",
"name",
",",
"thing",
",",
"header_level",
",",
"source_loc... | Generate markdown for a class or function
Parameters
----------
name : str
Name of the thing being documented
thing : class or function
Class or function to document
header_level : int
Heading level
source_location : str
URL of repo containing source code | [
"Generate",
"markdown",
"for",
"a",
"class",
"or",
"function"
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L698-L738 | train | 57,746 |
greenape/mktheapidocs | mktheapidocs/mkapi.py | doc_module | def doc_module(module_name, module, output_dir, source_location, leaf):
"""
Document a module
Parameters
----------
module_name : str
module : module
output_dir : str
source_location : str
leaf : bool
"""
path = pathlib.Path(output_dir).joinpath(*module.__name__.split("."))
... | python | def doc_module(module_name, module, output_dir, source_location, leaf):
"""
Document a module
Parameters
----------
module_name : str
module : module
output_dir : str
source_location : str
leaf : bool
"""
path = pathlib.Path(output_dir).joinpath(*module.__name__.split("."))
... | [
"def",
"doc_module",
"(",
"module_name",
",",
"module",
",",
"output_dir",
",",
"source_location",
",",
"leaf",
")",
":",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"output_dir",
")",
".",
"joinpath",
"(",
"*",
"module",
".",
"__name__",
".",
"split",
"("... | Document a module
Parameters
----------
module_name : str
module : module
output_dir : str
source_location : str
leaf : bool | [
"Document",
"a",
"module"
] | a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7 | https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L741-L789 | train | 57,747 |
MisanthropicBit/colorise | colorise/__init__.py | set_color | def set_color(fg=None, bg=None):
"""Set the current colors.
If no arguments are given, sets default colors.
"""
if fg or bg:
_color_manager.set_color(fg, bg)
else:
_color_manager.set_defaults() | python | def set_color(fg=None, bg=None):
"""Set the current colors.
If no arguments are given, sets default colors.
"""
if fg or bg:
_color_manager.set_color(fg, bg)
else:
_color_manager.set_defaults() | [
"def",
"set_color",
"(",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
")",
":",
"if",
"fg",
"or",
"bg",
":",
"_color_manager",
".",
"set_color",
"(",
"fg",
",",
"bg",
")",
"else",
":",
"_color_manager",
".",
"set_defaults",
"(",
")"
] | Set the current colors.
If no arguments are given, sets default colors. | [
"Set",
"the",
"current",
"colors",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L69-L78 | train | 57,748 |
MisanthropicBit/colorise | colorise/__init__.py | cprint | def cprint(string, fg=None, bg=None, end='\n', target=sys.stdout):
"""Print a colored string to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in print
function. Colors are returned to their defaul... | python | def cprint(string, fg=None, bg=None, end='\n', target=sys.stdout):
"""Print a colored string to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in print
function. Colors are returned to their defaul... | [
"def",
"cprint",
"(",
"string",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"end",
"=",
"'\\n'",
",",
"target",
"=",
"sys",
".",
"stdout",
")",
":",
"_color_manager",
".",
"set_color",
"(",
"fg",
",",
"bg",
")",
"target",
".",
"write",
"... | Print a colored string to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in print
function. Colors are returned to their defaults before the function
returns. | [
"Print",
"a",
"colored",
"string",
"to",
"the",
"target",
"handle",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L81-L93 | train | 57,749 |
MisanthropicBit/colorise | colorise/__init__.py | fprint | def fprint(fmt, *args, **kwargs):
"""Parse and print a colored and perhaps formatted string.
The remaining keyword arguments are the same as for Python's built-in print
function. Colors are returning to their defaults before the function
returns.
"""
if not fmt:
return
hascolor = ... | python | def fprint(fmt, *args, **kwargs):
"""Parse and print a colored and perhaps formatted string.
The remaining keyword arguments are the same as for Python's built-in print
function. Colors are returning to their defaults before the function
returns.
"""
if not fmt:
return
hascolor = ... | [
"def",
"fprint",
"(",
"fmt",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"fmt",
":",
"return",
"hascolor",
"=",
"False",
"target",
"=",
"kwargs",
".",
"get",
"(",
"\"target\"",
",",
"sys",
".",
"stdout",
")",
"# Format the strin... | Parse and print a colored and perhaps formatted string.
The remaining keyword arguments are the same as for Python's built-in print
function. Colors are returning to their defaults before the function
returns. | [
"Parse",
"and",
"print",
"a",
"colored",
"and",
"perhaps",
"formatted",
"string",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L96-L127 | train | 57,750 |
MisanthropicBit/colorise | colorise/__init__.py | formatcolor | def formatcolor(string, fg=None, bg=None):
"""Wrap color syntax around a string and return it.
fg and bg specify foreground- and background colors, respectively.
"""
if fg is bg is None:
return string
temp = (['fg='+fg] if fg else []) +\
(['bg='+bg] if bg else [])
fmt = _co... | python | def formatcolor(string, fg=None, bg=None):
"""Wrap color syntax around a string and return it.
fg and bg specify foreground- and background colors, respectively.
"""
if fg is bg is None:
return string
temp = (['fg='+fg] if fg else []) +\
(['bg='+bg] if bg else [])
fmt = _co... | [
"def",
"formatcolor",
"(",
"string",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
")",
":",
"if",
"fg",
"is",
"bg",
"is",
"None",
":",
"return",
"string",
"temp",
"=",
"(",
"[",
"'fg='",
"+",
"fg",
"]",
"if",
"fg",
"else",
"[",
"]",
")",
"... | Wrap color syntax around a string and return it.
fg and bg specify foreground- and background colors, respectively. | [
"Wrap",
"color",
"syntax",
"around",
"a",
"string",
"and",
"return",
"it",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L130-L145 | train | 57,751 |
MisanthropicBit/colorise | colorise/__init__.py | formatbyindex | def formatbyindex(string, fg=None, bg=None, indices=[]):
"""Wrap color syntax around characters using indices and return it.
fg and bg specify foreground- and background colors, respectively.
"""
if not string or not indices or (fg is bg is None):
return string
result, p = '', 0
# Th... | python | def formatbyindex(string, fg=None, bg=None, indices=[]):
"""Wrap color syntax around characters using indices and return it.
fg and bg specify foreground- and background colors, respectively.
"""
if not string or not indices or (fg is bg is None):
return string
result, p = '', 0
# Th... | [
"def",
"formatbyindex",
"(",
"string",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"indices",
"=",
"[",
"]",
")",
":",
"if",
"not",
"string",
"or",
"not",
"indices",
"or",
"(",
"fg",
"is",
"bg",
"is",
"None",
")",
":",
"return",
"string"... | Wrap color syntax around characters using indices and return it.
fg and bg specify foreground- and background colors, respectively. | [
"Wrap",
"color",
"syntax",
"around",
"characters",
"using",
"indices",
"and",
"return",
"it",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L148-L173 | train | 57,752 |
MisanthropicBit/colorise | colorise/__init__.py | highlight | def highlight(string, fg=None, bg=None, indices=[], end='\n',
target=sys.stdout):
"""Highlight characters using indices and print it to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in p... | python | def highlight(string, fg=None, bg=None, indices=[], end='\n',
target=sys.stdout):
"""Highlight characters using indices and print it to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in p... | [
"def",
"highlight",
"(",
"string",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"indices",
"=",
"[",
"]",
",",
"end",
"=",
"'\\n'",
",",
"target",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"not",
"string",
"or",
"not",
"indices",
"or",
... | Highlight characters using indices and print it to the target handle.
fg and bg specify foreground- and background colors, respectively. The
remaining keyword arguments are the same as for Python's built-in print
function. | [
"Highlight",
"characters",
"using",
"indices",
"and",
"print",
"it",
"to",
"the",
"target",
"handle",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L176-L206 | train | 57,753 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | create_param_info | def create_param_info(task_params, parameter_map):
"""
Builds the code block for the GPTool GetParameterInfo method based on the input task_params.
:param task_params: A list of task parameters to map to GPTool parameters.
:return: A string representing the code block to the GPTool GetParameterInfo met... | python | def create_param_info(task_params, parameter_map):
"""
Builds the code block for the GPTool GetParameterInfo method based on the input task_params.
:param task_params: A list of task parameters to map to GPTool parameters.
:return: A string representing the code block to the GPTool GetParameterInfo met... | [
"def",
"create_param_info",
"(",
"task_params",
",",
"parameter_map",
")",
":",
"gp_params",
"=",
"[",
"]",
"gp_param_list",
"=",
"[",
"]",
"gp_param_idx_list",
"=",
"[",
"]",
"gp_param_idx",
"=",
"0",
"for",
"task_param",
"in",
"task_params",
":",
"# Setup to... | Builds the code block for the GPTool GetParameterInfo method based on the input task_params.
:param task_params: A list of task parameters to map to GPTool parameters.
:return: A string representing the code block to the GPTool GetParameterInfo method. | [
"Builds",
"the",
"code",
"block",
"for",
"the",
"GPTool",
"GetParameterInfo",
"method",
"based",
"on",
"the",
"input",
"task_params",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L100-L163 | train | 57,754 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | create_update_parameter | def create_update_parameter(task_params, parameter_map):
"""
Builds the code block for the GPTool UpdateParameter method based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool UpdateParamete... | python | def create_update_parameter(task_params, parameter_map):
"""
Builds the code block for the GPTool UpdateParameter method based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool UpdateParamete... | [
"def",
"create_update_parameter",
"(",
"task_params",
",",
"parameter_map",
")",
":",
"gp_params",
"=",
"[",
"]",
"for",
"param",
"in",
"task_params",
":",
"if",
"param",
"[",
"'direction'",
"]",
".",
"upper",
"(",
")",
"==",
"'OUTPUT'",
":",
"continue",
"... | Builds the code block for the GPTool UpdateParameter method based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool UpdateParameter method. | [
"Builds",
"the",
"code",
"block",
"for",
"the",
"GPTool",
"UpdateParameter",
"method",
"based",
"on",
"the",
"input",
"task_params",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L166-L186 | train | 57,755 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | create_pre_execute | def create_pre_execute(task_params, parameter_map):
"""
Builds the code block for the GPTool Execute method before the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GP... | python | def create_pre_execute(task_params, parameter_map):
"""
Builds the code block for the GPTool Execute method before the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GP... | [
"def",
"create_pre_execute",
"(",
"task_params",
",",
"parameter_map",
")",
":",
"gp_params",
"=",
"[",
"_PRE_EXECUTE_INIT_TEMPLATE",
"]",
"for",
"task_param",
"in",
"task_params",
":",
"if",
"task_param",
"[",
"'direction'",
"]",
".",
"upper",
"(",
")",
"==",
... | Builds the code block for the GPTool Execute method before the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool Execute method. | [
"Builds",
"the",
"code",
"block",
"for",
"the",
"GPTool",
"Execute",
"method",
"before",
"the",
"job",
"is",
"submitted",
"based",
"on",
"the",
"input",
"task_params",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L207-L229 | train | 57,756 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | create_post_execute | def create_post_execute(task_params, parameter_map):
"""
Builds the code block for the GPTool Execute method after the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GP... | python | def create_post_execute(task_params, parameter_map):
"""
Builds the code block for the GPTool Execute method after the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GP... | [
"def",
"create_post_execute",
"(",
"task_params",
",",
"parameter_map",
")",
":",
"gp_params",
"=",
"[",
"]",
"for",
"task_param",
"in",
"task_params",
":",
"if",
"task_param",
"[",
"'direction'",
"]",
".",
"upper",
"(",
")",
"==",
"'INPUT'",
":",
"continue"... | Builds the code block for the GPTool Execute method after the job is
submitted based on the input task_params.
:param task_params: A list of task parameters from the task info structure.
:return: A string representing the code block to the GPTool Execute method. | [
"Builds",
"the",
"code",
"block",
"for",
"the",
"GPTool",
"Execute",
"method",
"after",
"the",
"job",
"is",
"submitted",
"based",
"on",
"the",
"input",
"task_params",
"."
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L232-L254 | train | 57,757 |
envi-idl/envipyarclib | envipyarclib/gptool/parameter/builder.py | ParameterMap.load_default_templates | def load_default_templates(self):
"""Load the default templates"""
for importer, modname, is_pkg in pkgutil.iter_modules(templates.__path__):
self.register_template('.'.join((templates.__name__, modname))) | python | def load_default_templates(self):
"""Load the default templates"""
for importer, modname, is_pkg in pkgutil.iter_modules(templates.__path__):
self.register_template('.'.join((templates.__name__, modname))) | [
"def",
"load_default_templates",
"(",
"self",
")",
":",
"for",
"importer",
",",
"modname",
",",
"is_pkg",
"in",
"pkgutil",
".",
"iter_modules",
"(",
"templates",
".",
"__path__",
")",
":",
"self",
".",
"register_template",
"(",
"'.'",
".",
"join",
"(",
"("... | Load the default templates | [
"Load",
"the",
"default",
"templates"
] | 90135652510c3d53c5f51177252c1fea2639bf22 | https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/gptool/parameter/builder.py#L70-L73 | train | 57,758 |
ponty/confduino | confduino/hwpackremove.py | remove_hwpack | def remove_hwpack(name):
"""remove hardware package.
:param name: hardware package name (e.g. 'Sanguino')
:rtype: None
"""
targ_dlib = hwpack_dir() / name
log.debug('remove %s', targ_dlib)
targ_dlib.rmtree() | python | def remove_hwpack(name):
"""remove hardware package.
:param name: hardware package name (e.g. 'Sanguino')
:rtype: None
"""
targ_dlib = hwpack_dir() / name
log.debug('remove %s', targ_dlib)
targ_dlib.rmtree() | [
"def",
"remove_hwpack",
"(",
"name",
")",
":",
"targ_dlib",
"=",
"hwpack_dir",
"(",
")",
"/",
"name",
"log",
".",
"debug",
"(",
"'remove %s'",
",",
"targ_dlib",
")",
"targ_dlib",
".",
"rmtree",
"(",
")"
] | remove hardware package.
:param name: hardware package name (e.g. 'Sanguino')
:rtype: None | [
"remove",
"hardware",
"package",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/hwpackremove.py#L9-L18 | train | 57,759 |
pbrisk/timewave | timewave/stochasticconsumer.py | StatisticsConsumer.finalize | def finalize(self):
"""finalize for StatisticsConsumer"""
super(StatisticsConsumer, self).finalize()
# run statistics on timewave slice w at grid point g
# self.result = [(g, self.statistics(w)) for g, w in zip(self.grid, self.result)]
# self.result = zip(self.grid, (self.statist... | python | def finalize(self):
"""finalize for StatisticsConsumer"""
super(StatisticsConsumer, self).finalize()
# run statistics on timewave slice w at grid point g
# self.result = [(g, self.statistics(w)) for g, w in zip(self.grid, self.result)]
# self.result = zip(self.grid, (self.statist... | [
"def",
"finalize",
"(",
"self",
")",
":",
"super",
"(",
"StatisticsConsumer",
",",
"self",
")",
".",
"finalize",
"(",
")",
"# run statistics on timewave slice w at grid point g",
"# self.result = [(g, self.statistics(w)) for g, w in zip(self.grid, self.result)]",
"# self.result =... | finalize for StatisticsConsumer | [
"finalize",
"for",
"StatisticsConsumer"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/stochasticconsumer.py#L63-L69 | train | 57,760 |
pbrisk/timewave | timewave/stochasticconsumer.py | StochasticProcessStatisticsConsumer.finalize | def finalize(self):
"""finalize for StochasticProcessStatisticsConsumer"""
super(StochasticProcessStatisticsConsumer, self).finalize()
class StochasticProcessStatistics(self.statistics):
"""local version to store statistics"""
def __str__(self):
s = [k.r... | python | def finalize(self):
"""finalize for StochasticProcessStatisticsConsumer"""
super(StochasticProcessStatisticsConsumer, self).finalize()
class StochasticProcessStatistics(self.statistics):
"""local version to store statistics"""
def __str__(self):
s = [k.r... | [
"def",
"finalize",
"(",
"self",
")",
":",
"super",
"(",
"StochasticProcessStatisticsConsumer",
",",
"self",
")",
".",
"finalize",
"(",
")",
"class",
"StochasticProcessStatistics",
"(",
"self",
".",
"statistics",
")",
":",
"\"\"\"local version to store statistics\"\"\"... | finalize for StochasticProcessStatisticsConsumer | [
"finalize",
"for",
"StochasticProcessStatisticsConsumer"
] | cf641391d1607a424042724c8b990d43ee270ef6 | https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/stochasticconsumer.py#L77-L105 | train | 57,761 |
contains-io/rcli | rcli/autodetect.py | setup_keyword | def setup_keyword(dist, _, value):
# type: (setuptools.dist.Distribution, str, bool) -> None
"""Add autodetected commands as entry points.
Args:
dist: The distutils Distribution object for the project being
installed.
_: The keyword used in the setup function. Unused.
va... | python | def setup_keyword(dist, _, value):
# type: (setuptools.dist.Distribution, str, bool) -> None
"""Add autodetected commands as entry points.
Args:
dist: The distutils Distribution object for the project being
installed.
_: The keyword used in the setup function. Unused.
va... | [
"def",
"setup_keyword",
"(",
"dist",
",",
"_",
",",
"value",
")",
":",
"# type: (setuptools.dist.Distribution, str, bool) -> None",
"if",
"value",
"is",
"not",
"True",
":",
"return",
"dist",
".",
"entry_points",
"=",
"_ensure_entry_points_is_dict",
"(",
"dist",
".",... | Add autodetected commands as entry points.
Args:
dist: The distutils Distribution object for the project being
installed.
_: The keyword used in the setup function. Unused.
value: The value set to the keyword in the setup function. If the value
is not True, this func... | [
"Add",
"autodetected",
"commands",
"as",
"entry",
"points",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L30-L51 | train | 57,762 |
contains-io/rcli | rcli/autodetect.py | egg_info_writer | def egg_info_writer(cmd, basename, filename):
# type: (setuptools.command.egg_info.egg_info, str, str) -> None
"""Read rcli configuration and write it out to the egg info.
Args:
cmd: An egg info command instance to use for writing.
basename: The basename of the file to write.
filena... | python | def egg_info_writer(cmd, basename, filename):
# type: (setuptools.command.egg_info.egg_info, str, str) -> None
"""Read rcli configuration and write it out to the egg info.
Args:
cmd: An egg info command instance to use for writing.
basename: The basename of the file to write.
filena... | [
"def",
"egg_info_writer",
"(",
"cmd",
",",
"basename",
",",
"filename",
")",
":",
"# type: (setuptools.command.egg_info.egg_info, str, str) -> None",
"setupcfg",
"=",
"next",
"(",
"(",
"f",
"for",
"f",
"in",
"setuptools",
".",
"findall",
"(",
")",
"if",
"os",
".... | Read rcli configuration and write it out to the egg info.
Args:
cmd: An egg info command instance to use for writing.
basename: The basename of the file to write.
filename: The full path of the file to write into the egg info. | [
"Read",
"rcli",
"configuration",
"and",
"write",
"it",
"out",
"to",
"the",
"egg",
"info",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L66-L94 | train | 57,763 |
contains-io/rcli | rcli/autodetect.py | _get_commands | def _get_commands(dist # type: setuptools.dist.Distribution
):
# type: (...) -> typing.Dict[str, typing.Set[str]]
"""Find all commands belonging to the given distribution.
Args:
dist: The Distribution to search for docopt-compatible docstrings that
can be used to gene... | python | def _get_commands(dist # type: setuptools.dist.Distribution
):
# type: (...) -> typing.Dict[str, typing.Set[str]]
"""Find all commands belonging to the given distribution.
Args:
dist: The Distribution to search for docopt-compatible docstrings that
can be used to gene... | [
"def",
"_get_commands",
"(",
"dist",
"# type: setuptools.dist.Distribution",
")",
":",
"# type: (...) -> typing.Dict[str, typing.Set[str]]",
"py_files",
"=",
"(",
"f",
"for",
"f",
"in",
"setuptools",
".",
"findall",
"(",
")",
"if",
"os",
".",
"path",
".",
"splitext"... | Find all commands belonging to the given distribution.
Args:
dist: The Distribution to search for docopt-compatible docstrings that
can be used to generate command entry points.
Returns:
A dictionary containing a mapping of primary commands to sets of
subcommands. | [
"Find",
"all",
"commands",
"belonging",
"to",
"the",
"given",
"distribution",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L97-L121 | train | 57,764 |
contains-io/rcli | rcli/autodetect.py | _append_commands | def _append_commands(dct, # type: typing.Dict[str, typing.Set[str]]
module_name, # type: str
commands # type:typing.Iterable[_EntryPoint]
):
# type: (...) -> None
"""Append entry point strings representing the given Command objects.
Args:
... | python | def _append_commands(dct, # type: typing.Dict[str, typing.Set[str]]
module_name, # type: str
commands # type:typing.Iterable[_EntryPoint]
):
# type: (...) -> None
"""Append entry point strings representing the given Command objects.
Args:
... | [
"def",
"_append_commands",
"(",
"dct",
",",
"# type: typing.Dict[str, typing.Set[str]]",
"module_name",
",",
"# type: str",
"commands",
"# type:typing.Iterable[_EntryPoint]",
")",
":",
"# type: (...) -> None",
"for",
"command",
"in",
"commands",
":",
"entry_point",
"=",
"'{... | Append entry point strings representing the given Command objects.
Args:
dct: The dictionary to append with entry point strings. Each key will
be a primary command with a value containing a list of entry point
strings representing a Command.
module_name: The name of the modu... | [
"Append",
"entry",
"point",
"strings",
"representing",
"the",
"given",
"Command",
"objects",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L124-L148 | train | 57,765 |
contains-io/rcli | rcli/autodetect.py | _get_module_commands | def _get_module_commands(module):
# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]
"""Yield all Command objects represented by the python module.
Module commands consist of a docopt-style module docstring and a callable
Command class.
Args:
module: An ast.Module object use... | python | def _get_module_commands(module):
# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]
"""Yield all Command objects represented by the python module.
Module commands consist of a docopt-style module docstring and a callable
Command class.
Args:
module: An ast.Module object use... | [
"def",
"_get_module_commands",
"(",
"module",
")",
":",
"# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]",
"cls",
"=",
"next",
"(",
"(",
"n",
"for",
"n",
"in",
"module",
".",
"body",
"if",
"isinstance",
"(",
"n",
",",
"ast",
".",
"ClassDef",
")... | Yield all Command objects represented by the python module.
Module commands consist of a docopt-style module docstring and a callable
Command class.
Args:
module: An ast.Module object used to retrieve docopt-style commands.
Yields:
Command objects that represent entry points to append... | [
"Yield",
"all",
"Command",
"objects",
"represented",
"by",
"the",
"python",
"module",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L178-L200 | train | 57,766 |
contains-io/rcli | rcli/autodetect.py | _get_function_commands | def _get_function_commands(module):
# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]
"""Yield all Command objects represented by python functions in the module.
Function commands consist of all top-level functions that contain
docopt-style docstrings.
Args:
module: An ast.... | python | def _get_function_commands(module):
# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]
"""Yield all Command objects represented by python functions in the module.
Function commands consist of all top-level functions that contain
docopt-style docstrings.
Args:
module: An ast.... | [
"def",
"_get_function_commands",
"(",
"module",
")",
":",
"# type: (ast.Module) -> typing.Generator[_EntryPoint, None, None]",
"nodes",
"=",
"(",
"n",
"for",
"n",
"in",
"module",
".",
"body",
"if",
"isinstance",
"(",
"n",
",",
"ast",
".",
"FunctionDef",
")",
")",
... | Yield all Command objects represented by python functions in the module.
Function commands consist of all top-level functions that contain
docopt-style docstrings.
Args:
module: An ast.Module object used to retrieve docopt-style commands.
Yields:
Command objects that represent entry p... | [
"Yield",
"all",
"Command",
"objects",
"represented",
"by",
"python",
"functions",
"in",
"the",
"module",
"."
] | cdd6191a0e0a19bc767f84921650835d099349cf | https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/autodetect.py#L226-L244 | train | 57,767 |
tslight/pdu | pdu/du.py | convert | def convert(b):
'''
takes a number of bytes as an argument and returns the most suitable human
readable unit conversion.
'''
if b > 1024**3:
hr = round(b/1024**3)
unit = "GB"
elif b > 1024**2:
hr = round(b/1024**2)
unit = "MB"
else:
hr = round(b/1024)
... | python | def convert(b):
'''
takes a number of bytes as an argument and returns the most suitable human
readable unit conversion.
'''
if b > 1024**3:
hr = round(b/1024**3)
unit = "GB"
elif b > 1024**2:
hr = round(b/1024**2)
unit = "MB"
else:
hr = round(b/1024)
... | [
"def",
"convert",
"(",
"b",
")",
":",
"if",
"b",
">",
"1024",
"**",
"3",
":",
"hr",
"=",
"round",
"(",
"b",
"/",
"1024",
"**",
"3",
")",
"unit",
"=",
"\"GB\"",
"elif",
"b",
">",
"1024",
"**",
"2",
":",
"hr",
"=",
"round",
"(",
"b",
"/",
"... | takes a number of bytes as an argument and returns the most suitable human
readable unit conversion. | [
"takes",
"a",
"number",
"of",
"bytes",
"as",
"an",
"argument",
"and",
"returns",
"the",
"most",
"suitable",
"human",
"readable",
"unit",
"conversion",
"."
] | b6dfc5e8f6773b1e4e3047496b0ab72fef267a27 | https://github.com/tslight/pdu/blob/b6dfc5e8f6773b1e4e3047496b0ab72fef267a27/pdu/du.py#L7-L21 | train | 57,768 |
tslight/pdu | pdu/du.py | calc | def calc(path):
'''
Takes a path as an argument and returns the total size in bytes of the file
or directory. If the path is a directory the size will be calculated
recursively.
'''
total = 0
err = None
if os.path.isdir(path):
try:
for entry in os.scandir(path):
... | python | def calc(path):
'''
Takes a path as an argument and returns the total size in bytes of the file
or directory. If the path is a directory the size will be calculated
recursively.
'''
total = 0
err = None
if os.path.isdir(path):
try:
for entry in os.scandir(path):
... | [
"def",
"calc",
"(",
"path",
")",
":",
"total",
"=",
"0",
"err",
"=",
"None",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"try",
":",
"for",
"entry",
"in",
"os",
".",
"scandir",
"(",
"path",
")",
":",
"try",
":",
"is_dir",
"=... | Takes a path as an argument and returns the total size in bytes of the file
or directory. If the path is a directory the size will be calculated
recursively. | [
"Takes",
"a",
"path",
"as",
"an",
"argument",
"and",
"returns",
"the",
"total",
"size",
"in",
"bytes",
"of",
"the",
"file",
"or",
"directory",
".",
"If",
"the",
"path",
"is",
"a",
"directory",
"the",
"size",
"will",
"be",
"calculated",
"recursively",
"."... | b6dfc5e8f6773b1e4e3047496b0ab72fef267a27 | https://github.com/tslight/pdu/blob/b6dfc5e8f6773b1e4e3047496b0ab72fef267a27/pdu/du.py#L24-L57 | train | 57,769 |
tslight/pdu | pdu/du.py | du | def du(path):
'''
Put it all together!
'''
size, err = calc(path)
if err:
return err
else:
hr, unit = convert(size)
hr = str(hr)
result = hr + " " + unit
return result | python | def du(path):
'''
Put it all together!
'''
size, err = calc(path)
if err:
return err
else:
hr, unit = convert(size)
hr = str(hr)
result = hr + " " + unit
return result | [
"def",
"du",
"(",
"path",
")",
":",
"size",
",",
"err",
"=",
"calc",
"(",
"path",
")",
"if",
"err",
":",
"return",
"err",
"else",
":",
"hr",
",",
"unit",
"=",
"convert",
"(",
"size",
")",
"hr",
"=",
"str",
"(",
"hr",
")",
"result",
"=",
"hr",... | Put it all together! | [
"Put",
"it",
"all",
"together!"
] | b6dfc5e8f6773b1e4e3047496b0ab72fef267a27 | https://github.com/tslight/pdu/blob/b6dfc5e8f6773b1e4e3047496b0ab72fef267a27/pdu/du.py#L60-L71 | train | 57,770 |
tBaxter/activity-monitor | activity_monitor/management/commands/register_timeline_content.py | Command.handle | def handle(self, **kwargs):
"""
Simply re-saves all objects from models listed in settings.TIMELINE_MODELS. Since the timeline
app is now following these models, it will register each item as it is re-saved. The purpose of this
script is to register content in your database that existed prior to... | python | def handle(self, **kwargs):
"""
Simply re-saves all objects from models listed in settings.TIMELINE_MODELS. Since the timeline
app is now following these models, it will register each item as it is re-saved. The purpose of this
script is to register content in your database that existed prior to... | [
"def",
"handle",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"item",
"in",
"settings",
".",
"ACTIVITY_MONITOR_MODELS",
":",
"app_label",
",",
"model",
"=",
"item",
"[",
"'model'",
"]",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"content_type",... | Simply re-saves all objects from models listed in settings.TIMELINE_MODELS. Since the timeline
app is now following these models, it will register each item as it is re-saved. The purpose of this
script is to register content in your database that existed prior to installing the timeline app. | [
"Simply",
"re",
"-",
"saves",
"all",
"objects",
"from",
"models",
"listed",
"in",
"settings",
".",
"TIMELINE_MODELS",
".",
"Since",
"the",
"timeline",
"app",
"is",
"now",
"following",
"these",
"models",
"it",
"will",
"register",
"each",
"item",
"as",
"it",
... | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/management/commands/register_timeline_content.py#L12-L29 | train | 57,771 |
andy29485/embypy | embypy/objects/misc.py | Audio.album_primary_image_url | def album_primary_image_url(self):
'''The image of the album'''
path = '/Items/{}/Images/Primary'.format(self.album_id)
return self.connector.get_url(path, attach_api_key=False) | python | def album_primary_image_url(self):
'''The image of the album'''
path = '/Items/{}/Images/Primary'.format(self.album_id)
return self.connector.get_url(path, attach_api_key=False) | [
"def",
"album_primary_image_url",
"(",
"self",
")",
":",
"path",
"=",
"'/Items/{}/Images/Primary'",
".",
"format",
"(",
"self",
".",
"album_id",
")",
"return",
"self",
".",
"connector",
".",
"get_url",
"(",
"path",
",",
"attach_api_key",
"=",
"False",
")"
] | The image of the album | [
"The",
"image",
"of",
"the",
"album"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/misc.py#L118-L121 | train | 57,772 |
andy29485/embypy | embypy/objects/misc.py | Audio.stream_url | def stream_url(self):
'''stream for this song - not re-encoded'''
path = '/Audio/{}/universal'.format(self.id)
return self.connector.get_url(path,
userId=self.connector.userid,
MaxStreamingBitrate=140000000,
Container='opus',
TranscodingContainer='opus... | python | def stream_url(self):
'''stream for this song - not re-encoded'''
path = '/Audio/{}/universal'.format(self.id)
return self.connector.get_url(path,
userId=self.connector.userid,
MaxStreamingBitrate=140000000,
Container='opus',
TranscodingContainer='opus... | [
"def",
"stream_url",
"(",
"self",
")",
":",
"path",
"=",
"'/Audio/{}/universal'",
".",
"format",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"connector",
".",
"get_url",
"(",
"path",
",",
"userId",
"=",
"self",
".",
"connector",
".",
"userid",
... | stream for this song - not re-encoded | [
"stream",
"for",
"this",
"song",
"-",
"not",
"re",
"-",
"encoded"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/objects/misc.py#L132-L143 | train | 57,773 |
koehlma/pygrooveshark | src/grooveshark/classes/picture.py | Picture.data | def data(self):
"""
raw image data
"""
if self._data is None:
request = urllib.Request(self._url, headers={'User-Agent': USER_AGENT})
with contextlib.closing(self._connection.urlopen(request)) as response:
self._data = response.read()
retur... | python | def data(self):
"""
raw image data
"""
if self._data is None:
request = urllib.Request(self._url, headers={'User-Agent': USER_AGENT})
with contextlib.closing(self._connection.urlopen(request)) as response:
self._data = response.read()
retur... | [
"def",
"data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"request",
"=",
"urllib",
".",
"Request",
"(",
"self",
".",
"_url",
",",
"headers",
"=",
"{",
"'User-Agent'",
":",
"USER_AGENT",
"}",
")",
"with",
"contextlib",
".",... | raw image data | [
"raw",
"image",
"data"
] | 17673758ac12f54dc26ac879c30ea44f13b81057 | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/picture.py#L51-L59 | train | 57,774 |
helixyte/everest | everest/url.py | UrlPartsConverter.make_filter_string | def make_filter_string(cls, filter_specification):
"""
Converts the given filter specification to a CQL filter expression.
"""
registry = get_current_registry()
visitor_cls = registry.getUtility(IFilterSpecificationVisitor,
name=EXPRESSIO... | python | def make_filter_string(cls, filter_specification):
"""
Converts the given filter specification to a CQL filter expression.
"""
registry = get_current_registry()
visitor_cls = registry.getUtility(IFilterSpecificationVisitor,
name=EXPRESSIO... | [
"def",
"make_filter_string",
"(",
"cls",
",",
"filter_specification",
")",
":",
"registry",
"=",
"get_current_registry",
"(",
")",
"visitor_cls",
"=",
"registry",
".",
"getUtility",
"(",
"IFilterSpecificationVisitor",
",",
"name",
"=",
"EXPRESSION_KINDS",
".",
"CQL"... | Converts the given filter specification to a CQL filter expression. | [
"Converts",
"the",
"given",
"filter",
"specification",
"to",
"a",
"CQL",
"filter",
"expression",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/url.py#L161-L170 | train | 57,775 |
helixyte/everest | everest/url.py | UrlPartsConverter.make_order_string | def make_order_string(cls, order_specification):
"""
Converts the given order specification to a CQL order expression.
"""
registry = get_current_registry()
visitor_cls = registry.getUtility(IOrderSpecificationVisitor,
name=EXPRESSION_KIN... | python | def make_order_string(cls, order_specification):
"""
Converts the given order specification to a CQL order expression.
"""
registry = get_current_registry()
visitor_cls = registry.getUtility(IOrderSpecificationVisitor,
name=EXPRESSION_KIN... | [
"def",
"make_order_string",
"(",
"cls",
",",
"order_specification",
")",
":",
"registry",
"=",
"get_current_registry",
"(",
")",
"visitor_cls",
"=",
"registry",
".",
"getUtility",
"(",
"IOrderSpecificationVisitor",
",",
"name",
"=",
"EXPRESSION_KINDS",
".",
"CQL",
... | Converts the given order specification to a CQL order expression. | [
"Converts",
"the",
"given",
"order",
"specification",
"to",
"a",
"CQL",
"order",
"expression",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/url.py#L183-L192 | train | 57,776 |
helixyte/everest | everest/url.py | UrlPartsConverter.make_slice_key | def make_slice_key(cls, start_string, size_string):
"""
Converts the given start and size query parts to a slice key.
:return: slice key
:rtype: slice
"""
try:
start = int(start_string)
except ValueError:
raise ValueError('Query parameter ... | python | def make_slice_key(cls, start_string, size_string):
"""
Converts the given start and size query parts to a slice key.
:return: slice key
:rtype: slice
"""
try:
start = int(start_string)
except ValueError:
raise ValueError('Query parameter ... | [
"def",
"make_slice_key",
"(",
"cls",
",",
"start_string",
",",
"size_string",
")",
":",
"try",
":",
"start",
"=",
"int",
"(",
"start_string",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'Query parameter \"start\" must be a number.'",
")",
"if",
... | Converts the given start and size query parts to a slice key.
:return: slice key
:rtype: slice | [
"Converts",
"the",
"given",
"start",
"and",
"size",
"query",
"parts",
"to",
"a",
"slice",
"key",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/url.py#L195-L216 | train | 57,777 |
helixyte/everest | everest/url.py | UrlPartsConverter.make_slice_strings | def make_slice_strings(cls, slice_key):
"""
Converts the given slice key to start and size query parts.
"""
start = slice_key.start
size = slice_key.stop - start
return (str(start), str(size)) | python | def make_slice_strings(cls, slice_key):
"""
Converts the given slice key to start and size query parts.
"""
start = slice_key.start
size = slice_key.stop - start
return (str(start), str(size)) | [
"def",
"make_slice_strings",
"(",
"cls",
",",
"slice_key",
")",
":",
"start",
"=",
"slice_key",
".",
"start",
"size",
"=",
"slice_key",
".",
"stop",
"-",
"start",
"return",
"(",
"str",
"(",
"start",
")",
",",
"str",
"(",
"size",
")",
")"
] | Converts the given slice key to start and size query parts. | [
"Converts",
"the",
"given",
"slice",
"key",
"to",
"start",
"and",
"size",
"query",
"parts",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/url.py#L219-L225 | train | 57,778 |
BlackEarth/bxml | bxml/xt.py | XT.match | def match(self, expression=None, xpath=None, namespaces=None):
"""decorator that allows us to match by expression or by xpath for each transformation method"""
class MatchObject(Dict):
pass
def _match(function):
self.matches.append(
MatchObject(expression... | python | def match(self, expression=None, xpath=None, namespaces=None):
"""decorator that allows us to match by expression or by xpath for each transformation method"""
class MatchObject(Dict):
pass
def _match(function):
self.matches.append(
MatchObject(expression... | [
"def",
"match",
"(",
"self",
",",
"expression",
"=",
"None",
",",
"xpath",
"=",
"None",
",",
"namespaces",
"=",
"None",
")",
":",
"class",
"MatchObject",
"(",
"Dict",
")",
":",
"pass",
"def",
"_match",
"(",
"function",
")",
":",
"self",
".",
"matches... | decorator that allows us to match by expression or by xpath for each transformation method | [
"decorator",
"that",
"allows",
"us",
"to",
"match",
"by",
"expression",
"or",
"by",
"xpath",
"for",
"each",
"transformation",
"method"
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xt.py#L16-L26 | train | 57,779 |
BlackEarth/bxml | bxml/xt.py | XT.get_match | def get_match(self, elem):
"""for the given elem, return the @match function that will be applied"""
for m in self.matches:
if (m.expression is not None and eval(m.expression)==True) \
or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
... | python | def get_match(self, elem):
"""for the given elem, return the @match function that will be applied"""
for m in self.matches:
if (m.expression is not None and eval(m.expression)==True) \
or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
... | [
"def",
"get_match",
"(",
"self",
",",
"elem",
")",
":",
"for",
"m",
"in",
"self",
".",
"matches",
":",
"if",
"(",
"m",
".",
"expression",
"is",
"not",
"None",
"and",
"eval",
"(",
"m",
".",
"expression",
")",
"==",
"True",
")",
"or",
"(",
"m",
"... | for the given elem, return the @match function that will be applied | [
"for",
"the",
"given",
"elem",
"return",
"the"
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xt.py#L45-L51 | train | 57,780 |
BlackEarth/bxml | bxml/xt.py | XT.Element | def Element(self, elem, **params):
"""Ensure that the input element is immutable by the transformation. Returns a single element."""
res = self.__call__(deepcopy(elem), **params)
if len(res) > 0:
return res[0]
else:
return None | python | def Element(self, elem, **params):
"""Ensure that the input element is immutable by the transformation. Returns a single element."""
res = self.__call__(deepcopy(elem), **params)
if len(res) > 0:
return res[0]
else:
return None | [
"def",
"Element",
"(",
"self",
",",
"elem",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"__call__",
"(",
"deepcopy",
"(",
"elem",
")",
",",
"*",
"*",
"params",
")",
"if",
"len",
"(",
"res",
")",
">",
"0",
":",
"return",
"res",
... | Ensure that the input element is immutable by the transformation. Returns a single element. | [
"Ensure",
"that",
"the",
"input",
"element",
"is",
"immutable",
"by",
"the",
"transformation",
".",
"Returns",
"a",
"single",
"element",
"."
] | 8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77 | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xt.py#L53-L59 | train | 57,781 |
ponty/confduino | confduino/util.py | read_properties | def read_properties(filename):
"""read properties file into bunch.
:param filename: string
:rtype: bunch (dict like and object like)
"""
s = path(filename).text()
dummy_section = 'xxx'
cfgparser = configparser.RawConfigParser()
# avoid converting options to lower case
cfgparser.op... | python | def read_properties(filename):
"""read properties file into bunch.
:param filename: string
:rtype: bunch (dict like and object like)
"""
s = path(filename).text()
dummy_section = 'xxx'
cfgparser = configparser.RawConfigParser()
# avoid converting options to lower case
cfgparser.op... | [
"def",
"read_properties",
"(",
"filename",
")",
":",
"s",
"=",
"path",
"(",
"filename",
")",
".",
"text",
"(",
")",
"dummy_section",
"=",
"'xxx'",
"cfgparser",
"=",
"configparser",
".",
"RawConfigParser",
"(",
")",
"# avoid converting options to lower case",
"cf... | read properties file into bunch.
:param filename: string
:rtype: bunch (dict like and object like) | [
"read",
"properties",
"file",
"into",
"bunch",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/util.py#L58-L76 | train | 57,782 |
shawnsilva/steamwebapi | steamwebapi/api.py | _SteamWebAPI.create_request_url | def create_request_url(self, interface, method, version, parameters):
"""Create the URL to submit to the Steam Web API
interface: Steam Web API interface containing methods.
method: The method to call.
version: The version of the method.
paramters: Parameters to supply to the me... | python | def create_request_url(self, interface, method, version, parameters):
"""Create the URL to submit to the Steam Web API
interface: Steam Web API interface containing methods.
method: The method to call.
version: The version of the method.
paramters: Parameters to supply to the me... | [
"def",
"create_request_url",
"(",
"self",
",",
"interface",
",",
"method",
",",
"version",
",",
"parameters",
")",
":",
"if",
"'format'",
"in",
"parameters",
":",
"parameters",
"[",
"'key'",
"]",
"=",
"self",
".",
"apikey",
"else",
":",
"parameters",
".",
... | Create the URL to submit to the Steam Web API
interface: Steam Web API interface containing methods.
method: The method to call.
version: The version of the method.
paramters: Parameters to supply to the method. | [
"Create",
"the",
"URL",
"to",
"submit",
"to",
"the",
"Steam",
"Web",
"API"
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L56-L72 | train | 57,783 |
shawnsilva/steamwebapi | steamwebapi/api.py | _SteamWebAPI.retrieve_request | def retrieve_request(self, url):
"""Open the given url and decode and return the response
url: The url to open.
"""
try:
data = urlopen(url)
except:
print("Error Retrieving Data from Steam")
sys.exit(2)
return data.read().decode('utf-... | python | def retrieve_request(self, url):
"""Open the given url and decode and return the response
url: The url to open.
"""
try:
data = urlopen(url)
except:
print("Error Retrieving Data from Steam")
sys.exit(2)
return data.read().decode('utf-... | [
"def",
"retrieve_request",
"(",
"self",
",",
"url",
")",
":",
"try",
":",
"data",
"=",
"urlopen",
"(",
"url",
")",
"except",
":",
"print",
"(",
"\"Error Retrieving Data from Steam\"",
")",
"sys",
".",
"exit",
"(",
"2",
")",
"return",
"data",
".",
"read",... | Open the given url and decode and return the response
url: The url to open. | [
"Open",
"the",
"given",
"url",
"and",
"decode",
"and",
"return",
"the",
"response"
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L74-L85 | train | 57,784 |
shawnsilva/steamwebapi | steamwebapi/api.py | _SteamWebAPI.return_data | def return_data(self, data, format=None):
"""Format and return data appropriate to the requested API format.
data: The data retured by the api request
"""
if format is None:
format = self.format
if format == "json":
formatted_data = json.loads(data)
... | python | def return_data(self, data, format=None):
"""Format and return data appropriate to the requested API format.
data: The data retured by the api request
"""
if format is None:
format = self.format
if format == "json":
formatted_data = json.loads(data)
... | [
"def",
"return_data",
"(",
"self",
",",
"data",
",",
"format",
"=",
"None",
")",
":",
"if",
"format",
"is",
"None",
":",
"format",
"=",
"self",
".",
"format",
"if",
"format",
"==",
"\"json\"",
":",
"formatted_data",
"=",
"json",
".",
"loads",
"(",
"d... | Format and return data appropriate to the requested API format.
data: The data retured by the api request | [
"Format",
"and",
"return",
"data",
"appropriate",
"to",
"the",
"requested",
"API",
"format",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L87-L99 | train | 57,785 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUser.get_friends_list | def get_friends_list(self, steamID, relationship='all', format=None):
"""Request the friends list of a given steam ID filtered by role.
steamID: The user ID
relationship: Type of friend to request (all, friend)
format: Return format. None defaults to json. (json, xml, vdf)
"""
... | python | def get_friends_list(self, steamID, relationship='all', format=None):
"""Request the friends list of a given steam ID filtered by role.
steamID: The user ID
relationship: Type of friend to request (all, friend)
format: Return format. None defaults to json. (json, xml, vdf)
"""
... | [
"def",
"get_friends_list",
"(",
"self",
",",
"steamID",
",",
"relationship",
"=",
"'all'",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'relationship'",
":",
"relationship",
"}",
"if",
"format",
"is",
"no... | Request the friends list of a given steam ID filtered by role.
steamID: The user ID
relationship: Type of friend to request (all, friend)
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"friends",
"list",
"of",
"a",
"given",
"steam",
"ID",
"filtered",
"by",
"role",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L106-L120 | train | 57,786 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUser.get_player_bans | def get_player_bans(self, steamIDS, format=None):
"""Request the communities a steam id is banned in.
steamIDS: Comma-delimited list of SteamIDs
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamids' : steamIDS}
if format is not None... | python | def get_player_bans(self, steamIDS, format=None):
"""Request the communities a steam id is banned in.
steamIDS: Comma-delimited list of SteamIDs
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamids' : steamIDS}
if format is not None... | [
"def",
"get_player_bans",
"(",
"self",
",",
"steamIDS",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamids'",
":",
"steamIDS",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
"]",
"=",
"format",
"url",
... | Request the communities a steam id is banned in.
steamIDS: Comma-delimited list of SteamIDs
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"communities",
"a",
"steam",
"id",
"is",
"banned",
"in",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L122-L135 | train | 57,787 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUser.get_user_group_list | def get_user_group_list(self, steamID, format=None):
"""Request a list of groups a user is subscribed to.
steamID: User ID
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamid' : steamID}
if format is not None:
parameters... | python | def get_user_group_list(self, steamID, format=None):
"""Request a list of groups a user is subscribed to.
steamID: User ID
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamid' : steamID}
if format is not None:
parameters... | [
"def",
"get_user_group_list",
"(",
"self",
",",
"steamID",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
"]",
"=",
"format",
"url",... | Request a list of groups a user is subscribed to.
steamID: User ID
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"a",
"list",
"of",
"groups",
"a",
"user",
"is",
"subscribed",
"to",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L153-L166 | train | 57,788 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUser.resolve_vanity_url | def resolve_vanity_url(self, vanityURL, url_type=1, format=None):
"""Request the steam id associated with a vanity url.
vanityURL: The users vanity URL
url_type: The type of vanity URL. 1 (default): Individual profile,
2: Group, 3: Official game group
format: Return ... | python | def resolve_vanity_url(self, vanityURL, url_type=1, format=None):
"""Request the steam id associated with a vanity url.
vanityURL: The users vanity URL
url_type: The type of vanity URL. 1 (default): Individual profile,
2: Group, 3: Official game group
format: Return ... | [
"def",
"resolve_vanity_url",
"(",
"self",
",",
"vanityURL",
",",
"url_type",
"=",
"1",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'vanityurl'",
":",
"vanityURL",
",",
"\"url_type\"",
":",
"url_type",
"}",
"if",
"format",
"is",
"not",
... | Request the steam id associated with a vanity url.
vanityURL: The users vanity URL
url_type: The type of vanity URL. 1 (default): Individual profile,
2: Group, 3: Official game group
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"steam",
"id",
"associated",
"with",
"a",
"vanity",
"url",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L168-L183 | train | 57,789 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_global_achievement_percentages_for_app | def get_global_achievement_percentages_for_app(self, gameID, format=None):
"""Request statistics showing global achievements that have been
unlocked.
gameID: The id of the game.
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'gameid' : ... | python | def get_global_achievement_percentages_for_app(self, gameID, format=None):
"""Request statistics showing global achievements that have been
unlocked.
gameID: The id of the game.
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'gameid' : ... | [
"def",
"get_global_achievement_percentages_for_app",
"(",
"self",
",",
"gameID",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'gameid'",
":",
"gameID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
"]",
"=",
... | Request statistics showing global achievements that have been
unlocked.
gameID: The id of the game.
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"statistics",
"showing",
"global",
"achievements",
"that",
"have",
"been",
"unlocked",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L190-L204 | train | 57,790 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_global_stats_for_game | def get_global_stats_for_game(self, appID, count, names, startdate,
enddate, format=None):
"""Request global stats for a give game.
appID: The app ID
count: Number of stats to get.
names: A list of names of stats to get.
startdate: The start time to gather stats. Uni... | python | def get_global_stats_for_game(self, appID, count, names, startdate,
enddate, format=None):
"""Request global stats for a give game.
appID: The app ID
count: Number of stats to get.
names: A list of names of stats to get.
startdate: The start time to gather stats. Uni... | [
"def",
"get_global_stats_for_game",
"(",
"self",
",",
"appID",
",",
"count",
",",
"names",
",",
"startdate",
",",
"enddate",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'appid'",
":",
"appID",
",",
"'count'",
":",
"count",
",",
"'start... | Request global stats for a give game.
appID: The app ID
count: Number of stats to get.
names: A list of names of stats to get.
startdate: The start time to gather stats. Unix timestamp
enddate: The end time to gather stats. Unix timestamp
format: Return format. None defa... | [
"Request",
"global",
"stats",
"for",
"a",
"give",
"game",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L206-L234 | train | 57,791 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_number_of_current_players | def get_number_of_current_players(self, appID, format=None):
"""Request the current number of players for a given app.
appID: The app ID
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'appid' : appID}
if format is not None:
... | python | def get_number_of_current_players(self, appID, format=None):
"""Request the current number of players for a given app.
appID: The app ID
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'appid' : appID}
if format is not None:
... | [
"def",
"get_number_of_current_players",
"(",
"self",
",",
"appID",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'appid'",
":",
"appID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
"]",
"=",
"format",
"u... | Request the current number of players for a given app.
appID: The app ID
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"current",
"number",
"of",
"players",
"for",
"a",
"given",
"app",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L236-L249 | train | 57,792 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_player_achievements | def get_player_achievements(self, steamID, appID, language=None,
format=None):
"""Request the achievements for a given app and steam id.
steamID: Users steam ID
appID: The app id
language: The language to return the results in. None uses default.
format: Return forma... | python | def get_player_achievements(self, steamID, appID, language=None,
format=None):
"""Request the achievements for a given app and steam id.
steamID: Users steam ID
appID: The app id
language: The language to return the results in. None uses default.
format: Return forma... | [
"def",
"get_player_achievements",
"(",
"self",
",",
"steamID",
",",
"appID",
",",
"language",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'appid'",
":",
"appID",
"}",
"if",
"format",
"is",... | Request the achievements for a given app and steam id.
steamID: Users steam ID
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"achievements",
"for",
"a",
"given",
"app",
"and",
"steam",
"id",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L251-L271 | train | 57,793 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_schema_for_game | def get_schema_for_game(self, appID, language=None, format=None):
"""Request the available achievements and stats for a game.
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf)
"""... | python | def get_schema_for_game(self, appID, language=None, format=None):
"""Request the available achievements and stats for a game.
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf)
"""... | [
"def",
"get_schema_for_game",
"(",
"self",
",",
"appID",
",",
"language",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'appid'",
":",
"appID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"parameters",
"[",
"'format'",
... | Request the available achievements and stats for a game.
appID: The app id
language: The language to return the results in. None uses default.
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"available",
"achievements",
"and",
"stats",
"for",
"a",
"game",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L273-L291 | train | 57,794 |
shawnsilva/steamwebapi | steamwebapi/api.py | ISteamUserStats.get_user_stats_for_game | def get_user_stats_for_game(self, steamID, appID, format=None):
"""Request the user stats for a given game.
steamID: The users ID
appID: The app id
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamid' : steamID, 'appid' : appID}
... | python | def get_user_stats_for_game(self, steamID, appID, format=None):
"""Request the user stats for a given game.
steamID: The users ID
appID: The app id
format: Return format. None defaults to json. (json, xml, vdf)
"""
parameters = {'steamid' : steamID, 'appid' : appID}
... | [
"def",
"get_user_stats_for_game",
"(",
"self",
",",
"steamID",
",",
"appID",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'appid'",
":",
"appID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
"paramete... | Request the user stats for a given game.
steamID: The users ID
appID: The app id
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"the",
"user",
"stats",
"for",
"a",
"given",
"game",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L293-L307 | train | 57,795 |
shawnsilva/steamwebapi | steamwebapi/api.py | IPlayerService.get_recently_played_games | def get_recently_played_games(self, steamID, count=0, format=None):
"""Request a list of recently played games by a given steam id.
steamID: The users ID
count: Number of games to return. (0 is all recent games.)
format: Return format. None defaults to json. (json, xml, vdf)
""... | python | def get_recently_played_games(self, steamID, count=0, format=None):
"""Request a list of recently played games by a given steam id.
steamID: The users ID
count: Number of games to return. (0 is all recent games.)
format: Return format. None defaults to json. (json, xml, vdf)
""... | [
"def",
"get_recently_played_games",
"(",
"self",
",",
"steamID",
",",
"count",
"=",
"0",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'count'",
":",
"count",
"}",
"if",
"format",
"is",
"not",
"None",
... | Request a list of recently played games by a given steam id.
steamID: The users ID
count: Number of games to return. (0 is all recent games.)
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"a",
"list",
"of",
"recently",
"played",
"games",
"by",
"a",
"given",
"steam",
"id",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L316-L330 | train | 57,796 |
shawnsilva/steamwebapi | steamwebapi/api.py | IPlayerService.get_owned_games | def get_owned_games(self, steamID, include_appinfo=1,
include_played_free_games=0, appids_filter=None, format=None):
"""Request a list of games owned by a given steam id.
steamID: The users id
include_appinfo: boolean.
include_played_free_games: boolean.
appids_filte... | python | def get_owned_games(self, steamID, include_appinfo=1,
include_played_free_games=0, appids_filter=None, format=None):
"""Request a list of games owned by a given steam id.
steamID: The users id
include_appinfo: boolean.
include_played_free_games: boolean.
appids_filte... | [
"def",
"get_owned_games",
"(",
"self",
",",
"steamID",
",",
"include_appinfo",
"=",
"1",
",",
"include_played_free_games",
"=",
"0",
",",
"appids_filter",
"=",
"None",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",... | Request a list of games owned by a given steam id.
steamID: The users id
include_appinfo: boolean.
include_played_free_games: boolean.
appids_filter: a json encoded list of app ids.
format: Return format. None defaults to json. (json, xml, vdf) | [
"Request",
"a",
"list",
"of",
"games",
"owned",
"by",
"a",
"given",
"steam",
"id",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L332-L355 | train | 57,797 |
shawnsilva/steamwebapi | steamwebapi/api.py | IPlayerService.get_community_badge_progress | def get_community_badge_progress(self, steamID, badgeID, format=None):
"""Gets all the quests needed to get the specified badge, and which are completed.
steamID: The users ID
badgeID: The badge we're asking about
format: Return format. None defaults to json. (json, xml, vdf)
"... | python | def get_community_badge_progress(self, steamID, badgeID, format=None):
"""Gets all the quests needed to get the specified badge, and which are completed.
steamID: The users ID
badgeID: The badge we're asking about
format: Return format. None defaults to json. (json, xml, vdf)
"... | [
"def",
"get_community_badge_progress",
"(",
"self",
",",
"steamID",
",",
"badgeID",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'badgeid'",
":",
"badgeID",
"}",
"if",
"format",
"is",
"not",
"None",
":",
... | Gets all the quests needed to get the specified badge, and which are completed.
steamID: The users ID
badgeID: The badge we're asking about
format: Return format. None defaults to json. (json, xml, vdf) | [
"Gets",
"all",
"the",
"quests",
"needed",
"to",
"get",
"the",
"specified",
"badge",
"and",
"which",
"are",
"completed",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L387-L401 | train | 57,798 |
shawnsilva/steamwebapi | steamwebapi/api.py | IPlayerService.is_playing_shared_game | def is_playing_shared_game(self, steamID, appid_playing, format=None):
"""Returns valid lender SteamID if game currently played is borrowed.
steamID: The users ID
appid_playing: The game player is currently playing
format: Return format. None defaults to json. (json, xml, vdf)
... | python | def is_playing_shared_game(self, steamID, appid_playing, format=None):
"""Returns valid lender SteamID if game currently played is borrowed.
steamID: The users ID
appid_playing: The game player is currently playing
format: Return format. None defaults to json. (json, xml, vdf)
... | [
"def",
"is_playing_shared_game",
"(",
"self",
",",
"steamID",
",",
"appid_playing",
",",
"format",
"=",
"None",
")",
":",
"parameters",
"=",
"{",
"'steamid'",
":",
"steamID",
",",
"'appid_playing'",
":",
"appid_playing",
"}",
"if",
"format",
"is",
"not",
"No... | Returns valid lender SteamID if game currently played is borrowed.
steamID: The users ID
appid_playing: The game player is currently playing
format: Return format. None defaults to json. (json, xml, vdf) | [
"Returns",
"valid",
"lender",
"SteamID",
"if",
"game",
"currently",
"played",
"is",
"borrowed",
"."
] | dc16538ebe985cc7ea170f660169ebc2366efbf2 | https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L403-L417 | train | 57,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.