repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
houluy/chessboard | chessboard/__init__.py | Chessboard.compute_coordinate | def compute_coordinate(self, index):
'''Compute two-dimension coordinate from one-dimension list'''
j = index%self.board_size
i = (index - j) // self.board_size
return (i, j) | python | def compute_coordinate(self, index):
'''Compute two-dimension coordinate from one-dimension list'''
j = index%self.board_size
i = (index - j) // self.board_size
return (i, j) | [
"def",
"compute_coordinate",
"(",
"self",
",",
"index",
")",
":",
"j",
"=",
"index",
"%",
"self",
".",
"board_size",
"i",
"=",
"(",
"index",
"-",
"j",
")",
"//",
"self",
".",
"board_size",
"return",
"(",
"i",
",",
"j",
")"
] | Compute two-dimension coordinate from one-dimension list | [
"Compute",
"two",
"-",
"dimension",
"coordinate",
"from",
"one",
"-",
"dimension",
"list"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L134-L138 |
houluy/chessboard | chessboard/__init__.py | Chessboard.print_pos | def print_pos(self, coordinates=None, pos=None):
'''Print the chessboard'''
if not pos:
pos = self.pos
self.graph = [list(map(self._transform, pos[i])) for i in self.pos_range]
xaxis = ' '.join([chr(ASC_ONE + _) for _ in range(min(self.board_size, MAX_NUM))])
if (self... | python | def print_pos(self, coordinates=None, pos=None):
'''Print the chessboard'''
if not pos:
pos = self.pos
self.graph = [list(map(self._transform, pos[i])) for i in self.pos_range]
xaxis = ' '.join([chr(ASC_ONE + _) for _ in range(min(self.board_size, MAX_NUM))])
if (self... | [
"def",
"print_pos",
"(",
"self",
",",
"coordinates",
"=",
"None",
",",
"pos",
"=",
"None",
")",
":",
"if",
"not",
"pos",
":",
"pos",
"=",
"self",
".",
"pos",
"self",
".",
"graph",
"=",
"[",
"list",
"(",
"map",
"(",
"self",
".",
"_transform",
",",... | Print the chessboard | [
"Print",
"the",
"chessboard"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L165-L206 |
houluy/chessboard | chessboard/__init__.py | Chessboard.set_pos | def set_pos(self, pos, check=False):
'''Set a chess'''
self.validate_pos(pos)
x, y = pos
user = self.get_player()
self.history[self._game_round] = copy.deepcopy(self.pos)
self.pos[x][y] = user
pos_str = self._cal_key(pos)
self._pos_dict[pos_str] = user
... | python | def set_pos(self, pos, check=False):
'''Set a chess'''
self.validate_pos(pos)
x, y = pos
user = self.get_player()
self.history[self._game_round] = copy.deepcopy(self.pos)
self.pos[x][y] = user
pos_str = self._cal_key(pos)
self._pos_dict[pos_str] = user
... | [
"def",
"set_pos",
"(",
"self",
",",
"pos",
",",
"check",
"=",
"False",
")",
":",
"self",
".",
"validate_pos",
"(",
"pos",
")",
"x",
",",
"y",
"=",
"pos",
"user",
"=",
"self",
".",
"get_player",
"(",
")",
"self",
".",
"history",
"[",
"self",
".",
... | Set a chess | [
"Set",
"a",
"chess"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L235-L250 |
houluy/chessboard | chessboard/__init__.py | Chessboard.clear | def clear(self):
'''Clear a chessboard'''
self.pos = [[0 for _ in range(self.board_size)] for _ in range(self.board_size)]
self.graph = copy.deepcopy(self.pos)
self._game_round = 1 | python | def clear(self):
'''Clear a chessboard'''
self.pos = [[0 for _ in range(self.board_size)] for _ in range(self.board_size)]
self.graph = copy.deepcopy(self.pos)
self._game_round = 1 | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"pos",
"=",
"[",
"[",
"0",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"board_size",
")",
"]",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"board_size",
")",
"]",
"self",
".",
"graph",
"=",
... | Clear a chessboard | [
"Clear",
"a",
"chessboard"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L258-L262 |
houluy/chessboard | chessboard/__init__.py | Chessboard.handle_input | def handle_input(self, input_str, place=True, check=False):
'''Transfer user input to valid chess position'''
user = self.get_player()
pos = self.validate_input(input_str)
if pos[0] == 'u':
self.undo(pos[1])
return pos
if place:
result = self.s... | python | def handle_input(self, input_str, place=True, check=False):
'''Transfer user input to valid chess position'''
user = self.get_player()
pos = self.validate_input(input_str)
if pos[0] == 'u':
self.undo(pos[1])
return pos
if place:
result = self.s... | [
"def",
"handle_input",
"(",
"self",
",",
"input_str",
",",
"place",
"=",
"True",
",",
"check",
"=",
"False",
")",
":",
"user",
"=",
"self",
".",
"get_player",
"(",
")",
"pos",
"=",
"self",
".",
"validate_input",
"(",
"input_str",
")",
"if",
"pos",
"[... | Transfer user input to valid chess position | [
"Transfer",
"user",
"input",
"to",
"valid",
"chess",
"position"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L314-L325 |
houluy/chessboard | chessboard/__init__.py | Chessboard.distance | def distance(self, piecex, piecey):
'''Return the distance of chess piece X and Y (Chebyshev Distance)'''
return max(abs(piecex[0] - piecey[0]), abs(piecex[1], piecey[1])) | python | def distance(self, piecex, piecey):
'''Return the distance of chess piece X and Y (Chebyshev Distance)'''
return max(abs(piecex[0] - piecey[0]), abs(piecex[1], piecey[1])) | [
"def",
"distance",
"(",
"self",
",",
"piecex",
",",
"piecey",
")",
":",
"return",
"max",
"(",
"abs",
"(",
"piecex",
"[",
"0",
"]",
"-",
"piecey",
"[",
"0",
"]",
")",
",",
"abs",
"(",
"piecex",
"[",
"1",
"]",
",",
"piecey",
"[",
"1",
"]",
")",... | Return the distance of chess piece X and Y (Chebyshev Distance) | [
"Return",
"the",
"distance",
"of",
"chess",
"piece",
"X",
"and",
"Y",
"(",
"Chebyshev",
"Distance",
")"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L327-L329 |
houluy/chessboard | chessboard/__init__.py | Chessboard.check_win_by_step | def check_win_by_step(self, x, y, user, line_number=None):
'''Check winners by current step'''
if not line_number:
line_number = self.win
for ang in self.angle:
self.win_list = [(x, y)]
angs = [ang, ang + math.pi]
line_num = 1
radius = ... | python | def check_win_by_step(self, x, y, user, line_number=None):
'''Check winners by current step'''
if not line_number:
line_number = self.win
for ang in self.angle:
self.win_list = [(x, y)]
angs = [ang, ang + math.pi]
line_num = 1
radius = ... | [
"def",
"check_win_by_step",
"(",
"self",
",",
"x",
",",
"y",
",",
"user",
",",
"line_number",
"=",
"None",
")",
":",
"if",
"not",
"line_number",
":",
"line_number",
"=",
"self",
".",
"win",
"for",
"ang",
"in",
"self",
".",
"angle",
":",
"self",
".",
... | Check winners by current step | [
"Check",
"winners",
"by",
"current",
"step"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L331-L359 |
houluy/chessboard | chessboard/__init__.py | Chessboard.get_not_num | def get_not_num(self, seq, num=0):
'''Find the index of first non num element'''
ind = next((i for i, x in enumerate(seq) if x != num), None)
if ind == None:
return self.board_size
else:
return ind | python | def get_not_num(self, seq, num=0):
'''Find the index of first non num element'''
ind = next((i for i, x in enumerate(seq) if x != num), None)
if ind == None:
return self.board_size
else:
return ind | [
"def",
"get_not_num",
"(",
"self",
",",
"seq",
",",
"num",
"=",
"0",
")",
":",
"ind",
"=",
"next",
"(",
"(",
"i",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"seq",
")",
"if",
"x",
"!=",
"num",
")",
",",
"None",
")",
"if",
"ind",
"==",
"N... | Find the index of first non num element | [
"Find",
"the",
"index",
"of",
"first",
"non",
"num",
"element"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L361-L367 |
houluy/chessboard | chessboard/__init__.py | ChessboardExtension.compare_board | def compare_board(self, dst, src=None):
'''Compare two chessboard'''
if not src:
src = self.pos
if src == dst:
return True
else:
#May return details
return False | python | def compare_board(self, dst, src=None):
'''Compare two chessboard'''
if not src:
src = self.pos
if src == dst:
return True
else:
#May return details
return False | [
"def",
"compare_board",
"(",
"self",
",",
"dst",
",",
"src",
"=",
"None",
")",
":",
"if",
"not",
"src",
":",
"src",
"=",
"self",
".",
"pos",
"if",
"src",
"==",
"dst",
":",
"return",
"True",
"else",
":",
"#May return details",
"return",
"False"
] | Compare two chessboard | [
"Compare",
"two",
"chessboard"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L390-L399 |
houluy/chessboard | chessboard/__init__.py | ChessboardExtension.rotate_board | def rotate_board(self, angle, unit='radian'):
'''Rotate the chessboard for a specific angle,
angle must be integral multiple of pi/2(90 degree)'''
if unit == 'angle':
angle = angle*math.pi/180
angle %= 2*math.pi
if angle not in [0, math.pi/2, math.pi, math.pi*3/2]:
... | python | def rotate_board(self, angle, unit='radian'):
'''Rotate the chessboard for a specific angle,
angle must be integral multiple of pi/2(90 degree)'''
if unit == 'angle':
angle = angle*math.pi/180
angle %= 2*math.pi
if angle not in [0, math.pi/2, math.pi, math.pi*3/2]:
... | [
"def",
"rotate_board",
"(",
"self",
",",
"angle",
",",
"unit",
"=",
"'radian'",
")",
":",
"if",
"unit",
"==",
"'angle'",
":",
"angle",
"=",
"angle",
"*",
"math",
".",
"pi",
"/",
"180",
"angle",
"%=",
"2",
"*",
"math",
".",
"pi",
"if",
"angle",
"n... | Rotate the chessboard for a specific angle,
angle must be integral multiple of pi/2(90 degree) | [
"Rotate",
"the",
"chessboard",
"for",
"a",
"specific",
"angle",
"angle",
"must",
"be",
"integral",
"multiple",
"of",
"pi",
"/",
"2",
"(",
"90",
"degree",
")"
] | train | https://github.com/houluy/chessboard/blob/b834819d93d71b492f27780a58dfbb3a107d7e85/chessboard/__init__.py#L423-L441 |
treycucco/bidon | bidon/data_table.py | reduce_number | def reduce_number(num):
"""Reduces the string representation of a number.
If the number is of the format n.00..., returns n.
If the decimal portion of the number has a repeating decimal, followed by up to two trailing
numbers, such as:
0.3333333
or
0.343434346
It will return just one instance of th... | python | def reduce_number(num):
"""Reduces the string representation of a number.
If the number is of the format n.00..., returns n.
If the decimal portion of the number has a repeating decimal, followed by up to two trailing
numbers, such as:
0.3333333
or
0.343434346
It will return just one instance of th... | [
"def",
"reduce_number",
"(",
"num",
")",
":",
"parts",
"=",
"str",
"(",
"num",
")",
".",
"split",
"(",
"\".\"",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
"or",
"parts",
"[",
"1",
"]",
"==",
"\"0\"",
":",
"return",
"int",
"(",
"parts",
"["... | Reduces the string representation of a number.
If the number is of the format n.00..., returns n.
If the decimal portion of the number has a repeating decimal, followed by up to two trailing
numbers, such as:
0.3333333
or
0.343434346
It will return just one instance of the repeating decimals:
0.3
... | [
"Reduces",
"the",
"string",
"representation",
"of",
"a",
"number",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L12-L45 |
treycucco/bidon | bidon/data_table.py | DataTable.set_cell_value | def set_cell_value(self, row, index, value):
"""Sets the value for the cell at row[index]."""
if self._set_cell_value:
self._set_cell_value(row, index, value)
else:
row[index] = value | python | def set_cell_value(self, row, index, value):
"""Sets the value for the cell at row[index]."""
if self._set_cell_value:
self._set_cell_value(row, index, value)
else:
row[index] = value | [
"def",
"set_cell_value",
"(",
"self",
",",
"row",
",",
"index",
",",
"value",
")",
":",
"if",
"self",
".",
"_set_cell_value",
":",
"self",
".",
"_set_cell_value",
"(",
"row",
",",
"index",
",",
"value",
")",
"else",
":",
"row",
"[",
"index",
"]",
"="... | Sets the value for the cell at row[index]. | [
"Sets",
"the",
"value",
"for",
"the",
"cell",
"at",
"row",
"[",
"index",
"]",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L80-L85 |
treycucco/bidon | bidon/data_table.py | DataTable.is_cell_empty | def is_cell_empty(self, cell):
"""Checks if the cell is empty."""
if cell is None:
return True
elif self._is_cell_empty:
return self._is_cell_empty(cell)
else:
return cell is None | python | def is_cell_empty(self, cell):
"""Checks if the cell is empty."""
if cell is None:
return True
elif self._is_cell_empty:
return self._is_cell_empty(cell)
else:
return cell is None | [
"def",
"is_cell_empty",
"(",
"self",
",",
"cell",
")",
":",
"if",
"cell",
"is",
"None",
":",
"return",
"True",
"elif",
"self",
".",
"_is_cell_empty",
":",
"return",
"self",
".",
"_is_cell_empty",
"(",
"cell",
")",
"else",
":",
"return",
"cell",
"is",
"... | Checks if the cell is empty. | [
"Checks",
"if",
"the",
"cell",
"is",
"empty",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L87-L94 |
treycucco/bidon | bidon/data_table.py | DataTable.is_row_empty | def is_row_empty(self, row):
"""Returns True if every cell in the row is empty."""
for cell in row:
if not self.is_cell_empty(cell):
return False
return True | python | def is_row_empty(self, row):
"""Returns True if every cell in the row is empty."""
for cell in row:
if not self.is_cell_empty(cell):
return False
return True | [
"def",
"is_row_empty",
"(",
"self",
",",
"row",
")",
":",
"for",
"cell",
"in",
"row",
":",
"if",
"not",
"self",
".",
"is_cell_empty",
"(",
"cell",
")",
":",
"return",
"False",
"return",
"True"
] | Returns True if every cell in the row is empty. | [
"Returns",
"True",
"if",
"every",
"cell",
"in",
"the",
"row",
"is",
"empty",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L96-L101 |
treycucco/bidon | bidon/data_table.py | DataTable.serialize | def serialize(self, serialize_cell=None):
"""Returns a list of all rows, with serialize_cell or self.get_cell_value called on the cells of
each.
"""
if serialize_cell is None:
serialize_cell = self.get_cell_value
return [[serialize_cell(cell) for cell in row] for row in self.rows] | python | def serialize(self, serialize_cell=None):
"""Returns a list of all rows, with serialize_cell or self.get_cell_value called on the cells of
each.
"""
if serialize_cell is None:
serialize_cell = self.get_cell_value
return [[serialize_cell(cell) for cell in row] for row in self.rows] | [
"def",
"serialize",
"(",
"self",
",",
"serialize_cell",
"=",
"None",
")",
":",
"if",
"serialize_cell",
"is",
"None",
":",
"serialize_cell",
"=",
"self",
".",
"get_cell_value",
"return",
"[",
"[",
"serialize_cell",
"(",
"cell",
")",
"for",
"cell",
"in",
"ro... | Returns a list of all rows, with serialize_cell or self.get_cell_value called on the cells of
each. | [
"Returns",
"a",
"list",
"of",
"all",
"rows",
"with",
"serialize_cell",
"or",
"self",
".",
"get_cell_value",
"called",
"on",
"the",
"cells",
"of",
"each",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L103-L109 |
treycucco/bidon | bidon/data_table.py | DataTable.headers | def headers(self, serialize_cell=None):
"""Gets the first row of the data table, with serialize_cell or self.get_cell_value is called on
each cell."""
if serialize_cell is None:
serialize_cell = self.get_cell_value
return [serialize_cell(cell) for cell in self.rows[0]] | python | def headers(self, serialize_cell=None):
"""Gets the first row of the data table, with serialize_cell or self.get_cell_value is called on
each cell."""
if serialize_cell is None:
serialize_cell = self.get_cell_value
return [serialize_cell(cell) for cell in self.rows[0]] | [
"def",
"headers",
"(",
"self",
",",
"serialize_cell",
"=",
"None",
")",
":",
"if",
"serialize_cell",
"is",
"None",
":",
"serialize_cell",
"=",
"self",
".",
"get_cell_value",
"return",
"[",
"serialize_cell",
"(",
"cell",
")",
"for",
"cell",
"in",
"self",
".... | Gets the first row of the data table, with serialize_cell or self.get_cell_value is called on
each cell. | [
"Gets",
"the",
"first",
"row",
"of",
"the",
"data",
"table",
"with",
"serialize_cell",
"or",
"self",
".",
"get_cell_value",
"is",
"called",
"on",
"each",
"cell",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L111-L116 |
treycucco/bidon | bidon/data_table.py | DataTable.rows_to_dicts | def rows_to_dicts(self, serialize_cell=None):
"""Generates a sequence of dictionaries of {header[i] => row[i]} for each row."""
if serialize_cell is None:
serialize_cell = self.get_cell_value
# keys = [serialize_cell(cell) for cell in self.rows[0]]
keys = self.headers(serialize_cell)
for row i... | python | def rows_to_dicts(self, serialize_cell=None):
"""Generates a sequence of dictionaries of {header[i] => row[i]} for each row."""
if serialize_cell is None:
serialize_cell = self.get_cell_value
# keys = [serialize_cell(cell) for cell in self.rows[0]]
keys = self.headers(serialize_cell)
for row i... | [
"def",
"rows_to_dicts",
"(",
"self",
",",
"serialize_cell",
"=",
"None",
")",
":",
"if",
"serialize_cell",
"is",
"None",
":",
"serialize_cell",
"=",
"self",
".",
"get_cell_value",
"# keys = [serialize_cell(cell) for cell in self.rows[0]]",
"keys",
"=",
"self",
".",
... | Generates a sequence of dictionaries of {header[i] => row[i]} for each row. | [
"Generates",
"a",
"sequence",
"of",
"dictionaries",
"of",
"{",
"header",
"[",
"i",
"]",
"=",
">",
"row",
"[",
"i",
"]",
"}",
"for",
"each",
"row",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L118-L125 |
treycucco/bidon | bidon/data_table.py | DataTable.trim_empty_rows | def trim_empty_rows(self):
"""Remove all trailing empty rows."""
if self.nrows != 0:
row_index = 0
for row_index, row in enumerate(reversed(self.rows)):
if not self.is_row_empty(row):
break
self.nrows = len(self.rows) - row_index
self.rows = self.rows[:self.nrows]
r... | python | def trim_empty_rows(self):
"""Remove all trailing empty rows."""
if self.nrows != 0:
row_index = 0
for row_index, row in enumerate(reversed(self.rows)):
if not self.is_row_empty(row):
break
self.nrows = len(self.rows) - row_index
self.rows = self.rows[:self.nrows]
r... | [
"def",
"trim_empty_rows",
"(",
"self",
")",
":",
"if",
"self",
".",
"nrows",
"!=",
"0",
":",
"row_index",
"=",
"0",
"for",
"row_index",
",",
"row",
"in",
"enumerate",
"(",
"reversed",
"(",
"self",
".",
"rows",
")",
")",
":",
"if",
"not",
"self",
".... | Remove all trailing empty rows. | [
"Remove",
"all",
"trailing",
"empty",
"rows",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L138-L147 |
treycucco/bidon | bidon/data_table.py | DataTable.trim_empty_columns | def trim_empty_columns(self):
"""Removes all trailing empty columns."""
if self.nrows != 0 and self.ncols != 0:
last_col = -1
for row in self.rows:
for i in range(last_col + 1, len(row)):
if not self.is_cell_empty(row[i]):
last_col = i
ncols = last_col + 1
s... | python | def trim_empty_columns(self):
"""Removes all trailing empty columns."""
if self.nrows != 0 and self.ncols != 0:
last_col = -1
for row in self.rows:
for i in range(last_col + 1, len(row)):
if not self.is_cell_empty(row[i]):
last_col = i
ncols = last_col + 1
s... | [
"def",
"trim_empty_columns",
"(",
"self",
")",
":",
"if",
"self",
".",
"nrows",
"!=",
"0",
"and",
"self",
".",
"ncols",
"!=",
"0",
":",
"last_col",
"=",
"-",
"1",
"for",
"row",
"in",
"self",
".",
"rows",
":",
"for",
"i",
"in",
"range",
"(",
"last... | Removes all trailing empty columns. | [
"Removes",
"all",
"trailing",
"empty",
"columns",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L149-L160 |
treycucco/bidon | bidon/data_table.py | DataTable.clean_values | def clean_values(self):
"""Cleans the values in each cell. Calls either the user provided clean_value, or the
class defined clean value.
"""
for row in self.rows:
for index, cell in enumerate(row):
self.set_cell_value(row, index, self.clean_value(self.get_cell_value(cell)))
return self | python | def clean_values(self):
"""Cleans the values in each cell. Calls either the user provided clean_value, or the
class defined clean value.
"""
for row in self.rows:
for index, cell in enumerate(row):
self.set_cell_value(row, index, self.clean_value(self.get_cell_value(cell)))
return self | [
"def",
"clean_values",
"(",
"self",
")",
":",
"for",
"row",
"in",
"self",
".",
"rows",
":",
"for",
"index",
",",
"cell",
"in",
"enumerate",
"(",
"row",
")",
":",
"self",
".",
"set_cell_value",
"(",
"row",
",",
"index",
",",
"self",
".",
"clean_value"... | Cleans the values in each cell. Calls either the user provided clean_value, or the
class defined clean value. | [
"Cleans",
"the",
"values",
"in",
"each",
"cell",
".",
"Calls",
"either",
"the",
"user",
"provided",
"clean_value",
"or",
"the",
"class",
"defined",
"clean",
"value",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L162-L169 |
treycucco/bidon | bidon/data_table.py | DataTable.clean_value | def clean_value(self, value):
"""Cleans a value, using either the user provided clean_value, or cls.reduce_value."""
if self._clean_value:
return self._clean_value(value)
else:
return self.reduce_value(value) | python | def clean_value(self, value):
"""Cleans a value, using either the user provided clean_value, or cls.reduce_value."""
if self._clean_value:
return self._clean_value(value)
else:
return self.reduce_value(value) | [
"def",
"clean_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_clean_value",
":",
"return",
"self",
".",
"_clean_value",
"(",
"value",
")",
"else",
":",
"return",
"self",
".",
"reduce_value",
"(",
"value",
")"
] | Cleans a value, using either the user provided clean_value, or cls.reduce_value. | [
"Cleans",
"a",
"value",
"using",
"either",
"the",
"user",
"provided",
"clean_value",
"or",
"cls",
".",
"reduce_value",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L171-L176 |
treycucco/bidon | bidon/data_table.py | DataTable.reduce_value | def reduce_value(cls, value):
"""Cleans the value by either compressing it if it is a string, or reducing it if it is a
number.
"""
if isinstance(value, str):
return to_compressed_string(value)
elif isinstance(value, bool):
return value
elif isinstance(value, Number):
return re... | python | def reduce_value(cls, value):
"""Cleans the value by either compressing it if it is a string, or reducing it if it is a
number.
"""
if isinstance(value, str):
return to_compressed_string(value)
elif isinstance(value, bool):
return value
elif isinstance(value, Number):
return re... | [
"def",
"reduce_value",
"(",
"cls",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"to_compressed_string",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"value",
"elif",
... | Cleans the value by either compressing it if it is a string, or reducing it if it is a
number. | [
"Cleans",
"the",
"value",
"by",
"either",
"compressing",
"it",
"if",
"it",
"is",
"a",
"string",
"or",
"reducing",
"it",
"if",
"it",
"is",
"a",
"number",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/data_table.py#L179-L190 |
rsalmei/about-time | about_time/about_time.py | about_time | def about_time(fn=None, it=None):
"""Measures the execution time of a block of code, and even counts iterations
and the throughput of them, always with a beautiful "human" representation.
There's three modes of operation: context manager, callable handler and
iterator metrics.
1. Use it like a con... | python | def about_time(fn=None, it=None):
"""Measures the execution time of a block of code, and even counts iterations
and the throughput of them, always with a beautiful "human" representation.
There's three modes of operation: context manager, callable handler and
iterator metrics.
1. Use it like a con... | [
"def",
"about_time",
"(",
"fn",
"=",
"None",
",",
"it",
"=",
"None",
")",
":",
"# has to be here to be mockable.",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"3",
")",
":",
"timer",
"=",
"time",
".",
"perf_counter",
"else",
":",
"# pragma: no... | Measures the execution time of a block of code, and even counts iterations
and the throughput of them, always with a beautiful "human" representation.
There's three modes of operation: context manager, callable handler and
iterator metrics.
1. Use it like a context manager:
>>> with about_time() ... | [
"Measures",
"the",
"execution",
"time",
"of",
"a",
"block",
"of",
"code",
"and",
"even",
"counts",
"iterations",
"and",
"the",
"throughput",
"of",
"them",
"always",
"with",
"a",
"beautiful",
"human",
"representation",
"."
] | train | https://github.com/rsalmei/about-time/blob/5dd0165a3a4cf6c6f8c4ad2fbb50e44b136a3077/about_time/about_time.py#L9-L93 |
dansackett/django-toolset | django_toolset/templatetags/custom_filters.py | method | def method(value, arg):
"""Method attempts to see if the value has a specified method.
Usage:
{% load custom_filters %}
{% if foo|method:"has_access" %}
"""
if hasattr(value, str(arg)):
return getattr(value, str(arg))
return "[%s has no method %s]" % (value, arg) | python | def method(value, arg):
"""Method attempts to see if the value has a specified method.
Usage:
{% load custom_filters %}
{% if foo|method:"has_access" %}
"""
if hasattr(value, str(arg)):
return getattr(value, str(arg))
return "[%s has no method %s]" % (value, arg) | [
"def",
"method",
"(",
"value",
",",
"arg",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"str",
"(",
"arg",
")",
")",
":",
"return",
"getattr",
"(",
"value",
",",
"str",
"(",
"arg",
")",
")",
"return",
"\"[%s has no method %s]\"",
"%",
"(",
"value",
... | Method attempts to see if the value has a specified method.
Usage:
{% load custom_filters %}
{% if foo|method:"has_access" %} | [
"Method",
"attempts",
"to",
"see",
"if",
"the",
"value",
"has",
"a",
"specified",
"method",
"."
] | train | https://github.com/dansackett/django-toolset/blob/a28cc19e32cf41130e848c268d26c1858a7cf26a/django_toolset/templatetags/custom_filters.py#L9-L20 |
mickbad/mblibs | mblibs/fast.py | FastSettings.reload | def reload(self):
"""
fonction de chargement automatique de la configuration
depuis le fichier extérieur
"""
# lecture du fichier de configuration en mode UTF-8
if self.config_filename != "":
try:
# content = open(self.config_filename).read()
self.config_content = codecs.open(self.config_filen... | python | def reload(self):
"""
fonction de chargement automatique de la configuration
depuis le fichier extérieur
"""
# lecture du fichier de configuration en mode UTF-8
if self.config_filename != "":
try:
# content = open(self.config_filename).read()
self.config_content = codecs.open(self.config_filen... | [
"def",
"reload",
"(",
"self",
")",
":",
"# lecture du fichier de configuration en mode UTF-8",
"if",
"self",
".",
"config_filename",
"!=",
"\"\"",
":",
"try",
":",
"# content = open(self.config_filename).read()",
"self",
".",
"config_content",
"=",
"codecs",
".",
"open"... | fonction de chargement automatique de la configuration
depuis le fichier extérieur | [
"fonction",
"de",
"chargement",
"automatique",
"de",
"la",
"configuration",
"depuis",
"le",
"fichier",
"extérieur"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L55-L100 |
mickbad/mblibs | mblibs/fast.py | FastSettings.get | def get(self, name, default="", parent_search=False, multikeys_search=False, __settings_temp=None, __rank_recursion=0):
"""
Récupération d'une configuration
le paramètre ```name``` peut être soit un nom ou
un chemin vers la valeur (séparateur /)
```parent_search``` est le boolean qui indique si on doi... | python | def get(self, name, default="", parent_search=False, multikeys_search=False, __settings_temp=None, __rank_recursion=0):
"""
Récupération d'une configuration
le paramètre ```name``` peut être soit un nom ou
un chemin vers la valeur (séparateur /)
```parent_search``` est le boolean qui indique si on doi... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"\"\"",
",",
"parent_search",
"=",
"False",
",",
"multikeys_search",
"=",
"False",
",",
"__settings_temp",
"=",
"None",
",",
"__rank_recursion",
"=",
"0",
")",
":",
"# configuration des settings temp... | Récupération d'une configuration
le paramètre ```name``` peut être soit un nom ou
un chemin vers la valeur (séparateur /)
```parent_search``` est le boolean qui indique si on doit
chercher la valeur dans la hiérarchie plus haute. Si la chaîne
"/document/host/val" retourne None, on recherche dans "/doc... | [
"Récupération",
"d",
"une",
"configuration",
"le",
"paramètre",
"name",
"peut",
"être",
"soit",
"un",
"nom",
"ou",
"un",
"chemin",
"vers",
"la",
"valeur",
"(",
"séparateur",
"/",
")"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L104-L257 |
mickbad/mblibs | mblibs/fast.py | FastSettings.getInt | def getInt(self, name, default=0, parent_search=False, multikeys_search=False):
""" récupération d'un élément entier """
try:
value = self.get(name, default, parent_search, multikeys_search)
return int(value)
except:
# pas de configuration trouvé ou convertion impossible ?
return default | python | def getInt(self, name, default=0, parent_search=False, multikeys_search=False):
""" récupération d'un élément entier """
try:
value = self.get(name, default, parent_search, multikeys_search)
return int(value)
except:
# pas de configuration trouvé ou convertion impossible ?
return default | [
"def",
"getInt",
"(",
"self",
",",
"name",
",",
"default",
"=",
"0",
",",
"parent_search",
"=",
"False",
",",
"multikeys_search",
"=",
"False",
")",
":",
"try",
":",
"value",
"=",
"self",
".",
"get",
"(",
"name",
",",
"default",
",",
"parent_search",
... | récupération d'un élément entier | [
"récupération",
"d",
"un",
"élément",
"entier"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L260-L268 |
mickbad/mblibs | mblibs/fast.py | FastSettings.getFloat | def getFloat(self, name, default=0.0, parent_search=False, multikeys_search=False):
""" récupération d'un élément float """
try:
value = self.get(name, default, parent_search, multikeys_search)
return float(value)
except:
# pas de configuration trouvé ou convertion impossible ?
return default | python | def getFloat(self, name, default=0.0, parent_search=False, multikeys_search=False):
""" récupération d'un élément float """
try:
value = self.get(name, default, parent_search, multikeys_search)
return float(value)
except:
# pas de configuration trouvé ou convertion impossible ?
return default | [
"def",
"getFloat",
"(",
"self",
",",
"name",
",",
"default",
"=",
"0.0",
",",
"parent_search",
"=",
"False",
",",
"multikeys_search",
"=",
"False",
")",
":",
"try",
":",
"value",
"=",
"self",
".",
"get",
"(",
"name",
",",
"default",
",",
"parent_search... | récupération d'un élément float | [
"récupération",
"d",
"un",
"élément",
"float"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L271-L279 |
mickbad/mblibs | mblibs/fast.py | FastSettings.getEnable | def getEnable(self, name, default=False, parent_search=False, multikeys_search=False):
""" récupération d'un élément vrai ou faux (transformation en bool) """
# valeur
value = self.get(name, default, parent_search, multikeys_search)
if type(value) != str:
return (value == 1 or value)
# test de retour
re... | python | def getEnable(self, name, default=False, parent_search=False, multikeys_search=False):
""" récupération d'un élément vrai ou faux (transformation en bool) """
# valeur
value = self.get(name, default, parent_search, multikeys_search)
if type(value) != str:
return (value == 1 or value)
# test de retour
re... | [
"def",
"getEnable",
"(",
"self",
",",
"name",
",",
"default",
"=",
"False",
",",
"parent_search",
"=",
"False",
",",
"multikeys_search",
"=",
"False",
")",
":",
"# valeur",
"value",
"=",
"self",
".",
"get",
"(",
"name",
",",
"default",
",",
"parent_searc... | récupération d'un élément vrai ou faux (transformation en bool) | [
"récupération",
"d",
"un",
"élément",
"vrai",
"ou",
"faux",
"(",
"transformation",
"en",
"bool",
")"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L282-L290 |
mickbad/mblibs | mblibs/fast.py | FastSettings.getWithDateFormat | def getWithDateFormat(self, name, default="", parent_search=False, multikeys_search=False):
"""
récupération d'un élément de configuration et interprétation des valeurs de dates
variables acceptés : {dd}, {mm}, {yyyy}, {H}, {M} et {S}
{mm_human} donne le nom du mois
"""
# récupération de la valeur
val... | python | def getWithDateFormat(self, name, default="", parent_search=False, multikeys_search=False):
"""
récupération d'un élément de configuration et interprétation des valeurs de dates
variables acceptés : {dd}, {mm}, {yyyy}, {H}, {M} et {S}
{mm_human} donne le nom du mois
"""
# récupération de la valeur
val... | [
"def",
"getWithDateFormat",
"(",
"self",
",",
"name",
",",
"default",
"=",
"\"\"",
",",
"parent_search",
"=",
"False",
",",
"multikeys_search",
"=",
"False",
")",
":",
"# récupération de la valeur",
"value",
"=",
"self",
".",
"get",
"(",
"name",
",",
"defaul... | récupération d'un élément de configuration et interprétation des valeurs de dates
variables acceptés : {dd}, {mm}, {yyyy}, {H}, {M} et {S}
{mm_human} donne le nom du mois | [
"récupération",
"d",
"un",
"élément",
"de",
"configuration",
"et",
"interprétation",
"des",
"valeurs",
"de",
"dates",
"variables",
"acceptés",
":",
"{",
"dd",
"}",
"{",
"mm",
"}",
"{",
"yyyy",
"}",
"{",
"H",
"}",
"{",
"M",
"}",
"et",
"{",
"S",
"}",
... | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L293-L398 |
mickbad/mblibs | mblibs/fast.py | FastSettings.getFileFormat | def getFileFormat(self, name, args):
""" Récupération du contenu d'un fichier via la configuration
et interprétation des variables données en argument """
# récupération du nom du fichier
template_pathname = self.get(name, "--")
if not os.path.isfile(template_pathname):
return False
# configuration
c... | python | def getFileFormat(self, name, args):
""" Récupération du contenu d'un fichier via la configuration
et interprétation des variables données en argument """
# récupération du nom du fichier
template_pathname = self.get(name, "--")
if not os.path.isfile(template_pathname):
return False
# configuration
c... | [
"def",
"getFileFormat",
"(",
"self",
",",
"name",
",",
"args",
")",
":",
"# récupération du nom du fichier",
"template_pathname",
"=",
"self",
".",
"get",
"(",
"name",
",",
"\"--\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"template_pathname... | Récupération du contenu d'un fichier via la configuration
et interprétation des variables données en argument | [
"Récupération",
"du",
"contenu",
"d",
"un",
"fichier",
"via",
"la",
"configuration",
"et",
"interprétation",
"des",
"variables",
"données",
"en",
"argument"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L402-L417 |
mickbad/mblibs | mblibs/fast.py | FastLogger.setPrefix | def setPrefix(self, text=""):
""" mise en place d'un préfixe à chaque écriture de message """
if len(text) > 0:
self.message_prefix = "{}: ".format(text)
else:
self.message_prefix = "" | python | def setPrefix(self, text=""):
""" mise en place d'un préfixe à chaque écriture de message """
if len(text) > 0:
self.message_prefix = "{}: ".format(text)
else:
self.message_prefix = "" | [
"def",
"setPrefix",
"(",
"self",
",",
"text",
"=",
"\"\"",
")",
":",
"if",
"len",
"(",
"text",
")",
">",
"0",
":",
"self",
".",
"message_prefix",
"=",
"\"{}: \"",
".",
"format",
"(",
"text",
")",
"else",
":",
"self",
".",
"message_prefix",
"=",
"\"... | mise en place d'un préfixe à chaque écriture de message | [
"mise",
"en",
"place",
"d",
"un",
"préfixe",
"à",
"chaque",
"écriture",
"de",
"message"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L491-L496 |
mickbad/mblibs | mblibs/fast.py | FastLogger.setLevel | def setLevel(self, level):
""" Changement du niveau du Log """
if isinstance(level, int):
self.logger.setLevel(level)
return
# level en tant que string
level = level.lower()
if level == "debug":
self.logger.setLevel(logging.DEBUG)
elif level == "info":
self.logger.setLevel(logging.INFO)
eli... | python | def setLevel(self, level):
""" Changement du niveau du Log """
if isinstance(level, int):
self.logger.setLevel(level)
return
# level en tant que string
level = level.lower()
if level == "debug":
self.logger.setLevel(logging.DEBUG)
elif level == "info":
self.logger.setLevel(logging.INFO)
eli... | [
"def",
"setLevel",
"(",
"self",
",",
"level",
")",
":",
"if",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"self",
".",
"logger",
".",
"setLevel",
"(",
"level",
")",
"return",
"# level en tant que string",
"level",
"=",
"level",
".",
"lower",
"(",
... | Changement du niveau du Log | [
"Changement",
"du",
"niveau",
"du",
"Log"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L499-L521 |
mickbad/mblibs | mblibs/fast.py | FastLogger.info | def info(self, text):
""" Ajout d'un message de log de type INFO """
self.logger.info("{}{}".format(self.message_prefix, text)) | python | def info(self, text):
""" Ajout d'un message de log de type INFO """
self.logger.info("{}{}".format(self.message_prefix, text)) | [
"def",
"info",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type INFO | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"INFO"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L524-L526 |
mickbad/mblibs | mblibs/fast.py | FastLogger.debug | def debug(self, text):
""" Ajout d'un message de log de type DEBUG """
self.logger.debug("{}{}".format(self.message_prefix, text)) | python | def debug(self, text):
""" Ajout d'un message de log de type DEBUG """
self.logger.debug("{}{}".format(self.message_prefix, text)) | [
"def",
"debug",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type DEBUG | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"DEBUG"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L529-L531 |
mickbad/mblibs | mblibs/fast.py | FastLogger.warn | def warn(self, text):
""" Ajout d'un message de log de type WARN """
self.logger.warn("{}{}".format(self.message_prefix, text)) | python | def warn(self, text):
""" Ajout d'un message de log de type WARN """
self.logger.warn("{}{}".format(self.message_prefix, text)) | [
"def",
"warn",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"warn",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type WARN | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"WARN"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L534-L536 |
mickbad/mblibs | mblibs/fast.py | FastLogger.warning | def warning(self, text):
""" Ajout d'un message de log de type WARN """
self.logger.warning("{}{}".format(self.message_prefix, text)) | python | def warning(self, text):
""" Ajout d'un message de log de type WARN """
self.logger.warning("{}{}".format(self.message_prefix, text)) | [
"def",
"warning",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type WARN | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"WARN"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L539-L541 |
mickbad/mblibs | mblibs/fast.py | FastLogger.error | def error(self, text):
""" Ajout d'un message de log de type ERROR """
self.logger.error("{}{}".format(self.message_prefix, text)) | python | def error(self, text):
""" Ajout d'un message de log de type ERROR """
self.logger.error("{}{}".format(self.message_prefix, text)) | [
"def",
"error",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"message_prefix",
",",
"text",
")",
")"
] | Ajout d'un message de log de type ERROR | [
"Ajout",
"d",
"un",
"message",
"de",
"log",
"de",
"type",
"ERROR"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L544-L546 |
mickbad/mblibs | mblibs/fast.py | FastEmail.setHTML_from_file | def setHTML_from_file(self, filename, args):
""" Définition d'un texte pour le cord du message """
# vérification d'usage
if not os.path.isfile(filename):
return False
with open(filename) as fp:
# Create a text/plain message
self.mail_html = fp.read().format(**args)
# retour ok
return True | python | def setHTML_from_file(self, filename, args):
""" Définition d'un texte pour le cord du message """
# vérification d'usage
if not os.path.isfile(filename):
return False
with open(filename) as fp:
# Create a text/plain message
self.mail_html = fp.read().format(**args)
# retour ok
return True | [
"def",
"setHTML_from_file",
"(",
"self",
",",
"filename",
",",
"args",
")",
":",
"# vérification d'usage",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"False",
"with",
"open",
"(",
"filename",
")",
"as",
"fp",
":"... | Définition d'un texte pour le cord du message | [
"Définition",
"d",
"un",
"texte",
"pour",
"le",
"cord",
"du",
"message"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L585-L596 |
mickbad/mblibs | mblibs/fast.py | FastEmail.send_mail | def send_mail(self, to, cc=[], bcc=[], attachfiles=[], embeddedimages_tag="graphic_embedded", embeddedimages=[]):
"""
Envoi d'un email à un ou plusieurs correspondants
:param to: liste des correspondants en adresse directe
:param cc: liste des correspondants en copie du mail
:param bcc: liste des corresponda... | python | def send_mail(self, to, cc=[], bcc=[], attachfiles=[], embeddedimages_tag="graphic_embedded", embeddedimages=[]):
"""
Envoi d'un email à un ou plusieurs correspondants
:param to: liste des correspondants en adresse directe
:param cc: liste des correspondants en copie du mail
:param bcc: liste des corresponda... | [
"def",
"send_mail",
"(",
"self",
",",
"to",
",",
"cc",
"=",
"[",
"]",
",",
"bcc",
"=",
"[",
"]",
",",
"attachfiles",
"=",
"[",
"]",
",",
"embeddedimages_tag",
"=",
"\"graphic_embedded\"",
",",
"embeddedimages",
"=",
"[",
"]",
")",
":",
"# vérifications... | Envoi d'un email à un ou plusieurs correspondants
:param to: liste des correspondants en adresse directe
:param cc: liste des correspondants en copie du mail
:param bcc: liste des correspondants en copie caché du mail
:param attachfiles: liste des fichiers à mettre en pièce jointe (chemin exacte)
:param embe... | [
"Envoi",
"d",
"un",
"email",
"à",
"un",
"ou",
"plusieurs",
"correspondants"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L599-L722 |
mickbad/mblibs | mblibs/fast.py | FastThread.run | def run(self):
""" Fonctionnement du thread """
if self.debug:
print("Starting " + self.name)
# Lancement du programme du thread
if isinstance(self.function, str):
globals()[self.function](*self.args, **self.kwargs)
else:
self.function(*self.args, **self.kwargs)
if self.debug:
print("Exiting "... | python | def run(self):
""" Fonctionnement du thread """
if self.debug:
print("Starting " + self.name)
# Lancement du programme du thread
if isinstance(self.function, str):
globals()[self.function](*self.args, **self.kwargs)
else:
self.function(*self.args, **self.kwargs)
if self.debug:
print("Exiting "... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"Starting \"",
"+",
"self",
".",
"name",
")",
"# Lancement du programme du thread",
"if",
"isinstance",
"(",
"self",
".",
"function",
",",
"str",
")",
":",
"globals",
"... | Fonctionnement du thread | [
"Fonctionnement",
"du",
"thread"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L781-L793 |
mickbad/mblibs | mblibs/fast.py | FastDate.convert | def convert(self, date_from=None, date_format=None):
"""
Retourne la date courante ou depuis l'argument au format datetime
:param: :date_from date de référence
:return datetime
"""
try:
if date_format is None:
# on détermine la date avec dateutil
return dateutil.parser.parse(date_from)
# il ... | python | def convert(self, date_from=None, date_format=None):
"""
Retourne la date courante ou depuis l'argument au format datetime
:param: :date_from date de référence
:return datetime
"""
try:
if date_format is None:
# on détermine la date avec dateutil
return dateutil.parser.parse(date_from)
# il ... | [
"def",
"convert",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"try",
":",
"if",
"date_format",
"is",
"None",
":",
"# on détermine la date avec dateutil",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"date... | Retourne la date courante ou depuis l'argument au format datetime
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"courante",
"ou",
"depuis",
"l",
"argument",
"au",
"format",
"datetime"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L810-L827 |
mickbad/mblibs | mblibs/fast.py | FastDate.delta | def delta(self, date_from=None, date_format=None, days=0, hours=0, minutes=0, seconds=0, days_range=[1, 2, 3, 4, 5, 6, 7]):
"""
Retourne la date courante ou depuis une date fournie moins un delta
et étant autorisé dans une plage de jour (lundi=1 ... dimanche=7)
:param: :date_from date de référence
:param: :d... | python | def delta(self, date_from=None, date_format=None, days=0, hours=0, minutes=0, seconds=0, days_range=[1, 2, 3, 4, 5, 6, 7]):
"""
Retourne la date courante ou depuis une date fournie moins un delta
et étant autorisé dans une plage de jour (lundi=1 ... dimanche=7)
:param: :date_from date de référence
:param: :d... | [
"def",
"delta",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
",",
"days",
"=",
"0",
",",
"hours",
"=",
"0",
",",
"minutes",
"=",
"0",
",",
"seconds",
"=",
"0",
",",
"days_range",
"=",
"[",
"1",
",",
"2",
",",
"3"... | Retourne la date courante ou depuis une date fournie moins un delta
et étant autorisé dans une plage de jour (lundi=1 ... dimanche=7)
:param: :date_from date de référence
:param: :days nombre de jours à changer
:param: :hours nombre d'heures à changer
:param: :minutes nombre de minutes à changer
:param: :s... | [
"Retourne",
"la",
"date",
"courante",
"ou",
"depuis",
"une",
"date",
"fournie",
"moins",
"un",
"delta",
"et",
"étant",
"autorisé",
"dans",
"une",
"plage",
"de",
"jour",
"(",
"lundi",
"=",
"1",
"...",
"dimanche",
"=",
"7",
")"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L830-L877 |
mickbad/mblibs | mblibs/fast.py | FastDate.yesterday | def yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime
"""
# date d'hier
return self.delta(date_from=date_from, date_format=date_format, days=-1) | python | def yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime
"""
# date d'hier
return self.delta(date_from=date_from, date_format=date_format, days=-1) | [
"def",
"yesterday",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date d'hier",
"return",
"self",
".",
"delta",
"(",
"date_from",
"=",
"date_from",
",",
"date_format",
"=",
"date_format",
",",
"days",
"=",
"-",
... | Retourne la date d'hier depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"d",
"hier",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L884-L892 |
mickbad/mblibs | mblibs/fast.py | FastDate.weekday_yesterday | def weekday_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date d'hier que ... | python | def weekday_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date d'hier que ... | [
"def",
"weekday_yesterday",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date d'hier que sur les jours de semaine",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"-",
"1",
",",
"date_from",
"=",
"date_from",
","... | Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"d",
"hier",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"de",
"semaine",
".",
"Ainsi",
"vendredi",
"devient",
"jeudi",
"et",
"lundi",
"devient",
"vendredi"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L895-L905 |
mickbad/mblibs | mblibs/fast.py | FastDate.weekend_yesterday | def weekend_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime
"""
# date d'hier qu... | python | def weekend_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime
"""
# date d'hier qu... | [
"def",
"weekend_yesterday",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date d'hier que sur les jours de week-end",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"-",
"1",
",",
"date_from",
"=",
"date_from",
",... | Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"d",
"hier",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"de",
"weekend",
".",
"Ainsi",
"dimanche",
"devient",
"samedi",
"et",
"samedi",
"devient",
"dimanche"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L908-L918 |
mickbad/mblibs | mblibs/fast.py | FastDate.working_yesterday | def working_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date d'hier que su... | python | def working_yesterday(self, date_from=None, date_format=None):
"""
Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date d'hier que su... | [
"def",
"working_yesterday",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date d'hier que sur les jours de week-end",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"-",
"1",
",",
"date_from",
"=",
"date_from",
",... | Retourne la date d'hier depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"d",
"hier",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"ouvrableq",
".",
"Ainsi",
"lundi",
"devient",
"samedi",
"et",
"samedi",
"devient",
"vendredi"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L921-L931 |
mickbad/mblibs | mblibs/fast.py | FastDate.tomorrow | def tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime
"""
# date de demain
return self.delta(date_from=date_from, date_format=date_format, days=1) | python | def tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime
"""
# date de demain
return self.delta(date_from=date_from, date_format=date_format, days=1) | [
"def",
"tomorrow",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date de demain",
"return",
"self",
".",
"delta",
"(",
"date_from",
"=",
"date_from",
",",
"date_format",
"=",
"date_format",
",",
"days",
"=",
"1",... | Retourne la date de demain depuis maintenant ou depuis une date fournie
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"de",
"demain",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L938-L946 |
mickbad/mblibs | mblibs/fast.py | FastDate.weekday_tomorrow | def weekday_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date de demain... | python | def weekday_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date de demain... | [
"def",
"weekday_tomorrow",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date de demain que sur les jours de semaine",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"1",
",",
"date_from",
"=",
"date_from",
",",
"... | Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de semaine.
Ainsi vendredi devient jeudi et lundi devient vendredi
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"de",
"demain",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"de",
"semaine",
".",
"Ainsi",
"vendredi",
"devient",
"jeudi",
"et",
"lundi",
"devient",
"vendredi"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L949-L959 |
mickbad/mblibs | mblibs/fast.py | FastDate.weekend_tomorrow | def weekend_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime
"""
# date de dema... | python | def weekend_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime
"""
# date de dema... | [
"def",
"weekend_tomorrow",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date de demain que sur les jours de week-end",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"1",
",",
"date_from",
"=",
"date_from",
",",
... | Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours de weekend.
Ainsi dimanche devient samedi et samedi devient dimanche
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"de",
"demain",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"de",
"weekend",
".",
"Ainsi",
"dimanche",
"devient",
"samedi",
"et",
"samedi",
"devient",
"dimanche"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L962-L972 |
mickbad/mblibs | mblibs/fast.py | FastDate.working_tomorrow | def working_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date de demain q... | python | def working_tomorrow(self, date_from=None, date_format=None):
"""
Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime
"""
# date de demain q... | [
"def",
"working_tomorrow",
"(",
"self",
",",
"date_from",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# date de demain que sur les jours de week-end",
"return",
"self",
".",
"delta",
"(",
"days",
"=",
"1",
",",
"date_from",
"=",
"date_from",
",",
... | Retourne la date de demain depuis maintenant ou depuis une date fournie
seulement sur les jours ouvrableq.
Ainsi lundi devient samedi et samedi devient vendredi
:param: :date_from date de référence
:return datetime | [
"Retourne",
"la",
"date",
"de",
"demain",
"depuis",
"maintenant",
"ou",
"depuis",
"une",
"date",
"fournie",
"seulement",
"sur",
"les",
"jours",
"ouvrableq",
".",
"Ainsi",
"lundi",
"devient",
"samedi",
"et",
"samedi",
"devient",
"vendredi"
] | train | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L975-L985 |
thespacedoctor/neddy | neddy/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="ERROR",
option... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="ERROR",
option... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"ERROR\"",
",",
"options_first",
"=",
"True",
")... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | train | https://github.com/thespacedoctor/neddy/blob/f32653b7d6a39a2c46c5845f83b3a29056311e5e/neddy/cl_utils.py#L46-L164 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | EventSystem.handle | def handle(self, handler):
""" register a handler (add a callback function) """
with self._hlock:
self._handler_list.append(handler)
return self | python | def handle(self, handler):
""" register a handler (add a callback function) """
with self._hlock:
self._handler_list.append(handler)
return self | [
"def",
"handle",
"(",
"self",
",",
"handler",
")",
":",
"with",
"self",
".",
"_hlock",
":",
"self",
".",
"_handler_list",
".",
"append",
"(",
"handler",
")",
"return",
"self"
] | register a handler (add a callback function) | [
"register",
"a",
"handler",
"(",
"add",
"a",
"callback",
"function",
")"
] | train | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L130-L134 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | EventSystem.unhandle | def unhandle(self, handler):
""" unregister handler (removing callback function) """
with self._hlock:
try:
self._handler_list.remove(handler)
except ValueError:
raise ValueError("Handler is not handling this event, so cannot unhandle it.")
... | python | def unhandle(self, handler):
""" unregister handler (removing callback function) """
with self._hlock:
try:
self._handler_list.remove(handler)
except ValueError:
raise ValueError("Handler is not handling this event, so cannot unhandle it.")
... | [
"def",
"unhandle",
"(",
"self",
",",
"handler",
")",
":",
"with",
"self",
".",
"_hlock",
":",
"try",
":",
"self",
".",
"_handler_list",
".",
"remove",
"(",
"handler",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"\"Handler is not handling th... | unregister handler (removing callback function) | [
"unregister",
"handler",
"(",
"removing",
"callback",
"function",
")"
] | train | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L136-L143 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | EventSystem.fire | def fire(self, *args, **kargs):
""" collects results of all executed handlers """
self._time_secs_old = time.time()
# allow register/unregister while execution
# (a shallowcopy should be okay.. https://docs.python.org/2/library/copy.html )
with self._hlock:
handler_l... | python | def fire(self, *args, **kargs):
""" collects results of all executed handlers """
self._time_secs_old = time.time()
# allow register/unregister while execution
# (a shallowcopy should be okay.. https://docs.python.org/2/library/copy.html )
with self._hlock:
handler_l... | [
"def",
"fire",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"self",
".",
"_time_secs_old",
"=",
"time",
".",
"time",
"(",
")",
"# allow register/unregister while execution",
"# (a shallowcopy should be okay.. https://docs.python.org/2/library/copy.ht... | collects results of all executed handlers | [
"collects",
"results",
"of",
"all",
"executed",
"handlers"
] | train | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L145-L174 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | EventSystem._execute | def _execute(self, handler, *args, **kwargs):
""" executes one callback function """
# difference to Axel Events: we don't use a timeout and execute all handlers in same thread
# FIXME: =>possible problem:
# blocking of event firing when user gives a long- or infini... | python | def _execute(self, handler, *args, **kwargs):
""" executes one callback function """
# difference to Axel Events: we don't use a timeout and execute all handlers in same thread
# FIXME: =>possible problem:
# blocking of event firing when user gives a long- or infini... | [
"def",
"_execute",
"(",
"self",
",",
"handler",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# difference to Axel Events: we don't use a timeout and execute all handlers in same thread",
"# FIXME: =>possible problem:",
"# blocking of event firing when... | executes one callback function | [
"executes",
"one",
"callback",
"function"
] | train | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L176-L195 |
stefanbraun-private/visitoolkit_eventsystem | visitoolkit_eventsystem/eventsystem.py | EventSystem._error | def _error(self, exc_info):
""" Retrieves the error info """
if self._exc_info:
if self._traceback:
return exc_info
return exc_info[:2]
return exc_info[1] | python | def _error(self, exc_info):
""" Retrieves the error info """
if self._exc_info:
if self._traceback:
return exc_info
return exc_info[:2]
return exc_info[1] | [
"def",
"_error",
"(",
"self",
",",
"exc_info",
")",
":",
"if",
"self",
".",
"_exc_info",
":",
"if",
"self",
".",
"_traceback",
":",
"return",
"exc_info",
"return",
"exc_info",
"[",
":",
"2",
"]",
"return",
"exc_info",
"[",
"1",
"]"
] | Retrieves the error info | [
"Retrieves",
"the",
"error",
"info"
] | train | https://github.com/stefanbraun-private/visitoolkit_eventsystem/blob/d606a167ac3b8edc5bfbd8de7fb7063a9a1922f1/visitoolkit_eventsystem/eventsystem.py#L197-L203 |
laysakura/relshell | relshell/recorddef.py | RecordDef.colindex_by_colname | def colindex_by_colname(self, colname):
"""Return column index whose name is :param:`column`
:raises: `ValueError` when no column with :param:`colname` found
"""
for i, coldef in enumerate(self): # iterate each column's definition
if coldef.name == colname:
... | python | def colindex_by_colname(self, colname):
"""Return column index whose name is :param:`column`
:raises: `ValueError` when no column with :param:`colname` found
"""
for i, coldef in enumerate(self): # iterate each column's definition
if coldef.name == colname:
... | [
"def",
"colindex_by_colname",
"(",
"self",
",",
"colname",
")",
":",
"for",
"i",
",",
"coldef",
"in",
"enumerate",
"(",
"self",
")",
":",
"# iterate each column's definition",
"if",
"coldef",
".",
"name",
"==",
"colname",
":",
"return",
"i",
"raise",
"ValueE... | Return column index whose name is :param:`column`
:raises: `ValueError` when no column with :param:`colname` found | [
"Return",
"column",
"index",
"whose",
"name",
"is",
":",
"param",
":",
"column"
] | train | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/recorddef.py#L67-L75 |
romantolkachyov/django-bridge | django_bridge/templatetags/bridge.py | bridge | def bridge(filename):
""" Add hash to filename for cache invalidation.
Uses gulp-buster for cache invalidation. Adds current file hash as url arg.
"""
if not hasattr(settings, 'BASE_DIR'):
raise Exception("You must provide BASE_DIR in settings for bridge")
file_path = getattr(settings, 'BUS... | python | def bridge(filename):
""" Add hash to filename for cache invalidation.
Uses gulp-buster for cache invalidation. Adds current file hash as url arg.
"""
if not hasattr(settings, 'BASE_DIR'):
raise Exception("You must provide BASE_DIR in settings for bridge")
file_path = getattr(settings, 'BUS... | [
"def",
"bridge",
"(",
"filename",
")",
":",
"if",
"not",
"hasattr",
"(",
"settings",
",",
"'BASE_DIR'",
")",
":",
"raise",
"Exception",
"(",
"\"You must provide BASE_DIR in settings for bridge\"",
")",
"file_path",
"=",
"getattr",
"(",
"settings",
",",
"'BUSTERS_F... | Add hash to filename for cache invalidation.
Uses gulp-buster for cache invalidation. Adds current file hash as url arg. | [
"Add",
"hash",
"to",
"filename",
"for",
"cache",
"invalidation",
"."
] | train | https://github.com/romantolkachyov/django-bridge/blob/c2ded281feecaca108072ad1934e216f34320ce5/django_bridge/templatetags/bridge.py#L11-L27 |
laysakura/relshell | relshell/shelloperator.py | ShellOperator.run | def run(self, in_batches):
"""Run shell operator synchronously to eat `in_batches`
:param in_batches: `tuple` of batches to process
"""
if len(in_batches) != len(self._batcmd.batch_to_file_s):
BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s) # [tod... | python | def run(self, in_batches):
"""Run shell operator synchronously to eat `in_batches`
:param in_batches: `tuple` of batches to process
"""
if len(in_batches) != len(self._batcmd.batch_to_file_s):
BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s) # [tod... | [
"def",
"run",
"(",
"self",
",",
"in_batches",
")",
":",
"if",
"len",
"(",
"in_batches",
")",
"!=",
"len",
"(",
"self",
".",
"_batcmd",
".",
"batch_to_file_s",
")",
":",
"BaseShellOperator",
".",
"_rm_process_input_tmpfiles",
"(",
"self",
".",
"_batcmd",
".... | Run shell operator synchronously to eat `in_batches`
:param in_batches: `tuple` of batches to process | [
"Run",
"shell",
"operator",
"synchronously",
"to",
"eat",
"in_batches"
] | train | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/shelloperator.py#L49-L78 |
gersolar/goescalibration | goescalibration/instrument.py | calibrate | def calibrate(filename):
"""
Append the calibration parameters as variables of the netcdf file.
Keyword arguments:
filename -- the name of a netcdf file.
"""
params = calibration_to(filename)
with nc.loader(filename) as root:
for key, value in params.items():
nc.getdim(r... | python | def calibrate(filename):
"""
Append the calibration parameters as variables of the netcdf file.
Keyword arguments:
filename -- the name of a netcdf file.
"""
params = calibration_to(filename)
with nc.loader(filename) as root:
for key, value in params.items():
nc.getdim(r... | [
"def",
"calibrate",
"(",
"filename",
")",
":",
"params",
"=",
"calibration_to",
"(",
"filename",
")",
"with",
"nc",
".",
"loader",
"(",
"filename",
")",
"as",
"root",
":",
"for",
"key",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"nc",... | Append the calibration parameters as variables of the netcdf file.
Keyword arguments:
filename -- the name of a netcdf file. | [
"Append",
"the",
"calibration",
"parameters",
"as",
"variables",
"of",
"the",
"netcdf",
"file",
"."
] | train | https://github.com/gersolar/goescalibration/blob/aab7f3e3cede9694e90048ceeaea74566578bc75/goescalibration/instrument.py#L37-L53 |
ryanjdillon/yamlord | yamlord/yamio.py | read_yaml | def read_yaml(file_path, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
'''Read YAML file and return as python dictionary'''
# http://stackoverflow.com/a/21912744/943773
class OrderedLoader(Loader):
pass
def construct_mapping(loader, node):
loader.flatten_mapping(node)
ret... | python | def read_yaml(file_path, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
'''Read YAML file and return as python dictionary'''
# http://stackoverflow.com/a/21912744/943773
class OrderedLoader(Loader):
pass
def construct_mapping(loader, node):
loader.flatten_mapping(node)
ret... | [
"def",
"read_yaml",
"(",
"file_path",
",",
"Loader",
"=",
"yaml",
".",
"Loader",
",",
"object_pairs_hook",
"=",
"OrderedDict",
")",
":",
"# http://stackoverflow.com/a/21912744/943773",
"class",
"OrderedLoader",
"(",
"Loader",
")",
":",
"pass",
"def",
"construct_mapp... | Read YAML file and return as python dictionary | [
"Read",
"YAML",
"file",
"and",
"return",
"as",
"python",
"dictionary"
] | train | https://github.com/ryanjdillon/yamlord/blob/a8abe5cd1b3294612bb466183f2f830e6666e22e/yamlord/yamio.py#L4-L21 |
ryanjdillon/yamlord | yamlord/yamio.py | write_yaml | def write_yaml(data, out_path, Dumper=yaml.Dumper, **kwds):
'''Write python dictionary to YAML'''
import errno
import os
class OrderedDumper(Dumper):
pass
def _dict_representer(dumper, data):
return dumper.represent_mapping(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG... | python | def write_yaml(data, out_path, Dumper=yaml.Dumper, **kwds):
'''Write python dictionary to YAML'''
import errno
import os
class OrderedDumper(Dumper):
pass
def _dict_representer(dumper, data):
return dumper.represent_mapping(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG... | [
"def",
"write_yaml",
"(",
"data",
",",
"out_path",
",",
"Dumper",
"=",
"yaml",
".",
"Dumper",
",",
"*",
"*",
"kwds",
")",
":",
"import",
"errno",
"import",
"os",
"class",
"OrderedDumper",
"(",
"Dumper",
")",
":",
"pass",
"def",
"_dict_representer",
"(",
... | Write python dictionary to YAML | [
"Write",
"python",
"dictionary",
"to",
"YAML"
] | train | https://github.com/ryanjdillon/yamlord/blob/a8abe5cd1b3294612bb466183f2f830e6666e22e/yamlord/yamio.py#L24-L49 |
tylerbutler/propane | propane/django/debug.py | _get_named_patterns | def _get_named_patterns():
"""Returns list of (pattern-name, pattern) tuples"""
resolver = urlresolvers.get_resolver(None)
patterns = sorted([(key, value[0][0][0])
for key, value in resolver.reverse_dict.items()
if isinstance(key, string_types)
... | python | def _get_named_patterns():
"""Returns list of (pattern-name, pattern) tuples"""
resolver = urlresolvers.get_resolver(None)
patterns = sorted([(key, value[0][0][0])
for key, value in resolver.reverse_dict.items()
if isinstance(key, string_types)
... | [
"def",
"_get_named_patterns",
"(",
")",
":",
"resolver",
"=",
"urlresolvers",
".",
"get_resolver",
"(",
"None",
")",
"patterns",
"=",
"sorted",
"(",
"[",
"(",
"key",
",",
"value",
"[",
"0",
"]",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"for",
"key",
",",... | Returns list of (pattern-name, pattern) tuples | [
"Returns",
"list",
"of",
"(",
"pattern",
"-",
"name",
"pattern",
")",
"tuples"
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/django/debug.py#L36-L43 |
pjanis/funtool | funtool/state_collection.py | join_state_collections | def join_state_collections( collection_a, collection_b):
"""
Warning: This is a very naive join. Only use it when measures and groups will remain entirely within each subcollection.
For example: if each collection has states grouped by date and both include the same date, then the new collection
w... | python | def join_state_collections( collection_a, collection_b):
"""
Warning: This is a very naive join. Only use it when measures and groups will remain entirely within each subcollection.
For example: if each collection has states grouped by date and both include the same date, then the new collection
w... | [
"def",
"join_state_collections",
"(",
"collection_a",
",",
"collection_b",
")",
":",
"return",
"StateCollection",
"(",
"(",
"collection_a",
".",
"states",
"+",
"collection_b",
".",
"states",
")",
",",
"{",
"grouping_name",
":",
"_combined_grouping_values",
"(",
"g... | Warning: This is a very naive join. Only use it when measures and groups will remain entirely within each subcollection.
For example: if each collection has states grouped by date and both include the same date, then the new collection
would have both of those groups, likely causing problems for group mea... | [
"Warning",
":",
"This",
"is",
"a",
"very",
"naive",
"join",
".",
"Only",
"use",
"it",
"when",
"measures",
"and",
"groups",
"will",
"remain",
"entirely",
"within",
"each",
"subcollection",
"."
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_collection.py#L11-L23 |
pjanis/funtool | funtool/state_collection.py | add_grouping | def add_grouping(state_collection, grouping_name, loaded_processes, overriding_parameters=None):
"""
Adds a grouping to a state collection by using the process selected by the grouping name
Does not override existing groupings
"""
if (
grouping_name not in state_collection.groupings and... | python | def add_grouping(state_collection, grouping_name, loaded_processes, overriding_parameters=None):
"""
Adds a grouping to a state collection by using the process selected by the grouping name
Does not override existing groupings
"""
if (
grouping_name not in state_collection.groupings and... | [
"def",
"add_grouping",
"(",
"state_collection",
",",
"grouping_name",
",",
"loaded_processes",
",",
"overriding_parameters",
"=",
"None",
")",
":",
"if",
"(",
"grouping_name",
"not",
"in",
"state_collection",
".",
"groupings",
"and",
"loaded_processes",
"!=",
"None"... | Adds a grouping to a state collection by using the process selected by the grouping name
Does not override existing groupings | [
"Adds",
"a",
"grouping",
"to",
"a",
"state",
"collection",
"by",
"using",
"the",
"process",
"selected",
"by",
"the",
"grouping",
"name",
"Does",
"not",
"override",
"existing",
"groupings"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_collection.py#L26-L38 |
pjanis/funtool | funtool/state_collection.py | add_group_to_grouping | def add_group_to_grouping(state_collection, grouping_name, group, group_key=None):
"""
Adds a group to the named grouping, with a given group key
If no group key is given, the lowest available integer becomes the group key
If no grouping exists by the given name a new one will be created
Replaces... | python | def add_group_to_grouping(state_collection, grouping_name, group, group_key=None):
"""
Adds a group to the named grouping, with a given group key
If no group key is given, the lowest available integer becomes the group key
If no grouping exists by the given name a new one will be created
Replaces... | [
"def",
"add_group_to_grouping",
"(",
"state_collection",
",",
"grouping_name",
",",
"group",
",",
"group_key",
"=",
"None",
")",
":",
"if",
"state_collection",
".",
"groupings",
".",
"get",
"(",
"grouping_name",
")",
"is",
"None",
":",
"state_collection",
".",
... | Adds a group to the named grouping, with a given group key
If no group key is given, the lowest available integer becomes the group key
If no grouping exists by the given name a new one will be created
Replaces any group with the same grouping_name and the same group_key | [
"Adds",
"a",
"group",
"to",
"the",
"named",
"grouping",
"with",
"a",
"given",
"group",
"key"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_collection.py#L40-L55 |
pjanis/funtool | funtool/state_collection.py | _combined_grouping_values | def _combined_grouping_values(grouping_name,collection_a,collection_b):
"""
returns a dict with values from both collections for a given grouping name
Warning: collection2 overrides collection1 if there is a group_key conflict
"""
new_grouping= collection_a.groupings.get(grouping_name,{}).copy()
... | python | def _combined_grouping_values(grouping_name,collection_a,collection_b):
"""
returns a dict with values from both collections for a given grouping name
Warning: collection2 overrides collection1 if there is a group_key conflict
"""
new_grouping= collection_a.groupings.get(grouping_name,{}).copy()
... | [
"def",
"_combined_grouping_values",
"(",
"grouping_name",
",",
"collection_a",
",",
"collection_b",
")",
":",
"new_grouping",
"=",
"collection_a",
".",
"groupings",
".",
"get",
"(",
"grouping_name",
",",
"{",
"}",
")",
".",
"copy",
"(",
")",
"new_grouping",
".... | returns a dict with values from both collections for a given grouping name
Warning: collection2 overrides collection1 if there is a group_key conflict | [
"returns",
"a",
"dict",
"with",
"values",
"from",
"both",
"collections",
"for",
"a",
"given",
"grouping",
"name"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_collection.py#L67-L75 |
pjanis/funtool | funtool/state_collection.py | _next_lowest_integer | def _next_lowest_integer(group_keys):
"""
returns the lowest available integer in a set of dict keys
"""
try: #TODO Replace with max default value when dropping compatibility with Python < 3.4
largest_int= max([ int(val) for val in group_keys if _is_int(val)])
except:
largest_int= 0
... | python | def _next_lowest_integer(group_keys):
"""
returns the lowest available integer in a set of dict keys
"""
try: #TODO Replace with max default value when dropping compatibility with Python < 3.4
largest_int= max([ int(val) for val in group_keys if _is_int(val)])
except:
largest_int= 0
... | [
"def",
"_next_lowest_integer",
"(",
"group_keys",
")",
":",
"try",
":",
"#TODO Replace with max default value when dropping compatibility with Python < 3.4",
"largest_int",
"=",
"max",
"(",
"[",
"int",
"(",
"val",
")",
"for",
"val",
"in",
"group_keys",
"if",
"_is_int",
... | returns the lowest available integer in a set of dict keys | [
"returns",
"the",
"lowest",
"available",
"integer",
"in",
"a",
"set",
"of",
"dict",
"keys"
] | train | https://github.com/pjanis/funtool/blob/231851238f0a62bc3682d8fa937db9053378c53d/funtool/state_collection.py#L77-L85 |
gfranxman/utinypass | utinypass/client.py | TinyPassApiClient.get_access_list | def get_access_list( self, email, uid ):
'''
Takes and email and matching uid, builds a uref and fetches an access structure that looks like:
{
"count": 1,
"code": 0,
"ts": 1428522205,
"limit": 100,
"offset": 0,
... | python | def get_access_list( self, email, uid ):
'''
Takes and email and matching uid, builds a uref and fetches an access structure that looks like:
{
"count": 1,
"code": 0,
"ts": 1428522205,
"limit": 100,
"offset": 0,
... | [
"def",
"get_access_list",
"(",
"self",
",",
"email",
",",
"uid",
")",
":",
"path",
"=",
"'/api/v3/access/list'",
"# package the user",
"userRef",
"=",
"{",
"'uid'",
":",
"uid",
",",
"'email'",
":",
"email",
",",
"'timestamp'",
":",
"int",
"(",
"time",
".",... | Takes and email and matching uid, builds a uref and fetches an access structure that looks like:
{
"count": 1,
"code": 0,
"ts": 1428522205,
"limit": 100,
"offset": 0,
"total": 1,
"data": [
... | [
"Takes",
"and",
"email",
"and",
"matching",
"uid",
"builds",
"a",
"uref",
"and",
"fetches",
"an",
"access",
"structure",
"that",
"looks",
"like",
":"
] | train | https://github.com/gfranxman/utinypass/blob/c49cff25ae408dbbb58ec98d1c87894474011cdf/utinypass/client.py#L26-L84 |
gfranxman/utinypass | utinypass/client.py | TinyPassApiClient.grant_user_access | def grant_user_access( self, uid, rid, expire_datetime = None, send_email=False ):
'''
Takes a user id and resource id and records a grant of access to that reseource for the user.
If no expire_date is set, we'll default to 24 hours.
If send_email is set to True, Tinypass wil... | python | def grant_user_access( self, uid, rid, expire_datetime = None, send_email=False ):
'''
Takes a user id and resource id and records a grant of access to that reseource for the user.
If no expire_date is set, we'll default to 24 hours.
If send_email is set to True, Tinypass wil... | [
"def",
"grant_user_access",
"(",
"self",
",",
"uid",
",",
"rid",
",",
"expire_datetime",
"=",
"None",
",",
"send_email",
"=",
"False",
")",
":",
"path",
"=",
"\"/api/v3/publisher/user/access/grant\"",
"# convert expire_date to gmt seconds",
"if",
"expire_datetime",
":... | Takes a user id and resource id and records a grant of access to that reseource for the user.
If no expire_date is set, we'll default to 24 hours.
If send_email is set to True, Tinypass will send an email related to the grant.
No return value, raises ValueError. | [
"Takes",
"a",
"user",
"id",
"and",
"resource",
"id",
"and",
"records",
"a",
"grant",
"of",
"access",
"to",
"that",
"reseource",
"for",
"the",
"user",
".",
"If",
"no",
"expire_date",
"is",
"set",
"we",
"ll",
"default",
"to",
"24",
"hours",
".",
"If",
... | train | https://github.com/gfranxman/utinypass/blob/c49cff25ae408dbbb58ec98d1c87894474011cdf/utinypass/client.py#L87-L114 |
gfranxman/utinypass | utinypass/client.py | TinyPassApiClient.revoke_user_access | def revoke_user_access( self, access_id ):
'''
Takes an access_id, probably obtained from the get_access_list structure, and revokes that access.
No return value, but may raise ValueError.
'''
path = "/api/v3/publisher/user/access/revoke"
data = {
'a... | python | def revoke_user_access( self, access_id ):
'''
Takes an access_id, probably obtained from the get_access_list structure, and revokes that access.
No return value, but may raise ValueError.
'''
path = "/api/v3/publisher/user/access/revoke"
data = {
'a... | [
"def",
"revoke_user_access",
"(",
"self",
",",
"access_id",
")",
":",
"path",
"=",
"\"/api/v3/publisher/user/access/revoke\"",
"data",
"=",
"{",
"'api_token'",
":",
"self",
".",
"api_token",
",",
"'access_id'",
":",
"access_id",
",",
"}",
"r",
"=",
"requests",
... | Takes an access_id, probably obtained from the get_access_list structure, and revokes that access.
No return value, but may raise ValueError. | [
"Takes",
"an",
"access_id",
"probably",
"obtained",
"from",
"the",
"get_access_list",
"structure",
"and",
"revokes",
"that",
"access",
".",
"No",
"return",
"value",
"but",
"may",
"raise",
"ValueError",
"."
] | train | https://github.com/gfranxman/utinypass/blob/c49cff25ae408dbbb58ec98d1c87894474011cdf/utinypass/client.py#L118-L133 |
gfranxman/utinypass | utinypass/client.py | TinyPassApiClient.get_user | def get_user( self, uid, disabled=False ):
''' given a uid, returns
{
first_name (string): User's first name,
image1 (string): User's profile image,
email (string): User's email address,
create_date (string): The creation date,
last_name (string): User's last name... | python | def get_user( self, uid, disabled=False ):
''' given a uid, returns
{
first_name (string): User's first name,
image1 (string): User's profile image,
email (string): User's email address,
create_date (string): The creation date,
last_name (string): User's last name... | [
"def",
"get_user",
"(",
"self",
",",
"uid",
",",
"disabled",
"=",
"False",
")",
":",
"path",
"=",
"\"/api/v3/publisher/user/get\"",
"data",
"=",
"{",
"'api_token'",
":",
"self",
".",
"api_token",
",",
"'aid'",
":",
"self",
".",
"app_id",
",",
"'uid'",
":... | given a uid, returns
{
first_name (string): User's first name,
image1 (string): User's profile image,
email (string): User's email address,
create_date (string): The creation date,
last_name (string): User's last name,
uid (string): User's UID
}
Y... | [
"given",
"a",
"uid",
"returns",
"{",
"first_name",
"(",
"string",
")",
":",
"User",
"s",
"first",
"name",
"image1",
"(",
"string",
")",
":",
"User",
"s",
"profile",
"image",
"email",
"(",
"string",
")",
":",
"User",
"s",
"email",
"address",
"create_dat... | train | https://github.com/gfranxman/utinypass/blob/c49cff25ae408dbbb58ec98d1c87894474011cdf/utinypass/client.py#L202-L243 |
kislyuk/httpnext | httpnext/__init__.py | HTTPConnection._send_head | def _send_head(self):
self._transport.write("{} {} HTTP/1.1\r\n".format(self._method, self._url).encode())
for header in self._headers:
self._transport.write("{}:{}\r\n".format(header, self._headers[header]).encode())
self._transport.write(b"\r\n")
print("Sent head")
# ... | python | def _send_head(self):
self._transport.write("{} {} HTTP/1.1\r\n".format(self._method, self._url).encode())
for header in self._headers:
self._transport.write("{}:{}\r\n".format(header, self._headers[header]).encode())
self._transport.write(b"\r\n")
print("Sent head")
# ... | [
"def",
"_send_head",
"(",
"self",
")",
":",
"self",
".",
"_transport",
".",
"write",
"(",
"\"{} {} HTTP/1.1\\r\\n\"",
".",
"format",
"(",
"self",
".",
"_method",
",",
"self",
".",
"_url",
")",
".",
"encode",
"(",
")",
")",
"for",
"header",
"in",
"self"... | if method == "POST":
headers["Expect"] = "100-continue"
# headers["Content-Length"] = str(len(body))
headers["Transfer-Encoding"] = "chunked"
self._ready_to_send_body = False
self._eof_received = False
self.body = body
self.response = b""
self.t... | [
"if",
"method",
"==",
"POST",
":",
"headers",
"[",
"Expect",
"]",
"=",
"100",
"-",
"continue",
"#",
"headers",
"[",
"Content",
"-",
"Length",
"]",
"=",
"str",
"(",
"len",
"(",
"body",
"))",
"headers",
"[",
"Transfer",
"-",
"Encoding",
"]",
"=",
"ch... | train | https://github.com/kislyuk/httpnext/blob/2708d822867b1d863104af30d6364fa90adf0933/httpnext/__init__.py#L91-L116 |
hawkowl/txctools | txctools/reports/hotspot.py | HotspotReport.process | def process(self):
"""
Process the warnings.
"""
for filename, warnings in self.warnings.iteritems():
self.fileCounts[filename] = {}
fc = self.fileCounts[filename]
fc["warning_count"] = len(warnings)
fc["warning_breakdown"] = self._warnCo... | python | def process(self):
"""
Process the warnings.
"""
for filename, warnings in self.warnings.iteritems():
self.fileCounts[filename] = {}
fc = self.fileCounts[filename]
fc["warning_count"] = len(warnings)
fc["warning_breakdown"] = self._warnCo... | [
"def",
"process",
"(",
"self",
")",
":",
"for",
"filename",
",",
"warnings",
"in",
"self",
".",
"warnings",
".",
"iteritems",
"(",
")",
":",
"self",
".",
"fileCounts",
"[",
"filename",
"]",
"=",
"{",
"}",
"fc",
"=",
"self",
".",
"fileCounts",
"[",
... | Process the warnings. | [
"Process",
"the",
"warnings",
"."
] | train | https://github.com/hawkowl/txctools/blob/14cab033ea179211a7bfd88dc202d576fc336ddc/txctools/reports/hotspot.py#L39-L51 |
hawkowl/txctools | txctools/reports/hotspot.py | HotspotReport.deliverTextResults | def deliverTextResults(self):
"""
Deliver the results in a pretty text output.
@return: Pretty text output!
"""
output = "=======================\ntxctools Hotspot Report\n"\
"=======================\n\n"
fileResults = sorted(self.fileCounts.items(),
... | python | def deliverTextResults(self):
"""
Deliver the results in a pretty text output.
@return: Pretty text output!
"""
output = "=======================\ntxctools Hotspot Report\n"\
"=======================\n\n"
fileResults = sorted(self.fileCounts.items(),
... | [
"def",
"deliverTextResults",
"(",
"self",
")",
":",
"output",
"=",
"\"=======================\\ntxctools Hotspot Report\\n\"",
"\"=======================\\n\\n\"",
"fileResults",
"=",
"sorted",
"(",
"self",
".",
"fileCounts",
".",
"items",
"(",
")",
",",
"key",
"=",
"... | Deliver the results in a pretty text output.
@return: Pretty text output! | [
"Deliver",
"the",
"results",
"in",
"a",
"pretty",
"text",
"output",
"."
] | train | https://github.com/hawkowl/txctools/blob/14cab033ea179211a7bfd88dc202d576fc336ddc/txctools/reports/hotspot.py#L63-L100 |
hawkowl/txctools | txctools/reports/hotspot.py | HotspotReport._warnCount | def _warnCount(self, warnings, warningCount=None):
"""
Calculate the count of each warning, being given a list of them.
@param warnings: L{list} of L{dict}s that come from
L{tools.parsePyLintWarnings}.
@param warningCount: A L{dict} produced by this method previously, if
... | python | def _warnCount(self, warnings, warningCount=None):
"""
Calculate the count of each warning, being given a list of them.
@param warnings: L{list} of L{dict}s that come from
L{tools.parsePyLintWarnings}.
@param warningCount: A L{dict} produced by this method previously, if
... | [
"def",
"_warnCount",
"(",
"self",
",",
"warnings",
",",
"warningCount",
"=",
"None",
")",
":",
"if",
"not",
"warningCount",
":",
"warningCount",
"=",
"{",
"}",
"for",
"warning",
"in",
"warnings",
":",
"wID",
"=",
"warning",
"[",
"\"warning_id\"",
"]",
"i... | Calculate the count of each warning, being given a list of them.
@param warnings: L{list} of L{dict}s that come from
L{tools.parsePyLintWarnings}.
@param warningCount: A L{dict} produced by this method previously, if
you are adding to the warnings.
@return: L{dict} of L... | [
"Calculate",
"the",
"count",
"of",
"each",
"warning",
"being",
"given",
"a",
"list",
"of",
"them",
"."
] | train | https://github.com/hawkowl/txctools/blob/14cab033ea179211a7bfd88dc202d576fc336ddc/txctools/reports/hotspot.py#L103-L126 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.is_in_channel | def is_in_channel(self, channel, should_be=True):
"""
Find out if you are in a channel.
Required arguments:
* channel - Channel to check whether you are in it or not.
* should_be - If True, raise an exception if you aren't in the channel;
If False, raise an ex... | python | def is_in_channel(self, channel, should_be=True):
"""
Find out if you are in a channel.
Required arguments:
* channel - Channel to check whether you are in it or not.
* should_be - If True, raise an exception if you aren't in the channel;
If False, raise an ex... | [
"def",
"is_in_channel",
"(",
"self",
",",
"channel",
",",
"should_be",
"=",
"True",
")",
":",
"with",
"self",
".",
"lock",
":",
"for",
"channel_",
"in",
"self",
".",
"channels",
":",
"if",
"self",
".",
"compare",
"(",
"channel_",
",",
"channel",
")",
... | Find out if you are in a channel.
Required arguments:
* channel - Channel to check whether you are in it or not.
* should_be - If True, raise an exception if you aren't in the channel;
If False, raise an exception if you are in the channel. | [
"Find",
"out",
"if",
"you",
"are",
"in",
"a",
"channel",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"check",
"whether",
"you",
"are",
"in",
"it",
"or",
"not",
".",
"*",
"should_be",
"-",
"If",
"True",
"raise",
"an",
"exc... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L24-L40 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.join_ | def join_(self, channel, key=None, process_only=False):
"""
Joins a channel.
Returns a tuple of information regarding the channel.
Channel Information:
* [0] - A tuple containing /NAMES.
* [1] - Channel topic.
* [2] - Tuple containing information regarding of whom... | python | def join_(self, channel, key=None, process_only=False):
"""
Joins a channel.
Returns a tuple of information regarding the channel.
Channel Information:
* [0] - A tuple containing /NAMES.
* [1] - Channel topic.
* [2] - Tuple containing information regarding of whom... | [
"def",
"join_",
"(",
"self",
",",
"channel",
",",
"key",
"=",
"None",
",",
"process_only",
"=",
"False",
")",
":",
"with",
"self",
".",
"lock",
":",
"topic",
"=",
"''",
"users",
"=",
"[",
"]",
"set_by",
"=",
"''",
"time_set",
"=",
"''",
"self",
"... | Joins a channel.
Returns a tuple of information regarding the channel.
Channel Information:
* [0] - A tuple containing /NAMES.
* [1] - Channel topic.
* [2] - Tuple containing information regarding of whom set the topic.
* [3] - Time object about when the topic was set.
... | [
"Joins",
"a",
"channel",
".",
"Returns",
"a",
"tuple",
"of",
"information",
"regarding",
"the",
"channel",
".",
"Channel",
"Information",
":",
"*",
"[",
"0",
"]",
"-",
"A",
"tuple",
"containing",
"/",
"NAMES",
".",
"*",
"[",
"1",
"]",
"-",
"Channel",
... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L42-L119 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.part | def part(self, channel, reason=''):
"""
Part a channel.
Required arguments:
* channel - Channel to part.
Optional arguments:
* reason='' - Reason for parting.
"""
with self.lock:
self.is_in_channel(channel)
self.send('PART %s :%s' ... | python | def part(self, channel, reason=''):
"""
Part a channel.
Required arguments:
* channel - Channel to part.
Optional arguments:
* reason='' - Reason for parting.
"""
with self.lock:
self.is_in_channel(channel)
self.send('PART %s :%s' ... | [
"def",
"part",
"(",
"self",
",",
"channel",
",",
"reason",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'PART %s :%s'",
"%",
"(",
"channel",
",",
"reason",
")",
... | Part a channel.
Required arguments:
* channel - Channel to part.
Optional arguments:
* reason='' - Reason for parting. | [
"Part",
"a",
"channel",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"part",
".",
"Optional",
"arguments",
":",
"*",
"reason",
"=",
"-",
"Reason",
"for",
"parting",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L121-L137 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.cmode | def cmode(self, channel, modes=''):
"""
Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel.
"""
with self.l... | python | def cmode(self, channel, modes=''):
"""
Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel.
"""
with self.l... | [
"def",
"cmode",
"(",
"self",
",",
"channel",
",",
"modes",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"if",
"not",
"modes",
":",
"self",
".",
"send",
"(",
"'MODE %s'",
"%",
"channel",
"... | Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel. | [
"Sets",
"or",
"gets",
"the",
"channel",
"mode",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"set",
"/",
"get",
"modes",
"of",
".",
"Optional",
"arguments",
":",
"*",
"modes",
"=",
"-",
"Modes",
"to",
"set",
".",
"If",
"no... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L139-L174 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.banlist | def banlist(self, channel):
"""
Get the channel banlist.
Required arguments:
* channel - Channel of which to get the banlist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s b' % channel)
bans = []
w... | python | def banlist(self, channel):
"""
Get the channel banlist.
Required arguments:
* channel - Channel of which to get the banlist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s b' % channel)
bans = []
w... | [
"def",
"banlist",
"(",
"self",
",",
"channel",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'MODE %s b'",
"%",
"channel",
")",
"bans",
"=",
"[",
"]",
"while",
"self",
".",
... | Get the channel banlist.
Required arguments:
* channel - Channel of which to get the banlist for. | [
"Get",
"the",
"channel",
"banlist",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"of",
"which",
"to",
"get",
"the",
"banlist",
"for",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L176-L196 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.exceptlist | def exceptlist(self, channel):
"""
Get the channel exceptlist.
Required arguments:
* channel - Channel of which to get the exceptlist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s e' % channel)
excepts = []
... | python | def exceptlist(self, channel):
"""
Get the channel exceptlist.
Required arguments:
* channel - Channel of which to get the exceptlist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s e' % channel)
excepts = []
... | [
"def",
"exceptlist",
"(",
"self",
",",
"channel",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'MODE %s e'",
"%",
"channel",
")",
"excepts",
"=",
"[",
"]",
"while",
"self",
... | Get the channel exceptlist.
Required arguments:
* channel - Channel of which to get the exceptlist for. | [
"Get",
"the",
"channel",
"exceptlist",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"of",
"which",
"to",
"get",
"the",
"exceptlist",
"for",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L198-L220 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.invitelist | def invitelist(self, channel):
"""
Get the channel invitelist.
Required arguments:
* channel - Channel of which to get the invitelist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s i' % channel)
invites = []
... | python | def invitelist(self, channel):
"""
Get the channel invitelist.
Required arguments:
* channel - Channel of which to get the invitelist for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('MODE %s i' % channel)
invites = []
... | [
"def",
"invitelist",
"(",
"self",
",",
"channel",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'MODE %s i'",
"%",
"channel",
")",
"invites",
"=",
"[",
"]",
"while",
"self",
... | Get the channel invitelist.
Required arguments:
* channel - Channel of which to get the invitelist for. | [
"Get",
"the",
"channel",
"invitelist",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"of",
"which",
"to",
"get",
"the",
"invitelist",
"for",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L222-L244 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.topic | def topic(self, channel, topic=None):
"""
Sets/gets the channel topic.
Required arguments:
* channel - Channel to set/get the topic for.
Optional arguments:
* topic - Topic to set.
If not specified the current channel topic will be returned.
"""
... | python | def topic(self, channel, topic=None):
"""
Sets/gets the channel topic.
Required arguments:
* channel - Channel to set/get the topic for.
Optional arguments:
* topic - Topic to set.
If not specified the current channel topic will be returned.
"""
... | [
"def",
"topic",
"(",
"self",
",",
"channel",
",",
"topic",
"=",
"None",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"if",
"topic",
":",
"self",
".",
"send",
"(",
"'TOPIC %s :%s'",
"%",
"(",
"channel"... | Sets/gets the channel topic.
Required arguments:
* channel - Channel to set/get the topic for.
Optional arguments:
* topic - Topic to set.
If not specified the current channel topic will be returned. | [
"Sets",
"/",
"gets",
"the",
"channel",
"topic",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"set",
"/",
"get",
"the",
"topic",
"for",
".",
"Optional",
"arguments",
":",
"*",
"topic",
"-",
"Topic",
"to",
"set",
".",
"If",
... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L246-L287 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.names | def names(self, channel):
"""
Get a list of users in the channel.
Required arguments:
* channel - Channel to get list of users for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('NAMES %s' % channel)
names = []
... | python | def names(self, channel):
"""
Get a list of users in the channel.
Required arguments:
* channel - Channel to get list of users for.
"""
with self.lock:
self.is_in_channel(channel)
self.send('NAMES %s' % channel)
names = []
... | [
"def",
"names",
"(",
"self",
",",
"channel",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'NAMES %s'",
"%",
"channel",
")",
"names",
"=",
"[",
"]",
"while",
"self",
".",
"... | Get a list of users in the channel.
Required arguments:
* channel - Channel to get list of users for. | [
"Get",
"a",
"list",
"of",
"users",
"in",
"the",
"channel",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"get",
"list",
"of",
"users",
"for",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L289-L335 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.list_ | def list_(self):
""" Gets a list of channels on the server. """
with self.lock:
self.send('LIST')
list_ = {}
while self.readable():
msg = self._recv(expected_replies=('322', '321', '323'))
if msg[0] == '322':
chann... | python | def list_(self):
""" Gets a list of channels on the server. """
with self.lock:
self.send('LIST')
list_ = {}
while self.readable():
msg = self._recv(expected_replies=('322', '321', '323'))
if msg[0] == '322':
chann... | [
"def",
"list_",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"send",
"(",
"'LIST'",
")",
"list_",
"=",
"{",
"}",
"while",
"self",
".",
"readable",
"(",
")",
":",
"msg",
"=",
"self",
".",
"_recv",
"(",
"expected_replies",
... | Gets a list of channels on the server. | [
"Gets",
"a",
"list",
"of",
"channels",
"on",
"the",
"server",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L337-L357 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.invite | def invite(self, channel, nick):
"""
Invite someone to a channel.
Required arguments:
* channel - Channel to invite them to.
* nick - Nick to invite.
"""
with self.lock:
self.is_in_channel(channel)
self.send('INVITE %s %s' % (nick, channel... | python | def invite(self, channel, nick):
"""
Invite someone to a channel.
Required arguments:
* channel - Channel to invite them to.
* nick - Nick to invite.
"""
with self.lock:
self.is_in_channel(channel)
self.send('INVITE %s %s' % (nick, channel... | [
"def",
"invite",
"(",
"self",
",",
"channel",
",",
"nick",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'INVITE %s %s'",
"%",
"(",
"nick",
",",
"channel",
")",
")",
"while",... | Invite someone to a channel.
Required arguments:
* channel - Channel to invite them to.
* nick - Nick to invite. | [
"Invite",
"someone",
"to",
"a",
"channel",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"invite",
"them",
"to",
".",
"*",
"nick",
"-",
"Nick",
"to",
"invite",
"."
] | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L359-L378 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.kick | def kick(self, channel, nick, reason=''):
"""
Kick someone from a channel.
Required arguments:
* channel - Channel to kick them from.
* nick - Nick to kick.
Optional arguments:
* reason - Reason for the kick.
"""
with self.lock:
self.is... | python | def kick(self, channel, nick, reason=''):
"""
Kick someone from a channel.
Required arguments:
* channel - Channel to kick them from.
* nick - Nick to kick.
Optional arguments:
* reason - Reason for the kick.
"""
with self.lock:
self.is... | [
"def",
"kick",
"(",
"self",
",",
"channel",
",",
"nick",
",",
"reason",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"self",
".",
"send",
"(",
"'KICK %s %s :%s'",
"%",
"(",
"channel",
",",
... | Kick someone from a channel.
Required arguments:
* channel - Channel to kick them from.
* nick - Nick to kick.
Optional arguments:
* reason - Reason for the kick. | [
"Kick",
"someone",
"from",
"a",
"channel",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"kick",
"them",
"from",
".",
"*",
"nick",
"-",
"Nick",
"to",
"kick",
".",
"Optional",
"arguments",
":",
"*",
"reason",
"-",
"Reason",
"f... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L380-L403 |
jamieleshaw/lurklib | lurklib/channel.py | _Channel.parse_cmode_string | def parse_cmode_string(self, mode_string, channel):
"""
Parse a channel mode string and update the IRC.channels dictionary.
Required arguments:
* mode_string - Mode string to parse.
* channel - Channel of which the modes were set.
"""
with self.lock:
m... | python | def parse_cmode_string(self, mode_string, channel):
"""
Parse a channel mode string and update the IRC.channels dictionary.
Required arguments:
* mode_string - Mode string to parse.
* channel - Channel of which the modes were set.
"""
with self.lock:
m... | [
"def",
"parse_cmode_string",
"(",
"self",
",",
"mode_string",
",",
"channel",
")",
":",
"with",
"self",
".",
"lock",
":",
"modes",
"=",
"mode_string",
".",
"split",
"(",
")",
"targets",
"=",
"modes",
"[",
"1",
":",
"]",
"modes",
"=",
"modes",
"[",
"0... | Parse a channel mode string and update the IRC.channels dictionary.
Required arguments:
* mode_string - Mode string to parse.
* channel - Channel of which the modes were set. | [
"Parse",
"a",
"channel",
"mode",
"string",
"and",
"update",
"the",
"IRC",
".",
"channels",
"dictionary",
".",
"Required",
"arguments",
":",
"*",
"mode_string",
"-",
"Mode",
"string",
"to",
"parse",
".",
"*",
"channel",
"-",
"Channel",
"of",
"which",
"the",... | train | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L405-L445 |
a1ezzz/wasp-launcher | wasp_launcher/apps/config.py | WConfigApp.read_config | def read_config(cls):
""" Setup :attr:`wasp_launcher.apps.WAppsGlobals.log` configuration. Reads defaults and
override it by a file given via :attr:`WConfigApp.__environment_file_var__` environment variable.
After that configuration files are applied from :attr:`WConfigApp.__environment_dir_var__`
:return: Non... | python | def read_config(cls):
""" Setup :attr:`wasp_launcher.apps.WAppsGlobals.log` configuration. Reads defaults and
override it by a file given via :attr:`WConfigApp.__environment_file_var__` environment variable.
After that configuration files are applied from :attr:`WConfigApp.__environment_dir_var__`
:return: Non... | [
"def",
"read_config",
"(",
"cls",
")",
":",
"WAppsGlobals",
".",
"config",
"=",
"WConfig",
"(",
")",
"def",
"load",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"is",
"False",
":",
"raise",
"RuntimeError",
... | Setup :attr:`wasp_launcher.apps.WAppsGlobals.log` configuration. Reads defaults and
override it by a file given via :attr:`WConfigApp.__environment_file_var__` environment variable.
After that configuration files are applied from :attr:`WConfigApp.__environment_dir_var__`
:return: None | [
"Setup",
":",
"attr",
":",
"wasp_launcher",
".",
"apps",
".",
"WAppsGlobals",
".",
"log",
"configuration",
".",
"Reads",
"defaults",
"and",
"override",
"it",
"by",
"a",
"file",
"given",
"via",
":",
"attr",
":",
"WConfigApp",
".",
"__environment_file_var__",
... | train | https://github.com/a1ezzz/wasp-launcher/blob/38b476286fb422830207031935d3af1fe8da316d/wasp_launcher/apps/config.py#L80-L120 |
bmuller/toquen-python | toquen/client.py | AWSClient.servers_with_roles | def servers_with_roles(self, roles, env=None, match_all=False):
"""
Get servers with the given roles. If env is given, then the environment must match as well.
If match_all is True, then only return servers who have all of the given roles. Otherwise,
return servers that have one or mor... | python | def servers_with_roles(self, roles, env=None, match_all=False):
"""
Get servers with the given roles. If env is given, then the environment must match as well.
If match_all is True, then only return servers who have all of the given roles. Otherwise,
return servers that have one or mor... | [
"def",
"servers_with_roles",
"(",
"self",
",",
"roles",
",",
"env",
"=",
"None",
",",
"match_all",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"roles",
"=",
"set",
"(",
"roles",
")",
"for",
"instance",
"in",
"self",
".",
"server_details",
"(",
"... | Get servers with the given roles. If env is given, then the environment must match as well.
If match_all is True, then only return servers who have all of the given roles. Otherwise,
return servers that have one or more of the given roles. | [
"Get",
"servers",
"with",
"the",
"given",
"roles",
".",
"If",
"env",
"is",
"given",
"then",
"the",
"environment",
"must",
"match",
"as",
"well",
".",
"If",
"match_all",
"is",
"True",
"then",
"only",
"return",
"servers",
"who",
"have",
"all",
"of",
"the",... | train | https://github.com/bmuller/toquen-python/blob/bfe4073a91b03b06b934aa20a174d96f7b7660e5/toquen/client.py#L19-L34 |
bmuller/toquen-python | toquen/client.py | FabricFriendlyClient.ips_with_roles | def ips_with_roles(self, roles, env=None, match_all=False):
"""
Returns a function that, when called, gets servers with the given roles.
If env is given, then the environment must match as well. If match_all is True,
then only return servers who have all of the given roles. Otherwise, ... | python | def ips_with_roles(self, roles, env=None, match_all=False):
"""
Returns a function that, when called, gets servers with the given roles.
If env is given, then the environment must match as well. If match_all is True,
then only return servers who have all of the given roles. Otherwise, ... | [
"def",
"ips_with_roles",
"(",
"self",
",",
"roles",
",",
"env",
"=",
"None",
",",
"match_all",
"=",
"False",
")",
":",
"def",
"func",
"(",
")",
":",
"return",
"[",
"s",
"[",
"'external_ip'",
"]",
"for",
"s",
"in",
"self",
".",
"servers_with_roles",
"... | Returns a function that, when called, gets servers with the given roles.
If env is given, then the environment must match as well. If match_all is True,
then only return servers who have all of the given roles. Otherwise, return
servers that have one or more of the given roles. | [
"Returns",
"a",
"function",
"that",
"when",
"called",
"gets",
"servers",
"with",
"the",
"given",
"roles",
".",
"If",
"env",
"is",
"given",
"then",
"the",
"environment",
"must",
"match",
"as",
"well",
".",
"If",
"match_all",
"is",
"True",
"then",
"only",
... | train | https://github.com/bmuller/toquen-python/blob/bfe4073a91b03b06b934aa20a174d96f7b7660e5/toquen/client.py#L67-L76 |
roaet/wafflehaus.neutron | wafflehaus/neutron/last_ip_check/last_ip_check.py | filter_factory | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def check_last_ip(app):
return LastIpCheck(app, conf)
return check_last_ip | python | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def check_last_ip(app):
return LastIpCheck(app, conf)
return check_last_ip | [
"def",
"filter_factory",
"(",
"global_conf",
",",
"*",
"*",
"local_conf",
")",
":",
"conf",
"=",
"global_conf",
".",
"copy",
"(",
")",
"conf",
".",
"update",
"(",
"local_conf",
")",
"def",
"check_last_ip",
"(",
"app",
")",
":",
"return",
"LastIpCheck",
"... | Returns a WSGI filter app for use with paste.deploy. | [
"Returns",
"a",
"WSGI",
"filter",
"app",
"for",
"use",
"with",
"paste",
".",
"deploy",
"."
] | train | https://github.com/roaet/wafflehaus.neutron/blob/01f6d69ae759ec2f24f2f7cf9dcfa4a4734f7e1c/wafflehaus/neutron/last_ip_check/last_ip_check.py#L135-L142 |
polysquare/polysquare-generic-file-linter | polysquarelinter/valid_words_dictionary.py | create | def create(spellchecker_cache_path):
"""Create a Dictionary at spellchecker_cache_path with valid words."""
user_dictionary = os.path.join(os.getcwd(), "DICTIONARY")
user_words = read_dictionary_file(user_dictionary)
valid_words = Dictionary(valid_words_set(user_dictionary, user_words),
... | python | def create(spellchecker_cache_path):
"""Create a Dictionary at spellchecker_cache_path with valid words."""
user_dictionary = os.path.join(os.getcwd(), "DICTIONARY")
user_words = read_dictionary_file(user_dictionary)
valid_words = Dictionary(valid_words_set(user_dictionary, user_words),
... | [
"def",
"create",
"(",
"spellchecker_cache_path",
")",
":",
"user_dictionary",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"\"DICTIONARY\"",
")",
"user_words",
"=",
"read_dictionary_file",
"(",
"user_dictionary",
")",
"valid_wo... | Create a Dictionary at spellchecker_cache_path with valid words. | [
"Create",
"a",
"Dictionary",
"at",
"spellchecker_cache_path",
"with",
"valid",
"words",
"."
] | train | https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/valid_words_dictionary.py#L16-L26 |
msuozzo/Aduro | aduro/snapshot.py | KindleLibrarySnapshot.process_event | def process_event(self, event):
"""Apply an event to the snapshot instance
"""
if not isinstance(event, KindleEvent):
pass
elif isinstance(event, AddEvent):
self._data[event.asin] = BookSnapshot(event.asin)
elif isinstance(event, SetReadingEvent):
... | python | def process_event(self, event):
"""Apply an event to the snapshot instance
"""
if not isinstance(event, KindleEvent):
pass
elif isinstance(event, AddEvent):
self._data[event.asin] = BookSnapshot(event.asin)
elif isinstance(event, SetReadingEvent):
... | [
"def",
"process_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"isinstance",
"(",
"event",
",",
"KindleEvent",
")",
":",
"pass",
"elif",
"isinstance",
"(",
"event",
",",
"AddEvent",
")",
":",
"self",
".",
"_data",
"[",
"event",
".",
"asin",
... | Apply an event to the snapshot instance | [
"Apply",
"an",
"event",
"to",
"the",
"snapshot",
"instance"
] | train | https://github.com/msuozzo/Aduro/blob/338eeb1deeff30c198e721b660ae4daca3660911/aduro/snapshot.py#L41-L56 |
msuozzo/Aduro | aduro/snapshot.py | KindleLibrarySnapshot.calc_update_events | def calc_update_events(self, asin_to_progress):
"""Calculate and return an iterable of `KindleEvent`s which, when
applied to the current snapshot, result in the the current snapshot
reflecting the progress state of the `asin_to_progress` mapping.
Functionally, this method generates `Add... | python | def calc_update_events(self, asin_to_progress):
"""Calculate and return an iterable of `KindleEvent`s which, when
applied to the current snapshot, result in the the current snapshot
reflecting the progress state of the `asin_to_progress` mapping.
Functionally, this method generates `Add... | [
"def",
"calc_update_events",
"(",
"self",
",",
"asin_to_progress",
")",
":",
"new_events",
"=",
"[",
"]",
"for",
"asin",
",",
"new_progress",
"in",
"asin_to_progress",
".",
"iteritems",
"(",
")",
":",
"try",
":",
"book_snapshot",
"=",
"self",
".",
"get_book"... | Calculate and return an iterable of `KindleEvent`s which, when
applied to the current snapshot, result in the the current snapshot
reflecting the progress state of the `asin_to_progress` mapping.
Functionally, this method generates `AddEvent`s and `ReadEvent`s from
updated Kindle Librar... | [
"Calculate",
"and",
"return",
"an",
"iterable",
"of",
"KindleEvent",
"s",
"which",
"when",
"applied",
"to",
"the",
"current",
"snapshot",
"result",
"in",
"the",
"the",
"current",
"snapshot",
"reflecting",
"the",
"progress",
"state",
"of",
"the",
"asin_to_progres... | train | https://github.com/msuozzo/Aduro/blob/338eeb1deeff30c198e721b660ae4daca3660911/aduro/snapshot.py#L66-L93 |
xtrementl/focus | focus/parser/parser.py | SettingParser._reset | def _reset(self):
""" Rebuilds structure for AST and resets internal data.
"""
self._filename = None
self._block_map = {}
self._ast = []
self._ast.append(None) # header
self._ast.append([]) # options list
self._ast.append([]) | python | def _reset(self):
""" Rebuilds structure for AST and resets internal data.
"""
self._filename = None
self._block_map = {}
self._ast = []
self._ast.append(None) # header
self._ast.append([]) # options list
self._ast.append([]) | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"_filename",
"=",
"None",
"self",
".",
"_block_map",
"=",
"{",
"}",
"self",
".",
"_ast",
"=",
"[",
"]",
"self",
".",
"_ast",
".",
"append",
"(",
"None",
")",
"# header",
"self",
".",
"_ast",
".... | Rebuilds structure for AST and resets internal data. | [
"Rebuilds",
"structure",
"for",
"AST",
"and",
"resets",
"internal",
"data",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L164-L173 |
xtrementl/focus | focus/parser/parser.py | SettingParser._get_token | def _get_token(self, regex=None):
""" Consumes the next token in the token stream.
`regex`
Validate against the specified `re.compile()` regex instance.
Returns token string.
* Raises a ``ParseError`` exception if stream is empty or regex
matc... | python | def _get_token(self, regex=None):
""" Consumes the next token in the token stream.
`regex`
Validate against the specified `re.compile()` regex instance.
Returns token string.
* Raises a ``ParseError`` exception if stream is empty or regex
matc... | [
"def",
"_get_token",
"(",
"self",
",",
"regex",
"=",
"None",
")",
":",
"item",
"=",
"self",
".",
"_lexer",
".",
"get_token",
"(",
")",
"if",
"not",
"item",
":",
"raise",
"ParseError",
"(",
"u'Unexpected end of file'",
")",
"else",
":",
"line_no",
",",
... | Consumes the next token in the token stream.
`regex`
Validate against the specified `re.compile()` regex instance.
Returns token string.
* Raises a ``ParseError`` exception if stream is empty or regex
match fails. | [
"Consumes",
"the",
"next",
"token",
"in",
"the",
"token",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L175-L198 |
xtrementl/focus | focus/parser/parser.py | SettingParser._lookahead_token | def _lookahead_token(self, count=1):
""" Peeks into the token stream up to the specified number of tokens
without consuming any tokens from the stream.
``count``
Look ahead in stream up to a maximum number of tokens.
Returns string token or ``None``.
... | python | def _lookahead_token(self, count=1):
""" Peeks into the token stream up to the specified number of tokens
without consuming any tokens from the stream.
``count``
Look ahead in stream up to a maximum number of tokens.
Returns string token or ``None``.
... | [
"def",
"_lookahead_token",
"(",
"self",
",",
"count",
"=",
"1",
")",
":",
"stack",
"=",
"[",
"]",
"next_token",
"=",
"None",
"# fetch the specified number of tokens ahead in stream",
"while",
"count",
">",
"0",
":",
"item",
"=",
"self",
".",
"_lexer",
".",
"... | Peeks into the token stream up to the specified number of tokens
without consuming any tokens from the stream.
``count``
Look ahead in stream up to a maximum number of tokens.
Returns string token or ``None``. | [
"Peeks",
"into",
"the",
"token",
"stream",
"up",
"to",
"the",
"specified",
"number",
"of",
"tokens",
"without",
"consuming",
"any",
"tokens",
"from",
"the",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/parser/parser.py#L200-L230 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.