partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _eratosthenes | Yields the sequence of prime numbers via the Sieve of Eratosthenes. | CGRtools/algorithms/morgan.py | def _eratosthenes():
"""Yields the sequence of prime numbers via the Sieve of Eratosthenes."""
d = {} # map each composite integer to its first-found prime factor
for q in count(2): # q gets 2, 3, 4, 5, ... ad infinitum
p = d.pop(q, None)
if p is None:
# q not a key in D, so q ... | def _eratosthenes():
"""Yields the sequence of prime numbers via the Sieve of Eratosthenes."""
d = {} # map each composite integer to its first-found prime factor
for q in count(2): # q gets 2, 3, 4, 5, ... ad infinitum
p = d.pop(q, None)
if p is None:
# q not a key in D, so q ... | [
"Yields",
"the",
"sequence",
"of",
"prime",
"numbers",
"via",
"the",
"Sieve",
"of",
"Eratosthenes",
"."
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/morgan.py#L88-L105 | [
"def",
"_eratosthenes",
"(",
")",
":",
"d",
"=",
"{",
"}",
"# map each composite integer to its first-found prime factor",
"for",
"q",
"in",
"count",
"(",
"2",
")",
":",
"# q gets 2, 3, 4, 5, ... ad infinitum",
"p",
"=",
"d",
".",
"pop",
"(",
"q",
",",
"None",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | Morgan.atoms_order | Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs | CGRtools/algorithms/morgan.py | def atoms_order(self):
"""
Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs
"""
if not len(self): # for empty containers
return {}
elif len(self) == 1: # optimize single atom containers
return dict.fromkeys(self,... | def atoms_order(self):
"""
Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs
"""
if not len(self): # for empty containers
return {}
elif len(self) == 1: # optimize single atom containers
return dict.fromkeys(self,... | [
"Morgan",
"like",
"algorithm",
"for",
"graph",
"nodes",
"ordering"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/morgan.py#L29-L85 | [
"def",
"atoms_order",
"(",
"self",
")",
":",
"if",
"not",
"len",
"(",
"self",
")",
":",
"# for empty containers",
"return",
"{",
"}",
"elif",
"len",
"(",
"self",
")",
"==",
"1",
":",
"# optimize single atom containers",
"return",
"dict",
".",
"fromkeys",
"... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | PieceValues.init_manual | Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE: int | chess_py/pieces/piece_const.py | def init_manual(cls, pawn_value, knight_value, bishop_value, rook_value, queen_value, king_value):
"""
Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE:... | def init_manual(cls, pawn_value, knight_value, bishop_value, rook_value, queen_value, king_value):
"""
Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE:... | [
"Manual",
"init",
"method",
"for",
"external",
"piece",
"values"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece_const.py#L27-L44 | [
"def",
"init_manual",
"(",
"cls",
",",
"pawn_value",
",",
"knight_value",
",",
"bishop_value",
",",
"rook_value",
",",
"queen_value",
",",
"king_value",
")",
":",
"piece_values",
"=",
"cls",
"(",
")",
"piece_values",
".",
"PAWN_VALUE",
"=",
"pawn_value",
"piec... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | PieceValues.val | Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int | chess_py/pieces/piece_const.py | def val(self, piece, ref_color):
"""
Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int
"""
if piece is None:
return 0
if ref_color == piece.color:
const = 1
else:
const = -1
... | def val(self, piece, ref_color):
"""
Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int
"""
if piece is None:
return 0
if ref_color == piece.color:
const = 1
else:
const = -1
... | [
"Finds",
"value",
"of",
"Piece"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece_const.py#L46-L74 | [
"def",
"val",
"(",
"self",
",",
"piece",
",",
"ref_color",
")",
":",
"if",
"piece",
"is",
"None",
":",
"return",
"0",
"if",
"ref_color",
"==",
"piece",
".",
"color",
":",
"const",
"=",
"1",
"else",
":",
"const",
"=",
"-",
"1",
"if",
"isinstance",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Game.play | Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int | chess_py/game/game.py | def play(self):
"""
Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int
"""
colors = [lambda:... | def play(self):
"""
Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int
"""
colors = [lambda:... | [
"Starts",
"game",
"and",
"returns",
"one",
"of",
"3",
"results",
".",
"Iterates",
"between",
"methods",
"white_move",
"()",
"and",
"black_move",
"()",
"until",
"game",
"ends",
".",
"Each",
"method",
"calls",
"the",
"respective",
"player",
"s",
"generate_move",... | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L39-L64 | [
"def",
"play",
"(",
"self",
")",
":",
"colors",
"=",
"[",
"lambda",
":",
"self",
".",
"white_move",
"(",
")",
",",
"lambda",
":",
"self",
".",
"black_move",
"(",
")",
"]",
"colors",
"=",
"itertools",
".",
"cycle",
"(",
"colors",
")",
"while",
"True... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Game.white_move | Calls the white player's ``generate_move()``
method and updates the board with the move returned. | chess_py/game/game.py | def white_move(self):
"""
Calls the white player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_white.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | def white_move(self):
"""
Calls the white player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_white.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | [
"Calls",
"the",
"white",
"player",
"s",
"generate_move",
"()",
"method",
"and",
"updates",
"the",
"board",
"with",
"the",
"move",
"returned",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L66-L73 | [
"def",
"white_move",
"(",
"self",
")",
":",
"move",
"=",
"self",
".",
"player_white",
".",
"generate_move",
"(",
"self",
".",
"position",
")",
"move",
"=",
"make_legal",
"(",
"move",
",",
"self",
".",
"position",
")",
"self",
".",
"position",
".",
"upd... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Game.black_move | Calls the black player's ``generate_move()``
method and updates the board with the move returned. | chess_py/game/game.py | def black_move(self):
"""
Calls the black player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_black.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | def black_move(self):
"""
Calls the black player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_black.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | [
"Calls",
"the",
"black",
"player",
"s",
"generate_move",
"()",
"method",
"and",
"updates",
"the",
"board",
"with",
"the",
"move",
"returned",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L75-L82 | [
"def",
"black_move",
"(",
"self",
")",
":",
"move",
"=",
"self",
".",
"player_black",
".",
"generate_move",
"(",
"self",
".",
"position",
")",
"move",
"=",
"make_legal",
"(",
"move",
",",
"self",
".",
"position",
")",
"self",
".",
"position",
".",
"upd... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | KibanaMapping.get_field_cache | Return a list of fields' mappings | kibana/mapping.py | def get_field_cache(self, cache_type='es'):
"""Return a list of fields' mappings"""
if cache_type == 'kibana':
try:
search_results = urlopen(self.get_url).read().decode('utf-8')
except HTTPError: # as e:
# self.pr_err("get_field_cache(kibana), HTT... | def get_field_cache(self, cache_type='es'):
"""Return a list of fields' mappings"""
if cache_type == 'kibana':
try:
search_results = urlopen(self.get_url).read().decode('utf-8')
except HTTPError: # as e:
# self.pr_err("get_field_cache(kibana), HTT... | [
"Return",
"a",
"list",
"of",
"fields",
"mappings"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L96-L125 | [
"def",
"get_field_cache",
"(",
"self",
",",
"cache_type",
"=",
"'es'",
")",
":",
"if",
"cache_type",
"==",
"'kibana'",
":",
"try",
":",
"search_results",
"=",
"urlopen",
"(",
"self",
".",
"get_url",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.post_field_cache | Where field_cache is a list of fields' mappings | kibana/mapping.py | def post_field_cache(self, field_cache):
"""Where field_cache is a list of fields' mappings"""
index_pattern = self.field_cache_to_index_pattern(field_cache)
# self.pr_dbg("request/post: %s" % index_pattern)
resp = requests.post(self.post_url, data=index_pattern).text
# resp = {"... | def post_field_cache(self, field_cache):
"""Where field_cache is a list of fields' mappings"""
index_pattern = self.field_cache_to_index_pattern(field_cache)
# self.pr_dbg("request/post: %s" % index_pattern)
resp = requests.post(self.post_url, data=index_pattern).text
# resp = {"... | [
"Where",
"field_cache",
"is",
"a",
"list",
"of",
"fields",
"mappings"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L142-L149 | [
"def",
"post_field_cache",
"(",
"self",
",",
"field_cache",
")",
":",
"index_pattern",
"=",
"self",
".",
"field_cache_to_index_pattern",
"(",
"field_cache",
")",
"# self.pr_dbg(\"request/post: %s\" % index_pattern)",
"resp",
"=",
"requests",
".",
"post",
"(",
"self",
... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.field_cache_to_index_pattern | Return a .kibana index-pattern doc_type | kibana/mapping.py | def field_cache_to_index_pattern(self, field_cache):
"""Return a .kibana index-pattern doc_type"""
mapping_dict = {}
mapping_dict['customFormats'] = "{}"
mapping_dict['title'] = self.index_pattern
# now post the data into .kibana
mapping_dict['fields'] = json.dumps(field_... | def field_cache_to_index_pattern(self, field_cache):
"""Return a .kibana index-pattern doc_type"""
mapping_dict = {}
mapping_dict['customFormats'] = "{}"
mapping_dict['title'] = self.index_pattern
# now post the data into .kibana
mapping_dict['fields'] = json.dumps(field_... | [
"Return",
"a",
".",
"kibana",
"index",
"-",
"pattern",
"doc_type"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L152-L161 | [
"def",
"field_cache_to_index_pattern",
"(",
"self",
",",
"field_cache",
")",
":",
"mapping_dict",
"=",
"{",
"}",
"mapping_dict",
"[",
"'customFormats'",
"]",
"=",
"\"{}\"",
"mapping_dict",
"[",
"'title'",
"]",
"=",
"self",
".",
"index_pattern",
"# now post the dat... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.check_mapping | Assert minimum set of fields in cache, does not validate contents | kibana/mapping.py | def check_mapping(self, m):
"""Assert minimum set of fields in cache, does not validate contents"""
if 'name' not in m:
self.pr_dbg("Missing %s" % "name")
return False
# self.pr_dbg("Checking %s" % m['name'])
for x in ['analyzed', 'indexed', 'type', 'scripted', 'c... | def check_mapping(self, m):
"""Assert minimum set of fields in cache, does not validate contents"""
if 'name' not in m:
self.pr_dbg("Missing %s" % "name")
return False
# self.pr_dbg("Checking %s" % m['name'])
for x in ['analyzed', 'indexed', 'type', 'scripted', 'c... | [
"Assert",
"minimum",
"set",
"of",
"fields",
"in",
"cache",
"does",
"not",
"validate",
"contents"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L163-L179 | [
"def",
"check_mapping",
"(",
"self",
",",
"m",
")",
":",
"if",
"'name'",
"not",
"in",
"m",
":",
"self",
".",
"pr_dbg",
"(",
"\"Missing %s\"",
"%",
"\"name\"",
")",
"return",
"False",
"# self.pr_dbg(\"Checking %s\" % m['name'])",
"for",
"x",
"in",
"[",
"'anal... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.get_index_mappings | Converts all index's doc_types to .kibana | kibana/mapping.py | def get_index_mappings(self, index):
"""Converts all index's doc_types to .kibana"""
fields_arr = []
for (key, val) in iteritems(index):
# self.pr_dbg("\tdoc_type: %s" % key)
doc_mapping = self.get_doc_type_mappings(index[key])
# self.pr_dbg("\tdoc_mapping: %s... | def get_index_mappings(self, index):
"""Converts all index's doc_types to .kibana"""
fields_arr = []
for (key, val) in iteritems(index):
# self.pr_dbg("\tdoc_type: %s" % key)
doc_mapping = self.get_doc_type_mappings(index[key])
# self.pr_dbg("\tdoc_mapping: %s... | [
"Converts",
"all",
"index",
"s",
"doc_types",
"to",
".",
"kibana"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L181-L192 | [
"def",
"get_index_mappings",
"(",
"self",
",",
"index",
")",
":",
"fields_arr",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"index",
")",
":",
"# self.pr_dbg(\"\\tdoc_type: %s\" % key)",
"doc_mapping",
"=",
"self",
".",
"get_do... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.get_doc_type_mappings | Converts all doc_types' fields to .kibana | kibana/mapping.py | def get_doc_type_mappings(self, doc_type):
"""Converts all doc_types' fields to .kibana"""
doc_fields_arr = []
found_score = False
for (key, val) in iteritems(doc_type):
# self.pr_dbg("\t\tfield: %s" % key)
# self.pr_dbg("\tval: %s" % val)
add_it = Fal... | def get_doc_type_mappings(self, doc_type):
"""Converts all doc_types' fields to .kibana"""
doc_fields_arr = []
found_score = False
for (key, val) in iteritems(doc_type):
# self.pr_dbg("\t\tfield: %s" % key)
# self.pr_dbg("\tval: %s" % val)
add_it = Fal... | [
"Converts",
"all",
"doc_types",
"fields",
"to",
".",
"kibana"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L194-L254 | [
"def",
"get_doc_type_mappings",
"(",
"self",
",",
"doc_type",
")",
":",
"doc_fields_arr",
"=",
"[",
"]",
"found_score",
"=",
"False",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"doc_type",
")",
":",
"# self.pr_dbg(\"\\t\\tfield: %s\" % key)",
... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.get_field_mappings | Converts ES field mappings to .kibana field mappings | kibana/mapping.py | def get_field_mappings(self, field):
"""Converts ES field mappings to .kibana field mappings"""
retdict = {}
retdict['indexed'] = False
retdict['analyzed'] = False
for (key, val) in iteritems(field):
if key in self.mappings:
if (key == 'type' and
... | def get_field_mappings(self, field):
"""Converts ES field mappings to .kibana field mappings"""
retdict = {}
retdict['indexed'] = False
retdict['analyzed'] = False
for (key, val) in iteritems(field):
if key in self.mappings:
if (key == 'type' and
... | [
"Converts",
"ES",
"field",
"mappings",
"to",
".",
"kibana",
"field",
"mappings"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L256-L278 | [
"def",
"get_field_mappings",
"(",
"self",
",",
"field",
")",
":",
"retdict",
"=",
"{",
"}",
"retdict",
"[",
"'indexed'",
"]",
"=",
"False",
"retdict",
"[",
"'analyzed'",
"]",
"=",
"False",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.is_kibana_cache_incomplete | Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has | kibana/mapping.py | def is_kibana_cache_incomplete(self, es_cache, k_cache):
"""Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has
"""
# convert list into dict, with each item's ['name'] as key
k_dict = {}
for field in k... | def is_kibana_cache_incomplete(self, es_cache, k_cache):
"""Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has
"""
# convert list into dict, with each item's ['name'] as key
k_dict = {}
for field in k... | [
"Test",
"if",
"k_cache",
"is",
"incomplete"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L310-L339 | [
"def",
"is_kibana_cache_incomplete",
"(",
"self",
",",
"es_cache",
",",
"k_cache",
")",
":",
"# convert list into dict, with each item's ['name'] as key",
"k_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"k_cache",
":",
"# self.pr_dbg(\"field: %s\" % field)",
"k_dict",
"[",... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.list_to_compare_dict | Convert list into a data structure we can query easier | kibana/mapping.py | def list_to_compare_dict(self, list_form):
"""Convert list into a data structure we can query easier"""
compare_dict = {}
for field in list_form:
if field['name'] in compare_dict:
self.pr_dbg("List has duplicate field %s:\n%s" %
(field['nam... | def list_to_compare_dict(self, list_form):
"""Convert list into a data structure we can query easier"""
compare_dict = {}
for field in list_form:
if field['name'] in compare_dict:
self.pr_dbg("List has duplicate field %s:\n%s" %
(field['nam... | [
"Convert",
"list",
"into",
"a",
"data",
"structure",
"we",
"can",
"query",
"easier"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L341-L354 | [
"def",
"list_to_compare_dict",
"(",
"self",
",",
"list_form",
")",
":",
"compare_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"list_form",
":",
"if",
"field",
"[",
"'name'",
"]",
"in",
"compare_dict",
":",
"self",
".",
"pr_dbg",
"(",
"\"List has duplicate fie... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | KibanaMapping.compare_field_caches | Verify original is subset of replica | kibana/mapping.py | def compare_field_caches(self, replica, original):
"""Verify original is subset of replica"""
if original is None:
original = []
if replica is None:
replica = []
self.pr_dbg("Comparing orig with %s fields to replica with %s fields" %
(len(origi... | def compare_field_caches(self, replica, original):
"""Verify original is subset of replica"""
if original is None:
original = []
if replica is None:
replica = []
self.pr_dbg("Comparing orig with %s fields to replica with %s fields" %
(len(origi... | [
"Verify",
"original",
"is",
"subset",
"of",
"replica"
] | rfarley3/Kibana | python | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L356-L400 | [
"def",
"compare_field_caches",
"(",
"self",
",",
"replica",
",",
"original",
")",
":",
"if",
"original",
"is",
"None",
":",
"original",
"=",
"[",
"]",
"if",
"replica",
"is",
"None",
":",
"replica",
"=",
"[",
"]",
"self",
".",
"pr_dbg",
"(",
"\"Comparin... | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 |
train | start_daemon_thread | starts a deamon thread for a given target function and arguments. | logagg/util.py | def start_daemon_thread(target, args=()):
"""starts a deamon thread for a given target function and arguments."""
th = Thread(target=target, args=args)
th.daemon = True
th.start()
return th | def start_daemon_thread(target, args=()):
"""starts a deamon thread for a given target function and arguments."""
th = Thread(target=target, args=args)
th.daemon = True
th.start()
return th | [
"starts",
"a",
"deamon",
"thread",
"for",
"a",
"given",
"target",
"function",
"and",
"arguments",
"."
] | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/util.py#L45-L50 | [
"def",
"start_daemon_thread",
"(",
"target",
",",
"args",
"=",
"(",
")",
")",
":",
"th",
"=",
"Thread",
"(",
"target",
"=",
"target",
",",
"args",
"=",
"args",
")",
"th",
".",
"daemon",
"=",
"True",
"th",
".",
"start",
"(",
")",
"return",
"th"
] | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | serialize_dict_keys | returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b'] | logagg/util.py | def serialize_dict_keys(d, prefix=""):
"""returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b']
"""
keys = []
for k, v in d.iteritems():
fqk = '%s%s' % (prefix, k)
keys.append(fqk)
if isinstance(v, ... | def serialize_dict_keys(d, prefix=""):
"""returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b']
"""
keys = []
for k, v in d.iteritems():
fqk = '%s%s' % (prefix, k)
keys.append(fqk)
if isinstance(v, ... | [
"returns",
"all",
"the",
"keys",
"in",
"a",
"dictionary",
"."
] | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/util.py#L53-L66 | [
"def",
"serialize_dict_keys",
"(",
"d",
",",
"prefix",
"=",
"\"\"",
")",
":",
"keys",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"d",
".",
"iteritems",
"(",
")",
":",
"fqk",
"=",
"'%s%s'",
"%",
"(",
"prefix",
",",
"k",
")",
"keys",
".",
"append... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | AuthBackend.set_user | Writes user data to session.
Args:
user: User object | zengine/auth/auth_backend.py | def set_user(self, user):
"""
Writes user data to session.
Args:
user: User object
"""
self.session['user_id'] = user.key
self.session['user_data'] = user.clean_value()
role = self.get_role()
# TODO: this should be remembered from previous lo... | def set_user(self, user):
"""
Writes user data to session.
Args:
user: User object
"""
self.session['user_id'] = user.key
self.session['user_data'] = user.clean_value()
role = self.get_role()
# TODO: this should be remembered from previous lo... | [
"Writes",
"user",
"data",
"to",
"session",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/auth_backend.py#L33-L50 | [
"def",
"set_user",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"session",
"[",
"'user_id'",
"]",
"=",
"user",
".",
"key",
"self",
".",
"session",
"[",
"'user_data'",
"]",
"=",
"user",
".",
"clean_value",
"(",
")",
"role",
"=",
"self",
".",
"ge... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Piece.contains_opposite_color_piece | Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool | chess_py/pieces/piece.py | def contains_opposite_color_piece(self, square, position):
"""
Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool
"""
return not position.is_square_empty(square) a... | def contains_opposite_color_piece(self, square, position):
"""
Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool
"""
return not position.is_square_empty(square) a... | [
"Finds",
"if",
"square",
"on",
"the",
"board",
"is",
"occupied",
"by",
"a",
"Piece",
"belonging",
"to",
"the",
"opponent",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece.py#L79-L89 | [
"def",
"contains_opposite_color_piece",
"(",
"self",
",",
"square",
",",
"position",
")",
":",
"return",
"not",
"position",
".",
"is_square_empty",
"(",
"square",
")",
"and",
"position",
".",
"piece_at_square",
"(",
"square",
")",
".",
"color",
"!=",
"self",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | gettext | Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from zengine.lib.translation import gettext as _
p... | zengine/lib/translation.py | def gettext(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from z... | def gettext(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from z... | [
"Mark",
"a",
"message",
"as",
"translateable",
"and",
"translate",
"it",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L133-L184 | [
"def",
"gettext",
"(",
"message",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"InstalledLocale",
".",
"_active_catalogs",
"[",
"domain",
"]",
".",
"ugettext",
"(",
"message",
")",
"else",
":",
"return",
"Installe... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | gettext_lazy | Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
the fields in a Model can't be translated at the point ... | zengine/lib/translation.py | def gettext_lazy(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
... | def gettext_lazy(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
... | [
"Mark",
"a",
"message",
"as",
"translatable",
"but",
"delay",
"the",
"translation",
"until",
"the",
"message",
"is",
"used",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L187-L219 | [
"def",
"gettext_lazy",
"(",
"message",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"return",
"LazyProxy",
"(",
"gettext",
",",
"message",
",",
"domain",
"=",
"domain",
",",
"enable_cache",
"=",
"False",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ngettext | Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): print(
'You have %d %s' % (msg_count, 'message' if msg_count... | zengine/lib/translation.py | def ngettext(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): pri... | def ngettext(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): pri... | [
"Mark",
"a",
"message",
"as",
"translateable",
"and",
"translate",
"it",
"considering",
"plural",
"forms",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L222-L269 | [
"def",
"ngettext",
"(",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"InstalledLocale",
".",
"_active_catalogs",
"[",
"domain",
"]",
".",
"ungettext",
"(",
"singular",
",",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ngettext_lazy | Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singular form of the message.
plural (unicode): The plural form of t... | zengine/lib/translation.py | def ngettext_lazy(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singul... | def ngettext_lazy(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singul... | [
"Mark",
"a",
"message",
"with",
"plural",
"forms",
"translateable",
"and",
"delay",
"the",
"translation",
"until",
"the",
"message",
"is",
"used",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L272-L288 | [
"def",
"ngettext_lazy",
"(",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"return",
"LazyProxy",
"(",
"ngettext",
",",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"domain",
",",
"enable_cache",
"=",
"F... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | _wrap_locale_formatter | Wrap a Babel data formatting function to automatically format
for currently installed locale. | zengine/lib/translation.py | def _wrap_locale_formatter(fn, locale_type):
"""Wrap a Babel data formatting function to automatically format
for currently installed locale."""
def wrapped_locale_formatter(*args, **kwargs):
"""A Babel formatting function, wrapped to automatically use the
currently installed language.
... | def _wrap_locale_formatter(fn, locale_type):
"""Wrap a Babel data formatting function to automatically format
for currently installed locale."""
def wrapped_locale_formatter(*args, **kwargs):
"""A Babel formatting function, wrapped to automatically use the
currently installed language.
... | [
"Wrap",
"a",
"Babel",
"data",
"formatting",
"function",
"to",
"automatically",
"format",
"for",
"currently",
"installed",
"locale",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L328-L361 | [
"def",
"_wrap_locale_formatter",
"(",
"fn",
",",
"locale_type",
")",
":",
"def",
"wrapped_locale_formatter",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"A Babel formatting function, wrapped to automatically use the\n currently installed language.\n\n ... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | InstalledLocale.install_language | Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op. | zengine/lib/translation.py | def install_language(cls, language_code):
"""Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op.
"""
# ... | def install_language(cls, language_code):
"""Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op.
"""
# ... | [
"Install",
"the",
"translations",
"for",
"language",
"specified",
"by",
"language_code",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L89-L107 | [
"def",
"install_language",
"(",
"cls",
",",
"language_code",
")",
":",
"# Skip if the language is already installed",
"if",
"language_code",
"==",
"cls",
".",
"language",
":",
"return",
"try",
":",
"cls",
".",
"_active_catalogs",
"=",
"cls",
".",
"_translation_catal... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | InstalledLocale.install_locale | Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified is already installed for the selected type, then this is a no-... | zengine/lib/translation.py | def install_locale(cls, locale_code, locale_type):
"""Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified ... | def install_locale(cls, locale_code, locale_type):
"""Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified ... | [
"Install",
"the",
"locale",
"specified",
"by",
"language_code",
"for",
"localizations",
"of",
"type",
"locale_type",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L110-L130 | [
"def",
"install_locale",
"(",
"cls",
",",
"locale_code",
",",
"locale_type",
")",
":",
"# Skip if the locale is already installed",
"if",
"locale_code",
"==",
"getattr",
"(",
"cls",
",",
"locale_type",
")",
":",
"return",
"try",
":",
"# We create a Locale instance to ... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Depict._rotate_vector | rotate x,y vector over x2-x1, y2-y1 angle | CGRtools/algorithms/depict.py | def _rotate_vector(x, y, x2, y2, x1, y1):
"""
rotate x,y vector over x2-x1, y2-y1 angle
"""
angle = atan2(y2 - y1, x2 - x1)
cos_rad = cos(angle)
sin_rad = sin(angle)
return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y | def _rotate_vector(x, y, x2, y2, x1, y1):
"""
rotate x,y vector over x2-x1, y2-y1 angle
"""
angle = atan2(y2 - y1, x2 - x1)
cos_rad = cos(angle)
sin_rad = sin(angle)
return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y | [
"rotate",
"x",
"y",
"vector",
"over",
"x2",
"-",
"x1",
"y2",
"-",
"y1",
"angle"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/depict.py#L86-L93 | [
"def",
"_rotate_vector",
"(",
"x",
",",
"y",
",",
"x2",
",",
"y2",
",",
"x1",
",",
"y1",
")",
":",
"angle",
"=",
"atan2",
"(",
"y2",
"-",
"y1",
",",
"x2",
"-",
"x1",
")",
"cos_rad",
"=",
"cos",
"(",
"angle",
")",
"sin_rad",
"=",
"sin",
"(",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | _build_static_table_mapping | Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching. | cocaine/detail/headers.py | def _build_static_table_mapping():
"""
Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching.
"""
static_table_mapping = {}
for index, (name, value) in enum... | def _build_static_table_mapping():
"""
Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching.
"""
static_table_mapping = {}
for index, (name, value) in enum... | [
"Build",
"static",
"table",
"mapping",
"from",
"header",
"name",
"to",
"tuple",
"with",
"next",
"structure",
":",
"(",
"<minimal",
"index",
"of",
"header",
">",
"<mapping",
"from",
"header",
"value",
"to",
"it",
"index",
">",
")",
"."
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L268-L279 | [
"def",
"_build_static_table_mapping",
"(",
")",
":",
"static_table_mapping",
"=",
"{",
"}",
"for",
"index",
",",
"(",
"name",
",",
"value",
")",
"in",
"enumerate",
"(",
"CocaineHeaders",
".",
"STATIC_TABLE",
",",
"1",
")",
":",
"header_name_search_result",
"="... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | CocaineHeaders.get_by_index | Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from the static table or
the dynamic table depe... | cocaine/detail/headers.py | def get_by_index(self, index):
"""
Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from... | def get_by_index(self, index):
"""
Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from... | [
"Returns",
"the",
"entry",
"specified",
"by",
"index"
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L145-L163 | [
"def",
"get_by_index",
"(",
"self",
",",
"index",
")",
":",
"index",
"-=",
"1",
"if",
"0",
"<=",
"index",
"<",
"len",
"(",
"CocaineHeaders",
".",
"STATIC_TABLE",
")",
":",
"return",
"CocaineHeaders",
".",
"STATIC_TABLE",
"[",
"index",
"]",
"index",
"-=",... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | CocaineHeaders.add | Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize. | cocaine/detail/headers.py | def add(self, name, value):
"""
Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize.
"""
# We just clear the table if the entry is too big
size = table_entry_size(name, value)
if size > self._m... | def add(self, name, value):
"""
Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize.
"""
# We just clear the table if the entry is too big
size = table_entry_size(name, value)
if size > self._m... | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"table"
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L172-L189 | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"# We just clear the table if the entry is too big",
"size",
"=",
"table_entry_size",
"(",
"name",
",",
"value",
")",
"if",
"size",
">",
"self",
".",
"_maxsize",
":",
"self",
".",
"dynamic_entries... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | CocaineHeaders.search | Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfect matches. | cocaine/detail/headers.py | def search(self, name, value):
"""
Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfec... | def search(self, name, value):
"""
Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfec... | [
"Searches",
"the",
"table",
"for",
"the",
"entry",
"specified",
"by",
"name",
"and",
"value"
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L191-L217 | [
"def",
"search",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"partial",
"=",
"None",
"header_name_search_result",
"=",
"CocaineHeaders",
".",
"STATIC_TABLE_MAPPING",
".",
"get",
"(",
"name",
")",
"if",
"header_name_search_result",
":",
"index",
"=",
"hea... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | CocaineHeaders._shrink | Shrinks the dynamic table to be at or below maxsize | cocaine/detail/headers.py | def _shrink(self):
"""
Shrinks the dynamic table to be at or below maxsize
"""
cursize = self._current_size
while cursize > self._maxsize:
name, value = self.dynamic_entries.pop()
cursize -= table_entry_size(name, value)
self._current_size = cursiz... | def _shrink(self):
"""
Shrinks the dynamic table to be at or below maxsize
"""
cursize = self._current_size
while cursize > self._maxsize:
name, value = self.dynamic_entries.pop()
cursize -= table_entry_size(name, value)
self._current_size = cursiz... | [
"Shrinks",
"the",
"dynamic",
"table",
"to",
"be",
"at",
"or",
"below",
"maxsize"
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L235-L243 | [
"def",
"_shrink",
"(",
"self",
")",
":",
"cursize",
"=",
"self",
".",
"_current_size",
"while",
"cursize",
">",
"self",
".",
"_maxsize",
":",
"name",
",",
"value",
"=",
"self",
".",
"dynamic_entries",
".",
"pop",
"(",
")",
"cursize",
"-=",
"table_entry_s... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | Headers.add | Adds a new value for the given key. | cocaine/detail/headers.py | def add(self, name, value):
# type: (str, str) -> None
"""Adds a new value for the given key."""
self._last_key = name
if name in self:
self._dict[name] = value
self._as_list[name].append(value)
else:
self[name] = value | def add(self, name, value):
# type: (str, str) -> None
"""Adds a new value for the given key."""
self._last_key = name
if name in self:
self._dict[name] = value
self._as_list[name].append(value)
else:
self[name] = value | [
"Adds",
"a",
"new",
"value",
"for",
"the",
"given",
"key",
"."
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L314-L322 | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"# type: (str, str) -> None",
"self",
".",
"_last_key",
"=",
"name",
"if",
"name",
"in",
"self",
":",
"self",
".",
"_dict",
"[",
"name",
"]",
"=",
"value",
"self",
".",
"_as_list",
"[",
... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | Headers.get_all | Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name. | cocaine/detail/headers.py | def get_all(self):
# type: () -> typing.Iterable[typing.Tuple[str, str]]
"""Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name.
"""
for name, values in six.iteritems(self._as_list):
... | def get_all(self):
# type: () -> typing.Iterable[typing.Tuple[str, str]]
"""Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name.
"""
for name, values in six.iteritems(self._as_list):
... | [
"Returns",
"an",
"iterable",
"of",
"all",
"(",
"name",
"value",
")",
"pairs",
"."
] | cocaine/cocaine-framework-python | python | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L328-L337 | [
"def",
"get_all",
"(",
"self",
")",
":",
"# type: () -> typing.Iterable[typing.Tuple[str, str]]",
"for",
"name",
",",
"values",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_as_list",
")",
":",
"for",
"value",
"in",
"values",
":",
"yield",
"(",
"name",
... | d8a30074b6338bac4389eb996e00d404338115e4 |
train | safe_print | Safely print a unicode string | marabunta/output.py | def safe_print(ustring, errors='replace', **kwargs):
""" Safely print a unicode string """
encoding = sys.stdout.encoding or 'utf-8'
if sys.version_info[0] == 3:
print(ustring, **kwargs)
else:
bytestr = ustring.encode(encoding, errors=errors)
print(bytestr, **kwargs) | def safe_print(ustring, errors='replace', **kwargs):
""" Safely print a unicode string """
encoding = sys.stdout.encoding or 'utf-8'
if sys.version_info[0] == 3:
print(ustring, **kwargs)
else:
bytestr = ustring.encode(encoding, errors=errors)
print(bytestr, **kwargs) | [
"Safely",
"print",
"a",
"unicode",
"string"
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/output.py#L26-L33 | [
"def",
"safe_print",
"(",
"ustring",
",",
"errors",
"=",
"'replace'",
",",
"*",
"*",
"kwargs",
")",
":",
"encoding",
"=",
"sys",
".",
"stdout",
".",
"encoding",
"or",
"'utf-8'",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"3",
":",
"print"... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Permissions.edit_permissions | Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
"tree": [
... | zengine/views/permissions.py | def edit_permissions(self):
"""Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
... | def edit_permissions(self):
"""Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
... | [
"Creates",
"the",
"view",
"used",
"to",
"edit",
"permissions",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L110-L196 | [
"def",
"edit_permissions",
"(",
"self",
")",
":",
"# Get the role that was selected in the CRUD view",
"key",
"=",
"self",
".",
"current",
".",
"input",
"[",
"'object_id'",
"]",
"self",
".",
"current",
".",
"task_data",
"[",
"'role_id'",
"]",
"=",
"key",
"role",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Permissions._permission_trees | Get the cached permission tree, or build a new one if necessary. | zengine/views/permissions.py | def _permission_trees(permissions):
"""Get the cached permission tree, or build a new one if necessary."""
treecache = PermissionTreeCache()
cached = treecache.get()
if not cached:
tree = PermissionTreeBuilder()
for permission in permissions:
tree.... | def _permission_trees(permissions):
"""Get the cached permission tree, or build a new one if necessary."""
treecache = PermissionTreeCache()
cached = treecache.get()
if not cached:
tree = PermissionTreeBuilder()
for permission in permissions:
tree.... | [
"Get",
"the",
"cached",
"permission",
"tree",
"or",
"build",
"a",
"new",
"one",
"if",
"necessary",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L199-L210 | [
"def",
"_permission_trees",
"(",
"permissions",
")",
":",
"treecache",
"=",
"PermissionTreeCache",
"(",
")",
"cached",
"=",
"treecache",
".",
"get",
"(",
")",
"if",
"not",
"cached",
":",
"tree",
"=",
"PermissionTreeBuilder",
"(",
")",
"for",
"permission",
"i... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Permissions._apply_role_tree | In permission tree, sets `'checked': True` for the permissions that the role has. | zengine/views/permissions.py | def _apply_role_tree(self, perm_tree, role):
"""In permission tree, sets `'checked': True` for the permissions that the role has."""
role_permissions = role.get_permissions()
for perm in role_permissions:
self._traverse_tree(perm_tree, perm)['checked'] = True
return perm_tree | def _apply_role_tree(self, perm_tree, role):
"""In permission tree, sets `'checked': True` for the permissions that the role has."""
role_permissions = role.get_permissions()
for perm in role_permissions:
self._traverse_tree(perm_tree, perm)['checked'] = True
return perm_tree | [
"In",
"permission",
"tree",
"sets",
"checked",
":",
"True",
"for",
"the",
"permissions",
"that",
"the",
"role",
"has",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L212-L217 | [
"def",
"_apply_role_tree",
"(",
"self",
",",
"perm_tree",
",",
"role",
")",
":",
"role_permissions",
"=",
"role",
".",
"get_permissions",
"(",
")",
"for",
"perm",
"in",
"role_permissions",
":",
"self",
".",
"_traverse_tree",
"(",
"perm_tree",
",",
"perm",
")... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Permissions._traverse_tree | Traverses the permission tree, returning the permission at given permission path. | zengine/views/permissions.py | def _traverse_tree(tree, path):
"""Traverses the permission tree, returning the permission at given permission path."""
path_steps = (step for step in path.split('.') if step != '')
# Special handling for first step, because the first step isn't under 'objects'
first_step = path_steps.ne... | def _traverse_tree(tree, path):
"""Traverses the permission tree, returning the permission at given permission path."""
path_steps = (step for step in path.split('.') if step != '')
# Special handling for first step, because the first step isn't under 'objects'
first_step = path_steps.ne... | [
"Traverses",
"the",
"permission",
"tree",
"returning",
"the",
"permission",
"at",
"given",
"permission",
"path",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L220-L229 | [
"def",
"_traverse_tree",
"(",
"tree",
",",
"path",
")",
":",
"path_steps",
"=",
"(",
"step",
"for",
"step",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
"if",
"step",
"!=",
"''",
")",
"# Special handling for first step, because the first step isn't under 'objects'... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Permissions._format_subtree | Recursively format all subtrees. | zengine/views/permissions.py | def _format_subtree(self, subtree):
"""Recursively format all subtrees."""
subtree['children'] = list(subtree['children'].values())
for child in subtree['children']:
self._format_subtree(child)
return subtree | def _format_subtree(self, subtree):
"""Recursively format all subtrees."""
subtree['children'] = list(subtree['children'].values())
for child in subtree['children']:
self._format_subtree(child)
return subtree | [
"Recursively",
"format",
"all",
"subtrees",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L241-L246 | [
"def",
"_format_subtree",
"(",
"self",
",",
"subtree",
")",
":",
"subtree",
"[",
"'children'",
"]",
"=",
"list",
"(",
"subtree",
"[",
"'children'",
"]",
".",
"values",
"(",
")",
")",
"for",
"child",
"in",
"subtree",
"[",
"'children'",
"]",
":",
"self",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Permissions.apply_change | Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id': 'workflow2.lane1.task1',
... | zengine/views/permissions.py | def apply_change(self):
"""Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id'... | def apply_change(self):
"""Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id'... | [
"Applies",
"changes",
"to",
"the",
"permissions",
"of",
"the",
"role",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L248-L276 | [
"def",
"apply_change",
"(",
"self",
")",
":",
"changes",
"=",
"self",
".",
"input",
"[",
"'change'",
"]",
"key",
"=",
"self",
".",
"current",
".",
"task_data",
"[",
"'role_id'",
"]",
"role",
"=",
"RoleModel",
".",
"objects",
".",
"get",
"(",
"key",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | SDFread.seek | shifts on a given number of record in the original file
:param offset: number of record | CGRtools/files/SDFrw.py | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | [
"shifts",
"on",
"a",
"given",
"number",
"of",
"record",
"in",
"the",
"original",
"file",
":",
"param",
"offset",
":",
"number",
"of",
"record"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L62-L79 | [
"def",
"seek",
"(",
"self",
",",
"offset",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"if",
"0",
"<=",
"offset",
"<",
"len",
"(",
"self",
".",
"_shifts",
")",
":",
"current_pos",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"new_pos",
"=",... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | SDFread.tell | :return: number of records processed from the original file | CGRtools/files/SDFrw.py | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
return bisect_left(self._shifts, t)
raise self._implement_error | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
return bisect_left(self._shifts, t)
raise self._implement_error | [
":",
"return",
":",
"number",
"of",
"records",
"processed",
"from",
"the",
"original",
"file"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L81-L88 | [
"def",
"tell",
"(",
"self",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"t",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"return",
"bisect_left",
"(",
"self",
".",
"_shifts",
",",
"t",
")",
"raise",
"self",
".",
"_implement_error"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | SDFwrite.write | write single molecule into file | CGRtools/files/SDFrw.py | def write(self, data):
"""
write single molecule into file
"""
m = self._convert_structure(data)
self._file.write(self._format_mol(*m))
self._file.write('M END\n')
for k, v in data.meta.items():
self._file.write(f'> <{k}>\n{v}\n')
self._file... | def write(self, data):
"""
write single molecule into file
"""
m = self._convert_structure(data)
self._file.write(self._format_mol(*m))
self._file.write('M END\n')
for k, v in data.meta.items():
self._file.write(f'> <{k}>\n{v}\n')
self._file... | [
"write",
"single",
"molecule",
"into",
"file"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L166-L176 | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"m",
"=",
"self",
".",
"_convert_structure",
"(",
"data",
")",
"self",
".",
"_file",
".",
"write",
"(",
"self",
".",
"_format_mol",
"(",
"*",
"m",
")",
")",
"self",
".",
"_file",
".",
"write",
"... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | ZEngine.save_workflow_to_cache | If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps. | zengine/engine.py | def save_workflow_to_cache(self, serialized_wf_instance):
"""
If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps.
"""
... | def save_workflow_to_cache(self, serialized_wf_instance):
"""
If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps.
"""
... | [
"If",
"we",
"aren",
"t",
"come",
"to",
"the",
"end",
"of",
"the",
"wf",
"saves",
"the",
"wf",
"state",
"and",
"task_data",
"to",
"cache"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L76-L102 | [
"def",
"save_workflow_to_cache",
"(",
"self",
",",
"serialized_wf_instance",
")",
":",
"# self.current.task_data['flow'] = None",
"task_data",
"=",
"self",
".",
"current",
".",
"task_data",
".",
"copy",
"(",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"task_da... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.get_pool_context | Builds context for the WF pool.
Returns:
Context dict. | zengine/engine.py | def get_pool_context(self):
# TODO: Add in-process caching
"""
Builds context for the WF pool.
Returns:
Context dict.
"""
context = {self.current.lane_id: self.current.role, 'self': self.current.role}
for lane_id, role_id in self.current.pool.items():... | def get_pool_context(self):
# TODO: Add in-process caching
"""
Builds context for the WF pool.
Returns:
Context dict.
"""
context = {self.current.lane_id: self.current.role, 'self': self.current.role}
for lane_id, role_id in self.current.pool.items():... | [
"Builds",
"context",
"for",
"the",
"WF",
"pool",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L104-L117 | [
"def",
"get_pool_context",
"(",
"self",
")",
":",
"# TODO: Add in-process caching",
"context",
"=",
"{",
"self",
".",
"current",
".",
"lane_id",
":",
"self",
".",
"current",
".",
"role",
",",
"'self'",
":",
"self",
".",
"current",
".",
"role",
"}",
"for",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.load_workflow_from_cache | loads the serialized wf state and data from cache
updates the self.current.task_data | zengine/engine.py | def load_workflow_from_cache(self):
"""
loads the serialized wf state and data from cache
updates the self.current.task_data
"""
if not self.current.new_token:
self.wf_state = self.current.wf_cache.get(self.wf_state)
self.current.task_data = self.wf_state[... | def load_workflow_from_cache(self):
"""
loads the serialized wf state and data from cache
updates the self.current.task_data
"""
if not self.current.new_token:
self.wf_state = self.current.wf_cache.get(self.wf_state)
self.current.task_data = self.wf_state[... | [
"loads",
"the",
"serialized",
"wf",
"state",
"and",
"data",
"from",
"cache",
"updates",
"the",
"self",
".",
"current",
".",
"task_data"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L119-L129 | [
"def",
"load_workflow_from_cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"current",
".",
"new_token",
":",
"self",
".",
"wf_state",
"=",
"self",
".",
"current",
".",
"wf_cache",
".",
"get",
"(",
"self",
".",
"wf_state",
")",
"self",
".",
"cu... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.serialize_workflow | Serializes the current WF.
Returns:
WF state data. | zengine/engine.py | def serialize_workflow(self):
"""
Serializes the current WF.
Returns:
WF state data.
"""
self.workflow.refresh_waiting_tasks()
return CompactWorkflowSerializer().serialize_workflow(self.workflow,
i... | def serialize_workflow(self):
"""
Serializes the current WF.
Returns:
WF state data.
"""
self.workflow.refresh_waiting_tasks()
return CompactWorkflowSerializer().serialize_workflow(self.workflow,
i... | [
"Serializes",
"the",
"current",
"WF",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L150-L159 | [
"def",
"serialize_workflow",
"(",
"self",
")",
":",
"self",
".",
"workflow",
".",
"refresh_waiting_tasks",
"(",
")",
"return",
"CompactWorkflowSerializer",
"(",
")",
".",
"serialize_workflow",
"(",
"self",
".",
"workflow",
",",
"include_spec",
"=",
"False",
")"
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.load_or_create_workflow | Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't | zengine/engine.py | def load_or_create_workflow(self):
"""
Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't
"""
self.workflow_spec = self.get_worfklow_spec()
return self._load_workflow() or self.create_workflow() | def load_or_create_workflow(self):
"""
Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't
"""
self.workflow_spec = self.get_worfklow_spec()
return self._load_workflow() or self.create_workflow() | [
"Tries",
"to",
"load",
"the",
"previously",
"serialized",
"(",
"and",
"saved",
")",
"workflow",
"Creates",
"a",
"new",
"one",
"if",
"it",
"can",
"t"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L169-L175 | [
"def",
"load_or_create_workflow",
"(",
"self",
")",
":",
"self",
".",
"workflow_spec",
"=",
"self",
".",
"get_worfklow_spec",
"(",
")",
"return",
"self",
".",
"_load_workflow",
"(",
")",
"or",
"self",
".",
"create_workflow",
"(",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.find_workflow_path | Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram) | zengine/engine.py | def find_workflow_path(self):
"""
Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram)
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
path = "%s/%s.bpmn" % (pth,... | def find_workflow_path(self):
"""
Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram)
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
path = "%s/%s.bpmn" % (pth,... | [
"Tries",
"to",
"find",
"the",
"path",
"of",
"the",
"workflow",
"diagram",
"file",
"in",
"WORKFLOW_PACKAGES_PATHS",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L178-L192 | [
"def",
"find_workflow_path",
"(",
"self",
")",
":",
"for",
"pth",
"in",
"settings",
".",
"WORKFLOW_PACKAGES_PATHS",
":",
"path",
"=",
"\"%s/%s.bpmn\"",
"%",
"(",
"pth",
",",
"self",
".",
"current",
".",
"workflow_name",
")",
"if",
"os",
".",
"path",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.get_worfklow_spec | Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object. | zengine/engine.py | def get_worfklow_spec(self):
"""
Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object.
"""
# TODO: convert from in-process to redis based caching
if self.current.workflow_name not in ... | def get_worfklow_spec(self):
"""
Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object.
"""
# TODO: convert from in-process to redis based caching
if self.current.workflow_name not in ... | [
"Generates",
"and",
"caches",
"the",
"workflow",
"spec",
"package",
"from",
"BPMN",
"diagrams",
"that",
"read",
"from",
"disk"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L194-L219 | [
"def",
"get_worfklow_spec",
"(",
"self",
")",
":",
"# TODO: convert from in-process to redis based caching",
"if",
"self",
".",
"current",
".",
"workflow_name",
"not",
"in",
"self",
".",
"workflow_spec_cache",
":",
"# path = self.find_workflow_path()",
"# spec_package = InMem... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine._save_or_delete_workflow | Calls the real save method if we pass the beggining of the wf | zengine/engine.py | def _save_or_delete_workflow(self):
"""
Calls the real save method if we pass the beggining of the wf
"""
if not self.current.task_type.startswith('Start'):
if self.current.task_name.startswith('End') and not self.are_we_in_subprocess():
self.wf_state['finishe... | def _save_or_delete_workflow(self):
"""
Calls the real save method if we pass the beggining of the wf
"""
if not self.current.task_type.startswith('Start'):
if self.current.task_name.startswith('End') and not self.are_we_in_subprocess():
self.wf_state['finishe... | [
"Calls",
"the",
"real",
"save",
"method",
"if",
"we",
"pass",
"the",
"beggining",
"of",
"the",
"wf"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L221-L239 | [
"def",
"_save_or_delete_workflow",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"current",
".",
"task_type",
".",
"startswith",
"(",
"'Start'",
")",
":",
"if",
"self",
".",
"current",
".",
"task_name",
".",
"startswith",
"(",
"'End'",
")",
"and",
"no... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.start_engine | Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of configured :py:attr:`~zengine.settings.WORKFLOW_PACKAGES_... | zengine/engine.py | def start_engine(self, **kwargs):
"""
Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of con... | def start_engine(self, **kwargs):
"""
Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of con... | [
"Initializes",
"the",
"workflow",
"with",
"given",
"request",
"response",
"objects",
"and",
"diagram",
"name",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L241-L289 | [
"def",
"start_engine",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"current",
"=",
"WFCurrent",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"wf_state",
"=",
"{",
"'in_external'",
":",
"False",
",",
"'finished'",
":",
"False",
"}",
"if... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.generate_wf_state_log | Logs the state of workflow and content of task_data. | zengine/engine.py | def generate_wf_state_log(self):
"""
Logs the state of workflow and content of task_data.
"""
output = '\n- - - - - -\n'
output += "WORKFLOW: %s ( %s )" % (self.current.workflow_name.upper(),
self.current.workflow.name)
output +... | def generate_wf_state_log(self):
"""
Logs the state of workflow and content of task_data.
"""
output = '\n- - - - - -\n'
output += "WORKFLOW: %s ( %s )" % (self.current.workflow_name.upper(),
self.current.workflow.name)
output +... | [
"Logs",
"the",
"state",
"of",
"workflow",
"and",
"content",
"of",
"task_data",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L291-L311 | [
"def",
"generate_wf_state_log",
"(",
"self",
")",
":",
"output",
"=",
"'\\n- - - - - -\\n'",
"output",
"+=",
"\"WORKFLOW: %s ( %s )\"",
"%",
"(",
"self",
".",
"current",
".",
"workflow_name",
".",
"upper",
"(",
")",
",",
"self",
".",
"current",
".",
"workflow"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.switch_from_external_to_main_wf | Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously. | zengine/engine.py | def switch_from_external_to_main_wf(self):
"""
Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously.
"""
# in external assigned as True in switch_to_external_wf.
# external_wf sh... | def switch_from_external_to_main_wf(self):
"""
Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously.
"""
# in external assigned as True in switch_to_external_wf.
# external_wf sh... | [
"Main",
"workflow",
"switcher",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L316-L365 | [
"def",
"switch_from_external_to_main_wf",
"(",
"self",
")",
":",
"# in external assigned as True in switch_to_external_wf.",
"# external_wf should finish EndEvent and it's name should be",
"# also EndEvent for switching again to main wf.",
"if",
"self",
".",
"wf_state",
"[",
"'in_externa... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.switch_to_external_wf | External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow. | zengine/engine.py | def switch_to_external_wf(self):
"""
External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow.
"""
# External WF name should be stated at main wf diagram and typ... | def switch_to_external_wf(self):
"""
External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow.
"""
# External WF name should be stated at main wf diagram and typ... | [
"External",
"workflow",
"switcher",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L367-L408 | [
"def",
"switch_to_external_wf",
"(",
"self",
")",
":",
"# External WF name should be stated at main wf diagram and type should be service task.",
"if",
"(",
"self",
".",
"current",
".",
"task_type",
"==",
"'ServiceTask'",
"and",
"self",
".",
"current",
".",
"task",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine._clear_current_task | Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF. | zengine/engine.py | def _clear_current_task(self):
"""
Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF.
"""
self.current.task_name = None
self.current.task_type = None
self.current.task = None | def _clear_current_task(self):
"""
Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF.
"""
self.current.task_name = None
self.current.task_type = None
self.current.task = None | [
"Clear",
"tasks",
"related",
"attributes",
"checks",
"permissions",
"While",
"switching",
"WF",
"to",
"WF",
"authentication",
"and",
"permissions",
"are",
"checked",
"for",
"new",
"WF",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L410-L418 | [
"def",
"_clear_current_task",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_name",
"=",
"None",
"self",
".",
"current",
".",
"task_type",
"=",
"None",
"self",
".",
"current",
".",
"task",
"=",
"None"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.run | Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndTask.
- Deletes state object... | zengine/engine.py | def run(self):
"""
Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndT... | def run(self):
"""
Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndT... | [
"Main",
"loop",
"of",
"the",
"workflow",
"engine"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L432-L477 | [
"def",
"run",
"(",
"self",
")",
":",
"# FIXME: raise if first task after line change isn't a UserTask",
"# FIXME: raise if last task of a workflow is a UserTask",
"# actually this check should be done at parser",
"is_lane_changed",
"=",
"False",
"while",
"self",
".",
"_should_we_run",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.check_for_rerun_user_task | Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current step is not EndEvent and there is no lane change,
t... | zengine/engine.py | def check_for_rerun_user_task(self):
"""
Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current st... | def check_for_rerun_user_task(self):
"""
Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current st... | [
"Checks",
"that",
"the",
"user",
"task",
"needs",
"to",
"re",
"-",
"run",
".",
"If",
"necessary",
"current",
"task",
"and",
"pre",
"task",
"s",
"states",
"are",
"changed",
"and",
"re",
"-",
"run",
".",
"If",
"wf_meta",
"not",
"in",
"data",
"(",
"ther... | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L479-L506 | [
"def",
"check_for_rerun_user_task",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"current",
".",
"input",
"if",
"'wf_meta'",
"in",
"data",
":",
"return",
"current_task",
"=",
"self",
".",
"workflow",
".",
"get_tasks",
"(",
"Task",
".",
"READY",
")",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.switch_lang | Switch to the language of the current user.
If the current language is already the specified one, nothing will be done. | zengine/engine.py | def switch_lang(self):
"""Switch to the language of the current user.
If the current language is already the specified one, nothing will be done.
"""
locale = self.current.locale
translation.InstalledLocale.install_language(locale['locale_language'])
translation.Installe... | def switch_lang(self):
"""Switch to the language of the current user.
If the current language is already the specified one, nothing will be done.
"""
locale = self.current.locale
translation.InstalledLocale.install_language(locale['locale_language'])
translation.Installe... | [
"Switch",
"to",
"the",
"language",
"of",
"the",
"current",
"user",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L508-L516 | [
"def",
"switch_lang",
"(",
"self",
")",
":",
"locale",
"=",
"self",
".",
"current",
".",
"locale",
"translation",
".",
"InstalledLocale",
".",
"install_language",
"(",
"locale",
"[",
"'locale_language'",
"]",
")",
"translation",
".",
"InstalledLocale",
".",
"i... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.catch_lane_change | trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one | zengine/engine.py | def catch_lane_change(self):
"""
trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one
"""
if self.current.lane_name:
if self.current.old_lane and self.current.lane_name != self.current.old_lane:
... | def catch_lane_change(self):
"""
trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one
"""
if self.current.lane_name:
if self.current.old_lane and self.current.lane_name != self.current.old_lane:
... | [
"trigger",
"a",
"lane_user_change",
"signal",
"if",
"we",
"switched",
"to",
"a",
"new",
"lane",
"and",
"new",
"lane",
"s",
"user",
"is",
"different",
"from",
"current",
"one"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L518-L535 | [
"def",
"catch_lane_change",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"lane_name",
":",
"if",
"self",
".",
"current",
".",
"old_lane",
"and",
"self",
".",
"current",
".",
"lane_name",
"!=",
"self",
".",
"current",
".",
"old_lane",
":",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.parse_workflow_messages | Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<camunda:map>
<camunda:entry key="title">Teşe... | zengine/engine.py | def parse_workflow_messages(self):
"""
Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<cam... | def parse_workflow_messages(self):
"""
Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<cam... | [
"Transmits",
"client",
"message",
"that",
"defined",
"in",
"a",
"workflow",
"task",
"s",
"inputOutput",
"extension"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L538-L562 | [
"def",
"parse_workflow_messages",
"(",
"self",
")",
":",
"if",
"'client_message'",
"in",
"self",
".",
"current",
".",
"spec",
".",
"data",
":",
"m",
"=",
"self",
".",
"current",
".",
"spec",
".",
"data",
"[",
"'client_message'",
"]",
"self",
".",
"curren... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.run_activity | runs the method that referenced from current task | zengine/engine.py | def run_activity(self):
"""
runs the method that referenced from current task
"""
activity = self.current.activity
if activity:
if activity not in self.wf_activities:
self._load_activity(activity)
self.current.log.debug(
"Ca... | def run_activity(self):
"""
runs the method that referenced from current task
"""
activity = self.current.activity
if activity:
if activity not in self.wf_activities:
self._load_activity(activity)
self.current.log.debug(
"Ca... | [
"runs",
"the",
"method",
"that",
"referenced",
"from",
"current",
"task"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L573-L583 | [
"def",
"run_activity",
"(",
"self",
")",
":",
"activity",
"=",
"self",
".",
"current",
".",
"activity",
"if",
"activity",
":",
"if",
"activity",
"not",
"in",
"self",
".",
"wf_activities",
":",
"self",
".",
"_load_activity",
"(",
"activity",
")",
"self",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine._import_object | Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tuple. (class object, class name, method to be called) | zengine/engine.py | def _import_object(self, path, look_for_cls_method):
"""
Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tupl... | def _import_object(self, path, look_for_cls_method):
"""
Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tupl... | [
"Imports",
"the",
"module",
"that",
"contains",
"the",
"referenced",
"method",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L585-L606 | [
"def",
"_import_object",
"(",
"self",
",",
"path",
",",
"look_for_cls_method",
")",
":",
"last_nth",
"=",
"2",
"if",
"look_for_cls_method",
"else",
"1",
"path",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"module_path",
"=",
"'.'",
".",
"join",
"(",
"pat... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine._load_activity | Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path. | zengine/engine.py | def _load_activity(self, activity):
"""
Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path.
"""
fpths = []
full_path = ''
errors = []
paths = settings.ACTIVITY_MODULES_IMPORT_PATHS
number_of_paths = len... | def _load_activity(self, activity):
"""
Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path.
"""
fpths = []
full_path = ''
errors = []
paths = settings.ACTIVITY_MODULES_IMPORT_PATHS
number_of_paths = len... | [
"Iterates",
"trough",
"the",
"all",
"enabled",
"~zengine",
".",
"settings",
".",
"ACTIVITY_MODULES_IMPORT_PATHS",
"to",
"find",
"the",
"given",
"path",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L608-L643 | [
"def",
"_load_activity",
"(",
"self",
",",
"activity",
")",
":",
"fpths",
"=",
"[",
"]",
"full_path",
"=",
"''",
"errors",
"=",
"[",
"]",
"paths",
"=",
"settings",
".",
"ACTIVITY_MODULES_IMPORT_PATHS",
"number_of_paths",
"=",
"len",
"(",
"paths",
")",
"for... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.check_for_authentication | Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't. | zengine/engine.py | def check_for_authentication(self):
"""
Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't.
"""
auth_required = self.current.workflow_name not in se... | def check_for_authentication(self):
"""
Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't.
"""
auth_required = self.current.workflow_name not in se... | [
"Checks",
"current",
"workflow",
"against",
":",
"py",
":",
"data",
":",
"~zengine",
".",
"settings",
".",
"ANONYMOUS_WORKFLOWS",
"list",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L645-L655 | [
"def",
"check_for_authentication",
"(",
"self",
")",
":",
"auth_required",
"=",
"self",
".",
"current",
".",
"workflow_name",
"not",
"in",
"settings",
".",
"ANONYMOUS_WORKFLOWS",
"if",
"auth_required",
"and",
"not",
"self",
".",
"current",
".",
"is_auth",
":",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.check_for_lane_permission | One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissions and relations.
Raises:
HTTPForb... | zengine/engine.py | def check_for_lane_permission(self):
"""
One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissi... | def check_for_lane_permission(self):
"""
One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissi... | [
"One",
"or",
"more",
"permissions",
"can",
"be",
"associated",
"with",
"a",
"lane",
"of",
"a",
"workflow",
".",
"In",
"a",
"similar",
"way",
"a",
"lane",
"can",
"be",
"restricted",
"with",
"relation",
"to",
"other",
"lanes",
"of",
"the",
"workflow",
"."
... | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L657-L690 | [
"def",
"check_for_lane_permission",
"(",
"self",
")",
":",
"# TODO: Cache lane_data in app memory",
"if",
"self",
".",
"current",
".",
"lane_permission",
":",
"log",
".",
"debug",
"(",
"\"HAS LANE PERM: %s\"",
"%",
"self",
".",
"current",
".",
"lane_permission",
")"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.check_for_permission | Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions. | zengine/engine.py | def check_for_permission(self):
# TODO: Works but not beautiful, needs review!
"""
Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions.
"""
if self.curren... | def check_for_permission(self):
# TODO: Works but not beautiful, needs review!
"""
Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions.
"""
if self.curren... | [
"Checks",
"if",
"current",
"user",
"(",
"or",
"role",
")",
"has",
"the",
"required",
"permission",
"for",
"current",
"workflow",
"step",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L692-L716 | [
"def",
"check_for_permission",
"(",
"self",
")",
":",
"# TODO: Works but not beautiful, needs review!",
"if",
"self",
".",
"current",
".",
"task",
":",
"lane",
"=",
"self",
".",
"current",
".",
"lane_id",
"permission",
"=",
"\"%s.%s.%s\"",
"%",
"(",
"self",
".",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ZEngine.handle_wf_finalization | Removes the ``token`` key from ``current.output`` if WF is over. | zengine/engine.py | def handle_wf_finalization(self):
"""
Removes the ``token`` key from ``current.output`` if WF is over.
"""
if ((not self.current.flow_enabled or (
self.current.task_type.startswith('End') and not self.are_we_in_subprocess())) and
'token' in self.current.ou... | def handle_wf_finalization(self):
"""
Removes the ``token`` key from ``current.output`` if WF is over.
"""
if ((not self.current.flow_enabled or (
self.current.task_type.startswith('End') and not self.are_we_in_subprocess())) and
'token' in self.current.ou... | [
"Removes",
"the",
"token",
"key",
"from",
"current",
".",
"output",
"if",
"WF",
"is",
"over",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L718-L725 | [
"def",
"handle_wf_finalization",
"(",
"self",
")",
":",
"if",
"(",
"(",
"not",
"self",
".",
"current",
".",
"flow_enabled",
"or",
"(",
"self",
".",
"current",
".",
"task_type",
".",
"startswith",
"(",
"'End'",
")",
"and",
"not",
"self",
".",
"are_we_in_s... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | from_rdkit_molecule | RDKit molecule object to MoleculeContainer converter | CGRtools/utils/rdkit.py | def from_rdkit_molecule(data):
"""
RDKit molecule object to MoleculeContainer converter
"""
m = MoleculeContainer()
atoms, mapping = [], []
for a in data.GetAtoms():
atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
atoms.append(atom)
mapping.append(a.GetAt... | def from_rdkit_molecule(data):
"""
RDKit molecule object to MoleculeContainer converter
"""
m = MoleculeContainer()
atoms, mapping = [], []
for a in data.GetAtoms():
atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
atoms.append(atom)
mapping.append(a.GetAt... | [
"RDKit",
"molecule",
"object",
"to",
"MoleculeContainer",
"converter"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L23-L56 | [
"def",
"from_rdkit_molecule",
"(",
"data",
")",
":",
"m",
"=",
"MoleculeContainer",
"(",
")",
"atoms",
",",
"mapping",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"a",
"in",
"data",
".",
"GetAtoms",
"(",
")",
":",
"atom",
"=",
"{",
"'element'",
":",
"a",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | to_rdkit_molecule | MoleculeContainer to RDKit molecule object converter | CGRtools/utils/rdkit.py | def to_rdkit_molecule(data):
"""
MoleculeContainer to RDKit molecule object converter
"""
mol = RWMol()
conf = Conformer()
mapping = {}
is_3d = False
for n, a in data.atoms():
ra = Atom(a.number)
ra.SetAtomMapNum(n)
if a.charge:
ra.SetFormalCharge(a.ch... | def to_rdkit_molecule(data):
"""
MoleculeContainer to RDKit molecule object converter
"""
mol = RWMol()
conf = Conformer()
mapping = {}
is_3d = False
for n, a in data.atoms():
ra = Atom(a.number)
ra.SetAtomMapNum(n)
if a.charge:
ra.SetFormalCharge(a.ch... | [
"MoleculeContainer",
"to",
"RDKit",
"molecule",
"object",
"converter"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L59-L88 | [
"def",
"to_rdkit_molecule",
"(",
"data",
")",
":",
"mol",
"=",
"RWMol",
"(",
")",
"conf",
"=",
"Conformer",
"(",
")",
"mapping",
"=",
"{",
"}",
"is_3d",
"=",
"False",
"for",
"n",
",",
"a",
"in",
"data",
".",
"atoms",
"(",
")",
":",
"ra",
"=",
"... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | StringCommon.__dfs | modified NX dfs | CGRtools/algorithms/strings.py | def __dfs(self, start, weights, depth_limit):
"""
modified NX dfs
"""
adj = self._adj
stack = [(start, depth_limit, iter(sorted(adj[start], key=weights)))]
visited = {start}
disconnected = defaultdict(list)
edges = defaultdict(list)
while stack:
... | def __dfs(self, start, weights, depth_limit):
"""
modified NX dfs
"""
adj = self._adj
stack = [(start, depth_limit, iter(sorted(adj[start], key=weights)))]
visited = {start}
disconnected = defaultdict(list)
edges = defaultdict(list)
while stack:
... | [
"modified",
"NX",
"dfs"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/strings.py#L130-L158 | [
"def",
"__dfs",
"(",
"self",
",",
"start",
",",
"weights",
",",
"depth_limit",
")",
":",
"adj",
"=",
"self",
".",
"_adj",
"stack",
"=",
"[",
"(",
"start",
",",
"depth_limit",
",",
"iter",
"(",
"sorted",
"(",
"adj",
"[",
"start",
"]",
",",
"key",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | get_args_parser | Return a parser for command line options. | marabunta/config.py | def get_args_parser():
"""Return a parser for command line options."""
parser = argparse.ArgumentParser(
description='Marabunta: Migrating ants for Odoo')
parser.add_argument('--migration-file', '-f',
action=EnvDefault,
envvar='MARABUNTA_MIGRATION_FILE... | def get_args_parser():
"""Return a parser for command line options."""
parser = argparse.ArgumentParser(
description='Marabunta: Migrating ants for Odoo')
parser.add_argument('--migration-file', '-f',
action=EnvDefault,
envvar='MARABUNTA_MIGRATION_FILE... | [
"Return",
"a",
"parser",
"for",
"command",
"line",
"options",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L90-L161 | [
"def",
"get_args_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Marabunta: Migrating ants for Odoo'",
")",
"parser",
".",
"add_argument",
"(",
"'--migration-file'",
",",
"'-f'",
",",
"action",
"=",
"EnvDefault",
... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Config.from_parse_args | Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser | marabunta/config.py | def from_parse_args(cls, args):
"""Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser
"""
return cls(args.migration_file,
args.database,
db_user=args.db_user,
... | def from_parse_args(cls, args):
"""Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser
"""
return cls(args.migration_file,
args.database,
db_user=args.db_user,
... | [
"Constructor",
"from",
"command",
"line",
"args",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L40-L60 | [
"def",
"from_parse_args",
"(",
"cls",
",",
"args",
")",
":",
"return",
"cls",
"(",
"args",
".",
"migration_file",
",",
"args",
".",
"database",
",",
"db_user",
"=",
"args",
".",
"db_user",
",",
"db_password",
"=",
"args",
".",
"db_password",
",",
"db_por... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | BaseView.set_current | Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object. | zengine/views/base.py | def set_current(self, current):
"""
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
"""
self.current = current
self.input = current.input
# self.req = current.request
# self.resp = c... | def set_current(self, current):
"""
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
"""
self.current = current
self.input = current.input
# self.req = current.request
# self.resp = c... | [
"Creates",
"some",
"aliases",
"for",
"attributes",
"of",
"current",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L35-L52 | [
"def",
"set_current",
"(",
"self",
",",
"current",
")",
":",
"self",
".",
"current",
"=",
"current",
"self",
".",
"input",
"=",
"current",
".",
"input",
"# self.req = current.request",
"# self.resp = current.response",
"self",
".",
"output",
"=",
"current",
".",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | BaseView.form_out | Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonForm`):
Form object to override `self.o... | zengine/views/base.py | def form_out(self, _form=None):
"""
Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonF... | def form_out(self, _form=None):
"""
Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonF... | [
"Renders",
"form",
".",
"Applies",
"form",
"modifiers",
"then",
"writes",
"result",
"to",
"response",
"payload",
".",
"If",
"supplied",
"given",
"form",
"object",
"instance",
"will",
"be",
"used",
"instead",
"of",
"view",
"s",
"default",
"ObjectForm",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L86-L103 | [
"def",
"form_out",
"(",
"self",
",",
"_form",
"=",
"None",
")",
":",
"_form",
"=",
"_form",
"or",
"self",
".",
"object_form",
"self",
".",
"output",
"[",
"'forms'",
"]",
"=",
"_form",
".",
"serialize",
"(",
")",
"self",
".",
"_add_meta_props",
"(",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | BaseView.set_client_cmd | Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands. | zengine/views/base.py | def set_client_cmd(self, *args):
"""
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
"""
self.client_cmd.update(args)
self.output['client_cmd'] = list(self.client_cmd) | def set_client_cmd(self, *args):
"""
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
"""
self.client_cmd.update(args)
self.output['client_cmd'] = list(self.client_cmd) | [
"Adds",
"given",
"cmd",
"(",
"s",
")",
"to",
"self",
".",
"output",
"[",
"client_cmd",
"]"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L117-L125 | [
"def",
"set_client_cmd",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"client_cmd",
".",
"update",
"(",
"args",
")",
"self",
".",
"output",
"[",
"'client_cmd'",
"]",
"=",
"list",
"(",
"self",
".",
"client_cmd",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | UpdatePermissions.run | Creates new permissions. | zengine/management_commands.py | def run(self):
"""
Creates new permissions.
"""
from pyoko.lib.utils import get_object_from_path
from zengine.config import settings
model = get_object_from_path(settings.PERMISSION_MODEL)
perm_provider = get_object_from_path(settings.PERMISSION_PROVIDER)
... | def run(self):
"""
Creates new permissions.
"""
from pyoko.lib.utils import get_object_from_path
from zengine.config import settings
model = get_object_from_path(settings.PERMISSION_MODEL)
perm_provider = get_object_from_path(settings.PERMISSION_PROVIDER)
... | [
"Creates",
"new",
"permissions",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L44-L92 | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"pyoko",
".",
"lib",
".",
"utils",
"import",
"get_object_from_path",
"from",
"zengine",
".",
"config",
"import",
"settings",
"model",
"=",
"get_object_from_path",
"(",
"settings",
".",
"PERMISSION_MODEL",
")",
"perm... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CreateUser.run | Creates user, encrypts password. | zengine/management_commands.py | def run(self):
"""
Creates user, encrypts password.
"""
from zengine.models import User
user = User(username=self.manager.args.username, superuser=self.manager.args.super)
user.set_password(self.manager.args.password)
user.save()
print("New user created wi... | def run(self):
"""
Creates user, encrypts password.
"""
from zengine.models import User
user = User(username=self.manager.args.username, superuser=self.manager.args.super)
user.set_password(self.manager.args.password)
user.save()
print("New user created wi... | [
"Creates",
"user",
"encrypts",
"password",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L110-L118 | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"models",
"import",
"User",
"user",
"=",
"User",
"(",
"username",
"=",
"self",
".",
"manager",
".",
"args",
".",
"username",
",",
"superuser",
"=",
"self",
".",
"manager",
".",
"args",
".",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | RunServer.run | Starts a development server for the zengine application | zengine/management_commands.py | def run(self):
"""
Starts a development server for the zengine application
"""
print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
self.manager.args.addr,
self.manager.args.port)
)
if self.manager.args.server_ty... | def run(self):
"""
Starts a development server for the zengine application
"""
print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
self.manager.args.addr,
self.manager.args.port)
)
if self.manager.args.server_ty... | [
"Starts",
"a",
"development",
"server",
"for",
"the",
"zengine",
"application"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L139-L150 | [
"def",
"run",
"(",
"self",
")",
":",
"print",
"(",
"\"Development server started on http://%s:%s. \\n\\nPress Ctrl+C to stop\\n\"",
"%",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
"self",
".",
"manager",
".",
"args",
".",
"port",
")",
")",
"if... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | RunServer.run_with_tornado | runs the tornado/websockets based test server | zengine/management_commands.py | def run_with_tornado(self):
"""
runs the tornado/websockets based test server
"""
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) | def run_with_tornado(self):
"""
runs the tornado/websockets based test server
"""
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) | [
"runs",
"the",
"tornado",
"/",
"websockets",
"based",
"test",
"server"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L152-L157 | [
"def",
"run_with_tornado",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"tornado_server",
".",
"server",
"import",
"runserver",
"runserver",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
"int",
"(",
"self",
".",
"manager",
".",
"args",
".... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | RunServer.run_with_falcon | runs the falcon/http based test server | zengine/management_commands.py | def run_with_falcon(self):
"""
runs the falcon/http based test server
"""
from wsgiref import simple_server
from zengine.server import app
httpd = simple_server.make_server(self.manager.args.addr, int(self.manager.args.port), app)
httpd.serve_forever() | def run_with_falcon(self):
"""
runs the falcon/http based test server
"""
from wsgiref import simple_server
from zengine.server import app
httpd = simple_server.make_server(self.manager.args.addr, int(self.manager.args.port), app)
httpd.serve_forever() | [
"runs",
"the",
"falcon",
"/",
"http",
"based",
"test",
"server"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L159-L166 | [
"def",
"run_with_falcon",
"(",
"self",
")",
":",
"from",
"wsgiref",
"import",
"simple_server",
"from",
"zengine",
".",
"server",
"import",
"app",
"httpd",
"=",
"simple_server",
".",
"make_server",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | RunWorker.run | Starts a development server for the zengine application | zengine/management_commands.py | def run(self):
"""
Starts a development server for the zengine application
"""
from zengine.wf_daemon import run_workers, Worker
worker_count = int(self.manager.args.workers or 1)
if not self.manager.args.daemonize:
print("Starting worker(s)")
if wor... | def run(self):
"""
Starts a development server for the zengine application
"""
from zengine.wf_daemon import run_workers, Worker
worker_count = int(self.manager.args.workers or 1)
if not self.manager.args.daemonize:
print("Starting worker(s)")
if wor... | [
"Starts",
"a",
"development",
"server",
"for",
"the",
"zengine",
"application"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L187-L203 | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"wf_daemon",
"import",
"run_workers",
",",
"Worker",
"worker_count",
"=",
"int",
"(",
"self",
".",
"manager",
".",
"args",
".",
"workers",
"or",
"1",
")",
"if",
"not",
"self",
".",
"manager",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ExtractTranslations._prepare_domain | Prepare a helper dictionary for the domain to temporarily hold some information. | zengine/management_commands.py | def _prepare_domain(mapping):
"""Prepare a helper dictionary for the domain to temporarily hold some information."""
# Parse the domain-directory mapping
try:
domain, dir = mapping.split(':')
except ValueError:
print("Please provide the sources in the form of '<do... | def _prepare_domain(mapping):
"""Prepare a helper dictionary for the domain to temporarily hold some information."""
# Parse the domain-directory mapping
try:
domain, dir = mapping.split(':')
except ValueError:
print("Please provide the sources in the form of '<do... | [
"Prepare",
"a",
"helper",
"dictionary",
"for",
"the",
"domain",
"to",
"temporarily",
"hold",
"some",
"information",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L227-L248 | [
"def",
"_prepare_domain",
"(",
"mapping",
")",
":",
"# Parse the domain-directory mapping",
"try",
":",
"domain",
",",
"dir",
"=",
"mapping",
".",
"split",
"(",
"':'",
")",
"except",
"ValueError",
":",
"print",
"(",
"\"Please provide the sources in the form of '<domai... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ExtractTranslations._validate_domains | Check that all domains specified in the settings was provided in the options. | zengine/management_commands.py | def _validate_domains(domains):
"""Check that all domains specified in the settings was provided in the options."""
missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
if missing:
print('The following domains have been set in the configuration, '
... | def _validate_domains(domains):
"""Check that all domains specified in the settings was provided in the options."""
missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
if missing:
print('The following domains have been set in the configuration, '
... | [
"Check",
"that",
"all",
"domains",
"specified",
"in",
"the",
"settings",
"was",
"provided",
"in",
"the",
"options",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L251-L258 | [
"def",
"_validate_domains",
"(",
"domains",
")",
":",
"missing",
"=",
"set",
"(",
"settings",
".",
"TRANSLATION_DOMAINS",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
"domains",
".",
"keys",
"(",
")",
")",
"if",
"missing",
":",
"print",
"(",
"'The foll... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ExtractTranslations._extract_translations | Extract the translations into `.pot` files | zengine/management_commands.py | def _extract_translations(self, domains):
"""Extract the translations into `.pot` files"""
for domain, options in domains.items():
# Create the extractor
extractor = babel_frontend.extract_messages()
extractor.initialize_options()
# The temporary location ... | def _extract_translations(self, domains):
"""Extract the translations into `.pot` files"""
for domain, options in domains.items():
# Create the extractor
extractor = babel_frontend.extract_messages()
extractor.initialize_options()
# The temporary location ... | [
"Extract",
"the",
"translations",
"into",
".",
"pot",
"files"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L260-L286 | [
"def",
"_extract_translations",
"(",
"self",
",",
"domains",
")",
":",
"for",
"domain",
",",
"options",
"in",
"domains",
".",
"items",
"(",
")",
":",
"# Create the extractor",
"extractor",
"=",
"babel_frontend",
".",
"extract_messages",
"(",
")",
"extractor",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ExtractTranslations._init_update_po_files | Update or initialize the `.po` translation files | zengine/management_commands.py | def _init_update_po_files(self, domains):
"""Update or initialize the `.po` translation files"""
for language in settings.TRANSLATIONS:
for domain, options in domains.items():
if language == options['default']: continue # Default language of the domain doesn't need translati... | def _init_update_po_files(self, domains):
"""Update or initialize the `.po` translation files"""
for language in settings.TRANSLATIONS:
for domain, options in domains.items():
if language == options['default']: continue # Default language of the domain doesn't need translati... | [
"Update",
"or",
"initialize",
"the",
".",
"po",
"translation",
"files"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L288-L298 | [
"def",
"_init_update_po_files",
"(",
"self",
",",
"domains",
")",
":",
"for",
"language",
"in",
"settings",
".",
"TRANSLATIONS",
":",
"for",
"domain",
",",
"options",
"in",
"domains",
".",
"items",
"(",
")",
":",
"if",
"language",
"==",
"options",
"[",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | ExtractTranslations._cleanup | Remove the temporary '.pot' files that were created for the domains. | zengine/management_commands.py | def _cleanup(self, domains):
"""Remove the temporary '.pot' files that were created for the domains."""
for option in domains.values():
try:
os.remove(option['pot'])
except (IOError, OSError):
# It is not a problem if we can't actually remove the t... | def _cleanup(self, domains):
"""Remove the temporary '.pot' files that were created for the domains."""
for option in domains.values():
try:
os.remove(option['pot'])
except (IOError, OSError):
# It is not a problem if we can't actually remove the t... | [
"Remove",
"the",
"temporary",
".",
"pot",
"files",
"that",
"were",
"created",
"for",
"the",
"domains",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L312-L319 | [
"def",
"_cleanup",
"(",
"self",
",",
"domains",
")",
":",
"for",
"option",
"in",
"domains",
".",
"values",
"(",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"option",
"[",
"'pot'",
"]",
")",
"except",
"(",
"IOError",
",",
"OSError",
")",
":",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | LoadDiagrams.run | read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf | zengine/management_commands.py | def run(self):
"""
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
"""
from zengine.lib.cache import WFSpecNames
if self.manager.args.clear:
self._clear_models()
return
if self.mana... | def run(self):
"""
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
"""
from zengine.lib.cache import WFSpecNames
if self.manager.args.clear:
self._clear_models()
return
if self.mana... | [
"read",
"workflows",
"checks",
"if",
"it",
"s",
"updated",
"tries",
"to",
"update",
"if",
"there",
"aren",
"t",
"any",
"running",
"instances",
"of",
"that",
"wf"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L450-L472 | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"lib",
".",
"cache",
"import",
"WFSpecNames",
"if",
"self",
".",
"manager",
".",
"args",
".",
"clear",
":",
"self",
".",
"_clear_models",
"(",
")",
"return",
"if",
"self",
".",
"manager",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | LoadDiagrams.get_wf_from_path | load xml from given path
Args:
path: diagram path
Returns: | zengine/management_commands.py | def get_wf_from_path(self, path):
"""
load xml from given path
Args:
path: diagram path
Returns:
"""
with open(path) as fp:
content = fp.read()
return [(os.path.basename(os.path.splitext(path)[0]), content), ] | def get_wf_from_path(self, path):
"""
load xml from given path
Args:
path: diagram path
Returns:
"""
with open(path) as fp:
content = fp.read()
return [(os.path.basename(os.path.splitext(path)[0]), content), ] | [
"load",
"xml",
"from",
"given",
"path",
"Args",
":",
"path",
":",
"diagram",
"path"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L515-L526 | [
"def",
"get_wf_from_path",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"fp",
":",
"content",
"=",
"fp",
".",
"read",
"(",
")",
"return",
"[",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | LoadDiagrams.get_workflows | Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file | zengine/management_commands.py | def get_workflows(self):
"""
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
for f in glob.glob("%s/*.bpmn" % pth):
with open(f) as fp:
... | def get_workflows(self):
"""
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
for f in glob.glob("%s/*.bpmn" % pth):
with open(f) as fp:
... | [
"Scans",
"and",
"loads",
"all",
"wf",
"found",
"under",
"WORKFLOW_PACKAGES_PATHS"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L528-L538 | [
"def",
"get_workflows",
"(",
"self",
")",
":",
"for",
"pth",
"in",
"settings",
".",
"WORKFLOW_PACKAGES_PATHS",
":",
"for",
"f",
"in",
"glob",
".",
"glob",
"(",
"\"%s/*.bpmn\"",
"%",
"pth",
")",
":",
"with",
"open",
"(",
"f",
")",
"as",
"fp",
":",
"yi... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CheckList.check_migration_and_solr | The model or models are checked for migrations that need to be done.
Solr is also checked. | zengine/management_commands.py | def check_migration_and_solr(self):
"""
The model or models are checked for migrations that need to be done.
Solr is also checked.
"""
from pyoko.db.schema_update import SchemaUpdater
from socket import error as socket_error
from pyoko.conf import settings... | def check_migration_and_solr(self):
"""
The model or models are checked for migrations that need to be done.
Solr is also checked.
"""
from pyoko.db.schema_update import SchemaUpdater
from socket import error as socket_error
from pyoko.conf import settings... | [
"The",
"model",
"or",
"models",
"are",
"checked",
"for",
"migrations",
"that",
"need",
"to",
"be",
"done",
".",
"Solr",
"is",
"also",
"checked",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L563-L583 | [
"def",
"check_migration_and_solr",
"(",
"self",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"schema_update",
"import",
"SchemaUpdater",
"from",
"socket",
"import",
"error",
"as",
"socket_error",
"from",
"pyoko",
".",
"conf",
"import",
"settings",
"from",
"importl... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CheckList.check_redis | Redis checks the connection
It displays on the screen whether or not you have a connection. | zengine/management_commands.py | def check_redis():
"""
Redis checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import cache
from redis.exceptions import ConnectionError
try:
cache.ping()
print(Check... | def check_redis():
"""
Redis checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import cache
from redis.exceptions import ConnectionError
try:
cache.ping()
print(Check... | [
"Redis",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L586-L599 | [
"def",
"check_redis",
"(",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"connection",
"import",
"cache",
"from",
"redis",
".",
"exceptions",
"import",
"ConnectionError",
"try",
":",
"cache",
".",
"ping",
"(",
")",
"print",
"(",
"CheckList",
".",
"OKGREEN",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CheckList.check_riak | Riak checks the connection
It displays on the screen whether or not you have a connection. | zengine/management_commands.py | def check_riak():
"""
Riak checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import client
from socket import error as socket_error
try:
if client.ping():
print(_... | def check_riak():
"""
Riak checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import client
from socket import error as socket_error
try:
if client.ping():
print(_... | [
"Riak",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L602-L617 | [
"def",
"check_riak",
"(",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"connection",
"import",
"client",
"from",
"socket",
"import",
"error",
"as",
"socket_error",
"try",
":",
"if",
"client",
".",
"ping",
"(",
")",
":",
"print",
"(",
"__",
"(",
"u\"{0}Ri... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CheckList.check_mq_connection | RabbitMQ checks the connection
It displays on the screen whether or not you have a connection. | zengine/management_commands.py | def check_mq_connection(self):
"""
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
"""
import pika
from zengine.client_queue import BLOCKING_MQ_PARAMS
from pika.exceptions import ProbableAuthenticationError, Connectio... | def check_mq_connection(self):
"""
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
"""
import pika
from zengine.client_queue import BLOCKING_MQ_PARAMS
from pika.exceptions import ProbableAuthenticationError, Connectio... | [
"RabbitMQ",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L619-L639 | [
"def",
"check_mq_connection",
"(",
"self",
")",
":",
"import",
"pika",
"from",
"zengine",
".",
"client_queue",
"import",
"BLOCKING_MQ_PARAMS",
"from",
"pika",
".",
"exceptions",
"import",
"ProbableAuthenticationError",
",",
"ConnectionClosed",
"try",
":",
"connection"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CheckList.check_encoding_and_env | It brings the environment variables to the screen.
The user checks to see if they are using the correct variables. | zengine/management_commands.py | def check_encoding_and_env():
"""
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
"""
import sys
import os
if sys.getfilesystemencoding() in ['utf-8', 'UTF-8']:
print(__(u"{0}File syste... | def check_encoding_and_env():
"""
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
"""
import sys
import os
if sys.getfilesystemencoding() in ['utf-8', 'UTF-8']:
print(__(u"{0}File syste... | [
"It",
"brings",
"the",
"environment",
"variables",
"to",
"the",
"screen",
".",
"The",
"user",
"checks",
"to",
"see",
"if",
"they",
"are",
"using",
"the",
"correct",
"variables",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L642-L662 | [
"def",
"check_encoding_and_env",
"(",
")",
":",
"import",
"sys",
"import",
"os",
"if",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"in",
"[",
"'utf-8'",
",",
"'UTF-8'",
"]",
":",
"print",
"(",
"__",
"(",
"u\"{0}File system encoding correct{1}\"",
")",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | no_moves | Finds if the game is over.
:type: position: Board
:rtype: bool | chess_py/game/game_state.py | def no_moves(position):
"""
Finds if the game is over.
:type: position: Board
:rtype: bool
"""
return position.no_moves(color.white) \
or position.no_moves(color.black) | def no_moves(position):
"""
Finds if the game is over.
:type: position: Board
:rtype: bool
"""
return position.no_moves(color.white) \
or position.no_moves(color.black) | [
"Finds",
"if",
"the",
"game",
"is",
"over",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game_state.py#L13-L21 | [
"def",
"no_moves",
"(",
"position",
")",
":",
"return",
"position",
".",
"no_moves",
"(",
"color",
".",
"white",
")",
"or",
"position",
".",
"no_moves",
"(",
"color",
".",
"black",
")"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | is_checkmate | Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool | chess_py/game/game_state.py | def is_checkmate(position, input_color):
"""
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
"""
return position.no_moves(input_color) and \
position.get_king(input_color).in_check(position) | def is_checkmate(position, input_color):
"""
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
"""
return position.no_moves(input_color) and \
position.get_king(input_color).in_check(position) | [
"Finds",
"if",
"particular",
"King",
"is",
"checkmated",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game_state.py#L24-L33 | [
"def",
"is_checkmate",
"(",
"position",
",",
"input_color",
")",
":",
"return",
"position",
".",
"no_moves",
"(",
"input_color",
")",
"and",
"position",
".",
"get_king",
"(",
"input_color",
")",
".",
"in_check",
"(",
"position",
")"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.