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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
staticdev/django-pagination-bootstrap | pagination_bootstrap/paginator.py | InfinitePaginator.page | def page(self, number):
"""
Returns a Page object for the given 1-based page number.
"""
number = self.validate_number(number)
bottom = (number - 1) * self.per_page
top = bottom + self.per_page
page_items = self.object_list[bottom:top]
# check moved from v... | python | def page(self, number):
"""
Returns a Page object for the given 1-based page number.
"""
number = self.validate_number(number)
bottom = (number - 1) * self.per_page
top = bottom + self.per_page
page_items = self.object_list[bottom:top]
# check moved from v... | [
"def",
"page",
"(",
"self",
",",
"number",
")",
":",
"number",
"=",
"self",
".",
"validate_number",
"(",
"number",
")",
"bottom",
"=",
"(",
"number",
"-",
"1",
")",
"*",
"self",
".",
"per_page",
"top",
"=",
"bottom",
"+",
"self",
".",
"per_page",
"... | Returns a Page object for the given 1-based page number. | [
"Returns",
"a",
"Page",
"object",
"for",
"the",
"given",
"1",
"-",
"based",
"page",
"number",
"."
] | b4bf8352a364b223babbc5f33e14ecabd82c0886 | https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/paginator.py#L39-L53 | train | Returns a Page object for the given 1 - based page number. |
staticdev/django-pagination-bootstrap | pagination_bootstrap/paginator.py | InfinitePage.end_index | def end_index(self):
"""
Returns the 1-based index of the last object on this page,
relative to total objects found (hits).
"""
return ((self.number - 1) * self.paginator.per_page +
len(self.object_list)) | python | def end_index(self):
"""
Returns the 1-based index of the last object on this page,
relative to total objects found (hits).
"""
return ((self.number - 1) * self.paginator.per_page +
len(self.object_list)) | [
"def",
"end_index",
"(",
"self",
")",
":",
"return",
"(",
"(",
"self",
".",
"number",
"-",
"1",
")",
"*",
"self",
".",
"paginator",
".",
"per_page",
"+",
"len",
"(",
"self",
".",
"object_list",
")",
")"
] | Returns the 1-based index of the last object on this page,
relative to total objects found (hits). | [
"Returns",
"the",
"1",
"-",
"based",
"index",
"of",
"the",
"last",
"object",
"on",
"this",
"page",
"relative",
"to",
"total",
"objects",
"found",
"(",
"hits",
")",
"."
] | b4bf8352a364b223babbc5f33e14ecabd82c0886 | https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/paginator.py#L93-L99 | train | Returns the index of the last object on this page relative to total objects found. |
staticdev/django-pagination-bootstrap | pagination_bootstrap/paginator.py | FinitePaginator.page | def page(self, number):
"""
Returns a Page object for the given 1-based page number.
"""
number = self.validate_number(number)
# remove the extra item(s) when creating the page
page_items = self.object_list[:self.per_page]
return FinitePage(page_items, number, sel... | python | def page(self, number):
"""
Returns a Page object for the given 1-based page number.
"""
number = self.validate_number(number)
# remove the extra item(s) when creating the page
page_items = self.object_list[:self.per_page]
return FinitePage(page_items, number, sel... | [
"def",
"page",
"(",
"self",
",",
"number",
")",
":",
"number",
"=",
"self",
".",
"validate_number",
"(",
"number",
")",
"# remove the extra item(s) when creating the page",
"page_items",
"=",
"self",
".",
"object_list",
"[",
":",
"self",
".",
"per_page",
"]",
... | Returns a Page object for the given 1-based page number. | [
"Returns",
"a",
"Page",
"object",
"for",
"the",
"given",
"1",
"-",
"based",
"page",
"number",
"."
] | b4bf8352a364b223babbc5f33e14ecabd82c0886 | https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/paginator.py#L145-L152 | train | Returns a Page object for the given 1 - based page number. |
staticdev/django-pagination-bootstrap | pagination_bootstrap/paginator.py | FinitePage.has_next | def has_next(self):
"""
Checks for one more item than last on this page.
"""
try:
next_item = self.paginator.object_list[self.paginator.per_page]
except IndexError:
return False
return True | python | def has_next(self):
"""
Checks for one more item than last on this page.
"""
try:
next_item = self.paginator.object_list[self.paginator.per_page]
except IndexError:
return False
return True | [
"def",
"has_next",
"(",
"self",
")",
":",
"try",
":",
"next_item",
"=",
"self",
".",
"paginator",
".",
"object_list",
"[",
"self",
".",
"paginator",
".",
"per_page",
"]",
"except",
"IndexError",
":",
"return",
"False",
"return",
"True"
] | Checks for one more item than last on this page. | [
"Checks",
"for",
"one",
"more",
"item",
"than",
"last",
"on",
"this",
"page",
"."
] | b4bf8352a364b223babbc5f33e14ecabd82c0886 | https://github.com/staticdev/django-pagination-bootstrap/blob/b4bf8352a364b223babbc5f33e14ecabd82c0886/pagination_bootstrap/paginator.py#L157-L165 | train | Checks if there is a next item on this page. |
acutesoftware/AIKIF | scripts/examples/puzzle_missions_canninballs.py | parse_miss_cann | def parse_miss_cann(node, m, c):
"""
extracts names from the node to get
counts of miss + cann on both sides
"""
if node[2]:
m1 = node[0]
m2 = m-node[0]
c1 = node[1]
c2 = c-node[1]
else:
m1=m-node[0]
m2=node[0]
c1=c-node[1]
c2=node... | python | def parse_miss_cann(node, m, c):
"""
extracts names from the node to get
counts of miss + cann on both sides
"""
if node[2]:
m1 = node[0]
m2 = m-node[0]
c1 = node[1]
c2 = c-node[1]
else:
m1=m-node[0]
m2=node[0]
c1=c-node[1]
c2=node... | [
"def",
"parse_miss_cann",
"(",
"node",
",",
"m",
",",
"c",
")",
":",
"if",
"node",
"[",
"2",
"]",
":",
"m1",
"=",
"node",
"[",
"0",
"]",
"m2",
"=",
"m",
"-",
"node",
"[",
"0",
"]",
"c1",
"=",
"node",
"[",
"1",
"]",
"c2",
"=",
"c",
"-",
... | extracts names from the node to get
counts of miss + cann on both sides | [
"extracts",
"names",
"from",
"the",
"node",
"to",
"get",
"counts",
"of",
"miss",
"+",
"cann",
"on",
"both",
"sides"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/puzzle_missions_canninballs.py#L167-L183 | train | Parses the miss and cann nodes into the two lists. |
acutesoftware/AIKIF | scripts/examples/puzzle_missions_canninballs.py | pick_next_boat_trip | def pick_next_boat_trip(node, m, c, frontier):
"""
based on current situation, pick who
gets transported next, and return the path
NOTE - improvement here as there are often
duplicate paths or backtracking, e.g.
"""
next_path = []
cur_path = []
boat, mult = boat_on_left_bank(node)
... | python | def pick_next_boat_trip(node, m, c, frontier):
"""
based on current situation, pick who
gets transported next, and return the path
NOTE - improvement here as there are often
duplicate paths or backtracking, e.g.
"""
next_path = []
cur_path = []
boat, mult = boat_on_left_bank(node)
... | [
"def",
"pick_next_boat_trip",
"(",
"node",
",",
"m",
",",
"c",
",",
"frontier",
")",
":",
"next_path",
"=",
"[",
"]",
"cur_path",
"=",
"[",
"]",
"boat",
",",
"mult",
"=",
"boat_on_left_bank",
"(",
"node",
")",
"shore",
"=",
"1",
"-",
"boat",
"m1",
... | based on current situation, pick who
gets transported next, and return the path
NOTE - improvement here as there are often
duplicate paths or backtracking, e.g. | [
"based",
"on",
"current",
"situation",
"pick",
"who",
"gets",
"transported",
"next",
"and",
"return",
"the",
"path",
"NOTE",
"-",
"improvement",
"here",
"as",
"there",
"are",
"often",
"duplicate",
"paths",
"or",
"backtracking",
"e",
".",
"g",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/puzzle_missions_canninballs.py#L185-L223 | train | picks next boat from the frontier and returns the path that is transported next |
acutesoftware/AIKIF | scripts/examples/puzzle_missions_canninballs.py | solve | def solve(m,c):
"""
run the algorithm to find the path list
"""
G={ (m,c,1):[] }
frontier=[ (m,c,1) ] # 1 as boat starts on left bank
while len(frontier) > 0:
hold=list(frontier)
for node in hold:
newnode=[]
frontier.remove(node)
newnode.exte... | python | def solve(m,c):
"""
run the algorithm to find the path list
"""
G={ (m,c,1):[] }
frontier=[ (m,c,1) ] # 1 as boat starts on left bank
while len(frontier) > 0:
hold=list(frontier)
for node in hold:
newnode=[]
frontier.remove(node)
newnode.exte... | [
"def",
"solve",
"(",
"m",
",",
"c",
")",
":",
"G",
"=",
"{",
"(",
"m",
",",
"c",
",",
"1",
")",
":",
"[",
"]",
"}",
"frontier",
"=",
"[",
"(",
"m",
",",
"c",
",",
"1",
")",
"]",
"# 1 as boat starts on left bank ",
"while",
"len",
"(",
"fronti... | run the algorithm to find the path list | [
"run",
"the",
"algorithm",
"to",
"find",
"the",
"path",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/puzzle_missions_canninballs.py#L225-L242 | train | run the algorithm to find the path list of the boat in the tree |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.get_column_list_from_select | def get_column_list_from_select(self, txt, col_delim=','):
"""
takes the list of columns as a string (via SELECT statement in DB)
and produces a lst of columns
"""
return [c.strip().strip(',') for c in txt.split(col_delim)] | python | def get_column_list_from_select(self, txt, col_delim=','):
"""
takes the list of columns as a string (via SELECT statement in DB)
and produces a lst of columns
"""
return [c.strip().strip(',') for c in txt.split(col_delim)] | [
"def",
"get_column_list_from_select",
"(",
"self",
",",
"txt",
",",
"col_delim",
"=",
"','",
")",
":",
"return",
"[",
"c",
".",
"strip",
"(",
")",
".",
"strip",
"(",
"','",
")",
"for",
"c",
"in",
"txt",
".",
"split",
"(",
"col_delim",
")",
"]"
] | takes the list of columns as a string (via SELECT statement in DB)
and produces a lst of columns | [
"takes",
"the",
"list",
"of",
"columns",
"as",
"a",
"string",
"(",
"via",
"SELECT",
"statement",
"in",
"DB",
")",
"and",
"produces",
"a",
"lst",
"of",
"columns"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L53-L58 | train | Takes a list of columns as a string and produces a lst of columns
|
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.create_script_fact | def create_script_fact(self):
"""
appends the CREATE TABLE, index etc to self.ddl_text
"""
self.ddl_text += '---------------------------------------------\n'
self.ddl_text += '-- CREATE Fact Table - ' + self.fact_table + '\n'
self.ddl_text += '----------------------------... | python | def create_script_fact(self):
"""
appends the CREATE TABLE, index etc to self.ddl_text
"""
self.ddl_text += '---------------------------------------------\n'
self.ddl_text += '-- CREATE Fact Table - ' + self.fact_table + '\n'
self.ddl_text += '----------------------------... | [
"def",
"create_script_fact",
"(",
"self",
")",
":",
"self",
".",
"ddl_text",
"+=",
"'---------------------------------------------\\n'",
"self",
".",
"ddl_text",
"+=",
"'-- CREATE Fact Table - '",
"+",
"self",
".",
"fact_table",
"+",
"'\\n'",
"self",
".",
"ddl_text",
... | appends the CREATE TABLE, index etc to self.ddl_text | [
"appends",
"the",
"CREATE",
"TABLE",
"index",
"etc",
"to",
"self",
".",
"ddl_text"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L60-L71 | train | Creates the CREATE TABLE and index tables for the fact table. |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.create_script_staging_table | def create_script_staging_table(self, output_table, col_list):
"""
appends the CREATE TABLE, index etc to another table
"""
self.ddl_text += '---------------------------------------------\n'
self.ddl_text += '-- CREATE Staging Table - ' + output_table + '\n'
self.ddl_text... | python | def create_script_staging_table(self, output_table, col_list):
"""
appends the CREATE TABLE, index etc to another table
"""
self.ddl_text += '---------------------------------------------\n'
self.ddl_text += '-- CREATE Staging Table - ' + output_table + '\n'
self.ddl_text... | [
"def",
"create_script_staging_table",
"(",
"self",
",",
"output_table",
",",
"col_list",
")",
":",
"self",
".",
"ddl_text",
"+=",
"'---------------------------------------------\\n'",
"self",
".",
"ddl_text",
"+=",
"'-- CREATE Staging Table - '",
"+",
"output_table",
"+",... | appends the CREATE TABLE, index etc to another table | [
"appends",
"the",
"CREATE",
"TABLE",
"index",
"etc",
"to",
"another",
"table"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L73-L84 | train | Creates the script staging table. |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.reverse_pivot_to_fact | def reverse_pivot_to_fact(self, staging_table, piv_column, piv_list, from_column, meas_names, meas_values, new_line):
"""
For each column in the piv_list, append ALL from_column's using the group_list
e.g.
Input Table
YEAR Person Q1 Q2
2010 Fre... | python | def reverse_pivot_to_fact(self, staging_table, piv_column, piv_list, from_column, meas_names, meas_values, new_line):
"""
For each column in the piv_list, append ALL from_column's using the group_list
e.g.
Input Table
YEAR Person Q1 Q2
2010 Fre... | [
"def",
"reverse_pivot_to_fact",
"(",
"self",
",",
"staging_table",
",",
"piv_column",
",",
"piv_list",
",",
"from_column",
",",
"meas_names",
",",
"meas_values",
",",
"new_line",
")",
":",
"self",
".",
"sql_text",
"+=",
"'\\n-----------------------------\\n--Reverse P... | For each column in the piv_list, append ALL from_column's using the group_list
e.g.
Input Table
YEAR Person Q1 Q2
2010 Fred Spain 14
2010 Jane Spain 13.995
Output Table
Year Person Question ... | [
"For",
"each",
"column",
"in",
"the",
"piv_list",
"append",
"ALL",
"from_column",
"s",
"using",
"the",
"group_list",
"e",
".",
"g",
".",
"Input",
"Table",
"YEAR",
"Person",
"Q1",
"Q2",
"2010",
"Fred",
"Spain",
"14",
"2010",
"Jane",
"Spain",
"13",
".",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L97-L177 | train | This method is used to reverse the pivot to the fact table. |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.populate_from_staging | def populate_from_staging(self, staging_table, from_column_list, output_table):
"""
generate SQL to insert staging table records into
the core table based on column_list (If no column list
then insert sequentially)
"""
self.sql_text += 'INSERT INTO ' + output_table + ' (... | python | def populate_from_staging(self, staging_table, from_column_list, output_table):
"""
generate SQL to insert staging table records into
the core table based on column_list (If no column list
then insert sequentially)
"""
self.sql_text += 'INSERT INTO ' + output_table + ' (... | [
"def",
"populate_from_staging",
"(",
"self",
",",
"staging_table",
",",
"from_column_list",
",",
"output_table",
")",
":",
"self",
".",
"sql_text",
"+=",
"'INSERT INTO '",
"+",
"output_table",
"+",
"' (\\n'",
"for",
"c",
"in",
"self",
".",
"col_list",
":",
"if... | generate SQL to insert staging table records into
the core table based on column_list (If no column list
then insert sequentially) | [
"generate",
"SQL",
"to",
"insert",
"staging",
"table",
"records",
"into",
"the",
"core",
"table",
"based",
"on",
"column_list",
"(",
"If",
"no",
"column",
"list",
"then",
"insert",
"sequentially",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L181-L197 | train | Populate the internal structure of the object with the records from the staging table. |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.update_old_to_new | def update_old_to_new(self, col, old_val, new_val):
""" simply updates all rows and sets COL to NEW_VAL where col = old_val
e.g. update_old_to_new("NAME", "The University of Adelaide", "University of Adelaide")
will generate
UPDATE table op SET op.NAME = 'University of Adelaide' WHERE op... | python | def update_old_to_new(self, col, old_val, new_val):
""" simply updates all rows and sets COL to NEW_VAL where col = old_val
e.g. update_old_to_new("NAME", "The University of Adelaide", "University of Adelaide")
will generate
UPDATE table op SET op.NAME = 'University of Adelaide' WHERE op... | [
"def",
"update_old_to_new",
"(",
"self",
",",
"col",
",",
"old_val",
",",
"new_val",
")",
":",
"self",
".",
"sql_text",
"+=",
"\"UPDATE \"",
"+",
"self",
".",
"fact_table",
"+",
"\" SET \"",
"+",
"col",
"+",
"\" = '\"",
"+",
"new_val",
"+",
"\"' WHERE \"",... | simply updates all rows and sets COL to NEW_VAL where col = old_val
e.g. update_old_to_new("NAME", "The University of Adelaide", "University of Adelaide")
will generate
UPDATE table op SET op.NAME = 'University of Adelaide' WHERE op.NAME = 'The University of Adelaide'; | [
"simply",
"updates",
"all",
"rows",
"and",
"sets",
"COL",
"to",
"NEW_VAL",
"where",
"col",
"=",
"old_val",
"e",
".",
"g",
".",
"update_old_to_new",
"(",
"NAME",
"The",
"University",
"of",
"Adelaide",
"University",
"of",
"Adelaide",
")",
"will",
"generate",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L211-L217 | train | update all rows and sets COL to NEW_VAL |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.key_to_dimension | def key_to_dimension(self, fact_key, fact_join_col, dimension_name, dimension_join_col, dimension_key):
"""
create SQL to join a fact table key based on "join_col" to a dimension
The fact table is aliased as "op" and the join dimension is aliased as "ip"
meaning you can pass substrings... | python | def key_to_dimension(self, fact_key, fact_join_col, dimension_name, dimension_join_col, dimension_key):
"""
create SQL to join a fact table key based on "join_col" to a dimension
The fact table is aliased as "op" and the join dimension is aliased as "ip"
meaning you can pass substrings... | [
"def",
"key_to_dimension",
"(",
"self",
",",
"fact_key",
",",
"fact_join_col",
",",
"dimension_name",
",",
"dimension_join_col",
",",
"dimension_key",
")",
":",
"self",
".",
"sql_text",
"+=",
"\"UPDATE \"",
"+",
"self",
".",
"fact_table",
"+",
"\" op SET op.\"",
... | create SQL to join a fact table key based on "join_col" to a dimension
The fact table is aliased as "op" and the join dimension is aliased as "ip"
meaning you can pass substrings or SQL to match values.
e.g. the command:
aup.key_to_dimension('GENDER_KEY', 'substr(op.GENDER, 1,1)', 'tbl_... | [
"create",
"SQL",
"to",
"join",
"a",
"fact",
"table",
"key",
"based",
"on",
"join_col",
"to",
"a",
"dimension",
"The",
"fact",
"table",
"is",
"aliased",
"as",
"op",
"and",
"the",
"join",
"dimension",
"is",
"aliased",
"as",
"ip",
"meaning",
"you",
"can",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L226-L242 | train | create SQL to join a fact table with a dimension |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.extract_dimension | def extract_dimension(self, dim_name, dim_cols, dim_key, dim_stag_table, src_table, src_cols, grain_cols, where_clause):
"""
selects the src_cols from src_table and groups by dim_grain
then inserts into newly created table dim_name the columns as 'dim_cols
"""
self.ddl_t... | python | def extract_dimension(self, dim_name, dim_cols, dim_key, dim_stag_table, src_table, src_cols, grain_cols, where_clause):
"""
selects the src_cols from src_table and groups by dim_grain
then inserts into newly created table dim_name the columns as 'dim_cols
"""
self.ddl_t... | [
"def",
"extract_dimension",
"(",
"self",
",",
"dim_name",
",",
"dim_cols",
",",
"dim_key",
",",
"dim_stag_table",
",",
"src_table",
",",
"src_cols",
",",
"grain_cols",
",",
"where_clause",
")",
":",
"self",
".",
"ddl_text",
"+=",
"'--------------------------------... | selects the src_cols from src_table and groups by dim_grain
then inserts into newly created table dim_name the columns as 'dim_cols | [
"selects",
"the",
"src_cols",
"from",
"src_table",
"and",
"groups",
"by",
"dim_grain",
"then",
"inserts",
"into",
"newly",
"created",
"table",
"dim_name",
"the",
"columns",
"as",
"dim_cols"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L244-L309 | train | This function extracts the Dimension from the source table and creates the Dimension table. |
acutesoftware/AIKIF | aikif/dataTools/cls_sql_code_generator.py | SQLCodeGenerator.aggregate | def aggregate(self, opTable, group_by_cols, meas):
"""
Create an aggregate table grouped by col showing meas
The meas is something like "sum(in)" or "count(*)"
RETURNS:
DROP TABLE C_AGG_PRODUCT;
CREATE TABLE C_AGG_PRODUCT AS (
SELECT PRODUCT, sum(... | python | def aggregate(self, opTable, group_by_cols, meas):
"""
Create an aggregate table grouped by col showing meas
The meas is something like "sum(in)" or "count(*)"
RETURNS:
DROP TABLE C_AGG_PRODUCT;
CREATE TABLE C_AGG_PRODUCT AS (
SELECT PRODUCT, sum(... | [
"def",
"aggregate",
"(",
"self",
",",
"opTable",
",",
"group_by_cols",
",",
"meas",
")",
":",
"self",
".",
"sql_text",
"+=",
"\"DROP TABLE \"",
"+",
"opTable",
"+",
"\";\\n\"",
"self",
".",
"sql_text",
"+=",
"\"CREATE TABLE \"",
"+",
"opTable",
"+",
"\" AS (... | Create an aggregate table grouped by col showing meas
The meas is something like "sum(in)" or "count(*)"
RETURNS:
DROP TABLE C_AGG_PRODUCT;
CREATE TABLE C_AGG_PRODUCT AS (
SELECT PRODUCT, sum(AMOUNT) AS result
FROM C_SALES GROUP BY PRODUCT
... | [
"Create",
"an",
"aggregate",
"table",
"grouped",
"by",
"col",
"showing",
"meas",
"The",
"meas",
"is",
"something",
"like",
"sum",
"(",
"in",
")",
"or",
"count",
"(",
"*",
")",
"RETURNS",
":",
"DROP",
"TABLE",
"C_AGG_PRODUCT",
";",
"CREATE",
"TABLE",
"C_A... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/dataTools/cls_sql_code_generator.py#L311-L327 | train | Create an aggregate table grouped by col showing meas |
acutesoftware/AIKIF | scripts/examples/table_compare.py | distinct_values | def distinct_values(t_old, t_new):
"""
for all columns, check which values are not in
the other table
"""
res = []
res.append([' -- NOT IN check -- '])
for new_col in t_new.header:
dist_new = t_new.get_distinct_values_from_cols([new_col])
#print('NEW Distinct values for '... | python | def distinct_values(t_old, t_new):
"""
for all columns, check which values are not in
the other table
"""
res = []
res.append([' -- NOT IN check -- '])
for new_col in t_new.header:
dist_new = t_new.get_distinct_values_from_cols([new_col])
#print('NEW Distinct values for '... | [
"def",
"distinct_values",
"(",
"t_old",
",",
"t_new",
")",
":",
"res",
"=",
"[",
"]",
"res",
".",
"append",
"(",
"[",
"' -- NOT IN check -- '",
"]",
")",
"for",
"new_col",
"in",
"t_new",
".",
"header",
":",
"dist_new",
"=",
"t_new",
".",
"get_distinct_va... | for all columns, check which values are not in
the other table | [
"for",
"all",
"columns",
"check",
"which",
"values",
"are",
"not",
"in",
"the",
"other",
"table"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/table_compare.py#L123-L151 | train | Return a list of distinct values from two tables. |
acutesoftware/AIKIF | aikif/web_app/web_aikif.py | aikif_web_menu | def aikif_web_menu(cur=''):
""" returns the web page header containing standard AIKIF top level web menu """
pgeHdg = ''
pgeBlurb = ''
if cur == '':
cur = 'Home'
txt = get_header(cur) #"<div id=top_menu>"
txt += '<div id = "container">\n'
txt += ' <div id = "header">\n'
txt +=... | python | def aikif_web_menu(cur=''):
""" returns the web page header containing standard AIKIF top level web menu """
pgeHdg = ''
pgeBlurb = ''
if cur == '':
cur = 'Home'
txt = get_header(cur) #"<div id=top_menu>"
txt += '<div id = "container">\n'
txt += ' <div id = "header">\n'
txt +=... | [
"def",
"aikif_web_menu",
"(",
"cur",
"=",
"''",
")",
":",
"pgeHdg",
"=",
"''",
"pgeBlurb",
"=",
"''",
"if",
"cur",
"==",
"''",
":",
"cur",
"=",
"'Home'",
"txt",
"=",
"get_header",
"(",
"cur",
")",
"#\"<div id=top_menu>\"",
"txt",
"+=",
"'<div id = \"cont... | returns the web page header containing standard AIKIF top level web menu | [
"returns",
"the",
"web",
"page",
"header",
"containing",
"standard",
"AIKIF",
"top",
"level",
"web",
"menu"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/web_app/web_aikif.py#L183-L208 | train | returns the web page header containing standard AIKIF top level web menu |
acutesoftware/AIKIF | scripts/res_core_data_NOTES.py | main | def main():
"""
This generates the research document based on the results of
the various programs and includes RST imports for introduction
and summary
"""
print("Generating research notes...")
if os.path.exists(fname):
os.remove(fname)
append_rst('===============================... | python | def main():
"""
This generates the research document based on the results of
the various programs and includes RST imports for introduction
and summary
"""
print("Generating research notes...")
if os.path.exists(fname):
os.remove(fname)
append_rst('===============================... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"\"Generating research notes...\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fname",
")",
":",
"os",
".",
"remove",
"(",
"fname",
")",
"append_rst",
"(",
"'================================================\\n'... | This generates the research document based on the results of
the various programs and includes RST imports for introduction
and summary | [
"This",
"generates",
"the",
"research",
"document",
"based",
"on",
"the",
"results",
"of",
"the",
"various",
"programs",
"and",
"includes",
"RST",
"imports",
"for",
"introduction",
"and",
"summary"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/res_core_data_NOTES.py#L20-L50 | train | This function generates the research document based on the results of the data files and returns the research document |
acutesoftware/AIKIF | aikif/knowledge.py | RawData.find | def find(self, txt):
"""
returns a list of records containing text
"""
result = []
for d in self.data:
if txt in d:
result.append(d)
return result | python | def find(self, txt):
"""
returns a list of records containing text
"""
result = []
for d in self.data:
if txt in d:
result.append(d)
return result | [
"def",
"find",
"(",
"self",
",",
"txt",
")",
":",
"result",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"data",
":",
"if",
"txt",
"in",
"d",
":",
"result",
".",
"append",
"(",
"d",
")",
"return",
"result"
] | returns a list of records containing text | [
"returns",
"a",
"list",
"of",
"records",
"containing",
"text"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/knowledge.py#L56-L64 | train | returns a list of records containing text txt |
Nachtfeuer/pipeline | spline/tools/report/collector.py | CollectorUpdate.schema_complete | def schema_complete():
"""Schema for data in CollectorUpdate."""
return Schema({
'stage': And(str, len),
'timestamp': int,
'status': And(str, lambda s: s in ['started', 'succeeded', 'failed']),
# optional matrix
Optional('matrix', default='defa... | python | def schema_complete():
"""Schema for data in CollectorUpdate."""
return Schema({
'stage': And(str, len),
'timestamp': int,
'status': And(str, lambda s: s in ['started', 'succeeded', 'failed']),
# optional matrix
Optional('matrix', default='defa... | [
"def",
"schema_complete",
"(",
")",
":",
"return",
"Schema",
"(",
"{",
"'stage'",
":",
"And",
"(",
"str",
",",
"len",
")",
",",
"'timestamp'",
":",
"int",
",",
"'status'",
":",
"And",
"(",
"str",
",",
"lambda",
"s",
":",
"s",
"in",
"[",
"'started'"... | Schema for data in CollectorUpdate. | [
"Schema",
"for",
"data",
"in",
"CollectorUpdate",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L56-L68 | train | Schema for data in CollectorUpdate |
Nachtfeuer/pipeline | spline/tools/report/collector.py | CollectorStage.schema_event_items | def schema_event_items():
"""Schema for event items."""
return {
'timestamp': And(int, lambda n: n > 0),
Optional('information', default={}): {
Optional(Regex(r'([a-z][_a-z]*)')): object
}
} | python | def schema_event_items():
"""Schema for event items."""
return {
'timestamp': And(int, lambda n: n > 0),
Optional('information', default={}): {
Optional(Regex(r'([a-z][_a-z]*)')): object
}
} | [
"def",
"schema_event_items",
"(",
")",
":",
"return",
"{",
"'timestamp'",
":",
"And",
"(",
"int",
",",
"lambda",
"n",
":",
"n",
">",
"0",
")",
",",
"Optional",
"(",
"'information'",
",",
"default",
"=",
"{",
"}",
")",
":",
"{",
"Optional",
"(",
"Re... | Schema for event items. | [
"Schema",
"for",
"event",
"items",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L115-L122 | train | Schema for event items. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | CollectorStage.schema_complete | def schema_complete():
"""Schema for data in CollectorStage."""
return Schema({
'stage': And(str, len),
'status': And(str, lambda s: s in ['started', 'succeeded', 'failed']),
Optional('events', default=[]): And(len, [CollectorStage.schema_event_items()])
}) | python | def schema_complete():
"""Schema for data in CollectorStage."""
return Schema({
'stage': And(str, len),
'status': And(str, lambda s: s in ['started', 'succeeded', 'failed']),
Optional('events', default=[]): And(len, [CollectorStage.schema_event_items()])
}) | [
"def",
"schema_complete",
"(",
")",
":",
"return",
"Schema",
"(",
"{",
"'stage'",
":",
"And",
"(",
"str",
",",
"len",
")",
",",
"'status'",
":",
"And",
"(",
"str",
",",
"lambda",
"s",
":",
"s",
"in",
"[",
"'started'",
",",
"'succeeded'",
",",
"'fai... | Schema for data in CollectorStage. | [
"Schema",
"for",
"data",
"in",
"CollectorStage",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L125-L131 | train | Schema for data in CollectorStage. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | CollectorStage.add | def add(self, timestamp, information):
"""
Add event information.
Args:
timestamp (int): event timestamp.
information (dict): event information.
Raises:
RuntimeError: when validation of parameters has failed.
"""
try:
item... | python | def add(self, timestamp, information):
"""
Add event information.
Args:
timestamp (int): event timestamp.
information (dict): event information.
Raises:
RuntimeError: when validation of parameters has failed.
"""
try:
item... | [
"def",
"add",
"(",
"self",
",",
"timestamp",
",",
"information",
")",
":",
"try",
":",
"item",
"=",
"Schema",
"(",
"CollectorStage",
".",
"schema_event_items",
"(",
")",
")",
".",
"validate",
"(",
"{",
"'timestamp'",
":",
"timestamp",
",",
"'information'",... | Add event information.
Args:
timestamp (int): event timestamp.
information (dict): event information.
Raises:
RuntimeError: when validation of parameters has failed. | [
"Add",
"event",
"information",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L152-L170 | train | Add event information. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | CollectorStage.duration | def duration(self):
"""
Calculate how long the stage took.
Returns:
float: (current) duration of the stage
"""
duration = 0.0
if len(self.events) > 0:
first = datetime.fromtimestamp(self.events[0]['timestamp'])
last = datetime.fromtime... | python | def duration(self):
"""
Calculate how long the stage took.
Returns:
float: (current) duration of the stage
"""
duration = 0.0
if len(self.events) > 0:
first = datetime.fromtimestamp(self.events[0]['timestamp'])
last = datetime.fromtime... | [
"def",
"duration",
"(",
"self",
")",
":",
"duration",
"=",
"0.0",
"if",
"len",
"(",
"self",
".",
"events",
")",
">",
"0",
":",
"first",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"events",
"[",
"0",
"]",
"[",
"'timestamp'",
"]",
")",
... | Calculate how long the stage took.
Returns:
float: (current) duration of the stage | [
"Calculate",
"how",
"long",
"the",
"stage",
"took",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L172-L184 | train | Calculate how long the stage took. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | Store.count_stages | def count_stages(self, matrix_name):
"""
Number of registered stages for given matrix name.
Parameters:
matrix_name (str): name of the matrix
Returns:
int: number of reported stages for given matrix name.
"""
return len(self.data[matrix_name]) if... | python | def count_stages(self, matrix_name):
"""
Number of registered stages for given matrix name.
Parameters:
matrix_name (str): name of the matrix
Returns:
int: number of reported stages for given matrix name.
"""
return len(self.data[matrix_name]) if... | [
"def",
"count_stages",
"(",
"self",
",",
"matrix_name",
")",
":",
"return",
"len",
"(",
"self",
".",
"data",
"[",
"matrix_name",
"]",
")",
"if",
"matrix_name",
"in",
"self",
".",
"data",
"else",
"0"
] | Number of registered stages for given matrix name.
Parameters:
matrix_name (str): name of the matrix
Returns:
int: number of reported stages for given matrix name. | [
"Number",
"of",
"registered",
"stages",
"for",
"given",
"matrix",
"name",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L229-L239 | train | Counts the number of stages registered for given matrix name. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | Store.get_stage | def get_stage(self, matrix_name, stage_name):
"""
Get Stage of a concrete matrix.
Attributes:
matrix_name (str): name of the matrix
stage_name (str): name of the stage.
Returns:
CollectorStage: when stage has been found or None.
"""
f... | python | def get_stage(self, matrix_name, stage_name):
"""
Get Stage of a concrete matrix.
Attributes:
matrix_name (str): name of the matrix
stage_name (str): name of the stage.
Returns:
CollectorStage: when stage has been found or None.
"""
f... | [
"def",
"get_stage",
"(",
"self",
",",
"matrix_name",
",",
"stage_name",
")",
":",
"found_stage",
"=",
"None",
"if",
"matrix_name",
"in",
"self",
".",
"data",
":",
"result",
"=",
"Select",
"(",
"self",
".",
"data",
"[",
"matrix_name",
"]",
")",
".",
"wh... | Get Stage of a concrete matrix.
Attributes:
matrix_name (str): name of the matrix
stage_name (str): name of the stage.
Returns:
CollectorStage: when stage has been found or None. | [
"Get",
"Stage",
"of",
"a",
"concrete",
"matrix",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L245-L261 | train | Get the stage of a concrete matrix. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | Store.get_duration | def get_duration(self, matrix_name):
"""
Get duration for a concrete matrix.
Args:
matrix_name (str): name of the Matrix.
Returns:
float: duration of concrete matrix in seconds.
"""
duration = 0.0
if matrix_name in self.data:
... | python | def get_duration(self, matrix_name):
"""
Get duration for a concrete matrix.
Args:
matrix_name (str): name of the Matrix.
Returns:
float: duration of concrete matrix in seconds.
"""
duration = 0.0
if matrix_name in self.data:
... | [
"def",
"get_duration",
"(",
"self",
",",
"matrix_name",
")",
":",
"duration",
"=",
"0.0",
"if",
"matrix_name",
"in",
"self",
".",
"data",
":",
"duration",
"=",
"sum",
"(",
"[",
"stage",
".",
"duration",
"(",
")",
"for",
"stage",
"in",
"self",
".",
"d... | Get duration for a concrete matrix.
Args:
matrix_name (str): name of the Matrix.
Returns:
float: duration of concrete matrix in seconds. | [
"Get",
"duration",
"for",
"a",
"concrete",
"matrix",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L263-L276 | train | Get the duration of a concrete matrix in seconds. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | Store.update | def update(self, item):
"""
Add a collector item.
Args:
item (CollectorUpdate): event data like stage, timestampe and status.
"""
if item.matrix not in self.data:
self.data[item.matrix] = []
result = Select(self.data[item.matrix]).where(
... | python | def update(self, item):
"""
Add a collector item.
Args:
item (CollectorUpdate): event data like stage, timestampe and status.
"""
if item.matrix not in self.data:
self.data[item.matrix] = []
result = Select(self.data[item.matrix]).where(
... | [
"def",
"update",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
".",
"matrix",
"not",
"in",
"self",
".",
"data",
":",
"self",
".",
"data",
"[",
"item",
".",
"matrix",
"]",
"=",
"[",
"]",
"result",
"=",
"Select",
"(",
"self",
".",
"data",
"["... | Add a collector item.
Args:
item (CollectorUpdate): event data like stage, timestampe and status. | [
"Add",
"a",
"collector",
"item",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L278-L298 | train | Add a collector item. |
Nachtfeuer/pipeline | spline/tools/report/collector.py | Collector.run | def run(self):
"""Collector main loop."""
while True:
data = self.queue.get()
if data is None:
Logger.get_logger(__name__).info("Stopping collector process ...")
break
# updating the report data
self.store.update(data)
... | python | def run(self):
"""Collector main loop."""
while True:
data = self.queue.get()
if data is None:
Logger.get_logger(__name__).info("Stopping collector process ...")
break
# updating the report data
self.store.update(data)
... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"True",
":",
"data",
"=",
"self",
".",
"queue",
".",
"get",
"(",
")",
"if",
"data",
"is",
"None",
":",
"Logger",
".",
"get_logger",
"(",
"__name__",
")",
".",
"info",
"(",
"\"Stopping collector process ...\... | Collector main loop. | [
"Collector",
"main",
"loop",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/report/collector.py#L310-L321 | train | Main loop for collector process. |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | display_map | def display_map(fname):
"""
view a text file (map) in high resolution
"""
print("viewing ", fname)
wrld = read_map(fname)
for row in wrld:
#for col in row:
print(row)
app = gui_view_tk(None)
app.add_file(fname)
app.show_grid_from_file(fname)
app.title('Map Vi... | python | def display_map(fname):
"""
view a text file (map) in high resolution
"""
print("viewing ", fname)
wrld = read_map(fname)
for row in wrld:
#for col in row:
print(row)
app = gui_view_tk(None)
app.add_file(fname)
app.show_grid_from_file(fname)
app.title('Map Vi... | [
"def",
"display_map",
"(",
"fname",
")",
":",
"print",
"(",
"\"viewing \"",
",",
"fname",
")",
"wrld",
"=",
"read_map",
"(",
"fname",
")",
"for",
"row",
"in",
"wrld",
":",
"#for col in row:",
"print",
"(",
"row",
")",
"app",
"=",
"gui_view_tk",
"(",
"N... | view a text file (map) in high resolution | [
"view",
"a",
"text",
"file",
"(",
"map",
")",
"in",
"high",
"resolution"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L21-L35 | train | display a text file in high resolution |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | read_map | def read_map(fname):
"""
reads a saved text file to list
"""
lst = []
with open(fname, "r") as f:
for line in f:
lst.append(line)
return lst | python | def read_map(fname):
"""
reads a saved text file to list
"""
lst = []
with open(fname, "r") as f:
for line in f:
lst.append(line)
return lst | [
"def",
"read_map",
"(",
"fname",
")",
":",
"lst",
"=",
"[",
"]",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"lst",
".",
"append",
"(",
"line",
")",
"return",
"lst"
] | reads a saved text file to list | [
"reads",
"a",
"saved",
"text",
"file",
"to",
"list"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L39-L47 | train | reads a saved text file to list of strings |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | gui_view_tk.show_grid_from_file | def show_grid_from_file(self, fname):
"""
reads a saved grid file and paints it on the canvas
"""
with open(fname, "r") as f:
for y, row in enumerate(f):
for x, val in enumerate(row):
self.draw_cell(y, x, val) | python | def show_grid_from_file(self, fname):
"""
reads a saved grid file and paints it on the canvas
"""
with open(fname, "r") as f:
for y, row in enumerate(f):
for x, val in enumerate(row):
self.draw_cell(y, x, val) | [
"def",
"show_grid_from_file",
"(",
"self",
",",
"fname",
")",
":",
"with",
"open",
"(",
"fname",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"y",
",",
"row",
"in",
"enumerate",
"(",
"f",
")",
":",
"for",
"x",
",",
"val",
"in",
"enumerate",
"(",
"ro... | reads a saved grid file and paints it on the canvas | [
"reads",
"a",
"saved",
"grid",
"file",
"and",
"paints",
"it",
"on",
"the",
"canvas"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L98-L105 | train | reads a saved grid file and paints it on the canvas |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | gui_view_tk.draw_cell | def draw_cell(self, row, col, val):
"""
draw a cell as position row, col containing val
"""
if val == 'T':
self.paint_target(row,col)
elif val == '#':
self.paint_block(row,col)
elif val == 'X':
self.paint_hill(row,col)
elif val ... | python | def draw_cell(self, row, col, val):
"""
draw a cell as position row, col containing val
"""
if val == 'T':
self.paint_target(row,col)
elif val == '#':
self.paint_block(row,col)
elif val == 'X':
self.paint_hill(row,col)
elif val ... | [
"def",
"draw_cell",
"(",
"self",
",",
"row",
",",
"col",
",",
"val",
")",
":",
"if",
"val",
"==",
"'T'",
":",
"self",
".",
"paint_target",
"(",
"row",
",",
"col",
")",
"elif",
"val",
"==",
"'#'",
":",
"self",
".",
"paint_block",
"(",
"row",
",",
... | draw a cell as position row, col containing val | [
"draw",
"a",
"cell",
"as",
"position",
"row",
"col",
"containing",
"val"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L108-L123 | train | draw a cell as position row col containing val |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | gui_view_tk.put_standard_block | def put_standard_block(self, y, x, val):
"""
prints a block, packing out around the y/x location
with pixels up to cell width and cell height
"""
for j in range(0,self.cell_height):
for i in range(0,self.cell_width):
self.img.put(val, (x*self.cell_widt... | python | def put_standard_block(self, y, x, val):
"""
prints a block, packing out around the y/x location
with pixels up to cell width and cell height
"""
for j in range(0,self.cell_height):
for i in range(0,self.cell_width):
self.img.put(val, (x*self.cell_widt... | [
"def",
"put_standard_block",
"(",
"self",
",",
"y",
",",
"x",
",",
"val",
")",
":",
"for",
"j",
"in",
"range",
"(",
"0",
",",
"self",
".",
"cell_height",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"cell_width",
")",
":",
"... | prints a block, packing out around the y/x location
with pixels up to cell width and cell height | [
"prints",
"a",
"block",
"packing",
"out",
"around",
"the",
"y",
"/",
"x",
"location",
"with",
"pixels",
"up",
"to",
"cell",
"width",
"and",
"cell",
"height"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L125-L132 | train | Print a standard block of data. |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | gui_view_tk.paint_agent_trail | def paint_agent_trail(self, y, x, val):
"""
paint an agent trail as ONE pixel to allow for multiple agent
trails to be seen in the same cell
"""
for j in range(1,self.cell_height-1):
for i in range(1,self.cell_width-1):
self.img.put(self.agent_color(va... | python | def paint_agent_trail(self, y, x, val):
"""
paint an agent trail as ONE pixel to allow for multiple agent
trails to be seen in the same cell
"""
for j in range(1,self.cell_height-1):
for i in range(1,self.cell_width-1):
self.img.put(self.agent_color(va... | [
"def",
"paint_agent_trail",
"(",
"self",
",",
"y",
",",
"x",
",",
"val",
")",
":",
"for",
"j",
"in",
"range",
"(",
"1",
",",
"self",
".",
"cell_height",
"-",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"cell_width",
"-... | paint an agent trail as ONE pixel to allow for multiple agent
trails to be seen in the same cell | [
"paint",
"an",
"agent",
"trail",
"as",
"ONE",
"pixel",
"to",
"allow",
"for",
"multiple",
"agent",
"trails",
"to",
"be",
"seen",
"in",
"the",
"same",
"cell"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L150-L157 | train | Paint an agent trail as ONE pixel |
acutesoftware/AIKIF | scripts/examples/gui_view_world.py | gui_view_tk.agent_color | def agent_color(self, val):
"""
gets a colour for agent 0 - 9
"""
if val == '0':
colour = 'blue'
elif val == '1':
colour = 'navy'
elif val == '2':
colour = 'firebrick'
elif val == '3':
colour = 'blue'
elif v... | python | def agent_color(self, val):
"""
gets a colour for agent 0 - 9
"""
if val == '0':
colour = 'blue'
elif val == '1':
colour = 'navy'
elif val == '2':
colour = 'firebrick'
elif val == '3':
colour = 'blue'
elif v... | [
"def",
"agent_color",
"(",
"self",
",",
"val",
")",
":",
"if",
"val",
"==",
"'0'",
":",
"colour",
"=",
"'blue'",
"elif",
"val",
"==",
"'1'",
":",
"colour",
"=",
"'navy'",
"elif",
"val",
"==",
"'2'",
":",
"colour",
"=",
"'firebrick'",
"elif",
"val",
... | gets a colour for agent 0 - 9 | [
"gets",
"a",
"colour",
"for",
"agent",
"0",
"-",
"9"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/gui_view_world.py#L167-L194 | train | returns a colour for an agent |
acutesoftware/AIKIF | scripts/examples/happiness_solver.py | create_random_population | def create_random_population(num=100):
"""
create a list of people with randomly generated names and stats
"""
people = []
for _ in range(num):
nme = 'blah'
tax_min = random.randint(1,40)/100
tax_max = tax_min + random.randint(1,40)/100
tradition = random.randint(1,10... | python | def create_random_population(num=100):
"""
create a list of people with randomly generated names and stats
"""
people = []
for _ in range(num):
nme = 'blah'
tax_min = random.randint(1,40)/100
tax_max = tax_min + random.randint(1,40)/100
tradition = random.randint(1,10... | [
"def",
"create_random_population",
"(",
"num",
"=",
"100",
")",
":",
"people",
"=",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"num",
")",
":",
"nme",
"=",
"'blah'",
"tax_min",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"40",
")",
"/",
"100",
"... | create a list of people with randomly generated names and stats | [
"create",
"a",
"list",
"of",
"people",
"with",
"randomly",
"generated",
"names",
"and",
"stats"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/happiness_solver.py#L29-L44 | train | create a list of people with randomly generated names and stats
|
Nachtfeuer/pipeline | spline/pipeline.py | Pipeline.cleanup | def cleanup(self):
"""Run cleanup script of pipeline when hook is configured."""
if self.data.hooks and len(self.data.hooks.cleanup) > 0:
env = self.data.env_list[0].copy()
env.update({'PIPELINE_RESULT': 'SUCCESS', 'PIPELINE_SHELL_EXIT_CODE': '0'})
config = ShellConfi... | python | def cleanup(self):
"""Run cleanup script of pipeline when hook is configured."""
if self.data.hooks and len(self.data.hooks.cleanup) > 0:
env = self.data.env_list[0].copy()
env.update({'PIPELINE_RESULT': 'SUCCESS', 'PIPELINE_SHELL_EXIT_CODE': '0'})
config = ShellConfi... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
".",
"hooks",
"and",
"len",
"(",
"self",
".",
"data",
".",
"hooks",
".",
"cleanup",
")",
">",
"0",
":",
"env",
"=",
"self",
".",
"data",
".",
"env_list",
"[",
"0",
"]",
".",
... | Run cleanup script of pipeline when hook is configured. | [
"Run",
"cleanup",
"script",
"of",
"pipeline",
"when",
"hook",
"is",
"configured",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/pipeline.py#L68-L79 | train | Run cleanup script of pipeline when hook is configured. |
Nachtfeuer/pipeline | spline/pipeline.py | Pipeline.process | def process(self, pipeline):
"""Processing the whole pipeline definition."""
output = []
for entry in pipeline:
key = list(entry.keys())[0]
# an environment block can be repeated
if key == "env":
self.data.env_list[0].update(entry[key])
... | python | def process(self, pipeline):
"""Processing the whole pipeline definition."""
output = []
for entry in pipeline:
key = list(entry.keys())[0]
# an environment block can be repeated
if key == "env":
self.data.env_list[0].update(entry[key])
... | [
"def",
"process",
"(",
"self",
",",
"pipeline",
")",
":",
"output",
"=",
"[",
"]",
"for",
"entry",
"in",
"pipeline",
":",
"key",
"=",
"list",
"(",
"entry",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"# an environment block can be repeated",
"if",
"key"... | Processing the whole pipeline definition. | [
"Processing",
"the",
"whole",
"pipeline",
"definition",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/pipeline.py#L81-L107 | train | Processes the whole pipeline definition. |
masci/django-appengine-toolkit | appengine_toolkit/management/commands/_utils.py | collect_dependency_paths | def collect_dependency_paths(package_name):
"""
TODO docstrings
"""
deps = []
try:
dist = pkg_resources.get_distribution(package_name)
except (pkg_resources.DistributionNotFound, ValueError):
message = "Distribution '{}' not found.".format(package_name)
raise RequirementN... | python | def collect_dependency_paths(package_name):
"""
TODO docstrings
"""
deps = []
try:
dist = pkg_resources.get_distribution(package_name)
except (pkg_resources.DistributionNotFound, ValueError):
message = "Distribution '{}' not found.".format(package_name)
raise RequirementN... | [
"def",
"collect_dependency_paths",
"(",
"package_name",
")",
":",
"deps",
"=",
"[",
"]",
"try",
":",
"dist",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"package_name",
")",
"except",
"(",
"pkg_resources",
".",
"DistributionNotFound",
",",
"ValueError",
... | TODO docstrings | [
"TODO",
"docstrings"
] | 9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2 | https://github.com/masci/django-appengine-toolkit/blob/9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2/appengine_toolkit/management/commands/_utils.py#L10-L34 | train | Collect the paths of all dependencies of a single package. |
masci/django-appengine-toolkit | appengine_toolkit/management/commands/_utils.py | parse_requirements_file | def parse_requirements_file(req_file):
"""
TODO docstrings
"""
lines = []
for line in req_file.readlines():
line = line.strip()
if not line or line.startswith('#'):
continue
lines.append(line)
return lines | python | def parse_requirements_file(req_file):
"""
TODO docstrings
"""
lines = []
for line in req_file.readlines():
line = line.strip()
if not line or line.startswith('#'):
continue
lines.append(line)
return lines | [
"def",
"parse_requirements_file",
"(",
"req_file",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"line",
"in",
"req_file",
".",
"readlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"not",
"line",
"or",
"line",
".",
"startswith",
... | TODO docstrings | [
"TODO",
"docstrings"
] | 9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2 | https://github.com/masci/django-appengine-toolkit/blob/9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2/appengine_toolkit/management/commands/_utils.py#L37-L47 | train | Parse a requirements file into a list of lines. |
masci/django-appengine-toolkit | appengine_toolkit/management/commands/_utils.py | make_simlinks | def make_simlinks(dest_dir, paths_list):
"""
TODO docstrings
"""
for path in paths_list:
dest = os.path.join(dest_dir, os.path.split(path)[-1])
if os.path.exists(dest):
if os.path.islink(dest):
os.remove(dest)
else:
sys.stderr.write... | python | def make_simlinks(dest_dir, paths_list):
"""
TODO docstrings
"""
for path in paths_list:
dest = os.path.join(dest_dir, os.path.split(path)[-1])
if os.path.exists(dest):
if os.path.islink(dest):
os.remove(dest)
else:
sys.stderr.write... | [
"def",
"make_simlinks",
"(",
"dest_dir",
",",
"paths_list",
")",
":",
"for",
"path",
"in",
"paths_list",
":",
"dest",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dest_dir",
",",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"[",
"-",
"1",
"]",
... | TODO docstrings | [
"TODO",
"docstrings"
] | 9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2 | https://github.com/masci/django-appengine-toolkit/blob/9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2/appengine_toolkit/management/commands/_utils.py#L50-L62 | train | Make symlinks to the specified directories. |
acutesoftware/AIKIF | scripts/AI_CLI.py | AICLI.get_command | def get_command(self, mode, txt=''):
"""
Takes a raw user input, initially from command line
Later:
- check user credentials
- rate bias
- check for malicious commands
"""
if mode == 'COMMAND':
self.prompt = '> '
elif mode ... | python | def get_command(self, mode, txt=''):
"""
Takes a raw user input, initially from command line
Later:
- check user credentials
- rate bias
- check for malicious commands
"""
if mode == 'COMMAND':
self.prompt = '> '
elif mode ... | [
"def",
"get_command",
"(",
"self",
",",
"mode",
",",
"txt",
"=",
"''",
")",
":",
"if",
"mode",
"==",
"'COMMAND'",
":",
"self",
".",
"prompt",
"=",
"'> '",
"elif",
"mode",
"==",
"'ADD'",
":",
"self",
".",
"prompt",
"=",
"'ADD > '",
"elif",
"mode",
"... | Takes a raw user input, initially from command line
Later:
- check user credentials
- rate bias
- check for malicious commands | [
"Takes",
"a",
"raw",
"user",
"input",
"initially",
"from",
"command",
"line",
"Later",
":",
"-",
"check",
"user",
"credentials",
"-",
"rate",
"bias",
"-",
"check",
"for",
"malicious",
"commands"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/AI_CLI.py#L31-L47 | train | Get a command from the user |
acutesoftware/AIKIF | scripts/AI_CLI.py | AICLI.show_output | def show_output(self, txt, device='Console'):
"""
Output the data to the current device (usually
screen via print statements but can be file or
network / API
"""
if device == 'Console':
print(txt)
elif device == 'File':
raise ('show_output ... | python | def show_output(self, txt, device='Console'):
"""
Output the data to the current device (usually
screen via print statements but can be file or
network / API
"""
if device == 'Console':
print(txt)
elif device == 'File':
raise ('show_output ... | [
"def",
"show_output",
"(",
"self",
",",
"txt",
",",
"device",
"=",
"'Console'",
")",
":",
"if",
"device",
"==",
"'Console'",
":",
"print",
"(",
"txt",
")",
"elif",
"device",
"==",
"'File'",
":",
"raise",
"(",
"'show_output to File not implemented'",
")",
"... | Output the data to the current device (usually
screen via print statements but can be file or
network / API | [
"Output",
"the",
"data",
"to",
"the",
"current",
"device",
"(",
"usually",
"screen",
"via",
"print",
"statements",
"but",
"can",
"be",
"file",
"or",
"network",
"/",
"API"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/AI_CLI.py#L49-L60 | train | Show the output of the current user. |
acutesoftware/AIKIF | scripts/AI_CLI.py | AICLI.process | def process(self, txt, mode):
"""
Top level function to process the command, mainly
depending on mode.
This should work by using the function name defined
in all_commamnds
"""
result = ''
if mode == 'ADD': # already in add mode, so add data
if... | python | def process(self, txt, mode):
"""
Top level function to process the command, mainly
depending on mode.
This should work by using the function name defined
in all_commamnds
"""
result = ''
if mode == 'ADD': # already in add mode, so add data
if... | [
"def",
"process",
"(",
"self",
",",
"txt",
",",
"mode",
")",
":",
"result",
"=",
"''",
"if",
"mode",
"==",
"'ADD'",
":",
"# already in add mode, so add data",
"if",
"txt",
"in",
"self",
".",
"all_commands",
"[",
"'cmd'",
"]",
"[",
"0",
"]",
":",
"self"... | Top level function to process the command, mainly
depending on mode.
This should work by using the function name defined
in all_commamnds | [
"Top",
"level",
"function",
"to",
"process",
"the",
"command",
"mainly",
"depending",
"on",
"mode",
".",
"This",
"should",
"work",
"by",
"using",
"the",
"function",
"name",
"defined",
"in",
"all_commamnds"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/AI_CLI.py#L62-L110 | train | This function processes the command text and returns the result. |
acutesoftware/AIKIF | scripts/AI_CLI.py | AICLI.cmd_add | def cmd_add(self, txt):
"""
Enter add mode - all text entered now will be
processed as adding information until cancelled
"""
self.show_output('Adding ', txt)
self.raw.add(txt)
print(self.raw)
return 'Added ' + txt | python | def cmd_add(self, txt):
"""
Enter add mode - all text entered now will be
processed as adding information until cancelled
"""
self.show_output('Adding ', txt)
self.raw.add(txt)
print(self.raw)
return 'Added ' + txt | [
"def",
"cmd_add",
"(",
"self",
",",
"txt",
")",
":",
"self",
".",
"show_output",
"(",
"'Adding '",
",",
"txt",
")",
"self",
".",
"raw",
".",
"add",
"(",
"txt",
")",
"print",
"(",
"self",
".",
"raw",
")",
"return",
"'Added '",
"+",
"txt"
] | Enter add mode - all text entered now will be
processed as adding information until cancelled | [
"Enter",
"add",
"mode",
"-",
"all",
"text",
"entered",
"now",
"will",
"be",
"processed",
"as",
"adding",
"information",
"until",
"cancelled"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/AI_CLI.py#L135-L143 | train | Add a new entry to the cache |
acutesoftware/AIKIF | scripts/AI_CLI.py | AICLI.cmd_query | def cmd_query(self, txt):
"""
search and query the AIKIF
"""
self.show_output('Searching for ', txt)
res = self.raw.find(txt)
for d in res:
self.show_output(d)
return str(len(res)) + ' results for ' + txt | python | def cmd_query(self, txt):
"""
search and query the AIKIF
"""
self.show_output('Searching for ', txt)
res = self.raw.find(txt)
for d in res:
self.show_output(d)
return str(len(res)) + ' results for ' + txt | [
"def",
"cmd_query",
"(",
"self",
",",
"txt",
")",
":",
"self",
".",
"show_output",
"(",
"'Searching for '",
",",
"txt",
")",
"res",
"=",
"self",
".",
"raw",
".",
"find",
"(",
"txt",
")",
"for",
"d",
"in",
"res",
":",
"self",
".",
"show_output",
"("... | search and query the AIKIF | [
"search",
"and",
"query",
"the",
"AIKIF"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/AI_CLI.py#L146-L154 | train | search and query the AIKIF object |
znc-sistemas/django-municipios | municipios/utils/ibge.py | convert_shapefile | def convert_shapefile(shapefilename, srid=4674):
"""
shapefilename: considera nomenclatura de shapefile do IBGE para determinar se é UF
ou Municípios.
ex. 55UF2500GC_SIR.shp para UF e 55MU2500GC_SIR.shp para Municípios
srid: 4674 (Projeção SIRGAS 2000)
"""
# /ho... | python | def convert_shapefile(shapefilename, srid=4674):
"""
shapefilename: considera nomenclatura de shapefile do IBGE para determinar se é UF
ou Municípios.
ex. 55UF2500GC_SIR.shp para UF e 55MU2500GC_SIR.shp para Municípios
srid: 4674 (Projeção SIRGAS 2000)
"""
# /ho... | [
"def",
"convert_shapefile",
"(",
"shapefilename",
",",
"srid",
"=",
"4674",
")",
":",
"# /home/nando/Desktop/IBGE/2010/55MU2500GC_SIR.shp",
"ds",
"=",
"DataSource",
"(",
"shapefilename",
")",
"is_uf",
"=",
"shapefilename",
".",
"upper",
"(",
")",
".",
"find",
"(",... | shapefilename: considera nomenclatura de shapefile do IBGE para determinar se é UF
ou Municípios.
ex. 55UF2500GC_SIR.shp para UF e 55MU2500GC_SIR.shp para Municípios
srid: 4674 (Projeção SIRGAS 2000) | [
"shapefilename",
":",
"considera",
"nomenclatura",
"de",
"shapefile",
"do",
"IBGE",
"para",
"determinar",
"se",
"é",
"UF",
"ou",
"Municípios",
".",
"ex",
".",
"55UF2500GC_SIR",
".",
"shp",
"para",
"UF",
"e",
"55MU2500GC_SIR",
".",
"shp",
"para",
"Municípios",
... | bdaf56315af7e1db4e0005a241e9fd95271a7ce1 | https://github.com/znc-sistemas/django-municipios/blob/bdaf56315af7e1db4e0005a241e9fd95271a7ce1/municipios/utils/ibge.py#L54-L120 | train | Convert a shapefile to a base class |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.verify_integrity | def verify_integrity(self):
"""Verifies that all required functions been injected."""
if not self.__integrity_check:
if not self.__appid:
raise Exception('U2F_APPID was not defined! Please define it in configuration file.')
if self.__facets_enabled and not len(se... | python | def verify_integrity(self):
"""Verifies that all required functions been injected."""
if not self.__integrity_check:
if not self.__appid:
raise Exception('U2F_APPID was not defined! Please define it in configuration file.')
if self.__facets_enabled and not len(se... | [
"def",
"verify_integrity",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__integrity_check",
":",
"if",
"not",
"self",
".",
"__appid",
":",
"raise",
"Exception",
"(",
"'U2F_APPID was not defined! Please define it in configuration file.'",
")",
"if",
"self",
".",... | Verifies that all required functions been injected. | [
"Verifies",
"that",
"all",
"required",
"functions",
"been",
"injected",
"."
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L132-L163 | train | Verifies that all required functions have been injected. |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.enroll | def enroll(self):
"""Enrollment function"""
self.verify_integrity()
if session.get('u2f_enroll_authorized', False):
if request.method == 'GET':
return jsonify(self.get_enroll()), 200
elif request.method == 'POST':
response = self.verify_e... | python | def enroll(self):
"""Enrollment function"""
self.verify_integrity()
if session.get('u2f_enroll_authorized', False):
if request.method == 'GET':
return jsonify(self.get_enroll()), 200
elif request.method == 'POST':
response = self.verify_e... | [
"def",
"enroll",
"(",
"self",
")",
":",
"self",
".",
"verify_integrity",
"(",
")",
"if",
"session",
".",
"get",
"(",
"'u2f_enroll_authorized'",
",",
"False",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"return",
"jsonify",
"(",
"self",
... | Enrollment function | [
"Enrollment",
"function"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L166-L182 | train | Enrollment function |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.sign | def sign(self):
"""Signature function"""
self.verify_integrity()
if session.get('u2f_sign_required', False):
if request.method == 'GET':
response = self.get_signature_challenge()
if response['status'] == 'ok':
return jsoni... | python | def sign(self):
"""Signature function"""
self.verify_integrity()
if session.get('u2f_sign_required', False):
if request.method == 'GET':
response = self.get_signature_challenge()
if response['status'] == 'ok':
return jsoni... | [
"def",
"sign",
"(",
"self",
")",
":",
"self",
".",
"verify_integrity",
"(",
")",
"if",
"session",
".",
"get",
"(",
"'u2f_sign_required'",
",",
"False",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"response",
"=",
"self",
".",
"get_sig... | Signature function | [
"Signature",
"function"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L184-L205 | train | Signs the user with the current user |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.devices | def devices(self):
"""Manages users enrolled u2f devices"""
self.verify_integrity()
if session.get('u2f_device_management_authorized', False):
if request.method == 'GET':
return jsonify(self.get_devices()), 200
elif request.method == 'DELETE':
... | python | def devices(self):
"""Manages users enrolled u2f devices"""
self.verify_integrity()
if session.get('u2f_device_management_authorized', False):
if request.method == 'GET':
return jsonify(self.get_devices()), 200
elif request.method == 'DELETE':
... | [
"def",
"devices",
"(",
"self",
")",
":",
"self",
".",
"verify_integrity",
"(",
")",
"if",
"session",
".",
"get",
"(",
"'u2f_device_management_authorized'",
",",
"False",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
":",
"return",
"jsonify",
"("... | Manages users enrolled u2f devices | [
"Manages",
"users",
"enrolled",
"u2f",
"devices"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L208-L224 | train | Manages users enrolled u2f devices |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.facets | def facets(self):
"""Provides facets support. REQUIRES VALID HTTPS!"""
self.verify_integrity()
if self.__facets_enabled:
data = json.dumps({
'trustedFacets' : [{
'version': { 'major': 1, 'minor' : 0 },
'ids': self.__facets_list... | python | def facets(self):
"""Provides facets support. REQUIRES VALID HTTPS!"""
self.verify_integrity()
if self.__facets_enabled:
data = json.dumps({
'trustedFacets' : [{
'version': { 'major': 1, 'minor' : 0 },
'ids': self.__facets_list... | [
"def",
"facets",
"(",
"self",
")",
":",
"self",
".",
"verify_integrity",
"(",
")",
"if",
"self",
".",
"__facets_enabled",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'trustedFacets'",
":",
"[",
"{",
"'version'",
":",
"{",
"'major'",
":",
"1",
... | Provides facets support. REQUIRES VALID HTTPS! | [
"Provides",
"facets",
"support",
".",
"REQUIRES",
"VALID",
"HTTPS!"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L226-L243 | train | Provides facets support. REQUIRES VALID HTTPS! |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.get_enroll | def get_enroll(self):
"""Returns new enroll seed"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
enroll = start_register(self.__appid, devices)
enroll['status'] = 'ok'
session['_u2f_enroll_'] = enroll.json
return enroll | python | def get_enroll(self):
"""Returns new enroll seed"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
enroll = start_register(self.__appid, devices)
enroll['status'] = 'ok'
session['_u2f_enroll_'] = enroll.json
return enroll | [
"def",
"get_enroll",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"DeviceRegistration",
".",
"wrap",
"(",
"device",
")",
"for",
"device",
"in",
"self",
".",
"__get_u2f_devices",
"(",
")",
"]",
"enroll",
"=",
"start_register",
"(",
"self",
".",
"__appid",
... | Returns new enroll seed | [
"Returns",
"new",
"enroll",
"seed"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L247-L255 | train | Returns new enroll seed |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.verify_enroll | def verify_enroll(self, response):
"""Verifies and saves U2F enroll"""
seed = session.pop('_u2f_enroll_')
try:
new_device, cert = complete_register(seed, response, self.__facets_list)
except Exception as e:
if self.__call_fail_enroll:
self.__call_... | python | def verify_enroll(self, response):
"""Verifies and saves U2F enroll"""
seed = session.pop('_u2f_enroll_')
try:
new_device, cert = complete_register(seed, response, self.__facets_list)
except Exception as e:
if self.__call_fail_enroll:
self.__call_... | [
"def",
"verify_enroll",
"(",
"self",
",",
"response",
")",
":",
"seed",
"=",
"session",
".",
"pop",
"(",
"'_u2f_enroll_'",
")",
"try",
":",
"new_device",
",",
"cert",
"=",
"complete_register",
"(",
"seed",
",",
"response",
",",
"self",
".",
"__facets_list"... | Verifies and saves U2F enroll | [
"Verifies",
"and",
"saves",
"U2F",
"enroll"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L257-L293 | train | Verifies and saves U2F enroll |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.get_signature_challenge | def get_signature_challenge(self):
"""Returns new signature challenge"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
if devices == []:
return {
'status' : 'failed',
'error' : 'No devices been associated with t... | python | def get_signature_challenge(self):
"""Returns new signature challenge"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
if devices == []:
return {
'status' : 'failed',
'error' : 'No devices been associated with t... | [
"def",
"get_signature_challenge",
"(",
"self",
")",
":",
"devices",
"=",
"[",
"DeviceRegistration",
".",
"wrap",
"(",
"device",
")",
"for",
"device",
"in",
"self",
".",
"__get_u2f_devices",
"(",
")",
"]",
"if",
"devices",
"==",
"[",
"]",
":",
"return",
"... | Returns new signature challenge | [
"Returns",
"new",
"signature",
"challenge"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L296-L312 | train | Returns new signature challenge |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.verify_signature | def verify_signature(self, signature):
"""Verifies signature"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
challenge = session.pop('_u2f_challenge_')
try:
counter, touch = verify_authenticate(devices, challenge, signature, self.__fa... | python | def verify_signature(self, signature):
"""Verifies signature"""
devices = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
challenge = session.pop('_u2f_challenge_')
try:
counter, touch = verify_authenticate(devices, challenge, signature, self.__fa... | [
"def",
"verify_signature",
"(",
"self",
",",
"signature",
")",
":",
"devices",
"=",
"[",
"DeviceRegistration",
".",
"wrap",
"(",
"device",
")",
"for",
"device",
"in",
"self",
".",
"__get_u2f_devices",
"(",
")",
"]",
"challenge",
"=",
"session",
".",
"pop",... | Verifies signature | [
"Verifies",
"signature"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L314-L351 | train | Verifies the signature of the current user s current user s current user s current user. |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.remove_device | def remove_device(self, request):
"""Removes device specified by id"""
devices = self.__get_u2f_devices()
for i in range(len(devices)):
if devices[i]['keyHandle'] == request['id']:
del devices[i]
self.__save_u2f_devices(devices)
... | python | def remove_device(self, request):
"""Removes device specified by id"""
devices = self.__get_u2f_devices()
for i in range(len(devices)):
if devices[i]['keyHandle'] == request['id']:
del devices[i]
self.__save_u2f_devices(devices)
... | [
"def",
"remove_device",
"(",
"self",
",",
"request",
")",
":",
"devices",
"=",
"self",
".",
"__get_u2f_devices",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"devices",
")",
")",
":",
"if",
"devices",
"[",
"i",
"]",
"[",
"'keyHandle'",
"]",
... | Removes device specified by id | [
"Removes",
"device",
"specified",
"by",
"id"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L367-L385 | train | Removes a device from the list of available U2F devices. |
herrjemand/flask-fido-u2f | flask_fido_u2f.py | U2F.verify_counter | def verify_counter(self, signature, counter):
""" Verifies that counter value is greater than previous signature"""
devices = self.__get_u2f_devices()
for device in devices:
# Searching for specific keyhandle
if device['keyHandle'] == signature['keyHandle']:
... | python | def verify_counter(self, signature, counter):
""" Verifies that counter value is greater than previous signature"""
devices = self.__get_u2f_devices()
for device in devices:
# Searching for specific keyhandle
if device['keyHandle'] == signature['keyHandle']:
... | [
"def",
"verify_counter",
"(",
"self",
",",
"signature",
",",
"counter",
")",
":",
"devices",
"=",
"self",
".",
"__get_u2f_devices",
"(",
")",
"for",
"device",
"in",
"devices",
":",
"# Searching for specific keyhandle",
"if",
"device",
"[",
"'keyHandle'",
"]",
... | Verifies that counter value is greater than previous signature | [
"Verifies",
"that",
"counter",
"value",
"is",
"greater",
"than",
"previous",
"signature"
] | 23acac4cfe285a33411e8a6bf980b3c345b04feb | https://github.com/herrjemand/flask-fido-u2f/blob/23acac4cfe285a33411e8a6bf980b3c345b04feb/flask_fido_u2f.py#L393-L409 | train | Verifies that the given counter value is greater than previous signature. |
Nachtfeuer/pipeline | spline/validation.py | Validator.validate | def validate(data):
"""
Validate data against the schema.
Args:
data(dict): data structure to validate.
Returns:
dict: data as provided and defaults where defined in schema.
"""
try:
return Schema(Validator.SCHEMA).validate(data)
... | python | def validate(data):
"""
Validate data against the schema.
Args:
data(dict): data structure to validate.
Returns:
dict: data as provided and defaults where defined in schema.
"""
try:
return Schema(Validator.SCHEMA).validate(data)
... | [
"def",
"validate",
"(",
"data",
")",
":",
"try",
":",
"return",
"Schema",
"(",
"Validator",
".",
"SCHEMA",
")",
".",
"validate",
"(",
"data",
")",
"except",
"SchemaError",
"as",
"exception",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
... | Validate data against the schema.
Args:
data(dict): data structure to validate.
Returns:
dict: data as provided and defaults where defined in schema. | [
"Validate",
"data",
"against",
"the",
"schema",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/validation.py#L159-L173 | train | Validate data against the schema. |
Nachtfeuer/pipeline | spline/tools/loader.py | Loader.include | def include(self, node):
"""Include the defined yaml file."""
result = None
if isinstance(node, ScalarNode):
result = Loader.include_file(self.construct_scalar(node))
else:
raise RuntimeError("Not supported !include on type %s" % type(node))
return result | python | def include(self, node):
"""Include the defined yaml file."""
result = None
if isinstance(node, ScalarNode):
result = Loader.include_file(self.construct_scalar(node))
else:
raise RuntimeError("Not supported !include on type %s" % type(node))
return result | [
"def",
"include",
"(",
"self",
",",
"node",
")",
":",
"result",
"=",
"None",
"if",
"isinstance",
"(",
"node",
",",
"ScalarNode",
")",
":",
"result",
"=",
"Loader",
".",
"include_file",
"(",
"self",
".",
"construct_scalar",
"(",
"node",
")",
")",
"else"... | Include the defined yaml file. | [
"Include",
"the",
"defined",
"yaml",
"file",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loader.py#L32-L39 | train | Include the defined yaml file. |
Nachtfeuer/pipeline | spline/tools/loader.py | Loader.include_file | def include_file(filename):
"""Load another yaml file (no recursion)."""
if os.path.isfile(filename):
with open(filename) as handle:
return safe_load(handle)
raise RuntimeError("Include file %s doesn't exist!" % filename) | python | def include_file(filename):
"""Load another yaml file (no recursion)."""
if os.path.isfile(filename):
with open(filename) as handle:
return safe_load(handle)
raise RuntimeError("Include file %s doesn't exist!" % filename) | [
"def",
"include_file",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"handle",
":",
"return",
"safe_load",
"(",
"handle",
")",
"raise",
"RuntimeError",
"(",
"\"... | Load another yaml file (no recursion). | [
"Load",
"another",
"yaml",
"file",
"(",
"no",
"recursion",
")",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loader.py#L42-L47 | train | Load another yaml file ( no recursion ). |
Nachtfeuer/pipeline | spline/tools/loader.py | Loader.load | def load(filename):
""""Load yaml file with specific include loader."""
if os.path.isfile(filename):
with open(filename) as handle:
return yaml_load(handle, Loader=Loader) # nosec
raise RuntimeError("File %s doesn't exist!" % filename) | python | def load(filename):
""""Load yaml file with specific include loader."""
if os.path.isfile(filename):
with open(filename) as handle:
return yaml_load(handle, Loader=Loader) # nosec
raise RuntimeError("File %s doesn't exist!" % filename) | [
"def",
"load",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"handle",
":",
"return",
"yaml_load",
"(",
"handle",
",",
"Loader",
"=",
"Loader",
")",
"# nosec"... | Load yaml file with specific include loader. | [
"Load",
"yaml",
"file",
"with",
"specific",
"include",
"loader",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loader.py#L50-L55 | train | Load yaml file with specific include loader. |
acutesoftware/AIKIF | scripts/examples/AIKIF_project/AIKIF_project.py | main | def main():
"""
This is an example of project documentation using AIKIF
It documents the project itself, including requirements,
design, test, goals,
"""
print('Initialising AIKIF Project...')
name = 'AIKIF'
type = 'Software'
desc = """
Artificial Intelligence Knowledge I... | python | def main():
"""
This is an example of project documentation using AIKIF
It documents the project itself, including requirements,
design, test, goals,
"""
print('Initialising AIKIF Project...')
name = 'AIKIF'
type = 'Software'
desc = """
Artificial Intelligence Knowledge I... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"'Initialising AIKIF Project...'",
")",
"name",
"=",
"'AIKIF'",
"type",
"=",
"'Software'",
"desc",
"=",
"\"\"\"\n Artificial Intelligence Knowledge Information Framework - Project Overview\n \n This document was autogenerate... | This is an example of project documentation using AIKIF
It documents the project itself, including requirements,
design, test, goals, | [
"This",
"is",
"an",
"example",
"of",
"project",
"documentation",
"using",
"AIKIF",
"It",
"documents",
"the",
"project",
"itself",
"including",
"requirements",
"design",
"test",
"goals"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/AIKIF_project/AIKIF_project.py#L7-L63 | train | This is the main function for the AIKIF project. It documents the AIKIF project and creates the project and returns the AIKIF project object. |
acutesoftware/AIKIF | aikif/transpose.py | Transpose.pivot | def pivot(self):
"""
transposes rows and columns
"""
self.op_data = [list(i) for i in zip(*self.ip_data)] | python | def pivot(self):
"""
transposes rows and columns
"""
self.op_data = [list(i) for i in zip(*self.ip_data)] | [
"def",
"pivot",
"(",
"self",
")",
":",
"self",
".",
"op_data",
"=",
"[",
"list",
"(",
"i",
")",
"for",
"i",
"in",
"zip",
"(",
"*",
"self",
".",
"ip_data",
")",
"]"
] | transposes rows and columns | [
"transposes",
"rows",
"and",
"columns"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/transpose.py#L20-L24 | train | transposes rows and columns and columns of the record set |
acutesoftware/AIKIF | aikif/transpose.py | Transpose.key_value_pairs | def key_value_pairs(self):
"""
convert list to key value pairs
This should also create unique id's to allow for any
dataset to be transposed, and then later manipulated
r1c1,r1c2,r1c3
r2c1,r2c2,r2c3
should be converted to
ID COLNUM VAL... | python | def key_value_pairs(self):
"""
convert list to key value pairs
This should also create unique id's to allow for any
dataset to be transposed, and then later manipulated
r1c1,r1c2,r1c3
r2c1,r2c2,r2c3
should be converted to
ID COLNUM VAL... | [
"def",
"key_value_pairs",
"(",
"self",
")",
":",
"self",
".",
"op_data",
"=",
"[",
"]",
"hdrs",
"=",
"self",
".",
"ip_data",
"[",
"0",
"]",
"for",
"row",
"in",
"self",
".",
"ip_data",
"[",
"1",
":",
"]",
":",
"id_col",
"=",
"row",
"[",
"0",
"]"... | convert list to key value pairs
This should also create unique id's to allow for any
dataset to be transposed, and then later manipulated
r1c1,r1c2,r1c3
r2c1,r2c2,r2c3
should be converted to
ID COLNUM VAL
r1c1, | [
"convert",
"list",
"to",
"key",
"value",
"pairs",
"This",
"should",
"also",
"create",
"unique",
"id",
"s",
"to",
"allow",
"for",
"any",
"dataset",
"to",
"be",
"transposed",
"and",
"then",
"later",
"manipulated",
"r1c1",
"r1c2",
"r1c3",
"r2c1",
"r2c2",
"r2c... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/transpose.py#L26-L44 | train | convert list to key value pairs |
acutesoftware/AIKIF | aikif/transpose.py | Transpose.data_to_links | def data_to_links(self, id_col_num, link_col_num, include_links_self='Y'):
"""
This takes a table of data conaining a person identifier (Name or ID)
and returns a table showing all links based on a common column
Ip table Links by Location Links by Job
NAME Lo... | python | def data_to_links(self, id_col_num, link_col_num, include_links_self='Y'):
"""
This takes a table of data conaining a person identifier (Name or ID)
and returns a table showing all links based on a common column
Ip table Links by Location Links by Job
NAME Lo... | [
"def",
"data_to_links",
"(",
"self",
",",
"id_col_num",
",",
"link_col_num",
",",
"include_links_self",
"=",
"'Y'",
")",
":",
"res",
"=",
"[",
"]",
"# construct the header - can be done in 1 line, but clarified",
"hdr_col_name",
"=",
"'Cat_name'",
"hdr_col_val",
"=",
... | This takes a table of data conaining a person identifier (Name or ID)
and returns a table showing all links based on a common column
Ip table Links by Location Links by Job
NAME Location Job
John Perth Plumber Location,Perth,John,Fred Job,Farmer,Mary,Jane
... | [
"This",
"takes",
"a",
"table",
"of",
"data",
"conaining",
"a",
"person",
"identifier",
"(",
"Name",
"or",
"ID",
")",
"and",
"returns",
"a",
"table",
"showing",
"all",
"links",
"based",
"on",
"a",
"common",
"column",
"Ip",
"table",
"Links",
"by",
"Locatio... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/transpose.py#L47-L91 | train | This function takes a table of data conaining a person identifier and a common column containing a person identifier and a common column containing a person identifier and a common column containing a person identifier and a common column containing a person identifier. The data is sorted by the number of links in the ... |
acutesoftware/AIKIF | aikif/transpose.py | Transpose.links_to_data | def links_to_data(self, col_name_col_num, col_val_col_num, id_a_col_num, id_b_col_num):
"""
This is the reverse of data_to_links and takes a links table and
generates a data table as follows
Input Table Output Table
Cat_Name,CAT_val,Person_a,person_b NAM... | python | def links_to_data(self, col_name_col_num, col_val_col_num, id_a_col_num, id_b_col_num):
"""
This is the reverse of data_to_links and takes a links table and
generates a data table as follows
Input Table Output Table
Cat_Name,CAT_val,Person_a,person_b NAM... | [
"def",
"links_to_data",
"(",
"self",
",",
"col_name_col_num",
",",
"col_val_col_num",
",",
"id_a_col_num",
",",
"id_b_col_num",
")",
":",
"print",
"(",
"'Converting links to data'",
")",
"self",
".",
"op_data",
"unique_ids",
"=",
"[",
"]",
"unique_vals",
"=",
"[... | This is the reverse of data_to_links and takes a links table and
generates a data table as follows
Input Table Output Table
Cat_Name,CAT_val,Person_a,person_b NAME,Location
Location,Perth,John,Fred John,Perth
Location,Perth,John,Cindy ... | [
"This",
"is",
"the",
"reverse",
"of",
"data_to_links",
"and",
"takes",
"a",
"links",
"table",
"and",
"generates",
"a",
"data",
"table",
"as",
"follows",
"Input",
"Table",
"Output",
"Table",
"Cat_Name",
"CAT_val",
"Person_a",
"person_b",
"NAME",
"Location",
"Lo... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/transpose.py#L94-L129 | train | This function converts the input table to the output table and generates the data table that contains the links. |
acutesoftware/AIKIF | aikif/lib/cls_goal_friendly.py | GoalFriendly.find_best_plan | def find_best_plan(self):
"""
try each strategy with different amounts
"""
for plan in self.plans:
for strat in self.strategy:
self.run_plan(plan, strat) | python | def find_best_plan(self):
"""
try each strategy with different amounts
"""
for plan in self.plans:
for strat in self.strategy:
self.run_plan(plan, strat) | [
"def",
"find_best_plan",
"(",
"self",
")",
":",
"for",
"plan",
"in",
"self",
".",
"plans",
":",
"for",
"strat",
"in",
"self",
".",
"strategy",
":",
"self",
".",
"run_plan",
"(",
"plan",
",",
"strat",
")"
] | try each strategy with different amounts | [
"try",
"each",
"strategy",
"with",
"different",
"amounts"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/lib/cls_goal_friendly.py#L37-L43 | train | find the best plan for the current strategy |
acutesoftware/AIKIF | aikif/ontology/read_opencyc.py | load_data | def load_data(fname):
""" loads previously exported CSV file to redis database """
print('Loading ' + fname + ' to redis')
r = redis.StrictRedis(host = '127.0.0.1', port = 6379, db = 0);
with open(fname, 'r') as f:
for line_num, row in enumerate(f):
if row.strip('') != '':
... | python | def load_data(fname):
""" loads previously exported CSV file to redis database """
print('Loading ' + fname + ' to redis')
r = redis.StrictRedis(host = '127.0.0.1', port = 6379, db = 0);
with open(fname, 'r') as f:
for line_num, row in enumerate(f):
if row.strip('') != '':
... | [
"def",
"load_data",
"(",
"fname",
")",
":",
"print",
"(",
"'Loading '",
"+",
"fname",
"+",
"' to redis'",
")",
"r",
"=",
"redis",
".",
"StrictRedis",
"(",
"host",
"=",
"'127.0.0.1'",
",",
"port",
"=",
"6379",
",",
"db",
"=",
"0",
")",
"with",
"open",... | loads previously exported CSV file to redis database | [
"loads",
"previously",
"exported",
"CSV",
"file",
"to",
"redis",
"database"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/read_opencyc.py#L28-L40 | train | loads previously exported CSV file to redis database |
acutesoftware/AIKIF | aikif/ontology/read_opencyc.py | parse_n3 | def parse_n3(row, src='csv'):
"""
takes a row from an n3 file and returns the triple
NOTE - currently parses a CSV line already split via
cyc_extract.py
"""
if row.strip() == '':
return '',''
l_root = 'opencyc'
key = ''
val = ''
if src == 'csv':
cols = row.split... | python | def parse_n3(row, src='csv'):
"""
takes a row from an n3 file and returns the triple
NOTE - currently parses a CSV line already split via
cyc_extract.py
"""
if row.strip() == '':
return '',''
l_root = 'opencyc'
key = ''
val = ''
if src == 'csv':
cols = row.split... | [
"def",
"parse_n3",
"(",
"row",
",",
"src",
"=",
"'csv'",
")",
":",
"if",
"row",
".",
"strip",
"(",
")",
"==",
"''",
":",
"return",
"''",
",",
"''",
"l_root",
"=",
"'opencyc'",
"key",
"=",
"''",
"val",
"=",
"''",
"if",
"src",
"==",
"'csv'",
":",... | takes a row from an n3 file and returns the triple
NOTE - currently parses a CSV line already split via
cyc_extract.py | [
"takes",
"a",
"row",
"from",
"an",
"n3",
"file",
"and",
"returns",
"the",
"triple",
"NOTE",
"-",
"currently",
"parses",
"a",
"CSV",
"line",
"already",
"split",
"via",
"cyc_extract",
".",
"py"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/read_opencyc.py#L42-L67 | train | Parses a row from an n3 file and returns the triple containing the key and value |
acutesoftware/AIKIF | aikif/ontology/read_opencyc.py | summarise_file_as_html | def summarise_file_as_html(fname):
"""
takes a large data file and produces a HTML summary as html
"""
txt = '<H1>' + fname + '</H1>'
num_lines = 0
print('Reading OpenCyc file - ', fname)
with open(ip_folder + os.sep + fname, 'r') as f:
txt += '<PRE>'
for line in f:
... | python | def summarise_file_as_html(fname):
"""
takes a large data file and produces a HTML summary as html
"""
txt = '<H1>' + fname + '</H1>'
num_lines = 0
print('Reading OpenCyc file - ', fname)
with open(ip_folder + os.sep + fname, 'r') as f:
txt += '<PRE>'
for line in f:
... | [
"def",
"summarise_file_as_html",
"(",
"fname",
")",
":",
"txt",
"=",
"'<H1>'",
"+",
"fname",
"+",
"'</H1>'",
"num_lines",
"=",
"0",
"print",
"(",
"'Reading OpenCyc file - '",
",",
"fname",
")",
"with",
"open",
"(",
"ip_folder",
"+",
"os",
".",
"sep",
"+",
... | takes a large data file and produces a HTML summary as html | [
"takes",
"a",
"large",
"data",
"file",
"and",
"produces",
"a",
"HTML",
"summary",
"as",
"html"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/ontology/read_opencyc.py#L88-L105 | train | Takes a large data file and produces a HTML summary as html
|
acutesoftware/AIKIF | scripts/examples/game_of_life_console.py | main | def main():
"""
Example to show AIKIF logging of results.
Generates a sequence of random grids and runs the
Game of Life, saving results
"""
iterations = 9 # how many simulations to run
years = 3 # how many times to run each simulation
width = 22 # grid height
... | python | def main():
"""
Example to show AIKIF logging of results.
Generates a sequence of random grids and runs the
Game of Life, saving results
"""
iterations = 9 # how many simulations to run
years = 3 # how many times to run each simulation
width = 22 # grid height
... | [
"def",
"main",
"(",
")",
":",
"iterations",
"=",
"9",
"# how many simulations to run",
"years",
"=",
"3",
"# how many times to run each simulation",
"width",
"=",
"22",
"# grid height",
"height",
"=",
"78",
"# grid width",
"time_delay",
"=",
"0.03",
"# delay when prin... | Example to show AIKIF logging of results.
Generates a sequence of random grids and runs the
Game of Life, saving results | [
"Example",
"to",
"show",
"AIKIF",
"logging",
"of",
"results",
".",
"Generates",
"a",
"sequence",
"of",
"random",
"grids",
"and",
"runs",
"the",
"Game",
"of",
"Life",
"saving",
"results"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/game_of_life_console.py#L28-L43 | train | This function is used to run the game of life. |
acutesoftware/AIKIF | scripts/examples/game_of_life_console.py | run_game_of_life | def run_game_of_life(years, width, height, time_delay, silent="N"):
"""
run a single game of life for 'years' and log start and
end living cells to aikif
"""
lfe = mod_grid.GameOfLife(width, height, ['.', 'x'], 1)
set_random_starting_grid(lfe)
lg.record_source(lfe, 'game_of_life_console.py'... | python | def run_game_of_life(years, width, height, time_delay, silent="N"):
"""
run a single game of life for 'years' and log start and
end living cells to aikif
"""
lfe = mod_grid.GameOfLife(width, height, ['.', 'x'], 1)
set_random_starting_grid(lfe)
lg.record_source(lfe, 'game_of_life_console.py'... | [
"def",
"run_game_of_life",
"(",
"years",
",",
"width",
",",
"height",
",",
"time_delay",
",",
"silent",
"=",
"\"N\"",
")",
":",
"lfe",
"=",
"mod_grid",
".",
"GameOfLife",
"(",
"width",
",",
"height",
",",
"[",
"'.'",
",",
"'x'",
"]",
",",
"1",
")",
... | run a single game of life for 'years' and log start and
end living cells to aikif | [
"run",
"a",
"single",
"game",
"of",
"life",
"for",
"years",
"and",
"log",
"start",
"and",
"end",
"living",
"cells",
"to",
"aikif"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/game_of_life_console.py#L45-L62 | train | run a single game of life for years and log start and end living cells to aikif
|
acutesoftware/AIKIF | scripts/examples/game_of_life_console.py | set_random_starting_grid | def set_random_starting_grid(lfe):
"""
generate a random grid for game of life using a
set of patterns (just to make it interesting)
"""
cls_patterns = mod_grid.GameOfLifePatterns(25)
print(cls_patterns)
exit(0)
patterns = cls_patterns.get_patterns()
for pattern in patterns:
... | python | def set_random_starting_grid(lfe):
"""
generate a random grid for game of life using a
set of patterns (just to make it interesting)
"""
cls_patterns = mod_grid.GameOfLifePatterns(25)
print(cls_patterns)
exit(0)
patterns = cls_patterns.get_patterns()
for pattern in patterns:
... | [
"def",
"set_random_starting_grid",
"(",
"lfe",
")",
":",
"cls_patterns",
"=",
"mod_grid",
".",
"GameOfLifePatterns",
"(",
"25",
")",
"print",
"(",
"cls_patterns",
")",
"exit",
"(",
"0",
")",
"patterns",
"=",
"cls_patterns",
".",
"get_patterns",
"(",
")",
"fo... | generate a random grid for game of life using a
set of patterns (just to make it interesting) | [
"generate",
"a",
"random",
"grid",
"for",
"game",
"of",
"life",
"using",
"a",
"set",
"of",
"patterns",
"(",
"just",
"to",
"make",
"it",
"interesting",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/game_of_life_console.py#L65-L76 | train | generate a random starting grid for game of life |
acutesoftware/AIKIF | scripts/examples/game_of_life_console.py | print_there | def print_there(x, y, text):
""""
allows display of a game of life on a console via
resetting cursor position to a set point - looks 'ok'
for testing but not production quality.
"""
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
sys.stdout.flush() | python | def print_there(x, y, text):
""""
allows display of a game of life on a console via
resetting cursor position to a set point - looks 'ok'
for testing but not production quality.
"""
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
sys.stdout.flush() | [
"def",
"print_there",
"(",
"x",
",",
"y",
",",
"text",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\x1b7\\x1b[%d;%df%s\\x1b8\"",
"%",
"(",
"x",
",",
"y",
",",
"text",
")",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | allows display of a game of life on a console via
resetting cursor position to a set point - looks 'ok'
for testing but not production quality. | [
"allows",
"display",
"of",
"a",
"game",
"of",
"life",
"on",
"a",
"console",
"via",
"resetting",
"cursor",
"position",
"to",
"a",
"set",
"point",
"-",
"looks",
"ok",
"for",
"testing",
"but",
"not",
"production",
"quality",
"."
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/game_of_life_console.py#L79-L86 | train | Print text at x y. |
acutesoftware/AIKIF | aikif/toolbox/text_tools.py | parse_text_to_table | def parse_text_to_table(txt):
"""
takes a blob of text and finds delimiter OR guesses
the column positions to parse into a table.
input: txt = blob of text, lines separated by \n
output: res = table of text
"""
res = [] # resulting table
delim = identify_delim(txt)
print('txt to pars... | python | def parse_text_to_table(txt):
"""
takes a blob of text and finds delimiter OR guesses
the column positions to parse into a table.
input: txt = blob of text, lines separated by \n
output: res = table of text
"""
res = [] # resulting table
delim = identify_delim(txt)
print('txt to pars... | [
"def",
"parse_text_to_table",
"(",
"txt",
")",
":",
"res",
"=",
"[",
"]",
"# resulting table\r",
"delim",
"=",
"identify_delim",
"(",
"txt",
")",
"print",
"(",
"'txt to parse = '",
",",
"txt",
",",
"'\\ndelim='",
",",
"delim",
")",
"if",
"delim",
"==",
"''... | takes a blob of text and finds delimiter OR guesses
the column positions to parse into a table.
input: txt = blob of text, lines separated by \n
output: res = table of text | [
"takes",
"a",
"blob",
"of",
"text",
"and",
"finds",
"delimiter",
"OR",
"guesses",
"the",
"column",
"positions",
"to",
"parse",
"into",
"a",
"table",
".",
"input",
":",
"txt",
"=",
"blob",
"of",
"text",
"lines",
"separated",
"by",
"\\",
"n",
"output",
"... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/text_tools.py#L5-L25 | train | Parse a text file into a table. |
acutesoftware/AIKIF | aikif/toolbox/text_tools.py | identify_col_pos | def identify_col_pos(txt):
"""
assume no delimiter in this file, so guess the best
fixed column widths to split by
"""
res = []
#res.append(0)
lines = txt.split('\n')
prev_ch = ''
for col_pos, ch in enumerate(lines[0]):
if _is_white_space(ch) is False and _is_white_space(prev_ch) is True:
res.a... | python | def identify_col_pos(txt):
"""
assume no delimiter in this file, so guess the best
fixed column widths to split by
"""
res = []
#res.append(0)
lines = txt.split('\n')
prev_ch = ''
for col_pos, ch in enumerate(lines[0]):
if _is_white_space(ch) is False and _is_white_space(prev_ch) is True:
res.a... | [
"def",
"identify_col_pos",
"(",
"txt",
")",
":",
"res",
"=",
"[",
"]",
"#res.append(0)\r",
"lines",
"=",
"txt",
".",
"split",
"(",
"'\\n'",
")",
"prev_ch",
"=",
"''",
"for",
"col_pos",
",",
"ch",
"in",
"enumerate",
"(",
"lines",
"[",
"0",
"]",
")",
... | assume no delimiter in this file, so guess the best
fixed column widths to split by | [
"assume",
"no",
"delimiter",
"in",
"this",
"file",
"so",
"guess",
"the",
"best",
"fixed",
"column",
"widths",
"to",
"split",
"by"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/text_tools.py#L27-L41 | train | Identify the column position in a string. |
acutesoftware/AIKIF | aikif/toolbox/text_tools.py | _get_dict_char_count | def _get_dict_char_count(txt):
"""
reads the characters in txt and returns a dictionary
of all letters
"""
dct = {}
for letter in txt:
if letter in dct:
dct[letter] += 1
else:
dct[letter] = 1
return dct | python | def _get_dict_char_count(txt):
"""
reads the characters in txt and returns a dictionary
of all letters
"""
dct = {}
for letter in txt:
if letter in dct:
dct[letter] += 1
else:
dct[letter] = 1
return dct | [
"def",
"_get_dict_char_count",
"(",
"txt",
")",
":",
"dct",
"=",
"{",
"}",
"for",
"letter",
"in",
"txt",
":",
"if",
"letter",
"in",
"dct",
":",
"dct",
"[",
"letter",
"]",
"+=",
"1",
"else",
":",
"dct",
"[",
"letter",
"]",
"=",
"1",
"return",
"dct... | reads the characters in txt and returns a dictionary
of all letters | [
"reads",
"the",
"characters",
"in",
"txt",
"and",
"returns",
"a",
"dictionary",
"of",
"all",
"letters"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/text_tools.py#L100-L111 | train | Returns a dictionary with the number of characters in txt. |
acutesoftware/AIKIF | aikif/toolbox/text_tools.py | identify_delim | def identify_delim(txt):
"""
identifies delimiters and returns a count by ROW
in the text file as well as the delimiter value (if any)
The delim is determined if the count of delims is consistant
in all rows.
"""
possible_delims = _get_dict_char_count(txt) # {'C': 3, 'a': 4, 'b': 5, 'c': 6, ',': 6, 'A': ... | python | def identify_delim(txt):
"""
identifies delimiters and returns a count by ROW
in the text file as well as the delimiter value (if any)
The delim is determined if the count of delims is consistant
in all rows.
"""
possible_delims = _get_dict_char_count(txt) # {'C': 3, 'a': 4, 'b': 5, 'c': 6, ',': 6, 'A': ... | [
"def",
"identify_delim",
"(",
"txt",
")",
":",
"possible_delims",
"=",
"_get_dict_char_count",
"(",
"txt",
")",
"# {'C': 3, 'a': 4, 'b': 5, 'c': 6, ',': 6, 'A': 3, '\\n': 3, 'B': 3})\r",
"delim",
"=",
"max",
"(",
"possible_delims",
".",
"keys",
"(",
")",
",",
"key",
"... | identifies delimiters and returns a count by ROW
in the text file as well as the delimiter value (if any)
The delim is determined if the count of delims is consistant
in all rows. | [
"identifies",
"delimiters",
"and",
"returns",
"a",
"count",
"by",
"ROW",
"in",
"the",
"text",
"file",
"as",
"well",
"as",
"the",
"delimiter",
"value",
"(",
"if",
"any",
")",
"The",
"delim",
"is",
"determined",
"if",
"the",
"count",
"of",
"delims",
"is",
... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/text_tools.py#L114-L146 | train | Identify the delimiter in a text file and return a count by ROW and the delimiter value. |
acutesoftware/AIKIF | aikif/toolbox/text_tools.py | fingerprint | def fingerprint(txt):
"""
takes a string and truncates to standard form for data matching.
Based on the spec at OpenRefine
https://github.com/OpenRefine/OpenRefine/wiki/Clustering-In-Depth#fingerprint
- remove leading and trailing whitespace
- change all characters to their lowercase representation
- remo... | python | def fingerprint(txt):
"""
takes a string and truncates to standard form for data matching.
Based on the spec at OpenRefine
https://github.com/OpenRefine/OpenRefine/wiki/Clustering-In-Depth#fingerprint
- remove leading and trailing whitespace
- change all characters to their lowercase representation
- remo... | [
"def",
"fingerprint",
"(",
"txt",
")",
":",
"raw_text",
"=",
"txt",
".",
"upper",
"(",
")",
"#.strip(' ').replace('\\n','')\r",
"tokens",
"=",
"sorted",
"(",
"list",
"(",
"set",
"(",
"raw_text",
".",
"split",
"(",
"' '",
")",
")",
")",
")",
"#print('toke... | takes a string and truncates to standard form for data matching.
Based on the spec at OpenRefine
https://github.com/OpenRefine/OpenRefine/wiki/Clustering-In-Depth#fingerprint
- remove leading and trailing whitespace
- change all characters to their lowercase representation
- remove all punctuation and control... | [
"takes",
"a",
"string",
"and",
"truncates",
"to",
"standard",
"form",
"for",
"data",
"matching",
".",
"Based",
"on",
"the",
"spec",
"at",
"OpenRefine",
"https",
":",
"//",
"github",
".",
"com",
"/",
"OpenRefine",
"/",
"OpenRefine",
"/",
"wiki",
"/",
"Clu... | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/text_tools.py#L148-L167 | train | Returns a fingerprint of the string txt |
Nachtfeuer/pipeline | spline/components/docker.py | Container.update_environment_variables | def update_environment_variables(self, filename):
"""Updating OS environment variables and current script path and filename."""
self.env.update({'PIPELINE_BASH_FILE_ORIGINAL': filename})
filename = os.path.join('/root/scripts', os.path.basename(filename))
self.env.update({'PIPELINE_BASH_... | python | def update_environment_variables(self, filename):
"""Updating OS environment variables and current script path and filename."""
self.env.update({'PIPELINE_BASH_FILE_ORIGINAL': filename})
filename = os.path.join('/root/scripts', os.path.basename(filename))
self.env.update({'PIPELINE_BASH_... | [
"def",
"update_environment_variables",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"env",
".",
"update",
"(",
"{",
"'PIPELINE_BASH_FILE_ORIGINAL'",
":",
"filename",
"}",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'/root/scripts'",
"... | 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/docker.py#L37-L48 | train | Updates OS environment variables and current script path and filename. |
Nachtfeuer/pipeline | spline/components/docker.py | Container.creator | def creator(entry, config):
"""Creator function for creating an instance of a Bash."""
template_file = os.path.join(os.path.dirname(__file__), 'templates/docker-container.sh.j2')
with open(template_file) as handle:
template = handle.read()
# all fields are re-rendered vi... | python | def creator(entry, config):
"""Creator function for creating an instance of a Bash."""
template_file = os.path.join(os.path.dirname(__file__), 'templates/docker-container.sh.j2')
with open(template_file) as handle:
template = handle.read()
# all fields are re-rendered vi... | [
"def",
"creator",
"(",
"entry",
",",
"config",
")",
":",
"template_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'templates/docker-container.sh.j2'",
")",
"with",
"open",
"(",
"template_file... | Creator function for creating an instance of a Bash. | [
"Creator",
"function",
"for",
"creating",
"an",
"instance",
"of",
"a",
"Bash",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/docker.py#L51-L70 | train | Creator function for creating an instance of a Bash. |
Nachtfeuer/pipeline | spline/components/docker.py | Image.creator | def creator(entry, config):
"""Creator function for creating an instance of a Docker image script."""
# writing Dockerfile
dockerfile = render(config.script, model=config.model, env=config.env,
variables=config.variables, item=config.item)
filename = "dockerfi... | python | def creator(entry, config):
"""Creator function for creating an instance of a Docker image script."""
# writing Dockerfile
dockerfile = render(config.script, model=config.model, env=config.env,
variables=config.variables, item=config.item)
filename = "dockerfi... | [
"def",
"creator",
"(",
"entry",
",",
"config",
")",
":",
"# writing Dockerfile",
"dockerfile",
"=",
"render",
"(",
"config",
".",
"script",
",",
"model",
"=",
"config",
".",
"model",
",",
"env",
"=",
"config",
".",
"env",
",",
"variables",
"=",
"config",... | Creator function for creating an instance of a Docker image script. | [
"Creator",
"function",
"for",
"creating",
"an",
"instance",
"of",
"a",
"Docker",
"image",
"script",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/components/docker.py#L85-L111 | train | Creator function for creating an instance of a Docker image script. |
acutesoftware/AIKIF | aikif/environments/environment.py | Environment.create | def create(self, num):
"""
Creates the environment
in your subclassed create function include the line below
super().build(arg1, arg2, arg2, ...)
"""
self.log.record_process('enviroment.py', 'Creating ' + str(num) + ' environments - ' + self.name) | python | def create(self, num):
"""
Creates the environment
in your subclassed create function include the line below
super().build(arg1, arg2, arg2, ...)
"""
self.log.record_process('enviroment.py', 'Creating ' + str(num) + ' environments - ' + self.name) | [
"def",
"create",
"(",
"self",
",",
"num",
")",
":",
"self",
".",
"log",
".",
"record_process",
"(",
"'enviroment.py'",
",",
"'Creating '",
"+",
"str",
"(",
"num",
")",
"+",
"' environments - '",
"+",
"self",
".",
"name",
")"
] | Creates the environment
in your subclassed create function include the line below
super().build(arg1, arg2, arg2, ...) | [
"Creates",
"the",
"environment",
"in",
"your",
"subclassed",
"create",
"function",
"include",
"the",
"line",
"below",
"super",
"()",
".",
"build",
"(",
"arg1",
"arg2",
"arg2",
"...",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/environment.py#L40-L46 | train | Creates the environment with the given number of environments. |
Nachtfeuer/pipeline | spline/tools/stream.py | stdout_redirector | def stdout_redirector():
"""
Simplify redirect of stdout.
Taken from here: https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
"""
old_stdout = sys.stdout
sys.stdout = Stream()
try:
yield sys.stdout
finally:
sys.stdout.close()
sys.stdout... | python | def stdout_redirector():
"""
Simplify redirect of stdout.
Taken from here: https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/
"""
old_stdout = sys.stdout
sys.stdout = Stream()
try:
yield sys.stdout
finally:
sys.stdout.close()
sys.stdout... | [
"def",
"stdout_redirector",
"(",
")",
":",
"old_stdout",
"=",
"sys",
".",
"stdout",
"sys",
".",
"stdout",
"=",
"Stream",
"(",
")",
"try",
":",
"yield",
"sys",
".",
"stdout",
"finally",
":",
"sys",
".",
"stdout",
".",
"close",
"(",
")",
"sys",
".",
... | Simplify redirect of stdout.
Taken from here: https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/ | [
"Simplify",
"redirect",
"of",
"stdout",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/stream.py#L34-L46 | train | A context manager that redirects stdout to the next available log entry. |
Nachtfeuer/pipeline | spline/tools/stream.py | write_temporary_file | def write_temporary_file(content, prefix='', suffix=''):
"""
Generating a temporary file with content.
Args:
content (str): file content (usually a script, Dockerfile, playbook or config file)
prefix (str): the filename starts with this prefix (default: no prefix)
suffix (str): the ... | python | def write_temporary_file(content, prefix='', suffix=''):
"""
Generating a temporary file with content.
Args:
content (str): file content (usually a script, Dockerfile, playbook or config file)
prefix (str): the filename starts with this prefix (default: no prefix)
suffix (str): the ... | [
"def",
"write_temporary_file",
"(",
"content",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"prefix",
"=",
"prefix",
",",
"suffix",
"=",
"suffix",
",",
"mode",
"=",
"'w+t'",
",",
... | Generating a temporary file with content.
Args:
content (str): file content (usually a script, Dockerfile, playbook or config file)
prefix (str): the filename starts with this prefix (default: no prefix)
suffix (str): the filename ends with this suffix (default: no suffix)
Returns:
... | [
"Generating",
"a",
"temporary",
"file",
"with",
"content",
"."
] | 04ca18c4e95e4349532bb45b768206393e1f2c13 | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/stream.py#L49-L67 | train | Generates a temporary file with content. |
aartur/mschematool | mschematool/cli.py | print_new | def print_new(ctx, name, migration_type):
"""Prints filename of a new migration"""
click.echo(ctx.obj.repository.generate_migration_name(name, migration_type)) | python | def print_new(ctx, name, migration_type):
"""Prints filename of a new migration"""
click.echo(ctx.obj.repository.generate_migration_name(name, migration_type)) | [
"def",
"print_new",
"(",
"ctx",
",",
"name",
",",
"migration_type",
")",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"obj",
".",
"repository",
".",
"generate_migration_name",
"(",
"name",
",",
"migration_type",
")",
")"
] | Prints filename of a new migration | [
"Prints",
"filename",
"of",
"a",
"new",
"migration"
] | 57ec9541f80b44890294126eab92ce243c8833c4 | https://github.com/aartur/mschematool/blob/57ec9541f80b44890294126eab92ce243c8833c4/mschematool/cli.py#L81-L83 | train | Prints a new migration |
acutesoftware/AIKIF | aikif/agents/agent.py | Agent._log_agent_name | def _log_agent_name(self, unique_name_file):
"""
logs the agent details to logfile
unique_name_file (list_agents.txtlist_agents_names.txt) = list of all instances of all agents
"""
agt_list = os.path.join(root_fldr, 'data', unique_name_file)
if os.path.exists(agt_list):
... | python | def _log_agent_name(self, unique_name_file):
"""
logs the agent details to logfile
unique_name_file (list_agents.txtlist_agents_names.txt) = list of all instances of all agents
"""
agt_list = os.path.join(root_fldr, 'data', unique_name_file)
if os.path.exists(agt_list):
... | [
"def",
"_log_agent_name",
"(",
"self",
",",
"unique_name_file",
")",
":",
"agt_list",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_fldr",
",",
"'data'",
",",
"unique_name_file",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"agt_list",
")",
":",
... | logs the agent details to logfile
unique_name_file (list_agents.txtlist_agents_names.txt) = list of all instances of all agents | [
"logs",
"the",
"agent",
"details",
"to",
"logfile",
"unique_name_file",
"(",
"list_agents",
".",
"txtlist_agents_names",
".",
"txt",
")",
"=",
"list",
"of",
"all",
"instances",
"of",
"all",
"agents"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent.py#L80-L93 | train | Logs the agent name to logfile
|
acutesoftware/AIKIF | aikif/agents/agent.py | Agent.start | def start(self):
"""
Starts an agent with standard logging
"""
self.running = True
self.status = 'RUNNING'
self.mylog.record_process('agent', self.name + ' - starting') | python | def start(self):
"""
Starts an agent with standard logging
"""
self.running = True
self.status = 'RUNNING'
self.mylog.record_process('agent', self.name + ' - starting') | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"running",
"=",
"True",
"self",
".",
"status",
"=",
"'RUNNING'",
"self",
".",
"mylog",
".",
"record_process",
"(",
"'agent'",
",",
"self",
".",
"name",
"+",
"' - starting'",
")"
] | Starts an agent with standard logging | [
"Starts",
"an",
"agent",
"with",
"standard",
"logging"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent.py#L96-L102 | train | Starts an agent with standard logging |
acutesoftware/AIKIF | aikif/agents/agent.py | Agent.set_coords | def set_coords(self, x=0, y=0, z=0, t=0):
"""
set coords of agent in an arbitrary world
"""
self.coords = {}
self.coords['x'] = x
self.coords['y'] = y
self.coords['z'] = z
self.coords['t'] = t | python | def set_coords(self, x=0, y=0, z=0, t=0):
"""
set coords of agent in an arbitrary world
"""
self.coords = {}
self.coords['x'] = x
self.coords['y'] = y
self.coords['z'] = z
self.coords['t'] = t | [
"def",
"set_coords",
"(",
"self",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"z",
"=",
"0",
",",
"t",
"=",
"0",
")",
":",
"self",
".",
"coords",
"=",
"{",
"}",
"self",
".",
"coords",
"[",
"'x'",
"]",
"=",
"x",
"self",
".",
"coords",
"["... | set coords of agent in an arbitrary world | [
"set",
"coords",
"of",
"agent",
"in",
"an",
"arbitrary",
"world"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent.py#L104-L112 | train | set coords of agent in an arbitrary world |
OpenHydrology/floodestimation | floodestimation/loaders.py | from_file | def from_file(file_path, incl_pot=True):
"""
Load catchment object from a ``.CD3`` or ``.xml`` file.
If there is also a corresponding ``.AM`` file (annual maximum flow data) or
a ``.PT`` file (peaks over threshold data) in the same folder as the CD3 file, these datasets will also be loaded.
:param... | python | def from_file(file_path, incl_pot=True):
"""
Load catchment object from a ``.CD3`` or ``.xml`` file.
If there is also a corresponding ``.AM`` file (annual maximum flow data) or
a ``.PT`` file (peaks over threshold data) in the same folder as the CD3 file, these datasets will also be loaded.
:param... | [
"def",
"from_file",
"(",
"file_path",
",",
"incl_pot",
"=",
"True",
")",
":",
"filename",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_path",
")",
"am_file_path",
"=",
"filename",
"+",
"'.AM'",
"pot_file_path",
"=",
"filename",
"+",
"'... | Load catchment object from a ``.CD3`` or ``.xml`` file.
If there is also a corresponding ``.AM`` file (annual maximum flow data) or
a ``.PT`` file (peaks over threshold data) in the same folder as the CD3 file, these datasets will also be loaded.
:param file_path: Location of CD3 or xml file
:type fil... | [
"Load",
"catchment",
"object",
"from",
"a",
".",
"CD3",
"or",
".",
"xml",
"file",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L30-L66 | train | Loads a catchment from a. CD3 or. xml file. |
OpenHydrology/floodestimation | floodestimation/loaders.py | to_db | def to_db(catchment, session, method='create', autocommit=False):
"""
Load catchment object into the database.
A catchment/station number (:attr:`catchment.id`) must be provided. If :attr:`method` is set to `update`, any
existing catchment in the database with the same catchment number will be updated.... | python | def to_db(catchment, session, method='create', autocommit=False):
"""
Load catchment object into the database.
A catchment/station number (:attr:`catchment.id`) must be provided. If :attr:`method` is set to `update`, any
existing catchment in the database with the same catchment number will be updated.... | [
"def",
"to_db",
"(",
"catchment",
",",
"session",
",",
"method",
"=",
"'create'",
",",
"autocommit",
"=",
"False",
")",
":",
"if",
"not",
"catchment",
".",
"id",
":",
"raise",
"ValueError",
"(",
"\"Catchment/station number (`catchment.id`) must be set.\"",
")",
... | Load catchment object into the database.
A catchment/station number (:attr:`catchment.id`) must be provided. If :attr:`method` is set to `update`, any
existing catchment in the database with the same catchment number will be updated.
:param catchment: New catchment object to replace any existing catchment... | [
"Load",
"catchment",
"object",
"into",
"the",
"database",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L69-L96 | train | Load catchment into the database. |
OpenHydrology/floodestimation | floodestimation/loaders.py | folder_to_db | def folder_to_db(path, session, method='create', autocommit=False, incl_pot=True):
"""
Import an entire folder (incl. sub-folders) into the database
:param path: Folder location
:type path: str
:param session: database session to use, typically `floodestimation.db.Session()`
:type session: :cla... | python | def folder_to_db(path, session, method='create', autocommit=False, incl_pot=True):
"""
Import an entire folder (incl. sub-folders) into the database
:param path: Folder location
:type path: str
:param session: database session to use, typically `floodestimation.db.Session()`
:type session: :cla... | [
"def",
"folder_to_db",
"(",
"path",
",",
"session",
",",
"method",
"=",
"'create'",
",",
"autocommit",
"=",
"False",
",",
"incl_pot",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"raise",
"ValueError",
"... | Import an entire folder (incl. sub-folders) into the database
:param path: Folder location
:type path: str
:param session: database session to use, typically `floodestimation.db.Session()`
:type session: :class:`sqlalchemy.orm.session.Session`
:param method: - ``create``: only new catchments will b... | [
"Import",
"an",
"entire",
"folder",
"(",
"incl",
".",
"sub",
"-",
"folders",
")",
"into",
"the",
"database"
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L99-L124 | train | Import a folder into the database. |
OpenHydrology/floodestimation | floodestimation/loaders.py | nrfa_to_db | def nrfa_to_db(session, method='create', autocommit=False, incl_pot=True):
"""
Retrieves all gauged catchments (incl. catchment descriptors and annual maximum flow data) from the National River
Flow Archive and saves it to a (sqlite) database.
:param session: database session to use, typically `floodes... | python | def nrfa_to_db(session, method='create', autocommit=False, incl_pot=True):
"""
Retrieves all gauged catchments (incl. catchment descriptors and annual maximum flow data) from the National River
Flow Archive and saves it to a (sqlite) database.
:param session: database session to use, typically `floodes... | [
"def",
"nrfa_to_db",
"(",
"session",
",",
"method",
"=",
"'create'",
",",
"autocommit",
"=",
"False",
",",
"incl_pot",
"=",
"True",
")",
":",
"fehdata",
".",
"clear_cache",
"(",
")",
"fehdata",
".",
"download_data",
"(",
")",
"fehdata",
".",
"unzip_data",
... | Retrieves all gauged catchments (incl. catchment descriptors and annual maximum flow data) from the National River
Flow Archive and saves it to a (sqlite) database.
:param session: database session to use, typically `floodestimation.db.Session()`
:type session: :class:`sqlalchemy.orm.session.Session`
:... | [
"Retrieves",
"all",
"gauged",
"catchments",
"(",
"incl",
".",
"catchment",
"descriptors",
"and",
"annual",
"maximum",
"flow",
"data",
")",
"from",
"the",
"National",
"River",
"Flow",
"Archive",
"and",
"saves",
"it",
"to",
"a",
"(",
"sqlite",
")",
"database",... | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L129-L148 | train | Downloads and saves all gauged catchments from National River
Flow Archive and saves them to a sqlite database. |
OpenHydrology/floodestimation | floodestimation/loaders.py | userdata_to_db | def userdata_to_db(session, method='update', autocommit=False):
"""
Add catchments from a user folder to the database.
The user folder is specified in the ``config.ini`` file like this::
[import]
folder = path/to/import/folder
If this configuration key does not exist this will be sile... | python | def userdata_to_db(session, method='update', autocommit=False):
"""
Add catchments from a user folder to the database.
The user folder is specified in the ``config.ini`` file like this::
[import]
folder = path/to/import/folder
If this configuration key does not exist this will be sile... | [
"def",
"userdata_to_db",
"(",
"session",
",",
"method",
"=",
"'update'",
",",
"autocommit",
"=",
"False",
")",
":",
"try",
":",
"folder",
"=",
"config",
"[",
"'import'",
"]",
"[",
"'folder'",
"]",
"except",
"KeyError",
":",
"return",
"if",
"folder",
":",... | Add catchments from a user folder to the database.
The user folder is specified in the ``config.ini`` file like this::
[import]
folder = path/to/import/folder
If this configuration key does not exist this will be silently ignored.
:param session: database session to use, typically `flood... | [
"Add",
"catchments",
"from",
"a",
"user",
"folder",
"to",
"the",
"database",
"."
] | 782da7c5abd1348923129efe89fb70003ebb088c | https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L151-L176 | train | Adds catchments from a user folder to the database. |
acutesoftware/AIKIF | aikif/toolbox/interface_windows_tools.py | get_window_by_caption | def get_window_by_caption(caption):
"""
finds the window by caption and returns handle (int)
"""
try:
hwnd = win32gui.FindWindow(None, caption)
return hwnd
except Exception as ex:
print('error calling win32gui.FindWindow ' + str(ex))
return -1 | python | def get_window_by_caption(caption):
"""
finds the window by caption and returns handle (int)
"""
try:
hwnd = win32gui.FindWindow(None, caption)
return hwnd
except Exception as ex:
print('error calling win32gui.FindWindow ' + str(ex))
return -1 | [
"def",
"get_window_by_caption",
"(",
"caption",
")",
":",
"try",
":",
"hwnd",
"=",
"win32gui",
".",
"FindWindow",
"(",
"None",
",",
"caption",
")",
"return",
"hwnd",
"except",
"Exception",
"as",
"ex",
":",
"print",
"(",
"'error calling win32gui.FindWindow '",
... | finds the window by caption and returns handle (int) | [
"finds",
"the",
"window",
"by",
"caption",
"and",
"returns",
"handle",
"(",
"int",
")"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/interface_windows_tools.py#L32-L41 | train | returns the handle of the window with the given caption |
acutesoftware/AIKIF | aikif/toolbox/interface_windows_tools.py | send_text | def send_text(hwnd, txt):
"""
sends the text 'txt' to the window handle hwnd using SendMessage
"""
try:
for c in txt:
if c == '\n':
win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
win32api.SendMessage(hwnd, win32con.WM_KEYUP, win... | python | def send_text(hwnd, txt):
"""
sends the text 'txt' to the window handle hwnd using SendMessage
"""
try:
for c in txt:
if c == '\n':
win32api.SendMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
win32api.SendMessage(hwnd, win32con.WM_KEYUP, win... | [
"def",
"send_text",
"(",
"hwnd",
",",
"txt",
")",
":",
"try",
":",
"for",
"c",
"in",
"txt",
":",
"if",
"c",
"==",
"'\\n'",
":",
"win32api",
".",
"SendMessage",
"(",
"hwnd",
",",
"win32con",
".",
"WM_KEYDOWN",
",",
"win32con",
".",
"VK_RETURN",
",",
... | sends the text 'txt' to the window handle hwnd using SendMessage | [
"sends",
"the",
"text",
"txt",
"to",
"the",
"window",
"handle",
"hwnd",
"using",
"SendMessage"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/interface_windows_tools.py#L43-L55 | train | Sends the text txt to the window handle hwnd using SendMessage
|
acutesoftware/AIKIF | aikif/toolbox/interface_windows_tools.py | launch_app | def launch_app(app_path, params=[], time_before_kill_app=15):
"""
start an app
"""
import subprocess
try:
res = subprocess.call([app_path, params], timeout=time_before_kill_app, shell=True)
print('res = ', res)
if res == 0:
return True
else:
re... | python | def launch_app(app_path, params=[], time_before_kill_app=15):
"""
start an app
"""
import subprocess
try:
res = subprocess.call([app_path, params], timeout=time_before_kill_app, shell=True)
print('res = ', res)
if res == 0:
return True
else:
re... | [
"def",
"launch_app",
"(",
"app_path",
",",
"params",
"=",
"[",
"]",
",",
"time_before_kill_app",
"=",
"15",
")",
":",
"import",
"subprocess",
"try",
":",
"res",
"=",
"subprocess",
".",
"call",
"(",
"[",
"app_path",
",",
"params",
"]",
",",
"timeout",
"... | start an app | [
"start",
"an",
"app"
] | fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03 | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/interface_windows_tools.py#L57-L71 | train | launch an app |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.