partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | abstractDictTable.select_by_field | Return collection of acces whose field equal value | pyDLib/Core/data_model.py | def select_by_field(self, base, field, value):
"""Return collection of acces whose field equal value"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i, row in self.items() if row[field] == value) | def select_by_field(self, base, field, value):
"""Return collection of acces whose field equal value"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i, row in self.items() if row[field] == value) | [
"Return",
"collection",
"of",
"acces",
"whose",
"field",
"equal",
"value"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L169-L172 | [
"def",
"select_by_field",
"(",
"self",
",",
"base",
",",
"field",
",",
"value",
")",
":",
"Ac",
"=",
"self",
".",
"ACCES",
"return",
"groups",
".",
"Collection",
"(",
"Ac",
"(",
"base",
",",
"i",
")",
"for",
"i",
",",
"row",
"in",
"self",
".",
"i... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractDictTable.select_by_critere | :param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria | pyDLib/Core/data_model.py | def select_by_critere(self, base, criteria):
"""
:param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria
"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i... | def select_by_critere(self, base, criteria):
"""
:param base: Reference on whole base
:param criteria: Callable abstractAcces -> Bool, acting as filter
:return: Collection on acces passing the criteria
"""
Ac = self.ACCES
return groups.Collection(Ac(base, i) for i... | [
":",
"param",
"base",
":",
"Reference",
"on",
"whole",
"base",
":",
"param",
"criteria",
":",
"Callable",
"abstractAcces",
"-",
">",
"Bool",
"acting",
"as",
"filter",
":",
"return",
":",
"Collection",
"on",
"acces",
"passing",
"the",
"criteria"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L174-L181 | [
"def",
"select_by_critere",
"(",
"self",
",",
"base",
",",
"criteria",
")",
":",
"Ac",
"=",
"self",
".",
"ACCES",
"return",
"groups",
".",
"Collection",
"(",
"Ac",
"(",
"base",
",",
"i",
")",
"for",
"i",
"in",
"self",
"if",
"criteria",
"(",
"Ac",
"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractBase.load_from_db | Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object. | pyDLib/Core/data_model.py | def load_from_db(cls, callback_etat=print, out=None):
"""Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object.
"""
dic = cls._load_remote_db(callback_etat)
... | def load_from_db(cls, callback_etat=print, out=None):
"""Launch data fetching then load data received.
The method _load_remote_db should be overridden.
If out is given, datas are set in it, instead of returning a new base object.
"""
dic = cls._load_remote_db(callback_etat)
... | [
"Launch",
"data",
"fetching",
"then",
"load",
"data",
"received",
".",
"The",
"method",
"_load_remote_db",
"should",
"be",
"overridden",
".",
"If",
"out",
"is",
"given",
"datas",
"are",
"set",
"in",
"it",
"instead",
"of",
"returning",
"a",
"new",
"base",
"... | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L214-L223 | [
"def",
"load_from_db",
"(",
"cls",
",",
"callback_etat",
"=",
"print",
",",
"out",
"=",
"None",
")",
":",
"dic",
"=",
"cls",
".",
"_load_remote_db",
"(",
"callback_etat",
")",
"callback_etat",
"(",
"\"Chargement...\"",
",",
"2",
",",
"3",
")",
"if",
"out... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractBase._parse_text_DB | Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] } | pyDLib/Core/data_model.py | def _parse_text_DB(self, s):
"""Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] }"""
dic = self.decode_json_str(s)
new_dic = {}
for table_name, (header, rows) in dic.items():
newl = [{... | def _parse_text_DB(self, s):
"""Returns a dict of table interpreted from s.
s should be Json string encoding a dict { table_name : [fields_name,...] , [rows,... ] }"""
dic = self.decode_json_str(s)
new_dic = {}
for table_name, (header, rows) in dic.items():
newl = [{... | [
"Returns",
"a",
"dict",
"of",
"table",
"interpreted",
"from",
"s",
".",
"s",
"should",
"be",
"Json",
"string",
"encoding",
"a",
"dict",
"{",
"table_name",
":",
"[",
"fields_name",
"...",
"]",
"[",
"rows",
"...",
"]",
"}"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L235-L244 | [
"def",
"_parse_text_DB",
"(",
"self",
",",
"s",
")",
":",
"dic",
"=",
"self",
".",
"decode_json_str",
"(",
"s",
")",
"new_dic",
"=",
"{",
"}",
"for",
"table_name",
",",
"(",
"header",
",",
"rows",
")",
"in",
"dic",
".",
"items",
"(",
")",
":",
"n... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractBase.load_from_local | Load datas from local file. | pyDLib/Core/data_model.py | def load_from_local(cls):
"""Load datas from local file."""
try:
with open(cls.LOCAL_DB_PATH, 'rb') as f:
b = f.read()
s = security.protege_data(b, False)
except (FileNotFoundError, KeyError):
logging.exception(cls.__name__)
rai... | def load_from_local(cls):
"""Load datas from local file."""
try:
with open(cls.LOCAL_DB_PATH, 'rb') as f:
b = f.read()
s = security.protege_data(b, False)
except (FileNotFoundError, KeyError):
logging.exception(cls.__name__)
rai... | [
"Load",
"datas",
"from",
"local",
"file",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L255-L266 | [
"def",
"load_from_local",
"(",
"cls",
")",
":",
"try",
":",
"with",
"open",
"(",
"cls",
".",
"LOCAL_DB_PATH",
",",
"'rb'",
")",
"as",
"f",
":",
"b",
"=",
"f",
".",
"read",
"(",
")",
"s",
"=",
"security",
".",
"protege_data",
"(",
"b",
",",
"False... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractBase.dumps | Return a dictionnary of current tables | pyDLib/Core/data_model.py | def dumps(self):
"""Return a dictionnary of current tables"""
return {table_name: getattr(self, table_name).dumps() for table_name in self.TABLES} | def dumps(self):
"""Return a dictionnary of current tables"""
return {table_name: getattr(self, table_name).dumps() for table_name in self.TABLES} | [
"Return",
"a",
"dictionnary",
"of",
"current",
"tables"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L285-L287 | [
"def",
"dumps",
"(",
"self",
")",
":",
"return",
"{",
"table_name",
":",
"getattr",
"(",
"self",
",",
"table_name",
")",
".",
"dumps",
"(",
")",
"for",
"table_name",
"in",
"self",
".",
"TABLES",
"}"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractBase.save_to_local | Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args | pyDLib/Core/data_model.py | def save_to_local(self, callback_etat=print):
"""
Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args
"""
callback_etat("Aquisition...", 0, 3)
d = self.d... | def save_to_local(self, callback_etat=print):
"""
Saved current in memory base to local file.
It's a backup, not a convenient way to update datas
:param callback_etat: state callback, taking str,int,int as args
"""
callback_etat("Aquisition...", 0, 3)
d = self.d... | [
"Saved",
"current",
"in",
"memory",
"base",
"to",
"local",
"file",
".",
"It",
"s",
"a",
"backup",
"not",
"a",
"convenient",
"way",
"to",
"update",
"datas"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L301-L319 | [
"def",
"save_to_local",
"(",
"self",
",",
"callback_etat",
"=",
"print",
")",
":",
"callback_etat",
"(",
"\"Aquisition...\"",
",",
"0",
",",
"3",
")",
"d",
"=",
"self",
".",
"dumps",
"(",
")",
"s",
"=",
"json",
".",
"dumps",
"(",
"d",
",",
"indent",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Xls.read_cell | reads the cell at position x and y; puts the default styles in xlwt | pyheaderfile/excel.py | def read_cell(self, x, y):
"""
reads the cell at position x and y; puts the default styles in xlwt
"""
cell = self._sheet.row(x)[y]
if self._file.xf_list[
cell.xf_index].background.pattern_colour_index == 64:
self._file.xf_list[
cell.xf... | def read_cell(self, x, y):
"""
reads the cell at position x and y; puts the default styles in xlwt
"""
cell = self._sheet.row(x)[y]
if self._file.xf_list[
cell.xf_index].background.pattern_colour_index == 64:
self._file.xf_list[
cell.xf... | [
"reads",
"the",
"cell",
"at",
"position",
"x",
"and",
"y",
";",
"puts",
"the",
"default",
"styles",
"in",
"xlwt"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/excel.py#L20-L54 | [
"def",
"read_cell",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"cell",
"=",
"self",
".",
"_sheet",
".",
"row",
"(",
"x",
")",
"[",
"y",
"]",
"if",
"self",
".",
"_file",
".",
"xf_list",
"[",
"cell",
".",
"xf_index",
"]",
".",
"background",
".",
... | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | Xls.write_cell | writing style and value in the cell of x and y position | pyheaderfile/excel.py | def write_cell(self, x, y, value, style=None):
"""
writing style and value in the cell of x and y position
"""
if isinstance(style, str):
style = self.xlwt.easyxf(style)
if style:
self._sheet.write(x, y, label=value, style=style)
else:
... | def write_cell(self, x, y, value, style=None):
"""
writing style and value in the cell of x and y position
"""
if isinstance(style, str):
style = self.xlwt.easyxf(style)
if style:
self._sheet.write(x, y, label=value, style=style)
else:
... | [
"writing",
"style",
"and",
"value",
"in",
"the",
"cell",
"of",
"x",
"and",
"y",
"position"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/excel.py#L56-L65 | [
"def",
"write_cell",
"(",
"self",
",",
"x",
",",
"y",
",",
"value",
",",
"style",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"style",
",",
"str",
")",
":",
"style",
"=",
"self",
".",
"xlwt",
".",
"easyxf",
"(",
"style",
")",
"if",
"style",
... | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | get_string | This function checks if a path was given as string, and tries to read the
file and return the string. | cgecore/argumentparsing.py | def get_string(string):
""" This function checks if a path was given as string, and tries to read the
file and return the string.
"""
truestring = string
if string is not None:
if '/' in string:
if os.path.isfile(string):
try:
with open_(string,'r') as f:
... | def get_string(string):
""" This function checks if a path was given as string, and tries to read the
file and return the string.
"""
truestring = string
if string is not None:
if '/' in string:
if os.path.isfile(string):
try:
with open_(string,'r') as f:
... | [
"This",
"function",
"checks",
"if",
"a",
"path",
"was",
"given",
"as",
"string",
"and",
"tries",
"to",
"read",
"the",
"file",
"and",
"return",
"the",
"string",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L14-L27 | [
"def",
"get_string",
"(",
"string",
")",
":",
"truestring",
"=",
"string",
"if",
"string",
"is",
"not",
"None",
":",
"if",
"'/'",
"in",
"string",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"string",
")",
":",
"try",
":",
"with",
"open_",
"("... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | get_arguments | This function handles and validates the wrapper arguments. | cgecore/argumentparsing.py | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------... | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------... | [
"This",
"function",
"handles",
"and",
"validates",
"the",
"wrapper",
"arguments",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L29-L76 | [
"def",
"get_arguments",
"(",
"options",
")",
":",
"# These the next couple of lines defines the header of the Help output",
"parser",
"=",
"ArgumentParser",
"(",
"formatter_class",
"=",
"RawDescriptionHelpFormatter",
",",
"usage",
"=",
"(",
"\"\"\"%(prog)s\n----------------------... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | check_file_type | Check whether the input files are in fasta format, reads format or
other/mix formats. | cgecore/argumentparsing.py | def check_file_type(files):
""" Check whether the input files are in fasta format, reads format or
other/mix formats.
"""
all_are_fasta = True
all_are_reads = True
all_are_empty = True
if sys.version_info < (3, 0):
if isinstance(files, (str, unicode)): files = [files]
else:
if is... | def check_file_type(files):
""" Check whether the input files are in fasta format, reads format or
other/mix formats.
"""
all_are_fasta = True
all_are_reads = True
all_are_empty = True
if sys.version_info < (3, 0):
if isinstance(files, (str, unicode)): files = [files]
else:
if is... | [
"Check",
"whether",
"the",
"input",
"files",
"are",
"in",
"fasta",
"format",
"reads",
"format",
"or",
"other",
"/",
"mix",
"formats",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L78-L101 | [
"def",
"check_file_type",
"(",
"files",
")",
":",
"all_are_fasta",
"=",
"True",
"all_are_reads",
"=",
"True",
"all_are_empty",
"=",
"True",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"if",
"isinstance",
"(",
"files",
",",
"(",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | make_file_list | This function returns list of files in the given dir | cgecore/argumentparsing.py | def make_file_list(upload_path):
""" This function returns list of files in the given dir """
newlist = []
for el in sorted(os.listdir(upload_path)):
if ' ' in el:
raise Exception('Error: Spaces are not allowed in file names!\n')
newlist.append(os.path.normpath(upload_path+'/'+el))
debu... | def make_file_list(upload_path):
""" This function returns list of files in the given dir """
newlist = []
for el in sorted(os.listdir(upload_path)):
if ' ' in el:
raise Exception('Error: Spaces are not allowed in file names!\n')
newlist.append(os.path.normpath(upload_path+'/'+el))
debu... | [
"This",
"function",
"returns",
"list",
"of",
"files",
"in",
"the",
"given",
"dir"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L103-L111 | [
"def",
"make_file_list",
"(",
"upload_path",
")",
":",
"newlist",
"=",
"[",
"]",
"for",
"el",
"in",
"sorted",
"(",
"os",
".",
"listdir",
"(",
"upload_path",
")",
")",
":",
"if",
"' '",
"in",
"el",
":",
"raise",
"Exception",
"(",
"'Error: Spaces are not a... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | create_server_rackspace | Creates Rackspace Instance and saves it state in a local json file | bookshelf/api_v2/rackspace.py | def create_server_rackspace(connection,
distribution,
disk_name,
disk_size,
ami,
region,
key_pair,
instance_type,
... | def create_server_rackspace(connection,
distribution,
disk_name,
disk_size,
ami,
region,
key_pair,
instance_type,
... | [
"Creates",
"Rackspace",
"Instance",
"and",
"saves",
"it",
"state",
"in",
"a",
"local",
"json",
"file"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L47-L93 | [
"def",
"create_server_rackspace",
"(",
"connection",
",",
"distribution",
",",
"disk_name",
",",
"disk_size",
",",
"ami",
",",
"region",
",",
"key_pair",
",",
"instance_type",
",",
"instance_name",
",",
"tags",
"=",
"{",
"}",
",",
"security_groups",
"=",
"None... | a6770678e735de95b194f6e6989223970db5f654 |
train | destroy_rackspace | terminates the instance | bookshelf/api_v2/rackspace.py | def destroy_rackspace(connection, region, instance_id):
""" terminates the instance """
server = connection.servers.get(instance_id)
log_yellow('deleting rackspace instance ...')
server.delete()
# wait for server to be deleted
try:
while True:
server = connection.servers.ge... | def destroy_rackspace(connection, region, instance_id):
""" terminates the instance """
server = connection.servers.get(instance_id)
log_yellow('deleting rackspace instance ...')
server.delete()
# wait for server to be deleted
try:
while True:
server = connection.servers.ge... | [
"terminates",
"the",
"instance"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L96-L111 | [
"def",
"destroy_rackspace",
"(",
"connection",
",",
"region",
",",
"instance_id",
")",
":",
"server",
"=",
"connection",
".",
"servers",
".",
"get",
"(",
"instance_id",
")",
"log_yellow",
"(",
"'deleting rackspace instance ...'",
")",
"server",
".",
"delete",
"(... | a6770678e735de95b194f6e6989223970db5f654 |
train | get_rackspace_info | queries Rackspace for details about a particular server id | bookshelf/api_v2/rackspace.py | def get_rackspace_info(connection,
server_id):
""" queries Rackspace for details about a particular server id
"""
server = connection.servers.get(server_id)
data = {}
data['ip_address'] = server.accessIPv4
data['accessIPv4'] = server.accessIPv4
data['accessIPv6'] = se... | def get_rackspace_info(connection,
server_id):
""" queries Rackspace for details about a particular server id
"""
server = connection.servers.get(server_id)
data = {}
data['ip_address'] = server.accessIPv4
data['accessIPv4'] = server.accessIPv4
data['accessIPv6'] = se... | [
"queries",
"Rackspace",
"for",
"details",
"about",
"a",
"particular",
"server",
"id"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/rackspace.py#L142-L166 | [
"def",
"get_rackspace_info",
"(",
"connection",
",",
"server_id",
")",
":",
"server",
"=",
"connection",
".",
"servers",
".",
"get",
"(",
"server_id",
")",
"data",
"=",
"{",
"}",
"data",
"[",
"'ip_address'",
"]",
"=",
"server",
".",
"accessIPv4",
"data",
... | a6770678e735de95b194f6e6989223970db5f654 |
train | date_decoder | Add python types decoding. See JsonEncoder | pyDLib/Core/formats.py | def date_decoder(dic):
"""Add python types decoding. See JsonEncoder"""
if '__date__' in dic:
try:
d = datetime.date(**{c: v for c, v in dic.items() if not c == "__date__"})
except (TypeError, ValueError):
raise json.JSONDecodeError("Corrupted date format !", str(dic), 1)... | def date_decoder(dic):
"""Add python types decoding. See JsonEncoder"""
if '__date__' in dic:
try:
d = datetime.date(**{c: v for c, v in dic.items() if not c == "__date__"})
except (TypeError, ValueError):
raise json.JSONDecodeError("Corrupted date format !", str(dic), 1)... | [
"Add",
"python",
"types",
"decoding",
".",
"See",
"JsonEncoder"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L31-L45 | [
"def",
"date_decoder",
"(",
"dic",
")",
":",
"if",
"'__date__'",
"in",
"dic",
":",
"try",
":",
"d",
"=",
"datetime",
".",
"date",
"(",
"*",
"*",
"{",
"c",
":",
"v",
"for",
"c",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
"if",
"not",
"c",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | _type_string | Shortcut for string like fields | pyDLib/Core/formats.py | def _type_string(label, case=None):
"""Shortcut for string like fields"""
return label, abstractSearch.in_string, lambda s: abstractRender.default(s, case=case), "" | def _type_string(label, case=None):
"""Shortcut for string like fields"""
return label, abstractSearch.in_string, lambda s: abstractRender.default(s, case=case), "" | [
"Shortcut",
"for",
"string",
"like",
"fields"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L301-L303 | [
"def",
"_type_string",
"(",
"label",
",",
"case",
"=",
"None",
")",
":",
"return",
"label",
",",
"abstractSearch",
".",
"in_string",
",",
"lambda",
"s",
":",
"abstractRender",
".",
"default",
"(",
"s",
",",
"case",
"=",
"case",
")",
",",
"\"\""
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | _type_bool | Shortcut fot boolean like fields | pyDLib/Core/formats.py | def _type_bool(label,default=False):
"""Shortcut fot boolean like fields"""
return label, abstractSearch.nothing, abstractRender.boolen, default | def _type_bool(label,default=False):
"""Shortcut fot boolean like fields"""
return label, abstractSearch.nothing, abstractRender.boolen, default | [
"Shortcut",
"fot",
"boolean",
"like",
"fields"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L316-L318 | [
"def",
"_type_bool",
"(",
"label",
",",
"default",
"=",
"False",
")",
":",
"return",
"label",
",",
"abstractSearch",
".",
"nothing",
",",
"abstractRender",
".",
"boolen",
",",
"default"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractSearch.in_string | abstractSearch dans une chaine, sans tenir compte de la casse. | pyDLib/Core/formats.py | def in_string(objet, pattern):
""" abstractSearch dans une chaine, sans tenir compte de la casse. """
return bool(re.search(pattern, str(objet), flags=re.I)) if objet else False | def in_string(objet, pattern):
""" abstractSearch dans une chaine, sans tenir compte de la casse. """
return bool(re.search(pattern, str(objet), flags=re.I)) if objet else False | [
"abstractSearch",
"dans",
"une",
"chaine",
"sans",
"tenir",
"compte",
"de",
"la",
"casse",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L199-L201 | [
"def",
"in_string",
"(",
"objet",
",",
"pattern",
")",
":",
"return",
"bool",
"(",
"re",
".",
"search",
"(",
"pattern",
",",
"str",
"(",
"objet",
")",
",",
"flags",
"=",
"re",
".",
"I",
")",
")",
"if",
"objet",
"else",
"False"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractSearch.in_date | abstractSearch dans une date datetime.date | pyDLib/Core/formats.py | def in_date(objet, pattern):
""" abstractSearch dans une date datetime.date"""
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.date(objet)
return bool(re.search(pattern, objet_str))
return False | def in_date(objet, pattern):
""" abstractSearch dans une date datetime.date"""
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.date(objet)
return bool(re.search(pattern, objet_str))
return False | [
"abstractSearch",
"dans",
"une",
"date",
"datetime",
".",
"date"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L204-L210 | [
"def",
"in_date",
"(",
"objet",
",",
"pattern",
")",
":",
"if",
"objet",
":",
"pattern",
"=",
"re",
".",
"sub",
"(",
"\" \"",
",",
"''",
",",
"pattern",
")",
"objet_str",
"=",
"abstractRender",
".",
"date",
"(",
"objet",
")",
"return",
"bool",
"(",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractSearch.in_dateheure | abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) | pyDLib/Core/formats.py | def in_dateheure(objet, pattern):
""" abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) """
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.dateheure(objet)
return bool(re.search(pattern, objet_str))
ret... | def in_dateheure(objet, pattern):
""" abstractSearch dans une date-heure datetime.datetime (cf abstractRender.dateheure) """
if objet:
pattern = re.sub(" ", '', pattern)
objet_str = abstractRender.dateheure(objet)
return bool(re.search(pattern, objet_str))
ret... | [
"abstractSearch",
"dans",
"une",
"date",
"-",
"heure",
"datetime",
".",
"datetime",
"(",
"cf",
"abstractRender",
".",
"dateheure",
")"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L213-L219 | [
"def",
"in_dateheure",
"(",
"objet",
",",
"pattern",
")",
":",
"if",
"objet",
":",
"pattern",
"=",
"re",
".",
"sub",
"(",
"\" \"",
",",
"''",
",",
"pattern",
")",
"objet_str",
"=",
"abstractRender",
".",
"dateheure",
"(",
"objet",
")",
"return",
"bool"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractSearch.in_telephones | abstractSearch dans une liste de téléphones. | pyDLib/Core/formats.py | def in_telephones(objet, pattern):
""" abstractSearch dans une liste de téléphones."""
objet = objet or []
if pattern == '' or not objet:
return False
return max(bool(re.search(pattern, t)) for t in objet) | def in_telephones(objet, pattern):
""" abstractSearch dans une liste de téléphones."""
objet = objet or []
if pattern == '' or not objet:
return False
return max(bool(re.search(pattern, t)) for t in objet) | [
"abstractSearch",
"dans",
"une",
"liste",
"de",
"téléphones",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L222-L227 | [
"def",
"in_telephones",
"(",
"objet",
",",
"pattern",
")",
":",
"objet",
"=",
"objet",
"or",
"[",
"]",
"if",
"pattern",
"==",
"''",
"or",
"not",
"objet",
":",
"return",
"False",
"return",
"max",
"(",
"bool",
"(",
"re",
".",
"search",
"(",
"pattern",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractRender.date | abstractRender d'une date datetime.date | pyDLib/Core/formats.py | def date(objet):
""" abstractRender d'une date datetime.date"""
if objet:
return "{}/{}/{}".format(objet.day, objet.month, objet.year)
return "" | def date(objet):
""" abstractRender d'une date datetime.date"""
if objet:
return "{}/{}/{}".format(objet.day, objet.month, objet.year)
return "" | [
"abstractRender",
"d",
"une",
"date",
"datetime",
".",
"date"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L250-L254 | [
"def",
"date",
"(",
"objet",
")",
":",
"if",
"objet",
":",
"return",
"\"{}/{}/{}\"",
".",
"format",
"(",
"objet",
".",
"day",
",",
"objet",
".",
"month",
",",
"objet",
".",
"year",
")",
"return",
"\"\""
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractRender.dateheure | abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm | pyDLib/Core/formats.py | def dateheure(objet):
""" abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm """
if objet:
return "{}/{}/{} à {:02}:{:02}".format(objet.day, objet.month, objet.year, objet.hour, objet.minute)
return "" | def dateheure(objet):
""" abstractRender d'une date-heure datetime.datetime au format JJ/MM/AAAAàHH:mm """
if objet:
return "{}/{}/{} à {:02}:{:02}".format(objet.day, objet.month, objet.year, objet.hour, objet.minute)
return "" | [
"abstractRender",
"d",
"une",
"date",
"-",
"heure",
"datetime",
".",
"datetime",
"au",
"format",
"JJ",
"/",
"MM",
"/",
"AAAAàHH",
":",
"mm"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/formats.py#L257-L261 | [
"def",
"dateheure",
"(",
"objet",
")",
":",
"if",
"objet",
":",
"return",
"\"{}/{}/{} à {:02}:{:02}\".",
"f",
"ormat(",
"o",
"bjet.",
"d",
"ay,",
" ",
"bjet.",
"m",
"onth,",
" ",
"bjet.",
"y",
"ear,",
" ",
"bjet.",
"h",
"our,",
" ",
"bjet.",
"m",
"inut... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | install | Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale) using
a translation-domain-specifi... | qg/core/gettextutils.py | def install(domain, lazy=False):
"""Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale... | def install(domain, lazy=False):
"""Install a _() function using the given translation domain.
Given a translation domain, install a _() function using gettext's
install() function.
The main difference from gettext.install() is that we allow
overriding the default localedir (e.g. /usr/share/locale... | [
"Install",
"a",
"_",
"()",
"function",
"using",
"the",
"given",
"translation",
"domain",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L83-L130 | [
"def",
"install",
"(",
"domain",
",",
"lazy",
"=",
"False",
")",
":",
"if",
"lazy",
":",
"# NOTE(mrodden): Lazy gettext functionality.",
"#",
"# The following introduces a deferred way to do translations on",
"# messages in OpenStack. We override the standard _() function",
"# and ... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | get_available_languages | Lists the available languages for the given translation domain.
:param domain: the domain to get languages for | qg/core/gettextutils.py | def get_available_languages(domain):
"""Lists the available languages for the given translation domain.
:param domain: the domain to get languages for
"""
if domain in _AVAILABLE_LANGUAGES:
return copy.copy(_AVAILABLE_LANGUAGES[domain])
localedir = '%s_LOCALEDIR' % domain.upper()
find ... | def get_available_languages(domain):
"""Lists the available languages for the given translation domain.
:param domain: the domain to get languages for
"""
if domain in _AVAILABLE_LANGUAGES:
return copy.copy(_AVAILABLE_LANGUAGES[domain])
localedir = '%s_LOCALEDIR' % domain.upper()
find ... | [
"Lists",
"the",
"available",
"languages",
"for",
"the",
"given",
"translation",
"domain",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L298-L343 | [
"def",
"get_available_languages",
"(",
"domain",
")",
":",
"if",
"domain",
"in",
"_AVAILABLE_LANGUAGES",
":",
"return",
"copy",
".",
"copy",
"(",
"_AVAILABLE_LANGUAGES",
"[",
"domain",
"]",
")",
"localedir",
"=",
"'%s_LOCALEDIR'",
"%",
"domain",
".",
"upper",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | translate | Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the locale to translate the message to, if None the
... | qg/core/gettextutils.py | def translate(obj, desired_locale=None):
"""Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the lo... | def translate(obj, desired_locale=None):
"""Gets the translated unicode representation of the given object.
If the object is not translatable it is returned as-is.
If the locale is None the object is translated to the system locale.
:param obj: the object to translate
:param desired_locale: the lo... | [
"Gets",
"the",
"translated",
"unicode",
"representation",
"of",
"the",
"given",
"object",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L346-L367 | [
"def",
"translate",
"(",
"obj",
",",
"desired_locale",
"=",
"None",
")",
":",
"message",
"=",
"obj",
"if",
"not",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"# If the object to translate is not already translatable,",
"# let's first get its unicode represen... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | _translate_args | Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the object itself is
translated if it is translatable.
... | qg/core/gettextutils.py | def _translate_args(args, desired_locale=None):
"""Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the obj... | def _translate_args(args, desired_locale=None):
"""Translates all the translatable elements of the given arguments object.
This method is used for translating the translatable values in method
arguments which include values of tuples or dictionaries.
If the object is not a tuple or a dictionary the obj... | [
"Translates",
"all",
"the",
"translatable",
"elements",
"of",
"the",
"given",
"arguments",
"object",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L370-L393 | [
"def",
"_translate_args",
"(",
"args",
",",
"desired_locale",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"args",
",",
"tuple",
")",
":",
"return",
"tuple",
"(",
"translate",
"(",
"v",
",",
"desired_locale",
")",
"for",
"v",
"in",
"args",
")",
"if"... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Message.translate | Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default locale.
:returns: the translated message in... | qg/core/gettextutils.py | def translate(self, desired_locale=None):
"""Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default... | def translate(self, desired_locale=None):
"""Translate this message to the desired locale.
:param desired_locale: The desired locale to translate the message to,
if no locale is provided the message will be
translated to the system's default... | [
"Translate",
"this",
"message",
"to",
"the",
"desired",
"locale",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L163-L188 | [
"def",
"translate",
"(",
"self",
",",
"desired_locale",
"=",
"None",
")",
":",
"translated_message",
"=",
"Message",
".",
"_translate_msgid",
"(",
"self",
".",
"msgid",
",",
"self",
".",
"domain",
",",
"desired_locale",
")",
"if",
"self",
".",
"params",
"i... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Message._sanitize_mod_params | Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- Snapshot the object being modded, in case the mess... | qg/core/gettextutils.py | def _sanitize_mod_params(self, other):
"""Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- ... | def _sanitize_mod_params(self, other):
"""Sanitize the object being modded with this Message.
- Add support for modding 'None' so translation supports it
- Trim the modded object, which can be a large dictionary, to only
those keys that would actually be used in a translation
- ... | [
"Sanitize",
"the",
"object",
"being",
"modded",
"with",
"this",
"Message",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L225-L240 | [
"def",
"_sanitize_mod_params",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"None",
":",
"params",
"=",
"(",
"other",
",",
")",
"elif",
"isinstance",
"(",
"other",
",",
"dict",
")",
":",
"params",
"=",
"self",
".",
"_trim_dictionary_paramete... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Message._trim_dictionary_parameters | Return a dict that only has matching entries in the msgid. | qg/core/gettextutils.py | def _trim_dictionary_parameters(self, dict_param):
"""Return a dict that only has matching entries in the msgid."""
# NOTE(luisg): Here we trim down the dictionary passed as parameters
# to avoid carrying a lot of unnecessary weight around in the message
# object, for example if someone ... | def _trim_dictionary_parameters(self, dict_param):
"""Return a dict that only has matching entries in the msgid."""
# NOTE(luisg): Here we trim down the dictionary passed as parameters
# to avoid carrying a lot of unnecessary weight around in the message
# object, for example if someone ... | [
"Return",
"a",
"dict",
"that",
"only",
"has",
"matching",
"entries",
"in",
"the",
"msgid",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/gettextutils.py#L242-L272 | [
"def",
"_trim_dictionary_parameters",
"(",
"self",
",",
"dict_param",
")",
":",
"# NOTE(luisg): Here we trim down the dictionary passed as parameters",
"# to avoid carrying a lot of unnecessary weight around in the message",
"# object, for example if someone passes in Message() % locals() but",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | registry_adapter | Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict` | pyramid_urireferencer/renderers.py | def registry_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'query_uri': obj.query_uri,
'... | def registry_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json.
:param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'query_uri': obj.query_uri,
'... | [
"Adapter",
"for",
"rendering",
"a",
":",
"class",
":",
"pyramid_urireferencer",
".",
"models",
".",
"RegistryResponse",
"to",
"json",
"."
] | OnroerendErfgoed/pyramid_urireferencer | python | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L14-L38 | [
"def",
"registry_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'query_uri'",
":",
"obj",
".",
"query_uri",
",",
"'success'",
":",
"obj",
".",
"success",
",",
"'has_references'",
":",
"obj",
".",
"has_references",
",",
"'count'",
":",
"obj... | c6ee4ba863e32ced304b9cf00f3f5b450757a29a |
train | application_adapter | Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict` | pyramid_urireferencer/renderers.py | def application_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'title': obj.title,
... | def application_adapter(obj, request):
"""
Adapter for rendering a :class:`pyramid_urireferencer.models.ApplicationResponse` to json.
:param pyramid_urireferencer.models.ApplicationResponse obj: The response to be rendered.
:rtype: :class:`dict`
"""
return {
'title': obj.title,
... | [
"Adapter",
"for",
"rendering",
"a",
":",
"class",
":",
"pyramid_urireferencer",
".",
"models",
".",
"ApplicationResponse",
"to",
"json",
"."
] | OnroerendErfgoed/pyramid_urireferencer | python | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L41-L59 | [
"def",
"application_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'title'",
":",
"obj",
".",
"title",
",",
"'uri'",
":",
"obj",
".",
"uri",
",",
"'service_url'",
":",
"obj",
".",
"service_url",
",",
"'success'",
":",
"obj",
".",
"succ... | c6ee4ba863e32ced304b9cf00f3f5b450757a29a |
train | replace_umlauts | If put_back is True, put in umlauts; else, take them out! | finnsyll/prev/phonology.py | def replace_umlauts(word, put_back=False): # use translate()
'''If put_back is True, put in umlauts; else, take them out!'''
if put_back:
word = word.replace('A', 'ä')
word = word.replace('O', 'ö')
else:
word = word.replace('ä', 'A').replace('\xc3\xa4', 'A')
word = word.rep... | def replace_umlauts(word, put_back=False): # use translate()
'''If put_back is True, put in umlauts; else, take them out!'''
if put_back:
word = word.replace('A', 'ä')
word = word.replace('O', 'ö')
else:
word = word.replace('ä', 'A').replace('\xc3\xa4', 'A')
word = word.rep... | [
"If",
"put_back",
"is",
"True",
"put",
"in",
"umlauts",
";",
"else",
"take",
"them",
"out!"
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/phonology.py#L203-L213 | [
"def",
"replace_umlauts",
"(",
"word",
",",
"put_back",
"=",
"False",
")",
":",
"# use translate()",
"if",
"put_back",
":",
"word",
"=",
"word",
".",
"replace",
"(",
"'A'",
",",
"'ä')",
"",
"word",
"=",
"word",
".",
"replace",
"(",
"'O'",
",",
"'ö')",
... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | Blaster.get_query_align | Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered | cgecore/blaster/blaster.py | def get_query_align(hit, contig):
"""
Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered
"""
# Getting data needed to extract sequences
query_seq = hit['query_string']
homo_seq = hit['homo_string']
sbjct_... | def get_query_align(hit, contig):
"""
Function for extracting extra seqeunce data to the query
alignment if the full reference length are not covered
"""
# Getting data needed to extract sequences
query_seq = hit['query_string']
homo_seq = hit['homo_string']
sbjct_... | [
"Function",
"for",
"extracting",
"extra",
"seqeunce",
"data",
"to",
"the",
"query",
"alignment",
"if",
"the",
"full",
"reference",
"length",
"are",
"not",
"covered"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/blaster/blaster.py#L465-L575 | [
"def",
"get_query_align",
"(",
"hit",
",",
"contig",
")",
":",
"# Getting data needed to extract sequences",
"query_seq",
"=",
"hit",
"[",
"'query_string'",
"]",
"homo_seq",
"=",
"hit",
"[",
"'homo_string'",
"]",
"sbjct_start",
"=",
"int",
"(",
"hit",
"[",
"'sbj... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | TableDataViewMixin.get_ordering_for_column | Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1. | tablature/views.py | def get_ordering_for_column(self, column, direction):
"""
Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1.
"""
if direction == 0:
return ()
if column in self.orderings:
ordering ... | def get_ordering_for_column(self, column, direction):
"""
Returns a tuple of lookups to order by for the given column
and direction. Direction is an integer, either -1, 0 or 1.
"""
if direction == 0:
return ()
if column in self.orderings:
ordering ... | [
"Returns",
"a",
"tuple",
"of",
"lookups",
"to",
"order",
"by",
"for",
"the",
"given",
"column",
"and",
"direction",
".",
"Direction",
"is",
"an",
"integer",
"either",
"-",
"1",
"0",
"or",
"1",
"."
] | BertrandBordage/django-tablature | python | https://github.com/BertrandBordage/django-tablature/blob/f5198b3fb1ebf7f5dfd8ebfd4bf977468e4f0390/tablature/views.py#L116-L135 | [
"def",
"get_ordering_for_column",
"(",
"self",
",",
"column",
",",
"direction",
")",
":",
"if",
"direction",
"==",
"0",
":",
"return",
"(",
")",
"if",
"column",
"in",
"self",
".",
"orderings",
":",
"ordering",
"=",
"self",
".",
"orderings",
"[",
"column"... | f5198b3fb1ebf7f5dfd8ebfd4bf977468e4f0390 |
train | ApiSpec.model_to_json | Take a model instance and return it as a json struct | pymacaron_core/swagger/spec.py | def model_to_json(self, object, cleanup=True):
"""Take a model instance and return it as a json struct"""
model_name = type(object).__name__
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
... | def model_to_json(self, object, cleanup=True):
"""Take a model instance and return it as a json struct"""
model_name = type(object).__name__
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
... | [
"Take",
"a",
"model",
"instance",
"and",
"return",
"it",
"as",
"a",
"json",
"struct"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L95-L105 | [
"def",
"model_to_json",
"(",
"self",
",",
"object",
",",
"cleanup",
"=",
"True",
")",
":",
"model_name",
"=",
"type",
"(",
"object",
")",
".",
"__name__",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"rais... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | ApiSpec.json_to_model | Take a json strust and a model name, and return a model instance | pymacaron_core/swagger/spec.py | def json_to_model(self, model_name, j):
"""Take a json strust and a model name, and return a model instance"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['defin... | def json_to_model(self, model_name, j):
"""Take a json strust and a model name, and return a model instance"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['defin... | [
"Take",
"a",
"json",
"strust",
"and",
"a",
"model",
"name",
"and",
"return",
"a",
"model",
"instance"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L124-L130 | [
"def",
"json_to_model",
"(",
"self",
",",
"model_name",
",",
"j",
")",
":",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"raise",
"ValidationError",
"(",
"\"Swagger spec has no definition for model %s\"",
"%",
"mode... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | ApiSpec.validate | Validate an object against its swagger model | pymacaron_core/swagger/spec.py | def validate(self, model_name, object):
"""Validate an object against its swagger model"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['definitions'][model_name]... | def validate(self, model_name, object):
"""Validate an object against its swagger model"""
if model_name not in self.swagger_dict['definitions']:
raise ValidationError("Swagger spec has no definition for model %s" % model_name)
model_def = self.swagger_dict['definitions'][model_name]... | [
"Validate",
"an",
"object",
"against",
"its",
"swagger",
"model"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L133-L139 | [
"def",
"validate",
"(",
"self",
",",
"model_name",
",",
"object",
")",
":",
"if",
"model_name",
"not",
"in",
"self",
".",
"swagger_dict",
"[",
"'definitions'",
"]",
":",
"raise",
"ValidationError",
"(",
"\"Swagger spec has no definition for model %s\"",
"%",
"mode... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | ApiSpec.call_on_each_endpoint | Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument. | pymacaron_core/swagger/spec.py | def call_on_each_endpoint(self, callback):
"""Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument.
"""
if 'paths' not in self.swagger_dict:
return
for path, d in list(self.swagger_dict['pa... | def call_on_each_endpoint(self, callback):
"""Find all server endpoints defined in the swagger spec and calls 'callback' for each,
with an instance of EndpointData as argument.
"""
if 'paths' not in self.swagger_dict:
return
for path, d in list(self.swagger_dict['pa... | [
"Find",
"all",
"server",
"endpoints",
"defined",
"in",
"the",
"swagger",
"spec",
"and",
"calls",
"callback",
"for",
"each",
"with",
"an",
"instance",
"of",
"EndpointData",
"as",
"argument",
"."
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/spec.py#L142-L213 | [
"def",
"call_on_each_endpoint",
"(",
"self",
",",
"callback",
")",
":",
"if",
"'paths'",
"not",
"in",
"self",
".",
"swagger_dict",
":",
"return",
"for",
"path",
",",
"d",
"in",
"list",
"(",
"self",
".",
"swagger_dict",
"[",
"'paths'",
"]",
".",
"items",
... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | main | Buffer stdin and flush, and avoid incomplete files. | safeoutput/__init__.py | def main(args=None):
"""Buffer stdin and flush, and avoid incomplete files."""
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'--binary',
dest='mode',
action='store_const',
const="wb",
default="w",
help='write in binary mode')
... | def main(args=None):
"""Buffer stdin and flush, and avoid incomplete files."""
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'--binary',
dest='mode',
action='store_const',
const="wb",
default="w",
help='write in binary mode')
... | [
"Buffer",
"stdin",
"and",
"flush",
"and",
"avoid",
"incomplete",
"files",
"."
] | andrewguy9/safeoutput | python | https://github.com/andrewguy9/safeoutput/blob/e48fa1f691b57ea81c8faf7539f0bdd28ab59be5/safeoutput/__init__.py#L64-L86 | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"main",
".",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'--binary'",
",",
"dest",
"=",
"'mode'",
",",
"action",
"=",
... | e48fa1f691b57ea81c8faf7539f0bdd28ab59be5 |
train | basic_c_defines | Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
@keyboard_prefix: Prefix used for to_hid_keyboard
@led_prefix: Prefix used for to_hid_led
@sysctrl_prefix: Prefix used for to_hid_sysctrl
@cons_prefix: Prefix used for to_hid_consumer
@code_suf... | layouts/emitter.py | def basic_c_defines(
layout,
keyboard_prefix="KEY_",
led_prefix="LED_",
sysctrl_prefix="SYS_",
cons_prefix="CONS_",
code_suffix=True,
all_caps=True,
space_char="_"
):
'''
Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
... | def basic_c_defines(
layout,
keyboard_prefix="KEY_",
led_prefix="LED_",
sysctrl_prefix="SYS_",
cons_prefix="CONS_",
code_suffix=True,
all_caps=True,
space_char="_"
):
'''
Generates a list of C defines that can be used to generate a header file
@param layout: Layout object
... | [
"Generates",
"a",
"list",
"of",
"C",
"defines",
"that",
"can",
"be",
"used",
"to",
"generate",
"a",
"header",
"file"
] | hid-io/layouts-python | python | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/emitter.py#L11-L81 | [
"def",
"basic_c_defines",
"(",
"layout",
",",
"keyboard_prefix",
"=",
"\"KEY_\"",
",",
"led_prefix",
"=",
"\"LED_\"",
",",
"sysctrl_prefix",
"=",
"\"SYS_\"",
",",
"cons_prefix",
"=",
"\"CONS_\"",
",",
"code_suffix",
"=",
"True",
",",
"all_caps",
"=",
"True",
"... | b347578bfb4198fd812ecd7a2d9c7e551a856280 |
train | ConstantContact.new_email_marketing_campaign | Create a Constant Contact email marketing campaign.
Returns an EmailMarketingCampaign object. | django_constant_contact/models.py | def new_email_marketing_campaign(self, name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
is_view_as_webpage_enabled=False,
view_as... | def new_email_marketing_campaign(self, name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
is_view_as_webpage_enabled=False,
view_as... | [
"Create",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
".",
"Returns",
"an",
"EmailMarketingCampaign",
"object",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L56-L105 | [
"def",
"new_email_marketing_campaign",
"(",
"self",
",",
"name",
",",
"email_content",
",",
"from_email",
",",
"from_name",
",",
"reply_to_email",
",",
"subject",
",",
"text_content",
",",
"address",
",",
"is_view_as_webpage_enabled",
"=",
"False",
",",
"view_as_web... | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | ConstantContact.update_email_marketing_campaign | Update a Constant Contact email marketing campaign.
Returns the updated EmailMarketingCampaign object. | django_constant_contact/models.py | def update_email_marketing_campaign(self, email_marketing_campaign,
name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
... | def update_email_marketing_campaign(self, email_marketing_campaign,
name, email_content, from_email,
from_name, reply_to_email, subject,
text_content, address,
... | [
"Update",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
".",
"Returns",
"the",
"updated",
"EmailMarketingCampaign",
"object",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L107-L162 | [
"def",
"update_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
",",
"name",
",",
"email_content",
",",
"from_email",
",",
"from_name",
",",
"reply_to_email",
",",
"subject",
",",
"text_content",
",",
"address",
",",
"is_view_as_webpage_enabled",... | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | ConstantContact.delete_email_marketing_campaign | Deletes a Constant Contact email marketing campaign. | django_constant_contact/models.py | def delete_email_marketing_campaign(self, email_marketing_campaign):
"""Deletes a Constant Contact email marketing campaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id)]))
response = url.d... | def delete_email_marketing_campaign(self, email_marketing_campaign):
"""Deletes a Constant Contact email marketing campaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id)]))
response = url.d... | [
"Deletes",
"a",
"Constant",
"Contact",
"email",
"marketing",
"campaign",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L164-L172 | [
"def",
"delete_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
")",
":",
"url",
"=",
"self",
".",
"api",
".",
"join",
"(",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"EMAIL_MARKETING_CAMPAIGN_URL",
",",
"str",
"(",
"email_marketing_campa... | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | ConstantContact.inline_css | Inlines CSS defined in external style sheets. | django_constant_contact/models.py | def inline_css(self, html):
"""Inlines CSS defined in external style sheets.
"""
premailer = Premailer(html)
inlined_html = premailer.transform(pretty_print=True)
return inlined_html | def inline_css(self, html):
"""Inlines CSS defined in external style sheets.
"""
premailer = Premailer(html)
inlined_html = premailer.transform(pretty_print=True)
return inlined_html | [
"Inlines",
"CSS",
"defined",
"in",
"external",
"style",
"sheets",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L174-L179 | [
"def",
"inline_css",
"(",
"self",
",",
"html",
")",
":",
"premailer",
"=",
"Premailer",
"(",
"html",
")",
"inlined_html",
"=",
"premailer",
".",
"transform",
"(",
"pretty_print",
"=",
"True",
")",
"return",
"inlined_html"
] | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | ConstantContact.preview_email_marketing_campaign | Returns HTML and text previews of an EmailMarketingCampaign. | django_constant_contact/models.py | def preview_email_marketing_campaign(self, email_marketing_campaign):
"""Returns HTML and text previews of an EmailMarketingCampaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id),
'prev... | def preview_email_marketing_campaign(self, email_marketing_campaign):
"""Returns HTML and text previews of an EmailMarketingCampaign.
"""
url = self.api.join('/'.join([
self.EMAIL_MARKETING_CAMPAIGN_URL,
str(email_marketing_campaign.constant_contact_id),
'prev... | [
"Returns",
"HTML",
"and",
"text",
"previews",
"of",
"an",
"EmailMarketingCampaign",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L181-L191 | [
"def",
"preview_email_marketing_campaign",
"(",
"self",
",",
"email_marketing_campaign",
")",
":",
"url",
"=",
"self",
".",
"api",
".",
"join",
"(",
"'/'",
".",
"join",
"(",
"[",
"self",
".",
"EMAIL_MARKETING_CAMPAIGN_URL",
",",
"str",
"(",
"email_marketing_camp... | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | EmailMarketingCampaign.pre_save | Pull constant_contact_id out of data. | django_constant_contact/models.py | def pre_save(cls, sender, instance, *args, **kwargs):
"""Pull constant_contact_id out of data.
"""
instance.constant_contact_id = str(instance.data['id']) | def pre_save(cls, sender, instance, *args, **kwargs):
"""Pull constant_contact_id out of data.
"""
instance.constant_contact_id = str(instance.data['id']) | [
"Pull",
"constant_contact_id",
"out",
"of",
"data",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L216-L219 | [
"def",
"pre_save",
"(",
"cls",
",",
"sender",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
".",
"constant_contact_id",
"=",
"str",
"(",
"instance",
".",
"data",
"[",
"'id'",
"]",
")"
] | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | EmailMarketingCampaign.pre_delete | Deletes the CC email marketing campaign associated with me. | django_constant_contact/models.py | def pre_delete(cls, sender, instance, *args, **kwargs):
"""Deletes the CC email marketing campaign associated with me.
"""
cc = ConstantContact()
response = cc.delete_email_marketing_campaign(instance)
response.raise_for_status() | def pre_delete(cls, sender, instance, *args, **kwargs):
"""Deletes the CC email marketing campaign associated with me.
"""
cc = ConstantContact()
response = cc.delete_email_marketing_campaign(instance)
response.raise_for_status() | [
"Deletes",
"the",
"CC",
"email",
"marketing",
"campaign",
"associated",
"with",
"me",
"."
] | AASHE/django-constant-contact | python | https://github.com/AASHE/django-constant-contact/blob/2a37f00ee62531804414b35637d0dad5992d5822/django_constant_contact/models.py#L222-L227 | [
"def",
"pre_delete",
"(",
"cls",
",",
"sender",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cc",
"=",
"ConstantContact",
"(",
")",
"response",
"=",
"cc",
".",
"delete_email_marketing_campaign",
"(",
"instance",
")",
"response",
... | 2a37f00ee62531804414b35637d0dad5992d5822 |
train | SixteenS.runner | Run the necessary methods in the correct order | sixteenS/sixteenS_probes.py | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteenS_probes.py#L418-L443 | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
",",
"self",
".",
"starttime",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# If the metadata has been passed f... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | send_email | Will send a multi-format email to recipients. Email may be queued through celery | mailing/mail.py | def send_email(recipients, subject, text_content=None, html_content=None, from_email=None, use_base_template=True, category=None, fail_silently=False, language=None, cc=None, bcc=None, attachments=None, headers=None, bypass_queue=False, bypass_hijacking=False, attach_files=None):
"""
Will send a multi-format ... | def send_email(recipients, subject, text_content=None, html_content=None, from_email=None, use_base_template=True, category=None, fail_silently=False, language=None, cc=None, bcc=None, attachments=None, headers=None, bypass_queue=False, bypass_hijacking=False, attach_files=None):
"""
Will send a multi-format ... | [
"Will",
"send",
"a",
"multi",
"-",
"format",
"email",
"to",
"recipients",
".",
"Email",
"may",
"be",
"queued",
"through",
"celery"
] | JeromeParadis/django-mailing | python | https://github.com/JeromeParadis/django-mailing/blob/e1773410ab8ab946caf2847c46e025ba43c1ba6c/mailing/mail.py#L23-L103 | [
"def",
"send_email",
"(",
"recipients",
",",
"subject",
",",
"text_content",
"=",
"None",
",",
"html_content",
"=",
"None",
",",
"from_email",
"=",
"None",
",",
"use_base_template",
"=",
"True",
",",
"category",
"=",
"None",
",",
"fail_silently",
"=",
"False... | e1773410ab8ab946caf2847c46e025ba43c1ba6c |
train | ConnectionPool.initialize_connections | Initialize a database connection by each connection string
defined in the configuration file | flask_philo_sqlalchemy/connection.py | def initialize_connections(self, scopefunc=None):
"""
Initialize a database connection by each connection string
defined in the configuration file
"""
for connection_name, connection_string in\
self.app.config['FLASK_PHILO_SQLALCHEMY'].items():
engine ... | def initialize_connections(self, scopefunc=None):
"""
Initialize a database connection by each connection string
defined in the configuration file
"""
for connection_name, connection_string in\
self.app.config['FLASK_PHILO_SQLALCHEMY'].items():
engine ... | [
"Initialize",
"a",
"database",
"connection",
"by",
"each",
"connection",
"string",
"defined",
"in",
"the",
"configuration",
"file"
] | Riffstation/Flask-Philo-SQLAlchemy | python | https://github.com/Riffstation/Flask-Philo-SQLAlchemy/blob/71598bb603b8458a2cf9f7989f71d8f1c77fafb9/flask_philo_sqlalchemy/connection.py#L26-L36 | [
"def",
"initialize_connections",
"(",
"self",
",",
"scopefunc",
"=",
"None",
")",
":",
"for",
"connection_name",
",",
"connection_string",
"in",
"self",
".",
"app",
".",
"config",
"[",
"'FLASK_PHILO_SQLALCHEMY'",
"]",
".",
"items",
"(",
")",
":",
"engine",
"... | 71598bb603b8458a2cf9f7989f71d8f1c77fafb9 |
train | sortableListe.sort | Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant | pyDLib/Core/groups.py | def sort(self, attribut, order=False):
"""
Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant
"""
value_default = formats.ASSOCIATION[attribut][3]
if type(value_default) is str: # case inse... | def sort(self, attribut, order=False):
"""
Implément un tri par attrbut.
:param str attribut: Nom du champ concerné
:param bool order: Ordre croissant ou décroissant
"""
value_default = formats.ASSOCIATION[attribut][3]
if type(value_default) is str: # case inse... | [
"Implément",
"un",
"tri",
"par",
"attrbut",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L9-L27 | [
"def",
"sort",
"(",
"self",
",",
"attribut",
",",
"order",
"=",
"False",
")",
":",
"value_default",
"=",
"formats",
".",
"ASSOCIATION",
"[",
"attribut",
"]",
"[",
"3",
"]",
"if",
"type",
"(",
"value_default",
")",
"is",
"str",
":",
"# case insensitive so... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | sortableListe.index_from_id | Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces | pyDLib/Core/groups.py | def index_from_id(self,Id):
"""Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces"""
try:
return [a.Id for a in self].index(Id)
except IndexError:
return | def index_from_id(self,Id):
"""Return the row of given Id if it'exists, otherwise None. Only works with pseudo-acces"""
try:
return [a.Id for a in self].index(Id)
except IndexError:
return | [
"Return",
"the",
"row",
"of",
"given",
"Id",
"if",
"it",
"exists",
"otherwise",
"None",
".",
"Only",
"works",
"with",
"pseudo",
"-",
"acces"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L38-L43 | [
"def",
"index_from_id",
"(",
"self",
",",
"Id",
")",
":",
"try",
":",
"return",
"[",
"a",
".",
"Id",
"for",
"a",
"in",
"self",
"]",
".",
"index",
"(",
"Id",
")",
"except",
"IndexError",
":",
"return"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Collection.append | Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces. | pyDLib/Core/groups.py | def append(self, acces, **kwargs):
"""Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces.
"""
if acces.Id in set(ac.Id for ac in self):
raise ValueError("Acces id already in list !")
list.append(self, acces)
if kw... | def append(self, acces, **kwargs):
"""Append acces to list. Quite slow since it checks uniqueness.
kwargs may set `info` for this acces.
"""
if acces.Id in set(ac.Id for ac in self):
raise ValueError("Acces id already in list !")
list.append(self, acces)
if kw... | [
"Append",
"acces",
"to",
"list",
".",
"Quite",
"slow",
"since",
"it",
"checks",
"uniqueness",
".",
"kwargs",
"may",
"set",
"info",
"for",
"this",
"acces",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L65-L73 | [
"def",
"append",
"(",
"self",
",",
"acces",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"acces",
".",
"Id",
"in",
"set",
"(",
"ac",
".",
"Id",
"for",
"ac",
"in",
"self",
")",
":",
"raise",
"ValueError",
"(",
"\"Acces id already in list !\"",
")",
"list"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Collection.remove_id | Suppress acces with id = key | pyDLib/Core/groups.py | def remove_id(self,key):
"""Suppress acces with id = key"""
self.infos.pop(key, "")
new_l = [a for a in self if not (a.Id == key)]
list.__init__(self, new_l) | def remove_id(self,key):
"""Suppress acces with id = key"""
self.infos.pop(key, "")
new_l = [a for a in self if not (a.Id == key)]
list.__init__(self, new_l) | [
"Suppress",
"acces",
"with",
"id",
"=",
"key"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L75-L79 | [
"def",
"remove_id",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"infos",
".",
"pop",
"(",
"key",
",",
"\"\"",
")",
"new_l",
"=",
"[",
"a",
"for",
"a",
"in",
"self",
"if",
"not",
"(",
"a",
".",
"Id",
"==",
"key",
")",
"]",
"list",
".",
"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Collection.get_info | Returns information associated with Id or list index | pyDLib/Core/groups.py | def get_info(self, key=None, Id=None) -> dict:
"""Returns information associated with Id or list index"""
if key is not None:
Id = self[key].Id
return self.infos.get(Id,{}) | def get_info(self, key=None, Id=None) -> dict:
"""Returns information associated with Id or list index"""
if key is not None:
Id = self[key].Id
return self.infos.get(Id,{}) | [
"Returns",
"information",
"associated",
"with",
"Id",
"or",
"list",
"index"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L91-L95 | [
"def",
"get_info",
"(",
"self",
",",
"key",
"=",
"None",
",",
"Id",
"=",
"None",
")",
"->",
"dict",
":",
"if",
"key",
"is",
"not",
"None",
":",
"Id",
"=",
"self",
"[",
"key",
"]",
".",
"Id",
"return",
"self",
".",
"infos",
".",
"get",
"(",
"I... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Collection.recherche | Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place | pyDLib/Core/groups.py | def recherche(self, pattern, entete):
"""Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place
"... | def recherche(self, pattern, entete):
"""Performs a search field by field, using functions defined in formats.
Matchs are marked with info[`font`]
:param pattern: String to look for
:param entete: Fields to look into
:return: Nothing. The collection is changed in place
"... | [
"Performs",
"a",
"search",
"field",
"by",
"field",
"using",
"functions",
"defined",
"in",
"formats",
".",
"Matchs",
"are",
"marked",
"with",
"info",
"[",
"font",
"]"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L102-L132 | [
"def",
"recherche",
"(",
"self",
",",
"pattern",
",",
"entete",
")",
":",
"new_liste",
"=",
"[",
"]",
"sub_patterns",
"=",
"pattern",
".",
"split",
"(",
"\" \"",
")",
"for",
"p",
"in",
"self",
":",
"d_font",
"=",
"{",
"att",
":",
"False",
"for",
"a... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | Collection.extend | Merges collections. Ensure uniqueness of ids | pyDLib/Core/groups.py | def extend(self, collection):
"""Merges collections. Ensure uniqueness of ids"""
l_ids = set([a.Id for a in self])
for acces in collection:
if not acces.Id in l_ids:
list.append(self,acces)
info = collection.get_info(Id=acces.Id)
if inf... | def extend(self, collection):
"""Merges collections. Ensure uniqueness of ids"""
l_ids = set([a.Id for a in self])
for acces in collection:
if not acces.Id in l_ids:
list.append(self,acces)
info = collection.get_info(Id=acces.Id)
if inf... | [
"Merges",
"collections",
".",
"Ensure",
"uniqueness",
"of",
"ids"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/groups.py#L135-L143 | [
"def",
"extend",
"(",
"self",
",",
"collection",
")",
":",
"l_ids",
"=",
"set",
"(",
"[",
"a",
".",
"Id",
"for",
"a",
"in",
"self",
"]",
")",
"for",
"acces",
"in",
"collection",
":",
"if",
"not",
"acces",
".",
"Id",
"in",
"l_ids",
":",
"list",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | isotime | Stringify time in ISO 8601 format. | qg/core/timeutils.py | def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format."""
if not at:
at = utcnow()
st = at.strftime(_ISO8601_TIME_FORMAT
if not subsecond
else _ISO8601_TIME_FORMAT_SUBSECOND)
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
s... | def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format."""
if not at:
at = utcnow()
st = at.strftime(_ISO8601_TIME_FORMAT
if not subsecond
else _ISO8601_TIME_FORMAT_SUBSECOND)
tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
s... | [
"Stringify",
"time",
"in",
"ISO",
"8601",
"format",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L34-L43 | [
"def",
"isotime",
"(",
"at",
"=",
"None",
",",
"subsecond",
"=",
"False",
")",
":",
"if",
"not",
"at",
":",
"at",
"=",
"utcnow",
"(",
")",
"st",
"=",
"at",
".",
"strftime",
"(",
"_ISO8601_TIME_FORMAT",
"if",
"not",
"subsecond",
"else",
"_ISO8601_TIME_F... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | parse_isotime | Parse time from ISO 8601 format. | qg/core/timeutils.py | def parse_isotime(timestr):
"""Parse time from ISO 8601 format."""
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
raise ValueError(six.text_type(e))
except TypeError as e:
raise ValueError(six.text_type(e)) | def parse_isotime(timestr):
"""Parse time from ISO 8601 format."""
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
raise ValueError(six.text_type(e))
except TypeError as e:
raise ValueError(six.text_type(e)) | [
"Parse",
"time",
"from",
"ISO",
"8601",
"format",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L46-L53 | [
"def",
"parse_isotime",
"(",
"timestr",
")",
":",
"try",
":",
"return",
"iso8601",
".",
"parse_date",
"(",
"timestr",
")",
"except",
"iso8601",
".",
"ParseError",
"as",
"e",
":",
"raise",
"ValueError",
"(",
"six",
".",
"text_type",
"(",
"e",
")",
")",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | strtime | Returns formatted utcnow. | qg/core/timeutils.py | def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
"""Returns formatted utcnow."""
if not at:
at = utcnow()
return at.strftime(fmt) | def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
"""Returns formatted utcnow."""
if not at:
at = utcnow()
return at.strftime(fmt) | [
"Returns",
"formatted",
"utcnow",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L56-L60 | [
"def",
"strtime",
"(",
"at",
"=",
"None",
",",
"fmt",
"=",
"PERFECT_TIME_FORMAT",
")",
":",
"if",
"not",
"at",
":",
"at",
"=",
"utcnow",
"(",
")",
"return",
"at",
".",
"strftime",
"(",
"fmt",
")"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | normalize_time | Normalize time in arbitrary timezone to UTC naive object. | qg/core/timeutils.py | def normalize_time(timestamp):
"""Normalize time in arbitrary timezone to UTC naive object."""
offset = timestamp.utcoffset()
if offset is None:
return timestamp
return timestamp.replace(tzinfo=None) - offset | def normalize_time(timestamp):
"""Normalize time in arbitrary timezone to UTC naive object."""
offset = timestamp.utcoffset()
if offset is None:
return timestamp
return timestamp.replace(tzinfo=None) - offset | [
"Normalize",
"time",
"in",
"arbitrary",
"timezone",
"to",
"UTC",
"naive",
"object",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L68-L73 | [
"def",
"normalize_time",
"(",
"timestamp",
")",
":",
"offset",
"=",
"timestamp",
".",
"utcoffset",
"(",
")",
"if",
"offset",
"is",
"None",
":",
"return",
"timestamp",
"return",
"timestamp",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"-",
"offset"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | is_older_than | Return True if before is older than seconds. | qg/core/timeutils.py | def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
else:
before = before.replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds) | def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
else:
before = before.replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds) | [
"Return",
"True",
"if",
"before",
"is",
"older",
"than",
"seconds",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L76-L83 | [
"def",
"is_older_than",
"(",
"before",
",",
"seconds",
")",
":",
"if",
"isinstance",
"(",
"before",
",",
"six",
".",
"string_types",
")",
":",
"before",
"=",
"parse_strtime",
"(",
"before",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"else",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | is_newer_than | Return True if after is newer than seconds. | qg/core/timeutils.py | def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
else:
after = after.replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds) | def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
else:
after = after.replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds) | [
"Return",
"True",
"if",
"after",
"is",
"newer",
"than",
"seconds",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L86-L93 | [
"def",
"is_newer_than",
"(",
"after",
",",
"seconds",
")",
":",
"if",
"isinstance",
"(",
"after",
",",
"six",
".",
"string_types",
")",
":",
"after",
"=",
"parse_strtime",
"(",
"after",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")",
"else",
":",... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | utcnow_ts | Timestamp version of our utcnow function. | qg/core/timeutils.py | def utcnow_ts():
"""Timestamp version of our utcnow function."""
if utcnow.override_time is None:
# NOTE(kgriffs): This is several times faster
# than going through calendar.timegm(...)
return int(time.time())
return calendar.timegm(utcnow().timetuple()) | def utcnow_ts():
"""Timestamp version of our utcnow function."""
if utcnow.override_time is None:
# NOTE(kgriffs): This is several times faster
# than going through calendar.timegm(...)
return int(time.time())
return calendar.timegm(utcnow().timetuple()) | [
"Timestamp",
"version",
"of",
"our",
"utcnow",
"function",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L96-L103 | [
"def",
"utcnow_ts",
"(",
")",
":",
"if",
"utcnow",
".",
"override_time",
"is",
"None",
":",
"# NOTE(kgriffs): This is several times faster",
"# than going through calendar.timegm(...)",
"return",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"return",
"calendar",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | utcnow | Overridable version of utils.utcnow. | qg/core/timeutils.py | def utcnow():
"""Overridable version of utils.utcnow."""
if utcnow.override_time:
try:
return utcnow.override_time.pop(0)
except AttributeError:
return utcnow.override_time
return datetime.datetime.utcnow() | def utcnow():
"""Overridable version of utils.utcnow."""
if utcnow.override_time:
try:
return utcnow.override_time.pop(0)
except AttributeError:
return utcnow.override_time
return datetime.datetime.utcnow() | [
"Overridable",
"version",
"of",
"utils",
".",
"utcnow",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L106-L113 | [
"def",
"utcnow",
"(",
")",
":",
"if",
"utcnow",
".",
"override_time",
":",
"try",
":",
"return",
"utcnow",
".",
"override_time",
".",
"pop",
"(",
"0",
")",
"except",
"AttributeError",
":",
"return",
"utcnow",
".",
"override_time",
"return",
"datetime",
"."... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | advance_time_delta | Advance overridden time using a datetime.timedelta. | qg/core/timeutils.py | def advance_time_delta(timedelta):
"""Advance overridden time using a datetime.timedelta."""
assert(utcnow.override_time is not None)
try:
for dt in utcnow.override_time:
dt += timedelta
except TypeError:
utcnow.override_time += timedelta | def advance_time_delta(timedelta):
"""Advance overridden time using a datetime.timedelta."""
assert(utcnow.override_time is not None)
try:
for dt in utcnow.override_time:
dt += timedelta
except TypeError:
utcnow.override_time += timedelta | [
"Advance",
"overridden",
"time",
"using",
"a",
"datetime",
".",
"timedelta",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L135-L142 | [
"def",
"advance_time_delta",
"(",
"timedelta",
")",
":",
"assert",
"(",
"utcnow",
".",
"override_time",
"is",
"not",
"None",
")",
"try",
":",
"for",
"dt",
"in",
"utcnow",
".",
"override_time",
":",
"dt",
"+=",
"timedelta",
"except",
"TypeError",
":",
"utcn... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | marshall_now | Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times. | qg/core/timeutils.py | def marshall_now(now=None):
"""Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times.
"""
if not now:
now = utcnow()
return dict(day=now.day, month=now.month, year=now.year, hour=now.hour,
minute=now.minute, second=now.sec... | def marshall_now(now=None):
"""Make an rpc-safe datetime with microseconds.
Note: tzinfo is stripped, but not required for relative times.
"""
if not now:
now = utcnow()
return dict(day=now.day, month=now.month, year=now.year, hour=now.hour,
minute=now.minute, second=now.sec... | [
"Make",
"an",
"rpc",
"-",
"safe",
"datetime",
"with",
"microseconds",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L155-L164 | [
"def",
"marshall_now",
"(",
"now",
"=",
"None",
")",
":",
"if",
"not",
"now",
":",
"now",
"=",
"utcnow",
"(",
")",
"return",
"dict",
"(",
"day",
"=",
"now",
".",
"day",
",",
"month",
"=",
"now",
".",
"month",
",",
"year",
"=",
"now",
".",
"year... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | unmarshall_time | Unmarshall a datetime dict. | qg/core/timeutils.py | def unmarshall_time(tyme):
"""Unmarshall a datetime dict."""
return datetime.datetime(day=tyme['day'],
month=tyme['month'],
year=tyme['year'],
hour=tyme['hour'],
minute=tyme['minute'],
... | def unmarshall_time(tyme):
"""Unmarshall a datetime dict."""
return datetime.datetime(day=tyme['day'],
month=tyme['month'],
year=tyme['year'],
hour=tyme['hour'],
minute=tyme['minute'],
... | [
"Unmarshall",
"a",
"datetime",
"dict",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L167-L175 | [
"def",
"unmarshall_time",
"(",
"tyme",
")",
":",
"return",
"datetime",
".",
"datetime",
"(",
"day",
"=",
"tyme",
"[",
"'day'",
"]",
",",
"month",
"=",
"tyme",
"[",
"'month'",
"]",
",",
"year",
"=",
"tyme",
"[",
"'year'",
"]",
",",
"hour",
"=",
"tym... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | total_seconds | Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually. | qg/core/timeutils.py | def total_seconds(delta):
"""Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually.
"""
try:
return delta.total_seconds()
except AttributeError:
... | def total_seconds(delta):
"""Return the total seconds of datetime.timedelta object.
Compute total seconds of datetime.timedelta, datetime.timedelta
doesn't have method total_seconds in Python2.6, calculate it manually.
"""
try:
return delta.total_seconds()
except AttributeError:
... | [
"Return",
"the",
"total",
"seconds",
"of",
"datetime",
".",
"timedelta",
"object",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L188-L198 | [
"def",
"total_seconds",
"(",
"delta",
")",
":",
"try",
":",
"return",
"delta",
".",
"total_seconds",
"(",
")",
"except",
"AttributeError",
":",
"return",
"(",
"(",
"delta",
".",
"days",
"*",
"24",
"*",
"3600",
")",
"+",
"delta",
".",
"seconds",
"+",
... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | is_soon | Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration | qg/core/timeutils.py | def is_soon(dt, window):
"""Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration
"""
soon = (utcnow() + datetime.timedelta(seconds=... | def is_soon(dt, window):
"""Determines if time is going to happen in the next window seconds.
:params dt: the time
:params window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration
"""
soon = (utcnow() + datetime.timedelta(seconds=... | [
"Determines",
"if",
"time",
"is",
"going",
"to",
"happen",
"in",
"the",
"next",
"window",
"seconds",
"."
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L201-L210 | [
"def",
"is_soon",
"(",
"dt",
",",
"window",
")",
":",
"soon",
"=",
"(",
"utcnow",
"(",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"window",
")",
")",
"return",
"normalize_time",
"(",
"dt",
")",
"<=",
"soon"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | download_file_powershell | Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete. | ez_setup.py | def download_file_powershell(url, target):
'''
Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete.
'''
target = os.path.abspath(target)
cmd = [
'powershell',
'-Command',
'(new-object System.Ne... | def download_file_powershell(url, target):
'''
Download the file at url to target using Powershell (which will validate
trust). Raise an exception if the command cannot complete.
'''
target = os.path.abspath(target)
cmd = [
'powershell',
'-Command',
'(new-object System.Ne... | [
"Download",
"the",
"file",
"at",
"url",
"to",
"target",
"using",
"Powershell",
"(",
"which",
"will",
"validate",
"trust",
")",
".",
"Raise",
"an",
"exception",
"if",
"the",
"command",
"cannot",
"complete",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L162-L173 | [
"def",
"download_file_powershell",
"(",
"url",
",",
"target",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"target",
")",
"cmd",
"=",
"[",
"'powershell'",
",",
"'-Command'",
",",
"'(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | download_file_insecure | Use Python to download the file, even though it cannot authenticate the
connection. | ez_setup.py | def download_file_insecure(url, target):
'''
Use Python to download the file, even though it cannot authenticate the
connection.
'''
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
src = dst = None
try:
src = urlopen(url)
... | def download_file_insecure(url, target):
'''
Use Python to download the file, even though it cannot authenticate the
connection.
'''
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
src = dst = None
try:
src = urlopen(url)
... | [
"Use",
"Python",
"to",
"download",
"the",
"file",
"even",
"though",
"it",
"cannot",
"authenticate",
"the",
"connection",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L233-L254 | [
"def",
"download_file_insecure",
"(",
"url",
",",
"target",
")",
":",
"try",
":",
"from",
"urllib",
".",
"request",
"import",
"urlopen",
"except",
"ImportError",
":",
"from",
"urllib2",
"import",
"urlopen",
"src",
"=",
"dst",
"=",
"None",
"try",
":",
"src"... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | _build_install_args | Build the arguments to 'python setup.py install' on the setuptools package | ez_setup.py | def _build_install_args(options):
'''
Build the arguments to 'python setup.py install' on the setuptools package
'''
install_args = []
if options.user_install:
if sys.version_info < (2, 6):
log.warn('--user requires Python 2.6 or later')
raise SystemExit(1)
in... | def _build_install_args(options):
'''
Build the arguments to 'python setup.py install' on the setuptools package
'''
install_args = []
if options.user_install:
if sys.version_info < (2, 6):
log.warn('--user requires Python 2.6 or later')
raise SystemExit(1)
in... | [
"Build",
"the",
"arguments",
"to",
"python",
"setup",
".",
"py",
"install",
"on",
"the",
"setuptools",
"package"
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L345-L355 | [
"def",
"_build_install_args",
"(",
"options",
")",
":",
"install_args",
"=",
"[",
"]",
"if",
"options",
".",
"user_install",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
"6",
")",
":",
"log",
".",
"warn",
"(",
"'--user requires Python 2.6 or ... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | write | Temporarily change or set the environment variable during the execution of a function.
Args:
name: The name of the environment variable
value: A value to set for the environment variable
Returns:
The function return value. | envitro/decorators.py | def write(name, value):
"""Temporarily change or set the environment variable during the execution of a function.
Args:
name: The name of the environment variable
value: A value to set for the environment variable
Returns:
The function return value.
"""
def wrapped(func):
... | def write(name, value):
"""Temporarily change or set the environment variable during the execution of a function.
Args:
name: The name of the environment variable
value: A value to set for the environment variable
Returns:
The function return value.
"""
def wrapped(func):
... | [
"Temporarily",
"change",
"or",
"set",
"the",
"environment",
"variable",
"during",
"the",
"execution",
"of",
"a",
"function",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/decorators.py#L17-L36 | [
"def",
"write",
"(",
"name",
",",
"value",
")",
":",
"def",
"wrapped",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"existing_env",
"=",
"core",
... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | isset | Only execute the function if the variable is set.
Args:
name: The name of the environment variable
Returns:
The function return value or `None` if the function was skipped. | envitro/decorators.py | def isset(name):
"""Only execute the function if the variable is set.
Args:
name: The name of the environment variable
Returns:
The function return value or `None` if the function was skipped.
"""
def wrapped(func):
@functools.wraps(func)
def _decorator(*args, **kwa... | def isset(name):
"""Only execute the function if the variable is set.
Args:
name: The name of the environment variable
Returns:
The function return value or `None` if the function was skipped.
"""
def wrapped(func):
@functools.wraps(func)
def _decorator(*args, **kwa... | [
"Only",
"execute",
"the",
"function",
"if",
"the",
"variable",
"is",
"set",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/decorators.py#L44-L59 | [
"def",
"isset",
"(",
"name",
")",
":",
"def",
"wrapped",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"core",
".",
"isset",
"(",
"name",
... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | bool | Only execute the function if the boolean variable is set.
Args:
name: The name of the environment variable
execute_bool: The boolean value to execute the function on
default: The default value if the environment variable is not set (respects `execute_bool`)
Returns:
The functio... | envitro/decorators.py | def bool(name, execute_bool=True, default=None):
"""Only execute the function if the boolean variable is set.
Args:
name: The name of the environment variable
execute_bool: The boolean value to execute the function on
default: The default value if the environment variable is not set (re... | def bool(name, execute_bool=True, default=None):
"""Only execute the function if the boolean variable is set.
Args:
name: The name of the environment variable
execute_bool: The boolean value to execute the function on
default: The default value if the environment variable is not set (re... | [
"Only",
"execute",
"the",
"function",
"if",
"the",
"boolean",
"variable",
"is",
"set",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/decorators.py#L62-L81 | [
"def",
"bool",
"(",
"name",
",",
"execute_bool",
"=",
"True",
",",
"default",
"=",
"None",
")",
":",
"def",
"wrapped",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_decorator",
"(",
"*",
"args",
",",
"*",
"*",
... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | GSheet.read_cell | Reads the cell at position x+1 and y+1; return value
:param x: line index
:param y: coll index
:return: {header: value} | pyheaderfile/drive.py | def read_cell(self, x, y):
"""
Reads the cell at position x+1 and y+1; return value
:param x: line index
:param y: coll index
:return: {header: value}
"""
if isinstance(self.header[y], tuple):
header = self.header[y][0]
else:
header... | def read_cell(self, x, y):
"""
Reads the cell at position x+1 and y+1; return value
:param x: line index
:param y: coll index
:return: {header: value}
"""
if isinstance(self.header[y], tuple):
header = self.header[y][0]
else:
header... | [
"Reads",
"the",
"cell",
"at",
"position",
"x",
"+",
"1",
"and",
"y",
"+",
"1",
";",
"return",
"value",
":",
"param",
"x",
":",
"line",
"index",
":",
"param",
"y",
":",
"coll",
"index",
":",
"return",
":",
"{",
"header",
":",
"value",
"}"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L33-L49 | [
"def",
"read_cell",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"header",
"[",
"y",
"]",
",",
"tuple",
")",
":",
"header",
"=",
"self",
".",
"header",
"[",
"y",
"]",
"[",
"0",
"]",
"else",
":",
"header",
"... | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | GSheet.write_cell | Writing value in the cell of x+1 and y+1 position
:param x: line index
:param y: coll index
:param value: value to be written
:return: | pyheaderfile/drive.py | def write_cell(self, x, y, value):
"""
Writing value in the cell of x+1 and y+1 position
:param x: line index
:param y: coll index
:param value: value to be written
:return:
"""
x += 1
y += 1
self._sheet.update_cell(x, y, value) | def write_cell(self, x, y, value):
"""
Writing value in the cell of x+1 and y+1 position
:param x: line index
:param y: coll index
:param value: value to be written
:return:
"""
x += 1
y += 1
self._sheet.update_cell(x, y, value) | [
"Writing",
"value",
"in",
"the",
"cell",
"of",
"x",
"+",
"1",
"and",
"y",
"+",
"1",
"position",
":",
"param",
"x",
":",
"line",
"index",
":",
"param",
"y",
":",
"coll",
"index",
":",
"param",
"value",
":",
"value",
"to",
"be",
"written",
":",
"re... | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L51-L61 | [
"def",
"write_cell",
"(",
"self",
",",
"x",
",",
"y",
",",
"value",
")",
":",
"x",
"+=",
"1",
"y",
"+=",
"1",
"self",
".",
"_sheet",
".",
"update_cell",
"(",
"x",
",",
"y",
",",
"value",
")"
] | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | GSheet._open | Open the file; get sheets
:return: | pyheaderfile/drive.py | def _open(self):
"""
Open the file; get sheets
:return:
"""
if not hasattr(self, '_file'):
self._file = self.gc.open(self.name)
self.sheet_names = self._file.worksheets() | def _open(self):
"""
Open the file; get sheets
:return:
"""
if not hasattr(self, '_file'):
self._file = self.gc.open(self.name)
self.sheet_names = self._file.worksheets() | [
"Open",
"the",
"file",
";",
"get",
"sheets",
":",
"return",
":"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L73-L80 | [
"def",
"_open",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_file'",
")",
":",
"self",
".",
"_file",
"=",
"self",
".",
"gc",
".",
"open",
"(",
"self",
".",
"name",
")",
"self",
".",
"sheet_names",
"=",
"self",
".",
"_file",... | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | GSheet._open_sheet | Read the sheet, get value the header, get number columns and rows
:return: | pyheaderfile/drive.py | def _open_sheet(self):
"""
Read the sheet, get value the header, get number columns and rows
:return:
"""
if self.sheet_name and not self.header:
self._sheet = self._file.worksheet(self.sheet_name.title)
self.ncols = self._sheet.col_count
self.... | def _open_sheet(self):
"""
Read the sheet, get value the header, get number columns and rows
:return:
"""
if self.sheet_name and not self.header:
self._sheet = self._file.worksheet(self.sheet_name.title)
self.ncols = self._sheet.col_count
self.... | [
"Read",
"the",
"sheet",
"get",
"value",
"the",
"header",
"get",
"number",
"columns",
"and",
"rows",
":",
"return",
":"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L82-L92 | [
"def",
"_open_sheet",
"(",
"self",
")",
":",
"if",
"self",
".",
"sheet_name",
"and",
"not",
"self",
".",
"header",
":",
"self",
".",
"_sheet",
"=",
"self",
".",
"_file",
".",
"worksheet",
"(",
"self",
".",
"sheet_name",
".",
"title",
")",
"self",
"."... | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | GSheet._import | Makes imports
:return: | pyheaderfile/drive.py | def _import(self):
"""
Makes imports
:return:
"""
import os.path
import gspread
self.path = os.path
self.gspread = gspread
self._login() | def _import(self):
"""
Makes imports
:return:
"""
import os.path
import gspread
self.path = os.path
self.gspread = gspread
self._login() | [
"Makes",
"imports",
":",
"return",
":"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L101-L110 | [
"def",
"_import",
"(",
"self",
")",
":",
"import",
"os",
".",
"path",
"import",
"gspread",
"self",
".",
"path",
"=",
"os",
".",
"path",
"self",
".",
"gspread",
"=",
"gspread",
"self",
".",
"_login",
"(",
")"
] | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | GSheet._login | Login with your Google account
:return: | pyheaderfile/drive.py | def _login(self):
"""
Login with your Google account
:return:
"""
# TODO(dmvieira) login changed to oauth2
self.gc = self.gspread.login(self.email, self.password) | def _login(self):
"""
Login with your Google account
:return:
"""
# TODO(dmvieira) login changed to oauth2
self.gc = self.gspread.login(self.email, self.password) | [
"Login",
"with",
"your",
"Google",
"account",
":",
"return",
":"
] | kappius/pyheaderfile | python | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/drive.py#L112-L118 | [
"def",
"_login",
"(",
"self",
")",
":",
"# TODO(dmvieira) login changed to oauth2",
"self",
".",
"gc",
"=",
"self",
".",
"gspread",
".",
"login",
"(",
"self",
".",
"email",
",",
"self",
".",
"password",
")"
] | 8d587dadae538adcec527fd8e74ad89ed5e2006a |
train | abstractModel.flags | All fields are selectable | pyDLib/GUI/list_views.py | def flags(self, index: QModelIndex):
"""All fields are selectable"""
if self.IS_EDITABLE and self.header[index.column()] in self.EDITABLE_FIELDS:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
else:
return super().flags(index) | Qt.ItemIsSelectable | def flags(self, index: QModelIndex):
"""All fields are selectable"""
if self.IS_EDITABLE and self.header[index.column()] in self.EDITABLE_FIELDS:
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
else:
return super().flags(index) | Qt.ItemIsSelectable | [
"All",
"fields",
"are",
"selectable"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L118-L123 | [
"def",
"flags",
"(",
"self",
",",
"index",
":",
"QModelIndex",
")",
":",
"if",
"self",
".",
"IS_EDITABLE",
"and",
"self",
".",
"header",
"[",
"index",
".",
"column",
"(",
")",
"]",
"in",
"self",
".",
"EDITABLE_FIELDS",
":",
"return",
"Qt",
".",
"Item... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractModel.sort | Order is defined by the current state of sorting | pyDLib/GUI/list_views.py | def sort(self, section: int, order=None):
"""Order is defined by the current state of sorting"""
attr = self.header[section]
old_i, old_sort = self.sort_state
self.beginResetModel()
if section == old_i:
self.collection.sort(attr, not old_sort)
self.sort_st... | def sort(self, section: int, order=None):
"""Order is defined by the current state of sorting"""
attr = self.header[section]
old_i, old_sort = self.sort_state
self.beginResetModel()
if section == old_i:
self.collection.sort(attr, not old_sort)
self.sort_st... | [
"Order",
"is",
"defined",
"by",
"the",
"current",
"state",
"of",
"sorting"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L125-L136 | [
"def",
"sort",
"(",
"self",
",",
"section",
":",
"int",
",",
"order",
"=",
"None",
")",
":",
"attr",
"=",
"self",
".",
"header",
"[",
"section",
"]",
"old_i",
",",
"old_sort",
"=",
"self",
".",
"sort_state",
"self",
".",
"beginResetModel",
"(",
")",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractModel.remove_line | Base implementation just pops the item from collection.
Re-implements to add global behaviour | pyDLib/GUI/list_views.py | def remove_line(self, section):
"""Base implementation just pops the item from collection.
Re-implements to add global behaviour
"""
self.beginResetModel()
self.collection.pop(section)
self.endResetModel() | def remove_line(self, section):
"""Base implementation just pops the item from collection.
Re-implements to add global behaviour
"""
self.beginResetModel()
self.collection.pop(section)
self.endResetModel() | [
"Base",
"implementation",
"just",
"pops",
"the",
"item",
"from",
"collection",
".",
"Re",
"-",
"implements",
"to",
"add",
"global",
"behaviour"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L139-L145 | [
"def",
"remove_line",
"(",
"self",
",",
"section",
")",
":",
"self",
".",
"beginResetModel",
"(",
")",
"self",
".",
"collection",
".",
"pop",
"(",
"section",
")",
"self",
".",
"endResetModel",
"(",
")"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractModel._update | Emit dataChanged signal on all cells | pyDLib/GUI/list_views.py | def _update(self):
"""Emit dataChanged signal on all cells"""
self.dataChanged.emit(self.createIndex(0, 0), self.createIndex(
len(self.collection), len(self.header))) | def _update(self):
"""Emit dataChanged signal on all cells"""
self.dataChanged.emit(self.createIndex(0, 0), self.createIndex(
len(self.collection), len(self.header))) | [
"Emit",
"dataChanged",
"signal",
"on",
"all",
"cells"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L147-L150 | [
"def",
"_update",
"(",
"self",
")",
":",
"self",
".",
"dataChanged",
".",
"emit",
"(",
"self",
".",
"createIndex",
"(",
"0",
",",
"0",
")",
",",
"self",
".",
"createIndex",
"(",
"len",
"(",
"self",
".",
"collection",
")",
",",
"len",
"(",
"self",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractModel.get_item | Acces shortcut
:param index: Number of row or index of cell
:return: Dict-like item | pyDLib/GUI/list_views.py | def get_item(self, index):
""" Acces shortcut
:param index: Number of row or index of cell
:return: Dict-like item
"""
row = index.row() if hasattr(index, "row") else index
try:
return self.collection[row]
except IndexError: # invalid index for exemp... | def get_item(self, index):
""" Acces shortcut
:param index: Number of row or index of cell
:return: Dict-like item
"""
row = index.row() if hasattr(index, "row") else index
try:
return self.collection[row]
except IndexError: # invalid index for exemp... | [
"Acces",
"shortcut"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L157-L167 | [
"def",
"get_item",
"(",
"self",
",",
"index",
")",
":",
"row",
"=",
"index",
".",
"row",
"(",
")",
"if",
"hasattr",
"(",
"index",
",",
"\"row\"",
")",
"else",
"index",
"try",
":",
"return",
"self",
".",
"collection",
"[",
"row",
"]",
"except",
"Ind... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractModel.set_collection | Reset sort state, set collection and emit resetModel signal | pyDLib/GUI/list_views.py | def set_collection(self, collection):
"""Reset sort state, set collection and emit resetModel signal"""
self.beginResetModel()
self.collection = collection
self.sort_state = (-1, False)
self.endResetModel() | def set_collection(self, collection):
"""Reset sort state, set collection and emit resetModel signal"""
self.beginResetModel()
self.collection = collection
self.sort_state = (-1, False)
self.endResetModel() | [
"Reset",
"sort",
"state",
"set",
"collection",
"and",
"emit",
"resetModel",
"signal"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L169-L174 | [
"def",
"set_collection",
"(",
"self",
",",
"collection",
")",
":",
"self",
".",
"beginResetModel",
"(",
")",
"self",
".",
"collection",
"=",
"collection",
"self",
".",
"sort_state",
"=",
"(",
"-",
"1",
",",
"False",
")",
"self",
".",
"endResetModel",
"("... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | InternalDataModel.set_item | Changes item at index in collection. Emit dataChanged signal.
:param index: Number of row or index of cell
:param new_item: Dict-like object | pyDLib/GUI/list_views.py | def set_item(self, index, new_item):
""" Changes item at index in collection. Emit dataChanged signal.
:param index: Number of row or index of cell
:param new_item: Dict-like object
"""
row = index.row() if hasattr(index, "row") else index
self.collection[row] = new_item... | def set_item(self, index, new_item):
""" Changes item at index in collection. Emit dataChanged signal.
:param index: Number of row or index of cell
:param new_item: Dict-like object
"""
row = index.row() if hasattr(index, "row") else index
self.collection[row] = new_item... | [
"Changes",
"item",
"at",
"index",
"in",
"collection",
".",
"Emit",
"dataChanged",
"signal",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L191-L200 | [
"def",
"set_item",
"(",
"self",
",",
"index",
",",
"new_item",
")",
":",
"row",
"=",
"index",
".",
"row",
"(",
")",
"if",
"hasattr",
"(",
"index",
",",
"\"row\"",
")",
"else",
"index",
"self",
".",
"collection",
"[",
"row",
"]",
"=",
"new_item",
"s... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | ExternalDataModel.set_data | Uses given data setter, and emit modelReset signal | pyDLib/GUI/list_views.py | def set_data(self, index, value):
"""Uses given data setter, and emit modelReset signal"""
acces, field = self.get_item(index), self.header[index.column()]
self.beginResetModel()
self.set_data_hook(acces, field, value)
self.endResetModel() | def set_data(self, index, value):
"""Uses given data setter, and emit modelReset signal"""
acces, field = self.get_item(index), self.header[index.column()]
self.beginResetModel()
self.set_data_hook(acces, field, value)
self.endResetModel() | [
"Uses",
"given",
"data",
"setter",
"and",
"emit",
"modelReset",
"signal"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L223-L228 | [
"def",
"set_data",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"acces",
",",
"field",
"=",
"self",
".",
"get_item",
"(",
"index",
")",
",",
"self",
".",
"header",
"[",
"index",
".",
"column",
"(",
")",
"]",
"self",
".",
"beginResetModel",
"(... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | MultiSelectModel._set_id | Update selected_ids and emit dataChanged | pyDLib/GUI/list_views.py | def _set_id(self, Id, is_added, index):
"""Update selected_ids and emit dataChanged"""
if is_added:
self.selected_ids.add(Id)
else:
self.selected_ids.remove(Id)
self.dataChanged.emit(index, index) | def _set_id(self, Id, is_added, index):
"""Update selected_ids and emit dataChanged"""
if is_added:
self.selected_ids.add(Id)
else:
self.selected_ids.remove(Id)
self.dataChanged.emit(index, index) | [
"Update",
"selected_ids",
"and",
"emit",
"dataChanged"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L259-L265 | [
"def",
"_set_id",
"(",
"self",
",",
"Id",
",",
"is_added",
",",
"index",
")",
":",
"if",
"is_added",
":",
"self",
".",
"selected_ids",
".",
"add",
"(",
"Id",
")",
"else",
":",
"self",
".",
"selected_ids",
".",
"remove",
"(",
"Id",
")",
"self",
".",... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | MultiSelectModel.setData | Update selected_ids on click on index cell. | pyDLib/GUI/list_views.py | def setData(self, index: QModelIndex, value, role=None):
"""Update selected_ids on click on index cell."""
if not (index.isValid() and role == Qt.CheckStateRole):
return False
c_id = self.get_item(index).Id
self._set_id(c_id, value == Qt.Checked, index)
return True | def setData(self, index: QModelIndex, value, role=None):
"""Update selected_ids on click on index cell."""
if not (index.isValid() and role == Qt.CheckStateRole):
return False
c_id = self.get_item(index).Id
self._set_id(c_id, value == Qt.Checked, index)
return True | [
"Update",
"selected_ids",
"on",
"click",
"on",
"index",
"cell",
"."
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L267-L273 | [
"def",
"setData",
"(",
"self",
",",
"index",
":",
"QModelIndex",
",",
"value",
",",
"role",
"=",
"None",
")",
":",
"if",
"not",
"(",
"index",
".",
"isValid",
"(",
")",
"and",
"role",
"==",
"Qt",
".",
"CheckStateRole",
")",
":",
"return",
"False",
"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | MultiSelectModel.set_by_Id | Update selected_ids with given Id | pyDLib/GUI/list_views.py | def set_by_Id(self, Id, is_added):
"""Update selected_ids with given Id"""
row = self.collection.index_from_id(Id)
if row is None:
return
self._set_id(Id, is_added, self.index(row, 0)) | def set_by_Id(self, Id, is_added):
"""Update selected_ids with given Id"""
row = self.collection.index_from_id(Id)
if row is None:
return
self._set_id(Id, is_added, self.index(row, 0)) | [
"Update",
"selected_ids",
"with",
"given",
"Id"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L275-L280 | [
"def",
"set_by_Id",
"(",
"self",
",",
"Id",
",",
"is_added",
")",
":",
"row",
"=",
"self",
".",
"collection",
".",
"index_from_id",
"(",
"Id",
")",
"if",
"row",
"is",
"None",
":",
"return",
"self",
".",
"_set_id",
"(",
"Id",
",",
"is_added",
",",
"... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractList._setup_delegate | Add resize behavior on edit | pyDLib/GUI/list_views.py | def _setup_delegate(self):
"""Add resize behavior on edit"""
delegate = self.DELEGATE_CLASS(self)
self.setItemDelegate(delegate)
delegate.sizeHintChanged.connect(
lambda index: self.resizeRowToContents(index.row()))
if self.RESIZE_COLUMN:
delegate.sizeHint... | def _setup_delegate(self):
"""Add resize behavior on edit"""
delegate = self.DELEGATE_CLASS(self)
self.setItemDelegate(delegate)
delegate.sizeHintChanged.connect(
lambda index: self.resizeRowToContents(index.row()))
if self.RESIZE_COLUMN:
delegate.sizeHint... | [
"Add",
"resize",
"behavior",
"on",
"edit"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L346-L356 | [
"def",
"_setup_delegate",
"(",
"self",
")",
":",
"delegate",
"=",
"self",
".",
"DELEGATE_CLASS",
"(",
"self",
")",
"self",
".",
"setItemDelegate",
"(",
"delegate",
")",
"delegate",
".",
"sizeHintChanged",
".",
"connect",
"(",
"lambda",
"index",
":",
"self",
... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractList._draw_placeholder | To be used in QTreeView | pyDLib/GUI/list_views.py | def _draw_placeholder(self):
"""To be used in QTreeView"""
if self.model().rowCount() == 0:
painter = QPainter(self.viewport())
painter.setFont(_custom_font(is_italic=True))
painter.drawText(self.rect().adjusted(0, 0, -5, -5), Qt.AlignCenter | Qt.TextWordWrap,
... | def _draw_placeholder(self):
"""To be used in QTreeView"""
if self.model().rowCount() == 0:
painter = QPainter(self.viewport())
painter.setFont(_custom_font(is_italic=True))
painter.drawText(self.rect().adjusted(0, 0, -5, -5), Qt.AlignCenter | Qt.TextWordWrap,
... | [
"To",
"be",
"used",
"in",
"QTreeView"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L361-L367 | [
"def",
"_draw_placeholder",
"(",
"self",
")",
":",
"if",
"self",
".",
"model",
"(",
")",
".",
"rowCount",
"(",
")",
"==",
"0",
":",
"painter",
"=",
"QPainter",
"(",
"self",
".",
"viewport",
"(",
")",
")",
"painter",
".",
"setFont",
"(",
"_custom_font... | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | abstractList.get_current_item | Returns (first) selected item or None | pyDLib/GUI/list_views.py | def get_current_item(self):
"""Returns (first) selected item or None"""
l = self.selectedIndexes()
if len(l) > 0:
return self.model().get_item(l[0]) | def get_current_item(self):
"""Returns (first) selected item or None"""
l = self.selectedIndexes()
if len(l) > 0:
return self.model().get_item(l[0]) | [
"Returns",
"(",
"first",
")",
"selected",
"item",
"or",
"None"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L391-L395 | [
"def",
"get_current_item",
"(",
"self",
")",
":",
"l",
"=",
"self",
".",
"selectedIndexes",
"(",
")",
"if",
"len",
"(",
"l",
")",
">",
"0",
":",
"return",
"self",
".",
"model",
"(",
")",
".",
"get_item",
"(",
"l",
"[",
"0",
"]",
")"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
train | MultiSelectList.model_from_list | Return a model with a collection from a list of entry | pyDLib/GUI/list_views.py | def model_from_list(l, header):
"""Return a model with a collection from a list of entry"""
col = groups.sortableListe(PseudoAccesCategorie(n) for n in l)
return MultiSelectModel(col, header) | def model_from_list(l, header):
"""Return a model with a collection from a list of entry"""
col = groups.sortableListe(PseudoAccesCategorie(n) for n in l)
return MultiSelectModel(col, header) | [
"Return",
"a",
"model",
"with",
"a",
"collection",
"from",
"a",
"list",
"of",
"entry"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L409-L412 | [
"def",
"model_from_list",
"(",
"l",
",",
"header",
")",
":",
"col",
"=",
"groups",
".",
"sortableListe",
"(",
"PseudoAccesCategorie",
"(",
"n",
")",
"for",
"n",
"in",
"l",
")",
"return",
"MultiSelectModel",
"(",
"col",
",",
"header",
")"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.