repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
acutesoftware/AIKIF | aikif/toolbox/interface_windows_tools.py | app_activate | def app_activate(caption):
"""
use shell to bring the application with caption to front
"""
try:
shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate(caption)
except Exception as ex:
print('error calling win32com.client.Dispatch (AppActivate)') | python | def app_activate(caption):
"""
use shell to bring the application with caption to front
"""
try:
shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate(caption)
except Exception as ex:
print('error calling win32com.client.Dispatch (AppActivate)') | [
"def",
"app_activate",
"(",
"caption",
")",
":",
"try",
":",
"shell",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"WScript.Shell\"",
")",
"shell",
".",
"AppActivate",
"(",
"caption",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
... | use shell to bring the application with caption to front | [
"use",
"shell",
"to",
"bring",
"the",
"application",
"with",
"caption",
"to",
"front"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/interface_windows_tools.py#L74-L82 | train | activate the application with the given caption |
acutesoftware/AIKIF | aikif/toolbox/interface_windows_tools.py | send_keys | def send_keys(key_string):
"""
sends the text or keys to the active application using shell
Note, that the imp module shows deprecation warning.
Examples:
shell.SendKeys("^a") # CTRL+A
shell.SendKeys("{DELETE}") # Delete key
shell.SendKeys("hello this is a lot of text with a //"... | python | def send_keys(key_string):
"""
sends the text or keys to the active application using shell
Note, that the imp module shows deprecation warning.
Examples:
shell.SendKeys("^a") # CTRL+A
shell.SendKeys("{DELETE}") # Delete key
shell.SendKeys("hello this is a lot of text with a //"... | [
"def",
"send_keys",
"(",
"key_string",
")",
":",
"try",
":",
"shell",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"WScript.Shell\"",
")",
"shell",
".",
"SendKeys",
"(",
"key_string",
")",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
... | sends the text or keys to the active application using shell
Note, that the imp module shows deprecation warning.
Examples:
shell.SendKeys("^a") # CTRL+A
shell.SendKeys("{DELETE}") # Delete key
shell.SendKeys("hello this is a lot of text with a //") | [
"sends",
"the",
"text",
"or",
"keys",
"to",
"the",
"active",
"application",
"using",
"shell",
"Note",
"that",
"the",
"imp",
"module",
"shows",
"deprecation",
"warning",
".",
"Examples",
":",
"shell",
".",
"SendKeys",
"(",
"^a",
")",
"#",
"CTRL",
"+",
"A"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/interface_windows_tools.py#L90-L103 | train | Sends the text or keys to the active application using the key_string. |
OpenHydrology/floodestimation | floodestimation/collections.py | CatchmentCollections.nearest_qmed_catchments | def nearest_qmed_catchments(self, subject_catchment, limit=None, dist_limit=500):
"""
Return a list of catchments sorted by distance to `subject_catchment` **and filtered to only include catchments
suitable for QMED analyses**.
:param subject_catchment: catchment object to measure dista... | python | def nearest_qmed_catchments(self, subject_catchment, limit=None, dist_limit=500):
"""
Return a list of catchments sorted by distance to `subject_catchment` **and filtered to only include catchments
suitable for QMED analyses**.
:param subject_catchment: catchment object to measure dista... | [
"def",
"nearest_qmed_catchments",
"(",
"self",
",",
"subject_catchment",
",",
"limit",
"=",
"None",
",",
"dist_limit",
"=",
"500",
")",
":",
"dist_sq",
"=",
"Catchment",
".",
"distance_to",
"(",
"subject_catchment",
")",
".",
"label",
"(",
"'dist_sq'",
")",
... | Return a list of catchments sorted by distance to `subject_catchment` **and filtered to only include catchments
suitable for QMED analyses**.
:param subject_catchment: catchment object to measure distances to
:type subject_catchment: :class:`floodestimation.entities.Catchment`
:param li... | [
"Return",
"a",
"list",
"of",
"catchments",
"sorted",
"by",
"distance",
"to",
"subject_catchment",
"**",
"and",
"filtered",
"to",
"only",
"include",
"catchments",
"suitable",
"for",
"QMED",
"analyses",
"**",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/collections.py#L73-L116 | train | Return a list of catchments nearest to a subject catchment. |
OpenHydrology/floodestimation | floodestimation/collections.py | CatchmentCollections.most_similar_catchments | def most_similar_catchments(self, subject_catchment, similarity_dist_function, records_limit=500,
include_subject_catchment='auto'):
"""
Return a list of catchments sorted by hydrological similarity defined by `similarity_distance_function`
:param subject_catchme... | python | def most_similar_catchments(self, subject_catchment, similarity_dist_function, records_limit=500,
include_subject_catchment='auto'):
"""
Return a list of catchments sorted by hydrological similarity defined by `similarity_distance_function`
:param subject_catchme... | [
"def",
"most_similar_catchments",
"(",
"self",
",",
"subject_catchment",
",",
"similarity_dist_function",
",",
"records_limit",
"=",
"500",
",",
"include_subject_catchment",
"=",
"'auto'",
")",
":",
"if",
"include_subject_catchment",
"not",
"in",
"[",
"'auto'",
",",
... | Return a list of catchments sorted by hydrological similarity defined by `similarity_distance_function`
:param subject_catchment: subject catchment to find similar catchments for
:type subject_catchment: :class:`floodestimation.entities.Catchment`
:param similarity_dist_function: a method retur... | [
"Return",
"a",
"list",
"of",
"catchments",
"sorted",
"by",
"hydrological",
"similarity",
"defined",
"by",
"similarity_distance_function"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/collections.py#L118-L173 | train | Return a list of catchments sorted by similarity distance between the given subject catchment and the most similar ones. |
mpg-age-bioinformatics/AGEpy | AGEpy/sam.py | readSAM | def readSAM(SAMfile,header=False):
"""
Reads and parses a sam file.
:param SAMfile: /path/to/file.sam
:param header: logical, if True, reads the header information
:returns: a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ'... | python | def readSAM(SAMfile,header=False):
"""
Reads and parses a sam file.
:param SAMfile: /path/to/file.sam
:param header: logical, if True, reads the header information
:returns: a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ'... | [
"def",
"readSAM",
"(",
"SAMfile",
",",
"header",
"=",
"False",
")",
":",
"if",
"header",
"==",
"True",
":",
"f",
"=",
"open",
"(",
"SAMfile",
",",
"\"r+\"",
")",
"head",
"=",
"[",
"]",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
":",
... | Reads and parses a sam file.
:param SAMfile: /path/to/file.sam
:param header: logical, if True, reads the header information
:returns: a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ','QUAL' and a list of the headers if header=Tru... | [
"Reads",
"and",
"parses",
"a",
"sam",
"file",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/sam.py#L4-L42 | train | Reads and parses a SAM file and returns a pandas dataframe with the respective SAM columns and the header information. |
mpg-age-bioinformatics/AGEpy | AGEpy/sam.py | writeSAM | def writeSAM(sam,SAMfile,header=None):
"""
Writes a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ','QUAL' into a sam file
:param sam: pandas dataframe to be writen
:param SAMfile: /path/to/file.sam
:returns: nothing
""... | python | def writeSAM(sam,SAMfile,header=None):
"""
Writes a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ','QUAL' into a sam file
:param sam: pandas dataframe to be writen
:param SAMfile: /path/to/file.sam
:returns: nothing
""... | [
"def",
"writeSAM",
"(",
"sam",
",",
"SAMfile",
",",
"header",
"=",
"None",
")",
":",
"def",
"toNone",
"(",
"x",
")",
":",
"if",
"x",
"==",
"\"None\"",
":",
"x",
"=",
"np",
".",
"nan",
"return",
"x",
"sam",
".",
"reset_index",
"(",
"inplace",
"=",... | Writes a pandas dataframe with the respective SAM columns: 'QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ','QUAL' into a sam file
:param sam: pandas dataframe to be writen
:param SAMfile: /path/to/file.sam
:returns: nothing | [
"Writes",
"a",
"pandas",
"dataframe",
"with",
"the",
"respective",
"SAM",
"columns",
":",
"QNAME",
"FLAG",
"RNAME",
"POS",
"MAPQ",
"CIGAR",
"RNEXT",
"PNEXT",
"TLEN",
"SEQ",
"QUAL",
"into",
"a",
"sam",
"file"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/sam.py#L44-L81 | train | Writes a pandas dataframe with the respective SAM columns and the respective SAM columns into a sam file. |
mpg-age-bioinformatics/AGEpy | AGEpy/sam.py | SAMflags | def SAMflags(x):
"""
Explains a SAM flag.
:param x: flag
:returns: complete SAM flag explanaition
"""
flags=[]
if x & 1:
l="1: Read paired"
else:
l="0: Read unpaired"
flags.append(l)
if x & 2 :
l="1: Read mapped in proper pair"
else:
l="0: ... | python | def SAMflags(x):
"""
Explains a SAM flag.
:param x: flag
:returns: complete SAM flag explanaition
"""
flags=[]
if x & 1:
l="1: Read paired"
else:
l="0: Read unpaired"
flags.append(l)
if x & 2 :
l="1: Read mapped in proper pair"
else:
l="0: ... | [
"def",
"SAMflags",
"(",
"x",
")",
":",
"flags",
"=",
"[",
"]",
"if",
"x",
"&",
"1",
":",
"l",
"=",
"\"1: Read paired\"",
"else",
":",
"l",
"=",
"\"0: Read unpaired\"",
"flags",
".",
"append",
"(",
"l",
")",
"if",
"x",
"&",
"2",
":",
"l",
"=",
"... | Explains a SAM flag.
:param x: flag
:returns: complete SAM flag explanaition | [
"Explains",
"a",
"SAM",
"flag",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/sam.py#L83-L165 | train | Returns a list of flags that define a complete SAM flag. |
acutesoftware/AIKIF | aikif/bias.py | Bias.get_bias_details | def get_bias_details(self):
"""
returns a string representation of the bias details
"""
res = 'Bias File Details\n'
for b in self.bias_details:
if len(b) > 2:
res += b[0].ljust(35)
res += b[1].ljust(35)
res += b[2].ljust... | python | def get_bias_details(self):
"""
returns a string representation of the bias details
"""
res = 'Bias File Details\n'
for b in self.bias_details:
if len(b) > 2:
res += b[0].ljust(35)
res += b[1].ljust(35)
res += b[2].ljust... | [
"def",
"get_bias_details",
"(",
"self",
")",
":",
"res",
"=",
"'Bias File Details\\n'",
"for",
"b",
"in",
"self",
".",
"bias_details",
":",
"if",
"len",
"(",
"b",
")",
">",
"2",
":",
"res",
"+=",
"b",
"[",
"0",
"]",
".",
"ljust",
"(",
"35",
")",
... | returns a string representation of the bias details | [
"returns",
"a",
"string",
"representation",
"of",
"the",
"bias",
"details"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/bias.py#L85-L96 | train | returns a string representation of the bias details |
acutesoftware/AIKIF | aikif/bias.py | Bias._calculate_bias | def _calculate_bias(self):
"""
returns a weighting from 0 to 1 based on the sources.
Due to fractions multiplying resulting in very small
numbers, adding 0.5 to bias calculations which means
actual range is 0.5 -> 1.5 (still testing)
Note - range should be from ... | python | def _calculate_bias(self):
"""
returns a weighting from 0 to 1 based on the sources.
Due to fractions multiplying resulting in very small
numbers, adding 0.5 to bias calculations which means
actual range is 0.5 -> 1.5 (still testing)
Note - range should be from ... | [
"def",
"_calculate_bias",
"(",
"self",
")",
":",
"for",
"m",
"in",
"self",
".",
"metadata",
":",
"for",
"b",
"in",
"self",
".",
"bias_details",
":",
"if",
"b",
"[",
"0",
"]",
"==",
"'bias-'",
"+",
"m",
"[",
"'label'",
"]",
"+",
"'.csv'",
":",
"l_... | returns a weighting from 0 to 1 based on the sources.
Due to fractions multiplying resulting in very small
numbers, adding 0.5 to bias calculations which means
actual range is 0.5 -> 1.5 (still testing)
Note - range should be from 0 - > 1 | [
"returns",
"a",
"weighting",
"from",
"0",
"to",
"1",
"based",
"on",
"the",
"sources",
".",
"Due",
"to",
"fractions",
"multiplying",
"resulting",
"in",
"very",
"small",
"numbers",
"adding",
"0",
".",
"5",
"to",
"bias",
"calculations",
"which",
"means",
"act... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/bias.py#L98-L116 | train | Calculates the bias value for the source and updates self. bias_rating based on the bias details. |
acutesoftware/AIKIF | aikif/bias.py | Bias._read_bias_rating | def _read_bias_rating(self, short_filename):
"""
read the bias file based on the short_filename
and return as a dictionary
"""
res = {}
full_name = os.path.join(root_fldr, 'aikif', 'data', 'ref', short_filename)
lg.record_process('bias.py','reading ' + full_name)
... | python | def _read_bias_rating(self, short_filename):
"""
read the bias file based on the short_filename
and return as a dictionary
"""
res = {}
full_name = os.path.join(root_fldr, 'aikif', 'data', 'ref', short_filename)
lg.record_process('bias.py','reading ' + full_name)
... | [
"def",
"_read_bias_rating",
"(",
"self",
",",
"short_filename",
")",
":",
"res",
"=",
"{",
"}",
"full_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_fldr",
",",
"'aikif'",
",",
"'data'",
",",
"'ref'",
",",
"short_filename",
")",
"lg",
".",
"rec... | read the bias file based on the short_filename
and return as a dictionary | [
"read",
"the",
"bias",
"file",
"based",
"on",
"the",
"short_filename",
"and",
"return",
"as",
"a",
"dictionary"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/bias.py#L119-L137 | train | read the bias file based on the short_filename and return as a dictionary |
acutesoftware/AIKIF | aikif/config.py | get_root_folder | def get_root_folder():
"""
returns the home folder and program root depending on OS
"""
locations = {
'linux':{'hme':'/home/duncan/', 'core_folder':'/home/duncan/dev/src/python/AIKIF'},
'win32':{'hme':'T:\\user\\', 'core_folder':'T:\\user\\dev\\src\\python\\AIKIF'},
'cygwin':{'hme':os.... | python | def get_root_folder():
"""
returns the home folder and program root depending on OS
"""
locations = {
'linux':{'hme':'/home/duncan/', 'core_folder':'/home/duncan/dev/src/python/AIKIF'},
'win32':{'hme':'T:\\user\\', 'core_folder':'T:\\user\\dev\\src\\python\\AIKIF'},
'cygwin':{'hme':os.... | [
"def",
"get_root_folder",
"(",
")",
":",
"locations",
"=",
"{",
"'linux'",
":",
"{",
"'hme'",
":",
"'/home/duncan/'",
",",
"'core_folder'",
":",
"'/home/duncan/dev/src/python/AIKIF'",
"}",
",",
"'win32'",
":",
"{",
"'hme'",
":",
"'T:\\\\user\\\\'",
",",
"'core_f... | returns the home folder and program root depending on OS | [
"returns",
"the",
"home",
"folder",
"and",
"program",
"root",
"depending",
"on",
"OS"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/config.py#L28-L45 | train | returns the home folder and program root depending on OS |
acutesoftware/AIKIF | aikif/config.py | read_credentials | def read_credentials(fname):
"""
read a simple text file from a private location to get
username and password
"""
with open(fname, 'r') as f:
username = f.readline().strip('\n')
password = f.readline().strip('\n')
return username, password | python | def read_credentials(fname):
"""
read a simple text file from a private location to get
username and password
"""
with open(fname, 'r') as f:
username = f.readline().strip('\n')
password = f.readline().strip('\n')
return username, password | [
"def",
"read_credentials",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"username",
"=",
"f",
".",
"readline",
"(",
")",
".",
"strip",
"(",
"'\\n'",
")",
"password",
"=",
"f",
".",
"readline",
"(",
")",
"... | read a simple text file from a private location to get
username and password | [
"read",
"a",
"simple",
"text",
"file",
"from",
"a",
"private",
"location",
"to",
"get",
"username",
"and",
"password"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/config.py#L84-L92 | train | read a simple text file from a private location to get
username and password |
acutesoftware/AIKIF | aikif/toolbox/data_structures.py | Graph.get_adjacency_matrix | def get_adjacency_matrix(self, show_in_console=False):
""" return the matrix as a list of lists
raw graph = {'1': ['2', '3', '4'], '2': ['6', '7']}
6 nodes: ['1', '2', '3', '4', '6', '7']
5 links: [['1', '2'], ['1', '3'], ['1', '4'], ['2', '6'], ['2', '7']]
[0, 1, 1, 1, 0, 0]
... | python | def get_adjacency_matrix(self, show_in_console=False):
""" return the matrix as a list of lists
raw graph = {'1': ['2', '3', '4'], '2': ['6', '7']}
6 nodes: ['1', '2', '3', '4', '6', '7']
5 links: [['1', '2'], ['1', '3'], ['1', '4'], ['2', '6'], ['2', '7']]
[0, 1, 1, 1, 0, 0]
... | [
"def",
"get_adjacency_matrix",
"(",
"self",
",",
"show_in_console",
"=",
"False",
")",
":",
"self",
".",
"links",
"=",
"[",
"[",
"i",
",",
"j",
"]",
"for",
"i",
"in",
"self",
".",
"graph",
"for",
"j",
"in",
"self",
".",
"graph",
"[",
"i",
"]",
"]... | return the matrix as a list of lists
raw graph = {'1': ['2', '3', '4'], '2': ['6', '7']}
6 nodes: ['1', '2', '3', '4', '6', '7']
5 links: [['1', '2'], ['1', '3'], ['1', '4'], ['2', '6'], ['2', '7']]
[0, 1, 1, 1, 0, 0]
[1, 0, 0, 0, 1, 1]
[1, 0, 0, 0, 0, 0]
[1, 0,... | [
"return",
"the",
"matrix",
"as",
"a",
"list",
"of",
"lists",
"raw",
"graph",
"=",
"{",
"1",
":",
"[",
"2",
"3",
"4",
"]",
"2",
":",
"[",
"6",
"7",
"]",
"}",
"6",
"nodes",
":",
"[",
"1",
"2",
"3",
"4",
"6",
"7",
"]",
"5",
"links",
":",
"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/data_structures.py#L71-L116 | train | return the adjacency matrix as a list of lists
|
mpg-age-bioinformatics/AGEpy | AGEpy/meme.py | filterMotifs | def filterMotifs(memeFile,outFile, minSites):
"""
Selectes motifs from a meme file based on the number of sites.
:param memeFile: MEME file to be read
:param outFile: MEME file to be written
:param minSites: minimum number of sites each motif needs to have to be valid
:returns: nothing
"""... | python | def filterMotifs(memeFile,outFile, minSites):
"""
Selectes motifs from a meme file based on the number of sites.
:param memeFile: MEME file to be read
:param outFile: MEME file to be written
:param minSites: minimum number of sites each motif needs to have to be valid
:returns: nothing
"""... | [
"def",
"filterMotifs",
"(",
"memeFile",
",",
"outFile",
",",
"minSites",
")",
":",
"with",
"open",
"(",
"memeFile",
",",
"\"r\"",
")",
"as",
"mF",
":",
"oldMEME",
"=",
"mF",
".",
"readlines",
"(",
")",
"newMEME",
"=",
"oldMEME",
"[",
":",
"7",
"]",
... | Selectes motifs from a meme file based on the number of sites.
:param memeFile: MEME file to be read
:param outFile: MEME file to be written
:param minSites: minimum number of sites each motif needs to have to be valid
:returns: nothing | [
"Selectes",
"motifs",
"from",
"a",
"meme",
"file",
"based",
"on",
"the",
"number",
"of",
"sites",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/meme.py#L2-L35 | train | This function filters motifs from a meme file based on the number of sites. |
acutesoftware/AIKIF | aikif/toolbox/parse_desc.py | Parse._read_file | def _read_file(self):
"""
reads the file and cleans into standard text ready for parsing
"""
self.raw = []
with open(self.fname, 'r') as f:
for line in f:
#print(line)
if line.startswith('#'):
pass # comment
... | python | def _read_file(self):
"""
reads the file and cleans into standard text ready for parsing
"""
self.raw = []
with open(self.fname, 'r') as f:
for line in f:
#print(line)
if line.startswith('#'):
pass # comment
... | [
"def",
"_read_file",
"(",
"self",
")",
":",
"self",
".",
"raw",
"=",
"[",
"]",
"with",
"open",
"(",
"self",
".",
"fname",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"#print(line)",
"if",
"line",
".",
"startswith",
"(",
"'#'",... | reads the file and cleans into standard text ready for parsing | [
"reads",
"the",
"file",
"and",
"cleans",
"into",
"standard",
"text",
"ready",
"for",
"parsing"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/parse_desc.py#L46-L59 | train | reads the file and cleans up the standard text ready for parsing
|
OpenHydrology/floodestimation | floodestimation/settings.py | Config.reset | def reset(self):
"""
Restore the default configuration and remove the user's config file.
"""
# Delete user config file
try:
os.remove(self._user_config_file)
except FileNotFoundError:
pass
# Empty and refill the config object
for... | python | def reset(self):
"""
Restore the default configuration and remove the user's config file.
"""
# Delete user config file
try:
os.remove(self._user_config_file)
except FileNotFoundError:
pass
# Empty and refill the config object
for... | [
"def",
"reset",
"(",
"self",
")",
":",
"# Delete user config file",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"_user_config_file",
")",
"except",
"FileNotFoundError",
":",
"pass",
"# Empty and refill the config object",
"for",
"section_name",
"in",
"self",
... | Restore the default configuration and remove the user's config file. | [
"Restore",
"the",
"default",
"configuration",
"and",
"remove",
"the",
"user",
"s",
"config",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/settings.py#L49-L63 | train | Resets the default configuration and removes the user s config file. |
OpenHydrology/floodestimation | floodestimation/settings.py | Config.save | def save(self):
"""
Write data to user config file.
"""
with open(self._user_config_file, 'w', encoding='utf-8') as f:
self.write(f) | python | def save(self):
"""
Write data to user config file.
"""
with open(self._user_config_file, 'w', encoding='utf-8') as f:
self.write(f) | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"_user_config_file",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"self",
".",
"write",
"(",
"f",
")"
] | Write data to user config file. | [
"Write",
"data",
"to",
"user",
"config",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/settings.py#L87-L92 | train | Write data to user config file. |
OpenHydrology/floodestimation | floodestimation/settings.py | Config.get_datetime | def get_datetime(self, section, option, fallback):
"""
Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param fallback: Fallback/default value
:return: Datetime in UTC
:rtype: :class:`datetime.datetim... | python | def get_datetime(self, section, option, fallback):
"""
Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param fallback: Fallback/default value
:return: Datetime in UTC
:rtype: :class:`datetime.datetim... | [
"def",
"get_datetime",
"(",
"self",
",",
"section",
",",
"option",
",",
"fallback",
")",
":",
"try",
":",
"s",
"=",
"self",
"[",
"section",
"]",
"[",
"option",
"]",
"try",
":",
"# If stored as timestamp",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",... | Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param fallback: Fallback/default value
:return: Datetime in UTC
:rtype: :class:`datetime.datetime` | [
"Return",
"UTC",
"datetime",
"from",
"timestamp",
"in",
"config",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/settings.py#L94-L113 | train | Get UTC datetime from timestamp in config file. |
OpenHydrology/floodestimation | floodestimation/settings.py | Config.set_datetime | def set_datetime(self, section, option, value):
"""
Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param value: Datetime value to set
:type value: :class:`datetime.datetime`
"""
self[section... | python | def set_datetime(self, section, option, value):
"""
Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param value: Datetime value to set
:type value: :class:`datetime.datetime`
"""
self[section... | [
"def",
"set_datetime",
"(",
"self",
",",
"section",
",",
"option",
",",
"value",
")",
":",
"self",
"[",
"section",
"]",
"[",
"option",
"]",
"=",
"value",
".",
"strftime",
"(",
"self",
".",
"DATETIME_FMT",
")"
] | Return UTC datetime from timestamp in config file.
:param section: Config section
:param option: Config option
:param value: Datetime value to set
:type value: :class:`datetime.datetime` | [
"Return",
"UTC",
"datetime",
"from",
"timestamp",
"in",
"config",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/settings.py#L115-L124 | train | Set the value of the option to the UTC datetime from timestamp in config file. |
acutesoftware/AIKIF | aikif/toolbox/maths_ml_algorithms.py | ml_entropy | def ml_entropy(lst):
"""
General Machine Learning Formulas
Intermezzo - computing Logarithms
log2(x) = y <=> 2^y = x
Definition of Entropy
k
E = - SUM ( p[i] log2(p[i])
i=1
where
k = possible values enumerated 1,2,...,k
p[i] = c[i] / n is... | python | def ml_entropy(lst):
"""
General Machine Learning Formulas
Intermezzo - computing Logarithms
log2(x) = y <=> 2^y = x
Definition of Entropy
k
E = - SUM ( p[i] log2(p[i])
i=1
where
k = possible values enumerated 1,2,...,k
p[i] = c[i] / n is... | [
"def",
"ml_entropy",
"(",
"lst",
")",
":",
"tot",
"=",
"sum",
"(",
"lst",
")",
"res",
"=",
"0",
"for",
"v",
"in",
"lst",
":",
"if",
"v",
">",
"0",
":",
"p",
"=",
"v",
"/",
"tot",
"l",
"=",
"math",
".",
"log",
"(",
"p",
",",
"2",
")",
"r... | General Machine Learning Formulas
Intermezzo - computing Logarithms
log2(x) = y <=> 2^y = x
Definition of Entropy
k
E = - SUM ( p[i] log2(p[i])
i=1
where
k = possible values enumerated 1,2,...,k
p[i] = c[i] / n is the fraction of elements having ... | [
"General",
"Machine",
"Learning",
"Formulas",
"Intermezzo",
"-",
"computing",
"Logarithms",
"log2",
"(",
"x",
")",
"=",
"y",
"<",
"=",
">",
"2^y",
"=",
"x"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/maths_ml_algorithms.py#L13-L42 | train | Calculates the General Machine Learning Formulas of the given list of logarithms and returns the Entropy of the current object. |
cdgriffith/puremagic | puremagic/main.py | _magic_data | def _magic_data(filename=os.path.join(here, 'magic_data.json')):
""" Read the magic file"""
with open(filename) as f:
data = json.load(f)
headers = [_create_puremagic(x) for x in data['headers']]
footers = [_create_puremagic(x) for x in data['footers']]
return headers, footers | python | def _magic_data(filename=os.path.join(here, 'magic_data.json')):
""" Read the magic file"""
with open(filename) as f:
data = json.load(f)
headers = [_create_puremagic(x) for x in data['headers']]
footers = [_create_puremagic(x) for x in data['footers']]
return headers, footers | [
"def",
"_magic_data",
"(",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"here",
",",
"'magic_data.json'",
")",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
")",
"headers",
"=",... | Read the magic file | [
"Read",
"the",
"magic",
"file"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L39-L45 | train | Read the magic data file and return the headers and footers |
cdgriffith/puremagic | puremagic/main.py | _max_lengths | def _max_lengths():
""" The length of the largest magic string + its offset"""
max_header_length = max([len(x.byte_match) + x.offset
for x in magic_header_array])
max_footer_length = max([len(x.byte_match) + abs(x.offset)
for x in magic_footer_array]... | python | def _max_lengths():
""" The length of the largest magic string + its offset"""
max_header_length = max([len(x.byte_match) + x.offset
for x in magic_header_array])
max_footer_length = max([len(x.byte_match) + abs(x.offset)
for x in magic_footer_array]... | [
"def",
"_max_lengths",
"(",
")",
":",
"max_header_length",
"=",
"max",
"(",
"[",
"len",
"(",
"x",
".",
"byte_match",
")",
"+",
"x",
".",
"offset",
"for",
"x",
"in",
"magic_header_array",
"]",
")",
"max_footer_length",
"=",
"max",
"(",
"[",
"len",
"(",
... | The length of the largest magic string + its offset | [
"The",
"length",
"of",
"the",
"largest",
"magic",
"string",
"+",
"its",
"offset"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L59-L65 | train | The length of the largest magic string + its offset |
cdgriffith/puremagic | puremagic/main.py | _confidence | def _confidence(matches, ext=None):
""" Rough confidence based on string length and file extension"""
results = []
for match in matches:
con = (0.8 if len(match.extension) > 9 else
float("0.{0}".format(len(match.extension))))
if ext == match.extension:
con = 0.9
... | python | def _confidence(matches, ext=None):
""" Rough confidence based on string length and file extension"""
results = []
for match in matches:
con = (0.8 if len(match.extension) > 9 else
float("0.{0}".format(len(match.extension))))
if ext == match.extension:
con = 0.9
... | [
"def",
"_confidence",
"(",
"matches",
",",
"ext",
"=",
"None",
")",
":",
"results",
"=",
"[",
"]",
"for",
"match",
"in",
"matches",
":",
"con",
"=",
"(",
"0.8",
"if",
"len",
"(",
"match",
".",
"extension",
")",
">",
"9",
"else",
"float",
"(",
"\"... | Rough confidence based on string length and file extension | [
"Rough",
"confidence",
"based",
"on",
"string",
"length",
"and",
"file",
"extension"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L68-L78 | train | Rough confidence based on string length and file extension |
cdgriffith/puremagic | puremagic/main.py | _identify_all | def _identify_all(header, footer, ext=None):
""" Attempt to identify 'data' by its magic numbers"""
# Capture the length of the data
# That way we do not try to identify bytes that don't exist
matches = list()
for magic_row in magic_header_array:
start = magic_row.offset
end = magic... | python | def _identify_all(header, footer, ext=None):
""" Attempt to identify 'data' by its magic numbers"""
# Capture the length of the data
# That way we do not try to identify bytes that don't exist
matches = list()
for magic_row in magic_header_array:
start = magic_row.offset
end = magic... | [
"def",
"_identify_all",
"(",
"header",
",",
"footer",
",",
"ext",
"=",
"None",
")",
":",
"# Capture the length of the data",
"# That way we do not try to identify bytes that don't exist",
"matches",
"=",
"list",
"(",
")",
"for",
"magic_row",
"in",
"magic_header_array",
... | Attempt to identify 'data' by its magic numbers | [
"Attempt",
"to",
"identify",
"data",
"by",
"its",
"magic",
"numbers"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L81-L102 | train | Identify all data in a file by its magic numbers. |
cdgriffith/puremagic | puremagic/main.py | _magic | def _magic(header, footer, mime, ext=None):
""" Discover what type of file it is based on the incoming string """
if not header:
raise ValueError("Input was empty")
info = _identify_all(header, footer, ext)[0]
if mime:
return info.mime_type
return info.extension if not \
isin... | python | def _magic(header, footer, mime, ext=None):
""" Discover what type of file it is based on the incoming string """
if not header:
raise ValueError("Input was empty")
info = _identify_all(header, footer, ext)[0]
if mime:
return info.mime_type
return info.extension if not \
isin... | [
"def",
"_magic",
"(",
"header",
",",
"footer",
",",
"mime",
",",
"ext",
"=",
"None",
")",
":",
"if",
"not",
"header",
":",
"raise",
"ValueError",
"(",
"\"Input was empty\"",
")",
"info",
"=",
"_identify_all",
"(",
"header",
",",
"footer",
",",
"ext",
"... | Discover what type of file it is based on the incoming string | [
"Discover",
"what",
"type",
"of",
"file",
"it",
"is",
"based",
"on",
"the",
"incoming",
"string"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L105-L113 | train | Discover what type of file it is based on the incoming string |
cdgriffith/puremagic | puremagic/main.py | _file_details | def _file_details(filename):
""" Grab the start and end of the file"""
max_head, max_foot = _max_lengths()
with open(filename, "rb") as fin:
head = fin.read(max_head)
try:
fin.seek(-max_foot, os.SEEK_END)
except IOError:
fin.seek(0)
foot = fin.read()
... | python | def _file_details(filename):
""" Grab the start and end of the file"""
max_head, max_foot = _max_lengths()
with open(filename, "rb") as fin:
head = fin.read(max_head)
try:
fin.seek(-max_foot, os.SEEK_END)
except IOError:
fin.seek(0)
foot = fin.read()
... | [
"def",
"_file_details",
"(",
"filename",
")",
":",
"max_head",
",",
"max_foot",
"=",
"_max_lengths",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"fin",
":",
"head",
"=",
"fin",
".",
"read",
"(",
"max_head",
")",
"try",
":",
"... | Grab the start and end of the file | [
"Grab",
"the",
"start",
"and",
"end",
"of",
"the",
"file"
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L116-L126 | train | Grab the start and end of the file |
cdgriffith/puremagic | puremagic/main.py | ext_from_filename | def ext_from_filename(filename):
""" Scan a filename for it's extension.
:param filename: string of the filename
:return: the extension off the end (empty string if it can't find one)
"""
try:
base, ext = filename.lower().rsplit(".", 1)
except ValueError:
return ''
ext = ".{... | python | def ext_from_filename(filename):
""" Scan a filename for it's extension.
:param filename: string of the filename
:return: the extension off the end (empty string if it can't find one)
"""
try:
base, ext = filename.lower().rsplit(".", 1)
except ValueError:
return ''
ext = ".{... | [
"def",
"ext_from_filename",
"(",
"filename",
")",
":",
"try",
":",
"base",
",",
"ext",
"=",
"filename",
".",
"lower",
"(",
")",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"except",
"ValueError",
":",
"return",
"''",
"ext",
"=",
"\".{0}\"",
".",
"for... | Scan a filename for it's extension.
:param filename: string of the filename
:return: the extension off the end (empty string if it can't find one) | [
"Scan",
"a",
"filename",
"for",
"it",
"s",
"extension",
"."
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L135-L154 | train | Scan a filename for the extension of the current object and return the extension off the end. |
cdgriffith/puremagic | puremagic/main.py | from_file | def from_file(filename, mime=False):
""" Opens file, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
:param filename: path to file
:param mime: Return mime, not extension
:return: guessed extension or ... | python | def from_file(filename, mime=False):
""" Opens file, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
:param filename: path to file
:param mime: Return mime, not extension
:return: guessed extension or ... | [
"def",
"from_file",
"(",
"filename",
",",
"mime",
"=",
"False",
")",
":",
"head",
",",
"foot",
"=",
"_file_details",
"(",
"filename",
")",
"return",
"_magic",
"(",
"head",
",",
"foot",
",",
"mime",
",",
"ext_from_filename",
"(",
"filename",
")",
")"
] | Opens file, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
:param filename: path to file
:param mime: Return mime, not extension
:return: guessed extension or mime | [
"Opens",
"file",
"attempts",
"to",
"identify",
"content",
"based",
"off",
"magic",
"number",
"and",
"will",
"return",
"the",
"file",
"extension",
".",
"If",
"mime",
"is",
"True",
"it",
"will",
"return",
"the",
"mime",
"type",
"instead",
"."
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L157-L168 | train | Returns the mime type or extension of a file. |
cdgriffith/puremagic | puremagic/main.py | from_string | def from_string(string, mime=False, filename=None):
""" Reads in string, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
If filename is provided it will be used in the computation.
:param string: string re... | python | def from_string(string, mime=False, filename=None):
""" Reads in string, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
If filename is provided it will be used in the computation.
:param string: string re... | [
"def",
"from_string",
"(",
"string",
",",
"mime",
"=",
"False",
",",
"filename",
"=",
"None",
")",
":",
"head",
",",
"foot",
"=",
"_string_details",
"(",
"string",
")",
"ext",
"=",
"ext_from_filename",
"(",
"filename",
")",
"if",
"filename",
"else",
"Non... | Reads in string, attempts to identify content based
off magic number and will return the file extension.
If mime is True it will return the mime type instead.
If filename is provided it will be used in the computation.
:param string: string representation to check
:param mime: Return mime, not exte... | [
"Reads",
"in",
"string",
"attempts",
"to",
"identify",
"content",
"based",
"off",
"magic",
"number",
"and",
"will",
"return",
"the",
"file",
"extension",
".",
"If",
"mime",
"is",
"True",
"it",
"will",
"return",
"the",
"mime",
"type",
"instead",
".",
"If",
... | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L171-L184 | train | Reads in a string and returns the mime type or mime type. |
cdgriffith/puremagic | puremagic/main.py | magic_file | def magic_file(filename):
""" Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first.
:param filename: path to file
:return: list of possible matches, highest confidence first
"""
head, foot = _file_details(filename)
if not head:
raise ValueError... | python | def magic_file(filename):
""" Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first.
:param filename: path to file
:return: list of possible matches, highest confidence first
"""
head, foot = _file_details(filename)
if not head:
raise ValueError... | [
"def",
"magic_file",
"(",
"filename",
")",
":",
"head",
",",
"foot",
"=",
"_file_details",
"(",
"filename",
")",
"if",
"not",
"head",
":",
"raise",
"ValueError",
"(",
"\"Input was empty\"",
")",
"try",
":",
"info",
"=",
"_identify_all",
"(",
"head",
",",
... | Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first.
:param filename: path to file
:return: list of possible matches, highest confidence first | [
"Returns",
"tuple",
"of",
"(",
"num_of_matches",
"array_of_matches",
")",
"arranged",
"highest",
"confidence",
"match",
"first",
"."
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L187-L202 | train | Returns tuple of num_of_matches array_of_matches highest confidence match first. |
cdgriffith/puremagic | puremagic/main.py | magic_string | def magic_string(string, filename=None):
""" Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first
If filename is provided it will be used in the computation.
:param string: string representation to check
:param filename: original filename
:return: list of ... | python | def magic_string(string, filename=None):
""" Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first
If filename is provided it will be used in the computation.
:param string: string representation to check
:param filename: original filename
:return: list of ... | [
"def",
"magic_string",
"(",
"string",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"string",
":",
"raise",
"ValueError",
"(",
"\"Input was empty\"",
")",
"head",
",",
"foot",
"=",
"_string_details",
"(",
"string",
")",
"ext",
"=",
"ext_from_filename"... | Returns tuple of (num_of_matches, array_of_matches)
arranged highest confidence match first
If filename is provided it will be used in the computation.
:param string: string representation to check
:param filename: original filename
:return: list of possible matches, highest confidence first | [
"Returns",
"tuple",
"of",
"(",
"num_of_matches",
"array_of_matches",
")",
"arranged",
"highest",
"confidence",
"match",
"first",
"If",
"filename",
"is",
"provided",
"it",
"will",
"be",
"used",
"in",
"the",
"computation",
"."
] | ae2c4c400930b8a19519e787f61dd779db7e415b | https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L205-L220 | train | Returns tuple of num_of_matches array_of_matches highest confidence match first
|
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | readGTF | def readGTF(infile):
"""
Reads a GTF file and labels the respective columns in agreement with GTF file standards:
'seqname','source','feature','start','end','score','strand','frame','attribute'.
:param infile: path/to/file.gtf
:returns: a Pandas dataframe of the respective GTF
"""
df=pd.re... | python | def readGTF(infile):
"""
Reads a GTF file and labels the respective columns in agreement with GTF file standards:
'seqname','source','feature','start','end','score','strand','frame','attribute'.
:param infile: path/to/file.gtf
:returns: a Pandas dataframe of the respective GTF
"""
df=pd.re... | [
"def",
"readGTF",
"(",
"infile",
")",
":",
"df",
"=",
"pd",
".",
"read_table",
"(",
"infile",
",",
"sep",
"=",
"'\\t'",
",",
"comment",
"=",
"\"#\"",
",",
"header",
"=",
"None",
",",
"dtype",
"=",
"str",
")",
"df",
".",
"columns",
"=",
"[",
"'seq... | Reads a GTF file and labels the respective columns in agreement with GTF file standards:
'seqname','source','feature','start','end','score','strand','frame','attribute'.
:param infile: path/to/file.gtf
:returns: a Pandas dataframe of the respective GTF | [
"Reads",
"a",
"GTF",
"file",
"and",
"labels",
"the",
"respective",
"columns",
"in",
"agreement",
"with",
"GTF",
"file",
"standards",
":",
"seqname",
"source",
"feature",
"start",
"end",
"score",
"strand",
"frame",
"attribute",
"."
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L4-L16 | train | Reads a GTF file and labels the respective columns in agreement with GTF file standards |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | retrieve_GTF_field | def retrieve_GTF_field(field,gtf):
"""
Returns a field of choice from the attribute column of the GTF
:param field: field to be retrieved
:returns: a Pandas dataframe with one columns containing the field of choice
"""
inGTF=gtf.copy()
def splits(x):
l=x.split(";")
l=[ s.sp... | python | def retrieve_GTF_field(field,gtf):
"""
Returns a field of choice from the attribute column of the GTF
:param field: field to be retrieved
:returns: a Pandas dataframe with one columns containing the field of choice
"""
inGTF=gtf.copy()
def splits(x):
l=x.split(";")
l=[ s.sp... | [
"def",
"retrieve_GTF_field",
"(",
"field",
",",
"gtf",
")",
":",
"inGTF",
"=",
"gtf",
".",
"copy",
"(",
")",
"def",
"splits",
"(",
"x",
")",
":",
"l",
"=",
"x",
".",
"split",
"(",
"\";\"",
")",
"l",
"=",
"[",
"s",
".",
"split",
"(",
"\" \"",
... | Returns a field of choice from the attribute column of the GTF
:param field: field to be retrieved
:returns: a Pandas dataframe with one columns containing the field of choice | [
"Returns",
"a",
"field",
"of",
"choice",
"from",
"the",
"attribute",
"column",
"of",
"the",
"GTF"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L18-L40 | train | Returns a Pandas dataframe containing the field of choice from the attribute column of the GTF |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | attributesGTF | def attributesGTF(inGTF):
"""
List the type of attributes in a the attribute section of a GTF file
:param inGTF: GTF dataframe to be analysed
:returns: a list of attributes present in the attribute section
"""
df=pd.DataFrame(inGTF['attribute'].str.split(";").tolist())
desc=[]
for i in... | python | def attributesGTF(inGTF):
"""
List the type of attributes in a the attribute section of a GTF file
:param inGTF: GTF dataframe to be analysed
:returns: a list of attributes present in the attribute section
"""
df=pd.DataFrame(inGTF['attribute'].str.split(";").tolist())
desc=[]
for i in... | [
"def",
"attributesGTF",
"(",
"inGTF",
")",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"inGTF",
"[",
"'attribute'",
"]",
".",
"str",
".",
"split",
"(",
"\";\"",
")",
".",
"tolist",
"(",
")",
")",
"desc",
"=",
"[",
"]",
"for",
"i",
"in",
"df",
... | List the type of attributes in a the attribute section of a GTF file
:param inGTF: GTF dataframe to be analysed
:returns: a list of attributes present in the attribute section | [
"List",
"the",
"type",
"of",
"attributes",
"in",
"a",
"the",
"attribute",
"section",
"of",
"a",
"GTF",
"file"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L42-L69 | train | Returns a list of attributes present in a GTF file |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | parseGTF | def parseGTF(inGTF):
"""
Reads an extracts all attributes in the attributes section of a GTF and constructs a new dataframe wiht one collumn per attribute instead of the attributes column
:param inGTF: GTF dataframe to be parsed
:returns: a dataframe of the orignal input GTF with attributes parsed.
... | python | def parseGTF(inGTF):
"""
Reads an extracts all attributes in the attributes section of a GTF and constructs a new dataframe wiht one collumn per attribute instead of the attributes column
:param inGTF: GTF dataframe to be parsed
:returns: a dataframe of the orignal input GTF with attributes parsed.
... | [
"def",
"parseGTF",
"(",
"inGTF",
")",
":",
"desc",
"=",
"attributesGTF",
"(",
"inGTF",
")",
"ref",
"=",
"inGTF",
".",
"copy",
"(",
")",
"ref",
".",
"reset_index",
"(",
"inplace",
"=",
"True",
",",
"drop",
"=",
"True",
")",
"df",
"=",
"ref",
".",
... | Reads an extracts all attributes in the attributes section of a GTF and constructs a new dataframe wiht one collumn per attribute instead of the attributes column
:param inGTF: GTF dataframe to be parsed
:returns: a dataframe of the orignal input GTF with attributes parsed. | [
"Reads",
"an",
"extracts",
"all",
"attributes",
"in",
"the",
"attributes",
"section",
"of",
"a",
"GTF",
"and",
"constructs",
"a",
"new",
"dataframe",
"wiht",
"one",
"collumn",
"per",
"attribute",
"instead",
"of",
"the",
"attributes",
"column"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L71-L87 | train | Reads an input GTF and returns a dataframe with all attributes parsed |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | writeGTF | def writeGTF(inGTF,file_path):
"""
Write a GTF dataframe into a file
:param inGTF: GTF dataframe to be written. It should either have 9 columns with the last one being the "attributes" section or more than 9 columns where all columns after the 8th will be colapsed into one.
:param file_path: path/to/th... | python | def writeGTF(inGTF,file_path):
"""
Write a GTF dataframe into a file
:param inGTF: GTF dataframe to be written. It should either have 9 columns with the last one being the "attributes" section or more than 9 columns where all columns after the 8th will be colapsed into one.
:param file_path: path/to/th... | [
"def",
"writeGTF",
"(",
"inGTF",
",",
"file_path",
")",
":",
"cols",
"=",
"inGTF",
".",
"columns",
".",
"tolist",
"(",
")",
"if",
"len",
"(",
"cols",
")",
"==",
"9",
":",
"if",
"'attribute'",
"in",
"cols",
":",
"df",
"=",
"inGTF",
"else",
":",
"d... | Write a GTF dataframe into a file
:param inGTF: GTF dataframe to be written. It should either have 9 columns with the last one being the "attributes" section or more than 9 columns where all columns after the 8th will be colapsed into one.
:param file_path: path/to/the/file.gtf
:returns: nothing | [
"Write",
"a",
"GTF",
"dataframe",
"into",
"a",
"file"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L89-L109 | train | Writes a GTF dataframe into a file. |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | GTFtoBED | def GTFtoBED(inGTF,name):
"""
Transform a GTF dataframe into a bed dataframe
:param inGTF: GTF dataframe for transformation
:param name: field of the GTF data frame to be use for the bed 'name' positon
returns: a bed dataframe with the corresponding bed fiels: 'chrom','chromStart','chromEnd','name... | python | def GTFtoBED(inGTF,name):
"""
Transform a GTF dataframe into a bed dataframe
:param inGTF: GTF dataframe for transformation
:param name: field of the GTF data frame to be use for the bed 'name' positon
returns: a bed dataframe with the corresponding bed fiels: 'chrom','chromStart','chromEnd','name... | [
"def",
"GTFtoBED",
"(",
"inGTF",
",",
"name",
")",
":",
"bed",
"=",
"inGTF",
".",
"copy",
"(",
")",
"bed",
".",
"reset_index",
"(",
"inplace",
"=",
"True",
",",
"drop",
"=",
"True",
")",
"if",
"name",
"not",
"in",
"bed",
".",
"columns",
".",
"tol... | Transform a GTF dataframe into a bed dataframe
:param inGTF: GTF dataframe for transformation
:param name: field of the GTF data frame to be use for the bed 'name' positon
returns: a bed dataframe with the corresponding bed fiels: 'chrom','chromStart','chromEnd','name','score','strand' | [
"Transform",
"a",
"GTF",
"dataframe",
"into",
"a",
"bed",
"dataframe"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L111-L130 | train | Transform a GTF dataframe into a bed dataframe |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | MAPGenoToTrans | def MAPGenoToTrans(parsedGTF,feature):
"""
Gets all positions of all bases in an exon
:param df: a Pandas dataframe with 'start','end', and 'strand' information for each entry.
df must contain 'seqname','feature','start','end','strand','frame','gene_id',
'transcript_id','exo... | python | def MAPGenoToTrans(parsedGTF,feature):
"""
Gets all positions of all bases in an exon
:param df: a Pandas dataframe with 'start','end', and 'strand' information for each entry.
df must contain 'seqname','feature','start','end','strand','frame','gene_id',
'transcript_id','exo... | [
"def",
"MAPGenoToTrans",
"(",
"parsedGTF",
",",
"feature",
")",
":",
"GenTransMap",
"=",
"parsedGTF",
"[",
"parsedGTF",
"[",
"\"feature\"",
"]",
"==",
"feature",
"]",
"def",
"getExonsPositions",
"(",
"df",
")",
":",
"start",
"=",
"int",
"(",
"df",
"[",
"... | Gets all positions of all bases in an exon
:param df: a Pandas dataframe with 'start','end', and 'strand' information for each entry.
df must contain 'seqname','feature','start','end','strand','frame','gene_id',
'transcript_id','exon_id','exon_number']
:param feature: feature up... | [
"Gets",
"all",
"positions",
"of",
"all",
"bases",
"in",
"an",
"exon"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L132-L161 | train | Returns a string that contains all positions of all bases in a single exon in a single gene. |
mpg-age-bioinformatics/AGEpy | AGEpy/gtf.py | GetTransPosition | def GetTransPosition(df,field,dic,refCol="transcript_id"):
"""
Maps a genome position to transcript positon"
:param df: a Pandas dataframe
:param field: the head of the column containing the genomic position
:param dic: a dictionary containing for each transcript the respective bases eg. {ENST23923... | python | def GetTransPosition(df,field,dic,refCol="transcript_id"):
"""
Maps a genome position to transcript positon"
:param df: a Pandas dataframe
:param field: the head of the column containing the genomic position
:param dic: a dictionary containing for each transcript the respective bases eg. {ENST23923... | [
"def",
"GetTransPosition",
"(",
"df",
",",
"field",
",",
"dic",
",",
"refCol",
"=",
"\"transcript_id\"",
")",
":",
"try",
":",
"gen",
"=",
"str",
"(",
"int",
"(",
"df",
"[",
"field",
"]",
")",
")",
"transid",
"=",
"df",
"[",
"refCol",
"]",
"bases",... | Maps a genome position to transcript positon"
:param df: a Pandas dataframe
:param field: the head of the column containing the genomic position
:param dic: a dictionary containing for each transcript the respective bases eg. {ENST23923910:'234,235,236,1021,..'}
:param refCol: header of the reference c... | [
"Maps",
"a",
"genome",
"position",
"to",
"transcript",
"positon"
] | 887808a7a2c1504f39ce8d8cb36c15c1721cd29f | https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/gtf.py#L163-L181 | train | Maps a genome position to transcript positon |
acutesoftware/AIKIF | aikif/toolbox/network_tools.py | download_file_no_logon | def download_file_no_logon(url, filename):
"""
download a file from a public website with no logon required
output = open(filename,'wb')
output.write(request.urlopen(url).read())
output.close()
"""
import urllib.request
#url = "http://www.google.com/"
request = urllib.reques... | python | def download_file_no_logon(url, filename):
"""
download a file from a public website with no logon required
output = open(filename,'wb')
output.write(request.urlopen(url).read())
output.close()
"""
import urllib.request
#url = "http://www.google.com/"
request = urllib.reques... | [
"def",
"download_file_no_logon",
"(",
"url",
",",
"filename",
")",
":",
"import",
"urllib",
".",
"request",
"#url = \"http://www.google.com/\"",
"request",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"url",
")",
"try",
":",
"response",
"=",
"urllib",
"... | download a file from a public website with no logon required
output = open(filename,'wb')
output.write(request.urlopen(url).read())
output.close() | [
"download",
"a",
"file",
"from",
"a",
"public",
"website",
"with",
"no",
"logon",
"required",
"output",
"=",
"open",
"(",
"filename",
"wb",
")",
"output",
".",
"write",
"(",
"request",
".",
"urlopen",
"(",
"url",
")",
".",
"read",
"()",
")",
"output",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/network_tools.py#L48-L65 | train | download a file from a public website with no logon required |
acutesoftware/AIKIF | aikif/toolbox/network_tools.py | get_protected_page | def get_protected_page(url, user, pwd, filename):
"""
having problems with urllib on a specific site so trying requests
"""
import requests
r = requests.get(url, auth=(user, pwd))
print(r.status_code)
if r.status_code == 200:
print('success')
with open(filename, 'wb') as fd:
... | python | def get_protected_page(url, user, pwd, filename):
"""
having problems with urllib on a specific site so trying requests
"""
import requests
r = requests.get(url, auth=(user, pwd))
print(r.status_code)
if r.status_code == 200:
print('success')
with open(filename, 'wb') as fd:
... | [
"def",
"get_protected_page",
"(",
"url",
",",
"user",
",",
"pwd",
",",
"filename",
")",
":",
"import",
"requests",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"(",
"user",
",",
"pwd",
")",
")",
"print",
"(",
"r",
".",
"status_co... | having problems with urllib on a specific site so trying requests | [
"having",
"problems",
"with",
"urllib",
"on",
"a",
"specific",
"site",
"so",
"trying",
"requests"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/network_tools.py#L67-L81 | train | Download a protected page from url and save it to filename |
acutesoftware/AIKIF | aikif/toolbox/network_tools.py | download_file | def download_file(p_realm, p_url, p_op_file, p_username, p_password):
"""
Currently not working...
# https://docs.python.org/3/library/urllib.request.html#examples
# Create an OpenerDirector with support for Basic HTTP Authentication...
"""
auth_handler = urllib.request.HTTPBasicAuthHandler()
... | python | def download_file(p_realm, p_url, p_op_file, p_username, p_password):
"""
Currently not working...
# https://docs.python.org/3/library/urllib.request.html#examples
# Create an OpenerDirector with support for Basic HTTP Authentication...
"""
auth_handler = urllib.request.HTTPBasicAuthHandler()
... | [
"def",
"download_file",
"(",
"p_realm",
",",
"p_url",
",",
"p_op_file",
",",
"p_username",
",",
"p_password",
")",
":",
"auth_handler",
"=",
"urllib",
".",
"request",
".",
"HTTPBasicAuthHandler",
"(",
")",
"auth_handler",
".",
"add_password",
"(",
"realm",
"="... | Currently not working...
# https://docs.python.org/3/library/urllib.request.html#examples
# Create an OpenerDirector with support for Basic HTTP Authentication... | [
"Currently",
"not",
"working",
"...",
"#",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"3",
"/",
"library",
"/",
"urllib",
".",
"request",
".",
"html#examples",
"#",
"Create",
"an",
"OpenerDirector",
"with",
"support",
"for",
"Basic",
"HT... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/network_tools.py#L83-L100 | train | Download a file from a URL and save it to a file in a local file. |
acutesoftware/AIKIF | aikif/toolbox/network_tools.py | download_file_proxy | def download_file_proxy(p_url, p_op_file, p_username, p_password, proxies):
"""
Currently fails behind proxy...
# https://docs.python.org/3/library/urllib.request.html#examples
"""
chunk_size=4096
import requests
r = requests.get(p_url, auth=(p_username, p_password), proxies=proxies)
#pr... | python | def download_file_proxy(p_url, p_op_file, p_username, p_password, proxies):
"""
Currently fails behind proxy...
# https://docs.python.org/3/library/urllib.request.html#examples
"""
chunk_size=4096
import requests
r = requests.get(p_url, auth=(p_username, p_password), proxies=proxies)
#pr... | [
"def",
"download_file_proxy",
"(",
"p_url",
",",
"p_op_file",
",",
"p_username",
",",
"p_password",
",",
"proxies",
")",
":",
"chunk_size",
"=",
"4096",
"import",
"requests",
"r",
"=",
"requests",
".",
"get",
"(",
"p_url",
",",
"auth",
"=",
"(",
"p_usernam... | Currently fails behind proxy...
# https://docs.python.org/3/library/urllib.request.html#examples | [
"Currently",
"fails",
"behind",
"proxy",
"...",
"#",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"3",
"/",
"library",
"/",
"urllib",
".",
"request",
".",
"html#examples"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/network_tools.py#L102-L114 | train | Download a file from a proxy. |
cox-labs/perseuspy | perseuspy/io/maxquant.py | read_rawFilesTable | def read_rawFilesTable(filename):
"""parse the 'rawFilesTable.txt' file into a pandas dataframe"""
exp = pd.read_table(filename)
expected_columns = {'File', 'Exists', 'Size', 'Data format', 'Parameter group', 'Experiment', 'Fraction'}
found_columns = set(exp.columns)
if len(expected_columns - found_... | python | def read_rawFilesTable(filename):
"""parse the 'rawFilesTable.txt' file into a pandas dataframe"""
exp = pd.read_table(filename)
expected_columns = {'File', 'Exists', 'Size', 'Data format', 'Parameter group', 'Experiment', 'Fraction'}
found_columns = set(exp.columns)
if len(expected_columns - found_... | [
"def",
"read_rawFilesTable",
"(",
"filename",
")",
":",
"exp",
"=",
"pd",
".",
"read_table",
"(",
"filename",
")",
"expected_columns",
"=",
"{",
"'File'",
",",
"'Exists'",
",",
"'Size'",
",",
"'Data format'",
",",
"'Parameter group'",
",",
"'Experiment'",
",",... | parse the 'rawFilesTable.txt' file into a pandas dataframe | [
"parse",
"the",
"rawFilesTable",
".",
"txt",
"file",
"into",
"a",
"pandas",
"dataframe"
] | 3809c1bd46512605f9e7ca7f97e026e4940ed604 | https://github.com/cox-labs/perseuspy/blob/3809c1bd46512605f9e7ca7f97e026e4940ed604/perseuspy/io/maxquant.py#L8-L22 | train | parse the rawFilesTable. txt file into a pandas dataframe |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.add_method | def add_method(self, m, **kwargs):
"""Add an instance method or function
Args:
m: The instance method or function to store
"""
if isinstance(m, types.FunctionType):
self['function', id(m)] = m
else:
f, obj = get_method_vars(m)
wrke... | python | def add_method(self, m, **kwargs):
"""Add an instance method or function
Args:
m: The instance method or function to store
"""
if isinstance(m, types.FunctionType):
self['function', id(m)] = m
else:
f, obj = get_method_vars(m)
wrke... | [
"def",
"add_method",
"(",
"self",
",",
"m",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"m",
",",
"types",
".",
"FunctionType",
")",
":",
"self",
"[",
"'function'",
",",
"id",
"(",
"m",
")",
"]",
"=",
"m",
"else",
":",
"f",
",",... | Add an instance method or function
Args:
m: The instance method or function to store | [
"Add",
"an",
"instance",
"method",
"or",
"function"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L49-L60 | train | Add an instance method or function to store
|
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.del_method | def del_method(self, m):
"""Remove an instance method or function if it exists
Args:
m: The instance method or function to remove
"""
if isinstance(m, types.FunctionType) and not iscoroutinefunction(m):
wrkey = ('function', id(m))
else:
f, obj... | python | def del_method(self, m):
"""Remove an instance method or function if it exists
Args:
m: The instance method or function to remove
"""
if isinstance(m, types.FunctionType) and not iscoroutinefunction(m):
wrkey = ('function', id(m))
else:
f, obj... | [
"def",
"del_method",
"(",
"self",
",",
"m",
")",
":",
"if",
"isinstance",
"(",
"m",
",",
"types",
".",
"FunctionType",
")",
"and",
"not",
"iscoroutinefunction",
"(",
"m",
")",
":",
"wrkey",
"=",
"(",
"'function'",
",",
"id",
"(",
"m",
")",
")",
"el... | Remove an instance method or function if it exists
Args:
m: The instance method or function to remove | [
"Remove",
"an",
"instance",
"method",
"or",
"function",
"if",
"it",
"exists"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L61-L73 | train | Removes an instance method or function from the cache if it exists. |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.del_instance | def del_instance(self, obj):
"""Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove
"""
to_remove = set()
for wrkey, _obj in self.iter_instances():
if obj is _obj:
to_remove.add(wrkey)
... | python | def del_instance(self, obj):
"""Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove
"""
to_remove = set()
for wrkey, _obj in self.iter_instances():
if obj is _obj:
to_remove.add(wrkey)
... | [
"def",
"del_instance",
"(",
"self",
",",
"obj",
")",
":",
"to_remove",
"=",
"set",
"(",
")",
"for",
"wrkey",
",",
"_obj",
"in",
"self",
".",
"iter_instances",
"(",
")",
":",
"if",
"obj",
"is",
"_obj",
":",
"to_remove",
".",
"add",
"(",
"wrkey",
")"... | Remove any stored instance methods that belong to an object
Args:
obj: The instance object to remove | [
"Remove",
"any",
"stored",
"instance",
"methods",
"that",
"belong",
"to",
"an",
"object"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L74-L85 | train | Removes any stored instance methods that belong to an object. |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.iter_instances | def iter_instances(self):
"""Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object
"""
for wrkey in set(self.keys()):
obj = self.get(wrkey)
if obj is None:
... | python | def iter_instances(self):
"""Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object
"""
for wrkey in set(self.keys()):
obj = self.get(wrkey)
if obj is None:
... | [
"def",
"iter_instances",
"(",
"self",
")",
":",
"for",
"wrkey",
"in",
"set",
"(",
"self",
".",
"keys",
"(",
")",
")",
":",
"obj",
"=",
"self",
".",
"get",
"(",
"wrkey",
")",
"if",
"obj",
"is",
"None",
":",
"continue",
"yield",
"wrkey",
",",
"obj"... | Iterate over the stored objects
Yields:
wrkey: The two-tuple key used to store the object
obj: The instance or function object | [
"Iterate",
"over",
"the",
"stored",
"objects"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L86-L97 | train | Iterate over the stored objects in the cache. |
nocarryr/python-dispatch | pydispatch/utils.py | WeakMethodContainer.iter_methods | def iter_methods(self):
"""Iterate over stored functions and instance methods
Yields:
Instance methods or function objects
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
if f == 'function':
yield self[wrkey]
... | python | def iter_methods(self):
"""Iterate over stored functions and instance methods
Yields:
Instance methods or function objects
"""
for wrkey, obj in self.iter_instances():
f, obj_id = wrkey
if f == 'function':
yield self[wrkey]
... | [
"def",
"iter_methods",
"(",
"self",
")",
":",
"for",
"wrkey",
",",
"obj",
"in",
"self",
".",
"iter_instances",
"(",
")",
":",
"f",
",",
"obj_id",
"=",
"wrkey",
"if",
"f",
"==",
"'function'",
":",
"yield",
"self",
"[",
"wrkey",
"]",
"else",
":",
"yi... | Iterate over stored functions and instance methods
Yields:
Instance methods or function objects | [
"Iterate",
"over",
"stored",
"functions",
"and",
"instance",
"methods"
] | 7c5ca03835c922cbfdfd62772c9e560062c954c7 | https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/utils.py#L98-L109 | train | Iterate over stored functions and instance methods or function objects |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | load_data_subject_areas | def load_data_subject_areas(subject_file):
"""
reads the subject file to a list, to confirm config is setup
"""
lst = []
if os.path.exists(subject_file):
with open(subject_file, 'r') as f:
for line in f:
lst.append(line.strip())
else:
print('MISSING DA... | python | def load_data_subject_areas(subject_file):
"""
reads the subject file to a list, to confirm config is setup
"""
lst = []
if os.path.exists(subject_file):
with open(subject_file, 'r') as f:
for line in f:
lst.append(line.strip())
else:
print('MISSING DA... | [
"def",
"load_data_subject_areas",
"(",
"subject_file",
")",
":",
"lst",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"subject_file",
")",
":",
"with",
"open",
"(",
"subject_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"... | reads the subject file to a list, to confirm config is setup | [
"reads",
"the",
"subject",
"file",
"to",
"a",
"list",
"to",
"confirm",
"config",
"is",
"setup"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L27-L39 | train | reads the subject file to a list |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | check_ontology | def check_ontology(fname):
"""
reads the ontology yaml file and does basic verifcation
"""
with open(fname, 'r') as stream:
y = yaml.safe_load(stream)
import pprint
pprint.pprint(y) | python | def check_ontology(fname):
"""
reads the ontology yaml file and does basic verifcation
"""
with open(fname, 'r') as stream:
y = yaml.safe_load(stream)
import pprint
pprint.pprint(y) | [
"def",
"check_ontology",
"(",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"'r'",
")",
"as",
"stream",
":",
"y",
"=",
"yaml",
".",
"safe_load",
"(",
"stream",
")",
"import",
"pprint",
"pprint",
".",
"pprint",
"(",
"y",
")"
] | reads the ontology yaml file and does basic verifcation | [
"reads",
"the",
"ontology",
"yaml",
"file",
"and",
"does",
"basic",
"verifcation"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L135-L142 | train | reads the ontology yaml file and does basic verifcation
|
acutesoftware/AIKIF | aikif/cls_file_mapping.py | FileMap.find_ontology | def find_ontology(self, txt):
"""
top level function used for new data processing which attempts
to find a level in a heirarchy and return the key and filename
usage res = FindOntology('file') # returns 'SYSTEM-PC-FILE'
"""
totFound = 0
searchString = txt.upper()... | python | def find_ontology(self, txt):
"""
top level function used for new data processing which attempts
to find a level in a heirarchy and return the key and filename
usage res = FindOntology('file') # returns 'SYSTEM-PC-FILE'
"""
totFound = 0
searchString = txt.upper()... | [
"def",
"find_ontology",
"(",
"self",
",",
"txt",
")",
":",
"totFound",
"=",
"0",
"searchString",
"=",
"txt",
".",
"upper",
"(",
")",
"match",
"=",
"[",
"]",
"if",
"searchString",
"!=",
"''",
":",
"for",
"i",
"in",
"self",
".",
"lst_subj",
":",
"if"... | top level function used for new data processing which attempts
to find a level in a heirarchy and return the key and filename
usage res = FindOntology('file') # returns 'SYSTEM-PC-FILE' | [
"top",
"level",
"function",
"used",
"for",
"new",
"data",
"processing",
"which",
"attempts",
"to",
"find",
"a",
"level",
"in",
"a",
"heirarchy",
"and",
"return",
"the",
"key",
"and",
"filename",
"usage",
"res",
"=",
"FindOntology",
"(",
"file",
")",
"#",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L87-L103 | train | find an ontology by name |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | FileMap.find_type | def find_type(self, txt):
"""
top level function used to simply return the
ONE ACTUAL string used for data types
"""
searchString = txt.upper()
match = 'Unknown'
for i in self.lst_type:
if searchString in i:
match = i
return ma... | python | def find_type(self, txt):
"""
top level function used to simply return the
ONE ACTUAL string used for data types
"""
searchString = txt.upper()
match = 'Unknown'
for i in self.lst_type:
if searchString in i:
match = i
return ma... | [
"def",
"find_type",
"(",
"self",
",",
"txt",
")",
":",
"searchString",
"=",
"txt",
".",
"upper",
"(",
")",
"match",
"=",
"'Unknown'",
"for",
"i",
"in",
"self",
".",
"lst_type",
":",
"if",
"searchString",
"in",
"i",
":",
"match",
"=",
"i",
"return",
... | top level function used to simply return the
ONE ACTUAL string used for data types | [
"top",
"level",
"function",
"used",
"to",
"simply",
"return",
"the",
"ONE",
"ACTUAL",
"string",
"used",
"for",
"data",
"types"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L105-L115 | train | find the type of the object |
acutesoftware/AIKIF | aikif/cls_file_mapping.py | FileMap.get_full_filename | def get_full_filename(self, dataType, subjectArea):
"""
returns the file based on dataType and subjectArea
"""
return dataPath + os.sep + 'core' + os.sep + dataType + '_' + subjectArea + '.CSV' | python | def get_full_filename(self, dataType, subjectArea):
"""
returns the file based on dataType and subjectArea
"""
return dataPath + os.sep + 'core' + os.sep + dataType + '_' + subjectArea + '.CSV' | [
"def",
"get_full_filename",
"(",
"self",
",",
"dataType",
",",
"subjectArea",
")",
":",
"return",
"dataPath",
"+",
"os",
".",
"sep",
"+",
"'core'",
"+",
"os",
".",
"sep",
"+",
"dataType",
"+",
"'_'",
"+",
"subjectArea",
"+",
"'.CSV'"
] | returns the file based on dataType and subjectArea | [
"returns",
"the",
"file",
"based",
"on",
"dataType",
"and",
"subjectArea"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L117-L121 | train | returns the full filename based on dataType and subjectArea |
masci/django-appengine-toolkit | appengine_toolkit/__init__.py | parse | def parse(url):
"""
Parses a database URL in this format:
[database type]://[username]:[password]@[host]:[port]/[database name]
or, for cloud SQL:
[database type]://[username]:[password]@[project_id]:[instance_name]/[database name]
"""
config = {}
url = urlparse.urlparse(url)
# Re... | python | def parse(url):
"""
Parses a database URL in this format:
[database type]://[username]:[password]@[host]:[port]/[database name]
or, for cloud SQL:
[database type]://[username]:[password]@[project_id]:[instance_name]/[database name]
"""
config = {}
url = urlparse.urlparse(url)
# Re... | [
"def",
"parse",
"(",
"url",
")",
":",
"config",
"=",
"{",
"}",
"url",
"=",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
"# Remove query strings.",
"path",
"=",
"url",
".",
"path",
"[",
"1",
":",
"]",
"path",
"=",
"path",
".",
"split",
"(",
"'?'",
... | Parses a database URL in this format:
[database type]://[username]:[password]@[host]:[port]/[database name]
or, for cloud SQL:
[database type]://[username]:[password]@[project_id]:[instance_name]/[database name] | [
"Parses",
"a",
"database",
"URL",
"in",
"this",
"format",
":",
"[",
"database",
"type",
"]",
":",
"//",
"[",
"username",
"]",
":",
"[",
"password",
"]",
"@",
"[",
"host",
"]",
":",
"[",
"port",
"]",
"/",
"[",
"database",
"name",
"]"
] | 9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2 | https://github.com/masci/django-appengine-toolkit/blob/9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2/appengine_toolkit/__init__.py#L43-L82 | train | Parses a database URL in this format and returns a dictionary with the configuration parameters. |
Nachtfeuer/pipeline | spline/tools/logger.py | Logger.get_logger | def get_logger(name):
"""Get a logger by name."""
if name is None:
return NoLogger()
logger = logging.getLogger(name)
if Logger.use_external_configuration:
logger.propagate = False
return logger | python | def get_logger(name):
"""Get a logger by name."""
if name is None:
return NoLogger()
logger = logging.getLogger(name)
if Logger.use_external_configuration:
logger.propagate = False
return logger | [
"def",
"get_logger",
"(",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"NoLogger",
"(",
")",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"if",
"Logger",
".",
"use_external_configuration",
":",
"logger",
".",
"propagate",
... | Get a logger by name. | [
"Get",
"a",
"logger",
"by",
"name",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/logger.py#L54-L62 | train | Get a logger by name. |
acutesoftware/AIKIF | aikif/lib/cls_plan_BDI.py | Plan_BDI.load_plan | def load_plan(self, fname):
""" read the list of thoughts from a text file """
with open(fname, "r") as f:
for line in f:
if line != '':
tpe, txt = self.parse_plan_from_string(line)
#print('tpe= "' + tpe + '"', txt)
... | python | def load_plan(self, fname):
""" read the list of thoughts from a text file """
with open(fname, "r") as f:
for line in f:
if line != '':
tpe, txt = self.parse_plan_from_string(line)
#print('tpe= "' + tpe + '"', txt)
... | [
"def",
"load_plan",
"(",
"self",
",",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
"!=",
"''",
":",
"tpe",
",",
"txt",
"=",
"self",
".",
"parse_plan_from_string",
... | read the list of thoughts from a text file | [
"read",
"the",
"list",
"of",
"thoughts",
"from",
"a",
"text",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_plan_BDI.py#L48-L64 | train | load the list of thoughts from a text file |
acutesoftware/AIKIF | aikif/lib/cls_plan_BDI.py | Plan_BDI.add_constraint | def add_constraint(self, name, tpe, val):
"""
adds a constraint for the plan
"""
self.constraint.append([name, tpe, val]) | python | def add_constraint(self, name, tpe, val):
"""
adds a constraint for the plan
"""
self.constraint.append([name, tpe, val]) | [
"def",
"add_constraint",
"(",
"self",
",",
"name",
",",
"tpe",
",",
"val",
")",
":",
"self",
".",
"constraint",
".",
"append",
"(",
"[",
"name",
",",
"tpe",
",",
"val",
"]",
")"
] | adds a constraint for the plan | [
"adds",
"a",
"constraint",
"for",
"the",
"plan"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_plan_BDI.py#L100-L104 | train | Adds a constraint for the plan
|
acutesoftware/AIKIF | aikif/mapper.py | Mapper.get_maps_stats | def get_maps_stats(self):
"""
calculates basic stats on the MapRule elements of the maps
to give a quick overview.
"""
tpes = {}
for m in self.maps:
if m.tpe in tpes:
tpes[m.tpe] += 1
else:
tpes[m.tpe] = 1
re... | python | def get_maps_stats(self):
"""
calculates basic stats on the MapRule elements of the maps
to give a quick overview.
"""
tpes = {}
for m in self.maps:
if m.tpe in tpes:
tpes[m.tpe] += 1
else:
tpes[m.tpe] = 1
re... | [
"def",
"get_maps_stats",
"(",
"self",
")",
":",
"tpes",
"=",
"{",
"}",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"if",
"m",
".",
"tpe",
"in",
"tpes",
":",
"tpes",
"[",
"m",
".",
"tpe",
"]",
"+=",
"1",
"else",
":",
"tpes",
"[",
"m",
".",
"... | calculates basic stats on the MapRule elements of the maps
to give a quick overview. | [
"calculates",
"basic",
"stats",
"on",
"the",
"MapRule",
"elements",
"of",
"the",
"maps",
"to",
"give",
"a",
"quick",
"overview",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L40-L51 | train | Calculates basic stats on the MapRule elements of the maps that are in the cache. |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.load_rules | def load_rules(self):
"""
load the rules from file
"""
self.maps = []
with open(self.map_file, 'r') as f:
for line in f:
if line.strip(' ')[0:1] != '#':
rule = MapRule(line)
#print('rule = ', rule)
... | python | def load_rules(self):
"""
load the rules from file
"""
self.maps = []
with open(self.map_file, 'r') as f:
for line in f:
if line.strip(' ')[0:1] != '#':
rule = MapRule(line)
#print('rule = ', rule)
... | [
"def",
"load_rules",
"(",
"self",
")",
":",
"self",
".",
"maps",
"=",
"[",
"]",
"with",
"open",
"(",
"self",
".",
"map_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
".",
"strip",
"(",
"' '",
")",
"[",
"0... | load the rules from file | [
"load",
"the",
"rules",
"from",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L53-L63 | train | load the rules from file |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.save_rules | def save_rules(self, op_file):
"""
save the rules to file after web updates or program changes
"""
with open(op_file, 'w') as f:
for m in self.maps:
f.write(m.format_for_file_output()) | python | def save_rules(self, op_file):
"""
save the rules to file after web updates or program changes
"""
with open(op_file, 'w') as f:
for m in self.maps:
f.write(m.format_for_file_output()) | [
"def",
"save_rules",
"(",
"self",
",",
"op_file",
")",
":",
"with",
"open",
"(",
"op_file",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"f",
".",
"write",
"(",
"m",
".",
"format_for_file_output",
"(",
")",
")"
] | save the rules to file after web updates or program changes | [
"save",
"the",
"rules",
"to",
"file",
"after",
"web",
"updates",
"or",
"program",
"changes"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L65-L71 | train | save the rules to file after web updates or program changes
|
acutesoftware/AIKIF | aikif/mapper.py | Mapper.process_raw_file | def process_raw_file(self, raw_file_name, field_names):
"""
takes the filename to be read and uses the maps setup
on class instantiation to process the file.
This is a top level function and uses self.maps which
should be the column descriptions (in order).
"""
... | python | def process_raw_file(self, raw_file_name, field_names):
"""
takes the filename to be read and uses the maps setup
on class instantiation to process the file.
This is a top level function and uses self.maps which
should be the column descriptions (in order).
"""
... | [
"def",
"process_raw_file",
"(",
"self",
",",
"raw_file_name",
",",
"field_names",
")",
":",
"#num_outouts = 0",
"dist_vals",
"=",
"[",
"]",
"group_dat",
"=",
"[",
"]",
"events",
"=",
"[",
"]",
"#facts = []",
"with",
"open",
"(",
"raw_file_name",
")",
"as",
... | takes the filename to be read and uses the maps setup
on class instantiation to process the file.
This is a top level function and uses self.maps which
should be the column descriptions (in order). | [
"takes",
"the",
"filename",
"to",
"be",
"read",
"and",
"uses",
"the",
"maps",
"setup",
"on",
"class",
"instantiation",
"to",
"process",
"the",
"file",
".",
"This",
"is",
"a",
"top",
"level",
"function",
"and",
"uses",
"self",
".",
"maps",
"which",
"shoul... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L73-L103 | train | This function takes the filename to be read and uses the maps setup
on class instantiation to process the file. |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.identify_data | def identify_data(self, tpe, raw_data):
"""
function to decide how to process
the raw data (which can be any format).
Note - not 100% sure how this will be implemented
should we pass the filename (currently takes a line)
"""
num_applicable_rules = 0
forma... | python | def identify_data(self, tpe, raw_data):
"""
function to decide how to process
the raw data (which can be any format).
Note - not 100% sure how this will be implemented
should we pass the filename (currently takes a line)
"""
num_applicable_rules = 0
forma... | [
"def",
"identify_data",
"(",
"self",
",",
"tpe",
",",
"raw_data",
")",
":",
"num_applicable_rules",
"=",
"0",
"formatted_data",
"=",
"self",
".",
"format_raw_data",
"(",
"tpe",
",",
"raw_data",
")",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"if",
"m",
... | function to decide how to process
the raw data (which can be any format).
Note - not 100% sure how this will be implemented
should we pass the filename (currently takes a line) | [
"function",
"to",
"decide",
"how",
"to",
"process",
"the",
"raw",
"data",
"(",
"which",
"can",
"be",
"any",
"format",
")",
".",
"Note",
"-",
"not",
"100%",
"sure",
"how",
"this",
"will",
"be",
"implemented",
"should",
"we",
"pass",
"the",
"filename",
"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L108-L121 | train | function to identify the data for a particular entry in the raw data file |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.process_rule | def process_rule(self, m, dct, tpe):
"""
uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule
"""
print('TODO - ' + tpe + ' + applying rule ' + str(m).replace('\n', '') ) | python | def process_rule(self, m, dct, tpe):
"""
uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule
"""
print('TODO - ' + tpe + ' + applying rule ' + str(m).replace('\n', '') ) | [
"def",
"process_rule",
"(",
"self",
",",
"m",
",",
"dct",
",",
"tpe",
")",
":",
"print",
"(",
"'TODO - '",
"+",
"tpe",
"+",
"' + applying rule '",
"+",
"str",
"(",
"m",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
")"
] | uses the MapRule 'm' to run through the 'dict'
and extract data based on the rule | [
"uses",
"the",
"MapRule",
"m",
"to",
"run",
"through",
"the",
"dict",
"and",
"extract",
"data",
"based",
"on",
"the",
"rule"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L123-L128 | train | This function is called by the process_data function of the map rule m. |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.format_raw_data | def format_raw_data(self, tpe, raw_data):
"""
uses type to format the raw information to a dictionary
usable by the mapper
"""
if tpe == 'text':
formatted_raw_data = self.parse_text_to_dict(raw_data)
elif tpe == 'file':
formatted_raw_data ... | python | def format_raw_data(self, tpe, raw_data):
"""
uses type to format the raw information to a dictionary
usable by the mapper
"""
if tpe == 'text':
formatted_raw_data = self.parse_text_to_dict(raw_data)
elif tpe == 'file':
formatted_raw_data ... | [
"def",
"format_raw_data",
"(",
"self",
",",
"tpe",
",",
"raw_data",
")",
":",
"if",
"tpe",
"==",
"'text'",
":",
"formatted_raw_data",
"=",
"self",
".",
"parse_text_to_dict",
"(",
"raw_data",
")",
"elif",
"tpe",
"==",
"'file'",
":",
"formatted_raw_data",
"=",... | uses type to format the raw information to a dictionary
usable by the mapper | [
"uses",
"type",
"to",
"format",
"the",
"raw",
"information",
"to",
"a",
"dictionary",
"usable",
"by",
"the",
"mapper"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L131-L143 | train | Formats the raw data into a dictionary. |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.parse_text_to_dict | def parse_text_to_dict(self, txt):
"""
takes a string and parses via NLP, ready for mapping
"""
op = {}
print('TODO - import NLP, split into verbs / nouns')
op['nouns'] = txt
op['verbs'] = txt
return op | python | def parse_text_to_dict(self, txt):
"""
takes a string and parses via NLP, ready for mapping
"""
op = {}
print('TODO - import NLP, split into verbs / nouns')
op['nouns'] = txt
op['verbs'] = txt
return op | [
"def",
"parse_text_to_dict",
"(",
"self",
",",
"txt",
")",
":",
"op",
"=",
"{",
"}",
"print",
"(",
"'TODO - import NLP, split into verbs / nouns'",
")",
"op",
"[",
"'nouns'",
"]",
"=",
"txt",
"op",
"[",
"'verbs'",
"]",
"=",
"txt",
"return",
"op"
] | takes a string and parses via NLP, ready for mapping | [
"takes",
"a",
"string",
"and",
"parses",
"via",
"NLP",
"ready",
"for",
"mapping"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L145-L154 | train | takes a string and parses via NLP and returns a dictionary of the keys verbs and nouns |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.parse_file_to_dict | def parse_file_to_dict(self, fname):
"""
process the file according to the mapping rules.
The cols list must match the columns in the filename
"""
print('TODO - parse_file_to_dict' + fname)
for m in self.maps:
if m.tpe == 'file':
if m.key[0:3] ... | python | def parse_file_to_dict(self, fname):
"""
process the file according to the mapping rules.
The cols list must match the columns in the filename
"""
print('TODO - parse_file_to_dict' + fname)
for m in self.maps:
if m.tpe == 'file':
if m.key[0:3] ... | [
"def",
"parse_file_to_dict",
"(",
"self",
",",
"fname",
")",
":",
"print",
"(",
"'TODO - parse_file_to_dict'",
"+",
"fname",
")",
"for",
"m",
"in",
"self",
".",
"maps",
":",
"if",
"m",
".",
"tpe",
"==",
"'file'",
":",
"if",
"m",
".",
"key",
"[",
"0",... | process the file according to the mapping rules.
The cols list must match the columns in the filename | [
"process",
"the",
"file",
"according",
"to",
"the",
"mapping",
"rules",
".",
"The",
"cols",
"list",
"must",
"match",
"the",
"columns",
"in",
"the",
"filename"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L156-L165 | train | parse the file to dict |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.generate_map_from_dataset | def generate_map_from_dataset(self, l_dataset):
"""
creates a map file (in the standard CSV format) based on
columns of a dataset.
1. read column names, lookup names in list
2. read column content, get highest match of distinct values
from ontology lists (eg, Years... | python | def generate_map_from_dataset(self, l_dataset):
"""
creates a map file (in the standard CSV format) based on
columns of a dataset.
1. read column names, lookup names in list
2. read column content, get highest match of distinct values
from ontology lists (eg, Years... | [
"def",
"generate_map_from_dataset",
"(",
"self",
",",
"l_dataset",
")",
":",
"l_map",
"=",
"[",
"]",
"headers",
"=",
"l_dataset",
".",
"get_header",
"(",
")",
"print",
"(",
"headers",
")",
"for",
"row_num",
",",
"col",
"in",
"enumerate",
"(",
"headers",
... | creates a map file (in the standard CSV format) based on
columns of a dataset.
1. read column names, lookup names in list
2. read column content, get highest match of distinct values
from ontology lists (eg, Years, countries, cities, ages) | [
"creates",
"a",
"map",
"file",
"(",
"in",
"the",
"standard",
"CSV",
"format",
")",
"based",
"on",
"columns",
"of",
"a",
"dataset",
".",
"1",
".",
"read",
"column",
"names",
"lookup",
"names",
"in",
"list",
"2",
".",
"read",
"column",
"content",
"get",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L168-L196 | train | Generates a list of CSV files based on the columns of a dataset. |
acutesoftware/AIKIF | aikif/mapper.py | Mapper.create_map_from_file | def create_map_from_file(self, data_filename):
"""
reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it
"""
o... | python | def create_map_from_file(self, data_filename):
"""
reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it
"""
o... | [
"def",
"create_map_from_file",
"(",
"self",
",",
"data_filename",
")",
":",
"op_filename",
"=",
"data_filename",
"+",
"'.rule'",
"dataset",
"=",
"mod_datatable",
".",
"DataTable",
"(",
"data_filename",
",",
"','",
")",
"dataset",
".",
"load_to_array",
"(",
")",
... | reads the data_filename into a matrix and calls the main
function '' to generate a .rule file based on the data in the map
For all datafiles mapped, there exists a .rule file to define it | [
"reads",
"the",
"data_filename",
"into",
"a",
"matrix",
"and",
"calls",
"the",
"main",
"function",
"to",
"generate",
"a",
".",
"rule",
"file",
"based",
"on",
"the",
"data",
"in",
"the",
"map",
"For",
"all",
"datafiles",
"mapped",
"there",
"exists",
"a",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L198-L222 | train | Reads the data_filename into a matrix and generates a. rule file based on the data in the map
ecords. |
acutesoftware/AIKIF | aikif/mapper.py | MapColumns.load_rules | def load_rules(self):
"""
load the rules from file
"""
self.col_maps = []
#print("reading mapping table")
with open(self.col_file, 'r') as f:
for line in f:
rule = MapColumn(line)
#rule = line
self.col_maps.appe... | python | def load_rules(self):
"""
load the rules from file
"""
self.col_maps = []
#print("reading mapping table")
with open(self.col_file, 'r') as f:
for line in f:
rule = MapColumn(line)
#rule = line
self.col_maps.appe... | [
"def",
"load_rules",
"(",
"self",
")",
":",
"self",
".",
"col_maps",
"=",
"[",
"]",
"#print(\"reading mapping table\")",
"with",
"open",
"(",
"self",
".",
"col_file",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"rule",
"=",
"MapColu... | load the rules from file | [
"load",
"the",
"rules",
"from",
"file"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L295-L305 | train | load the rules from file
. col_file |
acutesoftware/AIKIF | aikif/mapper.py | MapColumn._parse_csv_col_rules | def _parse_csv_col_rules(self):
"""
splits the CSV line of the current format and puts into
local class variables - mainly for testing, though this is
not the best method long term. (TODO - fix this)
"""
self.cols = self.csv_line.split(',')
self.table = self.extr... | python | def _parse_csv_col_rules(self):
"""
splits the CSV line of the current format and puts into
local class variables - mainly for testing, though this is
not the best method long term. (TODO - fix this)
"""
self.cols = self.csv_line.split(',')
self.table = self.extr... | [
"def",
"_parse_csv_col_rules",
"(",
"self",
")",
":",
"self",
".",
"cols",
"=",
"self",
".",
"csv_line",
".",
"split",
"(",
"','",
")",
"self",
".",
"table",
"=",
"self",
".",
"extract_col",
"(",
"0",
")",
"self",
".",
"column",
"=",
"self",
".",
"... | splits the CSV line of the current format and puts into
local class variables - mainly for testing, though this is
not the best method long term. (TODO - fix this) | [
"splits",
"the",
"CSV",
"line",
"of",
"the",
"current",
"format",
"and",
"puts",
"into",
"local",
"class",
"variables",
"-",
"mainly",
"for",
"testing",
"though",
"this",
"is",
"not",
"the",
"best",
"method",
"long",
"term",
".",
"(",
"TODO",
"-",
"fix",... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/mapper.py#L369-L384 | train | Parses the CSV line of the current format and puts into
|
acutesoftware/AIKIF | scripts/examples/aggie/aggie.py | Aggie.run | def run(self):
"""
loops until exit command given
"""
while self.status != 'EXIT':
print(self.process_input(self.get_input()))
print('Bye') | python | def run(self):
"""
loops until exit command given
"""
while self.status != 'EXIT':
print(self.process_input(self.get_input()))
print('Bye') | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"self",
".",
"status",
"!=",
"'EXIT'",
":",
"print",
"(",
"self",
".",
"process_input",
"(",
"self",
".",
"get_input",
"(",
")",
")",
")",
"print",
"(",
"'Bye'",
")"
] | loops until exit command given | [
"loops",
"until",
"exit",
"command",
"given"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/aggie/aggie.py#L45-L52 | train | loop until exit command given
|
acutesoftware/AIKIF | scripts/examples/aggie/aggie.py | Aggie.process_input | def process_input(self, question):
"""
takes a question and returns the best answer based on known skills
"""
ans = ''
if self.status == 'EXIT':
print('bye')
sys.exit()
if '?' in question:
ans = self.info.find_answer(question)
... | python | def process_input(self, question):
"""
takes a question and returns the best answer based on known skills
"""
ans = ''
if self.status == 'EXIT':
print('bye')
sys.exit()
if '?' in question:
ans = self.info.find_answer(question)
... | [
"def",
"process_input",
"(",
"self",
",",
"question",
")",
":",
"ans",
"=",
"''",
"if",
"self",
".",
"status",
"==",
"'EXIT'",
":",
"print",
"(",
"'bye'",
")",
"sys",
".",
"exit",
"(",
")",
"if",
"'?'",
"in",
"question",
":",
"ans",
"=",
"self",
... | takes a question and returns the best answer based on known skills | [
"takes",
"a",
"question",
"and",
"returns",
"the",
"best",
"answer",
"based",
"on",
"known",
"skills"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/aggie/aggie.py#L60-L83 | train | Takes a question and returns the best answer based on known skills |
acutesoftware/AIKIF | scripts/examples/aggie/aggie.py | Info.find_answer | def find_answer(self, qu):
"""
This takes the question 'qu' and parses info and raw input
to try and find an answer.
It should use the skills, and where parameters are needed it
should guess them if not in there - for example weather should
default to local location unle... | python | def find_answer(self, qu):
"""
This takes the question 'qu' and parses info and raw input
to try and find an answer.
It should use the skills, and where parameters are needed it
should guess them if not in there - for example weather should
default to local location unle... | [
"def",
"find_answer",
"(",
"self",
",",
"qu",
")",
":",
"if",
"'weather'",
"in",
"qu",
":",
"ans",
"=",
"'sunny'",
"elif",
"'where'",
"in",
"qu",
":",
"ans",
"=",
"'4km to the North'",
"elif",
"'when'",
"in",
"qu",
":",
"ans",
"=",
"'next week'",
"else... | This takes the question 'qu' and parses info and raw input
to try and find an answer.
It should use the skills, and where parameters are needed it
should guess them if not in there - for example weather should
default to local location unless a [country|city] is part of question | [
"This",
"takes",
"the",
"question",
"qu",
"and",
"parses",
"info",
"and",
"raw",
"input",
"to",
"try",
"and",
"find",
"an",
"answer",
".",
"It",
"should",
"use",
"the",
"skills",
"and",
"where",
"parameters",
"are",
"needed",
"it",
"should",
"guess",
"th... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/aggie/aggie.py#L101-L119 | train | This function takes a question and parses info and raw input
to try and find an answer. |
acutesoftware/AIKIF | aikif/web_app/page_data.py | show_data_file | def show_data_file(fname):
""" shows a data file in CSV format - all files live in CORE folder """
txt = '<H2>' + fname + '</H2>'
print (fname)
#try:
txt += web.read_csv_to_html_table(fname, 'Y') # it is ok to use a table for actual table data
#except:
# txt += '<H2>ERROR - cant read file</... | python | def show_data_file(fname):
""" shows a data file in CSV format - all files live in CORE folder """
txt = '<H2>' + fname + '</H2>'
print (fname)
#try:
txt += web.read_csv_to_html_table(fname, 'Y') # it is ok to use a table for actual table data
#except:
# txt += '<H2>ERROR - cant read file</... | [
"def",
"show_data_file",
"(",
"fname",
")",
":",
"txt",
"=",
"'<H2>'",
"+",
"fname",
"+",
"'</H2>'",
"print",
"(",
"fname",
")",
"#try:",
"txt",
"+=",
"web",
".",
"read_csv_to_html_table",
"(",
"fname",
",",
"'Y'",
")",
"# it is ok to use a table for actual ta... | shows a data file in CSV format - all files live in CORE folder | [
"shows",
"a",
"data",
"file",
"in",
"CSV",
"format",
"-",
"all",
"files",
"live",
"in",
"CORE",
"folder"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/page_data.py#L28-L39 | train | shows a data file in CSV format |
Nachtfeuer/pipeline | spline/components/bash.py | managed_process | def managed_process(process):
"""Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax."""
try:
yield process
finally:
for stream in [process.stdout, process.stdin, process.stderr]:
if stream:
stream.close()
proces... | python | def managed_process(process):
"""Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax."""
try:
yield process
finally:
for stream in [process.stdout, process.stdin, process.stderr]:
if stream:
stream.close()
proces... | [
"def",
"managed_process",
"(",
"process",
")",
":",
"try",
":",
"yield",
"process",
"finally",
":",
"for",
"stream",
"in",
"[",
"process",
".",
"stdout",
",",
"process",
".",
"stdin",
",",
"process",
".",
"stderr",
"]",
":",
"if",
"stream",
":",
"strea... | Wrapper for subprocess.Popen to work across various Python versions, when using the with syntax. | [
"Wrapper",
"for",
"subprocess",
".",
"Popen",
"to",
"work",
"across",
"various",
"Python",
"versions",
"when",
"using",
"the",
"with",
"syntax",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L33-L41 | train | Wrapper for subprocess. Popen to work across various Python versions when using the with syntax. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.update_environment_variables | def update_environment_variables(self, filename):
"""Updating OS environment variables and current script path and filename."""
self.env.update(os.environ.copy())
self.env.update({'PIPELINE_BASH_FILE': filename}) | python | def update_environment_variables(self, filename):
"""Updating OS environment variables and current script path and filename."""
self.env.update(os.environ.copy())
self.env.update({'PIPELINE_BASH_FILE': filename}) | [
"def",
"update_environment_variables",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"env",
".",
"update",
"(",
"os",
".",
"environ",
".",
"copy",
"(",
")",
")",
"self",
".",
"env",
".",
"update",
"(",
"{",
"'PIPELINE_BASH_FILE'",
":",
"filename",... | Updating OS environment variables and current script path and filename. | [
"Updating",
"OS",
"environment",
"variables",
"and",
"current",
"script",
"path",
"and",
"filename",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L79-L82 | train | Updates OS environment variables and current script path and filename. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.get_temporary_scripts_path | def get_temporary_scripts_path(self):
"""
Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set
"""
result = None
if len(self.config.temporary_scripts_path) > 0:
if os.path.isdir(self.config.temporary_scripts_... | python | def get_temporary_scripts_path(self):
"""
Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set
"""
result = None
if len(self.config.temporary_scripts_path) > 0:
if os.path.isdir(self.config.temporary_scripts_... | [
"def",
"get_temporary_scripts_path",
"(",
"self",
")",
":",
"result",
"=",
"None",
"if",
"len",
"(",
"self",
".",
"config",
".",
"temporary_scripts_path",
")",
">",
"0",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"config",
".",
"temp... | Get path for temporary scripts.
Returns:
str: path for temporary scripts or None if not set | [
"Get",
"path",
"for",
"temporary",
"scripts",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L84-L95 | train | Get path for temporary scripts. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.create_file_for | def create_file_for(self, script):
"""
Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): eithe... | python | def create_file_for(self, script):
"""
Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): eithe... | [
"def",
"create_file_for",
"(",
"self",
",",
"script",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"\"pipeline-script-\"",
",",
"mode",
"=",
"'w+t'",
",",
"suffix",
"=",
"\".sh\"",
",",
"delete",
"=",
"False",
",",
"dir... | Create a temporary, executable bash file.
It also does render given script (string) with the model and
the provided environment variables and optional also an item
when using the B{with} field.
Args:
script (str): either pather and filename or Bash code.
Returns:
... | [
"Create",
"a",
"temporary",
"executable",
"bash",
"file",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L97-L136 | train | Create a temporary file for the given script. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.render_bash_options | def render_bash_options(self):
"""Rendering Bash options."""
options = ''
if self.config.debug:
options += "set -x\n"
if self.config.strict:
options += "set -euo pipefail\n"
return options | python | def render_bash_options(self):
"""Rendering Bash options."""
options = ''
if self.config.debug:
options += "set -x\n"
if self.config.strict:
options += "set -euo pipefail\n"
return options | [
"def",
"render_bash_options",
"(",
"self",
")",
":",
"options",
"=",
"''",
"if",
"self",
".",
"config",
".",
"debug",
":",
"options",
"+=",
"\"set -x\\n\"",
"if",
"self",
".",
"config",
".",
"strict",
":",
"options",
"+=",
"\"set -euo pipefail\\n\"",
"return... | Rendering Bash options. | [
"Rendering",
"Bash",
"options",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L138-L145 | train | Rendering Bash options. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.process_script | def process_script(self, filename):
"""Running the Bash code."""
try:
with managed_process(subprocess.Popen(shlex.split("bash %s" % filename),
stdout=self.stdout, stderr=self.stderr,
shell=sel... | python | def process_script(self, filename):
"""Running the Bash code."""
try:
with managed_process(subprocess.Popen(shlex.split("bash %s" % filename),
stdout=self.stdout, stderr=self.stderr,
shell=sel... | [
"def",
"process_script",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"with",
"managed_process",
"(",
"subprocess",
".",
"Popen",
"(",
"shlex",
".",
"split",
"(",
"\"bash %s\"",
"%",
"filename",
")",
",",
"stdout",
"=",
"self",
".",
"stdout",
",",... | Running the Bash code. | [
"Running",
"the",
"Bash",
"code",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L147-L168 | train | Process the script. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.process_file | def process_file(self, filename):
"""Processing one file."""
if self.config.dry_run:
if not self.config.internal:
self.logger.info("Dry run mode for script %s", filename)
with open(filename) as handle:
for line in handle:
yield ... | python | def process_file(self, filename):
"""Processing one file."""
if self.config.dry_run:
if not self.config.internal:
self.logger.info("Dry run mode for script %s", filename)
with open(filename) as handle:
for line in handle:
yield ... | [
"def",
"process_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"config",
".",
"dry_run",
":",
"if",
"not",
"self",
".",
"config",
".",
"internal",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Dry run mode for script %s\"",
",",
"fi... | Processing one file. | [
"Processing",
"one",
"file",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L170-L182 | train | Process one file. |
Nachtfeuer/pipeline | spline/components/bash.py | Bash.process | def process(self):
"""Running the Bash code."""
temp_filename = self.create_file_for(self.config.script)
if len(self.config.title) > 0:
self.logger.info(render(self.config.title, model=self.config.model, env=self.env,
item=self.config.item, variab... | python | def process(self):
"""Running the Bash code."""
temp_filename = self.create_file_for(self.config.script)
if len(self.config.title) > 0:
self.logger.info(render(self.config.title, model=self.config.model, env=self.env,
item=self.config.item, variab... | [
"def",
"process",
"(",
"self",
")",
":",
"temp_filename",
"=",
"self",
".",
"create_file_for",
"(",
"self",
".",
"config",
".",
"script",
")",
"if",
"len",
"(",
"self",
".",
"config",
".",
"title",
")",
">",
"0",
":",
"self",
".",
"logger",
".",
"i... | Running the Bash code. | [
"Running",
"the",
"Bash",
"code",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/bash.py#L184-L204 | train | Process the Bash code. |
wanadev/pyguetzli | pyguetzli/pil_image.py | _to_pil_rgb_image | def _to_pil_rgb_image(image):
"""Returns an PIL Image converted to the RGB color space. If the image has
an alpha channel (transparency), it will be overlaid on a black background.
:param image: the PIL image to convert
:returns: The input image if it was already in RGB mode, or a new RGB image
... | python | def _to_pil_rgb_image(image):
"""Returns an PIL Image converted to the RGB color space. If the image has
an alpha channel (transparency), it will be overlaid on a black background.
:param image: the PIL image to convert
:returns: The input image if it was already in RGB mode, or a new RGB image
... | [
"def",
"_to_pil_rgb_image",
"(",
"image",
")",
":",
"if",
"image",
".",
"mode",
"==",
"\"RGB\"",
":",
"return",
"image",
"from",
"PIL",
"import",
"Image",
"image",
".",
"load",
"(",
")",
"rgb_image",
"=",
"Image",
".",
"new",
"(",
"\"RGB\"",
",",
"imag... | Returns an PIL Image converted to the RGB color space. If the image has
an alpha channel (transparency), it will be overlaid on a black background.
:param image: the PIL image to convert
:returns: The input image if it was already in RGB mode, or a new RGB image
if converted.
:raises Im... | [
"Returns",
"an",
"PIL",
"Image",
"converted",
"to",
"the",
"RGB",
"color",
"space",
".",
"If",
"the",
"image",
"has",
"an",
"alpha",
"channel",
"(",
"transparency",
")",
"it",
"will",
"be",
"overlaid",
"on",
"a",
"black",
"background",
"."
] | 4e0c221f5e8f23adb38505c3c1c5a09294b7ee98 | https://github.com/wanadev/pyguetzli/blob/4e0c221f5e8f23adb38505c3c1c5a09294b7ee98/pyguetzli/pil_image.py#L13-L38 | train | Converts an image to the RGB color space. |
wanadev/pyguetzli | pyguetzli/pil_image.py | process_pil_image | def process_pil_image(image, quality=guetzli.DEFAULT_JPEG_QUALITY):
"""Generates an optimized JPEG from a PIL image. If the image has an alpha
channel (transparency), it will be overlaid on a black background.
:param image: the PIL image
:param quality: the output JPEG quality (default 95)
:return... | python | def process_pil_image(image, quality=guetzli.DEFAULT_JPEG_QUALITY):
"""Generates an optimized JPEG from a PIL image. If the image has an alpha
channel (transparency), it will be overlaid on a black background.
:param image: the PIL image
:param quality: the output JPEG quality (default 95)
:return... | [
"def",
"process_pil_image",
"(",
"image",
",",
"quality",
"=",
"guetzli",
".",
"DEFAULT_JPEG_QUALITY",
")",
":",
"image_rgb",
"=",
"_to_pil_rgb_image",
"(",
"image",
")",
"image_rgb_bytes",
"=",
"image_rgb",
".",
"tobytes",
"(",
")",
"return",
"guetzli",
".",
... | Generates an optimized JPEG from a PIL image. If the image has an alpha
channel (transparency), it will be overlaid on a black background.
:param image: the PIL image
:param quality: the output JPEG quality (default 95)
:returns: Optimized JPEG bytes
:rtype: bytes
:raises ImportError: PIL / P... | [
"Generates",
"an",
"optimized",
"JPEG",
"from",
"a",
"PIL",
"image",
".",
"If",
"the",
"image",
"has",
"an",
"alpha",
"channel",
"(",
"transparency",
")",
"it",
"will",
"be",
"overlaid",
"on",
"a",
"black",
"background",
"."
] | 4e0c221f5e8f23adb38505c3c1c5a09294b7ee98 | https://github.com/wanadev/pyguetzli/blob/4e0c221f5e8f23adb38505c3c1c5a09294b7ee98/pyguetzli/pil_image.py#L41-L67 | train | Generates an optimized JPEG from a PIL image. |
sethmlarson/selectors2 | selectors2.py | _fileobj_to_fd | def _fileobj_to_fd(fileobj):
""" Return a file descriptor from a file object. If
given an integer will simply return that integer back. """
if isinstance(fileobj, _INTEGER_TYPES):
fd = fileobj
else:
for _integer_type in _INTEGER_TYPES:
try:
fd = _integer_type(... | python | def _fileobj_to_fd(fileobj):
""" Return a file descriptor from a file object. If
given an integer will simply return that integer back. """
if isinstance(fileobj, _INTEGER_TYPES):
fd = fileobj
else:
for _integer_type in _INTEGER_TYPES:
try:
fd = _integer_type(... | [
"def",
"_fileobj_to_fd",
"(",
"fileobj",
")",
":",
"if",
"isinstance",
"(",
"fileobj",
",",
"_INTEGER_TYPES",
")",
":",
"fd",
"=",
"fileobj",
"else",
":",
"for",
"_integer_type",
"in",
"_INTEGER_TYPES",
":",
"try",
":",
"fd",
"=",
"_integer_type",
"(",
"fi... | Return a file descriptor from a file object. If
given an integer will simply return that integer back. | [
"Return",
"a",
"file",
"descriptor",
"from",
"a",
"file",
"object",
".",
"If",
"given",
"an",
"integer",
"will",
"simply",
"return",
"that",
"integer",
"back",
"."
] | 9bdf3d86578d1a84738cac6eb4127281b75bd669 | https://github.com/sethmlarson/selectors2/blob/9bdf3d86578d1a84738cac6eb4127281b75bd669/selectors2.py#L86-L102 | train | Return a file descriptor from a file object. |
sethmlarson/selectors2 | selectors2.py | DefaultSelector | def DefaultSelector():
""" This function serves as a first call for DefaultSelector to
detect if the select module is being monkey-patched incorrectly
by eventlet, greenlet, and preserve proper behavior. """
global _DEFAULT_SELECTOR
if _DEFAULT_SELECTOR is None:
if platform.python_implementa... | python | def DefaultSelector():
""" This function serves as a first call for DefaultSelector to
detect if the select module is being monkey-patched incorrectly
by eventlet, greenlet, and preserve proper behavior. """
global _DEFAULT_SELECTOR
if _DEFAULT_SELECTOR is None:
if platform.python_implementa... | [
"def",
"DefaultSelector",
"(",
")",
":",
"global",
"_DEFAULT_SELECTOR",
"if",
"_DEFAULT_SELECTOR",
"is",
"None",
":",
"if",
"platform",
".",
"python_implementation",
"(",
")",
"==",
"'Jython'",
":",
"# Platform-specific: Jython",
"_DEFAULT_SELECTOR",
"=",
"JythonSelec... | This function serves as a first call for DefaultSelector to
detect if the select module is being monkey-patched incorrectly
by eventlet, greenlet, and preserve proper behavior. | [
"This",
"function",
"serves",
"as",
"a",
"first",
"call",
"for",
"DefaultSelector",
"to",
"detect",
"if",
"the",
"select",
"module",
"is",
"being",
"monkey",
"-",
"patched",
"incorrectly",
"by",
"eventlet",
"greenlet",
"and",
"preserve",
"proper",
"behavior",
... | 9bdf3d86578d1a84738cac6eb4127281b75bd669 | https://github.com/sethmlarson/selectors2/blob/9bdf3d86578d1a84738cac6eb4127281b75bd669/selectors2.py#L727-L747 | train | This function is used to detect if the select module is monkey - patched incorrectly
by eventlet greenlet. |
sethmlarson/selectors2 | selectors2.py | BaseSelector.unregister | def unregister(self, fileobj):
""" Unregister a file object from being monitored. """
try:
key = self._fd_to_key.pop(self._fileobj_lookup(fileobj))
except KeyError:
raise KeyError("{0!r} is not registered".format(fileobj))
# Getting the fileno of a closed socket ... | python | def unregister(self, fileobj):
""" Unregister a file object from being monitored. """
try:
key = self._fd_to_key.pop(self._fileobj_lookup(fileobj))
except KeyError:
raise KeyError("{0!r} is not registered".format(fileobj))
# Getting the fileno of a closed socket ... | [
"def",
"unregister",
"(",
"self",
",",
"fileobj",
")",
":",
"try",
":",
"key",
"=",
"self",
".",
"_fd_to_key",
".",
"pop",
"(",
"self",
".",
"_fileobj_lookup",
"(",
"fileobj",
")",
")",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"{0!r} is not... | Unregister a file object from being monitored. | [
"Unregister",
"a",
"file",
"object",
"from",
"being",
"monitored",
"."
] | 9bdf3d86578d1a84738cac6eb4127281b75bd669 | https://github.com/sethmlarson/selectors2/blob/9bdf3d86578d1a84738cac6eb4127281b75bd669/selectors2.py#L161-L179 | train | Unregisters a file object from being monitored. |
acutesoftware/AIKIF | aikif/comms.py | CommsManager.add_channel | def add_channel(self, channel, pwd_hash):
"""
adds a channel, but must have authenication
"""
if channel.pwd_hash == pwd_hash:
self.channels.append(channel)
lg.record_process('comms.py', 'Added channel ' + channel.name)
return True
else:
... | python | def add_channel(self, channel, pwd_hash):
"""
adds a channel, but must have authenication
"""
if channel.pwd_hash == pwd_hash:
self.channels.append(channel)
lg.record_process('comms.py', 'Added channel ' + channel.name)
return True
else:
... | [
"def",
"add_channel",
"(",
"self",
",",
"channel",
",",
"pwd_hash",
")",
":",
"if",
"channel",
".",
"pwd_hash",
"==",
"pwd_hash",
":",
"self",
".",
"channels",
".",
"append",
"(",
"channel",
")",
"lg",
".",
"record_process",
"(",
"'comms.py'",
",",
"'Add... | adds a channel, but must have authenication | [
"adds",
"a",
"channel",
"but",
"must",
"have",
"authenication"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L30-L41 | train | Add a channel to the list of channels. |
acutesoftware/AIKIF | aikif/comms.py | CommsManager.delete_channel | def delete_channel(self, channel, pwd_hash):
"""
adds a channel, but must have authenication
"""
if channel.pwd_hash == pwd_hash:
self.channels.remove(channel)
lg.record_process('comms.py', 'Removed channel ' + channel.name)
return True
else:
... | python | def delete_channel(self, channel, pwd_hash):
"""
adds a channel, but must have authenication
"""
if channel.pwd_hash == pwd_hash:
self.channels.remove(channel)
lg.record_process('comms.py', 'Removed channel ' + channel.name)
return True
else:
... | [
"def",
"delete_channel",
"(",
"self",
",",
"channel",
",",
"pwd_hash",
")",
":",
"if",
"channel",
".",
"pwd_hash",
"==",
"pwd_hash",
":",
"self",
".",
"channels",
".",
"remove",
"(",
"channel",
")",
"lg",
".",
"record_process",
"(",
"'comms.py'",
",",
"'... | adds a channel, but must have authenication | [
"adds",
"a",
"channel",
"but",
"must",
"have",
"authenication"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L43-L54 | train | Delete a channel from the list. |
acutesoftware/AIKIF | aikif/comms.py | Message.prepare | def prepare(self):
"""
does some basic validation
"""
try:
assert(type(self.sender) is Channel)
assert(type(self.receiver) is Channel)
return True
except:
return False | python | def prepare(self):
"""
does some basic validation
"""
try:
assert(type(self.sender) is Channel)
assert(type(self.receiver) is Channel)
return True
except:
return False | [
"def",
"prepare",
"(",
"self",
")",
":",
"try",
":",
"assert",
"(",
"type",
"(",
"self",
".",
"sender",
")",
"is",
"Channel",
")",
"assert",
"(",
"type",
"(",
"self",
".",
"receiver",
")",
"is",
"Channel",
")",
"return",
"True",
"except",
":",
"ret... | does some basic validation | [
"does",
"some",
"basic",
"validation"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L97-L106 | train | does some basic validation of the object |
acutesoftware/AIKIF | aikif/comms.py | Message.send | def send(self):
"""
this handles the message transmission
"""
#print('sending message to ' + self.receiver)
if self.prepare():
## TODO - send message via library
print('sending message')
lg.record_process('comms.py', 'Sending message ' + self.t... | python | def send(self):
"""
this handles the message transmission
"""
#print('sending message to ' + self.receiver)
if self.prepare():
## TODO - send message via library
print('sending message')
lg.record_process('comms.py', 'Sending message ' + self.t... | [
"def",
"send",
"(",
"self",
")",
":",
"#print('sending message to ' + self.receiver)",
"if",
"self",
".",
"prepare",
"(",
")",
":",
"## TODO - send message via library",
"print",
"(",
"'sending message'",
")",
"lg",
".",
"record_process",
"(",
"'comms.py'",
",",
"'S... | this handles the message transmission | [
"this",
"handles",
"the",
"message",
"transmission"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/comms.py#L109-L121 | train | sends a message to the receiver |
acutesoftware/AIKIF | aikif/index.py | index | def index():
"""
main function - outputs in following format BEFORE consolidation (which is TODO)
# filename, word, linenumbers
# refAction.csv, ActionTypeName, 1
# refAction.csv, PhysicalType, 1
# goals.csv, Cleanliness, 11
"""
lg = mod_log.Log(mod_cf... | python | def index():
"""
main function - outputs in following format BEFORE consolidation (which is TODO)
# filename, word, linenumbers
# refAction.csv, ActionTypeName, 1
# refAction.csv, PhysicalType, 1
# goals.csv, Cleanliness, 11
"""
lg = mod_log.Log(mod_cf... | [
"def",
"index",
"(",
")",
":",
"lg",
"=",
"mod_log",
".",
"Log",
"(",
"mod_cfg",
".",
"fldrs",
"[",
"'localPath'",
"]",
")",
"lg",
".",
"record_command",
"(",
"'Starting indexing'",
",",
"'index.py'",
")",
"# sys.modules[self.__module__].__file__)",
"if",
"sil... | main function - outputs in following format BEFORE consolidation (which is TODO)
# filename, word, linenumbers
# refAction.csv, ActionTypeName, 1
# refAction.csv, PhysicalType, 1
# goals.csv, Cleanliness, 11 | [
"main",
"function",
"-",
"outputs",
"in",
"following",
"format",
"BEFORE",
"consolidation",
"(",
"which",
"is",
"TODO",
")",
"#",
"filename",
"word",
"linenumbers",
"#",
"refAction",
".",
"csv",
"ActionTypeName",
"1",
"#",
"refAction",
".",
"csv",
"PhysicalTyp... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L26-L58 | train | This function builds the index file for the current language and returns the index file for the current language. |
acutesoftware/AIKIF | aikif/index.py | buildIndex | def buildIndex(ipFile, ndxFile, append='Y', silent='N', useShortFileName='Y'):
"""
this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts.
"""
if silent == 'N':
... | python | def buildIndex(ipFile, ndxFile, append='Y', silent='N', useShortFileName='Y'):
"""
this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts.
"""
if silent == 'N':
... | [
"def",
"buildIndex",
"(",
"ipFile",
",",
"ndxFile",
",",
"append",
"=",
"'Y'",
",",
"silent",
"=",
"'N'",
",",
"useShortFileName",
"=",
"'Y'",
")",
":",
"if",
"silent",
"==",
"'N'",
":",
"pass",
"if",
"append",
"==",
"'N'",
":",
"try",
":",
"os",
"... | this creates an index of a text file specifically for use in AIKIF
separates the ontology descriptions highest followed by values and lastly
a final pass to get all delimited word parts. | [
"this",
"creates",
"an",
"index",
"of",
"a",
"text",
"file",
"specifically",
"for",
"use",
"in",
"AIKIF",
"separates",
"the",
"ontology",
"descriptions",
"highest",
"followed",
"by",
"values",
"and",
"lastly",
"a",
"final",
"pass",
"to",
"get",
"all",
"delim... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L61-L87 | train | This function builds an index of a text file specifically for use in AIKIF. |
acutesoftware/AIKIF | aikif/index.py | format_op_row | def format_op_row(ipFile, totLines, totWords, uniqueWords):
"""
Format the output row with stats
"""
txt = os.path.basename(ipFile).ljust(36) + ' '
txt += str(totLines).rjust(7) + ' '
txt += str(totWords).rjust(7) + ' '
txt += str(len(uniqueWords)).rjust(7) + ' '
return txt | python | def format_op_row(ipFile, totLines, totWords, uniqueWords):
"""
Format the output row with stats
"""
txt = os.path.basename(ipFile).ljust(36) + ' '
txt += str(totLines).rjust(7) + ' '
txt += str(totWords).rjust(7) + ' '
txt += str(len(uniqueWords)).rjust(7) + ' '
return txt | [
"def",
"format_op_row",
"(",
"ipFile",
",",
"totLines",
",",
"totWords",
",",
"uniqueWords",
")",
":",
"txt",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"ipFile",
")",
".",
"ljust",
"(",
"36",
")",
"+",
"' '",
"txt",
"+=",
"str",
"(",
"totLines",
... | Format the output row with stats | [
"Format",
"the",
"output",
"row",
"with",
"stats"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L89-L97 | train | Format the output row with stats
|
acutesoftware/AIKIF | aikif/index.py | format_op_hdr | def format_op_hdr():
"""
Build the header
"""
txt = 'Base Filename'.ljust(36) + ' '
txt += 'Lines'.rjust(7) + ' '
txt += 'Words'.rjust(7) + ' '
txt += 'Unique'.ljust(8) + ''
return txt | python | def format_op_hdr():
"""
Build the header
"""
txt = 'Base Filename'.ljust(36) + ' '
txt += 'Lines'.rjust(7) + ' '
txt += 'Words'.rjust(7) + ' '
txt += 'Unique'.ljust(8) + ''
return txt | [
"def",
"format_op_hdr",
"(",
")",
":",
"txt",
"=",
"'Base Filename'",
".",
"ljust",
"(",
"36",
")",
"+",
"' '",
"txt",
"+=",
"'Lines'",
".",
"rjust",
"(",
"7",
")",
"+",
"' '",
"txt",
"+=",
"'Words'",
".",
"rjust",
"(",
"7",
")",
"+",
"' '",
"tx... | Build the header | [
"Build",
"the",
"header"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L99-L107 | train | Build the header for the operation |
acutesoftware/AIKIF | aikif/index.py | AppendIndexDictionaryToFile | def AppendIndexDictionaryToFile(uniqueWords, ndxFile, ipFile, useShortFileName='Y'):
"""
Save the list of unique words to the master list
"""
if useShortFileName == 'Y':
f = os.path.basename(ipFile)
else:
f = ipFile
with open(ndxFile, "a", encoding='utf-8', errors='replace') as... | python | def AppendIndexDictionaryToFile(uniqueWords, ndxFile, ipFile, useShortFileName='Y'):
"""
Save the list of unique words to the master list
"""
if useShortFileName == 'Y':
f = os.path.basename(ipFile)
else:
f = ipFile
with open(ndxFile, "a", encoding='utf-8', errors='replace') as... | [
"def",
"AppendIndexDictionaryToFile",
"(",
"uniqueWords",
",",
"ndxFile",
",",
"ipFile",
",",
"useShortFileName",
"=",
"'Y'",
")",
":",
"if",
"useShortFileName",
"==",
"'Y'",
":",
"f",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"ipFile",
")",
"else",
":... | Save the list of unique words to the master list | [
"Save",
"the",
"list",
"of",
"unique",
"words",
"to",
"the",
"master",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L110-L127 | train | Append the list of unique words to the master list
|
acutesoftware/AIKIF | aikif/index.py | DisplayIndexAsDictionary | def DisplayIndexAsDictionary(word_occurrences):
"""
print the index as a dict
"""
word_keys = word_occurrences.keys()
for num, word in enumerate(word_keys):
line_nums = word_occurrences[word]
print(word + " ")
if num > 3:
break | python | def DisplayIndexAsDictionary(word_occurrences):
"""
print the index as a dict
"""
word_keys = word_occurrences.keys()
for num, word in enumerate(word_keys):
line_nums = word_occurrences[word]
print(word + " ")
if num > 3:
break | [
"def",
"DisplayIndexAsDictionary",
"(",
"word_occurrences",
")",
":",
"word_keys",
"=",
"word_occurrences",
".",
"keys",
"(",
")",
"for",
"num",
",",
"word",
"in",
"enumerate",
"(",
"word_keys",
")",
":",
"line_nums",
"=",
"word_occurrences",
"[",
"word",
"]",... | print the index as a dict | [
"print",
"the",
"index",
"as",
"a",
"dict"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L129-L138 | train | Display the index as a dictionary. |
acutesoftware/AIKIF | aikif/index.py | show | def show(title, lst, full=-1):
"""
for testing, simply shows a list details
"""
txt = title + ' (' + str(len(lst)) + ') items :\n '
num = 0
for i in lst:
if full == -1 or num < full:
if type(i) is str:
txt = txt + i + ',\n '
else:
t... | python | def show(title, lst, full=-1):
"""
for testing, simply shows a list details
"""
txt = title + ' (' + str(len(lst)) + ') items :\n '
num = 0
for i in lst:
if full == -1 or num < full:
if type(i) is str:
txt = txt + i + ',\n '
else:
t... | [
"def",
"show",
"(",
"title",
",",
"lst",
",",
"full",
"=",
"-",
"1",
")",
":",
"txt",
"=",
"title",
"+",
"' ('",
"+",
"str",
"(",
"len",
"(",
"lst",
")",
")",
"+",
"') items :\\n '",
"num",
"=",
"0",
"for",
"i",
"in",
"lst",
":",
"if",
"full"... | for testing, simply shows a list details | [
"for",
"testing",
"simply",
"shows",
"a",
"list",
"details"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L140-L159 | train | shows a list of items |
acutesoftware/AIKIF | aikif/index.py | getWordList | def getWordList(ipFile, delim):
"""
extract a unique list of words and have line numbers that word appears
"""
indexedWords = {}
totWords = 0
totLines = 0
with codecs.open(ipFile, "r",encoding='utf-8', errors='replace') as f:
for line in f:
totLines = totLines + 1
... | python | def getWordList(ipFile, delim):
"""
extract a unique list of words and have line numbers that word appears
"""
indexedWords = {}
totWords = 0
totLines = 0
with codecs.open(ipFile, "r",encoding='utf-8', errors='replace') as f:
for line in f:
totLines = totLines + 1
... | [
"def",
"getWordList",
"(",
"ipFile",
",",
"delim",
")",
":",
"indexedWords",
"=",
"{",
"}",
"totWords",
"=",
"0",
"totLines",
"=",
"0",
"with",
"codecs",
".",
"open",
"(",
"ipFile",
",",
"\"r\"",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"... | extract a unique list of words and have line numbers that word appears | [
"extract",
"a",
"unique",
"list",
"of",
"words",
"and",
"have",
"line",
"numbers",
"that",
"word",
"appears"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/index.py#L161-L179 | train | extract a unique list of words and have line numbers that word appears
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.